1 c Copyright (C) 1988-2019 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
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@.
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++.
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++.
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:: Nested function in GNU C.
30 * Nonlocal Gotos:: Nonlocal gotos.
31 * Constructing Calls:: Dispatching a call to another function.
32 * Typeof:: @code{typeof}: referring to the type of an expression.
33 * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
34 * __int128:: 128-bit integers---@code{__int128}.
35 * Long Long:: Double-word integers---@code{long long int}.
36 * Complex:: Data types for complex numbers.
37 * Floating Types:: Additional Floating Types.
38 * Half-Precision:: Half-Precision Floating Point.
39 * Decimal Float:: Decimal Floating Types.
40 * Hex Floats:: Hexadecimal floating-point constants.
41 * Fixed-Point:: Fixed-Point Types.
42 * Named Address Spaces::Named address spaces.
43 * Zero Length:: Zero-length arrays.
44 * Empty Structures:: Structures with no members.
45 * Variable Length:: Arrays whose length is computed at run time.
46 * Variadic Macros:: Macros with a variable number of arguments.
47 * Escaped Newlines:: Slightly looser rules for escaped newlines.
48 * Subscripting:: Any array can be subscripted, even if not an lvalue.
49 * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
50 * Pointers to Arrays:: Pointers to arrays with qualifiers work as expected.
51 * Initializers:: Non-constant initializers.
52 * Compound Literals:: Compound literals give structures, unions
54 * Designated Inits:: Labeling elements of initializers.
55 * Case Ranges:: `case 1 ... 9' and such.
56 * Cast to Union:: Casting to union type from any member of the union.
57 * Mixed Declarations:: Mixing declarations and code.
58 * Function Attributes:: Declaring that functions have no side effects,
59 or that they can never return.
60 * Variable Attributes:: Specifying attributes of variables.
61 * Type Attributes:: Specifying attributes of types.
62 * Label Attributes:: Specifying attributes on labels.
63 * Enumerator Attributes:: Specifying attributes on enumerators.
64 * Statement Attributes:: Specifying attributes on statements.
65 * Attribute Syntax:: Formal syntax for attributes.
66 * Function Prototypes:: Prototype declarations and old-style definitions.
67 * C++ Comments:: C++ comments are recognized.
68 * Dollar Signs:: Dollar sign is allowed in identifiers.
69 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
70 * Alignment:: Determining the alignment of a function, type or variable.
71 * Inline:: Defining inline functions (as fast as macros).
72 * Volatiles:: What constitutes an access to a volatile object.
73 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
74 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
75 * Incomplete Enums:: @code{enum foo;}, with details to follow.
76 * Function Names:: Printable strings which are the name of the current
78 * Return Address:: Getting the return or frame address of a function.
79 * Vector Extensions:: Using vector instructions through built-in functions.
80 * Offsetof:: Special syntax for implementing @code{offsetof}.
81 * __sync Builtins:: Legacy built-in functions for atomic memory access.
82 * __atomic Builtins:: Atomic built-in functions with memory model.
83 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
84 arithmetic overflow checking.
85 * x86 specific memory model extensions for transactional memory:: x86 memory models.
86 * Object Size Checking:: Built-in functions for limited buffer overflow
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.
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
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.
110 Recall that a compound statement is a sequence of statements surrounded
111 by braces; in this construct, parentheses go around the braces. For
115 (@{ int y = foo (); int z;
122 is a valid (though slightly more complex than necessary) expression
123 for the absolute value of @code{foo ()}.
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.)
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
137 #define max(a,b) ((a) > (b) ? (a) : (b))
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:
148 #define maxint(a,b) \
149 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
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.
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}).
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
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
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,
184 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
185 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
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.
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
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,
221 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
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}.
230 @section Locally Declared Labels
232 @cindex macros, local labels
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.
239 A local label declaration looks like this:
242 __label__ @var{label};
249 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
252 Local label declarations must come at the beginning of the block,
253 before any ordinary declarations or statements.
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.
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:
267 #define SEARCH(value, array, target) \
270 typeof (target) _SEARCH_target = (target); \
271 typeof (*(array)) *_SEARCH_array = (array); \
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; @} \
283 This could also be written using a statement expression:
286 #define SEARCH(array, target) \
289 typeof (target) _SEARCH_target = (target); \
290 typeof (*(array)) *_SEARCH_array = (array); \
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; @} \
303 Local label declarations also make the labels they declare visible to
304 nested functions, if there are any. @xref{Nested Functions}, for details.
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
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:
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,
335 Any expression of type @code{void *} is allowed.
337 One way of using these constants is in initializing a static array that
338 serves as a jump table:
341 static void *array[] = @{ &&foo, &&bar, &&hack @};
345 Then you can select a label with indexing, like this:
352 Note that this does not check whether the subscript is in bounds---array
353 indexing in C never does that.
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.
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.
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.
369 An alternate way to write the above example is
372 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
374 goto *(&&foo + array[i]);
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.
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.
391 @node Nested Functions
392 @section Nested Functions
393 @cindex nested functions
394 @cindex downward funargs
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++.
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
407 foo (double a, double b)
409 double square (double z) @{ return z * z; @}
411 return square (a) + square (b);
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}:
423 bar (int *array, int offset, int size)
425 int access (int *array, int index)
426 @{ return array[index + offset]; @}
429 for (i = 0; i < size; i++)
430 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
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.
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:
443 hack (int *array, int size)
445 void store (int index, int value)
446 @{ array[index] = value; @}
448 intermediate (store, size);
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.
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
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).
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:
479 bar (int *array, int offset, int size)
482 int access (int *array, int index)
486 return array[index + offset];
490 for (i = 0; i < size; i++)
491 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
495 /* @r{Control comes here from @code{access}
496 if it detects an error.} */
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).
509 bar (int *array, int offset, int size)
512 auto int access (int *, int);
514 int access (int *array, int index)
518 return array[index + offset];
525 @section Nonlocal Gotos
526 @cindex nonlocal gotos
528 GCC provides the built-in functions @code{__builtin_setjmp} and
529 @code{__builtin_longjmp} which are similar to, but not interchangeable
530 with, the C library functions @code{setjmp} and @code{longjmp}.
531 The built-in versions are used internally by GCC's libraries
532 to implement exception handling on some targets. You should use the
533 standard C library functions declared in @code{<setjmp.h>} in user code
534 instead of the builtins.
536 The built-in versions of these functions use GCC's normal
537 mechanisms to save and restore registers using the stack on function
538 entry and exit. The jump buffer argument @var{buf} holds only the
539 information needed to restore the stack frame, rather than the entire
540 set of saved register values.
542 An important caveat is that GCC arranges to save and restore only
543 those registers known to the specific architecture variant being
544 compiled for. This can make @code{__builtin_setjmp} and
545 @code{__builtin_longjmp} more efficient than their library
546 counterparts in some cases, but it can also cause incorrect and
547 mysterious behavior when mixing with code that uses the full register
550 You should declare the jump buffer argument @var{buf} to the
551 built-in functions as:
555 intptr_t @var{buf}[5];
558 @deftypefn {Built-in Function} {int} __builtin_setjmp (intptr_t *@var{buf})
559 This function saves the current stack context in @var{buf}.
560 @code{__builtin_setjmp} returns 0 when returning directly,
561 and 1 when returning from @code{__builtin_longjmp} using the same
565 @deftypefn {Built-in Function} {void} __builtin_longjmp (intptr_t *@var{buf}, int @var{val})
566 This function restores the stack context in @var{buf},
567 saved by a previous call to @code{__builtin_setjmp}. After
568 @code{__builtin_longjmp} is finished, the program resumes execution as
569 if the matching @code{__builtin_setjmp} returns the value @var{val},
572 Because @code{__builtin_longjmp} depends on the function return
573 mechanism to restore the stack context, it cannot be called
574 from the same function calling @code{__builtin_setjmp} to
575 initialize @var{buf}. It can only be called from a function called
576 (directly or indirectly) from the function calling @code{__builtin_setjmp}.
579 @node Constructing Calls
580 @section Constructing Function Calls
581 @cindex constructing calls
582 @cindex forwarding calls
584 Using the built-in functions described below, you can record
585 the arguments a function received, and call another function
586 with the same arguments, without knowing the number or types
589 You can also record the return value of that function call,
590 and later return that value, without knowing what data type
591 the function tried to return (as long as your caller expects
594 However, these built-in functions may interact badly with some
595 sophisticated features or other extensions of the language. It
596 is, therefore, not recommended to use them outside very simple
597 functions acting as mere forwarders for their arguments.
599 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
600 This built-in function returns a pointer to data
601 describing how to perform a call with the same arguments as are passed
602 to the current function.
604 The function saves the arg pointer register, structure value address,
605 and all registers that might be used to pass arguments to a function
606 into a block of memory allocated on the stack. Then it returns the
607 address of that block.
610 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
611 This built-in function invokes @var{function}
612 with a copy of the parameters described by @var{arguments}
615 The value of @var{arguments} should be the value returned by
616 @code{__builtin_apply_args}. The argument @var{size} specifies the size
617 of the stack argument data, in bytes.
619 This function returns a pointer to data describing
620 how to return whatever value is returned by @var{function}. The data
621 is saved in a block of memory allocated on the stack.
623 It is not always simple to compute the proper value for @var{size}. The
624 value is used by @code{__builtin_apply} to compute the amount of data
625 that should be pushed on the stack and copied from the incoming argument
629 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
630 This built-in function returns the value described by @var{result} from
631 the containing function. You should specify, for @var{result}, a value
632 returned by @code{__builtin_apply}.
635 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
636 This built-in function represents all anonymous arguments of an inline
637 function. It can be used only in inline functions that are always
638 inlined, never compiled as a separate function, such as those using
639 @code{__attribute__ ((__always_inline__))} or
640 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
641 It must be only passed as last argument to some other function
642 with variable arguments. This is useful for writing small wrapper
643 inlines for variable argument functions, when using preprocessor
644 macros is undesirable. For example:
646 extern int myprintf (FILE *f, const char *format, ...);
647 extern inline __attribute__ ((__gnu_inline__)) int
648 myprintf (FILE *f, const char *format, ...)
650 int r = fprintf (f, "myprintf: ");
653 int s = fprintf (f, format, __builtin_va_arg_pack ());
661 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
662 This built-in function returns the number of anonymous arguments of
663 an inline function. It can be used only in inline functions that
664 are always inlined, never compiled as a separate function, such
665 as those using @code{__attribute__ ((__always_inline__))} or
666 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
667 For example following does link- or run-time checking of open
668 arguments for optimized code:
671 extern inline __attribute__((__gnu_inline__)) int
672 myopen (const char *path, int oflag, ...)
674 if (__builtin_va_arg_pack_len () > 1)
675 warn_open_too_many_arguments ();
677 if (__builtin_constant_p (oflag))
679 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
681 warn_open_missing_mode ();
682 return __open_2 (path, oflag);
684 return open (path, oflag, __builtin_va_arg_pack ());
687 if (__builtin_va_arg_pack_len () < 1)
688 return __open_2 (path, oflag);
690 return open (path, oflag, __builtin_va_arg_pack ());
697 @section Referring to a Type with @code{typeof}
700 @cindex macros, types of arguments
702 Another way to refer to the type of an expression is with @code{typeof}.
703 The syntax of using of this keyword looks like @code{sizeof}, but the
704 construct acts semantically like a type name defined with @code{typedef}.
706 There are two ways of writing the argument to @code{typeof}: with an
707 expression or with a type. Here is an example with an expression:
714 This assumes that @code{x} is an array of pointers to functions;
715 the type described is that of the values of the functions.
717 Here is an example with a typename as the argument:
724 Here the type described is that of pointers to @code{int}.
726 If you are writing a header file that must work when included in ISO C
727 programs, write @code{__typeof__} instead of @code{typeof}.
728 @xref{Alternate Keywords}.
730 A @code{typeof} construct can be used anywhere a typedef name can be
731 used. For example, you can use it in a declaration, in a cast, or inside
732 of @code{sizeof} or @code{typeof}.
734 The operand of @code{typeof} is evaluated for its side effects if and
735 only if it is an expression of variably modified type or the name of
738 @code{typeof} is often useful in conjunction with
739 statement expressions (@pxref{Statement Exprs}).
740 Here is how the two together can
741 be used to define a safe ``maximum'' macro which operates on any
742 arithmetic type and evaluates each of its arguments exactly once:
746 (@{ typeof (a) _a = (a); \
747 typeof (b) _b = (b); \
748 _a > _b ? _a : _b; @})
751 @cindex underscores in variables in macros
752 @cindex @samp{_} in variables in macros
753 @cindex local variables in macros
754 @cindex variables, local, in macros
755 @cindex macros, local variables in
757 The reason for using names that start with underscores for the local
758 variables is to avoid conflicts with variable names that occur within the
759 expressions that are substituted for @code{a} and @code{b}. Eventually we
760 hope to design a new form of declaration syntax that allows you to declare
761 variables whose scopes start only after their initializers; this will be a
762 more reliable way to prevent such conflicts.
765 Some more examples of the use of @code{typeof}:
769 This declares @code{y} with the type of what @code{x} points to.
776 This declares @code{y} as an array of such values.
783 This declares @code{y} as an array of pointers to characters:
786 typeof (typeof (char *)[4]) y;
790 It is equivalent to the following traditional C declaration:
796 To see the meaning of the declaration using @code{typeof}, and why it
797 might be a useful way to write, rewrite it with these macros:
800 #define pointer(T) typeof(T *)
801 #define array(T, N) typeof(T [N])
805 Now the declaration can be rewritten this way:
808 array (pointer (char), 4) y;
812 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
813 pointers to @code{char}.
816 In GNU C, but not GNU C++, you may also declare the type of a variable
817 as @code{__auto_type}. In that case, the declaration must declare
818 only one variable, whose declarator must just be an identifier, the
819 declaration must be initialized, and the type of the variable is
820 determined by the initializer; the name of the variable is not in
821 scope until after the initializer. (In C++, you should use C++11
822 @code{auto} for this purpose.) Using @code{__auto_type}, the
823 ``maximum'' macro above could be written as:
827 (@{ __auto_type _a = (a); \
828 __auto_type _b = (b); \
829 _a > _b ? _a : _b; @})
832 Using @code{__auto_type} instead of @code{typeof} has two advantages:
835 @item Each argument to the macro appears only once in the expansion of
836 the macro. This prevents the size of the macro expansion growing
837 exponentially when calls to such macros are nested inside arguments of
840 @item If the argument to the macro has variably modified type, it is
841 evaluated only once when using @code{__auto_type}, but twice if
842 @code{typeof} is used.
846 @section Conditionals with Omitted Operands
847 @cindex conditional expressions, extensions
848 @cindex omitted middle-operands
849 @cindex middle-operands, omitted
850 @cindex extensions, @code{?:}
851 @cindex @code{?:} extensions
853 The middle operand in a conditional expression may be omitted. Then
854 if the first operand is nonzero, its value is the value of the conditional
857 Therefore, the expression
864 has the value of @code{x} if that is nonzero; otherwise, the value of
867 This example is perfectly equivalent to
873 @cindex side effect in @code{?:}
874 @cindex @code{?:} side effect
876 In this simple case, the ability to omit the middle operand is not
877 especially useful. When it becomes useful is when the first operand does,
878 or may (if it is a macro argument), contain a side effect. Then repeating
879 the operand in the middle would perform the side effect twice. Omitting
880 the middle operand uses the value already computed without the undesirable
881 effects of recomputing it.
884 @section 128-bit Integers
885 @cindex @code{__int128} data types
887 As an extension the integer scalar type @code{__int128} is supported for
888 targets which have an integer mode wide enough to hold 128 bits.
889 Simply write @code{__int128} for a signed 128-bit integer, or
890 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
891 support in GCC for expressing an integer constant of type @code{__int128}
892 for targets with @code{long long} integer less than 128 bits wide.
895 @section Double-Word Integers
896 @cindex @code{long long} data types
897 @cindex double-word arithmetic
898 @cindex multiprecision arithmetic
899 @cindex @code{LL} integer suffix
900 @cindex @code{ULL} integer suffix
902 ISO C99 and ISO C++11 support data types for integers that are at least
903 64 bits wide, and as an extension GCC supports them in C90 and C++98 modes.
904 Simply write @code{long long int} for a signed integer, or
905 @code{unsigned long long int} for an unsigned integer. To make an
906 integer constant of type @code{long long int}, add the suffix @samp{LL}
907 to the integer. To make an integer constant of type @code{unsigned long
908 long int}, add the suffix @samp{ULL} to the integer.
910 You can use these types in arithmetic like any other integer types.
911 Addition, subtraction, and bitwise boolean operations on these types
912 are open-coded on all types of machines. Multiplication is open-coded
913 if the machine supports a fullword-to-doubleword widening multiply
914 instruction. Division and shifts are open-coded only on machines that
915 provide special support. The operations that are not open-coded use
916 special library routines that come with GCC@.
918 There may be pitfalls when you use @code{long long} types for function
919 arguments without function prototypes. If a function
920 expects type @code{int} for its argument, and you pass a value of type
921 @code{long long int}, confusion results because the caller and the
922 subroutine disagree about the number of bytes for the argument.
923 Likewise, if the function expects @code{long long int} and you pass
924 @code{int}. The best way to avoid such problems is to use prototypes.
927 @section Complex Numbers
928 @cindex complex numbers
929 @cindex @code{_Complex} keyword
930 @cindex @code{__complex__} keyword
932 ISO C99 supports complex floating data types, and as an extension GCC
933 supports them in C90 mode and in C++. GCC also supports complex integer data
934 types which are not part of ISO C99. You can declare complex types
935 using the keyword @code{_Complex}. As an extension, the older GNU
936 keyword @code{__complex__} is also supported.
938 For example, @samp{_Complex double x;} declares @code{x} as a
939 variable whose real part and imaginary part are both of type
940 @code{double}. @samp{_Complex short int y;} declares @code{y} to
941 have real and imaginary parts of type @code{short int}; this is not
942 likely to be useful, but it shows that the set of complex types is
945 To write a constant with a complex data type, use the suffix @samp{i} or
946 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
947 has type @code{_Complex float} and @code{3i} has type
948 @code{_Complex int}. Such a constant always has a pure imaginary
949 value, but you can form any complex value you like by adding one to a
950 real constant. This is a GNU extension; if you have an ISO C99
951 conforming C library (such as the GNU C Library), and want to construct complex
952 constants of floating type, you should include @code{<complex.h>} and
953 use the macros @code{I} or @code{_Complex_I} instead.
955 The ISO C++14 library also defines the @samp{i} suffix, so C++14 code
956 that includes the @samp{<complex>} header cannot use @samp{i} for the
957 GNU extension. The @samp{j} suffix still has the GNU meaning.
959 @cindex @code{__real__} keyword
960 @cindex @code{__imag__} keyword
961 To extract the real part of a complex-valued expression @var{exp}, write
962 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
963 extract the imaginary part. This is a GNU extension; for values of
964 floating type, you should use the ISO C99 functions @code{crealf},
965 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
966 @code{cimagl}, declared in @code{<complex.h>} and also provided as
967 built-in functions by GCC@.
969 @cindex complex conjugation
970 The operator @samp{~} performs complex conjugation when used on a value
971 with a complex type. This is a GNU extension; for values of
972 floating type, you should use the ISO C99 functions @code{conjf},
973 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
974 provided as built-in functions by GCC@.
976 GCC can allocate complex automatic variables in a noncontiguous
977 fashion; it's even possible for the real part to be in a register while
978 the imaginary part is on the stack (or vice versa). Only the DWARF
979 debug info format can represent this, so use of DWARF is recommended.
980 If you are using the stabs debug info format, GCC describes a noncontiguous
981 complex variable as if it were two separate variables of noncomplex type.
982 If the variable's actual name is @code{foo}, the two fictitious
983 variables are named @code{foo$real} and @code{foo$imag}. You can
984 examine and set these two fictitious variables with your debugger.
987 @section Additional Floating Types
988 @cindex additional floating types
989 @cindex @code{_Float@var{n}} data types
990 @cindex @code{_Float@var{n}x} data types
991 @cindex @code{__float80} data type
992 @cindex @code{__float128} data type
993 @cindex @code{__ibm128} data type
994 @cindex @code{w} floating point suffix
995 @cindex @code{q} floating point suffix
996 @cindex @code{W} floating point suffix
997 @cindex @code{Q} floating point suffix
999 ISO/IEC TS 18661-3:2015 defines C support for additional floating
1000 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
1001 these type names; the set of types supported depends on the target
1002 architecture. These types are not supported when compiling C++.
1003 Constants with these types use suffixes @code{f@var{n}} or
1004 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}. These type
1005 names can be used together with @code{_Complex} to declare complex
1008 As an extension, GNU C and GNU C++ support additional floating
1009 types, which are not supported by all targets.
1011 @item @code{__float128} is available on i386, x86_64, IA-64, and
1012 hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable
1013 the vector scalar (VSX) instruction set. @code{__float128} supports
1014 the 128-bit floating type. On i386, x86_64, PowerPC, and IA-64
1015 other than HP-UX, @code{__float128} is an alias for @code{_Float128}.
1016 On hppa and IA-64 HP-UX, @code{__float128} is an alias for @code{long
1019 @item @code{__float80} is available on the i386, x86_64, and IA-64
1020 targets, and supports the 80-bit (@code{XFmode}) floating type. It is
1021 an alias for the type name @code{_Float64x} on these targets.
1023 @item @code{__ibm128} is available on PowerPC targets, and provides
1024 access to the IBM extended double format which is the current format
1025 used for @code{long double}. When @code{long double} transitions to
1026 @code{__float128} on PowerPC in the future, @code{__ibm128} will remain
1027 for use in conversions between the two types.
1030 Support for these additional types includes the arithmetic operators:
1031 add, subtract, multiply, divide; unary arithmetic operators;
1032 relational operators; equality operators; and conversions to and from
1033 integer and other floating types. Use a suffix @samp{w} or @samp{W}
1034 in a literal constant of type @code{__float80} or type
1035 @code{__ibm128}. Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
1037 In order to use @code{_Float128}, @code{__float128}, and @code{__ibm128}
1038 on PowerPC Linux systems, you must use the @option{-mfloat128} option. It is
1039 expected in future versions of GCC that @code{_Float128} and @code{__float128}
1040 will be enabled automatically.
1042 The @code{_Float128} type is supported on all systems where
1043 @code{__float128} is supported or where @code{long double} has the
1044 IEEE binary128 format. The @code{_Float64x} type is supported on all
1045 systems where @code{__float128} is supported. The @code{_Float32}
1046 type is supported on all systems supporting IEEE binary32; the
1047 @code{_Float64} and @code{_Float32x} types are supported on all systems
1048 supporting IEEE binary64. The @code{_Float16} type is supported on AArch64
1049 systems by default, and on ARM systems when the IEEE format for 16-bit
1050 floating-point types is selected with @option{-mfp16-format=ieee}.
1051 GCC does not currently support @code{_Float128x} on any systems.
1053 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
1054 types using the corresponding internal complex type, @code{XCmode} for
1055 @code{__float80} type and @code{TCmode} for @code{__float128} type:
1058 typedef _Complex float __attribute__((mode(TC))) _Complex128;
1059 typedef _Complex float __attribute__((mode(XC))) _Complex80;
1062 On the PowerPC Linux VSX targets, you can declare complex types using
1063 the corresponding internal complex type, @code{KCmode} for
1064 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
1067 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
1068 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
1071 @node Half-Precision
1072 @section Half-Precision Floating Point
1073 @cindex half-precision floating point
1074 @cindex @code{__fp16} data type
1076 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1077 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1078 On ARM systems, you must enable this type explicitly with the
1079 @option{-mfp16-format} command-line option in order to use it.
1081 ARM targets support two incompatible representations for half-precision
1082 floating-point values. You must choose one of the representations and
1083 use it consistently in your program.
1085 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1086 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1087 There are 11 bits of significand precision, approximately 3
1090 Specifying @option{-mfp16-format=alternative} selects the ARM
1091 alternative format. This representation is similar to the IEEE
1092 format, but does not support infinities or NaNs. Instead, the range
1093 of exponents is extended, so that this format can represent normalized
1094 values in the range of @math{2^{-14}} to 131008.
1096 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1097 not require use of the @option{-mfp16-format} command-line option.
1099 The @code{__fp16} type may only be used as an argument to intrinsics defined
1100 in @code{<arm_fp16.h>}, or as a storage format. For purposes of
1101 arithmetic and other operations, @code{__fp16} values in C or C++
1102 expressions are automatically promoted to @code{float}.
1104 The ARM target provides hardware support for conversions between
1105 @code{__fp16} and @code{float} values
1106 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8-A provides
1107 hardware support for conversions between @code{__fp16} and @code{double}
1108 values. GCC generates code using these hardware instructions if you
1109 compile with options to select an FPU that provides them;
1110 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1111 in addition to the @option{-mfp16-format} option to select
1112 a half-precision format.
1114 Language-level support for the @code{__fp16} data type is
1115 independent of whether GCC generates code using hardware floating-point
1116 instructions. In cases where hardware support is not specified, GCC
1117 implements conversions between @code{__fp16} and other types as library
1120 It is recommended that portable code use the @code{_Float16} type defined
1121 by ISO/IEC TS 18661-3:2015. @xref{Floating Types}.
1124 @section Decimal Floating Types
1125 @cindex decimal floating types
1126 @cindex @code{_Decimal32} data type
1127 @cindex @code{_Decimal64} data type
1128 @cindex @code{_Decimal128} data type
1129 @cindex @code{df} integer suffix
1130 @cindex @code{dd} integer suffix
1131 @cindex @code{dl} integer suffix
1132 @cindex @code{DF} integer suffix
1133 @cindex @code{DD} integer suffix
1134 @cindex @code{DL} integer suffix
1136 As an extension, GNU C supports decimal floating types as
1137 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1138 floating types in GCC will evolve as the draft technical report changes.
1139 Calling conventions for any target might also change. Not all targets
1140 support decimal floating types.
1142 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1143 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1144 @code{float}, @code{double}, and @code{long double} whose radix is not
1145 specified by the C standard but is usually two.
1147 Support for decimal floating types includes the arithmetic operators
1148 add, subtract, multiply, divide; unary arithmetic operators;
1149 relational operators; equality operators; and conversions to and from
1150 integer and other floating types. Use a suffix @samp{df} or
1151 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1152 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1155 GCC support of decimal float as specified by the draft technical report
1160 When the value of a decimal floating type cannot be represented in the
1161 integer type to which it is being converted, the result is undefined
1162 rather than the result value specified by the draft technical report.
1165 GCC does not provide the C library functionality associated with
1166 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1167 @file{wchar.h}, which must come from a separate C library implementation.
1168 Because of this the GNU C compiler does not define macro
1169 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1170 the technical report.
1173 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1174 are supported by the DWARF debug information format.
1180 ISO C99 and ISO C++17 support floating-point numbers written not only in
1181 the usual decimal notation, such as @code{1.55e1}, but also numbers such as
1182 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1183 supports this in C90 mode (except in some cases when strictly
1184 conforming) and in C++98, C++11 and C++14 modes. In that format the
1185 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1186 mandatory. The exponent is a decimal number that indicates the power of
1187 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1194 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1195 is the same as @code{1.55e1}.
1197 Unlike for floating-point numbers in the decimal notation the exponent
1198 is always required in the hexadecimal notation. Otherwise the compiler
1199 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1200 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1201 extension for floating-point constants of type @code{float}.
1204 @section Fixed-Point Types
1205 @cindex fixed-point types
1206 @cindex @code{_Fract} data type
1207 @cindex @code{_Accum} data type
1208 @cindex @code{_Sat} data type
1209 @cindex @code{hr} fixed-suffix
1210 @cindex @code{r} fixed-suffix
1211 @cindex @code{lr} fixed-suffix
1212 @cindex @code{llr} fixed-suffix
1213 @cindex @code{uhr} fixed-suffix
1214 @cindex @code{ur} fixed-suffix
1215 @cindex @code{ulr} fixed-suffix
1216 @cindex @code{ullr} fixed-suffix
1217 @cindex @code{hk} fixed-suffix
1218 @cindex @code{k} fixed-suffix
1219 @cindex @code{lk} fixed-suffix
1220 @cindex @code{llk} fixed-suffix
1221 @cindex @code{uhk} fixed-suffix
1222 @cindex @code{uk} fixed-suffix
1223 @cindex @code{ulk} fixed-suffix
1224 @cindex @code{ullk} fixed-suffix
1225 @cindex @code{HR} fixed-suffix
1226 @cindex @code{R} fixed-suffix
1227 @cindex @code{LR} fixed-suffix
1228 @cindex @code{LLR} fixed-suffix
1229 @cindex @code{UHR} fixed-suffix
1230 @cindex @code{UR} fixed-suffix
1231 @cindex @code{ULR} fixed-suffix
1232 @cindex @code{ULLR} fixed-suffix
1233 @cindex @code{HK} fixed-suffix
1234 @cindex @code{K} fixed-suffix
1235 @cindex @code{LK} fixed-suffix
1236 @cindex @code{LLK} fixed-suffix
1237 @cindex @code{UHK} fixed-suffix
1238 @cindex @code{UK} fixed-suffix
1239 @cindex @code{ULK} fixed-suffix
1240 @cindex @code{ULLK} fixed-suffix
1242 As an extension, GNU C supports fixed-point types as
1243 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1244 types in GCC will evolve as the draft technical report changes.
1245 Calling conventions for any target might also change. Not all targets
1246 support fixed-point types.
1248 The fixed-point types are
1249 @code{short _Fract},
1252 @code{long long _Fract},
1253 @code{unsigned short _Fract},
1254 @code{unsigned _Fract},
1255 @code{unsigned long _Fract},
1256 @code{unsigned long long _Fract},
1257 @code{_Sat short _Fract},
1259 @code{_Sat long _Fract},
1260 @code{_Sat long long _Fract},
1261 @code{_Sat unsigned short _Fract},
1262 @code{_Sat unsigned _Fract},
1263 @code{_Sat unsigned long _Fract},
1264 @code{_Sat unsigned long long _Fract},
1265 @code{short _Accum},
1268 @code{long long _Accum},
1269 @code{unsigned short _Accum},
1270 @code{unsigned _Accum},
1271 @code{unsigned long _Accum},
1272 @code{unsigned long long _Accum},
1273 @code{_Sat short _Accum},
1275 @code{_Sat long _Accum},
1276 @code{_Sat long long _Accum},
1277 @code{_Sat unsigned short _Accum},
1278 @code{_Sat unsigned _Accum},
1279 @code{_Sat unsigned long _Accum},
1280 @code{_Sat unsigned long long _Accum}.
1282 Fixed-point data values contain fractional and optional integral parts.
1283 The format of fixed-point data varies and depends on the target machine.
1285 Support for fixed-point types includes:
1288 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1290 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1292 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1294 binary shift operators (@code{<<}, @code{>>})
1296 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1298 equality operators (@code{==}, @code{!=})
1300 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1301 @code{<<=}, @code{>>=})
1303 conversions to and from integer, floating-point, or fixed-point types
1306 Use a suffix in a fixed-point literal constant:
1308 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1309 @code{_Sat short _Fract}
1310 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1311 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1312 @code{_Sat long _Fract}
1313 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1314 @code{_Sat long long _Fract}
1315 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1316 @code{_Sat unsigned short _Fract}
1317 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1318 @code{_Sat unsigned _Fract}
1319 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1320 @code{_Sat unsigned long _Fract}
1321 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1322 and @code{_Sat unsigned long long _Fract}
1323 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1324 @code{_Sat short _Accum}
1325 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1326 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1327 @code{_Sat long _Accum}
1328 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1329 @code{_Sat long long _Accum}
1330 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1331 @code{_Sat unsigned short _Accum}
1332 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1333 @code{_Sat unsigned _Accum}
1334 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1335 @code{_Sat unsigned long _Accum}
1336 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1337 and @code{_Sat unsigned long long _Accum}
1340 GCC support of fixed-point types as specified by the draft technical report
1345 Pragmas to control overflow and rounding behaviors are not implemented.
1348 Fixed-point types are supported by the DWARF debug information format.
1350 @node Named Address Spaces
1351 @section Named Address Spaces
1352 @cindex Named Address Spaces
1354 As an extension, GNU C supports named address spaces as
1355 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1356 address spaces in GCC will evolve as the draft technical report
1357 changes. Calling conventions for any target might also change. At
1358 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1359 address spaces other than the generic address space.
1361 Address space identifiers may be used exactly like any other C type
1362 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1363 document for more details.
1365 @anchor{AVR Named Address Spaces}
1366 @subsection AVR Named Address Spaces
1368 On the AVR target, there are several address spaces that can be used
1369 in order to put read-only data into the flash memory and access that
1370 data by means of the special instructions @code{LPM} or @code{ELPM}
1371 needed to read from flash.
1373 Devices belonging to @code{avrtiny} and @code{avrxmega3} can access
1374 flash memory by means of @code{LD*} instructions because the flash
1375 memory is mapped into the RAM address space. There is @emph{no need}
1376 for language extensions like @code{__flash} or attribute
1377 @ref{AVR Variable Attributes,,@code{progmem}}.
1378 The default linker description files for these devices cater for that
1379 feature and @code{.rodata} stays in flash: The compiler just generates
1380 @code{LD*} instructions, and the linker script adds core specific
1381 offsets to all @code{.rodata} symbols: @code{0x4000} in the case of
1382 @code{avrtiny} and @code{0x8000} in the case of @code{avrxmega3}.
1383 See @ref{AVR Options} for a list of respective devices.
1385 For devices not in @code{avrtiny} or @code{avrxmega3},
1386 any data including read-only data is located in RAM (the generic
1387 address space) because flash memory is not visible in the RAM address
1388 space. In order to locate read-only data in flash memory @emph{and}
1389 to generate the right instructions to access this data without
1390 using (inline) assembler code, special address spaces are needed.
1394 @cindex @code{__flash} AVR Named Address Spaces
1395 The @code{__flash} qualifier locates data in the
1396 @code{.progmem.data} section. Data is read using the @code{LPM}
1397 instruction. Pointers to this address space are 16 bits wide.
1404 @cindex @code{__flash1} AVR Named Address Spaces
1405 @cindex @code{__flash2} AVR Named Address Spaces
1406 @cindex @code{__flash3} AVR Named Address Spaces
1407 @cindex @code{__flash4} AVR Named Address Spaces
1408 @cindex @code{__flash5} AVR Named Address Spaces
1409 These are 16-bit address spaces locating data in section
1410 @code{.progmem@var{N}.data} where @var{N} refers to
1411 address space @code{__flash@var{N}}.
1412 The compiler sets the @code{RAMPZ} segment register appropriately
1413 before reading data by means of the @code{ELPM} instruction.
1416 @cindex @code{__memx} AVR Named Address Spaces
1417 This is a 24-bit address space that linearizes flash and RAM:
1418 If the high bit of the address is set, data is read from
1419 RAM using the lower two bytes as RAM address.
1420 If the high bit of the address is clear, data is read from flash
1421 with @code{RAMPZ} set according to the high byte of the address.
1422 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1424 Objects in this address space are located in @code{.progmemx.data}.
1430 char my_read (const __flash char ** p)
1432 /* p is a pointer to RAM that points to a pointer to flash.
1433 The first indirection of p reads that flash pointer
1434 from RAM and the second indirection reads a char from this
1440 /* Locate array[] in flash memory */
1441 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1447 /* Return 17 by reading from flash memory */
1448 return array[array[i]];
1453 For each named address space supported by avr-gcc there is an equally
1454 named but uppercase built-in macro defined.
1455 The purpose is to facilitate testing if respective address space
1456 support is available or not:
1460 const __flash int var = 1;
1467 #include <avr/pgmspace.h> /* From AVR-LibC */
1469 const int var PROGMEM = 1;
1473 return (int) pgm_read_word (&var);
1475 #endif /* __FLASH */
1479 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1480 locates data in flash but
1481 accesses to these data read from generic address space, i.e.@:
1483 so that you need special accessors like @code{pgm_read_byte}
1484 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1485 together with attribute @code{progmem}.
1488 @b{Limitations and caveats}
1492 Reading across the 64@tie{}KiB section boundary of
1493 the @code{__flash} or @code{__flash@var{N}} address spaces
1494 shows undefined behavior. The only address space that
1495 supports reading across the 64@tie{}KiB flash segment boundaries is
1499 If you use one of the @code{__flash@var{N}} address spaces
1500 you must arrange your linker script to locate the
1501 @code{.progmem@var{N}.data} sections according to your needs.
1504 Any data or pointers to the non-generic address spaces must
1505 be qualified as @code{const}, i.e.@: as read-only data.
1506 This still applies if the data in one of these address
1507 spaces like software version number or calibration lookup table are intended to
1508 be changed after load time by, say, a boot loader. In this case
1509 the right qualification is @code{const} @code{volatile} so that the compiler
1510 must not optimize away known values or insert them
1511 as immediates into operands of instructions.
1514 The following code initializes a variable @code{pfoo}
1515 located in static storage with a 24-bit address:
1517 extern const __memx char foo;
1518 const __memx void *pfoo = &foo;
1522 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1523 Just use vanilla C / C++ code without overhead as outlined above.
1524 Attribute @code{progmem} is supported but works differently,
1525 see @ref{AVR Variable Attributes}.
1529 @subsection M32C Named Address Spaces
1530 @cindex @code{__far} M32C Named Address Spaces
1532 On the M32C target, with the R8C and M16C CPU variants, variables
1533 qualified with @code{__far} are accessed using 32-bit addresses in
1534 order to access memory beyond the first 64@tie{}Ki bytes. If
1535 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1538 @subsection RL78 Named Address Spaces
1539 @cindex @code{__far} RL78 Named Address Spaces
1541 On the RL78 target, variables qualified with @code{__far} are accessed
1542 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1543 addresses. Non-far variables are assumed to appear in the topmost
1544 64@tie{}KiB of the address space.
1546 @subsection SPU Named Address Spaces
1547 @cindex @code{__ea} SPU Named Address Spaces
1549 On the SPU target variables may be declared as
1550 belonging to another address space by qualifying the type with the
1551 @code{__ea} address space identifier:
1558 The compiler generates special code to access the variable @code{i}.
1559 It may use runtime library
1560 support, or generate special machine instructions to access that address
1563 @subsection x86 Named Address Spaces
1564 @cindex x86 named address spaces
1566 On the x86 target, variables may be declared as being relative
1567 to the @code{%fs} or @code{%gs} segments.
1572 @cindex @code{__seg_fs} x86 named address space
1573 @cindex @code{__seg_gs} x86 named address space
1574 The object is accessed with the respective segment override prefix.
1576 The respective segment base must be set via some method specific to
1577 the operating system. Rather than require an expensive system call
1578 to retrieve the segment base, these address spaces are not considered
1579 to be subspaces of the generic (flat) address space. This means that
1580 explicit casts are required to convert pointers between these address
1581 spaces and the generic address space. In practice the application
1582 should cast to @code{uintptr_t} and apply the segment base offset
1583 that it installed previously.
1585 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1586 defined when these address spaces are supported.
1590 @section Arrays of Length Zero
1591 @cindex arrays of length zero
1592 @cindex zero-length arrays
1593 @cindex length-zero arrays
1594 @cindex flexible array members
1596 Declaring zero-length arrays is allowed in GNU C as an extension.
1597 A zero-length array can be useful as the last element of a structure
1598 that is really a header for a variable-length object:
1606 struct line *thisline = (struct line *)
1607 malloc (sizeof (struct line) + this_length);
1608 thisline->length = this_length;
1611 Although the size of a zero-length array is zero, an array member of
1612 this kind may increase the size of the enclosing type as a result of tail
1613 padding. The offset of a zero-length array member from the beginning
1614 of the enclosing structure is the same as the offset of an array with
1615 one or more elements of the same type. The alignment of a zero-length
1616 array is the same as the alignment of its elements.
1618 Declaring zero-length arrays in other contexts, including as interior
1619 members of structure objects or as non-member objects, is discouraged.
1620 Accessing elements of zero-length arrays declared in such contexts is
1621 undefined and may be diagnosed.
1623 In the absence of the zero-length array extension, in ISO C90
1624 the @code{contents} array in the example above would typically be declared
1625 to have a single element. Unlike a zero-length array which only contributes
1626 to the size of the enclosing structure for the purposes of alignment,
1627 a one-element array always occupies at least as much space as a single
1628 object of the type. Although using one-element arrays this way is
1629 discouraged, GCC handles accesses to trailing one-element array members
1630 analogously to zero-length arrays.
1632 The preferred mechanism to declare variable-length types like
1633 @code{struct line} above is the ISO C99 @dfn{flexible array member},
1634 with slightly different syntax and semantics:
1638 Flexible array members are written as @code{contents[]} without
1642 Flexible array members have incomplete type, and so the @code{sizeof}
1643 operator may not be applied. As a quirk of the original implementation
1644 of zero-length arrays, @code{sizeof} evaluates to zero.
1647 Flexible array members may only appear as the last member of a
1648 @code{struct} that is otherwise non-empty.
1651 A structure containing a flexible array member, or a union containing
1652 such a structure (possibly recursively), may not be a member of a
1653 structure or an element of an array. (However, these uses are
1654 permitted by GCC as extensions.)
1657 Non-empty initialization of zero-length
1658 arrays is treated like any case where there are more initializer
1659 elements than the array holds, in that a suitable warning about ``excess
1660 elements in array'' is given, and the excess elements (all of them, in
1661 this case) are ignored.
1663 GCC allows static initialization of flexible array members.
1664 This is equivalent to defining a new structure containing the original
1665 structure followed by an array of sufficient size to contain the data.
1666 E.g.@: in the following, @code{f1} is constructed as if it were declared
1672 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1675 struct f1 f1; int data[3];
1676 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1680 The convenience of this extension is that @code{f1} has the desired
1681 type, eliminating the need to consistently refer to @code{f2.f1}.
1683 This has symmetry with normal static arrays, in that an array of
1684 unknown size is also written with @code{[]}.
1686 Of course, this extension only makes sense if the extra data comes at
1687 the end of a top-level object, as otherwise we would be overwriting
1688 data at subsequent offsets. To avoid undue complication and confusion
1689 with initialization of deeply nested arrays, we simply disallow any
1690 non-empty initialization except when the structure is the top-level
1691 object. For example:
1694 struct foo @{ int x; int y[]; @};
1695 struct bar @{ struct foo z; @};
1697 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1698 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1699 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1700 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1703 @node Empty Structures
1704 @section Structures with No Members
1705 @cindex empty structures
1706 @cindex zero-size structures
1708 GCC permits a C structure to have no members:
1715 The structure has size zero. In C++, empty structures are part
1716 of the language. G++ treats empty structures as if they had a single
1717 member of type @code{char}.
1719 @node Variable Length
1720 @section Arrays of Variable Length
1721 @cindex variable-length arrays
1722 @cindex arrays of variable length
1725 Variable-length automatic arrays are allowed in ISO C99, and as an
1726 extension GCC accepts them in C90 mode and in C++. These arrays are
1727 declared like any other automatic arrays, but with a length that is not
1728 a constant expression. The storage is allocated at the point of
1729 declaration and deallocated when the block scope containing the declaration
1735 concat_fopen (char *s1, char *s2, char *mode)
1737 char str[strlen (s1) + strlen (s2) + 1];
1740 return fopen (str, mode);
1744 @cindex scope of a variable length array
1745 @cindex variable-length array scope
1746 @cindex deallocating variable length arrays
1747 Jumping or breaking out of the scope of the array name deallocates the
1748 storage. Jumping into the scope is not allowed; you get an error
1751 @cindex variable-length array in a structure
1752 As an extension, GCC accepts variable-length arrays as a member of
1753 a structure or a union. For example:
1759 struct S @{ int x[n]; @};
1763 @cindex @code{alloca} vs variable-length arrays
1764 You can use the function @code{alloca} to get an effect much like
1765 variable-length arrays. The function @code{alloca} is available in
1766 many other C implementations (but not in all). On the other hand,
1767 variable-length arrays are more elegant.
1769 There are other differences between these two methods. Space allocated
1770 with @code{alloca} exists until the containing @emph{function} returns.
1771 The space for a variable-length array is deallocated as soon as the array
1772 name's scope ends, unless you also use @code{alloca} in this scope.
1774 You can also use variable-length arrays as arguments to functions:
1778 tester (int len, char data[len][len])
1784 The length of an array is computed once when the storage is allocated
1785 and is remembered for the scope of the array in case you access it with
1788 If you want to pass the array first and the length afterward, you can
1789 use a forward declaration in the parameter list---another GNU extension.
1793 tester (int len; char data[len][len], int len)
1799 @cindex parameter forward declaration
1800 The @samp{int len} before the semicolon is a @dfn{parameter forward
1801 declaration}, and it serves the purpose of making the name @code{len}
1802 known when the declaration of @code{data} is parsed.
1804 You can write any number of such parameter forward declarations in the
1805 parameter list. They can be separated by commas or semicolons, but the
1806 last one must end with a semicolon, which is followed by the ``real''
1807 parameter declarations. Each forward declaration must match a ``real''
1808 declaration in parameter name and data type. ISO C99 does not support
1809 parameter forward declarations.
1811 @node Variadic Macros
1812 @section Macros with a Variable Number of Arguments.
1813 @cindex variable number of arguments
1814 @cindex macro with variable arguments
1815 @cindex rest argument (in macro)
1816 @cindex variadic macros
1818 In the ISO C standard of 1999, a macro can be declared to accept a
1819 variable number of arguments much as a function can. The syntax for
1820 defining the macro is similar to that of a function. Here is an
1824 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1828 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1829 such a macro, it represents the zero or more tokens until the closing
1830 parenthesis that ends the invocation, including any commas. This set of
1831 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1832 wherever it appears. See the CPP manual for more information.
1834 GCC has long supported variadic macros, and used a different syntax that
1835 allowed you to give a name to the variable arguments just like any other
1836 argument. Here is an example:
1839 #define debug(format, args...) fprintf (stderr, format, args)
1843 This is in all ways equivalent to the ISO C example above, but arguably
1844 more readable and descriptive.
1846 GNU CPP has two further variadic macro extensions, and permits them to
1847 be used with either of the above forms of macro definition.
1849 In standard C, you are not allowed to leave the variable argument out
1850 entirely; but you are allowed to pass an empty argument. For example,
1851 this invocation is invalid in ISO C, because there is no comma after
1858 GNU CPP permits you to completely omit the variable arguments in this
1859 way. In the above examples, the compiler would complain, though since
1860 the expansion of the macro still has the extra comma after the format
1863 To help solve this problem, CPP behaves specially for variable arguments
1864 used with the token paste operator, @samp{##}. If instead you write
1867 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1871 and if the variable arguments are omitted or empty, the @samp{##}
1872 operator causes the preprocessor to remove the comma before it. If you
1873 do provide some variable arguments in your macro invocation, GNU CPP
1874 does not complain about the paste operation and instead places the
1875 variable arguments after the comma. Just like any other pasted macro
1876 argument, these arguments are not macro expanded.
1878 @node Escaped Newlines
1879 @section Slightly Looser Rules for Escaped Newlines
1880 @cindex escaped newlines
1881 @cindex newlines (escaped)
1883 The preprocessor treatment of escaped newlines is more relaxed
1884 than that specified by the C90 standard, which requires the newline
1885 to immediately follow a backslash.
1886 GCC's implementation allows whitespace in the form
1887 of spaces, horizontal and vertical tabs, and form feeds between the
1888 backslash and the subsequent newline. The preprocessor issues a
1889 warning, but treats it as a valid escaped newline and combines the two
1890 lines to form a single logical line. This works within comments and
1891 tokens, as well as between tokens. Comments are @emph{not} treated as
1892 whitespace for the purposes of this relaxation, since they have not
1893 yet been replaced with spaces.
1896 @section Non-Lvalue Arrays May Have Subscripts
1897 @cindex subscripting
1898 @cindex arrays, non-lvalue
1900 @cindex subscripting and function values
1901 In ISO C99, arrays that are not lvalues still decay to pointers, and
1902 may be subscripted, although they may not be modified or used after
1903 the next sequence point and the unary @samp{&} operator may not be
1904 applied to them. As an extension, GNU C allows such arrays to be
1905 subscripted in C90 mode, though otherwise they do not decay to
1906 pointers outside C99 mode. For example,
1907 this is valid in GNU C though not valid in C90:
1911 struct foo @{int a[4];@};
1917 return f().a[index];
1923 @section Arithmetic on @code{void}- and Function-Pointers
1924 @cindex void pointers, arithmetic
1925 @cindex void, size of pointer to
1926 @cindex function pointers, arithmetic
1927 @cindex function, size of pointer to
1929 In GNU C, addition and subtraction operations are supported on pointers to
1930 @code{void} and on pointers to functions. This is done by treating the
1931 size of a @code{void} or of a function as 1.
1933 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1934 and on function types, and returns 1.
1936 @opindex Wpointer-arith
1937 The option @option{-Wpointer-arith} requests a warning if these extensions
1940 @node Pointers to Arrays
1941 @section Pointers to Arrays with Qualifiers Work as Expected
1942 @cindex pointers to arrays
1943 @cindex const qualifier
1945 In GNU C, pointers to arrays with qualifiers work similar to pointers
1946 to other qualified types. For example, a value of type @code{int (*)[5]}
1947 can be used to initialize a variable of type @code{const int (*)[5]}.
1948 These types are incompatible in ISO C because the @code{const} qualifier
1949 is formally attached to the element type of the array and not the
1954 transpose (int N, int M, double out[M][N], const double in[N][M]);
1958 transpose(3, 2, y, x);
1962 @section Non-Constant Initializers
1963 @cindex initializers, non-constant
1964 @cindex non-constant initializers
1966 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1967 automatic variable are not required to be constant expressions in GNU C@.
1968 Here is an example of an initializer with run-time varying elements:
1971 foo (float f, float g)
1973 float beat_freqs[2] = @{ f-g, f+g @};
1978 @node Compound Literals
1979 @section Compound Literals
1980 @cindex constructor expressions
1981 @cindex initializations in expressions
1982 @cindex structures, constructor expression
1983 @cindex expressions, constructor
1984 @cindex compound literals
1985 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1987 A compound literal looks like a cast of a brace-enclosed aggregate
1988 initializer list. Its value is an object of the type specified in
1989 the cast, containing the elements specified in the initializer.
1990 Unlike the result of a cast, a compound literal is an lvalue. ISO
1991 C99 and later support compound literals. As an extension, GCC
1992 supports compound literals also in C90 mode and in C++, although
1993 as explained below, the C++ semantics are somewhat different.
1995 Usually, the specified type of a compound literal is a structure. Assume
1996 that @code{struct foo} and @code{structure} are declared as shown:
1999 struct foo @{int a; char b[2];@} structure;
2003 Here is an example of constructing a @code{struct foo} with a compound literal:
2006 structure = ((struct foo) @{x + y, 'a', 0@});
2010 This is equivalent to writing the following:
2014 struct foo temp = @{x + y, 'a', 0@};
2019 You can also construct an array, though this is dangerous in C++, as
2020 explained below. If all the elements of the compound literal are
2021 (made up of) simple constant expressions suitable for use in
2022 initializers of objects of static storage duration, then the compound
2023 literal can be coerced to a pointer to its first element and used in
2024 such an initializer, as shown here:
2027 char **foo = (char *[]) @{ "x", "y", "z" @};
2030 Compound literals for scalar types and union types are also allowed. In
2031 the following example the variable @code{i} is initialized to the value
2032 @code{2}, the result of incrementing the unnamed object created by
2033 the compound literal.
2036 int i = ++(int) @{ 1 @};
2039 As a GNU extension, GCC allows initialization of objects with static storage
2040 duration by compound literals (which is not possible in ISO C99 because
2041 the initializer is not a constant).
2042 It is handled as if the object were initialized only with the brace-enclosed
2043 list if the types of the compound literal and the object match.
2044 The elements of the compound literal must be constant.
2045 If the object being initialized has array type of unknown size, the size is
2046 determined by the size of the compound literal.
2049 static struct foo x = (struct foo) @{1, 'a', 'b'@};
2050 static int y[] = (int []) @{1, 2, 3@};
2051 static int z[] = (int [3]) @{1@};
2055 The above lines are equivalent to the following:
2057 static struct foo x = @{1, 'a', 'b'@};
2058 static int y[] = @{1, 2, 3@};
2059 static int z[] = @{1, 0, 0@};
2062 In C, a compound literal designates an unnamed object with static or
2063 automatic storage duration. In C++, a compound literal designates a
2064 temporary object that only lives until the end of its full-expression.
2065 As a result, well-defined C code that takes the address of a subobject
2066 of a compound literal can be undefined in C++, so G++ rejects
2067 the conversion of a temporary array to a pointer. For instance, if
2068 the array compound literal example above appeared inside a function,
2069 any subsequent use of @code{foo} in C++ would have undefined behavior
2070 because the lifetime of the array ends after the declaration of @code{foo}.
2072 As an optimization, G++ sometimes gives array compound literals longer
2073 lifetimes: when the array either appears outside a function or has
2074 a @code{const}-qualified type. If @code{foo} and its initializer had
2075 elements of type @code{char *const} rather than @code{char *}, or if
2076 @code{foo} were a global variable, the array would have static storage
2077 duration. But it is probably safest just to avoid the use of array
2078 compound literals in C++ code.
2080 @node Designated Inits
2081 @section Designated Initializers
2082 @cindex initializers with labeled elements
2083 @cindex labeled elements in initializers
2084 @cindex case labels in initializers
2085 @cindex designated initializers
2087 Standard C90 requires the elements of an initializer to appear in a fixed
2088 order, the same as the order of the elements in the array or structure
2091 In ISO C99 you can give the elements in any order, specifying the array
2092 indices or structure field names they apply to, and GNU C allows this as
2093 an extension in C90 mode as well. This extension is not
2094 implemented in GNU C++.
2096 To specify an array index, write
2097 @samp{[@var{index}] =} before the element value. For example,
2100 int a[6] = @{ [4] = 29, [2] = 15 @};
2107 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2111 The index values must be constant expressions, even if the array being
2112 initialized is automatic.
2114 An alternative syntax for this that has been obsolete since GCC 2.5 but
2115 GCC still accepts is to write @samp{[@var{index}]} before the element
2116 value, with no @samp{=}.
2118 To initialize a range of elements to the same value, write
2119 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
2120 extension. For example,
2123 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2127 If the value in it has side effects, the side effects happen only once,
2128 not for each initialized field by the range initializer.
2131 Note that the length of the array is the highest value specified
2134 In a structure initializer, specify the name of a field to initialize
2135 with @samp{.@var{fieldname} =} before the element value. For example,
2136 given the following structure,
2139 struct point @{ int x, y; @};
2143 the following initialization
2146 struct point p = @{ .y = yvalue, .x = xvalue @};
2153 struct point p = @{ xvalue, yvalue @};
2156 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2157 @samp{@var{fieldname}:}, as shown here:
2160 struct point p = @{ y: yvalue, x: xvalue @};
2163 Omitted fields are implicitly initialized the same as for objects
2164 that have static storage duration.
2167 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2168 @dfn{designator}. You can also use a designator (or the obsolete colon
2169 syntax) when initializing a union, to specify which element of the union
2170 should be used. For example,
2173 union foo @{ int i; double d; @};
2175 union foo f = @{ .d = 4 @};
2179 converts 4 to a @code{double} to store it in the union using
2180 the second element. By contrast, casting 4 to type @code{union foo}
2181 stores it into the union as the integer @code{i}, since it is
2182 an integer. @xref{Cast to Union}.
2184 You can combine this technique of naming elements with ordinary C
2185 initialization of successive elements. Each initializer element that
2186 does not have a designator applies to the next consecutive element of the
2187 array or structure. For example,
2190 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2197 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2200 Labeling the elements of an array initializer is especially useful
2201 when the indices are characters or belong to an @code{enum} type.
2206 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2207 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2210 @cindex designator lists
2211 You can also write a series of @samp{.@var{fieldname}} and
2212 @samp{[@var{index}]} designators before an @samp{=} to specify a
2213 nested subobject to initialize; the list is taken relative to the
2214 subobject corresponding to the closest surrounding brace pair. For
2215 example, with the @samp{struct point} declaration above:
2218 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2221 If the same field is initialized multiple times, or overlapping
2222 fields of a union are initialized, the value from the last
2223 initialization is used. When a field of a union is itself a structure,
2224 the entire structure from the last field initialized is used. If any previous
2225 initializer has side effect, it is unspecified whether the side effect
2226 happens or not. Currently, GCC discards the side-effecting
2227 initializer expressions and issues a warning.
2230 @section Case Ranges
2232 @cindex ranges in case statements
2234 You can specify a range of consecutive values in a single @code{case} label,
2238 case @var{low} ... @var{high}:
2242 This has the same effect as the proper number of individual @code{case}
2243 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2245 This feature is especially useful for ranges of ASCII character codes:
2251 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2252 it may be parsed wrong when you use it with integer values. For example,
2267 @section Cast to a Union Type
2268 @cindex cast to a union
2269 @cindex union, casting to a
2271 A cast to union type looks similar to other casts, except that the type
2272 specified is a union type. You can specify the type either with the
2273 @code{union} keyword or with a @code{typedef} name that refers to
2274 a union. A cast to a union actually creates a compound literal and
2275 yields an lvalue, not an rvalue like true casts do.
2276 @xref{Compound Literals}.
2278 The types that may be cast to the union type are those of the members
2279 of the union. Thus, given the following union and variables:
2282 union foo @{ int i; double d; @};
2288 both @code{x} and @code{y} can be cast to type @code{union foo}.
2290 Using the cast as the right-hand side of an assignment to a variable of
2291 union type is equivalent to storing in a member of the union:
2296 u = (union foo) x @equiv{} u.i = x
2297 u = (union foo) y @equiv{} u.d = y
2300 You can also use the union cast as a function argument:
2303 void hack (union foo);
2305 hack ((union foo) x);
2308 @node Mixed Declarations
2309 @section Mixed Declarations and Code
2310 @cindex mixed declarations and code
2311 @cindex declarations, mixed with code
2312 @cindex code, mixed with declarations
2314 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2315 within compound statements. As an extension, GNU C also allows this in
2316 C90 mode. For example, you could do:
2325 Each identifier is visible from where it is declared until the end of
2326 the enclosing block.
2328 @node Function Attributes
2329 @section Declaring Attributes of Functions
2330 @cindex function attributes
2331 @cindex declaring attributes of functions
2332 @cindex @code{volatile} applied to function
2333 @cindex @code{const} applied to function
2335 In GNU C and C++, you can use function attributes to specify certain
2336 function properties that may help the compiler optimize calls or
2337 check code more carefully for correctness. For example, you
2338 can use attributes to specify that a function never returns
2339 (@code{noreturn}), returns a value depending only on the values of
2340 its arguments (@code{const}), or has @code{printf}-style arguments
2343 You can also use attributes to control memory placement, code
2344 generation options or call/return conventions within the function
2345 being annotated. Many of these attributes are target-specific. For
2346 example, many targets support attributes for defining interrupt
2347 handler functions, which typically must follow special register usage
2348 and return conventions. Such attributes are described in the subsection
2349 for each target. However, a considerable number of attributes are
2350 supported by most, if not all targets. Those are described in
2351 the @ref{Common Function Attributes} section.
2353 Function attributes are introduced by the @code{__attribute__} keyword
2354 in the declaration of a function, followed by an attribute specification
2355 enclosed in double parentheses. You can specify multiple attributes in
2356 a declaration by separating them by commas within the double parentheses
2357 or by immediately following one attribute specification with another.
2358 @xref{Attribute Syntax}, for the exact rules on attribute syntax and
2359 placement. Compatible attribute specifications on distinct declarations
2360 of the same function are merged. An attribute specification that is not
2361 compatible with attributes already applied to a declaration of the same
2362 function is ignored with a warning.
2364 Some function attributes take one or more arguments that refer to
2365 the function's parameters by their positions within the function parameter
2366 list. Such attribute arguments are referred to as @dfn{positional arguments}.
2367 Unless specified otherwise, positional arguments that specify properties
2368 of parameters with pointer types can also specify the same properties of
2369 the implicit C++ @code{this} argument in non-static member functions, and
2370 of parameters of reference to a pointer type. For ordinary functions,
2371 position one refers to the first parameter on the list. In C++ non-static
2372 member functions, position one refers to the implicit @code{this} pointer.
2373 The same restrictions and effects apply to function attributes used with
2374 ordinary functions or C++ member functions.
2376 GCC also supports attributes on
2377 variable declarations (@pxref{Variable Attributes}),
2378 labels (@pxref{Label Attributes}),
2379 enumerators (@pxref{Enumerator Attributes}),
2380 statements (@pxref{Statement Attributes}),
2381 and types (@pxref{Type Attributes}).
2383 There is some overlap between the purposes of attributes and pragmas
2384 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2385 found convenient to use @code{__attribute__} to achieve a natural
2386 attachment of attributes to their corresponding declarations, whereas
2387 @code{#pragma} is of use for compatibility with other compilers
2388 or constructs that do not naturally form part of the grammar.
2390 In addition to the attributes documented here,
2391 GCC plugins may provide their own attributes.
2394 * Common Function Attributes::
2395 * AArch64 Function Attributes::
2396 * ARC Function Attributes::
2397 * ARM Function Attributes::
2398 * AVR Function Attributes::
2399 * Blackfin Function Attributes::
2400 * CR16 Function Attributes::
2401 * C-SKY Function Attributes::
2402 * Epiphany Function Attributes::
2403 * H8/300 Function Attributes::
2404 * IA-64 Function Attributes::
2405 * M32C Function Attributes::
2406 * M32R/D Function Attributes::
2407 * m68k Function Attributes::
2408 * MCORE Function Attributes::
2409 * MeP Function Attributes::
2410 * MicroBlaze Function Attributes::
2411 * Microsoft Windows Function Attributes::
2412 * MIPS Function Attributes::
2413 * MSP430 Function Attributes::
2414 * NDS32 Function Attributes::
2415 * Nios II Function Attributes::
2416 * Nvidia PTX Function Attributes::
2417 * PowerPC Function Attributes::
2418 * RISC-V Function Attributes::
2419 * RL78 Function Attributes::
2420 * RX Function Attributes::
2421 * S/390 Function Attributes::
2422 * SH Function Attributes::
2423 * SPU Function Attributes::
2424 * Symbian OS Function Attributes::
2425 * V850 Function Attributes::
2426 * Visium Function Attributes::
2427 * x86 Function Attributes::
2428 * Xstormy16 Function Attributes::
2431 @node Common Function Attributes
2432 @subsection Common Function Attributes
2434 The following attributes are supported on most targets.
2437 @c Keep this table alphabetized by attribute name. Treat _ as space.
2439 @item alias ("@var{target}")
2440 @cindex @code{alias} function attribute
2441 The @code{alias} attribute causes the declaration to be emitted as an
2442 alias for another symbol, which must be specified. For instance,
2445 void __f () @{ /* @r{Do something.} */; @}
2446 void f () __attribute__ ((weak, alias ("__f")));
2450 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2451 mangled name for the target must be used. It is an error if @samp{__f}
2452 is not defined in the same translation unit.
2454 This attribute requires assembler and object file support,
2455 and may not be available on all targets.
2458 @itemx aligned (@var{alignment})
2459 @cindex @code{aligned} function attribute
2460 The @code{aligned} attribute specifies a minimum alignment for
2461 the first instruction of the function, measured in bytes. When specified,
2462 @var{alignment} must be an integer constant power of 2. Specifying no
2463 @var{alignment} argument implies the ideal alignment for the target.
2464 The @code{__alignof__} operator can be used to determine what that is
2465 (@pxref{Alignment}). The attribute has no effect when a definition for
2466 the function is not provided in the same translation unit.
2468 The attribute cannot be used to decrease the alignment of a function
2469 previously declared with a more restrictive alignment; only to increase
2470 it. Attempts to do otherwise are diagnosed. Some targets specify
2471 a minimum default alignment for functions that is greater than 1. On
2472 such targets, specifying a less restrictive alignment is silently ignored.
2473 Using the attribute overrides the effect of the @option{-falign-functions}
2474 (@pxref{Optimize Options}) option for this function.
2476 Note that the effectiveness of @code{aligned} attributes may be
2477 limited by inherent limitations in the system linker
2478 and/or object file format. On some systems, the
2479 linker is only able to arrange for functions to be aligned up to a
2480 certain maximum alignment. (For some linkers, the maximum supported
2481 alignment may be very very small.) See your linker documentation for
2482 further information.
2484 The @code{aligned} attribute can also be used for variables and fields
2485 (@pxref{Variable Attributes}.)
2487 @item alloc_align (@var{position})
2488 @cindex @code{alloc_align} function attribute
2489 The @code{alloc_align} attribute may be applied to a function that
2490 returns a pointer and takes at least one argument of an integer type.
2491 It indicates that the returned pointer is aligned on a boundary given
2492 by the function argument at @var{position}. Meaningful alignments are
2493 powers of 2 greater than one. GCC uses this information to improve
2494 pointer alignment analysis.
2496 The function parameter denoting the allocated alignment is specified by
2497 one constant integer argument whose number is the argument of the attribute.
2498 Argument numbering starts at one.
2503 void* my_memalign (size_t, size_t) __attribute__ ((alloc_align (1)));
2507 declares that @code{my_memalign} returns memory with minimum alignment
2508 given by parameter 1.
2510 @item alloc_size (@var{position})
2511 @itemx alloc_size (@var{position-1}, @var{position-2})
2512 @cindex @code{alloc_size} function attribute
2513 The @code{alloc_size} attribute may be applied to a function that
2514 returns a pointer and takes at least one argument of an integer type.
2515 It indicates that the returned pointer points to memory whose size is
2516 given by the function argument at @var{position-1}, or by the product
2517 of the arguments at @var{position-1} and @var{position-2}. Meaningful
2518 sizes are positive values less than @code{PTRDIFF_MAX}. GCC uses this
2519 information to improve the results of @code{__builtin_object_size}.
2521 The function parameter(s) denoting the allocated size are specified by
2522 one or two integer arguments supplied to the attribute. The allocated size
2523 is either the value of the single function argument specified or the product
2524 of the two function arguments specified. Argument numbering starts at
2525 one for ordinary functions, and at two for C++ non-static member functions.
2530 void* my_calloc (size_t, size_t) __attribute__ ((alloc_size (1, 2)));
2531 void* my_realloc (void*, size_t) __attribute__ ((alloc_size (2)));
2535 declares that @code{my_calloc} returns memory of the size given by
2536 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2537 of the size given by parameter 2.
2540 @cindex @code{always_inline} function attribute
2541 Generally, functions are not inlined unless optimization is specified.
2542 For functions declared inline, this attribute inlines the function
2543 independent of any restrictions that otherwise apply to inlining.
2544 Failure to inline such a function is diagnosed as an error.
2545 Note that if such a function is called indirectly the compiler may
2546 or may not inline it depending on optimization level and a failure
2547 to inline an indirect call may or may not be diagnosed.
2550 @cindex @code{artificial} function attribute
2551 This attribute is useful for small inline wrappers that if possible
2552 should appear during debugging as a unit. Depending on the debug
2553 info format it either means marking the function as artificial
2554 or using the caller location for all instructions within the inlined
2557 @item assume_aligned (@var{alignment})
2558 @itemx assume_aligned (@var{alignment}, @var{offset})
2559 @cindex @code{assume_aligned} function attribute
2560 The @code{assume_aligned} attribute may be applied to a function that
2561 returns a pointer. It indicates that the returned pointer is aligned
2562 on a boundary given by @var{alignment}. If the attribute has two
2563 arguments, the second argument is misalignment @var{offset}. Meaningful
2564 values of @var{alignment} are powers of 2 greater than one. Meaningful
2565 values of @var{offset} are greater than zero and less than @var{alignment}.
2570 void* my_alloc1 (size_t) __attribute__((assume_aligned (16)));
2571 void* my_alloc2 (size_t) __attribute__((assume_aligned (32, 8)));
2575 declares that @code{my_alloc1} returns 16-byte aligned pointers and
2576 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2580 @cindex @code{cold} function attribute
2581 The @code{cold} attribute on functions is used to inform the compiler that
2582 the function is unlikely to be executed. The function is optimized for
2583 size rather than speed and on many targets it is placed into a special
2584 subsection of the text section so all cold functions appear close together,
2585 improving code locality of non-cold parts of program. The paths leading
2586 to calls of cold functions within code are marked as unlikely by the branch
2587 prediction mechanism. It is thus useful to mark functions used to handle
2588 unlikely conditions, such as @code{perror}, as cold to improve optimization
2589 of hot functions that do call marked functions in rare occasions.
2591 When profile feedback is available, via @option{-fprofile-use}, cold functions
2592 are automatically detected and this attribute is ignored.
2595 @cindex @code{const} function attribute
2596 @cindex functions that have no side effects
2597 Calls to functions whose return value is not affected by changes to
2598 the observable state of the program and that have no observable effects
2599 on such state other than to return a value may lend themselves to
2600 optimizations such as common subexpression elimination. Declaring such
2601 functions with the @code{const} attribute allows GCC to avoid emitting
2602 some calls in repeated invocations of the function with the same argument
2608 int square (int) __attribute__ ((const));
2612 tells GCC that subsequent calls to function @code{square} with the same
2613 argument value can be replaced by the result of the first call regardless
2614 of the statements in between.
2616 The @code{const} attribute prohibits a function from reading objects
2617 that affect its return value between successive invocations. However,
2618 functions declared with the attribute can safely read objects that do
2619 not change their return value, such as non-volatile constants.
2621 The @code{const} attribute imposes greater restrictions on a function's
2622 definition than the similar @code{pure} attribute. Declaring the same
2623 function with both the @code{const} and the @code{pure} attribute is
2624 diagnosed. Because a const function cannot have any observable side
2625 effects it does not make sense for it to return @code{void}. Declaring
2626 such a function is diagnosed.
2628 @cindex pointer arguments
2629 Note that a function that has pointer arguments and examines the data
2630 pointed to must @emph{not} be declared @code{const} if the pointed-to
2631 data might change between successive invocations of the function. In
2632 general, since a function cannot distinguish data that might change
2633 from data that cannot, const functions should never take pointer or,
2634 in C++, reference arguments. Likewise, a function that calls a non-const
2635 function usually must not be const itself.
2639 @itemx constructor (@var{priority})
2640 @itemx destructor (@var{priority})
2641 @cindex @code{constructor} function attribute
2642 @cindex @code{destructor} function attribute
2643 The @code{constructor} attribute causes the function to be called
2644 automatically before execution enters @code{main ()}. Similarly, the
2645 @code{destructor} attribute causes the function to be called
2646 automatically after @code{main ()} completes or @code{exit ()} is
2647 called. Functions with these attributes are useful for
2648 initializing data that is used implicitly during the execution of
2651 On some targets the attributes also accept an integer argument to
2652 specify a priority to control the order in which constructor and
2653 destructor functions are run. A constructor
2654 with a smaller priority number runs before a constructor with a larger
2655 priority number; the opposite relationship holds for destructors. So,
2656 if you have a constructor that allocates a resource and a destructor
2657 that deallocates the same resource, both functions typically have the
2658 same priority. The priorities for constructor and destructor
2659 functions are the same as those specified for namespace-scope C++
2660 objects (@pxref{C++ Attributes}). However, at present, the order in which
2661 constructors for C++ objects with static storage duration and functions
2662 decorated with attribute @code{constructor} are invoked is unspecified.
2663 In mixed declarations, attribute @code{init_priority} can be used to
2664 impose a specific ordering.
2666 Using the argument forms of the @code{constructor} and @code{destructor}
2667 attributes on targets where the feature is not supported is rejected with
2671 @itemx copy (@var{function})
2672 @cindex @code{copy} function attribute
2673 The @code{copy} attribute applies the set of attributes with which
2674 @var{function} has been declared to the declaration of the function
2675 to which the attribute is applied. The attribute is designed for
2676 libraries that define aliases or function resolvers that are expected
2677 to specify the same set of attributes as their targets. The @code{copy}
2678 attribute can be used with functions, variables, or types. However,
2679 the kind of symbol to which the attribute is applied (either function
2680 or variable) must match the kind of symbol to which the argument refers.
2681 The @code{copy} attribute copies only syntactic and semantic attributes
2682 but not attributes that affect a symbol's linkage or visibility such as
2683 @code{alias}, @code{visibility}, or @code{weak}. The @code{deprecated}
2684 attribute is also not copied. @xref{Common Type Attributes}.
2685 @xref{Common Variable Attributes}.
2687 For example, the @var{StrongAlias} macro below makes use of the @code{alias}
2688 and @code{copy} attributes to define an alias named @var{alloc} for function
2689 @var{allocate} declared with attributes @var{alloc_size}, @var{malloc}, and
2690 @var{nothrow}. Thanks to the @code{__typeof__} operator the alias has
2691 the same type as the target function. As a result of the @code{copy}
2692 attribute the alias also shares the same attributes as the target.
2695 #define StrongAlias(TagetFunc, AliasDecl) \
2696 extern __typeof__ (TargetFunc) AliasDecl \
2697 __attribute__ ((alias (#TargetFunc), copy (TargetFunc)));
2699 extern __attribute__ ((alloc_size (1), malloc, nothrow))
2700 void* allocate (size_t);
2701 StrongAlias (allocate, alloc);
2705 @itemx deprecated (@var{msg})
2706 @cindex @code{deprecated} function attribute
2707 The @code{deprecated} attribute results in a warning if the function
2708 is used anywhere in the source file. This is useful when identifying
2709 functions that are expected to be removed in a future version of a
2710 program. The warning also includes the location of the declaration
2711 of the deprecated function, to enable users to easily find further
2712 information about why the function is deprecated, or what they should
2713 do instead. Note that the warnings only occurs for uses:
2716 int old_fn () __attribute__ ((deprecated));
2718 int (*fn_ptr)() = old_fn;
2722 results in a warning on line 3 but not line 2. The optional @var{msg}
2723 argument, which must be a string, is printed in the warning if
2726 The @code{deprecated} attribute can also be used for variables and
2727 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2729 The message attached to the attribute is affected by the setting of
2730 the @option{-fmessage-length} option.
2732 @item error ("@var{message}")
2733 @itemx warning ("@var{message}")
2734 @cindex @code{error} function attribute
2735 @cindex @code{warning} function attribute
2736 If the @code{error} or @code{warning} attribute
2737 is used on a function declaration and a call to such a function
2738 is not eliminated through dead code elimination or other optimizations,
2739 an error or warning (respectively) that includes @var{message} is diagnosed.
2741 for compile-time checking, especially together with @code{__builtin_constant_p}
2742 and inline functions where checking the inline function arguments is not
2743 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2745 While it is possible to leave the function undefined and thus invoke
2746 a link failure (to define the function with
2747 a message in @code{.gnu.warning*} section),
2748 when using these attributes the problem is diagnosed
2749 earlier and with exact location of the call even in presence of inline
2750 functions or when not emitting debugging information.
2752 @item externally_visible
2753 @cindex @code{externally_visible} function attribute
2754 This attribute, attached to a global variable or function, nullifies
2755 the effect of the @option{-fwhole-program} command-line option, so the
2756 object remains visible outside the current compilation unit.
2758 If @option{-fwhole-program} is used together with @option{-flto} and
2759 @command{gold} is used as the linker plugin,
2760 @code{externally_visible} attributes are automatically added to functions
2761 (not variable yet due to a current @command{gold} issue)
2762 that are accessed outside of LTO objects according to resolution file
2763 produced by @command{gold}.
2764 For other linkers that cannot generate resolution file,
2765 explicit @code{externally_visible} attributes are still necessary.
2768 @cindex @code{flatten} function attribute
2769 Generally, inlining into a function is limited. For a function marked with
2770 this attribute, every call inside this function is inlined, if possible.
2771 Functions declared with attribute @code{noinline} and similar are not
2772 inlined. Whether the function itself is considered for inlining depends
2773 on its size and the current inlining parameters.
2775 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2776 @cindex @code{format} function attribute
2777 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2779 The @code{format} attribute specifies that a function takes @code{printf},
2780 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2781 should be type-checked against a format string. For example, the
2786 my_printf (void *my_object, const char *my_format, ...)
2787 __attribute__ ((format (printf, 2, 3)));
2791 causes the compiler to check the arguments in calls to @code{my_printf}
2792 for consistency with the @code{printf} style format string argument
2795 The parameter @var{archetype} determines how the format string is
2796 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2797 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2798 @code{strfmon}. (You can also use @code{__printf__},
2799 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2800 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2801 @code{ms_strftime} are also present.
2802 @var{archetype} values such as @code{printf} refer to the formats accepted
2803 by the system's C runtime library,
2804 while values prefixed with @samp{gnu_} always refer
2805 to the formats accepted by the GNU C Library. On Microsoft Windows
2806 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2807 @file{msvcrt.dll} library.
2808 The parameter @var{string-index}
2809 specifies which argument is the format string argument (starting
2810 from 1), while @var{first-to-check} is the number of the first
2811 argument to check against the format string. For functions
2812 where the arguments are not available to be checked (such as
2813 @code{vprintf}), specify the third parameter as zero. In this case the
2814 compiler only checks the format string for consistency. For
2815 @code{strftime} formats, the third parameter is required to be zero.
2816 Since non-static C++ methods have an implicit @code{this} argument, the
2817 arguments of such methods should be counted from two, not one, when
2818 giving values for @var{string-index} and @var{first-to-check}.
2820 In the example above, the format string (@code{my_format}) is the second
2821 argument of the function @code{my_print}, and the arguments to check
2822 start with the third argument, so the correct parameters for the format
2823 attribute are 2 and 3.
2825 @opindex ffreestanding
2826 @opindex fno-builtin
2827 The @code{format} attribute allows you to identify your own functions
2828 that take format strings as arguments, so that GCC can check the
2829 calls to these functions for errors. The compiler always (unless
2830 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2831 for the standard library functions @code{printf}, @code{fprintf},
2832 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2833 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2834 warnings are requested (using @option{-Wformat}), so there is no need to
2835 modify the header file @file{stdio.h}. In C99 mode, the functions
2836 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2837 @code{vsscanf} are also checked. Except in strictly conforming C
2838 standard modes, the X/Open function @code{strfmon} is also checked as
2839 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2840 @xref{C Dialect Options,,Options Controlling C Dialect}.
2842 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2843 recognized in the same context. Declarations including these format attributes
2844 are parsed for correct syntax, however the result of checking of such format
2845 strings is not yet defined, and is not carried out by this version of the
2848 The target may also provide additional types of format checks.
2849 @xref{Target Format Checks,,Format Checks Specific to Particular
2852 @item format_arg (@var{string-index})
2853 @cindex @code{format_arg} function attribute
2854 @opindex Wformat-nonliteral
2855 The @code{format_arg} attribute specifies that a function takes one or
2856 more format strings for a @code{printf}, @code{scanf}, @code{strftime} or
2857 @code{strfmon} style function and modifies it (for example, to translate
2858 it into another language), so the result can be passed to a
2859 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2860 function (with the remaining arguments to the format function the same
2861 as they would have been for the unmodified string). Multiple
2862 @code{format_arg} attributes may be applied to the same function, each
2863 designating a distinct parameter as a format string. For example, the
2868 my_dgettext (char *my_domain, const char *my_format)
2869 __attribute__ ((format_arg (2)));
2873 causes the compiler to check the arguments in calls to a @code{printf},
2874 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2875 format string argument is a call to the @code{my_dgettext} function, for
2876 consistency with the format string argument @code{my_format}. If the
2877 @code{format_arg} attribute had not been specified, all the compiler
2878 could tell in such calls to format functions would be that the format
2879 string argument is not constant; this would generate a warning when
2880 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2881 without the attribute.
2883 In calls to a function declared with more than one @code{format_arg}
2884 attribute, each with a distinct argument value, the corresponding
2885 actual function arguments are checked against all format strings
2886 designated by the attributes. This capability is designed to support
2887 the GNU @code{ngettext} family of functions.
2889 The parameter @var{string-index} specifies which argument is the format
2890 string argument (starting from one). Since non-static C++ methods have
2891 an implicit @code{this} argument, the arguments of such methods should
2892 be counted from two.
2894 The @code{format_arg} attribute allows you to identify your own
2895 functions that modify format strings, so that GCC can check the
2896 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2897 type function whose operands are a call to one of your own function.
2898 The compiler always treats @code{gettext}, @code{dgettext}, and
2899 @code{dcgettext} in this manner except when strict ISO C support is
2900 requested by @option{-ansi} or an appropriate @option{-std} option, or
2901 @option{-ffreestanding} or @option{-fno-builtin}
2902 is used. @xref{C Dialect Options,,Options
2903 Controlling C Dialect}.
2905 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2906 @code{NSString} reference for compatibility with the @code{format} attribute
2909 The target may also allow additional types in @code{format-arg} attributes.
2910 @xref{Target Format Checks,,Format Checks Specific to Particular
2914 @cindex @code{gnu_inline} function attribute
2915 This attribute should be used with a function that is also declared
2916 with the @code{inline} keyword. It directs GCC to treat the function
2917 as if it were defined in gnu90 mode even when compiling in C99 or
2920 If the function is declared @code{extern}, then this definition of the
2921 function is used only for inlining. In no case is the function
2922 compiled as a standalone function, not even if you take its address
2923 explicitly. Such an address becomes an external reference, as if you
2924 had only declared the function, and had not defined it. This has
2925 almost the effect of a macro. The way to use this is to put a
2926 function definition in a header file with this attribute, and put
2927 another copy of the function, without @code{extern}, in a library
2928 file. The definition in the header file causes most calls to the
2929 function to be inlined. If any uses of the function remain, they
2930 refer to the single copy in the library. Note that the two
2931 definitions of the functions need not be precisely the same, although
2932 if they do not have the same effect your program may behave oddly.
2934 In C, if the function is neither @code{extern} nor @code{static}, then
2935 the function is compiled as a standalone function, as well as being
2936 inlined where possible.
2938 This is how GCC traditionally handled functions declared
2939 @code{inline}. Since ISO C99 specifies a different semantics for
2940 @code{inline}, this function attribute is provided as a transition
2941 measure and as a useful feature in its own right. This attribute is
2942 available in GCC 4.1.3 and later. It is available if either of the
2943 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2944 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2945 Function is As Fast As a Macro}.
2947 In C++, this attribute does not depend on @code{extern} in any way,
2948 but it still requires the @code{inline} keyword to enable its special
2952 @cindex @code{hot} function attribute
2953 The @code{hot} attribute on a function is used to inform the compiler that
2954 the function is a hot spot of the compiled program. The function is
2955 optimized more aggressively and on many targets it is placed into a special
2956 subsection of the text section so all hot functions appear close together,
2959 When profile feedback is available, via @option{-fprofile-use}, hot functions
2960 are automatically detected and this attribute is ignored.
2962 @item ifunc ("@var{resolver}")
2963 @cindex @code{ifunc} function attribute
2964 @cindex indirect functions
2965 @cindex functions that are dynamically resolved
2966 The @code{ifunc} attribute is used to mark a function as an indirect
2967 function using the STT_GNU_IFUNC symbol type extension to the ELF
2968 standard. This allows the resolution of the symbol value to be
2969 determined dynamically at load time, and an optimized version of the
2970 routine to be selected for the particular processor or other system
2971 characteristics determined then. To use this attribute, first define
2972 the implementation functions available, and a resolver function that
2973 returns a pointer to the selected implementation function. The
2974 implementation functions' declarations must match the API of the
2975 function being implemented. The resolver should be declared to
2976 be a function taking no arguments and returning a pointer to
2977 a function of the same type as the implementation. For example:
2980 void *my_memcpy (void *dst, const void *src, size_t len)
2986 static void * (*resolve_memcpy (void))(void *, const void *, size_t)
2988 return my_memcpy; // we will just always select this routine
2993 The exported header file declaring the function the user calls would
2997 extern void *memcpy (void *, const void *, size_t);
3001 allowing the user to call @code{memcpy} as a regular function, unaware of
3002 the actual implementation. Finally, the indirect function needs to be
3003 defined in the same translation unit as the resolver function:
3006 void *memcpy (void *, const void *, size_t)
3007 __attribute__ ((ifunc ("resolve_memcpy")));
3010 In C++, the @code{ifunc} attribute takes a string that is the mangled name
3011 of the resolver function. A C++ resolver for a non-static member function
3012 of class @code{C} should be declared to return a pointer to a non-member
3013 function taking pointer to @code{C} as the first argument, followed by
3014 the same arguments as of the implementation function. G++ checks
3015 the signatures of the two functions and issues
3016 a @option{-Wattribute-alias} warning for mismatches. To suppress a warning
3017 for the necessary cast from a pointer to the implementation member function
3018 to the type of the corresponding non-member function use
3019 the @option{-Wno-pmf-conversions} option. For example:
3025 int debug_impl (int);
3026 int optimized_impl (int);
3028 typedef int Func (S*, int);
3030 static Func* resolver ();
3033 int interface (int);
3036 int S::debug_impl (int) @{ /* @r{@dots{}} */ @}
3037 int S::optimized_impl (int) @{ /* @r{@dots{}} */ @}
3039 S::Func* S::resolver ()
3041 int (S::*pimpl) (int)
3042 = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl;
3044 // Cast triggers -Wno-pmf-conversions.
3045 return reinterpret_cast<Func*>(pimpl);
3048 int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv")));
3051 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
3052 and GNU C Library version 2.11.1 are required to use this feature.
3055 @itemx interrupt_handler
3056 Many GCC back ends support attributes to indicate that a function is
3057 an interrupt handler, which tells the compiler to generate function
3058 entry and exit sequences that differ from those from regular
3059 functions. The exact syntax and behavior are target-specific;
3060 refer to the following subsections for details.
3063 @cindex @code{leaf} function attribute
3064 Calls to external functions with this attribute must return to the
3065 current compilation unit only by return or by exception handling. In
3066 particular, a leaf function is not allowed to invoke callback functions
3067 passed to it from the current compilation unit, directly call functions
3068 exported by the unit, or @code{longjmp} into the unit. Leaf functions
3069 might still call functions from other compilation units and thus they
3070 are not necessarily leaf in the sense that they contain no function
3073 The attribute is intended for library functions to improve dataflow
3074 analysis. The compiler takes the hint that any data not escaping the
3075 current compilation unit cannot be used or modified by the leaf
3076 function. For example, the @code{sin} function is a leaf function, but
3077 @code{qsort} is not.
3079 Note that leaf functions might indirectly run a signal handler defined
3080 in the current compilation unit that uses static variables. Similarly,
3081 when lazy symbol resolution is in effect, leaf functions might invoke
3082 indirect functions whose resolver function or implementation function is
3083 defined in the current compilation unit and uses static variables. There
3084 is no standard-compliant way to write such a signal handler, resolver
3085 function, or implementation function, and the best that you can do is to
3086 remove the @code{leaf} attribute or mark all such static variables
3087 @code{volatile}. Lastly, for ELF-based systems that support symbol
3088 interposition, care should be taken that functions defined in the
3089 current compilation unit do not unexpectedly interpose other symbols
3090 based on the defined standards mode and defined feature test macros;
3091 otherwise an inadvertent callback would be added.
3093 The attribute has no effect on functions defined within the current
3094 compilation unit. This is to allow easy merging of multiple compilation
3095 units into one, for example, by using the link-time optimization. For
3096 this reason the attribute is not allowed on types to annotate indirect
3100 @cindex @code{malloc} function attribute
3101 @cindex functions that behave like malloc
3102 This tells the compiler that a function is @code{malloc}-like, i.e.,
3103 that the pointer @var{P} returned by the function cannot alias any
3104 other pointer valid when the function returns, and moreover no
3105 pointers to valid objects occur in any storage addressed by @var{P}.
3107 Using this attribute can improve optimization. Compiler predicts
3108 that a function with the attribute returns non-null in most cases.
3110 @code{malloc} and @code{calloc} have this property because they return
3111 a pointer to uninitialized or zeroed-out storage. However, functions
3112 like @code{realloc} do not have this property, as they can return a
3113 pointer to storage containing pointers.
3116 @cindex @code{no_icf} function attribute
3117 This function attribute prevents a functions from being merged with another
3118 semantically equivalent function.
3120 @item no_instrument_function
3121 @cindex @code{no_instrument_function} function attribute
3122 @opindex finstrument-functions
3125 If any of @option{-finstrument-functions}, @option{-p}, or @option{-pg} are
3126 given, profiling function calls are
3127 generated at entry and exit of most user-compiled functions.
3128 Functions with this attribute are not so instrumented.
3130 @item no_profile_instrument_function
3131 @cindex @code{no_profile_instrument_function} function attribute
3132 The @code{no_profile_instrument_function} attribute on functions is used
3133 to inform the compiler that it should not process any profile feedback based
3134 optimization code instrumentation.
3137 @cindex @code{no_reorder} function attribute
3138 Do not reorder functions or variables marked @code{no_reorder}
3139 against each other or top level assembler statements the executable.
3140 The actual order in the program will depend on the linker command
3141 line. Static variables marked like this are also not removed.
3142 This has a similar effect
3143 as the @option{-fno-toplevel-reorder} option, but only applies to the
3146 @item no_sanitize ("@var{sanitize_option}")
3147 @cindex @code{no_sanitize} function attribute
3148 The @code{no_sanitize} attribute on functions is used
3149 to inform the compiler that it should not do sanitization of all options
3150 mentioned in @var{sanitize_option}. A list of values acceptable by
3151 @option{-fsanitize} option can be provided.
3154 void __attribute__ ((no_sanitize ("alignment", "object-size")))
3155 f () @{ /* @r{Do something.} */; @}
3156 void __attribute__ ((no_sanitize ("alignment,object-size")))
3157 g () @{ /* @r{Do something.} */; @}
3160 @item no_sanitize_address
3161 @itemx no_address_safety_analysis
3162 @cindex @code{no_sanitize_address} function attribute
3163 The @code{no_sanitize_address} attribute on functions is used
3164 to inform the compiler that it should not instrument memory accesses
3165 in the function when compiling with the @option{-fsanitize=address} option.
3166 The @code{no_address_safety_analysis} is a deprecated alias of the
3167 @code{no_sanitize_address} attribute, new code should use
3168 @code{no_sanitize_address}.
3170 @item no_sanitize_thread
3171 @cindex @code{no_sanitize_thread} function attribute
3172 The @code{no_sanitize_thread} attribute on functions is used
3173 to inform the compiler that it should not instrument memory accesses
3174 in the function when compiling with the @option{-fsanitize=thread} option.
3176 @item no_sanitize_undefined
3177 @cindex @code{no_sanitize_undefined} function attribute
3178 The @code{no_sanitize_undefined} attribute on functions is used
3179 to inform the compiler that it should not check for undefined behavior
3180 in the function when compiling with the @option{-fsanitize=undefined} option.
3182 @item no_split_stack
3183 @cindex @code{no_split_stack} function attribute
3184 @opindex fsplit-stack
3185 If @option{-fsplit-stack} is given, functions have a small
3186 prologue which decides whether to split the stack. Functions with the
3187 @code{no_split_stack} attribute do not have that prologue, and thus
3188 may run with only a small amount of stack space available.
3190 @item no_stack_limit
3191 @cindex @code{no_stack_limit} function attribute
3192 This attribute locally overrides the @option{-fstack-limit-register}
3193 and @option{-fstack-limit-symbol} command-line options; it has the effect
3194 of disabling stack limit checking in the function it applies to.
3197 @cindex @code{noclone} function attribute
3198 This function attribute prevents a function from being considered for
3199 cloning---a mechanism that produces specialized copies of functions
3200 and which is (currently) performed by interprocedural constant
3204 @cindex @code{noinline} function attribute
3205 This function attribute prevents a function from being considered for
3207 @c Don't enumerate the optimizations by name here; we try to be
3208 @c future-compatible with this mechanism.
3209 If the function does not have side effects, there are optimizations
3210 other than inlining that cause function calls to be optimized away,
3211 although the function call is live. To keep such calls from being
3218 (@pxref{Extended Asm}) in the called function, to serve as a special
3222 @cindex @code{noipa} function attribute
3223 Disable interprocedural optimizations between the function with this
3224 attribute and its callers, as if the body of the function is not available
3225 when optimizing callers and the callers are unavailable when optimizing
3226 the body. This attribute implies @code{noinline}, @code{noclone} and
3227 @code{no_icf} attributes. However, this attribute is not equivalent
3228 to a combination of other attributes, because its purpose is to suppress
3229 existing and future optimizations employing interprocedural analysis,
3230 including those that do not have an attribute suitable for disabling
3231 them individually. This attribute is supported mainly for the purpose
3232 of testing the compiler.
3235 @itemx nonnull (@var{arg-index}, @dots{})
3236 @cindex @code{nonnull} function attribute
3237 @cindex functions with non-null pointer arguments
3238 The @code{nonnull} attribute may be applied to a function that takes at
3239 least one argument of a pointer type. It indicates that the referenced
3240 arguments must be non-null pointers. For instance, the declaration:
3244 my_memcpy (void *dest, const void *src, size_t len)
3245 __attribute__((nonnull (1, 2)));
3249 causes the compiler to check that, in calls to @code{my_memcpy},
3250 arguments @var{dest} and @var{src} are non-null. If the compiler
3251 determines that a null pointer is passed in an argument slot marked
3252 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3253 is issued. @xref{Warning Options}. Unless disabled by
3254 the @option{-fno-delete-null-pointer-checks} option the compiler may
3255 also perform optimizations based on the knowledge that certain function
3256 arguments cannot be null. In addition,
3257 the @option{-fisolate-erroneous-paths-attribute} option can be specified
3258 to have GCC transform calls with null arguments to non-null functions
3259 into traps. @xref{Optimize Options}.
3261 If no @var{arg-index} is given to the @code{nonnull} attribute,
3262 all pointer arguments are marked as non-null. To illustrate, the
3263 following declaration is equivalent to the previous example:
3267 my_memcpy (void *dest, const void *src, size_t len)
3268 __attribute__((nonnull));
3272 @cindex @code{noplt} function attribute
3273 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3274 Calls to functions marked with this attribute in position-independent code
3279 /* Externally defined function foo. */
3280 int foo () __attribute__ ((noplt));
3283 main (/* @r{@dots{}} */)
3292 The @code{noplt} attribute on function @code{foo}
3293 tells the compiler to assume that
3294 the function @code{foo} is externally defined and that the call to
3295 @code{foo} must avoid the PLT
3296 in position-independent code.
3298 In position-dependent code, a few targets also convert calls to
3299 functions that are marked to not use the PLT to use the GOT instead.
3302 @cindex @code{noreturn} function attribute
3303 @cindex functions that never return
3304 A few standard library functions, such as @code{abort} and @code{exit},
3305 cannot return. GCC knows this automatically. Some programs define
3306 their own functions that never return. You can declare them
3307 @code{noreturn} to tell the compiler this fact. For example,
3311 void fatal () __attribute__ ((noreturn));
3314 fatal (/* @r{@dots{}} */)
3316 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3322 The @code{noreturn} keyword tells the compiler to assume that
3323 @code{fatal} cannot return. It can then optimize without regard to what
3324 would happen if @code{fatal} ever did return. This makes slightly
3325 better code. More importantly, it helps avoid spurious warnings of
3326 uninitialized variables.
3328 The @code{noreturn} keyword does not affect the exceptional path when that
3329 applies: a @code{noreturn}-marked function may still return to the caller
3330 by throwing an exception or calling @code{longjmp}.
3332 In order to preserve backtraces, GCC will never turn calls to
3333 @code{noreturn} functions into tail calls.
3335 Do not assume that registers saved by the calling function are
3336 restored before calling the @code{noreturn} function.
3338 It does not make sense for a @code{noreturn} function to have a return
3339 type other than @code{void}.
3342 @cindex @code{nothrow} function attribute
3343 The @code{nothrow} attribute is used to inform the compiler that a
3344 function cannot throw an exception. For example, most functions in
3345 the standard C library can be guaranteed not to throw an exception
3346 with the notable exceptions of @code{qsort} and @code{bsearch} that
3347 take function pointer arguments.
3349 @item optimize (@var{level}, @dots{})
3350 @item optimize (@var{string}, @dots{})
3351 @cindex @code{optimize} function attribute
3352 The @code{optimize} attribute is used to specify that a function is to
3353 be compiled with different optimization options than specified on the
3354 command line. Valid arguments are constant non-negative integers and
3355 strings. Each numeric argument specifies an optimization @var{level}.
3356 Each @var{string} argument consists of one or more comma-separated
3357 substrings. Each substring that begins with the letter @code{O} refers
3358 to an optimization option such as @option{-O0} or @option{-Os}. Other
3359 substrings are taken as suffixes to the @code{-f} prefix jointly
3360 forming the name of an optimization option. @xref{Optimize Options}.
3362 @samp{#pragma GCC optimize} can be used to set optimization options
3363 for more than one function. @xref{Function Specific Option Pragmas},
3364 for details about the pragma.
3366 Providing multiple strings as arguments separated by commas to specify
3367 multiple options is equivalent to separating the option suffixes with
3368 a comma (@samp{,}) within a single string. Spaces are not permitted
3371 Not every optimization option that starts with the @var{-f} prefix
3372 specified by the attribute necessarily has an effect on the function.
3373 The @code{optimize} attribute should be used for debugging purposes only.
3374 It is not suitable in production code.
3376 @item patchable_function_entry
3377 @cindex @code{patchable_function_entry} function attribute
3378 @cindex extra NOP instructions at the function entry point
3379 In case the target's text segment can be made writable at run time by
3380 any means, padding the function entry with a number of NOPs can be
3381 used to provide a universal tool for instrumentation.
3383 The @code{patchable_function_entry} function attribute can be used to
3384 change the number of NOPs to any desired value. The two-value syntax
3385 is the same as for the command-line switch
3386 @option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with
3387 the function entry point before the @var{M}th NOP instruction.
3388 @var{M} defaults to 0 if omitted e.g.@: function entry point is before
3391 If patchable function entries are enabled globally using the command-line
3392 option @option{-fpatchable-function-entry=N,M}, then you must disable
3393 instrumentation on all functions that are part of the instrumentation
3394 framework with the attribute @code{patchable_function_entry (0)}
3395 to prevent recursion.
3398 @cindex @code{pure} function attribute
3399 @cindex functions that have no side effects
3401 Calls to functions that have no observable effects on the state of
3402 the program other than to return a value may lend themselves to optimizations
3403 such as common subexpression elimination. Declaring such functions with
3404 the @code{pure} attribute allows GCC to avoid emitting some calls in repeated
3405 invocations of the function with the same argument values.
3407 The @code{pure} attribute prohibits a function from modifying the state
3408 of the program that is observable by means other than inspecting
3409 the function's return value. However, functions declared with the @code{pure}
3410 attribute can safely read any non-volatile objects, and modify the value of
3411 objects in a way that does not affect their return value or the observable
3412 state of the program.
3417 int hash (char *) __attribute__ ((pure));
3421 tells GCC that subsequent calls to the function @code{hash} with the same
3422 string can be replaced by the result of the first call provided the state
3423 of the program observable by @code{hash}, including the contents of the array
3424 itself, does not change in between. Even though @code{hash} takes a non-const
3425 pointer argument it must not modify the array it points to, or any other object
3426 whose value the rest of the program may depend on. However, the caller may
3427 safely change the contents of the array between successive calls to
3428 the function (doing so disables the optimization). The restriction also
3429 applies to member objects referenced by the @code{this} pointer in C++
3430 non-static member functions.
3432 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3433 Interesting non-pure functions are functions with infinite loops or those
3434 depending on volatile memory or other system resource, that may change between
3435 consecutive calls (such as the standard C @code{feof} function in
3436 a multithreading environment).
3438 The @code{pure} attribute imposes similar but looser restrictions on
3439 a function's definition than the @code{const} attribute: @code{pure}
3440 allows the function to read any non-volatile memory, even if it changes
3441 in between successive invocations of the function. Declaring the same
3442 function with both the @code{pure} and the @code{const} attribute is
3443 diagnosed. Because a pure function cannot have any observable side
3444 effects it does not make sense for such a function to return @code{void}.
3445 Declaring such a function is diagnosed.
3447 @item returns_nonnull
3448 @cindex @code{returns_nonnull} function attribute
3449 The @code{returns_nonnull} attribute specifies that the function
3450 return value should be a non-null pointer. For instance, the declaration:
3454 mymalloc (size_t len) __attribute__((returns_nonnull));
3458 lets the compiler optimize callers based on the knowledge
3459 that the return value will never be null.
3462 @cindex @code{returns_twice} function attribute
3463 @cindex functions that return more than once
3464 The @code{returns_twice} attribute tells the compiler that a function may
3465 return more than one time. The compiler ensures that all registers
3466 are dead before calling such a function and emits a warning about
3467 the variables that may be clobbered after the second return from the
3468 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3469 The @code{longjmp}-like counterpart of such function, if any, might need
3470 to be marked with the @code{noreturn} attribute.
3472 @item section ("@var{section-name}")
3473 @cindex @code{section} function attribute
3474 @cindex functions in arbitrary sections
3475 Normally, the compiler places the code it generates in the @code{text} section.
3476 Sometimes, however, you need additional sections, or you need certain
3477 particular functions to appear in special sections. The @code{section}
3478 attribute specifies that a function lives in a particular section.
3479 For example, the declaration:
3482 extern void foobar (void) __attribute__ ((section ("bar")));
3486 puts the function @code{foobar} in the @code{bar} section.
3488 Some file formats do not support arbitrary sections so the @code{section}
3489 attribute is not available on all platforms.
3490 If you need to map the entire contents of a module to a particular
3491 section, consider using the facilities of the linker instead.
3494 @itemx sentinel (@var{position})
3495 @cindex @code{sentinel} function attribute
3496 This function attribute indicates that an argument in a call to the function
3497 is expected to be an explicit @code{NULL}. The attribute is only valid on
3498 variadic functions. By default, the sentinel is expected to be the last
3499 argument of the function call. If the optional @var{position} argument
3500 is specified to the attribute, the sentinel must be located at
3501 @var{position} counting backwards from the end of the argument list.
3504 __attribute__ ((sentinel))
3506 __attribute__ ((sentinel(0)))
3509 The attribute is automatically set with a position of 0 for the built-in
3510 functions @code{execl} and @code{execlp}. The built-in function
3511 @code{execle} has the attribute set with a position of 1.
3513 A valid @code{NULL} in this context is defined as zero with any object
3514 pointer type. If your system defines the @code{NULL} macro with
3515 an integer type then you need to add an explicit cast. During
3516 installation GCC replaces the system @code{<stddef.h>} header with
3517 a copy that redefines NULL appropriately.
3519 The warnings for missing or incorrect sentinels are enabled with
3523 @itemx simd("@var{mask}")
3524 @cindex @code{simd} function attribute
3525 This attribute enables creation of one or more function versions that
3526 can process multiple arguments using SIMD instructions from a
3527 single invocation. Specifying this attribute allows compiler to
3528 assume that such versions are available at link time (provided
3529 in the same or another translation unit). Generated versions are
3530 target-dependent and described in the corresponding Vector ABI document. For
3531 x86_64 target this document can be found
3532 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3534 The optional argument @var{mask} may have the value
3535 @code{notinbranch} or @code{inbranch},
3536 and instructs the compiler to generate non-masked or masked
3537 clones correspondingly. By default, all clones are generated.
3539 If the attribute is specified and @code{#pragma omp declare simd} is
3540 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3541 switch is specified, then the attribute is ignored.
3544 @cindex @code{stack_protect} function attribute
3545 This attribute adds stack protection code to the function if
3546 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3547 or @option{-fstack-protector-explicit} are set.
3549 @item target (@var{string}, @dots{})
3550 @cindex @code{target} function attribute
3551 Multiple target back ends implement the @code{target} attribute
3552 to specify that a function is to
3553 be compiled with different target options than specified on the
3554 command line. One or more strings can be provided as arguments.
3555 Each string consists of one or more comma-separated suffixes to
3556 the @code{-m} prefix jointly forming the name of a machine-dependent
3557 option. @xref{Submodel Options,,Machine-Dependent Options}.
3559 The @code{target} attribute can be used for instance to have a function
3560 compiled with a different ISA (instruction set architecture) than the
3561 default. @samp{#pragma GCC target} can be used to specify target-specific
3562 options for more than one function. @xref{Function Specific Option Pragmas},
3563 for details about the pragma.
3565 For instance, on an x86, you could declare one function with the
3566 @code{target("sse4.1,arch=core2")} attribute and another with
3567 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3568 compiling the first function with @option{-msse4.1} and
3569 @option{-march=core2} options, and the second function with
3570 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3571 to make sure that a function is only invoked on a machine that
3572 supports the particular ISA it is compiled for (for example by using
3573 @code{cpuid} on x86 to determine what feature bits and architecture
3577 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3578 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3581 Providing multiple strings as arguments separated by commas to specify
3582 multiple options is equivalent to separating the option suffixes with
3583 a comma (@samp{,}) within a single string. Spaces are not permitted
3586 The options supported are specific to each target; refer to @ref{x86
3587 Function Attributes}, @ref{PowerPC Function Attributes},
3588 @ref{ARM Function Attributes}, @ref{AArch64 Function Attributes},
3589 @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
3592 @item target_clones (@var{options})
3593 @cindex @code{target_clones} function attribute
3594 The @code{target_clones} attribute is used to specify that a function
3595 be cloned into multiple versions compiled with different target options
3596 than specified on the command line. The supported options and restrictions
3597 are the same as for @code{target} attribute.
3599 For instance, on an x86, you could compile a function with
3600 @code{target_clones("sse4.1,avx")}. GCC creates two function clones,
3601 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3603 On a PowerPC, you can compile a function with
3604 @code{target_clones("cpu=power9,default")}. GCC will create two
3605 function clones, one compiled with @option{-mcpu=power9} and another
3606 with the default options. GCC must be configured to use GLIBC 2.23 or
3607 newer in order to use the @code{target_clones} attribute.
3609 It also creates a resolver function (see
3610 the @code{ifunc} attribute above) that dynamically selects a clone
3611 suitable for current architecture. The resolver is created only if there
3612 is a usage of a function with @code{target_clones} attribute.
3615 @cindex @code{unused} function attribute
3616 This attribute, attached to a function, means that the function is meant
3617 to be possibly unused. GCC does not produce a warning for this
3621 @cindex @code{used} function attribute
3622 This attribute, attached to a function, means that code must be emitted
3623 for the function even if it appears that the function is not referenced.
3624 This is useful, for example, when the function is referenced only in
3627 When applied to a member function of a C++ class template, the
3628 attribute also means that the function is instantiated if the
3629 class itself is instantiated.
3631 @item visibility ("@var{visibility_type}")
3632 @cindex @code{visibility} function attribute
3633 This attribute affects the linkage of the declaration to which it is attached.
3634 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3635 (@pxref{Common Type Attributes}) as well as functions.
3637 There are four supported @var{visibility_type} values: default,
3638 hidden, protected or internal visibility.
3641 void __attribute__ ((visibility ("protected")))
3642 f () @{ /* @r{Do something.} */; @}
3643 int i __attribute__ ((visibility ("hidden")));
3646 The possible values of @var{visibility_type} correspond to the
3647 visibility settings in the ELF gABI.
3650 @c keep this list of visibilities in alphabetical order.
3653 Default visibility is the normal case for the object file format.
3654 This value is available for the visibility attribute to override other
3655 options that may change the assumed visibility of entities.
3657 On ELF, default visibility means that the declaration is visible to other
3658 modules and, in shared libraries, means that the declared entity may be
3661 On Darwin, default visibility means that the declaration is visible to
3664 Default visibility corresponds to ``external linkage'' in the language.
3667 Hidden visibility indicates that the entity declared has a new
3668 form of linkage, which we call ``hidden linkage''. Two
3669 declarations of an object with hidden linkage refer to the same object
3670 if they are in the same shared object.
3673 Internal visibility is like hidden visibility, but with additional
3674 processor specific semantics. Unless otherwise specified by the
3675 psABI, GCC defines internal visibility to mean that a function is
3676 @emph{never} called from another module. Compare this with hidden
3677 functions which, while they cannot be referenced directly by other
3678 modules, can be referenced indirectly via function pointers. By
3679 indicating that a function cannot be called from outside the module,
3680 GCC may for instance omit the load of a PIC register since it is known
3681 that the calling function loaded the correct value.
3684 Protected visibility is like default visibility except that it
3685 indicates that references within the defining module bind to the
3686 definition in that module. That is, the declared entity cannot be
3687 overridden by another module.
3691 All visibilities are supported on many, but not all, ELF targets
3692 (supported when the assembler supports the @samp{.visibility}
3693 pseudo-op). Default visibility is supported everywhere. Hidden
3694 visibility is supported on Darwin targets.
3696 The visibility attribute should be applied only to declarations that
3697 would otherwise have external linkage. The attribute should be applied
3698 consistently, so that the same entity should not be declared with
3699 different settings of the attribute.
3701 In C++, the visibility attribute applies to types as well as functions
3702 and objects, because in C++ types have linkage. A class must not have
3703 greater visibility than its non-static data member types and bases,
3704 and class members default to the visibility of their class. Also, a
3705 declaration without explicit visibility is limited to the visibility
3708 In C++, you can mark member functions and static member variables of a
3709 class with the visibility attribute. This is useful if you know a
3710 particular method or static member variable should only be used from
3711 one shared object; then you can mark it hidden while the rest of the
3712 class has default visibility. Care must be taken to avoid breaking
3713 the One Definition Rule; for example, it is usually not useful to mark
3714 an inline method as hidden without marking the whole class as hidden.
3716 A C++ namespace declaration can also have the visibility attribute.
3719 namespace nspace1 __attribute__ ((visibility ("protected")))
3720 @{ /* @r{Do something.} */; @}
3723 This attribute applies only to the particular namespace body, not to
3724 other definitions of the same namespace; it is equivalent to using
3725 @samp{#pragma GCC visibility} before and after the namespace
3726 definition (@pxref{Visibility Pragmas}).
3728 In C++, if a template argument has limited visibility, this
3729 restriction is implicitly propagated to the template instantiation.
3730 Otherwise, template instantiations and specializations default to the
3731 visibility of their template.
3733 If both the template and enclosing class have explicit visibility, the
3734 visibility from the template is used.
3736 @item warn_unused_result
3737 @cindex @code{warn_unused_result} function attribute
3738 The @code{warn_unused_result} attribute causes a warning to be emitted
3739 if a caller of the function with this attribute does not use its
3740 return value. This is useful for functions where not checking
3741 the result is either a security problem or always a bug, such as
3745 int fn () __attribute__ ((warn_unused_result));
3748 if (fn () < 0) return -1;
3755 results in warning on line 5.
3758 @cindex @code{weak} function attribute
3759 The @code{weak} attribute causes the declaration to be emitted as a weak
3760 symbol rather than a global. This is primarily useful in defining
3761 library functions that can be overridden in user code, though it can
3762 also be used with non-function declarations. Weak symbols are supported
3763 for ELF targets, and also for a.out targets when using the GNU assembler
3767 @itemx weakref ("@var{target}")
3768 @cindex @code{weakref} function attribute
3769 The @code{weakref} attribute marks a declaration as a weak reference.
3770 Without arguments, it should be accompanied by an @code{alias} attribute
3771 naming the target symbol. Optionally, the @var{target} may be given as
3772 an argument to @code{weakref} itself. In either case, @code{weakref}
3773 implicitly marks the declaration as @code{weak}. Without a
3774 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3775 @code{weakref} is equivalent to @code{weak}.
3778 static int x() __attribute__ ((weakref ("y")));
3779 /* is equivalent to... */
3780 static int x() __attribute__ ((weak, weakref, alias ("y")));
3782 static int x() __attribute__ ((weakref));
3783 static int x() __attribute__ ((alias ("y")));
3786 A weak reference is an alias that does not by itself require a
3787 definition to be given for the target symbol. If the target symbol is
3788 only referenced through weak references, then it becomes a @code{weak}
3789 undefined symbol. If it is directly referenced, however, then such
3790 strong references prevail, and a definition is required for the
3791 symbol, not necessarily in the same translation unit.
3793 The effect is equivalent to moving all references to the alias to a
3794 separate translation unit, renaming the alias to the aliased symbol,
3795 declaring it as weak, compiling the two separate translation units and
3796 performing a link with relocatable output (ie: @code{ld -r}) on them.
3798 At present, a declaration to which @code{weakref} is attached can
3799 only be @code{static}.
3804 @c This is the end of the target-independent attribute table
3806 @node AArch64 Function Attributes
3807 @subsection AArch64 Function Attributes
3809 The following target-specific function attributes are available for the
3810 AArch64 target. For the most part, these options mirror the behavior of
3811 similar command-line options (@pxref{AArch64 Options}), but on a
3815 @item general-regs-only
3816 @cindex @code{general-regs-only} function attribute, AArch64
3817 Indicates that no floating-point or Advanced SIMD registers should be
3818 used when generating code for this function. If the function explicitly
3819 uses floating-point code, then the compiler gives an error. This is
3820 the same behavior as that of the command-line option
3821 @option{-mgeneral-regs-only}.
3823 @item fix-cortex-a53-835769
3824 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3825 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3826 applied to this function. To explicitly disable the workaround for this
3827 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3828 This corresponds to the behavior of the command line options
3829 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3832 @cindex @code{cmodel=} function attribute, AArch64
3833 Indicates that code should be generated for a particular code model for
3834 this function. The behavior and permissible arguments are the same as
3835 for the command line option @option{-mcmodel=}.
3838 @itemx no-strict-align
3839 @cindex @code{strict-align} function attribute, AArch64
3840 @code{strict-align} indicates that the compiler should not assume that unaligned
3841 memory references are handled by the system. To allow the compiler to assume
3842 that aligned memory references are handled by the system, the inverse attribute
3843 @code{no-strict-align} can be specified. The behavior is same as for the
3844 command-line option @option{-mstrict-align} and @option{-mno-strict-align}.
3846 @item omit-leaf-frame-pointer
3847 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3848 Indicates that the frame pointer should be omitted for a leaf function call.
3849 To keep the frame pointer, the inverse attribute
3850 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3851 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3852 and @option{-mno-omit-leaf-frame-pointer}.
3855 @cindex @code{tls-dialect=} function attribute, AArch64
3856 Specifies the TLS dialect to use for this function. The behavior and
3857 permissible arguments are the same as for the command-line option
3858 @option{-mtls-dialect=}.
3861 @cindex @code{arch=} function attribute, AArch64
3862 Specifies the architecture version and architectural extensions to use
3863 for this function. The behavior and permissible arguments are the same as
3864 for the @option{-march=} command-line option.
3867 @cindex @code{tune=} function attribute, AArch64
3868 Specifies the core for which to tune the performance of this function.
3869 The behavior and permissible arguments are the same as for the @option{-mtune=}
3870 command-line option.
3873 @cindex @code{cpu=} function attribute, AArch64
3874 Specifies the core for which to tune the performance of this function and also
3875 whose architectural features to use. The behavior and valid arguments are the
3876 same as for the @option{-mcpu=} command-line option.
3878 @item sign-return-address
3879 @cindex @code{sign-return-address} function attribute, AArch64
3880 Select the function scope on which return address signing will be applied. The
3881 behavior and permissible arguments are the same as for the command-line option
3882 @option{-msign-return-address=}. The default value is @code{none}.
3886 The above target attributes can be specified as follows:
3889 __attribute__((target("@var{attr-string}")))
3897 where @code{@var{attr-string}} is one of the attribute strings specified above.
3899 Additionally, the architectural extension string may be specified on its
3900 own. This can be used to turn on and off particular architectural extensions
3901 without having to specify a particular architecture version or core. Example:
3904 __attribute__((target("+crc+nocrypto")))
3912 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3913 extension and disables the @code{crypto} extension for the function @code{foo}
3914 without modifying an existing @option{-march=} or @option{-mcpu} option.
3916 Multiple target function attributes can be specified by separating them with
3917 a comma. For example:
3919 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3927 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3928 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3930 @subsubsection Inlining rules
3931 Specifying target attributes on individual functions or performing link-time
3932 optimization across translation units compiled with different target options
3933 can affect function inlining rules:
3935 In particular, a caller function can inline a callee function only if the
3936 architectural features available to the callee are a subset of the features
3937 available to the caller.
3938 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3939 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3940 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3941 because the all the architectural features that function @code{bar} requires
3942 are available to function @code{foo}. Conversely, function @code{bar} cannot
3943 inline function @code{foo}.
3945 Additionally inlining a function compiled with @option{-mstrict-align} into a
3946 function compiled without @code{-mstrict-align} is not allowed.
3947 However, inlining a function compiled without @option{-mstrict-align} into a
3948 function compiled with @option{-mstrict-align} is allowed.
3950 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3951 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3952 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3953 architectural feature rules specified above.
3955 @node ARC Function Attributes
3956 @subsection ARC Function Attributes
3958 These function attributes are supported by the ARC back end:
3962 @cindex @code{interrupt} function attribute, ARC
3963 Use this attribute to indicate
3964 that the specified function is an interrupt handler. The compiler generates
3965 function entry and exit sequences suitable for use in an interrupt handler
3966 when this attribute is present.
3968 On the ARC, you must specify the kind of interrupt to be handled
3969 in a parameter to the interrupt attribute like this:
3972 void f () __attribute__ ((interrupt ("ilink1")));
3975 Permissible values for this parameter are: @w{@code{ilink1}} and
3981 @cindex @code{long_call} function attribute, ARC
3982 @cindex @code{medium_call} function attribute, ARC
3983 @cindex @code{short_call} function attribute, ARC
3984 @cindex indirect calls, ARC
3985 These attributes specify how a particular function is called.
3986 These attributes override the
3987 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3988 command-line switches and @code{#pragma long_calls} settings.
3990 For ARC, a function marked with the @code{long_call} attribute is
3991 always called using register-indirect jump-and-link instructions,
3992 thereby enabling the called function to be placed anywhere within the
3993 32-bit address space. A function marked with the @code{medium_call}
3994 attribute will always be close enough to be called with an unconditional
3995 branch-and-link instruction, which has a 25-bit offset from
3996 the call site. A function marked with the @code{short_call}
3997 attribute will always be close enough to be called with a conditional
3998 branch-and-link instruction, which has a 21-bit offset from
4002 @cindex @code{jli_always} function attribute, ARC
4003 Forces a particular function to be called using @code{jli}
4004 instruction. The @code{jli} instruction makes use of a table stored
4005 into @code{.jlitab} section, which holds the location of the functions
4006 which are addressed using this instruction.
4009 @cindex @code{jli_fixed} function attribute, ARC
4010 Identical like the above one, but the location of the function in the
4011 @code{jli} table is known and given as an attribute parameter.
4014 @cindex @code{secure_call} function attribute, ARC
4015 This attribute allows one to mark secure-code functions that are
4016 callable from normal mode. The location of the secure call function
4017 into the @code{sjli} table needs to be passed as argument.
4021 @node ARM Function Attributes
4022 @subsection ARM Function Attributes
4024 These function attributes are supported for ARM targets:
4028 @cindex @code{interrupt} function attribute, ARM
4029 Use this attribute to indicate
4030 that the specified function is an interrupt handler. The compiler generates
4031 function entry and exit sequences suitable for use in an interrupt handler
4032 when this attribute is present.
4034 You can specify the kind of interrupt to be handled by
4035 adding an optional parameter to the interrupt attribute like this:
4038 void f () __attribute__ ((interrupt ("IRQ")));
4042 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
4043 @code{SWI}, @code{ABORT} and @code{UNDEF}.
4045 On ARMv7-M the interrupt type is ignored, and the attribute means the function
4046 may be called with a word-aligned stack pointer.
4049 @cindex @code{isr} function attribute, ARM
4050 Use this attribute on ARM to write Interrupt Service Routines. This is an
4051 alias to the @code{interrupt} attribute above.
4055 @cindex @code{long_call} function attribute, ARM
4056 @cindex @code{short_call} function attribute, ARM
4057 @cindex indirect calls, ARM
4058 These attributes specify how a particular function is called.
4059 These attributes override the
4060 @option{-mlong-calls} (@pxref{ARM Options})
4061 command-line switch and @code{#pragma long_calls} settings. For ARM, the
4062 @code{long_call} attribute indicates that the function might be far
4063 away from the call site and require a different (more expensive)
4064 calling sequence. The @code{short_call} attribute always places
4065 the offset to the function from the call site into the @samp{BL}
4066 instruction directly.
4069 @cindex @code{naked} function attribute, ARM
4070 This attribute allows the compiler to construct the
4071 requisite function declaration, while allowing the body of the
4072 function to be assembly code. The specified function will not have
4073 prologue/epilogue sequences generated by the compiler. Only basic
4074 @code{asm} statements can safely be included in naked functions
4075 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4076 basic @code{asm} and C code may appear to work, they cannot be
4077 depended upon to work reliably and are not supported.
4080 @cindex @code{pcs} function attribute, ARM
4082 The @code{pcs} attribute can be used to control the calling convention
4083 used for a function on ARM. The attribute takes an argument that specifies
4084 the calling convention to use.
4086 When compiling using the AAPCS ABI (or a variant of it) then valid
4087 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
4088 order to use a variant other than @code{"aapcs"} then the compiler must
4089 be permitted to use the appropriate co-processor registers (i.e., the
4090 VFP registers must be available in order to use @code{"aapcs-vfp"}).
4094 /* Argument passed in r0, and result returned in r0+r1. */
4095 double f2d (float) __attribute__((pcs("aapcs")));
4098 Variadic functions always use the @code{"aapcs"} calling convention and
4099 the compiler rejects attempts to specify an alternative.
4101 @item target (@var{options})
4102 @cindex @code{target} function attribute
4103 As discussed in @ref{Common Function Attributes}, this attribute
4104 allows specification of target-specific compilation options.
4106 On ARM, the following options are allowed:
4110 @cindex @code{target("thumb")} function attribute, ARM
4111 Force code generation in the Thumb (T16/T32) ISA, depending on the
4115 @cindex @code{target("arm")} function attribute, ARM
4116 Force code generation in the ARM (A32) ISA.
4118 Functions from different modes can be inlined in the caller's mode.
4121 @cindex @code{target("fpu=")} function attribute, ARM
4122 Specifies the fpu for which to tune the performance of this function.
4123 The behavior and permissible arguments are the same as for the @option{-mfpu=}
4124 command-line option.
4127 @cindex @code{arch=} function attribute, ARM
4128 Specifies the architecture version and architectural extensions to use
4129 for this function. The behavior and permissible arguments are the same as
4130 for the @option{-march=} command-line option.
4132 The above target attributes can be specified as follows:
4135 __attribute__((target("arch=armv8-a+crc")))
4143 Additionally, the architectural extension string may be specified on its
4144 own. This can be used to turn on and off particular architectural extensions
4145 without having to specify a particular architecture version or core. Example:
4148 __attribute__((target("+crc+nocrypto")))
4156 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
4157 extension and disables the @code{crypto} extension for the function @code{foo}
4158 without modifying an existing @option{-march=} or @option{-mcpu} option.
4164 @node AVR Function Attributes
4165 @subsection AVR Function Attributes
4167 These function attributes are supported by the AVR back end:
4171 @cindex @code{interrupt} function attribute, AVR
4172 Use this attribute to indicate
4173 that the specified function is an interrupt handler. The compiler generates
4174 function entry and exit sequences suitable for use in an interrupt handler
4175 when this attribute is present.
4177 On the AVR, the hardware globally disables interrupts when an
4178 interrupt is executed. The first instruction of an interrupt handler
4179 declared with this attribute is a @code{SEI} instruction to
4180 re-enable interrupts. See also the @code{signal} function attribute
4181 that does not insert a @code{SEI} instruction. If both @code{signal} and
4182 @code{interrupt} are specified for the same function, @code{signal}
4183 is silently ignored.
4186 @cindex @code{naked} function attribute, AVR
4187 This attribute allows the compiler to construct the
4188 requisite function declaration, while allowing the body of the
4189 function to be assembly code. The specified function will not have
4190 prologue/epilogue sequences generated by the compiler. Only basic
4191 @code{asm} statements can safely be included in naked functions
4192 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4193 basic @code{asm} and C code may appear to work, they cannot be
4194 depended upon to work reliably and are not supported.
4197 @cindex @code{no_gccisr} function attribute, AVR
4198 Do not use @code{__gcc_isr} pseudo instructions in a function with
4199 the @code{interrupt} or @code{signal} attribute aka. interrupt
4200 service routine (ISR).
4201 Use this attribute if the preamble of the ISR prologue should always read
4205 in __tmp_reg__, __SREG__
4209 and accordingly for the postamble of the epilogue --- no matter whether
4210 the mentioned registers are actually used in the ISR or not.
4211 Situations where you might want to use this attribute include:
4214 Code that (effectively) clobbers bits of @code{SREG} other than the
4215 @code{I}-flag by writing to the memory location of @code{SREG}.
4217 Code that uses inline assembler to jump to a different function which
4218 expects (parts of) the prologue code as outlined above to be present.
4220 To disable @code{__gcc_isr} generation for the whole compilation unit,
4221 there is option @option{-mno-gas-isr-prologues}, @pxref{AVR Options}.
4225 @cindex @code{OS_main} function attribute, AVR
4226 @cindex @code{OS_task} function attribute, AVR
4227 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
4228 do not save/restore any call-saved register in their prologue/epilogue.
4230 The @code{OS_main} attribute can be used when there @emph{is
4231 guarantee} that interrupts are disabled at the time when the function
4232 is entered. This saves resources when the stack pointer has to be
4233 changed to set up a frame for local variables.
4235 The @code{OS_task} attribute can be used when there is @emph{no
4236 guarantee} that interrupts are disabled at that time when the function
4237 is entered like for, e@.g@. task functions in a multi-threading operating
4238 system. In that case, changing the stack pointer register is
4239 guarded by save/clear/restore of the global interrupt enable flag.
4241 The differences to the @code{naked} function attribute are:
4243 @item @code{naked} functions do not have a return instruction whereas
4244 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
4245 @code{RETI} return instruction.
4246 @item @code{naked} functions do not set up a frame for local variables
4247 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
4252 @cindex @code{signal} function attribute, AVR
4253 Use this attribute on the AVR to indicate that the specified
4254 function is an interrupt handler. The compiler generates function
4255 entry and exit sequences suitable for use in an interrupt handler when this
4256 attribute is present.
4258 See also the @code{interrupt} function attribute.
4260 The AVR hardware globally disables interrupts when an interrupt is executed.
4261 Interrupt handler functions defined with the @code{signal} attribute
4262 do not re-enable interrupts. It is save to enable interrupts in a
4263 @code{signal} handler. This ``save'' only applies to the code
4264 generated by the compiler and not to the IRQ layout of the
4265 application which is responsibility of the application.
4267 If both @code{signal} and @code{interrupt} are specified for the same
4268 function, @code{signal} is silently ignored.
4271 @node Blackfin Function Attributes
4272 @subsection Blackfin Function Attributes
4274 These function attributes are supported by the Blackfin back end:
4278 @item exception_handler
4279 @cindex @code{exception_handler} function attribute
4280 @cindex exception handler functions, Blackfin
4281 Use this attribute on the Blackfin to indicate that the specified function
4282 is an exception handler. The compiler generates function entry and
4283 exit sequences suitable for use in an exception handler when this
4284 attribute is present.
4286 @item interrupt_handler
4287 @cindex @code{interrupt_handler} function attribute, Blackfin
4288 Use this attribute to
4289 indicate that the specified function is an interrupt handler. The compiler
4290 generates function entry and exit sequences suitable for use in an
4291 interrupt handler when this attribute is present.
4294 @cindex @code{kspisusp} function attribute, Blackfin
4295 @cindex User stack pointer in interrupts on the Blackfin
4296 When used together with @code{interrupt_handler}, @code{exception_handler}
4297 or @code{nmi_handler}, code is generated to load the stack pointer
4298 from the USP register in the function prologue.
4301 @cindex @code{l1_text} function attribute, Blackfin
4302 This attribute specifies a function to be placed into L1 Instruction
4303 SRAM@. The function is put into a specific section named @code{.l1.text}.
4304 With @option{-mfdpic}, function calls with a such function as the callee
4305 or caller uses inlined PLT.
4308 @cindex @code{l2} function attribute, Blackfin
4309 This attribute specifies a function to be placed into L2
4310 SRAM. The function is put into a specific section named
4311 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
4316 @cindex indirect calls, Blackfin
4317 @cindex @code{longcall} function attribute, Blackfin
4318 @cindex @code{shortcall} function attribute, Blackfin
4319 The @code{longcall} attribute
4320 indicates that the function might be far away from the call site and
4321 require a different (more expensive) calling sequence. The
4322 @code{shortcall} attribute indicates that the function is always close
4323 enough for the shorter calling sequence to be used. These attributes
4324 override the @option{-mlongcall} switch.
4327 @cindex @code{nesting} function attribute, Blackfin
4328 @cindex Allow nesting in an interrupt handler on the Blackfin processor
4329 Use this attribute together with @code{interrupt_handler},
4330 @code{exception_handler} or @code{nmi_handler} to indicate that the function
4331 entry code should enable nested interrupts or exceptions.
4334 @cindex @code{nmi_handler} function attribute, Blackfin
4335 @cindex NMI handler functions on the Blackfin processor
4336 Use this attribute on the Blackfin to indicate that the specified function
4337 is an NMI handler. The compiler generates function entry and
4338 exit sequences suitable for use in an NMI handler when this
4339 attribute is present.
4342 @cindex @code{saveall} function attribute, Blackfin
4343 @cindex save all registers on the Blackfin
4344 Use this attribute to indicate that
4345 all registers except the stack pointer should be saved in the prologue
4346 regardless of whether they are used or not.
4349 @node CR16 Function Attributes
4350 @subsection CR16 Function Attributes
4352 These function attributes are supported by the CR16 back end:
4356 @cindex @code{interrupt} function attribute, CR16
4357 Use this attribute to indicate
4358 that the specified function is an interrupt handler. The compiler generates
4359 function entry and exit sequences suitable for use in an interrupt handler
4360 when this attribute is present.
4363 @node C-SKY Function Attributes
4364 @subsection C-SKY Function Attributes
4366 These function attributes are supported by the C-SKY back end:
4371 @cindex @code{interrupt} function attribute, C-SKY
4372 @cindex @code{isr} function attribute, C-SKY
4373 Use these attributes to indicate that the specified function
4374 is an interrupt handler.
4375 The compiler generates function entry and exit sequences suitable for
4376 use in an interrupt handler when either of these attributes are present.
4378 Use of these options requires the @option{-mistack} command-line option
4379 to enable support for the necessary interrupt stack instructions. They
4380 are ignored with a warning otherwise. @xref{C-SKY Options}.
4383 @cindex @code{naked} function attribute, C-SKY
4384 This attribute allows the compiler to construct the
4385 requisite function declaration, while allowing the body of the
4386 function to be assembly code. The specified function will not have
4387 prologue/epilogue sequences generated by the compiler. Only basic
4388 @code{asm} statements can safely be included in naked functions
4389 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4390 basic @code{asm} and C code may appear to work, they cannot be
4391 depended upon to work reliably and are not supported.
4395 @node Epiphany Function Attributes
4396 @subsection Epiphany Function Attributes
4398 These function attributes are supported by the Epiphany back end:
4402 @cindex @code{disinterrupt} function attribute, Epiphany
4403 This attribute causes the compiler to emit
4404 instructions to disable interrupts for the duration of the given
4407 @item forwarder_section
4408 @cindex @code{forwarder_section} function attribute, Epiphany
4409 This attribute modifies the behavior of an interrupt handler.
4410 The interrupt handler may be in external memory which cannot be
4411 reached by a branch instruction, so generate a local memory trampoline
4412 to transfer control. The single parameter identifies the section where
4413 the trampoline is placed.
4416 @cindex @code{interrupt} function attribute, Epiphany
4417 Use this attribute to indicate
4418 that the specified function is an interrupt handler. The compiler generates
4419 function entry and exit sequences suitable for use in an interrupt handler
4420 when this attribute is present. It may also generate
4421 a special section with code to initialize the interrupt vector table.
4423 On Epiphany targets one or more optional parameters can be added like this:
4426 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
4429 Permissible values for these parameters are: @w{@code{reset}},
4430 @w{@code{software_exception}}, @w{@code{page_miss}},
4431 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
4432 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
4433 Multiple parameters indicate that multiple entries in the interrupt
4434 vector table should be initialized for this function, i.e.@: for each
4435 parameter @w{@var{name}}, a jump to the function is emitted in
4436 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
4437 entirely, in which case no interrupt vector table entry is provided.
4439 Note that interrupts are enabled inside the function
4440 unless the @code{disinterrupt} attribute is also specified.
4442 The following examples are all valid uses of these attributes on
4445 void __attribute__ ((interrupt)) universal_handler ();
4446 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
4447 void __attribute__ ((interrupt ("dma0, dma1")))
4448 universal_dma_handler ();
4449 void __attribute__ ((interrupt ("timer0"), disinterrupt))
4450 fast_timer_handler ();
4451 void __attribute__ ((interrupt ("dma0, dma1"),
4452 forwarder_section ("tramp")))
4453 external_dma_handler ();
4458 @cindex @code{long_call} function attribute, Epiphany
4459 @cindex @code{short_call} function attribute, Epiphany
4460 @cindex indirect calls, Epiphany
4461 These attributes specify how a particular function is called.
4462 These attributes override the
4463 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4464 command-line switch and @code{#pragma long_calls} settings.
4468 @node H8/300 Function Attributes
4469 @subsection H8/300 Function Attributes
4471 These function attributes are available for H8/300 targets:
4474 @item function_vector
4475 @cindex @code{function_vector} function attribute, H8/300
4476 Use this attribute on the H8/300, H8/300H, and H8S to indicate
4477 that the specified function should be called through the function vector.
4478 Calling a function through the function vector reduces code size; however,
4479 the function vector has a limited size (maximum 128 entries on the H8/300
4480 and 64 entries on the H8/300H and H8S)
4481 and shares space with the interrupt vector.
4483 @item interrupt_handler
4484 @cindex @code{interrupt_handler} function attribute, H8/300
4485 Use this attribute on the H8/300, H8/300H, and H8S to
4486 indicate that the specified function is an interrupt handler. The compiler
4487 generates function entry and exit sequences suitable for use in an
4488 interrupt handler when this attribute is present.
4491 @cindex @code{saveall} function attribute, H8/300
4492 @cindex save all registers on the H8/300, H8/300H, and H8S
4493 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4494 all registers except the stack pointer should be saved in the prologue
4495 regardless of whether they are used or not.
4498 @node IA-64 Function Attributes
4499 @subsection IA-64 Function Attributes
4501 These function attributes are supported on IA-64 targets:
4504 @item syscall_linkage
4505 @cindex @code{syscall_linkage} function attribute, IA-64
4506 This attribute is used to modify the IA-64 calling convention by marking
4507 all input registers as live at all function exits. This makes it possible
4508 to restart a system call after an interrupt without having to save/restore
4509 the input registers. This also prevents kernel data from leaking into
4513 @cindex @code{version_id} function attribute, IA-64
4514 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4515 symbol to contain a version string, thus allowing for function level
4516 versioning. HP-UX system header files may use function level versioning
4517 for some system calls.
4520 extern int foo () __attribute__((version_id ("20040821")));
4524 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4527 @node M32C Function Attributes
4528 @subsection M32C Function Attributes
4530 These function attributes are supported by the M32C back end:
4534 @cindex @code{bank_switch} function attribute, M32C
4535 When added to an interrupt handler with the M32C port, causes the
4536 prologue and epilogue to use bank switching to preserve the registers
4537 rather than saving them on the stack.
4539 @item fast_interrupt
4540 @cindex @code{fast_interrupt} function attribute, M32C
4541 Use this attribute on the M32C port to indicate that the specified
4542 function is a fast interrupt handler. This is just like the
4543 @code{interrupt} attribute, except that @code{freit} is used to return
4544 instead of @code{reit}.
4546 @item function_vector
4547 @cindex @code{function_vector} function attribute, M16C/M32C
4548 On M16C/M32C targets, the @code{function_vector} attribute declares a
4549 special page subroutine call function. Use of this attribute reduces
4550 the code size by 2 bytes for each call generated to the
4551 subroutine. The argument to the attribute is the vector number entry
4552 from the special page vector table which contains the 16 low-order
4553 bits of the subroutine's entry address. Each vector table has special
4554 page number (18 to 255) that is used in @code{jsrs} instructions.
4555 Jump addresses of the routines are generated by adding 0x0F0000 (in
4556 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4557 2-byte addresses set in the vector table. Therefore you need to ensure
4558 that all the special page vector routines should get mapped within the
4559 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4562 In the following example 2 bytes are saved for each call to
4563 function @code{foo}.
4566 void foo (void) __attribute__((function_vector(0x18)));
4577 If functions are defined in one file and are called in another file,
4578 then be sure to write this declaration in both files.
4580 This attribute is ignored for R8C target.
4583 @cindex @code{interrupt} function attribute, M32C
4584 Use this attribute to indicate
4585 that the specified function is an interrupt handler. The compiler generates
4586 function entry and exit sequences suitable for use in an interrupt handler
4587 when this attribute is present.
4590 @node M32R/D Function Attributes
4591 @subsection M32R/D Function Attributes
4593 These function attributes are supported by the M32R/D back end:
4597 @cindex @code{interrupt} function attribute, M32R/D
4598 Use this attribute to indicate
4599 that the specified function is an interrupt handler. The compiler generates
4600 function entry and exit sequences suitable for use in an interrupt handler
4601 when this attribute is present.
4603 @item model (@var{model-name})
4604 @cindex @code{model} function attribute, M32R/D
4605 @cindex function addressability on the M32R/D
4607 On the M32R/D, use this attribute to set the addressability of an
4608 object, and of the code generated for a function. The identifier
4609 @var{model-name} is one of @code{small}, @code{medium}, or
4610 @code{large}, representing each of the code models.
4612 Small model objects live in the lower 16MB of memory (so that their
4613 addresses can be loaded with the @code{ld24} instruction), and are
4614 callable with the @code{bl} instruction.
4616 Medium model objects may live anywhere in the 32-bit address space (the
4617 compiler generates @code{seth/add3} instructions to load their addresses),
4618 and are callable with the @code{bl} instruction.
4620 Large model objects may live anywhere in the 32-bit address space (the
4621 compiler generates @code{seth/add3} instructions to load their addresses),
4622 and may not be reachable with the @code{bl} instruction (the compiler
4623 generates the much slower @code{seth/add3/jl} instruction sequence).
4626 @node m68k Function Attributes
4627 @subsection m68k Function Attributes
4629 These function attributes are supported by the m68k back end:
4633 @itemx interrupt_handler
4634 @cindex @code{interrupt} function attribute, m68k
4635 @cindex @code{interrupt_handler} function attribute, m68k
4636 Use this attribute to
4637 indicate that the specified function is an interrupt handler. The compiler
4638 generates function entry and exit sequences suitable for use in an
4639 interrupt handler when this attribute is present. Either name may be used.
4641 @item interrupt_thread
4642 @cindex @code{interrupt_thread} function attribute, fido
4643 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4644 that the specified function is an interrupt handler that is designed
4645 to run as a thread. The compiler omits generate prologue/epilogue
4646 sequences and replaces the return instruction with a @code{sleep}
4647 instruction. This attribute is available only on fido.
4650 @node MCORE Function Attributes
4651 @subsection MCORE Function Attributes
4653 These function attributes are supported by the MCORE back end:
4657 @cindex @code{naked} function attribute, MCORE
4658 This attribute allows the compiler to construct the
4659 requisite function declaration, while allowing the body of the
4660 function to be assembly code. The specified function will not have
4661 prologue/epilogue sequences generated by the compiler. Only basic
4662 @code{asm} statements can safely be included in naked functions
4663 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4664 basic @code{asm} and C code may appear to work, they cannot be
4665 depended upon to work reliably and are not supported.
4668 @node MeP Function Attributes
4669 @subsection MeP Function Attributes
4671 These function attributes are supported by the MeP back end:
4675 @cindex @code{disinterrupt} function attribute, MeP
4676 On MeP targets, this attribute causes the compiler to emit
4677 instructions to disable interrupts for the duration of the given
4681 @cindex @code{interrupt} function attribute, MeP
4682 Use this attribute to indicate
4683 that the specified function is an interrupt handler. The compiler generates
4684 function entry and exit sequences suitable for use in an interrupt handler
4685 when this attribute is present.
4688 @cindex @code{near} function attribute, MeP
4689 This attribute causes the compiler to assume the called
4690 function is close enough to use the normal calling convention,
4691 overriding the @option{-mtf} command-line option.
4694 @cindex @code{far} function attribute, MeP
4695 On MeP targets this causes the compiler to use a calling convention
4696 that assumes the called function is too far away for the built-in
4700 @cindex @code{vliw} function attribute, MeP
4701 The @code{vliw} attribute tells the compiler to emit
4702 instructions in VLIW mode instead of core mode. Note that this
4703 attribute is not allowed unless a VLIW coprocessor has been configured
4704 and enabled through command-line options.
4707 @node MicroBlaze Function Attributes
4708 @subsection MicroBlaze Function Attributes
4710 These function attributes are supported on MicroBlaze targets:
4713 @item save_volatiles
4714 @cindex @code{save_volatiles} function attribute, MicroBlaze
4715 Use this attribute to indicate that the function is
4716 an interrupt handler. All volatile registers (in addition to non-volatile
4717 registers) are saved in the function prologue. If the function is a leaf
4718 function, only volatiles used by the function are saved. A normal function
4719 return is generated instead of a return from interrupt.
4722 @cindex @code{break_handler} function attribute, MicroBlaze
4723 @cindex break handler functions
4724 Use this attribute to indicate that
4725 the specified function is a break handler. The compiler generates function
4726 entry and exit sequences suitable for use in an break handler when this
4727 attribute is present. The return from @code{break_handler} is done through
4728 the @code{rtbd} instead of @code{rtsd}.
4731 void f () __attribute__ ((break_handler));
4734 @item interrupt_handler
4735 @itemx fast_interrupt
4736 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4737 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4738 These attributes indicate that the specified function is an interrupt
4739 handler. Use the @code{fast_interrupt} attribute to indicate handlers
4740 used in low-latency interrupt mode, and @code{interrupt_handler} for
4741 interrupts that do not use low-latency handlers. In both cases, GCC
4742 emits appropriate prologue code and generates a return from the handler
4743 using @code{rtid} instead of @code{rtsd}.
4746 @node Microsoft Windows Function Attributes
4747 @subsection Microsoft Windows Function Attributes
4749 The following attributes are available on Microsoft Windows and Symbian OS
4754 @cindex @code{dllexport} function attribute
4755 @cindex @code{__declspec(dllexport)}
4756 On Microsoft Windows targets and Symbian OS targets the
4757 @code{dllexport} attribute causes the compiler to provide a global
4758 pointer to a pointer in a DLL, so that it can be referenced with the
4759 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4760 name is formed by combining @code{_imp__} and the function or variable
4763 You can use @code{__declspec(dllexport)} as a synonym for
4764 @code{__attribute__ ((dllexport))} for compatibility with other
4767 On systems that support the @code{visibility} attribute, this
4768 attribute also implies ``default'' visibility. It is an error to
4769 explicitly specify any other visibility.
4771 GCC's default behavior is to emit all inline functions with the
4772 @code{dllexport} attribute. Since this can cause object file-size bloat,
4773 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4774 ignore the attribute for inlined functions unless the
4775 @option{-fkeep-inline-functions} flag is used instead.
4777 The attribute is ignored for undefined symbols.
4779 When applied to C++ classes, the attribute marks defined non-inlined
4780 member functions and static data members as exports. Static consts
4781 initialized in-class are not marked unless they are also defined
4784 For Microsoft Windows targets there are alternative methods for
4785 including the symbol in the DLL's export table such as using a
4786 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4787 the @option{--export-all} linker flag.
4790 @cindex @code{dllimport} function attribute
4791 @cindex @code{__declspec(dllimport)}
4792 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4793 attribute causes the compiler to reference a function or variable via
4794 a global pointer to a pointer that is set up by the DLL exporting the
4795 symbol. The attribute implies @code{extern}. On Microsoft Windows
4796 targets, the pointer name is formed by combining @code{_imp__} and the
4797 function or variable name.
4799 You can use @code{__declspec(dllimport)} as a synonym for
4800 @code{__attribute__ ((dllimport))} for compatibility with other
4803 On systems that support the @code{visibility} attribute, this
4804 attribute also implies ``default'' visibility. It is an error to
4805 explicitly specify any other visibility.
4807 Currently, the attribute is ignored for inlined functions. If the
4808 attribute is applied to a symbol @emph{definition}, an error is reported.
4809 If a symbol previously declared @code{dllimport} is later defined, the
4810 attribute is ignored in subsequent references, and a warning is emitted.
4811 The attribute is also overridden by a subsequent declaration as
4814 When applied to C++ classes, the attribute marks non-inlined
4815 member functions and static data members as imports. However, the
4816 attribute is ignored for virtual methods to allow creation of vtables
4819 On the SH Symbian OS target the @code{dllimport} attribute also has
4820 another affect---it can cause the vtable and run-time type information
4821 for a class to be exported. This happens when the class has a
4822 dllimported constructor or a non-inline, non-pure virtual function
4823 and, for either of those two conditions, the class also has an inline
4824 constructor or destructor and has a key function that is defined in
4825 the current translation unit.
4827 For Microsoft Windows targets the use of the @code{dllimport}
4828 attribute on functions is not necessary, but provides a small
4829 performance benefit by eliminating a thunk in the DLL@. The use of the
4830 @code{dllimport} attribute on imported variables can be avoided by passing the
4831 @option{--enable-auto-import} switch to the GNU linker. As with
4832 functions, using the attribute for a variable eliminates a thunk in
4835 One drawback to using this attribute is that a pointer to a
4836 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4837 address. However, a pointer to a @emph{function} with the
4838 @code{dllimport} attribute can be used as a constant initializer; in
4839 this case, the address of a stub function in the import lib is
4840 referenced. On Microsoft Windows targets, the attribute can be disabled
4841 for functions by setting the @option{-mnop-fun-dllimport} flag.
4844 @node MIPS Function Attributes
4845 @subsection MIPS Function Attributes
4847 These function attributes are supported by the MIPS back end:
4851 @cindex @code{interrupt} function attribute, MIPS
4852 Use this attribute to indicate that the specified function is an interrupt
4853 handler. The compiler generates function entry and exit sequences suitable
4854 for use in an interrupt handler when this attribute is present.
4855 An optional argument is supported for the interrupt attribute which allows
4856 the interrupt mode to be described. By default GCC assumes the external
4857 interrupt controller (EIC) mode is in use, this can be explicitly set using
4858 @code{eic}. When interrupts are non-masked then the requested Interrupt
4859 Priority Level (IPL) is copied to the current IPL which has the effect of only
4860 enabling higher priority interrupts. To use vectored interrupt mode use
4861 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4862 the behavior of the non-masked interrupt support and GCC will arrange to mask
4863 all interrupts from sw0 up to and including the specified interrupt vector.
4865 You can use the following attributes to modify the behavior
4866 of an interrupt handler:
4868 @item use_shadow_register_set
4869 @cindex @code{use_shadow_register_set} function attribute, MIPS
4870 Assume that the handler uses a shadow register set, instead of
4871 the main general-purpose registers. An optional argument @code{intstack} is
4872 supported to indicate that the shadow register set contains a valid stack
4875 @item keep_interrupts_masked
4876 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4877 Keep interrupts masked for the whole function. Without this attribute,
4878 GCC tries to reenable interrupts for as much of the function as it can.
4880 @item use_debug_exception_return
4881 @cindex @code{use_debug_exception_return} function attribute, MIPS
4882 Return using the @code{deret} instruction. Interrupt handlers that don't
4883 have this attribute return using @code{eret} instead.
4886 You can use any combination of these attributes, as shown below:
4888 void __attribute__ ((interrupt)) v0 ();
4889 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4890 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4891 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4892 void __attribute__ ((interrupt, use_shadow_register_set,
4893 keep_interrupts_masked)) v4 ();
4894 void __attribute__ ((interrupt, use_shadow_register_set,
4895 use_debug_exception_return)) v5 ();
4896 void __attribute__ ((interrupt, keep_interrupts_masked,
4897 use_debug_exception_return)) v6 ();
4898 void __attribute__ ((interrupt, use_shadow_register_set,
4899 keep_interrupts_masked,
4900 use_debug_exception_return)) v7 ();
4901 void __attribute__ ((interrupt("eic"))) v8 ();
4902 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4909 @cindex indirect calls, MIPS
4910 @cindex @code{long_call} function attribute, MIPS
4911 @cindex @code{short_call} function attribute, MIPS
4912 @cindex @code{near} function attribute, MIPS
4913 @cindex @code{far} function attribute, MIPS
4914 These attributes specify how a particular function is called on MIPS@.
4915 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4916 command-line switch. The @code{long_call} and @code{far} attributes are
4917 synonyms, and cause the compiler to always call
4918 the function by first loading its address into a register, and then using
4919 the contents of that register. The @code{short_call} and @code{near}
4920 attributes are synonyms, and have the opposite
4921 effect; they specify that non-PIC calls should be made using the more
4922 efficient @code{jal} instruction.
4926 @cindex @code{mips16} function attribute, MIPS
4927 @cindex @code{nomips16} function attribute, MIPS
4929 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4930 function attributes to locally select or turn off MIPS16 code generation.
4931 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4932 while MIPS16 code generation is disabled for functions with the
4933 @code{nomips16} attribute. These attributes override the
4934 @option{-mips16} and @option{-mno-mips16} options on the command line
4935 (@pxref{MIPS Options}).
4937 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4938 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4939 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4940 may interact badly with some GCC extensions such as @code{__builtin_apply}
4941 (@pxref{Constructing Calls}).
4943 @item micromips, MIPS
4944 @itemx nomicromips, MIPS
4945 @cindex @code{micromips} function attribute
4946 @cindex @code{nomicromips} function attribute
4948 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4949 function attributes to locally select or turn off microMIPS code generation.
4950 A function with the @code{micromips} attribute is emitted as microMIPS code,
4951 while microMIPS code generation is disabled for functions with the
4952 @code{nomicromips} attribute. These attributes override the
4953 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4954 (@pxref{MIPS Options}).
4956 When compiling files containing mixed microMIPS and non-microMIPS code, the
4957 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4959 not that within individual functions. Mixed microMIPS and non-microMIPS code
4960 may interact badly with some GCC extensions such as @code{__builtin_apply}
4961 (@pxref{Constructing Calls}).
4964 @cindex @code{nocompression} function attribute, MIPS
4965 On MIPS targets, you can use the @code{nocompression} function attribute
4966 to locally turn off MIPS16 and microMIPS code generation. This attribute
4967 overrides the @option{-mips16} and @option{-mmicromips} options on the
4968 command line (@pxref{MIPS Options}).
4971 @node MSP430 Function Attributes
4972 @subsection MSP430 Function Attributes
4974 These function attributes are supported by the MSP430 back end:
4978 @cindex @code{critical} function attribute, MSP430
4979 Critical functions disable interrupts upon entry and restore the
4980 previous interrupt state upon exit. Critical functions cannot also
4981 have the @code{naked}, @code{reentrant} or @code{interrupt} attributes.
4983 The MSP430 hardware ensures that interrupts are disabled on entry to
4984 @code{interrupt} functions, and restores the previous interrupt state
4985 on exit. The @code{critical} attribute is therefore redundant on
4986 @code{interrupt} functions.
4989 @cindex @code{interrupt} function attribute, MSP430
4990 Use this attribute to indicate
4991 that the specified function is an interrupt handler. The compiler generates
4992 function entry and exit sequences suitable for use in an interrupt handler
4993 when this attribute is present.
4995 You can provide an argument to the interrupt
4996 attribute which specifies a name or number. If the argument is a
4997 number it indicates the slot in the interrupt vector table (0 - 31) to
4998 which this handler should be assigned. If the argument is a name it
4999 is treated as a symbolic name for the vector slot. These names should
5000 match up with appropriate entries in the linker script. By default
5001 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
5002 @code{reset} for vector 31 are recognized.
5005 @cindex @code{naked} function attribute, MSP430
5006 This attribute allows the compiler to construct the
5007 requisite function declaration, while allowing the body of the
5008 function to be assembly code. The specified function will not have
5009 prologue/epilogue sequences generated by the compiler. Only basic
5010 @code{asm} statements can safely be included in naked functions
5011 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5012 basic @code{asm} and C code may appear to work, they cannot be
5013 depended upon to work reliably and are not supported.
5016 @cindex @code{reentrant} function attribute, MSP430
5017 Reentrant functions disable interrupts upon entry and enable them
5018 upon exit. Reentrant functions cannot also have the @code{naked}
5019 or @code{critical} attributes. They can have the @code{interrupt}
5023 @cindex @code{wakeup} function attribute, MSP430
5024 This attribute only applies to interrupt functions. It is silently
5025 ignored if applied to a non-interrupt function. A wakeup interrupt
5026 function will rouse the processor from any low-power state that it
5027 might be in when the function exits.
5032 @cindex @code{lower} function attribute, MSP430
5033 @cindex @code{upper} function attribute, MSP430
5034 @cindex @code{either} function attribute, MSP430
5035 On the MSP430 target these attributes can be used to specify whether
5036 the function or variable should be placed into low memory, high
5037 memory, or the placement should be left to the linker to decide. The
5038 attributes are only significant if compiling for the MSP430X
5041 The attributes work in conjunction with a linker script that has been
5042 augmented to specify where to place sections with a @code{.lower} and
5043 a @code{.upper} prefix. So, for example, as well as placing the
5044 @code{.data} section, the script also specifies the placement of a
5045 @code{.lower.data} and a @code{.upper.data} section. The intention
5046 is that @code{lower} sections are placed into a small but easier to
5047 access memory region and the upper sections are placed into a larger, but
5048 slower to access, region.
5050 The @code{either} attribute is special. It tells the linker to place
5051 the object into the corresponding @code{lower} section if there is
5052 room for it. If there is insufficient room then the object is placed
5053 into the corresponding @code{upper} section instead. Note that the
5054 placement algorithm is not very sophisticated. It does not attempt to
5055 find an optimal packing of the @code{lower} sections. It just makes
5056 one pass over the objects and does the best that it can. Using the
5057 @option{-ffunction-sections} and @option{-fdata-sections} command-line
5058 options can help the packing, however, since they produce smaller,
5059 easier to pack regions.
5062 @node NDS32 Function Attributes
5063 @subsection NDS32 Function Attributes
5065 These function attributes are supported by the NDS32 back end:
5069 @cindex @code{exception} function attribute
5070 @cindex exception handler functions, NDS32
5071 Use this attribute on the NDS32 target to indicate that the specified function
5072 is an exception handler. The compiler will generate corresponding sections
5073 for use in an exception handler.
5076 @cindex @code{interrupt} function attribute, NDS32
5077 On NDS32 target, this attribute indicates that the specified function
5078 is an interrupt handler. The compiler generates corresponding sections
5079 for use in an interrupt handler. You can use the following attributes
5080 to modify the behavior:
5083 @cindex @code{nested} function attribute, NDS32
5084 This interrupt service routine is interruptible.
5086 @cindex @code{not_nested} function attribute, NDS32
5087 This interrupt service routine is not interruptible.
5089 @cindex @code{nested_ready} function attribute, NDS32
5090 This interrupt service routine is interruptible after @code{PSW.GIE}
5091 (global interrupt enable) is set. This allows interrupt service routine to
5092 finish some short critical code before enabling interrupts.
5094 @cindex @code{save_all} function attribute, NDS32
5095 The system will help save all registers into stack before entering
5098 @cindex @code{partial_save} function attribute, NDS32
5099 The system will help save caller registers into stack before entering
5104 @cindex @code{naked} function attribute, NDS32
5105 This attribute allows the compiler to construct the
5106 requisite function declaration, while allowing the body of the
5107 function to be assembly code. The specified function will not have
5108 prologue/epilogue sequences generated by the compiler. Only basic
5109 @code{asm} statements can safely be included in naked functions
5110 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5111 basic @code{asm} and C code may appear to work, they cannot be
5112 depended upon to work reliably and are not supported.
5115 @cindex @code{reset} function attribute, NDS32
5116 @cindex reset handler functions
5117 Use this attribute on the NDS32 target to indicate that the specified function
5118 is a reset handler. The compiler will generate corresponding sections
5119 for use in a reset handler. You can use the following attributes
5120 to provide extra exception handling:
5123 @cindex @code{nmi} function attribute, NDS32
5124 Provide a user-defined function to handle NMI exception.
5126 @cindex @code{warm} function attribute, NDS32
5127 Provide a user-defined function to handle warm reset exception.
5131 @node Nios II Function Attributes
5132 @subsection Nios II Function Attributes
5134 These function attributes are supported by the Nios II back end:
5137 @item target (@var{options})
5138 @cindex @code{target} function attribute
5139 As discussed in @ref{Common Function Attributes}, this attribute
5140 allows specification of target-specific compilation options.
5142 When compiling for Nios II, the following options are allowed:
5145 @item custom-@var{insn}=@var{N}
5146 @itemx no-custom-@var{insn}
5147 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
5148 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
5149 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
5150 custom instruction with encoding @var{N} when generating code that uses
5151 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
5152 the custom instruction @var{insn}.
5153 These target attributes correspond to the
5154 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
5155 command-line options, and support the same set of @var{insn} keywords.
5156 @xref{Nios II Options}, for more information.
5158 @item custom-fpu-cfg=@var{name}
5159 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
5160 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
5161 command-line option, to select a predefined set of custom instructions
5163 @xref{Nios II Options}, for more information.
5167 @node Nvidia PTX Function Attributes
5168 @subsection Nvidia PTX Function Attributes
5170 These function attributes are supported by the Nvidia PTX back end:
5174 @cindex @code{kernel} attribute, Nvidia PTX
5175 This attribute indicates that the corresponding function should be compiled
5176 as a kernel function, which can be invoked from the host via the CUDA RT
5178 By default functions are only callable only from other PTX functions.
5180 Kernel functions must have @code{void} return type.
5183 @node PowerPC Function Attributes
5184 @subsection PowerPC Function Attributes
5186 These function attributes are supported by the PowerPC back end:
5191 @cindex indirect calls, PowerPC
5192 @cindex @code{longcall} function attribute, PowerPC
5193 @cindex @code{shortcall} function attribute, PowerPC
5194 The @code{longcall} attribute
5195 indicates that the function might be far away from the call site and
5196 require a different (more expensive) calling sequence. The
5197 @code{shortcall} attribute indicates that the function is always close
5198 enough for the shorter calling sequence to be used. These attributes
5199 override both the @option{-mlongcall} switch and
5200 the @code{#pragma longcall} setting.
5202 @xref{RS/6000 and PowerPC Options}, for more information on whether long
5203 calls are necessary.
5205 @item target (@var{options})
5206 @cindex @code{target} function attribute
5207 As discussed in @ref{Common Function Attributes}, this attribute
5208 allows specification of target-specific compilation options.
5210 On the PowerPC, the following options are allowed:
5215 @cindex @code{target("altivec")} function attribute, PowerPC
5216 Generate code that uses (does not use) AltiVec instructions. In
5217 32-bit code, you cannot enable AltiVec instructions unless
5218 @option{-mabi=altivec} is used on the command line.
5222 @cindex @code{target("cmpb")} function attribute, PowerPC
5223 Generate code that uses (does not use) the compare bytes instruction
5224 implemented on the POWER6 processor and other processors that support
5225 the PowerPC V2.05 architecture.
5229 @cindex @code{target("dlmzb")} function attribute, PowerPC
5230 Generate code that uses (does not use) the string-search @samp{dlmzb}
5231 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
5232 generated by default when targeting those processors.
5236 @cindex @code{target("fprnd")} function attribute, PowerPC
5237 Generate code that uses (does not use) the FP round to integer
5238 instructions implemented on the POWER5+ processor and other processors
5239 that support the PowerPC V2.03 architecture.
5243 @cindex @code{target("hard-dfp")} function attribute, PowerPC
5244 Generate code that uses (does not use) the decimal floating-point
5245 instructions implemented on some POWER processors.
5249 @cindex @code{target("isel")} function attribute, PowerPC
5250 Generate code that uses (does not use) ISEL instruction.
5254 @cindex @code{target("mfcrf")} function attribute, PowerPC
5255 Generate code that uses (does not use) the move from condition
5256 register field instruction implemented on the POWER4 processor and
5257 other processors that support the PowerPC V2.01 architecture.
5261 @cindex @code{target("mfpgpr")} function attribute, PowerPC
5262 Generate code that uses (does not use) the FP move to/from general
5263 purpose register instructions implemented on the POWER6X processor and
5264 other processors that support the extended PowerPC V2.05 architecture.
5268 @cindex @code{target("mulhw")} function attribute, PowerPC
5269 Generate code that uses (does not use) the half-word multiply and
5270 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
5271 These instructions are generated by default when targeting those
5276 @cindex @code{target("multiple")} function attribute, PowerPC
5277 Generate code that uses (does not use) the load multiple word
5278 instructions and the store multiple word instructions.
5282 @cindex @code{target("update")} function attribute, PowerPC
5283 Generate code that uses (does not use) the load or store instructions
5284 that update the base register to the address of the calculated memory
5289 @cindex @code{target("popcntb")} function attribute, PowerPC
5290 Generate code that uses (does not use) the popcount and double-precision
5291 FP reciprocal estimate instruction implemented on the POWER5
5292 processor and other processors that support the PowerPC V2.02
5297 @cindex @code{target("popcntd")} function attribute, PowerPC
5298 Generate code that uses (does not use) the popcount instruction
5299 implemented on the POWER7 processor and other processors that support
5300 the PowerPC V2.06 architecture.
5302 @item powerpc-gfxopt
5303 @itemx no-powerpc-gfxopt
5304 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
5305 Generate code that uses (does not use) the optional PowerPC
5306 architecture instructions in the Graphics group, including
5307 floating-point select.
5310 @itemx no-powerpc-gpopt
5311 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
5312 Generate code that uses (does not use) the optional PowerPC
5313 architecture instructions in the General Purpose group, including
5314 floating-point square root.
5316 @item recip-precision
5317 @itemx no-recip-precision
5318 @cindex @code{target("recip-precision")} function attribute, PowerPC
5319 Assume (do not assume) that the reciprocal estimate instructions
5320 provide higher-precision estimates than is mandated by the PowerPC
5325 @cindex @code{target("string")} function attribute, PowerPC
5326 Generate code that uses (does not use) the load string instructions
5327 and the store string word instructions to save multiple registers and
5328 do small block moves.
5332 @cindex @code{target("vsx")} function attribute, PowerPC
5333 Generate code that uses (does not use) vector/scalar (VSX)
5334 instructions, and also enable the use of built-in functions that allow
5335 more direct access to the VSX instruction set. In 32-bit code, you
5336 cannot enable VSX or AltiVec instructions unless
5337 @option{-mabi=altivec} is used on the command line.
5341 @cindex @code{target("friz")} function attribute, PowerPC
5342 Generate (do not generate) the @code{friz} instruction when the
5343 @option{-funsafe-math-optimizations} option is used to optimize
5344 rounding a floating-point value to 64-bit integer and back to floating
5345 point. The @code{friz} instruction does not return the same value if
5346 the floating-point number is too large to fit in an integer.
5348 @item avoid-indexed-addresses
5349 @itemx no-avoid-indexed-addresses
5350 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
5351 Generate code that tries to avoid (not avoid) the use of indexed load
5352 or store instructions.
5356 @cindex @code{target("paired")} function attribute, PowerPC
5357 Generate code that uses (does not use) the generation of PAIRED simd
5362 @cindex @code{target("longcall")} function attribute, PowerPC
5363 Generate code that assumes (does not assume) that all calls are far
5364 away so that a longer more expensive calling sequence is required.
5367 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
5368 Specify the architecture to generate code for when compiling the
5369 function. If you select the @code{target("cpu=power7")} attribute when
5370 generating 32-bit code, VSX and AltiVec instructions are not generated
5371 unless you use the @option{-mabi=altivec} option on the command line.
5373 @item tune=@var{TUNE}
5374 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
5375 Specify the architecture to tune for when compiling the function. If
5376 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
5377 you do specify the @code{target("cpu=@var{CPU}")} attribute,
5378 compilation tunes for the @var{CPU} architecture, and not the
5379 default tuning specified on the command line.
5382 On the PowerPC, the inliner does not inline a
5383 function that has different target options than the caller, unless the
5384 callee has a subset of the target options of the caller.
5387 @node RISC-V Function Attributes
5388 @subsection RISC-V Function Attributes
5390 These function attributes are supported by the RISC-V back end:
5394 @cindex @code{naked} function attribute, RISC-V
5395 This attribute allows the compiler to construct the
5396 requisite function declaration, while allowing the body of the
5397 function to be assembly code. The specified function will not have
5398 prologue/epilogue sequences generated by the compiler. Only basic
5399 @code{asm} statements can safely be included in naked functions
5400 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5401 basic @code{asm} and C code may appear to work, they cannot be
5402 depended upon to work reliably and are not supported.
5405 @cindex @code{interrupt} function attribute, RISC-V
5406 Use this attribute to indicate that the specified function is an interrupt
5407 handler. The compiler generates function entry and exit sequences suitable
5408 for use in an interrupt handler when this attribute is present.
5410 You can specify the kind of interrupt to be handled by adding an optional
5411 parameter to the interrupt attribute like this:
5414 void f (void) __attribute__ ((interrupt ("user")));
5417 Permissible values for this parameter are @code{user}, @code{supervisor},
5418 and @code{machine}. If there is no parameter, then it defaults to
5422 @node RL78 Function Attributes
5423 @subsection RL78 Function Attributes
5425 These function attributes are supported by the RL78 back end:
5429 @itemx brk_interrupt
5430 @cindex @code{interrupt} function attribute, RL78
5431 @cindex @code{brk_interrupt} function attribute, RL78
5432 These attributes indicate
5433 that the specified function is an interrupt handler. The compiler generates
5434 function entry and exit sequences suitable for use in an interrupt handler
5435 when this attribute is present.
5437 Use @code{brk_interrupt} instead of @code{interrupt} for
5438 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
5439 that must end with @code{RETB} instead of @code{RETI}).
5442 @cindex @code{naked} function attribute, RL78
5443 This attribute allows the compiler to construct the
5444 requisite function declaration, while allowing the body of the
5445 function to be assembly code. The specified function will not have
5446 prologue/epilogue sequences generated by the compiler. Only basic
5447 @code{asm} statements can safely be included in naked functions
5448 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5449 basic @code{asm} and C code may appear to work, they cannot be
5450 depended upon to work reliably and are not supported.
5453 @node RX Function Attributes
5454 @subsection RX Function Attributes
5456 These function attributes are supported by the RX back end:
5459 @item fast_interrupt
5460 @cindex @code{fast_interrupt} function attribute, RX
5461 Use this attribute on the RX port to indicate that the specified
5462 function is a fast interrupt handler. This is just like the
5463 @code{interrupt} attribute, except that @code{freit} is used to return
5464 instead of @code{reit}.
5467 @cindex @code{interrupt} function attribute, RX
5468 Use this attribute to indicate
5469 that the specified function is an interrupt handler. The compiler generates
5470 function entry and exit sequences suitable for use in an interrupt handler
5471 when this attribute is present.
5473 On RX and RL78 targets, you may specify one or more vector numbers as arguments
5474 to the attribute, as well as naming an alternate table name.
5475 Parameters are handled sequentially, so one handler can be assigned to
5476 multiple entries in multiple tables. One may also pass the magic
5477 string @code{"$default"} which causes the function to be used for any
5478 unfilled slots in the current table.
5480 This example shows a simple assignment of a function to one vector in
5481 the default table (note that preprocessor macros may be used for
5482 chip-specific symbolic vector names):
5484 void __attribute__ ((interrupt (5))) txd1_handler ();
5487 This example assigns a function to two slots in the default table
5488 (using preprocessor macros defined elsewhere) and makes it the default
5489 for the @code{dct} table:
5491 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
5496 @cindex @code{naked} function attribute, RX
5497 This attribute allows the compiler to construct the
5498 requisite function declaration, while allowing the body of the
5499 function to be assembly code. The specified function will not have
5500 prologue/epilogue sequences generated by the compiler. Only basic
5501 @code{asm} statements can safely be included in naked functions
5502 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5503 basic @code{asm} and C code may appear to work, they cannot be
5504 depended upon to work reliably and are not supported.
5507 @cindex @code{vector} function attribute, RX
5508 This RX attribute is similar to the @code{interrupt} attribute, including its
5509 parameters, but does not make the function an interrupt-handler type
5510 function (i.e.@: it retains the normal C function calling ABI). See the
5511 @code{interrupt} attribute for a description of its arguments.
5514 @node S/390 Function Attributes
5515 @subsection S/390 Function Attributes
5517 These function attributes are supported on the S/390:
5520 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5521 @cindex @code{hotpatch} function attribute, S/390
5523 On S/390 System z targets, you can use this function attribute to
5524 make GCC generate a ``hot-patching'' function prologue. If the
5525 @option{-mhotpatch=} command-line option is used at the same time,
5526 the @code{hotpatch} attribute takes precedence. The first of the
5527 two arguments specifies the number of halfwords to be added before
5528 the function label. A second argument can be used to specify the
5529 number of halfwords to be added after the function label. For
5530 both arguments the maximum allowed value is 1000000.
5532 If both arguments are zero, hotpatching is disabled.
5534 @item target (@var{options})
5535 @cindex @code{target} function attribute
5536 As discussed in @ref{Common Function Attributes}, this attribute
5537 allows specification of target-specific compilation options.
5539 On S/390, the following options are supported:
5547 @item warn-framesize=
5559 @itemx no-packed-stack
5561 @itemx no-small-exec
5564 @item warn-dynamicstack
5565 @itemx no-warn-dynamicstack
5568 The options work exactly like the S/390 specific command line
5569 options (without the prefix @option{-m}) except that they do not
5570 change any feature macros. For example,
5573 @code{target("no-vx")}
5576 does not undefine the @code{__VEC__} macro.
5579 @node SH Function Attributes
5580 @subsection SH Function Attributes
5582 These function attributes are supported on the SH family of processors:
5585 @item function_vector
5586 @cindex @code{function_vector} function attribute, SH
5587 @cindex calling functions through the function vector on SH2A
5588 On SH2A targets, this attribute declares a function to be called using the
5589 TBR relative addressing mode. The argument to this attribute is the entry
5590 number of the same function in a vector table containing all the TBR
5591 relative addressable functions. For correct operation the TBR must be setup
5592 accordingly to point to the start of the vector table before any functions with
5593 this attribute are invoked. Usually a good place to do the initialization is
5594 the startup routine. The TBR relative vector table can have at max 256 function
5595 entries. The jumps to these functions are generated using a SH2A specific,
5596 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
5597 from GNU binutils version 2.7 or later for this attribute to work correctly.
5599 In an application, for a function being called once, this attribute
5600 saves at least 8 bytes of code; and if other successive calls are being
5601 made to the same function, it saves 2 bytes of code per each of these
5604 @item interrupt_handler
5605 @cindex @code{interrupt_handler} function attribute, SH
5606 Use this attribute to
5607 indicate that the specified function is an interrupt handler. The compiler
5608 generates function entry and exit sequences suitable for use in an
5609 interrupt handler when this attribute is present.
5611 @item nosave_low_regs
5612 @cindex @code{nosave_low_regs} function attribute, SH
5613 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5614 function should not save and restore registers R0..R7. This can be used on SH3*
5615 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5619 @cindex @code{renesas} function attribute, SH
5620 On SH targets this attribute specifies that the function or struct follows the
5624 @cindex @code{resbank} function attribute, SH
5625 On the SH2A target, this attribute enables the high-speed register
5626 saving and restoration using a register bank for @code{interrupt_handler}
5627 routines. Saving to the bank is performed automatically after the CPU
5628 accepts an interrupt that uses a register bank.
5630 The nineteen 32-bit registers comprising general register R0 to R14,
5631 control register GBR, and system registers MACH, MACL, and PR and the
5632 vector table address offset are saved into a register bank. Register
5633 banks are stacked in first-in last-out (FILO) sequence. Restoration
5634 from the bank is executed by issuing a RESBANK instruction.
5637 @cindex @code{sp_switch} function attribute, SH
5638 Use this attribute on the SH to indicate an @code{interrupt_handler}
5639 function should switch to an alternate stack. It expects a string
5640 argument that names a global variable holding the address of the
5645 void f () __attribute__ ((interrupt_handler,
5646 sp_switch ("alt_stack")));
5650 @cindex @code{trap_exit} function attribute, SH
5651 Use this attribute on the SH for an @code{interrupt_handler} to return using
5652 @code{trapa} instead of @code{rte}. This attribute expects an integer
5653 argument specifying the trap number to be used.
5656 @cindex @code{trapa_handler} function attribute, SH
5657 On SH targets this function attribute is similar to @code{interrupt_handler}
5658 but it does not save and restore all registers.
5661 @node SPU Function Attributes
5662 @subsection SPU Function Attributes
5664 These function attributes are supported by the SPU back end:
5668 @cindex @code{naked} function attribute, SPU
5669 This attribute allows the compiler to construct the
5670 requisite function declaration, while allowing the body of the
5671 function to be assembly code. The specified function will not have
5672 prologue/epilogue sequences generated by the compiler. Only basic
5673 @code{asm} statements can safely be included in naked functions
5674 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5675 basic @code{asm} and C code may appear to work, they cannot be
5676 depended upon to work reliably and are not supported.
5679 @node Symbian OS Function Attributes
5680 @subsection Symbian OS Function Attributes
5682 @xref{Microsoft Windows Function Attributes}, for discussion of the
5683 @code{dllexport} and @code{dllimport} attributes.
5685 @node V850 Function Attributes
5686 @subsection V850 Function Attributes
5688 The V850 back end supports these function attributes:
5692 @itemx interrupt_handler
5693 @cindex @code{interrupt} function attribute, V850
5694 @cindex @code{interrupt_handler} function attribute, V850
5695 Use these attributes to indicate
5696 that the specified function is an interrupt handler. The compiler generates
5697 function entry and exit sequences suitable for use in an interrupt handler
5698 when either attribute is present.
5701 @node Visium Function Attributes
5702 @subsection Visium Function Attributes
5704 These function attributes are supported by the Visium back end:
5708 @cindex @code{interrupt} function attribute, Visium
5709 Use this attribute to indicate
5710 that the specified function is an interrupt handler. The compiler generates
5711 function entry and exit sequences suitable for use in an interrupt handler
5712 when this attribute is present.
5715 @node x86 Function Attributes
5716 @subsection x86 Function Attributes
5718 These function attributes are supported by the x86 back end:
5722 @cindex @code{cdecl} function attribute, x86-32
5723 @cindex functions that pop the argument stack on x86-32
5725 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5726 assume that the calling function pops off the stack space used to
5727 pass arguments. This is
5728 useful to override the effects of the @option{-mrtd} switch.
5731 @cindex @code{fastcall} function attribute, x86-32
5732 @cindex functions that pop the argument stack on x86-32
5733 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5734 pass the first argument (if of integral type) in the register ECX and
5735 the second argument (if of integral type) in the register EDX@. Subsequent
5736 and other typed arguments are passed on the stack. The called function
5737 pops the arguments off the stack. If the number of arguments is variable all
5738 arguments are pushed on the stack.
5741 @cindex @code{thiscall} function attribute, x86-32
5742 @cindex functions that pop the argument stack on x86-32
5743 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5744 pass the first argument (if of integral type) in the register ECX.
5745 Subsequent and other typed arguments are passed on the stack. The called
5746 function pops the arguments off the stack.
5747 If the number of arguments is variable all arguments are pushed on the
5749 The @code{thiscall} attribute is intended for C++ non-static member functions.
5750 As a GCC extension, this calling convention can be used for C functions
5751 and for static member methods.
5755 @cindex @code{ms_abi} function attribute, x86
5756 @cindex @code{sysv_abi} function attribute, x86
5758 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5759 to indicate which calling convention should be used for a function. The
5760 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5761 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5762 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5763 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5765 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5766 requires the @option{-maccumulate-outgoing-args} option.
5768 @item callee_pop_aggregate_return (@var{number})
5769 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5771 On x86-32 targets, you can use this attribute to control how
5772 aggregates are returned in memory. If the caller is responsible for
5773 popping the hidden pointer together with the rest of the arguments, specify
5774 @var{number} equal to zero. If callee is responsible for popping the
5775 hidden pointer, specify @var{number} equal to one.
5777 The default x86-32 ABI assumes that the callee pops the
5778 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5779 the compiler assumes that the
5780 caller pops the stack for hidden pointer.
5782 @item ms_hook_prologue
5783 @cindex @code{ms_hook_prologue} function attribute, x86
5785 On 32-bit and 64-bit x86 targets, you can use
5786 this function attribute to make GCC generate the ``hot-patching'' function
5787 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5791 @cindex @code{naked} function attribute, x86
5792 This attribute allows the compiler to construct the
5793 requisite function declaration, while allowing the body of the
5794 function to be assembly code. The specified function will not have
5795 prologue/epilogue sequences generated by the compiler. Only basic
5796 @code{asm} statements can safely be included in naked functions
5797 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5798 basic @code{asm} and C code may appear to work, they cannot be
5799 depended upon to work reliably and are not supported.
5801 @item regparm (@var{number})
5802 @cindex @code{regparm} function attribute, x86
5803 @cindex functions that are passed arguments in registers on x86-32
5804 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5805 pass arguments number one to @var{number} if they are of integral type
5806 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5807 take a variable number of arguments continue to be passed all of their
5808 arguments on the stack.
5810 Beware that on some ELF systems this attribute is unsuitable for
5811 global functions in shared libraries with lazy binding (which is the
5812 default). Lazy binding sends the first call via resolving code in
5813 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5814 per the standard calling conventions. Solaris 8 is affected by this.
5815 Systems with the GNU C Library version 2.1 or higher
5816 and FreeBSD are believed to be
5817 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5818 disabled with the linker or the loader if desired, to avoid the
5822 @cindex @code{sseregparm} function attribute, x86
5823 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5824 causes the compiler to pass up to 3 floating-point arguments in
5825 SSE registers instead of on the stack. Functions that take a
5826 variable number of arguments continue to pass all of their
5827 floating-point arguments on the stack.
5829 @item force_align_arg_pointer
5830 @cindex @code{force_align_arg_pointer} function attribute, x86
5831 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5832 applied to individual function definitions, generating an alternate
5833 prologue and epilogue that realigns the run-time stack if necessary.
5834 This supports mixing legacy codes that run with a 4-byte aligned stack
5835 with modern codes that keep a 16-byte stack for SSE compatibility.
5838 @cindex @code{stdcall} function attribute, x86-32
5839 @cindex functions that pop the argument stack on x86-32
5840 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5841 assume that the called function pops off the stack space used to
5842 pass arguments, unless it takes a variable number of arguments.
5844 @item no_caller_saved_registers
5845 @cindex @code{no_caller_saved_registers} function attribute, x86
5846 Use this attribute to indicate that the specified function has no
5847 caller-saved registers. That is, all registers are callee-saved. For
5848 example, this attribute can be used for a function called from an
5849 interrupt handler. The compiler generates proper function entry and
5850 exit sequences to save and restore any modified registers, except for
5851 the EFLAGS register. Since GCC doesn't preserve SSE, MMX nor x87
5852 states, the GCC option @option{-mgeneral-regs-only} should be used to
5853 compile functions with @code{no_caller_saved_registers} attribute.
5856 @cindex @code{interrupt} function attribute, x86
5857 Use this attribute to indicate that the specified function is an
5858 interrupt handler or an exception handler (depending on parameters passed
5859 to the function, explained further). The compiler generates function
5860 entry and exit sequences suitable for use in an interrupt handler when
5861 this attribute is present. The @code{IRET} instruction, instead of the
5862 @code{RET} instruction, is used to return from interrupt handlers. All
5863 registers, except for the EFLAGS register which is restored by the
5864 @code{IRET} instruction, are preserved by the compiler. Since GCC
5865 doesn't preserve SSE, MMX nor x87 states, the GCC option
5866 @option{-mgeneral-regs-only} should be used to compile interrupt and
5869 Any interruptible-without-stack-switch code must be compiled with
5870 @option{-mno-red-zone} since interrupt handlers can and will, because
5871 of the hardware design, touch the red zone.
5873 An interrupt handler must be declared with a mandatory pointer
5877 struct interrupt_frame;
5879 __attribute__ ((interrupt))
5881 f (struct interrupt_frame *frame)
5887 and you must define @code{struct interrupt_frame} as described in the
5890 Exception handlers differ from interrupt handlers because the system
5891 pushes an error code on the stack. An exception handler declaration is
5892 similar to that for an interrupt handler, but with a different mandatory
5893 function signature. The compiler arranges to pop the error code off the
5894 stack before the @code{IRET} instruction.
5898 typedef unsigned long long int uword_t;
5900 typedef unsigned int uword_t;
5903 struct interrupt_frame;
5905 __attribute__ ((interrupt))
5907 f (struct interrupt_frame *frame, uword_t error_code)
5913 Exception handlers should only be used for exceptions that push an error
5914 code; you should use an interrupt handler in other cases. The system
5915 will crash if the wrong kind of handler is used.
5917 @item target (@var{options})
5918 @cindex @code{target} function attribute
5919 As discussed in @ref{Common Function Attributes}, this attribute
5920 allows specification of target-specific compilation options.
5922 On the x86, the following options are allowed:
5926 @cindex @code{target("abm")} function attribute, x86
5927 Enable/disable the generation of the advanced bit instructions.
5931 @cindex @code{target("aes")} function attribute, x86
5932 Enable/disable the generation of the AES instructions.
5935 @cindex @code{target("default")} function attribute, x86
5936 @xref{Function Multiversioning}, where it is used to specify the
5937 default function version.
5941 @cindex @code{target("mmx")} function attribute, x86
5942 Enable/disable the generation of the MMX instructions.
5946 @cindex @code{target("pclmul")} function attribute, x86
5947 Enable/disable the generation of the PCLMUL instructions.
5951 @cindex @code{target("popcnt")} function attribute, x86
5952 Enable/disable the generation of the POPCNT instruction.
5956 @cindex @code{target("sse")} function attribute, x86
5957 Enable/disable the generation of the SSE instructions.
5961 @cindex @code{target("sse2")} function attribute, x86
5962 Enable/disable the generation of the SSE2 instructions.
5966 @cindex @code{target("sse3")} function attribute, x86
5967 Enable/disable the generation of the SSE3 instructions.
5971 @cindex @code{target("sse4")} function attribute, x86
5972 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5977 @cindex @code{target("sse4.1")} function attribute, x86
5978 Enable/disable the generation of the sse4.1 instructions.
5982 @cindex @code{target("sse4.2")} function attribute, x86
5983 Enable/disable the generation of the sse4.2 instructions.
5987 @cindex @code{target("sse4a")} function attribute, x86
5988 Enable/disable the generation of the SSE4A instructions.
5992 @cindex @code{target("fma4")} function attribute, x86
5993 Enable/disable the generation of the FMA4 instructions.
5997 @cindex @code{target("xop")} function attribute, x86
5998 Enable/disable the generation of the XOP instructions.
6002 @cindex @code{target("lwp")} function attribute, x86
6003 Enable/disable the generation of the LWP instructions.
6007 @cindex @code{target("ssse3")} function attribute, x86
6008 Enable/disable the generation of the SSSE3 instructions.
6012 @cindex @code{target("cld")} function attribute, x86
6013 Enable/disable the generation of the CLD before string moves.
6015 @item fancy-math-387
6016 @itemx no-fancy-math-387
6017 @cindex @code{target("fancy-math-387")} function attribute, x86
6018 Enable/disable the generation of the @code{sin}, @code{cos}, and
6019 @code{sqrt} instructions on the 387 floating-point unit.
6023 @cindex @code{target("ieee-fp")} function attribute, x86
6024 Enable/disable the generation of floating point that depends on IEEE arithmetic.
6026 @item inline-all-stringops
6027 @itemx no-inline-all-stringops
6028 @cindex @code{target("inline-all-stringops")} function attribute, x86
6029 Enable/disable inlining of string operations.
6031 @item inline-stringops-dynamically
6032 @itemx no-inline-stringops-dynamically
6033 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
6034 Enable/disable the generation of the inline code to do small string
6035 operations and calling the library routines for large operations.
6037 @item align-stringops
6038 @itemx no-align-stringops
6039 @cindex @code{target("align-stringops")} function attribute, x86
6040 Do/do not align destination of inlined string operations.
6044 @cindex @code{target("recip")} function attribute, x86
6045 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
6046 instructions followed an additional Newton-Raphson step instead of
6047 doing a floating-point division.
6049 @item arch=@var{ARCH}
6050 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
6051 Specify the architecture to generate code for in compiling the function.
6053 @item tune=@var{TUNE}
6054 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
6055 Specify the architecture to tune for in compiling the function.
6057 @item fpmath=@var{FPMATH}
6058 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
6059 Specify which floating-point unit to use. You must specify the
6060 @code{target("fpmath=sse,387")} option as
6061 @code{target("fpmath=sse+387")} because the comma would separate
6064 @item indirect_branch("@var{choice}")
6065 @cindex @code{indirect_branch} function attribute, x86
6066 On x86 targets, the @code{indirect_branch} attribute causes the compiler
6067 to convert indirect call and jump with @var{choice}. @samp{keep}
6068 keeps indirect call and jump unmodified. @samp{thunk} converts indirect
6069 call and jump to call and return thunk. @samp{thunk-inline} converts
6070 indirect call and jump to inlined call and return thunk.
6071 @samp{thunk-extern} converts indirect call and jump to external call
6072 and return thunk provided in a separate object file.
6074 @item function_return("@var{choice}")
6075 @cindex @code{function_return} function attribute, x86
6076 On x86 targets, the @code{function_return} attribute causes the compiler
6077 to convert function return with @var{choice}. @samp{keep} keeps function
6078 return unmodified. @samp{thunk} converts function return to call and
6079 return thunk. @samp{thunk-inline} converts function return to inlined
6080 call and return thunk. @samp{thunk-extern} converts function return to
6081 external call and return thunk provided in a separate object file.
6084 @cindex @code{nocf_check} function attribute
6085 The @code{nocf_check} attribute on a function is used to inform the
6086 compiler that the function's prologue should not be instrumented when
6087 compiled with the @option{-fcf-protection=branch} option. The
6088 compiler assumes that the function's address is a valid target for a
6089 control-flow transfer.
6091 The @code{nocf_check} attribute on a type of pointer to function is
6092 used to inform the compiler that a call through the pointer should
6093 not be instrumented when compiled with the
6094 @option{-fcf-protection=branch} option. The compiler assumes
6095 that the function's address from the pointer is a valid target for
6096 a control-flow transfer. A direct function call through a function
6097 name is assumed to be a safe call thus direct calls are not
6098 instrumented by the compiler.
6100 The @code{nocf_check} attribute is applied to an object's type.
6101 In case of assignment of a function address or a function pointer to
6102 another pointer, the attribute is not carried over from the right-hand
6103 object's type; the type of left-hand object stays unchanged. The
6104 compiler checks for @code{nocf_check} attribute mismatch and reports
6105 a warning in case of mismatch.
6109 int foo (void) __attribute__(nocf_check);
6110 void (*foo1)(void) __attribute__(nocf_check);
6113 /* foo's address is assumed to be valid. */
6117 /* This call site is not checked for control-flow
6121 /* A warning is issued about attribute mismatch. */
6124 /* This call site is still not checked. */
6127 /* This call site is checked. */
6130 /* A warning is issued about attribute mismatch. */
6133 /* This call site is still checked. */
6141 @cindex @code{cf_check} function attribute, x86
6143 The @code{cf_check} attribute on a function is used to inform the
6144 compiler that ENDBR instruction should be placed at the function
6145 entry when @option{-fcf-protection=branch} is enabled.
6147 @item indirect_return
6148 @cindex @code{indirect_return} function attribute, x86
6150 The @code{indirect_return} attribute can be applied to a function,
6151 as well as variable or type of function pointer to inform the
6152 compiler that the function may return via indirect branch.
6154 @item fentry_name("@var{name}")
6155 @cindex @code{fentry_name} function attribute, x86
6156 On x86 targets, the @code{fentry_name} attribute sets the function to
6157 call on function entry when function instrumentation is enabled
6158 with @option{-pg -mfentry}. When @var{name} is nop then a 5 byte
6159 nop sequence is generated.
6161 @item fentry_section("@var{name}")
6162 @cindex @code{fentry_section} function attribute, x86
6163 On x86 targets, the @code{fentry_section} attribute sets the name
6164 of the section to record function entry instrumentation calls in when
6165 enabled with @option{-pg -mrecord-mcount}
6169 On the x86, the inliner does not inline a
6170 function that has different target options than the caller, unless the
6171 callee has a subset of the target options of the caller. For example
6172 a function declared with @code{target("sse3")} can inline a function
6173 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
6176 @node Xstormy16 Function Attributes
6177 @subsection Xstormy16 Function Attributes
6179 These function attributes are supported by the Xstormy16 back end:
6183 @cindex @code{interrupt} function attribute, Xstormy16
6184 Use this attribute to indicate
6185 that the specified function is an interrupt handler. The compiler generates
6186 function entry and exit sequences suitable for use in an interrupt handler
6187 when this attribute is present.
6190 @node Variable Attributes
6191 @section Specifying Attributes of Variables
6192 @cindex attribute of variables
6193 @cindex variable attributes
6195 The keyword @code{__attribute__} allows you to specify special properties
6196 of variables, function parameters, or structure, union, and, in C++, class
6197 members. This @code{__attribute__} keyword is followed by an attribute
6198 specification enclosed in double parentheses. Some attributes are currently
6199 defined generically for variables. Other attributes are defined for
6200 variables on particular target systems. Other attributes are available
6201 for functions (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
6202 enumerators (@pxref{Enumerator Attributes}), statements
6203 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
6204 Other front ends might define more attributes
6205 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
6207 @xref{Attribute Syntax}, for details of the exact syntax for using
6211 * Common Variable Attributes::
6212 * ARC Variable Attributes::
6213 * AVR Variable Attributes::
6214 * Blackfin Variable Attributes::
6215 * H8/300 Variable Attributes::
6216 * IA-64 Variable Attributes::
6217 * M32R/D Variable Attributes::
6218 * MeP Variable Attributes::
6219 * Microsoft Windows Variable Attributes::
6220 * MSP430 Variable Attributes::
6221 * Nvidia PTX Variable Attributes::
6222 * PowerPC Variable Attributes::
6223 * RL78 Variable Attributes::
6224 * SPU Variable Attributes::
6225 * V850 Variable Attributes::
6226 * x86 Variable Attributes::
6227 * Xstormy16 Variable Attributes::
6230 @node Common Variable Attributes
6231 @subsection Common Variable Attributes
6233 The following attributes are supported on most targets.
6236 @cindex @code{aligned} variable attribute
6238 @itemx aligned (@var{alignment})
6239 The @code{aligned} attribute specifies a minimum alignment for the variable
6240 or structure field, measured in bytes. When specified, @var{alignment} must
6241 be an integer constant power of 2. Specifying no @var{alignment} argument
6242 implies the maximum alignment for the target, which is often, but by no
6243 means always, 8 or 16 bytes.
6245 For example, the declaration:
6248 int x __attribute__ ((aligned (16))) = 0;
6252 causes the compiler to allocate the global variable @code{x} on a
6253 16-byte boundary. On a 68040, this could be used in conjunction with
6254 an @code{asm} expression to access the @code{move16} instruction which
6255 requires 16-byte aligned operands.
6257 You can also specify the alignment of structure fields. For example, to
6258 create a double-word aligned @code{int} pair, you could write:
6261 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
6265 This is an alternative to creating a union with a @code{double} member,
6266 which forces the union to be double-word aligned.
6268 As in the preceding examples, you can explicitly specify the alignment
6269 (in bytes) that you wish the compiler to use for a given variable or
6270 structure field. Alternatively, you can leave out the alignment factor
6271 and just ask the compiler to align a variable or field to the
6272 default alignment for the target architecture you are compiling for.
6273 The default alignment is sufficient for all scalar types, but may not be
6274 enough for all vector types on a target that supports vector operations.
6275 The default alignment is fixed for a particular target ABI.
6277 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
6278 which is the largest alignment ever used for any data type on the
6279 target machine you are compiling for. For example, you could write:
6282 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
6285 The compiler automatically sets the alignment for the declared
6286 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
6287 often make copy operations more efficient, because the compiler can
6288 use whatever instructions copy the biggest chunks of memory when
6289 performing copies to or from the variables or fields that you have
6290 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
6291 may change depending on command-line options.
6293 When used on a struct, or struct member, the @code{aligned} attribute can
6294 only increase the alignment; in order to decrease it, the @code{packed}
6295 attribute must be specified as well. When used as part of a typedef, the
6296 @code{aligned} attribute can both increase and decrease alignment, and
6297 specifying the @code{packed} attribute generates a warning.
6299 Note that the effectiveness of @code{aligned} attributes for static
6300 variables may be limited by inherent limitations in the system linker
6301 and/or object file format. On some systems, the linker is
6302 only able to arrange for variables to be aligned up to a certain maximum
6303 alignment. (For some linkers, the maximum supported alignment may
6304 be very very small.) If your linker is only able to align variables
6305 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6306 in an @code{__attribute__} still only provides you with 8-byte
6307 alignment. See your linker documentation for further information.
6309 Stack variables are not affected by linker restrictions; GCC can properly
6310 align them on any target.
6312 The @code{aligned} attribute can also be used for functions
6313 (@pxref{Common Function Attributes}.)
6315 @cindex @code{warn_if_not_aligned} variable attribute
6316 @item warn_if_not_aligned (@var{alignment})
6317 This attribute specifies a threshold for the structure field, measured
6318 in bytes. If the structure field is aligned below the threshold, a
6319 warning will be issued. For example, the declaration:
6326 unsigned long long x __attribute__ ((warn_if_not_aligned (16)));
6331 causes the compiler to issue an warning on @code{struct foo}, like
6332 @samp{warning: alignment 8 of 'struct foo' is less than 16}.
6333 The compiler also issues a warning, like @samp{warning: 'x' offset
6334 8 in 'struct foo' isn't aligned to 16}, when the structure field has
6335 the misaligned offset:
6338 struct __attribute__ ((aligned (16))) foo
6342 unsigned long long x __attribute__ ((warn_if_not_aligned (16)));
6346 This warning can be disabled by @option{-Wno-if-not-aligned}.
6347 The @code{warn_if_not_aligned} attribute can also be used for types
6348 (@pxref{Common Type Attributes}.)
6350 @item alloc_size (@var{position})
6351 @itemx alloc_size (@var{position-1}, @var{position-2})
6352 @cindex @code{alloc_size} variable attribute
6353 The @code{alloc_size} variable attribute may be applied to the declaration
6354 of a pointer to a function that returns a pointer and takes at least one
6355 argument of an integer type. It indicates that the returned pointer points
6356 to an object whose size is given by the function argument at @var{position-1},
6357 or by the product of the arguments at @var{position-1} and @var{position-2}.
6358 Meaningful sizes are positive values less than @code{PTRDIFF_MAX}. Other
6359 sizes are disagnosed when detected. GCC uses this information to improve
6360 the results of @code{__builtin_object_size}.
6362 For instance, the following declarations
6365 typedef __attribute__ ((alloc_size (1, 2))) void*
6366 (*calloc_ptr) (size_t, size_t);
6367 typedef __attribute__ ((alloc_size (1))) void*
6368 (*malloc_ptr) (size_t);
6372 specify that @code{calloc_ptr} is a pointer of a function that, like
6373 the standard C function @code{calloc}, returns an object whose size
6374 is given by the product of arguments 1 and 2, and similarly, that
6375 @code{malloc_ptr}, like the standard C function @code{malloc},
6376 returns an object whose size is given by argument 1 to the function.
6378 @item cleanup (@var{cleanup_function})
6379 @cindex @code{cleanup} variable attribute
6380 The @code{cleanup} attribute runs a function when the variable goes
6381 out of scope. This attribute can only be applied to auto function
6382 scope variables; it may not be applied to parameters or variables
6383 with static storage duration. The function must take one parameter,
6384 a pointer to a type compatible with the variable. The return value
6385 of the function (if any) is ignored.
6387 If @option{-fexceptions} is enabled, then @var{cleanup_function}
6388 is run during the stack unwinding that happens during the
6389 processing of the exception. Note that the @code{cleanup} attribute
6390 does not allow the exception to be caught, only to perform an action.
6391 It is undefined what happens if @var{cleanup_function} does not
6396 @cindex @code{common} variable attribute
6397 @cindex @code{nocommon} variable attribute
6400 The @code{common} attribute requests GCC to place a variable in
6401 ``common'' storage. The @code{nocommon} attribute requests the
6402 opposite---to allocate space for it directly.
6404 These attributes override the default chosen by the
6405 @option{-fno-common} and @option{-fcommon} flags respectively.
6408 @itemx copy (@var{variable})
6409 @cindex @code{copy} variable attribute
6410 The @code{copy} attribute applies the set of attributes with which
6411 @var{variable} has been declared to the declaration of the variable
6412 to which the attribute is applied. The attribute is designed for
6413 libraries that define aliases that are expected to specify the same
6414 set of attributes as the aliased symbols. The @code{copy} attribute
6415 can be used with variables, functions or types. However, the kind
6416 of symbol to which the attribute is applied (either varible or
6417 function) must match the kind of symbol to which the argument refers.
6418 The @code{copy} attribute copies only syntactic and semantic attributes
6419 but not attributes that affect a symbol's linkage or visibility such as
6420 @code{alias}, @code{visibility}, or @code{weak}. The @code{deprecated}
6421 attribute is also not copied. @xref{Common Function Attributes}.
6422 @xref{Common Type Attributes}.
6425 @itemx deprecated (@var{msg})
6426 @cindex @code{deprecated} variable attribute
6427 The @code{deprecated} attribute results in a warning if the variable
6428 is used anywhere in the source file. This is useful when identifying
6429 variables that are expected to be removed in a future version of a
6430 program. The warning also includes the location of the declaration
6431 of the deprecated variable, to enable users to easily find further
6432 information about why the variable is deprecated, or what they should
6433 do instead. Note that the warning only occurs for uses:
6436 extern int old_var __attribute__ ((deprecated));
6438 int new_fn () @{ return old_var; @}
6442 results in a warning on line 3 but not line 2. The optional @var{msg}
6443 argument, which must be a string, is printed in the warning if
6446 The @code{deprecated} attribute can also be used for functions and
6447 types (@pxref{Common Function Attributes},
6448 @pxref{Common Type Attributes}).
6450 The message attached to the attribute is affected by the setting of
6451 the @option{-fmessage-length} option.
6453 @item mode (@var{mode})
6454 @cindex @code{mode} variable attribute
6455 This attribute specifies the data type for the declaration---whichever
6456 type corresponds to the mode @var{mode}. This in effect lets you
6457 request an integer or floating-point type according to its width.
6459 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
6460 for a list of the possible keywords for @var{mode}.
6461 You may also specify a mode of @code{byte} or @code{__byte__} to
6462 indicate the mode corresponding to a one-byte integer, @code{word} or
6463 @code{__word__} for the mode of a one-word integer, and @code{pointer}
6464 or @code{__pointer__} for the mode used to represent pointers.
6467 @cindex @code{nonstring} variable attribute
6468 The @code{nonstring} variable attribute specifies that an object or member
6469 declaration with type array of @code{char}, @code{signed char}, or
6470 @code{unsigned char}, or pointer to such a type is intended to store
6471 character arrays that do not necessarily contain a terminating @code{NUL}.
6472 This is useful in detecting uses of such arrays or pointers with functions
6473 that expect @code{NUL}-terminated strings, and to avoid warnings when such
6474 an array or pointer is used as an argument to a bounded string manipulation
6475 function such as @code{strncpy}. For example, without the attribute, GCC
6476 will issue a warning for the @code{strncpy} call below because it may
6477 truncate the copy without appending the terminating @code{NUL} character.
6478 Using the attribute makes it possible to suppress the warning. However,
6479 when the array is declared with the attribute the call to @code{strlen} is
6480 diagnosed because when the array doesn't contain a @code{NUL}-terminated
6481 string the call is undefined. To copy, compare, of search non-string
6482 character arrays use the @code{memcpy}, @code{memcmp}, @code{memchr},
6483 and other functions that operate on arrays of bytes. In addition,
6484 calling @code{strnlen} and @code{strndup} with such arrays is safe
6485 provided a suitable bound is specified, and not diagnosed.
6490 char name [32] __attribute__ ((nonstring));
6493 int f (struct Data *pd, const char *s)
6495 strncpy (pd->name, s, sizeof pd->name);
6497 return strlen (pd->name); // unsafe, gets a warning
6502 @cindex @code{packed} variable attribute
6503 The @code{packed} attribute specifies that a structure member should have
6504 the smallest possible alignment---one bit for a bit-field and one byte
6505 otherwise, unless a larger value is specified with the @code{aligned}
6506 attribute. The attribute does not apply to non-member objects.
6508 For example in the structure below, the member array @code{x} is packed
6509 so that it immediately follows @code{a} with no intervening padding:
6515 int x[2] __attribute__ ((packed));
6519 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
6520 @code{packed} attribute on bit-fields of type @code{char}. This has
6521 been fixed in GCC 4.4 but the change can lead to differences in the
6522 structure layout. See the documentation of
6523 @option{-Wpacked-bitfield-compat} for more information.
6525 @item section ("@var{section-name}")
6526 @cindex @code{section} variable attribute
6527 Normally, the compiler places the objects it generates in sections like
6528 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
6529 or you need certain particular variables to appear in special sections,
6530 for example to map to special hardware. The @code{section}
6531 attribute specifies that a variable (or function) lives in a particular
6532 section. For example, this small program uses several specific section names:
6535 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
6536 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
6537 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
6538 int init_data __attribute__ ((section ("INITDATA")));
6542 /* @r{Initialize stack pointer} */
6543 init_sp (stack + sizeof (stack));
6545 /* @r{Initialize initialized data} */
6546 memcpy (&init_data, &data, &edata - &data);
6548 /* @r{Turn on the serial ports} */
6555 Use the @code{section} attribute with
6556 @emph{global} variables and not @emph{local} variables,
6557 as shown in the example.
6559 You may use the @code{section} attribute with initialized or
6560 uninitialized global variables but the linker requires
6561 each object be defined once, with the exception that uninitialized
6562 variables tentatively go in the @code{common} (or @code{bss}) section
6563 and can be multiply ``defined''. Using the @code{section} attribute
6564 changes what section the variable goes into and may cause the
6565 linker to issue an error if an uninitialized variable has multiple
6566 definitions. You can force a variable to be initialized with the
6567 @option{-fno-common} flag or the @code{nocommon} attribute.
6569 Some file formats do not support arbitrary sections so the @code{section}
6570 attribute is not available on all platforms.
6571 If you need to map the entire contents of a module to a particular
6572 section, consider using the facilities of the linker instead.
6574 @item tls_model ("@var{tls_model}")
6575 @cindex @code{tls_model} variable attribute
6576 The @code{tls_model} attribute sets thread-local storage model
6577 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
6578 overriding @option{-ftls-model=} command-line switch on a per-variable
6580 The @var{tls_model} argument should be one of @code{global-dynamic},
6581 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
6583 Not all targets support this attribute.
6586 @cindex @code{unused} variable attribute
6587 This attribute, attached to a variable, means that the variable is meant
6588 to be possibly unused. GCC does not produce a warning for this
6592 @cindex @code{used} variable attribute
6593 This attribute, attached to a variable with static storage, means that
6594 the variable must be emitted even if it appears that the variable is not
6597 When applied to a static data member of a C++ class template, the
6598 attribute also means that the member is instantiated if the
6599 class itself is instantiated.
6601 @item vector_size (@var{bytes})
6602 @cindex @code{vector_size} variable attribute
6603 This attribute specifies the vector size for the variable, measured in
6604 bytes. For example, the declaration:
6607 int foo __attribute__ ((vector_size (16)));
6611 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
6612 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
6613 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
6615 This attribute is only applicable to integral and float scalars,
6616 although arrays, pointers, and function return values are allowed in
6617 conjunction with this construct.
6619 Aggregates with this attribute are invalid, even if they are of the same
6620 size as a corresponding scalar. For example, the declaration:
6623 struct S @{ int a; @};
6624 struct S __attribute__ ((vector_size (16))) foo;
6628 is invalid even if the size of the structure is the same as the size of
6631 @item visibility ("@var{visibility_type}")
6632 @cindex @code{visibility} variable attribute
6633 This attribute affects the linkage of the declaration to which it is attached.
6634 The @code{visibility} attribute is described in
6635 @ref{Common Function Attributes}.
6638 @cindex @code{weak} variable attribute
6639 The @code{weak} attribute is described in
6640 @ref{Common Function Attributes}.
6644 @node ARC Variable Attributes
6645 @subsection ARC Variable Attributes
6649 @cindex @code{aux} variable attribute, ARC
6650 The @code{aux} attribute is used to directly access the ARC's
6651 auxiliary register space from C. The auxilirary register number is
6652 given via attribute argument.
6656 @node AVR Variable Attributes
6657 @subsection AVR Variable Attributes
6661 @cindex @code{progmem} variable attribute, AVR
6662 The @code{progmem} attribute is used on the AVR to place read-only
6663 data in the non-volatile program memory (flash). The @code{progmem}
6664 attribute accomplishes this by putting respective variables into a
6665 section whose name starts with @code{.progmem}.
6667 This attribute works similar to the @code{section} attribute
6668 but adds additional checking.
6671 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
6672 @code{progmem} affects the location
6673 of the data but not how this data is accessed.
6674 In order to read data located with the @code{progmem} attribute
6675 (inline) assembler must be used.
6677 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
6678 #include <avr/pgmspace.h>
6680 /* Locate var in flash memory */
6681 const int var[2] PROGMEM = @{ 1, 2 @};
6683 int read_var (int i)
6685 /* Access var[] by accessor macro from avr/pgmspace.h */
6686 return (int) pgm_read_word (& var[i]);
6690 AVR is a Harvard architecture processor and data and read-only data
6691 normally resides in the data memory (RAM).
6693 See also the @ref{AVR Named Address Spaces} section for
6694 an alternate way to locate and access data in flash memory.
6696 @item @bullet{}@tie{} AVR cores with flash memory visible in the RAM address range:
6697 On such devices, there is no need for attribute @code{progmem} or
6698 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
6699 Just use standard C / C++. The compiler will generate @code{LD*}
6700 instructions. As flash memory is visible in the RAM address range,
6701 and the default linker script does @emph{not} locate @code{.rodata} in
6702 RAM, no special features are needed in order not to waste RAM for
6703 read-only data or to read from flash. You might even get slightly better
6705 avoiding @code{progmem} and @code{__flash}. This applies to devices from
6706 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
6709 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
6710 The compiler adds @code{0x4000}
6711 to the addresses of objects and declarations in @code{progmem} and locates
6712 the objects in flash memory, namely in section @code{.progmem.data}.
6713 The offset is needed because the flash memory is visible in the RAM
6714 address space starting at address @code{0x4000}.
6716 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
6717 no special functions or macros are needed.
6720 /* var is located in flash memory */
6721 extern const int var[2] __attribute__((progmem));
6723 int read_var (int i)
6729 Please notice that on these devices, there is no need for @code{progmem}
6735 @itemx io (@var{addr})
6736 @cindex @code{io} variable attribute, AVR
6737 Variables with the @code{io} attribute are used to address
6738 memory-mapped peripherals in the io address range.
6739 If an address is specified, the variable
6740 is assigned that address, and the value is interpreted as an
6741 address in the data address space.
6745 volatile int porta __attribute__((io (0x22)));
6748 The address specified in the address in the data address range.
6750 Otherwise, the variable it is not assigned an address, but the
6751 compiler will still use in/out instructions where applicable,
6752 assuming some other module assigns an address in the io address range.
6756 extern volatile int porta __attribute__((io));
6760 @itemx io_low (@var{addr})
6761 @cindex @code{io_low} variable attribute, AVR
6762 This is like the @code{io} attribute, but additionally it informs the
6763 compiler that the object lies in the lower half of the I/O area,
6764 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
6768 @itemx address (@var{addr})
6769 @cindex @code{address} variable attribute, AVR
6770 Variables with the @code{address} attribute are used to address
6771 memory-mapped peripherals that may lie outside the io address range.
6774 volatile int porta __attribute__((address (0x600)));
6778 @cindex @code{absdata} variable attribute, AVR
6779 Variables in static storage and with the @code{absdata} attribute can
6780 be accessed by the @code{LDS} and @code{STS} instructions which take
6785 This attribute is only supported for the reduced AVR Tiny core
6789 You must make sure that respective data is located in the
6790 address range @code{0x40}@dots{}@code{0xbf} accessible by
6791 @code{LDS} and @code{STS}. One way to achieve this as an
6792 appropriate linker description file.
6795 If the location does not fit the address range of @code{LDS}
6796 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6799 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6804 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6808 @node Blackfin Variable Attributes
6809 @subsection Blackfin Variable Attributes
6811 Three attributes are currently defined for the Blackfin.
6817 @cindex @code{l1_data} variable attribute, Blackfin
6818 @cindex @code{l1_data_A} variable attribute, Blackfin
6819 @cindex @code{l1_data_B} variable attribute, Blackfin
6820 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6821 Variables with @code{l1_data} attribute are put into the specific section
6822 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6823 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6824 attribute are put into the specific section named @code{.l1.data.B}.
6827 @cindex @code{l2} variable attribute, Blackfin
6828 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6829 Variables with @code{l2} attribute are put into the specific section
6830 named @code{.l2.data}.
6833 @node H8/300 Variable Attributes
6834 @subsection H8/300 Variable Attributes
6836 These variable attributes are available for H8/300 targets:
6840 @cindex @code{eightbit_data} variable attribute, H8/300
6841 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6842 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6843 variable should be placed into the eight-bit data section.
6844 The compiler generates more efficient code for certain operations
6845 on data in the eight-bit data area. Note the eight-bit data area is limited to
6848 You must use GAS and GLD from GNU binutils version 2.7 or later for
6849 this attribute to work correctly.
6852 @cindex @code{tiny_data} variable attribute, H8/300
6853 @cindex tiny data section on the H8/300H and H8S
6854 Use this attribute on the H8/300H and H8S to indicate that the specified
6855 variable should be placed into the tiny data section.
6856 The compiler generates more efficient code for loads and stores
6857 on data in the tiny data section. Note the tiny data area is limited to
6858 slightly under 32KB of data.
6862 @node IA-64 Variable Attributes
6863 @subsection IA-64 Variable Attributes
6865 The IA-64 back end supports the following variable attribute:
6868 @item model (@var{model-name})
6869 @cindex @code{model} variable attribute, IA-64
6871 On IA-64, use this attribute to set the addressability of an object.
6872 At present, the only supported identifier for @var{model-name} is
6873 @code{small}, indicating addressability via ``small'' (22-bit)
6874 addresses (so that their addresses can be loaded with the @code{addl}
6875 instruction). Caveat: such addressing is by definition not position
6876 independent and hence this attribute must not be used for objects
6877 defined by shared libraries.
6881 @node M32R/D Variable Attributes
6882 @subsection M32R/D Variable Attributes
6884 One attribute is currently defined for the M32R/D@.
6887 @item model (@var{model-name})
6888 @cindex @code{model-name} variable attribute, M32R/D
6889 @cindex variable addressability on the M32R/D
6890 Use this attribute on the M32R/D to set the addressability of an object.
6891 The identifier @var{model-name} is one of @code{small}, @code{medium},
6892 or @code{large}, representing each of the code models.
6894 Small model objects live in the lower 16MB of memory (so that their
6895 addresses can be loaded with the @code{ld24} instruction).
6897 Medium and large model objects may live anywhere in the 32-bit address space
6898 (the compiler generates @code{seth/add3} instructions to load their
6902 @node MeP Variable Attributes
6903 @subsection MeP Variable Attributes
6905 The MeP target has a number of addressing modes and busses. The
6906 @code{near} space spans the standard memory space's first 16 megabytes
6907 (24 bits). The @code{far} space spans the entire 32-bit memory space.
6908 The @code{based} space is a 128-byte region in the memory space that
6909 is addressed relative to the @code{$tp} register. The @code{tiny}
6910 space is a 65536-byte region relative to the @code{$gp} register. In
6911 addition to these memory regions, the MeP target has a separate 16-bit
6912 control bus which is specified with @code{cb} attributes.
6917 @cindex @code{based} variable attribute, MeP
6918 Any variable with the @code{based} attribute is assigned to the
6919 @code{.based} section, and is accessed with relative to the
6920 @code{$tp} register.
6923 @cindex @code{tiny} variable attribute, MeP
6924 Likewise, the @code{tiny} attribute assigned variables to the
6925 @code{.tiny} section, relative to the @code{$gp} register.
6928 @cindex @code{near} variable attribute, MeP
6929 Variables with the @code{near} attribute are assumed to have addresses
6930 that fit in a 24-bit addressing mode. This is the default for large
6931 variables (@code{-mtiny=4} is the default) but this attribute can
6932 override @code{-mtiny=} for small variables, or override @code{-ml}.
6935 @cindex @code{far} variable attribute, MeP
6936 Variables with the @code{far} attribute are addressed using a full
6937 32-bit address. Since this covers the entire memory space, this
6938 allows modules to make no assumptions about where variables might be
6942 @cindex @code{io} variable attribute, MeP
6943 @itemx io (@var{addr})
6944 Variables with the @code{io} attribute are used to address
6945 memory-mapped peripherals. If an address is specified, the variable
6946 is assigned that address, else it is not assigned an address (it is
6947 assumed some other module assigns an address). Example:
6950 int timer_count __attribute__((io(0x123)));
6954 @itemx cb (@var{addr})
6955 @cindex @code{cb} variable attribute, MeP
6956 Variables with the @code{cb} attribute are used to access the control
6957 bus, using special instructions. @code{addr} indicates the control bus
6961 int cpu_clock __attribute__((cb(0x123)));
6966 @node Microsoft Windows Variable Attributes
6967 @subsection Microsoft Windows Variable Attributes
6969 You can use these attributes on Microsoft Windows targets.
6970 @ref{x86 Variable Attributes} for additional Windows compatibility
6971 attributes available on all x86 targets.
6976 @cindex @code{dllimport} variable attribute
6977 @cindex @code{dllexport} variable attribute
6978 The @code{dllimport} and @code{dllexport} attributes are described in
6979 @ref{Microsoft Windows Function Attributes}.
6982 @cindex @code{selectany} variable attribute
6983 The @code{selectany} attribute causes an initialized global variable to
6984 have link-once semantics. When multiple definitions of the variable are
6985 encountered by the linker, the first is selected and the remainder are
6986 discarded. Following usage by the Microsoft compiler, the linker is told
6987 @emph{not} to warn about size or content differences of the multiple
6990 Although the primary usage of this attribute is for POD types, the
6991 attribute can also be applied to global C++ objects that are initialized
6992 by a constructor. In this case, the static initialization and destruction
6993 code for the object is emitted in each translation defining the object,
6994 but the calls to the constructor and destructor are protected by a
6995 link-once guard variable.
6997 The @code{selectany} attribute is only available on Microsoft Windows
6998 targets. You can use @code{__declspec (selectany)} as a synonym for
6999 @code{__attribute__ ((selectany))} for compatibility with other
7003 @cindex @code{shared} variable attribute
7004 On Microsoft Windows, in addition to putting variable definitions in a named
7005 section, the section can also be shared among all running copies of an
7006 executable or DLL@. For example, this small program defines shared data
7007 by putting it in a named section @code{shared} and marking the section
7011 int foo __attribute__((section ("shared"), shared)) = 0;
7016 /* @r{Read and write foo. All running
7017 copies see the same value.} */
7023 You may only use the @code{shared} attribute along with @code{section}
7024 attribute with a fully-initialized global definition because of the way
7025 linkers work. See @code{section} attribute for more information.
7027 The @code{shared} attribute is only available on Microsoft Windows@.
7031 @node MSP430 Variable Attributes
7032 @subsection MSP430 Variable Attributes
7036 @cindex @code{noinit} variable attribute, MSP430
7037 Any data with the @code{noinit} attribute will not be initialised by
7038 the C runtime startup code, or the program loader. Not initialising
7039 data in this way can reduce program startup times.
7042 @cindex @code{persistent} variable attribute, MSP430
7043 Any variable with the @code{persistent} attribute will not be
7044 initialised by the C runtime startup code. Instead its value will be
7045 set once, when the application is loaded, and then never initialised
7046 again, even if the processor is reset or the program restarts.
7047 Persistent data is intended to be placed into FLASH RAM, where its
7048 value will be retained across resets. The linker script being used to
7049 create the application should ensure that persistent data is correctly
7055 @cindex @code{lower} variable attribute, MSP430
7056 @cindex @code{upper} variable attribute, MSP430
7057 @cindex @code{either} variable attribute, MSP430
7058 These attributes are the same as the MSP430 function attributes of the
7059 same name (@pxref{MSP430 Function Attributes}).
7060 These attributes can be applied to both functions and variables.
7063 @node Nvidia PTX Variable Attributes
7064 @subsection Nvidia PTX Variable Attributes
7066 These variable attributes are supported by the Nvidia PTX back end:
7070 @cindex @code{shared} attribute, Nvidia PTX
7071 Use this attribute to place a variable in the @code{.shared} memory space.
7072 This memory space is private to each cooperative thread array; only threads
7073 within one thread block refer to the same instance of the variable.
7074 The runtime does not initialize variables in this memory space.
7077 @node PowerPC Variable Attributes
7078 @subsection PowerPC Variable Attributes
7080 Three attributes currently are defined for PowerPC configurations:
7081 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7083 @cindex @code{ms_struct} variable attribute, PowerPC
7084 @cindex @code{gcc_struct} variable attribute, PowerPC
7085 For full documentation of the struct attributes please see the
7086 documentation in @ref{x86 Variable Attributes}.
7088 @cindex @code{altivec} variable attribute, PowerPC
7089 For documentation of @code{altivec} attribute please see the
7090 documentation in @ref{PowerPC Type Attributes}.
7092 @node RL78 Variable Attributes
7093 @subsection RL78 Variable Attributes
7095 @cindex @code{saddr} variable attribute, RL78
7096 The RL78 back end supports the @code{saddr} variable attribute. This
7097 specifies placement of the corresponding variable in the SADDR area,
7098 which can be accessed more efficiently than the default memory region.
7100 @node SPU Variable Attributes
7101 @subsection SPU Variable Attributes
7103 @cindex @code{spu_vector} variable attribute, SPU
7104 The SPU supports the @code{spu_vector} attribute for variables. For
7105 documentation of this attribute please see the documentation in
7106 @ref{SPU Type Attributes}.
7108 @node V850 Variable Attributes
7109 @subsection V850 Variable Attributes
7111 These variable attributes are supported by the V850 back end:
7116 @cindex @code{sda} variable attribute, V850
7117 Use this attribute to explicitly place a variable in the small data area,
7118 which can hold up to 64 kilobytes.
7121 @cindex @code{tda} variable attribute, V850
7122 Use this attribute to explicitly place a variable in the tiny data area,
7123 which can hold up to 256 bytes in total.
7126 @cindex @code{zda} variable attribute, V850
7127 Use this attribute to explicitly place a variable in the first 32 kilobytes
7131 @node x86 Variable Attributes
7132 @subsection x86 Variable Attributes
7134 Two attributes are currently defined for x86 configurations:
7135 @code{ms_struct} and @code{gcc_struct}.
7140 @cindex @code{ms_struct} variable attribute, x86
7141 @cindex @code{gcc_struct} variable attribute, x86
7143 If @code{packed} is used on a structure, or if bit-fields are used,
7144 it may be that the Microsoft ABI lays out the structure differently
7145 than the way GCC normally does. Particularly when moving packed
7146 data between functions compiled with GCC and the native Microsoft compiler
7147 (either via function call or as data in a file), it may be necessary to access
7150 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7151 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7152 command-line options, respectively;
7153 see @ref{x86 Options}, for details of how structure layout is affected.
7154 @xref{x86 Type Attributes}, for information about the corresponding
7155 attributes on types.
7159 @node Xstormy16 Variable Attributes
7160 @subsection Xstormy16 Variable Attributes
7162 One attribute is currently defined for xstormy16 configurations:
7167 @cindex @code{below100} variable attribute, Xstormy16
7169 If a variable has the @code{below100} attribute (@code{BELOW100} is
7170 allowed also), GCC places the variable in the first 0x100 bytes of
7171 memory and use special opcodes to access it. Such variables are
7172 placed in either the @code{.bss_below100} section or the
7173 @code{.data_below100} section.
7177 @node Type Attributes
7178 @section Specifying Attributes of Types
7179 @cindex attribute of types
7180 @cindex type attributes
7182 The keyword @code{__attribute__} allows you to specify various special
7183 properties of types. Some type attributes apply only to structure and
7184 union types, and in C++, also class types, while others can apply to
7185 any type defined via a @code{typedef} declaration. Unless otherwise
7186 specified, the same restrictions and effects apply to attributes regardless
7187 of whether a type is a trivial structure or a C++ class with user-defined
7188 constructors, destructors, or a copy assignment.
7190 Other attributes are defined for functions (@pxref{Function Attributes}),
7191 labels (@pxref{Label Attributes}), enumerators (@pxref{Enumerator
7192 Attributes}), statements (@pxref{Statement Attributes}), and for variables
7193 (@pxref{Variable Attributes}).
7195 The @code{__attribute__} keyword is followed by an attribute specification
7196 enclosed in double parentheses.
7198 You may specify type attributes in an enum, struct or union type
7199 declaration or definition by placing them immediately after the
7200 @code{struct}, @code{union} or @code{enum} keyword. You can also place
7201 them just past the closing curly brace of the definition, but this is less
7202 preferred because logically the type should be fully defined at
7205 You can also include type attributes in a @code{typedef} declaration.
7206 @xref{Attribute Syntax}, for details of the exact syntax for using
7210 * Common Type Attributes::
7211 * ARC Type Attributes::
7212 * ARM Type Attributes::
7213 * MeP Type Attributes::
7214 * PowerPC Type Attributes::
7215 * SPU Type Attributes::
7216 * x86 Type Attributes::
7219 @node Common Type Attributes
7220 @subsection Common Type Attributes
7222 The following type attributes are supported on most targets.
7225 @cindex @code{aligned} type attribute
7227 @itemx aligned (@var{alignment})
7228 The @code{aligned} attribute specifies a minimum alignment (in bytes) for
7229 variables of the specified type. When specified, @var{alignment} must be
7230 a power of 2. Specifying no @var{alignment} argument implies the maximum
7231 alignment for the target, which is often, but by no means always, 8 or 16
7232 bytes. For example, the declarations:
7235 struct __attribute__ ((aligned (8))) S @{ short f[3]; @};
7236 typedef int more_aligned_int __attribute__ ((aligned (8)));
7240 force the compiler to ensure (as far as it can) that each variable whose
7241 type is @code{struct S} or @code{more_aligned_int} is allocated and
7242 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
7243 variables of type @code{struct S} aligned to 8-byte boundaries allows
7244 the compiler to use the @code{ldd} and @code{std} (doubleword load and
7245 store) instructions when copying one variable of type @code{struct S} to
7246 another, thus improving run-time efficiency.
7248 Note that the alignment of any given @code{struct} or @code{union} type
7249 is required by the ISO C standard to be at least a perfect multiple of
7250 the lowest common multiple of the alignments of all of the members of
7251 the @code{struct} or @code{union} in question. This means that you @emph{can}
7252 effectively adjust the alignment of a @code{struct} or @code{union}
7253 type by attaching an @code{aligned} attribute to any one of the members
7254 of such a type, but the notation illustrated in the example above is a
7255 more obvious, intuitive, and readable way to request the compiler to
7256 adjust the alignment of an entire @code{struct} or @code{union} type.
7258 As in the preceding example, you can explicitly specify the alignment
7259 (in bytes) that you wish the compiler to use for a given @code{struct}
7260 or @code{union} type. Alternatively, you can leave out the alignment factor
7261 and just ask the compiler to align a type to the maximum
7262 useful alignment for the target machine you are compiling for. For
7263 example, you could write:
7266 struct __attribute__ ((aligned)) S @{ short f[3]; @};
7269 Whenever you leave out the alignment factor in an @code{aligned}
7270 attribute specification, the compiler automatically sets the alignment
7271 for the type to the largest alignment that is ever used for any data
7272 type on the target machine you are compiling for. Doing this can often
7273 make copy operations more efficient, because the compiler can use
7274 whatever instructions copy the biggest chunks of memory when performing
7275 copies to or from the variables that have types that you have aligned
7278 In the example above, if the size of each @code{short} is 2 bytes, then
7279 the size of the entire @code{struct S} type is 6 bytes. The smallest
7280 power of two that is greater than or equal to that is 8, so the
7281 compiler sets the alignment for the entire @code{struct S} type to 8
7284 Note that although you can ask the compiler to select a time-efficient
7285 alignment for a given type and then declare only individual stand-alone
7286 objects of that type, the compiler's ability to select a time-efficient
7287 alignment is primarily useful only when you plan to create arrays of
7288 variables having the relevant (efficiently aligned) type. If you
7289 declare or use arrays of variables of an efficiently-aligned type, then
7290 it is likely that your program also does pointer arithmetic (or
7291 subscripting, which amounts to the same thing) on pointers to the
7292 relevant type, and the code that the compiler generates for these
7293 pointer arithmetic operations is often more efficient for
7294 efficiently-aligned types than for other types.
7296 Note that the effectiveness of @code{aligned} attributes may be limited
7297 by inherent limitations in your linker. On many systems, the linker is
7298 only able to arrange for variables to be aligned up to a certain maximum
7299 alignment. (For some linkers, the maximum supported alignment may
7300 be very very small.) If your linker is only able to align variables
7301 up to a maximum of 8-byte alignment, then specifying @code{aligned (16)}
7302 in an @code{__attribute__} still only provides you with 8-byte
7303 alignment. See your linker documentation for further information.
7305 When used on a struct, or struct member, the @code{aligned} attribute can
7306 only increase the alignment; in order to decrease it, the @code{packed}
7307 attribute must be specified as well. When used as part of a typedef, the
7308 @code{aligned} attribute can both increase and decrease alignment, and
7309 specifying the @code{packed} attribute generates a warning.
7311 @cindex @code{warn_if_not_aligned} type attribute
7312 @item warn_if_not_aligned (@var{alignment})
7313 This attribute specifies a threshold for the structure field, measured
7314 in bytes. If the structure field is aligned below the threshold, a
7315 warning will be issued. For example, the declaration:
7318 typedef unsigned long long __u64
7319 __attribute__((aligned (4), warn_if_not_aligned (8)));
7330 causes the compiler to issue an warning on @code{struct foo}, like
7331 @samp{warning: alignment 4 of 'struct foo' is less than 8}.
7332 It is used to define @code{struct foo} in such a way that
7333 @code{struct foo} has the same layout and the structure field @code{x}
7334 has the same alignment when @code{__u64} is aligned at either 4 or
7335 8 bytes. Align @code{struct foo} to 8 bytes:
7338 struct __attribute__ ((aligned (8))) foo
7347 silences the warning. The compiler also issues a warning, like
7348 @samp{warning: 'x' offset 12 in 'struct foo' isn't aligned to 8},
7349 when the structure field has the misaligned offset:
7352 struct __attribute__ ((aligned (8))) foo
7361 This warning can be disabled by @option{-Wno-if-not-aligned}.
7363 @item alloc_size (@var{position})
7364 @itemx alloc_size (@var{position-1}, @var{position-2})
7365 @cindex @code{alloc_size} type attribute
7366 The @code{alloc_size} type attribute may be applied to the definition
7367 of a type of a function that returns a pointer and takes at least one
7368 argument of an integer type. It indicates that the returned pointer
7369 points to an object whose size is given by the function argument at
7370 @var{position-1}, or by the product of the arguments at @var{position-1}
7371 and @var{position-2}. Meaningful sizes are positive values less than
7372 @code{PTRDIFF_MAX}. Other sizes are disagnosed when detected. GCC uses
7373 this information to improve the results of @code{__builtin_object_size}.
7375 For instance, the following declarations
7378 typedef __attribute__ ((alloc_size (1, 2))) void*
7379 calloc_type (size_t, size_t);
7380 typedef __attribute__ ((alloc_size (1))) void*
7381 malloc_type (size_t);
7385 specify that @code{calloc_type} is a type of a function that, like
7386 the standard C function @code{calloc}, returns an object whose size
7387 is given by the product of arguments 1 and 2, and that
7388 @code{malloc_type}, like the standard C function @code{malloc},
7389 returns an object whose size is given by argument 1 to the function.
7392 @itemx copy (@var{expression})
7393 @cindex @code{copy} type attribute
7394 The @code{copy} attribute applies the set of attributes with which
7395 the type of the @var{expression} has been declared to the declaration
7396 of the type to which the attribute is applied. The attribute is
7397 designed for libraries that define aliases that are expected to
7398 specify the same set of attributes as the aliased symbols.
7399 The @code{copy} attribute can be used with types, variables, or
7400 functions. However, the kind of symbol to which the attribute is
7401 applied (either varible or function) must match the kind of symbol
7402 to which the argument refers.
7403 The @code{copy} attribute copies only syntactic and semantic attributes
7404 but not attributes that affect a symbol's linkage or visibility such as
7405 @code{alias}, @code{visibility}, or @code{weak}. The @code{deprecated}
7406 attribute is also not copied. @xref{Common Function Attributes}.
7407 @xref{Common Variable Attributes}.
7409 For example, suppose @code{struct A} below is defined in some third
7410 party library header to have the alignment requirement @code{N} and
7411 to force a warning whenever a variable of the type is not so aligned
7412 due to attribute @code{packed}. Specifying the @code{copy} attribute
7413 on the definition on the unrelated @code{struct B} has the effect of
7414 copying all relevant attributes from the type referenced by the pointer
7415 expression to @code{struct B}.
7418 struct __attribute__ ((aligned (N), warn_if_not_aligned (N)))
7419 A @{ /* @r{@dots{}} */ @};
7420 struct __attribute__ ((copy ( (struct A *)0)) B @{ /* @r{@dots{}} */ @};
7424 @itemx deprecated (@var{msg})
7425 @cindex @code{deprecated} type attribute
7426 The @code{deprecated} attribute results in a warning if the type
7427 is used anywhere in the source file. This is useful when identifying
7428 types that are expected to be removed in a future version of a program.
7429 If possible, the warning also includes the location of the declaration
7430 of the deprecated type, to enable users to easily find further
7431 information about why the type is deprecated, or what they should do
7432 instead. Note that the warnings only occur for uses and then only
7433 if the type is being applied to an identifier that itself is not being
7434 declared as deprecated.
7437 typedef int T1 __attribute__ ((deprecated));
7441 typedef T1 T3 __attribute__ ((deprecated));
7442 T3 z __attribute__ ((deprecated));
7446 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
7447 warning is issued for line 4 because T2 is not explicitly
7448 deprecated. Line 5 has no warning because T3 is explicitly
7449 deprecated. Similarly for line 6. The optional @var{msg}
7450 argument, which must be a string, is printed in the warning if
7451 present. Control characters in the string will be replaced with
7452 escape sequences, and if the @option{-fmessage-length} option is set
7453 to 0 (its default value) then any newline characters will be ignored.
7455 The @code{deprecated} attribute can also be used for functions and
7456 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
7458 The message attached to the attribute is affected by the setting of
7459 the @option{-fmessage-length} option.
7461 @item designated_init
7462 @cindex @code{designated_init} type attribute
7463 This attribute may only be applied to structure types. It indicates
7464 that any initialization of an object of this type must use designated
7465 initializers rather than positional initializers. The intent of this
7466 attribute is to allow the programmer to indicate that a structure's
7467 layout may change, and that therefore relying on positional
7468 initialization will result in future breakage.
7470 GCC emits warnings based on this attribute by default; use
7471 @option{-Wno-designated-init} to suppress them.
7474 @cindex @code{may_alias} type attribute
7475 Accesses through pointers to types with this attribute are not subject
7476 to type-based alias analysis, but are instead assumed to be able to alias
7477 any other type of objects.
7478 In the context of section 6.5 paragraph 7 of the C99 standard,
7479 an lvalue expression
7480 dereferencing such a pointer is treated like having a character type.
7481 See @option{-fstrict-aliasing} for more information on aliasing issues.
7482 This extension exists to support some vector APIs, in which pointers to
7483 one vector type are permitted to alias pointers to a different vector type.
7485 Note that an object of a type with this attribute does not have any
7491 typedef short __attribute__ ((__may_alias__)) short_a;
7497 short_a *b = (short_a *) &a;
7501 if (a == 0x12345678)
7509 If you replaced @code{short_a} with @code{short} in the variable
7510 declaration, the above program would abort when compiled with
7511 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
7514 @item mode (@var{mode})
7515 @cindex @code{mode} type attribute
7516 This attribute specifies the data type for the declaration---whichever
7517 type corresponds to the mode @var{mode}. This in effect lets you
7518 request an integer or floating-point type according to its width.
7520 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
7521 for a list of the possible keywords for @var{mode}.
7522 You may also specify a mode of @code{byte} or @code{__byte__} to
7523 indicate the mode corresponding to a one-byte integer, @code{word} or
7524 @code{__word__} for the mode of a one-word integer, and @code{pointer}
7525 or @code{__pointer__} for the mode used to represent pointers.
7528 @cindex @code{packed} type attribute
7529 This attribute, attached to a @code{struct}, @code{union}, or C++ @code{class}
7530 type definition, specifies that each of its members (other than zero-width
7531 bit-fields) is placed to minimize the memory required. This is equivalent
7532 to specifying the @code{packed} attribute on each of the members.
7534 @opindex fshort-enums
7535 When attached to an @code{enum} definition, the @code{packed} attribute
7536 indicates that the smallest integral type should be used.
7537 Specifying the @option{-fshort-enums} flag on the command line
7538 is equivalent to specifying the @code{packed}
7539 attribute on all @code{enum} definitions.
7541 In the following example @code{struct my_packed_struct}'s members are
7542 packed closely together, but the internal layout of its @code{s} member
7543 is not packed---to do that, @code{struct my_unpacked_struct} needs to
7547 struct my_unpacked_struct
7553 struct __attribute__ ((__packed__)) my_packed_struct
7557 struct my_unpacked_struct s;
7561 You may only specify the @code{packed} attribute on the definition
7562 of an @code{enum}, @code{struct}, @code{union}, or @code{class},
7563 not on a @code{typedef} that does not also define the enumerated type,
7564 structure, union, or class.
7566 @item scalar_storage_order ("@var{endianness}")
7567 @cindex @code{scalar_storage_order} type attribute
7568 When attached to a @code{union} or a @code{struct}, this attribute sets
7569 the storage order, aka endianness, of the scalar fields of the type, as
7570 well as the array fields whose component is scalar. The supported
7571 endiannesses are @code{big-endian} and @code{little-endian}. The attribute
7572 has no effects on fields which are themselves a @code{union}, a @code{struct}
7573 or an array whose component is a @code{union} or a @code{struct}, and it is
7574 possible for these fields to have a different scalar storage order than the
7577 This attribute is supported only for targets that use a uniform default
7578 scalar storage order (fortunately, most of them), i.e.@: targets that store
7579 the scalars either all in big-endian or all in little-endian.
7581 Additional restrictions are enforced for types with the reverse scalar
7582 storage order with regard to the scalar storage order of the target:
7585 @item Taking the address of a scalar field of a @code{union} or a
7586 @code{struct} with reverse scalar storage order is not permitted and yields
7588 @item Taking the address of an array field, whose component is scalar, of
7589 a @code{union} or a @code{struct} with reverse scalar storage order is
7590 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
7592 @item Taking the address of a @code{union} or a @code{struct} with reverse
7593 scalar storage order is permitted.
7596 These restrictions exist because the storage order attribute is lost when
7597 the address of a scalar or the address of an array with scalar component is
7598 taken, so storing indirectly through this address generally does not work.
7599 The second case is nevertheless allowed to be able to perform a block copy
7600 from or to the array.
7602 Moreover, the use of type punning or aliasing to toggle the storage order
7603 is not supported; that is to say, a given scalar object cannot be accessed
7604 through distinct types that assign a different storage order to it.
7606 @item transparent_union
7607 @cindex @code{transparent_union} type attribute
7609 This attribute, attached to a @code{union} type definition, indicates
7610 that any function parameter having that union type causes calls to that
7611 function to be treated in a special way.
7613 First, the argument corresponding to a transparent union type can be of
7614 any type in the union; no cast is required. Also, if the union contains
7615 a pointer type, the corresponding argument can be a null pointer
7616 constant or a void pointer expression; and if the union contains a void
7617 pointer type, the corresponding argument can be any pointer expression.
7618 If the union member type is a pointer, qualifiers like @code{const} on
7619 the referenced type must be respected, just as with normal pointer
7622 Second, the argument is passed to the function using the calling
7623 conventions of the first member of the transparent union, not the calling
7624 conventions of the union itself. All members of the union must have the
7625 same machine representation; this is necessary for this argument passing
7628 Transparent unions are designed for library functions that have multiple
7629 interfaces for compatibility reasons. For example, suppose the
7630 @code{wait} function must accept either a value of type @code{int *} to
7631 comply with POSIX, or a value of type @code{union wait *} to comply with
7632 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
7633 @code{wait} would accept both kinds of arguments, but it would also
7634 accept any other pointer type and this would make argument type checking
7635 less useful. Instead, @code{<sys/wait.h>} might define the interface
7639 typedef union __attribute__ ((__transparent_union__))
7643 @} wait_status_ptr_t;
7645 pid_t wait (wait_status_ptr_t);
7649 This interface allows either @code{int *} or @code{union wait *}
7650 arguments to be passed, using the @code{int *} calling convention.
7651 The program can call @code{wait} with arguments of either type:
7654 int w1 () @{ int w; return wait (&w); @}
7655 int w2 () @{ union wait w; return wait (&w); @}
7659 With this interface, @code{wait}'s implementation might look like this:
7662 pid_t wait (wait_status_ptr_t p)
7664 return waitpid (-1, p.__ip, 0);
7669 @cindex @code{unused} type attribute
7670 When attached to a type (including a @code{union} or a @code{struct}),
7671 this attribute means that variables of that type are meant to appear
7672 possibly unused. GCC does not produce a warning for any variables of
7673 that type, even if the variable appears to do nothing. This is often
7674 the case with lock or thread classes, which are usually defined and then
7675 not referenced, but contain constructors and destructors that have
7676 nontrivial bookkeeping functions.
7679 @cindex @code{visibility} type attribute
7680 In C++, attribute visibility (@pxref{Function Attributes}) can also be
7681 applied to class, struct, union and enum types. Unlike other type
7682 attributes, the attribute must appear between the initial keyword and
7683 the name of the type; it cannot appear after the body of the type.
7685 Note that the type visibility is applied to vague linkage entities
7686 associated with the class (vtable, typeinfo node, etc.). In
7687 particular, if a class is thrown as an exception in one shared object
7688 and caught in another, the class must have default visibility.
7689 Otherwise the two shared objects are unable to use the same
7690 typeinfo node and exception handling will break.
7694 To specify multiple attributes, separate them by commas within the
7695 double parentheses: for example, @samp{__attribute__ ((aligned (16),
7698 @node ARC Type Attributes
7699 @subsection ARC Type Attributes
7701 @cindex @code{uncached} type attribute, ARC
7702 Declaring objects with @code{uncached} allows you to exclude
7703 data-cache participation in load and store operations on those objects
7704 without involving the additional semantic implications of
7705 @code{volatile}. The @code{.di} instruction suffix is used for all
7706 loads and stores of data declared @code{uncached}.
7708 @node ARM Type Attributes
7709 @subsection ARM Type Attributes
7711 @cindex @code{notshared} type attribute, ARM
7712 On those ARM targets that support @code{dllimport} (such as Symbian
7713 OS), you can use the @code{notshared} attribute to indicate that the
7714 virtual table and other similar data for a class should not be
7715 exported from a DLL@. For example:
7718 class __declspec(notshared) C @{
7720 __declspec(dllimport) C();
7724 __declspec(dllexport)
7729 In this code, @code{C::C} is exported from the current DLL, but the
7730 virtual table for @code{C} is not exported. (You can use
7731 @code{__attribute__} instead of @code{__declspec} if you prefer, but
7732 most Symbian OS code uses @code{__declspec}.)
7734 @node MeP Type Attributes
7735 @subsection MeP Type Attributes
7737 @cindex @code{based} type attribute, MeP
7738 @cindex @code{tiny} type attribute, MeP
7739 @cindex @code{near} type attribute, MeP
7740 @cindex @code{far} type attribute, MeP
7741 Many of the MeP variable attributes may be applied to types as well.
7742 Specifically, the @code{based}, @code{tiny}, @code{near}, and
7743 @code{far} attributes may be applied to either. The @code{io} and
7744 @code{cb} attributes may not be applied to types.
7746 @node PowerPC Type Attributes
7747 @subsection PowerPC Type Attributes
7749 Three attributes currently are defined for PowerPC configurations:
7750 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7752 @cindex @code{ms_struct} type attribute, PowerPC
7753 @cindex @code{gcc_struct} type attribute, PowerPC
7754 For full documentation of the @code{ms_struct} and @code{gcc_struct}
7755 attributes please see the documentation in @ref{x86 Type Attributes}.
7757 @cindex @code{altivec} type attribute, PowerPC
7758 The @code{altivec} attribute allows one to declare AltiVec vector data
7759 types supported by the AltiVec Programming Interface Manual. The
7760 attribute requires an argument to specify one of three vector types:
7761 @code{vector__}, @code{pixel__} (always followed by unsigned short),
7762 and @code{bool__} (always followed by unsigned).
7765 __attribute__((altivec(vector__)))
7766 __attribute__((altivec(pixel__))) unsigned short
7767 __attribute__((altivec(bool__))) unsigned
7770 These attributes mainly are intended to support the @code{__vector},
7771 @code{__pixel}, and @code{__bool} AltiVec keywords.
7773 @node SPU Type Attributes
7774 @subsection SPU Type Attributes
7776 @cindex @code{spu_vector} type attribute, SPU
7777 The SPU supports the @code{spu_vector} attribute for types. This attribute
7778 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
7779 Language Extensions Specification. It is intended to support the
7780 @code{__vector} keyword.
7782 @node x86 Type Attributes
7783 @subsection x86 Type Attributes
7785 Two attributes are currently defined for x86 configurations:
7786 @code{ms_struct} and @code{gcc_struct}.
7792 @cindex @code{ms_struct} type attribute, x86
7793 @cindex @code{gcc_struct} type attribute, x86
7795 If @code{packed} is used on a structure, or if bit-fields are used
7796 it may be that the Microsoft ABI packs them differently
7797 than GCC normally packs them. Particularly when moving packed
7798 data between functions compiled with GCC and the native Microsoft compiler
7799 (either via function call or as data in a file), it may be necessary to access
7802 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7803 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7804 command-line options, respectively;
7805 see @ref{x86 Options}, for details of how structure layout is affected.
7806 @xref{x86 Variable Attributes}, for information about the corresponding
7807 attributes on variables.
7811 @node Label Attributes
7812 @section Label Attributes
7813 @cindex Label Attributes
7815 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
7816 details of the exact syntax for using attributes. Other attributes are
7817 available for functions (@pxref{Function Attributes}), variables
7818 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
7819 statements (@pxref{Statement Attributes}), and for types
7820 (@pxref{Type Attributes}).
7822 This example uses the @code{cold} label attribute to indicate the
7823 @code{ErrorHandling} branch is unlikely to be taken and that the
7824 @code{ErrorHandling} label is unused:
7828 asm goto ("some asm" : : : : NoError);
7830 /* This branch (the fall-through from the asm) is less commonly used */
7832 __attribute__((cold, unused)); /* Semi-colon is required here */
7837 printf("no error\n");
7843 @cindex @code{unused} label attribute
7844 This feature is intended for program-generated code that may contain
7845 unused labels, but which is compiled with @option{-Wall}. It is
7846 not normally appropriate to use in it human-written code, though it
7847 could be useful in cases where the code that jumps to the label is
7848 contained within an @code{#ifdef} conditional.
7851 @cindex @code{hot} label attribute
7852 The @code{hot} attribute on a label is used to inform the compiler that
7853 the path following the label is more likely than paths that are not so
7854 annotated. This attribute is used in cases where @code{__builtin_expect}
7855 cannot be used, for instance with computed goto or @code{asm goto}.
7858 @cindex @code{cold} label attribute
7859 The @code{cold} attribute on labels is used to inform the compiler that
7860 the path following the label is unlikely to be executed. This attribute
7861 is used in cases where @code{__builtin_expect} cannot be used, for instance
7862 with computed goto or @code{asm goto}.
7866 @node Enumerator Attributes
7867 @section Enumerator Attributes
7868 @cindex Enumerator Attributes
7870 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
7871 details of the exact syntax for using attributes. Other attributes are
7872 available for functions (@pxref{Function Attributes}), variables
7873 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
7874 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
7876 This example uses the @code{deprecated} enumerator attribute to indicate the
7877 @code{oldval} enumerator is deprecated:
7881 oldval __attribute__((deprecated)),
7894 @cindex @code{deprecated} enumerator attribute
7895 The @code{deprecated} attribute results in a warning if the enumerator
7896 is used anywhere in the source file. This is useful when identifying
7897 enumerators that are expected to be removed in a future version of a
7898 program. The warning also includes the location of the declaration
7899 of the deprecated enumerator, to enable users to easily find further
7900 information about why the enumerator is deprecated, or what they should
7901 do instead. Note that the warnings only occurs for uses.
7905 @node Statement Attributes
7906 @section Statement Attributes
7907 @cindex Statement Attributes
7909 GCC allows attributes to be set on null statements. @xref{Attribute Syntax},
7910 for details of the exact syntax for using attributes. Other attributes are
7911 available for functions (@pxref{Function Attributes}), variables
7912 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7913 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7915 This example uses the @code{fallthrough} statement attribute to indicate that
7916 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7923 __attribute__((fallthrough));
7931 @cindex @code{fallthrough} statement attribute
7932 The @code{fallthrough} attribute with a null statement serves as a
7933 fallthrough statement. It hints to the compiler that a statement
7934 that falls through to another case label, or user-defined label
7935 in a switch statement is intentional and thus the
7936 @option{-Wimplicit-fallthrough} warning must not trigger. The
7937 fallthrough attribute may appear at most once in each attribute
7938 list, and may not be mixed with other attributes. It can only
7939 be used in a switch statement (the compiler will issue an error
7940 otherwise), after a preceding statement and before a logically
7941 succeeding case label, or user-defined label.
7945 @node Attribute Syntax
7946 @section Attribute Syntax
7947 @cindex attribute syntax
7949 This section describes the syntax with which @code{__attribute__} may be
7950 used, and the constructs to which attribute specifiers bind, for the C
7951 language. Some details may vary for C++ and Objective-C@. Because of
7952 infelicities in the grammar for attributes, some forms described here
7953 may not be successfully parsed in all cases.
7955 There are some problems with the semantics of attributes in C++. For
7956 example, there are no manglings for attributes, although they may affect
7957 code generation, so problems may arise when attributed types are used in
7958 conjunction with templates or overloading. Similarly, @code{typeid}
7959 does not distinguish between types with different attributes. Support
7960 for attributes in C++ may be restricted in future to attributes on
7961 declarations only, but not on nested declarators.
7963 @xref{Function Attributes}, for details of the semantics of attributes
7964 applying to functions. @xref{Variable Attributes}, for details of the
7965 semantics of attributes applying to variables. @xref{Type Attributes},
7966 for details of the semantics of attributes applying to structure, union
7967 and enumerated types.
7968 @xref{Label Attributes}, for details of the semantics of attributes
7970 @xref{Enumerator Attributes}, for details of the semantics of attributes
7971 applying to enumerators.
7972 @xref{Statement Attributes}, for details of the semantics of attributes
7973 applying to statements.
7975 An @dfn{attribute specifier} is of the form
7976 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
7977 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7978 each attribute is one of the following:
7982 Empty. Empty attributes are ignored.
7986 (which may be an identifier such as @code{unused}, or a reserved
7987 word such as @code{const}).
7990 An attribute name followed by a parenthesized list of
7991 parameters for the attribute.
7992 These parameters take one of the following forms:
7996 An identifier. For example, @code{mode} attributes use this form.
7999 An identifier followed by a comma and a non-empty comma-separated list
8000 of expressions. For example, @code{format} attributes use this form.
8003 A possibly empty comma-separated list of expressions. For example,
8004 @code{format_arg} attributes use this form with the list being a single
8005 integer constant expression, and @code{alias} attributes use this form
8006 with the list being a single string constant.
8010 An @dfn{attribute specifier list} is a sequence of one or more attribute
8011 specifiers, not separated by any other tokens.
8013 You may optionally specify attribute names with @samp{__}
8014 preceding and following the name.
8015 This allows you to use them in header files without
8016 being concerned about a possible macro of the same name. For example,
8017 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
8020 @subsubheading Label Attributes
8022 In GNU C, an attribute specifier list may appear after the colon following a
8023 label, other than a @code{case} or @code{default} label. GNU C++ only permits
8024 attributes on labels if the attribute specifier is immediately
8025 followed by a semicolon (i.e., the label applies to an empty
8026 statement). If the semicolon is missing, C++ label attributes are
8027 ambiguous, as it is permissible for a declaration, which could begin
8028 with an attribute list, to be labelled in C++. Declarations cannot be
8029 labelled in C90 or C99, so the ambiguity does not arise there.
8031 @subsubheading Enumerator Attributes
8033 In GNU C, an attribute specifier list may appear as part of an enumerator.
8034 The attribute goes after the enumeration constant, before @code{=}, if
8035 present. The optional attribute in the enumerator appertains to the
8036 enumeration constant. It is not possible to place the attribute after
8037 the constant expression, if present.
8039 @subsubheading Statement Attributes
8040 In GNU C, an attribute specifier list may appear as part of a null
8041 statement. The attribute goes before the semicolon.
8043 @subsubheading Type Attributes
8045 An attribute specifier list may appear as part of a @code{struct},
8046 @code{union} or @code{enum} specifier. It may go either immediately
8047 after the @code{struct}, @code{union} or @code{enum} keyword, or after
8048 the closing brace. The former syntax is preferred.
8049 Where attribute specifiers follow the closing brace, they are considered
8050 to relate to the structure, union or enumerated type defined, not to any
8051 enclosing declaration the type specifier appears in, and the type
8052 defined is not complete until after the attribute specifiers.
8053 @c Otherwise, there would be the following problems: a shift/reduce
8054 @c conflict between attributes binding the struct/union/enum and
8055 @c binding to the list of specifiers/qualifiers; and "aligned"
8056 @c attributes could use sizeof for the structure, but the size could be
8057 @c changed later by "packed" attributes.
8060 @subsubheading All other attributes
8062 Otherwise, an attribute specifier appears as part of a declaration,
8063 counting declarations of unnamed parameters and type names, and relates
8064 to that declaration (which may be nested in another declaration, for
8065 example in the case of a parameter declaration), or to a particular declarator
8066 within a declaration. Where an
8067 attribute specifier is applied to a parameter declared as a function or
8068 an array, it should apply to the function or array rather than the
8069 pointer to which the parameter is implicitly converted, but this is not
8070 yet correctly implemented.
8072 Any list of specifiers and qualifiers at the start of a declaration may
8073 contain attribute specifiers, whether or not such a list may in that
8074 context contain storage class specifiers. (Some attributes, however,
8075 are essentially in the nature of storage class specifiers, and only make
8076 sense where storage class specifiers may be used; for example,
8077 @code{section}.) There is one necessary limitation to this syntax: the
8078 first old-style parameter declaration in a function definition cannot
8079 begin with an attribute specifier, because such an attribute applies to
8080 the function instead by syntax described below (which, however, is not
8081 yet implemented in this case). In some other cases, attribute
8082 specifiers are permitted by this grammar but not yet supported by the
8083 compiler. All attribute specifiers in this place relate to the
8084 declaration as a whole. In the obsolescent usage where a type of
8085 @code{int} is implied by the absence of type specifiers, such a list of
8086 specifiers and qualifiers may be an attribute specifier list with no
8087 other specifiers or qualifiers.
8089 At present, the first parameter in a function prototype must have some
8090 type specifier that is not an attribute specifier; this resolves an
8091 ambiguity in the interpretation of @code{void f(int
8092 (__attribute__((foo)) x))}, but is subject to change. At present, if
8093 the parentheses of a function declarator contain only attributes then
8094 those attributes are ignored, rather than yielding an error or warning
8095 or implying a single parameter of type int, but this is subject to
8098 An attribute specifier list may appear immediately before a declarator
8099 (other than the first) in a comma-separated list of declarators in a
8100 declaration of more than one identifier using a single list of
8101 specifiers and qualifiers. Such attribute specifiers apply
8102 only to the identifier before whose declarator they appear. For
8106 __attribute__((noreturn)) void d0 (void),
8107 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
8112 the @code{noreturn} attribute applies to all the functions
8113 declared; the @code{format} attribute only applies to @code{d1}.
8115 An attribute specifier list may appear immediately before the comma,
8116 @code{=} or semicolon terminating the declaration of an identifier other
8117 than a function definition. Such attribute specifiers apply
8118 to the declared object or function. Where an
8119 assembler name for an object or function is specified (@pxref{Asm
8120 Labels}), the attribute must follow the @code{asm}
8123 An attribute specifier list may, in future, be permitted to appear after
8124 the declarator in a function definition (before any old-style parameter
8125 declarations or the function body).
8127 Attribute specifiers may be mixed with type qualifiers appearing inside
8128 the @code{[]} of a parameter array declarator, in the C99 construct by
8129 which such qualifiers are applied to the pointer to which the array is
8130 implicitly converted. Such attribute specifiers apply to the pointer,
8131 not to the array, but at present this is not implemented and they are
8134 An attribute specifier list may appear at the start of a nested
8135 declarator. At present, there are some limitations in this usage: the
8136 attributes correctly apply to the declarator, but for most individual
8137 attributes the semantics this implies are not implemented.
8138 When attribute specifiers follow the @code{*} of a pointer
8139 declarator, they may be mixed with any type qualifiers present.
8140 The following describes the formal semantics of this syntax. It makes the
8141 most sense if you are familiar with the formal specification of
8142 declarators in the ISO C standard.
8144 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
8145 D1}, where @code{T} contains declaration specifiers that specify a type
8146 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
8147 contains an identifier @var{ident}. The type specified for @var{ident}
8148 for derived declarators whose type does not include an attribute
8149 specifier is as in the ISO C standard.
8151 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
8152 and the declaration @code{T D} specifies the type
8153 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
8154 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
8155 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
8157 If @code{D1} has the form @code{*
8158 @var{type-qualifier-and-attribute-specifier-list} D}, and the
8159 declaration @code{T D} specifies the type
8160 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
8161 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
8162 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
8168 void (__attribute__((noreturn)) ****f) (void);
8172 specifies the type ``pointer to pointer to pointer to pointer to
8173 non-returning function returning @code{void}''. As another example,
8176 char *__attribute__((aligned(8))) *f;
8180 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
8181 Note again that this does not work with most attributes; for example,
8182 the usage of @samp{aligned} and @samp{noreturn} attributes given above
8183 is not yet supported.
8185 For compatibility with existing code written for compiler versions that
8186 did not implement attributes on nested declarators, some laxity is
8187 allowed in the placing of attributes. If an attribute that only applies
8188 to types is applied to a declaration, it is treated as applying to
8189 the type of that declaration. If an attribute that only applies to
8190 declarations is applied to the type of a declaration, it is treated
8191 as applying to that declaration; and, for compatibility with code
8192 placing the attributes immediately before the identifier declared, such
8193 an attribute applied to a function return type is treated as
8194 applying to the function type, and such an attribute applied to an array
8195 element type is treated as applying to the array type. If an
8196 attribute that only applies to function types is applied to a
8197 pointer-to-function type, it is treated as applying to the pointer
8198 target type; if such an attribute is applied to a function return type
8199 that is not a pointer-to-function type, it is treated as applying
8200 to the function type.
8202 @node Function Prototypes
8203 @section Prototypes and Old-Style Function Definitions
8204 @cindex function prototype declarations
8205 @cindex old-style function definitions
8206 @cindex promotion of formal parameters
8208 GNU C extends ISO C to allow a function prototype to override a later
8209 old-style non-prototype definition. Consider the following example:
8212 /* @r{Use prototypes unless the compiler is old-fashioned.} */
8219 /* @r{Prototype function declaration.} */
8220 int isroot P((uid_t));
8222 /* @r{Old-style function definition.} */
8224 isroot (x) /* @r{??? lossage here ???} */
8231 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
8232 not allow this example, because subword arguments in old-style
8233 non-prototype definitions are promoted. Therefore in this example the
8234 function definition's argument is really an @code{int}, which does not
8235 match the prototype argument type of @code{short}.
8237 This restriction of ISO C makes it hard to write code that is portable
8238 to traditional C compilers, because the programmer does not know
8239 whether the @code{uid_t} type is @code{short}, @code{int}, or
8240 @code{long}. Therefore, in cases like these GNU C allows a prototype
8241 to override a later old-style definition. More precisely, in GNU C, a
8242 function prototype argument type overrides the argument type specified
8243 by a later old-style definition if the former type is the same as the
8244 latter type before promotion. Thus in GNU C the above example is
8245 equivalent to the following:
8258 GNU C++ does not support old-style function definitions, so this
8259 extension is irrelevant.
8262 @section C++ Style Comments
8264 @cindex C++ comments
8265 @cindex comments, C++ style
8267 In GNU C, you may use C++ style comments, which start with @samp{//} and
8268 continue until the end of the line. Many other C implementations allow
8269 such comments, and they are included in the 1999 C standard. However,
8270 C++ style comments are not recognized if you specify an @option{-std}
8271 option specifying a version of ISO C before C99, or @option{-ansi}
8272 (equivalent to @option{-std=c90}).
8275 @section Dollar Signs in Identifier Names
8277 @cindex dollar signs in identifier names
8278 @cindex identifier names, dollar signs in
8280 In GNU C, you may normally use dollar signs in identifier names.
8281 This is because many traditional C implementations allow such identifiers.
8282 However, dollar signs in identifiers are not supported on a few target
8283 machines, typically because the target assembler does not allow them.
8285 @node Character Escapes
8286 @section The Character @key{ESC} in Constants
8288 You can use the sequence @samp{\e} in a string or character constant to
8289 stand for the ASCII character @key{ESC}.
8292 @section Determining the Alignment of Functions, Types or Variables
8294 @cindex type alignment
8295 @cindex variable alignment
8297 The keyword @code{__alignof__} determines the alignment requirement of
8298 a function, object, or a type, or the minimum alignment usually required
8299 by a type. Its syntax is just like @code{sizeof} and C11 @code{_Alignof}.
8301 For example, if the target machine requires a @code{double} value to be
8302 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
8303 This is true on many RISC machines. On more traditional machine
8304 designs, @code{__alignof__ (double)} is 4 or even 2.
8306 Some machines never actually require alignment; they allow references to any
8307 data type even at an odd address. For these machines, @code{__alignof__}
8308 reports the smallest alignment that GCC gives the data type, usually as
8309 mandated by the target ABI.
8311 If the operand of @code{__alignof__} is an lvalue rather than a type,
8312 its value is the required alignment for its type, taking into account
8313 any minimum alignment specified by attribute @code{aligned}
8314 (@pxref{Common Variable Attributes}). For example, after this
8318 struct foo @{ int x; char y; @} foo1;
8322 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
8323 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
8324 It is an error to ask for the alignment of an incomplete type other
8327 If the operand of the @code{__alignof__} expression is a function,
8328 the expression evaluates to the alignment of the function which may
8329 be specified by attribute @code{aligned} (@pxref{Common Function Attributes}).
8332 @section An Inline Function is As Fast As a Macro
8333 @cindex inline functions
8334 @cindex integrating function code
8336 @cindex macros, inline alternative
8338 By declaring a function inline, you can direct GCC to make
8339 calls to that function faster. One way GCC can achieve this is to
8340 integrate that function's code into the code for its callers. This
8341 makes execution faster by eliminating the function-call overhead; in
8342 addition, if any of the actual argument values are constant, their
8343 known values may permit simplifications at compile time so that not
8344 all of the inline function's code needs to be included. The effect on
8345 code size is less predictable; object code may be larger or smaller
8346 with function inlining, depending on the particular case. You can
8347 also direct GCC to try to integrate all ``simple enough'' functions
8348 into their callers with the option @option{-finline-functions}.
8350 GCC implements three different semantics of declaring a function
8351 inline. One is available with @option{-std=gnu89} or
8352 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
8353 on all inline declarations, another when
8355 @option{-std=gnu99} or an option for a later C version is used
8356 (without @option{-fgnu89-inline}), and the third
8357 is used when compiling C++.
8359 To declare a function inline, use the @code{inline} keyword in its
8360 declaration, like this:
8370 If you are writing a header file to be included in ISO C90 programs, write
8371 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
8373 The three types of inlining behave similarly in two important cases:
8374 when the @code{inline} keyword is used on a @code{static} function,
8375 like the example above, and when a function is first declared without
8376 using the @code{inline} keyword and then is defined with
8377 @code{inline}, like this:
8380 extern int inc (int *a);
8388 In both of these common cases, the program behaves the same as if you
8389 had not used the @code{inline} keyword, except for its speed.
8391 @cindex inline functions, omission of
8392 @opindex fkeep-inline-functions
8393 When a function is both inline and @code{static}, if all calls to the
8394 function are integrated into the caller, and the function's address is
8395 never used, then the function's own assembler code is never referenced.
8396 In this case, GCC does not actually output assembler code for the
8397 function, unless you specify the option @option{-fkeep-inline-functions}.
8398 If there is a nonintegrated call, then the function is compiled to
8399 assembler code as usual. The function must also be compiled as usual if
8400 the program refers to its address, because that cannot be inlined.
8403 Note that certain usages in a function definition can make it unsuitable
8404 for inline substitution. Among these usages are: variadic functions,
8405 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
8406 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
8407 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
8408 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
8409 function marked @code{inline} could not be substituted, and gives the
8410 reason for the failure.
8412 @cindex automatic @code{inline} for C++ member fns
8413 @cindex @code{inline} automatic for C++ member fns
8414 @cindex member fns, automatically @code{inline}
8415 @cindex C++ member fns, automatically @code{inline}
8416 @opindex fno-default-inline
8417 As required by ISO C++, GCC considers member functions defined within
8418 the body of a class to be marked inline even if they are
8419 not explicitly declared with the @code{inline} keyword. You can
8420 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
8421 Options,,Options Controlling C++ Dialect}.
8423 GCC does not inline any functions when not optimizing unless you specify
8424 the @samp{always_inline} attribute for the function, like this:
8427 /* @r{Prototype.} */
8428 inline void foo (const char) __attribute__((always_inline));
8431 The remainder of this section is specific to GNU C90 inlining.
8433 @cindex non-static inline function
8434 When an inline function is not @code{static}, then the compiler must assume
8435 that there may be calls from other source files; since a global symbol can
8436 be defined only once in any program, the function must not be defined in
8437 the other source files, so the calls therein cannot be integrated.
8438 Therefore, a non-@code{static} inline function is always compiled on its
8439 own in the usual fashion.
8441 If you specify both @code{inline} and @code{extern} in the function
8442 definition, then the definition is used only for inlining. In no case
8443 is the function compiled on its own, not even if you refer to its
8444 address explicitly. Such an address becomes an external reference, as
8445 if you had only declared the function, and had not defined it.
8447 This combination of @code{inline} and @code{extern} has almost the
8448 effect of a macro. The way to use it is to put a function definition in
8449 a header file with these keywords, and put another copy of the
8450 definition (lacking @code{inline} and @code{extern}) in a library file.
8451 The definition in the header file causes most calls to the function
8452 to be inlined. If any uses of the function remain, they refer to
8453 the single copy in the library.
8456 @section When is a Volatile Object Accessed?
8457 @cindex accessing volatiles
8458 @cindex volatile read
8459 @cindex volatile write
8460 @cindex volatile access
8462 C has the concept of volatile objects. These are normally accessed by
8463 pointers and used for accessing hardware or inter-thread
8464 communication. The standard encourages compilers to refrain from
8465 optimizations concerning accesses to volatile objects, but leaves it
8466 implementation defined as to what constitutes a volatile access. The
8467 minimum requirement is that at a sequence point all previous accesses
8468 to volatile objects have stabilized and no subsequent accesses have
8469 occurred. Thus an implementation is free to reorder and combine
8470 volatile accesses that occur between sequence points, but cannot do
8471 so for accesses across a sequence point. The use of volatile does
8472 not allow you to violate the restriction on updating objects multiple
8473 times between two sequence points.
8475 Accesses to non-volatile objects are not ordered with respect to
8476 volatile accesses. You cannot use a volatile object as a memory
8477 barrier to order a sequence of writes to non-volatile memory. For
8481 int *ptr = @var{something};
8483 *ptr = @var{something};
8488 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
8489 that the write to @var{*ptr} occurs by the time the update
8490 of @var{vobj} happens. If you need this guarantee, you must use
8491 a stronger memory barrier such as:
8494 int *ptr = @var{something};
8496 *ptr = @var{something};
8497 asm volatile ("" : : : "memory");
8501 A scalar volatile object is read when it is accessed in a void context:
8504 volatile int *src = @var{somevalue};
8508 Such expressions are rvalues, and GCC implements this as a
8509 read of the volatile object being pointed to.
8511 Assignments are also expressions and have an rvalue. However when
8512 assigning to a scalar volatile, the volatile object is not reread,
8513 regardless of whether the assignment expression's rvalue is used or
8514 not. If the assignment's rvalue is used, the value is that assigned
8515 to the volatile object. For instance, there is no read of @var{vobj}
8516 in all the following cases:
8521 vobj = @var{something};
8522 obj = vobj = @var{something};
8523 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
8524 obj = (@var{something}, vobj = @var{anotherthing});
8527 If you need to read the volatile object after an assignment has
8528 occurred, you must use a separate expression with an intervening
8531 As bit-fields are not individually addressable, volatile bit-fields may
8532 be implicitly read when written to, or when adjacent bit-fields are
8533 accessed. Bit-field operations may be optimized such that adjacent
8534 bit-fields are only partially accessed, if they straddle a storage unit
8535 boundary. For these reasons it is unwise to use volatile bit-fields to
8538 @node Using Assembly Language with C
8539 @section How to Use Inline Assembly Language in C Code
8540 @cindex @code{asm} keyword
8541 @cindex assembly language in C
8542 @cindex inline assembly language
8543 @cindex mixing assembly language and C
8545 The @code{asm} keyword allows you to embed assembler instructions
8546 within C code. GCC provides two forms of inline @code{asm}
8547 statements. A @dfn{basic @code{asm}} statement is one with no
8548 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
8549 statement (@pxref{Extended Asm}) includes one or more operands.
8550 The extended form is preferred for mixing C and assembly language
8551 within a function, but to include assembly language at
8552 top level you must use basic @code{asm}.
8554 You can also use the @code{asm} keyword to override the assembler name
8555 for a C symbol, or to place a C variable in a specific register.
8558 * Basic Asm:: Inline assembler without operands.
8559 * Extended Asm:: Inline assembler with operands.
8560 * Constraints:: Constraints for @code{asm} operands
8561 * Asm Labels:: Specifying the assembler name to use for a C symbol.
8562 * Explicit Register Variables:: Defining variables residing in specified
8564 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
8568 @subsection Basic Asm --- Assembler Instructions Without Operands
8569 @cindex basic @code{asm}
8570 @cindex assembly language in C, basic
8572 A basic @code{asm} statement has the following syntax:
8575 asm @var{asm-qualifiers} ( @var{AssemblerInstructions} )
8578 The @code{asm} keyword is a GNU extension.
8579 When writing code that can be compiled with @option{-ansi} and the
8580 various @option{-std} options, use @code{__asm__} instead of
8581 @code{asm} (@pxref{Alternate Keywords}).
8583 @subsubheading Qualifiers
8586 The optional @code{volatile} qualifier has no effect.
8587 All basic @code{asm} blocks are implicitly volatile.
8590 If you use the @code{inline} qualifier, then for inlining purposes the size
8591 of the @code{asm} statement is taken as the smallest size possible (@pxref{Size
8595 @subsubheading Parameters
8598 @item AssemblerInstructions
8599 This is a literal string that specifies the assembler code. The string can
8600 contain any instructions recognized by the assembler, including directives.
8601 GCC does not parse the assembler instructions themselves and
8602 does not know what they mean or even whether they are valid assembler input.
8604 You may place multiple assembler instructions together in a single @code{asm}
8605 string, separated by the characters normally used in assembly code for the
8606 system. A combination that works in most places is a newline to break the
8607 line, plus a tab character (written as @samp{\n\t}).
8608 Some assemblers allow semicolons as a line separator. However,
8609 note that some assembler dialects use semicolons to start a comment.
8612 @subsubheading Remarks
8613 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
8614 smaller, safer, and more efficient code, and in most cases it is a
8615 better solution than basic @code{asm}. However, there are two
8616 situations where only basic @code{asm} can be used:
8620 Extended @code{asm} statements have to be inside a C
8621 function, so to write inline assembly language at file scope (``top-level''),
8622 outside of C functions, you must use basic @code{asm}.
8623 You can use this technique to emit assembler directives,
8624 define assembly language macros that can be invoked elsewhere in the file,
8625 or write entire functions in assembly language.
8629 with the @code{naked} attribute also require basic @code{asm}
8630 (@pxref{Function Attributes}).
8633 Safely accessing C data and calling functions from basic @code{asm} is more
8634 complex than it may appear. To access C data, it is better to use extended
8637 Do not expect a sequence of @code{asm} statements to remain perfectly
8638 consecutive after compilation. If certain instructions need to remain
8639 consecutive in the output, put them in a single multi-instruction @code{asm}
8640 statement. Note that GCC's optimizers can move @code{asm} statements
8641 relative to other code, including across jumps.
8643 @code{asm} statements may not perform jumps into other @code{asm} statements.
8644 GCC does not know about these jumps, and therefore cannot take
8645 account of them when deciding how to optimize. Jumps from @code{asm} to C
8646 labels are only supported in extended @code{asm}.
8648 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
8649 assembly code when optimizing. This can lead to unexpected duplicate
8650 symbol errors during compilation if your assembly code defines symbols or
8653 @strong{Warning:} The C standards do not specify semantics for @code{asm},
8654 making it a potential source of incompatibilities between compilers. These
8655 incompatibilities may not produce compiler warnings/errors.
8657 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
8658 means there is no way to communicate to the compiler what is happening
8659 inside them. GCC has no visibility of symbols in the @code{asm} and may
8660 discard them as unreferenced. It also does not know about side effects of
8661 the assembler code, such as modifications to memory or registers. Unlike
8662 some compilers, GCC assumes that no changes to general purpose registers
8663 occur. This assumption may change in a future release.
8665 To avoid complications from future changes to the semantics and the
8666 compatibility issues between compilers, consider replacing basic @code{asm}
8667 with extended @code{asm}. See
8668 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
8669 from basic asm to extended asm} for information about how to perform this
8672 The compiler copies the assembler instructions in a basic @code{asm}
8673 verbatim to the assembly language output file, without
8674 processing dialects or any of the @samp{%} operators that are available with
8675 extended @code{asm}. This results in minor differences between basic
8676 @code{asm} strings and extended @code{asm} templates. For example, to refer to
8677 registers you might use @samp{%eax} in basic @code{asm} and
8678 @samp{%%eax} in extended @code{asm}.
8680 On targets such as x86 that support multiple assembler dialects,
8681 all basic @code{asm} blocks use the assembler dialect specified by the
8682 @option{-masm} command-line option (@pxref{x86 Options}).
8683 Basic @code{asm} provides no
8684 mechanism to provide different assembler strings for different dialects.
8686 For basic @code{asm} with non-empty assembler string GCC assumes
8687 the assembler block does not change any general purpose registers,
8688 but it may read or write any globally accessible variable.
8690 Here is an example of basic @code{asm} for i386:
8693 /* Note that this code will not compile with -masm=intel */
8694 #define DebugBreak() asm("int $3")
8698 @subsection Extended Asm - Assembler Instructions with C Expression Operands
8699 @cindex extended @code{asm}
8700 @cindex assembly language in C, extended
8702 With extended @code{asm} you can read and write C variables from
8703 assembler and perform jumps from assembler code to C labels.
8704 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
8705 the operand parameters after the assembler template:
8708 asm @var{asm-qualifiers} ( @var{AssemblerTemplate}
8709 : @var{OutputOperands}
8710 @r{[} : @var{InputOperands}
8711 @r{[} : @var{Clobbers} @r{]} @r{]})
8713 asm @var{asm-qualifiers} ( @var{AssemblerTemplate}
8715 : @var{InputOperands}
8719 where in the last form, @var{asm-qualifiers} contains @code{goto} (and in the
8722 The @code{asm} keyword is a GNU extension.
8723 When writing code that can be compiled with @option{-ansi} and the
8724 various @option{-std} options, use @code{__asm__} instead of
8725 @code{asm} (@pxref{Alternate Keywords}).
8727 @subsubheading Qualifiers
8731 The typical use of extended @code{asm} statements is to manipulate input
8732 values to produce output values. However, your @code{asm} statements may
8733 also produce side effects. If so, you may need to use the @code{volatile}
8734 qualifier to disable certain optimizations. @xref{Volatile}.
8737 If you use the @code{inline} qualifier, then for inlining purposes the size
8738 of the @code{asm} statement is taken as the smallest size possible
8739 (@pxref{Size of an asm}).
8742 This qualifier informs the compiler that the @code{asm} statement may
8743 perform a jump to one of the labels listed in the @var{GotoLabels}.
8747 @subsubheading Parameters
8749 @item AssemblerTemplate
8750 This is a literal string that is the template for the assembler code. It is a
8751 combination of fixed text and tokens that refer to the input, output,
8752 and goto parameters. @xref{AssemblerTemplate}.
8754 @item OutputOperands
8755 A comma-separated list of the C variables modified by the instructions in the
8756 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
8759 A comma-separated list of C expressions read by the instructions in the
8760 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
8763 A comma-separated list of registers or other values changed by the
8764 @var{AssemblerTemplate}, beyond those listed as outputs.
8765 An empty list is permitted. @xref{Clobbers and Scratch Registers}.
8768 When you are using the @code{goto} form of @code{asm}, this section contains
8769 the list of all C labels to which the code in the
8770 @var{AssemblerTemplate} may jump.
8773 @code{asm} statements may not perform jumps into other @code{asm} statements,
8774 only to the listed @var{GotoLabels}.
8775 GCC's optimizers do not know about other jumps; therefore they cannot take
8776 account of them when deciding how to optimize.
8779 The total number of input + output + goto operands is limited to 30.
8781 @subsubheading Remarks
8782 The @code{asm} statement allows you to include assembly instructions directly
8783 within C code. This may help you to maximize performance in time-sensitive
8784 code or to access assembly instructions that are not readily available to C
8787 Note that extended @code{asm} statements must be inside a function. Only
8788 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
8789 Functions declared with the @code{naked} attribute also require basic
8790 @code{asm} (@pxref{Function Attributes}).
8792 While the uses of @code{asm} are many and varied, it may help to think of an
8793 @code{asm} statement as a series of low-level instructions that convert input
8794 parameters to output parameters. So a simple (if not particularly useful)
8795 example for i386 using @code{asm} might look like this:
8801 asm ("mov %1, %0\n\t"
8806 printf("%d\n", dst);
8809 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
8812 @subsubsection Volatile
8813 @cindex volatile @code{asm}
8814 @cindex @code{asm} volatile
8816 GCC's optimizers sometimes discard @code{asm} statements if they determine
8817 there is no need for the output variables. Also, the optimizers may move
8818 code out of loops if they believe that the code will always return the same
8819 result (i.e.@: none of its input values change between calls). Using the
8820 @code{volatile} qualifier disables these optimizations. @code{asm} statements
8821 that have no output operands, including @code{asm goto} statements,
8822 are implicitly volatile.
8824 This i386 code demonstrates a case that does not use (or require) the
8825 @code{volatile} qualifier. If it is performing assertion checking, this code
8826 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
8827 unreferenced by any code. As a result, the optimizers can discard the
8828 @code{asm} statement, which in turn removes the need for the entire
8829 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
8830 isn't needed you allow the optimizers to produce the most efficient code
8834 void DoCheck(uint32_t dwSomeValue)
8838 // Assumes dwSomeValue is not zero.
8848 The next example shows a case where the optimizers can recognize that the input
8849 (@code{dwSomeValue}) never changes during the execution of the function and can
8850 therefore move the @code{asm} outside the loop to produce more efficient code.
8851 Again, using the @code{volatile} qualifier disables this type of optimization.
8854 void do_print(uint32_t dwSomeValue)
8858 for (uint32_t x=0; x < 5; x++)
8860 // Assumes dwSomeValue is not zero.
8866 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
8871 The following example demonstrates a case where you need to use the
8872 @code{volatile} qualifier.
8873 It uses the x86 @code{rdtsc} instruction, which reads
8874 the computer's time-stamp counter. Without the @code{volatile} qualifier,
8875 the optimizers might assume that the @code{asm} block will always return the
8876 same value and therefore optimize away the second call.
8881 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
8882 "shl $32, %%rdx\n\t" // Shift the upper bits left.
8883 "or %%rdx, %0" // 'Or' in the lower bits.
8888 printf("msr: %llx\n", msr);
8892 // Reprint the timestamp
8893 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
8894 "shl $32, %%rdx\n\t" // Shift the upper bits left.
8895 "or %%rdx, %0" // 'Or' in the lower bits.
8900 printf("msr: %llx\n", msr);
8903 GCC's optimizers do not treat this code like the non-volatile code in the
8904 earlier examples. They do not move it out of loops or omit it on the
8905 assumption that the result from a previous call is still valid.
8907 Note that the compiler can move even @code{volatile asm} instructions relative
8908 to other code, including across jump instructions. For example, on many
8909 targets there is a system register that controls the rounding mode of
8910 floating-point operations. Setting it with a @code{volatile asm} statement,
8911 as in the following PowerPC example, does not work reliably.
8914 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8918 The compiler may move the addition back before the @code{volatile asm}
8919 statement. To make it work as expected, add an artificial dependency to
8920 the @code{asm} by referencing a variable in the subsequent code, for
8924 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8928 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
8929 assembly code when optimizing. This can lead to unexpected duplicate symbol
8930 errors during compilation if your @code{asm} code defines symbols or labels.
8932 (@pxref{AssemblerTemplate}) may help resolve this problem.
8934 @anchor{AssemblerTemplate}
8935 @subsubsection Assembler Template
8936 @cindex @code{asm} assembler template
8938 An assembler template is a literal string containing assembler instructions.
8939 The compiler replaces tokens in the template that refer
8940 to inputs, outputs, and goto labels,
8941 and then outputs the resulting string to the assembler. The
8942 string can contain any instructions recognized by the assembler, including
8943 directives. GCC does not parse the assembler instructions
8944 themselves and does not know what they mean or even whether they are valid
8945 assembler input. However, it does count the statements
8946 (@pxref{Size of an asm}).
8948 You may place multiple assembler instructions together in a single @code{asm}
8949 string, separated by the characters normally used in assembly code for the
8950 system. A combination that works in most places is a newline to break the
8951 line, plus a tab character to move to the instruction field (written as
8953 Some assemblers allow semicolons as a line separator. However, note
8954 that some assembler dialects use semicolons to start a comment.
8956 Do not expect a sequence of @code{asm} statements to remain perfectly
8957 consecutive after compilation, even when you are using the @code{volatile}
8958 qualifier. If certain instructions need to remain consecutive in the output,
8959 put them in a single multi-instruction @code{asm} statement.
8961 Accessing data from C programs without using input/output operands (such as
8962 by using global symbols directly from the assembler template) may not work as
8963 expected. Similarly, calling functions directly from an assembler template
8964 requires a detailed understanding of the target assembler and ABI.
8966 Since GCC does not parse the assembler template,
8967 it has no visibility of any
8968 symbols it references. This may result in GCC discarding those symbols as
8969 unreferenced unless they are also listed as input, output, or goto operands.
8971 @subsubheading Special format strings
8973 In addition to the tokens described by the input, output, and goto operands,
8974 these tokens have special meanings in the assembler template:
8978 Outputs a single @samp{%} into the assembler code.
8981 Outputs a number that is unique to each instance of the @code{asm}
8982 statement in the entire compilation. This option is useful when creating local
8983 labels and referring to them multiple times in a single template that
8984 generates multiple assembler instructions.
8989 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8990 into the assembler code. When unescaped, these characters have special
8991 meaning to indicate multiple assembler dialects, as described below.
8994 @subsubheading Multiple assembler dialects in @code{asm} templates
8996 On targets such as x86, GCC supports multiple assembler dialects.
8997 The @option{-masm} option controls which dialect GCC uses as its
8998 default for inline assembler. The target-specific documentation for the
8999 @option{-masm} option contains the list of supported dialects, as well as the
9000 default dialect if the option is not specified. This information may be
9001 important to understand, since assembler code that works correctly when
9002 compiled using one dialect will likely fail if compiled using another.
9005 If your code needs to support multiple assembler dialects (for example, if
9006 you are writing public headers that need to support a variety of compilation
9007 options), use constructs of this form:
9010 @{ dialect0 | dialect1 | dialect2... @}
9013 This construct outputs @code{dialect0}
9014 when using dialect #0 to compile the code,
9015 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
9016 braces than the number of dialects the compiler supports, the construct
9019 For example, if an x86 compiler supports two dialects
9020 (@samp{att}, @samp{intel}), an
9021 assembler template such as this:
9024 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
9028 is equivalent to one of
9031 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
9032 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
9035 Using that same compiler, this code:
9038 "xchg@{l@}\t@{%%@}ebx, %1"
9042 corresponds to either
9045 "xchgl\t%%ebx, %1" @r{/* att dialect */}
9046 "xchg\tebx, %1" @r{/* intel dialect */}
9049 There is no support for nesting dialect alternatives.
9051 @anchor{OutputOperands}
9052 @subsubsection Output Operands
9053 @cindex @code{asm} output operands
9055 An @code{asm} statement has zero or more output operands indicating the names
9056 of C variables modified by the assembler code.
9058 In this i386 example, @code{old} (referred to in the template string as
9059 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
9060 (@code{%2}) is an input:
9065 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
9066 "sbb %0,%0" // Use the CF to calculate old.
9067 : "=r" (old), "+rm" (*Base)
9074 Operands are separated by commas. Each operand has this format:
9077 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
9081 @item asmSymbolicName
9082 Specifies a symbolic name for the operand.
9083 Reference the name in the assembler template
9084 by enclosing it in square brackets
9085 (i.e.@: @samp{%[Value]}). The scope of the name is the @code{asm} statement
9086 that contains the definition. Any valid C variable name is acceptable,
9087 including names already defined in the surrounding code. No two operands
9088 within the same @code{asm} statement can use the same symbolic name.
9090 When not using an @var{asmSymbolicName}, use the (zero-based) position
9092 in the list of operands in the assembler template. For example if there are
9093 three output operands, use @samp{%0} in the template to refer to the first,
9094 @samp{%1} for the second, and @samp{%2} for the third.
9097 A string constant specifying constraints on the placement of the operand;
9098 @xref{Constraints}, for details.
9100 Output constraints must begin with either @samp{=} (a variable overwriting an
9101 existing value) or @samp{+} (when reading and writing). When using
9102 @samp{=}, do not assume the location contains the existing value
9103 on entry to the @code{asm}, except
9104 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
9106 After the prefix, there must be one or more additional constraints
9107 (@pxref{Constraints}) that describe where the value resides. Common
9108 constraints include @samp{r} for register and @samp{m} for memory.
9109 When you list more than one possible location (for example, @code{"=rm"}),
9110 the compiler chooses the most efficient one based on the current context.
9111 If you list as many alternates as the @code{asm} statement allows, you permit
9112 the optimizers to produce the best possible code.
9113 If you must use a specific register, but your Machine Constraints do not
9114 provide sufficient control to select the specific register you want,
9115 local register variables may provide a solution (@pxref{Local Register
9119 Specifies a C lvalue expression to hold the output, typically a variable name.
9120 The enclosing parentheses are a required part of the syntax.
9124 When the compiler selects the registers to use to
9125 represent the output operands, it does not use any of the clobbered registers
9126 (@pxref{Clobbers and Scratch Registers}).
9128 Output operand expressions must be lvalues. The compiler cannot check whether
9129 the operands have data types that are reasonable for the instruction being
9130 executed. For output expressions that are not directly addressable (for
9131 example a bit-field), the constraint must allow a register. In that case, GCC
9132 uses the register as the output of the @code{asm}, and then stores that
9133 register into the output.
9135 Operands using the @samp{+} constraint modifier count as two operands
9136 (that is, both as input and output) towards the total maximum of 30 operands
9137 per @code{asm} statement.
9139 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
9140 operands that must not overlap an input. Otherwise,
9141 GCC may allocate the output operand in the same register as an unrelated
9142 input operand, on the assumption that the assembler code consumes its
9143 inputs before producing outputs. This assumption may be false if the assembler
9144 code actually consists of more than one instruction.
9146 The same problem can occur if one output parameter (@var{a}) allows a register
9147 constraint and another output parameter (@var{b}) allows a memory constraint.
9148 The code generated by GCC to access the memory address in @var{b} can contain
9149 registers which @emph{might} be shared by @var{a}, and GCC considers those
9150 registers to be inputs to the asm. As above, GCC assumes that such input
9151 registers are consumed before any outputs are written. This assumption may
9152 result in incorrect behavior if the @code{asm} statement writes to @var{a}
9154 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
9155 ensures that modifying @var{a} does not affect the address referenced by
9156 @var{b}. Otherwise, the location of @var{b}
9157 is undefined if @var{a} is modified before using @var{b}.
9159 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
9160 instead of simply @samp{%2}). Typically these qualifiers are hardware
9161 dependent. The list of supported modifiers for x86 is found at
9162 @ref{x86Operandmodifiers,x86 Operand modifiers}.
9164 If the C code that follows the @code{asm} makes no use of any of the output
9165 operands, use @code{volatile} for the @code{asm} statement to prevent the
9166 optimizers from discarding the @code{asm} statement as unneeded
9167 (see @ref{Volatile}).
9169 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
9170 references the first output operand as @code{%0} (were there a second, it
9171 would be @code{%1}, etc). The number of the first input operand is one greater
9172 than that of the last output operand. In this i386 example, that makes
9173 @code{Mask} referenced as @code{%1}:
9176 uint32_t Mask = 1234;
9185 That code overwrites the variable @code{Index} (@samp{=}),
9186 placing the value in a register (@samp{r}).
9187 Using the generic @samp{r} constraint instead of a constraint for a specific
9188 register allows the compiler to pick the register to use, which can result
9189 in more efficient code. This may not be possible if an assembler instruction
9190 requires a specific register.
9192 The following i386 example uses the @var{asmSymbolicName} syntax.
9194 same result as the code above, but some may consider it more readable or more
9195 maintainable since reordering index numbers is not necessary when adding or
9196 removing operands. The names @code{aIndex} and @code{aMask}
9197 are only used in this example to emphasize which
9198 names get used where.
9199 It is acceptable to reuse the names @code{Index} and @code{Mask}.
9202 uint32_t Mask = 1234;
9205 asm ("bsfl %[aMask], %[aIndex]"
9206 : [aIndex] "=r" (Index)
9207 : [aMask] "r" (Mask)
9211 Here are some more examples of output operands.
9218 asm ("mov %[e], %[d]"
9223 Here, @code{d} may either be in a register or in memory. Since the compiler
9224 might already have the current value of the @code{uint32_t} location
9225 pointed to by @code{e}
9226 in a register, you can enable it to choose the best location
9227 for @code{d} by specifying both constraints.
9229 @anchor{FlagOutputOperands}
9230 @subsubsection Flag Output Operands
9231 @cindex @code{asm} flag output operands
9233 Some targets have a special register that holds the ``flags'' for the
9234 result of an operation or comparison. Normally, the contents of that
9235 register are either unmodifed by the asm, or the @code{asm} statement is
9236 considered to clobber the contents.
9238 On some targets, a special form of output operand exists by which
9239 conditions in the flags register may be outputs of the asm. The set of
9240 conditions supported are target specific, but the general rule is that
9241 the output variable must be a scalar integer, and the value is boolean.
9242 When supported, the target defines the preprocessor symbol
9243 @code{__GCC_ASM_FLAG_OUTPUTS__}.
9245 Because of the special nature of the flag output operands, the constraint
9246 may not include alternatives.
9248 Most often, the target has only one flags register, and thus is an implied
9249 operand of many instructions. In this case, the operand should not be
9250 referenced within the assembler template via @code{%0} etc, as there's
9251 no corresponding text in the assembly language.
9255 The flag output constraints for the x86 family are of the form
9256 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
9257 conditions defined in the ISA manual for @code{j@var{cc}} or
9262 ``above'' or unsigned greater than
9264 ``above or equal'' or unsigned greater than or equal
9266 ``below'' or unsigned less than
9268 ``below or equal'' or unsigned less than or equal
9273 ``equal'' or zero flag set
9277 signed greater than or equal
9281 signed less than or equal
9302 ``not'' @var{flag}, or inverted versions of those above
9307 @anchor{InputOperands}
9308 @subsubsection Input Operands
9309 @cindex @code{asm} input operands
9310 @cindex @code{asm} expressions
9312 Input operands make values from C variables and expressions available to the
9315 Operands are separated by commas. Each operand has this format:
9318 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
9322 @item asmSymbolicName
9323 Specifies a symbolic name for the operand.
9324 Reference the name in the assembler template
9325 by enclosing it in square brackets
9326 (i.e.@: @samp{%[Value]}). The scope of the name is the @code{asm} statement
9327 that contains the definition. Any valid C variable name is acceptable,
9328 including names already defined in the surrounding code. No two operands
9329 within the same @code{asm} statement can use the same symbolic name.
9331 When not using an @var{asmSymbolicName}, use the (zero-based) position
9333 in the list of operands in the assembler template. For example if there are
9334 two output operands and three inputs,
9335 use @samp{%2} in the template to refer to the first input operand,
9336 @samp{%3} for the second, and @samp{%4} for the third.
9339 A string constant specifying constraints on the placement of the operand;
9340 @xref{Constraints}, for details.
9342 Input constraint strings may not begin with either @samp{=} or @samp{+}.
9343 When you list more than one possible location (for example, @samp{"irm"}),
9344 the compiler chooses the most efficient one based on the current context.
9345 If you must use a specific register, but your Machine Constraints do not
9346 provide sufficient control to select the specific register you want,
9347 local register variables may provide a solution (@pxref{Local Register
9350 Input constraints can also be digits (for example, @code{"0"}). This indicates
9351 that the specified input must be in the same place as the output constraint
9352 at the (zero-based) index in the output constraint list.
9353 When using @var{asmSymbolicName} syntax for the output operands,
9354 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
9357 This is the C variable or expression being passed to the @code{asm} statement
9358 as input. The enclosing parentheses are a required part of the syntax.
9362 When the compiler selects the registers to use to represent the input
9363 operands, it does not use any of the clobbered registers
9364 (@pxref{Clobbers and Scratch Registers}).
9366 If there are no output operands but there are input operands, place two
9367 consecutive colons where the output operands would go:
9370 __asm__ ("some instructions"
9372 : "r" (Offset / 8));
9375 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
9376 (except for inputs tied to outputs). The compiler assumes that on exit from
9377 the @code{asm} statement these operands contain the same values as they
9378 had before executing the statement.
9379 It is @emph{not} possible to use clobbers
9380 to inform the compiler that the values in these inputs are changing. One
9381 common work-around is to tie the changing input variable to an output variable
9382 that never gets used. Note, however, that if the code that follows the
9383 @code{asm} statement makes no use of any of the output operands, the GCC
9384 optimizers may discard the @code{asm} statement as unneeded
9385 (see @ref{Volatile}).
9387 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
9388 instead of simply @samp{%2}). Typically these qualifiers are hardware
9389 dependent. The list of supported modifiers for x86 is found at
9390 @ref{x86Operandmodifiers,x86 Operand modifiers}.
9392 In this example using the fictitious @code{combine} instruction, the
9393 constraint @code{"0"} for input operand 1 says that it must occupy the same
9394 location as output operand 0. Only input operands may use numbers in
9395 constraints, and they must each refer to an output operand. Only a number (or
9396 the symbolic assembler name) in the constraint can guarantee that one operand
9397 is in the same place as another. The mere fact that @code{foo} is the value of
9398 both operands is not enough to guarantee that they are in the same place in
9399 the generated assembler code.
9402 asm ("combine %2, %0"
9404 : "0" (foo), "g" (bar));
9407 Here is an example using symbolic names.
9410 asm ("cmoveq %1, %2, %[result]"
9411 : [result] "=r"(result)
9412 : "r" (test), "r" (new), "[result]" (old));
9415 @anchor{Clobbers and Scratch Registers}
9416 @subsubsection Clobbers and Scratch Registers
9417 @cindex @code{asm} clobbers
9418 @cindex @code{asm} scratch registers
9420 While the compiler is aware of changes to entries listed in the output
9421 operands, the inline @code{asm} code may modify more than just the outputs. For
9422 example, calculations may require additional registers, or the processor may
9423 overwrite a register as a side effect of a particular assembler instruction.
9424 In order to inform the compiler of these changes, list them in the clobber
9425 list. Clobber list items are either register names or the special clobbers
9426 (listed below). Each clobber list item is a string constant
9427 enclosed in double quotes and separated by commas.
9429 Clobber descriptions may not in any way overlap with an input or output
9430 operand. For example, you may not have an operand describing a register class
9431 with one member when listing that register in the clobber list. Variables
9432 declared to live in specific registers (@pxref{Explicit Register
9433 Variables}) and used
9434 as @code{asm} input or output operands must have no part mentioned in the
9435 clobber description. In particular, there is no way to specify that input
9436 operands get modified without also specifying them as output operands.
9438 When the compiler selects which registers to use to represent input and output
9439 operands, it does not use any of the clobbered registers. As a result,
9440 clobbered registers are available for any use in the assembler code.
9442 Here is a realistic example for the VAX showing the use of clobbered
9446 asm volatile ("movc3 %0, %1, %2"
9448 : "g" (from), "g" (to), "g" (count)
9449 : "r0", "r1", "r2", "r3", "r4", "r5", "memory");
9452 Also, there are two special clobber arguments:
9456 The @code{"cc"} clobber indicates that the assembler code modifies the flags
9457 register. On some machines, GCC represents the condition codes as a specific
9458 hardware register; @code{"cc"} serves to name this register.
9459 On other machines, condition code handling is different,
9460 and specifying @code{"cc"} has no effect. But
9461 it is valid no matter what the target.
9464 The @code{"memory"} clobber tells the compiler that the assembly code
9466 reads or writes to items other than those listed in the input and output
9467 operands (for example, accessing the memory pointed to by one of the input
9468 parameters). To ensure memory contains correct values, GCC may need to flush
9469 specific register values to memory before executing the @code{asm}. Further,
9470 the compiler does not assume that any values read from memory before an
9471 @code{asm} remain unchanged after that @code{asm}; it reloads them as
9473 Using the @code{"memory"} clobber effectively forms a read/write
9474 memory barrier for the compiler.
9476 Note that this clobber does not prevent the @emph{processor} from doing
9477 speculative reads past the @code{asm} statement. To prevent that, you need
9478 processor-specific fence instructions.
9482 Flushing registers to memory has performance implications and may be
9483 an issue for time-sensitive code. You can provide better information
9484 to GCC to avoid this, as shown in the following examples. At a
9485 minimum, aliasing rules allow GCC to know what memory @emph{doesn't}
9488 Here is a fictitious sum of squares instruction, that takes two
9489 pointers to floating point values in memory and produces a floating
9490 point register output.
9491 Notice that @code{x}, and @code{y} both appear twice in the @code{asm}
9492 parameters, once to specify memory accessed, and once to specify a
9493 base register used by the @code{asm}. You won't normally be wasting a
9494 register by doing this as GCC can use the same register for both
9495 purposes. However, it would be foolish to use both @code{%1} and
9496 @code{%3} for @code{x} in this @code{asm} and expect them to be the
9497 same. In fact, @code{%3} may well not be a register. It might be a
9498 symbolic memory reference to the object pointed to by @code{x}.
9501 asm ("sumsq %0, %1, %2"
9503 : "r" (x), "r" (y), "m" (*x), "m" (*y));
9506 Here is a fictitious @code{*z++ = *x++ * *y++} instruction.
9507 Notice that the @code{x}, @code{y} and @code{z} pointer registers
9508 must be specified as input/output because the @code{asm} modifies
9512 asm ("vecmul %0, %1, %2"
9513 : "+r" (z), "+r" (x), "+r" (y), "=m" (*z)
9514 : "m" (*x), "m" (*y));
9517 An x86 example where the string memory argument is of unknown length.
9521 : "=c" (count), "+D" (p)
9522 : "m" (*(const char (*)[]) p), "0" (-1), "a" (0));
9525 If you know the above will only be reading a ten byte array then you
9526 could instead use a memory input like:
9527 @code{"m" (*(const char (*)[10]) p)}.
9529 Here is an example of a PowerPC vector scale implemented in assembly,
9530 complete with vector and condition code clobbers, and some initialized
9531 offset registers that are unchanged by the @code{asm}.
9535 dscal (size_t n, double *x, double alpha)
9537 asm ("/* lots of asm here */"
9538 : "+m" (*(double (*)[n]) x), "+&r" (n), "+b" (x)
9539 : "d" (alpha), "b" (32), "b" (48), "b" (64),
9540 "b" (80), "b" (96), "b" (112)
9542 "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
9543 "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47");
9547 Rather than allocating fixed registers via clobbers to provide scratch
9548 registers for an @code{asm} statement, an alternative is to define a
9549 variable and make it an early-clobber output as with @code{a2} and
9550 @code{a3} in the example below. This gives the compiler register
9551 allocator more freedom. You can also define a variable and make it an
9552 output tied to an input as with @code{a0} and @code{a1}, tied
9553 respectively to @code{ap} and @code{lda}. Of course, with tied
9554 outputs your @code{asm} can't use the input value after modifying the
9555 output register since they are one and the same register. What's
9556 more, if you omit the early-clobber on the output, it is possible that
9557 GCC might allocate the same register to another of the inputs if GCC
9558 could prove they had the same value on entry to the @code{asm}. This
9559 is why @code{a1} has an early-clobber. Its tied input, @code{lda}
9560 might conceivably be known to have the value 16 and without an
9561 early-clobber share the same register as @code{%11}. On the other
9562 hand, @code{ap} can't be the same as any of the other inputs, so an
9563 early-clobber on @code{a0} is not needed. It is also not desirable in
9564 this case. An early-clobber on @code{a0} would cause GCC to allocate
9565 a separate register for the @code{"m" (*(const double (*)[]) ap)}
9566 input. Note that tying an input to an output is the way to set up an
9567 initialized temporary register modified by an @code{asm} statement.
9568 An input not tied to an output is assumed by GCC to be unchanged, for
9569 example @code{"b" (16)} below sets up @code{%11} to 16, and GCC might
9570 use that register in following code if the value 16 happened to be
9571 needed. You can even use a normal @code{asm} output for a scratch if
9572 all inputs that might share the same register are consumed before the
9573 scratch is used. The VSX registers clobbered by the @code{asm}
9574 statement could have used this technique except for GCC's limit on the
9575 number of @code{asm} parameters.
9579 dgemv_kernel_4x4 (long n, const double *ap, long lda,
9580 const double *x, double *y, double alpha)
9589 /* lots of asm here */
9590 "#n=%1 ap=%8=%12 lda=%13 x=%7=%10 y=%0=%2 alpha=%9 o16=%11\n"
9591 "#a0=%3 a1=%4 a2=%5 a3=%6"
9593 "+m" (*(double (*)[n]) y),
9601 "m" (*(const double (*)[n]) x),
9602 "m" (*(const double (*)[]) ap),
9610 "vs32","vs33","vs34","vs35","vs36","vs37",
9611 "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47"
9617 @subsubsection Goto Labels
9618 @cindex @code{asm} goto labels
9620 @code{asm goto} allows assembly code to jump to one or more C labels. The
9621 @var{GotoLabels} section in an @code{asm goto} statement contains
9623 list of all C labels to which the assembler code may jump. GCC assumes that
9624 @code{asm} execution falls through to the next statement (if this is not the
9625 case, consider using the @code{__builtin_unreachable} intrinsic after the
9626 @code{asm} statement). Optimization of @code{asm goto} may be improved by
9627 using the @code{hot} and @code{cold} label attributes (@pxref{Label
9630 An @code{asm goto} statement cannot have outputs.
9631 This is due to an internal restriction of
9632 the compiler: control transfer instructions cannot have outputs.
9633 If the assembler code does modify anything, use the @code{"memory"} clobber
9635 optimizers to flush all register values to memory and reload them if
9636 necessary after the @code{asm} statement.
9638 Also note that an @code{asm goto} statement is always implicitly
9639 considered volatile.
9641 To reference a label in the assembler template,
9642 prefix it with @samp{%l} (lowercase @samp{L}) followed
9643 by its (zero-based) position in @var{GotoLabels} plus the number of input
9644 operands. For example, if the @code{asm} has three inputs and references two
9645 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
9647 Alternately, you can reference labels using the actual C label name enclosed
9648 in brackets. For example, to reference a label named @code{carry}, you can
9649 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
9650 section when using this approach.
9652 Here is an example of @code{asm goto} for i386:
9659 : "r" (p1), "r" (p2)
9669 The following example shows an @code{asm goto} that uses a memory clobber.
9675 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
9686 @anchor{x86Operandmodifiers}
9687 @subsubsection x86 Operand Modifiers
9689 References to input, output, and goto operands in the assembler template
9690 of extended @code{asm} statements can use
9691 modifiers to affect the way the operands are formatted in
9692 the code output to the assembler. For example, the
9693 following code uses the @samp{h} and @samp{b} modifiers for x86:
9697 asm volatile ("xchg %h0, %b0" : "+a" (num) );
9701 These modifiers generate this assembler code:
9707 The rest of this discussion uses the following code for illustrative purposes.
9716 asm volatile goto ("some assembler instructions here"
9718 : "q" (iInt), "X" (sizeof(unsigned char) + 1), "i" (42)
9719 : /* No clobbers. */
9724 With no modifiers, this is what the output from the operands would be
9725 for the @samp{att} and @samp{intel} dialects of assembler:
9727 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
9728 @headitem Operand @tab @samp{att} @tab @samp{intel}
9737 @tab @code{OFFSET FLAT:.L3}
9740 The table below shows the list of supported modifiers and their effects.
9742 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
9743 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
9745 @tab Print an absolute memory reference.
9750 @tab Print the QImode name of the register.
9755 @tab Require a constant operand and print the constant expression with no punctuation.
9760 @tab Print the address in Double Integer (DImode) mode (8 bytes) when the target is 64-bit.
9761 Otherwise mode is unspecified (VOIDmode).
9766 @tab Print the QImode name for a ``high'' register.
9771 @tab Add 8 bytes to an offsettable memory reference. Useful when accessing the
9772 high 8 bytes of SSE values. For a memref in (%rax), it generates
9777 @tab Print the SImode name of the register.
9782 @tab Print the label name with no punctuation.
9787 @tab Print raw symbol name (without syntax-specific prefixes).
9792 @tab If used for a function, print the PLT suffix and generate PIC code.
9793 For example, emit @code{foo@@PLT} instead of 'foo' for the function
9794 foo(). If used for a constant, drop all syntax-specific prefixes and
9795 issue the bare constant. See @code{p} above.
9797 @tab Print the DImode name of the register.
9802 @tab Print the HImode name of the register.
9807 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
9813 @code{V} is a special modifier which prints the name of the full integer
9814 register without @code{%}.
9816 @anchor{x86floatingpointasmoperands}
9817 @subsubsection x86 Floating-Point @code{asm} Operands
9819 On x86 targets, there are several rules on the usage of stack-like registers
9820 in the operands of an @code{asm}. These rules apply only to the operands
9821 that are stack-like registers:
9825 Given a set of input registers that die in an @code{asm}, it is
9826 necessary to know which are implicitly popped by the @code{asm}, and
9827 which must be explicitly popped by GCC@.
9829 An input register that is implicitly popped by the @code{asm} must be
9830 explicitly clobbered, unless it is constrained to match an
9834 For any input register that is implicitly popped by an @code{asm}, it is
9835 necessary to know how to adjust the stack to compensate for the pop.
9836 If any non-popped input is closer to the top of the reg-stack than
9837 the implicitly popped register, it would not be possible to know what the
9838 stack looked like---it's not clear how the rest of the stack ``slides
9841 All implicitly popped input registers must be closer to the top of
9842 the reg-stack than any input that is not implicitly popped.
9844 It is possible that if an input dies in an @code{asm}, the compiler might
9845 use the input register for an output reload. Consider this example:
9848 asm ("foo" : "=t" (a) : "f" (b));
9852 This code says that input @code{b} is not popped by the @code{asm}, and that
9853 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
9854 deeper after the @code{asm} than it was before. But, it is possible that
9855 reload may think that it can use the same register for both the input and
9858 To prevent this from happening,
9859 if any input operand uses the @samp{f} constraint, all output register
9860 constraints must use the @samp{&} early-clobber modifier.
9862 The example above is correctly written as:
9865 asm ("foo" : "=&t" (a) : "f" (b));
9869 Some operands need to be in particular places on the stack. All
9870 output operands fall in this category---GCC has no other way to
9871 know which registers the outputs appear in unless you indicate
9872 this in the constraints.
9874 Output operands must specifically indicate which register an output
9875 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
9876 constraints must select a class with a single register.
9879 Output operands may not be ``inserted'' between existing stack registers.
9880 Since no 387 opcode uses a read/write operand, all output operands
9881 are dead before the @code{asm}, and are pushed by the @code{asm}.
9882 It makes no sense to push anywhere but the top of the reg-stack.
9884 Output operands must start at the top of the reg-stack: output
9885 operands may not ``skip'' a register.
9888 Some @code{asm} statements may need extra stack space for internal
9889 calculations. This can be guaranteed by clobbering stack registers
9890 unrelated to the inputs and outputs.
9895 takes one input, which is internally popped, and produces two outputs.
9898 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
9902 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
9903 and replaces them with one output. The @code{st(1)} clobber is necessary
9904 for the compiler to know that @code{fyl2xp1} pops both inputs.
9907 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
9915 @subsection Controlling Names Used in Assembler Code
9916 @cindex assembler names for identifiers
9917 @cindex names used in assembler code
9918 @cindex identifiers, names in assembler code
9920 You can specify the name to be used in the assembler code for a C
9921 function or variable by writing the @code{asm} (or @code{__asm__})
9922 keyword after the declarator.
9923 It is up to you to make sure that the assembler names you choose do not
9924 conflict with any other assembler symbols, or reference registers.
9926 @subsubheading Assembler names for data:
9928 This sample shows how to specify the assembler name for data:
9931 int foo asm ("myfoo") = 2;
9935 This specifies that the name to be used for the variable @code{foo} in
9936 the assembler code should be @samp{myfoo} rather than the usual
9939 On systems where an underscore is normally prepended to the name of a C
9940 variable, this feature allows you to define names for the
9941 linker that do not start with an underscore.
9943 GCC does not support using this feature with a non-static local variable
9944 since such variables do not have assembler names. If you are
9945 trying to put the variable in a particular register, see
9946 @ref{Explicit Register Variables}.
9948 @subsubheading Assembler names for functions:
9950 To specify the assembler name for functions, write a declaration for the
9951 function before its definition and put @code{asm} there, like this:
9954 int func (int x, int y) asm ("MYFUNC");
9956 int func (int x, int y)
9962 This specifies that the name to be used for the function @code{func} in
9963 the assembler code should be @code{MYFUNC}.
9965 @node Explicit Register Variables
9966 @subsection Variables in Specified Registers
9967 @anchor{Explicit Reg Vars}
9968 @cindex explicit register variables
9969 @cindex variables in specified registers
9970 @cindex specified registers
9972 GNU C allows you to associate specific hardware registers with C
9973 variables. In almost all cases, allowing the compiler to assign
9974 registers produces the best code. However under certain unusual
9975 circumstances, more precise control over the variable storage is
9978 Both global and local variables can be associated with a register. The
9979 consequences of performing this association are very different between
9980 the two, as explained in the sections below.
9983 * Global Register Variables:: Variables declared at global scope.
9984 * Local Register Variables:: Variables declared within a function.
9987 @node Global Register Variables
9988 @subsubsection Defining Global Register Variables
9989 @anchor{Global Reg Vars}
9990 @cindex global register variables
9991 @cindex registers, global variables in
9992 @cindex registers, global allocation
9994 You can define a global register variable and associate it with a specified
9998 register int *foo asm ("r12");
10002 Here @code{r12} is the name of the register that should be used. Note that
10003 this is the same syntax used for defining local register variables, but for
10004 a global variable the declaration appears outside a function. The
10005 @code{register} keyword is required, and cannot be combined with
10006 @code{static}. The register name must be a valid register name for the
10009 Do not use type qualifiers such as @code{const} and @code{volatile}, as
10010 the outcome may be contrary to expectations. In particular, using the
10011 @code{volatile} qualifier does not fully prevent the compiler from
10012 optimizing accesses to the register.
10014 Registers are a scarce resource on most systems and allowing the
10015 compiler to manage their usage usually results in the best code. However,
10016 under special circumstances it can make sense to reserve some globally.
10017 For example this may be useful in programs such as programming language
10018 interpreters that have a couple of global variables that are accessed
10021 After defining a global register variable, for the current compilation
10025 @item If the register is a call-saved register, call ABI is affected:
10026 the register will not be restored in function epilogue sequences after
10027 the variable has been assigned. Therefore, functions cannot safely
10028 return to callers that assume standard ABI.
10029 @item Conversely, if the register is a call-clobbered register, making
10030 calls to functions that use standard ABI may lose contents of the variable.
10031 Such calls may be created by the compiler even if none are evident in
10032 the original program, for example when libgcc functions are used to
10033 make up for unavailable instructions.
10034 @item Accesses to the variable may be optimized as usual and the register
10035 remains available for allocation and use in any computations, provided that
10036 observable values of the variable are not affected.
10037 @item If the variable is referenced in inline assembly, the type of access
10038 must be provided to the compiler via constraints (@pxref{Constraints}).
10039 Accesses from basic asms are not supported.
10042 Note that these points @emph{only} apply to code that is compiled with the
10043 definition. The behavior of code that is merely linked in (for example
10044 code from libraries) is not affected.
10046 If you want to recompile source files that do not actually use your global
10047 register variable so they do not use the specified register for any other
10048 purpose, you need not actually add the global register declaration to
10049 their source code. It suffices to specify the compiler option
10050 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
10053 @subsubheading Declaring the variable
10055 Global register variables can not have initial values, because an
10056 executable file has no means to supply initial contents for a register.
10058 When selecting a register, choose one that is normally saved and
10059 restored by function calls on your machine. This ensures that code
10060 which is unaware of this reservation (such as library routines) will
10061 restore it before returning.
10063 On machines with register windows, be sure to choose a global
10064 register that is not affected magically by the function call mechanism.
10066 @subsubheading Using the variable
10068 @cindex @code{qsort}, and global register variables
10069 When calling routines that are not aware of the reservation, be
10070 cautious if those routines call back into code which uses them. As an
10071 example, if you call the system library version of @code{qsort}, it may
10072 clobber your registers during execution, but (if you have selected
10073 appropriate registers) it will restore them before returning. However
10074 it will @emph{not} restore them before calling @code{qsort}'s comparison
10075 function. As a result, global values will not reliably be available to
10076 the comparison function unless the @code{qsort} function itself is rebuilt.
10078 Similarly, it is not safe to access the global register variables from signal
10079 handlers or from more than one thread of control. Unless you recompile
10080 them specially for the task at hand, the system library routines may
10081 temporarily use the register for other things. Furthermore, since the register
10082 is not reserved exclusively for the variable, accessing it from handlers of
10083 asynchronous signals may observe unrelated temporary values residing in the
10086 @cindex register variable after @code{longjmp}
10087 @cindex global register after @code{longjmp}
10088 @cindex value after @code{longjmp}
10091 On most machines, @code{longjmp} restores to each global register
10092 variable the value it had at the time of the @code{setjmp}. On some
10093 machines, however, @code{longjmp} does not change the value of global
10094 register variables. To be portable, the function that called @code{setjmp}
10095 should make other arrangements to save the values of the global register
10096 variables, and to restore them in a @code{longjmp}. This way, the same
10097 thing happens regardless of what @code{longjmp} does.
10099 @node Local Register Variables
10100 @subsubsection Specifying Registers for Local Variables
10101 @anchor{Local Reg Vars}
10102 @cindex local variables, specifying registers
10103 @cindex specifying registers for local variables
10104 @cindex registers for local variables
10106 You can define a local register variable and associate it with a specified
10107 register like this:
10110 register int *foo asm ("r12");
10114 Here @code{r12} is the name of the register that should be used. Note
10115 that this is the same syntax used for defining global register variables,
10116 but for a local variable the declaration appears within a function. The
10117 @code{register} keyword is required, and cannot be combined with
10118 @code{static}. The register name must be a valid register name for the
10121 Do not use type qualifiers such as @code{const} and @code{volatile}, as
10122 the outcome may be contrary to expectations. In particular, when the
10123 @code{const} qualifier is used, the compiler may substitute the
10124 variable with its initializer in @code{asm} statements, which may cause
10125 the corresponding operand to appear in a different register.
10127 As with global register variables, it is recommended that you choose
10128 a register that is normally saved and restored by function calls on your
10129 machine, so that calls to library routines will not clobber it.
10131 The only supported use for this feature is to specify registers
10132 for input and output operands when calling Extended @code{asm}
10133 (@pxref{Extended Asm}). This may be necessary if the constraints for a
10134 particular machine don't provide sufficient control to select the desired
10135 register. To force an operand into a register, create a local variable
10136 and specify the register name after the variable's declaration. Then use
10137 the local variable for the @code{asm} operand and specify any constraint
10138 letter that matches the register:
10141 register int *p1 asm ("r0") = @dots{};
10142 register int *p2 asm ("r1") = @dots{};
10143 register int *result asm ("r0");
10144 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
10147 @emph{Warning:} In the above example, be aware that a register (for example
10148 @code{r0}) can be call-clobbered by subsequent code, including function
10149 calls and library calls for arithmetic operators on other variables (for
10150 example the initialization of @code{p2}). In this case, use temporary
10151 variables for expressions between the register assignments:
10155 register int *p1 asm ("r0") = @dots{};
10156 register int *p2 asm ("r1") = t1;
10157 register int *result asm ("r0");
10158 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
10161 Defining a register variable does not reserve the register. Other than
10162 when invoking the Extended @code{asm}, the contents of the specified
10163 register are not guaranteed. For this reason, the following uses
10164 are explicitly @emph{not} supported. If they appear to work, it is only
10165 happenstance, and may stop working as intended due to (seemingly)
10166 unrelated changes in surrounding code, or even minor changes in the
10167 optimization of a future version of gcc:
10170 @item Passing parameters to or from Basic @code{asm}
10171 @item Passing parameters to or from Extended @code{asm} without using input
10172 or output operands.
10173 @item Passing parameters to or from routines written in assembler (or
10174 other languages) using non-standard calling conventions.
10177 Some developers use Local Register Variables in an attempt to improve
10178 gcc's allocation of registers, especially in large functions. In this
10179 case the register name is essentially a hint to the register allocator.
10180 While in some instances this can generate better code, improvements are
10181 subject to the whims of the allocator/optimizers. Since there are no
10182 guarantees that your improvements won't be lost, this usage of Local
10183 Register Variables is discouraged.
10185 On the MIPS platform, there is related use for local register variables
10186 with slightly different characteristics (@pxref{MIPS Coprocessors,,
10187 Defining coprocessor specifics for MIPS targets, gccint,
10188 GNU Compiler Collection (GCC) Internals}).
10190 @node Size of an asm
10191 @subsection Size of an @code{asm}
10193 Some targets require that GCC track the size of each instruction used
10194 in order to generate correct code. Because the final length of the
10195 code produced by an @code{asm} statement is only known by the
10196 assembler, GCC must make an estimate as to how big it will be. It
10197 does this by counting the number of instructions in the pattern of the
10198 @code{asm} and multiplying that by the length of the longest
10199 instruction supported by that processor. (When working out the number
10200 of instructions, it assumes that any occurrence of a newline or of
10201 whatever statement separator character is supported by the assembler ---
10202 typically @samp{;} --- indicates the end of an instruction.)
10204 Normally, GCC's estimate is adequate to ensure that correct
10205 code is generated, but it is possible to confuse the compiler if you use
10206 pseudo instructions or assembler macros that expand into multiple real
10207 instructions, or if you use assembler directives that expand to more
10208 space in the object file than is needed for a single instruction.
10209 If this happens then the assembler may produce a diagnostic saying that
10210 a label is unreachable.
10212 @cindex @code{asm inline}
10213 This size is also used for inlining decisions. If you use @code{asm inline}
10214 instead of just @code{asm}, then for inlining purposes the size of the asm
10215 is taken as the minimum size, ignoring how many instructions GCC thinks it is.
10217 @node Alternate Keywords
10218 @section Alternate Keywords
10219 @cindex alternate keywords
10220 @cindex keywords, alternate
10222 @option{-ansi} and the various @option{-std} options disable certain
10223 keywords. This causes trouble when you want to use GNU C extensions, or
10224 a general-purpose header file that should be usable by all programs,
10225 including ISO C programs. The keywords @code{asm}, @code{typeof} and
10226 @code{inline} are not available in programs compiled with
10227 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
10228 program compiled with @option{-std=c99} or @option{-std=c11}). The
10230 @code{restrict} is only available when @option{-std=gnu99} (which will
10231 eventually be the default) or @option{-std=c99} (or the equivalent
10232 @option{-std=iso9899:1999}), or an option for a later standard
10235 The way to solve these problems is to put @samp{__} at the beginning and
10236 end of each problematical keyword. For example, use @code{__asm__}
10237 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
10239 Other C compilers won't accept these alternative keywords; if you want to
10240 compile with another compiler, you can define the alternate keywords as
10241 macros to replace them with the customary keywords. It looks like this:
10245 #define __asm__ asm
10249 @findex __extension__
10251 @option{-pedantic} and other options cause warnings for many GNU C extensions.
10253 prevent such warnings within one expression by writing
10254 @code{__extension__} before the expression. @code{__extension__} has no
10255 effect aside from this.
10257 @node Incomplete Enums
10258 @section Incomplete @code{enum} Types
10260 You can define an @code{enum} tag without specifying its possible values.
10261 This results in an incomplete type, much like what you get if you write
10262 @code{struct foo} without describing the elements. A later declaration
10263 that does specify the possible values completes the type.
10265 You cannot allocate variables or storage using the type while it is
10266 incomplete. However, you can work with pointers to that type.
10268 This extension may not be very useful, but it makes the handling of
10269 @code{enum} more consistent with the way @code{struct} and @code{union}
10272 This extension is not supported by GNU C++.
10274 @node Function Names
10275 @section Function Names as Strings
10276 @cindex @code{__func__} identifier
10277 @cindex @code{__FUNCTION__} identifier
10278 @cindex @code{__PRETTY_FUNCTION__} identifier
10280 GCC provides three magic constants that hold the name of the current
10281 function as a string. In C++11 and later modes, all three are treated
10282 as constant expressions and can be used in @code{constexpr} constexts.
10283 The first of these constants is @code{__func__}, which is part of
10286 The identifier @code{__func__} is implicitly declared by the translator
10287 as if, immediately following the opening brace of each function
10288 definition, the declaration
10291 static const char __func__[] = "function-name";
10295 appeared, where function-name is the name of the lexically-enclosing
10296 function. This name is the unadorned name of the function. As an
10297 extension, at file (or, in C++, namespace scope), @code{__func__}
10298 evaluates to the empty string.
10300 @code{__FUNCTION__} is another name for @code{__func__}, provided for
10301 backward compatibility with old versions of GCC.
10303 In C, @code{__PRETTY_FUNCTION__} is yet another name for
10304 @code{__func__}, except that at file (or, in C++, namespace scope),
10305 it evaluates to the string @code{"top level"}. In addition, in C++,
10306 @code{__PRETTY_FUNCTION__} contains the signature of the function as
10307 well as its bare name. For example, this program:
10310 extern "C" int printf (const char *, ...);
10316 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
10317 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
10335 __PRETTY_FUNCTION__ = void a::sub(int)
10338 These identifiers are variables, not preprocessor macros, and may not
10339 be used to initialize @code{char} arrays or be concatenated with string
10342 @node Return Address
10343 @section Getting the Return or Frame Address of a Function
10345 These functions may be used to get information about the callers of a
10348 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
10349 This function returns the return address of the current function, or of
10350 one of its callers. The @var{level} argument is number of frames to
10351 scan up the call stack. A value of @code{0} yields the return address
10352 of the current function, a value of @code{1} yields the return address
10353 of the caller of the current function, and so forth. When inlining
10354 the expected behavior is that the function returns the address of
10355 the function that is returned to. To work around this behavior use
10356 the @code{noinline} function attribute.
10358 The @var{level} argument must be a constant integer.
10360 On some machines it may be impossible to determine the return address of
10361 any function other than the current one; in such cases, or when the top
10362 of the stack has been reached, this function returns @code{0} or a
10363 random value. In addition, @code{__builtin_frame_address} may be used
10364 to determine if the top of the stack has been reached.
10366 Additional post-processing of the returned value may be needed, see
10367 @code{__builtin_extract_return_addr}.
10369 Calling this function with a nonzero argument can have unpredictable
10370 effects, including crashing the calling program. As a result, calls
10371 that are considered unsafe are diagnosed when the @option{-Wframe-address}
10372 option is in effect. Such calls should only be made in debugging
10376 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
10377 The address as returned by @code{__builtin_return_address} may have to be fed
10378 through this function to get the actual encoded address. For example, on the
10379 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
10380 platforms an offset has to be added for the true next instruction to be
10383 If no fixup is needed, this function simply passes through @var{addr}.
10386 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
10387 This function does the reverse of @code{__builtin_extract_return_addr}.
10390 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
10391 This function is similar to @code{__builtin_return_address}, but it
10392 returns the address of the function frame rather than the return address
10393 of the function. Calling @code{__builtin_frame_address} with a value of
10394 @code{0} yields the frame address of the current function, a value of
10395 @code{1} yields the frame address of the caller of the current function,
10398 The frame is the area on the stack that holds local variables and saved
10399 registers. The frame address is normally the address of the first word
10400 pushed on to the stack by the function. However, the exact definition
10401 depends upon the processor and the calling convention. If the processor
10402 has a dedicated frame pointer register, and the function has a frame,
10403 then @code{__builtin_frame_address} returns the value of the frame
10406 On some machines it may be impossible to determine the frame address of
10407 any function other than the current one; in such cases, or when the top
10408 of the stack has been reached, this function returns @code{0} if
10409 the first frame pointer is properly initialized by the startup code.
10411 Calling this function with a nonzero argument can have unpredictable
10412 effects, including crashing the calling program. As a result, calls
10413 that are considered unsafe are diagnosed when the @option{-Wframe-address}
10414 option is in effect. Such calls should only be made in debugging
10418 @node Vector Extensions
10419 @section Using Vector Instructions through Built-in Functions
10421 On some targets, the instruction set contains SIMD vector instructions which
10422 operate on multiple values contained in one large register at the same time.
10423 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
10426 The first step in using these extensions is to provide the necessary data
10427 types. This should be done using an appropriate @code{typedef}:
10430 typedef int v4si __attribute__ ((vector_size (16)));
10434 The @code{int} type specifies the base type, while the attribute specifies
10435 the vector size for the variable, measured in bytes. For example, the
10436 declaration above causes the compiler to set the mode for the @code{v4si}
10437 type to be 16 bytes wide and divided into @code{int} sized units. For
10438 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
10439 corresponding mode of @code{foo} is @acronym{V4SI}.
10441 The @code{vector_size} attribute is only applicable to integral and
10442 float scalars, although arrays, pointers, and function return values
10443 are allowed in conjunction with this construct. Only sizes that are
10444 a power of two are currently allowed.
10446 All the basic integer types can be used as base types, both as signed
10447 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
10448 @code{long long}. In addition, @code{float} and @code{double} can be
10449 used to build floating-point vector types.
10451 Specifying a combination that is not valid for the current architecture
10452 causes GCC to synthesize the instructions using a narrower mode.
10453 For example, if you specify a variable of type @code{V4SI} and your
10454 architecture does not allow for this specific SIMD type, GCC
10455 produces code that uses 4 @code{SIs}.
10457 The types defined in this manner can be used with a subset of normal C
10458 operations. Currently, GCC allows using the following operators
10459 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
10461 The operations behave like C++ @code{valarrays}. Addition is defined as
10462 the addition of the corresponding elements of the operands. For
10463 example, in the code below, each of the 4 elements in @var{a} is
10464 added to the corresponding 4 elements in @var{b} and the resulting
10465 vector is stored in @var{c}.
10468 typedef int v4si __attribute__ ((vector_size (16)));
10475 Subtraction, multiplication, division, and the logical operations
10476 operate in a similar manner. Likewise, the result of using the unary
10477 minus or complement operators on a vector type is a vector whose
10478 elements are the negative or complemented values of the corresponding
10479 elements in the operand.
10481 It is possible to use shifting operators @code{<<}, @code{>>} on
10482 integer-type vectors. The operation is defined as following: @code{@{a0,
10483 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
10484 @dots{}, an >> bn@}}@. Vector operands must have the same number of
10487 For convenience, it is allowed to use a binary vector operation
10488 where one operand is a scalar. In that case the compiler transforms
10489 the scalar operand into a vector where each element is the scalar from
10490 the operation. The transformation happens only if the scalar could be
10491 safely converted to the vector-element type.
10492 Consider the following code.
10495 typedef int v4si __attribute__ ((vector_size (16)));
10500 a = b + 1; /* a = b + @{1,1,1,1@}; */
10501 a = 2 * b; /* a = @{2,2,2,2@} * b; */
10503 a = l + a; /* Error, cannot convert long to int. */
10506 Vectors can be subscripted as if the vector were an array with
10507 the same number of elements and base type. Out of bound accesses
10508 invoke undefined behavior at run time. Warnings for out of bound
10509 accesses for vector subscription can be enabled with
10510 @option{-Warray-bounds}.
10512 Vector comparison is supported with standard comparison
10513 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
10514 vector expressions of integer-type or real-type. Comparison between
10515 integer-type vectors and real-type vectors are not supported. The
10516 result of the comparison is a vector of the same width and number of
10517 elements as the comparison operands with a signed integral element
10520 Vectors are compared element-wise producing 0 when comparison is false
10521 and -1 (constant of the appropriate type where all bits are set)
10522 otherwise. Consider the following example.
10525 typedef int v4si __attribute__ ((vector_size (16)));
10527 v4si a = @{1,2,3,4@};
10528 v4si b = @{3,2,1,4@};
10531 c = a > b; /* The result would be @{0, 0,-1, 0@} */
10532 c = a == b; /* The result would be @{0,-1, 0,-1@} */
10535 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
10536 @code{b} and @code{c} are vectors of the same type and @code{a} is an
10537 integer vector with the same number of elements of the same size as @code{b}
10538 and @code{c}, computes all three arguments and creates a vector
10539 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
10540 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
10541 As in the case of binary operations, this syntax is also accepted when
10542 one of @code{b} or @code{c} is a scalar that is then transformed into a
10543 vector. If both @code{b} and @code{c} are scalars and the type of
10544 @code{true?b:c} has the same size as the element type of @code{a}, then
10545 @code{b} and @code{c} are converted to a vector type whose elements have
10546 this type and with the same number of elements as @code{a}.
10548 In C++, the logic operators @code{!, &&, ||} are available for vectors.
10549 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
10550 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
10551 For mixed operations between a scalar @code{s} and a vector @code{v},
10552 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
10553 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
10555 @findex __builtin_shuffle
10556 Vector shuffling is available using functions
10557 @code{__builtin_shuffle (vec, mask)} and
10558 @code{__builtin_shuffle (vec0, vec1, mask)}.
10559 Both functions construct a permutation of elements from one or two
10560 vectors and return a vector of the same type as the input vector(s).
10561 The @var{mask} is an integral vector with the same width (@var{W})
10562 and element count (@var{N}) as the output vector.
10564 The elements of the input vectors are numbered in memory ordering of
10565 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
10566 elements of @var{mask} are considered modulo @var{N} in the single-operand
10567 case and modulo @math{2*@var{N}} in the two-operand case.
10569 Consider the following example,
10572 typedef int v4si __attribute__ ((vector_size (16)));
10574 v4si a = @{1,2,3,4@};
10575 v4si b = @{5,6,7,8@};
10576 v4si mask1 = @{0,1,1,3@};
10577 v4si mask2 = @{0,4,2,5@};
10580 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
10581 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
10584 Note that @code{__builtin_shuffle} is intentionally semantically
10585 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
10587 You can declare variables and use them in function calls and returns, as
10588 well as in assignments and some casts. You can specify a vector type as
10589 a return type for a function. Vector types can also be used as function
10590 arguments. It is possible to cast from one vector type to another,
10591 provided they are of the same size (in fact, you can also cast vectors
10592 to and from other datatypes of the same size).
10594 You cannot operate between vectors of different lengths or different
10595 signedness without a cast.
10598 @section Support for @code{offsetof}
10599 @findex __builtin_offsetof
10601 GCC implements for both C and C++ a syntactic extension to implement
10602 the @code{offsetof} macro.
10606 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
10608 offsetof_member_designator:
10610 | offsetof_member_designator "." @code{identifier}
10611 | offsetof_member_designator "[" @code{expr} "]"
10614 This extension is sufficient such that
10617 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
10621 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
10622 may be dependent. In either case, @var{member} may consist of a single
10623 identifier, or a sequence of member accesses and array references.
10625 @node __sync Builtins
10626 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
10628 The following built-in functions
10629 are intended to be compatible with those described
10630 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
10631 section 7.4. As such, they depart from normal GCC practice by not using
10632 the @samp{__builtin_} prefix and also by being overloaded so that they
10633 work on multiple types.
10635 The definition given in the Intel documentation allows only for the use of
10636 the types @code{int}, @code{long}, @code{long long} or their unsigned
10637 counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
10638 size other than the C type @code{_Bool} or the C++ type @code{bool}.
10639 Operations on pointer arguments are performed as if the operands were
10640 of the @code{uintptr_t} type. That is, they are not scaled by the size
10641 of the type to which the pointer points.
10643 These functions are implemented in terms of the @samp{__atomic}
10644 builtins (@pxref{__atomic Builtins}). They should not be used for new
10645 code which should use the @samp{__atomic} builtins instead.
10647 Not all operations are supported by all target processors. If a particular
10648 operation cannot be implemented on the target processor, a warning is
10649 generated and a call to an external function is generated. The external
10650 function carries the same name as the built-in version,
10651 with an additional suffix
10652 @samp{_@var{n}} where @var{n} is the size of the data type.
10654 @c ??? Should we have a mechanism to suppress this warning? This is almost
10655 @c useful for implementing the operation under the control of an external
10658 In most cases, these built-in functions are considered a @dfn{full barrier}.
10660 no memory operand is moved across the operation, either forward or
10661 backward. Further, instructions are issued as necessary to prevent the
10662 processor from speculating loads across the operation and from queuing stores
10663 after the operation.
10665 All of the routines are described in the Intel documentation to take
10666 ``an optional list of variables protected by the memory barrier''. It's
10667 not clear what is meant by that; it could mean that @emph{only} the
10668 listed variables are protected, or it could mean a list of additional
10669 variables to be protected. The list is ignored by GCC which treats it as
10670 empty. GCC interprets an empty list as meaning that all globally
10671 accessible variables should be protected.
10674 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
10675 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
10676 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
10677 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
10678 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
10679 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
10680 @findex __sync_fetch_and_add
10681 @findex __sync_fetch_and_sub
10682 @findex __sync_fetch_and_or
10683 @findex __sync_fetch_and_and
10684 @findex __sync_fetch_and_xor
10685 @findex __sync_fetch_and_nand
10686 These built-in functions perform the operation suggested by the name, and
10687 returns the value that had previously been in memory. That is, operations
10688 on integer operands have the following semantics. Operations on pointer
10689 arguments are performed as if the operands were of the @code{uintptr_t}
10690 type. That is, they are not scaled by the size of the type to which
10691 the pointer points.
10694 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
10695 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
10698 The object pointed to by the first argument must be of integer or pointer
10699 type. It must not be a boolean type.
10701 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
10702 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
10704 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
10705 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
10706 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
10707 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
10708 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
10709 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
10710 @findex __sync_add_and_fetch
10711 @findex __sync_sub_and_fetch
10712 @findex __sync_or_and_fetch
10713 @findex __sync_and_and_fetch
10714 @findex __sync_xor_and_fetch
10715 @findex __sync_nand_and_fetch
10716 These built-in functions perform the operation suggested by the name, and
10717 return the new value. That is, operations on integer operands have
10718 the following semantics. Operations on pointer operands are performed as
10719 if the operand's type were @code{uintptr_t}.
10722 @{ *ptr @var{op}= value; return *ptr; @}
10723 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
10726 The same constraints on arguments apply as for the corresponding
10727 @code{__sync_op_and_fetch} built-in functions.
10729 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
10730 as @code{*ptr = ~(*ptr & value)} instead of
10731 @code{*ptr = ~*ptr & value}.
10733 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10734 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10735 @findex __sync_bool_compare_and_swap
10736 @findex __sync_val_compare_and_swap
10737 These built-in functions perform an atomic compare and swap.
10738 That is, if the current
10739 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
10742 The ``bool'' version returns @code{true} if the comparison is successful and
10743 @var{newval} is written. The ``val'' version returns the contents
10744 of @code{*@var{ptr}} before the operation.
10746 @item __sync_synchronize (...)
10747 @findex __sync_synchronize
10748 This built-in function issues a full memory barrier.
10750 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
10751 @findex __sync_lock_test_and_set
10752 This built-in function, as described by Intel, is not a traditional test-and-set
10753 operation, but rather an atomic exchange operation. It writes @var{value}
10754 into @code{*@var{ptr}}, and returns the previous contents of
10757 Many targets have only minimal support for such locks, and do not support
10758 a full exchange operation. In this case, a target may support reduced
10759 functionality here by which the @emph{only} valid value to store is the
10760 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
10761 is implementation defined.
10763 This built-in function is not a full barrier,
10764 but rather an @dfn{acquire barrier}.
10765 This means that references after the operation cannot move to (or be
10766 speculated to) before the operation, but previous memory stores may not
10767 be globally visible yet, and previous memory loads may not yet be
10770 @item void __sync_lock_release (@var{type} *ptr, ...)
10771 @findex __sync_lock_release
10772 This built-in function releases the lock acquired by
10773 @code{__sync_lock_test_and_set}.
10774 Normally this means writing the constant 0 to @code{*@var{ptr}}.
10776 This built-in function is not a full barrier,
10777 but rather a @dfn{release barrier}.
10778 This means that all previous memory stores are globally visible, and all
10779 previous memory loads have been satisfied, but following memory reads
10780 are not prevented from being speculated to before the barrier.
10783 @node __atomic Builtins
10784 @section Built-in Functions for Memory Model Aware Atomic Operations
10786 The following built-in functions approximately match the requirements
10787 for the C++11 memory model. They are all
10788 identified by being prefixed with @samp{__atomic} and most are
10789 overloaded so that they work with multiple types.
10791 These functions are intended to replace the legacy @samp{__sync}
10792 builtins. The main difference is that the memory order that is requested
10793 is a parameter to the functions. New code should always use the
10794 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
10796 Note that the @samp{__atomic} builtins assume that programs will
10797 conform to the C++11 memory model. In particular, they assume
10798 that programs are free of data races. See the C++11 standard for
10799 detailed requirements.
10801 The @samp{__atomic} builtins can be used with any integral scalar or
10802 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
10803 types are also allowed if @samp{__int128} (@pxref{__int128}) is
10804 supported by the architecture.
10806 The four non-arithmetic functions (load, store, exchange, and
10807 compare_exchange) all have a generic version as well. This generic
10808 version works on any data type. It uses the lock-free built-in function
10809 if the specific data type size makes that possible; otherwise, an
10810 external call is left to be resolved at run time. This external call is
10811 the same format with the addition of a @samp{size_t} parameter inserted
10812 as the first parameter indicating the size of the object being pointed to.
10813 All objects must be the same size.
10815 There are 6 different memory orders that can be specified. These map
10816 to the C++11 memory orders with the same names, see the C++11 standard
10817 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
10818 on atomic synchronization} for detailed definitions. Individual
10819 targets may also support additional memory orders for use on specific
10820 architectures. Refer to the target documentation for details of
10823 An atomic operation can both constrain code motion and
10824 be mapped to hardware instructions for synchronization between threads
10825 (e.g., a fence). To which extent this happens is controlled by the
10826 memory orders, which are listed here in approximately ascending order of
10827 strength. The description of each memory order is only meant to roughly
10828 illustrate the effects and is not a specification; see the C++11
10829 memory model for precise semantics.
10832 @item __ATOMIC_RELAXED
10833 Implies no inter-thread ordering constraints.
10834 @item __ATOMIC_CONSUME
10835 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
10836 memory order because of a deficiency in C++11's semantics for
10837 @code{memory_order_consume}.
10838 @item __ATOMIC_ACQUIRE
10839 Creates an inter-thread happens-before constraint from the release (or
10840 stronger) semantic store to this acquire load. Can prevent hoisting
10841 of code to before the operation.
10842 @item __ATOMIC_RELEASE
10843 Creates an inter-thread happens-before constraint to acquire (or stronger)
10844 semantic loads that read from this release store. Can prevent sinking
10845 of code to after the operation.
10846 @item __ATOMIC_ACQ_REL
10847 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
10848 @code{__ATOMIC_RELEASE}.
10849 @item __ATOMIC_SEQ_CST
10850 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
10853 Note that in the C++11 memory model, @emph{fences} (e.g.,
10854 @samp{__atomic_thread_fence}) take effect in combination with other
10855 atomic operations on specific memory locations (e.g., atomic loads);
10856 operations on specific memory locations do not necessarily affect other
10857 operations in the same way.
10859 Target architectures are encouraged to provide their own patterns for
10860 each of the atomic built-in functions. If no target is provided, the original
10861 non-memory model set of @samp{__sync} atomic built-in functions are
10862 used, along with any required synchronization fences surrounding it in
10863 order to achieve the proper behavior. Execution in this case is subject
10864 to the same restrictions as those built-in functions.
10866 If there is no pattern or mechanism to provide a lock-free instruction
10867 sequence, a call is made to an external routine with the same parameters
10868 to be resolved at run time.
10870 When implementing patterns for these built-in functions, the memory order
10871 parameter can be ignored as long as the pattern implements the most
10872 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
10873 orders execute correctly with this memory order but they may not execute as
10874 efficiently as they could with a more appropriate implementation of the
10875 relaxed requirements.
10877 Note that the C++11 standard allows for the memory order parameter to be
10878 determined at run time rather than at compile time. These built-in
10879 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
10880 than invoke a runtime library call or inline a switch statement. This is
10881 standard compliant, safe, and the simplest approach for now.
10883 The memory order parameter is a signed int, but only the lower 16 bits are
10884 reserved for the memory order. The remainder of the signed int is reserved
10885 for target use and should be 0. Use of the predefined atomic values
10886 ensures proper usage.
10888 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
10889 This built-in function implements an atomic load operation. It returns the
10890 contents of @code{*@var{ptr}}.
10892 The valid memory order variants are
10893 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10894 and @code{__ATOMIC_CONSUME}.
10898 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
10899 This is the generic version of an atomic load. It returns the
10900 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
10904 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
10905 This built-in function implements an atomic store operation. It writes
10906 @code{@var{val}} into @code{*@var{ptr}}.
10908 The valid memory order variants are
10909 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
10913 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
10914 This is the generic version of an atomic store. It stores the value
10915 of @code{*@var{val}} into @code{*@var{ptr}}.
10919 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
10920 This built-in function implements an atomic exchange operation. It writes
10921 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
10924 The valid memory order variants are
10925 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10926 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
10930 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
10931 This is the generic version of an atomic exchange. It stores the
10932 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
10933 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
10937 @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)
10938 This built-in function implements an atomic compare and exchange operation.
10939 This compares the contents of @code{*@var{ptr}} with the contents of
10940 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
10941 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
10942 equal, the operation is a @emph{read} and the current contents of
10943 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is @code{true}
10944 for weak compare_exchange, which may fail spuriously, and @code{false} for
10945 the strong variation, which never fails spuriously. Many targets
10946 only offer the strong variation and ignore the parameter. When in doubt, use
10947 the strong variation.
10949 If @var{desired} is written into @code{*@var{ptr}} then @code{true} is returned
10950 and memory is affected according to the
10951 memory order specified by @var{success_memorder}. There are no
10952 restrictions on what memory order can be used here.
10954 Otherwise, @code{false} is returned and memory is affected according
10955 to @var{failure_memorder}. This memory order cannot be
10956 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
10957 stronger order than that specified by @var{success_memorder}.
10961 @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)
10962 This built-in function implements the generic version of
10963 @code{__atomic_compare_exchange}. The function is virtually identical to
10964 @code{__atomic_compare_exchange_n}, except the desired value is also a
10969 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
10970 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
10971 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
10972 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
10973 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
10974 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
10975 These built-in functions perform the operation suggested by the name, and
10976 return the result of the operation. Operations on pointer arguments are
10977 performed as if the operands were of the @code{uintptr_t} type. That is,
10978 they are not scaled by the size of the type to which the pointer points.
10981 @{ *ptr @var{op}= val; return *ptr; @}
10984 The object pointed to by the first argument must be of integer or pointer
10985 type. It must not be a boolean type. All memory orders are valid.
10989 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
10990 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
10991 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
10992 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
10993 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
10994 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
10995 These built-in functions perform the operation suggested by the name, and
10996 return the value that had previously been in @code{*@var{ptr}}. Operations
10997 on pointer arguments are performed as if the operands were of
10998 the @code{uintptr_t} type. That is, they are not scaled by the size of
10999 the type to which the pointer points.
11002 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
11005 The same constraints on arguments apply as for the corresponding
11006 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
11010 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
11012 This built-in function performs an atomic test-and-set operation on
11013 the byte at @code{*@var{ptr}}. The byte is set to some implementation
11014 defined nonzero ``set'' value and the return value is @code{true} if and only
11015 if the previous contents were ``set''.
11016 It should be only used for operands of type @code{bool} or @code{char}. For
11017 other types only part of the value may be set.
11019 All memory orders are valid.
11023 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
11025 This built-in function performs an atomic clear operation on
11026 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
11027 It should be only used for operands of type @code{bool} or @code{char} and
11028 in conjunction with @code{__atomic_test_and_set}.
11029 For other types it may only clear partially. If the type is not @code{bool}
11030 prefer using @code{__atomic_store}.
11032 The valid memory order variants are
11033 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
11034 @code{__ATOMIC_RELEASE}.
11038 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
11040 This built-in function acts as a synchronization fence between threads
11041 based on the specified memory order.
11043 All memory orders are valid.
11047 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
11049 This built-in function acts as a synchronization fence between a thread
11050 and signal handlers based in the same thread.
11052 All memory orders are valid.
11056 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
11058 This built-in function returns @code{true} if objects of @var{size} bytes always
11059 generate lock-free atomic instructions for the target architecture.
11060 @var{size} must resolve to a compile-time constant and the result also
11061 resolves to a compile-time constant.
11063 @var{ptr} is an optional pointer to the object that may be used to determine
11064 alignment. A value of 0 indicates typical alignment should be used. The
11065 compiler may also ignore this parameter.
11068 if (__atomic_always_lock_free (sizeof (long long), 0))
11073 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
11075 This built-in function returns @code{true} if objects of @var{size} bytes always
11076 generate lock-free atomic instructions for the target architecture. If
11077 the built-in function is not known to be lock-free, a call is made to a
11078 runtime routine named @code{__atomic_is_lock_free}.
11080 @var{ptr} is an optional pointer to the object that may be used to determine
11081 alignment. A value of 0 indicates typical alignment should be used. The
11082 compiler may also ignore this parameter.
11085 @node Integer Overflow Builtins
11086 @section Built-in Functions to Perform Arithmetic with Overflow Checking
11088 The following built-in functions allow performing simple arithmetic operations
11089 together with checking whether the operations overflowed.
11091 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
11092 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
11093 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
11094 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
11095 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
11096 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
11097 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
11099 These built-in functions promote the first two operands into infinite precision signed
11100 type and perform addition on those promoted operands. The result is then
11101 cast to the type the third pointer argument points to and stored there.
11102 If the stored result is equal to the infinite precision result, the built-in
11103 functions return @code{false}, otherwise they return @code{true}. As the addition is
11104 performed in infinite signed precision, these built-in functions have fully defined
11105 behavior for all argument values.
11107 The first built-in function allows arbitrary integral types for operands and
11108 the result type must be pointer to some integral type other than enumerated or
11109 boolean type, the rest of the built-in functions have explicit integer types.
11111 The compiler will attempt to use hardware instructions to implement
11112 these built-in functions where possible, like conditional jump on overflow
11113 after addition, conditional jump on carry etc.
11117 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
11118 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
11119 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
11120 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
11121 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
11122 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
11123 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
11125 These built-in functions are similar to the add overflow checking built-in
11126 functions above, except they perform subtraction, subtract the second argument
11127 from the first one, instead of addition.
11131 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
11132 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
11133 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
11134 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
11135 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
11136 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
11137 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
11139 These built-in functions are similar to the add overflow checking built-in
11140 functions above, except they perform multiplication, instead of addition.
11144 The following built-in functions allow checking if simple arithmetic operation
11147 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
11148 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
11149 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
11151 These built-in functions are similar to @code{__builtin_add_overflow},
11152 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
11153 they don't store the result of the arithmetic operation anywhere and the
11154 last argument is not a pointer, but some expression with integral type other
11155 than enumerated or boolean type.
11157 The built-in functions promote the first two operands into infinite precision signed type
11158 and perform addition on those promoted operands. The result is then
11159 cast to the type of the third argument. If the cast result is equal to the infinite
11160 precision result, the built-in functions return @code{false}, otherwise they return @code{true}.
11161 The value of the third argument is ignored, just the side effects in the third argument
11162 are evaluated, and no integral argument promotions are performed on the last argument.
11163 If the third argument is a bit-field, the type used for the result cast has the
11164 precision and signedness of the given bit-field, rather than precision and signedness
11165 of the underlying type.
11167 For example, the following macro can be used to portably check, at
11168 compile-time, whether or not adding two constant integers will overflow,
11169 and perform the addition only when it is known to be safe and not to trigger
11170 a @option{-Woverflow} warning.
11173 #define INT_ADD_OVERFLOW_P(a, b) \
11174 __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
11177 A = INT_MAX, B = 3,
11178 C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
11179 D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
11183 The compiler will attempt to use hardware instructions to implement
11184 these built-in functions where possible, like conditional jump on overflow
11185 after addition, conditional jump on carry etc.
11189 @node x86 specific memory model extensions for transactional memory
11190 @section x86-Specific Memory Model Extensions for Transactional Memory
11192 The x86 architecture supports additional memory ordering flags
11193 to mark critical sections for hardware lock elision.
11194 These must be specified in addition to an existing memory order to
11198 @item __ATOMIC_HLE_ACQUIRE
11199 Start lock elision on a lock variable.
11200 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
11201 @item __ATOMIC_HLE_RELEASE
11202 End lock elision on a lock variable.
11203 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
11206 When a lock acquire fails, it is required for good performance to abort
11207 the transaction quickly. This can be done with a @code{_mm_pause}.
11210 #include <immintrin.h> // For _mm_pause
11214 /* Acquire lock with lock elision */
11215 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
11216 _mm_pause(); /* Abort failed transaction */
11218 /* Free lock with lock elision */
11219 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
11222 @node Object Size Checking
11223 @section Object Size Checking Built-in Functions
11224 @findex __builtin_object_size
11225 @findex __builtin___memcpy_chk
11226 @findex __builtin___mempcpy_chk
11227 @findex __builtin___memmove_chk
11228 @findex __builtin___memset_chk
11229 @findex __builtin___strcpy_chk
11230 @findex __builtin___stpcpy_chk
11231 @findex __builtin___strncpy_chk
11232 @findex __builtin___strcat_chk
11233 @findex __builtin___strncat_chk
11234 @findex __builtin___sprintf_chk
11235 @findex __builtin___snprintf_chk
11236 @findex __builtin___vsprintf_chk
11237 @findex __builtin___vsnprintf_chk
11238 @findex __builtin___printf_chk
11239 @findex __builtin___vprintf_chk
11240 @findex __builtin___fprintf_chk
11241 @findex __builtin___vfprintf_chk
11243 GCC implements a limited buffer overflow protection mechanism that can
11244 prevent some buffer overflow attacks by determining the sizes of objects
11245 into which data is about to be written and preventing the writes when
11246 the size isn't sufficient. The built-in functions described below yield
11247 the best results when used together and when optimization is enabled.
11248 For example, to detect object sizes across function boundaries or to
11249 follow pointer assignments through non-trivial control flow they rely
11250 on various optimization passes enabled with @option{-O2}. However, to
11251 a limited extent, they can be used without optimization as well.
11253 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
11254 is a built-in construct that returns a constant number of bytes from
11255 @var{ptr} to the end of the object @var{ptr} pointer points to
11256 (if known at compile time). To determine the sizes of dynamically allocated
11257 objects the function relies on the allocation functions called to obtain
11258 the storage to be declared with the @code{alloc_size} attribute (@xref{Common
11259 Function Attributes}). @code{__builtin_object_size} never evaluates
11260 its arguments for side effects. If there are any side effects in them, it
11261 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
11262 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
11263 point to and all of them are known at compile time, the returned number
11264 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
11265 0 and minimum if nonzero. If it is not possible to determine which objects
11266 @var{ptr} points to at compile time, @code{__builtin_object_size} should
11267 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
11268 for @var{type} 2 or 3.
11270 @var{type} is an integer constant from 0 to 3. If the least significant
11271 bit is clear, objects are whole variables, if it is set, a closest
11272 surrounding subobject is considered the object a pointer points to.
11273 The second bit determines if maximum or minimum of remaining bytes
11277 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
11278 char *p = &var.buf1[1], *q = &var.b;
11280 /* Here the object p points to is var. */
11281 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
11282 /* The subobject p points to is var.buf1. */
11283 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
11284 /* The object q points to is var. */
11285 assert (__builtin_object_size (q, 0)
11286 == (char *) (&var + 1) - (char *) &var.b);
11287 /* The subobject q points to is var.b. */
11288 assert (__builtin_object_size (q, 1) == sizeof (var.b));
11292 There are built-in functions added for many common string operation
11293 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
11294 built-in is provided. This built-in has an additional last argument,
11295 which is the number of bytes remaining in the object the @var{dest}
11296 argument points to or @code{(size_t) -1} if the size is not known.
11298 The built-in functions are optimized into the normal string functions
11299 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
11300 it is known at compile time that the destination object will not
11301 be overflowed. If the compiler can determine at compile time that the
11302 object will always be overflowed, it issues a warning.
11304 The intended use can be e.g.@:
11308 #define bos0(dest) __builtin_object_size (dest, 0)
11309 #define memcpy(dest, src, n) \
11310 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
11314 /* It is unknown what object p points to, so this is optimized
11315 into plain memcpy - no checking is possible. */
11316 memcpy (p, "abcde", n);
11317 /* Destination is known and length too. It is known at compile
11318 time there will be no overflow. */
11319 memcpy (&buf[5], "abcde", 5);
11320 /* Destination is known, but the length is not known at compile time.
11321 This will result in __memcpy_chk call that can check for overflow
11323 memcpy (&buf[5], "abcde", n);
11324 /* Destination is known and it is known at compile time there will
11325 be overflow. There will be a warning and __memcpy_chk call that
11326 will abort the program at run time. */
11327 memcpy (&buf[6], "abcde", 5);
11330 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
11331 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
11332 @code{strcat} and @code{strncat}.
11334 There are also checking built-in functions for formatted output functions.
11336 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
11337 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
11338 const char *fmt, ...);
11339 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
11341 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
11342 const char *fmt, va_list ap);
11345 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
11346 etc.@: functions and can contain implementation specific flags on what
11347 additional security measures the checking function might take, such as
11348 handling @code{%n} differently.
11350 The @var{os} argument is the object size @var{s} points to, like in the
11351 other built-in functions. There is a small difference in the behavior
11352 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
11353 optimized into the non-checking functions only if @var{flag} is 0, otherwise
11354 the checking function is called with @var{os} argument set to
11355 @code{(size_t) -1}.
11357 In addition to this, there are checking built-in functions
11358 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
11359 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
11360 These have just one additional argument, @var{flag}, right before
11361 format string @var{fmt}. If the compiler is able to optimize them to
11362 @code{fputc} etc.@: functions, it does, otherwise the checking function
11363 is called and the @var{flag} argument passed to it.
11365 @node Other Builtins
11366 @section Other Built-in Functions Provided by GCC
11367 @cindex built-in functions
11368 @findex __builtin_alloca
11369 @findex __builtin_alloca_with_align
11370 @findex __builtin_alloca_with_align_and_max
11371 @findex __builtin_call_with_static_chain
11372 @findex __builtin_extend_pointer
11373 @findex __builtin_fpclassify
11374 @findex __builtin_has_attribute
11375 @findex __builtin_isfinite
11376 @findex __builtin_isnormal
11377 @findex __builtin_isgreater
11378 @findex __builtin_isgreaterequal
11379 @findex __builtin_isinf_sign
11380 @findex __builtin_isless
11381 @findex __builtin_islessequal
11382 @findex __builtin_islessgreater
11383 @findex __builtin_isunordered
11384 @findex __builtin_object_size
11385 @findex __builtin_powi
11386 @findex __builtin_powif
11387 @findex __builtin_powil
11388 @findex __builtin_speculation_safe_value
11549 @findex fprintf_unlocked
11551 @findex fputs_unlocked
11659 @findex nexttowardf
11660 @findex nexttowardl
11668 @findex printf_unlocked
11698 @findex signbitd128
11699 @findex significand
11700 @findex significandf
11701 @findex significandl
11729 @findex strncasecmp
11773 GCC provides a large number of built-in functions other than the ones
11774 mentioned above. Some of these are for internal use in the processing
11775 of exceptions or variable-length argument lists and are not
11776 documented here because they may change from time to time; we do not
11777 recommend general use of these functions.
11779 The remaining functions are provided for optimization purposes.
11781 With the exception of built-ins that have library equivalents such as
11782 the standard C library functions discussed below, or that expand to
11783 library calls, GCC built-in functions are always expanded inline and
11784 thus do not have corresponding entry points and their address cannot
11785 be obtained. Attempting to use them in an expression other than
11786 a function call results in a compile-time error.
11788 @opindex fno-builtin
11789 GCC includes built-in versions of many of the functions in the standard
11790 C library. These functions come in two forms: one whose names start with
11791 the @code{__builtin_} prefix, and the other without. Both forms have the
11792 same type (including prototype), the same address (when their address is
11793 taken), and the same meaning as the C library functions even if you specify
11794 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
11795 functions are only optimized in certain cases; if they are not optimized in
11796 a particular case, a call to the library function is emitted.
11800 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
11801 @option{-std=c99} or @option{-std=c11}), the functions
11802 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
11803 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
11804 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
11805 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
11806 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
11807 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
11808 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
11809 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
11810 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
11811 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
11812 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
11813 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
11814 @code{signbitd64}, @code{signbitd128}, @code{significandf},
11815 @code{significandl}, @code{significand}, @code{sincosf},
11816 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
11817 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
11818 @code{strndup}, @code{strnlen}, @code{toascii}, @code{y0f}, @code{y0l},
11819 @code{y0}, @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
11821 may be handled as built-in functions.
11822 All these functions have corresponding versions
11823 prefixed with @code{__builtin_}, which may be used even in strict C90
11826 The ISO C99 functions
11827 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
11828 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
11829 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
11830 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
11831 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
11832 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
11833 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
11834 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
11835 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
11836 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
11837 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
11838 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
11839 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
11840 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
11841 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
11842 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
11843 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
11844 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
11845 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
11846 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
11847 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
11848 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
11849 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
11850 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
11851 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
11852 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
11853 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
11854 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
11855 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
11856 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
11857 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
11858 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
11859 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
11860 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
11861 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
11862 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
11863 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
11864 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
11865 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
11866 are handled as built-in functions
11867 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11869 There are also built-in versions of the ISO C99 functions
11870 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
11871 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
11872 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
11873 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
11874 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
11875 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
11876 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
11877 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
11878 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
11879 that are recognized in any mode since ISO C90 reserves these names for
11880 the purpose to which ISO C99 puts them. All these functions have
11881 corresponding versions prefixed with @code{__builtin_}.
11883 There are also built-in functions @code{__builtin_fabsf@var{n}},
11884 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
11885 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
11886 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
11887 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
11888 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
11890 There are also GNU extension functions @code{clog10}, @code{clog10f} and
11891 @code{clog10l} which names are reserved by ISO C99 for future use.
11892 All these functions have versions prefixed with @code{__builtin_}.
11894 The ISO C94 functions
11895 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
11896 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
11897 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
11899 are handled as built-in functions
11900 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11902 The ISO C90 functions
11903 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11904 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11905 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11906 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11907 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11908 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11909 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11910 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11911 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11912 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11913 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11914 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11915 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11916 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11917 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11918 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11919 are all recognized as built-in functions unless
11920 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11921 is specified for an individual function). All of these functions have
11922 corresponding versions prefixed with @code{__builtin_}.
11924 GCC provides built-in versions of the ISO C99 floating-point comparison
11925 macros that avoid raising exceptions for unordered operands. They have
11926 the same names as the standard macros ( @code{isgreater},
11927 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11928 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11929 prefixed. We intend for a library implementor to be able to simply
11930 @code{#define} each standard macro to its built-in equivalent.
11931 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11932 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11933 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
11934 built-in functions appear both with and without the @code{__builtin_} prefix.
11936 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11937 The @code{__builtin_alloca} function must be called at block scope.
11938 The function allocates an object @var{size} bytes large on the stack
11939 of the calling function. The object is aligned on the default stack
11940 alignment boundary for the target determined by the
11941 @code{__BIGGEST_ALIGNMENT__} macro. The @code{__builtin_alloca}
11942 function returns a pointer to the first byte of the allocated object.
11943 The lifetime of the allocated object ends just before the calling
11944 function returns to its caller. This is so even when
11945 @code{__builtin_alloca} is called within a nested block.
11947 For example, the following function allocates eight objects of @code{n}
11948 bytes each on the stack, storing a pointer to each in consecutive elements
11949 of the array @code{a}. It then passes the array to function @code{g}
11950 which can safely use the storage pointed to by each of the array elements.
11953 void f (unsigned n)
11956 for (int i = 0; i != 8; ++i)
11957 a [i] = __builtin_alloca (n);
11959 g (a, n); // @r{safe}
11963 Since the @code{__builtin_alloca} function doesn't validate its argument
11964 it is the responsibility of its caller to make sure the argument doesn't
11965 cause it to exceed the stack size limit.
11966 The @code{__builtin_alloca} function is provided to make it possible to
11967 allocate on the stack arrays of bytes with an upper bound that may be
11968 computed at run time. Since C99 Variable Length Arrays offer
11969 similar functionality under a portable, more convenient, and safer
11970 interface they are recommended instead, in both C99 and C++ programs
11971 where GCC provides them as an extension.
11972 @xref{Variable Length}, for details.
11976 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11977 The @code{__builtin_alloca_with_align} function must be called at block
11978 scope. The function allocates an object @var{size} bytes large on
11979 the stack of the calling function. The allocated object is aligned on
11980 the boundary specified by the argument @var{alignment} whose unit is given
11981 in bits (not bytes). The @var{size} argument must be positive and not
11982 exceed the stack size limit. The @var{alignment} argument must be a constant
11983 integer expression that evaluates to a power of 2 greater than or equal to
11984 @code{CHAR_BIT} and less than some unspecified maximum. Invocations
11985 with other values are rejected with an error indicating the valid bounds.
11986 The function returns a pointer to the first byte of the allocated object.
11987 The lifetime of the allocated object ends at the end of the block in which
11988 the function was called. The allocated storage is released no later than
11989 just before the calling function returns to its caller, but may be released
11990 at the end of the block in which the function was called.
11992 For example, in the following function the call to @code{g} is unsafe
11993 because when @code{overalign} is non-zero, the space allocated by
11994 @code{__builtin_alloca_with_align} may have been released at the end
11995 of the @code{if} statement in which it was called.
11998 void f (unsigned n, bool overalign)
12002 p = __builtin_alloca_with_align (n, 64 /* bits */);
12004 p = __builtin_alloc (n);
12006 g (p, n); // @r{unsafe}
12010 Since the @code{__builtin_alloca_with_align} function doesn't validate its
12011 @var{size} argument it is the responsibility of its caller to make sure
12012 the argument doesn't cause it to exceed the stack size limit.
12013 The @code{__builtin_alloca_with_align} function is provided to make
12014 it possible to allocate on the stack overaligned arrays of bytes with
12015 an upper bound that may be computed at run time. Since C99
12016 Variable Length Arrays offer the same functionality under
12017 a portable, more convenient, and safer interface they are recommended
12018 instead, in both C99 and C++ programs where GCC provides them as
12019 an extension. @xref{Variable Length}, for details.
12023 @deftypefn {Built-in Function} void *__builtin_alloca_with_align_and_max (size_t size, size_t alignment, size_t max_size)
12024 Similar to @code{__builtin_alloca_with_align} but takes an extra argument
12025 specifying an upper bound for @var{size} in case its value cannot be computed
12026 at compile time, for use by @option{-fstack-usage}, @option{-Wstack-usage}
12027 and @option{-Walloca-larger-than}. @var{max_size} must be a constant integer
12028 expression, it has no effect on code generation and no attempt is made to
12029 check its compatibility with @var{size}.
12033 @deftypefn {Built-in Function} bool __builtin_has_attribute (@var{type-or-expression}, @var{attribute})
12034 The @code{__builtin_has_attribute} function evaluates to an integer constant
12035 expression equal to @code{true} if the symbol or type referenced by
12036 the @var{type-or-expression} argument has been declared with
12037 the @var{attribute} referenced by the second argument. Neither argument
12038 is evaluated. The @var{type-or-expression} argument is subject to the same
12039 restrictions as the argument to @code{typeof} (@pxref{Typeof}). The
12040 @var{attribute} argument is an attribute name optionally followed by
12041 a comma-separated list of arguments enclosed in parentheses. Both forms
12042 of attribute names---with and without double leading and trailing
12043 underscores---are recognized. @xref{Attribute Syntax} for details.
12044 When no attribute arguments are specified for an attribute that expects
12045 one or more arguments the function returns @code{true} if
12046 @var{type-or-expression} has been declared with the attribute regardless
12047 of the attribute argument values. Arguments provided for an attribute
12048 that expects some are validated and matched up to the provided number.
12049 The function returns @code{true} if all provided arguments match. For
12050 example, the first call to the function below evaluates to @code{true}
12051 because @code{x} is declared with the @code{aligned} attribute but
12052 the second call evaluates to @code{false} because @code{x} is declared
12053 @code{aligned (8)} and not @code{aligned (4)}.
12056 __attribute__ ((aligned (8))) int x;
12057 _Static_assert (__builtin_has_attribute (x, aligned), "aligned");
12058 _Static_assert (!__builtin_has_attribute (x, aligned (4)), "aligned (4)");
12061 Due to a limitation the @code{__builtin_has_attribute} function returns
12062 @code{false} for the @code{mode} attribute even if the type or variable
12063 referenced by the @var{type-or-expression} argument was declared with one.
12064 The function is also not supported with labels, and in C with enumerators.
12066 Note that unlike the @code{__has_attribute} preprocessor operator which
12067 is suitable for use in @code{#if} preprocessing directives
12068 @code{__builtin_has_attribute} is an intrinsic function that is not
12069 recognized in such contexts.
12073 @deftypefn {Built-in Function} @var{type} __builtin_speculation_safe_value (@var{type} val, @var{type} failval)
12075 This built-in function can be used to help mitigate against unsafe
12076 speculative execution. @var{type} may be any integral type or any
12081 If the CPU is not speculatively executing the code, then @var{val}
12084 If the CPU is executing speculatively then either:
12087 The function may cause execution to pause until it is known that the
12088 code is no-longer being executed speculatively (in which case
12089 @var{val} can be returned, as above); or
12091 The function may use target-dependent speculation tracking state to cause
12092 @var{failval} to be returned when it is known that speculative
12093 execution has incorrectly predicted a conditional branch operation.
12097 The second argument, @var{failval}, is optional and defaults to zero
12100 GCC defines the preprocessor macro
12101 @code{__HAVE_BUILTIN_SPECULATION_SAFE_VALUE} for targets that have been
12102 updated to support this builtin.
12104 The built-in function can be used where a variable appears to be used in a
12105 safe way, but the CPU, due to speculative execution may temporarily ignore
12106 the bounds checks. Consider, for example, the following function:
12110 int f (unsigned untrusted_index)
12112 if (untrusted_index < 500)
12113 return array[untrusted_index];
12118 If the function is called repeatedly with @code{untrusted_index} less
12119 than the limit of 500, then a branch predictor will learn that the
12120 block of code that returns a value stored in @code{array} will be
12121 executed. If the function is subsequently called with an
12122 out-of-range value it will still try to execute that block of code
12123 first until the CPU determines that the prediction was incorrect
12124 (the CPU will unwind any incorrect operations at that point).
12125 However, depending on how the result of the function is used, it might be
12126 possible to leave traces in the cache that can reveal what was stored
12127 at the out-of-bounds location. The built-in function can be used to
12128 provide some protection against leaking data in this way by changing
12133 int f (unsigned untrusted_index)
12135 if (untrusted_index < 500)
12136 return array[__builtin_speculation_safe_value (untrusted_index)];
12141 The built-in function will either cause execution to stall until the
12142 conditional branch has been fully resolved, or it may permit
12143 speculative execution to continue, but using 0 instead of
12144 @code{untrusted_value} if that exceeds the limit.
12146 If accessing any memory location is potentially unsafe when speculative
12147 execution is incorrect, then the code can be rewritten as
12151 int f (unsigned untrusted_index)
12153 if (untrusted_index < 500)
12154 return *__builtin_speculation_safe_value (&array[untrusted_index], NULL);
12159 which will cause a @code{NULL} pointer to be used for the unsafe case.
12163 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
12165 You can use the built-in function @code{__builtin_types_compatible_p} to
12166 determine whether two types are the same.
12168 This built-in function returns 1 if the unqualified versions of the
12169 types @var{type1} and @var{type2} (which are types, not expressions) are
12170 compatible, 0 otherwise. The result of this built-in function can be
12171 used in integer constant expressions.
12173 This built-in function ignores top level qualifiers (e.g., @code{const},
12174 @code{volatile}). For example, @code{int} is equivalent to @code{const
12177 The type @code{int[]} and @code{int[5]} are compatible. On the other
12178 hand, @code{int} and @code{char *} are not compatible, even if the size
12179 of their types, on the particular architecture are the same. Also, the
12180 amount of pointer indirection is taken into account when determining
12181 similarity. Consequently, @code{short *} is not similar to
12182 @code{short **}. Furthermore, two types that are typedefed are
12183 considered compatible if their underlying types are compatible.
12185 An @code{enum} type is not considered to be compatible with another
12186 @code{enum} type even if both are compatible with the same integer
12187 type; this is what the C standard specifies.
12188 For example, @code{enum @{foo, bar@}} is not similar to
12189 @code{enum @{hot, dog@}}.
12191 You typically use this function in code whose execution varies
12192 depending on the arguments' types. For example:
12197 typeof (x) tmp = (x); \
12198 if (__builtin_types_compatible_p (typeof (x), long double)) \
12199 tmp = foo_long_double (tmp); \
12200 else if (__builtin_types_compatible_p (typeof (x), double)) \
12201 tmp = foo_double (tmp); \
12202 else if (__builtin_types_compatible_p (typeof (x), float)) \
12203 tmp = foo_float (tmp); \
12210 @emph{Note:} This construct is only available for C@.
12214 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
12216 The @var{call_exp} expression must be a function call, and the
12217 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
12218 is passed to the function call in the target's static chain location.
12219 The result of builtin is the result of the function call.
12221 @emph{Note:} This builtin is only available for C@.
12222 This builtin can be used to call Go closures from C.
12226 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
12228 You can use the built-in function @code{__builtin_choose_expr} to
12229 evaluate code depending on the value of a constant expression. This
12230 built-in function returns @var{exp1} if @var{const_exp}, which is an
12231 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
12233 This built-in function is analogous to the @samp{? :} operator in C,
12234 except that the expression returned has its type unaltered by promotion
12235 rules. Also, the built-in function does not evaluate the expression
12236 that is not chosen. For example, if @var{const_exp} evaluates to @code{true},
12237 @var{exp2} is not evaluated even if it has side effects.
12239 This built-in function can return an lvalue if the chosen argument is an
12242 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
12243 type. Similarly, if @var{exp2} is returned, its return type is the same
12250 __builtin_choose_expr ( \
12251 __builtin_types_compatible_p (typeof (x), double), \
12253 __builtin_choose_expr ( \
12254 __builtin_types_compatible_p (typeof (x), float), \
12256 /* @r{The void expression results in a compile-time error} \
12257 @r{when assigning the result to something.} */ \
12261 @emph{Note:} This construct is only available for C@. Furthermore, the
12262 unused expression (@var{exp1} or @var{exp2} depending on the value of
12263 @var{const_exp}) may still generate syntax errors. This may change in
12268 @deftypefn {Built-in Function} @var{type} __builtin_tgmath (@var{functions}, @var{arguments})
12270 The built-in function @code{__builtin_tgmath}, available only for C
12271 and Objective-C, calls a function determined according to the rules of
12272 @code{<tgmath.h>} macros. It is intended to be used in
12273 implementations of that header, so that expansions of macros from that
12274 header only expand each of their arguments once, to avoid problems
12275 when calls to such macros are nested inside the arguments of other
12276 calls to such macros; in addition, it results in better diagnostics
12277 for invalid calls to @code{<tgmath.h>} macros than implementations
12278 using other GNU C language features. For example, the @code{pow}
12279 type-generic macro might be defined as:
12282 #define pow(a, b) __builtin_tgmath (powf, pow, powl, \
12283 cpowf, cpow, cpowl, a, b)
12286 The arguments to @code{__builtin_tgmath} are at least two pointers to
12287 functions, followed by the arguments to the type-generic macro (which
12288 will be passed as arguments to the selected function). All the
12289 pointers to functions must be pointers to prototyped functions, none
12290 of which may have variable arguments, and all of which must have the
12291 same number of parameters; the number of parameters of the first
12292 function determines how many arguments to @code{__builtin_tgmath} are
12293 interpreted as function pointers, and how many as the arguments to the
12296 The types of the specified functions must all be different, but
12297 related to each other in the same way as a set of functions that may
12298 be selected between by a macro in @code{<tgmath.h>}. This means that
12299 the functions are parameterized by a floating-point type @var{t},
12300 different for each such function. The function return types may all
12301 be the same type, or they may be @var{t} for each function, or they
12302 may be the real type corresponding to @var{t} for each function (if
12303 some of the types @var{t} are complex). Likewise, for each parameter
12304 position, the type of the parameter in that position may always be the
12305 same type, or may be @var{t} for each function (this case must apply
12306 for at least one parameter position), or may be the real type
12307 corresponding to @var{t} for each function.
12309 The standard rules for @code{<tgmath.h>} macros are used to find a
12310 common type @var{u} from the types of the arguments for parameters
12311 whose types vary between the functions; complex integer types (a GNU
12312 extension) are treated like @code{_Complex double} for this purpose
12313 (or @code{_Complex _Float64} if all the function return types are the
12314 same @code{_Float@var{n}} or @code{_Float@var{n}x} type).
12315 If the function return types vary, or are all the same integer type,
12316 the function called is the one for which @var{t} is @var{u}, and it is
12317 an error if there is no such function. If the function return types
12318 are all the same floating-point type, the type-generic macro is taken
12319 to be one of those from TS 18661 that rounds the result to a narrower
12320 type; if there is a function for which @var{t} is @var{u}, it is
12321 called, and otherwise the first function, if any, for which @var{t}
12322 has at least the range and precision of @var{u} is called, and it is
12323 an error if there is no such function.
12327 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
12329 The built-in function @code{__builtin_complex} is provided for use in
12330 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
12331 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
12332 real binary floating-point type, and the result has the corresponding
12333 complex type with real and imaginary parts @var{real} and @var{imag}.
12334 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
12335 infinities, NaNs and negative zeros are involved.
12339 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
12340 You can use the built-in function @code{__builtin_constant_p} to
12341 determine if a value is known to be constant at compile time and hence
12342 that GCC can perform constant-folding on expressions involving that
12343 value. The argument of the function is the value to test. The function
12344 returns the integer 1 if the argument is known to be a compile-time
12345 constant and 0 if it is not known to be a compile-time constant. A
12346 return of 0 does not indicate that the value is @emph{not} a constant,
12347 but merely that GCC cannot prove it is a constant with the specified
12348 value of the @option{-O} option.
12350 You typically use this function in an embedded application where
12351 memory is a critical resource. If you have some complex calculation,
12352 you may want it to be folded if it involves constants, but need to call
12353 a function if it does not. For example:
12356 #define Scale_Value(X) \
12357 (__builtin_constant_p (X) \
12358 ? ((X) * SCALE + OFFSET) : Scale (X))
12361 You may use this built-in function in either a macro or an inline
12362 function. However, if you use it in an inlined function and pass an
12363 argument of the function as the argument to the built-in, GCC
12364 never returns 1 when you call the inline function with a string constant
12365 or compound literal (@pxref{Compound Literals}) and does not return 1
12366 when you pass a constant numeric value to the inline function unless you
12367 specify the @option{-O} option.
12369 You may also use @code{__builtin_constant_p} in initializers for static
12370 data. For instance, you can write
12373 static const int table[] = @{
12374 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
12380 This is an acceptable initializer even if @var{EXPRESSION} is not a
12381 constant expression, including the case where
12382 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
12383 folded to a constant but @var{EXPRESSION} contains operands that are
12384 not otherwise permitted in a static initializer (for example,
12385 @code{0 && foo ()}). GCC must be more conservative about evaluating the
12386 built-in in this case, because it has no opportunity to perform
12390 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
12391 @opindex fprofile-arcs
12392 You may use @code{__builtin_expect} to provide the compiler with
12393 branch prediction information. In general, you should prefer to
12394 use actual profile feedback for this (@option{-fprofile-arcs}), as
12395 programmers are notoriously bad at predicting how their programs
12396 actually perform. However, there are applications in which this
12397 data is hard to collect.
12399 The return value is the value of @var{exp}, which should be an integral
12400 expression. The semantics of the built-in are that it is expected that
12401 @var{exp} == @var{c}. For example:
12404 if (__builtin_expect (x, 0))
12409 indicates that we do not expect to call @code{foo}, since
12410 we expect @code{x} to be zero. Since you are limited to integral
12411 expressions for @var{exp}, you should use constructions such as
12414 if (__builtin_expect (ptr != NULL, 1))
12419 when testing pointer or floating-point values.
12421 For the purposes of branch prediction optimizations, the probability that
12422 a @code{__builtin_expect} expression is @code{true} is controlled by GCC's
12423 @code{builtin-expect-probability} parameter, which defaults to 90%.
12424 You can also use @code{__builtin_expect_with_probability} to explicitly
12425 assign a probability value to individual expressions.
12428 @deftypefn {Built-in Function} long __builtin_expect_with_probability
12429 (long @var{exp}, long @var{c}, double @var{probability})
12431 This function has the same semantics as @code{__builtin_expect},
12432 but the caller provides the expected probability that @var{exp} == @var{c}.
12433 The last argument, @var{probability}, is a floating-point value in the
12434 range 0.0 to 1.0, inclusive. The @var{probability} argument must be
12435 constant floating-point expression.
12438 @deftypefn {Built-in Function} void __builtin_trap (void)
12439 This function causes the program to exit abnormally. GCC implements
12440 this function by using a target-dependent mechanism (such as
12441 intentionally executing an illegal instruction) or by calling
12442 @code{abort}. The mechanism used may vary from release to release so
12443 you should not rely on any particular implementation.
12446 @deftypefn {Built-in Function} void __builtin_unreachable (void)
12447 If control flow reaches the point of the @code{__builtin_unreachable},
12448 the program is undefined. It is useful in situations where the
12449 compiler cannot deduce the unreachability of the code.
12451 One such case is immediately following an @code{asm} statement that
12452 either never terminates, or one that transfers control elsewhere
12453 and never returns. In this example, without the
12454 @code{__builtin_unreachable}, GCC issues a warning that control
12455 reaches the end of a non-void function. It also generates code
12456 to return after the @code{asm}.
12459 int f (int c, int v)
12467 asm("jmp error_handler");
12468 __builtin_unreachable ();
12474 Because the @code{asm} statement unconditionally transfers control out
12475 of the function, control never reaches the end of the function
12476 body. The @code{__builtin_unreachable} is in fact unreachable and
12477 communicates this fact to the compiler.
12479 Another use for @code{__builtin_unreachable} is following a call a
12480 function that never returns but that is not declared
12481 @code{__attribute__((noreturn))}, as in this example:
12484 void function_that_never_returns (void);
12494 function_that_never_returns ();
12495 __builtin_unreachable ();
12502 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
12503 This function returns its first argument, and allows the compiler
12504 to assume that the returned pointer is at least @var{align} bytes
12505 aligned. This built-in can have either two or three arguments,
12506 if it has three, the third argument should have integer type, and
12507 if it is nonzero means misalignment offset. For example:
12510 void *x = __builtin_assume_aligned (arg, 16);
12514 means that the compiler can assume @code{x}, set to @code{arg}, is at least
12515 16-byte aligned, while:
12518 void *x = __builtin_assume_aligned (arg, 32, 8);
12522 means that the compiler can assume for @code{x}, set to @code{arg}, that
12523 @code{(char *) x - 8} is 32-byte aligned.
12526 @deftypefn {Built-in Function} int __builtin_LINE ()
12527 This function is the equivalent of the preprocessor @code{__LINE__}
12528 macro and returns a constant integer expression that evaluates to
12529 the line number of the invocation of the built-in. When used as a C++
12530 default argument for a function @var{F}, it returns the line number
12531 of the call to @var{F}.
12534 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
12535 This function is the equivalent of the @code{__FUNCTION__} symbol
12536 and returns an address constant pointing to the name of the function
12537 from which the built-in was invoked, or the empty string if
12538 the invocation is not at function scope. When used as a C++ default
12539 argument for a function @var{F}, it returns the name of @var{F}'s
12540 caller or the empty string if the call was not made at function
12544 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
12545 This function is the equivalent of the preprocessor @code{__FILE__}
12546 macro and returns an address constant pointing to the file name
12547 containing the invocation of the built-in, or the empty string if
12548 the invocation is not at function scope. When used as a C++ default
12549 argument for a function @var{F}, it returns the file name of the call
12550 to @var{F} or the empty string if the call was not made at function
12553 For example, in the following, each call to function @code{foo} will
12554 print a line similar to @code{"file.c:123: foo: message"} with the name
12555 of the file and the line number of the @code{printf} call, the name of
12556 the function @code{foo}, followed by the word @code{message}.
12560 function (const char *func = __builtin_FUNCTION ())
12567 printf ("%s:%i: %s: message\n", file (), line (), function ());
12573 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
12574 This function is used to flush the processor's instruction cache for
12575 the region of memory between @var{begin} inclusive and @var{end}
12576 exclusive. Some targets require that the instruction cache be
12577 flushed, after modifying memory containing code, in order to obtain
12578 deterministic behavior.
12580 If the target does not require instruction cache flushes,
12581 @code{__builtin___clear_cache} has no effect. Otherwise either
12582 instructions are emitted in-line to clear the instruction cache or a
12583 call to the @code{__clear_cache} function in libgcc is made.
12586 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
12587 This function is used to minimize cache-miss latency by moving data into
12588 a cache before it is accessed.
12589 You can insert calls to @code{__builtin_prefetch} into code for which
12590 you know addresses of data in memory that is likely to be accessed soon.
12591 If the target supports them, data prefetch instructions are generated.
12592 If the prefetch is done early enough before the access then the data will
12593 be in the cache by the time it is accessed.
12595 The value of @var{addr} is the address of the memory to prefetch.
12596 There are two optional arguments, @var{rw} and @var{locality}.
12597 The value of @var{rw} is a compile-time constant one or zero; one
12598 means that the prefetch is preparing for a write to the memory address
12599 and zero, the default, means that the prefetch is preparing for a read.
12600 The value @var{locality} must be a compile-time constant integer between
12601 zero and three. A value of zero means that the data has no temporal
12602 locality, so it need not be left in the cache after the access. A value
12603 of three means that the data has a high degree of temporal locality and
12604 should be left in all levels of cache possible. Values of one and two
12605 mean, respectively, a low or moderate degree of temporal locality. The
12609 for (i = 0; i < n; i++)
12611 a[i] = a[i] + b[i];
12612 __builtin_prefetch (&a[i+j], 1, 1);
12613 __builtin_prefetch (&b[i+j], 0, 1);
12618 Data prefetch does not generate faults if @var{addr} is invalid, but
12619 the address expression itself must be valid. For example, a prefetch
12620 of @code{p->next} does not fault if @code{p->next} is not a valid
12621 address, but evaluation faults if @code{p} is not a valid address.
12623 If the target does not support data prefetch, the address expression
12624 is evaluated if it includes side effects but no other code is generated
12625 and GCC does not issue a warning.
12628 @deftypefn {Built-in Function}{size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
12629 Returns the size of an object pointed to by @var{ptr}. @xref{Object Size Checking} for a detailed description of the function.
12632 @deftypefn {Built-in Function} double __builtin_huge_val (void)
12633 Returns a positive infinity, if supported by the floating-point format,
12634 else @code{DBL_MAX}. This function is suitable for implementing the
12635 ISO C macro @code{HUGE_VAL}.
12638 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
12639 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
12642 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
12643 Similar to @code{__builtin_huge_val}, except the return
12644 type is @code{long double}.
12647 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
12648 Similar to @code{__builtin_huge_val}, except the return type is
12649 @code{_Float@var{n}}.
12652 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
12653 Similar to @code{__builtin_huge_val}, except the return type is
12654 @code{_Float@var{n}x}.
12657 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
12658 This built-in implements the C99 fpclassify functionality. The first
12659 five int arguments should be the target library's notion of the
12660 possible FP classes and are used for return values. They must be
12661 constant values and they must appear in this order: @code{FP_NAN},
12662 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
12663 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
12664 to classify. GCC treats the last argument as type-generic, which
12665 means it does not do default promotion from float to double.
12668 @deftypefn {Built-in Function} double __builtin_inf (void)
12669 Similar to @code{__builtin_huge_val}, except a warning is generated
12670 if the target floating-point format does not support infinities.
12673 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
12674 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
12677 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
12678 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
12681 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
12682 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
12685 @deftypefn {Built-in Function} float __builtin_inff (void)
12686 Similar to @code{__builtin_inf}, except the return type is @code{float}.
12687 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
12690 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
12691 Similar to @code{__builtin_inf}, except the return
12692 type is @code{long double}.
12695 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
12696 Similar to @code{__builtin_inf}, except the return
12697 type is @code{_Float@var{n}}.
12700 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
12701 Similar to @code{__builtin_inf}, except the return
12702 type is @code{_Float@var{n}x}.
12705 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
12706 Similar to @code{isinf}, except the return value is -1 for
12707 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
12708 Note while the parameter list is an
12709 ellipsis, this function only accepts exactly one floating-point
12710 argument. GCC treats this parameter as type-generic, which means it
12711 does not do default promotion from float to double.
12714 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
12715 This is an implementation of the ISO C99 function @code{nan}.
12717 Since ISO C99 defines this function in terms of @code{strtod}, which we
12718 do not implement, a description of the parsing is in order. The string
12719 is parsed as by @code{strtol}; that is, the base is recognized by
12720 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
12721 in the significand such that the least significant bit of the number
12722 is at the least significant bit of the significand. The number is
12723 truncated to fit the significand field provided. The significand is
12724 forced to be a quiet NaN@.
12726 This function, if given a string literal all of which would have been
12727 consumed by @code{strtol}, is evaluated early enough that it is considered a
12728 compile-time constant.
12731 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
12732 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
12735 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
12736 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
12739 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
12740 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
12743 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
12744 Similar to @code{__builtin_nan}, except the return type is @code{float}.
12747 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
12748 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
12751 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
12752 Similar to @code{__builtin_nan}, except the return type is
12753 @code{_Float@var{n}}.
12756 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
12757 Similar to @code{__builtin_nan}, except the return type is
12758 @code{_Float@var{n}x}.
12761 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
12762 Similar to @code{__builtin_nan}, except the significand is forced
12763 to be a signaling NaN@. The @code{nans} function is proposed by
12764 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
12767 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
12768 Similar to @code{__builtin_nans}, except the return type is @code{float}.
12771 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
12772 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
12775 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
12776 Similar to @code{__builtin_nans}, except the return type is
12777 @code{_Float@var{n}}.
12780 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
12781 Similar to @code{__builtin_nans}, except the return type is
12782 @code{_Float@var{n}x}.
12785 @deftypefn {Built-in Function} int __builtin_ffs (int x)
12786 Returns one plus the index of the least significant 1-bit of @var{x}, or
12787 if @var{x} is zero, returns zero.
12790 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
12791 Returns the number of leading 0-bits in @var{x}, starting at the most
12792 significant bit position. If @var{x} is 0, the result is undefined.
12795 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
12796 Returns the number of trailing 0-bits in @var{x}, starting at the least
12797 significant bit position. If @var{x} is 0, the result is undefined.
12800 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
12801 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
12802 number of bits following the most significant bit that are identical
12803 to it. There are no special cases for 0 or other values.
12806 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
12807 Returns the number of 1-bits in @var{x}.
12810 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
12811 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
12815 @deftypefn {Built-in Function} int __builtin_ffsl (long)
12816 Similar to @code{__builtin_ffs}, except the argument type is
12820 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
12821 Similar to @code{__builtin_clz}, except the argument type is
12822 @code{unsigned long}.
12825 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
12826 Similar to @code{__builtin_ctz}, except the argument type is
12827 @code{unsigned long}.
12830 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
12831 Similar to @code{__builtin_clrsb}, except the argument type is
12835 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
12836 Similar to @code{__builtin_popcount}, except the argument type is
12837 @code{unsigned long}.
12840 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
12841 Similar to @code{__builtin_parity}, except the argument type is
12842 @code{unsigned long}.
12845 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
12846 Similar to @code{__builtin_ffs}, except the argument type is
12850 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
12851 Similar to @code{__builtin_clz}, except the argument type is
12852 @code{unsigned long long}.
12855 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
12856 Similar to @code{__builtin_ctz}, except the argument type is
12857 @code{unsigned long long}.
12860 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
12861 Similar to @code{__builtin_clrsb}, except the argument type is
12865 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
12866 Similar to @code{__builtin_popcount}, except the argument type is
12867 @code{unsigned long long}.
12870 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
12871 Similar to @code{__builtin_parity}, except the argument type is
12872 @code{unsigned long long}.
12875 @deftypefn {Built-in Function} double __builtin_powi (double, int)
12876 Returns the first argument raised to the power of the second. Unlike the
12877 @code{pow} function no guarantees about precision and rounding are made.
12880 @deftypefn {Built-in Function} float __builtin_powif (float, int)
12881 Similar to @code{__builtin_powi}, except the argument and return types
12885 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
12886 Similar to @code{__builtin_powi}, except the argument and return types
12887 are @code{long double}.
12890 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
12891 Returns @var{x} with the order of the bytes reversed; for example,
12892 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
12896 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
12897 Similar to @code{__builtin_bswap16}, except the argument and return types
12901 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
12902 Similar to @code{__builtin_bswap32}, except the argument and return types
12906 @deftypefn {Built-in Function} Pmode __builtin_extend_pointer (void * x)
12907 On targets where the user visible pointer size is smaller than the size
12908 of an actual hardware address this function returns the extended user
12909 pointer. Targets where this is true included ILP32 mode on x86_64 or
12910 Aarch64. This function is mainly useful when writing inline assembly
12914 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_id (int x)
12915 Returns the openacc gang, worker or vector id depending on whether @var{x} is
12919 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_size (int x)
12920 Returns the openacc gang, worker or vector size depending on whether @var{x} is
12924 @node Target Builtins
12925 @section Built-in Functions Specific to Particular Target Machines
12927 On some target machines, GCC supports many built-in functions specific
12928 to those machines. Generally these generate calls to specific machine
12929 instructions, but allow the compiler to schedule those calls.
12932 * AArch64 Built-in Functions::
12933 * Alpha Built-in Functions::
12934 * Altera Nios II Built-in Functions::
12935 * ARC Built-in Functions::
12936 * ARC SIMD Built-in Functions::
12937 * ARM iWMMXt Built-in Functions::
12938 * ARM C Language Extensions (ACLE)::
12939 * ARM Floating Point Status and Control Intrinsics::
12940 * ARM ARMv8-M Security Extensions::
12941 * AVR Built-in Functions::
12942 * Blackfin Built-in Functions::
12943 * FR-V Built-in Functions::
12944 * MIPS DSP Built-in Functions::
12945 * MIPS Paired-Single Support::
12946 * MIPS Loongson Built-in Functions::
12947 * MIPS SIMD Architecture (MSA) Support::
12948 * Other MIPS Built-in Functions::
12949 * MSP430 Built-in Functions::
12950 * NDS32 Built-in Functions::
12951 * picoChip Built-in Functions::
12952 * Basic PowerPC Built-in Functions::
12953 * PowerPC AltiVec/VSX Built-in Functions::
12954 * PowerPC Hardware Transactional Memory Built-in Functions::
12955 * PowerPC Atomic Memory Operation Functions::
12956 * RX Built-in Functions::
12957 * S/390 System z Built-in Functions::
12958 * SH Built-in Functions::
12959 * SPARC VIS Built-in Functions::
12960 * SPU Built-in Functions::
12961 * TI C6X Built-in Functions::
12962 * TILE-Gx Built-in Functions::
12963 * TILEPro Built-in Functions::
12964 * x86 Built-in Functions::
12965 * x86 transactional memory intrinsics::
12966 * x86 control-flow protection intrinsics::
12969 @node AArch64 Built-in Functions
12970 @subsection AArch64 Built-in Functions
12972 These built-in functions are available for the AArch64 family of
12975 unsigned int __builtin_aarch64_get_fpcr ()
12976 void __builtin_aarch64_set_fpcr (unsigned int)
12977 unsigned int __builtin_aarch64_get_fpsr ()
12978 void __builtin_aarch64_set_fpsr (unsigned int)
12981 @node Alpha Built-in Functions
12982 @subsection Alpha Built-in Functions
12984 These built-in functions are available for the Alpha family of
12985 processors, depending on the command-line switches used.
12987 The following built-in functions are always available. They
12988 all generate the machine instruction that is part of the name.
12991 long __builtin_alpha_implver (void)
12992 long __builtin_alpha_rpcc (void)
12993 long __builtin_alpha_amask (long)
12994 long __builtin_alpha_cmpbge (long, long)
12995 long __builtin_alpha_extbl (long, long)
12996 long __builtin_alpha_extwl (long, long)
12997 long __builtin_alpha_extll (long, long)
12998 long __builtin_alpha_extql (long, long)
12999 long __builtin_alpha_extwh (long, long)
13000 long __builtin_alpha_extlh (long, long)
13001 long __builtin_alpha_extqh (long, long)
13002 long __builtin_alpha_insbl (long, long)
13003 long __builtin_alpha_inswl (long, long)
13004 long __builtin_alpha_insll (long, long)
13005 long __builtin_alpha_insql (long, long)
13006 long __builtin_alpha_inswh (long, long)
13007 long __builtin_alpha_inslh (long, long)
13008 long __builtin_alpha_insqh (long, long)
13009 long __builtin_alpha_mskbl (long, long)
13010 long __builtin_alpha_mskwl (long, long)
13011 long __builtin_alpha_mskll (long, long)
13012 long __builtin_alpha_mskql (long, long)
13013 long __builtin_alpha_mskwh (long, long)
13014 long __builtin_alpha_msklh (long, long)
13015 long __builtin_alpha_mskqh (long, long)
13016 long __builtin_alpha_umulh (long, long)
13017 long __builtin_alpha_zap (long, long)
13018 long __builtin_alpha_zapnot (long, long)
13021 The following built-in functions are always with @option{-mmax}
13022 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
13023 later. They all generate the machine instruction that is part
13027 long __builtin_alpha_pklb (long)
13028 long __builtin_alpha_pkwb (long)
13029 long __builtin_alpha_unpkbl (long)
13030 long __builtin_alpha_unpkbw (long)
13031 long __builtin_alpha_minub8 (long, long)
13032 long __builtin_alpha_minsb8 (long, long)
13033 long __builtin_alpha_minuw4 (long, long)
13034 long __builtin_alpha_minsw4 (long, long)
13035 long __builtin_alpha_maxub8 (long, long)
13036 long __builtin_alpha_maxsb8 (long, long)
13037 long __builtin_alpha_maxuw4 (long, long)
13038 long __builtin_alpha_maxsw4 (long, long)
13039 long __builtin_alpha_perr (long, long)
13042 The following built-in functions are always with @option{-mcix}
13043 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
13044 later. They all generate the machine instruction that is part
13048 long __builtin_alpha_cttz (long)
13049 long __builtin_alpha_ctlz (long)
13050 long __builtin_alpha_ctpop (long)
13053 The following built-in functions are available on systems that use the OSF/1
13054 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
13055 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
13056 @code{rdval} and @code{wrval}.
13059 void *__builtin_thread_pointer (void)
13060 void __builtin_set_thread_pointer (void *)
13063 @node Altera Nios II Built-in Functions
13064 @subsection Altera Nios II Built-in Functions
13066 These built-in functions are available for the Altera Nios II
13067 family of processors.
13069 The following built-in functions are always available. They
13070 all generate the machine instruction that is part of the name.
13073 int __builtin_ldbio (volatile const void *)
13074 int __builtin_ldbuio (volatile const void *)
13075 int __builtin_ldhio (volatile const void *)
13076 int __builtin_ldhuio (volatile const void *)
13077 int __builtin_ldwio (volatile const void *)
13078 void __builtin_stbio (volatile void *, int)
13079 void __builtin_sthio (volatile void *, int)
13080 void __builtin_stwio (volatile void *, int)
13081 void __builtin_sync (void)
13082 int __builtin_rdctl (int)
13083 int __builtin_rdprs (int, int)
13084 void __builtin_wrctl (int, int)
13085 void __builtin_flushd (volatile void *)
13086 void __builtin_flushda (volatile void *)
13087 int __builtin_wrpie (int);
13088 void __builtin_eni (int);
13089 int __builtin_ldex (volatile const void *)
13090 int __builtin_stex (volatile void *, int)
13091 int __builtin_ldsex (volatile const void *)
13092 int __builtin_stsex (volatile void *, int)
13095 The following built-in functions are always available. They
13096 all generate a Nios II Custom Instruction. The name of the
13097 function represents the types that the function takes and
13098 returns. The letter before the @code{n} is the return type
13099 or void if absent. The @code{n} represents the first parameter
13100 to all the custom instructions, the custom instruction number.
13101 The two letters after the @code{n} represent the up to two
13102 parameters to the function.
13104 The letters represent the following data types:
13107 @code{void} for return type and no parameter for parameter types.
13110 @code{int} for return type and parameter type
13113 @code{float} for return type and parameter type
13116 @code{void *} for return type and parameter type
13120 And the function names are:
13122 void __builtin_custom_n (void)
13123 void __builtin_custom_ni (int)
13124 void __builtin_custom_nf (float)
13125 void __builtin_custom_np (void *)
13126 void __builtin_custom_nii (int, int)
13127 void __builtin_custom_nif (int, float)
13128 void __builtin_custom_nip (int, void *)
13129 void __builtin_custom_nfi (float, int)
13130 void __builtin_custom_nff (float, float)
13131 void __builtin_custom_nfp (float, void *)
13132 void __builtin_custom_npi (void *, int)
13133 void __builtin_custom_npf (void *, float)
13134 void __builtin_custom_npp (void *, void *)
13135 int __builtin_custom_in (void)
13136 int __builtin_custom_ini (int)
13137 int __builtin_custom_inf (float)
13138 int __builtin_custom_inp (void *)
13139 int __builtin_custom_inii (int, int)
13140 int __builtin_custom_inif (int, float)
13141 int __builtin_custom_inip (int, void *)
13142 int __builtin_custom_infi (float, int)
13143 int __builtin_custom_inff (float, float)
13144 int __builtin_custom_infp (float, void *)
13145 int __builtin_custom_inpi (void *, int)
13146 int __builtin_custom_inpf (void *, float)
13147 int __builtin_custom_inpp (void *, void *)
13148 float __builtin_custom_fn (void)
13149 float __builtin_custom_fni (int)
13150 float __builtin_custom_fnf (float)
13151 float __builtin_custom_fnp (void *)
13152 float __builtin_custom_fnii (int, int)
13153 float __builtin_custom_fnif (int, float)
13154 float __builtin_custom_fnip (int, void *)
13155 float __builtin_custom_fnfi (float, int)
13156 float __builtin_custom_fnff (float, float)
13157 float __builtin_custom_fnfp (float, void *)
13158 float __builtin_custom_fnpi (void *, int)
13159 float __builtin_custom_fnpf (void *, float)
13160 float __builtin_custom_fnpp (void *, void *)
13161 void * __builtin_custom_pn (void)
13162 void * __builtin_custom_pni (int)
13163 void * __builtin_custom_pnf (float)
13164 void * __builtin_custom_pnp (void *)
13165 void * __builtin_custom_pnii (int, int)
13166 void * __builtin_custom_pnif (int, float)
13167 void * __builtin_custom_pnip (int, void *)
13168 void * __builtin_custom_pnfi (float, int)
13169 void * __builtin_custom_pnff (float, float)
13170 void * __builtin_custom_pnfp (float, void *)
13171 void * __builtin_custom_pnpi (void *, int)
13172 void * __builtin_custom_pnpf (void *, float)
13173 void * __builtin_custom_pnpp (void *, void *)
13176 @node ARC Built-in Functions
13177 @subsection ARC Built-in Functions
13179 The following built-in functions are provided for ARC targets. The
13180 built-ins generate the corresponding assembly instructions. In the
13181 examples given below, the generated code often requires an operand or
13182 result to be in a register. Where necessary further code will be
13183 generated to ensure this is true, but for brevity this is not
13184 described in each case.
13186 @emph{Note:} Using a built-in to generate an instruction not supported
13187 by a target may cause problems. At present the compiler is not
13188 guaranteed to detect such misuse, and as a result an internal compiler
13189 error may be generated.
13191 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
13192 Return 1 if @var{val} is known to have the byte alignment given
13193 by @var{alignval}, otherwise return 0.
13194 Note that this is different from
13196 __alignof__(*(char *)@var{val}) >= alignval
13198 because __alignof__ sees only the type of the dereference, whereas
13199 __builtin_arc_align uses alignment information from the pointer
13200 as well as from the pointed-to type.
13201 The information available will depend on optimization level.
13204 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
13211 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
13212 The operand is the number of a register to be read. Generates:
13214 mov @var{dest}, r@var{regno}
13216 where the value in @var{dest} will be the result returned from the
13220 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
13221 The first operand is the number of a register to be written, the
13222 second operand is a compile time constant to write into that
13223 register. Generates:
13225 mov r@var{regno}, @var{val}
13229 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
13230 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
13233 divaw @var{dest}, @var{a}, @var{b}
13235 where the value in @var{dest} will be the result returned from the
13239 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
13246 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
13247 The operand, @var{auxv}, is the address of an auxiliary register and
13248 must be a compile time constant. Generates:
13250 lr @var{dest}, [@var{auxr}]
13252 Where the value in @var{dest} will be the result returned from the
13256 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
13257 Only available with @option{-mmul64}. Generates:
13259 mul64 @var{a}, @var{b}
13263 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
13264 Only available with @option{-mmul64}. Generates:
13266 mulu64 @var{a}, @var{b}
13270 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
13277 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
13278 Only valid if the @samp{norm} instruction is available through the
13279 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
13282 norm @var{dest}, @var{src}
13284 Where the value in @var{dest} will be the result returned from the
13288 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
13289 Only valid if the @samp{normw} instruction is available through the
13290 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
13293 normw @var{dest}, @var{src}
13295 Where the value in @var{dest} will be the result returned from the
13299 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
13306 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
13313 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
13314 The first argument, @var{auxv}, is the address of an auxiliary
13315 register, the second argument, @var{val}, is a compile time constant
13316 to be written to the register. Generates:
13318 sr @var{auxr}, [@var{val}]
13322 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
13323 Only valid with @option{-mswap}. Generates:
13325 swap @var{dest}, @var{src}
13327 Where the value in @var{dest} will be the result returned from the
13331 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
13338 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
13339 Only available with @option{-mcpu=ARC700}. Generates:
13345 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
13346 Only available with @option{-mcpu=ARC700}. Generates:
13352 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
13353 Only available with @option{-mcpu=ARC700}. Generates:
13359 The instructions generated by the following builtins are not
13360 considered as candidates for scheduling. They are not moved around by
13361 the compiler during scheduling, and thus can be expected to appear
13362 where they are put in the C code:
13364 __builtin_arc_brk()
13365 __builtin_arc_core_read()
13366 __builtin_arc_core_write()
13367 __builtin_arc_flag()
13369 __builtin_arc_sleep()
13371 __builtin_arc_swi()
13374 @node ARC SIMD Built-in Functions
13375 @subsection ARC SIMD Built-in Functions
13377 SIMD builtins provided by the compiler can be used to generate the
13378 vector instructions. This section describes the available builtins
13379 and their usage in programs. With the @option{-msimd} option, the
13380 compiler provides 128-bit vector types, which can be specified using
13381 the @code{vector_size} attribute. The header file @file{arc-simd.h}
13382 can be included to use the following predefined types:
13384 typedef int __v4si __attribute__((vector_size(16)));
13385 typedef short __v8hi __attribute__((vector_size(16)));
13388 These types can be used to define 128-bit variables. The built-in
13389 functions listed in the following section can be used on these
13390 variables to generate the vector operations.
13392 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
13393 @file{arc-simd.h} also provides equivalent macros called
13394 @code{_@var{someinsn}} that can be used for programming ease and
13395 improved readability. The following macros for DMA control are also
13398 #define _setup_dma_in_channel_reg _vdiwr
13399 #define _setup_dma_out_channel_reg _vdowr
13402 The following is a complete list of all the SIMD built-ins provided
13403 for ARC, grouped by calling signature.
13405 The following take two @code{__v8hi} arguments and return a
13406 @code{__v8hi} result:
13408 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
13409 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
13410 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
13411 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
13412 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
13413 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
13414 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
13415 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
13416 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
13417 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
13418 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
13419 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
13420 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
13421 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
13422 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
13423 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
13424 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
13425 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
13426 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
13427 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
13428 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
13429 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
13430 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
13431 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
13432 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
13433 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
13434 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
13435 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
13436 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
13437 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
13438 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
13439 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
13440 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
13441 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
13442 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
13443 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
13444 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
13445 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
13446 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
13447 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
13448 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
13449 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
13450 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
13451 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
13452 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
13453 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
13454 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
13455 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
13458 The following take one @code{__v8hi} and one @code{int} argument and return a
13459 @code{__v8hi} result:
13462 __v8hi __builtin_arc_vbaddw (__v8hi, int)
13463 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
13464 __v8hi __builtin_arc_vbminw (__v8hi, int)
13465 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
13466 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
13467 __v8hi __builtin_arc_vbmulw (__v8hi, int)
13468 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
13469 __v8hi __builtin_arc_vbsubw (__v8hi, int)
13472 The following take one @code{__v8hi} argument and one @code{int} argument which
13473 must be a 3-bit compile time constant indicating a register number
13474 I0-I7. They return a @code{__v8hi} result.
13476 __v8hi __builtin_arc_vasrw (__v8hi, const int)
13477 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
13478 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
13481 The following take one @code{__v8hi} argument and one @code{int}
13482 argument which must be a 6-bit compile time constant. They return a
13483 @code{__v8hi} result.
13485 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
13486 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
13487 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
13488 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
13489 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
13490 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
13491 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
13494 The following take one @code{__v8hi} argument and one @code{int} argument which
13495 must be a 8-bit compile time constant. They return a @code{__v8hi}
13498 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
13499 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
13500 __v8hi __builtin_arc_vmvw (__v8hi, const int)
13501 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
13504 The following take two @code{int} arguments, the second of which which
13505 must be a 8-bit compile time constant. They return a @code{__v8hi}
13508 __v8hi __builtin_arc_vmovaw (int, const int)
13509 __v8hi __builtin_arc_vmovw (int, const int)
13510 __v8hi __builtin_arc_vmovzw (int, const int)
13513 The following take a single @code{__v8hi} argument and return a
13514 @code{__v8hi} result:
13516 __v8hi __builtin_arc_vabsaw (__v8hi)
13517 __v8hi __builtin_arc_vabsw (__v8hi)
13518 __v8hi __builtin_arc_vaddsuw (__v8hi)
13519 __v8hi __builtin_arc_vexch1 (__v8hi)
13520 __v8hi __builtin_arc_vexch2 (__v8hi)
13521 __v8hi __builtin_arc_vexch4 (__v8hi)
13522 __v8hi __builtin_arc_vsignw (__v8hi)
13523 __v8hi __builtin_arc_vupbaw (__v8hi)
13524 __v8hi __builtin_arc_vupbw (__v8hi)
13525 __v8hi __builtin_arc_vupsbaw (__v8hi)
13526 __v8hi __builtin_arc_vupsbw (__v8hi)
13529 The following take two @code{int} arguments and return no result:
13531 void __builtin_arc_vdirun (int, int)
13532 void __builtin_arc_vdorun (int, int)
13535 The following take two @code{int} arguments and return no result. The
13536 first argument must a 3-bit compile time constant indicating one of
13537 the DR0-DR7 DMA setup channels:
13539 void __builtin_arc_vdiwr (const int, int)
13540 void __builtin_arc_vdowr (const int, int)
13543 The following take an @code{int} argument and return no result:
13545 void __builtin_arc_vendrec (int)
13546 void __builtin_arc_vrec (int)
13547 void __builtin_arc_vrecrun (int)
13548 void __builtin_arc_vrun (int)
13551 The following take a @code{__v8hi} argument and two @code{int}
13552 arguments and return a @code{__v8hi} result. The second argument must
13553 be a 3-bit compile time constants, indicating one the registers I0-I7,
13554 and the third argument must be an 8-bit compile time constant.
13556 @emph{Note:} Although the equivalent hardware instructions do not take
13557 an SIMD register as an operand, these builtins overwrite the relevant
13558 bits of the @code{__v8hi} register provided as the first argument with
13559 the value loaded from the @code{[Ib, u8]} location in the SDM.
13562 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
13563 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
13564 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
13565 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
13568 The following take two @code{int} arguments and return a @code{__v8hi}
13569 result. The first argument must be a 3-bit compile time constants,
13570 indicating one the registers I0-I7, and the second argument must be an
13571 8-bit compile time constant.
13574 __v8hi __builtin_arc_vld128 (const int, const int)
13575 __v8hi __builtin_arc_vld64w (const int, const int)
13578 The following take a @code{__v8hi} argument and two @code{int}
13579 arguments and return no result. The second argument must be a 3-bit
13580 compile time constants, indicating one the registers I0-I7, and the
13581 third argument must be an 8-bit compile time constant.
13584 void __builtin_arc_vst128 (__v8hi, const int, const int)
13585 void __builtin_arc_vst64 (__v8hi, const int, const int)
13588 The following take a @code{__v8hi} argument and three @code{int}
13589 arguments and return no result. The second argument must be a 3-bit
13590 compile-time constant, identifying the 16-bit sub-register to be
13591 stored, the third argument must be a 3-bit compile time constants,
13592 indicating one the registers I0-I7, and the fourth argument must be an
13593 8-bit compile time constant.
13596 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
13597 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
13600 @node ARM iWMMXt Built-in Functions
13601 @subsection ARM iWMMXt Built-in Functions
13603 These built-in functions are available for the ARM family of
13604 processors when the @option{-mcpu=iwmmxt} switch is used:
13607 typedef int v2si __attribute__ ((vector_size (8)));
13608 typedef short v4hi __attribute__ ((vector_size (8)));
13609 typedef char v8qi __attribute__ ((vector_size (8)));
13611 int __builtin_arm_getwcgr0 (void)
13612 void __builtin_arm_setwcgr0 (int)
13613 int __builtin_arm_getwcgr1 (void)
13614 void __builtin_arm_setwcgr1 (int)
13615 int __builtin_arm_getwcgr2 (void)
13616 void __builtin_arm_setwcgr2 (int)
13617 int __builtin_arm_getwcgr3 (void)
13618 void __builtin_arm_setwcgr3 (int)
13619 int __builtin_arm_textrmsb (v8qi, int)
13620 int __builtin_arm_textrmsh (v4hi, int)
13621 int __builtin_arm_textrmsw (v2si, int)
13622 int __builtin_arm_textrmub (v8qi, int)
13623 int __builtin_arm_textrmuh (v4hi, int)
13624 int __builtin_arm_textrmuw (v2si, int)
13625 v8qi __builtin_arm_tinsrb (v8qi, int, int)
13626 v4hi __builtin_arm_tinsrh (v4hi, int, int)
13627 v2si __builtin_arm_tinsrw (v2si, int, int)
13628 long long __builtin_arm_tmia (long long, int, int)
13629 long long __builtin_arm_tmiabb (long long, int, int)
13630 long long __builtin_arm_tmiabt (long long, int, int)
13631 long long __builtin_arm_tmiaph (long long, int, int)
13632 long long __builtin_arm_tmiatb (long long, int, int)
13633 long long __builtin_arm_tmiatt (long long, int, int)
13634 int __builtin_arm_tmovmskb (v8qi)
13635 int __builtin_arm_tmovmskh (v4hi)
13636 int __builtin_arm_tmovmskw (v2si)
13637 long long __builtin_arm_waccb (v8qi)
13638 long long __builtin_arm_wacch (v4hi)
13639 long long __builtin_arm_waccw (v2si)
13640 v8qi __builtin_arm_waddb (v8qi, v8qi)
13641 v8qi __builtin_arm_waddbss (v8qi, v8qi)
13642 v8qi __builtin_arm_waddbus (v8qi, v8qi)
13643 v4hi __builtin_arm_waddh (v4hi, v4hi)
13644 v4hi __builtin_arm_waddhss (v4hi, v4hi)
13645 v4hi __builtin_arm_waddhus (v4hi, v4hi)
13646 v2si __builtin_arm_waddw (v2si, v2si)
13647 v2si __builtin_arm_waddwss (v2si, v2si)
13648 v2si __builtin_arm_waddwus (v2si, v2si)
13649 v8qi __builtin_arm_walign (v8qi, v8qi, int)
13650 long long __builtin_arm_wand(long long, long long)
13651 long long __builtin_arm_wandn (long long, long long)
13652 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
13653 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
13654 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
13655 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
13656 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
13657 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
13658 v2si __builtin_arm_wcmpeqw (v2si, v2si)
13659 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
13660 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
13661 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
13662 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
13663 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
13664 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
13665 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
13666 long long __builtin_arm_wmacsz (v4hi, v4hi)
13667 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
13668 long long __builtin_arm_wmacuz (v4hi, v4hi)
13669 v4hi __builtin_arm_wmadds (v4hi, v4hi)
13670 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
13671 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
13672 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
13673 v2si __builtin_arm_wmaxsw (v2si, v2si)
13674 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
13675 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
13676 v2si __builtin_arm_wmaxuw (v2si, v2si)
13677 v8qi __builtin_arm_wminsb (v8qi, v8qi)
13678 v4hi __builtin_arm_wminsh (v4hi, v4hi)
13679 v2si __builtin_arm_wminsw (v2si, v2si)
13680 v8qi __builtin_arm_wminub (v8qi, v8qi)
13681 v4hi __builtin_arm_wminuh (v4hi, v4hi)
13682 v2si __builtin_arm_wminuw (v2si, v2si)
13683 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
13684 v4hi __builtin_arm_wmulul (v4hi, v4hi)
13685 v4hi __builtin_arm_wmulum (v4hi, v4hi)
13686 long long __builtin_arm_wor (long long, long long)
13687 v2si __builtin_arm_wpackdss (long long, long long)
13688 v2si __builtin_arm_wpackdus (long long, long long)
13689 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
13690 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
13691 v4hi __builtin_arm_wpackwss (v2si, v2si)
13692 v4hi __builtin_arm_wpackwus (v2si, v2si)
13693 long long __builtin_arm_wrord (long long, long long)
13694 long long __builtin_arm_wrordi (long long, int)
13695 v4hi __builtin_arm_wrorh (v4hi, long long)
13696 v4hi __builtin_arm_wrorhi (v4hi, int)
13697 v2si __builtin_arm_wrorw (v2si, long long)
13698 v2si __builtin_arm_wrorwi (v2si, int)
13699 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
13700 v2si __builtin_arm_wsadbz (v8qi, v8qi)
13701 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
13702 v2si __builtin_arm_wsadhz (v4hi, v4hi)
13703 v4hi __builtin_arm_wshufh (v4hi, int)
13704 long long __builtin_arm_wslld (long long, long long)
13705 long long __builtin_arm_wslldi (long long, int)
13706 v4hi __builtin_arm_wsllh (v4hi, long long)
13707 v4hi __builtin_arm_wsllhi (v4hi, int)
13708 v2si __builtin_arm_wsllw (v2si, long long)
13709 v2si __builtin_arm_wsllwi (v2si, int)
13710 long long __builtin_arm_wsrad (long long, long long)
13711 long long __builtin_arm_wsradi (long long, int)
13712 v4hi __builtin_arm_wsrah (v4hi, long long)
13713 v4hi __builtin_arm_wsrahi (v4hi, int)
13714 v2si __builtin_arm_wsraw (v2si, long long)
13715 v2si __builtin_arm_wsrawi (v2si, int)
13716 long long __builtin_arm_wsrld (long long, long long)
13717 long long __builtin_arm_wsrldi (long long, int)
13718 v4hi __builtin_arm_wsrlh (v4hi, long long)
13719 v4hi __builtin_arm_wsrlhi (v4hi, int)
13720 v2si __builtin_arm_wsrlw (v2si, long long)
13721 v2si __builtin_arm_wsrlwi (v2si, int)
13722 v8qi __builtin_arm_wsubb (v8qi, v8qi)
13723 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
13724 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
13725 v4hi __builtin_arm_wsubh (v4hi, v4hi)
13726 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
13727 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
13728 v2si __builtin_arm_wsubw (v2si, v2si)
13729 v2si __builtin_arm_wsubwss (v2si, v2si)
13730 v2si __builtin_arm_wsubwus (v2si, v2si)
13731 v4hi __builtin_arm_wunpckehsb (v8qi)
13732 v2si __builtin_arm_wunpckehsh (v4hi)
13733 long long __builtin_arm_wunpckehsw (v2si)
13734 v4hi __builtin_arm_wunpckehub (v8qi)
13735 v2si __builtin_arm_wunpckehuh (v4hi)
13736 long long __builtin_arm_wunpckehuw (v2si)
13737 v4hi __builtin_arm_wunpckelsb (v8qi)
13738 v2si __builtin_arm_wunpckelsh (v4hi)
13739 long long __builtin_arm_wunpckelsw (v2si)
13740 v4hi __builtin_arm_wunpckelub (v8qi)
13741 v2si __builtin_arm_wunpckeluh (v4hi)
13742 long long __builtin_arm_wunpckeluw (v2si)
13743 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
13744 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
13745 v2si __builtin_arm_wunpckihw (v2si, v2si)
13746 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
13747 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
13748 v2si __builtin_arm_wunpckilw (v2si, v2si)
13749 long long __builtin_arm_wxor (long long, long long)
13750 long long __builtin_arm_wzero ()
13754 @node ARM C Language Extensions (ACLE)
13755 @subsection ARM C Language Extensions (ACLE)
13757 GCC implements extensions for C as described in the ARM C Language
13758 Extensions (ACLE) specification, which can be found at
13759 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
13761 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
13762 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
13763 intrinsics can be found at
13764 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
13765 The built-in intrinsics for the Advanced SIMD extension are available when
13768 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
13769 back ends support CRC32 intrinsics and the ARM back end supports the
13770 Coprocessor intrinsics, all from @file{arm_acle.h}. The ARM back end's 16-bit
13771 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
13772 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
13775 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
13776 availability of extensions.
13778 @node ARM Floating Point Status and Control Intrinsics
13779 @subsection ARM Floating Point Status and Control Intrinsics
13781 These built-in functions are available for the ARM family of
13782 processors with floating-point unit.
13785 unsigned int __builtin_arm_get_fpscr ()
13786 void __builtin_arm_set_fpscr (unsigned int)
13789 @node ARM ARMv8-M Security Extensions
13790 @subsection ARM ARMv8-M Security Extensions
13792 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
13793 Security Extensions: Requirements on Development Tools Engineering
13794 Specification, which can be found at
13795 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
13797 As part of the Security Extensions GCC implements two new function attributes:
13798 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
13800 As part of the Security Extensions GCC implements the intrinsics below. FPTR
13801 is used here to mean any function pointer type.
13804 cmse_address_info_t cmse_TT (void *)
13805 cmse_address_info_t cmse_TT_fptr (FPTR)
13806 cmse_address_info_t cmse_TTT (void *)
13807 cmse_address_info_t cmse_TTT_fptr (FPTR)
13808 cmse_address_info_t cmse_TTA (void *)
13809 cmse_address_info_t cmse_TTA_fptr (FPTR)
13810 cmse_address_info_t cmse_TTAT (void *)
13811 cmse_address_info_t cmse_TTAT_fptr (FPTR)
13812 void * cmse_check_address_range (void *, size_t, int)
13813 typeof(p) cmse_nsfptr_create (FPTR p)
13814 intptr_t cmse_is_nsfptr (FPTR)
13815 int cmse_nonsecure_caller (void)
13818 @node AVR Built-in Functions
13819 @subsection AVR Built-in Functions
13821 For each built-in function for AVR, there is an equally named,
13822 uppercase built-in macro defined. That way users can easily query if
13823 or if not a specific built-in is implemented or not. For example, if
13824 @code{__builtin_avr_nop} is available the macro
13825 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
13829 @item void __builtin_avr_nop (void)
13830 @itemx void __builtin_avr_sei (void)
13831 @itemx void __builtin_avr_cli (void)
13832 @itemx void __builtin_avr_sleep (void)
13833 @itemx void __builtin_avr_wdr (void)
13834 @itemx unsigned char __builtin_avr_swap (unsigned char)
13835 @itemx unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
13836 @itemx int __builtin_avr_fmuls (char, char)
13837 @itemx int __builtin_avr_fmulsu (char, unsigned char)
13838 These built-in functions map to the respective machine
13839 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
13840 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
13841 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
13842 as library call if no hardware multiplier is available.
13844 @item void __builtin_avr_delay_cycles (unsigned long ticks)
13845 Delay execution for @var{ticks} cycles. Note that this
13846 built-in does not take into account the effect of interrupts that
13847 might increase delay time. @var{ticks} must be a compile-time
13848 integer constant; delays with a variable number of cycles are not supported.
13850 @item char __builtin_avr_flash_segment (const __memx void*)
13851 This built-in takes a byte address to the 24-bit
13852 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
13853 the number of the flash segment (the 64 KiB chunk) where the address
13854 points to. Counting starts at @code{0}.
13855 If the address does not point to flash memory, return @code{-1}.
13857 @item uint8_t __builtin_avr_insert_bits (uint32_t map, uint8_t bits, uint8_t val)
13858 Insert bits from @var{bits} into @var{val} and return the resulting
13859 value. The nibbles of @var{map} determine how the insertion is
13860 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
13862 @item If @var{X} is @code{0xf},
13863 then the @var{n}-th bit of @var{val} is returned unaltered.
13865 @item If X is in the range 0@dots{}7,
13866 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
13868 @item If X is in the range 8@dots{}@code{0xe},
13869 then the @var{n}-th result bit is undefined.
13873 One typical use case for this built-in is adjusting input and
13874 output values to non-contiguous port layouts. Some examples:
13877 // same as val, bits is unused
13878 __builtin_avr_insert_bits (0xffffffff, bits, val)
13882 // same as bits, val is unused
13883 __builtin_avr_insert_bits (0x76543210, bits, val)
13887 // same as rotating bits by 4
13888 __builtin_avr_insert_bits (0x32107654, bits, 0)
13892 // high nibble of result is the high nibble of val
13893 // low nibble of result is the low nibble of bits
13894 __builtin_avr_insert_bits (0xffff3210, bits, val)
13898 // reverse the bit order of bits
13899 __builtin_avr_insert_bits (0x01234567, bits, 0)
13902 @item void __builtin_avr_nops (unsigned count)
13903 Insert @var{count} @code{NOP} instructions.
13904 The number of instructions must be a compile-time integer constant.
13909 There are many more AVR-specific built-in functions that are used to
13910 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
13911 section 7.18a.6. You don't need to use these built-ins directly.
13912 Instead, use the declarations as supplied by the @code{stdfix.h} header
13916 #include <stdfix.h>
13918 // Re-interpret the bit representation of unsigned 16-bit
13919 // integer @var{uval} as Q-format 0.16 value.
13920 unsigned fract get_bits (uint_ur_t uval)
13922 return urbits (uval);
13926 @node Blackfin Built-in Functions
13927 @subsection Blackfin Built-in Functions
13929 Currently, there are two Blackfin-specific built-in functions. These are
13930 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
13931 using inline assembly; by using these built-in functions the compiler can
13932 automatically add workarounds for hardware errata involving these
13933 instructions. These functions are named as follows:
13936 void __builtin_bfin_csync (void)
13937 void __builtin_bfin_ssync (void)
13940 @node FR-V Built-in Functions
13941 @subsection FR-V Built-in Functions
13943 GCC provides many FR-V-specific built-in functions. In general,
13944 these functions are intended to be compatible with those described
13945 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
13946 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
13947 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
13948 pointer rather than by value.
13950 Most of the functions are named after specific FR-V instructions.
13951 Such functions are said to be ``directly mapped'' and are summarized
13952 here in tabular form.
13956 * Directly-mapped Integer Functions::
13957 * Directly-mapped Media Functions::
13958 * Raw read/write Functions::
13959 * Other Built-in Functions::
13962 @node Argument Types
13963 @subsubsection Argument Types
13965 The arguments to the built-in functions can be divided into three groups:
13966 register numbers, compile-time constants and run-time values. In order
13967 to make this classification clear at a glance, the arguments and return
13968 values are given the following pseudo types:
13970 @multitable @columnfractions .20 .30 .15 .35
13971 @item Pseudo type @tab Real C type @tab Constant? @tab Description
13972 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
13973 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
13974 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
13975 @item @code{uw2} @tab @code{unsigned long long} @tab No
13976 @tab an unsigned doubleword
13977 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
13978 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
13979 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
13980 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
13983 These pseudo types are not defined by GCC, they are simply a notational
13984 convenience used in this manual.
13986 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
13987 and @code{sw2} are evaluated at run time. They correspond to
13988 register operands in the underlying FR-V instructions.
13990 @code{const} arguments represent immediate operands in the underlying
13991 FR-V instructions. They must be compile-time constants.
13993 @code{acc} arguments are evaluated at compile time and specify the number
13994 of an accumulator register. For example, an @code{acc} argument of 2
13995 selects the ACC2 register.
13997 @code{iacc} arguments are similar to @code{acc} arguments but specify the
13998 number of an IACC register. See @pxref{Other Built-in Functions}
14001 @node Directly-mapped Integer Functions
14002 @subsubsection Directly-Mapped Integer Functions
14004 The functions listed below map directly to FR-V I-type instructions.
14006 @multitable @columnfractions .45 .32 .23
14007 @item Function prototype @tab Example usage @tab Assembly output
14008 @item @code{sw1 __ADDSS (sw1, sw1)}
14009 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
14010 @tab @code{ADDSS @var{a},@var{b},@var{c}}
14011 @item @code{sw1 __SCAN (sw1, sw1)}
14012 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
14013 @tab @code{SCAN @var{a},@var{b},@var{c}}
14014 @item @code{sw1 __SCUTSS (sw1)}
14015 @tab @code{@var{b} = __SCUTSS (@var{a})}
14016 @tab @code{SCUTSS @var{a},@var{b}}
14017 @item @code{sw1 __SLASS (sw1, sw1)}
14018 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
14019 @tab @code{SLASS @var{a},@var{b},@var{c}}
14020 @item @code{void __SMASS (sw1, sw1)}
14021 @tab @code{__SMASS (@var{a}, @var{b})}
14022 @tab @code{SMASS @var{a},@var{b}}
14023 @item @code{void __SMSSS (sw1, sw1)}
14024 @tab @code{__SMSSS (@var{a}, @var{b})}
14025 @tab @code{SMSSS @var{a},@var{b}}
14026 @item @code{void __SMU (sw1, sw1)}
14027 @tab @code{__SMU (@var{a}, @var{b})}
14028 @tab @code{SMU @var{a},@var{b}}
14029 @item @code{sw2 __SMUL (sw1, sw1)}
14030 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
14031 @tab @code{SMUL @var{a},@var{b},@var{c}}
14032 @item @code{sw1 __SUBSS (sw1, sw1)}
14033 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
14034 @tab @code{SUBSS @var{a},@var{b},@var{c}}
14035 @item @code{uw2 __UMUL (uw1, uw1)}
14036 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
14037 @tab @code{UMUL @var{a},@var{b},@var{c}}
14040 @node Directly-mapped Media Functions
14041 @subsubsection Directly-Mapped Media Functions
14043 The functions listed below map directly to FR-V M-type instructions.
14045 @multitable @columnfractions .45 .32 .23
14046 @item Function prototype @tab Example usage @tab Assembly output
14047 @item @code{uw1 __MABSHS (sw1)}
14048 @tab @code{@var{b} = __MABSHS (@var{a})}
14049 @tab @code{MABSHS @var{a},@var{b}}
14050 @item @code{void __MADDACCS (acc, acc)}
14051 @tab @code{__MADDACCS (@var{b}, @var{a})}
14052 @tab @code{MADDACCS @var{a},@var{b}}
14053 @item @code{sw1 __MADDHSS (sw1, sw1)}
14054 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
14055 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
14056 @item @code{uw1 __MADDHUS (uw1, uw1)}
14057 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
14058 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
14059 @item @code{uw1 __MAND (uw1, uw1)}
14060 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
14061 @tab @code{MAND @var{a},@var{b},@var{c}}
14062 @item @code{void __MASACCS (acc, acc)}
14063 @tab @code{__MASACCS (@var{b}, @var{a})}
14064 @tab @code{MASACCS @var{a},@var{b}}
14065 @item @code{uw1 __MAVEH (uw1, uw1)}
14066 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
14067 @tab @code{MAVEH @var{a},@var{b},@var{c}}
14068 @item @code{uw2 __MBTOH (uw1)}
14069 @tab @code{@var{b} = __MBTOH (@var{a})}
14070 @tab @code{MBTOH @var{a},@var{b}}
14071 @item @code{void __MBTOHE (uw1 *, uw1)}
14072 @tab @code{__MBTOHE (&@var{b}, @var{a})}
14073 @tab @code{MBTOHE @var{a},@var{b}}
14074 @item @code{void __MCLRACC (acc)}
14075 @tab @code{__MCLRACC (@var{a})}
14076 @tab @code{MCLRACC @var{a}}
14077 @item @code{void __MCLRACCA (void)}
14078 @tab @code{__MCLRACCA ()}
14079 @tab @code{MCLRACCA}
14080 @item @code{uw1 __Mcop1 (uw1, uw1)}
14081 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
14082 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
14083 @item @code{uw1 __Mcop2 (uw1, uw1)}
14084 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
14085 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
14086 @item @code{uw1 __MCPLHI (uw2, const)}
14087 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
14088 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
14089 @item @code{uw1 __MCPLI (uw2, const)}
14090 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
14091 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
14092 @item @code{void __MCPXIS (acc, sw1, sw1)}
14093 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
14094 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
14095 @item @code{void __MCPXIU (acc, uw1, uw1)}
14096 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
14097 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
14098 @item @code{void __MCPXRS (acc, sw1, sw1)}
14099 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
14100 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
14101 @item @code{void __MCPXRU (acc, uw1, uw1)}
14102 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
14103 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
14104 @item @code{uw1 __MCUT (acc, uw1)}
14105 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
14106 @tab @code{MCUT @var{a},@var{b},@var{c}}
14107 @item @code{uw1 __MCUTSS (acc, sw1)}
14108 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
14109 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
14110 @item @code{void __MDADDACCS (acc, acc)}
14111 @tab @code{__MDADDACCS (@var{b}, @var{a})}
14112 @tab @code{MDADDACCS @var{a},@var{b}}
14113 @item @code{void __MDASACCS (acc, acc)}
14114 @tab @code{__MDASACCS (@var{b}, @var{a})}
14115 @tab @code{MDASACCS @var{a},@var{b}}
14116 @item @code{uw2 __MDCUTSSI (acc, const)}
14117 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
14118 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
14119 @item @code{uw2 __MDPACKH (uw2, uw2)}
14120 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
14121 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
14122 @item @code{uw2 __MDROTLI (uw2, const)}
14123 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
14124 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
14125 @item @code{void __MDSUBACCS (acc, acc)}
14126 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
14127 @tab @code{MDSUBACCS @var{a},@var{b}}
14128 @item @code{void __MDUNPACKH (uw1 *, uw2)}
14129 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
14130 @tab @code{MDUNPACKH @var{a},@var{b}}
14131 @item @code{uw2 __MEXPDHD (uw1, const)}
14132 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
14133 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
14134 @item @code{uw1 __MEXPDHW (uw1, const)}
14135 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
14136 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
14137 @item @code{uw1 __MHDSETH (uw1, const)}
14138 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
14139 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
14140 @item @code{sw1 __MHDSETS (const)}
14141 @tab @code{@var{b} = __MHDSETS (@var{a})}
14142 @tab @code{MHDSETS #@var{a},@var{b}}
14143 @item @code{uw1 __MHSETHIH (uw1, const)}
14144 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
14145 @tab @code{MHSETHIH #@var{a},@var{b}}
14146 @item @code{sw1 __MHSETHIS (sw1, const)}
14147 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
14148 @tab @code{MHSETHIS #@var{a},@var{b}}
14149 @item @code{uw1 __MHSETLOH (uw1, const)}
14150 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
14151 @tab @code{MHSETLOH #@var{a},@var{b}}
14152 @item @code{sw1 __MHSETLOS (sw1, const)}
14153 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
14154 @tab @code{MHSETLOS #@var{a},@var{b}}
14155 @item @code{uw1 __MHTOB (uw2)}
14156 @tab @code{@var{b} = __MHTOB (@var{a})}
14157 @tab @code{MHTOB @var{a},@var{b}}
14158 @item @code{void __MMACHS (acc, sw1, sw1)}
14159 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
14160 @tab @code{MMACHS @var{a},@var{b},@var{c}}
14161 @item @code{void __MMACHU (acc, uw1, uw1)}
14162 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
14163 @tab @code{MMACHU @var{a},@var{b},@var{c}}
14164 @item @code{void __MMRDHS (acc, sw1, sw1)}
14165 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
14166 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
14167 @item @code{void __MMRDHU (acc, uw1, uw1)}
14168 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
14169 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
14170 @item @code{void __MMULHS (acc, sw1, sw1)}
14171 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
14172 @tab @code{MMULHS @var{a},@var{b},@var{c}}
14173 @item @code{void __MMULHU (acc, uw1, uw1)}
14174 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
14175 @tab @code{MMULHU @var{a},@var{b},@var{c}}
14176 @item @code{void __MMULXHS (acc, sw1, sw1)}
14177 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
14178 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
14179 @item @code{void __MMULXHU (acc, uw1, uw1)}
14180 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
14181 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
14182 @item @code{uw1 __MNOT (uw1)}
14183 @tab @code{@var{b} = __MNOT (@var{a})}
14184 @tab @code{MNOT @var{a},@var{b}}
14185 @item @code{uw1 __MOR (uw1, uw1)}
14186 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
14187 @tab @code{MOR @var{a},@var{b},@var{c}}
14188 @item @code{uw1 __MPACKH (uh, uh)}
14189 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
14190 @tab @code{MPACKH @var{a},@var{b},@var{c}}
14191 @item @code{sw2 __MQADDHSS (sw2, sw2)}
14192 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
14193 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
14194 @item @code{uw2 __MQADDHUS (uw2, uw2)}
14195 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
14196 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
14197 @item @code{void __MQCPXIS (acc, sw2, sw2)}
14198 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
14199 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
14200 @item @code{void __MQCPXIU (acc, uw2, uw2)}
14201 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
14202 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
14203 @item @code{void __MQCPXRS (acc, sw2, sw2)}
14204 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
14205 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
14206 @item @code{void __MQCPXRU (acc, uw2, uw2)}
14207 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
14208 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
14209 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
14210 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
14211 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
14212 @item @code{sw2 __MQLMTHS (sw2, sw2)}
14213 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
14214 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
14215 @item @code{void __MQMACHS (acc, sw2, sw2)}
14216 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
14217 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
14218 @item @code{void __MQMACHU (acc, uw2, uw2)}
14219 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
14220 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
14221 @item @code{void __MQMACXHS (acc, sw2, sw2)}
14222 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
14223 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
14224 @item @code{void __MQMULHS (acc, sw2, sw2)}
14225 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
14226 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
14227 @item @code{void __MQMULHU (acc, uw2, uw2)}
14228 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
14229 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
14230 @item @code{void __MQMULXHS (acc, sw2, sw2)}
14231 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
14232 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
14233 @item @code{void __MQMULXHU (acc, uw2, uw2)}
14234 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
14235 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
14236 @item @code{sw2 __MQSATHS (sw2, sw2)}
14237 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
14238 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
14239 @item @code{uw2 __MQSLLHI (uw2, int)}
14240 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
14241 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
14242 @item @code{sw2 __MQSRAHI (sw2, int)}
14243 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
14244 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
14245 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
14246 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
14247 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
14248 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
14249 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
14250 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
14251 @item @code{void __MQXMACHS (acc, sw2, sw2)}
14252 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
14253 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
14254 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
14255 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
14256 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
14257 @item @code{uw1 __MRDACC (acc)}
14258 @tab @code{@var{b} = __MRDACC (@var{a})}
14259 @tab @code{MRDACC @var{a},@var{b}}
14260 @item @code{uw1 __MRDACCG (acc)}
14261 @tab @code{@var{b} = __MRDACCG (@var{a})}
14262 @tab @code{MRDACCG @var{a},@var{b}}
14263 @item @code{uw1 __MROTLI (uw1, const)}
14264 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
14265 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
14266 @item @code{uw1 __MROTRI (uw1, const)}
14267 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
14268 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
14269 @item @code{sw1 __MSATHS (sw1, sw1)}
14270 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
14271 @tab @code{MSATHS @var{a},@var{b},@var{c}}
14272 @item @code{uw1 __MSATHU (uw1, uw1)}
14273 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
14274 @tab @code{MSATHU @var{a},@var{b},@var{c}}
14275 @item @code{uw1 __MSLLHI (uw1, const)}
14276 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
14277 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
14278 @item @code{sw1 __MSRAHI (sw1, const)}
14279 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
14280 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
14281 @item @code{uw1 __MSRLHI (uw1, const)}
14282 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
14283 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
14284 @item @code{void __MSUBACCS (acc, acc)}
14285 @tab @code{__MSUBACCS (@var{b}, @var{a})}
14286 @tab @code{MSUBACCS @var{a},@var{b}}
14287 @item @code{sw1 __MSUBHSS (sw1, sw1)}
14288 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
14289 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
14290 @item @code{uw1 __MSUBHUS (uw1, uw1)}
14291 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
14292 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
14293 @item @code{void __MTRAP (void)}
14294 @tab @code{__MTRAP ()}
14296 @item @code{uw2 __MUNPACKH (uw1)}
14297 @tab @code{@var{b} = __MUNPACKH (@var{a})}
14298 @tab @code{MUNPACKH @var{a},@var{b}}
14299 @item @code{uw1 __MWCUT (uw2, uw1)}
14300 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
14301 @tab @code{MWCUT @var{a},@var{b},@var{c}}
14302 @item @code{void __MWTACC (acc, uw1)}
14303 @tab @code{__MWTACC (@var{b}, @var{a})}
14304 @tab @code{MWTACC @var{a},@var{b}}
14305 @item @code{void __MWTACCG (acc, uw1)}
14306 @tab @code{__MWTACCG (@var{b}, @var{a})}
14307 @tab @code{MWTACCG @var{a},@var{b}}
14308 @item @code{uw1 __MXOR (uw1, uw1)}
14309 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
14310 @tab @code{MXOR @var{a},@var{b},@var{c}}
14313 @node Raw read/write Functions
14314 @subsubsection Raw Read/Write Functions
14316 This sections describes built-in functions related to read and write
14317 instructions to access memory. These functions generate
14318 @code{membar} instructions to flush the I/O load and stores where
14319 appropriate, as described in Fujitsu's manual described above.
14323 @item unsigned char __builtin_read8 (void *@var{data})
14324 @item unsigned short __builtin_read16 (void *@var{data})
14325 @item unsigned long __builtin_read32 (void *@var{data})
14326 @item unsigned long long __builtin_read64 (void *@var{data})
14328 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
14329 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
14330 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
14331 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
14334 @node Other Built-in Functions
14335 @subsubsection Other Built-in Functions
14337 This section describes built-in functions that are not named after
14338 a specific FR-V instruction.
14341 @item sw2 __IACCreadll (iacc @var{reg})
14342 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
14343 for future expansion and must be 0.
14345 @item sw1 __IACCreadl (iacc @var{reg})
14346 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
14347 Other values of @var{reg} are rejected as invalid.
14349 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
14350 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
14351 is reserved for future expansion and must be 0.
14353 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
14354 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
14355 is 1. Other values of @var{reg} are rejected as invalid.
14357 @item void __data_prefetch0 (const void *@var{x})
14358 Use the @code{dcpl} instruction to load the contents of address @var{x}
14359 into the data cache.
14361 @item void __data_prefetch (const void *@var{x})
14362 Use the @code{nldub} instruction to load the contents of address @var{x}
14363 into the data cache. The instruction is issued in slot I1@.
14366 @node MIPS DSP Built-in Functions
14367 @subsection MIPS DSP Built-in Functions
14369 The MIPS DSP Application-Specific Extension (ASE) includes new
14370 instructions that are designed to improve the performance of DSP and
14371 media applications. It provides instructions that operate on packed
14372 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
14374 GCC supports MIPS DSP operations using both the generic
14375 vector extensions (@pxref{Vector Extensions}) and a collection of
14376 MIPS-specific built-in functions. Both kinds of support are
14377 enabled by the @option{-mdsp} command-line option.
14379 Revision 2 of the ASE was introduced in the second half of 2006.
14380 This revision adds extra instructions to the original ASE, but is
14381 otherwise backwards-compatible with it. You can select revision 2
14382 using the command-line option @option{-mdspr2}; this option implies
14385 The SCOUNT and POS bits of the DSP control register are global. The
14386 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
14387 POS bits. During optimization, the compiler does not delete these
14388 instructions and it does not delete calls to functions containing
14389 these instructions.
14391 At present, GCC only provides support for operations on 32-bit
14392 vectors. The vector type associated with 8-bit integer data is
14393 usually called @code{v4i8}, the vector type associated with Q7
14394 is usually called @code{v4q7}, the vector type associated with 16-bit
14395 integer data is usually called @code{v2i16}, and the vector type
14396 associated with Q15 is usually called @code{v2q15}. They can be
14397 defined in C as follows:
14400 typedef signed char v4i8 __attribute__ ((vector_size(4)));
14401 typedef signed char v4q7 __attribute__ ((vector_size(4)));
14402 typedef short v2i16 __attribute__ ((vector_size(4)));
14403 typedef short v2q15 __attribute__ ((vector_size(4)));
14406 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
14407 initialized in the same way as aggregates. For example:
14410 v4i8 a = @{1, 2, 3, 4@};
14412 b = (v4i8) @{5, 6, 7, 8@};
14414 v2q15 c = @{0x0fcb, 0x3a75@};
14416 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
14419 @emph{Note:} The CPU's endianness determines the order in which values
14420 are packed. On little-endian targets, the first value is the least
14421 significant and the last value is the most significant. The opposite
14422 order applies to big-endian targets. For example, the code above
14423 sets the lowest byte of @code{a} to @code{1} on little-endian targets
14424 and @code{4} on big-endian targets.
14426 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
14427 representation. As shown in this example, the integer representation
14428 of a Q7 value can be obtained by multiplying the fractional value by
14429 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
14430 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
14433 The table below lists the @code{v4i8} and @code{v2q15} operations for which
14434 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
14435 and @code{c} and @code{d} are @code{v2q15} values.
14437 @multitable @columnfractions .50 .50
14438 @item C code @tab MIPS instruction
14439 @item @code{a + b} @tab @code{addu.qb}
14440 @item @code{c + d} @tab @code{addq.ph}
14441 @item @code{a - b} @tab @code{subu.qb}
14442 @item @code{c - d} @tab @code{subq.ph}
14445 The table below lists the @code{v2i16} operation for which
14446 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
14447 @code{v2i16} values.
14449 @multitable @columnfractions .50 .50
14450 @item C code @tab MIPS instruction
14451 @item @code{e * f} @tab @code{mul.ph}
14454 It is easier to describe the DSP built-in functions if we first define
14455 the following types:
14460 typedef unsigned int ui32;
14461 typedef long long a64;
14464 @code{q31} and @code{i32} are actually the same as @code{int}, but we
14465 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
14466 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
14467 @code{long long}, but we use @code{a64} to indicate values that are
14468 placed in one of the four DSP accumulators (@code{$ac0},
14469 @code{$ac1}, @code{$ac2} or @code{$ac3}).
14471 Also, some built-in functions prefer or require immediate numbers as
14472 parameters, because the corresponding DSP instructions accept both immediate
14473 numbers and register operands, or accept immediate numbers only. The
14474 immediate parameters are listed as follows.
14482 imm0_255: 0 to 255.
14483 imm_n32_31: -32 to 31.
14484 imm_n512_511: -512 to 511.
14487 The following built-in functions map directly to a particular MIPS DSP
14488 instruction. Please refer to the architecture specification
14489 for details on what each instruction does.
14492 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
14493 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
14494 q31 __builtin_mips_addq_s_w (q31, q31)
14495 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
14496 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
14497 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
14498 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
14499 q31 __builtin_mips_subq_s_w (q31, q31)
14500 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
14501 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
14502 i32 __builtin_mips_addsc (i32, i32)
14503 i32 __builtin_mips_addwc (i32, i32)
14504 i32 __builtin_mips_modsub (i32, i32)
14505 i32 __builtin_mips_raddu_w_qb (v4i8)
14506 v2q15 __builtin_mips_absq_s_ph (v2q15)
14507 q31 __builtin_mips_absq_s_w (q31)
14508 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
14509 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
14510 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
14511 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
14512 q31 __builtin_mips_preceq_w_phl (v2q15)
14513 q31 __builtin_mips_preceq_w_phr (v2q15)
14514 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
14515 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
14516 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
14517 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
14518 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
14519 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
14520 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
14521 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
14522 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
14523 v4i8 __builtin_mips_shll_qb (v4i8, i32)
14524 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
14525 v2q15 __builtin_mips_shll_ph (v2q15, i32)
14526 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
14527 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
14528 q31 __builtin_mips_shll_s_w (q31, imm0_31)
14529 q31 __builtin_mips_shll_s_w (q31, i32)
14530 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
14531 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
14532 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
14533 v2q15 __builtin_mips_shra_ph (v2q15, i32)
14534 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
14535 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
14536 q31 __builtin_mips_shra_r_w (q31, imm0_31)
14537 q31 __builtin_mips_shra_r_w (q31, i32)
14538 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
14539 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
14540 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
14541 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
14542 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
14543 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
14544 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
14545 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
14546 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
14547 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
14548 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
14549 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
14550 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
14551 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
14552 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
14553 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
14554 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
14555 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
14556 i32 __builtin_mips_bitrev (i32)
14557 i32 __builtin_mips_insv (i32, i32)
14558 v4i8 __builtin_mips_repl_qb (imm0_255)
14559 v4i8 __builtin_mips_repl_qb (i32)
14560 v2q15 __builtin_mips_repl_ph (imm_n512_511)
14561 v2q15 __builtin_mips_repl_ph (i32)
14562 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
14563 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
14564 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
14565 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
14566 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
14567 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
14568 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
14569 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
14570 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
14571 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
14572 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
14573 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
14574 i32 __builtin_mips_extr_w (a64, imm0_31)
14575 i32 __builtin_mips_extr_w (a64, i32)
14576 i32 __builtin_mips_extr_r_w (a64, imm0_31)
14577 i32 __builtin_mips_extr_s_h (a64, i32)
14578 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
14579 i32 __builtin_mips_extr_rs_w (a64, i32)
14580 i32 __builtin_mips_extr_s_h (a64, imm0_31)
14581 i32 __builtin_mips_extr_r_w (a64, i32)
14582 i32 __builtin_mips_extp (a64, imm0_31)
14583 i32 __builtin_mips_extp (a64, i32)
14584 i32 __builtin_mips_extpdp (a64, imm0_31)
14585 i32 __builtin_mips_extpdp (a64, i32)
14586 a64 __builtin_mips_shilo (a64, imm_n32_31)
14587 a64 __builtin_mips_shilo (a64, i32)
14588 a64 __builtin_mips_mthlip (a64, i32)
14589 void __builtin_mips_wrdsp (i32, imm0_63)
14590 i32 __builtin_mips_rddsp (imm0_63)
14591 i32 __builtin_mips_lbux (void *, i32)
14592 i32 __builtin_mips_lhx (void *, i32)
14593 i32 __builtin_mips_lwx (void *, i32)
14594 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
14595 i32 __builtin_mips_bposge32 (void)
14596 a64 __builtin_mips_madd (a64, i32, i32);
14597 a64 __builtin_mips_maddu (a64, ui32, ui32);
14598 a64 __builtin_mips_msub (a64, i32, i32);
14599 a64 __builtin_mips_msubu (a64, ui32, ui32);
14600 a64 __builtin_mips_mult (i32, i32);
14601 a64 __builtin_mips_multu (ui32, ui32);
14604 The following built-in functions map directly to a particular MIPS DSP REV 2
14605 instruction. Please refer to the architecture specification
14606 for details on what each instruction does.
14609 v4q7 __builtin_mips_absq_s_qb (v4q7);
14610 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
14611 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
14612 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
14613 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
14614 i32 __builtin_mips_append (i32, i32, imm0_31);
14615 i32 __builtin_mips_balign (i32, i32, imm0_3);
14616 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
14617 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
14618 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
14619 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
14620 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
14621 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
14622 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
14623 q31 __builtin_mips_mulq_rs_w (q31, q31);
14624 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
14625 q31 __builtin_mips_mulq_s_w (q31, q31);
14626 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
14627 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
14628 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
14629 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
14630 i32 __builtin_mips_prepend (i32, i32, imm0_31);
14631 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
14632 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
14633 v4i8 __builtin_mips_shra_qb (v4i8, i32);
14634 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
14635 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
14636 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
14637 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
14638 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
14639 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
14640 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
14641 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
14642 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
14643 q31 __builtin_mips_addqh_w (q31, q31);
14644 q31 __builtin_mips_addqh_r_w (q31, q31);
14645 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
14646 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
14647 q31 __builtin_mips_subqh_w (q31, q31);
14648 q31 __builtin_mips_subqh_r_w (q31, q31);
14649 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
14650 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
14651 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
14652 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
14653 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
14654 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
14658 @node MIPS Paired-Single Support
14659 @subsection MIPS Paired-Single Support
14661 The MIPS64 architecture includes a number of instructions that
14662 operate on pairs of single-precision floating-point values.
14663 Each pair is packed into a 64-bit floating-point register,
14664 with one element being designated the ``upper half'' and
14665 the other being designated the ``lower half''.
14667 GCC supports paired-single operations using both the generic
14668 vector extensions (@pxref{Vector Extensions}) and a collection of
14669 MIPS-specific built-in functions. Both kinds of support are
14670 enabled by the @option{-mpaired-single} command-line option.
14672 The vector type associated with paired-single values is usually
14673 called @code{v2sf}. It can be defined in C as follows:
14676 typedef float v2sf __attribute__ ((vector_size (8)));
14679 @code{v2sf} values are initialized in the same way as aggregates.
14683 v2sf a = @{1.5, 9.1@};
14686 b = (v2sf) @{e, f@};
14689 @emph{Note:} The CPU's endianness determines which value is stored in
14690 the upper half of a register and which value is stored in the lower half.
14691 On little-endian targets, the first value is the lower one and the second
14692 value is the upper one. The opposite order applies to big-endian targets.
14693 For example, the code above sets the lower half of @code{a} to
14694 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
14696 @node MIPS Loongson Built-in Functions
14697 @subsection MIPS Loongson Built-in Functions
14699 GCC provides intrinsics to access the SIMD instructions provided by the
14700 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
14701 available after inclusion of the @code{loongson.h} header file,
14702 operate on the following 64-bit vector types:
14705 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
14706 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
14707 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
14708 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
14709 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
14710 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
14713 The intrinsics provided are listed below; each is named after the
14714 machine instruction to which it corresponds, with suffixes added as
14715 appropriate to distinguish intrinsics that expand to the same machine
14716 instruction yet have different argument types. Refer to the architecture
14717 documentation for a description of the functionality of each
14721 int16x4_t packsswh (int32x2_t s, int32x2_t t);
14722 int8x8_t packsshb (int16x4_t s, int16x4_t t);
14723 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
14724 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
14725 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
14726 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
14727 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
14728 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
14729 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
14730 uint64_t paddd_u (uint64_t s, uint64_t t);
14731 int64_t paddd_s (int64_t s, int64_t t);
14732 int16x4_t paddsh (int16x4_t s, int16x4_t t);
14733 int8x8_t paddsb (int8x8_t s, int8x8_t t);
14734 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
14735 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
14736 uint64_t pandn_ud (uint64_t s, uint64_t t);
14737 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
14738 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
14739 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
14740 int64_t pandn_sd (int64_t s, int64_t t);
14741 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
14742 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
14743 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
14744 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
14745 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
14746 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
14747 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
14748 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
14749 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
14750 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
14751 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
14752 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
14753 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
14754 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
14755 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
14756 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
14757 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
14758 uint16x4_t pextrh_u (uint16x4_t s, int field);
14759 int16x4_t pextrh_s (int16x4_t s, int field);
14760 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
14761 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
14762 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
14763 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
14764 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
14765 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
14766 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
14767 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
14768 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
14769 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
14770 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
14771 int16x4_t pminsh (int16x4_t s, int16x4_t t);
14772 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
14773 uint8x8_t pmovmskb_u (uint8x8_t s);
14774 int8x8_t pmovmskb_s (int8x8_t s);
14775 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
14776 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
14777 int16x4_t pmullh (int16x4_t s, int16x4_t t);
14778 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
14779 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
14780 uint16x4_t biadd (uint8x8_t s);
14781 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
14782 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
14783 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
14784 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
14785 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
14786 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
14787 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
14788 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
14789 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
14790 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
14791 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
14792 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
14793 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
14794 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
14795 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
14796 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
14797 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
14798 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
14799 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
14800 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
14801 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
14802 uint64_t psubd_u (uint64_t s, uint64_t t);
14803 int64_t psubd_s (int64_t s, int64_t t);
14804 int16x4_t psubsh (int16x4_t s, int16x4_t t);
14805 int8x8_t psubsb (int8x8_t s, int8x8_t t);
14806 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
14807 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
14808 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
14809 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
14810 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
14811 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
14812 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
14813 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
14814 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
14815 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
14816 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
14817 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
14818 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
14819 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
14823 * Paired-Single Arithmetic::
14824 * Paired-Single Built-in Functions::
14825 * MIPS-3D Built-in Functions::
14828 @node Paired-Single Arithmetic
14829 @subsubsection Paired-Single Arithmetic
14831 The table below lists the @code{v2sf} operations for which hardware
14832 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
14833 values and @code{x} is an integral value.
14835 @multitable @columnfractions .50 .50
14836 @item C code @tab MIPS instruction
14837 @item @code{a + b} @tab @code{add.ps}
14838 @item @code{a - b} @tab @code{sub.ps}
14839 @item @code{-a} @tab @code{neg.ps}
14840 @item @code{a * b} @tab @code{mul.ps}
14841 @item @code{a * b + c} @tab @code{madd.ps}
14842 @item @code{a * b - c} @tab @code{msub.ps}
14843 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
14844 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
14845 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
14848 Note that the multiply-accumulate instructions can be disabled
14849 using the command-line option @code{-mno-fused-madd}.
14851 @node Paired-Single Built-in Functions
14852 @subsubsection Paired-Single Built-in Functions
14854 The following paired-single functions map directly to a particular
14855 MIPS instruction. Please refer to the architecture specification
14856 for details on what each instruction does.
14859 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
14860 Pair lower lower (@code{pll.ps}).
14862 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
14863 Pair upper lower (@code{pul.ps}).
14865 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
14866 Pair lower upper (@code{plu.ps}).
14868 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
14869 Pair upper upper (@code{puu.ps}).
14871 @item v2sf __builtin_mips_cvt_ps_s (float, float)
14872 Convert pair to paired single (@code{cvt.ps.s}).
14874 @item float __builtin_mips_cvt_s_pl (v2sf)
14875 Convert pair lower to single (@code{cvt.s.pl}).
14877 @item float __builtin_mips_cvt_s_pu (v2sf)
14878 Convert pair upper to single (@code{cvt.s.pu}).
14880 @item v2sf __builtin_mips_abs_ps (v2sf)
14881 Absolute value (@code{abs.ps}).
14883 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
14884 Align variable (@code{alnv.ps}).
14886 @emph{Note:} The value of the third parameter must be 0 or 4
14887 modulo 8, otherwise the result is unpredictable. Please read the
14888 instruction description for details.
14891 The following multi-instruction functions are also available.
14892 In each case, @var{cond} can be any of the 16 floating-point conditions:
14893 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14894 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
14895 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14898 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14899 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14900 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
14901 @code{movt.ps}/@code{movf.ps}).
14903 The @code{movt} functions return the value @var{x} computed by:
14906 c.@var{cond}.ps @var{cc},@var{a},@var{b}
14907 mov.ps @var{x},@var{c}
14908 movt.ps @var{x},@var{d},@var{cc}
14911 The @code{movf} functions are similar but use @code{movf.ps} instead
14914 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14915 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14916 Comparison of two paired-single values (@code{c.@var{cond}.ps},
14917 @code{bc1t}/@code{bc1f}).
14919 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14920 and return either the upper or lower half of the result. For example:
14924 if (__builtin_mips_upper_c_eq_ps (a, b))
14925 upper_halves_are_equal ();
14927 upper_halves_are_unequal ();
14929 if (__builtin_mips_lower_c_eq_ps (a, b))
14930 lower_halves_are_equal ();
14932 lower_halves_are_unequal ();
14936 @node MIPS-3D Built-in Functions
14937 @subsubsection MIPS-3D Built-in Functions
14939 The MIPS-3D Application-Specific Extension (ASE) includes additional
14940 paired-single instructions that are designed to improve the performance
14941 of 3D graphics operations. Support for these instructions is controlled
14942 by the @option{-mips3d} command-line option.
14944 The functions listed below map directly to a particular MIPS-3D
14945 instruction. Please refer to the architecture specification for
14946 more details on what each instruction does.
14949 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
14950 Reduction add (@code{addr.ps}).
14952 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
14953 Reduction multiply (@code{mulr.ps}).
14955 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
14956 Convert paired single to paired word (@code{cvt.pw.ps}).
14958 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
14959 Convert paired word to paired single (@code{cvt.ps.pw}).
14961 @item float __builtin_mips_recip1_s (float)
14962 @itemx double __builtin_mips_recip1_d (double)
14963 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
14964 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
14966 @item float __builtin_mips_recip2_s (float, float)
14967 @itemx double __builtin_mips_recip2_d (double, double)
14968 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
14969 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
14971 @item float __builtin_mips_rsqrt1_s (float)
14972 @itemx double __builtin_mips_rsqrt1_d (double)
14973 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
14974 Reduced-precision reciprocal square root (sequence step 1)
14975 (@code{rsqrt1.@var{fmt}}).
14977 @item float __builtin_mips_rsqrt2_s (float, float)
14978 @itemx double __builtin_mips_rsqrt2_d (double, double)
14979 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
14980 Reduced-precision reciprocal square root (sequence step 2)
14981 (@code{rsqrt2.@var{fmt}}).
14984 The following multi-instruction functions are also available.
14985 In each case, @var{cond} can be any of the 16 floating-point conditions:
14986 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14987 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
14988 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14991 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
14992 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
14993 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
14994 @code{bc1t}/@code{bc1f}).
14996 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
14997 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
15002 if (__builtin_mips_cabs_eq_s (a, b))
15008 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15009 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15010 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
15011 @code{bc1t}/@code{bc1f}).
15013 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
15014 and return either the upper or lower half of the result. For example:
15018 if (__builtin_mips_upper_cabs_eq_ps (a, b))
15019 upper_halves_are_equal ();
15021 upper_halves_are_unequal ();
15023 if (__builtin_mips_lower_cabs_eq_ps (a, b))
15024 lower_halves_are_equal ();
15026 lower_halves_are_unequal ();
15029 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15030 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15031 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
15032 @code{movt.ps}/@code{movf.ps}).
15034 The @code{movt} functions return the value @var{x} computed by:
15037 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
15038 mov.ps @var{x},@var{c}
15039 movt.ps @var{x},@var{d},@var{cc}
15042 The @code{movf} functions are similar but use @code{movf.ps} instead
15045 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15046 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15047 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15048 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15049 Comparison of two paired-single values
15050 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
15051 @code{bc1any2t}/@code{bc1any2f}).
15053 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
15054 or @code{cabs.@var{cond}.ps}. The @code{any} forms return @code{true} if either
15055 result is @code{true} and the @code{all} forms return @code{true} if both results are @code{true}.
15060 if (__builtin_mips_any_c_eq_ps (a, b))
15065 if (__builtin_mips_all_c_eq_ps (a, b))
15071 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15072 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15073 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15074 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15075 Comparison of four paired-single values
15076 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
15077 @code{bc1any4t}/@code{bc1any4f}).
15079 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
15080 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
15081 The @code{any} forms return @code{true} if any of the four results are @code{true}
15082 and the @code{all} forms return @code{true} if all four results are @code{true}.
15087 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
15092 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
15099 @node MIPS SIMD Architecture (MSA) Support
15100 @subsection MIPS SIMD Architecture (MSA) Support
15103 * MIPS SIMD Architecture Built-in Functions::
15106 GCC provides intrinsics to access the SIMD instructions provided by the
15107 MSA MIPS SIMD Architecture. The interface is made available by including
15108 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
15109 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
15112 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
15113 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
15114 data elements. The following vectors typedefs are included in @code{msa.h}:
15116 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
15117 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
15118 @item @code{v8i16}, a vector of eight signed 16-bit integers;
15119 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
15120 @item @code{v4i32}, a vector of four signed 32-bit integers;
15121 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
15122 @item @code{v2i64}, a vector of two signed 64-bit integers;
15123 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
15124 @item @code{v4f32}, a vector of four 32-bit floats;
15125 @item @code{v2f64}, a vector of two 64-bit doubles.
15128 Instructions and corresponding built-ins may have additional restrictions and/or
15129 input/output values manipulated:
15131 @item @code{imm0_1}, an integer literal in range 0 to 1;
15132 @item @code{imm0_3}, an integer literal in range 0 to 3;
15133 @item @code{imm0_7}, an integer literal in range 0 to 7;
15134 @item @code{imm0_15}, an integer literal in range 0 to 15;
15135 @item @code{imm0_31}, an integer literal in range 0 to 31;
15136 @item @code{imm0_63}, an integer literal in range 0 to 63;
15137 @item @code{imm0_255}, an integer literal in range 0 to 255;
15138 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
15139 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
15140 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
15141 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
15142 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
15143 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
15144 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
15145 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
15146 @item @code{imm1_4}, an integer literal in range 1 to 4;
15147 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
15153 #if __LONG_MAX__ == __LONG_LONG_MAX__
15156 typedef long long i64;
15159 typedef unsigned int u32;
15160 #if __LONG_MAX__ == __LONG_LONG_MAX__
15161 typedef unsigned long u64;
15163 typedef unsigned long long u64;
15166 typedef double f64;
15171 @node MIPS SIMD Architecture Built-in Functions
15172 @subsubsection MIPS SIMD Architecture Built-in Functions
15174 The intrinsics provided are listed below; each is named after the
15175 machine instruction.
15178 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
15179 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
15180 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
15181 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
15183 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
15184 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
15185 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
15186 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
15188 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
15189 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
15190 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
15191 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
15193 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
15194 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
15195 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
15196 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
15198 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
15199 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
15200 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
15201 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
15203 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
15204 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
15205 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
15206 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
15208 v16u8 __builtin_msa_and_v (v16u8, v16u8);
15210 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
15212 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
15213 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
15214 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
15215 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
15217 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
15218 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
15219 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
15220 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
15222 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
15223 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
15224 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
15225 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
15227 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
15228 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
15229 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
15230 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
15232 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
15233 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
15234 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
15235 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
15237 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
15238 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
15239 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
15240 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
15242 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
15243 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
15244 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
15245 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
15247 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
15248 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
15249 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
15250 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
15252 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
15253 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
15254 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
15255 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
15257 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
15258 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
15259 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
15260 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
15262 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
15263 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
15264 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
15265 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
15267 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
15268 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
15269 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
15270 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
15272 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
15274 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
15276 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
15278 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
15280 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
15281 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
15282 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
15283 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
15285 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
15286 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
15287 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
15288 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
15290 i32 __builtin_msa_bnz_b (v16u8);
15291 i32 __builtin_msa_bnz_h (v8u16);
15292 i32 __builtin_msa_bnz_w (v4u32);
15293 i32 __builtin_msa_bnz_d (v2u64);
15295 i32 __builtin_msa_bnz_v (v16u8);
15297 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
15299 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
15301 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
15302 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
15303 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
15304 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
15306 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
15307 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
15308 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
15309 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
15311 i32 __builtin_msa_bz_b (v16u8);
15312 i32 __builtin_msa_bz_h (v8u16);
15313 i32 __builtin_msa_bz_w (v4u32);
15314 i32 __builtin_msa_bz_d (v2u64);
15316 i32 __builtin_msa_bz_v (v16u8);
15318 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
15319 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
15320 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
15321 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
15323 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
15324 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
15325 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
15326 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
15328 i32 __builtin_msa_cfcmsa (imm0_31);
15330 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
15331 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
15332 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
15333 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
15335 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
15336 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
15337 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
15338 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
15340 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
15341 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
15342 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
15343 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
15345 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
15346 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
15347 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
15348 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
15350 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
15351 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
15352 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
15353 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
15355 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
15356 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
15357 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
15358 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
15360 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
15361 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
15362 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
15363 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
15365 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
15366 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
15367 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
15368 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
15370 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
15371 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
15372 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
15373 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
15375 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
15376 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
15377 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
15378 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
15380 void __builtin_msa_ctcmsa (imm0_31, i32);
15382 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
15383 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
15384 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
15385 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
15387 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
15388 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
15389 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
15390 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
15392 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
15393 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
15394 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
15396 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
15397 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
15398 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
15400 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
15401 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
15402 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
15404 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
15405 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
15406 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
15408 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
15409 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
15410 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
15412 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
15413 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
15414 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
15416 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
15417 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
15419 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
15420 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
15422 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
15423 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
15425 v4i32 __builtin_msa_fclass_w (v4f32);
15426 v2i64 __builtin_msa_fclass_d (v2f64);
15428 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
15429 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
15431 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
15432 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
15434 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
15435 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
15437 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
15438 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
15440 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
15441 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
15443 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
15444 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
15446 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
15447 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
15449 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
15450 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
15452 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
15453 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
15455 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
15456 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
15458 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
15459 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
15461 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
15462 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
15464 v4f32 __builtin_msa_fexupl_w (v8i16);
15465 v2f64 __builtin_msa_fexupl_d (v4f32);
15467 v4f32 __builtin_msa_fexupr_w (v8i16);
15468 v2f64 __builtin_msa_fexupr_d (v4f32);
15470 v4f32 __builtin_msa_ffint_s_w (v4i32);
15471 v2f64 __builtin_msa_ffint_s_d (v2i64);
15473 v4f32 __builtin_msa_ffint_u_w (v4u32);
15474 v2f64 __builtin_msa_ffint_u_d (v2u64);
15476 v4f32 __builtin_msa_ffql_w (v8i16);
15477 v2f64 __builtin_msa_ffql_d (v4i32);
15479 v4f32 __builtin_msa_ffqr_w (v8i16);
15480 v2f64 __builtin_msa_ffqr_d (v4i32);
15482 v16i8 __builtin_msa_fill_b (i32);
15483 v8i16 __builtin_msa_fill_h (i32);
15484 v4i32 __builtin_msa_fill_w (i32);
15485 v2i64 __builtin_msa_fill_d (i64);
15487 v4f32 __builtin_msa_flog2_w (v4f32);
15488 v2f64 __builtin_msa_flog2_d (v2f64);
15490 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
15491 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
15493 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
15494 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
15496 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
15497 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
15499 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
15500 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
15502 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
15503 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
15505 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
15506 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
15508 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
15509 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
15511 v4f32 __builtin_msa_frint_w (v4f32);
15512 v2f64 __builtin_msa_frint_d (v2f64);
15514 v4f32 __builtin_msa_frcp_w (v4f32);
15515 v2f64 __builtin_msa_frcp_d (v2f64);
15517 v4f32 __builtin_msa_frsqrt_w (v4f32);
15518 v2f64 __builtin_msa_frsqrt_d (v2f64);
15520 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
15521 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
15523 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
15524 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
15526 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
15527 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
15529 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
15530 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
15532 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
15533 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
15535 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
15536 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
15538 v4f32 __builtin_msa_fsqrt_w (v4f32);
15539 v2f64 __builtin_msa_fsqrt_d (v2f64);
15541 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
15542 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
15544 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
15545 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
15547 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
15548 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
15550 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
15551 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
15553 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
15554 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
15556 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
15557 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
15559 v4i32 __builtin_msa_ftint_s_w (v4f32);
15560 v2i64 __builtin_msa_ftint_s_d (v2f64);
15562 v4u32 __builtin_msa_ftint_u_w (v4f32);
15563 v2u64 __builtin_msa_ftint_u_d (v2f64);
15565 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
15566 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
15568 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
15569 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
15571 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
15572 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
15574 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
15575 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
15576 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
15578 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
15579 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
15580 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
15582 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
15583 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
15584 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
15586 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
15587 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
15588 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
15590 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
15591 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
15592 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
15593 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
15595 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
15596 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
15597 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
15598 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
15600 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
15601 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
15602 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
15603 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
15605 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
15606 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
15607 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
15608 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
15610 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
15611 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
15612 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
15613 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
15615 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
15616 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
15617 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
15618 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
15620 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
15621 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
15622 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
15623 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
15625 v16i8 __builtin_msa_ldi_b (imm_n512_511);
15626 v8i16 __builtin_msa_ldi_h (imm_n512_511);
15627 v4i32 __builtin_msa_ldi_w (imm_n512_511);
15628 v2i64 __builtin_msa_ldi_d (imm_n512_511);
15630 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
15631 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
15633 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
15634 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
15636 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
15637 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
15638 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
15639 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
15641 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
15642 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
15643 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
15644 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
15646 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
15647 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
15648 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
15649 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
15651 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
15652 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
15653 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
15654 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
15656 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
15657 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
15658 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
15659 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
15661 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
15662 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
15663 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
15664 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
15666 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
15667 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
15668 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
15669 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
15671 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
15672 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
15673 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
15674 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
15676 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
15677 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
15678 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
15679 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
15681 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
15682 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
15683 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
15684 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
15686 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
15687 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
15688 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
15689 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
15691 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
15692 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
15693 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
15694 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
15696 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
15697 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
15698 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
15699 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
15701 v16i8 __builtin_msa_move_v (v16i8);
15703 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
15704 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
15706 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
15707 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
15709 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
15710 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
15711 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
15712 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
15714 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
15715 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
15717 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
15718 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
15720 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
15721 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
15722 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
15723 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
15725 v16i8 __builtin_msa_nloc_b (v16i8);
15726 v8i16 __builtin_msa_nloc_h (v8i16);
15727 v4i32 __builtin_msa_nloc_w (v4i32);
15728 v2i64 __builtin_msa_nloc_d (v2i64);
15730 v16i8 __builtin_msa_nlzc_b (v16i8);
15731 v8i16 __builtin_msa_nlzc_h (v8i16);
15732 v4i32 __builtin_msa_nlzc_w (v4i32);
15733 v2i64 __builtin_msa_nlzc_d (v2i64);
15735 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
15737 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
15739 v16u8 __builtin_msa_or_v (v16u8, v16u8);
15741 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
15743 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
15744 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
15745 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
15746 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
15748 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
15749 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
15750 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
15751 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
15753 v16i8 __builtin_msa_pcnt_b (v16i8);
15754 v8i16 __builtin_msa_pcnt_h (v8i16);
15755 v4i32 __builtin_msa_pcnt_w (v4i32);
15756 v2i64 __builtin_msa_pcnt_d (v2i64);
15758 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
15759 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
15760 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
15761 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
15763 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
15764 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
15765 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
15766 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
15768 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
15769 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
15770 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
15772 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
15773 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
15774 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
15775 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
15777 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
15778 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
15779 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
15780 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
15782 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
15783 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
15784 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
15785 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
15787 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
15788 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
15789 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
15790 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
15792 v16i8 __builtin_msa_splat_b (v16i8, i32);
15793 v8i16 __builtin_msa_splat_h (v8i16, i32);
15794 v4i32 __builtin_msa_splat_w (v4i32, i32);
15795 v2i64 __builtin_msa_splat_d (v2i64, i32);
15797 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
15798 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
15799 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
15800 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
15802 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
15803 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
15804 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
15805 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
15807 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
15808 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
15809 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
15810 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
15812 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
15813 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
15814 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
15815 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
15817 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
15818 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
15819 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
15820 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
15822 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
15823 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
15824 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
15825 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
15827 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
15828 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
15829 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
15830 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
15832 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
15833 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
15834 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
15835 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
15837 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
15838 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
15839 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
15840 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
15842 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
15843 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
15844 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
15845 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
15847 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
15848 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
15849 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
15850 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
15852 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
15853 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
15854 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
15855 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
15857 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
15858 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
15859 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
15860 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
15862 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
15863 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
15864 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
15865 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
15867 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
15868 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
15869 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
15870 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
15872 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
15873 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
15874 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
15875 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
15877 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
15878 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
15879 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
15880 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
15882 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
15884 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
15887 @node Other MIPS Built-in Functions
15888 @subsection Other MIPS Built-in Functions
15890 GCC provides other MIPS-specific built-in functions:
15893 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
15894 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
15895 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
15896 when this function is available.
15898 @item unsigned int __builtin_mips_get_fcsr (void)
15899 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
15900 Get and set the contents of the floating-point control and status register
15901 (FPU control register 31). These functions are only available in hard-float
15902 code but can be called in both MIPS16 and non-MIPS16 contexts.
15904 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
15905 register except the condition codes, which GCC assumes are preserved.
15908 @node MSP430 Built-in Functions
15909 @subsection MSP430 Built-in Functions
15911 GCC provides a couple of special builtin functions to aid in the
15912 writing of interrupt handlers in C.
15915 @item __bic_SR_register_on_exit (int @var{mask})
15916 This clears the indicated bits in the saved copy of the status register
15917 currently residing on the stack. This only works inside interrupt
15918 handlers and the changes to the status register will only take affect
15919 once the handler returns.
15921 @item __bis_SR_register_on_exit (int @var{mask})
15922 This sets the indicated bits in the saved copy of the status register
15923 currently residing on the stack. This only works inside interrupt
15924 handlers and the changes to the status register will only take affect
15925 once the handler returns.
15927 @item __delay_cycles (long long @var{cycles})
15928 This inserts an instruction sequence that takes exactly @var{cycles}
15929 cycles (between 0 and about 17E9) to complete. The inserted sequence
15930 may use jumps, loops, or no-ops, and does not interfere with any other
15931 instructions. Note that @var{cycles} must be a compile-time constant
15932 integer - that is, you must pass a number, not a variable that may be
15933 optimized to a constant later. The number of cycles delayed by this
15937 @node NDS32 Built-in Functions
15938 @subsection NDS32 Built-in Functions
15940 These built-in functions are available for the NDS32 target:
15942 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
15943 Insert an ISYNC instruction into the instruction stream where
15944 @var{addr} is an instruction address for serialization.
15947 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
15948 Insert an ISB instruction into the instruction stream.
15951 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
15952 Return the content of a system register which is mapped by @var{sr}.
15955 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
15956 Return the content of a user space register which is mapped by @var{usr}.
15959 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
15960 Move the @var{value} to a system register which is mapped by @var{sr}.
15963 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
15964 Move the @var{value} to a user space register which is mapped by @var{usr}.
15967 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
15968 Enable global interrupt.
15971 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
15972 Disable global interrupt.
15975 @node picoChip Built-in Functions
15976 @subsection picoChip Built-in Functions
15978 GCC provides an interface to selected machine instructions from the
15979 picoChip instruction set.
15982 @item int __builtin_sbc (int @var{value})
15983 Sign bit count. Return the number of consecutive bits in @var{value}
15984 that have the same value as the sign bit. The result is the number of
15985 leading sign bits minus one, giving the number of redundant sign bits in
15988 @item int __builtin_byteswap (int @var{value})
15989 Byte swap. Return the result of swapping the upper and lower bytes of
15992 @item int __builtin_brev (int @var{value})
15993 Bit reversal. Return the result of reversing the bits in
15994 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
15997 @item int __builtin_adds (int @var{x}, int @var{y})
15998 Saturating addition. Return the result of adding @var{x} and @var{y},
15999 storing the value 32767 if the result overflows.
16001 @item int __builtin_subs (int @var{x}, int @var{y})
16002 Saturating subtraction. Return the result of subtracting @var{y} from
16003 @var{x}, storing the value @minus{}32768 if the result overflows.
16005 @item void __builtin_halt (void)
16006 Halt. The processor stops execution. This built-in is useful for
16007 implementing assertions.
16011 @node Basic PowerPC Built-in Functions
16012 @subsection Basic PowerPC Built-in Functions
16015 * Basic PowerPC Built-in Functions Available on all Configurations::
16016 * Basic PowerPC Built-in Functions Available on ISA 2.05::
16017 * Basic PowerPC Built-in Functions Available on ISA 2.06::
16018 * Basic PowerPC Built-in Functions Available on ISA 2.07::
16019 * Basic PowerPC Built-in Functions Available on ISA 3.0::
16022 This section describes PowerPC built-in functions that do not require
16023 the inclusion of any special header files to declare prototypes or
16024 provide macro definitions. The sections that follow describe
16025 additional PowerPC built-in functions.
16027 @node Basic PowerPC Built-in Functions Available on all Configurations
16028 @subsubsection Basic PowerPC Built-in Functions Available on all Configurations
16030 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
16031 This function is a @code{nop} on the PowerPC platform and is included solely
16032 to maintain API compatibility with the x86 builtins.
16035 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
16036 This function returns a value of @code{1} if the run-time CPU is of type
16037 @var{cpuname} and returns @code{0} otherwise
16039 The @code{__builtin_cpu_is} function requires GLIBC 2.23 or newer
16040 which exports the hardware capability bits. GCC defines the macro
16041 @code{__BUILTIN_CPU_SUPPORTS__} if the @code{__builtin_cpu_supports}
16042 built-in function is fully supported.
16044 If GCC was configured to use a GLIBC before 2.23, the built-in
16045 function @code{__builtin_cpu_is} always returns a 0 and the compiler
16048 The following CPU names can be detected:
16052 IBM POWER9 Server CPU.
16054 IBM POWER8 Server CPU.
16056 IBM POWER7 Server CPU.
16058 IBM POWER6 Server CPU (RAW mode).
16060 IBM POWER6 Server CPU (Architected mode).
16062 IBM POWER5+ Server CPU.
16064 IBM POWER5 Server CPU.
16066 IBM 970 Server CPU (ie, Apple G5).
16068 IBM POWER4 Server CPU.
16070 IBM A2 64-bit Embedded CPU
16072 IBM PowerPC 476FP 32-bit Embedded CPU.
16074 IBM PowerPC 464 32-bit Embedded CPU.
16076 PowerPC 440 32-bit Embedded CPU.
16078 PowerPC 405 32-bit Embedded CPU.
16080 IBM PowerPC Cell Broadband Engine Architecture CPU.
16083 Here is an example:
16085 #ifdef __BUILTIN_CPU_SUPPORTS__
16086 if (__builtin_cpu_is ("power8"))
16088 do_power8 (); // POWER8 specific implementation.
16093 do_generic (); // Generic implementation.
16098 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
16099 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
16100 feature @var{feature} and returns @code{0} otherwise.
16102 The @code{__builtin_cpu_supports} function requires GLIBC 2.23 or
16103 newer which exports the hardware capability bits. GCC defines the
16104 macro @code{__BUILTIN_CPU_SUPPORTS__} if the
16105 @code{__builtin_cpu_supports} built-in function is fully supported.
16107 If GCC was configured to use a GLIBC before 2.23, the built-in
16108 function @code{__builtin_cpu_suports} always returns a 0 and the
16109 compiler issues a warning.
16111 The following features can be
16116 4xx CPU has a Multiply Accumulator.
16118 CPU has a SIMD/Vector Unit.
16120 CPU supports ISA 2.05 (eg, POWER6)
16122 CPU supports ISA 2.06 (eg, POWER7)
16124 CPU supports ISA 2.07 (eg, POWER8)
16126 CPU supports ISA 3.0 (eg, POWER9)
16128 CPU supports the set of compatible performance monitoring events.
16130 CPU supports the Embedded ISA category.
16132 CPU has a CELL broadband engine.
16134 CPU supports the @code{darn} (deliver a random number) instruction.
16136 CPU has a decimal floating point unit.
16138 CPU supports the data stream control register.
16140 CPU supports event base branching.
16142 CPU has a SPE double precision floating point unit.
16144 CPU has a SPE single precision floating point unit.
16146 CPU has a floating point unit.
16148 CPU has hardware transaction memory instructions.
16150 Kernel aborts hardware transactions when a syscall is made.
16151 @item htm-no-suspend
16152 CPU supports hardware transaction memory but does not support the
16153 @code{tsuspend.} instruction.
16155 CPU supports icache snooping capabilities.
16157 CPU supports 128-bit IEEE binary floating point instructions.
16159 CPU supports the integer select instruction.
16161 CPU has a memory management unit.
16163 CPU does not have a timebase (eg, 601 and 403gx).
16165 CPU supports the PA Semi 6T CORE ISA.
16167 CPU supports ISA 2.00 (eg, POWER4)
16169 CPU supports ISA 2.02 (eg, POWER5)
16171 CPU supports ISA 2.03 (eg, POWER5+)
16173 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
16175 CPU supports 32-bit mode execution.
16177 CPU supports the old POWER ISA (eg, 601)
16179 CPU supports 64-bit mode execution.
16181 CPU supports a little-endian mode that uses address swizzling.
16183 Kernel supports system call vectored.
16185 CPU support simultaneous multi-threading.
16187 CPU has a signal processing extension unit.
16189 CPU supports the target address register.
16191 CPU supports true little-endian mode.
16193 CPU has unified I/D cache.
16195 CPU supports the vector cryptography instructions.
16197 CPU supports the vector-scalar extension.
16200 Here is an example:
16202 #ifdef __BUILTIN_CPU_SUPPORTS__
16203 if (__builtin_cpu_supports ("fpu"))
16205 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
16210 dst = __fadd (src1, src2); // Software FP addition function.
16215 The following built-in functions are also available on all PowerPC
16218 uint64_t __builtin_ppc_get_timebase ();
16219 unsigned long __builtin_ppc_mftb ();
16220 double __builtin_unpack_ibm128 (__ibm128, int);
16221 __ibm128 __builtin_pack_ibm128 (double, double);
16222 double __builtin_mffs (void);
16223 void __builtin_mtfsb0 (const int);
16224 void __builtin_mtfsb1 (const int);
16225 void __builtin_set_fpscr_rn (int);
16228 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
16229 functions generate instructions to read the Time Base Register. The
16230 @code{__builtin_ppc_get_timebase} function may generate multiple
16231 instructions and always returns the 64 bits of the Time Base Register.
16232 The @code{__builtin_ppc_mftb} function always generates one instruction and
16233 returns the Time Base Register value as an unsigned long, throwing away
16234 the most significant word on 32-bit environments. The @code{__builtin_mffs}
16235 return the value of the FPSCR register. Note, ISA 3.0 supports the
16236 @code{__builtin_mffsl()} which permits software to read the control and
16237 non-sticky status bits in the FSPCR without the higher latency associated with
16238 accessing the sticky status bits. The
16239 @code{__builtin_mtfsb0} and @code{__builtin_mtfsb1} take the bit to change
16240 as an argument. The valid bit range is between 0 and 31. The builtins map to
16241 the @code{mtfsb0} and @code{mtfsb1} instructions which take the argument and
16242 add 32. Hence these instructions only modify the FPSCR[32:63] bits by
16243 changing the specified bit to a zero or one respectively. The
16244 @code{__builtin_set_fpscr_rn} builtin allows changing both of the floating
16245 point rounding mode bits. The argument is a 2-bit value. The argument can
16246 either be a @code{const int} or stored in a variable. The builtin uses
16248 instruction @code{mffscrn} if available, otherwise it reads the FPSCR, masks
16249 the current rounding mode bits out and OR's in the new value.
16251 @node Basic PowerPC Built-in Functions Available on ISA 2.05
16252 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.05
16254 The basic built-in functions described in this section are
16255 available on the PowerPC family of processors starting with ISA 2.05
16256 or later. Unless specific options are explicitly disabled on the
16257 command line, specifying option @option{-mcpu=power6} has the effect of
16258 enabling the @option{-mpowerpc64}, @option{-mpowerpc-gpopt},
16259 @option{-mpowerpc-gfxopt}, @option{-mmfcrf}, @option{-mpopcntb},
16260 @option{-mfprnd}, @option{-mcmpb}, @option{-mhard-dfp}, and
16261 @option{-mrecip-precision} options. Specify the
16262 @option{-maltivec} and @option{-mfpgpr} options explicitly in
16263 combination with the above options if they are desired.
16265 The following functions require option @option{-mcmpb}.
16267 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
16268 unsigned int __builtin_cmpb (unsigned int, unsigned int);
16271 The @code{__builtin_cmpb} function
16272 performs a byte-wise compare on the contents of its two arguments,
16273 returning the result of the byte-wise comparison as the returned
16274 value. For each byte comparison, the corresponding byte of the return
16275 value holds 0xff if the input bytes are equal and 0 if the input bytes
16276 are not equal. If either of the arguments to this built-in function
16277 is wider than 32 bits, the function call expands into the form that
16278 expects @code{unsigned long long int} arguments
16279 which is only available on 64-bit targets.
16281 The following built-in functions are available
16282 when hardware decimal floating point
16283 (@option{-mhard-dfp}) is available:
16285 void __builtin_set_fpscr_drn(int);
16286 _Decimal64 __builtin_ddedpd (int, _Decimal64);
16287 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
16288 _Decimal64 __builtin_denbcd (int, _Decimal64);
16289 _Decimal128 __builtin_denbcdq (int, _Decimal128);
16290 _Decimal64 __builtin_diex (long long, _Decimal64);
16291 _Decimal128 _builtin_diexq (long long, _Decimal128);
16292 _Decimal64 __builtin_dscli (_Decimal64, int);
16293 _Decimal128 __builtin_dscliq (_Decimal128, int);
16294 _Decimal64 __builtin_dscri (_Decimal64, int);
16295 _Decimal128 __builtin_dscriq (_Decimal128, int);
16296 long long __builtin_dxex (_Decimal64);
16297 long long __builtin_dxexq (_Decimal128);
16298 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
16299 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
16301 The @code{__builtin_set_fpscr_drn} builtin allows changing the three decimal
16302 floating point rounding mode bits. The argument is a 3-bit value. The
16303 argument can either be a @code{const int} or the value can be stored in
16305 The builtin uses the ISA 3.0 instruction @code{mffscdrn} if available.
16306 Otherwise the builtin reads the FPSCR, masks the current decimal rounding
16307 mode bits out and OR's in the new value.
16311 The following functions require @option{-mhard-float},
16312 @option{-mpowerpc-gfxopt}, and @option{-mpopcntb} options.
16315 double __builtin_recipdiv (double, double);
16316 float __builtin_recipdivf (float, float);
16317 double __builtin_rsqrt (double);
16318 float __builtin_rsqrtf (float);
16321 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
16322 @code{__builtin_rsqrtf} functions generate multiple instructions to
16323 implement the reciprocal sqrt functionality using reciprocal sqrt
16324 estimate instructions.
16326 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
16327 functions generate multiple instructions to implement division using
16328 the reciprocal estimate instructions.
16330 The following functions require @option{-mhard-float} and
16331 @option{-mmultiple} options.
16333 The @code{__builtin_unpack_longdouble} function takes a
16334 @code{long double} argument and a compile time constant of 0 or 1. If
16335 the constant is 0, the first @code{double} within the
16336 @code{long double} is returned, otherwise the second @code{double}
16337 is returned. The @code{__builtin_unpack_longdouble} function is only
16338 available if @code{long double} uses the IBM extended double
16341 The @code{__builtin_pack_longdouble} function takes two @code{double}
16342 arguments and returns a @code{long double} value that combines the two
16343 arguments. The @code{__builtin_pack_longdouble} function is only
16344 available if @code{long double} uses the IBM extended double
16347 The @code{__builtin_unpack_ibm128} function takes a @code{__ibm128}
16348 argument and a compile time constant of 0 or 1. If the constant is 0,
16349 the first @code{double} within the @code{__ibm128} is returned,
16350 otherwise the second @code{double} is returned.
16352 The @code{__builtin_pack_ibm128} function takes two @code{double}
16353 arguments and returns a @code{__ibm128} value that combines the two
16356 Additional built-in functions are available for the 64-bit PowerPC
16357 family of processors, for efficient use of 128-bit floating point
16358 (@code{__float128}) values.
16360 @node Basic PowerPC Built-in Functions Available on ISA 2.06
16361 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.06
16363 The basic built-in functions described in this section are
16364 available on the PowerPC family of processors starting with ISA 2.05
16365 or later. Unless specific options are explicitly disabled on the
16366 command line, specifying option @option{-mcpu=power7} has the effect of
16367 enabling all the same options as for @option{-mcpu=power6} in
16368 addition to the @option{-maltivec}, @option{-mpopcntd}, and
16369 @option{-mvsx} options.
16371 The following basic built-in functions require @option{-mpopcntd}:
16373 unsigned int __builtin_addg6s (unsigned int, unsigned int);
16374 long long __builtin_bpermd (long long, long long);
16375 unsigned int __builtin_cbcdtd (unsigned int);
16376 unsigned int __builtin_cdtbcd (unsigned int);
16377 long long __builtin_divde (long long, long long);
16378 unsigned long long __builtin_divdeu (unsigned long long, unsigned long long);
16379 int __builtin_divwe (int, int);
16380 unsigned int __builtin_divweu (unsigned int, unsigned int);
16381 vector __int128 __builtin_pack_vector_int128 (long long, long long);
16382 void __builtin_rs6000_speculation_barrier (void);
16383 long long __builtin_unpack_vector_int128 (vector __int128, signed char);
16386 Of these, the @code{__builtin_divde} and @code{__builtin_divdeu} functions
16387 require a 64-bit environment.
16389 The following basic built-in functions, which are also supported on
16390 x86 targets, require @option{-mfloat128}.
16392 __float128 __builtin_fabsq (__float128);
16393 __float128 __builtin_copysignq (__float128, __float128);
16394 __float128 __builtin_infq (void);
16395 __float128 __builtin_huge_valq (void);
16396 __float128 __builtin_nanq (void);
16397 __float128 __builtin_nansq (void);
16399 __float128 __builtin_sqrtf128 (__float128);
16400 __float128 __builtin_fmaf128 (__float128, __float128, __float128);
16403 @node Basic PowerPC Built-in Functions Available on ISA 2.07
16404 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.07
16406 The basic built-in functions described in this section are
16407 available on the PowerPC family of processors starting with ISA 2.07
16408 or later. Unless specific options are explicitly disabled on the
16409 command line, specifying option @option{-mcpu=power8} has the effect of
16410 enabling all the same options as for @option{-mcpu=power7} in
16411 addition to the @option{-mpower8-fusion}, @option{-mpower8-vector},
16412 @option{-mcrypto}, @option{-mhtm}, @option{-mquad-memory}, and
16413 @option{-mquad-memory-atomic} options.
16415 This section intentionally empty.
16417 @node Basic PowerPC Built-in Functions Available on ISA 3.0
16418 @subsubsection Basic PowerPC Built-in Functions Available on ISA 3.0
16420 The basic built-in functions described in this section are
16421 available on the PowerPC family of processors starting with ISA 3.0
16422 or later. Unless specific options are explicitly disabled on the
16423 command line, specifying option @option{-mcpu=power9} has the effect of
16424 enabling all the same options as for @option{-mcpu=power8} in
16425 addition to the @option{-misel} option.
16427 The following built-in functions are available on Linux 64-bit systems
16428 that use the ISA 3.0 instruction set (@option{-mcpu=power9}):
16431 @item __float128 __builtin_addf128_round_to_odd (__float128, __float128)
16432 Perform a 128-bit IEEE floating point add using round to odd as the
16434 @findex __builtin_addf128_round_to_odd
16436 @item __float128 __builtin_subf128_round_to_odd (__float128, __float128)
16437 Perform a 128-bit IEEE floating point subtract using round to odd as
16439 @findex __builtin_subf128_round_to_odd
16441 @item __float128 __builtin_mulf128_round_to_odd (__float128, __float128)
16442 Perform a 128-bit IEEE floating point multiply using round to odd as
16444 @findex __builtin_mulf128_round_to_odd
16446 @item __float128 __builtin_divf128_round_to_odd (__float128, __float128)
16447 Perform a 128-bit IEEE floating point divide using round to odd as
16449 @findex __builtin_divf128_round_to_odd
16451 @item __float128 __builtin_sqrtf128_round_to_odd (__float128)
16452 Perform a 128-bit IEEE floating point square root using round to odd
16453 as the rounding mode.
16454 @findex __builtin_sqrtf128_round_to_odd
16456 @item __float128 __builtin_fmaf128_round_to_odd (__float128, __float128, __float128)
16457 Perform a 128-bit IEEE floating point fused multiply and add operation
16458 using round to odd as the rounding mode.
16459 @findex __builtin_fmaf128_round_to_odd
16461 @item double __builtin_truncf128_round_to_odd (__float128)
16462 Convert a 128-bit IEEE floating point value to @code{double} using
16463 round to odd as the rounding mode.
16464 @findex __builtin_truncf128_round_to_odd
16467 The following additional built-in functions are also available for the
16468 PowerPC family of processors, starting with ISA 3.0 or later:
16470 long long __builtin_darn (void);
16471 long long __builtin_darn_raw (void);
16472 int __builtin_darn_32 (void);
16475 The @code{__builtin_darn} and @code{__builtin_darn_raw}
16476 functions require a
16477 64-bit environment supporting ISA 3.0 or later.
16478 The @code{__builtin_darn} function provides a 64-bit conditioned
16479 random number. The @code{__builtin_darn_raw} function provides a
16480 64-bit raw random number. The @code{__builtin_darn_32} function
16481 provides a 32-bit conditioned random number.
16483 The following additional built-in functions are also available for the
16484 PowerPC family of processors, starting with ISA 3.0 or later:
16487 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
16488 int __builtin_byte_in_range (unsigned char u, unsigned int range);
16489 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
16491 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
16492 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
16493 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
16494 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
16496 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
16497 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
16498 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
16499 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
16501 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
16502 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
16503 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
16504 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
16506 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
16507 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
16508 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
16509 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
16511 double __builtin_mffsl(void);
16514 The @code{__builtin_byte_in_set} function requires a
16515 64-bit environment supporting ISA 3.0 or later. This function returns
16516 a non-zero value if and only if its @code{u} argument exactly equals one of
16517 the eight bytes contained within its 64-bit @code{set} argument.
16519 The @code{__builtin_byte_in_range} and
16520 @code{__builtin_byte_in_either_range} require an environment
16521 supporting ISA 3.0 or later. For these two functions, the
16522 @code{range} argument is encoded as 4 bytes, organized as
16523 @code{hi_1:lo_1:hi_2:lo_2}.
16524 The @code{__builtin_byte_in_range} function returns a
16525 non-zero value if and only if its @code{u} argument is within the
16526 range bounded between @code{lo_2} and @code{hi_2} inclusive.
16527 The @code{__builtin_byte_in_either_range} function returns non-zero if
16528 and only if its @code{u} argument is within either the range bounded
16529 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
16530 between @code{lo_2} and @code{hi_2} inclusive.
16532 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
16533 if and only if the number of signficant digits of its @code{value} argument
16534 is less than its @code{comparison} argument. The
16535 @code{__builtin_dfp_dtstsfi_lt_dd} and
16536 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
16537 require that the type of the @code{value} argument be
16538 @code{__Decimal64} and @code{__Decimal128} respectively.
16540 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
16541 if and only if the number of signficant digits of its @code{value} argument
16542 is greater than its @code{comparison} argument. The
16543 @code{__builtin_dfp_dtstsfi_gt_dd} and
16544 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
16545 require that the type of the @code{value} argument be
16546 @code{__Decimal64} and @code{__Decimal128} respectively.
16548 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
16549 if and only if the number of signficant digits of its @code{value} argument
16550 equals its @code{comparison} argument. The
16551 @code{__builtin_dfp_dtstsfi_eq_dd} and
16552 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
16553 require that the type of the @code{value} argument be
16554 @code{__Decimal64} and @code{__Decimal128} respectively.
16556 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
16557 if and only if its @code{value} argument has an undefined number of
16558 significant digits, such as when @code{value} is an encoding of @code{NaN}.
16559 The @code{__builtin_dfp_dtstsfi_ov_dd} and
16560 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
16561 require that the type of the @code{value} argument be
16562 @code{__Decimal64} and @code{__Decimal128} respectively.
16564 The @code{__builtin_mffsl} uses the ISA 3.0 @code{mffsl} instruction to read
16565 the FPSCR. The instruction is a lower latency version of the @code{mffs}
16566 instruction. If the @code{mffsl} instruction is not available, then the
16567 builtin uses the older @code{mffs} instruction to read the FPSCR.
16570 @node PowerPC AltiVec/VSX Built-in Functions
16571 @subsection PowerPC AltiVec/VSX Built-in Functions
16573 GCC provides an interface for the PowerPC family of processors to access
16574 the AltiVec operations described in Motorola's AltiVec Programming
16575 Interface Manual. The interface is made available by including
16576 @code{<altivec.h>} and using @option{-maltivec} and
16577 @option{-mabi=altivec}. The interface supports the following vector
16581 vector unsigned char
16585 vector unsigned short
16586 vector signed short
16590 vector unsigned int
16596 GCC's implementation of the high-level language interface available from
16597 C and C++ code differs from Motorola's documentation in several ways.
16602 A vector constant is a list of constant expressions within curly braces.
16605 A vector initializer requires no cast if the vector constant is of the
16606 same type as the variable it is initializing.
16609 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16610 vector type is the default signedness of the base type. The default
16611 varies depending on the operating system, so a portable program should
16612 always specify the signedness.
16615 Compiling with @option{-maltivec} adds keywords @code{__vector},
16616 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
16617 @code{bool}. When compiling ISO C, the context-sensitive substitution
16618 of the keywords @code{vector}, @code{pixel} and @code{bool} is
16619 disabled. To use them, you must include @code{<altivec.h>} instead.
16622 GCC allows using a @code{typedef} name as the type specifier for a
16623 vector type, but only under the following circumstances:
16628 When using @code{__vector} instead of @code{vector}; for example,
16631 typedef signed short int16;
16632 __vector int16 data;
16636 When using @code{vector} in keyword-and-predefine mode; for example,
16639 typedef signed short int16;
16643 Note that keyword-and-predefine mode is enabled by disabling GNU
16644 extensions (e.g., by using @code{-std=c11}) and including
16645 @code{<altivec.h>}.
16649 For C, overloaded functions are implemented with macros so the following
16653 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16657 Since @code{vec_add} is a macro, the vector constant in the example
16658 is treated as four separate arguments. Wrap the entire argument in
16659 parentheses for this to work.
16662 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
16663 Internally, GCC uses built-in functions to achieve the functionality in
16664 the aforementioned header file, but they are not supported and are
16665 subject to change without notice.
16667 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
16668 which may be found at
16669 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
16670 Appendix A of this document lists the vector API interfaces that must be
16671 provided by compliant compilers. Programmers should preferentially use
16672 the interfaces described therein. However, historically GCC has provided
16673 additional interfaces for access to vector instructions. These are
16674 briefly described below.
16677 * PowerPC AltiVec Built-in Functions on ISA 2.05::
16678 * PowerPC AltiVec Built-in Functions Available on ISA 2.06::
16679 * PowerPC AltiVec Built-in Functions Available on ISA 2.07::
16680 * PowerPC AltiVec Built-in Functions Available on ISA 3.0::
16683 @node PowerPC AltiVec Built-in Functions on ISA 2.05
16684 @subsubsection PowerPC AltiVec Built-in Functions on ISA 2.05
16686 The following interfaces are supported for the generic and specific
16687 AltiVec operations and the AltiVec predicates. In cases where there
16688 is a direct mapping between generic and specific operations, only the
16689 generic names are shown here, although the specific operations can also
16692 Arguments that are documented as @code{const int} require literal
16693 integral values within the range required for that operation.
16696 vector signed char vec_abs (vector signed char);
16697 vector signed short vec_abs (vector signed short);
16698 vector signed int vec_abs (vector signed int);
16699 vector float vec_abs (vector float);
16701 vector signed char vec_abss (vector signed char);
16702 vector signed short vec_abss (vector signed short);
16703 vector signed int vec_abss (vector signed int);
16705 vector signed char vec_add (vector bool char, vector signed char);
16706 vector signed char vec_add (vector signed char, vector bool char);
16707 vector signed char vec_add (vector signed char, vector signed char);
16708 vector unsigned char vec_add (vector bool char, vector unsigned char);
16709 vector unsigned char vec_add (vector unsigned char, vector bool char);
16710 vector unsigned char vec_add (vector unsigned char, vector unsigned char);
16711 vector signed short vec_add (vector bool short, vector signed short);
16712 vector signed short vec_add (vector signed short, vector bool short);
16713 vector signed short vec_add (vector signed short, vector signed short);
16714 vector unsigned short vec_add (vector bool short, vector unsigned short);
16715 vector unsigned short vec_add (vector unsigned short, vector bool short);
16716 vector unsigned short vec_add (vector unsigned short, vector unsigned short);
16717 vector signed int vec_add (vector bool int, vector signed int);
16718 vector signed int vec_add (vector signed int, vector bool int);
16719 vector signed int vec_add (vector signed int, vector signed int);
16720 vector unsigned int vec_add (vector bool int, vector unsigned int);
16721 vector unsigned int vec_add (vector unsigned int, vector bool int);
16722 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
16723 vector float vec_add (vector float, vector float);
16725 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
16727 vector unsigned char vec_adds (vector bool char, vector unsigned char);
16728 vector unsigned char vec_adds (vector unsigned char, vector bool char);
16729 vector unsigned char vec_adds (vector unsigned char, vector unsigned char);
16730 vector signed char vec_adds (vector bool char, vector signed char);
16731 vector signed char vec_adds (vector signed char, vector bool char);
16732 vector signed char vec_adds (vector signed char, vector signed char);
16733 vector unsigned short vec_adds (vector bool short, vector unsigned short);
16734 vector unsigned short vec_adds (vector unsigned short, vector bool short);
16735 vector unsigned short vec_adds (vector unsigned short, vector unsigned short);
16736 vector signed short vec_adds (vector bool short, vector signed short);
16737 vector signed short vec_adds (vector signed short, vector bool short);
16738 vector signed short vec_adds (vector signed short, vector signed short);
16739 vector unsigned int vec_adds (vector bool int, vector unsigned int);
16740 vector unsigned int vec_adds (vector unsigned int, vector bool int);
16741 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
16742 vector signed int vec_adds (vector bool int, vector signed int);
16743 vector signed int vec_adds (vector signed int, vector bool int);
16744 vector signed int vec_adds (vector signed int, vector signed int);
16746 int vec_all_eq (vector signed char, vector bool char);
16747 int vec_all_eq (vector signed char, vector signed char);
16748 int vec_all_eq (vector unsigned char, vector bool char);
16749 int vec_all_eq (vector unsigned char, vector unsigned char);
16750 int vec_all_eq (vector bool char, vector bool char);
16751 int vec_all_eq (vector bool char, vector unsigned char);
16752 int vec_all_eq (vector bool char, vector signed char);
16753 int vec_all_eq (vector signed short, vector bool short);
16754 int vec_all_eq (vector signed short, vector signed short);
16755 int vec_all_eq (vector unsigned short, vector bool short);
16756 int vec_all_eq (vector unsigned short, vector unsigned short);
16757 int vec_all_eq (vector bool short, vector bool short);
16758 int vec_all_eq (vector bool short, vector unsigned short);
16759 int vec_all_eq (vector bool short, vector signed short);
16760 int vec_all_eq (vector pixel, vector pixel);
16761 int vec_all_eq (vector signed int, vector bool int);
16762 int vec_all_eq (vector signed int, vector signed int);
16763 int vec_all_eq (vector unsigned int, vector bool int);
16764 int vec_all_eq (vector unsigned int, vector unsigned int);
16765 int vec_all_eq (vector bool int, vector bool int);
16766 int vec_all_eq (vector bool int, vector unsigned int);
16767 int vec_all_eq (vector bool int, vector signed int);
16768 int vec_all_eq (vector float, vector float);
16770 int vec_all_ge (vector bool char, vector unsigned char);
16771 int vec_all_ge (vector unsigned char, vector bool char);
16772 int vec_all_ge (vector unsigned char, vector unsigned char);
16773 int vec_all_ge (vector bool char, vector signed char);
16774 int vec_all_ge (vector signed char, vector bool char);
16775 int vec_all_ge (vector signed char, vector signed char);
16776 int vec_all_ge (vector bool short, vector unsigned short);
16777 int vec_all_ge (vector unsigned short, vector bool short);
16778 int vec_all_ge (vector unsigned short, vector unsigned short);
16779 int vec_all_ge (vector signed short, vector signed short);
16780 int vec_all_ge (vector bool short, vector signed short);
16781 int vec_all_ge (vector signed short, vector bool short);
16782 int vec_all_ge (vector bool int, vector unsigned int);
16783 int vec_all_ge (vector unsigned int, vector bool int);
16784 int vec_all_ge (vector unsigned int, vector unsigned int);
16785 int vec_all_ge (vector bool int, vector signed int);
16786 int vec_all_ge (vector signed int, vector bool int);
16787 int vec_all_ge (vector signed int, vector signed int);
16788 int vec_all_ge (vector float, vector float);
16790 int vec_all_gt (vector bool char, vector unsigned char);
16791 int vec_all_gt (vector unsigned char, vector bool char);
16792 int vec_all_gt (vector unsigned char, vector unsigned char);
16793 int vec_all_gt (vector bool char, vector signed char);
16794 int vec_all_gt (vector signed char, vector bool char);
16795 int vec_all_gt (vector signed char, vector signed char);
16796 int vec_all_gt (vector bool short, vector unsigned short);
16797 int vec_all_gt (vector unsigned short, vector bool short);
16798 int vec_all_gt (vector unsigned short, vector unsigned short);
16799 int vec_all_gt (vector bool short, vector signed short);
16800 int vec_all_gt (vector signed short, vector bool short);
16801 int vec_all_gt (vector signed short, vector signed short);
16802 int vec_all_gt (vector bool int, vector unsigned int);
16803 int vec_all_gt (vector unsigned int, vector bool int);
16804 int vec_all_gt (vector unsigned int, vector unsigned int);
16805 int vec_all_gt (vector bool int, vector signed int);
16806 int vec_all_gt (vector signed int, vector bool int);
16807 int vec_all_gt (vector signed int, vector signed int);
16808 int vec_all_gt (vector float, vector float);
16810 int vec_all_in (vector float, vector float);
16812 int vec_all_le (vector bool char, vector unsigned char);
16813 int vec_all_le (vector unsigned char, vector bool char);
16814 int vec_all_le (vector unsigned char, vector unsigned char);
16815 int vec_all_le (vector bool char, vector signed char);
16816 int vec_all_le (vector signed char, vector bool char);
16817 int vec_all_le (vector signed char, vector signed char);
16818 int vec_all_le (vector bool short, vector unsigned short);
16819 int vec_all_le (vector unsigned short, vector bool short);
16820 int vec_all_le (vector unsigned short, vector unsigned short);
16821 int vec_all_le (vector bool short, vector signed short);
16822 int vec_all_le (vector signed short, vector bool short);
16823 int vec_all_le (vector signed short, vector signed short);
16824 int vec_all_le (vector bool int, vector unsigned int);
16825 int vec_all_le (vector unsigned int, vector bool int);
16826 int vec_all_le (vector unsigned int, vector unsigned int);
16827 int vec_all_le (vector bool int, vector signed int);
16828 int vec_all_le (vector signed int, vector bool int);
16829 int vec_all_le (vector signed int, vector signed int);
16830 int vec_all_le (vector float, vector float);
16832 int vec_all_lt (vector bool char, vector unsigned char);
16833 int vec_all_lt (vector unsigned char, vector bool char);
16834 int vec_all_lt (vector unsigned char, vector unsigned char);
16835 int vec_all_lt (vector bool char, vector signed char);
16836 int vec_all_lt (vector signed char, vector bool char);
16837 int vec_all_lt (vector signed char, vector signed char);
16838 int vec_all_lt (vector bool short, vector unsigned short);
16839 int vec_all_lt (vector unsigned short, vector bool short);
16840 int vec_all_lt (vector unsigned short, vector unsigned short);
16841 int vec_all_lt (vector bool short, vector signed short);
16842 int vec_all_lt (vector signed short, vector bool short);
16843 int vec_all_lt (vector signed short, vector signed short);
16844 int vec_all_lt (vector bool int, vector unsigned int);
16845 int vec_all_lt (vector unsigned int, vector bool int);
16846 int vec_all_lt (vector unsigned int, vector unsigned int);
16847 int vec_all_lt (vector bool int, vector signed int);
16848 int vec_all_lt (vector signed int, vector bool int);
16849 int vec_all_lt (vector signed int, vector signed int);
16850 int vec_all_lt (vector float, vector float);
16852 int vec_all_nan (vector float);
16854 int vec_all_ne (vector signed char, vector bool char);
16855 int vec_all_ne (vector signed char, vector signed char);
16856 int vec_all_ne (vector unsigned char, vector bool char);
16857 int vec_all_ne (vector unsigned char, vector unsigned char);
16858 int vec_all_ne (vector bool char, vector bool char);
16859 int vec_all_ne (vector bool char, vector unsigned char);
16860 int vec_all_ne (vector bool char, vector signed char);
16861 int vec_all_ne (vector signed short, vector bool short);
16862 int vec_all_ne (vector signed short, vector signed short);
16863 int vec_all_ne (vector unsigned short, vector bool short);
16864 int vec_all_ne (vector unsigned short, vector unsigned short);
16865 int vec_all_ne (vector bool short, vector bool short);
16866 int vec_all_ne (vector bool short, vector unsigned short);
16867 int vec_all_ne (vector bool short, vector signed short);
16868 int vec_all_ne (vector pixel, vector pixel);
16869 int vec_all_ne (vector signed int, vector bool int);
16870 int vec_all_ne (vector signed int, vector signed int);
16871 int vec_all_ne (vector unsigned int, vector bool int);
16872 int vec_all_ne (vector unsigned int, vector unsigned int);
16873 int vec_all_ne (vector bool int, vector bool int);
16874 int vec_all_ne (vector bool int, vector unsigned int);
16875 int vec_all_ne (vector bool int, vector signed int);
16876 int vec_all_ne (vector float, vector float);
16878 int vec_all_nge (vector float, vector float);
16880 int vec_all_ngt (vector float, vector float);
16882 int vec_all_nle (vector float, vector float);
16884 int vec_all_nlt (vector float, vector float);
16886 int vec_all_numeric (vector float);
16888 vector float vec_and (vector float, vector float);
16889 vector float vec_and (vector float, vector bool int);
16890 vector float vec_and (vector bool int, vector float);
16891 vector bool int vec_and (vector bool int, vector bool int);
16892 vector signed int vec_and (vector bool int, vector signed int);
16893 vector signed int vec_and (vector signed int, vector bool int);
16894 vector signed int vec_and (vector signed int, vector signed int);
16895 vector unsigned int vec_and (vector bool int, vector unsigned int);
16896 vector unsigned int vec_and (vector unsigned int, vector bool int);
16897 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
16898 vector bool short vec_and (vector bool short, vector bool short);
16899 vector signed short vec_and (vector bool short, vector signed short);
16900 vector signed short vec_and (vector signed short, vector bool short);
16901 vector signed short vec_and (vector signed short, vector signed short);
16902 vector unsigned short vec_and (vector bool short, vector unsigned short);
16903 vector unsigned short vec_and (vector unsigned short, vector bool short);
16904 vector unsigned short vec_and (vector unsigned short, vector unsigned short);
16905 vector signed char vec_and (vector bool char, vector signed char);
16906 vector bool char vec_and (vector bool char, vector bool char);
16907 vector signed char vec_and (vector signed char, vector bool char);
16908 vector signed char vec_and (vector signed char, vector signed char);
16909 vector unsigned char vec_and (vector bool char, vector unsigned char);
16910 vector unsigned char vec_and (vector unsigned char, vector bool char);
16911 vector unsigned char vec_and (vector unsigned char, vector unsigned char);
16913 vector float vec_andc (vector float, vector float);
16914 vector float vec_andc (vector float, vector bool int);
16915 vector float vec_andc (vector bool int, vector float);
16916 vector bool int vec_andc (vector bool int, vector bool int);
16917 vector signed int vec_andc (vector bool int, vector signed int);
16918 vector signed int vec_andc (vector signed int, vector bool int);
16919 vector signed int vec_andc (vector signed int, vector signed int);
16920 vector unsigned int vec_andc (vector bool int, vector unsigned int);
16921 vector unsigned int vec_andc (vector unsigned int, vector bool int);
16922 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
16923 vector bool short vec_andc (vector bool short, vector bool short);
16924 vector signed short vec_andc (vector bool short, vector signed short);
16925 vector signed short vec_andc (vector signed short, vector bool short);
16926 vector signed short vec_andc (vector signed short, vector signed short);
16927 vector unsigned short vec_andc (vector bool short, vector unsigned short);
16928 vector unsigned short vec_andc (vector unsigned short, vector bool short);
16929 vector unsigned short vec_andc (vector unsigned short, vector unsigned short);
16930 vector signed char vec_andc (vector bool char, vector signed char);
16931 vector bool char vec_andc (vector bool char, vector bool char);
16932 vector signed char vec_andc (vector signed char, vector bool char);
16933 vector signed char vec_andc (vector signed char, vector signed char);
16934 vector unsigned char vec_andc (vector bool char, vector unsigned char);
16935 vector unsigned char vec_andc (vector unsigned char, vector bool char);
16936 vector unsigned char vec_andc (vector unsigned char, vector unsigned char);
16938 int vec_any_eq (vector signed char, vector bool char);
16939 int vec_any_eq (vector signed char, vector signed char);
16940 int vec_any_eq (vector unsigned char, vector bool char);
16941 int vec_any_eq (vector unsigned char, vector unsigned char);
16942 int vec_any_eq (vector bool char, vector bool char);
16943 int vec_any_eq (vector bool char, vector unsigned char);
16944 int vec_any_eq (vector bool char, vector signed char);
16945 int vec_any_eq (vector signed short, vector bool short);
16946 int vec_any_eq (vector signed short, vector signed short);
16947 int vec_any_eq (vector unsigned short, vector bool short);
16948 int vec_any_eq (vector unsigned short, vector unsigned short);
16949 int vec_any_eq (vector bool short, vector bool short);
16950 int vec_any_eq (vector bool short, vector unsigned short);
16951 int vec_any_eq (vector bool short, vector signed short);
16952 int vec_any_eq (vector pixel, vector pixel);
16953 int vec_any_eq (vector signed int, vector bool int);
16954 int vec_any_eq (vector signed int, vector signed int);
16955 int vec_any_eq (vector unsigned int, vector bool int);
16956 int vec_any_eq (vector unsigned int, vector unsigned int);
16957 int vec_any_eq (vector bool int, vector bool int);
16958 int vec_any_eq (vector bool int, vector unsigned int);
16959 int vec_any_eq (vector bool int, vector signed int);
16960 int vec_any_eq (vector float, vector float);
16962 int vec_any_ge (vector signed char, vector bool char);
16963 int vec_any_ge (vector unsigned char, vector bool char);
16964 int vec_any_ge (vector unsigned char, vector unsigned char);
16965 int vec_any_ge (vector signed char, vector signed char);
16966 int vec_any_ge (vector bool char, vector unsigned char);
16967 int vec_any_ge (vector bool char, vector signed char);
16968 int vec_any_ge (vector unsigned short, vector bool short);
16969 int vec_any_ge (vector unsigned short, vector unsigned short);
16970 int vec_any_ge (vector signed short, vector signed short);
16971 int vec_any_ge (vector signed short, vector bool short);
16972 int vec_any_ge (vector bool short, vector unsigned short);
16973 int vec_any_ge (vector bool short, vector signed short);
16974 int vec_any_ge (vector signed int, vector bool int);
16975 int vec_any_ge (vector unsigned int, vector bool int);
16976 int vec_any_ge (vector unsigned int, vector unsigned int);
16977 int vec_any_ge (vector signed int, vector signed int);
16978 int vec_any_ge (vector bool int, vector unsigned int);
16979 int vec_any_ge (vector bool int, vector signed int);
16980 int vec_any_ge (vector float, vector float);
16982 int vec_any_gt (vector bool char, vector unsigned char);
16983 int vec_any_gt (vector unsigned char, vector bool char);
16984 int vec_any_gt (vector unsigned char, vector unsigned char);
16985 int vec_any_gt (vector bool char, vector signed char);
16986 int vec_any_gt (vector signed char, vector bool char);
16987 int vec_any_gt (vector signed char, vector signed char);
16988 int vec_any_gt (vector bool short, vector unsigned short);
16989 int vec_any_gt (vector unsigned short, vector bool short);
16990 int vec_any_gt (vector unsigned short, vector unsigned short);
16991 int vec_any_gt (vector bool short, vector signed short);
16992 int vec_any_gt (vector signed short, vector bool short);
16993 int vec_any_gt (vector signed short, vector signed short);
16994 int vec_any_gt (vector bool int, vector unsigned int);
16995 int vec_any_gt (vector unsigned int, vector bool int);
16996 int vec_any_gt (vector unsigned int, vector unsigned int);
16997 int vec_any_gt (vector bool int, vector signed int);
16998 int vec_any_gt (vector signed int, vector bool int);
16999 int vec_any_gt (vector signed int, vector signed int);
17000 int vec_any_gt (vector float, vector float);
17002 int vec_any_le (vector bool char, vector unsigned char);
17003 int vec_any_le (vector unsigned char, vector bool char);
17004 int vec_any_le (vector unsigned char, vector unsigned char);
17005 int vec_any_le (vector bool char, vector signed char);
17006 int vec_any_le (vector signed char, vector bool char);
17007 int vec_any_le (vector signed char, vector signed char);
17008 int vec_any_le (vector bool short, vector unsigned short);
17009 int vec_any_le (vector unsigned short, vector bool short);
17010 int vec_any_le (vector unsigned short, vector unsigned short);
17011 int vec_any_le (vector bool short, vector signed short);
17012 int vec_any_le (vector signed short, vector bool short);
17013 int vec_any_le (vector signed short, vector signed short);
17014 int vec_any_le (vector bool int, vector unsigned int);
17015 int vec_any_le (vector unsigned int, vector bool int);
17016 int vec_any_le (vector unsigned int, vector unsigned int);
17017 int vec_any_le (vector bool int, vector signed int);
17018 int vec_any_le (vector signed int, vector bool int);
17019 int vec_any_le (vector signed int, vector signed int);
17020 int vec_any_le (vector float, vector float);
17022 int vec_any_lt (vector bool char, vector unsigned char);
17023 int vec_any_lt (vector unsigned char, vector bool char);
17024 int vec_any_lt (vector unsigned char, vector unsigned char);
17025 int vec_any_lt (vector bool char, vector signed char);
17026 int vec_any_lt (vector signed char, vector bool char);
17027 int vec_any_lt (vector signed char, vector signed char);
17028 int vec_any_lt (vector bool short, vector unsigned short);
17029 int vec_any_lt (vector unsigned short, vector bool short);
17030 int vec_any_lt (vector unsigned short, vector unsigned short);
17031 int vec_any_lt (vector bool short, vector signed short);
17032 int vec_any_lt (vector signed short, vector bool short);
17033 int vec_any_lt (vector signed short, vector signed short);
17034 int vec_any_lt (vector bool int, vector unsigned int);
17035 int vec_any_lt (vector unsigned int, vector bool int);
17036 int vec_any_lt (vector unsigned int, vector unsigned int);
17037 int vec_any_lt (vector bool int, vector signed int);
17038 int vec_any_lt (vector signed int, vector bool int);
17039 int vec_any_lt (vector signed int, vector signed int);
17040 int vec_any_lt (vector float, vector float);
17042 int vec_any_nan (vector float);
17044 int vec_any_ne (vector signed char, vector bool char);
17045 int vec_any_ne (vector signed char, vector signed char);
17046 int vec_any_ne (vector unsigned char, vector bool char);
17047 int vec_any_ne (vector unsigned char, vector unsigned char);
17048 int vec_any_ne (vector bool char, vector bool char);
17049 int vec_any_ne (vector bool char, vector unsigned char);
17050 int vec_any_ne (vector bool char, vector signed char);
17051 int vec_any_ne (vector signed short, vector bool short);
17052 int vec_any_ne (vector signed short, vector signed short);
17053 int vec_any_ne (vector unsigned short, vector bool short);
17054 int vec_any_ne (vector unsigned short, vector unsigned short);
17055 int vec_any_ne (vector bool short, vector bool short);
17056 int vec_any_ne (vector bool short, vector unsigned short);
17057 int vec_any_ne (vector bool short, vector signed short);
17058 int vec_any_ne (vector pixel, vector pixel);
17059 int vec_any_ne (vector signed int, vector bool int);
17060 int vec_any_ne (vector signed int, vector signed int);
17061 int vec_any_ne (vector unsigned int, vector bool int);
17062 int vec_any_ne (vector unsigned int, vector unsigned int);
17063 int vec_any_ne (vector bool int, vector bool int);
17064 int vec_any_ne (vector bool int, vector unsigned int);
17065 int vec_any_ne (vector bool int, vector signed int);
17066 int vec_any_ne (vector float, vector float);
17068 int vec_any_nge (vector float, vector float);
17070 int vec_any_ngt (vector float, vector float);
17072 int vec_any_nle (vector float, vector float);
17074 int vec_any_nlt (vector float, vector float);
17076 int vec_any_numeric (vector float);
17078 int vec_any_out (vector float, vector float);
17080 vector unsigned char vec_avg (vector unsigned char, vector unsigned char);
17081 vector signed char vec_avg (vector signed char, vector signed char);
17082 vector unsigned short vec_avg (vector unsigned short, vector unsigned short);
17083 vector signed short vec_avg (vector signed short, vector signed short);
17084 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
17085 vector signed int vec_avg (vector signed int, vector signed int);
17087 vector float vec_ceil (vector float);
17089 vector signed int vec_cmpb (vector float, vector float);
17091 vector bool char vec_cmpeq (vector bool char, vector bool char);
17092 vector bool short vec_cmpeq (vector bool short, vector bool short);
17093 vector bool int vec_cmpeq (vector bool int, vector bool int);
17094 vector bool char vec_cmpeq (vector signed char, vector signed char);
17095 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
17096 vector bool short vec_cmpeq (vector signed short, vector signed short);
17097 vector bool short vec_cmpeq (vector unsigned short, vector unsigned short);
17098 vector bool int vec_cmpeq (vector signed int, vector signed int);
17099 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
17100 vector bool int vec_cmpeq (vector float, vector float);
17102 vector bool int vec_cmpge (vector float, vector float);
17104 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
17105 vector bool char vec_cmpgt (vector signed char, vector signed char);
17106 vector bool short vec_cmpgt (vector unsigned short, vector unsigned short);
17107 vector bool short vec_cmpgt (vector signed short, vector signed short);
17108 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
17109 vector bool int vec_cmpgt (vector signed int, vector signed int);
17110 vector bool int vec_cmpgt (vector float, vector float);
17112 vector bool int vec_cmple (vector float, vector float);
17114 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
17115 vector bool char vec_cmplt (vector signed char, vector signed char);
17116 vector bool short vec_cmplt (vector unsigned short, vector unsigned short);
17117 vector bool short vec_cmplt (vector signed short, vector signed short);
17118 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
17119 vector bool int vec_cmplt (vector signed int, vector signed int);
17120 vector bool int vec_cmplt (vector float, vector float);
17122 vector float vec_cpsgn (vector float, vector float);
17124 vector float vec_ctf (vector unsigned int, const int);
17125 vector float vec_ctf (vector signed int, const int);
17127 vector signed int vec_cts (vector float, const int);
17129 vector unsigned int vec_ctu (vector float, const int);
17131 void vec_dss (const int);
17133 void vec_dssall (void);
17135 void vec_dst (const vector unsigned char *, int, const int);
17136 void vec_dst (const vector signed char *, int, const int);
17137 void vec_dst (const vector bool char *, int, const int);
17138 void vec_dst (const vector unsigned short *, int, const int);
17139 void vec_dst (const vector signed short *, int, const int);
17140 void vec_dst (const vector bool short *, int, const int);
17141 void vec_dst (const vector pixel *, int, const int);
17142 void vec_dst (const vector unsigned int *, int, const int);
17143 void vec_dst (const vector signed int *, int, const int);
17144 void vec_dst (const vector bool int *, int, const int);
17145 void vec_dst (const vector float *, int, const int);
17146 void vec_dst (const unsigned char *, int, const int);
17147 void vec_dst (const signed char *, int, const int);
17148 void vec_dst (const unsigned short *, int, const int);
17149 void vec_dst (const short *, int, const int);
17150 void vec_dst (const unsigned int *, int, const int);
17151 void vec_dst (const int *, int, const int);
17152 void vec_dst (const float *, int, const int);
17154 void vec_dstst (const vector unsigned char *, int, const int);
17155 void vec_dstst (const vector signed char *, int, const int);
17156 void vec_dstst (const vector bool char *, int, const int);
17157 void vec_dstst (const vector unsigned short *, int, const int);
17158 void vec_dstst (const vector signed short *, int, const int);
17159 void vec_dstst (const vector bool short *, int, const int);
17160 void vec_dstst (const vector pixel *, int, const int);
17161 void vec_dstst (const vector unsigned int *, int, const int);
17162 void vec_dstst (const vector signed int *, int, const int);
17163 void vec_dstst (const vector bool int *, int, const int);
17164 void vec_dstst (const vector float *, int, const int);
17165 void vec_dstst (const unsigned char *, int, const int);
17166 void vec_dstst (const signed char *, int, const int);
17167 void vec_dstst (const unsigned short *, int, const int);
17168 void vec_dstst (const short *, int, const int);
17169 void vec_dstst (const unsigned int *, int, const int);
17170 void vec_dstst (const int *, int, const int);
17171 void vec_dstst (const unsigned long *, int, const int);
17172 void vec_dstst (const long *, int, const int);
17173 void vec_dstst (const float *, int, const int);
17175 void vec_dststt (const vector unsigned char *, int, const int);
17176 void vec_dststt (const vector signed char *, int, const int);
17177 void vec_dststt (const vector bool char *, int, const int);
17178 void vec_dststt (const vector unsigned short *, int, const int);
17179 void vec_dststt (const vector signed short *, int, const int);
17180 void vec_dststt (const vector bool short *, int, const int);
17181 void vec_dststt (const vector pixel *, int, const int);
17182 void vec_dststt (const vector unsigned int *, int, const int);
17183 void vec_dststt (const vector signed int *, int, const int);
17184 void vec_dststt (const vector bool int *, int, const int);
17185 void vec_dststt (const vector float *, int, const int);
17186 void vec_dststt (const unsigned char *, int, const int);
17187 void vec_dststt (const signed char *, int, const int);
17188 void vec_dststt (const unsigned short *, int, const int);
17189 void vec_dststt (const short *, int, const int);
17190 void vec_dststt (const unsigned int *, int, const int);
17191 void vec_dststt (const int *, int, const int);
17192 void vec_dststt (const float *, int, const int);
17194 void vec_dstt (const vector unsigned char *, int, const int);
17195 void vec_dstt (const vector signed char *, int, const int);
17196 void vec_dstt (const vector bool char *, int, const int);
17197 void vec_dstt (const vector unsigned short *, int, const int);
17198 void vec_dstt (const vector signed short *, int, const int);
17199 void vec_dstt (const vector bool short *, int, const int);
17200 void vec_dstt (const vector pixel *, int, const int);
17201 void vec_dstt (const vector unsigned int *, int, const int);
17202 void vec_dstt (const vector signed int *, int, const int);
17203 void vec_dstt (const vector bool int *, int, const int);
17204 void vec_dstt (const vector float *, int, const int);
17205 void vec_dstt (const unsigned char *, int, const int);
17206 void vec_dstt (const signed char *, int, const int);
17207 void vec_dstt (const unsigned short *, int, const int);
17208 void vec_dstt (const short *, int, const int);
17209 void vec_dstt (const unsigned int *, int, const int);
17210 void vec_dstt (const int *, int, const int);
17211 void vec_dstt (const float *, int, const int);
17213 vector float vec_expte (vector float);
17215 vector float vec_floor (vector float);
17217 vector float vec_ld (int, const vector float *);
17218 vector float vec_ld (int, const float *);
17219 vector bool int vec_ld (int, const vector bool int *);
17220 vector signed int vec_ld (int, const vector signed int *);
17221 vector signed int vec_ld (int, const int *);
17222 vector unsigned int vec_ld (int, const vector unsigned int *);
17223 vector unsigned int vec_ld (int, const unsigned int *);
17224 vector bool short vec_ld (int, const vector bool short *);
17225 vector pixel vec_ld (int, const vector pixel *);
17226 vector signed short vec_ld (int, const vector signed short *);
17227 vector signed short vec_ld (int, const short *);
17228 vector unsigned short vec_ld (int, const vector unsigned short *);
17229 vector unsigned short vec_ld (int, const unsigned short *);
17230 vector bool char vec_ld (int, const vector bool char *);
17231 vector signed char vec_ld (int, const vector signed char *);
17232 vector signed char vec_ld (int, const signed char *);
17233 vector unsigned char vec_ld (int, const vector unsigned char *);
17234 vector unsigned char vec_ld (int, const unsigned char *);
17236 vector signed char vec_lde (int, const signed char *);
17237 vector unsigned char vec_lde (int, const unsigned char *);
17238 vector signed short vec_lde (int, const short *);
17239 vector unsigned short vec_lde (int, const unsigned short *);
17240 vector float vec_lde (int, const float *);
17241 vector signed int vec_lde (int, const int *);
17242 vector unsigned int vec_lde (int, const unsigned int *);
17244 vector float vec_ldl (int, const vector float *);
17245 vector float vec_ldl (int, const float *);
17246 vector bool int vec_ldl (int, const vector bool int *);
17247 vector signed int vec_ldl (int, const vector signed int *);
17248 vector signed int vec_ldl (int, const int *);
17249 vector unsigned int vec_ldl (int, const vector unsigned int *);
17250 vector unsigned int vec_ldl (int, const unsigned int *);
17251 vector bool short vec_ldl (int, const vector bool short *);
17252 vector pixel vec_ldl (int, const vector pixel *);
17253 vector signed short vec_ldl (int, const vector signed short *);
17254 vector signed short vec_ldl (int, const short *);
17255 vector unsigned short vec_ldl (int, const vector unsigned short *);
17256 vector unsigned short vec_ldl (int, const unsigned short *);
17257 vector bool char vec_ldl (int, const vector bool char *);
17258 vector signed char vec_ldl (int, const vector signed char *);
17259 vector signed char vec_ldl (int, const signed char *);
17260 vector unsigned char vec_ldl (int, const vector unsigned char *);
17261 vector unsigned char vec_ldl (int, const unsigned char *);
17263 vector float vec_loge (vector float);
17265 vector signed char vec_lvebx (int, char *);
17266 vector unsigned char vec_lvebx (int, unsigned char *);
17268 vector signed short vec_lvehx (int, short *);
17269 vector unsigned short vec_lvehx (int, unsigned short *);
17271 vector float vec_lvewx (int, float *);
17272 vector signed int vec_lvewx (int, int *);
17273 vector unsigned int vec_lvewx (int, unsigned int *);
17275 vector unsigned char vec_lvsl (int, const unsigned char *);
17276 vector unsigned char vec_lvsl (int, const signed char *);
17277 vector unsigned char vec_lvsl (int, const unsigned short *);
17278 vector unsigned char vec_lvsl (int, const short *);
17279 vector unsigned char vec_lvsl (int, const unsigned int *);
17280 vector unsigned char vec_lvsl (int, const int *);
17281 vector unsigned char vec_lvsl (int, const float *);
17283 vector unsigned char vec_lvsr (int, const unsigned char *);
17284 vector unsigned char vec_lvsr (int, const signed char *);
17285 vector unsigned char vec_lvsr (int, const unsigned short *);
17286 vector unsigned char vec_lvsr (int, const short *);
17287 vector unsigned char vec_lvsr (int, const unsigned int *);
17288 vector unsigned char vec_lvsr (int, const int *);
17289 vector unsigned char vec_lvsr (int, const float *);
17291 vector float vec_madd (vector float, vector float, vector float);
17293 vector signed short vec_madds (vector signed short, vector signed short,
17294 vector signed short);
17296 vector unsigned char vec_max (vector bool char, vector unsigned char);
17297 vector unsigned char vec_max (vector unsigned char, vector bool char);
17298 vector unsigned char vec_max (vector unsigned char, vector unsigned char);
17299 vector signed char vec_max (vector bool char, vector signed char);
17300 vector signed char vec_max (vector signed char, vector bool char);
17301 vector signed char vec_max (vector signed char, vector signed char);
17302 vector unsigned short vec_max (vector bool short, vector unsigned short);
17303 vector unsigned short vec_max (vector unsigned short, vector bool short);
17304 vector unsigned short vec_max (vector unsigned short, vector unsigned short);
17305 vector signed short vec_max (vector bool short, vector signed short);
17306 vector signed short vec_max (vector signed short, vector bool short);
17307 vector signed short vec_max (vector signed short, vector signed short);
17308 vector unsigned int vec_max (vector bool int, vector unsigned int);
17309 vector unsigned int vec_max (vector unsigned int, vector bool int);
17310 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
17311 vector signed int vec_max (vector bool int, vector signed int);
17312 vector signed int vec_max (vector signed int, vector bool int);
17313 vector signed int vec_max (vector signed int, vector signed int);
17314 vector float vec_max (vector float, vector float);
17316 vector bool char vec_mergeh (vector bool char, vector bool char);
17317 vector signed char vec_mergeh (vector signed char, vector signed char);
17318 vector unsigned char vec_mergeh (vector unsigned char, vector unsigned char);
17319 vector bool short vec_mergeh (vector bool short, vector bool short);
17320 vector pixel vec_mergeh (vector pixel, vector pixel);
17321 vector signed short vec_mergeh (vector signed short, vector signed short);
17322 vector unsigned short vec_mergeh (vector unsigned short, vector unsigned short);
17323 vector float vec_mergeh (vector float, vector float);
17324 vector bool int vec_mergeh (vector bool int, vector bool int);
17325 vector signed int vec_mergeh (vector signed int, vector signed int);
17326 vector unsigned int vec_mergeh (vector unsigned int, vector unsigned int);
17328 vector bool char vec_mergel (vector bool char, vector bool char);
17329 vector signed char vec_mergel (vector signed char, vector signed char);
17330 vector unsigned char vec_mergel (vector unsigned char, vector unsigned char);
17331 vector bool short vec_mergel (vector bool short, vector bool short);
17332 vector pixel vec_mergel (vector pixel, vector pixel);
17333 vector signed short vec_mergel (vector signed short, vector signed short);
17334 vector unsigned short vec_mergel (vector unsigned short, vector unsigned short);
17335 vector float vec_mergel (vector float, vector float);
17336 vector bool int vec_mergel (vector bool int, vector bool int);
17337 vector signed int vec_mergel (vector signed int, vector signed int);
17338 vector unsigned int vec_mergel (vector unsigned int, vector unsigned int);
17340 vector unsigned short vec_mfvscr (void);
17342 vector unsigned char vec_min (vector bool char, vector unsigned char);
17343 vector unsigned char vec_min (vector unsigned char, vector bool char);
17344 vector unsigned char vec_min (vector unsigned char, vector unsigned char);
17345 vector signed char vec_min (vector bool char, vector signed char);
17346 vector signed char vec_min (vector signed char, vector bool char);
17347 vector signed char vec_min (vector signed char, vector signed char);
17348 vector unsigned short vec_min (vector bool short, vector unsigned short);
17349 vector unsigned short vec_min (vector unsigned short, vector bool short);
17350 vector unsigned short vec_min (vector unsigned short, vector unsigned short);
17351 vector signed short vec_min (vector bool short, vector signed short);
17352 vector signed short vec_min (vector signed short, vector bool short);
17353 vector signed short vec_min (vector signed short, vector signed short);
17354 vector unsigned int vec_min (vector bool int, vector unsigned int);
17355 vector unsigned int vec_min (vector unsigned int, vector bool int);
17356 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
17357 vector signed int vec_min (vector bool int, vector signed int);
17358 vector signed int vec_min (vector signed int, vector bool int);
17359 vector signed int vec_min (vector signed int, vector signed int);
17360 vector float vec_min (vector float, vector float);
17362 vector signed short vec_mladd (vector signed short, vector signed short,
17363 vector signed short);
17364 vector signed short vec_mladd (vector signed short, vector unsigned short,
17365 vector unsigned short);
17366 vector signed short vec_mladd (vector unsigned short, vector signed short,
17367 vector signed short);
17368 vector unsigned short vec_mladd (vector unsigned short, vector unsigned short,
17369 vector unsigned short);
17371 vector signed short vec_mradds (vector signed short, vector signed short,
17372 vector signed short);
17374 vector unsigned int vec_msum (vector unsigned char, vector unsigned char,
17375 vector unsigned int);
17376 vector signed int vec_msum (vector signed char, vector unsigned char,
17377 vector signed int);
17378 vector unsigned int vec_msum (vector unsigned short, vector unsigned short,
17379 vector unsigned int);
17380 vector signed int vec_msum (vector signed short, vector signed short,
17381 vector signed int);
17383 vector unsigned int vec_msums (vector unsigned short, vector unsigned short,
17384 vector unsigned int);
17385 vector signed int vec_msums (vector signed short, vector signed short,
17386 vector signed int);
17388 void vec_mtvscr (vector signed int);
17389 void vec_mtvscr (vector unsigned int);
17390 void vec_mtvscr (vector bool int);
17391 void vec_mtvscr (vector signed short);
17392 void vec_mtvscr (vector unsigned short);
17393 void vec_mtvscr (vector bool short);
17394 void vec_mtvscr (vector pixel);
17395 void vec_mtvscr (vector signed char);
17396 void vec_mtvscr (vector unsigned char);
17397 void vec_mtvscr (vector bool char);
17399 vector float vec_mul (vector float, vector float);
17401 vector unsigned short vec_mule (vector unsigned char, vector unsigned char);
17402 vector signed short vec_mule (vector signed char, vector signed char);
17403 vector unsigned int vec_mule (vector unsigned short, vector unsigned short);
17404 vector signed int vec_mule (vector signed short, vector signed short);
17406 vector unsigned short vec_mulo (vector unsigned char, vector unsigned char);
17407 vector signed short vec_mulo (vector signed char, vector signed char);
17408 vector unsigned int vec_mulo (vector unsigned short, vector unsigned short);
17409 vector signed int vec_mulo (vector signed short, vector signed short);
17411 vector signed char vec_nabs (vector signed char);
17412 vector signed short vec_nabs (vector signed short);
17413 vector signed int vec_nabs (vector signed int);
17414 vector float vec_nabs (vector float);
17416 vector float vec_nmsub (vector float, vector float, vector float);
17418 vector float vec_nor (vector float, vector float);
17419 vector signed int vec_nor (vector signed int, vector signed int);
17420 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
17421 vector bool int vec_nor (vector bool int, vector bool int);
17422 vector signed short vec_nor (vector signed short, vector signed short);
17423 vector unsigned short vec_nor (vector unsigned short, vector unsigned short);
17424 vector bool short vec_nor (vector bool short, vector bool short);
17425 vector signed char vec_nor (vector signed char, vector signed char);
17426 vector unsigned char vec_nor (vector unsigned char, vector unsigned char);
17427 vector bool char vec_nor (vector bool char, vector bool char);
17429 vector float vec_or (vector float, vector float);
17430 vector float vec_or (vector float, vector bool int);
17431 vector float vec_or (vector bool int, vector float);
17432 vector bool int vec_or (vector bool int, vector bool int);
17433 vector signed int vec_or (vector bool int, vector signed int);
17434 vector signed int vec_or (vector signed int, vector bool int);
17435 vector signed int vec_or (vector signed int, vector signed int);
17436 vector unsigned int vec_or (vector bool int, vector unsigned int);
17437 vector unsigned int vec_or (vector unsigned int, vector bool int);
17438 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
17439 vector bool short vec_or (vector bool short, vector bool short);
17440 vector signed short vec_or (vector bool short, vector signed short);
17441 vector signed short vec_or (vector signed short, vector bool short);
17442 vector signed short vec_or (vector signed short, vector signed short);
17443 vector unsigned short vec_or (vector bool short, vector unsigned short);
17444 vector unsigned short vec_or (vector unsigned short, vector bool short);
17445 vector unsigned short vec_or (vector unsigned short, vector unsigned short);
17446 vector signed char vec_or (vector bool char, vector signed char);
17447 vector bool char vec_or (vector bool char, vector bool char);
17448 vector signed char vec_or (vector signed char, vector bool char);
17449 vector signed char vec_or (vector signed char, vector signed char);
17450 vector unsigned char vec_or (vector bool char, vector unsigned char);
17451 vector unsigned char vec_or (vector unsigned char, vector bool char);
17452 vector unsigned char vec_or (vector unsigned char, vector unsigned char);
17454 vector signed char vec_pack (vector signed short, vector signed short);
17455 vector unsigned char vec_pack (vector unsigned short, vector unsigned short);
17456 vector bool char vec_pack (vector bool short, vector bool short);
17457 vector signed short vec_pack (vector signed int, vector signed int);
17458 vector unsigned short vec_pack (vector unsigned int, vector unsigned int);
17459 vector bool short vec_pack (vector bool int, vector bool int);
17461 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
17463 vector unsigned char vec_packs (vector unsigned short, vector unsigned short);
17464 vector signed char vec_packs (vector signed short, vector signed short);
17465 vector unsigned short vec_packs (vector unsigned int, vector unsigned int);
17466 vector signed short vec_packs (vector signed int, vector signed int);
17468 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short);
17469 vector unsigned char vec_packsu (vector signed short, vector signed short);
17470 vector unsigned short vec_packsu (vector unsigned int, vector unsigned int);
17471 vector unsigned short vec_packsu (vector signed int, vector signed int);
17473 vector float vec_perm (vector float, vector float, vector unsigned char);
17474 vector signed int vec_perm (vector signed int, vector signed int, vector unsigned char);
17475 vector unsigned int vec_perm (vector unsigned int, vector unsigned int,
17476 vector unsigned char);
17477 vector bool int vec_perm (vector bool int, vector bool int, vector unsigned char);
17478 vector signed short vec_perm (vector signed short, vector signed short,
17479 vector unsigned char);
17480 vector unsigned short vec_perm (vector unsigned short, vector unsigned short,
17481 vector unsigned char);
17482 vector bool short vec_perm (vector bool short, vector bool short, vector unsigned char);
17483 vector pixel vec_perm (vector pixel, vector pixel, vector unsigned char);
17484 vector signed char vec_perm (vector signed char, vector signed char,
17485 vector unsigned char);
17486 vector unsigned char vec_perm (vector unsigned char, vector unsigned char,
17487 vector unsigned char);
17488 vector bool char vec_perm (vector bool char, vector bool char, vector unsigned char);
17490 vector float vec_re (vector float);
17492 vector bool char vec_reve (vector bool char);
17493 vector signed char vec_reve (vector signed char);
17494 vector unsigned char vec_reve (vector unsigned char);
17495 vector bool int vec_reve (vector bool int);
17496 vector signed int vec_reve (vector signed int);
17497 vector unsigned int vec_reve (vector unsigned int);
17498 vector bool short vec_reve (vector bool short);
17499 vector signed short vec_reve (vector signed short);
17500 vector unsigned short vec_reve (vector unsigned short);
17502 vector signed char vec_rl (vector signed char, vector unsigned char);
17503 vector unsigned char vec_rl (vector unsigned char, vector unsigned char);
17504 vector signed short vec_rl (vector signed short, vector unsigned short);
17505 vector unsigned short vec_rl (vector unsigned short, vector unsigned short);
17506 vector signed int vec_rl (vector signed int, vector unsigned int);
17507 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
17509 vector float vec_round (vector float);
17511 vector float vec_rsqrt (vector float);
17513 vector float vec_rsqrte (vector float);
17515 vector float vec_sel (vector float, vector float, vector bool int);
17516 vector float vec_sel (vector float, vector float, vector unsigned int);
17517 vector signed int vec_sel (vector signed int, vector signed int, vector bool int);
17518 vector signed int vec_sel (vector signed int, vector signed int, vector unsigned int);
17519 vector unsigned int vec_sel (vector unsigned int, vector unsigned int, vector bool int);
17520 vector unsigned int vec_sel (vector unsigned int, vector unsigned int,
17521 vector unsigned int);
17522 vector bool int vec_sel (vector bool int, vector bool int, vector bool int);
17523 vector bool int vec_sel (vector bool int, vector bool int, vector unsigned int);
17524 vector signed short vec_sel (vector signed short, vector signed short,
17525 vector bool short);
17526 vector signed short vec_sel (vector signed short, vector signed short,
17527 vector unsigned short);
17528 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
17529 vector bool short);
17530 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
17531 vector unsigned short);
17532 vector bool short vec_sel (vector bool short, vector bool short, vector bool short);
17533 vector bool short vec_sel (vector bool short, vector bool short, vector unsigned short);
17534 vector signed char vec_sel (vector signed char, vector signed char, vector bool char);
17535 vector signed char vec_sel (vector signed char, vector signed char,
17536 vector unsigned char);
17537 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
17539 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
17540 vector unsigned char);
17541 vector bool char vec_sel (vector bool char, vector bool char, vector bool char);
17542 vector bool char vec_sel (vector bool char, vector bool char, vector unsigned char);
17544 vector signed char vec_sl (vector signed char, vector unsigned char);
17545 vector unsigned char vec_sl (vector unsigned char, vector unsigned char);
17546 vector signed short vec_sl (vector signed short, vector unsigned short);
17547 vector unsigned short vec_sl (vector unsigned short, vector unsigned short);
17548 vector signed int vec_sl (vector signed int, vector unsigned int);
17549 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
17551 vector float vec_sld (vector float, vector float, const int);
17552 vector signed int vec_sld (vector signed int, vector signed int, const int);
17553 vector unsigned int vec_sld (vector unsigned int, vector unsigned int, const int);
17554 vector bool int vec_sld (vector bool int, vector bool int, const int);
17555 vector signed short vec_sld (vector signed short, vector signed short, const int);
17556 vector unsigned short vec_sld (vector unsigned short, vector unsigned short, const int);
17557 vector bool short vec_sld (vector bool short, vector bool short, const int);
17558 vector pixel vec_sld (vector pixel, vector pixel, const int);
17559 vector signed char vec_sld (vector signed char, vector signed char, const int);
17560 vector unsigned char vec_sld (vector unsigned char, vector unsigned char, const int);
17561 vector bool char vec_sld (vector bool char, vector bool char, const int);
17563 vector signed int vec_sll (vector signed int, vector unsigned int);
17564 vector signed int vec_sll (vector signed int, vector unsigned short);
17565 vector signed int vec_sll (vector signed int, vector unsigned char);
17566 vector unsigned int vec_sll (vector unsigned int, vector unsigned int);
17567 vector unsigned int vec_sll (vector unsigned int, vector unsigned short);
17568 vector unsigned int vec_sll (vector unsigned int, vector unsigned char);
17569 vector bool int vec_sll (vector bool int, vector unsigned int);
17570 vector bool int vec_sll (vector bool int, vector unsigned short);
17571 vector bool int vec_sll (vector bool int, vector unsigned char);
17572 vector signed short vec_sll (vector signed short, vector unsigned int);
17573 vector signed short vec_sll (vector signed short, vector unsigned short);
17574 vector signed short vec_sll (vector signed short, vector unsigned char);
17575 vector unsigned short vec_sll (vector unsigned short, vector unsigned int);
17576 vector unsigned short vec_sll (vector unsigned short, vector unsigned short);
17577 vector unsigned short vec_sll (vector unsigned short, vector unsigned char);
17578 vector bool short vec_sll (vector bool short, vector unsigned int);
17579 vector bool short vec_sll (vector bool short, vector unsigned short);
17580 vector bool short vec_sll (vector bool short, vector unsigned char);
17581 vector pixel vec_sll (vector pixel, vector unsigned int);
17582 vector pixel vec_sll (vector pixel, vector unsigned short);
17583 vector pixel vec_sll (vector pixel, vector unsigned char);
17584 vector signed char vec_sll (vector signed char, vector unsigned int);
17585 vector signed char vec_sll (vector signed char, vector unsigned short);
17586 vector signed char vec_sll (vector signed char, vector unsigned char);
17587 vector unsigned char vec_sll (vector unsigned char, vector unsigned int);
17588 vector unsigned char vec_sll (vector unsigned char, vector unsigned short);
17589 vector unsigned char vec_sll (vector unsigned char, vector unsigned char);
17590 vector bool char vec_sll (vector bool char, vector unsigned int);
17591 vector bool char vec_sll (vector bool char, vector unsigned short);
17592 vector bool char vec_sll (vector bool char, vector unsigned char);
17594 vector float vec_slo (vector float, vector signed char);
17595 vector float vec_slo (vector float, vector unsigned char);
17596 vector signed int vec_slo (vector signed int, vector signed char);
17597 vector signed int vec_slo (vector signed int, vector unsigned char);
17598 vector unsigned int vec_slo (vector unsigned int, vector signed char);
17599 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
17600 vector signed short vec_slo (vector signed short, vector signed char);
17601 vector signed short vec_slo (vector signed short, vector unsigned char);
17602 vector unsigned short vec_slo (vector unsigned short, vector signed char);
17603 vector unsigned short vec_slo (vector unsigned short, vector unsigned char);
17604 vector pixel vec_slo (vector pixel, vector signed char);
17605 vector pixel vec_slo (vector pixel, vector unsigned char);
17606 vector signed char vec_slo (vector signed char, vector signed char);
17607 vector signed char vec_slo (vector signed char, vector unsigned char);
17608 vector unsigned char vec_slo (vector unsigned char, vector signed char);
17609 vector unsigned char vec_slo (vector unsigned char, vector unsigned char);
17611 vector signed char vec_splat (vector signed char, const int);
17612 vector unsigned char vec_splat (vector unsigned char, const int);
17613 vector bool char vec_splat (vector bool char, const int);
17614 vector signed short vec_splat (vector signed short, const int);
17615 vector unsigned short vec_splat (vector unsigned short, const int);
17616 vector bool short vec_splat (vector bool short, const int);
17617 vector pixel vec_splat (vector pixel, const int);
17618 vector float vec_splat (vector float, const int);
17619 vector signed int vec_splat (vector signed int, const int);
17620 vector unsigned int vec_splat (vector unsigned int, const int);
17621 vector bool int vec_splat (vector bool int, const int);
17623 vector signed short vec_splat_s16 (const int);
17625 vector signed int vec_splat_s32 (const int);
17627 vector signed char vec_splat_s8 (const int);
17629 vector unsigned short vec_splat_u16 (const int);
17631 vector unsigned int vec_splat_u32 (const int);
17633 vector unsigned char vec_splat_u8 (const int);
17635 vector signed char vec_splats (signed char);
17636 vector unsigned char vec_splats (unsigned char);
17637 vector signed short vec_splats (signed short);
17638 vector unsigned short vec_splats (unsigned short);
17639 vector signed int vec_splats (signed int);
17640 vector unsigned int vec_splats (unsigned int);
17641 vector float vec_splats (float);
17643 vector signed char vec_sr (vector signed char, vector unsigned char);
17644 vector unsigned char vec_sr (vector unsigned char, vector unsigned char);
17645 vector signed short vec_sr (vector signed short, vector unsigned short);
17646 vector unsigned short vec_sr (vector unsigned short, vector unsigned short);
17647 vector signed int vec_sr (vector signed int, vector unsigned int);
17648 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
17650 vector signed char vec_sra (vector signed char, vector unsigned char);
17651 vector unsigned char vec_sra (vector unsigned char, vector unsigned char);
17652 vector signed short vec_sra (vector signed short, vector unsigned short);
17653 vector unsigned short vec_sra (vector unsigned short, vector unsigned short);
17654 vector signed int vec_sra (vector signed int, vector unsigned int);
17655 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
17657 vector signed int vec_srl (vector signed int, vector unsigned int);
17658 vector signed int vec_srl (vector signed int, vector unsigned short);
17659 vector signed int vec_srl (vector signed int, vector unsigned char);
17660 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
17661 vector unsigned int vec_srl (vector unsigned int, vector unsigned short);
17662 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
17663 vector bool int vec_srl (vector bool int, vector unsigned int);
17664 vector bool int vec_srl (vector bool int, vector unsigned short);
17665 vector bool int vec_srl (vector bool int, vector unsigned char);
17666 vector signed short vec_srl (vector signed short, vector unsigned int);
17667 vector signed short vec_srl (vector signed short, vector unsigned short);
17668 vector signed short vec_srl (vector signed short, vector unsigned char);
17669 vector unsigned short vec_srl (vector unsigned short, vector unsigned int);
17670 vector unsigned short vec_srl (vector unsigned short, vector unsigned short);
17671 vector unsigned short vec_srl (vector unsigned short, vector unsigned char);
17672 vector bool short vec_srl (vector bool short, vector unsigned int);
17673 vector bool short vec_srl (vector bool short, vector unsigned short);
17674 vector bool short vec_srl (vector bool short, vector unsigned char);
17675 vector pixel vec_srl (vector pixel, vector unsigned int);
17676 vector pixel vec_srl (vector pixel, vector unsigned short);
17677 vector pixel vec_srl (vector pixel, vector unsigned char);
17678 vector signed char vec_srl (vector signed char, vector unsigned int);
17679 vector signed char vec_srl (vector signed char, vector unsigned short);
17680 vector signed char vec_srl (vector signed char, vector unsigned char);
17681 vector unsigned char vec_srl (vector unsigned char, vector unsigned int);
17682 vector unsigned char vec_srl (vector unsigned char, vector unsigned short);
17683 vector unsigned char vec_srl (vector unsigned char, vector unsigned char);
17684 vector bool char vec_srl (vector bool char, vector unsigned int);
17685 vector bool char vec_srl (vector bool char, vector unsigned short);
17686 vector bool char vec_srl (vector bool char, vector unsigned char);
17688 vector float vec_sro (vector float, vector signed char);
17689 vector float vec_sro (vector float, vector unsigned char);
17690 vector signed int vec_sro (vector signed int, vector signed char);
17691 vector signed int vec_sro (vector signed int, vector unsigned char);
17692 vector unsigned int vec_sro (vector unsigned int, vector signed char);
17693 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
17694 vector signed short vec_sro (vector signed short, vector signed char);
17695 vector signed short vec_sro (vector signed short, vector unsigned char);
17696 vector unsigned short vec_sro (vector unsigned short, vector signed char);
17697 vector unsigned short vec_sro (vector unsigned short, vector unsigned char);
17698 vector pixel vec_sro (vector pixel, vector signed char);
17699 vector pixel vec_sro (vector pixel, vector unsigned char);
17700 vector signed char vec_sro (vector signed char, vector signed char);
17701 vector signed char vec_sro (vector signed char, vector unsigned char);
17702 vector unsigned char vec_sro (vector unsigned char, vector signed char);
17703 vector unsigned char vec_sro (vector unsigned char, vector unsigned char);
17705 void vec_st (vector float, int, vector float *);
17706 void vec_st (vector float, int, float *);
17707 void vec_st (vector signed int, int, vector signed int *);
17708 void vec_st (vector signed int, int, int *);
17709 void vec_st (vector unsigned int, int, vector unsigned int *);
17710 void vec_st (vector unsigned int, int, unsigned int *);
17711 void vec_st (vector bool int, int, vector bool int *);
17712 void vec_st (vector bool int, int, unsigned int *);
17713 void vec_st (vector bool int, int, int *);
17714 void vec_st (vector signed short, int, vector signed short *);
17715 void vec_st (vector signed short, int, short *);
17716 void vec_st (vector unsigned short, int, vector unsigned short *);
17717 void vec_st (vector unsigned short, int, unsigned short *);
17718 void vec_st (vector bool short, int, vector bool short *);
17719 void vec_st (vector bool short, int, unsigned short *);
17720 void vec_st (vector pixel, int, vector pixel *);
17721 void vec_st (vector bool short, int, short *);
17722 void vec_st (vector signed char, int, vector signed char *);
17723 void vec_st (vector signed char, int, signed char *);
17724 void vec_st (vector unsigned char, int, vector unsigned char *);
17725 void vec_st (vector unsigned char, int, unsigned char *);
17726 void vec_st (vector bool char, int, vector bool char *);
17727 void vec_st (vector bool char, int, unsigned char *);
17728 void vec_st (vector bool char, int, signed char *);
17730 void vec_ste (vector signed char, int, signed char *);
17731 void vec_ste (vector unsigned char, int, unsigned char *);
17732 void vec_ste (vector bool char, int, signed char *);
17733 void vec_ste (vector bool char, int, unsigned char *);
17734 void vec_ste (vector signed short, int, short *);
17735 void vec_ste (vector unsigned short, int, unsigned short *);
17736 void vec_ste (vector bool short, int, short *);
17737 void vec_ste (vector bool short, int, unsigned short *);
17738 void vec_ste (vector pixel, int, short *);
17739 void vec_ste (vector pixel, int, unsigned short *);
17740 void vec_ste (vector float, int, float *);
17741 void vec_ste (vector signed int, int, int *);
17742 void vec_ste (vector unsigned int, int, unsigned int *);
17743 void vec_ste (vector bool int, int, int *);
17744 void vec_ste (vector bool int, int, unsigned int *);
17746 void vec_stl (vector float, int, vector float *);
17747 void vec_stl (vector float, int, float *);
17748 void vec_stl (vector signed int, int, vector signed int *);
17749 void vec_stl (vector signed int, int, int *);
17750 void vec_stl (vector unsigned int, int, vector unsigned int *);
17751 void vec_stl (vector unsigned int, int, unsigned int *);
17752 void vec_stl (vector bool int, int, vector bool int *);
17753 void vec_stl (vector bool int, int, unsigned int *);
17754 void vec_stl (vector bool int, int, int *);
17755 void vec_stl (vector signed short, int, vector signed short *);
17756 void vec_stl (vector signed short, int, short *);
17757 void vec_stl (vector unsigned short, int, vector unsigned short *);
17758 void vec_stl (vector unsigned short, int, unsigned short *);
17759 void vec_stl (vector bool short, int, vector bool short *);
17760 void vec_stl (vector bool short, int, unsigned short *);
17761 void vec_stl (vector bool short, int, short *);
17762 void vec_stl (vector pixel, int, vector pixel *);
17763 void vec_stl (vector signed char, int, vector signed char *);
17764 void vec_stl (vector signed char, int, signed char *);
17765 void vec_stl (vector unsigned char, int, vector unsigned char *);
17766 void vec_stl (vector unsigned char, int, unsigned char *);
17767 void vec_stl (vector bool char, int, vector bool char *);
17768 void vec_stl (vector bool char, int, unsigned char *);
17769 void vec_stl (vector bool char, int, signed char *);
17771 void vec_stvebx (vector signed char, int, signed char *);
17772 void vec_stvebx (vector unsigned char, int, unsigned char *);
17773 void vec_stvebx (vector bool char, int, signed char *);
17774 void vec_stvebx (vector bool char, int, unsigned char *);
17776 void vec_stvehx (vector signed short, int, short *);
17777 void vec_stvehx (vector unsigned short, int, unsigned short *);
17778 void vec_stvehx (vector bool short, int, short *);
17779 void vec_stvehx (vector bool short, int, unsigned short *);
17781 void vec_stvewx (vector float, int, float *);
17782 void vec_stvewx (vector signed int, int, int *);
17783 void vec_stvewx (vector unsigned int, int, unsigned int *);
17784 void vec_stvewx (vector bool int, int, int *);
17785 void vec_stvewx (vector bool int, int, unsigned int *);
17787 vector signed char vec_sub (vector bool char, vector signed char);
17788 vector signed char vec_sub (vector signed char, vector bool char);
17789 vector signed char vec_sub (vector signed char, vector signed char);
17790 vector unsigned char vec_sub (vector bool char, vector unsigned char);
17791 vector unsigned char vec_sub (vector unsigned char, vector bool char);
17792 vector unsigned char vec_sub (vector unsigned char, vector unsigned char);
17793 vector signed short vec_sub (vector bool short, vector signed short);
17794 vector signed short vec_sub (vector signed short, vector bool short);
17795 vector signed short vec_sub (vector signed short, vector signed short);
17796 vector unsigned short vec_sub (vector bool short, vector unsigned short);
17797 vector unsigned short vec_sub (vector unsigned short, vector bool short);
17798 vector unsigned short vec_sub (vector unsigned short, vector unsigned short);
17799 vector signed int vec_sub (vector bool int, vector signed int);
17800 vector signed int vec_sub (vector signed int, vector bool int);
17801 vector signed int vec_sub (vector signed int, vector signed int);
17802 vector unsigned int vec_sub (vector bool int, vector unsigned int);
17803 vector unsigned int vec_sub (vector unsigned int, vector bool int);
17804 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
17805 vector float vec_sub (vector float, vector float);
17807 vector signed int vec_subc (vector signed int, vector signed int);
17808 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
17810 vector signed int vec_sube (vector signed int, vector signed int,
17811 vector signed int);
17812 vector unsigned int vec_sube (vector unsigned int, vector unsigned int,
17813 vector unsigned int);
17815 vector signed int vec_subec (vector signed int, vector signed int,
17816 vector signed int);
17817 vector unsigned int vec_subec (vector unsigned int, vector unsigned int,
17818 vector unsigned int);
17820 vector unsigned char vec_subs (vector bool char, vector unsigned char);
17821 vector unsigned char vec_subs (vector unsigned char, vector bool char);
17822 vector unsigned char vec_subs (vector unsigned char, vector unsigned char);
17823 vector signed char vec_subs (vector bool char, vector signed char);
17824 vector signed char vec_subs (vector signed char, vector bool char);
17825 vector signed char vec_subs (vector signed char, vector signed char);
17826 vector unsigned short vec_subs (vector bool short, vector unsigned short);
17827 vector unsigned short vec_subs (vector unsigned short, vector bool short);
17828 vector unsigned short vec_subs (vector unsigned short, vector unsigned short);
17829 vector signed short vec_subs (vector bool short, vector signed short);
17830 vector signed short vec_subs (vector signed short, vector bool short);
17831 vector signed short vec_subs (vector signed short, vector signed short);
17832 vector unsigned int vec_subs (vector bool int, vector unsigned int);
17833 vector unsigned int vec_subs (vector unsigned int, vector bool int);
17834 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
17835 vector signed int vec_subs (vector bool int, vector signed int);
17836 vector signed int vec_subs (vector signed int, vector bool int);
17837 vector signed int vec_subs (vector signed int, vector signed int);
17839 vector signed int vec_sum2s (vector signed int, vector signed int);
17841 vector unsigned int vec_sum4s (vector unsigned char, vector unsigned int);
17842 vector signed int vec_sum4s (vector signed char, vector signed int);
17843 vector signed int vec_sum4s (vector signed short, vector signed int);
17845 vector signed int vec_sums (vector signed int, vector signed int);
17847 vector float vec_trunc (vector float);
17849 vector signed short vec_unpackh (vector signed char);
17850 vector bool short vec_unpackh (vector bool char);
17851 vector signed int vec_unpackh (vector signed short);
17852 vector bool int vec_unpackh (vector bool short);
17853 vector unsigned int vec_unpackh (vector pixel);
17855 vector signed short vec_unpackl (vector signed char);
17856 vector bool short vec_unpackl (vector bool char);
17857 vector unsigned int vec_unpackl (vector pixel);
17858 vector signed int vec_unpackl (vector signed short);
17859 vector bool int vec_unpackl (vector bool short);
17861 vector float vec_vaddfp (vector float, vector float);
17863 vector signed char vec_vaddsbs (vector bool char, vector signed char);
17864 vector signed char vec_vaddsbs (vector signed char, vector bool char);
17865 vector signed char vec_vaddsbs (vector signed char, vector signed char);
17867 vector signed short vec_vaddshs (vector bool short, vector signed short);
17868 vector signed short vec_vaddshs (vector signed short, vector bool short);
17869 vector signed short vec_vaddshs (vector signed short, vector signed short);
17871 vector signed int vec_vaddsws (vector bool int, vector signed int);
17872 vector signed int vec_vaddsws (vector signed int, vector bool int);
17873 vector signed int vec_vaddsws (vector signed int, vector signed int);
17875 vector signed char vec_vaddubm (vector bool char, vector signed char);
17876 vector signed char vec_vaddubm (vector signed char, vector bool char);
17877 vector signed char vec_vaddubm (vector signed char, vector signed char);
17878 vector unsigned char vec_vaddubm (vector bool char, vector unsigned char);
17879 vector unsigned char vec_vaddubm (vector unsigned char, vector bool char);
17880 vector unsigned char vec_vaddubm (vector unsigned char, vector unsigned char);
17882 vector unsigned char vec_vaddubs (vector bool char, vector unsigned char);
17883 vector unsigned char vec_vaddubs (vector unsigned char, vector bool char);
17884 vector unsigned char vec_vaddubs (vector unsigned char, vector unsigned char);
17886 vector signed short vec_vadduhm (vector bool short, vector signed short);
17887 vector signed short vec_vadduhm (vector signed short, vector bool short);
17888 vector signed short vec_vadduhm (vector signed short, vector signed short);
17889 vector unsigned short vec_vadduhm (vector bool short, vector unsigned short);
17890 vector unsigned short vec_vadduhm (vector unsigned short, vector bool short);
17891 vector unsigned short vec_vadduhm (vector unsigned short, vector unsigned short);
17893 vector unsigned short vec_vadduhs (vector bool short, vector unsigned short);
17894 vector unsigned short vec_vadduhs (vector unsigned short, vector bool short);
17895 vector unsigned short vec_vadduhs (vector unsigned short, vector unsigned short);
17897 vector signed int vec_vadduwm (vector bool int, vector signed int);
17898 vector signed int vec_vadduwm (vector signed int, vector bool int);
17899 vector signed int vec_vadduwm (vector signed int, vector signed int);
17900 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
17901 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
17902 vector unsigned int vec_vadduwm (vector unsigned int, vector unsigned int);
17904 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
17905 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
17906 vector unsigned int vec_vadduws (vector unsigned int, vector unsigned int);
17908 vector signed char vec_vavgsb (vector signed char, vector signed char);
17910 vector signed short vec_vavgsh (vector signed short, vector signed short);
17912 vector signed int vec_vavgsw (vector signed int, vector signed int);
17914 vector unsigned char vec_vavgub (vector unsigned char, vector unsigned char);
17916 vector unsigned short vec_vavguh (vector unsigned short, vector unsigned short);
17918 vector unsigned int vec_vavguw (vector unsigned int, vector unsigned int);
17920 vector float vec_vcfsx (vector signed int, const int);
17922 vector float vec_vcfux (vector unsigned int, const int);
17924 vector bool int vec_vcmpeqfp (vector float, vector float);
17926 vector bool char vec_vcmpequb (vector signed char, vector signed char);
17927 vector bool char vec_vcmpequb (vector unsigned char, vector unsigned char);
17929 vector bool short vec_vcmpequh (vector signed short, vector signed short);
17930 vector bool short vec_vcmpequh (vector unsigned short, vector unsigned short);
17932 vector bool int vec_vcmpequw (vector signed int, vector signed int);
17933 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
17935 vector bool int vec_vcmpgtfp (vector float, vector float);
17937 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
17939 vector bool short vec_vcmpgtsh (vector signed short, vector signed short);
17941 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
17943 vector bool char vec_vcmpgtub (vector unsigned char, vector unsigned char);
17945 vector bool short vec_vcmpgtuh (vector unsigned short, vector unsigned short);
17947 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
17949 vector float vec_vmaxfp (vector float, vector float);
17951 vector signed char vec_vmaxsb (vector bool char, vector signed char);
17952 vector signed char vec_vmaxsb (vector signed char, vector bool char);
17953 vector signed char vec_vmaxsb (vector signed char, vector signed char);
17955 vector signed short vec_vmaxsh (vector bool short, vector signed short);
17956 vector signed short vec_vmaxsh (vector signed short, vector bool short);
17957 vector signed short vec_vmaxsh (vector signed short, vector signed short);
17959 vector signed int vec_vmaxsw (vector bool int, vector signed int);
17960 vector signed int vec_vmaxsw (vector signed int, vector bool int);
17961 vector signed int vec_vmaxsw (vector signed int, vector signed int);
17963 vector unsigned char vec_vmaxub (vector bool char, vector unsigned char);
17964 vector unsigned char vec_vmaxub (vector unsigned char, vector bool char);
17965 vector unsigned char vec_vmaxub (vector unsigned char, vector unsigned char);
17967 vector unsigned short vec_vmaxuh (vector bool short, vector unsigned short);
17968 vector unsigned short vec_vmaxuh (vector unsigned short, vector bool short);
17969 vector unsigned short vec_vmaxuh (vector unsigned short, vector unsigned short);
17971 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
17972 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
17973 vector unsigned int vec_vmaxuw (vector unsigned int, vector unsigned int);
17975 vector float vec_vminfp (vector float, vector float);
17977 vector signed char vec_vminsb (vector bool char, vector signed char);
17978 vector signed char vec_vminsb (vector signed char, vector bool char);
17979 vector signed char vec_vminsb (vector signed char, vector signed char);
17981 vector signed short vec_vminsh (vector bool short, vector signed short);
17982 vector signed short vec_vminsh (vector signed short, vector bool short);
17983 vector signed short vec_vminsh (vector signed short, vector signed short);
17985 vector signed int vec_vminsw (vector bool int, vector signed int);
17986 vector signed int vec_vminsw (vector signed int, vector bool int);
17987 vector signed int vec_vminsw (vector signed int, vector signed int);
17989 vector unsigned char vec_vminub (vector bool char, vector unsigned char);
17990 vector unsigned char vec_vminub (vector unsigned char, vector bool char);
17991 vector unsigned char vec_vminub (vector unsigned char, vector unsigned char);
17993 vector unsigned short vec_vminuh (vector bool short, vector unsigned short);
17994 vector unsigned short vec_vminuh (vector unsigned short, vector bool short);
17995 vector unsigned short vec_vminuh (vector unsigned short, vector unsigned short);
17997 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
17998 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
17999 vector unsigned int vec_vminuw (vector unsigned int, vector unsigned int);
18001 vector bool char vec_vmrghb (vector bool char, vector bool char);
18002 vector signed char vec_vmrghb (vector signed char, vector signed char);
18003 vector unsigned char vec_vmrghb (vector unsigned char, vector unsigned char);
18005 vector bool short vec_vmrghh (vector bool short, vector bool short);
18006 vector signed short vec_vmrghh (vector signed short, vector signed short);
18007 vector unsigned short vec_vmrghh (vector unsigned short, vector unsigned short);
18008 vector pixel vec_vmrghh (vector pixel, vector pixel);
18010 vector float vec_vmrghw (vector float, vector float);
18011 vector bool int vec_vmrghw (vector bool int, vector bool int);
18012 vector signed int vec_vmrghw (vector signed int, vector signed int);
18013 vector unsigned int vec_vmrghw (vector unsigned int, vector unsigned int);
18015 vector bool char vec_vmrglb (vector bool char, vector bool char);
18016 vector signed char vec_vmrglb (vector signed char, vector signed char);
18017 vector unsigned char vec_vmrglb (vector unsigned char, vector unsigned char);
18019 vector bool short vec_vmrglh (vector bool short, vector bool short);
18020 vector signed short vec_vmrglh (vector signed short, vector signed short);
18021 vector unsigned short vec_vmrglh (vector unsigned short, vector unsigned short);
18022 vector pixel vec_vmrglh (vector pixel, vector pixel);
18024 vector float vec_vmrglw (vector float, vector float);
18025 vector signed int vec_vmrglw (vector signed int, vector signed int);
18026 vector unsigned int vec_vmrglw (vector unsigned int, vector unsigned int);
18027 vector bool int vec_vmrglw (vector bool int, vector bool int);
18029 vector signed int vec_vmsummbm (vector signed char, vector unsigned char,
18030 vector signed int);
18032 vector signed int vec_vmsumshm (vector signed short, vector signed short,
18033 vector signed int);
18035 vector signed int vec_vmsumshs (vector signed short, vector signed short,
18036 vector signed int);
18038 vector unsigned int vec_vmsumubm (vector unsigned char, vector unsigned char,
18039 vector unsigned int);
18041 vector unsigned int vec_vmsumuhm (vector unsigned short, vector unsigned short,
18042 vector unsigned int);
18044 vector unsigned int vec_vmsumuhs (vector unsigned short, vector unsigned short,
18045 vector unsigned int);
18047 vector signed short vec_vmulesb (vector signed char, vector signed char);
18049 vector signed int vec_vmulesh (vector signed short, vector signed short);
18051 vector unsigned short vec_vmuleub (vector unsigned char, vector unsigned char);
18053 vector unsigned int vec_vmuleuh (vector unsigned short, vector unsigned short);
18055 vector signed short vec_vmulosb (vector signed char, vector signed char);
18057 vector signed int vec_vmulosh (vector signed short, vector signed short);
18059 vector unsigned short vec_vmuloub (vector unsigned char, vector unsigned char);
18061 vector unsigned int vec_vmulouh (vector unsigned short, vector unsigned short);
18063 vector signed char vec_vpkshss (vector signed short, vector signed short);
18065 vector unsigned char vec_vpkshus (vector signed short, vector signed short);
18067 vector signed short vec_vpkswss (vector signed int, vector signed int);
18069 vector unsigned short vec_vpkswus (vector signed int, vector signed int);
18071 vector bool char vec_vpkuhum (vector bool short, vector bool short);
18072 vector signed char vec_vpkuhum (vector signed short, vector signed short);
18073 vector unsigned char vec_vpkuhum (vector unsigned short, vector unsigned short);
18075 vector unsigned char vec_vpkuhus (vector unsigned short, vector unsigned short);
18077 vector bool short vec_vpkuwum (vector bool int, vector bool int);
18078 vector signed short vec_vpkuwum (vector signed int, vector signed int);
18079 vector unsigned short vec_vpkuwum (vector unsigned int, vector unsigned int);
18081 vector unsigned short vec_vpkuwus (vector unsigned int, vector unsigned int);
18083 vector signed char vec_vrlb (vector signed char, vector unsigned char);
18084 vector unsigned char vec_vrlb (vector unsigned char, vector unsigned char);
18086 vector signed short vec_vrlh (vector signed short, vector unsigned short);
18087 vector unsigned short vec_vrlh (vector unsigned short, vector unsigned short);
18089 vector signed int vec_vrlw (vector signed int, vector unsigned int);
18090 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
18092 vector signed char vec_vslb (vector signed char, vector unsigned char);
18093 vector unsigned char vec_vslb (vector unsigned char, vector unsigned char);
18095 vector signed short vec_vslh (vector signed short, vector unsigned short);
18096 vector unsigned short vec_vslh (vector unsigned short, vector unsigned short);
18098 vector signed int vec_vslw (vector signed int, vector unsigned int);
18099 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
18101 vector signed char vec_vspltb (vector signed char, const int);
18102 vector unsigned char vec_vspltb (vector unsigned char, const int);
18103 vector bool char vec_vspltb (vector bool char, const int);
18105 vector bool short vec_vsplth (vector bool short, const int);
18106 vector signed short vec_vsplth (vector signed short, const int);
18107 vector unsigned short vec_vsplth (vector unsigned short, const int);
18108 vector pixel vec_vsplth (vector pixel, const int);
18110 vector float vec_vspltw (vector float, const int);
18111 vector signed int vec_vspltw (vector signed int, const int);
18112 vector unsigned int vec_vspltw (vector unsigned int, const int);
18113 vector bool int vec_vspltw (vector bool int, const int);
18115 vector signed char vec_vsrab (vector signed char, vector unsigned char);
18116 vector unsigned char vec_vsrab (vector unsigned char, vector unsigned char);
18118 vector signed short vec_vsrah (vector signed short, vector unsigned short);
18119 vector unsigned short vec_vsrah (vector unsigned short, vector unsigned short);
18121 vector signed int vec_vsraw (vector signed int, vector unsigned int);
18122 vector unsigned int vec_vsraw (vector unsigned int, vector unsigned int);
18124 vector signed char vec_vsrb (vector signed char, vector unsigned char);
18125 vector unsigned char vec_vsrb (vector unsigned char, vector unsigned char);
18127 vector signed short vec_vsrh (vector signed short, vector unsigned short);
18128 vector unsigned short vec_vsrh (vector unsigned short, vector unsigned short);
18130 vector signed int vec_vsrw (vector signed int, vector unsigned int);
18131 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
18133 vector float vec_vsubfp (vector float, vector float);
18135 vector signed char vec_vsubsbs (vector bool char, vector signed char);
18136 vector signed char vec_vsubsbs (vector signed char, vector bool char);
18137 vector signed char vec_vsubsbs (vector signed char, vector signed char);
18139 vector signed short vec_vsubshs (vector bool short, vector signed short);
18140 vector signed short vec_vsubshs (vector signed short, vector bool short);
18141 vector signed short vec_vsubshs (vector signed short, vector signed short);
18143 vector signed int vec_vsubsws (vector bool int, vector signed int);
18144 vector signed int vec_vsubsws (vector signed int, vector bool int);
18145 vector signed int vec_vsubsws (vector signed int, vector signed int);
18147 vector signed char vec_vsububm (vector bool char, vector signed char);
18148 vector signed char vec_vsububm (vector signed char, vector bool char);
18149 vector signed char vec_vsububm (vector signed char, vector signed char);
18150 vector unsigned char vec_vsububm (vector bool char, vector unsigned char);
18151 vector unsigned char vec_vsububm (vector unsigned char, vector bool char);
18152 vector unsigned char vec_vsububm (vector unsigned char, vector unsigned char);
18154 vector unsigned char vec_vsububs (vector bool char, vector unsigned char);
18155 vector unsigned char vec_vsububs (vector unsigned char, vector bool char);
18156 vector unsigned char vec_vsububs (vector unsigned char, vector unsigned char);
18158 vector signed short vec_vsubuhm (vector bool short, vector signed short);
18159 vector signed short vec_vsubuhm (vector signed short, vector bool short);
18160 vector signed short vec_vsubuhm (vector signed short, vector signed short);
18161 vector unsigned short vec_vsubuhm (vector bool short, vector unsigned short);
18162 vector unsigned short vec_vsubuhm (vector unsigned short, vector bool short);
18163 vector unsigned short vec_vsubuhm (vector unsigned short, vector unsigned short);
18165 vector unsigned short vec_vsubuhs (vector bool short, vector unsigned short);
18166 vector unsigned short vec_vsubuhs (vector unsigned short, vector bool short);
18167 vector unsigned short vec_vsubuhs (vector unsigned short, vector unsigned short);
18169 vector signed int vec_vsubuwm (vector bool int, vector signed int);
18170 vector signed int vec_vsubuwm (vector signed int, vector bool int);
18171 vector signed int vec_vsubuwm (vector signed int, vector signed int);
18172 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
18173 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
18174 vector unsigned int vec_vsubuwm (vector unsigned int, vector unsigned int);
18176 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
18177 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
18178 vector unsigned int vec_vsubuws (vector unsigned int, vector unsigned int);
18180 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
18182 vector signed int vec_vsum4shs (vector signed short, vector signed int);
18184 vector unsigned int vec_vsum4ubs (vector unsigned char, vector unsigned int);
18186 vector unsigned int vec_vupkhpx (vector pixel);
18188 vector bool short vec_vupkhsb (vector bool char);
18189 vector signed short vec_vupkhsb (vector signed char);
18191 vector bool int vec_vupkhsh (vector bool short);
18192 vector signed int vec_vupkhsh (vector signed short);
18194 vector unsigned int vec_vupklpx (vector pixel);
18196 vector bool short vec_vupklsb (vector bool char);
18197 vector signed short vec_vupklsb (vector signed char);
18199 vector bool int vec_vupklsh (vector bool short);
18200 vector signed int vec_vupklsh (vector signed short);
18202 vector float vec_xor (vector float, vector float);
18203 vector float vec_xor (vector float, vector bool int);
18204 vector float vec_xor (vector bool int, vector float);
18205 vector bool int vec_xor (vector bool int, vector bool int);
18206 vector signed int vec_xor (vector bool int, vector signed int);
18207 vector signed int vec_xor (vector signed int, vector bool int);
18208 vector signed int vec_xor (vector signed int, vector signed int);
18209 vector unsigned int vec_xor (vector bool int, vector unsigned int);
18210 vector unsigned int vec_xor (vector unsigned int, vector bool int);
18211 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
18212 vector bool short vec_xor (vector bool short, vector bool short);
18213 vector signed short vec_xor (vector bool short, vector signed short);
18214 vector signed short vec_xor (vector signed short, vector bool short);
18215 vector signed short vec_xor (vector signed short, vector signed short);
18216 vector unsigned short vec_xor (vector bool short, vector unsigned short);
18217 vector unsigned short vec_xor (vector unsigned short, vector bool short);
18218 vector unsigned short vec_xor (vector unsigned short, vector unsigned short);
18219 vector signed char vec_xor (vector bool char, vector signed char);
18220 vector bool char vec_xor (vector bool char, vector bool char);
18221 vector signed char vec_xor (vector signed char, vector bool char);
18222 vector signed char vec_xor (vector signed char, vector signed char);
18223 vector unsigned char vec_xor (vector bool char, vector unsigned char);
18224 vector unsigned char vec_xor (vector unsigned char, vector bool char);
18225 vector unsigned char vec_xor (vector unsigned char, vector unsigned char);
18228 @node PowerPC AltiVec Built-in Functions Available on ISA 2.06
18229 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.06
18231 The AltiVec built-in functions described in this section are
18232 available on the PowerPC family of processors starting with ISA 2.06
18233 or later. These are normally enabled by adding @option{-mvsx} to the
18236 When @option{-mvsx} is used, the following additional vector types are
18240 vector unsigned __int128
18241 vector signed __int128
18242 vector unsigned long long int
18243 vector signed long long int
18247 The long long types are only implemented for 64-bit code generation.
18251 vector bool long long vec_and (vector bool long long int, vector bool long long);
18253 vector double vec_ctf (vector unsigned long, const int);
18254 vector double vec_ctf (vector signed long, const int);
18256 vector signed long vec_cts (vector double, const int);
18258 vector unsigned long vec_ctu (vector double, const int);
18260 void vec_dst (const unsigned long *, int, const int);
18261 void vec_dst (const long *, int, const int);
18263 void vec_dststt (const unsigned long *, int, const int);
18264 void vec_dststt (const long *, int, const int);
18266 void vec_dstt (const unsigned long *, int, const int);
18267 void vec_dstt (const long *, int, const int);
18269 vector unsigned char vec_lvsl (int, const unsigned long *);
18270 vector unsigned char vec_lvsl (int, const long *);
18272 vector unsigned char vec_lvsr (int, const unsigned long *);
18273 vector unsigned char vec_lvsr (int, const long *);
18275 vector double vec_mul (vector double, vector double);
18276 vector long vec_mul (vector long, vector long);
18277 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
18279 vector unsigned long long vec_mule (vector unsigned int, vector unsigned int);
18280 vector signed long long vec_mule (vector signed int, vector signed int);
18282 vector unsigned long long vec_mulo (vector unsigned int, vector unsigned int);
18283 vector signed long long vec_mulo (vector signed int, vector signed int);
18285 vector double vec_nabs (vector double);
18287 vector bool long long vec_reve (vector bool long long);
18288 vector signed long long vec_reve (vector signed long long);
18289 vector unsigned long long vec_reve (vector unsigned long long);
18290 vector double vec_sld (vector double, vector double, const int);
18292 vector bool long long int vec_sld (vector bool long long int,
18293 vector bool long long int, const int);
18294 vector long long int vec_sld (vector long long int, vector long long int, const int);
18295 vector unsigned long long int vec_sld (vector unsigned long long int,
18296 vector unsigned long long int, const int);
18298 vector long long int vec_sll (vector long long int, vector unsigned char);
18299 vector unsigned long long int vec_sll (vector unsigned long long int,
18300 vector unsigned char);
18302 vector signed long long vec_slo (vector signed long long, vector signed char);
18303 vector signed long long vec_slo (vector signed long long, vector unsigned char);
18304 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
18305 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
18307 vector signed long vec_splat (vector signed long, const int);
18308 vector unsigned long vec_splat (vector unsigned long, const int);
18310 vector long long int vec_srl (vector long long int, vector unsigned char);
18311 vector unsigned long long int vec_srl (vector unsigned long long int,
18312 vector unsigned char);
18314 vector long long int vec_sro (vector long long int, vector char);
18315 vector long long int vec_sro (vector long long int, vector unsigned char);
18316 vector unsigned long long int vec_sro (vector unsigned long long int, vector char);
18317 vector unsigned long long int vec_sro (vector unsigned long long int,
18318 vector unsigned char);
18320 vector signed __int128 vec_subc (vector signed __int128, vector signed __int128);
18321 vector unsigned __int128 vec_subc (vector unsigned __int128, vector unsigned __int128);
18323 vector signed __int128 vec_sube (vector signed __int128, vector signed __int128,
18324 vector signed __int128);
18325 vector unsigned __int128 vec_sube (vector unsigned __int128, vector unsigned __int128,
18326 vector unsigned __int128);
18328 vector signed __int128 vec_subec (vector signed __int128, vector signed __int128,
18329 vector signed __int128);
18330 vector unsigned __int128 vec_subec (vector unsigned __int128, vector unsigned __int128,
18331 vector unsigned __int128);
18333 vector double vec_unpackh (vector float);
18335 vector double vec_unpackl (vector float);
18337 vector double vec_doublee (vector float);
18338 vector double vec_doublee (vector signed int);
18339 vector double vec_doublee (vector unsigned int);
18341 vector double vec_doubleo (vector float);
18342 vector double vec_doubleo (vector signed int);
18343 vector double vec_doubleo (vector unsigned int);
18345 vector double vec_doubleh (vector float);
18346 vector double vec_doubleh (vector signed int);
18347 vector double vec_doubleh (vector unsigned int);
18349 vector double vec_doublel (vector float);
18350 vector double vec_doublel (vector signed int);
18351 vector double vec_doublel (vector unsigned int);
18353 vector float vec_float (vector signed int);
18354 vector float vec_float (vector unsigned int);
18356 vector float vec_float2 (vector signed long long, vector signed long long);
18357 vector float vec_float2 (vector unsigned long long, vector signed long long);
18359 vector float vec_floate (vector double);
18360 vector float vec_floate (vector signed long long);
18361 vector float vec_floate (vector unsigned long long);
18363 vector float vec_floato (vector double);
18364 vector float vec_floato (vector signed long long);
18365 vector float vec_floato (vector unsigned long long);
18367 vector signed long long vec_signed (vector double);
18368 vector signed int vec_signed (vector float);
18370 vector signed int vec_signede (vector double);
18372 vector signed int vec_signedo (vector double);
18374 vector signed char vec_sldw (vector signed char, vector signed char, const int);
18375 vector unsigned char vec_sldw (vector unsigned char, vector unsigned char, const int);
18376 vector signed short vec_sldw (vector signed short, vector signed short, const int);
18377 vector unsigned short vec_sldw (vector unsigned short,
18378 vector unsigned short, const int);
18379 vector signed int vec_sldw (vector signed int, vector signed int, const int);
18380 vector unsigned int vec_sldw (vector unsigned int, vector unsigned int, const int);
18381 vector signed long long vec_sldw (vector signed long long,
18382 vector signed long long, const int);
18383 vector unsigned long long vec_sldw (vector unsigned long long,
18384 vector unsigned long long, const int);
18386 vector signed long long vec_unsigned (vector double);
18387 vector signed int vec_unsigned (vector float);
18389 vector signed int vec_unsignede (vector double);
18391 vector signed int vec_unsignedo (vector double);
18393 vector double vec_abs (vector double);
18394 vector double vec_add (vector double, vector double);
18395 vector double vec_and (vector double, vector double);
18396 vector double vec_and (vector double, vector bool long);
18397 vector double vec_and (vector bool long, vector double);
18398 vector long vec_and (vector long, vector long);
18399 vector long vec_and (vector long, vector bool long);
18400 vector long vec_and (vector bool long, vector long);
18401 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
18402 vector unsigned long vec_and (vector unsigned long, vector bool long);
18403 vector unsigned long vec_and (vector bool long, vector unsigned long);
18404 vector double vec_andc (vector double, vector double);
18405 vector double vec_andc (vector double, vector bool long);
18406 vector double vec_andc (vector bool long, vector double);
18407 vector long vec_andc (vector long, vector long);
18408 vector long vec_andc (vector long, vector bool long);
18409 vector long vec_andc (vector bool long, vector long);
18410 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
18411 vector unsigned long vec_andc (vector unsigned long, vector bool long);
18412 vector unsigned long vec_andc (vector bool long, vector unsigned long);
18413 vector double vec_ceil (vector double);
18414 vector bool long vec_cmpeq (vector double, vector double);
18415 vector bool long vec_cmpge (vector double, vector double);
18416 vector bool long vec_cmpgt (vector double, vector double);
18417 vector bool long vec_cmple (vector double, vector double);
18418 vector bool long vec_cmplt (vector double, vector double);
18419 vector double vec_cpsgn (vector double, vector double);
18420 vector float vec_div (vector float, vector float);
18421 vector double vec_div (vector double, vector double);
18422 vector long vec_div (vector long, vector long);
18423 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
18424 vector double vec_floor (vector double);
18425 vector __int128 vec_ld (int, const vector __int128 *);
18426 vector unsigned __int128 vec_ld (int, const vector unsigned __int128 *);
18427 vector __int128 vec_ld (int, const __int128 *);
18428 vector unsigned __int128 vec_ld (int, const unsigned __int128 *);
18429 vector double vec_ld (int, const vector double *);
18430 vector double vec_ld (int, const double *);
18431 vector double vec_ldl (int, const vector double *);
18432 vector double vec_ldl (int, const double *);
18433 vector unsigned char vec_lvsl (int, const double *);
18434 vector unsigned char vec_lvsr (int, const double *);
18435 vector double vec_madd (vector double, vector double, vector double);
18436 vector double vec_max (vector double, vector double);
18437 vector signed long vec_mergeh (vector signed long, vector signed long);
18438 vector signed long vec_mergeh (vector signed long, vector bool long);
18439 vector signed long vec_mergeh (vector bool long, vector signed long);
18440 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
18441 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
18442 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
18443 vector signed long vec_mergel (vector signed long, vector signed long);
18444 vector signed long vec_mergel (vector signed long, vector bool long);
18445 vector signed long vec_mergel (vector bool long, vector signed long);
18446 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
18447 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
18448 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
18449 vector double vec_min (vector double, vector double);
18450 vector float vec_msub (vector float, vector float, vector float);
18451 vector double vec_msub (vector double, vector double, vector double);
18452 vector float vec_nearbyint (vector float);
18453 vector double vec_nearbyint (vector double);
18454 vector float vec_nmadd (vector float, vector float, vector float);
18455 vector double vec_nmadd (vector double, vector double, vector double);
18456 vector double vec_nmsub (vector double, vector double, vector double);
18457 vector double vec_nor (vector double, vector double);
18458 vector long vec_nor (vector long, vector long);
18459 vector long vec_nor (vector long, vector bool long);
18460 vector long vec_nor (vector bool long, vector long);
18461 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
18462 vector unsigned long vec_nor (vector unsigned long, vector bool long);
18463 vector unsigned long vec_nor (vector bool long, vector unsigned long);
18464 vector double vec_or (vector double, vector double);
18465 vector double vec_or (vector double, vector bool long);
18466 vector double vec_or (vector bool long, vector double);
18467 vector long vec_or (vector long, vector long);
18468 vector long vec_or (vector long, vector bool long);
18469 vector long vec_or (vector bool long, vector long);
18470 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
18471 vector unsigned long vec_or (vector unsigned long, vector bool long);
18472 vector unsigned long vec_or (vector bool long, vector unsigned long);
18473 vector double vec_perm (vector double, vector double, vector unsigned char);
18474 vector long vec_perm (vector long, vector long, vector unsigned char);
18475 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
18476 vector unsigned char);
18477 vector bool char vec_permxor (vector bool char, vector bool char,
18479 vector unsigned char vec_permxor (vector signed char, vector signed char,
18480 vector signed char);
18481 vector unsigned char vec_permxor (vector unsigned char, vector unsigned char,
18482 vector unsigned char);
18483 vector double vec_rint (vector double);
18484 vector double vec_recip (vector double, vector double);
18485 vector double vec_rsqrt (vector double);
18486 vector double vec_rsqrte (vector double);
18487 vector double vec_sel (vector double, vector double, vector bool long);
18488 vector double vec_sel (vector double, vector double, vector unsigned long);
18489 vector long vec_sel (vector long, vector long, vector long);
18490 vector long vec_sel (vector long, vector long, vector unsigned long);
18491 vector long vec_sel (vector long, vector long, vector bool long);
18492 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18494 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18495 vector unsigned long);
18496 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18498 vector double vec_splats (double);
18499 vector signed long vec_splats (signed long);
18500 vector unsigned long vec_splats (unsigned long);
18501 vector float vec_sqrt (vector float);
18502 vector double vec_sqrt (vector double);
18503 void vec_st (vector double, int, vector double *);
18504 void vec_st (vector double, int, double *);
18505 vector double vec_sub (vector double, vector double);
18506 vector double vec_trunc (vector double);
18507 vector double vec_xl (int, vector double *);
18508 vector double vec_xl (int, double *);
18509 vector long long vec_xl (int, vector long long *);
18510 vector long long vec_xl (int, long long *);
18511 vector unsigned long long vec_xl (int, vector unsigned long long *);
18512 vector unsigned long long vec_xl (int, unsigned long long *);
18513 vector float vec_xl (int, vector float *);
18514 vector float vec_xl (int, float *);
18515 vector int vec_xl (int, vector int *);
18516 vector int vec_xl (int, int *);
18517 vector unsigned int vec_xl (int, vector unsigned int *);
18518 vector unsigned int vec_xl (int, unsigned int *);
18519 vector double vec_xor (vector double, vector double);
18520 vector double vec_xor (vector double, vector bool long);
18521 vector double vec_xor (vector bool long, vector double);
18522 vector long vec_xor (vector long, vector long);
18523 vector long vec_xor (vector long, vector bool long);
18524 vector long vec_xor (vector bool long, vector long);
18525 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
18526 vector unsigned long vec_xor (vector unsigned long, vector bool long);
18527 vector unsigned long vec_xor (vector bool long, vector unsigned long);
18528 void vec_xst (vector double, int, vector double *);
18529 void vec_xst (vector double, int, double *);
18530 void vec_xst (vector long long, int, vector long long *);
18531 void vec_xst (vector long long, int, long long *);
18532 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
18533 void vec_xst (vector unsigned long long, int, unsigned long long *);
18534 void vec_xst (vector float, int, vector float *);
18535 void vec_xst (vector float, int, float *);
18536 void vec_xst (vector int, int, vector int *);
18537 void vec_xst (vector int, int, int *);
18538 void vec_xst (vector unsigned int, int, vector unsigned int *);
18539 void vec_xst (vector unsigned int, int, unsigned int *);
18540 int vec_all_eq (vector double, vector double);
18541 int vec_all_ge (vector double, vector double);
18542 int vec_all_gt (vector double, vector double);
18543 int vec_all_le (vector double, vector double);
18544 int vec_all_lt (vector double, vector double);
18545 int vec_all_nan (vector double);
18546 int vec_all_ne (vector double, vector double);
18547 int vec_all_nge (vector double, vector double);
18548 int vec_all_ngt (vector double, vector double);
18549 int vec_all_nle (vector double, vector double);
18550 int vec_all_nlt (vector double, vector double);
18551 int vec_all_numeric (vector double);
18552 int vec_any_eq (vector double, vector double);
18553 int vec_any_ge (vector double, vector double);
18554 int vec_any_gt (vector double, vector double);
18555 int vec_any_le (vector double, vector double);
18556 int vec_any_lt (vector double, vector double);
18557 int vec_any_nan (vector double);
18558 int vec_any_ne (vector double, vector double);
18559 int vec_any_nge (vector double, vector double);
18560 int vec_any_ngt (vector double, vector double);
18561 int vec_any_nle (vector double, vector double);
18562 int vec_any_nlt (vector double, vector double);
18563 int vec_any_numeric (vector double);
18565 vector double vec_vsx_ld (int, const vector double *);
18566 vector double vec_vsx_ld (int, const double *);
18567 vector float vec_vsx_ld (int, const vector float *);
18568 vector float vec_vsx_ld (int, const float *);
18569 vector bool int vec_vsx_ld (int, const vector bool int *);
18570 vector signed int vec_vsx_ld (int, const vector signed int *);
18571 vector signed int vec_vsx_ld (int, const int *);
18572 vector signed int vec_vsx_ld (int, const long *);
18573 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
18574 vector unsigned int vec_vsx_ld (int, const unsigned int *);
18575 vector unsigned int vec_vsx_ld (int, const unsigned long *);
18576 vector bool short vec_vsx_ld (int, const vector bool short *);
18577 vector pixel vec_vsx_ld (int, const vector pixel *);
18578 vector signed short vec_vsx_ld (int, const vector signed short *);
18579 vector signed short vec_vsx_ld (int, const short *);
18580 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
18581 vector unsigned short vec_vsx_ld (int, const unsigned short *);
18582 vector bool char vec_vsx_ld (int, const vector bool char *);
18583 vector signed char vec_vsx_ld (int, const vector signed char *);
18584 vector signed char vec_vsx_ld (int, const signed char *);
18585 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
18586 vector unsigned char vec_vsx_ld (int, const unsigned char *);
18588 void vec_vsx_st (vector double, int, vector double *);
18589 void vec_vsx_st (vector double, int, double *);
18590 void vec_vsx_st (vector float, int, vector float *);
18591 void vec_vsx_st (vector float, int, float *);
18592 void vec_vsx_st (vector signed int, int, vector signed int *);
18593 void vec_vsx_st (vector signed int, int, int *);
18594 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
18595 void vec_vsx_st (vector unsigned int, int, unsigned int *);
18596 void vec_vsx_st (vector bool int, int, vector bool int *);
18597 void vec_vsx_st (vector bool int, int, unsigned int *);
18598 void vec_vsx_st (vector bool int, int, int *);
18599 void vec_vsx_st (vector signed short, int, vector signed short *);
18600 void vec_vsx_st (vector signed short, int, short *);
18601 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
18602 void vec_vsx_st (vector unsigned short, int, unsigned short *);
18603 void vec_vsx_st (vector bool short, int, vector bool short *);
18604 void vec_vsx_st (vector bool short, int, unsigned short *);
18605 void vec_vsx_st (vector pixel, int, vector pixel *);
18606 void vec_vsx_st (vector pixel, int, unsigned short *);
18607 void vec_vsx_st (vector pixel, int, short *);
18608 void vec_vsx_st (vector bool short, int, short *);
18609 void vec_vsx_st (vector signed char, int, vector signed char *);
18610 void vec_vsx_st (vector signed char, int, signed char *);
18611 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
18612 void vec_vsx_st (vector unsigned char, int, unsigned char *);
18613 void vec_vsx_st (vector bool char, int, vector bool char *);
18614 void vec_vsx_st (vector bool char, int, unsigned char *);
18615 void vec_vsx_st (vector bool char, int, signed char *);
18617 vector double vec_xxpermdi (vector double, vector double, const int);
18618 vector float vec_xxpermdi (vector float, vector float, const int);
18619 vector long long vec_xxpermdi (vector long long, vector long long, const int);
18620 vector unsigned long long vec_xxpermdi (vector unsigned long long,
18621 vector unsigned long long, const int);
18622 vector int vec_xxpermdi (vector int, vector int, const int);
18623 vector unsigned int vec_xxpermdi (vector unsigned int,
18624 vector unsigned int, const int);
18625 vector short vec_xxpermdi (vector short, vector short, const int);
18626 vector unsigned short vec_xxpermdi (vector unsigned short,
18627 vector unsigned short, const int);
18628 vector signed char vec_xxpermdi (vector signed char, vector signed char,
18630 vector unsigned char vec_xxpermdi (vector unsigned char,
18631 vector unsigned char, const int);
18633 vector double vec_xxsldi (vector double, vector double, int);
18634 vector float vec_xxsldi (vector float, vector float, int);
18635 vector long long vec_xxsldi (vector long long, vector long long, int);
18636 vector unsigned long long vec_xxsldi (vector unsigned long long,
18637 vector unsigned long long, int);
18638 vector int vec_xxsldi (vector int, vector int, int);
18639 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
18640 vector short vec_xxsldi (vector short, vector short, int);
18641 vector unsigned short vec_xxsldi (vector unsigned short,
18642 vector unsigned short, int);
18643 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
18644 vector unsigned char vec_xxsldi (vector unsigned char,
18645 vector unsigned char, int);
18648 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
18649 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
18650 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
18651 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
18652 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
18654 @node PowerPC AltiVec Built-in Functions Available on ISA 2.07
18655 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.07
18657 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18658 instruction set are available, the following additional functions are
18659 available for both 32-bit and 64-bit targets. For 64-bit targets, you
18660 can use @var{vector long} instead of @var{vector long long},
18661 @var{vector bool long} instead of @var{vector bool long long}, and
18662 @var{vector unsigned long} instead of @var{vector unsigned long long}.
18665 vector signed char vec_neg (vector signed char);
18666 vector signed short vec_neg (vector signed short);
18667 vector signed int vec_neg (vector signed int);
18668 vector signed long long vec_neg (vector signed long long);
18669 vector float char vec_neg (vector float);
18670 vector double vec_neg (vector double);
18672 vector signed int vec_signed2 (vector double, vector double);
18674 vector signed int vec_unsigned2 (vector double, vector double);
18676 vector long long vec_abs (vector long long);
18678 vector long long vec_add (vector long long, vector long long);
18679 vector unsigned long long vec_add (vector unsigned long long,
18680 vector unsigned long long);
18682 int vec_all_eq (vector long long, vector long long);
18683 int vec_all_eq (vector unsigned long long, vector unsigned long long);
18684 int vec_all_ge (vector long long, vector long long);
18685 int vec_all_ge (vector unsigned long long, vector unsigned long long);
18686 int vec_all_gt (vector long long, vector long long);
18687 int vec_all_gt (vector unsigned long long, vector unsigned long long);
18688 int vec_all_le (vector long long, vector long long);
18689 int vec_all_le (vector unsigned long long, vector unsigned long long);
18690 int vec_all_lt (vector long long, vector long long);
18691 int vec_all_lt (vector unsigned long long, vector unsigned long long);
18692 int vec_all_ne (vector long long, vector long long);
18693 int vec_all_ne (vector unsigned long long, vector unsigned long long);
18695 int vec_any_eq (vector long long, vector long long);
18696 int vec_any_eq (vector unsigned long long, vector unsigned long long);
18697 int vec_any_ge (vector long long, vector long long);
18698 int vec_any_ge (vector unsigned long long, vector unsigned long long);
18699 int vec_any_gt (vector long long, vector long long);
18700 int vec_any_gt (vector unsigned long long, vector unsigned long long);
18701 int vec_any_le (vector long long, vector long long);
18702 int vec_any_le (vector unsigned long long, vector unsigned long long);
18703 int vec_any_lt (vector long long, vector long long);
18704 int vec_any_lt (vector unsigned long long, vector unsigned long long);
18705 int vec_any_ne (vector long long, vector long long);
18706 int vec_any_ne (vector unsigned long long, vector unsigned long long);
18708 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
18710 vector long long vec_eqv (vector long long, vector long long);
18711 vector long long vec_eqv (vector bool long long, vector long long);
18712 vector long long vec_eqv (vector long long, vector bool long long);
18713 vector unsigned long long vec_eqv (vector unsigned long long, vector unsigned long long);
18714 vector unsigned long long vec_eqv (vector bool long long, vector unsigned long long);
18715 vector unsigned long long vec_eqv (vector unsigned long long,
18716 vector bool long long);
18717 vector int vec_eqv (vector int, vector int);
18718 vector int vec_eqv (vector bool int, vector int);
18719 vector int vec_eqv (vector int, vector bool int);
18720 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
18721 vector unsigned int vec_eqv (vector bool unsigned int, vector unsigned int);
18722 vector unsigned int vec_eqv (vector unsigned int, vector bool unsigned int);
18723 vector short vec_eqv (vector short, vector short);
18724 vector short vec_eqv (vector bool short, vector short);
18725 vector short vec_eqv (vector short, vector bool short);
18726 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
18727 vector unsigned short vec_eqv (vector bool unsigned short, vector unsigned short);
18728 vector unsigned short vec_eqv (vector unsigned short, vector bool unsigned short);
18729 vector signed char vec_eqv (vector signed char, vector signed char);
18730 vector signed char vec_eqv (vector bool signed char, vector signed char);
18731 vector signed char vec_eqv (vector signed char, vector bool signed char);
18732 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
18733 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
18734 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
18736 vector long long vec_max (vector long long, vector long long);
18737 vector unsigned long long vec_max (vector unsigned long long,
18738 vector unsigned long long);
18740 vector signed int vec_mergee (vector signed int, vector signed int);
18741 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
18742 vector bool int vec_mergee (vector bool int, vector bool int);
18744 vector signed int vec_mergeo (vector signed int, vector signed int);
18745 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
18746 vector bool int vec_mergeo (vector bool int, vector bool int);
18748 vector long long vec_min (vector long long, vector long long);
18749 vector unsigned long long vec_min (vector unsigned long long,
18750 vector unsigned long long);
18752 vector signed long long vec_nabs (vector signed long long);
18754 vector long long vec_nand (vector long long, vector long long);
18755 vector long long vec_nand (vector bool long long, vector long long);
18756 vector long long vec_nand (vector long long, vector bool long long);
18757 vector unsigned long long vec_nand (vector unsigned long long,
18758 vector unsigned long long);
18759 vector unsigned long long vec_nand (vector bool long long, vector unsigned long long);
18760 vector unsigned long long vec_nand (vector unsigned long long, vector bool long long);
18761 vector int vec_nand (vector int, vector int);
18762 vector int vec_nand (vector bool int, vector int);
18763 vector int vec_nand (vector int, vector bool int);
18764 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
18765 vector unsigned int vec_nand (vector bool unsigned int, vector unsigned int);
18766 vector unsigned int vec_nand (vector unsigned int, vector bool unsigned int);
18767 vector short vec_nand (vector short, vector short);
18768 vector short vec_nand (vector bool short, vector short);
18769 vector short vec_nand (vector short, vector bool short);
18770 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
18771 vector unsigned short vec_nand (vector bool unsigned short, vector unsigned short);
18772 vector unsigned short vec_nand (vector unsigned short, vector bool unsigned short);
18773 vector signed char vec_nand (vector signed char, vector signed char);
18774 vector signed char vec_nand (vector bool signed char, vector signed char);
18775 vector signed char vec_nand (vector signed char, vector bool signed char);
18776 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
18777 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
18778 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
18780 vector long long vec_orc (vector long long, vector long long);
18781 vector long long vec_orc (vector bool long long, vector long long);
18782 vector long long vec_orc (vector long long, vector bool long long);
18783 vector unsigned long long vec_orc (vector unsigned long long,
18784 vector unsigned long long);
18785 vector unsigned long long vec_orc (vector bool long long, vector unsigned long long);
18786 vector unsigned long long vec_orc (vector unsigned long long, vector bool long long);
18787 vector int vec_orc (vector int, vector int);
18788 vector int vec_orc (vector bool int, vector int);
18789 vector int vec_orc (vector int, vector bool int);
18790 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
18791 vector unsigned int vec_orc (vector bool unsigned int, vector unsigned int);
18792 vector unsigned int vec_orc (vector unsigned int, vector bool unsigned int);
18793 vector short vec_orc (vector short, vector short);
18794 vector short vec_orc (vector bool short, vector short);
18795 vector short vec_orc (vector short, vector bool short);
18796 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
18797 vector unsigned short vec_orc (vector bool unsigned short, vector unsigned short);
18798 vector unsigned short vec_orc (vector unsigned short, vector bool unsigned short);
18799 vector signed char vec_orc (vector signed char, vector signed char);
18800 vector signed char vec_orc (vector bool signed char, vector signed char);
18801 vector signed char vec_orc (vector signed char, vector bool signed char);
18802 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
18803 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
18804 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
18806 vector int vec_pack (vector long long, vector long long);
18807 vector unsigned int vec_pack (vector unsigned long long, vector unsigned long long);
18808 vector bool int vec_pack (vector bool long long, vector bool long long);
18809 vector float vec_pack (vector double, vector double);
18811 vector int vec_packs (vector long long, vector long long);
18812 vector unsigned int vec_packs (vector unsigned long long, vector unsigned long long);
18814 vector unsigned char vec_packsu (vector signed short, vector signed short)
18815 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short)
18816 vector unsigned short int vec_packsu (vector signed int, vector signed int);
18817 vector unsigned short int vec_packsu (vector unsigned int, vector unsigned int);
18818 vector unsigned int vec_packsu (vector long long, vector long long);
18819 vector unsigned int vec_packsu (vector unsigned long long, vector unsigned long long);
18820 vector unsigned int vec_packsu (vector signed long long, vector signed long long);
18822 vector unsigned char vec_popcnt (vector signed char);
18823 vector unsigned char vec_popcnt (vector unsigned char);
18824 vector unsigned short vec_popcnt (vector signed short);
18825 vector unsigned short vec_popcnt (vector unsigned short);
18826 vector unsigned int vec_popcnt (vector signed int);
18827 vector unsigned int vec_popcnt (vector unsigned int);
18828 vector unsigned long long vec_popcnt (vector signed long long);
18829 vector unsigned long long vec_popcnt (vector unsigned long long);
18831 vector long long vec_rl (vector long long, vector unsigned long long);
18832 vector long long vec_rl (vector unsigned long long, vector unsigned long long);
18834 vector long long vec_sl (vector long long, vector unsigned long long);
18835 vector long long vec_sl (vector unsigned long long, vector unsigned long long);
18837 vector long long vec_sr (vector long long, vector unsigned long long);
18838 vector unsigned long long char vec_sr (vector unsigned long long,
18839 vector unsigned long long);
18841 vector long long vec_sra (vector long long, vector unsigned long long);
18842 vector unsigned long long vec_sra (vector unsigned long long,
18843 vector unsigned long long);
18845 vector long long vec_sub (vector long long, vector long long);
18846 vector unsigned long long vec_sub (vector unsigned long long,
18847 vector unsigned long long);
18849 vector long long vec_unpackh (vector int);
18850 vector unsigned long long vec_unpackh (vector unsigned int);
18852 vector long long vec_unpackl (vector int);
18853 vector unsigned long long vec_unpackl (vector unsigned int);
18855 vector long long vec_vaddudm (vector long long, vector long long);
18856 vector long long vec_vaddudm (vector bool long long, vector long long);
18857 vector long long vec_vaddudm (vector long long, vector bool long long);
18858 vector unsigned long long vec_vaddudm (vector unsigned long long,
18859 vector unsigned long long);
18860 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
18861 vector unsigned long long);
18862 vector unsigned long long vec_vaddudm (vector unsigned long long,
18863 vector bool unsigned long long);
18865 vector long long vec_vbpermq (vector signed char, vector signed char);
18866 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
18868 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
18869 vector unsigned char vec_bperm (vector unsigned long long, vector unsigned char);
18870 vector unsigned long long vec_bperm (vector unsigned __int128, vector unsigned char);
18872 vector long long vec_cntlz (vector long long);
18873 vector unsigned long long vec_cntlz (vector unsigned long long);
18874 vector int vec_cntlz (vector int);
18875 vector unsigned int vec_cntlz (vector int);
18876 vector short vec_cntlz (vector short);
18877 vector unsigned short vec_cntlz (vector unsigned short);
18878 vector signed char vec_cntlz (vector signed char);
18879 vector unsigned char vec_cntlz (vector unsigned char);
18881 vector long long vec_vclz (vector long long);
18882 vector unsigned long long vec_vclz (vector unsigned long long);
18883 vector int vec_vclz (vector int);
18884 vector unsigned int vec_vclz (vector int);
18885 vector short vec_vclz (vector short);
18886 vector unsigned short vec_vclz (vector unsigned short);
18887 vector signed char vec_vclz (vector signed char);
18888 vector unsigned char vec_vclz (vector unsigned char);
18890 vector signed char vec_vclzb (vector signed char);
18891 vector unsigned char vec_vclzb (vector unsigned char);
18893 vector long long vec_vclzd (vector long long);
18894 vector unsigned long long vec_vclzd (vector unsigned long long);
18896 vector short vec_vclzh (vector short);
18897 vector unsigned short vec_vclzh (vector unsigned short);
18899 vector int vec_vclzw (vector int);
18900 vector unsigned int vec_vclzw (vector int);
18902 vector signed char vec_vgbbd (vector signed char);
18903 vector unsigned char vec_vgbbd (vector unsigned char);
18905 vector long long vec_vmaxsd (vector long long, vector long long);
18907 vector unsigned long long vec_vmaxud (vector unsigned long long,
18908 unsigned vector long long);
18910 vector long long vec_vminsd (vector long long, vector long long);
18912 vector unsigned long long vec_vminud (vector long long, vector long long);
18914 vector int vec_vpksdss (vector long long, vector long long);
18915 vector unsigned int vec_vpksdss (vector long long, vector long long);
18917 vector unsigned int vec_vpkudus (vector unsigned long long,
18918 vector unsigned long long);
18920 vector int vec_vpkudum (vector long long, vector long long);
18921 vector unsigned int vec_vpkudum (vector unsigned long long,
18922 vector unsigned long long);
18923 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
18925 vector long long vec_vpopcnt (vector long long);
18926 vector unsigned long long vec_vpopcnt (vector unsigned long long);
18927 vector int vec_vpopcnt (vector int);
18928 vector unsigned int vec_vpopcnt (vector int);
18929 vector short vec_vpopcnt (vector short);
18930 vector unsigned short vec_vpopcnt (vector unsigned short);
18931 vector signed char vec_vpopcnt (vector signed char);
18932 vector unsigned char vec_vpopcnt (vector unsigned char);
18934 vector signed char vec_vpopcntb (vector signed char);
18935 vector unsigned char vec_vpopcntb (vector unsigned char);
18937 vector long long vec_vpopcntd (vector long long);
18938 vector unsigned long long vec_vpopcntd (vector unsigned long long);
18940 vector short vec_vpopcnth (vector short);
18941 vector unsigned short vec_vpopcnth (vector unsigned short);
18943 vector int vec_vpopcntw (vector int);
18944 vector unsigned int vec_vpopcntw (vector int);
18946 vector long long vec_vrld (vector long long, vector unsigned long long);
18947 vector unsigned long long vec_vrld (vector unsigned long long,
18948 vector unsigned long long);
18950 vector long long vec_vsld (vector long long, vector unsigned long long);
18951 vector long long vec_vsld (vector unsigned long long,
18952 vector unsigned long long);
18954 vector long long vec_vsrad (vector long long, vector unsigned long long);
18955 vector unsigned long long vec_vsrad (vector unsigned long long,
18956 vector unsigned long long);
18958 vector long long vec_vsrd (vector long long, vector unsigned long long);
18959 vector unsigned long long char vec_vsrd (vector unsigned long long,
18960 vector unsigned long long);
18962 vector long long vec_vsubudm (vector long long, vector long long);
18963 vector long long vec_vsubudm (vector bool long long, vector long long);
18964 vector long long vec_vsubudm (vector long long, vector bool long long);
18965 vector unsigned long long vec_vsubudm (vector unsigned long long,
18966 vector unsigned long long);
18967 vector unsigned long long vec_vsubudm (vector bool long long,
18968 vector unsigned long long);
18969 vector unsigned long long vec_vsubudm (vector unsigned long long,
18970 vector bool long long);
18972 vector long long vec_vupkhsw (vector int);
18973 vector unsigned long long vec_vupkhsw (vector unsigned int);
18975 vector long long vec_vupklsw (vector int);
18976 vector unsigned long long vec_vupklsw (vector int);
18979 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18980 instruction set are available, the following additional functions are
18981 available for 64-bit targets. New vector types
18982 (@var{vector __int128} and @var{vector __uint128}) are available
18983 to hold the @var{__int128} and @var{__uint128} types to use these
18986 The normal vector extract, and set operations work on
18987 @var{vector __int128} and @var{vector __uint128} types,
18988 but the index value must be 0.
18991 vector __int128 vec_vaddcuq (vector __int128, vector __int128);
18992 vector __uint128 vec_vaddcuq (vector __uint128, vector __uint128);
18994 vector __int128 vec_vadduqm (vector __int128, vector __int128);
18995 vector __uint128 vec_vadduqm (vector __uint128, vector __uint128);
18997 vector __int128 vec_vaddecuq (vector __int128, vector __int128,
18999 vector __uint128 vec_vaddecuq (vector __uint128, vector __uint128,
19002 vector __int128 vec_vaddeuqm (vector __int128, vector __int128,
19004 vector __uint128 vec_vaddeuqm (vector __uint128, vector __uint128,
19007 vector __int128 vec_vsubecuq (vector __int128, vector __int128,
19009 vector __uint128 vec_vsubecuq (vector __uint128, vector __uint128,
19012 vector __int128 vec_vsubeuqm (vector __int128, vector __int128,
19014 vector __uint128 vec_vsubeuqm (vector __uint128, vector __uint128,
19017 vector __int128 vec_vsubcuq (vector __int128, vector __int128);
19018 vector __uint128 vec_vsubcuq (vector __uint128, vector __uint128);
19020 __int128 vec_vsubuqm (__int128, __int128);
19021 __uint128 vec_vsubuqm (__uint128, __uint128);
19023 vector __int128 __builtin_bcdadd (vector __int128, vector __int128, const int);
19024 int __builtin_bcdadd_lt (vector __int128, vector __int128, const int);
19025 int __builtin_bcdadd_eq (vector __int128, vector __int128, const int);
19026 int __builtin_bcdadd_gt (vector __int128, vector __int128, const int);
19027 int __builtin_bcdadd_ov (vector __int128, vector __int128, const int);
19028 vector __int128 __builtin_bcdsub (vector __int128, vector __int128, const int);
19029 int __builtin_bcdsub_lt (vector __int128, vector __int128, const int);
19030 int __builtin_bcdsub_eq (vector __int128, vector __int128, const int);
19031 int __builtin_bcdsub_gt (vector __int128, vector __int128, const int);
19032 int __builtin_bcdsub_ov (vector __int128, vector __int128, const int);
19035 @node PowerPC AltiVec Built-in Functions Available on ISA 3.0
19036 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 3.0
19038 The following additional built-in functions are also available for the
19039 PowerPC family of processors, starting with ISA 3.0
19040 (@option{-mcpu=power9}) or later:
19042 unsigned int scalar_extract_exp (double source);
19043 unsigned long long int scalar_extract_exp (__ieee128 source);
19045 unsigned long long int scalar_extract_sig (double source);
19046 unsigned __int128 scalar_extract_sig (__ieee128 source);
19048 double scalar_insert_exp (unsigned long long int significand,
19049 unsigned long long int exponent);
19050 double scalar_insert_exp (double significand, unsigned long long int exponent);
19052 ieee_128 scalar_insert_exp (unsigned __int128 significand,
19053 unsigned long long int exponent);
19054 ieee_128 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent);
19056 int scalar_cmp_exp_gt (double arg1, double arg2);
19057 int scalar_cmp_exp_lt (double arg1, double arg2);
19058 int scalar_cmp_exp_eq (double arg1, double arg2);
19059 int scalar_cmp_exp_unordered (double arg1, double arg2);
19061 bool scalar_test_data_class (float source, const int condition);
19062 bool scalar_test_data_class (double source, const int condition);
19063 bool scalar_test_data_class (__ieee128 source, const int condition);
19065 bool scalar_test_neg (float source);
19066 bool scalar_test_neg (double source);
19067 bool scalar_test_neg (__ieee128 source);
19070 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
19071 functions require a 64-bit environment supporting ISA 3.0 or later.
19072 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
19073 functions return the significand and the biased exponent value
19074 respectively of their @code{source} arguments.
19075 When supplied with a 64-bit @code{source} argument, the
19076 result returned by @code{scalar_extract_sig} has
19077 the @code{0x0010000000000000} bit set if the
19078 function's @code{source} argument is in normalized form.
19079 Otherwise, this bit is set to 0.
19080 When supplied with a 128-bit @code{source} argument, the
19081 @code{0x00010000000000000000000000000000} bit of the result is
19083 Note that the sign of the significand is not represented in the result
19084 returned from the @code{scalar_extract_sig} function. Use the
19085 @code{scalar_test_neg} function to test the sign of its @code{double}
19088 The @code{scalar_insert_exp}
19089 functions require a 64-bit environment supporting ISA 3.0 or later.
19090 When supplied with a 64-bit first argument, the
19091 @code{scalar_insert_exp} built-in function returns a double-precision
19092 floating point value that is constructed by assembling the values of its
19093 @code{significand} and @code{exponent} arguments. The sign of the
19094 result is copied from the most significant bit of the
19095 @code{significand} argument. The significand and exponent components
19096 of the result are composed of the least significant 11 bits of the
19097 @code{exponent} argument and the least significant 52 bits of the
19098 @code{significand} argument respectively.
19100 When supplied with a 128-bit first argument, the
19101 @code{scalar_insert_exp} built-in function returns a quad-precision
19102 ieee floating point value. The sign bit of the result is copied from
19103 the most significant bit of the @code{significand} argument.
19104 The significand and exponent components of the result are composed of
19105 the least significant 15 bits of the @code{exponent} argument and the
19106 least significant 112 bits of the @code{significand} argument respectively.
19108 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
19109 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
19110 functions return a non-zero value if @code{arg1} is greater than, less
19111 than, equal to, or not comparable to @code{arg2} respectively. The
19112 arguments are not comparable if one or the other equals NaN (not a
19115 The @code{scalar_test_data_class} built-in function returns 1
19116 if any of the condition tests enabled by the value of the
19117 @code{condition} variable are true, and 0 otherwise. The
19118 @code{condition} argument must be a compile-time constant integer with
19119 value not exceeding 127. The
19120 @code{condition} argument is encoded as a bitmask with each bit
19121 enabling the testing of a different condition, as characterized by the
19125 0x20 Test for +Infinity
19126 0x10 Test for -Infinity
19127 0x08 Test for +Zero
19128 0x04 Test for -Zero
19129 0x02 Test for +Denormal
19130 0x01 Test for -Denormal
19133 The @code{scalar_test_neg} built-in function returns 1 if its
19134 @code{source} argument holds a negative value, 0 otherwise.
19136 The following built-in functions are also available for the PowerPC family
19137 of processors, starting with ISA 3.0 or later
19138 (@option{-mcpu=power9}). These string functions are described
19139 separately in order to group the descriptions closer to the function
19142 int vec_all_nez (vector signed char, vector signed char);
19143 int vec_all_nez (vector unsigned char, vector unsigned char);
19144 int vec_all_nez (vector signed short, vector signed short);
19145 int vec_all_nez (vector unsigned short, vector unsigned short);
19146 int vec_all_nez (vector signed int, vector signed int);
19147 int vec_all_nez (vector unsigned int, vector unsigned int);
19149 int vec_any_eqz (vector signed char, vector signed char);
19150 int vec_any_eqz (vector unsigned char, vector unsigned char);
19151 int vec_any_eqz (vector signed short, vector signed short);
19152 int vec_any_eqz (vector unsigned short, vector unsigned short);
19153 int vec_any_eqz (vector signed int, vector signed int);
19154 int vec_any_eqz (vector unsigned int, vector unsigned int);
19156 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
19157 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
19158 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
19159 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
19160 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
19161 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
19163 vector signed char vec_cnttz (vector signed char);
19164 vector unsigned char vec_cnttz (vector unsigned char);
19165 vector signed short vec_cnttz (vector signed short);
19166 vector unsigned short vec_cnttz (vector unsigned short);
19167 vector signed int vec_cnttz (vector signed int);
19168 vector unsigned int vec_cnttz (vector unsigned int);
19169 vector signed long long vec_cnttz (vector signed long long);
19170 vector unsigned long long vec_cnttz (vector unsigned long long);
19172 signed int vec_cntlz_lsbb (vector signed char);
19173 signed int vec_cntlz_lsbb (vector unsigned char);
19175 signed int vec_cnttz_lsbb (vector signed char);
19176 signed int vec_cnttz_lsbb (vector unsigned char);
19178 unsigned int vec_first_match_index (vector signed char, vector signed char);
19179 unsigned int vec_first_match_index (vector unsigned char, vector unsigned char);
19180 unsigned int vec_first_match_index (vector signed int, vector signed int);
19181 unsigned int vec_first_match_index (vector unsigned int, vector unsigned int);
19182 unsigned int vec_first_match_index (vector signed short, vector signed short);
19183 unsigned int vec_first_match_index (vector unsigned short, vector unsigned short);
19184 unsigned int vec_first_match_or_eos_index (vector signed char, vector signed char);
19185 unsigned int vec_first_match_or_eos_index (vector unsigned char, vector unsigned char);
19186 unsigned int vec_first_match_or_eos_index (vector signed int, vector signed int);
19187 unsigned int vec_first_match_or_eos_index (vector unsigned int, vector unsigned int);
19188 unsigned int vec_first_match_or_eos_index (vector signed short, vector signed short);
19189 unsigned int vec_first_match_or_eos_index (vector unsigned short,
19190 vector unsigned short);
19191 unsigned int vec_first_mismatch_index (vector signed char, vector signed char);
19192 unsigned int vec_first_mismatch_index (vector unsigned char, vector unsigned char);
19193 unsigned int vec_first_mismatch_index (vector signed int, vector signed int);
19194 unsigned int vec_first_mismatch_index (vector unsigned int, vector unsigned int);
19195 unsigned int vec_first_mismatch_index (vector signed short, vector signed short);
19196 unsigned int vec_first_mismatch_index (vector unsigned short, vector unsigned short);
19197 unsigned int vec_first_mismatch_or_eos_index (vector signed char, vector signed char);
19198 unsigned int vec_first_mismatch_or_eos_index (vector unsigned char,
19199 vector unsigned char);
19200 unsigned int vec_first_mismatch_or_eos_index (vector signed int, vector signed int);
19201 unsigned int vec_first_mismatch_or_eos_index (vector unsigned int, vector unsigned int);
19202 unsigned int vec_first_mismatch_or_eos_index (vector signed short, vector signed short);
19203 unsigned int vec_first_mismatch_or_eos_index (vector unsigned short,
19204 vector unsigned short);
19206 vector unsigned short vec_pack_to_short_fp32 (vector float, vector float);
19208 vector signed char vec_xl_be (signed long long, signed char *);
19209 vector unsigned char vec_xl_be (signed long long, unsigned char *);
19210 vector signed int vec_xl_be (signed long long, signed int *);
19211 vector unsigned int vec_xl_be (signed long long, unsigned int *);
19212 vector signed __int128 vec_xl_be (signed long long, signed __int128 *);
19213 vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *);
19214 vector signed long long vec_xl_be (signed long long, signed long long *);
19215 vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
19216 vector signed short vec_xl_be (signed long long, signed short *);
19217 vector unsigned short vec_xl_be (signed long long, unsigned short *);
19218 vector double vec_xl_be (signed long long, double *);
19219 vector float vec_xl_be (signed long long, float *);
19221 vector signed char vec_xl_len (signed char *addr, size_t len);
19222 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
19223 vector signed int vec_xl_len (signed int *addr, size_t len);
19224 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
19225 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
19226 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
19227 vector signed long long vec_xl_len (signed long long *addr, size_t len);
19228 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
19229 vector signed short vec_xl_len (signed short *addr, size_t len);
19230 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
19231 vector double vec_xl_len (double *addr, size_t len);
19232 vector float vec_xl_len (float *addr, size_t len);
19234 vector unsigned char vec_xl_len_r (unsigned char *addr, size_t len);
19236 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
19237 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
19238 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
19239 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
19240 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
19241 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
19242 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
19243 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
19244 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
19245 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
19246 void vec_xst_len (vector double data, double *addr, size_t len);
19247 void vec_xst_len (vector float data, float *addr, size_t len);
19249 void vec_xst_len_r (vector unsigned char data, unsigned char *addr, size_t len);
19251 signed char vec_xlx (unsigned int index, vector signed char data);
19252 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
19253 signed short vec_xlx (unsigned int index, vector signed short data);
19254 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
19255 signed int vec_xlx (unsigned int index, vector signed int data);
19256 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
19257 float vec_xlx (unsigned int index, vector float data);
19259 signed char vec_xrx (unsigned int index, vector signed char data);
19260 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
19261 signed short vec_xrx (unsigned int index, vector signed short data);
19262 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
19263 signed int vec_xrx (unsigned int index, vector signed int data);
19264 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
19265 float vec_xrx (unsigned int index, vector float data);
19268 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
19269 perform pairwise comparisons between the elements at the same
19270 positions within their two vector arguments.
19271 The @code{vec_all_nez} function returns a
19272 non-zero value if and only if all pairwise comparisons are not
19273 equal and no element of either vector argument contains a zero.
19274 The @code{vec_any_eqz} function returns a
19275 non-zero value if and only if at least one pairwise comparison is equal
19276 or if at least one element of either vector argument contains a zero.
19277 The @code{vec_cmpnez} function returns a vector of the same type as
19278 its two arguments, within which each element consists of all ones to
19279 denote that either the corresponding elements of the incoming arguments are
19280 not equal or that at least one of the corresponding elements contains
19281 zero. Otherwise, the element of the returned vector contains all zeros.
19283 The @code{vec_cntlz_lsbb} function returns the count of the number of
19284 consecutive leading byte elements (starting from position 0 within the
19285 supplied vector argument) for which the least-significant bit
19286 equals zero. The @code{vec_cnttz_lsbb} function returns the count of
19287 the number of consecutive trailing byte elements (starting from
19288 position 15 and counting backwards within the supplied vector
19289 argument) for which the least-significant bit equals zero.
19291 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
19292 64-bit environment supporting ISA 3.0 or later. The @code{vec_xl_len}
19293 function loads a variable length vector from memory. The
19294 @code{vec_xst_len} function stores a variable length vector to memory.
19295 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
19296 @code{addr} argument represents the memory address to or from which
19297 data will be transferred, and the
19298 @code{len} argument represents the number of bytes to be
19299 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
19300 If this expression's value is not a multiple of the vector element's
19301 size, the behavior of this function is undefined.
19302 In the case that the underlying computer is configured to run in
19303 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
19304 the corresponding vector. In little-endian mode, the data transfer
19305 moves bytes @code{(16 - len)} to @code{15} of the corresponding
19306 vector. For the load function, any bytes of the result vector that
19307 are not loaded from memory are set to zero.
19308 The value of the @code{addr} argument need not be aligned on a
19309 multiple of the vector's element size.
19311 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
19312 element selected by the @code{index} argument from the vector
19313 represented by the @code{data} argument. The @code{index} argument
19314 always specifies a byte offset, regardless of the size of the vector
19315 element. With @code{vec_xlx}, @code{index} is the offset of the first
19316 byte of the element to be extracted. With @code{vec_xrx}, @code{index}
19317 represents the last byte of the element to be extracted, measured
19318 from the right end of the vector. In other words, the last byte of
19319 the element to be extracted is found at position @code{(15 - index)}.
19320 There is no requirement that @code{index} be a multiple of the vector
19321 element size. However, if the size of the vector element added to
19322 @code{index} is greater than 15, the content of the returned value is
19325 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19329 vector unsigned long long vec_bperm (vector unsigned long long, vector unsigned char);
19331 vector bool char vec_cmpne (vector bool char, vector bool char);
19332 vector bool char vec_cmpne (vector signed char, vector signed char);
19333 vector bool char vec_cmpne (vector unsigned char, vector unsigned char);
19334 vector bool int vec_cmpne (vector bool int, vector bool int);
19335 vector bool int vec_cmpne (vector signed int, vector signed int);
19336 vector bool int vec_cmpne (vector unsigned int, vector unsigned int);
19337 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
19338 vector bool long long vec_cmpne (vector signed long long, vector signed long long);
19339 vector bool long long vec_cmpne (vector unsigned long long, vector unsigned long long);
19340 vector bool short vec_cmpne (vector bool short, vector bool short);
19341 vector bool short vec_cmpne (vector signed short, vector signed short);
19342 vector bool short vec_cmpne (vector unsigned short, vector unsigned short);
19343 vector bool long long vec_cmpne (vector double, vector double);
19344 vector bool int vec_cmpne (vector float, vector float);
19346 vector float vec_extract_fp32_from_shorth (vector unsigned short);
19347 vector float vec_extract_fp32_from_shortl (vector unsigned short);
19349 vector long long vec_vctz (vector long long);
19350 vector unsigned long long vec_vctz (vector unsigned long long);
19351 vector int vec_vctz (vector int);
19352 vector unsigned int vec_vctz (vector int);
19353 vector short vec_vctz (vector short);
19354 vector unsigned short vec_vctz (vector unsigned short);
19355 vector signed char vec_vctz (vector signed char);
19356 vector unsigned char vec_vctz (vector unsigned char);
19358 vector signed char vec_vctzb (vector signed char);
19359 vector unsigned char vec_vctzb (vector unsigned char);
19361 vector long long vec_vctzd (vector long long);
19362 vector unsigned long long vec_vctzd (vector unsigned long long);
19364 vector short vec_vctzh (vector short);
19365 vector unsigned short vec_vctzh (vector unsigned short);
19367 vector int vec_vctzw (vector int);
19368 vector unsigned int vec_vctzw (vector int);
19370 vector unsigned long long vec_extract4b (vector unsigned char, const int);
19372 vector unsigned char vec_insert4b (vector signed int, vector unsigned char,
19374 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
19377 vector unsigned int vec_parity_lsbb (vector signed int);
19378 vector unsigned int vec_parity_lsbb (vector unsigned int);
19379 vector unsigned __int128 vec_parity_lsbb (vector signed __int128);
19380 vector unsigned __int128 vec_parity_lsbb (vector unsigned __int128);
19381 vector unsigned long long vec_parity_lsbb (vector signed long long);
19382 vector unsigned long long vec_parity_lsbb (vector unsigned long long);
19384 vector int vec_vprtyb (vector int);
19385 vector unsigned int vec_vprtyb (vector unsigned int);
19386 vector long long vec_vprtyb (vector long long);
19387 vector unsigned long long vec_vprtyb (vector unsigned long long);
19389 vector int vec_vprtybw (vector int);
19390 vector unsigned int vec_vprtybw (vector unsigned int);
19392 vector long long vec_vprtybd (vector long long);
19393 vector unsigned long long vec_vprtybd (vector unsigned long long);
19396 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19400 vector long vec_vprtyb (vector long);
19401 vector unsigned long vec_vprtyb (vector unsigned long);
19402 vector __int128 vec_vprtyb (vector __int128);
19403 vector __uint128 vec_vprtyb (vector __uint128);
19405 vector long vec_vprtybd (vector long);
19406 vector unsigned long vec_vprtybd (vector unsigned long);
19408 vector __int128 vec_vprtybq (vector __int128);
19409 vector __uint128 vec_vprtybd (vector __uint128);
19412 The following built-in vector functions are available for the PowerPC family
19413 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19415 __vector unsigned char
19416 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
19417 __vector unsigned char
19418 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
19421 The @code{vec_slv} and @code{vec_srv} functions operate on
19422 all of the bytes of their @code{src} and @code{shift_distance}
19423 arguments in parallel. The behavior of the @code{vec_slv} is as if
19424 there existed a temporary array of 17 unsigned characters
19425 @code{slv_array} within which elements 0 through 15 are the same as
19426 the entries in the @code{src} array and element 16 equals 0. The
19427 result returned from the @code{vec_slv} function is a
19428 @code{__vector} of 16 unsigned characters within which element
19429 @code{i} is computed using the C expression
19430 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
19431 shift_distance[i]))},
19432 with this resulting value coerced to the @code{unsigned char} type.
19433 The behavior of the @code{vec_srv} is as if
19434 there existed a temporary array of 17 unsigned characters
19435 @code{srv_array} within which element 0 equals zero and
19436 elements 1 through 16 equal the elements 0 through 15 of
19437 the @code{src} array. The
19438 result returned from the @code{vec_srv} function is a
19439 @code{__vector} of 16 unsigned characters within which element
19440 @code{i} is computed using the C expression
19441 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
19442 (0x07 & shift_distance[i]))},
19443 with this resulting value coerced to the @code{unsigned char} type.
19445 The following built-in functions are available for the PowerPC family
19446 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19448 __vector unsigned char
19449 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
19450 __vector unsigned short
19451 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
19452 __vector unsigned int
19453 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
19455 __vector unsigned char
19456 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
19457 __vector unsigned short
19458 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
19459 __vector unsigned int
19460 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
19463 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
19464 @code{vec_absdw} built-in functions each computes the absolute
19465 differences of the pairs of vector elements supplied in its two vector
19466 arguments, placing the absolute differences into the corresponding
19467 elements of the vector result.
19469 The following built-in functions are available for the PowerPC family
19470 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19472 __vector unsigned int vec_extract_exp (__vector float source);
19473 __vector unsigned long long int vec_extract_exp (__vector double source);
19475 __vector unsigned int vec_extract_sig (__vector float source);
19476 __vector unsigned long long int vec_extract_sig (__vector double source);
19478 __vector float vec_insert_exp (__vector unsigned int significands,
19479 __vector unsigned int exponents);
19480 __vector float vec_insert_exp (__vector unsigned float significands,
19481 __vector unsigned int exponents);
19482 __vector double vec_insert_exp (__vector unsigned long long int significands,
19483 __vector unsigned long long int exponents);
19484 __vector double vec_insert_exp (__vector unsigned double significands,
19485 __vector unsigned long long int exponents);
19487 __vector bool int vec_test_data_class (__vector float source, const int condition);
19488 __vector bool long long int vec_test_data_class (__vector double source,
19489 const int condition);
19492 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
19493 functions return vectors representing the significands and biased
19494 exponent values of their @code{source} arguments respectively.
19495 Within the result vector returned by @code{vec_extract_sig}, the
19496 @code{0x800000} bit of each vector element returned when the
19497 function's @code{source} argument is of type @code{float} is set to 1
19498 if the corresponding floating point value is in normalized form.
19499 Otherwise, this bit is set to 0. When the @code{source} argument is
19500 of type @code{double}, the @code{0x10000000000000} bit within each of
19501 the result vector's elements is set according to the same rules.
19502 Note that the sign of the significand is not represented in the result
19503 returned from the @code{vec_extract_sig} function. To extract the
19505 @code{vec_cpsgn} function, which returns a new vector within which all
19506 of the sign bits of its second argument vector are overwritten with the
19507 sign bits copied from the coresponding elements of its first argument
19508 vector, and all other (non-sign) bits of the second argument vector
19509 are copied unchanged into the result vector.
19511 The @code{vec_insert_exp} built-in functions return a vector of
19512 single- or double-precision floating
19513 point values constructed by assembling the values of their
19514 @code{significands} and @code{exponents} arguments into the
19515 corresponding elements of the returned vector.
19517 element of the result is copied from the most significant bit of the
19518 corresponding entry within the @code{significands} argument.
19519 Note that the relevant
19520 bits of the @code{significands} argument are the same, for both integer
19521 and floating point types.
19523 significand and exponent components of each element of the result are
19524 composed of the least significant bits of the corresponding
19525 @code{significands} element and the least significant bits of the
19526 corresponding @code{exponents} element.
19528 The @code{vec_test_data_class} built-in function returns a vector
19529 representing the results of testing the @code{source} vector for the
19530 condition selected by the @code{condition} argument. The
19531 @code{condition} argument must be a compile-time constant integer with
19532 value not exceeding 127. The
19533 @code{condition} argument is encoded as a bitmask with each bit
19534 enabling the testing of a different condition, as characterized by the
19538 0x20 Test for +Infinity
19539 0x10 Test for -Infinity
19540 0x08 Test for +Zero
19541 0x04 Test for -Zero
19542 0x02 Test for +Denormal
19543 0x01 Test for -Denormal
19546 If any of the enabled test conditions is true, the corresponding entry
19547 in the result vector is -1. Otherwise (all of the enabled test
19548 conditions are false), the corresponding entry of the result vector is 0.
19550 The following built-in functions are available for the PowerPC family
19551 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19553 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
19554 vector unsigned int);
19555 vector unsigned long long vec_rlmi (vector unsigned long long,
19556 vector unsigned long long,
19557 vector unsigned long long);
19558 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
19559 vector unsigned int);
19560 vector unsigned long long vec_rlnm (vector unsigned long long,
19561 vector unsigned long long,
19562 vector unsigned long long);
19563 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
19564 vector unsigned long long vec_vrlnm (vector unsigned long long,
19565 vector unsigned long long);
19568 The result of @code{vec_rlmi} is obtained by rotating each element of
19569 the first argument vector left and inserting it under mask into the
19570 second argument vector. The third argument vector contains the mask
19571 beginning in bits 11:15, the mask end in bits 19:23, and the shift
19572 count in bits 27:31, of each element.
19574 The result of @code{vec_rlnm} is obtained by rotating each element of
19575 the first argument vector left and ANDing it with a mask specified by
19576 the second and third argument vectors. The second argument vector
19577 contains the shift count for each element in the low-order byte. The
19578 third argument vector contains the mask end for each element in the
19579 low-order byte, with the mask begin in the next higher byte.
19581 The result of @code{vec_vrlnm} is obtained by rotating each element
19582 of the first argument vector left and ANDing it with a mask. The
19583 second argument vector contains the mask beginning in bits 11:15,
19584 the mask end in bits 19:23, and the shift count in bits 27:31,
19587 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19590 vector signed bool char vec_revb (vector signed char);
19591 vector signed char vec_revb (vector signed char);
19592 vector unsigned char vec_revb (vector unsigned char);
19593 vector bool short vec_revb (vector bool short);
19594 vector short vec_revb (vector short);
19595 vector unsigned short vec_revb (vector unsigned short);
19596 vector bool int vec_revb (vector bool int);
19597 vector int vec_revb (vector int);
19598 vector unsigned int vec_revb (vector unsigned int);
19599 vector float vec_revb (vector float);
19600 vector bool long long vec_revb (vector bool long long);
19601 vector long long vec_revb (vector long long);
19602 vector unsigned long long vec_revb (vector unsigned long long);
19603 vector double vec_revb (vector double);
19606 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19609 vector long vec_revb (vector long);
19610 vector unsigned long vec_revb (vector unsigned long);
19611 vector __int128 vec_revb (vector __int128);
19612 vector __uint128 vec_revb (vector __uint128);
19615 The @code{vec_revb} built-in function reverses the bytes on an element
19616 by element basis. A vector of @code{vector unsigned char} or
19617 @code{vector signed char} reverses the bytes in the whole word.
19619 If the cryptographic instructions are enabled (@option{-mcrypto} or
19620 @option{-mcpu=power8}), the following builtins are enabled.
19623 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
19625 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
19626 vector unsigned long long);
19628 vector unsigned long long __builtin_crypto_vcipherlast
19629 (vector unsigned long long,
19630 vector unsigned long long);
19632 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
19633 vector unsigned long long);
19635 vector unsigned long long __builtin_crypto_vncipherlast (vector unsigned long long,
19636 vector unsigned long long);
19638 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
19639 vector unsigned char,
19640 vector unsigned char);
19642 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
19643 vector unsigned short,
19644 vector unsigned short);
19646 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
19647 vector unsigned int,
19648 vector unsigned int);
19650 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
19651 vector unsigned long long,
19652 vector unsigned long long);
19654 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
19655 vector unsigned char);
19657 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
19658 vector unsigned short);
19660 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
19661 vector unsigned int);
19663 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
19664 vector unsigned long long);
19666 vector unsigned long long __builtin_crypto_vshasigmad (vector unsigned long long,
19669 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int, int, int);
19672 The second argument to @var{__builtin_crypto_vshasigmad} and
19673 @var{__builtin_crypto_vshasigmaw} must be a constant
19674 integer that is 0 or 1. The third argument to these built-in functions
19675 must be a constant integer in the range of 0 to 15.
19677 If the ISA 3.0 instruction set additions
19678 are enabled (@option{-mcpu=power9}), the following additional
19679 functions are available for both 32-bit and 64-bit targets.
19681 vector short vec_xl (int, vector short *);
19682 vector short vec_xl (int, short *);
19683 vector unsigned short vec_xl (int, vector unsigned short *);
19684 vector unsigned short vec_xl (int, unsigned short *);
19685 vector char vec_xl (int, vector char *);
19686 vector char vec_xl (int, char *);
19687 vector unsigned char vec_xl (int, vector unsigned char *);
19688 vector unsigned char vec_xl (int, unsigned char *);
19690 void vec_xst (vector short, int, vector short *);
19691 void vec_xst (vector short, int, short *);
19692 void vec_xst (vector unsigned short, int, vector unsigned short *);
19693 void vec_xst (vector unsigned short, int, unsigned short *);
19694 void vec_xst (vector char, int, vector char *);
19695 void vec_xst (vector char, int, char *);
19696 void vec_xst (vector unsigned char, int, vector unsigned char *);
19697 void vec_xst (vector unsigned char, int, unsigned char *);
19699 @node PowerPC Hardware Transactional Memory Built-in Functions
19700 @subsection PowerPC Hardware Transactional Memory Built-in Functions
19701 GCC provides two interfaces for accessing the Hardware Transactional
19702 Memory (HTM) instructions available on some of the PowerPC family
19703 of processors (eg, POWER8). The two interfaces come in a low level
19704 interface, consisting of built-in functions specific to PowerPC and a
19705 higher level interface consisting of inline functions that are common
19706 between PowerPC and S/390.
19708 @subsubsection PowerPC HTM Low Level Built-in Functions
19710 The following low level built-in functions are available with
19711 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
19712 They all generate the machine instruction that is part of the name.
19714 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
19715 the full 4-bit condition register value set by their associated hardware
19716 instruction. The header file @code{htmintrin.h} defines some macros that can
19717 be used to decipher the return value. The @code{__builtin_tbegin} builtin
19718 returns a simple @code{true} or @code{false} value depending on whether a transaction was
19719 successfully started or not. The arguments of the builtins match exactly the
19720 type and order of the associated hardware instruction's operands, except for
19721 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
19722 Refer to the ISA manual for a description of each instruction's operands.
19725 unsigned int __builtin_tbegin (unsigned int)
19726 unsigned int __builtin_tend (unsigned int)
19728 unsigned int __builtin_tabort (unsigned int)
19729 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
19730 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
19731 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
19732 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
19734 unsigned int __builtin_tcheck (void)
19735 unsigned int __builtin_treclaim (unsigned int)
19736 unsigned int __builtin_trechkpt (void)
19737 unsigned int __builtin_tsr (unsigned int)
19740 In addition to the above HTM built-ins, we have added built-ins for
19741 some common extended mnemonics of the HTM instructions:
19744 unsigned int __builtin_tendall (void)
19745 unsigned int __builtin_tresume (void)
19746 unsigned int __builtin_tsuspend (void)
19749 Note that the semantics of the above HTM builtins are required to mimic
19750 the locking semantics used for critical sections. Builtins that are used
19751 to create a new transaction or restart a suspended transaction must have
19752 lock acquisition like semantics while those builtins that end or suspend a
19753 transaction must have lock release like semantics. Specifically, this must
19754 mimic lock semantics as specified by C++11, for example: Lock acquisition is
19755 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
19756 that returns 0, and lock release is as-if an execution of
19757 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
19758 implicit implementation-defined lock used for all transactions. The HTM
19759 instructions associated with with the builtins inherently provide the
19760 correct acquisition and release hardware barriers required. However,
19761 the compiler must also be prohibited from moving loads and stores across
19762 the builtins in a way that would violate their semantics. This has been
19763 accomplished by adding memory barriers to the associated HTM instructions
19764 (which is a conservative approach to provide acquire and release semantics).
19765 Earlier versions of the compiler did not treat the HTM instructions as
19766 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
19767 be used to determine whether the current compiler treats HTM instructions
19768 as memory barriers or not. This allows the user to explicitly add memory
19769 barriers to their code when using an older version of the compiler.
19771 The following set of built-in functions are available to gain access
19772 to the HTM specific special purpose registers.
19775 unsigned long __builtin_get_texasr (void)
19776 unsigned long __builtin_get_texasru (void)
19777 unsigned long __builtin_get_tfhar (void)
19778 unsigned long __builtin_get_tfiar (void)
19780 void __builtin_set_texasr (unsigned long);
19781 void __builtin_set_texasru (unsigned long);
19782 void __builtin_set_tfhar (unsigned long);
19783 void __builtin_set_tfiar (unsigned long);
19786 Example usage of these low level built-in functions may look like:
19789 #include <htmintrin.h>
19791 int num_retries = 10;
19795 if (__builtin_tbegin (0))
19797 /* Transaction State Initiated. */
19798 if (is_locked (lock))
19799 __builtin_tabort (0);
19800 ... transaction code...
19801 __builtin_tend (0);
19806 /* Transaction State Failed. Use locks if the transaction
19807 failure is "persistent" or we've tried too many times. */
19808 if (num_retries-- <= 0
19809 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
19811 acquire_lock (lock);
19812 ... non transactional fallback path...
19813 release_lock (lock);
19820 One final built-in function has been added that returns the value of
19821 the 2-bit Transaction State field of the Machine Status Register (MSR)
19822 as stored in @code{CR0}.
19825 unsigned long __builtin_ttest (void)
19828 This built-in can be used to determine the current transaction state
19829 using the following code example:
19832 #include <htmintrin.h>
19834 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
19836 if (tx_state == _HTM_TRANSACTIONAL)
19838 /* Code to use in transactional state. */
19840 else if (tx_state == _HTM_NONTRANSACTIONAL)
19842 /* Code to use in non-transactional state. */
19844 else if (tx_state == _HTM_SUSPENDED)
19846 /* Code to use in transaction suspended state. */
19850 @subsubsection PowerPC HTM High Level Inline Functions
19852 The following high level HTM interface is made available by including
19853 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
19854 where CPU is `power8' or later. This interface is common between PowerPC
19855 and S/390, allowing users to write one HTM source implementation that
19856 can be compiled and executed on either system.
19859 long __TM_simple_begin (void)
19860 long __TM_begin (void* const TM_buff)
19861 long __TM_end (void)
19862 void __TM_abort (void)
19863 void __TM_named_abort (unsigned char const code)
19864 void __TM_resume (void)
19865 void __TM_suspend (void)
19867 long __TM_is_user_abort (void* const TM_buff)
19868 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
19869 long __TM_is_illegal (void* const TM_buff)
19870 long __TM_is_footprint_exceeded (void* const TM_buff)
19871 long __TM_nesting_depth (void* const TM_buff)
19872 long __TM_is_nested_too_deep(void* const TM_buff)
19873 long __TM_is_conflict(void* const TM_buff)
19874 long __TM_is_failure_persistent(void* const TM_buff)
19875 long __TM_failure_address(void* const TM_buff)
19876 long long __TM_failure_code(void* const TM_buff)
19879 Using these common set of HTM inline functions, we can create
19880 a more portable version of the HTM example in the previous
19881 section that will work on either PowerPC or S/390:
19884 #include <htmxlintrin.h>
19886 int num_retries = 10;
19887 TM_buff_type TM_buff;
19891 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
19893 /* Transaction State Initiated. */
19894 if (is_locked (lock))
19896 ... transaction code...
19902 /* Transaction State Failed. Use locks if the transaction
19903 failure is "persistent" or we've tried too many times. */
19904 if (num_retries-- <= 0
19905 || __TM_is_failure_persistent (TM_buff))
19907 acquire_lock (lock);
19908 ... non transactional fallback path...
19909 release_lock (lock);
19916 @node PowerPC Atomic Memory Operation Functions
19917 @subsection PowerPC Atomic Memory Operation Functions
19918 ISA 3.0 of the PowerPC added new atomic memory operation (amo)
19919 instructions. GCC provides support for these instructions in 64-bit
19920 environments. All of the functions are declared in the include file
19923 The functions supported are:
19928 uint32_t amo_lwat_add (uint32_t *, uint32_t);
19929 uint32_t amo_lwat_xor (uint32_t *, uint32_t);
19930 uint32_t amo_lwat_ior (uint32_t *, uint32_t);
19931 uint32_t amo_lwat_and (uint32_t *, uint32_t);
19932 uint32_t amo_lwat_umax (uint32_t *, uint32_t);
19933 uint32_t amo_lwat_umin (uint32_t *, uint32_t);
19934 uint32_t amo_lwat_swap (uint32_t *, uint32_t);
19936 int32_t amo_lwat_sadd (int32_t *, int32_t);
19937 int32_t amo_lwat_smax (int32_t *, int32_t);
19938 int32_t amo_lwat_smin (int32_t *, int32_t);
19939 int32_t amo_lwat_sswap (int32_t *, int32_t);
19941 uint64_t amo_ldat_add (uint64_t *, uint64_t);
19942 uint64_t amo_ldat_xor (uint64_t *, uint64_t);
19943 uint64_t amo_ldat_ior (uint64_t *, uint64_t);
19944 uint64_t amo_ldat_and (uint64_t *, uint64_t);
19945 uint64_t amo_ldat_umax (uint64_t *, uint64_t);
19946 uint64_t amo_ldat_umin (uint64_t *, uint64_t);
19947 uint64_t amo_ldat_swap (uint64_t *, uint64_t);
19949 int64_t amo_ldat_sadd (int64_t *, int64_t);
19950 int64_t amo_ldat_smax (int64_t *, int64_t);
19951 int64_t amo_ldat_smin (int64_t *, int64_t);
19952 int64_t amo_ldat_sswap (int64_t *, int64_t);
19954 void amo_stwat_add (uint32_t *, uint32_t);
19955 void amo_stwat_xor (uint32_t *, uint32_t);
19956 void amo_stwat_ior (uint32_t *, uint32_t);
19957 void amo_stwat_and (uint32_t *, uint32_t);
19958 void amo_stwat_umax (uint32_t *, uint32_t);
19959 void amo_stwat_umin (uint32_t *, uint32_t);
19961 void amo_stwat_sadd (int32_t *, int32_t);
19962 void amo_stwat_smax (int32_t *, int32_t);
19963 void amo_stwat_smin (int32_t *, int32_t);
19965 void amo_stdat_add (uint64_t *, uint64_t);
19966 void amo_stdat_xor (uint64_t *, uint64_t);
19967 void amo_stdat_ior (uint64_t *, uint64_t);
19968 void amo_stdat_and (uint64_t *, uint64_t);
19969 void amo_stdat_umax (uint64_t *, uint64_t);
19970 void amo_stdat_umin (uint64_t *, uint64_t);
19972 void amo_stdat_sadd (int64_t *, int64_t);
19973 void amo_stdat_smax (int64_t *, int64_t);
19974 void amo_stdat_smin (int64_t *, int64_t);
19977 @node RX Built-in Functions
19978 @subsection RX Built-in Functions
19979 GCC supports some of the RX instructions which cannot be expressed in
19980 the C programming language via the use of built-in functions. The
19981 following functions are supported:
19983 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
19984 Generates the @code{brk} machine instruction.
19987 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
19988 Generates the @code{clrpsw} machine instruction to clear the specified
19989 bit in the processor status word.
19992 @deftypefn {Built-in Function} void __builtin_rx_int (int)
19993 Generates the @code{int} machine instruction to generate an interrupt
19994 with the specified value.
19997 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
19998 Generates the @code{machi} machine instruction to add the result of
19999 multiplying the top 16 bits of the two arguments into the
20003 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
20004 Generates the @code{maclo} machine instruction to add the result of
20005 multiplying the bottom 16 bits of the two arguments into the
20009 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
20010 Generates the @code{mulhi} machine instruction to place the result of
20011 multiplying the top 16 bits of the two arguments into the
20015 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
20016 Generates the @code{mullo} machine instruction to place the result of
20017 multiplying the bottom 16 bits of the two arguments into the
20021 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
20022 Generates the @code{mvfachi} machine instruction to read the top
20023 32 bits of the accumulator.
20026 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
20027 Generates the @code{mvfacmi} machine instruction to read the middle
20028 32 bits of the accumulator.
20031 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
20032 Generates the @code{mvfc} machine instruction which reads the control
20033 register specified in its argument and returns its value.
20036 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
20037 Generates the @code{mvtachi} machine instruction to set the top
20038 32 bits of the accumulator.
20041 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
20042 Generates the @code{mvtaclo} machine instruction to set the bottom
20043 32 bits of the accumulator.
20046 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
20047 Generates the @code{mvtc} machine instruction which sets control
20048 register number @code{reg} to @code{val}.
20051 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
20052 Generates the @code{mvtipl} machine instruction set the interrupt
20056 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
20057 Generates the @code{racw} machine instruction to round the accumulator
20058 according to the specified mode.
20061 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
20062 Generates the @code{revw} machine instruction which swaps the bytes in
20063 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
20064 and also bits 16--23 occupy bits 24--31 and vice versa.
20067 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
20068 Generates the @code{rmpa} machine instruction which initiates a
20069 repeated multiply and accumulate sequence.
20072 @deftypefn {Built-in Function} void __builtin_rx_round (float)
20073 Generates the @code{round} machine instruction which returns the
20074 floating-point argument rounded according to the current rounding mode
20075 set in the floating-point status word register.
20078 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
20079 Generates the @code{sat} machine instruction which returns the
20080 saturated value of the argument.
20083 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
20084 Generates the @code{setpsw} machine instruction to set the specified
20085 bit in the processor status word.
20088 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
20089 Generates the @code{wait} machine instruction.
20092 @node S/390 System z Built-in Functions
20093 @subsection S/390 System z Built-in Functions
20094 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
20095 Generates the @code{tbegin} machine instruction starting a
20096 non-constrained hardware transaction. If the parameter is non-NULL the
20097 memory area is used to store the transaction diagnostic buffer and
20098 will be passed as first operand to @code{tbegin}. This buffer can be
20099 defined using the @code{struct __htm_tdb} C struct defined in
20100 @code{htmintrin.h} and must reside on a double-word boundary. The
20101 second tbegin operand is set to @code{0xff0c}. This enables
20102 save/restore of all GPRs and disables aborts for FPR and AR
20103 manipulations inside the transaction body. The condition code set by
20104 the tbegin instruction is returned as integer value. The tbegin
20105 instruction by definition overwrites the content of all FPRs. The
20106 compiler will generate code which saves and restores the FPRs. For
20107 soft-float code it is recommended to used the @code{*_nofloat}
20108 variant. In order to prevent a TDB from being written it is required
20109 to pass a constant zero value as parameter. Passing a zero value
20110 through a variable is not sufficient. Although modifications of
20111 access registers inside the transaction will not trigger an
20112 transaction abort it is not supported to actually modify them. Access
20113 registers do not get saved when entering a transaction. They will have
20114 undefined state when reaching the abort code.
20117 Macros for the possible return codes of tbegin are defined in the
20118 @code{htmintrin.h} header file:
20121 @item _HTM_TBEGIN_STARTED
20122 @code{tbegin} has been executed as part of normal processing. The
20123 transaction body is supposed to be executed.
20124 @item _HTM_TBEGIN_INDETERMINATE
20125 The transaction was aborted due to an indeterminate condition which
20126 might be persistent.
20127 @item _HTM_TBEGIN_TRANSIENT
20128 The transaction aborted due to a transient failure. The transaction
20129 should be re-executed in that case.
20130 @item _HTM_TBEGIN_PERSISTENT
20131 The transaction aborted due to a persistent failure. Re-execution
20132 under same circumstances will not be productive.
20135 @defmac _HTM_FIRST_USER_ABORT_CODE
20136 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
20137 specifies the first abort code which can be used for
20138 @code{__builtin_tabort}. Values below this threshold are reserved for
20142 @deftp {Data type} {struct __htm_tdb}
20143 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
20144 the structure of the transaction diagnostic block as specified in the
20145 Principles of Operation manual chapter 5-91.
20148 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
20149 Same as @code{__builtin_tbegin} but without FPR saves and restores.
20150 Using this variant in code making use of FPRs will leave the FPRs in
20151 undefined state when entering the transaction abort handler code.
20154 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
20155 In addition to @code{__builtin_tbegin} a loop for transient failures
20156 is generated. If tbegin returns a condition code of 2 the transaction
20157 will be retried as often as specified in the second argument. The
20158 perform processor assist instruction is used to tell the CPU about the
20159 number of fails so far.
20162 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
20163 Same as @code{__builtin_tbegin_retry} but without FPR saves and
20164 restores. Using this variant in code making use of FPRs will leave
20165 the FPRs in undefined state when entering the transaction abort
20169 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
20170 Generates the @code{tbeginc} machine instruction starting a constrained
20171 hardware transaction. The second operand is set to @code{0xff08}.
20174 @deftypefn {Built-in Function} int __builtin_tend (void)
20175 Generates the @code{tend} machine instruction finishing a transaction
20176 and making the changes visible to other threads. The condition code
20177 generated by tend is returned as integer value.
20180 @deftypefn {Built-in Function} void __builtin_tabort (int)
20181 Generates the @code{tabort} machine instruction with the specified
20182 abort code. Abort codes from 0 through 255 are reserved and will
20183 result in an error message.
20186 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
20187 Generates the @code{ppa rX,rY,1} machine instruction. Where the
20188 integer parameter is loaded into rX and a value of zero is loaded into
20189 rY. The integer parameter specifies the number of times the
20190 transaction repeatedly aborted.
20193 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
20194 Generates the @code{etnd} machine instruction. The current nesting
20195 depth is returned as integer value. For a nesting depth of 0 the code
20196 is not executed as part of an transaction.
20199 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
20201 Generates the @code{ntstg} machine instruction. The second argument
20202 is written to the first arguments location. The store operation will
20203 not be rolled-back in case of an transaction abort.
20206 @node SH Built-in Functions
20207 @subsection SH Built-in Functions
20208 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
20209 families of processors:
20211 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
20212 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
20213 used by system code that manages threads and execution contexts. The compiler
20214 normally does not generate code that modifies the contents of @samp{GBR} and
20215 thus the value is preserved across function calls. Changing the @samp{GBR}
20216 value in user code must be done with caution, since the compiler might use
20217 @samp{GBR} in order to access thread local variables.
20221 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
20222 Returns the value that is currently set in the @samp{GBR} register.
20223 Memory loads and stores that use the thread pointer as a base address are
20224 turned into @samp{GBR} based displacement loads and stores, if possible.
20232 int get_tcb_value (void)
20234 // Generate @samp{mov.l @@(8,gbr),r0} instruction
20235 return ((my_tcb*)__builtin_thread_pointer ())->c;
20241 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
20242 Returns the value that is currently set in the @samp{FPSCR} register.
20245 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
20246 Sets the @samp{FPSCR} register to the specified value @var{val}, while
20247 preserving the current values of the FR, SZ and PR bits.
20250 @node SPARC VIS Built-in Functions
20251 @subsection SPARC VIS Built-in Functions
20253 GCC supports SIMD operations on the SPARC using both the generic vector
20254 extensions (@pxref{Vector Extensions}) as well as built-in functions for
20255 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
20256 switch, the VIS extension is exposed as the following built-in functions:
20259 typedef int v1si __attribute__ ((vector_size (4)));
20260 typedef int v2si __attribute__ ((vector_size (8)));
20261 typedef short v4hi __attribute__ ((vector_size (8)));
20262 typedef short v2hi __attribute__ ((vector_size (4)));
20263 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
20264 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
20266 void __builtin_vis_write_gsr (int64_t);
20267 int64_t __builtin_vis_read_gsr (void);
20269 void * __builtin_vis_alignaddr (void *, long);
20270 void * __builtin_vis_alignaddrl (void *, long);
20271 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
20272 v2si __builtin_vis_faligndatav2si (v2si, v2si);
20273 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
20274 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
20276 v4hi __builtin_vis_fexpand (v4qi);
20278 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
20279 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
20280 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
20281 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
20282 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
20283 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
20284 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
20286 v4qi __builtin_vis_fpack16 (v4hi);
20287 v8qi __builtin_vis_fpack32 (v2si, v8qi);
20288 v2hi __builtin_vis_fpackfix (v2si);
20289 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
20291 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
20293 long __builtin_vis_edge8 (void *, void *);
20294 long __builtin_vis_edge8l (void *, void *);
20295 long __builtin_vis_edge16 (void *, void *);
20296 long __builtin_vis_edge16l (void *, void *);
20297 long __builtin_vis_edge32 (void *, void *);
20298 long __builtin_vis_edge32l (void *, void *);
20300 long __builtin_vis_fcmple16 (v4hi, v4hi);
20301 long __builtin_vis_fcmple32 (v2si, v2si);
20302 long __builtin_vis_fcmpne16 (v4hi, v4hi);
20303 long __builtin_vis_fcmpne32 (v2si, v2si);
20304 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
20305 long __builtin_vis_fcmpgt32 (v2si, v2si);
20306 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
20307 long __builtin_vis_fcmpeq32 (v2si, v2si);
20309 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
20310 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
20311 v2si __builtin_vis_fpadd32 (v2si, v2si);
20312 v1si __builtin_vis_fpadd32s (v1si, v1si);
20313 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
20314 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
20315 v2si __builtin_vis_fpsub32 (v2si, v2si);
20316 v1si __builtin_vis_fpsub32s (v1si, v1si);
20318 long __builtin_vis_array8 (long, long);
20319 long __builtin_vis_array16 (long, long);
20320 long __builtin_vis_array32 (long, long);
20323 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
20324 functions also become available:
20327 long __builtin_vis_bmask (long, long);
20328 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
20329 v2si __builtin_vis_bshufflev2si (v2si, v2si);
20330 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
20331 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
20333 long __builtin_vis_edge8n (void *, void *);
20334 long __builtin_vis_edge8ln (void *, void *);
20335 long __builtin_vis_edge16n (void *, void *);
20336 long __builtin_vis_edge16ln (void *, void *);
20337 long __builtin_vis_edge32n (void *, void *);
20338 long __builtin_vis_edge32ln (void *, void *);
20341 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
20342 functions also become available:
20345 void __builtin_vis_cmask8 (long);
20346 void __builtin_vis_cmask16 (long);
20347 void __builtin_vis_cmask32 (long);
20349 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
20351 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
20352 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
20353 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
20354 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
20355 v2si __builtin_vis_fsll16 (v2si, v2si);
20356 v2si __builtin_vis_fslas16 (v2si, v2si);
20357 v2si __builtin_vis_fsrl16 (v2si, v2si);
20358 v2si __builtin_vis_fsra16 (v2si, v2si);
20360 long __builtin_vis_pdistn (v8qi, v8qi);
20362 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
20364 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
20365 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
20367 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
20368 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
20369 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
20370 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
20371 v2si __builtin_vis_fpadds32 (v2si, v2si);
20372 v1si __builtin_vis_fpadds32s (v1si, v1si);
20373 v2si __builtin_vis_fpsubs32 (v2si, v2si);
20374 v1si __builtin_vis_fpsubs32s (v1si, v1si);
20376 long __builtin_vis_fucmple8 (v8qi, v8qi);
20377 long __builtin_vis_fucmpne8 (v8qi, v8qi);
20378 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
20379 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
20381 float __builtin_vis_fhadds (float, float);
20382 double __builtin_vis_fhaddd (double, double);
20383 float __builtin_vis_fhsubs (float, float);
20384 double __builtin_vis_fhsubd (double, double);
20385 float __builtin_vis_fnhadds (float, float);
20386 double __builtin_vis_fnhaddd (double, double);
20388 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
20389 int64_t __builtin_vis_xmulx (int64_t, int64_t);
20390 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
20393 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
20394 functions also become available:
20397 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
20398 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
20399 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
20400 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
20402 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
20403 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
20404 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
20405 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
20407 long __builtin_vis_fpcmple8 (v8qi, v8qi);
20408 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
20409 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
20410 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
20411 long __builtin_vis_fpcmpule32 (v2si, v2si);
20412 long __builtin_vis_fpcmpugt32 (v2si, v2si);
20414 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
20415 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
20416 v2si __builtin_vis_fpmax32 (v2si, v2si);
20418 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
20419 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
20420 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
20423 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
20424 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
20425 v2si __builtin_vis_fpmin32 (v2si, v2si);
20427 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
20428 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
20429 v2si __builtin_vis_fpminu32 (v2si, v2si);
20432 When you use the @option{-mvis4b} switch, the VIS version 4.0B
20433 built-in functions also become available:
20436 v8qi __builtin_vis_dictunpack8 (double, int);
20437 v4hi __builtin_vis_dictunpack16 (double, int);
20438 v2si __builtin_vis_dictunpack32 (double, int);
20440 long __builtin_vis_fpcmple8shl (v8qi, v8qi, int);
20441 long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int);
20442 long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int);
20443 long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int);
20445 long __builtin_vis_fpcmple16shl (v4hi, v4hi, int);
20446 long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int);
20447 long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int);
20448 long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int);
20450 long __builtin_vis_fpcmple32shl (v2si, v2si, int);
20451 long __builtin_vis_fpcmpgt32shl (v2si, v2si, int);
20452 long __builtin_vis_fpcmpeq32shl (v2si, v2si, int);
20453 long __builtin_vis_fpcmpne32shl (v2si, v2si, int);
20455 long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int);
20456 long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int);
20457 long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int);
20458 long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int);
20459 long __builtin_vis_fpcmpule32shl (v2si, v2si, int);
20460 long __builtin_vis_fpcmpugt32shl (v2si, v2si, int);
20462 long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int);
20463 long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int);
20464 long __builtin_vis_fpcmpde32shl (v2si, v2si, int);
20466 long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int);
20467 long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int);
20468 long __builtin_vis_fpcmpur32shl (v2si, v2si, int);
20471 @node SPU Built-in Functions
20472 @subsection SPU Built-in Functions
20474 GCC provides extensions for the SPU processor as described in the
20475 Sony/Toshiba/IBM SPU Language Extensions Specification. GCC's
20476 implementation differs in several ways.
20481 The optional extension of specifying vector constants in parentheses is
20485 A vector initializer requires no cast if the vector constant is of the
20486 same type as the variable it is initializing.
20489 If @code{signed} or @code{unsigned} is omitted, the signedness of the
20490 vector type is the default signedness of the base type. The default
20491 varies depending on the operating system, so a portable program should
20492 always specify the signedness.
20495 By default, the keyword @code{__vector} is added. The macro
20496 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
20500 GCC allows using a @code{typedef} name as the type specifier for a
20504 For C, overloaded functions are implemented with macros so the following
20508 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
20512 Since @code{spu_add} is a macro, the vector constant in the example
20513 is treated as four separate arguments. Wrap the entire argument in
20514 parentheses for this to work.
20517 The extended version of @code{__builtin_expect} is not supported.
20521 @emph{Note:} Only the interface described in the aforementioned
20522 specification is supported. Internally, GCC uses built-in functions to
20523 implement the required functionality, but these are not supported and
20524 are subject to change without notice.
20526 @node TI C6X Built-in Functions
20527 @subsection TI C6X Built-in Functions
20529 GCC provides intrinsics to access certain instructions of the TI C6X
20530 processors. These intrinsics, listed below, are available after
20531 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
20532 to C6X instructions.
20536 int _sadd (int, int)
20537 int _ssub (int, int)
20538 int _sadd2 (int, int)
20539 int _ssub2 (int, int)
20540 long long _mpy2 (int, int)
20541 long long _smpy2 (int, int)
20542 int _add4 (int, int)
20543 int _sub4 (int, int)
20544 int _saddu4 (int, int)
20546 int _smpy (int, int)
20547 int _smpyh (int, int)
20548 int _smpyhl (int, int)
20549 int _smpylh (int, int)
20551 int _sshl (int, int)
20552 int _subc (int, int)
20554 int _avg2 (int, int)
20555 int _avgu4 (int, int)
20557 int _clrr (int, int)
20558 int _extr (int, int)
20559 int _extru (int, int)
20565 @node TILE-Gx Built-in Functions
20566 @subsection TILE-Gx Built-in Functions
20568 GCC provides intrinsics to access every instruction of the TILE-Gx
20569 processor. The intrinsics are of the form:
20573 unsigned long long __insn_@var{op} (...)
20577 Where @var{op} is the name of the instruction. Refer to the ISA manual
20578 for the complete list of instructions.
20580 GCC also provides intrinsics to directly access the network registers.
20581 The intrinsics are:
20585 unsigned long long __tile_idn0_receive (void)
20586 unsigned long long __tile_idn1_receive (void)
20587 unsigned long long __tile_udn0_receive (void)
20588 unsigned long long __tile_udn1_receive (void)
20589 unsigned long long __tile_udn2_receive (void)
20590 unsigned long long __tile_udn3_receive (void)
20591 void __tile_idn_send (unsigned long long)
20592 void __tile_udn_send (unsigned long long)
20596 The intrinsic @code{void __tile_network_barrier (void)} is used to
20597 guarantee that no network operations before it are reordered with
20600 @node TILEPro Built-in Functions
20601 @subsection TILEPro Built-in Functions
20603 GCC provides intrinsics to access every instruction of the TILEPro
20604 processor. The intrinsics are of the form:
20608 unsigned __insn_@var{op} (...)
20613 where @var{op} is the name of the instruction. Refer to the ISA manual
20614 for the complete list of instructions.
20616 GCC also provides intrinsics to directly access the network registers.
20617 The intrinsics are:
20621 unsigned __tile_idn0_receive (void)
20622 unsigned __tile_idn1_receive (void)
20623 unsigned __tile_sn_receive (void)
20624 unsigned __tile_udn0_receive (void)
20625 unsigned __tile_udn1_receive (void)
20626 unsigned __tile_udn2_receive (void)
20627 unsigned __tile_udn3_receive (void)
20628 void __tile_idn_send (unsigned)
20629 void __tile_sn_send (unsigned)
20630 void __tile_udn_send (unsigned)
20634 The intrinsic @code{void __tile_network_barrier (void)} is used to
20635 guarantee that no network operations before it are reordered with
20638 @node x86 Built-in Functions
20639 @subsection x86 Built-in Functions
20641 These built-in functions are available for the x86-32 and x86-64 family
20642 of computers, depending on the command-line switches used.
20644 If you specify command-line switches such as @option{-msse},
20645 the compiler could use the extended instruction sets even if the built-ins
20646 are not used explicitly in the program. For this reason, applications
20647 that perform run-time CPU detection must compile separate files for each
20648 supported architecture, using the appropriate flags. In particular,
20649 the file containing the CPU detection code should be compiled without
20652 The following machine modes are available for use with MMX built-in functions
20653 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
20654 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
20655 vector of eight 8-bit integers. Some of the built-in functions operate on
20656 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
20658 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
20659 of two 32-bit floating-point values.
20661 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
20662 floating-point values. Some instructions use a vector of four 32-bit
20663 integers, these use @code{V4SI}. Finally, some instructions operate on an
20664 entire vector register, interpreting it as a 128-bit integer, these use mode
20667 The x86-32 and x86-64 family of processors use additional built-in
20668 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
20669 floating point and @code{TC} 128-bit complex floating-point values.
20671 The following floating-point built-in functions are always available. All
20672 of them implement the function that is part of the name.
20675 __float128 __builtin_fabsq (__float128)
20676 __float128 __builtin_copysignq (__float128, __float128)
20679 The following built-in functions are always available.
20682 @item __float128 __builtin_infq (void)
20683 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
20684 @findex __builtin_infq
20686 @item __float128 __builtin_huge_valq (void)
20687 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
20688 @findex __builtin_huge_valq
20690 @item __float128 __builtin_nanq (void)
20691 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
20692 @findex __builtin_nanq
20694 @item __float128 __builtin_nansq (void)
20695 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
20696 @findex __builtin_nansq
20699 The following built-in function is always available.
20702 @item void __builtin_ia32_pause (void)
20703 Generates the @code{pause} machine instruction with a compiler memory
20707 The following built-in functions are always available and can be used to
20708 check the target platform type.
20710 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
20711 This function runs the CPU detection code to check the type of CPU and the
20712 features supported. This built-in function needs to be invoked along with the built-in functions
20713 to check CPU type and features, @code{__builtin_cpu_is} and
20714 @code{__builtin_cpu_supports}, only when used in a function that is
20715 executed before any constructors are called. The CPU detection code is
20716 automatically executed in a very high priority constructor.
20718 For example, this function has to be used in @code{ifunc} resolvers that
20719 check for CPU type using the built-in functions @code{__builtin_cpu_is}
20720 and @code{__builtin_cpu_supports}, or in constructors on targets that
20721 don't support constructor priority.
20724 static void (*resolve_memcpy (void)) (void)
20726 // ifunc resolvers fire before constructors, explicitly call the init
20728 __builtin_cpu_init ();
20729 if (__builtin_cpu_supports ("ssse3"))
20730 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
20732 return default_memcpy;
20735 void *memcpy (void *, const void *, size_t)
20736 __attribute__ ((ifunc ("resolve_memcpy")));
20741 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
20742 This function returns a positive integer if the run-time CPU
20743 is of type @var{cpuname}
20744 and returns @code{0} otherwise. The following CPU names can be detected:
20757 Intel Silvermont CPU.
20766 Intel Core i7 Nehalem CPU.
20769 Intel Core i7 Westmere CPU.
20772 Intel Core i7 Sandy Bridge CPU.
20775 Intel Core i7 Ivy Bridge CPU.
20778 Intel Core i7 Haswell CPU.
20781 Intel Core i7 Broadwell CPU.
20784 Intel Core i7 Skylake CPU.
20786 @item skylake-avx512
20787 Intel Core i7 Skylake AVX512 CPU.
20790 Intel Core i7 Cannon Lake CPU.
20792 @item icelake-client
20793 Intel Core i7 Ice Lake Client CPU.
20795 @item icelake-server
20796 Intel Core i7 Ice Lake Server CPU.
20799 Intel Core i7 Cascadelake CPU.
20802 Intel Atom Bonnell CPU.
20805 Intel Atom Silvermont CPU.
20808 Intel Atom Goldmont CPU.
20810 @item goldmont-plus
20811 Intel Atom Goldmont Plus CPU.
20814 Intel Atom Tremont CPU.
20817 Intel Knights Landing CPU.
20820 Intel Knights Mill CPU.
20823 AMD Family 10h CPU.
20826 AMD Family 10h Barcelona CPU.
20829 AMD Family 10h Shanghai CPU.
20832 AMD Family 10h Istanbul CPU.
20835 AMD Family 14h CPU.
20838 AMD Family 15h CPU.
20841 AMD Family 15h Bulldozer version 1.
20844 AMD Family 15h Bulldozer version 2.
20847 AMD Family 15h Bulldozer version 3.
20850 AMD Family 15h Bulldozer version 4.
20853 AMD Family 16h CPU.
20856 AMD Family 17h CPU.
20859 AMD Family 17h Zen version 1.
20862 AMD Family 17h Zen version 2.
20865 Here is an example:
20867 if (__builtin_cpu_is ("corei7"))
20869 do_corei7 (); // Core i7 specific implementation.
20873 do_generic (); // Generic implementation.
20878 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
20879 This function returns a positive integer if the run-time CPU
20880 supports @var{feature}
20881 and returns @code{0} otherwise. The following features can be detected:
20889 POPCNT instruction.
20897 SSSE3 instructions.
20899 SSE4.1 instructions.
20901 SSE4.2 instructions.
20907 SSE4A instructions.
20915 AVX512F instructions.
20923 PCLMUL instructions.
20925 AVX512VL instructions.
20927 AVX512BW instructions.
20929 AVX512DQ instructions.
20931 AVX512CD instructions.
20933 AVX512ER instructions.
20935 AVX512PF instructions.
20937 AVX512VBMI instructions.
20939 AVX512IFMA instructions.
20941 AVX5124VNNIW instructions.
20943 AVX5124FMAPS instructions.
20944 @item avx512vpopcntdq
20945 AVX512VPOPCNTDQ instructions.
20947 AVX512VBMI2 instructions.
20951 VPCLMULQDQ instructions.
20953 AVX512VNNI instructions.
20955 AVX512BITALG instructions.
20958 Here is an example:
20960 if (__builtin_cpu_supports ("popcnt"))
20962 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
20966 count = generic_countbits (n); //generic implementation.
20972 The following built-in functions are made available by @option{-mmmx}.
20973 All of them generate the machine instruction that is part of the name.
20976 v8qi __builtin_ia32_paddb (v8qi, v8qi)
20977 v4hi __builtin_ia32_paddw (v4hi, v4hi)
20978 v2si __builtin_ia32_paddd (v2si, v2si)
20979 v8qi __builtin_ia32_psubb (v8qi, v8qi)
20980 v4hi __builtin_ia32_psubw (v4hi, v4hi)
20981 v2si __builtin_ia32_psubd (v2si, v2si)
20982 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
20983 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
20984 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
20985 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
20986 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
20987 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
20988 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
20989 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
20990 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
20991 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
20992 di __builtin_ia32_pand (di, di)
20993 di __builtin_ia32_pandn (di,di)
20994 di __builtin_ia32_por (di, di)
20995 di __builtin_ia32_pxor (di, di)
20996 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
20997 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
20998 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
20999 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
21000 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
21001 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
21002 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
21003 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
21004 v2si __builtin_ia32_punpckhdq (v2si, v2si)
21005 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
21006 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
21007 v2si __builtin_ia32_punpckldq (v2si, v2si)
21008 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
21009 v4hi __builtin_ia32_packssdw (v2si, v2si)
21010 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
21012 v4hi __builtin_ia32_psllw (v4hi, v4hi)
21013 v2si __builtin_ia32_pslld (v2si, v2si)
21014 v1di __builtin_ia32_psllq (v1di, v1di)
21015 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
21016 v2si __builtin_ia32_psrld (v2si, v2si)
21017 v1di __builtin_ia32_psrlq (v1di, v1di)
21018 v4hi __builtin_ia32_psraw (v4hi, v4hi)
21019 v2si __builtin_ia32_psrad (v2si, v2si)
21020 v4hi __builtin_ia32_psllwi (v4hi, int)
21021 v2si __builtin_ia32_pslldi (v2si, int)
21022 v1di __builtin_ia32_psllqi (v1di, int)
21023 v4hi __builtin_ia32_psrlwi (v4hi, int)
21024 v2si __builtin_ia32_psrldi (v2si, int)
21025 v1di __builtin_ia32_psrlqi (v1di, int)
21026 v4hi __builtin_ia32_psrawi (v4hi, int)
21027 v2si __builtin_ia32_psradi (v2si, int)
21031 The following built-in functions are made available either with
21032 @option{-msse}, or with @option{-m3dnowa}. All of them generate
21033 the machine instruction that is part of the name.
21036 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
21037 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
21038 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
21039 v1di __builtin_ia32_psadbw (v8qi, v8qi)
21040 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
21041 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
21042 v8qi __builtin_ia32_pminub (v8qi, v8qi)
21043 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
21044 int __builtin_ia32_pmovmskb (v8qi)
21045 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
21046 void __builtin_ia32_movntq (di *, di)
21047 void __builtin_ia32_sfence (void)
21050 The following built-in functions are available when @option{-msse} is used.
21051 All of them generate the machine instruction that is part of the name.
21054 int __builtin_ia32_comieq (v4sf, v4sf)
21055 int __builtin_ia32_comineq (v4sf, v4sf)
21056 int __builtin_ia32_comilt (v4sf, v4sf)
21057 int __builtin_ia32_comile (v4sf, v4sf)
21058 int __builtin_ia32_comigt (v4sf, v4sf)
21059 int __builtin_ia32_comige (v4sf, v4sf)
21060 int __builtin_ia32_ucomieq (v4sf, v4sf)
21061 int __builtin_ia32_ucomineq (v4sf, v4sf)
21062 int __builtin_ia32_ucomilt (v4sf, v4sf)
21063 int __builtin_ia32_ucomile (v4sf, v4sf)
21064 int __builtin_ia32_ucomigt (v4sf, v4sf)
21065 int __builtin_ia32_ucomige (v4sf, v4sf)
21066 v4sf __builtin_ia32_addps (v4sf, v4sf)
21067 v4sf __builtin_ia32_subps (v4sf, v4sf)
21068 v4sf __builtin_ia32_mulps (v4sf, v4sf)
21069 v4sf __builtin_ia32_divps (v4sf, v4sf)
21070 v4sf __builtin_ia32_addss (v4sf, v4sf)
21071 v4sf __builtin_ia32_subss (v4sf, v4sf)
21072 v4sf __builtin_ia32_mulss (v4sf, v4sf)
21073 v4sf __builtin_ia32_divss (v4sf, v4sf)
21074 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
21075 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
21076 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
21077 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
21078 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
21079 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
21080 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
21081 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
21082 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
21083 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
21084 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
21085 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
21086 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
21087 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
21088 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
21089 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
21090 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
21091 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
21092 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
21093 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
21094 v4sf __builtin_ia32_maxps (v4sf, v4sf)
21095 v4sf __builtin_ia32_maxss (v4sf, v4sf)
21096 v4sf __builtin_ia32_minps (v4sf, v4sf)
21097 v4sf __builtin_ia32_minss (v4sf, v4sf)
21098 v4sf __builtin_ia32_andps (v4sf, v4sf)
21099 v4sf __builtin_ia32_andnps (v4sf, v4sf)
21100 v4sf __builtin_ia32_orps (v4sf, v4sf)
21101 v4sf __builtin_ia32_xorps (v4sf, v4sf)
21102 v4sf __builtin_ia32_movss (v4sf, v4sf)
21103 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
21104 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
21105 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
21106 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
21107 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
21108 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
21109 v2si __builtin_ia32_cvtps2pi (v4sf)
21110 int __builtin_ia32_cvtss2si (v4sf)
21111 v2si __builtin_ia32_cvttps2pi (v4sf)
21112 int __builtin_ia32_cvttss2si (v4sf)
21113 v4sf __builtin_ia32_rcpps (v4sf)
21114 v4sf __builtin_ia32_rsqrtps (v4sf)
21115 v4sf __builtin_ia32_sqrtps (v4sf)
21116 v4sf __builtin_ia32_rcpss (v4sf)
21117 v4sf __builtin_ia32_rsqrtss (v4sf)
21118 v4sf __builtin_ia32_sqrtss (v4sf)
21119 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
21120 void __builtin_ia32_movntps (float *, v4sf)
21121 int __builtin_ia32_movmskps (v4sf)
21124 The following built-in functions are available when @option{-msse} is used.
21127 @item v4sf __builtin_ia32_loadups (float *)
21128 Generates the @code{movups} machine instruction as a load from memory.
21129 @item void __builtin_ia32_storeups (float *, v4sf)
21130 Generates the @code{movups} machine instruction as a store to memory.
21131 @item v4sf __builtin_ia32_loadss (float *)
21132 Generates the @code{movss} machine instruction as a load from memory.
21133 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
21134 Generates the @code{movhps} machine instruction as a load from memory.
21135 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
21136 Generates the @code{movlps} machine instruction as a load from memory
21137 @item void __builtin_ia32_storehps (v2sf *, v4sf)
21138 Generates the @code{movhps} machine instruction as a store to memory.
21139 @item void __builtin_ia32_storelps (v2sf *, v4sf)
21140 Generates the @code{movlps} machine instruction as a store to memory.
21143 The following built-in functions are available when @option{-msse2} is used.
21144 All of them generate the machine instruction that is part of the name.
21147 int __builtin_ia32_comisdeq (v2df, v2df)
21148 int __builtin_ia32_comisdlt (v2df, v2df)
21149 int __builtin_ia32_comisdle (v2df, v2df)
21150 int __builtin_ia32_comisdgt (v2df, v2df)
21151 int __builtin_ia32_comisdge (v2df, v2df)
21152 int __builtin_ia32_comisdneq (v2df, v2df)
21153 int __builtin_ia32_ucomisdeq (v2df, v2df)
21154 int __builtin_ia32_ucomisdlt (v2df, v2df)
21155 int __builtin_ia32_ucomisdle (v2df, v2df)
21156 int __builtin_ia32_ucomisdgt (v2df, v2df)
21157 int __builtin_ia32_ucomisdge (v2df, v2df)
21158 int __builtin_ia32_ucomisdneq (v2df, v2df)
21159 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
21160 v2df __builtin_ia32_cmpltpd (v2df, v2df)
21161 v2df __builtin_ia32_cmplepd (v2df, v2df)
21162 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
21163 v2df __builtin_ia32_cmpgepd (v2df, v2df)
21164 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
21165 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
21166 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
21167 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
21168 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
21169 v2df __builtin_ia32_cmpngepd (v2df, v2df)
21170 v2df __builtin_ia32_cmpordpd (v2df, v2df)
21171 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
21172 v2df __builtin_ia32_cmpltsd (v2df, v2df)
21173 v2df __builtin_ia32_cmplesd (v2df, v2df)
21174 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
21175 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
21176 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
21177 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
21178 v2df __builtin_ia32_cmpordsd (v2df, v2df)
21179 v2di __builtin_ia32_paddq (v2di, v2di)
21180 v2di __builtin_ia32_psubq (v2di, v2di)
21181 v2df __builtin_ia32_addpd (v2df, v2df)
21182 v2df __builtin_ia32_subpd (v2df, v2df)
21183 v2df __builtin_ia32_mulpd (v2df, v2df)
21184 v2df __builtin_ia32_divpd (v2df, v2df)
21185 v2df __builtin_ia32_addsd (v2df, v2df)
21186 v2df __builtin_ia32_subsd (v2df, v2df)
21187 v2df __builtin_ia32_mulsd (v2df, v2df)
21188 v2df __builtin_ia32_divsd (v2df, v2df)
21189 v2df __builtin_ia32_minpd (v2df, v2df)
21190 v2df __builtin_ia32_maxpd (v2df, v2df)
21191 v2df __builtin_ia32_minsd (v2df, v2df)
21192 v2df __builtin_ia32_maxsd (v2df, v2df)
21193 v2df __builtin_ia32_andpd (v2df, v2df)
21194 v2df __builtin_ia32_andnpd (v2df, v2df)
21195 v2df __builtin_ia32_orpd (v2df, v2df)
21196 v2df __builtin_ia32_xorpd (v2df, v2df)
21197 v2df __builtin_ia32_movsd (v2df, v2df)
21198 v2df __builtin_ia32_unpckhpd (v2df, v2df)
21199 v2df __builtin_ia32_unpcklpd (v2df, v2df)
21200 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
21201 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
21202 v4si __builtin_ia32_paddd128 (v4si, v4si)
21203 v2di __builtin_ia32_paddq128 (v2di, v2di)
21204 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
21205 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
21206 v4si __builtin_ia32_psubd128 (v4si, v4si)
21207 v2di __builtin_ia32_psubq128 (v2di, v2di)
21208 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
21209 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
21210 v2di __builtin_ia32_pand128 (v2di, v2di)
21211 v2di __builtin_ia32_pandn128 (v2di, v2di)
21212 v2di __builtin_ia32_por128 (v2di, v2di)
21213 v2di __builtin_ia32_pxor128 (v2di, v2di)
21214 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
21215 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
21216 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
21217 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
21218 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
21219 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
21220 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
21221 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
21222 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
21223 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
21224 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
21225 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
21226 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
21227 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
21228 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
21229 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
21230 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
21231 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
21232 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
21233 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
21234 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
21235 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
21236 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
21237 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
21238 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
21239 v2df __builtin_ia32_loadupd (double *)
21240 void __builtin_ia32_storeupd (double *, v2df)
21241 v2df __builtin_ia32_loadhpd (v2df, double const *)
21242 v2df __builtin_ia32_loadlpd (v2df, double const *)
21243 int __builtin_ia32_movmskpd (v2df)
21244 int __builtin_ia32_pmovmskb128 (v16qi)
21245 void __builtin_ia32_movnti (int *, int)
21246 void __builtin_ia32_movnti64 (long long int *, long long int)
21247 void __builtin_ia32_movntpd (double *, v2df)
21248 void __builtin_ia32_movntdq (v2df *, v2df)
21249 v4si __builtin_ia32_pshufd (v4si, int)
21250 v8hi __builtin_ia32_pshuflw (v8hi, int)
21251 v8hi __builtin_ia32_pshufhw (v8hi, int)
21252 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
21253 v2df __builtin_ia32_sqrtpd (v2df)
21254 v2df __builtin_ia32_sqrtsd (v2df)
21255 v2df __builtin_ia32_shufpd (v2df, v2df, int)
21256 v2df __builtin_ia32_cvtdq2pd (v4si)
21257 v4sf __builtin_ia32_cvtdq2ps (v4si)
21258 v4si __builtin_ia32_cvtpd2dq (v2df)
21259 v2si __builtin_ia32_cvtpd2pi (v2df)
21260 v4sf __builtin_ia32_cvtpd2ps (v2df)
21261 v4si __builtin_ia32_cvttpd2dq (v2df)
21262 v2si __builtin_ia32_cvttpd2pi (v2df)
21263 v2df __builtin_ia32_cvtpi2pd (v2si)
21264 int __builtin_ia32_cvtsd2si (v2df)
21265 int __builtin_ia32_cvttsd2si (v2df)
21266 long long __builtin_ia32_cvtsd2si64 (v2df)
21267 long long __builtin_ia32_cvttsd2si64 (v2df)
21268 v4si __builtin_ia32_cvtps2dq (v4sf)
21269 v2df __builtin_ia32_cvtps2pd (v4sf)
21270 v4si __builtin_ia32_cvttps2dq (v4sf)
21271 v2df __builtin_ia32_cvtsi2sd (v2df, int)
21272 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
21273 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
21274 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
21275 void __builtin_ia32_clflush (const void *)
21276 void __builtin_ia32_lfence (void)
21277 void __builtin_ia32_mfence (void)
21278 v16qi __builtin_ia32_loaddqu (const char *)
21279 void __builtin_ia32_storedqu (char *, v16qi)
21280 v1di __builtin_ia32_pmuludq (v2si, v2si)
21281 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
21282 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
21283 v4si __builtin_ia32_pslld128 (v4si, v4si)
21284 v2di __builtin_ia32_psllq128 (v2di, v2di)
21285 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
21286 v4si __builtin_ia32_psrld128 (v4si, v4si)
21287 v2di __builtin_ia32_psrlq128 (v2di, v2di)
21288 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
21289 v4si __builtin_ia32_psrad128 (v4si, v4si)
21290 v2di __builtin_ia32_pslldqi128 (v2di, int)
21291 v8hi __builtin_ia32_psllwi128 (v8hi, int)
21292 v4si __builtin_ia32_pslldi128 (v4si, int)
21293 v2di __builtin_ia32_psllqi128 (v2di, int)
21294 v2di __builtin_ia32_psrldqi128 (v2di, int)
21295 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
21296 v4si __builtin_ia32_psrldi128 (v4si, int)
21297 v2di __builtin_ia32_psrlqi128 (v2di, int)
21298 v8hi __builtin_ia32_psrawi128 (v8hi, int)
21299 v4si __builtin_ia32_psradi128 (v4si, int)
21300 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
21301 v2di __builtin_ia32_movq128 (v2di)
21304 The following built-in functions are available when @option{-msse3} is used.
21305 All of them generate the machine instruction that is part of the name.
21308 v2df __builtin_ia32_addsubpd (v2df, v2df)
21309 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
21310 v2df __builtin_ia32_haddpd (v2df, v2df)
21311 v4sf __builtin_ia32_haddps (v4sf, v4sf)
21312 v2df __builtin_ia32_hsubpd (v2df, v2df)
21313 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
21314 v16qi __builtin_ia32_lddqu (char const *)
21315 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
21316 v4sf __builtin_ia32_movshdup (v4sf)
21317 v4sf __builtin_ia32_movsldup (v4sf)
21318 void __builtin_ia32_mwait (unsigned int, unsigned int)
21321 The following built-in functions are available when @option{-mssse3} is used.
21322 All of them generate the machine instruction that is part of the name.
21325 v2si __builtin_ia32_phaddd (v2si, v2si)
21326 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
21327 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
21328 v2si __builtin_ia32_phsubd (v2si, v2si)
21329 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
21330 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
21331 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
21332 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
21333 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
21334 v8qi __builtin_ia32_psignb (v8qi, v8qi)
21335 v2si __builtin_ia32_psignd (v2si, v2si)
21336 v4hi __builtin_ia32_psignw (v4hi, v4hi)
21337 v1di __builtin_ia32_palignr (v1di, v1di, int)
21338 v8qi __builtin_ia32_pabsb (v8qi)
21339 v2si __builtin_ia32_pabsd (v2si)
21340 v4hi __builtin_ia32_pabsw (v4hi)
21343 The following built-in functions are available when @option{-mssse3} is used.
21344 All of them generate the machine instruction that is part of the name.
21347 v4si __builtin_ia32_phaddd128 (v4si, v4si)
21348 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
21349 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
21350 v4si __builtin_ia32_phsubd128 (v4si, v4si)
21351 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
21352 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
21353 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
21354 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
21355 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
21356 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
21357 v4si __builtin_ia32_psignd128 (v4si, v4si)
21358 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
21359 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
21360 v16qi __builtin_ia32_pabsb128 (v16qi)
21361 v4si __builtin_ia32_pabsd128 (v4si)
21362 v8hi __builtin_ia32_pabsw128 (v8hi)
21365 The following built-in functions are available when @option{-msse4.1} is
21366 used. All of them generate the machine instruction that is part of the
21370 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
21371 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
21372 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
21373 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
21374 v2df __builtin_ia32_dppd (v2df, v2df, const int)
21375 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
21376 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
21377 v2di __builtin_ia32_movntdqa (v2di *);
21378 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
21379 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
21380 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
21381 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
21382 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
21383 v8hi __builtin_ia32_phminposuw128 (v8hi)
21384 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
21385 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
21386 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
21387 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
21388 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
21389 v4si __builtin_ia32_pminsd128 (v4si, v4si)
21390 v4si __builtin_ia32_pminud128 (v4si, v4si)
21391 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
21392 v4si __builtin_ia32_pmovsxbd128 (v16qi)
21393 v2di __builtin_ia32_pmovsxbq128 (v16qi)
21394 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
21395 v2di __builtin_ia32_pmovsxdq128 (v4si)
21396 v4si __builtin_ia32_pmovsxwd128 (v8hi)
21397 v2di __builtin_ia32_pmovsxwq128 (v8hi)
21398 v4si __builtin_ia32_pmovzxbd128 (v16qi)
21399 v2di __builtin_ia32_pmovzxbq128 (v16qi)
21400 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
21401 v2di __builtin_ia32_pmovzxdq128 (v4si)
21402 v4si __builtin_ia32_pmovzxwd128 (v8hi)
21403 v2di __builtin_ia32_pmovzxwq128 (v8hi)
21404 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
21405 v4si __builtin_ia32_pmulld128 (v4si, v4si)
21406 int __builtin_ia32_ptestc128 (v2di, v2di)
21407 int __builtin_ia32_ptestnzc128 (v2di, v2di)
21408 int __builtin_ia32_ptestz128 (v2di, v2di)
21409 v2df __builtin_ia32_roundpd (v2df, const int)
21410 v4sf __builtin_ia32_roundps (v4sf, const int)
21411 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
21412 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
21415 The following built-in functions are available when @option{-msse4.1} is
21419 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
21420 Generates the @code{insertps} machine instruction.
21421 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
21422 Generates the @code{pextrb} machine instruction.
21423 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
21424 Generates the @code{pinsrb} machine instruction.
21425 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
21426 Generates the @code{pinsrd} machine instruction.
21427 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
21428 Generates the @code{pinsrq} machine instruction in 64bit mode.
21431 The following built-in functions are changed to generate new SSE4.1
21432 instructions when @option{-msse4.1} is used.
21435 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
21436 Generates the @code{extractps} machine instruction.
21437 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
21438 Generates the @code{pextrd} machine instruction.
21439 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
21440 Generates the @code{pextrq} machine instruction in 64bit mode.
21443 The following built-in functions are available when @option{-msse4.2} is
21444 used. All of them generate the machine instruction that is part of the
21448 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
21449 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
21450 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
21451 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
21452 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
21453 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
21454 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
21455 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
21456 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
21457 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
21458 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
21459 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
21460 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
21461 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
21462 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
21465 The following built-in functions are available when @option{-msse4.2} is
21469 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
21470 Generates the @code{crc32b} machine instruction.
21471 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
21472 Generates the @code{crc32w} machine instruction.
21473 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
21474 Generates the @code{crc32l} machine instruction.
21475 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
21476 Generates the @code{crc32q} machine instruction.
21479 The following built-in functions are changed to generate new SSE4.2
21480 instructions when @option{-msse4.2} is used.
21483 @item int __builtin_popcount (unsigned int)
21484 Generates the @code{popcntl} machine instruction.
21485 @item int __builtin_popcountl (unsigned long)
21486 Generates the @code{popcntl} or @code{popcntq} machine instruction,
21487 depending on the size of @code{unsigned long}.
21488 @item int __builtin_popcountll (unsigned long long)
21489 Generates the @code{popcntq} machine instruction.
21492 The following built-in functions are available when @option{-mavx} is
21493 used. All of them generate the machine instruction that is part of the
21497 v4df __builtin_ia32_addpd256 (v4df,v4df)
21498 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
21499 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
21500 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
21501 v4df __builtin_ia32_andnpd256 (v4df,v4df)
21502 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
21503 v4df __builtin_ia32_andpd256 (v4df,v4df)
21504 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
21505 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
21506 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
21507 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
21508 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
21509 v2df __builtin_ia32_cmppd (v2df,v2df,int)
21510 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
21511 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
21512 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
21513 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
21514 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
21515 v4df __builtin_ia32_cvtdq2pd256 (v4si)
21516 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
21517 v4si __builtin_ia32_cvtpd2dq256 (v4df)
21518 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
21519 v8si __builtin_ia32_cvtps2dq256 (v8sf)
21520 v4df __builtin_ia32_cvtps2pd256 (v4sf)
21521 v4si __builtin_ia32_cvttpd2dq256 (v4df)
21522 v8si __builtin_ia32_cvttps2dq256 (v8sf)
21523 v4df __builtin_ia32_divpd256 (v4df,v4df)
21524 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
21525 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
21526 v4df __builtin_ia32_haddpd256 (v4df,v4df)
21527 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
21528 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
21529 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
21530 v32qi __builtin_ia32_lddqu256 (pcchar)
21531 v32qi __builtin_ia32_loaddqu256 (pcchar)
21532 v4df __builtin_ia32_loadupd256 (pcdouble)
21533 v8sf __builtin_ia32_loadups256 (pcfloat)
21534 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
21535 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
21536 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
21537 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
21538 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
21539 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
21540 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
21541 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
21542 v4df __builtin_ia32_maxpd256 (v4df,v4df)
21543 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
21544 v4df __builtin_ia32_minpd256 (v4df,v4df)
21545 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
21546 v4df __builtin_ia32_movddup256 (v4df)
21547 int __builtin_ia32_movmskpd256 (v4df)
21548 int __builtin_ia32_movmskps256 (v8sf)
21549 v8sf __builtin_ia32_movshdup256 (v8sf)
21550 v8sf __builtin_ia32_movsldup256 (v8sf)
21551 v4df __builtin_ia32_mulpd256 (v4df,v4df)
21552 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
21553 v4df __builtin_ia32_orpd256 (v4df,v4df)
21554 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
21555 v2df __builtin_ia32_pd_pd256 (v4df)
21556 v4df __builtin_ia32_pd256_pd (v2df)
21557 v4sf __builtin_ia32_ps_ps256 (v8sf)
21558 v8sf __builtin_ia32_ps256_ps (v4sf)
21559 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
21560 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
21561 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
21562 v8sf __builtin_ia32_rcpps256 (v8sf)
21563 v4df __builtin_ia32_roundpd256 (v4df,int)
21564 v8sf __builtin_ia32_roundps256 (v8sf,int)
21565 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
21566 v8sf __builtin_ia32_rsqrtps256 (v8sf)
21567 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
21568 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
21569 v4si __builtin_ia32_si_si256 (v8si)
21570 v8si __builtin_ia32_si256_si (v4si)
21571 v4df __builtin_ia32_sqrtpd256 (v4df)
21572 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
21573 v8sf __builtin_ia32_sqrtps256 (v8sf)
21574 void __builtin_ia32_storedqu256 (pchar,v32qi)
21575 void __builtin_ia32_storeupd256 (pdouble,v4df)
21576 void __builtin_ia32_storeups256 (pfloat,v8sf)
21577 v4df __builtin_ia32_subpd256 (v4df,v4df)
21578 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
21579 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
21580 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
21581 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
21582 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
21583 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
21584 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
21585 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
21586 v4sf __builtin_ia32_vbroadcastss (pcfloat)
21587 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
21588 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
21589 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
21590 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
21591 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
21592 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
21593 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
21594 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
21595 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
21596 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
21597 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
21598 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
21599 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
21600 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
21601 v2df __builtin_ia32_vpermilpd (v2df,int)
21602 v4df __builtin_ia32_vpermilpd256 (v4df,int)
21603 v4sf __builtin_ia32_vpermilps (v4sf,int)
21604 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
21605 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
21606 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
21607 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
21608 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
21609 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
21610 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
21611 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
21612 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
21613 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
21614 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
21615 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
21616 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
21617 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
21618 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
21619 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
21620 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
21621 void __builtin_ia32_vzeroall (void)
21622 void __builtin_ia32_vzeroupper (void)
21623 v4df __builtin_ia32_xorpd256 (v4df,v4df)
21624 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
21627 The following built-in functions are available when @option{-mavx2} is
21628 used. All of them generate the machine instruction that is part of the
21632 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
21633 v32qi __builtin_ia32_pabsb256 (v32qi)
21634 v16hi __builtin_ia32_pabsw256 (v16hi)
21635 v8si __builtin_ia32_pabsd256 (v8si)
21636 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
21637 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
21638 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
21639 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
21640 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
21641 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
21642 v8si __builtin_ia32_paddd256 (v8si,v8si)
21643 v4di __builtin_ia32_paddq256 (v4di,v4di)
21644 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
21645 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
21646 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
21647 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
21648 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
21649 v4di __builtin_ia32_andsi256 (v4di,v4di)
21650 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
21651 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
21652 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
21653 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
21654 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
21655 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
21656 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
21657 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
21658 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
21659 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
21660 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
21661 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
21662 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
21663 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
21664 v8si __builtin_ia32_phaddd256 (v8si,v8si)
21665 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
21666 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
21667 v8si __builtin_ia32_phsubd256 (v8si,v8si)
21668 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
21669 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
21670 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
21671 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
21672 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
21673 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
21674 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
21675 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
21676 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
21677 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
21678 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
21679 v8si __builtin_ia32_pminsd256 (v8si,v8si)
21680 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
21681 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
21682 v8si __builtin_ia32_pminud256 (v8si,v8si)
21683 int __builtin_ia32_pmovmskb256 (v32qi)
21684 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
21685 v8si __builtin_ia32_pmovsxbd256 (v16qi)
21686 v4di __builtin_ia32_pmovsxbq256 (v16qi)
21687 v8si __builtin_ia32_pmovsxwd256 (v8hi)
21688 v4di __builtin_ia32_pmovsxwq256 (v8hi)
21689 v4di __builtin_ia32_pmovsxdq256 (v4si)
21690 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
21691 v8si __builtin_ia32_pmovzxbd256 (v16qi)
21692 v4di __builtin_ia32_pmovzxbq256 (v16qi)
21693 v8si __builtin_ia32_pmovzxwd256 (v8hi)
21694 v4di __builtin_ia32_pmovzxwq256 (v8hi)
21695 v4di __builtin_ia32_pmovzxdq256 (v4si)
21696 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
21697 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
21698 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
21699 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
21700 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
21701 v8si __builtin_ia32_pmulld256 (v8si,v8si)
21702 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
21703 v4di __builtin_ia32_por256 (v4di,v4di)
21704 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
21705 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
21706 v8si __builtin_ia32_pshufd256 (v8si,int)
21707 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
21708 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
21709 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
21710 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
21711 v8si __builtin_ia32_psignd256 (v8si,v8si)
21712 v4di __builtin_ia32_pslldqi256 (v4di,int)
21713 v16hi __builtin_ia32_psllwi256 (16hi,int)
21714 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
21715 v8si __builtin_ia32_pslldi256 (v8si,int)
21716 v8si __builtin_ia32_pslld256(v8si,v4si)
21717 v4di __builtin_ia32_psllqi256 (v4di,int)
21718 v4di __builtin_ia32_psllq256(v4di,v2di)
21719 v16hi __builtin_ia32_psrawi256 (v16hi,int)
21720 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
21721 v8si __builtin_ia32_psradi256 (v8si,int)
21722 v8si __builtin_ia32_psrad256 (v8si,v4si)
21723 v4di __builtin_ia32_psrldqi256 (v4di, int)
21724 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
21725 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
21726 v8si __builtin_ia32_psrldi256 (v8si,int)
21727 v8si __builtin_ia32_psrld256 (v8si,v4si)
21728 v4di __builtin_ia32_psrlqi256 (v4di,int)
21729 v4di __builtin_ia32_psrlq256(v4di,v2di)
21730 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
21731 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
21732 v8si __builtin_ia32_psubd256 (v8si,v8si)
21733 v4di __builtin_ia32_psubq256 (v4di,v4di)
21734 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
21735 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
21736 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
21737 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
21738 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
21739 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
21740 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
21741 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
21742 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
21743 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
21744 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
21745 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
21746 v4di __builtin_ia32_pxor256 (v4di,v4di)
21747 v4di __builtin_ia32_movntdqa256 (pv4di)
21748 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
21749 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
21750 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
21751 v4di __builtin_ia32_vbroadcastsi256 (v2di)
21752 v4si __builtin_ia32_pblendd128 (v4si,v4si)
21753 v8si __builtin_ia32_pblendd256 (v8si,v8si)
21754 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
21755 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
21756 v8si __builtin_ia32_pbroadcastd256 (v4si)
21757 v4di __builtin_ia32_pbroadcastq256 (v2di)
21758 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
21759 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
21760 v4si __builtin_ia32_pbroadcastd128 (v4si)
21761 v2di __builtin_ia32_pbroadcastq128 (v2di)
21762 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
21763 v4df __builtin_ia32_permdf256 (v4df,int)
21764 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
21765 v4di __builtin_ia32_permdi256 (v4di,int)
21766 v4di __builtin_ia32_permti256 (v4di,v4di,int)
21767 v4di __builtin_ia32_extract128i256 (v4di,int)
21768 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
21769 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
21770 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
21771 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
21772 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
21773 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
21774 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
21775 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
21776 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
21777 v8si __builtin_ia32_psllv8si (v8si,v8si)
21778 v4si __builtin_ia32_psllv4si (v4si,v4si)
21779 v4di __builtin_ia32_psllv4di (v4di,v4di)
21780 v2di __builtin_ia32_psllv2di (v2di,v2di)
21781 v8si __builtin_ia32_psrav8si (v8si,v8si)
21782 v4si __builtin_ia32_psrav4si (v4si,v4si)
21783 v8si __builtin_ia32_psrlv8si (v8si,v8si)
21784 v4si __builtin_ia32_psrlv4si (v4si,v4si)
21785 v4di __builtin_ia32_psrlv4di (v4di,v4di)
21786 v2di __builtin_ia32_psrlv2di (v2di,v2di)
21787 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
21788 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
21789 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
21790 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
21791 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
21792 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
21793 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
21794 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
21795 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
21796 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
21797 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
21798 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
21799 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
21800 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
21801 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
21802 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
21805 The following built-in functions are available when @option{-maes} is
21806 used. All of them generate the machine instruction that is part of the
21810 v2di __builtin_ia32_aesenc128 (v2di, v2di)
21811 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
21812 v2di __builtin_ia32_aesdec128 (v2di, v2di)
21813 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
21814 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
21815 v2di __builtin_ia32_aesimc128 (v2di)
21818 The following built-in function is available when @option{-mpclmul} is
21822 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
21823 Generates the @code{pclmulqdq} machine instruction.
21826 The following built-in function is available when @option{-mfsgsbase} is
21827 used. All of them generate the machine instruction that is part of the
21831 unsigned int __builtin_ia32_rdfsbase32 (void)
21832 unsigned long long __builtin_ia32_rdfsbase64 (void)
21833 unsigned int __builtin_ia32_rdgsbase32 (void)
21834 unsigned long long __builtin_ia32_rdgsbase64 (void)
21835 void _writefsbase_u32 (unsigned int)
21836 void _writefsbase_u64 (unsigned long long)
21837 void _writegsbase_u32 (unsigned int)
21838 void _writegsbase_u64 (unsigned long long)
21841 The following built-in function is available when @option{-mrdrnd} is
21842 used. All of them generate the machine instruction that is part of the
21846 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
21847 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
21848 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
21851 The following built-in function is available when @option{-mptwrite} is
21852 used. All of them generate the machine instruction that is part of the
21856 void __builtin_ia32_ptwrite32 (unsigned)
21857 void __builtin_ia32_ptwrite64 (unsigned long long)
21860 The following built-in functions are available when @option{-msse4a} is used.
21861 All of them generate the machine instruction that is part of the name.
21864 void __builtin_ia32_movntsd (double *, v2df)
21865 void __builtin_ia32_movntss (float *, v4sf)
21866 v2di __builtin_ia32_extrq (v2di, v16qi)
21867 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
21868 v2di __builtin_ia32_insertq (v2di, v2di)
21869 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
21872 The following built-in functions are available when @option{-mxop} is used.
21874 v2df __builtin_ia32_vfrczpd (v2df)
21875 v4sf __builtin_ia32_vfrczps (v4sf)
21876 v2df __builtin_ia32_vfrczsd (v2df)
21877 v4sf __builtin_ia32_vfrczss (v4sf)
21878 v4df __builtin_ia32_vfrczpd256 (v4df)
21879 v8sf __builtin_ia32_vfrczps256 (v8sf)
21880 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
21881 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
21882 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
21883 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
21884 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
21885 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
21886 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
21887 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
21888 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
21889 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
21890 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
21891 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
21892 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
21893 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
21894 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21895 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
21896 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
21897 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
21898 v4si __builtin_ia32_vpcomequd (v4si, v4si)
21899 v2di __builtin_ia32_vpcomequq (v2di, v2di)
21900 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
21901 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21902 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
21903 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
21904 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
21905 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
21906 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
21907 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
21908 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
21909 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
21910 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
21911 v4si __builtin_ia32_vpcomged (v4si, v4si)
21912 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
21913 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
21914 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
21915 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
21916 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
21917 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
21918 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
21919 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
21920 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
21921 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
21922 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
21923 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
21924 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
21925 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
21926 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
21927 v4si __builtin_ia32_vpcomled (v4si, v4si)
21928 v2di __builtin_ia32_vpcomleq (v2di, v2di)
21929 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
21930 v4si __builtin_ia32_vpcomleud (v4si, v4si)
21931 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
21932 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
21933 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
21934 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
21935 v4si __builtin_ia32_vpcomltd (v4si, v4si)
21936 v2di __builtin_ia32_vpcomltq (v2di, v2di)
21937 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
21938 v4si __builtin_ia32_vpcomltud (v4si, v4si)
21939 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
21940 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
21941 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
21942 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
21943 v4si __builtin_ia32_vpcomned (v4si, v4si)
21944 v2di __builtin_ia32_vpcomneq (v2di, v2di)
21945 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
21946 v4si __builtin_ia32_vpcomneud (v4si, v4si)
21947 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
21948 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
21949 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
21950 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
21951 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
21952 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
21953 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
21954 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
21955 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
21956 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
21957 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
21958 v4si __builtin_ia32_vphaddbd (v16qi)
21959 v2di __builtin_ia32_vphaddbq (v16qi)
21960 v8hi __builtin_ia32_vphaddbw (v16qi)
21961 v2di __builtin_ia32_vphadddq (v4si)
21962 v4si __builtin_ia32_vphaddubd (v16qi)
21963 v2di __builtin_ia32_vphaddubq (v16qi)
21964 v8hi __builtin_ia32_vphaddubw (v16qi)
21965 v2di __builtin_ia32_vphaddudq (v4si)
21966 v4si __builtin_ia32_vphadduwd (v8hi)
21967 v2di __builtin_ia32_vphadduwq (v8hi)
21968 v4si __builtin_ia32_vphaddwd (v8hi)
21969 v2di __builtin_ia32_vphaddwq (v8hi)
21970 v8hi __builtin_ia32_vphsubbw (v16qi)
21971 v2di __builtin_ia32_vphsubdq (v4si)
21972 v4si __builtin_ia32_vphsubwd (v8hi)
21973 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
21974 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
21975 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
21976 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
21977 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
21978 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
21979 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
21980 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
21981 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
21982 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
21983 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
21984 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
21985 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
21986 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
21987 v4si __builtin_ia32_vprotd (v4si, v4si)
21988 v2di __builtin_ia32_vprotq (v2di, v2di)
21989 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
21990 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
21991 v4si __builtin_ia32_vpshad (v4si, v4si)
21992 v2di __builtin_ia32_vpshaq (v2di, v2di)
21993 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
21994 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
21995 v4si __builtin_ia32_vpshld (v4si, v4si)
21996 v2di __builtin_ia32_vpshlq (v2di, v2di)
21997 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
22000 The following built-in functions are available when @option{-mfma4} is used.
22001 All of them generate the machine instruction that is part of the name.
22004 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
22005 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
22006 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
22007 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
22008 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
22009 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
22010 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
22011 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
22012 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
22013 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
22014 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
22015 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
22016 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
22017 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
22018 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
22019 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
22020 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
22021 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
22022 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
22023 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
22024 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
22025 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
22026 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
22027 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
22028 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
22029 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
22030 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
22031 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
22032 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
22033 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
22034 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
22035 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
22039 The following built-in functions are available when @option{-mlwp} is used.
22042 void __builtin_ia32_llwpcb16 (void *);
22043 void __builtin_ia32_llwpcb32 (void *);
22044 void __builtin_ia32_llwpcb64 (void *);
22045 void * __builtin_ia32_llwpcb16 (void);
22046 void * __builtin_ia32_llwpcb32 (void);
22047 void * __builtin_ia32_llwpcb64 (void);
22048 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
22049 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
22050 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
22051 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
22052 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
22053 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
22056 The following built-in functions are available when @option{-mbmi} is used.
22057 All of them generate the machine instruction that is part of the name.
22059 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
22060 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
22063 The following built-in functions are available when @option{-mbmi2} is used.
22064 All of them generate the machine instruction that is part of the name.
22066 unsigned int _bzhi_u32 (unsigned int, unsigned int)
22067 unsigned int _pdep_u32 (unsigned int, unsigned int)
22068 unsigned int _pext_u32 (unsigned int, unsigned int)
22069 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
22070 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
22071 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
22074 The following built-in functions are available when @option{-mlzcnt} is used.
22075 All of them generate the machine instruction that is part of the name.
22077 unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
22078 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
22079 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
22082 The following built-in functions are available when @option{-mfxsr} is used.
22083 All of them generate the machine instruction that is part of the name.
22085 void __builtin_ia32_fxsave (void *)
22086 void __builtin_ia32_fxrstor (void *)
22087 void __builtin_ia32_fxsave64 (void *)
22088 void __builtin_ia32_fxrstor64 (void *)
22091 The following built-in functions are available when @option{-mxsave} is used.
22092 All of them generate the machine instruction that is part of the name.
22094 void __builtin_ia32_xsave (void *, long long)
22095 void __builtin_ia32_xrstor (void *, long long)
22096 void __builtin_ia32_xsave64 (void *, long long)
22097 void __builtin_ia32_xrstor64 (void *, long long)
22100 The following built-in functions are available when @option{-mxsaveopt} is used.
22101 All of them generate the machine instruction that is part of the name.
22103 void __builtin_ia32_xsaveopt (void *, long long)
22104 void __builtin_ia32_xsaveopt64 (void *, long long)
22107 The following built-in functions are available when @option{-mtbm} is used.
22108 Both of them generate the immediate form of the bextr machine instruction.
22110 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
22111 const unsigned int);
22112 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
22113 const unsigned long long);
22117 The following built-in functions are available when @option{-m3dnow} is used.
22118 All of them generate the machine instruction that is part of the name.
22121 void __builtin_ia32_femms (void)
22122 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
22123 v2si __builtin_ia32_pf2id (v2sf)
22124 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
22125 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
22126 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
22127 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
22128 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
22129 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
22130 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
22131 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
22132 v2sf __builtin_ia32_pfrcp (v2sf)
22133 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
22134 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
22135 v2sf __builtin_ia32_pfrsqrt (v2sf)
22136 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
22137 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
22138 v2sf __builtin_ia32_pi2fd (v2si)
22139 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
22142 The following built-in functions are available when @option{-m3dnowa} is used.
22143 All of them generate the machine instruction that is part of the name.
22146 v2si __builtin_ia32_pf2iw (v2sf)
22147 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
22148 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
22149 v2sf __builtin_ia32_pi2fw (v2si)
22150 v2sf __builtin_ia32_pswapdsf (v2sf)
22151 v2si __builtin_ia32_pswapdsi (v2si)
22154 The following built-in functions are available when @option{-mrtm} is used
22155 They are used for restricted transactional memory. These are the internal
22156 low level functions. Normally the functions in
22157 @ref{x86 transactional memory intrinsics} should be used instead.
22160 int __builtin_ia32_xbegin ()
22161 void __builtin_ia32_xend ()
22162 void __builtin_ia32_xabort (status)
22163 int __builtin_ia32_xtest ()
22166 The following built-in functions are available when @option{-mmwaitx} is used.
22167 All of them generate the machine instruction that is part of the name.
22169 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
22170 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
22173 The following built-in functions are available when @option{-mclzero} is used.
22174 All of them generate the machine instruction that is part of the name.
22176 void __builtin_i32_clzero (void *)
22179 The following built-in functions are available when @option{-mpku} is used.
22180 They generate reads and writes to PKRU.
22182 void __builtin_ia32_wrpkru (unsigned int)
22183 unsigned int __builtin_ia32_rdpkru ()
22186 The following built-in functions are available when @option{-mcet} or
22187 @option{-mshstk} option is used. They support shadow stack
22188 machine instructions from Intel Control-flow Enforcement Technology (CET).
22189 Each built-in function generates the machine instruction that is part
22190 of the function's name. These are the internal low-level functions.
22191 Normally the functions in @ref{x86 control-flow protection intrinsics}
22192 should be used instead.
22195 unsigned int __builtin_ia32_rdsspd (void)
22196 unsigned long long __builtin_ia32_rdsspq (void)
22197 void __builtin_ia32_incsspd (unsigned int)
22198 void __builtin_ia32_incsspq (unsigned long long)
22199 void __builtin_ia32_saveprevssp(void);
22200 void __builtin_ia32_rstorssp(void *);
22201 void __builtin_ia32_wrssd(unsigned int, void *);
22202 void __builtin_ia32_wrssq(unsigned long long, void *);
22203 void __builtin_ia32_wrussd(unsigned int, void *);
22204 void __builtin_ia32_wrussq(unsigned long long, void *);
22205 void __builtin_ia32_setssbsy(void);
22206 void __builtin_ia32_clrssbsy(void *);
22209 @node x86 transactional memory intrinsics
22210 @subsection x86 Transactional Memory Intrinsics
22212 These hardware transactional memory intrinsics for x86 allow you to use
22213 memory transactions with RTM (Restricted Transactional Memory).
22214 This support is enabled with the @option{-mrtm} option.
22215 For using HLE (Hardware Lock Elision) see
22216 @ref{x86 specific memory model extensions for transactional memory} instead.
22218 A memory transaction commits all changes to memory in an atomic way,
22219 as visible to other threads. If the transaction fails it is rolled back
22220 and all side effects discarded.
22222 Generally there is no guarantee that a memory transaction ever succeeds
22223 and suitable fallback code always needs to be supplied.
22225 @deftypefn {RTM Function} {unsigned} _xbegin ()
22226 Start a RTM (Restricted Transactional Memory) transaction.
22227 Returns @code{_XBEGIN_STARTED} when the transaction
22228 started successfully (note this is not 0, so the constant has to be
22229 explicitly tested).
22231 If the transaction aborts, all side effects
22232 are undone and an abort code encoded as a bit mask is returned.
22233 The following macros are defined:
22236 @item _XABORT_EXPLICIT
22237 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
22238 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
22239 @item _XABORT_RETRY
22240 Transaction retry is possible.
22241 @item _XABORT_CONFLICT
22242 Transaction abort due to a memory conflict with another thread.
22243 @item _XABORT_CAPACITY
22244 Transaction abort due to the transaction using too much memory.
22245 @item _XABORT_DEBUG
22246 Transaction abort due to a debug trap.
22247 @item _XABORT_NESTED
22248 Transaction abort in an inner nested transaction.
22251 There is no guarantee
22252 any transaction ever succeeds, so there always needs to be a valid
22256 @deftypefn {RTM Function} {void} _xend ()
22257 Commit the current transaction. When no transaction is active this faults.
22258 All memory side effects of the transaction become visible
22259 to other threads in an atomic manner.
22262 @deftypefn {RTM Function} {int} _xtest ()
22263 Return a nonzero value if a transaction is currently active, otherwise 0.
22266 @deftypefn {RTM Function} {void} _xabort (status)
22267 Abort the current transaction. When no transaction is active this is a no-op.
22268 The @var{status} is an 8-bit constant; its value is encoded in the return
22269 value from @code{_xbegin}.
22272 Here is an example showing handling for @code{_XABORT_RETRY}
22273 and a fallback path for other failures:
22276 #include <immintrin.h>
22278 int n_tries, max_tries;
22279 unsigned status = _XABORT_EXPLICIT;
22282 for (n_tries = 0; n_tries < max_tries; n_tries++)
22284 status = _xbegin ();
22285 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
22288 if (status == _XBEGIN_STARTED)
22290 ... transaction code...
22295 ... non-transactional fallback path...
22300 Note that, in most cases, the transactional and non-transactional code
22301 must synchronize together to ensure consistency.
22303 @node x86 control-flow protection intrinsics
22304 @subsection x86 Control-Flow Protection Intrinsics
22306 @deftypefn {CET Function} {ret_type} _get_ssp (void)
22307 Get the current value of shadow stack pointer if shadow stack support
22308 from Intel CET is enabled in the hardware or @code{0} otherwise.
22309 The @code{ret_type} is @code{unsigned long long} for 64-bit targets
22310 and @code{unsigned int} for 32-bit targets.
22313 @deftypefn {CET Function} void _inc_ssp (unsigned int)
22314 Increment the current shadow stack pointer by the size specified by the
22315 function argument. The argument is masked to a byte value for security
22316 reasons, so to increment by more than 255 bytes you must call the function
22320 The shadow stack unwind code looks like:
22323 #include <immintrin.h>
22325 /* Unwind the shadow stack for EH. */
22326 #define _Unwind_Frames_Extra(x) \
22329 _Unwind_Word ssp = _get_ssp (); \
22332 _Unwind_Word tmp = (x); \
22333 while (tmp > 255) \
22345 This code runs unconditionally on all 64-bit processors. For 32-bit
22346 processors the code runs on those that support multi-byte NOP instructions.
22348 @node Target Format Checks
22349 @section Format Checks Specific to Particular Target Machines
22351 For some target machines, GCC supports additional options to the
22353 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
22356 * Solaris Format Checks::
22357 * Darwin Format Checks::
22360 @node Solaris Format Checks
22361 @subsection Solaris Format Checks
22363 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
22364 check. @code{cmn_err} accepts a subset of the standard @code{printf}
22365 conversions, and the two-argument @code{%b} conversion for displaying
22366 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
22368 @node Darwin Format Checks
22369 @subsection Darwin Format Checks
22371 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
22372 attribute context. Declarations made with such attribution are parsed for correct syntax
22373 and format argument types. However, parsing of the format string itself is currently undefined
22374 and is not carried out by this version of the compiler.
22376 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
22377 also be used as format arguments. Note that the relevant headers are only likely to be
22378 available on Darwin (OSX) installations. On such installations, the XCode and system
22379 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
22380 associated functions.
22383 @section Pragmas Accepted by GCC
22385 @cindex @code{#pragma}
22387 GCC supports several types of pragmas, primarily in order to compile
22388 code originally written for other compilers. Note that in general
22389 we do not recommend the use of pragmas; @xref{Function Attributes},
22390 for further explanation.
22392 The GNU C preprocessor recognizes several pragmas in addition to the
22393 compiler pragmas documented here. Refer to the CPP manual for more
22397 * AArch64 Pragmas::
22401 * RS/6000 and PowerPC Pragmas::
22404 * Solaris Pragmas::
22405 * Symbol-Renaming Pragmas::
22406 * Structure-Layout Pragmas::
22408 * Diagnostic Pragmas::
22409 * Visibility Pragmas::
22410 * Push/Pop Macro Pragmas::
22411 * Function Specific Option Pragmas::
22412 * Loop-Specific Pragmas::
22415 @node AArch64 Pragmas
22416 @subsection AArch64 Pragmas
22418 The pragmas defined by the AArch64 target correspond to the AArch64
22419 target function attributes. They can be specified as below:
22421 #pragma GCC target("string")
22424 where @code{@var{string}} can be any string accepted as an AArch64 target
22425 attribute. @xref{AArch64 Function Attributes}, for more details
22426 on the permissible values of @code{string}.
22429 @subsection ARM Pragmas
22431 The ARM target defines pragmas for controlling the default addition of
22432 @code{long_call} and @code{short_call} attributes to functions.
22433 @xref{Function Attributes}, for information about the effects of these
22438 @cindex pragma, long_calls
22439 Set all subsequent functions to have the @code{long_call} attribute.
22441 @item no_long_calls
22442 @cindex pragma, no_long_calls
22443 Set all subsequent functions to have the @code{short_call} attribute.
22445 @item long_calls_off
22446 @cindex pragma, long_calls_off
22447 Do not affect the @code{long_call} or @code{short_call} attributes of
22448 subsequent functions.
22452 @subsection M32C Pragmas
22455 @item GCC memregs @var{number}
22456 @cindex pragma, memregs
22457 Overrides the command-line option @code{-memregs=} for the current
22458 file. Use with care! This pragma must be before any function in the
22459 file, and mixing different memregs values in different objects may
22460 make them incompatible. This pragma is useful when a
22461 performance-critical function uses a memreg for temporary values,
22462 as it may allow you to reduce the number of memregs used.
22464 @item ADDRESS @var{name} @var{address}
22465 @cindex pragma, address
22466 For any declared symbols matching @var{name}, this does three things
22467 to that symbol: it forces the symbol to be located at the given
22468 address (a number), it forces the symbol to be volatile, and it
22469 changes the symbol's scope to be static. This pragma exists for
22470 compatibility with other compilers, but note that the common
22471 @code{1234H} numeric syntax is not supported (use @code{0x1234}
22475 #pragma ADDRESS port3 0x103
22482 @subsection MeP Pragmas
22486 @item custom io_volatile (on|off)
22487 @cindex pragma, custom io_volatile
22488 Overrides the command-line option @code{-mio-volatile} for the current
22489 file. Note that for compatibility with future GCC releases, this
22490 option should only be used once before any @code{io} variables in each
22493 @item GCC coprocessor available @var{registers}
22494 @cindex pragma, coprocessor available
22495 Specifies which coprocessor registers are available to the register
22496 allocator. @var{registers} may be a single register, register range
22497 separated by ellipses, or comma-separated list of those. Example:
22500 #pragma GCC coprocessor available $c0...$c10, $c28
22503 @item GCC coprocessor call_saved @var{registers}
22504 @cindex pragma, coprocessor call_saved
22505 Specifies which coprocessor registers are to be saved and restored by
22506 any function using them. @var{registers} may be a single register,
22507 register range separated by ellipses, or comma-separated list of
22511 #pragma GCC coprocessor call_saved $c4...$c6, $c31
22514 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
22515 @cindex pragma, coprocessor subclass
22516 Creates and defines a register class. These register classes can be
22517 used by inline @code{asm} constructs. @var{registers} may be a single
22518 register, register range separated by ellipses, or comma-separated
22519 list of those. Example:
22522 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
22524 asm ("cpfoo %0" : "=B" (x));
22527 @item GCC disinterrupt @var{name} , @var{name} @dots{}
22528 @cindex pragma, disinterrupt
22529 For the named functions, the compiler adds code to disable interrupts
22530 for the duration of those functions. If any functions so named
22531 are not encountered in the source, a warning is emitted that the pragma is
22532 not used. Examples:
22535 #pragma disinterrupt foo
22536 #pragma disinterrupt bar, grill
22537 int foo () @{ @dots{} @}
22540 @item GCC call @var{name} , @var{name} @dots{}
22541 @cindex pragma, call
22542 For the named functions, the compiler always uses a register-indirect
22543 call model when calling the named functions. Examples:
22552 @node RS/6000 and PowerPC Pragmas
22553 @subsection RS/6000 and PowerPC Pragmas
22555 The RS/6000 and PowerPC targets define one pragma for controlling
22556 whether or not the @code{longcall} attribute is added to function
22557 declarations by default. This pragma overrides the @option{-mlongcall}
22558 option, but not the @code{longcall} and @code{shortcall} attributes.
22559 @xref{RS/6000 and PowerPC Options}, for more information about when long
22560 calls are and are not necessary.
22564 @cindex pragma, longcall
22565 Apply the @code{longcall} attribute to all subsequent function
22569 Do not apply the @code{longcall} attribute to subsequent function
22573 @c Describe h8300 pragmas here.
22574 @c Describe sh pragmas here.
22575 @c Describe v850 pragmas here.
22577 @node S/390 Pragmas
22578 @subsection S/390 Pragmas
22580 The pragmas defined by the S/390 target correspond to the S/390
22581 target function attributes and some the additional options:
22588 Note that options of the pragma, unlike options of the target
22589 attribute, do change the value of preprocessor macros like
22590 @code{__VEC__}. They can be specified as below:
22593 #pragma GCC target("string[,string]...")
22594 #pragma GCC target("string"[,"string"]...)
22597 @node Darwin Pragmas
22598 @subsection Darwin Pragmas
22600 The following pragmas are available for all architectures running the
22601 Darwin operating system. These are useful for compatibility with other
22605 @item mark @var{tokens}@dots{}
22606 @cindex pragma, mark
22607 This pragma is accepted, but has no effect.
22609 @item options align=@var{alignment}
22610 @cindex pragma, options align
22611 This pragma sets the alignment of fields in structures. The values of
22612 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
22613 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
22614 properly; to restore the previous setting, use @code{reset} for the
22617 @item segment @var{tokens}@dots{}
22618 @cindex pragma, segment
22619 This pragma is accepted, but has no effect.
22621 @item unused (@var{var} [, @var{var}]@dots{})
22622 @cindex pragma, unused
22623 This pragma declares variables to be possibly unused. GCC does not
22624 produce warnings for the listed variables. The effect is similar to
22625 that of the @code{unused} attribute, except that this pragma may appear
22626 anywhere within the variables' scopes.
22629 @node Solaris Pragmas
22630 @subsection Solaris Pragmas
22632 The Solaris target supports @code{#pragma redefine_extname}
22633 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
22634 @code{#pragma} directives for compatibility with the system compiler.
22637 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
22638 @cindex pragma, align
22640 Increase the minimum alignment of each @var{variable} to @var{alignment}.
22641 This is the same as GCC's @code{aligned} attribute @pxref{Variable
22642 Attributes}). Macro expansion occurs on the arguments to this pragma
22643 when compiling C and Objective-C@. It does not currently occur when
22644 compiling C++, but this is a bug which may be fixed in a future
22647 @item fini (@var{function} [, @var{function}]...)
22648 @cindex pragma, fini
22650 This pragma causes each listed @var{function} to be called after
22651 main, or during shared module unloading, by adding a call to the
22652 @code{.fini} section.
22654 @item init (@var{function} [, @var{function}]...)
22655 @cindex pragma, init
22657 This pragma causes each listed @var{function} to be called during
22658 initialization (before @code{main}) or during shared module loading, by
22659 adding a call to the @code{.init} section.
22663 @node Symbol-Renaming Pragmas
22664 @subsection Symbol-Renaming Pragmas
22666 GCC supports a @code{#pragma} directive that changes the name used in
22667 assembly for a given declaration. While this pragma is supported on all
22668 platforms, it is intended primarily to provide compatibility with the
22669 Solaris system headers. This effect can also be achieved using the asm
22670 labels extension (@pxref{Asm Labels}).
22673 @item redefine_extname @var{oldname} @var{newname}
22674 @cindex pragma, redefine_extname
22676 This pragma gives the C function @var{oldname} the assembly symbol
22677 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
22678 is defined if this pragma is available (currently on all platforms).
22681 This pragma and the @code{asm} labels extension interact in a complicated
22682 manner. Here are some corner cases you may want to be aware of:
22685 @item This pragma silently applies only to declarations with external
22686 linkage. The @code{asm} label feature does not have this restriction.
22688 @item In C++, this pragma silently applies only to declarations with
22689 ``C'' linkage. Again, @code{asm} labels do not have this restriction.
22691 @item If either of the ways of changing the assembly name of a
22692 declaration are applied to a declaration whose assembly name has
22693 already been determined (either by a previous use of one of these
22694 features, or because the compiler needed the assembly name in order to
22695 generate code), and the new name is different, a warning issues and
22696 the name does not change.
22698 @item The @var{oldname} used by @code{#pragma redefine_extname} is
22699 always the C-language name.
22702 @node Structure-Layout Pragmas
22703 @subsection Structure-Layout Pragmas
22705 For compatibility with Microsoft Windows compilers, GCC supports a
22706 set of @code{#pragma} directives that change the maximum alignment of
22707 members of structures (other than zero-width bit-fields), unions, and
22708 classes subsequently defined. The @var{n} value below always is required
22709 to be a small power of two and specifies the new alignment in bytes.
22712 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
22713 @item @code{#pragma pack()} sets the alignment to the one that was in
22714 effect when compilation started (see also command-line option
22715 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
22716 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
22717 setting on an internal stack and then optionally sets the new alignment.
22718 @item @code{#pragma pack(pop)} restores the alignment setting to the one
22719 saved at the top of the internal stack (and removes that stack entry).
22720 Note that @code{#pragma pack([@var{n}])} does not influence this internal
22721 stack; thus it is possible to have @code{#pragma pack(push)} followed by
22722 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
22723 @code{#pragma pack(pop)}.
22726 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
22727 directive which lays out structures and unions subsequently defined as the
22728 documented @code{__attribute__ ((ms_struct))}.
22731 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
22732 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
22733 @item @code{#pragma ms_struct reset} goes back to the default layout.
22736 Most targets also support the @code{#pragma scalar_storage_order} directive
22737 which lays out structures and unions subsequently defined as the documented
22738 @code{__attribute__ ((scalar_storage_order))}.
22741 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
22742 of the scalar fields to big-endian.
22743 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
22744 of the scalar fields to little-endian.
22745 @item @code{#pragma scalar_storage_order default} goes back to the endianness
22746 that was in effect when compilation started (see also command-line option
22747 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
22751 @subsection Weak Pragmas
22753 For compatibility with SVR4, GCC supports a set of @code{#pragma}
22754 directives for declaring symbols to be weak, and defining weak
22758 @item #pragma weak @var{symbol}
22759 @cindex pragma, weak
22760 This pragma declares @var{symbol} to be weak, as if the declaration
22761 had the attribute of the same name. The pragma may appear before
22762 or after the declaration of @var{symbol}. It is not an error for
22763 @var{symbol} to never be defined at all.
22765 @item #pragma weak @var{symbol1} = @var{symbol2}
22766 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
22767 It is an error if @var{symbol2} is not defined in the current
22771 @node Diagnostic Pragmas
22772 @subsection Diagnostic Pragmas
22774 GCC allows the user to selectively enable or disable certain types of
22775 diagnostics, and change the kind of the diagnostic. For example, a
22776 project's policy might require that all sources compile with
22777 @option{-Werror} but certain files might have exceptions allowing
22778 specific types of warnings. Or, a project might selectively enable
22779 diagnostics and treat them as errors depending on which preprocessor
22780 macros are defined.
22783 @item #pragma GCC diagnostic @var{kind} @var{option}
22784 @cindex pragma, diagnostic
22786 Modifies the disposition of a diagnostic. Note that not all
22787 diagnostics are modifiable; at the moment only warnings (normally
22788 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
22789 Use @option{-fdiagnostics-show-option} to determine which diagnostics
22790 are controllable and which option controls them.
22792 @var{kind} is @samp{error} to treat this diagnostic as an error,
22793 @samp{warning} to treat it like a warning (even if @option{-Werror} is
22794 in effect), or @samp{ignored} if the diagnostic is to be ignored.
22795 @var{option} is a double quoted string that matches the command-line
22799 #pragma GCC diagnostic warning "-Wformat"
22800 #pragma GCC diagnostic error "-Wformat"
22801 #pragma GCC diagnostic ignored "-Wformat"
22804 Note that these pragmas override any command-line options. GCC keeps
22805 track of the location of each pragma, and issues diagnostics according
22806 to the state as of that point in the source file. Thus, pragmas occurring
22807 after a line do not affect diagnostics caused by that line.
22809 @item #pragma GCC diagnostic push
22810 @itemx #pragma GCC diagnostic pop
22812 Causes GCC to remember the state of the diagnostics as of each
22813 @code{push}, and restore to that point at each @code{pop}. If a
22814 @code{pop} has no matching @code{push}, the command-line options are
22818 #pragma GCC diagnostic error "-Wuninitialized"
22819 foo(a); /* error is given for this one */
22820 #pragma GCC diagnostic push
22821 #pragma GCC diagnostic ignored "-Wuninitialized"
22822 foo(b); /* no diagnostic for this one */
22823 #pragma GCC diagnostic pop
22824 foo(c); /* error is given for this one */
22825 #pragma GCC diagnostic pop
22826 foo(d); /* depends on command-line options */
22831 GCC also offers a simple mechanism for printing messages during
22835 @item #pragma message @var{string}
22836 @cindex pragma, diagnostic
22838 Prints @var{string} as a compiler message on compilation. The message
22839 is informational only, and is neither a compilation warning nor an
22840 error. Newlines can be included in the string by using the @samp{\n}
22844 #pragma message "Compiling " __FILE__ "..."
22847 @var{string} may be parenthesized, and is printed with location
22848 information. For example,
22851 #define DO_PRAGMA(x) _Pragma (#x)
22852 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
22854 TODO(Remember to fix this)
22858 prints @samp{/tmp/file.c:4: note: #pragma message:
22859 TODO - Remember to fix this}.
22861 @item #pragma GCC error @var{message}
22862 @cindex pragma, diagnostic
22863 Generates an error message. This pragma @emph{is} considered to
22864 indicate an error in the compilation, and it will be treated as such.
22866 Newlines can be included in the string by using the @samp{\n}
22867 escape sequence. They will be displayed as newlines even if the
22868 @option{-fmessage-length} option is set to zero.
22870 The error is only generated if the pragma is present in the code after
22871 pre-processing has been completed. It does not matter however if the
22872 code containing the pragma is unreachable:
22876 #pragma GCC error "this error is not seen"
22881 #pragma GCC error "this error is seen"
22885 @item #pragma GCC warning @var{message}
22886 @cindex pragma, diagnostic
22887 This is just like @samp{pragma GCC error} except that a warning
22888 message is issued instead of an error message. Unless
22889 @option{-Werror} is in effect, in which case this pragma will generate
22894 @node Visibility Pragmas
22895 @subsection Visibility Pragmas
22898 @item #pragma GCC visibility push(@var{visibility})
22899 @itemx #pragma GCC visibility pop
22900 @cindex pragma, visibility
22902 This pragma allows the user to set the visibility for multiple
22903 declarations without having to give each a visibility attribute
22904 (@pxref{Function Attributes}).
22906 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
22907 declarations. Class members and template specializations are not
22908 affected; if you want to override the visibility for a particular
22909 member or instantiation, you must use an attribute.
22914 @node Push/Pop Macro Pragmas
22915 @subsection Push/Pop Macro Pragmas
22917 For compatibility with Microsoft Windows compilers, GCC supports
22918 @samp{#pragma push_macro(@var{"macro_name"})}
22919 and @samp{#pragma pop_macro(@var{"macro_name"})}.
22922 @item #pragma push_macro(@var{"macro_name"})
22923 @cindex pragma, push_macro
22924 This pragma saves the value of the macro named as @var{macro_name} to
22925 the top of the stack for this macro.
22927 @item #pragma pop_macro(@var{"macro_name"})
22928 @cindex pragma, pop_macro
22929 This pragma sets the value of the macro named as @var{macro_name} to
22930 the value on top of the stack for this macro. If the stack for
22931 @var{macro_name} is empty, the value of the macro remains unchanged.
22938 #pragma push_macro("X")
22941 #pragma pop_macro("X")
22946 In this example, the definition of X as 1 is saved by @code{#pragma
22947 push_macro} and restored by @code{#pragma pop_macro}.
22949 @node Function Specific Option Pragmas
22950 @subsection Function Specific Option Pragmas
22953 @item #pragma GCC target (@var{string}, @dots{})
22954 @cindex pragma GCC target
22956 This pragma allows you to set target-specific options for functions
22957 defined later in the source file. One or more strings can be
22958 specified. Each function that is defined after this point is treated
22959 as if it had been declared with one @code{target(}@var{string}@code{)}
22960 attribute for each @var{string} argument. The parentheses around
22961 the strings in the pragma are optional. @xref{Function Attributes},
22962 for more information about the @code{target} attribute and the attribute
22965 The @code{#pragma GCC target} pragma is presently implemented for
22966 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
22968 @item #pragma GCC optimize (@var{string}, @dots{})
22969 @cindex pragma GCC optimize
22971 This pragma allows you to set global optimization options for functions
22972 defined later in the source file. One or more strings can be
22973 specified. Each function that is defined after this point is treated
22974 as if it had been declared with one @code{optimize(}@var{string}@code{)}
22975 attribute for each @var{string} argument. The parentheses around
22976 the strings in the pragma are optional. @xref{Function Attributes},
22977 for more information about the @code{optimize} attribute and the attribute
22980 @item #pragma GCC push_options
22981 @itemx #pragma GCC pop_options
22982 @cindex pragma GCC push_options
22983 @cindex pragma GCC pop_options
22985 These pragmas maintain a stack of the current target and optimization
22986 options. It is intended for include files where you temporarily want
22987 to switch to using a different @samp{#pragma GCC target} or
22988 @samp{#pragma GCC optimize} and then to pop back to the previous
22991 @item #pragma GCC reset_options
22992 @cindex pragma GCC reset_options
22994 This pragma clears the current @code{#pragma GCC target} and
22995 @code{#pragma GCC optimize} to use the default switches as specified
22996 on the command line.
23000 @node Loop-Specific Pragmas
23001 @subsection Loop-Specific Pragmas
23004 @item #pragma GCC ivdep
23005 @cindex pragma GCC ivdep
23007 With this pragma, the programmer asserts that there are no loop-carried
23008 dependencies which would prevent consecutive iterations of
23009 the following loop from executing concurrently with SIMD
23010 (single instruction multiple data) instructions.
23012 For example, the compiler can only unconditionally vectorize the following
23013 loop with the pragma:
23016 void foo (int n, int *a, int *b, int *c)
23020 for (i = 0; i < n; ++i)
23021 a[i] = b[i] + c[i];
23026 In this example, using the @code{restrict} qualifier had the same
23027 effect. In the following example, that would not be possible. Assume
23028 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
23029 that it can unconditionally vectorize the following loop:
23032 void ignore_vec_dep (int *a, int k, int c, int m)
23035 for (int i = 0; i < m; i++)
23036 a[i] = a[i + k] * c;
23040 @item #pragma GCC unroll @var{n}
23041 @cindex pragma GCC unroll @var{n}
23043 You can use this pragma to control how many times a loop should be unrolled.
23044 It must be placed immediately before a @code{for}, @code{while} or @code{do}
23045 loop or a @code{#pragma GCC ivdep}, and applies only to the loop that follows.
23046 @var{n} is an integer constant expression specifying the unrolling factor.
23047 The values of @math{0} and @math{1} block any unrolling of the loop.
23051 @node Unnamed Fields
23052 @section Unnamed Structure and Union Fields
23053 @cindex @code{struct}
23054 @cindex @code{union}
23056 As permitted by ISO C11 and for compatibility with other compilers,
23057 GCC allows you to define
23058 a structure or union that contains, as fields, structures and unions
23059 without names. For example:
23073 In this example, you are able to access members of the unnamed
23074 union with code like @samp{foo.b}. Note that only unnamed structs and
23075 unions are allowed, you may not have, for example, an unnamed
23078 You must never create such structures that cause ambiguous field definitions.
23079 For example, in this structure:
23091 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
23092 The compiler gives errors for such constructs.
23094 @opindex fms-extensions
23095 Unless @option{-fms-extensions} is used, the unnamed field must be a
23096 structure or union definition without a tag (for example, @samp{struct
23097 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
23098 also be a definition with a tag such as @samp{struct foo @{ int a;
23099 @};}, a reference to a previously defined structure or union such as
23100 @samp{struct foo;}, or a reference to a @code{typedef} name for a
23101 previously defined structure or union type.
23103 @opindex fplan9-extensions
23104 The option @option{-fplan9-extensions} enables
23105 @option{-fms-extensions} as well as two other extensions. First, a
23106 pointer to a structure is automatically converted to a pointer to an
23107 anonymous field for assignments and function calls. For example:
23110 struct s1 @{ int a; @};
23111 struct s2 @{ struct s1; @};
23112 extern void f1 (struct s1 *);
23113 void f2 (struct s2 *p) @{ f1 (p); @}
23117 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
23118 converted into a pointer to the anonymous field.
23120 Second, when the type of an anonymous field is a @code{typedef} for a
23121 @code{struct} or @code{union}, code may refer to the field using the
23122 name of the @code{typedef}.
23125 typedef struct @{ int a; @} s1;
23126 struct s2 @{ s1; @};
23127 s1 f1 (struct s2 *p) @{ return p->s1; @}
23130 These usages are only permitted when they are not ambiguous.
23133 @section Thread-Local Storage
23134 @cindex Thread-Local Storage
23135 @cindex @acronym{TLS}
23136 @cindex @code{__thread}
23138 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
23139 are allocated such that there is one instance of the variable per extant
23140 thread. The runtime model GCC uses to implement this originates
23141 in the IA-64 processor-specific ABI, but has since been migrated
23142 to other processors as well. It requires significant support from
23143 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
23144 system libraries (@file{libc.so} and @file{libpthread.so}), so it
23145 is not available everywhere.
23147 At the user level, the extension is visible with a new storage
23148 class keyword: @code{__thread}. For example:
23152 extern __thread struct state s;
23153 static __thread char *p;
23156 The @code{__thread} specifier may be used alone, with the @code{extern}
23157 or @code{static} specifiers, but with no other storage class specifier.
23158 When used with @code{extern} or @code{static}, @code{__thread} must appear
23159 immediately after the other storage class specifier.
23161 The @code{__thread} specifier may be applied to any global, file-scoped
23162 static, function-scoped static, or static data member of a class. It may
23163 not be applied to block-scoped automatic or non-static data member.
23165 When the address-of operator is applied to a thread-local variable, it is
23166 evaluated at run time and returns the address of the current thread's
23167 instance of that variable. An address so obtained may be used by any
23168 thread. When a thread terminates, any pointers to thread-local variables
23169 in that thread become invalid.
23171 No static initialization may refer to the address of a thread-local variable.
23173 In C++, if an initializer is present for a thread-local variable, it must
23174 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
23177 See @uref{https://www.akkadia.org/drepper/tls.pdf,
23178 ELF Handling For Thread-Local Storage} for a detailed explanation of
23179 the four thread-local storage addressing models, and how the runtime
23180 is expected to function.
23183 * C99 Thread-Local Edits::
23184 * C++98 Thread-Local Edits::
23187 @node C99 Thread-Local Edits
23188 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
23190 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
23191 that document the exact semantics of the language extension.
23195 @cite{5.1.2 Execution environments}
23197 Add new text after paragraph 1
23200 Within either execution environment, a @dfn{thread} is a flow of
23201 control within a program. It is implementation defined whether
23202 or not there may be more than one thread associated with a program.
23203 It is implementation defined how threads beyond the first are
23204 created, the name and type of the function called at thread
23205 startup, and how threads may be terminated. However, objects
23206 with thread storage duration shall be initialized before thread
23211 @cite{6.2.4 Storage durations of objects}
23213 Add new text before paragraph 3
23216 An object whose identifier is declared with the storage-class
23217 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
23218 Its lifetime is the entire execution of the thread, and its
23219 stored value is initialized only once, prior to thread startup.
23223 @cite{6.4.1 Keywords}
23225 Add @code{__thread}.
23228 @cite{6.7.1 Storage-class specifiers}
23230 Add @code{__thread} to the list of storage class specifiers in
23233 Change paragraph 2 to
23236 With the exception of @code{__thread}, at most one storage-class
23237 specifier may be given [@dots{}]. The @code{__thread} specifier may
23238 be used alone, or immediately following @code{extern} or
23242 Add new text after paragraph 6
23245 The declaration of an identifier for a variable that has
23246 block scope that specifies @code{__thread} shall also
23247 specify either @code{extern} or @code{static}.
23249 The @code{__thread} specifier shall be used only with
23254 @node C++98 Thread-Local Edits
23255 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
23257 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
23258 that document the exact semantics of the language extension.
23262 @b{[intro.execution]}
23264 New text after paragraph 4
23267 A @dfn{thread} is a flow of control within the abstract machine.
23268 It is implementation defined whether or not there may be more than
23272 New text after paragraph 7
23275 It is unspecified whether additional action must be taken to
23276 ensure when and whether side effects are visible to other threads.
23282 Add @code{__thread}.
23285 @b{[basic.start.main]}
23287 Add after paragraph 5
23290 The thread that begins execution at the @code{main} function is called
23291 the @dfn{main thread}. It is implementation defined how functions
23292 beginning threads other than the main thread are designated or typed.
23293 A function so designated, as well as the @code{main} function, is called
23294 a @dfn{thread startup function}. It is implementation defined what
23295 happens if a thread startup function returns. It is implementation
23296 defined what happens to other threads when any thread calls @code{exit}.
23300 @b{[basic.start.init]}
23302 Add after paragraph 4
23305 The storage for an object of thread storage duration shall be
23306 statically initialized before the first statement of the thread startup
23307 function. An object of thread storage duration shall not require
23308 dynamic initialization.
23312 @b{[basic.start.term]}
23314 Add after paragraph 3
23317 The type of an object with thread storage duration shall not have a
23318 non-trivial destructor, nor shall it be an array type whose elements
23319 (directly or indirectly) have non-trivial destructors.
23325 Add ``thread storage duration'' to the list in paragraph 1.
23330 Thread, static, and automatic storage durations are associated with
23331 objects introduced by declarations [@dots{}].
23334 Add @code{__thread} to the list of specifiers in paragraph 3.
23337 @b{[basic.stc.thread]}
23339 New section before @b{[basic.stc.static]}
23342 The keyword @code{__thread} applied to a non-local object gives the
23343 object thread storage duration.
23345 A local variable or class data member declared both @code{static}
23346 and @code{__thread} gives the variable or member thread storage
23351 @b{[basic.stc.static]}
23356 All objects that have neither thread storage duration, dynamic
23357 storage duration nor are local [@dots{}].
23363 Add @code{__thread} to the list in paragraph 1.
23368 With the exception of @code{__thread}, at most one
23369 @var{storage-class-specifier} shall appear in a given
23370 @var{decl-specifier-seq}. The @code{__thread} specifier may
23371 be used alone, or immediately following the @code{extern} or
23372 @code{static} specifiers. [@dots{}]
23375 Add after paragraph 5
23378 The @code{__thread} specifier can be applied only to the names of objects
23379 and to anonymous unions.
23385 Add after paragraph 6
23388 Non-@code{static} members shall not be @code{__thread}.
23392 @node Binary constants
23393 @section Binary Constants using the @samp{0b} Prefix
23394 @cindex Binary constants using the @samp{0b} prefix
23396 Integer constants can be written as binary constants, consisting of a
23397 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
23398 @samp{0B}. This is particularly useful in environments that operate a
23399 lot on the bit level (like microcontrollers).
23401 The following statements are identical:
23410 The type of these constants follows the same rules as for octal or
23411 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
23414 @node C++ Extensions
23415 @chapter Extensions to the C++ Language
23416 @cindex extensions, C++ language
23417 @cindex C++ language extensions
23419 The GNU compiler provides these extensions to the C++ language (and you
23420 can also use most of the C language extensions in your C++ programs). If you
23421 want to write code that checks whether these features are available, you can
23422 test for the GNU compiler the same way as for C programs: check for a
23423 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
23424 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
23425 Predefined Macros,cpp,The GNU C Preprocessor}).
23428 * C++ Volatiles:: What constitutes an access to a volatile object.
23429 * Restricted Pointers:: C99 restricted pointers and references.
23430 * Vague Linkage:: Where G++ puts inlines, vtables and such.
23431 * C++ Interface:: You can use a single C++ header file for both
23432 declarations and definitions.
23433 * Template Instantiation:: Methods for ensuring that exactly one copy of
23434 each needed template instantiation is emitted.
23435 * Bound member functions:: You can extract a function pointer to the
23436 method denoted by a @samp{->*} or @samp{.*} expression.
23437 * C++ Attributes:: Variable, function, and type attributes for C++ only.
23438 * Function Multiversioning:: Declaring multiple function versions.
23439 * Type Traits:: Compiler support for type traits.
23440 * C++ Concepts:: Improved support for generic programming.
23441 * Deprecated Features:: Things will disappear from G++.
23442 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
23445 @node C++ Volatiles
23446 @section When is a Volatile C++ Object Accessed?
23447 @cindex accessing volatiles
23448 @cindex volatile read
23449 @cindex volatile write
23450 @cindex volatile access
23452 The C++ standard differs from the C standard in its treatment of
23453 volatile objects. It fails to specify what constitutes a volatile
23454 access, except to say that C++ should behave in a similar manner to C
23455 with respect to volatiles, where possible. However, the different
23456 lvalueness of expressions between C and C++ complicate the behavior.
23457 G++ behaves the same as GCC for volatile access, @xref{C
23458 Extensions,,Volatiles}, for a description of GCC's behavior.
23460 The C and C++ language specifications differ when an object is
23461 accessed in a void context:
23464 volatile int *src = @var{somevalue};
23468 The C++ standard specifies that such expressions do not undergo lvalue
23469 to rvalue conversion, and that the type of the dereferenced object may
23470 be incomplete. The C++ standard does not specify explicitly that it
23471 is lvalue to rvalue conversion that is responsible for causing an
23472 access. There is reason to believe that it is, because otherwise
23473 certain simple expressions become undefined. However, because it
23474 would surprise most programmers, G++ treats dereferencing a pointer to
23475 volatile object of complete type as GCC would do for an equivalent
23476 type in C@. When the object has incomplete type, G++ issues a
23477 warning; if you wish to force an error, you must force a conversion to
23478 rvalue with, for instance, a static cast.
23480 When using a reference to volatile, G++ does not treat equivalent
23481 expressions as accesses to volatiles, but instead issues a warning that
23482 no volatile is accessed. The rationale for this is that otherwise it
23483 becomes difficult to determine where volatile access occur, and not
23484 possible to ignore the return value from functions returning volatile
23485 references. Again, if you wish to force a read, cast the reference to
23488 G++ implements the same behavior as GCC does when assigning to a
23489 volatile object---there is no reread of the assigned-to object, the
23490 assigned rvalue is reused. Note that in C++ assignment expressions
23491 are lvalues, and if used as an lvalue, the volatile object is
23492 referred to. For instance, @var{vref} refers to @var{vobj}, as
23493 expected, in the following example:
23497 volatile int &vref = vobj = @var{something};
23500 @node Restricted Pointers
23501 @section Restricting Pointer Aliasing
23502 @cindex restricted pointers
23503 @cindex restricted references
23504 @cindex restricted this pointer
23506 As with the C front end, G++ understands the C99 feature of restricted pointers,
23507 specified with the @code{__restrict__}, or @code{__restrict} type
23508 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
23509 language flag, @code{restrict} is not a keyword in C++.
23511 In addition to allowing restricted pointers, you can specify restricted
23512 references, which indicate that the reference is not aliased in the local
23516 void fn (int *__restrict__ rptr, int &__restrict__ rref)
23523 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
23524 @var{rref} refers to a (different) unaliased integer.
23526 You may also specify whether a member function's @var{this} pointer is
23527 unaliased by using @code{__restrict__} as a member function qualifier.
23530 void T::fn () __restrict__
23537 Within the body of @code{T::fn}, @var{this} has the effective
23538 definition @code{T *__restrict__ const this}. Notice that the
23539 interpretation of a @code{__restrict__} member function qualifier is
23540 different to that of @code{const} or @code{volatile} qualifier, in that it
23541 is applied to the pointer rather than the object. This is consistent with
23542 other compilers that implement restricted pointers.
23544 As with all outermost parameter qualifiers, @code{__restrict__} is
23545 ignored in function definition matching. This means you only need to
23546 specify @code{__restrict__} in a function definition, rather than
23547 in a function prototype as well.
23549 @node Vague Linkage
23550 @section Vague Linkage
23551 @cindex vague linkage
23553 There are several constructs in C++ that require space in the object
23554 file but are not clearly tied to a single translation unit. We say that
23555 these constructs have ``vague linkage''. Typically such constructs are
23556 emitted wherever they are needed, though sometimes we can be more
23560 @item Inline Functions
23561 Inline functions are typically defined in a header file which can be
23562 included in many different compilations. Hopefully they can usually be
23563 inlined, but sometimes an out-of-line copy is necessary, if the address
23564 of the function is taken or if inlining fails. In general, we emit an
23565 out-of-line copy in all translation units where one is needed. As an
23566 exception, we only emit inline virtual functions with the vtable, since
23567 it always requires a copy.
23569 Local static variables and string constants used in an inline function
23570 are also considered to have vague linkage, since they must be shared
23571 between all inlined and out-of-line instances of the function.
23575 C++ virtual functions are implemented in most compilers using a lookup
23576 table, known as a vtable. The vtable contains pointers to the virtual
23577 functions provided by a class, and each object of the class contains a
23578 pointer to its vtable (or vtables, in some multiple-inheritance
23579 situations). If the class declares any non-inline, non-pure virtual
23580 functions, the first one is chosen as the ``key method'' for the class,
23581 and the vtable is only emitted in the translation unit where the key
23584 @emph{Note:} If the chosen key method is later defined as inline, the
23585 vtable is still emitted in every translation unit that defines it.
23586 Make sure that any inline virtuals are declared inline in the class
23587 body, even if they are not defined there.
23589 @item @code{type_info} objects
23590 @cindex @code{type_info}
23592 C++ requires information about types to be written out in order to
23593 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
23594 For polymorphic classes (classes with virtual functions), the @samp{type_info}
23595 object is written out along with the vtable so that @samp{dynamic_cast}
23596 can determine the dynamic type of a class object at run time. For all
23597 other types, we write out the @samp{type_info} object when it is used: when
23598 applying @samp{typeid} to an expression, throwing an object, or
23599 referring to a type in a catch clause or exception specification.
23601 @item Template Instantiations
23602 Most everything in this section also applies to template instantiations,
23603 but there are other options as well.
23604 @xref{Template Instantiation,,Where's the Template?}.
23608 When used with GNU ld version 2.8 or later on an ELF system such as
23609 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
23610 these constructs will be discarded at link time. This is known as
23613 On targets that don't support COMDAT, but do support weak symbols, GCC
23614 uses them. This way one copy overrides all the others, but
23615 the unused copies still take up space in the executable.
23617 For targets that do not support either COMDAT or weak symbols,
23618 most entities with vague linkage are emitted as local symbols to
23619 avoid duplicate definition errors from the linker. This does not happen
23620 for local statics in inlines, however, as having multiple copies
23621 almost certainly breaks things.
23623 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
23624 another way to control placement of these constructs.
23626 @node C++ Interface
23627 @section C++ Interface and Implementation Pragmas
23629 @cindex interface and implementation headers, C++
23630 @cindex C++ interface and implementation headers
23631 @cindex pragmas, interface and implementation
23633 @code{#pragma interface} and @code{#pragma implementation} provide the
23634 user with a way of explicitly directing the compiler to emit entities
23635 with vague linkage (and debugging information) in a particular
23638 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
23639 by COMDAT support and the ``key method'' heuristic
23640 mentioned in @ref{Vague Linkage}. Using them can actually cause your
23641 program to grow due to unnecessary out-of-line copies of inline
23645 @item #pragma interface
23646 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
23647 @kindex #pragma interface
23648 Use this directive in @emph{header files} that define object classes, to save
23649 space in most of the object files that use those classes. Normally,
23650 local copies of certain information (backup copies of inline member
23651 functions, debugging information, and the internal tables that implement
23652 virtual functions) must be kept in each object file that includes class
23653 definitions. You can use this pragma to avoid such duplication. When a
23654 header file containing @samp{#pragma interface} is included in a
23655 compilation, this auxiliary information is not generated (unless
23656 the main input source file itself uses @samp{#pragma implementation}).
23657 Instead, the object files contain references to be resolved at link
23660 The second form of this directive is useful for the case where you have
23661 multiple headers with the same name in different directories. If you
23662 use this form, you must specify the same string to @samp{#pragma
23665 @item #pragma implementation
23666 @itemx #pragma implementation "@var{objects}.h"
23667 @kindex #pragma implementation
23668 Use this pragma in a @emph{main input file}, when you want full output from
23669 included header files to be generated (and made globally visible). The
23670 included header file, in turn, should use @samp{#pragma interface}.
23671 Backup copies of inline member functions, debugging information, and the
23672 internal tables used to implement virtual functions are all generated in
23673 implementation files.
23675 @cindex implied @code{#pragma implementation}
23676 @cindex @code{#pragma implementation}, implied
23677 @cindex naming convention, implementation headers
23678 If you use @samp{#pragma implementation} with no argument, it applies to
23679 an include file with the same basename@footnote{A file's @dfn{basename}
23680 is the name stripped of all leading path information and of trailing
23681 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
23682 file. For example, in @file{allclass.cc}, giving just
23683 @samp{#pragma implementation}
23684 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
23686 Use the string argument if you want a single implementation file to
23687 include code from multiple header files. (You must also use
23688 @samp{#include} to include the header file; @samp{#pragma
23689 implementation} only specifies how to use the file---it doesn't actually
23692 There is no way to split up the contents of a single header file into
23693 multiple implementation files.
23696 @cindex inlining and C++ pragmas
23697 @cindex C++ pragmas, effect on inlining
23698 @cindex pragmas in C++, effect on inlining
23699 @samp{#pragma implementation} and @samp{#pragma interface} also have an
23700 effect on function inlining.
23702 If you define a class in a header file marked with @samp{#pragma
23703 interface}, the effect on an inline function defined in that class is
23704 similar to an explicit @code{extern} declaration---the compiler emits
23705 no code at all to define an independent version of the function. Its
23706 definition is used only for inlining with its callers.
23708 @opindex fno-implement-inlines
23709 Conversely, when you include the same header file in a main source file
23710 that declares it as @samp{#pragma implementation}, the compiler emits
23711 code for the function itself; this defines a version of the function
23712 that can be found via pointers (or by callers compiled without
23713 inlining). If all calls to the function can be inlined, you can avoid
23714 emitting the function by compiling with @option{-fno-implement-inlines}.
23715 If any calls are not inlined, you will get linker errors.
23717 @node Template Instantiation
23718 @section Where's the Template?
23719 @cindex template instantiation
23721 C++ templates were the first language feature to require more
23722 intelligence from the environment than was traditionally found on a UNIX
23723 system. Somehow the compiler and linker have to make sure that each
23724 template instance occurs exactly once in the executable if it is needed,
23725 and not at all otherwise. There are two basic approaches to this
23726 problem, which are referred to as the Borland model and the Cfront model.
23729 @item Borland model
23730 Borland C++ solved the template instantiation problem by adding the code
23731 equivalent of common blocks to their linker; the compiler emits template
23732 instances in each translation unit that uses them, and the linker
23733 collapses them together. The advantage of this model is that the linker
23734 only has to consider the object files themselves; there is no external
23735 complexity to worry about. The disadvantage is that compilation time
23736 is increased because the template code is being compiled repeatedly.
23737 Code written for this model tends to include definitions of all
23738 templates in the header file, since they must be seen to be
23742 The AT&T C++ translator, Cfront, solved the template instantiation
23743 problem by creating the notion of a template repository, an
23744 automatically maintained place where template instances are stored. A
23745 more modern version of the repository works as follows: As individual
23746 object files are built, the compiler places any template definitions and
23747 instantiations encountered in the repository. At link time, the link
23748 wrapper adds in the objects in the repository and compiles any needed
23749 instances that were not previously emitted. The advantages of this
23750 model are more optimal compilation speed and the ability to use the
23751 system linker; to implement the Borland model a compiler vendor also
23752 needs to replace the linker. The disadvantages are vastly increased
23753 complexity, and thus potential for error; for some code this can be
23754 just as transparent, but in practice it can been very difficult to build
23755 multiple programs in one directory and one program in multiple
23756 directories. Code written for this model tends to separate definitions
23757 of non-inline member templates into a separate file, which should be
23758 compiled separately.
23761 G++ implements the Borland model on targets where the linker supports it,
23762 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
23763 Otherwise G++ implements neither automatic model.
23765 You have the following options for dealing with template instantiations:
23769 Do nothing. Code written for the Borland model works fine, but
23770 each translation unit contains instances of each of the templates it
23771 uses. The duplicate instances will be discarded by the linker, but in
23772 a large program, this can lead to an unacceptable amount of code
23773 duplication in object files or shared libraries.
23775 Duplicate instances of a template can be avoided by defining an explicit
23776 instantiation in one object file, and preventing the compiler from doing
23777 implicit instantiations in any other object files by using an explicit
23778 instantiation declaration, using the @code{extern template} syntax:
23781 extern template int max (int, int);
23784 This syntax is defined in the C++ 2011 standard, but has been supported by
23785 G++ and other compilers since well before 2011.
23787 Explicit instantiations can be used for the largest or most frequently
23788 duplicated instances, without having to know exactly which other instances
23789 are used in the rest of the program. You can scatter the explicit
23790 instantiations throughout your program, perhaps putting them in the
23791 translation units where the instances are used or the translation units
23792 that define the templates themselves; you can put all of the explicit
23793 instantiations you need into one big file; or you can create small files
23800 template class Foo<int>;
23801 template ostream& operator <<
23802 (ostream&, const Foo<int>&);
23806 for each of the instances you need, and create a template instantiation
23807 library from those.
23809 This is the simplest option, but also offers flexibility and
23810 fine-grained control when necessary. It is also the most portable
23811 alternative and programs using this approach will work with most modern
23816 Compile your template-using code with @option{-frepo}. The compiler
23817 generates files with the extension @samp{.rpo} listing all of the
23818 template instantiations used in the corresponding object files that
23819 could be instantiated there; the link wrapper, @samp{collect2},
23820 then updates the @samp{.rpo} files to tell the compiler where to place
23821 those instantiations and rebuild any affected object files. The
23822 link-time overhead is negligible after the first pass, as the compiler
23823 continues to place the instantiations in the same files.
23825 This can be a suitable option for application code written for the Borland
23826 model, as it usually just works. Code written for the Cfront model
23827 needs to be modified so that the template definitions are available at
23828 one or more points of instantiation; usually this is as simple as adding
23829 @code{#include <tmethods.cc>} to the end of each template header.
23831 For library code, if you want the library to provide all of the template
23832 instantiations it needs, just try to link all of its object files
23833 together; the link will fail, but cause the instantiations to be
23834 generated as a side effect. Be warned, however, that this may cause
23835 conflicts if multiple libraries try to provide the same instantiations.
23836 For greater control, use explicit instantiation as described in the next
23840 @opindex fno-implicit-templates
23841 Compile your code with @option{-fno-implicit-templates} to disable the
23842 implicit generation of template instances, and explicitly instantiate
23843 all the ones you use. This approach requires more knowledge of exactly
23844 which instances you need than do the others, but it's less
23845 mysterious and allows greater control if you want to ensure that only
23846 the intended instances are used.
23848 If you are using Cfront-model code, you can probably get away with not
23849 using @option{-fno-implicit-templates} when compiling files that don't
23850 @samp{#include} the member template definitions.
23852 If you use one big file to do the instantiations, you may want to
23853 compile it without @option{-fno-implicit-templates} so you get all of the
23854 instances required by your explicit instantiations (but not by any
23855 other files) without having to specify them as well.
23857 In addition to forward declaration of explicit instantiations
23858 (with @code{extern}), G++ has extended the template instantiation
23859 syntax to support instantiation of the compiler support data for a
23860 template class (i.e.@: the vtable) without instantiating any of its
23861 members (with @code{inline}), and instantiation of only the static data
23862 members of a template class, without the support data or member
23863 functions (with @code{static}):
23866 inline template class Foo<int>;
23867 static template class Foo<int>;
23871 @node Bound member functions
23872 @section Extracting the Function Pointer from a Bound Pointer to Member Function
23874 @cindex pointer to member function
23875 @cindex bound pointer to member function
23877 In C++, pointer to member functions (PMFs) are implemented using a wide
23878 pointer of sorts to handle all the possible call mechanisms; the PMF
23879 needs to store information about how to adjust the @samp{this} pointer,
23880 and if the function pointed to is virtual, where to find the vtable, and
23881 where in the vtable to look for the member function. If you are using
23882 PMFs in an inner loop, you should really reconsider that decision. If
23883 that is not an option, you can extract the pointer to the function that
23884 would be called for a given object/PMF pair and call it directly inside
23885 the inner loop, to save a bit of time.
23887 Note that you still pay the penalty for the call through a
23888 function pointer; on most modern architectures, such a call defeats the
23889 branch prediction features of the CPU@. This is also true of normal
23890 virtual function calls.
23892 The syntax for this extension is
23896 extern int (A::*fp)();
23897 typedef int (*fptr)(A *);
23899 fptr p = (fptr)(a.*fp);
23902 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
23903 no object is needed to obtain the address of the function. They can be
23904 converted to function pointers directly:
23907 fptr p1 = (fptr)(&A::foo);
23910 @opindex Wno-pmf-conversions
23911 You must specify @option{-Wno-pmf-conversions} to use this extension.
23913 @node C++ Attributes
23914 @section C++-Specific Variable, Function, and Type Attributes
23916 Some attributes only make sense for C++ programs.
23919 @item abi_tag ("@var{tag}", ...)
23920 @cindex @code{abi_tag} function attribute
23921 @cindex @code{abi_tag} variable attribute
23922 @cindex @code{abi_tag} type attribute
23923 The @code{abi_tag} attribute can be applied to a function, variable, or class
23924 declaration. It modifies the mangled name of the entity to
23925 incorporate the tag name, in order to distinguish the function or
23926 class from an earlier version with a different ABI; perhaps the class
23927 has changed size, or the function has a different return type that is
23928 not encoded in the mangled name.
23930 The attribute can also be applied to an inline namespace, but does not
23931 affect the mangled name of the namespace; in this case it is only used
23932 for @option{-Wabi-tag} warnings and automatic tagging of functions and
23933 variables. Tagging inline namespaces is generally preferable to
23934 tagging individual declarations, but the latter is sometimes
23935 necessary, such as when only certain members of a class need to be
23938 The argument can be a list of strings of arbitrary length. The
23939 strings are sorted on output, so the order of the list is
23942 A redeclaration of an entity must not add new ABI tags,
23943 since doing so would change the mangled name.
23945 The ABI tags apply to a name, so all instantiations and
23946 specializations of a template have the same tags. The attribute will
23947 be ignored if applied to an explicit specialization or instantiation.
23949 The @option{-Wabi-tag} flag enables a warning about a class which does
23950 not have all the ABI tags used by its subobjects and virtual functions; for users with code
23951 that needs to coexist with an earlier ABI, using this option can help
23952 to find all affected types that need to be tagged.
23954 When a type involving an ABI tag is used as the type of a variable or
23955 return type of a function where that tag is not already present in the
23956 signature of the function, the tag is automatically applied to the
23957 variable or function. @option{-Wabi-tag} also warns about this
23958 situation; this warning can be avoided by explicitly tagging the
23959 variable or function or moving it into a tagged inline namespace.
23961 @item init_priority (@var{priority})
23962 @cindex @code{init_priority} variable attribute
23964 In Standard C++, objects defined at namespace scope are guaranteed to be
23965 initialized in an order in strict accordance with that of their definitions
23966 @emph{in a given translation unit}. No guarantee is made for initializations
23967 across translation units. However, GNU C++ allows users to control the
23968 order of initialization of objects defined at namespace scope with the
23969 @code{init_priority} attribute by specifying a relative @var{priority},
23970 a constant integral expression currently bounded between 101 and 65535
23971 inclusive. Lower numbers indicate a higher priority.
23973 In the following example, @code{A} would normally be created before
23974 @code{B}, but the @code{init_priority} attribute reverses that order:
23977 Some_Class A __attribute__ ((init_priority (2000)));
23978 Some_Class B __attribute__ ((init_priority (543)));
23982 Note that the particular values of @var{priority} do not matter; only their
23986 @cindex @code{warn_unused} type attribute
23988 For C++ types with non-trivial constructors and/or destructors it is
23989 impossible for the compiler to determine whether a variable of this
23990 type is truly unused if it is not referenced. This type attribute
23991 informs the compiler that variables of this type should be warned
23992 about if they appear to be unused, just like variables of fundamental
23995 This attribute is appropriate for types which just represent a value,
23996 such as @code{std::string}; it is not appropriate for types which
23997 control a resource, such as @code{std::lock_guard}.
23999 This attribute is also accepted in C, but it is unnecessary because C
24000 does not have constructors or destructors.
24004 @node Function Multiversioning
24005 @section Function Multiversioning
24006 @cindex function versions
24008 With the GNU C++ front end, for x86 targets, you may specify multiple
24009 versions of a function, where each function is specialized for a
24010 specific target feature. At runtime, the appropriate version of the
24011 function is automatically executed depending on the characteristics of
24012 the execution platform. Here is an example.
24015 __attribute__ ((target ("default")))
24018 // The default version of foo.
24022 __attribute__ ((target ("sse4.2")))
24025 // foo version for SSE4.2
24029 __attribute__ ((target ("arch=atom")))
24032 // foo version for the Intel ATOM processor
24036 __attribute__ ((target ("arch=amdfam10")))
24039 // foo version for the AMD Family 0x10 processors.
24046 assert ((*p) () == foo ());
24051 In the above example, four versions of function foo are created. The
24052 first version of foo with the target attribute "default" is the default
24053 version. This version gets executed when no other target specific
24054 version qualifies for execution on a particular platform. A new version
24055 of foo is created by using the same function signature but with a
24056 different target string. Function foo is called or a pointer to it is
24057 taken just like a regular function. GCC takes care of doing the
24058 dispatching to call the right version at runtime. Refer to the
24059 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
24060 Function Multiversioning} for more details.
24063 @section Type Traits
24065 The C++ front end implements syntactic extensions that allow
24066 compile-time determination of
24067 various characteristics of a type (or of a
24071 @item __has_nothrow_assign (type)
24072 If @code{type} is @code{const}-qualified or is a reference type then
24073 the trait is @code{false}. Otherwise if @code{__has_trivial_assign (type)}
24074 is @code{true} then the trait is @code{true}, else if @code{type} is
24075 a cv-qualified class or union type with copy assignment operators that are
24076 known not to throw an exception then the trait is @code{true}, else it is
24078 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24079 @code{void}, or an array of unknown bound.
24081 @item __has_nothrow_copy (type)
24082 If @code{__has_trivial_copy (type)} is @code{true} then the trait is
24083 @code{true}, else if @code{type} is a cv-qualified class or union type
24084 with copy constructors that are known not to throw an exception then
24085 the trait is @code{true}, else it is @code{false}.
24086 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24087 @code{void}, or an array of unknown bound.
24089 @item __has_nothrow_constructor (type)
24090 If @code{__has_trivial_constructor (type)} is @code{true} then the trait
24091 is @code{true}, else if @code{type} is a cv class or union type (or array
24092 thereof) with a default constructor that is known not to throw an
24093 exception then the trait is @code{true}, else it is @code{false}.
24094 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24095 @code{void}, or an array of unknown bound.
24097 @item __has_trivial_assign (type)
24098 If @code{type} is @code{const}- qualified or is a reference type then
24099 the trait is @code{false}. Otherwise if @code{__is_pod (type)} is
24100 @code{true} then the trait is @code{true}, else if @code{type} is
24101 a cv-qualified class or union type with a trivial copy assignment
24102 ([class.copy]) then the trait is @code{true}, else it is @code{false}.
24103 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24104 @code{void}, or an array of unknown bound.
24106 @item __has_trivial_copy (type)
24107 If @code{__is_pod (type)} is @code{true} or @code{type} is a reference
24108 type then the trait is @code{true}, else if @code{type} is a cv class
24109 or union type with a trivial copy constructor ([class.copy]) then the trait
24110 is @code{true}, else it is @code{false}. Requires: @code{type} shall be
24111 a complete type, (possibly cv-qualified) @code{void}, or an array of unknown
24114 @item __has_trivial_constructor (type)
24115 If @code{__is_pod (type)} is @code{true} then the trait is @code{true},
24116 else if @code{type} is a cv-qualified class or union type (or array thereof)
24117 with a trivial default constructor ([class.ctor]) then the trait is @code{true},
24118 else it is @code{false}.
24119 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24120 @code{void}, or an array of unknown bound.
24122 @item __has_trivial_destructor (type)
24123 If @code{__is_pod (type)} is @code{true} or @code{type} is a reference type
24124 then the trait is @code{true}, else if @code{type} is a cv class or union
24125 type (or array thereof) with a trivial destructor ([class.dtor]) then
24126 the trait is @code{true}, else it is @code{false}.
24127 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24128 @code{void}, or an array of unknown bound.
24130 @item __has_virtual_destructor (type)
24131 If @code{type} is a class type with a virtual destructor
24132 ([class.dtor]) then the trait is @code{true}, else it is @code{false}.
24133 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24134 @code{void}, or an array of unknown bound.
24136 @item __is_abstract (type)
24137 If @code{type} is an abstract class ([class.abstract]) then the trait
24138 is @code{true}, else it is @code{false}.
24139 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24140 @code{void}, or an array of unknown bound.
24142 @item __is_base_of (base_type, derived_type)
24143 If @code{base_type} is a base class of @code{derived_type}
24144 ([class.derived]) then the trait is @code{true}, otherwise it is @code{false}.
24145 Top-level cv-qualifications of @code{base_type} and
24146 @code{derived_type} are ignored. For the purposes of this trait, a
24147 class type is considered is own base.
24148 Requires: if @code{__is_class (base_type)} and @code{__is_class (derived_type)}
24149 are @code{true} and @code{base_type} and @code{derived_type} are not the same
24150 type (disregarding cv-qualifiers), @code{derived_type} shall be a complete
24151 type. A diagnostic is produced if this requirement is not met.
24153 @item __is_class (type)
24154 If @code{type} is a cv-qualified class type, and not a union type
24155 ([basic.compound]) the trait is @code{true}, else it is @code{false}.
24157 @item __is_empty (type)
24158 If @code{__is_class (type)} is @code{false} then the trait is @code{false}.
24159 Otherwise @code{type} is considered empty if and only if: @code{type}
24160 has no non-static data members, or all non-static data members, if
24161 any, are bit-fields of length 0, and @code{type} has no virtual
24162 members, and @code{type} has no virtual base classes, and @code{type}
24163 has no base classes @code{base_type} for which
24164 @code{__is_empty (base_type)} is @code{false}.
24165 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24166 @code{void}, or an array of unknown bound.
24168 @item __is_enum (type)
24169 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
24170 @code{true}, else it is @code{false}.
24172 @item __is_literal_type (type)
24173 If @code{type} is a literal type ([basic.types]) the trait is
24174 @code{true}, else it is @code{false}.
24175 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24176 @code{void}, or an array of unknown bound.
24178 @item __is_pod (type)
24179 If @code{type} is a cv POD type ([basic.types]) then the trait is @code{true},
24180 else it is @code{false}.
24181 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24182 @code{void}, or an array of unknown bound.
24184 @item __is_polymorphic (type)
24185 If @code{type} is a polymorphic class ([class.virtual]) then the trait
24186 is @code{true}, else it is @code{false}.
24187 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24188 @code{void}, or an array of unknown bound.
24190 @item __is_standard_layout (type)
24191 If @code{type} is a standard-layout type ([basic.types]) the trait is
24192 @code{true}, else it is @code{false}.
24193 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24194 @code{void}, or an array of unknown bound.
24196 @item __is_trivial (type)
24197 If @code{type} is a trivial type ([basic.types]) the trait is
24198 @code{true}, else it is @code{false}.
24199 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24200 @code{void}, or an array of unknown bound.
24202 @item __is_union (type)
24203 If @code{type} is a cv union type ([basic.compound]) the trait is
24204 @code{true}, else it is @code{false}.
24206 @item __underlying_type (type)
24207 The underlying type of @code{type}.
24208 Requires: @code{type} shall be an enumeration type ([dcl.enum]).
24210 @item __integer_pack (length)
24211 When used as the pattern of a pack expansion within a template
24212 definition, expands to a template argument pack containing integers
24213 from @code{0} to @code{length-1}. This is provided for efficient
24214 implementation of @code{std::make_integer_sequence}.
24220 @section C++ Concepts
24222 C++ concepts provide much-improved support for generic programming. In
24223 particular, they allow the specification of constraints on template arguments.
24224 The constraints are used to extend the usual overloading and partial
24225 specialization capabilities of the language, allowing generic data structures
24226 and algorithms to be ``refined'' based on their properties rather than their
24229 The following keywords are reserved for concepts.
24233 States an expression as an assumption, and if possible, verifies that the
24234 assumption is valid. For example, @code{assume(n > 0)}.
24237 Introduces an axiom definition. Axioms introduce requirements on values.
24240 Introduces a universally quantified object in an axiom. For example,
24241 @code{forall (int n) n + 0 == n}).
24244 Introduces a concept definition. Concepts are sets of syntactic and semantic
24245 requirements on types and their values.
24248 Introduces constraints on template arguments or requirements for a member
24249 function of a class template.
24253 The front end also exposes a number of internal mechanism that can be used
24254 to simplify the writing of type traits. Note that some of these traits are
24255 likely to be removed in the future.
24258 @item __is_same (type1, type2)
24259 A binary type trait: @code{true} whenever the type arguments are the same.
24264 @node Deprecated Features
24265 @section Deprecated Features
24267 In the past, the GNU C++ compiler was extended to experiment with new
24268 features, at a time when the C++ language was still evolving. Now that
24269 the C++ standard is complete, some of those features are superseded by
24270 superior alternatives. Using the old features might cause a warning in
24271 some cases that the feature will be dropped in the future. In other
24272 cases, the feature might be gone already.
24274 G++ allows a virtual function returning @samp{void *} to be overridden
24275 by one returning a different pointer type. This extension to the
24276 covariant return type rules is now deprecated and will be removed from a
24279 The use of default arguments in function pointers, function typedefs
24280 and other places where they are not permitted by the standard is
24281 deprecated and will be removed from a future version of G++.
24283 G++ allows floating-point literals to appear in integral constant expressions,
24284 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
24285 This extension is deprecated and will be removed from a future version.
24287 G++ allows static data members of const floating-point type to be declared
24288 with an initializer in a class definition. The standard only allows
24289 initializers for static members of const integral types and const
24290 enumeration types so this extension has been deprecated and will be removed
24291 from a future version.
24293 G++ allows attributes to follow a parenthesized direct initializer,
24294 e.g.@: @samp{ int f (0) __attribute__ ((something)); } This extension
24295 has been ignored since G++ 3.3 and is deprecated.
24297 G++ allows anonymous structs and unions to have members that are not
24298 public non-static data members (i.e.@: fields). These extensions are
24301 @node Backwards Compatibility
24302 @section Backwards Compatibility
24303 @cindex Backwards Compatibility
24304 @cindex ARM [Annotated C++ Reference Manual]
24306 Now that there is a definitive ISO standard C++, G++ has a specification
24307 to adhere to. The C++ language evolved over time, and features that
24308 used to be acceptable in previous drafts of the standard, such as the ARM
24309 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
24310 compilation of C++ written to such drafts, G++ contains some backwards
24311 compatibilities. @emph{All such backwards compatibility features are
24312 liable to disappear in future versions of G++.} They should be considered
24313 deprecated. @xref{Deprecated Features}.
24317 @item Implicit C language
24318 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
24319 scope to set the language. On such systems, all system header files are
24320 implicitly scoped inside a C language scope. Such headers must
24321 correctly prototype function argument types, there is no leeway for
24322 @code{()} to indicate an unspecified set of arguments.
24326 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
24327 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr