1 c Copyright (C) 1988-2018 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:: As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls:: Dispatching a call to another function.
31 * Typeof:: @code{typeof}: referring to the type of an expression.
32 * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
33 * __int128:: 128-bit integers---@code{__int128}.
34 * Long Long:: Double-word integers---@code{long long int}.
35 * Complex:: Data types for complex numbers.
36 * Floating Types:: Additional Floating Types.
37 * Half-Precision:: Half-Precision Floating Point.
38 * Decimal Float:: Decimal Floating Types.
39 * Hex Floats:: Hexadecimal floating-point constants.
40 * Fixed-Point:: Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length:: Zero-length arrays.
43 * Empty Structures:: Structures with no members.
44 * Variable Length:: Arrays whose length is computed at run time.
45 * Variadic Macros:: Macros with a variable number of arguments.
46 * Escaped Newlines:: Slightly looser rules for escaped newlines.
47 * Subscripting:: Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays:: Pointers to arrays with qualifiers work as expected.
50 * Initializers:: Non-constant initializers.
51 * Compound Literals:: Compound literals give structures, unions
53 * Designated Inits:: Labeling elements of initializers.
54 * Case Ranges:: `case 1 ... 9' and such.
55 * Cast to Union:: Casting to union type from any member of the union.
56 * Mixed Declarations:: Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58 or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes:: Specifying attributes of types.
61 * Label Attributes:: Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Statement Attributes:: Specifying attributes on statements.
64 * Attribute Syntax:: Formal syntax for attributes.
65 * Function Prototypes:: Prototype declarations and old-style definitions.
66 * C++ Comments:: C++ comments are recognized.
67 * Dollar Signs:: Dollar sign is allowed in identifiers.
68 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
69 * Alignment:: Inquiring about the alignment of a type or variable.
70 * Inline:: Defining inline functions (as fast as macros).
71 * Volatiles:: What constitutes an access to a volatile object.
72 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
73 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums:: @code{enum foo;}, with details to follow.
75 * Function Names:: Printable strings which are the name of the current
77 * Return Address:: Getting the return or frame address of a function.
78 * Vector Extensions:: Using vector instructions through built-in functions.
79 * Offsetof:: Special syntax for implementing @code{offsetof}.
80 * __sync Builtins:: Legacy built-in functions for atomic memory access.
81 * __atomic Builtins:: Atomic built-in functions with memory model.
82 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
83 arithmetic overflow checking.
84 * x86 specific memory model extensions for transactional memory:: x86 memory models.
85 * Object Size Checking:: Built-in functions for limited buffer overflow
87 * Other Builtins:: Other built-in functions.
88 * Target Builtins:: Built-in functions specific to particular targets.
89 * Target Format Checks:: Format checks specific to particular targets.
90 * Pragmas:: Pragmas accepted by GCC.
91 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
92 * Thread-Local:: Per-thread variables.
93 * Binary constants:: Binary constants using the @samp{0b} prefix.
97 @section Statements and Declarations in Expressions
98 @cindex statements inside expressions
99 @cindex declarations inside expressions
100 @cindex expressions containing statements
101 @cindex macros, statements in expressions
103 @c the above section title wrapped and causes an underfull hbox.. i
104 @c changed it from "within" to "in". --mew 4feb93
105 A compound statement enclosed in parentheses may appear as an expression
106 in GNU C@. This allows you to use loops, switches, and local variables
107 within an expression.
109 Recall that a compound statement is a sequence of statements surrounded
110 by braces; in this construct, parentheses go around the braces. For
114 (@{ int y = foo (); int z;
121 is a valid (though slightly more complex than necessary) expression
122 for the absolute value of @code{foo ()}.
124 The last thing in the compound statement should be an expression
125 followed by a semicolon; the value of this subexpression serves as the
126 value of the entire construct. (If you use some other kind of statement
127 last within the braces, the construct has type @code{void}, and thus
128 effectively no value.)
130 This feature is especially useful in making macro definitions ``safe'' (so
131 that they evaluate each operand exactly once). For example, the
132 ``maximum'' function is commonly defined as a macro in standard C as
136 #define max(a,b) ((a) > (b) ? (a) : (b))
140 @cindex side effects, macro argument
141 But this definition computes either @var{a} or @var{b} twice, with bad
142 results if the operand has side effects. In GNU C, if you know the
143 type of the operands (here taken as @code{int}), you can define
144 the macro safely as follows:
147 #define maxint(a,b) \
148 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
151 Embedded statements are not allowed in constant expressions, such as
152 the value of an enumeration constant, the width of a bit-field, or
153 the initial value of a static variable.
155 If you don't know the type of the operand, you can still do this, but you
156 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
158 In G++, the result value of a statement expression undergoes array and
159 function pointer decay, and is returned by value to the enclosing
160 expression. For instance, if @code{A} is a class, then
169 constructs a temporary @code{A} object to hold the result of the
170 statement expression, and that is used to invoke @code{Foo}.
171 Therefore the @code{this} pointer observed by @code{Foo} is not the
174 In a statement expression, any temporaries created within a statement
175 are destroyed at that statement's end. This makes statement
176 expressions inside macros slightly different from function calls. In
177 the latter case temporaries introduced during argument evaluation are
178 destroyed at the end of the statement that includes the function
179 call. In the statement expression case they are destroyed during
180 the statement expression. For instance,
183 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
184 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
194 has different places where temporaries are destroyed. For the
195 @code{macro} case, the temporary @code{X} is destroyed just after
196 the initialization of @code{b}. In the @code{function} case that
197 temporary is destroyed when the function returns.
199 These considerations mean that it is probably a bad idea to use
200 statement expressions of this form in header files that are designed to
201 work with C++. (Note that some versions of the GNU C Library contained
202 header files using statement expressions that lead to precisely this
205 Jumping into a statement expression with @code{goto} or using a
206 @code{switch} statement outside the statement expression with a
207 @code{case} or @code{default} label inside the statement expression is
208 not permitted. Jumping into a statement expression with a computed
209 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
210 Jumping out of a statement expression is permitted, but if the
211 statement expression is part of a larger expression then it is
212 unspecified which other subexpressions of that expression have been
213 evaluated except where the language definition requires certain
214 subexpressions to be evaluated before or after the statement
215 expression. In any case, as with a function call, the evaluation of a
216 statement expression is not interleaved with the evaluation of other
217 parts of the containing expression. For example,
220 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
224 calls @code{foo} and @code{bar1} and does not call @code{baz} but
225 may or may not call @code{bar2}. If @code{bar2} is called, it is
226 called after @code{foo} and before @code{bar1}.
229 @section Locally Declared Labels
231 @cindex macros, local labels
233 GCC allows you to declare @dfn{local labels} in any nested block
234 scope. A local label is just like an ordinary label, but you can
235 only reference it (with a @code{goto} statement, or by taking its
236 address) within the block in which it is declared.
238 A local label declaration looks like this:
241 __label__ @var{label};
248 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
251 Local label declarations must come at the beginning of the block,
252 before any ordinary declarations or statements.
254 The label declaration defines the label @emph{name}, but does not define
255 the label itself. You must do this in the usual way, with
256 @code{@var{label}:}, within the statements of the statement expression.
258 The local label feature is useful for complex macros. If a macro
259 contains nested loops, a @code{goto} can be useful for breaking out of
260 them. However, an ordinary label whose scope is the whole function
261 cannot be used: if the macro can be expanded several times in one
262 function, the label is multiply defined in that function. A
263 local label avoids this problem. For example:
266 #define SEARCH(value, array, target) \
269 typeof (target) _SEARCH_target = (target); \
270 typeof (*(array)) *_SEARCH_array = (array); \
273 for (i = 0; i < max; i++) \
274 for (j = 0; j < max; j++) \
275 if (_SEARCH_array[i][j] == _SEARCH_target) \
276 @{ (value) = i; goto found; @} \
282 This could also be written using a statement expression:
285 #define SEARCH(array, target) \
288 typeof (target) _SEARCH_target = (target); \
289 typeof (*(array)) *_SEARCH_array = (array); \
292 for (i = 0; i < max; i++) \
293 for (j = 0; j < max; j++) \
294 if (_SEARCH_array[i][j] == _SEARCH_target) \
295 @{ value = i; goto found; @} \
302 Local label declarations also make the labels they declare visible to
303 nested functions, if there are any. @xref{Nested Functions}, for details.
305 @node Labels as Values
306 @section Labels as Values
307 @cindex labels as values
308 @cindex computed gotos
309 @cindex goto with computed label
310 @cindex address of a label
312 You can get the address of a label defined in the current function
313 (or a containing function) with the unary operator @samp{&&}. The
314 value has type @code{void *}. This value is a constant and can be used
315 wherever a constant of that type is valid. For example:
323 To use these values, you need to be able to jump to one. This is done
324 with the computed goto statement@footnote{The analogous feature in
325 Fortran is called an assigned goto, but that name seems inappropriate in
326 C, where one can do more than simply store label addresses in label
327 variables.}, @code{goto *@var{exp};}. For example,
334 Any expression of type @code{void *} is allowed.
336 One way of using these constants is in initializing a static array that
337 serves as a jump table:
340 static void *array[] = @{ &&foo, &&bar, &&hack @};
344 Then you can select a label with indexing, like this:
351 Note that this does not check whether the subscript is in bounds---array
352 indexing in C never does that.
354 Such an array of label values serves a purpose much like that of the
355 @code{switch} statement. The @code{switch} statement is cleaner, so
356 use that rather than an array unless the problem does not fit a
357 @code{switch} statement very well.
359 Another use of label values is in an interpreter for threaded code.
360 The labels within the interpreter function can be stored in the
361 threaded code for super-fast dispatching.
363 You may not use this mechanism to jump to code in a different function.
364 If you do that, totally unpredictable things happen. The best way to
365 avoid this is to store the label address only in automatic variables and
366 never pass it as an argument.
368 An alternate way to write the above example is
371 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
373 goto *(&&foo + array[i]);
377 This is more friendly to code living in shared libraries, as it reduces
378 the number of dynamic relocations that are needed, and by consequence,
379 allows the data to be read-only.
380 This alternative with label differences is not supported for the AVR target,
381 please use the first approach for AVR programs.
383 The @code{&&foo} expressions for the same label might have different
384 values if the containing function is inlined or cloned. If a program
385 relies on them being always the same,
386 @code{__attribute__((__noinline__,__noclone__))} should be used to
387 prevent inlining and cloning. If @code{&&foo} is used in a static
388 variable initializer, inlining and cloning is forbidden.
390 @node Nested Functions
391 @section Nested Functions
392 @cindex nested functions
393 @cindex downward funargs
396 A @dfn{nested function} is a function defined inside another function.
397 Nested functions are supported as an extension in GNU C, but are not
398 supported by GNU C++.
400 The nested function's name is local to the block where it is defined.
401 For example, here we define a nested function named @code{square}, and
406 foo (double a, double b)
408 double square (double z) @{ return z * z; @}
410 return square (a) + square (b);
415 The nested function can access all the variables of the containing
416 function that are visible at the point of its definition. This is
417 called @dfn{lexical scoping}. For example, here we show a nested
418 function which uses an inherited variable named @code{offset}:
422 bar (int *array, int offset, int size)
424 int access (int *array, int index)
425 @{ return array[index + offset]; @}
428 for (i = 0; i < size; i++)
429 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
434 Nested function definitions are permitted within functions in the places
435 where variable definitions are allowed; that is, in any block, mixed
436 with the other declarations and statements in the block.
438 It is possible to call the nested function from outside the scope of its
439 name by storing its address or passing the address to another function:
442 hack (int *array, int size)
444 void store (int index, int value)
445 @{ array[index] = value; @}
447 intermediate (store, size);
451 Here, the function @code{intermediate} receives the address of
452 @code{store} as an argument. If @code{intermediate} calls @code{store},
453 the arguments given to @code{store} are used to store into @code{array}.
454 But this technique works only so long as the containing function
455 (@code{hack}, in this example) does not exit.
457 If you try to call the nested function through its address after the
458 containing function exits, all hell breaks loose. If you try
459 to call it after a containing scope level exits, and if it refers
460 to some of the variables that are no longer in scope, you may be lucky,
461 but it's not wise to take the risk. If, however, the nested function
462 does not refer to anything that has gone out of scope, you should be
465 GCC implements taking the address of a nested function using a technique
466 called @dfn{trampolines}. This technique was described in
467 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
468 C++ Conference Proceedings, October 17-21, 1988).
470 A nested function can jump to a label inherited from a containing
471 function, provided the label is explicitly declared in the containing
472 function (@pxref{Local Labels}). Such a jump returns instantly to the
473 containing function, exiting the nested function that did the
474 @code{goto} and any intermediate functions as well. Here is an example:
478 bar (int *array, int offset, int size)
481 int access (int *array, int index)
485 return array[index + offset];
489 for (i = 0; i < size; i++)
490 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
494 /* @r{Control comes here from @code{access}
495 if it detects an error.} */
502 A nested function always has no linkage. Declaring one with
503 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
504 before its definition, use @code{auto} (which is otherwise meaningless
505 for function declarations).
508 bar (int *array, int offset, int size)
511 auto int access (int *, int);
513 int access (int *array, int index)
517 return array[index + offset];
523 @node Constructing Calls
524 @section Constructing Function Calls
525 @cindex constructing calls
526 @cindex forwarding calls
528 Using the built-in functions described below, you can record
529 the arguments a function received, and call another function
530 with the same arguments, without knowing the number or types
533 You can also record the return value of that function call,
534 and later return that value, without knowing what data type
535 the function tried to return (as long as your caller expects
538 However, these built-in functions may interact badly with some
539 sophisticated features or other extensions of the language. It
540 is, therefore, not recommended to use them outside very simple
541 functions acting as mere forwarders for their arguments.
543 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
544 This built-in function returns a pointer to data
545 describing how to perform a call with the same arguments as are passed
546 to the current function.
548 The function saves the arg pointer register, structure value address,
549 and all registers that might be used to pass arguments to a function
550 into a block of memory allocated on the stack. Then it returns the
551 address of that block.
554 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
555 This built-in function invokes @var{function}
556 with a copy of the parameters described by @var{arguments}
559 The value of @var{arguments} should be the value returned by
560 @code{__builtin_apply_args}. The argument @var{size} specifies the size
561 of the stack argument data, in bytes.
563 This function returns a pointer to data describing
564 how to return whatever value is returned by @var{function}. The data
565 is saved in a block of memory allocated on the stack.
567 It is not always simple to compute the proper value for @var{size}. The
568 value is used by @code{__builtin_apply} to compute the amount of data
569 that should be pushed on the stack and copied from the incoming argument
573 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
574 This built-in function returns the value described by @var{result} from
575 the containing function. You should specify, for @var{result}, a value
576 returned by @code{__builtin_apply}.
579 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
580 This built-in function represents all anonymous arguments of an inline
581 function. It can be used only in inline functions that are always
582 inlined, never compiled as a separate function, such as those using
583 @code{__attribute__ ((__always_inline__))} or
584 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
585 It must be only passed as last argument to some other function
586 with variable arguments. This is useful for writing small wrapper
587 inlines for variable argument functions, when using preprocessor
588 macros is undesirable. For example:
590 extern int myprintf (FILE *f, const char *format, ...);
591 extern inline __attribute__ ((__gnu_inline__)) int
592 myprintf (FILE *f, const char *format, ...)
594 int r = fprintf (f, "myprintf: ");
597 int s = fprintf (f, format, __builtin_va_arg_pack ());
605 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
606 This built-in function returns the number of anonymous arguments of
607 an inline function. It can be used only in inline functions that
608 are always inlined, never compiled as a separate function, such
609 as those using @code{__attribute__ ((__always_inline__))} or
610 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
611 For example following does link- or run-time checking of open
612 arguments for optimized code:
615 extern inline __attribute__((__gnu_inline__)) int
616 myopen (const char *path, int oflag, ...)
618 if (__builtin_va_arg_pack_len () > 1)
619 warn_open_too_many_arguments ();
621 if (__builtin_constant_p (oflag))
623 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
625 warn_open_missing_mode ();
626 return __open_2 (path, oflag);
628 return open (path, oflag, __builtin_va_arg_pack ());
631 if (__builtin_va_arg_pack_len () < 1)
632 return __open_2 (path, oflag);
634 return open (path, oflag, __builtin_va_arg_pack ());
641 @section Referring to a Type with @code{typeof}
644 @cindex macros, types of arguments
646 Another way to refer to the type of an expression is with @code{typeof}.
647 The syntax of using of this keyword looks like @code{sizeof}, but the
648 construct acts semantically like a type name defined with @code{typedef}.
650 There are two ways of writing the argument to @code{typeof}: with an
651 expression or with a type. Here is an example with an expression:
658 This assumes that @code{x} is an array of pointers to functions;
659 the type described is that of the values of the functions.
661 Here is an example with a typename as the argument:
668 Here the type described is that of pointers to @code{int}.
670 If you are writing a header file that must work when included in ISO C
671 programs, write @code{__typeof__} instead of @code{typeof}.
672 @xref{Alternate Keywords}.
674 A @code{typeof} construct can be used anywhere a typedef name can be
675 used. For example, you can use it in a declaration, in a cast, or inside
676 of @code{sizeof} or @code{typeof}.
678 The operand of @code{typeof} is evaluated for its side effects if and
679 only if it is an expression of variably modified type or the name of
682 @code{typeof} is often useful in conjunction with
683 statement expressions (@pxref{Statement Exprs}).
684 Here is how the two together can
685 be used to define a safe ``maximum'' macro which operates on any
686 arithmetic type and evaluates each of its arguments exactly once:
690 (@{ typeof (a) _a = (a); \
691 typeof (b) _b = (b); \
692 _a > _b ? _a : _b; @})
695 @cindex underscores in variables in macros
696 @cindex @samp{_} in variables in macros
697 @cindex local variables in macros
698 @cindex variables, local, in macros
699 @cindex macros, local variables in
701 The reason for using names that start with underscores for the local
702 variables is to avoid conflicts with variable names that occur within the
703 expressions that are substituted for @code{a} and @code{b}. Eventually we
704 hope to design a new form of declaration syntax that allows you to declare
705 variables whose scopes start only after their initializers; this will be a
706 more reliable way to prevent such conflicts.
709 Some more examples of the use of @code{typeof}:
713 This declares @code{y} with the type of what @code{x} points to.
720 This declares @code{y} as an array of such values.
727 This declares @code{y} as an array of pointers to characters:
730 typeof (typeof (char *)[4]) y;
734 It is equivalent to the following traditional C declaration:
740 To see the meaning of the declaration using @code{typeof}, and why it
741 might be a useful way to write, rewrite it with these macros:
744 #define pointer(T) typeof(T *)
745 #define array(T, N) typeof(T [N])
749 Now the declaration can be rewritten this way:
752 array (pointer (char), 4) y;
756 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
757 pointers to @code{char}.
760 In GNU C, but not GNU C++, you may also declare the type of a variable
761 as @code{__auto_type}. In that case, the declaration must declare
762 only one variable, whose declarator must just be an identifier, the
763 declaration must be initialized, and the type of the variable is
764 determined by the initializer; the name of the variable is not in
765 scope until after the initializer. (In C++, you should use C++11
766 @code{auto} for this purpose.) Using @code{__auto_type}, the
767 ``maximum'' macro above could be written as:
771 (@{ __auto_type _a = (a); \
772 __auto_type _b = (b); \
773 _a > _b ? _a : _b; @})
776 Using @code{__auto_type} instead of @code{typeof} has two advantages:
779 @item Each argument to the macro appears only once in the expansion of
780 the macro. This prevents the size of the macro expansion growing
781 exponentially when calls to such macros are nested inside arguments of
784 @item If the argument to the macro has variably modified type, it is
785 evaluated only once when using @code{__auto_type}, but twice if
786 @code{typeof} is used.
790 @section Conditionals with Omitted Operands
791 @cindex conditional expressions, extensions
792 @cindex omitted middle-operands
793 @cindex middle-operands, omitted
794 @cindex extensions, @code{?:}
795 @cindex @code{?:} extensions
797 The middle operand in a conditional expression may be omitted. Then
798 if the first operand is nonzero, its value is the value of the conditional
801 Therefore, the expression
808 has the value of @code{x} if that is nonzero; otherwise, the value of
811 This example is perfectly equivalent to
817 @cindex side effect in @code{?:}
818 @cindex @code{?:} side effect
820 In this simple case, the ability to omit the middle operand is not
821 especially useful. When it becomes useful is when the first operand does,
822 or may (if it is a macro argument), contain a side effect. Then repeating
823 the operand in the middle would perform the side effect twice. Omitting
824 the middle operand uses the value already computed without the undesirable
825 effects of recomputing it.
828 @section 128-bit Integers
829 @cindex @code{__int128} data types
831 As an extension the integer scalar type @code{__int128} is supported for
832 targets which have an integer mode wide enough to hold 128 bits.
833 Simply write @code{__int128} for a signed 128-bit integer, or
834 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
835 support in GCC for expressing an integer constant of type @code{__int128}
836 for targets with @code{long long} integer less than 128 bits wide.
839 @section Double-Word Integers
840 @cindex @code{long long} data types
841 @cindex double-word arithmetic
842 @cindex multiprecision arithmetic
843 @cindex @code{LL} integer suffix
844 @cindex @code{ULL} integer suffix
846 ISO C99 supports data types for integers that are at least 64 bits wide,
847 and as an extension GCC supports them in C90 mode and in C++.
848 Simply write @code{long long int} for a signed integer, or
849 @code{unsigned long long int} for an unsigned integer. To make an
850 integer constant of type @code{long long int}, add the suffix @samp{LL}
851 to the integer. To make an integer constant of type @code{unsigned long
852 long int}, add the suffix @samp{ULL} to the integer.
854 You can use these types in arithmetic like any other integer types.
855 Addition, subtraction, and bitwise boolean operations on these types
856 are open-coded on all types of machines. Multiplication is open-coded
857 if the machine supports a fullword-to-doubleword widening multiply
858 instruction. Division and shifts are open-coded only on machines that
859 provide special support. The operations that are not open-coded use
860 special library routines that come with GCC@.
862 There may be pitfalls when you use @code{long long} types for function
863 arguments without function prototypes. If a function
864 expects type @code{int} for its argument, and you pass a value of type
865 @code{long long int}, confusion results because the caller and the
866 subroutine disagree about the number of bytes for the argument.
867 Likewise, if the function expects @code{long long int} and you pass
868 @code{int}. The best way to avoid such problems is to use prototypes.
871 @section Complex Numbers
872 @cindex complex numbers
873 @cindex @code{_Complex} keyword
874 @cindex @code{__complex__} keyword
876 ISO C99 supports complex floating data types, and as an extension GCC
877 supports them in C90 mode and in C++. GCC also supports complex integer data
878 types which are not part of ISO C99. You can declare complex types
879 using the keyword @code{_Complex}. As an extension, the older GNU
880 keyword @code{__complex__} is also supported.
882 For example, @samp{_Complex double x;} declares @code{x} as a
883 variable whose real part and imaginary part are both of type
884 @code{double}. @samp{_Complex short int y;} declares @code{y} to
885 have real and imaginary parts of type @code{short int}; this is not
886 likely to be useful, but it shows that the set of complex types is
889 To write a constant with a complex data type, use the suffix @samp{i} or
890 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
891 has type @code{_Complex float} and @code{3i} has type
892 @code{_Complex int}. Such a constant always has a pure imaginary
893 value, but you can form any complex value you like by adding one to a
894 real constant. This is a GNU extension; if you have an ISO C99
895 conforming C library (such as the GNU C Library), and want to construct complex
896 constants of floating type, you should include @code{<complex.h>} and
897 use the macros @code{I} or @code{_Complex_I} instead.
899 The ISO C++14 library also defines the @samp{i} suffix, so C++14 code
900 that includes the @samp{<complex>} header cannot use @samp{i} for the
901 GNU extension. The @samp{j} suffix still has the GNU meaning.
903 @cindex @code{__real__} keyword
904 @cindex @code{__imag__} keyword
905 To extract the real part of a complex-valued expression @var{exp}, write
906 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
907 extract the imaginary part. This is a GNU extension; for values of
908 floating type, you should use the ISO C99 functions @code{crealf},
909 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
910 @code{cimagl}, declared in @code{<complex.h>} and also provided as
911 built-in functions by GCC@.
913 @cindex complex conjugation
914 The operator @samp{~} performs complex conjugation when used on a value
915 with a complex type. This is a GNU extension; for values of
916 floating type, you should use the ISO C99 functions @code{conjf},
917 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
918 provided as built-in functions by GCC@.
920 GCC can allocate complex automatic variables in a noncontiguous
921 fashion; it's even possible for the real part to be in a register while
922 the imaginary part is on the stack (or vice versa). Only the DWARF
923 debug info format can represent this, so use of DWARF is recommended.
924 If you are using the stabs debug info format, GCC describes a noncontiguous
925 complex variable as if it were two separate variables of noncomplex type.
926 If the variable's actual name is @code{foo}, the two fictitious
927 variables are named @code{foo$real} and @code{foo$imag}. You can
928 examine and set these two fictitious variables with your debugger.
931 @section Additional Floating Types
932 @cindex additional floating types
933 @cindex @code{_Float@var{n}} data types
934 @cindex @code{_Float@var{n}x} data types
935 @cindex @code{__float80} data type
936 @cindex @code{__float128} data type
937 @cindex @code{__ibm128} data type
938 @cindex @code{w} floating point suffix
939 @cindex @code{q} floating point suffix
940 @cindex @code{W} floating point suffix
941 @cindex @code{Q} floating point suffix
943 ISO/IEC TS 18661-3:2015 defines C support for additional floating
944 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
945 these type names; the set of types supported depends on the target
946 architecture. These types are not supported when compiling C++.
947 Constants with these types use suffixes @code{f@var{n}} or
948 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}. These type
949 names can be used together with @code{_Complex} to declare complex
952 As an extension, GNU C and GNU C++ support additional floating
953 types, which are not supported by all targets.
955 @item @code{__float128} is available on i386, x86_64, IA-64, and
956 hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable
957 the vector scalar (VSX) instruction set. @code{__float128} supports
958 the 128-bit floating type. On i386, x86_64, PowerPC, and IA-64
959 other than HP-UX, @code{__float128} is an alias for @code{_Float128}.
960 On hppa and IA-64 HP-UX, @code{__float128} is an alias for @code{long
963 @item @code{__float80} is available on the i386, x86_64, and IA-64
964 targets, and supports the 80-bit (@code{XFmode}) floating type. It is
965 an alias for the type name @code{_Float64x} on these targets.
967 @item @code{__ibm128} is available on PowerPC targets, and provides
968 access to the IBM extended double format which is the current format
969 used for @code{long double}. When @code{long double} transitions to
970 @code{__float128} on PowerPC in the future, @code{__ibm128} will remain
971 for use in conversions between the two types.
974 Support for these additional types includes the arithmetic operators:
975 add, subtract, multiply, divide; unary arithmetic operators;
976 relational operators; equality operators; and conversions to and from
977 integer and other floating types. Use a suffix @samp{w} or @samp{W}
978 in a literal constant of type @code{__float80} or type
979 @code{__ibm128}. Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
981 In order to use @code{_Float128}, @code{__float128}, and @code{__ibm128}
982 on PowerPC Linux systems, you must use the @option{-mfloat128} option. It is
983 expected in future versions of GCC that @code{_Float128} and @code{__float128}
984 will be enabled automatically.
986 The @code{_Float128} type is supported on all systems where
987 @code{__float128} is supported or where @code{long double} has the
988 IEEE binary128 format. The @code{_Float64x} type is supported on all
989 systems where @code{__float128} is supported. The @code{_Float32}
990 type is supported on all systems supporting IEEE binary32; the
991 @code{_Float64} and @code{_Float32x} types are supported on all systems
992 supporting IEEE binary64. The @code{_Float16} type is supported on AArch64
993 systems by default, and on ARM systems when the IEEE format for 16-bit
994 floating-point types is selected with @option{-mfp16-format=ieee}.
995 GCC does not currently support @code{_Float128x} on any systems.
997 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
998 types using the corresponding internal complex type, @code{XCmode} for
999 @code{__float80} type and @code{TCmode} for @code{__float128} type:
1002 typedef _Complex float __attribute__((mode(TC))) _Complex128;
1003 typedef _Complex float __attribute__((mode(XC))) _Complex80;
1006 On the PowerPC Linux VSX targets, you can declare complex types using
1007 the corresponding internal complex type, @code{KCmode} for
1008 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
1011 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
1012 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
1015 @node Half-Precision
1016 @section Half-Precision Floating Point
1017 @cindex half-precision floating point
1018 @cindex @code{__fp16} data type
1020 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1021 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1022 On ARM systems, you must enable this type explicitly with the
1023 @option{-mfp16-format} command-line option in order to use it.
1025 ARM targets support two incompatible representations for half-precision
1026 floating-point values. You must choose one of the representations and
1027 use it consistently in your program.
1029 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1030 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1031 There are 11 bits of significand precision, approximately 3
1034 Specifying @option{-mfp16-format=alternative} selects the ARM
1035 alternative format. This representation is similar to the IEEE
1036 format, but does not support infinities or NaNs. Instead, the range
1037 of exponents is extended, so that this format can represent normalized
1038 values in the range of @math{2^{-14}} to 131008.
1040 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1041 not require use of the @option{-mfp16-format} command-line option.
1043 The @code{__fp16} type may only be used as an argument to intrinsics defined
1044 in @code{<arm_fp16.h>}, or as a storage format. For purposes of
1045 arithmetic and other operations, @code{__fp16} values in C or C++
1046 expressions are automatically promoted to @code{float}.
1048 The ARM target provides hardware support for conversions between
1049 @code{__fp16} and @code{float} values
1050 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8-A provides
1051 hardware support for conversions between @code{__fp16} and @code{double}
1052 values. GCC generates code using these hardware instructions if you
1053 compile with options to select an FPU that provides them;
1054 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1055 in addition to the @option{-mfp16-format} option to select
1056 a half-precision format.
1058 Language-level support for the @code{__fp16} data type is
1059 independent of whether GCC generates code using hardware floating-point
1060 instructions. In cases where hardware support is not specified, GCC
1061 implements conversions between @code{__fp16} and other types as library
1064 It is recommended that portable code use the @code{_Float16} type defined
1065 by ISO/IEC TS 18661-3:2015. @xref{Floating Types}.
1068 @section Decimal Floating Types
1069 @cindex decimal floating types
1070 @cindex @code{_Decimal32} data type
1071 @cindex @code{_Decimal64} data type
1072 @cindex @code{_Decimal128} data type
1073 @cindex @code{df} integer suffix
1074 @cindex @code{dd} integer suffix
1075 @cindex @code{dl} integer suffix
1076 @cindex @code{DF} integer suffix
1077 @cindex @code{DD} integer suffix
1078 @cindex @code{DL} integer suffix
1080 As an extension, GNU C supports decimal floating types as
1081 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1082 floating types in GCC will evolve as the draft technical report changes.
1083 Calling conventions for any target might also change. Not all targets
1084 support decimal floating types.
1086 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1087 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1088 @code{float}, @code{double}, and @code{long double} whose radix is not
1089 specified by the C standard but is usually two.
1091 Support for decimal floating types includes the arithmetic operators
1092 add, subtract, multiply, divide; unary arithmetic operators;
1093 relational operators; equality operators; and conversions to and from
1094 integer and other floating types. Use a suffix @samp{df} or
1095 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1096 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1099 GCC support of decimal float as specified by the draft technical report
1104 When the value of a decimal floating type cannot be represented in the
1105 integer type to which it is being converted, the result is undefined
1106 rather than the result value specified by the draft technical report.
1109 GCC does not provide the C library functionality associated with
1110 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1111 @file{wchar.h}, which must come from a separate C library implementation.
1112 Because of this the GNU C compiler does not define macro
1113 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1114 the technical report.
1117 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1118 are supported by the DWARF debug information format.
1124 ISO C99 supports floating-point numbers written not only in the usual
1125 decimal notation, such as @code{1.55e1}, but also numbers such as
1126 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1127 supports this in C90 mode (except in some cases when strictly
1128 conforming) and in C++. In that format the
1129 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1130 mandatory. The exponent is a decimal number that indicates the power of
1131 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1138 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1139 is the same as @code{1.55e1}.
1141 Unlike for floating-point numbers in the decimal notation the exponent
1142 is always required in the hexadecimal notation. Otherwise the compiler
1143 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1144 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1145 extension for floating-point constants of type @code{float}.
1148 @section Fixed-Point Types
1149 @cindex fixed-point types
1150 @cindex @code{_Fract} data type
1151 @cindex @code{_Accum} data type
1152 @cindex @code{_Sat} data type
1153 @cindex @code{hr} fixed-suffix
1154 @cindex @code{r} fixed-suffix
1155 @cindex @code{lr} fixed-suffix
1156 @cindex @code{llr} fixed-suffix
1157 @cindex @code{uhr} fixed-suffix
1158 @cindex @code{ur} fixed-suffix
1159 @cindex @code{ulr} fixed-suffix
1160 @cindex @code{ullr} fixed-suffix
1161 @cindex @code{hk} fixed-suffix
1162 @cindex @code{k} fixed-suffix
1163 @cindex @code{lk} fixed-suffix
1164 @cindex @code{llk} fixed-suffix
1165 @cindex @code{uhk} fixed-suffix
1166 @cindex @code{uk} fixed-suffix
1167 @cindex @code{ulk} fixed-suffix
1168 @cindex @code{ullk} fixed-suffix
1169 @cindex @code{HR} fixed-suffix
1170 @cindex @code{R} fixed-suffix
1171 @cindex @code{LR} fixed-suffix
1172 @cindex @code{LLR} fixed-suffix
1173 @cindex @code{UHR} fixed-suffix
1174 @cindex @code{UR} fixed-suffix
1175 @cindex @code{ULR} fixed-suffix
1176 @cindex @code{ULLR} fixed-suffix
1177 @cindex @code{HK} fixed-suffix
1178 @cindex @code{K} fixed-suffix
1179 @cindex @code{LK} fixed-suffix
1180 @cindex @code{LLK} fixed-suffix
1181 @cindex @code{UHK} fixed-suffix
1182 @cindex @code{UK} fixed-suffix
1183 @cindex @code{ULK} fixed-suffix
1184 @cindex @code{ULLK} fixed-suffix
1186 As an extension, GNU C supports fixed-point types as
1187 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1188 types in GCC will evolve as the draft technical report changes.
1189 Calling conventions for any target might also change. Not all targets
1190 support fixed-point types.
1192 The fixed-point types are
1193 @code{short _Fract},
1196 @code{long long _Fract},
1197 @code{unsigned short _Fract},
1198 @code{unsigned _Fract},
1199 @code{unsigned long _Fract},
1200 @code{unsigned long long _Fract},
1201 @code{_Sat short _Fract},
1203 @code{_Sat long _Fract},
1204 @code{_Sat long long _Fract},
1205 @code{_Sat unsigned short _Fract},
1206 @code{_Sat unsigned _Fract},
1207 @code{_Sat unsigned long _Fract},
1208 @code{_Sat unsigned long long _Fract},
1209 @code{short _Accum},
1212 @code{long long _Accum},
1213 @code{unsigned short _Accum},
1214 @code{unsigned _Accum},
1215 @code{unsigned long _Accum},
1216 @code{unsigned long long _Accum},
1217 @code{_Sat short _Accum},
1219 @code{_Sat long _Accum},
1220 @code{_Sat long long _Accum},
1221 @code{_Sat unsigned short _Accum},
1222 @code{_Sat unsigned _Accum},
1223 @code{_Sat unsigned long _Accum},
1224 @code{_Sat unsigned long long _Accum}.
1226 Fixed-point data values contain fractional and optional integral parts.
1227 The format of fixed-point data varies and depends on the target machine.
1229 Support for fixed-point types includes:
1232 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1234 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1236 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1238 binary shift operators (@code{<<}, @code{>>})
1240 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1242 equality operators (@code{==}, @code{!=})
1244 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1245 @code{<<=}, @code{>>=})
1247 conversions to and from integer, floating-point, or fixed-point types
1250 Use a suffix in a fixed-point literal constant:
1252 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1253 @code{_Sat short _Fract}
1254 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1255 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1256 @code{_Sat long _Fract}
1257 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1258 @code{_Sat long long _Fract}
1259 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1260 @code{_Sat unsigned short _Fract}
1261 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1262 @code{_Sat unsigned _Fract}
1263 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1264 @code{_Sat unsigned long _Fract}
1265 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1266 and @code{_Sat unsigned long long _Fract}
1267 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1268 @code{_Sat short _Accum}
1269 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1270 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1271 @code{_Sat long _Accum}
1272 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1273 @code{_Sat long long _Accum}
1274 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1275 @code{_Sat unsigned short _Accum}
1276 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1277 @code{_Sat unsigned _Accum}
1278 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1279 @code{_Sat unsigned long _Accum}
1280 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1281 and @code{_Sat unsigned long long _Accum}
1284 GCC support of fixed-point types as specified by the draft technical report
1289 Pragmas to control overflow and rounding behaviors are not implemented.
1292 Fixed-point types are supported by the DWARF debug information format.
1294 @node Named Address Spaces
1295 @section Named Address Spaces
1296 @cindex Named Address Spaces
1298 As an extension, GNU C supports named address spaces as
1299 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1300 address spaces in GCC will evolve as the draft technical report
1301 changes. Calling conventions for any target might also change. At
1302 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1303 address spaces other than the generic address space.
1305 Address space identifiers may be used exactly like any other C type
1306 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1307 document for more details.
1309 @anchor{AVR Named Address Spaces}
1310 @subsection AVR Named Address Spaces
1312 On the AVR target, there are several address spaces that can be used
1313 in order to put read-only data into the flash memory and access that
1314 data by means of the special instructions @code{LPM} or @code{ELPM}
1315 needed to read from flash.
1317 Devices belonging to @code{avrtiny} and @code{avrxmega3} can access
1318 flash memory by means of @code{LD*} instructions because the flash
1319 memory is mapped into the RAM address space. There is @emph{no need}
1320 for language extensions like @code{__flash} or attribute
1321 @ref{AVR Variable Attributes,,@code{progmem}}.
1322 The default linker description files for these devices cater for that
1323 feature and @code{.rodata} stays in flash: The compiler just generates
1324 @code{LD*} instructions, and the linker script adds core specific
1325 offsets to all @code{.rodata} symbols: @code{0x4000} in the case of
1326 @code{avrtiny} and @code{0x8000} in the case of @code{avrxmega3}.
1327 See @ref{AVR Options} for a list of respective devices.
1329 For devices not in @code{avrtiny} or @code{avrxmega3},
1330 any data including read-only data is located in RAM (the generic
1331 address space) because flash memory is not visible in the RAM address
1332 space. In order to locate read-only data in flash memory @emph{and}
1333 to generate the right instructions to access this data without
1334 using (inline) assembler code, special address spaces are needed.
1338 @cindex @code{__flash} AVR Named Address Spaces
1339 The @code{__flash} qualifier locates data in the
1340 @code{.progmem.data} section. Data is read using the @code{LPM}
1341 instruction. Pointers to this address space are 16 bits wide.
1348 @cindex @code{__flash1} AVR Named Address Spaces
1349 @cindex @code{__flash2} AVR Named Address Spaces
1350 @cindex @code{__flash3} AVR Named Address Spaces
1351 @cindex @code{__flash4} AVR Named Address Spaces
1352 @cindex @code{__flash5} AVR Named Address Spaces
1353 These are 16-bit address spaces locating data in section
1354 @code{.progmem@var{N}.data} where @var{N} refers to
1355 address space @code{__flash@var{N}}.
1356 The compiler sets the @code{RAMPZ} segment register appropriately
1357 before reading data by means of the @code{ELPM} instruction.
1360 @cindex @code{__memx} AVR Named Address Spaces
1361 This is a 24-bit address space that linearizes flash and RAM:
1362 If the high bit of the address is set, data is read from
1363 RAM using the lower two bytes as RAM address.
1364 If the high bit of the address is clear, data is read from flash
1365 with @code{RAMPZ} set according to the high byte of the address.
1366 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1368 Objects in this address space are located in @code{.progmemx.data}.
1374 char my_read (const __flash char ** p)
1376 /* p is a pointer to RAM that points to a pointer to flash.
1377 The first indirection of p reads that flash pointer
1378 from RAM and the second indirection reads a char from this
1384 /* Locate array[] in flash memory */
1385 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1391 /* Return 17 by reading from flash memory */
1392 return array[array[i]];
1397 For each named address space supported by avr-gcc there is an equally
1398 named but uppercase built-in macro defined.
1399 The purpose is to facilitate testing if respective address space
1400 support is available or not:
1404 const __flash int var = 1;
1411 #include <avr/pgmspace.h> /* From AVR-LibC */
1413 const int var PROGMEM = 1;
1417 return (int) pgm_read_word (&var);
1419 #endif /* __FLASH */
1423 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1424 locates data in flash but
1425 accesses to these data read from generic address space, i.e.@:
1427 so that you need special accessors like @code{pgm_read_byte}
1428 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1429 together with attribute @code{progmem}.
1432 @b{Limitations and caveats}
1436 Reading across the 64@tie{}KiB section boundary of
1437 the @code{__flash} or @code{__flash@var{N}} address spaces
1438 shows undefined behavior. The only address space that
1439 supports reading across the 64@tie{}KiB flash segment boundaries is
1443 If you use one of the @code{__flash@var{N}} address spaces
1444 you must arrange your linker script to locate the
1445 @code{.progmem@var{N}.data} sections according to your needs.
1448 Any data or pointers to the non-generic address spaces must
1449 be qualified as @code{const}, i.e.@: as read-only data.
1450 This still applies if the data in one of these address
1451 spaces like software version number or calibration lookup table are intended to
1452 be changed after load time by, say, a boot loader. In this case
1453 the right qualification is @code{const} @code{volatile} so that the compiler
1454 must not optimize away known values or insert them
1455 as immediates into operands of instructions.
1458 The following code initializes a variable @code{pfoo}
1459 located in static storage with a 24-bit address:
1461 extern const __memx char foo;
1462 const __memx void *pfoo = &foo;
1466 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1467 Just use vanilla C / C++ code without overhead as outlined above.
1468 Attribute @code{progmem} is supported but works differently,
1469 see @ref{AVR Variable Attributes}.
1473 @subsection M32C Named Address Spaces
1474 @cindex @code{__far} M32C Named Address Spaces
1476 On the M32C target, with the R8C and M16C CPU variants, variables
1477 qualified with @code{__far} are accessed using 32-bit addresses in
1478 order to access memory beyond the first 64@tie{}Ki bytes. If
1479 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1482 @subsection RL78 Named Address Spaces
1483 @cindex @code{__far} RL78 Named Address Spaces
1485 On the RL78 target, variables qualified with @code{__far} are accessed
1486 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1487 addresses. Non-far variables are assumed to appear in the topmost
1488 64@tie{}KiB of the address space.
1490 @subsection SPU Named Address Spaces
1491 @cindex @code{__ea} SPU Named Address Spaces
1493 On the SPU target variables may be declared as
1494 belonging to another address space by qualifying the type with the
1495 @code{__ea} address space identifier:
1502 The compiler generates special code to access the variable @code{i}.
1503 It may use runtime library
1504 support, or generate special machine instructions to access that address
1507 @subsection x86 Named Address Spaces
1508 @cindex x86 named address spaces
1510 On the x86 target, variables may be declared as being relative
1511 to the @code{%fs} or @code{%gs} segments.
1516 @cindex @code{__seg_fs} x86 named address space
1517 @cindex @code{__seg_gs} x86 named address space
1518 The object is accessed with the respective segment override prefix.
1520 The respective segment base must be set via some method specific to
1521 the operating system. Rather than require an expensive system call
1522 to retrieve the segment base, these address spaces are not considered
1523 to be subspaces of the generic (flat) address space. This means that
1524 explicit casts are required to convert pointers between these address
1525 spaces and the generic address space. In practice the application
1526 should cast to @code{uintptr_t} and apply the segment base offset
1527 that it installed previously.
1529 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1530 defined when these address spaces are supported.
1534 @section Arrays of Length Zero
1535 @cindex arrays of length zero
1536 @cindex zero-length arrays
1537 @cindex length-zero arrays
1538 @cindex flexible array members
1540 Declaring zero-length arrays is allowed in GNU C as an extension.
1541 A zero-length array can be useful as the last element of a structure
1542 that is really a header for a variable-length object:
1550 struct line *thisline = (struct line *)
1551 malloc (sizeof (struct line) + this_length);
1552 thisline->length = this_length;
1555 Although the size of a zero-length array is zero, an array member of
1556 this kind may increase the size of the enclosing type as a result of tail
1557 padding. The offset of a zero-length array member from the beginning
1558 of the enclosing structure is the same as the offset of an array with
1559 one or more elements of the same type. The alignment of a zero-length
1560 array is the same as the alignment of its elements.
1562 Declaring zero-length arrays in other contexts, including as interior
1563 members of structure objects or as non-member objects, is discouraged.
1564 Accessing elements of zero-length arrays declared in such contexts is
1565 undefined and may be diagnosed.
1567 In the absence of the zero-length array extension, in ISO C90
1568 the @code{contents} array in the example above would typically be declared
1569 to have a single element. Unlike a zero-length array which only contributes
1570 to the size of the enclosing structure for the purposes of alignment,
1571 a one-element array always occupies at least as much space as a single
1572 object of the type. Although using one-element arrays this way is
1573 discouraged, GCC handles accesses to trailing one-element array members
1574 analogously to zero-length arrays.
1576 The preferred mechanism to declare variable-length types like
1577 @code{struct line} above is the ISO C99 @dfn{flexible array member},
1578 with slightly different syntax and semantics:
1582 Flexible array members are written as @code{contents[]} without
1586 Flexible array members have incomplete type, and so the @code{sizeof}
1587 operator may not be applied. As a quirk of the original implementation
1588 of zero-length arrays, @code{sizeof} evaluates to zero.
1591 Flexible array members may only appear as the last member of a
1592 @code{struct} that is otherwise non-empty.
1595 A structure containing a flexible array member, or a union containing
1596 such a structure (possibly recursively), may not be a member of a
1597 structure or an element of an array. (However, these uses are
1598 permitted by GCC as extensions.)
1601 Non-empty initialization of zero-length
1602 arrays is treated like any case where there are more initializer
1603 elements than the array holds, in that a suitable warning about ``excess
1604 elements in array'' is given, and the excess elements (all of them, in
1605 this case) are ignored.
1607 GCC allows static initialization of flexible array members.
1608 This is equivalent to defining a new structure containing the original
1609 structure followed by an array of sufficient size to contain the data.
1610 E.g.@: in the following, @code{f1} is constructed as if it were declared
1616 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1619 struct f1 f1; int data[3];
1620 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1624 The convenience of this extension is that @code{f1} has the desired
1625 type, eliminating the need to consistently refer to @code{f2.f1}.
1627 This has symmetry with normal static arrays, in that an array of
1628 unknown size is also written with @code{[]}.
1630 Of course, this extension only makes sense if the extra data comes at
1631 the end of a top-level object, as otherwise we would be overwriting
1632 data at subsequent offsets. To avoid undue complication and confusion
1633 with initialization of deeply nested arrays, we simply disallow any
1634 non-empty initialization except when the structure is the top-level
1635 object. For example:
1638 struct foo @{ int x; int y[]; @};
1639 struct bar @{ struct foo z; @};
1641 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1642 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1643 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1644 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1647 @node Empty Structures
1648 @section Structures with No Members
1649 @cindex empty structures
1650 @cindex zero-size structures
1652 GCC permits a C structure to have no members:
1659 The structure has size zero. In C++, empty structures are part
1660 of the language. G++ treats empty structures as if they had a single
1661 member of type @code{char}.
1663 @node Variable Length
1664 @section Arrays of Variable Length
1665 @cindex variable-length arrays
1666 @cindex arrays of variable length
1669 Variable-length automatic arrays are allowed in ISO C99, and as an
1670 extension GCC accepts them in C90 mode and in C++. These arrays are
1671 declared like any other automatic arrays, but with a length that is not
1672 a constant expression. The storage is allocated at the point of
1673 declaration and deallocated when the block scope containing the declaration
1679 concat_fopen (char *s1, char *s2, char *mode)
1681 char str[strlen (s1) + strlen (s2) + 1];
1684 return fopen (str, mode);
1688 @cindex scope of a variable length array
1689 @cindex variable-length array scope
1690 @cindex deallocating variable length arrays
1691 Jumping or breaking out of the scope of the array name deallocates the
1692 storage. Jumping into the scope is not allowed; you get an error
1695 @cindex variable-length array in a structure
1696 As an extension, GCC accepts variable-length arrays as a member of
1697 a structure or a union. For example:
1703 struct S @{ int x[n]; @};
1707 @cindex @code{alloca} vs variable-length arrays
1708 You can use the function @code{alloca} to get an effect much like
1709 variable-length arrays. The function @code{alloca} is available in
1710 many other C implementations (but not in all). On the other hand,
1711 variable-length arrays are more elegant.
1713 There are other differences between these two methods. Space allocated
1714 with @code{alloca} exists until the containing @emph{function} returns.
1715 The space for a variable-length array is deallocated as soon as the array
1716 name's scope ends, unless you also use @code{alloca} in this scope.
1718 You can also use variable-length arrays as arguments to functions:
1722 tester (int len, char data[len][len])
1728 The length of an array is computed once when the storage is allocated
1729 and is remembered for the scope of the array in case you access it with
1732 If you want to pass the array first and the length afterward, you can
1733 use a forward declaration in the parameter list---another GNU extension.
1737 tester (int len; char data[len][len], int len)
1743 @cindex parameter forward declaration
1744 The @samp{int len} before the semicolon is a @dfn{parameter forward
1745 declaration}, and it serves the purpose of making the name @code{len}
1746 known when the declaration of @code{data} is parsed.
1748 You can write any number of such parameter forward declarations in the
1749 parameter list. They can be separated by commas or semicolons, but the
1750 last one must end with a semicolon, which is followed by the ``real''
1751 parameter declarations. Each forward declaration must match a ``real''
1752 declaration in parameter name and data type. ISO C99 does not support
1753 parameter forward declarations.
1755 @node Variadic Macros
1756 @section Macros with a Variable Number of Arguments.
1757 @cindex variable number of arguments
1758 @cindex macro with variable arguments
1759 @cindex rest argument (in macro)
1760 @cindex variadic macros
1762 In the ISO C standard of 1999, a macro can be declared to accept a
1763 variable number of arguments much as a function can. The syntax for
1764 defining the macro is similar to that of a function. Here is an
1768 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1772 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1773 such a macro, it represents the zero or more tokens until the closing
1774 parenthesis that ends the invocation, including any commas. This set of
1775 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1776 wherever it appears. See the CPP manual for more information.
1778 GCC has long supported variadic macros, and used a different syntax that
1779 allowed you to give a name to the variable arguments just like any other
1780 argument. Here is an example:
1783 #define debug(format, args...) fprintf (stderr, format, args)
1787 This is in all ways equivalent to the ISO C example above, but arguably
1788 more readable and descriptive.
1790 GNU CPP has two further variadic macro extensions, and permits them to
1791 be used with either of the above forms of macro definition.
1793 In standard C, you are not allowed to leave the variable argument out
1794 entirely; but you are allowed to pass an empty argument. For example,
1795 this invocation is invalid in ISO C, because there is no comma after
1802 GNU CPP permits you to completely omit the variable arguments in this
1803 way. In the above examples, the compiler would complain, though since
1804 the expansion of the macro still has the extra comma after the format
1807 To help solve this problem, CPP behaves specially for variable arguments
1808 used with the token paste operator, @samp{##}. If instead you write
1811 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1815 and if the variable arguments are omitted or empty, the @samp{##}
1816 operator causes the preprocessor to remove the comma before it. If you
1817 do provide some variable arguments in your macro invocation, GNU CPP
1818 does not complain about the paste operation and instead places the
1819 variable arguments after the comma. Just like any other pasted macro
1820 argument, these arguments are not macro expanded.
1822 @node Escaped Newlines
1823 @section Slightly Looser Rules for Escaped Newlines
1824 @cindex escaped newlines
1825 @cindex newlines (escaped)
1827 The preprocessor treatment of escaped newlines is more relaxed
1828 than that specified by the C90 standard, which requires the newline
1829 to immediately follow a backslash.
1830 GCC's implementation allows whitespace in the form
1831 of spaces, horizontal and vertical tabs, and form feeds between the
1832 backslash and the subsequent newline. The preprocessor issues a
1833 warning, but treats it as a valid escaped newline and combines the two
1834 lines to form a single logical line. This works within comments and
1835 tokens, as well as between tokens. Comments are @emph{not} treated as
1836 whitespace for the purposes of this relaxation, since they have not
1837 yet been replaced with spaces.
1840 @section Non-Lvalue Arrays May Have Subscripts
1841 @cindex subscripting
1842 @cindex arrays, non-lvalue
1844 @cindex subscripting and function values
1845 In ISO C99, arrays that are not lvalues still decay to pointers, and
1846 may be subscripted, although they may not be modified or used after
1847 the next sequence point and the unary @samp{&} operator may not be
1848 applied to them. As an extension, GNU C allows such arrays to be
1849 subscripted in C90 mode, though otherwise they do not decay to
1850 pointers outside C99 mode. For example,
1851 this is valid in GNU C though not valid in C90:
1855 struct foo @{int a[4];@};
1861 return f().a[index];
1867 @section Arithmetic on @code{void}- and Function-Pointers
1868 @cindex void pointers, arithmetic
1869 @cindex void, size of pointer to
1870 @cindex function pointers, arithmetic
1871 @cindex function, size of pointer to
1873 In GNU C, addition and subtraction operations are supported on pointers to
1874 @code{void} and on pointers to functions. This is done by treating the
1875 size of a @code{void} or of a function as 1.
1877 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1878 and on function types, and returns 1.
1880 @opindex Wpointer-arith
1881 The option @option{-Wpointer-arith} requests a warning if these extensions
1884 @node Pointers to Arrays
1885 @section Pointers to Arrays with Qualifiers Work as Expected
1886 @cindex pointers to arrays
1887 @cindex const qualifier
1889 In GNU C, pointers to arrays with qualifiers work similar to pointers
1890 to other qualified types. For example, a value of type @code{int (*)[5]}
1891 can be used to initialize a variable of type @code{const int (*)[5]}.
1892 These types are incompatible in ISO C because the @code{const} qualifier
1893 is formally attached to the element type of the array and not the
1898 transpose (int N, int M, double out[M][N], const double in[N][M]);
1902 transpose(3, 2, y, x);
1906 @section Non-Constant Initializers
1907 @cindex initializers, non-constant
1908 @cindex non-constant initializers
1910 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1911 automatic variable are not required to be constant expressions in GNU C@.
1912 Here is an example of an initializer with run-time varying elements:
1915 foo (float f, float g)
1917 float beat_freqs[2] = @{ f-g, f+g @};
1922 @node Compound Literals
1923 @section Compound Literals
1924 @cindex constructor expressions
1925 @cindex initializations in expressions
1926 @cindex structures, constructor expression
1927 @cindex expressions, constructor
1928 @cindex compound literals
1929 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1931 A compound literal looks like a cast of a brace-enclosed aggregate
1932 initializer list. Its value is an object of the type specified in
1933 the cast, containing the elements specified in the initializer.
1934 Unlike the result of a cast, a compound literal is an lvalue. ISO
1935 C99 and later support compound literals. As an extension, GCC
1936 supports compound literals also in C90 mode and in C++, although
1937 as explained below, the C++ semantics are somewhat different.
1939 Usually, the specified type of a compound literal is a structure. Assume
1940 that @code{struct foo} and @code{structure} are declared as shown:
1943 struct foo @{int a; char b[2];@} structure;
1947 Here is an example of constructing a @code{struct foo} with a compound literal:
1950 structure = ((struct foo) @{x + y, 'a', 0@});
1954 This is equivalent to writing the following:
1958 struct foo temp = @{x + y, 'a', 0@};
1963 You can also construct an array, though this is dangerous in C++, as
1964 explained below. If all the elements of the compound literal are
1965 (made up of) simple constant expressions suitable for use in
1966 initializers of objects of static storage duration, then the compound
1967 literal can be coerced to a pointer to its first element and used in
1968 such an initializer, as shown here:
1971 char **foo = (char *[]) @{ "x", "y", "z" @};
1974 Compound literals for scalar types and union types are also allowed. In
1975 the following example the variable @code{i} is initialized to the value
1976 @code{2}, the result of incrementing the unnamed object created by
1977 the compound literal.
1980 int i = ++(int) @{ 1 @};
1983 As a GNU extension, GCC allows initialization of objects with static storage
1984 duration by compound literals (which is not possible in ISO C99 because
1985 the initializer is not a constant).
1986 It is handled as if the object were initialized only with the brace-enclosed
1987 list if the types of the compound literal and the object match.
1988 The elements of the compound literal must be constant.
1989 If the object being initialized has array type of unknown size, the size is
1990 determined by the size of the compound literal.
1993 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1994 static int y[] = (int []) @{1, 2, 3@};
1995 static int z[] = (int [3]) @{1@};
1999 The above lines are equivalent to the following:
2001 static struct foo x = @{1, 'a', 'b'@};
2002 static int y[] = @{1, 2, 3@};
2003 static int z[] = @{1, 0, 0@};
2006 In C, a compound literal designates an unnamed object with static or
2007 automatic storage duration. In C++, a compound literal designates a
2008 temporary object that only lives until the end of its full-expression.
2009 As a result, well-defined C code that takes the address of a subobject
2010 of a compound literal can be undefined in C++, so G++ rejects
2011 the conversion of a temporary array to a pointer. For instance, if
2012 the array compound literal example above appeared inside a function,
2013 any subsequent use of @code{foo} in C++ would have undefined behavior
2014 because the lifetime of the array ends after the declaration of @code{foo}.
2016 As an optimization, G++ sometimes gives array compound literals longer
2017 lifetimes: when the array either appears outside a function or has
2018 a @code{const}-qualified type. If @code{foo} and its initializer had
2019 elements of type @code{char *const} rather than @code{char *}, or if
2020 @code{foo} were a global variable, the array would have static storage
2021 duration. But it is probably safest just to avoid the use of array
2022 compound literals in C++ code.
2024 @node Designated Inits
2025 @section Designated Initializers
2026 @cindex initializers with labeled elements
2027 @cindex labeled elements in initializers
2028 @cindex case labels in initializers
2029 @cindex designated initializers
2031 Standard C90 requires the elements of an initializer to appear in a fixed
2032 order, the same as the order of the elements in the array or structure
2035 In ISO C99 you can give the elements in any order, specifying the array
2036 indices or structure field names they apply to, and GNU C allows this as
2037 an extension in C90 mode as well. This extension is not
2038 implemented in GNU C++.
2040 To specify an array index, write
2041 @samp{[@var{index}] =} before the element value. For example,
2044 int a[6] = @{ [4] = 29, [2] = 15 @};
2051 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2055 The index values must be constant expressions, even if the array being
2056 initialized is automatic.
2058 An alternative syntax for this that has been obsolete since GCC 2.5 but
2059 GCC still accepts is to write @samp{[@var{index}]} before the element
2060 value, with no @samp{=}.
2062 To initialize a range of elements to the same value, write
2063 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
2064 extension. For example,
2067 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2071 If the value in it has side effects, the side effects happen only once,
2072 not for each initialized field by the range initializer.
2075 Note that the length of the array is the highest value specified
2078 In a structure initializer, specify the name of a field to initialize
2079 with @samp{.@var{fieldname} =} before the element value. For example,
2080 given the following structure,
2083 struct point @{ int x, y; @};
2087 the following initialization
2090 struct point p = @{ .y = yvalue, .x = xvalue @};
2097 struct point p = @{ xvalue, yvalue @};
2100 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2101 @samp{@var{fieldname}:}, as shown here:
2104 struct point p = @{ y: yvalue, x: xvalue @};
2107 Omitted field members are implicitly initialized the same as objects
2108 that have static storage duration.
2111 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2112 @dfn{designator}. You can also use a designator (or the obsolete colon
2113 syntax) when initializing a union, to specify which element of the union
2114 should be used. For example,
2117 union foo @{ int i; double d; @};
2119 union foo f = @{ .d = 4 @};
2123 converts 4 to a @code{double} to store it in the union using
2124 the second element. By contrast, casting 4 to type @code{union foo}
2125 stores it into the union as the integer @code{i}, since it is
2126 an integer. @xref{Cast to Union}.
2128 You can combine this technique of naming elements with ordinary C
2129 initialization of successive elements. Each initializer element that
2130 does not have a designator applies to the next consecutive element of the
2131 array or structure. For example,
2134 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2141 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2144 Labeling the elements of an array initializer is especially useful
2145 when the indices are characters or belong to an @code{enum} type.
2150 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2151 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2154 @cindex designator lists
2155 You can also write a series of @samp{.@var{fieldname}} and
2156 @samp{[@var{index}]} designators before an @samp{=} to specify a
2157 nested subobject to initialize; the list is taken relative to the
2158 subobject corresponding to the closest surrounding brace pair. For
2159 example, with the @samp{struct point} declaration above:
2162 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2166 If the same field is initialized multiple times, it has the value from
2167 the last initialization. If any such overridden initialization has
2168 side effect, it is unspecified whether the side effect happens or not.
2169 Currently, GCC discards them and issues a warning.
2172 @section Case Ranges
2174 @cindex ranges in case statements
2176 You can specify a range of consecutive values in a single @code{case} label,
2180 case @var{low} ... @var{high}:
2184 This has the same effect as the proper number of individual @code{case}
2185 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2187 This feature is especially useful for ranges of ASCII character codes:
2193 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2194 it may be parsed wrong when you use it with integer values. For example,
2209 @section Cast to a Union Type
2210 @cindex cast to a union
2211 @cindex union, casting to a
2213 A cast to union type looks similar to other casts, except that the type
2214 specified is a union type. You can specify the type either with the
2215 @code{union} keyword or with a @code{typedef} name that refers to
2216 a union. A cast to a union actually creates a compound literal and
2217 yields an lvalue, not an rvalue like true casts do.
2218 @xref{Compound Literals}.
2220 The types that may be cast to the union type are those of the members
2221 of the union. Thus, given the following union and variables:
2224 union foo @{ int i; double d; @};
2230 both @code{x} and @code{y} can be cast to type @code{union foo}.
2232 Using the cast as the right-hand side of an assignment to a variable of
2233 union type is equivalent to storing in a member of the union:
2238 u = (union foo) x @equiv{} u.i = x
2239 u = (union foo) y @equiv{} u.d = y
2242 You can also use the union cast as a function argument:
2245 void hack (union foo);
2247 hack ((union foo) x);
2250 @node Mixed Declarations
2251 @section Mixed Declarations and Code
2252 @cindex mixed declarations and code
2253 @cindex declarations, mixed with code
2254 @cindex code, mixed with declarations
2256 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2257 within compound statements. As an extension, GNU C also allows this in
2258 C90 mode. For example, you could do:
2267 Each identifier is visible from where it is declared until the end of
2268 the enclosing block.
2270 @node Function Attributes
2271 @section Declaring Attributes of Functions
2272 @cindex function attributes
2273 @cindex declaring attributes of functions
2274 @cindex @code{volatile} applied to function
2275 @cindex @code{const} applied to function
2277 In GNU C, you can use function attributes to declare certain things
2278 about functions called in your program which help the compiler
2279 optimize calls and check your code more carefully. For example, you
2280 can use attributes to declare that a function never returns
2281 (@code{noreturn}), returns a value depending only on its arguments
2282 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2284 You can also use attributes to control memory placement, code
2285 generation options or call/return conventions within the function
2286 being annotated. Many of these attributes are target-specific. For
2287 example, many targets support attributes for defining interrupt
2288 handler functions, which typically must follow special register usage
2289 and return conventions.
2291 Function attributes are introduced by the @code{__attribute__} keyword
2292 on a declaration, followed by an attribute specification inside double
2293 parentheses. You can specify multiple attributes in a declaration by
2294 separating them by commas within the double parentheses or by
2295 immediately following an attribute declaration with another attribute
2296 declaration. @xref{Attribute Syntax}, for the exact rules on attribute
2297 syntax and placement. Compatible attribute specifications on distinct
2298 declarations of the same function are merged. An attribute specification
2299 that is not compatible with attributes already applied to a declaration
2300 of the same function is ignored with a warning.
2302 GCC also supports attributes on
2303 variable declarations (@pxref{Variable Attributes}),
2304 labels (@pxref{Label Attributes}),
2305 enumerators (@pxref{Enumerator Attributes}),
2306 statements (@pxref{Statement Attributes}),
2307 and types (@pxref{Type Attributes}).
2309 There is some overlap between the purposes of attributes and pragmas
2310 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2311 found convenient to use @code{__attribute__} to achieve a natural
2312 attachment of attributes to their corresponding declarations, whereas
2313 @code{#pragma} is of use for compatibility with other compilers
2314 or constructs that do not naturally form part of the grammar.
2316 In addition to the attributes documented here,
2317 GCC plugins may provide their own attributes.
2320 * Common Function Attributes::
2321 * AArch64 Function Attributes::
2322 * ARC Function Attributes::
2323 * ARM Function Attributes::
2324 * AVR Function Attributes::
2325 * Blackfin Function Attributes::
2326 * CR16 Function Attributes::
2327 * C-SKY Function Attributes::
2328 * Epiphany Function Attributes::
2329 * H8/300 Function Attributes::
2330 * IA-64 Function Attributes::
2331 * M32C Function Attributes::
2332 * M32R/D Function Attributes::
2333 * m68k Function Attributes::
2334 * MCORE Function Attributes::
2335 * MeP Function Attributes::
2336 * MicroBlaze Function Attributes::
2337 * Microsoft Windows Function Attributes::
2338 * MIPS Function Attributes::
2339 * MSP430 Function Attributes::
2340 * NDS32 Function Attributes::
2341 * Nios II Function Attributes::
2342 * Nvidia PTX Function Attributes::
2343 * PowerPC Function Attributes::
2344 * RISC-V Function Attributes::
2345 * RL78 Function Attributes::
2346 * RX Function Attributes::
2347 * S/390 Function Attributes::
2348 * SH Function Attributes::
2349 * SPU Function Attributes::
2350 * Symbian OS Function Attributes::
2351 * V850 Function Attributes::
2352 * Visium Function Attributes::
2353 * x86 Function Attributes::
2354 * Xstormy16 Function Attributes::
2357 @node Common Function Attributes
2358 @subsection Common Function Attributes
2360 The following attributes are supported on most targets.
2363 @c Keep this table alphabetized by attribute name. Treat _ as space.
2365 @item alias ("@var{target}")
2366 @cindex @code{alias} function attribute
2367 The @code{alias} attribute causes the declaration to be emitted as an
2368 alias for another symbol, which must be specified. For instance,
2371 void __f () @{ /* @r{Do something.} */; @}
2372 void f () __attribute__ ((weak, alias ("__f")));
2376 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2377 mangled name for the target must be used. It is an error if @samp{__f}
2378 is not defined in the same translation unit.
2380 This attribute requires assembler and object file support,
2381 and may not be available on all targets.
2383 @item aligned (@var{alignment})
2384 @cindex @code{aligned} function attribute
2385 This attribute specifies a minimum alignment for the function,
2388 You cannot use this attribute to decrease the alignment of a function,
2389 only to increase it. However, when you explicitly specify a function
2390 alignment this overrides the effect of the
2391 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2394 Note that the effectiveness of @code{aligned} attributes may be
2395 limited by inherent limitations in your linker. On many systems, the
2396 linker is only able to arrange for functions to be aligned up to a
2397 certain maximum alignment. (For some linkers, the maximum supported
2398 alignment may be very very small.) See your linker documentation for
2399 further information.
2401 The @code{aligned} attribute can also be used for variables and fields
2402 (@pxref{Variable Attributes}.)
2405 @cindex @code{alloc_align} function attribute
2406 The @code{alloc_align} attribute is used to tell the compiler that the
2407 function return value points to memory, where the returned pointer minimum
2408 alignment is given by one of the functions parameters. GCC uses this
2409 information to improve pointer alignment analysis.
2411 The function parameter denoting the allocated alignment is specified by
2412 one integer argument, whose number is the argument of the attribute.
2413 Argument numbering starts at one.
2418 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2422 declares that @code{my_memalign} returns memory with minimum alignment
2423 given by parameter 1.
2426 @cindex @code{alloc_size} function attribute
2427 The @code{alloc_size} attribute is used to tell the compiler that the
2428 function return value points to memory, where the size is given by
2429 one or two of the functions parameters. GCC uses this
2430 information to improve the correctness of @code{__builtin_object_size}.
2432 The function parameter(s) denoting the allocated size are specified by
2433 one or two integer arguments supplied to the attribute. The allocated size
2434 is either the value of the single function argument specified or the product
2435 of the two function arguments specified. Argument numbering starts at
2441 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2442 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2446 declares that @code{my_calloc} returns memory of the size given by
2447 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2448 of the size given by parameter 2.
2451 @cindex @code{always_inline} function attribute
2452 Generally, functions are not inlined unless optimization is specified.
2453 For functions declared inline, this attribute inlines the function
2454 independent of any restrictions that otherwise apply to inlining.
2455 Failure to inline such a function is diagnosed as an error.
2456 Note that if such a function is called indirectly the compiler may
2457 or may not inline it depending on optimization level and a failure
2458 to inline an indirect call may or may not be diagnosed.
2461 @cindex @code{artificial} function attribute
2462 This attribute is useful for small inline wrappers that if possible
2463 should appear during debugging as a unit. Depending on the debug
2464 info format it either means marking the function as artificial
2465 or using the caller location for all instructions within the inlined
2468 @item assume_aligned
2469 @cindex @code{assume_aligned} function attribute
2470 The @code{assume_aligned} attribute is used to tell the compiler that the
2471 function return value points to memory, where the returned pointer minimum
2472 alignment is given by the first argument.
2473 If the attribute has two arguments, the second argument is misalignment offset.
2478 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2479 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2483 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2484 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2488 @cindex @code{cold} function attribute
2489 The @code{cold} attribute on functions is used to inform the compiler that
2490 the function is unlikely to be executed. The function is optimized for
2491 size rather than speed and on many targets it is placed into a special
2492 subsection of the text section so all cold functions appear close together,
2493 improving code locality of non-cold parts of program. The paths leading
2494 to calls of cold functions within code are marked as unlikely by the branch
2495 prediction mechanism. It is thus useful to mark functions used to handle
2496 unlikely conditions, such as @code{perror}, as cold to improve optimization
2497 of hot functions that do call marked functions in rare occasions.
2499 When profile feedback is available, via @option{-fprofile-use}, cold functions
2500 are automatically detected and this attribute is ignored.
2503 @cindex @code{const} function attribute
2504 @cindex functions that have no side effects
2505 Many functions do not examine any values except their arguments, and
2506 have no effects except to return a value. Calls to such functions lend
2507 themselves to optimization such as common subexpression elimination.
2508 The @code{const} attribute imposes greater restrictions on a function's
2509 definition than the similar @code{pure} attribute below because it prohibits
2510 the function from reading global variables. Consequently, the presence of
2511 the attribute on a function declaration allows GCC to emit more efficient
2512 code for some calls to the function. Decorating the same function with
2513 both the @code{const} and the @code{pure} attribute is diagnosed.
2515 @cindex pointer arguments
2516 Note that a function that has pointer arguments and examines the data
2517 pointed to must @emph{not} be declared @code{const}. Likewise, a
2518 function that calls a non-@code{const} function usually must not be
2519 @code{const}. Because a @code{const} function cannot have any side
2520 effects it does not make sense for such a function to return @code{void}.
2521 Declaring such a function is diagnosed.
2525 @itemx constructor (@var{priority})
2526 @itemx destructor (@var{priority})
2527 @cindex @code{constructor} function attribute
2528 @cindex @code{destructor} function attribute
2529 The @code{constructor} attribute causes the function to be called
2530 automatically before execution enters @code{main ()}. Similarly, the
2531 @code{destructor} attribute causes the function to be called
2532 automatically after @code{main ()} completes or @code{exit ()} is
2533 called. Functions with these attributes are useful for
2534 initializing data that is used implicitly during the execution of
2537 You may provide an optional integer priority to control the order in
2538 which constructor and destructor functions are run. A constructor
2539 with a smaller priority number runs before a constructor with a larger
2540 priority number; the opposite relationship holds for destructors. So,
2541 if you have a constructor that allocates a resource and a destructor
2542 that deallocates the same resource, both functions typically have the
2543 same priority. The priorities for constructor and destructor
2544 functions are the same as those specified for namespace-scope C++
2545 objects (@pxref{C++ Attributes}). However, at present, the order in which
2546 constructors for C++ objects with static storage duration and functions
2547 decorated with attribute @code{constructor} are invoked is unspecified.
2548 In mixed declarations, attribute @code{init_priority} can be used to
2549 impose a specific ordering.
2552 @itemx deprecated (@var{msg})
2553 @cindex @code{deprecated} function attribute
2554 The @code{deprecated} attribute results in a warning if the function
2555 is used anywhere in the source file. This is useful when identifying
2556 functions that are expected to be removed in a future version of a
2557 program. The warning also includes the location of the declaration
2558 of the deprecated function, to enable users to easily find further
2559 information about why the function is deprecated, or what they should
2560 do instead. Note that the warnings only occurs for uses:
2563 int old_fn () __attribute__ ((deprecated));
2565 int (*fn_ptr)() = old_fn;
2569 results in a warning on line 3 but not line 2. The optional @var{msg}
2570 argument, which must be a string, is printed in the warning if
2573 The @code{deprecated} attribute can also be used for variables and
2574 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2576 The message attached to the attribute is affected by the setting of
2577 the @option{-fmessage-length} option.
2579 @item error ("@var{message}")
2580 @itemx warning ("@var{message}")
2581 @cindex @code{error} function attribute
2582 @cindex @code{warning} function attribute
2583 If the @code{error} or @code{warning} attribute
2584 is used on a function declaration and a call to such a function
2585 is not eliminated through dead code elimination or other optimizations,
2586 an error or warning (respectively) that includes @var{message} is diagnosed.
2588 for compile-time checking, especially together with @code{__builtin_constant_p}
2589 and inline functions where checking the inline function arguments is not
2590 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2592 While it is possible to leave the function undefined and thus invoke
2593 a link failure (to define the function with
2594 a message in @code{.gnu.warning*} section),
2595 when using these attributes the problem is diagnosed
2596 earlier and with exact location of the call even in presence of inline
2597 functions or when not emitting debugging information.
2599 @item externally_visible
2600 @cindex @code{externally_visible} function attribute
2601 This attribute, attached to a global variable or function, nullifies
2602 the effect of the @option{-fwhole-program} command-line option, so the
2603 object remains visible outside the current compilation unit.
2605 If @option{-fwhole-program} is used together with @option{-flto} and
2606 @command{gold} is used as the linker plugin,
2607 @code{externally_visible} attributes are automatically added to functions
2608 (not variable yet due to a current @command{gold} issue)
2609 that are accessed outside of LTO objects according to resolution file
2610 produced by @command{gold}.
2611 For other linkers that cannot generate resolution file,
2612 explicit @code{externally_visible} attributes are still necessary.
2615 @cindex @code{flatten} function attribute
2616 Generally, inlining into a function is limited. For a function marked with
2617 this attribute, every call inside this function is inlined, if possible.
2618 Whether the function itself is considered for inlining depends on its size and
2619 the current inlining parameters.
2621 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2622 @cindex @code{format} function attribute
2623 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2625 The @code{format} attribute specifies that a function takes @code{printf},
2626 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2627 should be type-checked against a format string. For example, the
2632 my_printf (void *my_object, const char *my_format, ...)
2633 __attribute__ ((format (printf, 2, 3)));
2637 causes the compiler to check the arguments in calls to @code{my_printf}
2638 for consistency with the @code{printf} style format string argument
2641 The parameter @var{archetype} determines how the format string is
2642 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2643 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2644 @code{strfmon}. (You can also use @code{__printf__},
2645 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2646 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2647 @code{ms_strftime} are also present.
2648 @var{archetype} values such as @code{printf} refer to the formats accepted
2649 by the system's C runtime library,
2650 while values prefixed with @samp{gnu_} always refer
2651 to the formats accepted by the GNU C Library. On Microsoft Windows
2652 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2653 @file{msvcrt.dll} library.
2654 The parameter @var{string-index}
2655 specifies which argument is the format string argument (starting
2656 from 1), while @var{first-to-check} is the number of the first
2657 argument to check against the format string. For functions
2658 where the arguments are not available to be checked (such as
2659 @code{vprintf}), specify the third parameter as zero. In this case the
2660 compiler only checks the format string for consistency. For
2661 @code{strftime} formats, the third parameter is required to be zero.
2662 Since non-static C++ methods have an implicit @code{this} argument, the
2663 arguments of such methods should be counted from two, not one, when
2664 giving values for @var{string-index} and @var{first-to-check}.
2666 In the example above, the format string (@code{my_format}) is the second
2667 argument of the function @code{my_print}, and the arguments to check
2668 start with the third argument, so the correct parameters for the format
2669 attribute are 2 and 3.
2671 @opindex ffreestanding
2672 @opindex fno-builtin
2673 The @code{format} attribute allows you to identify your own functions
2674 that take format strings as arguments, so that GCC can check the
2675 calls to these functions for errors. The compiler always (unless
2676 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2677 for the standard library functions @code{printf}, @code{fprintf},
2678 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2679 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2680 warnings are requested (using @option{-Wformat}), so there is no need to
2681 modify the header file @file{stdio.h}. In C99 mode, the functions
2682 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2683 @code{vsscanf} are also checked. Except in strictly conforming C
2684 standard modes, the X/Open function @code{strfmon} is also checked as
2685 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2686 @xref{C Dialect Options,,Options Controlling C Dialect}.
2688 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2689 recognized in the same context. Declarations including these format attributes
2690 are parsed for correct syntax, however the result of checking of such format
2691 strings is not yet defined, and is not carried out by this version of the
2694 The target may also provide additional types of format checks.
2695 @xref{Target Format Checks,,Format Checks Specific to Particular
2698 @item format_arg (@var{string-index})
2699 @cindex @code{format_arg} function attribute
2700 @opindex Wformat-nonliteral
2701 The @code{format_arg} attribute specifies that a function takes a format
2702 string for a @code{printf}, @code{scanf}, @code{strftime} or
2703 @code{strfmon} style function and modifies it (for example, to translate
2704 it into another language), so the result can be passed to a
2705 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2706 function (with the remaining arguments to the format function the same
2707 as they would have been for the unmodified string). For example, the
2712 my_dgettext (char *my_domain, const char *my_format)
2713 __attribute__ ((format_arg (2)));
2717 causes the compiler to check the arguments in calls to a @code{printf},
2718 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2719 format string argument is a call to the @code{my_dgettext} function, for
2720 consistency with the format string argument @code{my_format}. If the
2721 @code{format_arg} attribute had not been specified, all the compiler
2722 could tell in such calls to format functions would be that the format
2723 string argument is not constant; this would generate a warning when
2724 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2725 without the attribute.
2727 The parameter @var{string-index} specifies which argument is the format
2728 string argument (starting from one). Since non-static C++ methods have
2729 an implicit @code{this} argument, the arguments of such methods should
2730 be counted from two.
2732 The @code{format_arg} attribute allows you to identify your own
2733 functions that modify format strings, so that GCC can check the
2734 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2735 type function whose operands are a call to one of your own function.
2736 The compiler always treats @code{gettext}, @code{dgettext}, and
2737 @code{dcgettext} in this manner except when strict ISO C support is
2738 requested by @option{-ansi} or an appropriate @option{-std} option, or
2739 @option{-ffreestanding} or @option{-fno-builtin}
2740 is used. @xref{C Dialect Options,,Options
2741 Controlling C Dialect}.
2743 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2744 @code{NSString} reference for compatibility with the @code{format} attribute
2747 The target may also allow additional types in @code{format-arg} attributes.
2748 @xref{Target Format Checks,,Format Checks Specific to Particular
2752 @cindex @code{gnu_inline} function attribute
2753 This attribute should be used with a function that is also declared
2754 with the @code{inline} keyword. It directs GCC to treat the function
2755 as if it were defined in gnu90 mode even when compiling in C99 or
2758 If the function is declared @code{extern}, then this definition of the
2759 function is used only for inlining. In no case is the function
2760 compiled as a standalone function, not even if you take its address
2761 explicitly. Such an address becomes an external reference, as if you
2762 had only declared the function, and had not defined it. This has
2763 almost the effect of a macro. The way to use this is to put a
2764 function definition in a header file with this attribute, and put
2765 another copy of the function, without @code{extern}, in a library
2766 file. The definition in the header file causes most calls to the
2767 function to be inlined. If any uses of the function remain, they
2768 refer to the single copy in the library. Note that the two
2769 definitions of the functions need not be precisely the same, although
2770 if they do not have the same effect your program may behave oddly.
2772 In C, if the function is neither @code{extern} nor @code{static}, then
2773 the function is compiled as a standalone function, as well as being
2774 inlined where possible.
2776 This is how GCC traditionally handled functions declared
2777 @code{inline}. Since ISO C99 specifies a different semantics for
2778 @code{inline}, this function attribute is provided as a transition
2779 measure and as a useful feature in its own right. This attribute is
2780 available in GCC 4.1.3 and later. It is available if either of the
2781 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2782 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2783 Function is As Fast As a Macro}.
2785 In C++, this attribute does not depend on @code{extern} in any way,
2786 but it still requires the @code{inline} keyword to enable its special
2790 @cindex @code{hot} function attribute
2791 The @code{hot} attribute on a function is used to inform the compiler that
2792 the function is a hot spot of the compiled program. The function is
2793 optimized more aggressively and on many targets it is placed into a special
2794 subsection of the text section so all hot functions appear close together,
2797 When profile feedback is available, via @option{-fprofile-use}, hot functions
2798 are automatically detected and this attribute is ignored.
2800 @item ifunc ("@var{resolver}")
2801 @cindex @code{ifunc} function attribute
2802 @cindex indirect functions
2803 @cindex functions that are dynamically resolved
2804 The @code{ifunc} attribute is used to mark a function as an indirect
2805 function using the STT_GNU_IFUNC symbol type extension to the ELF
2806 standard. This allows the resolution of the symbol value to be
2807 determined dynamically at load time, and an optimized version of the
2808 routine to be selected for the particular processor or other system
2809 characteristics determined then. To use this attribute, first define
2810 the implementation functions available, and a resolver function that
2811 returns a pointer to the selected implementation function. The
2812 implementation functions' declarations must match the API of the
2813 function being implemented. The resolver should be declared to
2814 be a function taking no arguments and returning a pointer to
2815 a function of the same type as the implementation. For example:
2818 void *my_memcpy (void *dst, const void *src, size_t len)
2824 static void * (*resolve_memcpy (void))(void *, const void *, size_t)
2826 return my_memcpy; // we will just always select this routine
2831 The exported header file declaring the function the user calls would
2835 extern void *memcpy (void *, const void *, size_t);
2839 allowing the user to call @code{memcpy} as a regular function, unaware of
2840 the actual implementation. Finally, the indirect function needs to be
2841 defined in the same translation unit as the resolver function:
2844 void *memcpy (void *, const void *, size_t)
2845 __attribute__ ((ifunc ("resolve_memcpy")));
2848 In C++, the @code{ifunc} attribute takes a string that is the mangled name
2849 of the resolver function. A C++ resolver for a non-static member function
2850 of class @code{C} should be declared to return a pointer to a non-member
2851 function taking pointer to @code{C} as the first argument, followed by
2852 the same arguments as of the implementation function. G++ checks
2853 the signatures of the two functions and issues
2854 a @option{-Wattribute-alias} warning for mismatches. To suppress a warning
2855 for the necessary cast from a pointer to the implementation member function
2856 to the type of the corresponding non-member function use
2857 the @option{-Wno-pmf-conversions} option. For example:
2863 int debug_impl (int);
2864 int optimized_impl (int);
2866 typedef int Func (S*, int);
2868 static Func* resolver ();
2871 int interface (int);
2874 int S::debug_impl (int) @{ /* @r{@dots{}} */ @}
2875 int S::optimized_impl (int) @{ /* @r{@dots{}} */ @}
2877 S::Func* S::resolver ()
2879 int (S::*pimpl) (int)
2880 = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl;
2882 // Cast triggers -Wno-pmf-conversions.
2883 return reinterpret_cast<Func*>(pimpl);
2886 int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv")));
2889 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
2890 and GNU C Library version 2.11.1 are required to use this feature.
2893 @itemx interrupt_handler
2894 Many GCC back ends support attributes to indicate that a function is
2895 an interrupt handler, which tells the compiler to generate function
2896 entry and exit sequences that differ from those from regular
2897 functions. The exact syntax and behavior are target-specific;
2898 refer to the following subsections for details.
2901 @cindex @code{leaf} function attribute
2902 Calls to external functions with this attribute must return to the
2903 current compilation unit only by return or by exception handling. In
2904 particular, a leaf function is not allowed to invoke callback functions
2905 passed to it from the current compilation unit, directly call functions
2906 exported by the unit, or @code{longjmp} into the unit. Leaf functions
2907 might still call functions from other compilation units and thus they
2908 are not necessarily leaf in the sense that they contain no function
2911 The attribute is intended for library functions to improve dataflow
2912 analysis. The compiler takes the hint that any data not escaping the
2913 current compilation unit cannot be used or modified by the leaf
2914 function. For example, the @code{sin} function is a leaf function, but
2915 @code{qsort} is not.
2917 Note that leaf functions might indirectly run a signal handler defined
2918 in the current compilation unit that uses static variables. Similarly,
2919 when lazy symbol resolution is in effect, leaf functions might invoke
2920 indirect functions whose resolver function or implementation function is
2921 defined in the current compilation unit and uses static variables. There
2922 is no standard-compliant way to write such a signal handler, resolver
2923 function, or implementation function, and the best that you can do is to
2924 remove the @code{leaf} attribute or mark all such static variables
2925 @code{volatile}. Lastly, for ELF-based systems that support symbol
2926 interposition, care should be taken that functions defined in the
2927 current compilation unit do not unexpectedly interpose other symbols
2928 based on the defined standards mode and defined feature test macros;
2929 otherwise an inadvertent callback would be added.
2931 The attribute has no effect on functions defined within the current
2932 compilation unit. This is to allow easy merging of multiple compilation
2933 units into one, for example, by using the link-time optimization. For
2934 this reason the attribute is not allowed on types to annotate indirect
2938 @cindex @code{malloc} function attribute
2939 @cindex functions that behave like malloc
2940 This tells the compiler that a function is @code{malloc}-like, i.e.,
2941 that the pointer @var{P} returned by the function cannot alias any
2942 other pointer valid when the function returns, and moreover no
2943 pointers to valid objects occur in any storage addressed by @var{P}.
2945 Using this attribute can improve optimization. Compiler predicts
2946 that a function with the attribute returns non-null in most cases.
2948 @code{malloc} and @code{calloc} have this property because they return
2949 a pointer to uninitialized or zeroed-out storage. However, functions
2950 like @code{realloc} do not have this property, as they can return a
2951 pointer to storage containing pointers.
2954 @cindex @code{no_icf} function attribute
2955 This function attribute prevents a functions from being merged with another
2956 semantically equivalent function.
2958 @item no_instrument_function
2959 @cindex @code{no_instrument_function} function attribute
2960 @opindex finstrument-functions
2961 If @option{-finstrument-functions} is given, profiling function calls are
2962 generated at entry and exit of most user-compiled functions.
2963 Functions with this attribute are not so instrumented.
2965 @item no_profile_instrument_function
2966 @cindex @code{no_profile_instrument_function} function attribute
2967 The @code{no_profile_instrument_function} attribute on functions is used
2968 to inform the compiler that it should not process any profile feedback based
2969 optimization code instrumentation.
2972 @cindex @code{no_reorder} function attribute
2973 Do not reorder functions or variables marked @code{no_reorder}
2974 against each other or top level assembler statements the executable.
2975 The actual order in the program will depend on the linker command
2976 line. Static variables marked like this are also not removed.
2977 This has a similar effect
2978 as the @option{-fno-toplevel-reorder} option, but only applies to the
2981 @item no_sanitize ("@var{sanitize_option}")
2982 @cindex @code{no_sanitize} function attribute
2983 The @code{no_sanitize} attribute on functions is used
2984 to inform the compiler that it should not do sanitization of all options
2985 mentioned in @var{sanitize_option}. A list of values acceptable by
2986 @option{-fsanitize} option can be provided.
2989 void __attribute__ ((no_sanitize ("alignment", "object-size")))
2990 f () @{ /* @r{Do something.} */; @}
2991 void __attribute__ ((no_sanitize ("alignment,object-size")))
2992 g () @{ /* @r{Do something.} */; @}
2995 @item no_sanitize_address
2996 @itemx no_address_safety_analysis
2997 @cindex @code{no_sanitize_address} function attribute
2998 The @code{no_sanitize_address} attribute on functions is used
2999 to inform the compiler that it should not instrument memory accesses
3000 in the function when compiling with the @option{-fsanitize=address} option.
3001 The @code{no_address_safety_analysis} is a deprecated alias of the
3002 @code{no_sanitize_address} attribute, new code should use
3003 @code{no_sanitize_address}.
3005 @item no_sanitize_thread
3006 @cindex @code{no_sanitize_thread} function attribute
3007 The @code{no_sanitize_thread} attribute on functions is used
3008 to inform the compiler that it should not instrument memory accesses
3009 in the function when compiling with the @option{-fsanitize=thread} option.
3011 @item no_sanitize_undefined
3012 @cindex @code{no_sanitize_undefined} function attribute
3013 The @code{no_sanitize_undefined} attribute on functions is used
3014 to inform the compiler that it should not check for undefined behavior
3015 in the function when compiling with the @option{-fsanitize=undefined} option.
3017 @item no_split_stack
3018 @cindex @code{no_split_stack} function attribute
3019 @opindex fsplit-stack
3020 If @option{-fsplit-stack} is given, functions have a small
3021 prologue which decides whether to split the stack. Functions with the
3022 @code{no_split_stack} attribute do not have that prologue, and thus
3023 may run with only a small amount of stack space available.
3025 @item no_stack_limit
3026 @cindex @code{no_stack_limit} function attribute
3027 This attribute locally overrides the @option{-fstack-limit-register}
3028 and @option{-fstack-limit-symbol} command-line options; it has the effect
3029 of disabling stack limit checking in the function it applies to.
3032 @cindex @code{noclone} function attribute
3033 This function attribute prevents a function from being considered for
3034 cloning---a mechanism that produces specialized copies of functions
3035 and which is (currently) performed by interprocedural constant
3039 @cindex @code{noinline} function attribute
3040 This function attribute prevents a function from being considered for
3042 @c Don't enumerate the optimizations by name here; we try to be
3043 @c future-compatible with this mechanism.
3044 If the function does not have side effects, there are optimizations
3045 other than inlining that cause function calls to be optimized away,
3046 although the function call is live. To keep such calls from being
3053 (@pxref{Extended Asm}) in the called function, to serve as a special
3057 @cindex @code{noipa} function attribute
3058 Disable interprocedural optimizations between the function with this
3059 attribute and its callers, as if the body of the function is not available
3060 when optimizing callers and the callers are unavailable when optimizing
3061 the body. This attribute implies @code{noinline}, @code{noclone} and
3062 @code{no_icf} attributes. However, this attribute is not equivalent
3063 to a combination of other attributes, because its purpose is to suppress
3064 existing and future optimizations employing interprocedural analysis,
3065 including those that do not have an attribute suitable for disabling
3066 them individually. This attribute is supported mainly for the purpose
3067 of testing the compiler.
3069 @item nonnull (@var{arg-index}, @dots{})
3070 @cindex @code{nonnull} function attribute
3071 @cindex functions with non-null pointer arguments
3072 The @code{nonnull} attribute specifies that some function parameters should
3073 be non-null pointers. For instance, the declaration:
3077 my_memcpy (void *dest, const void *src, size_t len)
3078 __attribute__((nonnull (1, 2)));
3082 causes the compiler to check that, in calls to @code{my_memcpy},
3083 arguments @var{dest} and @var{src} are non-null. If the compiler
3084 determines that a null pointer is passed in an argument slot marked
3085 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3086 is issued. The compiler may also choose to make optimizations based
3087 on the knowledge that certain function arguments will never be null.
3089 If no argument index list is given to the @code{nonnull} attribute,
3090 all pointer arguments are marked as non-null. To illustrate, the
3091 following declaration is equivalent to the previous example:
3095 my_memcpy (void *dest, const void *src, size_t len)
3096 __attribute__((nonnull));
3100 @cindex @code{noplt} function attribute
3101 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3102 Calls to functions marked with this attribute in position-independent code
3107 /* Externally defined function foo. */
3108 int foo () __attribute__ ((noplt));
3111 main (/* @r{@dots{}} */)
3120 The @code{noplt} attribute on function @code{foo}
3121 tells the compiler to assume that
3122 the function @code{foo} is externally defined and that the call to
3123 @code{foo} must avoid the PLT
3124 in position-independent code.
3126 In position-dependent code, a few targets also convert calls to
3127 functions that are marked to not use the PLT to use the GOT instead.
3130 @cindex @code{noreturn} function attribute
3131 @cindex functions that never return
3132 A few standard library functions, such as @code{abort} and @code{exit},
3133 cannot return. GCC knows this automatically. Some programs define
3134 their own functions that never return. You can declare them
3135 @code{noreturn} to tell the compiler this fact. For example,
3139 void fatal () __attribute__ ((noreturn));
3142 fatal (/* @r{@dots{}} */)
3144 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3150 The @code{noreturn} keyword tells the compiler to assume that
3151 @code{fatal} cannot return. It can then optimize without regard to what
3152 would happen if @code{fatal} ever did return. This makes slightly
3153 better code. More importantly, it helps avoid spurious warnings of
3154 uninitialized variables.
3156 The @code{noreturn} keyword does not affect the exceptional path when that
3157 applies: a @code{noreturn}-marked function may still return to the caller
3158 by throwing an exception or calling @code{longjmp}.
3160 Do not assume that registers saved by the calling function are
3161 restored before calling the @code{noreturn} function.
3163 It does not make sense for a @code{noreturn} function to have a return
3164 type other than @code{void}.
3167 @cindex @code{nothrow} function attribute
3168 The @code{nothrow} attribute is used to inform the compiler that a
3169 function cannot throw an exception. For example, most functions in
3170 the standard C library can be guaranteed not to throw an exception
3171 with the notable exceptions of @code{qsort} and @code{bsearch} that
3172 take function pointer arguments.
3175 @cindex @code{optimize} function attribute
3176 The @code{optimize} attribute is used to specify that a function is to
3177 be compiled with different optimization options than specified on the
3178 command line. Arguments can either be numbers or strings. Numbers
3179 are assumed to be an optimization level. Strings that begin with
3180 @code{O} are assumed to be an optimization option, while other options
3181 are assumed to be used with a @code{-f} prefix. You can also use the
3182 @samp{#pragma GCC optimize} pragma to set the optimization options
3183 that affect more than one function.
3184 @xref{Function Specific Option Pragmas}, for details about the
3185 @samp{#pragma GCC optimize} pragma.
3187 This attribute should be used for debugging purposes only. It is not
3188 suitable in production code.
3190 @item patchable_function_entry
3191 @cindex @code{patchable_function_entry} function attribute
3192 @cindex extra NOP instructions at the function entry point
3193 In case the target's text segment can be made writable at run time by
3194 any means, padding the function entry with a number of NOPs can be
3195 used to provide a universal tool for instrumentation.
3197 The @code{patchable_function_entry} function attribute can be used to
3198 change the number of NOPs to any desired value. The two-value syntax
3199 is the same as for the command-line switch
3200 @option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with
3201 the function entry point before the @var{M}th NOP instruction.
3202 @var{M} defaults to 0 if omitted e.g. function entry point is before
3205 If patchable function entries are enabled globally using the command-line
3206 option @option{-fpatchable-function-entry=N,M}, then you must disable
3207 instrumentation on all functions that are part of the instrumentation
3208 framework with the attribute @code{patchable_function_entry (0)}
3209 to prevent recursion.
3212 @cindex @code{pure} function attribute
3213 @cindex functions that have no side effects
3214 Many functions have no effects except the return value and their
3215 return value depends only on the parameters and/or global variables.
3216 Calls to such functions can be subject
3217 to common subexpression elimination and loop optimization just as an
3218 arithmetic operator would be. These functions should be declared
3219 with the attribute @code{pure}. For example,
3222 int square (int) __attribute__ ((pure));
3226 says that the hypothetical function @code{square} is safe to call
3227 fewer times than the program says.
3229 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3230 Interesting non-pure functions are functions with infinite loops or those
3231 depending on volatile memory or other system resource, that may change between
3232 two consecutive calls (such as @code{feof} in a multithreading environment).
3234 The @code{pure} attribute imposes similar but looser restrictions on
3235 a function's defintion than the @code{const} attribute: it allows the
3236 function to read global variables. Decorating the same function with
3237 both the @code{pure} and the @code{const} attribute is diagnosed.
3238 Because a @code{pure} function cannot have any side effects it does not
3239 make sense for such a function to return @code{void}. Declaring such
3240 a function is diagnosed.
3242 @item returns_nonnull
3243 @cindex @code{returns_nonnull} function attribute
3244 The @code{returns_nonnull} attribute specifies that the function
3245 return value should be a non-null pointer. For instance, the declaration:
3249 mymalloc (size_t len) __attribute__((returns_nonnull));
3253 lets the compiler optimize callers based on the knowledge
3254 that the return value will never be null.
3257 @cindex @code{returns_twice} function attribute
3258 @cindex functions that return more than once
3259 The @code{returns_twice} attribute tells the compiler that a function may
3260 return more than one time. The compiler ensures that all registers
3261 are dead before calling such a function and emits a warning about
3262 the variables that may be clobbered after the second return from the
3263 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3264 The @code{longjmp}-like counterpart of such function, if any, might need
3265 to be marked with the @code{noreturn} attribute.
3267 @item section ("@var{section-name}")
3268 @cindex @code{section} function attribute
3269 @cindex functions in arbitrary sections
3270 Normally, the compiler places the code it generates in the @code{text} section.
3271 Sometimes, however, you need additional sections, or you need certain
3272 particular functions to appear in special sections. The @code{section}
3273 attribute specifies that a function lives in a particular section.
3274 For example, the declaration:
3277 extern void foobar (void) __attribute__ ((section ("bar")));
3281 puts the function @code{foobar} in the @code{bar} section.
3283 Some file formats do not support arbitrary sections so the @code{section}
3284 attribute is not available on all platforms.
3285 If you need to map the entire contents of a module to a particular
3286 section, consider using the facilities of the linker instead.
3289 @cindex @code{sentinel} function attribute
3290 This function attribute ensures that a parameter in a function call is
3291 an explicit @code{NULL}. The attribute is only valid on variadic
3292 functions. By default, the sentinel is located at position zero, the
3293 last parameter of the function call. If an optional integer position
3294 argument P is supplied to the attribute, the sentinel must be located at
3295 position P counting backwards from the end of the argument list.
3298 __attribute__ ((sentinel))
3300 __attribute__ ((sentinel(0)))
3303 The attribute is automatically set with a position of 0 for the built-in
3304 functions @code{execl} and @code{execlp}. The built-in function
3305 @code{execle} has the attribute set with a position of 1.
3307 A valid @code{NULL} in this context is defined as zero with any pointer
3308 type. If your system defines the @code{NULL} macro with an integer type
3309 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3310 with a copy that redefines NULL appropriately.
3312 The warnings for missing or incorrect sentinels are enabled with
3316 @itemx simd("@var{mask}")
3317 @cindex @code{simd} function attribute
3318 This attribute enables creation of one or more function versions that
3319 can process multiple arguments using SIMD instructions from a
3320 single invocation. Specifying this attribute allows compiler to
3321 assume that such versions are available at link time (provided
3322 in the same or another translation unit). Generated versions are
3323 target-dependent and described in the corresponding Vector ABI document. For
3324 x86_64 target this document can be found
3325 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3327 The optional argument @var{mask} may have the value
3328 @code{notinbranch} or @code{inbranch},
3329 and instructs the compiler to generate non-masked or masked
3330 clones correspondingly. By default, all clones are generated.
3332 If the attribute is specified and @code{#pragma omp declare simd} is
3333 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3334 switch is specified, then the attribute is ignored.
3337 @cindex @code{stack_protect} function attribute
3338 This attribute adds stack protection code to the function if
3339 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3340 or @option{-fstack-protector-explicit} are set.
3342 @item target (@var{options})
3343 @cindex @code{target} function attribute
3344 Multiple target back ends implement the @code{target} attribute
3345 to specify that a function is to
3346 be compiled with different target options than specified on the
3347 command line. This can be used for instance to have functions
3348 compiled with a different ISA (instruction set architecture) than the
3349 default. You can also use the @samp{#pragma GCC target} pragma to set
3350 more than one function to be compiled with specific target options.
3351 @xref{Function Specific Option Pragmas}, for details about the
3352 @samp{#pragma GCC target} pragma.
3354 For instance, on an x86, you could declare one function with the
3355 @code{target("sse4.1,arch=core2")} attribute and another with
3356 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3357 compiling the first function with @option{-msse4.1} and
3358 @option{-march=core2} options, and the second function with
3359 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3360 to make sure that a function is only invoked on a machine that
3361 supports the particular ISA it is compiled for (for example by using
3362 @code{cpuid} on x86 to determine what feature bits and architecture
3366 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3367 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3370 You can either use multiple
3371 strings separated by commas to specify multiple options,
3372 or separate the options with a comma (@samp{,}) within a single string.
3374 The options supported are specific to each target; refer to @ref{x86
3375 Function Attributes}, @ref{PowerPC Function Attributes},
3376 @ref{ARM Function Attributes}, @ref{AArch64 Function Attributes},
3377 @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
3380 @item target_clones (@var{options})
3381 @cindex @code{target_clones} function attribute
3382 The @code{target_clones} attribute is used to specify that a function
3383 be cloned into multiple versions compiled with different target options
3384 than specified on the command line. The supported options and restrictions
3385 are the same as for @code{target} attribute.
3387 For instance, on an x86, you could compile a function with
3388 @code{target_clones("sse4.1,avx")}. GCC creates two function clones,
3389 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3391 On a PowerPC, you can compile a function with
3392 @code{target_clones("cpu=power9,default")}. GCC will create two
3393 function clones, one compiled with @option{-mcpu=power9} and another
3394 with the default options. GCC must be configured to use GLIBC 2.23 or
3395 newer in order to use the @code{target_clones} attribute.
3397 It also creates a resolver function (see
3398 the @code{ifunc} attribute above) that dynamically selects a clone
3399 suitable for current architecture. The resolver is created only if there
3400 is a usage of a function with @code{target_clones} attribute.
3403 @cindex @code{unused} function attribute
3404 This attribute, attached to a function, means that the function is meant
3405 to be possibly unused. GCC does not produce a warning for this
3409 @cindex @code{used} function attribute
3410 This attribute, attached to a function, means that code must be emitted
3411 for the function even if it appears that the function is not referenced.
3412 This is useful, for example, when the function is referenced only in
3415 When applied to a member function of a C++ class template, the
3416 attribute also means that the function is instantiated if the
3417 class itself is instantiated.
3419 @item visibility ("@var{visibility_type}")
3420 @cindex @code{visibility} function attribute
3421 This attribute affects the linkage of the declaration to which it is attached.
3422 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3423 (@pxref{Common Type Attributes}) as well as functions.
3425 There are four supported @var{visibility_type} values: default,
3426 hidden, protected or internal visibility.
3429 void __attribute__ ((visibility ("protected")))
3430 f () @{ /* @r{Do something.} */; @}
3431 int i __attribute__ ((visibility ("hidden")));
3434 The possible values of @var{visibility_type} correspond to the
3435 visibility settings in the ELF gABI.
3438 @c keep this list of visibilities in alphabetical order.
3441 Default visibility is the normal case for the object file format.
3442 This value is available for the visibility attribute to override other
3443 options that may change the assumed visibility of entities.
3445 On ELF, default visibility means that the declaration is visible to other
3446 modules and, in shared libraries, means that the declared entity may be
3449 On Darwin, default visibility means that the declaration is visible to
3452 Default visibility corresponds to ``external linkage'' in the language.
3455 Hidden visibility indicates that the entity declared has a new
3456 form of linkage, which we call ``hidden linkage''. Two
3457 declarations of an object with hidden linkage refer to the same object
3458 if they are in the same shared object.
3461 Internal visibility is like hidden visibility, but with additional
3462 processor specific semantics. Unless otherwise specified by the
3463 psABI, GCC defines internal visibility to mean that a function is
3464 @emph{never} called from another module. Compare this with hidden
3465 functions which, while they cannot be referenced directly by other
3466 modules, can be referenced indirectly via function pointers. By
3467 indicating that a function cannot be called from outside the module,
3468 GCC may for instance omit the load of a PIC register since it is known
3469 that the calling function loaded the correct value.
3472 Protected visibility is like default visibility except that it
3473 indicates that references within the defining module bind to the
3474 definition in that module. That is, the declared entity cannot be
3475 overridden by another module.
3479 All visibilities are supported on many, but not all, ELF targets
3480 (supported when the assembler supports the @samp{.visibility}
3481 pseudo-op). Default visibility is supported everywhere. Hidden
3482 visibility is supported on Darwin targets.
3484 The visibility attribute should be applied only to declarations that
3485 would otherwise have external linkage. The attribute should be applied
3486 consistently, so that the same entity should not be declared with
3487 different settings of the attribute.
3489 In C++, the visibility attribute applies to types as well as functions
3490 and objects, because in C++ types have linkage. A class must not have
3491 greater visibility than its non-static data member types and bases,
3492 and class members default to the visibility of their class. Also, a
3493 declaration without explicit visibility is limited to the visibility
3496 In C++, you can mark member functions and static member variables of a
3497 class with the visibility attribute. This is useful if you know a
3498 particular method or static member variable should only be used from
3499 one shared object; then you can mark it hidden while the rest of the
3500 class has default visibility. Care must be taken to avoid breaking
3501 the One Definition Rule; for example, it is usually not useful to mark
3502 an inline method as hidden without marking the whole class as hidden.
3504 A C++ namespace declaration can also have the visibility attribute.
3507 namespace nspace1 __attribute__ ((visibility ("protected")))
3508 @{ /* @r{Do something.} */; @}
3511 This attribute applies only to the particular namespace body, not to
3512 other definitions of the same namespace; it is equivalent to using
3513 @samp{#pragma GCC visibility} before and after the namespace
3514 definition (@pxref{Visibility Pragmas}).
3516 In C++, if a template argument has limited visibility, this
3517 restriction is implicitly propagated to the template instantiation.
3518 Otherwise, template instantiations and specializations default to the
3519 visibility of their template.
3521 If both the template and enclosing class have explicit visibility, the
3522 visibility from the template is used.
3524 @item warn_unused_result
3525 @cindex @code{warn_unused_result} function attribute
3526 The @code{warn_unused_result} attribute causes a warning to be emitted
3527 if a caller of the function with this attribute does not use its
3528 return value. This is useful for functions where not checking
3529 the result is either a security problem or always a bug, such as
3533 int fn () __attribute__ ((warn_unused_result));
3536 if (fn () < 0) return -1;
3543 results in warning on line 5.
3546 @cindex @code{weak} function attribute
3547 The @code{weak} attribute causes the declaration to be emitted as a weak
3548 symbol rather than a global. This is primarily useful in defining
3549 library functions that can be overridden in user code, though it can
3550 also be used with non-function declarations. Weak symbols are supported
3551 for ELF targets, and also for a.out targets when using the GNU assembler
3555 @itemx weakref ("@var{target}")
3556 @cindex @code{weakref} function attribute
3557 The @code{weakref} attribute marks a declaration as a weak reference.
3558 Without arguments, it should be accompanied by an @code{alias} attribute
3559 naming the target symbol. Optionally, the @var{target} may be given as
3560 an argument to @code{weakref} itself. In either case, @code{weakref}
3561 implicitly marks the declaration as @code{weak}. Without a
3562 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3563 @code{weakref} is equivalent to @code{weak}.
3566 static int x() __attribute__ ((weakref ("y")));
3567 /* is equivalent to... */
3568 static int x() __attribute__ ((weak, weakref, alias ("y")));
3570 static int x() __attribute__ ((weakref));
3571 static int x() __attribute__ ((alias ("y")));
3574 A weak reference is an alias that does not by itself require a
3575 definition to be given for the target symbol. If the target symbol is
3576 only referenced through weak references, then it becomes a @code{weak}
3577 undefined symbol. If it is directly referenced, however, then such
3578 strong references prevail, and a definition is required for the
3579 symbol, not necessarily in the same translation unit.
3581 The effect is equivalent to moving all references to the alias to a
3582 separate translation unit, renaming the alias to the aliased symbol,
3583 declaring it as weak, compiling the two separate translation units and
3584 performing a reloadable link on them.
3586 At present, a declaration to which @code{weakref} is attached can
3587 only be @code{static}.
3592 @c This is the end of the target-independent attribute table
3594 @node AArch64 Function Attributes
3595 @subsection AArch64 Function Attributes
3597 The following target-specific function attributes are available for the
3598 AArch64 target. For the most part, these options mirror the behavior of
3599 similar command-line options (@pxref{AArch64 Options}), but on a
3603 @item general-regs-only
3604 @cindex @code{general-regs-only} function attribute, AArch64
3605 Indicates that no floating-point or Advanced SIMD registers should be
3606 used when generating code for this function. If the function explicitly
3607 uses floating-point code, then the compiler gives an error. This is
3608 the same behavior as that of the command-line option
3609 @option{-mgeneral-regs-only}.
3611 @item fix-cortex-a53-835769
3612 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3613 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3614 applied to this function. To explicitly disable the workaround for this
3615 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3616 This corresponds to the behavior of the command line options
3617 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3620 @cindex @code{cmodel=} function attribute, AArch64
3621 Indicates that code should be generated for a particular code model for
3622 this function. The behavior and permissible arguments are the same as
3623 for the command line option @option{-mcmodel=}.
3626 @itemx no-strict-align
3627 @cindex @code{strict-align} function attribute, AArch64
3628 @code{strict-align} indicates that the compiler should not assume that unaligned
3629 memory references are handled by the system. To allow the compiler to assume
3630 that aligned memory references are handled by the system, the inverse attribute
3631 @code{no-strict-align} can be specified. The behavior is same as for the
3632 command-line option @option{-mstrict-align} and @option{-mno-strict-align}.
3634 @item omit-leaf-frame-pointer
3635 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3636 Indicates that the frame pointer should be omitted for a leaf function call.
3637 To keep the frame pointer, the inverse attribute
3638 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3639 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3640 and @option{-mno-omit-leaf-frame-pointer}.
3643 @cindex @code{tls-dialect=} function attribute, AArch64
3644 Specifies the TLS dialect to use for this function. The behavior and
3645 permissible arguments are the same as for the command-line option
3646 @option{-mtls-dialect=}.
3649 @cindex @code{arch=} function attribute, AArch64
3650 Specifies the architecture version and architectural extensions to use
3651 for this function. The behavior and permissible arguments are the same as
3652 for the @option{-march=} command-line option.
3655 @cindex @code{tune=} function attribute, AArch64
3656 Specifies the core for which to tune the performance of this function.
3657 The behavior and permissible arguments are the same as for the @option{-mtune=}
3658 command-line option.
3661 @cindex @code{cpu=} function attribute, AArch64
3662 Specifies the core for which to tune the performance of this function and also
3663 whose architectural features to use. The behavior and valid arguments are the
3664 same as for the @option{-mcpu=} command-line option.
3666 @item sign-return-address
3667 @cindex @code{sign-return-address} function attribute, AArch64
3668 Select the function scope on which return address signing will be applied. The
3669 behavior and permissible arguments are the same as for the command-line option
3670 @option{-msign-return-address=}. The default value is @code{none}.
3674 The above target attributes can be specified as follows:
3677 __attribute__((target("@var{attr-string}")))
3685 where @code{@var{attr-string}} is one of the attribute strings specified above.
3687 Additionally, the architectural extension string may be specified on its
3688 own. This can be used to turn on and off particular architectural extensions
3689 without having to specify a particular architecture version or core. Example:
3692 __attribute__((target("+crc+nocrypto")))
3700 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3701 extension and disables the @code{crypto} extension for the function @code{foo}
3702 without modifying an existing @option{-march=} or @option{-mcpu} option.
3704 Multiple target function attributes can be specified by separating them with
3705 a comma. For example:
3707 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3715 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3716 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3718 @subsubsection Inlining rules
3719 Specifying target attributes on individual functions or performing link-time
3720 optimization across translation units compiled with different target options
3721 can affect function inlining rules:
3723 In particular, a caller function can inline a callee function only if the
3724 architectural features available to the callee are a subset of the features
3725 available to the caller.
3726 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3727 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3728 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3729 because the all the architectural features that function @code{bar} requires
3730 are available to function @code{foo}. Conversely, function @code{bar} cannot
3731 inline function @code{foo}.
3733 Additionally inlining a function compiled with @option{-mstrict-align} into a
3734 function compiled without @code{-mstrict-align} is not allowed.
3735 However, inlining a function compiled without @option{-mstrict-align} into a
3736 function compiled with @option{-mstrict-align} is allowed.
3738 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3739 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3740 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3741 architectural feature rules specified above.
3743 @node ARC Function Attributes
3744 @subsection ARC Function Attributes
3746 These function attributes are supported by the ARC back end:
3750 @cindex @code{interrupt} function attribute, ARC
3751 Use this attribute to indicate
3752 that the specified function is an interrupt handler. The compiler generates
3753 function entry and exit sequences suitable for use in an interrupt handler
3754 when this attribute is present.
3756 On the ARC, you must specify the kind of interrupt to be handled
3757 in a parameter to the interrupt attribute like this:
3760 void f () __attribute__ ((interrupt ("ilink1")));
3763 Permissible values for this parameter are: @w{@code{ilink1}} and
3769 @cindex @code{long_call} function attribute, ARC
3770 @cindex @code{medium_call} function attribute, ARC
3771 @cindex @code{short_call} function attribute, ARC
3772 @cindex indirect calls, ARC
3773 These attributes specify how a particular function is called.
3774 These attributes override the
3775 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3776 command-line switches and @code{#pragma long_calls} settings.
3778 For ARC, a function marked with the @code{long_call} attribute is
3779 always called using register-indirect jump-and-link instructions,
3780 thereby enabling the called function to be placed anywhere within the
3781 32-bit address space. A function marked with the @code{medium_call}
3782 attribute will always be close enough to be called with an unconditional
3783 branch-and-link instruction, which has a 25-bit offset from
3784 the call site. A function marked with the @code{short_call}
3785 attribute will always be close enough to be called with a conditional
3786 branch-and-link instruction, which has a 21-bit offset from
3790 @cindex @code{jli_always} function attribute, ARC
3791 Forces a particular function to be called using @code{jli}
3792 instruction. The @code{jli} instruction makes use of a table stored
3793 into @code{.jlitab} section, which holds the location of the functions
3794 which are addressed using this instruction.
3797 @cindex @code{jli_fixed} function attribute, ARC
3798 Identical like the above one, but the location of the function in the
3799 @code{jli} table is known and given as an attribute parameter.
3802 @cindex @code{secure_call} function attribute, ARC
3803 This attribute allows one to mark secure-code functions that are
3804 callable from normal mode. The location of the secure call function
3805 into the @code{sjli} table needs to be passed as argument.
3809 @node ARM Function Attributes
3810 @subsection ARM Function Attributes
3812 These function attributes are supported for ARM targets:
3816 @cindex @code{interrupt} function attribute, ARM
3817 Use this attribute to indicate
3818 that the specified function is an interrupt handler. The compiler generates
3819 function entry and exit sequences suitable for use in an interrupt handler
3820 when this attribute is present.
3822 You can specify the kind of interrupt to be handled by
3823 adding an optional parameter to the interrupt attribute like this:
3826 void f () __attribute__ ((interrupt ("IRQ")));
3830 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3831 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3833 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3834 may be called with a word-aligned stack pointer.
3837 @cindex @code{isr} function attribute, ARM
3838 Use this attribute on ARM to write Interrupt Service Routines. This is an
3839 alias to the @code{interrupt} attribute above.
3843 @cindex @code{long_call} function attribute, ARM
3844 @cindex @code{short_call} function attribute, ARM
3845 @cindex indirect calls, ARM
3846 These attributes specify how a particular function is called.
3847 These attributes override the
3848 @option{-mlong-calls} (@pxref{ARM Options})
3849 command-line switch and @code{#pragma long_calls} settings. For ARM, the
3850 @code{long_call} attribute indicates that the function might be far
3851 away from the call site and require a different (more expensive)
3852 calling sequence. The @code{short_call} attribute always places
3853 the offset to the function from the call site into the @samp{BL}
3854 instruction directly.
3857 @cindex @code{naked} function attribute, ARM
3858 This attribute allows the compiler to construct the
3859 requisite function declaration, while allowing the body of the
3860 function to be assembly code. The specified function will not have
3861 prologue/epilogue sequences generated by the compiler. Only basic
3862 @code{asm} statements can safely be included in naked functions
3863 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3864 basic @code{asm} and C code may appear to work, they cannot be
3865 depended upon to work reliably and are not supported.
3868 @cindex @code{pcs} function attribute, ARM
3870 The @code{pcs} attribute can be used to control the calling convention
3871 used for a function on ARM. The attribute takes an argument that specifies
3872 the calling convention to use.
3874 When compiling using the AAPCS ABI (or a variant of it) then valid
3875 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3876 order to use a variant other than @code{"aapcs"} then the compiler must
3877 be permitted to use the appropriate co-processor registers (i.e., the
3878 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3882 /* Argument passed in r0, and result returned in r0+r1. */
3883 double f2d (float) __attribute__((pcs("aapcs")));
3886 Variadic functions always use the @code{"aapcs"} calling convention and
3887 the compiler rejects attempts to specify an alternative.
3889 @item target (@var{options})
3890 @cindex @code{target} function attribute
3891 As discussed in @ref{Common Function Attributes}, this attribute
3892 allows specification of target-specific compilation options.
3894 On ARM, the following options are allowed:
3898 @cindex @code{target("thumb")} function attribute, ARM
3899 Force code generation in the Thumb (T16/T32) ISA, depending on the
3903 @cindex @code{target("arm")} function attribute, ARM
3904 Force code generation in the ARM (A32) ISA.
3906 Functions from different modes can be inlined in the caller's mode.
3909 @cindex @code{target("fpu=")} function attribute, ARM
3910 Specifies the fpu for which to tune the performance of this function.
3911 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3912 command-line option.
3915 @cindex @code{arch=} function attribute, ARM
3916 Specifies the architecture version and architectural extensions to use
3917 for this function. The behavior and permissible arguments are the same as
3918 for the @option{-march=} command-line option.
3920 The above target attributes can be specified as follows:
3923 __attribute__((target("arch=armv8-a+crc")))
3931 Additionally, the architectural extension string may be specified on its
3932 own. This can be used to turn on and off particular architectural extensions
3933 without having to specify a particular architecture version or core. Example:
3936 __attribute__((target("+crc+nocrypto")))
3944 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3945 extension and disables the @code{crypto} extension for the function @code{foo}
3946 without modifying an existing @option{-march=} or @option{-mcpu} option.
3952 @node AVR Function Attributes
3953 @subsection AVR Function Attributes
3955 These function attributes are supported by the AVR back end:
3959 @cindex @code{interrupt} function attribute, AVR
3960 Use this attribute to indicate
3961 that the specified function is an interrupt handler. The compiler generates
3962 function entry and exit sequences suitable for use in an interrupt handler
3963 when this attribute is present.
3965 On the AVR, the hardware globally disables interrupts when an
3966 interrupt is executed. The first instruction of an interrupt handler
3967 declared with this attribute is a @code{SEI} instruction to
3968 re-enable interrupts. See also the @code{signal} function attribute
3969 that does not insert a @code{SEI} instruction. If both @code{signal} and
3970 @code{interrupt} are specified for the same function, @code{signal}
3971 is silently ignored.
3974 @cindex @code{naked} function attribute, AVR
3975 This attribute allows the compiler to construct the
3976 requisite function declaration, while allowing the body of the
3977 function to be assembly code. The specified function will not have
3978 prologue/epilogue sequences generated by the compiler. Only basic
3979 @code{asm} statements can safely be included in naked functions
3980 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3981 basic @code{asm} and C code may appear to work, they cannot be
3982 depended upon to work reliably and are not supported.
3985 @cindex @code{no_gccisr} function attribute, AVR
3986 Do not use @code{__gcc_isr} pseudo instructions in a function with
3987 the @code{interrupt} or @code{signal} attribute aka. interrupt
3988 service routine (ISR).
3989 Use this attribute if the preamble of the ISR prologue should always read
3993 in __tmp_reg__, __SREG__
3997 and accordingly for the postamble of the epilogue --- no matter whether
3998 the mentioned registers are actually used in the ISR or not.
3999 Situations where you might want to use this attribute include:
4002 Code that (effectively) clobbers bits of @code{SREG} other than the
4003 @code{I}-flag by writing to the memory location of @code{SREG}.
4005 Code that uses inline assembler to jump to a different function which
4006 expects (parts of) the prologue code as outlined above to be present.
4008 To disable @code{__gcc_isr} generation for the whole compilation unit,
4009 there is option @option{-mno-gas-isr-prologues}, @pxref{AVR Options}.
4013 @cindex @code{OS_main} function attribute, AVR
4014 @cindex @code{OS_task} function attribute, AVR
4015 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
4016 do not save/restore any call-saved register in their prologue/epilogue.
4018 The @code{OS_main} attribute can be used when there @emph{is
4019 guarantee} that interrupts are disabled at the time when the function
4020 is entered. This saves resources when the stack pointer has to be
4021 changed to set up a frame for local variables.
4023 The @code{OS_task} attribute can be used when there is @emph{no
4024 guarantee} that interrupts are disabled at that time when the function
4025 is entered like for, e@.g@. task functions in a multi-threading operating
4026 system. In that case, changing the stack pointer register is
4027 guarded by save/clear/restore of the global interrupt enable flag.
4029 The differences to the @code{naked} function attribute are:
4031 @item @code{naked} functions do not have a return instruction whereas
4032 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
4033 @code{RETI} return instruction.
4034 @item @code{naked} functions do not set up a frame for local variables
4035 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
4040 @cindex @code{signal} function attribute, AVR
4041 Use this attribute on the AVR to indicate that the specified
4042 function is an interrupt handler. The compiler generates function
4043 entry and exit sequences suitable for use in an interrupt handler when this
4044 attribute is present.
4046 See also the @code{interrupt} function attribute.
4048 The AVR hardware globally disables interrupts when an interrupt is executed.
4049 Interrupt handler functions defined with the @code{signal} attribute
4050 do not re-enable interrupts. It is save to enable interrupts in a
4051 @code{signal} handler. This ``save'' only applies to the code
4052 generated by the compiler and not to the IRQ layout of the
4053 application which is responsibility of the application.
4055 If both @code{signal} and @code{interrupt} are specified for the same
4056 function, @code{signal} is silently ignored.
4059 @node Blackfin Function Attributes
4060 @subsection Blackfin Function Attributes
4062 These function attributes are supported by the Blackfin back end:
4066 @item exception_handler
4067 @cindex @code{exception_handler} function attribute
4068 @cindex exception handler functions, Blackfin
4069 Use this attribute on the Blackfin to indicate that the specified function
4070 is an exception handler. The compiler generates function entry and
4071 exit sequences suitable for use in an exception handler when this
4072 attribute is present.
4074 @item interrupt_handler
4075 @cindex @code{interrupt_handler} function attribute, Blackfin
4076 Use this attribute to
4077 indicate that the specified function is an interrupt handler. The compiler
4078 generates function entry and exit sequences suitable for use in an
4079 interrupt handler when this attribute is present.
4082 @cindex @code{kspisusp} function attribute, Blackfin
4083 @cindex User stack pointer in interrupts on the Blackfin
4084 When used together with @code{interrupt_handler}, @code{exception_handler}
4085 or @code{nmi_handler}, code is generated to load the stack pointer
4086 from the USP register in the function prologue.
4089 @cindex @code{l1_text} function attribute, Blackfin
4090 This attribute specifies a function to be placed into L1 Instruction
4091 SRAM@. The function is put into a specific section named @code{.l1.text}.
4092 With @option{-mfdpic}, function calls with a such function as the callee
4093 or caller uses inlined PLT.
4096 @cindex @code{l2} function attribute, Blackfin
4097 This attribute specifies a function to be placed into L2
4098 SRAM. The function is put into a specific section named
4099 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
4104 @cindex indirect calls, Blackfin
4105 @cindex @code{longcall} function attribute, Blackfin
4106 @cindex @code{shortcall} function attribute, Blackfin
4107 The @code{longcall} attribute
4108 indicates that the function might be far away from the call site and
4109 require a different (more expensive) calling sequence. The
4110 @code{shortcall} attribute indicates that the function is always close
4111 enough for the shorter calling sequence to be used. These attributes
4112 override the @option{-mlongcall} switch.
4115 @cindex @code{nesting} function attribute, Blackfin
4116 @cindex Allow nesting in an interrupt handler on the Blackfin processor
4117 Use this attribute together with @code{interrupt_handler},
4118 @code{exception_handler} or @code{nmi_handler} to indicate that the function
4119 entry code should enable nested interrupts or exceptions.
4122 @cindex @code{nmi_handler} function attribute, Blackfin
4123 @cindex NMI handler functions on the Blackfin processor
4124 Use this attribute on the Blackfin to indicate that the specified function
4125 is an NMI handler. The compiler generates function entry and
4126 exit sequences suitable for use in an NMI handler when this
4127 attribute is present.
4130 @cindex @code{saveall} function attribute, Blackfin
4131 @cindex save all registers on the Blackfin
4132 Use this attribute to indicate that
4133 all registers except the stack pointer should be saved in the prologue
4134 regardless of whether they are used or not.
4137 @node CR16 Function Attributes
4138 @subsection CR16 Function Attributes
4140 These function attributes are supported by the CR16 back end:
4144 @cindex @code{interrupt} function attribute, CR16
4145 Use this attribute to indicate
4146 that the specified function is an interrupt handler. The compiler generates
4147 function entry and exit sequences suitable for use in an interrupt handler
4148 when this attribute is present.
4151 @node C-SKY Function Attributes
4152 @subsection C-SKY Function Attributes
4154 These function attributes are supported by the C-SKY back end:
4159 @cindex @code{interrupt} function attribute, C-SKY
4160 @cindex @code{isr} function attribute, C-SKY
4161 Use these attributes to indicate that the specified function
4162 is an interrupt handler.
4163 The compiler generates function entry and exit sequences suitable for
4164 use in an interrupt handler when either of these attributes are present.
4166 Use of these options requires the @option{-mistack} command-line option
4167 to enable support for the necessary interrupt stack instructions. They
4168 are ignored with a warning otherwise. @xref{C-SKY Options}.
4171 @cindex @code{naked} function attribute, C-SKY
4172 This attribute allows the compiler to construct the
4173 requisite function declaration, while allowing the body of the
4174 function to be assembly code. The specified function will not have
4175 prologue/epilogue sequences generated by the compiler. Only basic
4176 @code{asm} statements can safely be included in naked functions
4177 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4178 basic @code{asm} and C code may appear to work, they cannot be
4179 depended upon to work reliably and are not supported.
4183 @node Epiphany Function Attributes
4184 @subsection Epiphany Function Attributes
4186 These function attributes are supported by the Epiphany back end:
4190 @cindex @code{disinterrupt} function attribute, Epiphany
4191 This attribute causes the compiler to emit
4192 instructions to disable interrupts for the duration of the given
4195 @item forwarder_section
4196 @cindex @code{forwarder_section} function attribute, Epiphany
4197 This attribute modifies the behavior of an interrupt handler.
4198 The interrupt handler may be in external memory which cannot be
4199 reached by a branch instruction, so generate a local memory trampoline
4200 to transfer control. The single parameter identifies the section where
4201 the trampoline is placed.
4204 @cindex @code{interrupt} function attribute, Epiphany
4205 Use this attribute to indicate
4206 that the specified function is an interrupt handler. The compiler generates
4207 function entry and exit sequences suitable for use in an interrupt handler
4208 when this attribute is present. It may also generate
4209 a special section with code to initialize the interrupt vector table.
4211 On Epiphany targets one or more optional parameters can be added like this:
4214 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
4217 Permissible values for these parameters are: @w{@code{reset}},
4218 @w{@code{software_exception}}, @w{@code{page_miss}},
4219 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
4220 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
4221 Multiple parameters indicate that multiple entries in the interrupt
4222 vector table should be initialized for this function, i.e.@: for each
4223 parameter @w{@var{name}}, a jump to the function is emitted in
4224 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
4225 entirely, in which case no interrupt vector table entry is provided.
4227 Note that interrupts are enabled inside the function
4228 unless the @code{disinterrupt} attribute is also specified.
4230 The following examples are all valid uses of these attributes on
4233 void __attribute__ ((interrupt)) universal_handler ();
4234 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
4235 void __attribute__ ((interrupt ("dma0, dma1")))
4236 universal_dma_handler ();
4237 void __attribute__ ((interrupt ("timer0"), disinterrupt))
4238 fast_timer_handler ();
4239 void __attribute__ ((interrupt ("dma0, dma1"),
4240 forwarder_section ("tramp")))
4241 external_dma_handler ();
4246 @cindex @code{long_call} function attribute, Epiphany
4247 @cindex @code{short_call} function attribute, Epiphany
4248 @cindex indirect calls, Epiphany
4249 These attributes specify how a particular function is called.
4250 These attributes override the
4251 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4252 command-line switch and @code{#pragma long_calls} settings.
4256 @node H8/300 Function Attributes
4257 @subsection H8/300 Function Attributes
4259 These function attributes are available for H8/300 targets:
4262 @item function_vector
4263 @cindex @code{function_vector} function attribute, H8/300
4264 Use this attribute on the H8/300, H8/300H, and H8S to indicate
4265 that the specified function should be called through the function vector.
4266 Calling a function through the function vector reduces code size; however,
4267 the function vector has a limited size (maximum 128 entries on the H8/300
4268 and 64 entries on the H8/300H and H8S)
4269 and shares space with the interrupt vector.
4271 @item interrupt_handler
4272 @cindex @code{interrupt_handler} function attribute, H8/300
4273 Use this attribute on the H8/300, H8/300H, and H8S to
4274 indicate that the specified function is an interrupt handler. The compiler
4275 generates function entry and exit sequences suitable for use in an
4276 interrupt handler when this attribute is present.
4279 @cindex @code{saveall} function attribute, H8/300
4280 @cindex save all registers on the H8/300, H8/300H, and H8S
4281 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4282 all registers except the stack pointer should be saved in the prologue
4283 regardless of whether they are used or not.
4286 @node IA-64 Function Attributes
4287 @subsection IA-64 Function Attributes
4289 These function attributes are supported on IA-64 targets:
4292 @item syscall_linkage
4293 @cindex @code{syscall_linkage} function attribute, IA-64
4294 This attribute is used to modify the IA-64 calling convention by marking
4295 all input registers as live at all function exits. This makes it possible
4296 to restart a system call after an interrupt without having to save/restore
4297 the input registers. This also prevents kernel data from leaking into
4301 @cindex @code{version_id} function attribute, IA-64
4302 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4303 symbol to contain a version string, thus allowing for function level
4304 versioning. HP-UX system header files may use function level versioning
4305 for some system calls.
4308 extern int foo () __attribute__((version_id ("20040821")));
4312 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4315 @node M32C Function Attributes
4316 @subsection M32C Function Attributes
4318 These function attributes are supported by the M32C back end:
4322 @cindex @code{bank_switch} function attribute, M32C
4323 When added to an interrupt handler with the M32C port, causes the
4324 prologue and epilogue to use bank switching to preserve the registers
4325 rather than saving them on the stack.
4327 @item fast_interrupt
4328 @cindex @code{fast_interrupt} function attribute, M32C
4329 Use this attribute on the M32C port to indicate that the specified
4330 function is a fast interrupt handler. This is just like the
4331 @code{interrupt} attribute, except that @code{freit} is used to return
4332 instead of @code{reit}.
4334 @item function_vector
4335 @cindex @code{function_vector} function attribute, M16C/M32C
4336 On M16C/M32C targets, the @code{function_vector} attribute declares a
4337 special page subroutine call function. Use of this attribute reduces
4338 the code size by 2 bytes for each call generated to the
4339 subroutine. The argument to the attribute is the vector number entry
4340 from the special page vector table which contains the 16 low-order
4341 bits of the subroutine's entry address. Each vector table has special
4342 page number (18 to 255) that is used in @code{jsrs} instructions.
4343 Jump addresses of the routines are generated by adding 0x0F0000 (in
4344 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4345 2-byte addresses set in the vector table. Therefore you need to ensure
4346 that all the special page vector routines should get mapped within the
4347 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4350 In the following example 2 bytes are saved for each call to
4351 function @code{foo}.
4354 void foo (void) __attribute__((function_vector(0x18)));
4365 If functions are defined in one file and are called in another file,
4366 then be sure to write this declaration in both files.
4368 This attribute is ignored for R8C target.
4371 @cindex @code{interrupt} function attribute, M32C
4372 Use this attribute to indicate
4373 that the specified function is an interrupt handler. The compiler generates
4374 function entry and exit sequences suitable for use in an interrupt handler
4375 when this attribute is present.
4378 @node M32R/D Function Attributes
4379 @subsection M32R/D Function Attributes
4381 These function attributes are supported by the M32R/D back end:
4385 @cindex @code{interrupt} function attribute, M32R/D
4386 Use this attribute to indicate
4387 that the specified function is an interrupt handler. The compiler generates
4388 function entry and exit sequences suitable for use in an interrupt handler
4389 when this attribute is present.
4391 @item model (@var{model-name})
4392 @cindex @code{model} function attribute, M32R/D
4393 @cindex function addressability on the M32R/D
4395 On the M32R/D, use this attribute to set the addressability of an
4396 object, and of the code generated for a function. The identifier
4397 @var{model-name} is one of @code{small}, @code{medium}, or
4398 @code{large}, representing each of the code models.
4400 Small model objects live in the lower 16MB of memory (so that their
4401 addresses can be loaded with the @code{ld24} instruction), and are
4402 callable with the @code{bl} instruction.
4404 Medium model objects may live anywhere in the 32-bit address space (the
4405 compiler generates @code{seth/add3} instructions to load their addresses),
4406 and are callable with the @code{bl} instruction.
4408 Large model objects may live anywhere in the 32-bit address space (the
4409 compiler generates @code{seth/add3} instructions to load their addresses),
4410 and may not be reachable with the @code{bl} instruction (the compiler
4411 generates the much slower @code{seth/add3/jl} instruction sequence).
4414 @node m68k Function Attributes
4415 @subsection m68k Function Attributes
4417 These function attributes are supported by the m68k back end:
4421 @itemx interrupt_handler
4422 @cindex @code{interrupt} function attribute, m68k
4423 @cindex @code{interrupt_handler} function attribute, m68k
4424 Use this attribute to
4425 indicate that the specified function is an interrupt handler. The compiler
4426 generates function entry and exit sequences suitable for use in an
4427 interrupt handler when this attribute is present. Either name may be used.
4429 @item interrupt_thread
4430 @cindex @code{interrupt_thread} function attribute, fido
4431 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4432 that the specified function is an interrupt handler that is designed
4433 to run as a thread. The compiler omits generate prologue/epilogue
4434 sequences and replaces the return instruction with a @code{sleep}
4435 instruction. This attribute is available only on fido.
4438 @node MCORE Function Attributes
4439 @subsection MCORE Function Attributes
4441 These function attributes are supported by the MCORE back end:
4445 @cindex @code{naked} function attribute, MCORE
4446 This attribute allows the compiler to construct the
4447 requisite function declaration, while allowing the body of the
4448 function to be assembly code. The specified function will not have
4449 prologue/epilogue sequences generated by the compiler. Only basic
4450 @code{asm} statements can safely be included in naked functions
4451 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4452 basic @code{asm} and C code may appear to work, they cannot be
4453 depended upon to work reliably and are not supported.
4456 @node MeP Function Attributes
4457 @subsection MeP Function Attributes
4459 These function attributes are supported by the MeP back end:
4463 @cindex @code{disinterrupt} function attribute, MeP
4464 On MeP targets, this attribute causes the compiler to emit
4465 instructions to disable interrupts for the duration of the given
4469 @cindex @code{interrupt} function attribute, MeP
4470 Use this attribute to indicate
4471 that the specified function is an interrupt handler. The compiler generates
4472 function entry and exit sequences suitable for use in an interrupt handler
4473 when this attribute is present.
4476 @cindex @code{near} function attribute, MeP
4477 This attribute causes the compiler to assume the called
4478 function is close enough to use the normal calling convention,
4479 overriding the @option{-mtf} command-line option.
4482 @cindex @code{far} function attribute, MeP
4483 On MeP targets this causes the compiler to use a calling convention
4484 that assumes the called function is too far away for the built-in
4488 @cindex @code{vliw} function attribute, MeP
4489 The @code{vliw} attribute tells the compiler to emit
4490 instructions in VLIW mode instead of core mode. Note that this
4491 attribute is not allowed unless a VLIW coprocessor has been configured
4492 and enabled through command-line options.
4495 @node MicroBlaze Function Attributes
4496 @subsection MicroBlaze Function Attributes
4498 These function attributes are supported on MicroBlaze targets:
4501 @item save_volatiles
4502 @cindex @code{save_volatiles} function attribute, MicroBlaze
4503 Use this attribute to indicate that the function is
4504 an interrupt handler. All volatile registers (in addition to non-volatile
4505 registers) are saved in the function prologue. If the function is a leaf
4506 function, only volatiles used by the function are saved. A normal function
4507 return is generated instead of a return from interrupt.
4510 @cindex @code{break_handler} function attribute, MicroBlaze
4511 @cindex break handler functions
4512 Use this attribute to indicate that
4513 the specified function is a break handler. The compiler generates function
4514 entry and exit sequences suitable for use in an break handler when this
4515 attribute is present. The return from @code{break_handler} is done through
4516 the @code{rtbd} instead of @code{rtsd}.
4519 void f () __attribute__ ((break_handler));
4522 @item interrupt_handler
4523 @itemx fast_interrupt
4524 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4525 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4526 These attributes indicate that the specified function is an interrupt
4527 handler. Use the @code{fast_interrupt} attribute to indicate handlers
4528 used in low-latency interrupt mode, and @code{interrupt_handler} for
4529 interrupts that do not use low-latency handlers. In both cases, GCC
4530 emits appropriate prologue code and generates a return from the handler
4531 using @code{rtid} instead of @code{rtsd}.
4534 @node Microsoft Windows Function Attributes
4535 @subsection Microsoft Windows Function Attributes
4537 The following attributes are available on Microsoft Windows and Symbian OS
4542 @cindex @code{dllexport} function attribute
4543 @cindex @code{__declspec(dllexport)}
4544 On Microsoft Windows targets and Symbian OS targets the
4545 @code{dllexport} attribute causes the compiler to provide a global
4546 pointer to a pointer in a DLL, so that it can be referenced with the
4547 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4548 name is formed by combining @code{_imp__} and the function or variable
4551 You can use @code{__declspec(dllexport)} as a synonym for
4552 @code{__attribute__ ((dllexport))} for compatibility with other
4555 On systems that support the @code{visibility} attribute, this
4556 attribute also implies ``default'' visibility. It is an error to
4557 explicitly specify any other visibility.
4559 GCC's default behavior is to emit all inline functions with the
4560 @code{dllexport} attribute. Since this can cause object file-size bloat,
4561 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4562 ignore the attribute for inlined functions unless the
4563 @option{-fkeep-inline-functions} flag is used instead.
4565 The attribute is ignored for undefined symbols.
4567 When applied to C++ classes, the attribute marks defined non-inlined
4568 member functions and static data members as exports. Static consts
4569 initialized in-class are not marked unless they are also defined
4572 For Microsoft Windows targets there are alternative methods for
4573 including the symbol in the DLL's export table such as using a
4574 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4575 the @option{--export-all} linker flag.
4578 @cindex @code{dllimport} function attribute
4579 @cindex @code{__declspec(dllimport)}
4580 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4581 attribute causes the compiler to reference a function or variable via
4582 a global pointer to a pointer that is set up by the DLL exporting the
4583 symbol. The attribute implies @code{extern}. On Microsoft Windows
4584 targets, the pointer name is formed by combining @code{_imp__} and the
4585 function or variable name.
4587 You can use @code{__declspec(dllimport)} as a synonym for
4588 @code{__attribute__ ((dllimport))} for compatibility with other
4591 On systems that support the @code{visibility} attribute, this
4592 attribute also implies ``default'' visibility. It is an error to
4593 explicitly specify any other visibility.
4595 Currently, the attribute is ignored for inlined functions. If the
4596 attribute is applied to a symbol @emph{definition}, an error is reported.
4597 If a symbol previously declared @code{dllimport} is later defined, the
4598 attribute is ignored in subsequent references, and a warning is emitted.
4599 The attribute is also overridden by a subsequent declaration as
4602 When applied to C++ classes, the attribute marks non-inlined
4603 member functions and static data members as imports. However, the
4604 attribute is ignored for virtual methods to allow creation of vtables
4607 On the SH Symbian OS target the @code{dllimport} attribute also has
4608 another affect---it can cause the vtable and run-time type information
4609 for a class to be exported. This happens when the class has a
4610 dllimported constructor or a non-inline, non-pure virtual function
4611 and, for either of those two conditions, the class also has an inline
4612 constructor or destructor and has a key function that is defined in
4613 the current translation unit.
4615 For Microsoft Windows targets the use of the @code{dllimport}
4616 attribute on functions is not necessary, but provides a small
4617 performance benefit by eliminating a thunk in the DLL@. The use of the
4618 @code{dllimport} attribute on imported variables can be avoided by passing the
4619 @option{--enable-auto-import} switch to the GNU linker. As with
4620 functions, using the attribute for a variable eliminates a thunk in
4623 One drawback to using this attribute is that a pointer to a
4624 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4625 address. However, a pointer to a @emph{function} with the
4626 @code{dllimport} attribute can be used as a constant initializer; in
4627 this case, the address of a stub function in the import lib is
4628 referenced. On Microsoft Windows targets, the attribute can be disabled
4629 for functions by setting the @option{-mnop-fun-dllimport} flag.
4632 @node MIPS Function Attributes
4633 @subsection MIPS Function Attributes
4635 These function attributes are supported by the MIPS back end:
4639 @cindex @code{interrupt} function attribute, MIPS
4640 Use this attribute to indicate that the specified function is an interrupt
4641 handler. The compiler generates function entry and exit sequences suitable
4642 for use in an interrupt handler when this attribute is present.
4643 An optional argument is supported for the interrupt attribute which allows
4644 the interrupt mode to be described. By default GCC assumes the external
4645 interrupt controller (EIC) mode is in use, this can be explicitly set using
4646 @code{eic}. When interrupts are non-masked then the requested Interrupt
4647 Priority Level (IPL) is copied to the current IPL which has the effect of only
4648 enabling higher priority interrupts. To use vectored interrupt mode use
4649 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4650 the behavior of the non-masked interrupt support and GCC will arrange to mask
4651 all interrupts from sw0 up to and including the specified interrupt vector.
4653 You can use the following attributes to modify the behavior
4654 of an interrupt handler:
4656 @item use_shadow_register_set
4657 @cindex @code{use_shadow_register_set} function attribute, MIPS
4658 Assume that the handler uses a shadow register set, instead of
4659 the main general-purpose registers. An optional argument @code{intstack} is
4660 supported to indicate that the shadow register set contains a valid stack
4663 @item keep_interrupts_masked
4664 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4665 Keep interrupts masked for the whole function. Without this attribute,
4666 GCC tries to reenable interrupts for as much of the function as it can.
4668 @item use_debug_exception_return
4669 @cindex @code{use_debug_exception_return} function attribute, MIPS
4670 Return using the @code{deret} instruction. Interrupt handlers that don't
4671 have this attribute return using @code{eret} instead.
4674 You can use any combination of these attributes, as shown below:
4676 void __attribute__ ((interrupt)) v0 ();
4677 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4678 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4679 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4680 void __attribute__ ((interrupt, use_shadow_register_set,
4681 keep_interrupts_masked)) v4 ();
4682 void __attribute__ ((interrupt, use_shadow_register_set,
4683 use_debug_exception_return)) v5 ();
4684 void __attribute__ ((interrupt, keep_interrupts_masked,
4685 use_debug_exception_return)) v6 ();
4686 void __attribute__ ((interrupt, use_shadow_register_set,
4687 keep_interrupts_masked,
4688 use_debug_exception_return)) v7 ();
4689 void __attribute__ ((interrupt("eic"))) v8 ();
4690 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4697 @cindex indirect calls, MIPS
4698 @cindex @code{long_call} function attribute, MIPS
4699 @cindex @code{short_call} function attribute, MIPS
4700 @cindex @code{near} function attribute, MIPS
4701 @cindex @code{far} function attribute, MIPS
4702 These attributes specify how a particular function is called on MIPS@.
4703 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4704 command-line switch. The @code{long_call} and @code{far} attributes are
4705 synonyms, and cause the compiler to always call
4706 the function by first loading its address into a register, and then using
4707 the contents of that register. The @code{short_call} and @code{near}
4708 attributes are synonyms, and have the opposite
4709 effect; they specify that non-PIC calls should be made using the more
4710 efficient @code{jal} instruction.
4714 @cindex @code{mips16} function attribute, MIPS
4715 @cindex @code{nomips16} function attribute, MIPS
4717 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4718 function attributes to locally select or turn off MIPS16 code generation.
4719 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4720 while MIPS16 code generation is disabled for functions with the
4721 @code{nomips16} attribute. These attributes override the
4722 @option{-mips16} and @option{-mno-mips16} options on the command line
4723 (@pxref{MIPS Options}).
4725 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4726 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4727 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4728 may interact badly with some GCC extensions such as @code{__builtin_apply}
4729 (@pxref{Constructing Calls}).
4731 @item micromips, MIPS
4732 @itemx nomicromips, MIPS
4733 @cindex @code{micromips} function attribute
4734 @cindex @code{nomicromips} function attribute
4736 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4737 function attributes to locally select or turn off microMIPS code generation.
4738 A function with the @code{micromips} attribute is emitted as microMIPS code,
4739 while microMIPS code generation is disabled for functions with the
4740 @code{nomicromips} attribute. These attributes override the
4741 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4742 (@pxref{MIPS Options}).
4744 When compiling files containing mixed microMIPS and non-microMIPS code, the
4745 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4747 not that within individual functions. Mixed microMIPS and non-microMIPS code
4748 may interact badly with some GCC extensions such as @code{__builtin_apply}
4749 (@pxref{Constructing Calls}).
4752 @cindex @code{nocompression} function attribute, MIPS
4753 On MIPS targets, you can use the @code{nocompression} function attribute
4754 to locally turn off MIPS16 and microMIPS code generation. This attribute
4755 overrides the @option{-mips16} and @option{-mmicromips} options on the
4756 command line (@pxref{MIPS Options}).
4759 @node MSP430 Function Attributes
4760 @subsection MSP430 Function Attributes
4762 These function attributes are supported by the MSP430 back end:
4766 @cindex @code{critical} function attribute, MSP430
4767 Critical functions disable interrupts upon entry and restore the
4768 previous interrupt state upon exit. Critical functions cannot also
4769 have the @code{naked} or @code{reentrant} attributes. They can have
4770 the @code{interrupt} attribute.
4773 @cindex @code{interrupt} function attribute, MSP430
4774 Use this attribute to indicate
4775 that the specified function is an interrupt handler. The compiler generates
4776 function entry and exit sequences suitable for use in an interrupt handler
4777 when this attribute is present.
4779 You can provide an argument to the interrupt
4780 attribute which specifies a name or number. If the argument is a
4781 number it indicates the slot in the interrupt vector table (0 - 31) to
4782 which this handler should be assigned. If the argument is a name it
4783 is treated as a symbolic name for the vector slot. These names should
4784 match up with appropriate entries in the linker script. By default
4785 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4786 @code{reset} for vector 31 are recognized.
4789 @cindex @code{naked} function attribute, MSP430
4790 This attribute allows the compiler to construct the
4791 requisite function declaration, while allowing the body of the
4792 function to be assembly code. The specified function will not have
4793 prologue/epilogue sequences generated by the compiler. Only basic
4794 @code{asm} statements can safely be included in naked functions
4795 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4796 basic @code{asm} and C code may appear to work, they cannot be
4797 depended upon to work reliably and are not supported.
4800 @cindex @code{reentrant} function attribute, MSP430
4801 Reentrant functions disable interrupts upon entry and enable them
4802 upon exit. Reentrant functions cannot also have the @code{naked}
4803 or @code{critical} attributes. They can have the @code{interrupt}
4807 @cindex @code{wakeup} function attribute, MSP430
4808 This attribute only applies to interrupt functions. It is silently
4809 ignored if applied to a non-interrupt function. A wakeup interrupt
4810 function will rouse the processor from any low-power state that it
4811 might be in when the function exits.
4816 @cindex @code{lower} function attribute, MSP430
4817 @cindex @code{upper} function attribute, MSP430
4818 @cindex @code{either} function attribute, MSP430
4819 On the MSP430 target these attributes can be used to specify whether
4820 the function or variable should be placed into low memory, high
4821 memory, or the placement should be left to the linker to decide. The
4822 attributes are only significant if compiling for the MSP430X
4825 The attributes work in conjunction with a linker script that has been
4826 augmented to specify where to place sections with a @code{.lower} and
4827 a @code{.upper} prefix. So, for example, as well as placing the
4828 @code{.data} section, the script also specifies the placement of a
4829 @code{.lower.data} and a @code{.upper.data} section. The intention
4830 is that @code{lower} sections are placed into a small but easier to
4831 access memory region and the upper sections are placed into a larger, but
4832 slower to access, region.
4834 The @code{either} attribute is special. It tells the linker to place
4835 the object into the corresponding @code{lower} section if there is
4836 room for it. If there is insufficient room then the object is placed
4837 into the corresponding @code{upper} section instead. Note that the
4838 placement algorithm is not very sophisticated. It does not attempt to
4839 find an optimal packing of the @code{lower} sections. It just makes
4840 one pass over the objects and does the best that it can. Using the
4841 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4842 options can help the packing, however, since they produce smaller,
4843 easier to pack regions.
4846 @node NDS32 Function Attributes
4847 @subsection NDS32 Function Attributes
4849 These function attributes are supported by the NDS32 back end:
4853 @cindex @code{exception} function attribute
4854 @cindex exception handler functions, NDS32
4855 Use this attribute on the NDS32 target to indicate that the specified function
4856 is an exception handler. The compiler will generate corresponding sections
4857 for use in an exception handler.
4860 @cindex @code{interrupt} function attribute, NDS32
4861 On NDS32 target, this attribute indicates that the specified function
4862 is an interrupt handler. The compiler generates corresponding sections
4863 for use in an interrupt handler. You can use the following attributes
4864 to modify the behavior:
4867 @cindex @code{nested} function attribute, NDS32
4868 This interrupt service routine is interruptible.
4870 @cindex @code{not_nested} function attribute, NDS32
4871 This interrupt service routine is not interruptible.
4873 @cindex @code{nested_ready} function attribute, NDS32
4874 This interrupt service routine is interruptible after @code{PSW.GIE}
4875 (global interrupt enable) is set. This allows interrupt service routine to
4876 finish some short critical code before enabling interrupts.
4878 @cindex @code{save_all} function attribute, NDS32
4879 The system will help save all registers into stack before entering
4882 @cindex @code{partial_save} function attribute, NDS32
4883 The system will help save caller registers into stack before entering
4888 @cindex @code{naked} function attribute, NDS32
4889 This attribute allows the compiler to construct the
4890 requisite function declaration, while allowing the body of the
4891 function to be assembly code. The specified function will not have
4892 prologue/epilogue sequences generated by the compiler. Only basic
4893 @code{asm} statements can safely be included in naked functions
4894 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4895 basic @code{asm} and C code may appear to work, they cannot be
4896 depended upon to work reliably and are not supported.
4899 @cindex @code{reset} function attribute, NDS32
4900 @cindex reset handler functions
4901 Use this attribute on the NDS32 target to indicate that the specified function
4902 is a reset handler. The compiler will generate corresponding sections
4903 for use in a reset handler. You can use the following attributes
4904 to provide extra exception handling:
4907 @cindex @code{nmi} function attribute, NDS32
4908 Provide a user-defined function to handle NMI exception.
4910 @cindex @code{warm} function attribute, NDS32
4911 Provide a user-defined function to handle warm reset exception.
4915 @node Nios II Function Attributes
4916 @subsection Nios II Function Attributes
4918 These function attributes are supported by the Nios II back end:
4921 @item target (@var{options})
4922 @cindex @code{target} function attribute
4923 As discussed in @ref{Common Function Attributes}, this attribute
4924 allows specification of target-specific compilation options.
4926 When compiling for Nios II, the following options are allowed:
4929 @item custom-@var{insn}=@var{N}
4930 @itemx no-custom-@var{insn}
4931 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4932 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4933 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4934 custom instruction with encoding @var{N} when generating code that uses
4935 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4936 the custom instruction @var{insn}.
4937 These target attributes correspond to the
4938 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4939 command-line options, and support the same set of @var{insn} keywords.
4940 @xref{Nios II Options}, for more information.
4942 @item custom-fpu-cfg=@var{name}
4943 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4944 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4945 command-line option, to select a predefined set of custom instructions
4947 @xref{Nios II Options}, for more information.
4951 @node Nvidia PTX Function Attributes
4952 @subsection Nvidia PTX Function Attributes
4954 These function attributes are supported by the Nvidia PTX back end:
4958 @cindex @code{kernel} attribute, Nvidia PTX
4959 This attribute indicates that the corresponding function should be compiled
4960 as a kernel function, which can be invoked from the host via the CUDA RT
4962 By default functions are only callable only from other PTX functions.
4964 Kernel functions must have @code{void} return type.
4967 @node PowerPC Function Attributes
4968 @subsection PowerPC Function Attributes
4970 These function attributes are supported by the PowerPC back end:
4975 @cindex indirect calls, PowerPC
4976 @cindex @code{longcall} function attribute, PowerPC
4977 @cindex @code{shortcall} function attribute, PowerPC
4978 The @code{longcall} attribute
4979 indicates that the function might be far away from the call site and
4980 require a different (more expensive) calling sequence. The
4981 @code{shortcall} attribute indicates that the function is always close
4982 enough for the shorter calling sequence to be used. These attributes
4983 override both the @option{-mlongcall} switch and
4984 the @code{#pragma longcall} setting.
4986 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4987 calls are necessary.
4989 @item target (@var{options})
4990 @cindex @code{target} function attribute
4991 As discussed in @ref{Common Function Attributes}, this attribute
4992 allows specification of target-specific compilation options.
4994 On the PowerPC, the following options are allowed:
4999 @cindex @code{target("altivec")} function attribute, PowerPC
5000 Generate code that uses (does not use) AltiVec instructions. In
5001 32-bit code, you cannot enable AltiVec instructions unless
5002 @option{-mabi=altivec} is used on the command line.
5006 @cindex @code{target("cmpb")} function attribute, PowerPC
5007 Generate code that uses (does not use) the compare bytes instruction
5008 implemented on the POWER6 processor and other processors that support
5009 the PowerPC V2.05 architecture.
5013 @cindex @code{target("dlmzb")} function attribute, PowerPC
5014 Generate code that uses (does not use) the string-search @samp{dlmzb}
5015 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
5016 generated by default when targeting those processors.
5020 @cindex @code{target("fprnd")} function attribute, PowerPC
5021 Generate code that uses (does not use) the FP round to integer
5022 instructions implemented on the POWER5+ processor and other processors
5023 that support the PowerPC V2.03 architecture.
5027 @cindex @code{target("hard-dfp")} function attribute, PowerPC
5028 Generate code that uses (does not use) the decimal floating-point
5029 instructions implemented on some POWER processors.
5033 @cindex @code{target("isel")} function attribute, PowerPC
5034 Generate code that uses (does not use) ISEL instruction.
5038 @cindex @code{target("mfcrf")} function attribute, PowerPC
5039 Generate code that uses (does not use) the move from condition
5040 register field instruction implemented on the POWER4 processor and
5041 other processors that support the PowerPC V2.01 architecture.
5045 @cindex @code{target("mfpgpr")} function attribute, PowerPC
5046 Generate code that uses (does not use) the FP move to/from general
5047 purpose register instructions implemented on the POWER6X processor and
5048 other processors that support the extended PowerPC V2.05 architecture.
5052 @cindex @code{target("mulhw")} function attribute, PowerPC
5053 Generate code that uses (does not use) the half-word multiply and
5054 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
5055 These instructions are generated by default when targeting those
5060 @cindex @code{target("multiple")} function attribute, PowerPC
5061 Generate code that uses (does not use) the load multiple word
5062 instructions and the store multiple word instructions.
5066 @cindex @code{target("update")} function attribute, PowerPC
5067 Generate code that uses (does not use) the load or store instructions
5068 that update the base register to the address of the calculated memory
5073 @cindex @code{target("popcntb")} function attribute, PowerPC
5074 Generate code that uses (does not use) the popcount and double-precision
5075 FP reciprocal estimate instruction implemented on the POWER5
5076 processor and other processors that support the PowerPC V2.02
5081 @cindex @code{target("popcntd")} function attribute, PowerPC
5082 Generate code that uses (does not use) the popcount instruction
5083 implemented on the POWER7 processor and other processors that support
5084 the PowerPC V2.06 architecture.
5086 @item powerpc-gfxopt
5087 @itemx no-powerpc-gfxopt
5088 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
5089 Generate code that uses (does not use) the optional PowerPC
5090 architecture instructions in the Graphics group, including
5091 floating-point select.
5094 @itemx no-powerpc-gpopt
5095 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
5096 Generate code that uses (does not use) the optional PowerPC
5097 architecture instructions in the General Purpose group, including
5098 floating-point square root.
5100 @item recip-precision
5101 @itemx no-recip-precision
5102 @cindex @code{target("recip-precision")} function attribute, PowerPC
5103 Assume (do not assume) that the reciprocal estimate instructions
5104 provide higher-precision estimates than is mandated by the PowerPC
5109 @cindex @code{target("string")} function attribute, PowerPC
5110 Generate code that uses (does not use) the load string instructions
5111 and the store string word instructions to save multiple registers and
5112 do small block moves.
5116 @cindex @code{target("vsx")} function attribute, PowerPC
5117 Generate code that uses (does not use) vector/scalar (VSX)
5118 instructions, and also enable the use of built-in functions that allow
5119 more direct access to the VSX instruction set. In 32-bit code, you
5120 cannot enable VSX or AltiVec instructions unless
5121 @option{-mabi=altivec} is used on the command line.
5125 @cindex @code{target("friz")} function attribute, PowerPC
5126 Generate (do not generate) the @code{friz} instruction when the
5127 @option{-funsafe-math-optimizations} option is used to optimize
5128 rounding a floating-point value to 64-bit integer and back to floating
5129 point. The @code{friz} instruction does not return the same value if
5130 the floating-point number is too large to fit in an integer.
5132 @item avoid-indexed-addresses
5133 @itemx no-avoid-indexed-addresses
5134 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
5135 Generate code that tries to avoid (not avoid) the use of indexed load
5136 or store instructions.
5140 @cindex @code{target("paired")} function attribute, PowerPC
5141 Generate code that uses (does not use) the generation of PAIRED simd
5146 @cindex @code{target("longcall")} function attribute, PowerPC
5147 Generate code that assumes (does not assume) that all calls are far
5148 away so that a longer more expensive calling sequence is required.
5151 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
5152 Specify the architecture to generate code for when compiling the
5153 function. If you select the @code{target("cpu=power7")} attribute when
5154 generating 32-bit code, VSX and AltiVec instructions are not generated
5155 unless you use the @option{-mabi=altivec} option on the command line.
5157 @item tune=@var{TUNE}
5158 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
5159 Specify the architecture to tune for when compiling the function. If
5160 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
5161 you do specify the @code{target("cpu=@var{CPU}")} attribute,
5162 compilation tunes for the @var{CPU} architecture, and not the
5163 default tuning specified on the command line.
5166 On the PowerPC, the inliner does not inline a
5167 function that has different target options than the caller, unless the
5168 callee has a subset of the target options of the caller.
5171 @node RISC-V Function Attributes
5172 @subsection RISC-V Function Attributes
5174 These function attributes are supported by the RISC-V back end:
5178 @cindex @code{naked} function attribute, RISC-V
5179 This attribute allows the compiler to construct the
5180 requisite function declaration, while allowing the body of the
5181 function to be assembly code. The specified function will not have
5182 prologue/epilogue sequences generated by the compiler. Only basic
5183 @code{asm} statements can safely be included in naked functions
5184 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5185 basic @code{asm} and C code may appear to work, they cannot be
5186 depended upon to work reliably and are not supported.
5189 @cindex @code{interrupt} function attribute, RISC-V
5190 Use this attribute to indicate that the specified function is an interrupt
5191 handler. The compiler generates function entry and exit sequences suitable
5192 for use in an interrupt handler when this attribute is present.
5194 You can specify the kind of interrupt to be handled by adding an optional
5195 parameter to the interrupt attribute like this:
5198 void f (void) __attribute__ ((interrupt ("user")));
5201 Permissible values for this parameter are @code{user}, @code{supervisor},
5202 and @code{machine}. If there is no parameter, then it defaults to
5206 @node RL78 Function Attributes
5207 @subsection RL78 Function Attributes
5209 These function attributes are supported by the RL78 back end:
5213 @itemx brk_interrupt
5214 @cindex @code{interrupt} function attribute, RL78
5215 @cindex @code{brk_interrupt} function attribute, RL78
5216 These attributes indicate
5217 that the specified function is an interrupt handler. The compiler generates
5218 function entry and exit sequences suitable for use in an interrupt handler
5219 when this attribute is present.
5221 Use @code{brk_interrupt} instead of @code{interrupt} for
5222 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
5223 that must end with @code{RETB} instead of @code{RETI}).
5226 @cindex @code{naked} function attribute, RL78
5227 This attribute allows the compiler to construct the
5228 requisite function declaration, while allowing the body of the
5229 function to be assembly code. The specified function will not have
5230 prologue/epilogue sequences generated by the compiler. Only basic
5231 @code{asm} statements can safely be included in naked functions
5232 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5233 basic @code{asm} and C code may appear to work, they cannot be
5234 depended upon to work reliably and are not supported.
5237 @node RX Function Attributes
5238 @subsection RX Function Attributes
5240 These function attributes are supported by the RX back end:
5243 @item fast_interrupt
5244 @cindex @code{fast_interrupt} function attribute, RX
5245 Use this attribute on the RX port to indicate that the specified
5246 function is a fast interrupt handler. This is just like the
5247 @code{interrupt} attribute, except that @code{freit} is used to return
5248 instead of @code{reit}.
5251 @cindex @code{interrupt} function attribute, RX
5252 Use this attribute to indicate
5253 that the specified function is an interrupt handler. The compiler generates
5254 function entry and exit sequences suitable for use in an interrupt handler
5255 when this attribute is present.
5257 On RX and RL78 targets, you may specify one or more vector numbers as arguments
5258 to the attribute, as well as naming an alternate table name.
5259 Parameters are handled sequentially, so one handler can be assigned to
5260 multiple entries in multiple tables. One may also pass the magic
5261 string @code{"$default"} which causes the function to be used for any
5262 unfilled slots in the current table.
5264 This example shows a simple assignment of a function to one vector in
5265 the default table (note that preprocessor macros may be used for
5266 chip-specific symbolic vector names):
5268 void __attribute__ ((interrupt (5))) txd1_handler ();
5271 This example assigns a function to two slots in the default table
5272 (using preprocessor macros defined elsewhere) and makes it the default
5273 for the @code{dct} table:
5275 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
5280 @cindex @code{naked} function attribute, RX
5281 This attribute allows the compiler to construct the
5282 requisite function declaration, while allowing the body of the
5283 function to be assembly code. The specified function will not have
5284 prologue/epilogue sequences generated by the compiler. Only basic
5285 @code{asm} statements can safely be included in naked functions
5286 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5287 basic @code{asm} and C code may appear to work, they cannot be
5288 depended upon to work reliably and are not supported.
5291 @cindex @code{vector} function attribute, RX
5292 This RX attribute is similar to the @code{interrupt} attribute, including its
5293 parameters, but does not make the function an interrupt-handler type
5294 function (i.e. it retains the normal C function calling ABI). See the
5295 @code{interrupt} attribute for a description of its arguments.
5298 @node S/390 Function Attributes
5299 @subsection S/390 Function Attributes
5301 These function attributes are supported on the S/390:
5304 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5305 @cindex @code{hotpatch} function attribute, S/390
5307 On S/390 System z targets, you can use this function attribute to
5308 make GCC generate a ``hot-patching'' function prologue. If the
5309 @option{-mhotpatch=} command-line option is used at the same time,
5310 the @code{hotpatch} attribute takes precedence. The first of the
5311 two arguments specifies the number of halfwords to be added before
5312 the function label. A second argument can be used to specify the
5313 number of halfwords to be added after the function label. For
5314 both arguments the maximum allowed value is 1000000.
5316 If both arguments are zero, hotpatching is disabled.
5318 @item target (@var{options})
5319 @cindex @code{target} function attribute
5320 As discussed in @ref{Common Function Attributes}, this attribute
5321 allows specification of target-specific compilation options.
5323 On S/390, the following options are supported:
5331 @item warn-framesize=
5343 @itemx no-packed-stack
5345 @itemx no-small-exec
5348 @item warn-dynamicstack
5349 @itemx no-warn-dynamicstack
5352 The options work exactly like the S/390 specific command line
5353 options (without the prefix @option{-m}) except that they do not
5354 change any feature macros. For example,
5357 @code{target("no-vx")}
5360 does not undefine the @code{__VEC__} macro.
5363 @node SH Function Attributes
5364 @subsection SH Function Attributes
5366 These function attributes are supported on the SH family of processors:
5369 @item function_vector
5370 @cindex @code{function_vector} function attribute, SH
5371 @cindex calling functions through the function vector on SH2A
5372 On SH2A targets, this attribute declares a function to be called using the
5373 TBR relative addressing mode. The argument to this attribute is the entry
5374 number of the same function in a vector table containing all the TBR
5375 relative addressable functions. For correct operation the TBR must be setup
5376 accordingly to point to the start of the vector table before any functions with
5377 this attribute are invoked. Usually a good place to do the initialization is
5378 the startup routine. The TBR relative vector table can have at max 256 function
5379 entries. The jumps to these functions are generated using a SH2A specific,
5380 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
5381 from GNU binutils version 2.7 or later for this attribute to work correctly.
5383 In an application, for a function being called once, this attribute
5384 saves at least 8 bytes of code; and if other successive calls are being
5385 made to the same function, it saves 2 bytes of code per each of these
5388 @item interrupt_handler
5389 @cindex @code{interrupt_handler} function attribute, SH
5390 Use this attribute to
5391 indicate that the specified function is an interrupt handler. The compiler
5392 generates function entry and exit sequences suitable for use in an
5393 interrupt handler when this attribute is present.
5395 @item nosave_low_regs
5396 @cindex @code{nosave_low_regs} function attribute, SH
5397 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5398 function should not save and restore registers R0..R7. This can be used on SH3*
5399 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5403 @cindex @code{renesas} function attribute, SH
5404 On SH targets this attribute specifies that the function or struct follows the
5408 @cindex @code{resbank} function attribute, SH
5409 On the SH2A target, this attribute enables the high-speed register
5410 saving and restoration using a register bank for @code{interrupt_handler}
5411 routines. Saving to the bank is performed automatically after the CPU
5412 accepts an interrupt that uses a register bank.
5414 The nineteen 32-bit registers comprising general register R0 to R14,
5415 control register GBR, and system registers MACH, MACL, and PR and the
5416 vector table address offset are saved into a register bank. Register
5417 banks are stacked in first-in last-out (FILO) sequence. Restoration
5418 from the bank is executed by issuing a RESBANK instruction.
5421 @cindex @code{sp_switch} function attribute, SH
5422 Use this attribute on the SH to indicate an @code{interrupt_handler}
5423 function should switch to an alternate stack. It expects a string
5424 argument that names a global variable holding the address of the
5429 void f () __attribute__ ((interrupt_handler,
5430 sp_switch ("alt_stack")));
5434 @cindex @code{trap_exit} function attribute, SH
5435 Use this attribute on the SH for an @code{interrupt_handler} to return using
5436 @code{trapa} instead of @code{rte}. This attribute expects an integer
5437 argument specifying the trap number to be used.
5440 @cindex @code{trapa_handler} function attribute, SH
5441 On SH targets this function attribute is similar to @code{interrupt_handler}
5442 but it does not save and restore all registers.
5445 @node SPU Function Attributes
5446 @subsection SPU Function Attributes
5448 These function attributes are supported by the SPU back end:
5452 @cindex @code{naked} function attribute, SPU
5453 This attribute allows the compiler to construct the
5454 requisite function declaration, while allowing the body of the
5455 function to be assembly code. The specified function will not have
5456 prologue/epilogue sequences generated by the compiler. Only basic
5457 @code{asm} statements can safely be included in naked functions
5458 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5459 basic @code{asm} and C code may appear to work, they cannot be
5460 depended upon to work reliably and are not supported.
5463 @node Symbian OS Function Attributes
5464 @subsection Symbian OS Function Attributes
5466 @xref{Microsoft Windows Function Attributes}, for discussion of the
5467 @code{dllexport} and @code{dllimport} attributes.
5469 @node V850 Function Attributes
5470 @subsection V850 Function Attributes
5472 The V850 back end supports these function attributes:
5476 @itemx interrupt_handler
5477 @cindex @code{interrupt} function attribute, V850
5478 @cindex @code{interrupt_handler} function attribute, V850
5479 Use these attributes to indicate
5480 that the specified function is an interrupt handler. The compiler generates
5481 function entry and exit sequences suitable for use in an interrupt handler
5482 when either attribute is present.
5485 @node Visium Function Attributes
5486 @subsection Visium Function Attributes
5488 These function attributes are supported by the Visium back end:
5492 @cindex @code{interrupt} function attribute, Visium
5493 Use this attribute to indicate
5494 that the specified function is an interrupt handler. The compiler generates
5495 function entry and exit sequences suitable for use in an interrupt handler
5496 when this attribute is present.
5499 @node x86 Function Attributes
5500 @subsection x86 Function Attributes
5502 These function attributes are supported by the x86 back end:
5506 @cindex @code{cdecl} function attribute, x86-32
5507 @cindex functions that pop the argument stack on x86-32
5509 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5510 assume that the calling function pops off the stack space used to
5511 pass arguments. This is
5512 useful to override the effects of the @option{-mrtd} switch.
5515 @cindex @code{fastcall} function attribute, x86-32
5516 @cindex functions that pop the argument stack on x86-32
5517 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5518 pass the first argument (if of integral type) in the register ECX and
5519 the second argument (if of integral type) in the register EDX@. Subsequent
5520 and other typed arguments are passed on the stack. The called function
5521 pops the arguments off the stack. If the number of arguments is variable all
5522 arguments are pushed on the stack.
5525 @cindex @code{thiscall} function attribute, x86-32
5526 @cindex functions that pop the argument stack on x86-32
5527 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5528 pass the first argument (if of integral type) in the register ECX.
5529 Subsequent and other typed arguments are passed on the stack. The called
5530 function pops the arguments off the stack.
5531 If the number of arguments is variable all arguments are pushed on the
5533 The @code{thiscall} attribute is intended for C++ non-static member functions.
5534 As a GCC extension, this calling convention can be used for C functions
5535 and for static member methods.
5539 @cindex @code{ms_abi} function attribute, x86
5540 @cindex @code{sysv_abi} function attribute, x86
5542 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5543 to indicate which calling convention should be used for a function. The
5544 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5545 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5546 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5547 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5549 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5550 requires the @option{-maccumulate-outgoing-args} option.
5552 @item callee_pop_aggregate_return (@var{number})
5553 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5555 On x86-32 targets, you can use this attribute to control how
5556 aggregates are returned in memory. If the caller is responsible for
5557 popping the hidden pointer together with the rest of the arguments, specify
5558 @var{number} equal to zero. If callee is responsible for popping the
5559 hidden pointer, specify @var{number} equal to one.
5561 The default x86-32 ABI assumes that the callee pops the
5562 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5563 the compiler assumes that the
5564 caller pops the stack for hidden pointer.
5566 @item ms_hook_prologue
5567 @cindex @code{ms_hook_prologue} function attribute, x86
5569 On 32-bit and 64-bit x86 targets, you can use
5570 this function attribute to make GCC generate the ``hot-patching'' function
5571 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5575 @cindex @code{naked} function attribute, x86
5576 This attribute allows the compiler to construct the
5577 requisite function declaration, while allowing the body of the
5578 function to be assembly code. The specified function will not have
5579 prologue/epilogue sequences generated by the compiler. Only basic
5580 @code{asm} statements can safely be included in naked functions
5581 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5582 basic @code{asm} and C code may appear to work, they cannot be
5583 depended upon to work reliably and are not supported.
5585 @item regparm (@var{number})
5586 @cindex @code{regparm} function attribute, x86
5587 @cindex functions that are passed arguments in registers on x86-32
5588 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5589 pass arguments number one to @var{number} if they are of integral type
5590 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5591 take a variable number of arguments continue to be passed all of their
5592 arguments on the stack.
5594 Beware that on some ELF systems this attribute is unsuitable for
5595 global functions in shared libraries with lazy binding (which is the
5596 default). Lazy binding sends the first call via resolving code in
5597 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5598 per the standard calling conventions. Solaris 8 is affected by this.
5599 Systems with the GNU C Library version 2.1 or higher
5600 and FreeBSD are believed to be
5601 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5602 disabled with the linker or the loader if desired, to avoid the
5606 @cindex @code{sseregparm} function attribute, x86
5607 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5608 causes the compiler to pass up to 3 floating-point arguments in
5609 SSE registers instead of on the stack. Functions that take a
5610 variable number of arguments continue to pass all of their
5611 floating-point arguments on the stack.
5613 @item force_align_arg_pointer
5614 @cindex @code{force_align_arg_pointer} function attribute, x86
5615 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5616 applied to individual function definitions, generating an alternate
5617 prologue and epilogue that realigns the run-time stack if necessary.
5618 This supports mixing legacy codes that run with a 4-byte aligned stack
5619 with modern codes that keep a 16-byte stack for SSE compatibility.
5622 @cindex @code{stdcall} function attribute, x86-32
5623 @cindex functions that pop the argument stack on x86-32
5624 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5625 assume that the called function pops off the stack space used to
5626 pass arguments, unless it takes a variable number of arguments.
5628 @item no_caller_saved_registers
5629 @cindex @code{no_caller_saved_registers} function attribute, x86
5630 Use this attribute to indicate that the specified function has no
5631 caller-saved registers. That is, all registers are callee-saved. For
5632 example, this attribute can be used for a function called from an
5633 interrupt handler. The compiler generates proper function entry and
5634 exit sequences to save and restore any modified registers, except for
5635 the EFLAGS register. Since GCC doesn't preserve SSE, MMX nor x87
5636 states, the GCC option @option{-mgeneral-regs-only} should be used to
5637 compile functions with @code{no_caller_saved_registers} attribute.
5640 @cindex @code{interrupt} function attribute, x86
5641 Use this attribute to indicate that the specified function is an
5642 interrupt handler or an exception handler (depending on parameters passed
5643 to the function, explained further). The compiler generates function
5644 entry and exit sequences suitable for use in an interrupt handler when
5645 this attribute is present. The @code{IRET} instruction, instead of the
5646 @code{RET} instruction, is used to return from interrupt handlers. All
5647 registers, except for the EFLAGS register which is restored by the
5648 @code{IRET} instruction, are preserved by the compiler. Since GCC
5649 doesn't preserve SSE, MMX nor x87 states, the GCC option
5650 @option{-mgeneral-regs-only} should be used to compile interrupt and
5653 Any interruptible-without-stack-switch code must be compiled with
5654 @option{-mno-red-zone} since interrupt handlers can and will, because
5655 of the hardware design, touch the red zone.
5657 An interrupt handler must be declared with a mandatory pointer
5661 struct interrupt_frame;
5663 __attribute__ ((interrupt))
5665 f (struct interrupt_frame *frame)
5671 and you must define @code{struct interrupt_frame} as described in the
5674 Exception handlers differ from interrupt handlers because the system
5675 pushes an error code on the stack. An exception handler declaration is
5676 similar to that for an interrupt handler, but with a different mandatory
5677 function signature. The compiler arranges to pop the error code off the
5678 stack before the @code{IRET} instruction.
5682 typedef unsigned long long int uword_t;
5684 typedef unsigned int uword_t;
5687 struct interrupt_frame;
5689 __attribute__ ((interrupt))
5691 f (struct interrupt_frame *frame, uword_t error_code)
5697 Exception handlers should only be used for exceptions that push an error
5698 code; you should use an interrupt handler in other cases. The system
5699 will crash if the wrong kind of handler is used.
5701 @item target (@var{options})
5702 @cindex @code{target} function attribute
5703 As discussed in @ref{Common Function Attributes}, this attribute
5704 allows specification of target-specific compilation options.
5706 On the x86, the following options are allowed:
5710 @cindex @code{target("abm")} function attribute, x86
5711 Enable/disable the generation of the advanced bit instructions.
5715 @cindex @code{target("aes")} function attribute, x86
5716 Enable/disable the generation of the AES instructions.
5719 @cindex @code{target("default")} function attribute, x86
5720 @xref{Function Multiversioning}, where it is used to specify the
5721 default function version.
5725 @cindex @code{target("mmx")} function attribute, x86
5726 Enable/disable the generation of the MMX instructions.
5730 @cindex @code{target("pclmul")} function attribute, x86
5731 Enable/disable the generation of the PCLMUL instructions.
5735 @cindex @code{target("popcnt")} function attribute, x86
5736 Enable/disable the generation of the POPCNT instruction.
5740 @cindex @code{target("sse")} function attribute, x86
5741 Enable/disable the generation of the SSE instructions.
5745 @cindex @code{target("sse2")} function attribute, x86
5746 Enable/disable the generation of the SSE2 instructions.
5750 @cindex @code{target("sse3")} function attribute, x86
5751 Enable/disable the generation of the SSE3 instructions.
5755 @cindex @code{target("sse4")} function attribute, x86
5756 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5761 @cindex @code{target("sse4.1")} function attribute, x86
5762 Enable/disable the generation of the sse4.1 instructions.
5766 @cindex @code{target("sse4.2")} function attribute, x86
5767 Enable/disable the generation of the sse4.2 instructions.
5771 @cindex @code{target("sse4a")} function attribute, x86
5772 Enable/disable the generation of the SSE4A instructions.
5776 @cindex @code{target("fma4")} function attribute, x86
5777 Enable/disable the generation of the FMA4 instructions.
5781 @cindex @code{target("xop")} function attribute, x86
5782 Enable/disable the generation of the XOP instructions.
5786 @cindex @code{target("lwp")} function attribute, x86
5787 Enable/disable the generation of the LWP instructions.
5791 @cindex @code{target("ssse3")} function attribute, x86
5792 Enable/disable the generation of the SSSE3 instructions.
5796 @cindex @code{target("cld")} function attribute, x86
5797 Enable/disable the generation of the CLD before string moves.
5799 @item fancy-math-387
5800 @itemx no-fancy-math-387
5801 @cindex @code{target("fancy-math-387")} function attribute, x86
5802 Enable/disable the generation of the @code{sin}, @code{cos}, and
5803 @code{sqrt} instructions on the 387 floating-point unit.
5807 @cindex @code{target("ieee-fp")} function attribute, x86
5808 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5810 @item inline-all-stringops
5811 @itemx no-inline-all-stringops
5812 @cindex @code{target("inline-all-stringops")} function attribute, x86
5813 Enable/disable inlining of string operations.
5815 @item inline-stringops-dynamically
5816 @itemx no-inline-stringops-dynamically
5817 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5818 Enable/disable the generation of the inline code to do small string
5819 operations and calling the library routines for large operations.
5821 @item align-stringops
5822 @itemx no-align-stringops
5823 @cindex @code{target("align-stringops")} function attribute, x86
5824 Do/do not align destination of inlined string operations.
5828 @cindex @code{target("recip")} function attribute, x86
5829 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5830 instructions followed an additional Newton-Raphson step instead of
5831 doing a floating-point division.
5833 @item arch=@var{ARCH}
5834 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5835 Specify the architecture to generate code for in compiling the function.
5837 @item tune=@var{TUNE}
5838 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5839 Specify the architecture to tune for in compiling the function.
5841 @item fpmath=@var{FPMATH}
5842 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5843 Specify which floating-point unit to use. You must specify the
5844 @code{target("fpmath=sse,387")} option as
5845 @code{target("fpmath=sse+387")} because the comma would separate
5848 @item indirect_branch("@var{choice}")
5849 @cindex @code{indirect_branch} function attribute, x86
5850 On x86 targets, the @code{indirect_branch} attribute causes the compiler
5851 to convert indirect call and jump with @var{choice}. @samp{keep}
5852 keeps indirect call and jump unmodified. @samp{thunk} converts indirect
5853 call and jump to call and return thunk. @samp{thunk-inline} converts
5854 indirect call and jump to inlined call and return thunk.
5855 @samp{thunk-extern} converts indirect call and jump to external call
5856 and return thunk provided in a separate object file.
5858 @item function_return("@var{choice}")
5859 @cindex @code{function_return} function attribute, x86
5860 On x86 targets, the @code{function_return} attribute causes the compiler
5861 to convert function return with @var{choice}. @samp{keep} keeps function
5862 return unmodified. @samp{thunk} converts function return to call and
5863 return thunk. @samp{thunk-inline} converts function return to inlined
5864 call and return thunk. @samp{thunk-extern} converts function return to
5865 external call and return thunk provided in a separate object file.
5868 @cindex @code{nocf_check} function attribute
5869 The @code{nocf_check} attribute on a function is used to inform the
5870 compiler that the function's prologue should not be instrumented when
5871 compiled with the @option{-fcf-protection=branch} option. The
5872 compiler assumes that the function's address is a valid target for a
5873 control-flow transfer.
5875 The @code{nocf_check} attribute on a type of pointer to function is
5876 used to inform the compiler that a call through the pointer should
5877 not be instrumented when compiled with the
5878 @option{-fcf-protection=branch} option. The compiler assumes
5879 that the function's address from the pointer is a valid target for
5880 a control-flow transfer. A direct function call through a function
5881 name is assumed to be a safe call thus direct calls are not
5882 instrumented by the compiler.
5884 The @code{nocf_check} attribute is applied to an object's type.
5885 In case of assignment of a function address or a function pointer to
5886 another pointer, the attribute is not carried over from the right-hand
5887 object's type; the type of left-hand object stays unchanged. The
5888 compiler checks for @code{nocf_check} attribute mismatch and reports
5889 a warning in case of mismatch.
5893 int foo (void) __attribute__(nocf_check);
5894 void (*foo1)(void) __attribute__(nocf_check);
5897 /* foo's address is assumed to be valid. */
5901 /* This call site is not checked for control-flow
5905 /* A warning is issued about attribute mismatch. */
5908 /* This call site is still not checked. */
5911 /* This call site is checked. */
5914 /* A warning is issued about attribute mismatch. */
5917 /* This call site is still checked. */
5924 @item indirect_return
5925 @cindex @code{indirect_return} function attribute, x86
5927 The @code{indirect_return} attribute can be applied to a function,
5928 as well as variable or type of function pointer to inform the
5929 compiler that the function may return via indirect branch.
5933 On the x86, the inliner does not inline a
5934 function that has different target options than the caller, unless the
5935 callee has a subset of the target options of the caller. For example
5936 a function declared with @code{target("sse3")} can inline a function
5937 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5940 @node Xstormy16 Function Attributes
5941 @subsection Xstormy16 Function Attributes
5943 These function attributes are supported by the Xstormy16 back end:
5947 @cindex @code{interrupt} function attribute, Xstormy16
5948 Use this attribute to indicate
5949 that the specified function is an interrupt handler. The compiler generates
5950 function entry and exit sequences suitable for use in an interrupt handler
5951 when this attribute is present.
5954 @node Variable Attributes
5955 @section Specifying Attributes of Variables
5956 @cindex attribute of variables
5957 @cindex variable attributes
5959 The keyword @code{__attribute__} allows you to specify special
5960 attributes of variables or structure fields. This keyword is followed
5961 by an attribute specification inside double parentheses. Some
5962 attributes are currently defined generically for variables.
5963 Other attributes are defined for variables on particular target
5964 systems. Other attributes are available for functions
5965 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5966 enumerators (@pxref{Enumerator Attributes}), statements
5967 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
5968 Other front ends might define more attributes
5969 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5971 @xref{Attribute Syntax}, for details of the exact syntax for using
5975 * Common Variable Attributes::
5976 * ARC Variable Attributes::
5977 * AVR Variable Attributes::
5978 * Blackfin Variable Attributes::
5979 * H8/300 Variable Attributes::
5980 * IA-64 Variable Attributes::
5981 * M32R/D Variable Attributes::
5982 * MeP Variable Attributes::
5983 * Microsoft Windows Variable Attributes::
5984 * MSP430 Variable Attributes::
5985 * Nvidia PTX Variable Attributes::
5986 * PowerPC Variable Attributes::
5987 * RL78 Variable Attributes::
5988 * SPU Variable Attributes::
5989 * V850 Variable Attributes::
5990 * x86 Variable Attributes::
5991 * Xstormy16 Variable Attributes::
5994 @node Common Variable Attributes
5995 @subsection Common Variable Attributes
5997 The following attributes are supported on most targets.
6000 @cindex @code{aligned} variable attribute
6001 @item aligned (@var{alignment})
6002 This attribute specifies a minimum alignment for the variable or
6003 structure field, measured in bytes. For example, the declaration:
6006 int x __attribute__ ((aligned (16))) = 0;
6010 causes the compiler to allocate the global variable @code{x} on a
6011 16-byte boundary. On a 68040, this could be used in conjunction with
6012 an @code{asm} expression to access the @code{move16} instruction which
6013 requires 16-byte aligned operands.
6015 You can also specify the alignment of structure fields. For example, to
6016 create a double-word aligned @code{int} pair, you could write:
6019 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
6023 This is an alternative to creating a union with a @code{double} member,
6024 which forces the union to be double-word aligned.
6026 As in the preceding examples, you can explicitly specify the alignment
6027 (in bytes) that you wish the compiler to use for a given variable or
6028 structure field. Alternatively, you can leave out the alignment factor
6029 and just ask the compiler to align a variable or field to the
6030 default alignment for the target architecture you are compiling for.
6031 The default alignment is sufficient for all scalar types, but may not be
6032 enough for all vector types on a target that supports vector operations.
6033 The default alignment is fixed for a particular target ABI.
6035 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
6036 which is the largest alignment ever used for any data type on the
6037 target machine you are compiling for. For example, you could write:
6040 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
6043 The compiler automatically sets the alignment for the declared
6044 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
6045 often make copy operations more efficient, because the compiler can
6046 use whatever instructions copy the biggest chunks of memory when
6047 performing copies to or from the variables or fields that you have
6048 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
6049 may change depending on command-line options.
6051 When used on a struct, or struct member, the @code{aligned} attribute can
6052 only increase the alignment; in order to decrease it, the @code{packed}
6053 attribute must be specified as well. When used as part of a typedef, the
6054 @code{aligned} attribute can both increase and decrease alignment, and
6055 specifying the @code{packed} attribute generates a warning.
6057 Note that the effectiveness of @code{aligned} attributes may be limited
6058 by inherent limitations in your linker. On many systems, the linker is
6059 only able to arrange for variables to be aligned up to a certain maximum
6060 alignment. (For some linkers, the maximum supported alignment may
6061 be very very small.) If your linker is only able to align variables
6062 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6063 in an @code{__attribute__} still only provides you with 8-byte
6064 alignment. See your linker documentation for further information.
6066 The @code{aligned} attribute can also be used for functions
6067 (@pxref{Common Function Attributes}.)
6069 @cindex @code{warn_if_not_aligned} variable attribute
6070 @item warn_if_not_aligned (@var{alignment})
6071 This attribute specifies a threshold for the structure field, measured
6072 in bytes. If the structure field is aligned below the threshold, a
6073 warning will be issued. For example, the declaration:
6080 unsigned long long x __attribute__((warn_if_not_aligned(16)));
6085 causes the compiler to issue an warning on @code{struct foo}, like
6086 @samp{warning: alignment 8 of 'struct foo' is less than 16}.
6087 The compiler also issues a warning, like @samp{warning: 'x' offset
6088 8 in 'struct foo' isn't aligned to 16}, when the structure field has
6089 the misaligned offset:
6096 unsigned long long x __attribute__((warn_if_not_aligned(16)));
6097 @} __attribute__((aligned(16)));
6100 This warning can be disabled by @option{-Wno-if-not-aligned}.
6101 The @code{warn_if_not_aligned} attribute can also be used for types
6102 (@pxref{Common Type Attributes}.)
6104 @item cleanup (@var{cleanup_function})
6105 @cindex @code{cleanup} variable attribute
6106 The @code{cleanup} attribute runs a function when the variable goes
6107 out of scope. This attribute can only be applied to auto function
6108 scope variables; it may not be applied to parameters or variables
6109 with static storage duration. The function must take one parameter,
6110 a pointer to a type compatible with the variable. The return value
6111 of the function (if any) is ignored.
6113 If @option{-fexceptions} is enabled, then @var{cleanup_function}
6114 is run during the stack unwinding that happens during the
6115 processing of the exception. Note that the @code{cleanup} attribute
6116 does not allow the exception to be caught, only to perform an action.
6117 It is undefined what happens if @var{cleanup_function} does not
6122 @cindex @code{common} variable attribute
6123 @cindex @code{nocommon} variable attribute
6126 The @code{common} attribute requests GCC to place a variable in
6127 ``common'' storage. The @code{nocommon} attribute requests the
6128 opposite---to allocate space for it directly.
6130 These attributes override the default chosen by the
6131 @option{-fno-common} and @option{-fcommon} flags respectively.
6134 @itemx deprecated (@var{msg})
6135 @cindex @code{deprecated} variable attribute
6136 The @code{deprecated} attribute results in a warning if the variable
6137 is used anywhere in the source file. This is useful when identifying
6138 variables that are expected to be removed in a future version of a
6139 program. The warning also includes the location of the declaration
6140 of the deprecated variable, to enable users to easily find further
6141 information about why the variable is deprecated, or what they should
6142 do instead. Note that the warning only occurs for uses:
6145 extern int old_var __attribute__ ((deprecated));
6147 int new_fn () @{ return old_var; @}
6151 results in a warning on line 3 but not line 2. The optional @var{msg}
6152 argument, which must be a string, is printed in the warning if
6155 The @code{deprecated} attribute can also be used for functions and
6156 types (@pxref{Common Function Attributes},
6157 @pxref{Common Type Attributes}).
6159 The message attached to the attribute is affected by the setting of
6160 the @option{-fmessage-length} option.
6162 @item mode (@var{mode})
6163 @cindex @code{mode} variable attribute
6164 This attribute specifies the data type for the declaration---whichever
6165 type corresponds to the mode @var{mode}. This in effect lets you
6166 request an integer or floating-point type according to its width.
6168 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
6169 for a list of the possible keywords for @var{mode}.
6170 You may also specify a mode of @code{byte} or @code{__byte__} to
6171 indicate the mode corresponding to a one-byte integer, @code{word} or
6172 @code{__word__} for the mode of a one-word integer, and @code{pointer}
6173 or @code{__pointer__} for the mode used to represent pointers.
6176 @cindex @code{nonstring} variable attribute
6177 The @code{nonstring} variable attribute specifies that an object or member
6178 declaration with type array of @code{char}, @code{signed char}, or
6179 @code{unsigned char}, or pointer to such a type is intended to store
6180 character arrays that do not necessarily contain a terminating @code{NUL}.
6181 This is useful in detecting uses of such arrays or pointers with functions
6182 that expect @code{NUL}-terminated strings, and to avoid warnings when such
6183 an array or pointer is used as an argument to a bounded string manipulation
6184 function such as @code{strncpy}. For example, without the attribute, GCC
6185 will issue a warning for the @code{strncpy} call below because it may
6186 truncate the copy without appending the terminating @code{NUL} character.
6187 Using the attribute makes it possible to suppress the warning. However,
6188 when the array is declared with the attribute the call to @code{strlen} is
6189 diagnosed because when the array doesn't contain a @code{NUL}-terminated
6190 string the call is undefined. To copy, compare, of search non-string
6191 character arrays use the @code{memcpy}, @code{memcmp}, @code{memchr},
6192 and other functions that operate on arrays of bytes. In addition,
6193 calling @code{strnlen} and @code{strndup} with such arrays is safe
6194 provided a suitable bound is specified, and not diagnosed.
6199 char name [32] __attribute__ ((nonstring));
6202 int f (struct Data *pd, const char *s)
6204 strncpy (pd->name, s, sizeof pd->name);
6206 return strlen (pd->name); // unsafe, gets a warning
6211 @cindex @code{packed} variable attribute
6212 The @code{packed} attribute specifies that a variable or structure field
6213 should have the smallest possible alignment---one byte for a variable,
6214 and one bit for a field, unless you specify a larger value with the
6215 @code{aligned} attribute.
6217 Here is a structure in which the field @code{x} is packed, so that it
6218 immediately follows @code{a}:
6224 int x[2] __attribute__ ((packed));
6228 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
6229 @code{packed} attribute on bit-fields of type @code{char}. This has
6230 been fixed in GCC 4.4 but the change can lead to differences in the
6231 structure layout. See the documentation of
6232 @option{-Wpacked-bitfield-compat} for more information.
6234 @item section ("@var{section-name}")
6235 @cindex @code{section} variable attribute
6236 Normally, the compiler places the objects it generates in sections like
6237 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
6238 or you need certain particular variables to appear in special sections,
6239 for example to map to special hardware. The @code{section}
6240 attribute specifies that a variable (or function) lives in a particular
6241 section. For example, this small program uses several specific section names:
6244 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
6245 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
6246 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
6247 int init_data __attribute__ ((section ("INITDATA")));
6251 /* @r{Initialize stack pointer} */
6252 init_sp (stack + sizeof (stack));
6254 /* @r{Initialize initialized data} */
6255 memcpy (&init_data, &data, &edata - &data);
6257 /* @r{Turn on the serial ports} */
6264 Use the @code{section} attribute with
6265 @emph{global} variables and not @emph{local} variables,
6266 as shown in the example.
6268 You may use the @code{section} attribute with initialized or
6269 uninitialized global variables but the linker requires
6270 each object be defined once, with the exception that uninitialized
6271 variables tentatively go in the @code{common} (or @code{bss}) section
6272 and can be multiply ``defined''. Using the @code{section} attribute
6273 changes what section the variable goes into and may cause the
6274 linker to issue an error if an uninitialized variable has multiple
6275 definitions. You can force a variable to be initialized with the
6276 @option{-fno-common} flag or the @code{nocommon} attribute.
6278 Some file formats do not support arbitrary sections so the @code{section}
6279 attribute is not available on all platforms.
6280 If you need to map the entire contents of a module to a particular
6281 section, consider using the facilities of the linker instead.
6283 @item tls_model ("@var{tls_model}")
6284 @cindex @code{tls_model} variable attribute
6285 The @code{tls_model} attribute sets thread-local storage model
6286 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
6287 overriding @option{-ftls-model=} command-line switch on a per-variable
6289 The @var{tls_model} argument should be one of @code{global-dynamic},
6290 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
6292 Not all targets support this attribute.
6295 @cindex @code{unused} variable attribute
6296 This attribute, attached to a variable, means that the variable is meant
6297 to be possibly unused. GCC does not produce a warning for this
6301 @cindex @code{used} variable attribute
6302 This attribute, attached to a variable with static storage, means that
6303 the variable must be emitted even if it appears that the variable is not
6306 When applied to a static data member of a C++ class template, the
6307 attribute also means that the member is instantiated if the
6308 class itself is instantiated.
6310 @item vector_size (@var{bytes})
6311 @cindex @code{vector_size} variable attribute
6312 This attribute specifies the vector size for the variable, measured in
6313 bytes. For example, the declaration:
6316 int foo __attribute__ ((vector_size (16)));
6320 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
6321 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
6322 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
6324 This attribute is only applicable to integral and float scalars,
6325 although arrays, pointers, and function return values are allowed in
6326 conjunction with this construct.
6328 Aggregates with this attribute are invalid, even if they are of the same
6329 size as a corresponding scalar. For example, the declaration:
6332 struct S @{ int a; @};
6333 struct S __attribute__ ((vector_size (16))) foo;
6337 is invalid even if the size of the structure is the same as the size of
6340 @item visibility ("@var{visibility_type}")
6341 @cindex @code{visibility} variable attribute
6342 This attribute affects the linkage of the declaration to which it is attached.
6343 The @code{visibility} attribute is described in
6344 @ref{Common Function Attributes}.
6347 @cindex @code{weak} variable attribute
6348 The @code{weak} attribute is described in
6349 @ref{Common Function Attributes}.
6353 @node ARC Variable Attributes
6354 @subsection ARC Variable Attributes
6358 @cindex @code{aux} variable attribute, ARC
6359 The @code{aux} attribute is used to directly access the ARC's
6360 auxiliary register space from C. The auxilirary register number is
6361 given via attribute argument.
6365 @node AVR Variable Attributes
6366 @subsection AVR Variable Attributes
6370 @cindex @code{progmem} variable attribute, AVR
6371 The @code{progmem} attribute is used on the AVR to place read-only
6372 data in the non-volatile program memory (flash). The @code{progmem}
6373 attribute accomplishes this by putting respective variables into a
6374 section whose name starts with @code{.progmem}.
6376 This attribute works similar to the @code{section} attribute
6377 but adds additional checking.
6380 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
6381 @code{progmem} affects the location
6382 of the data but not how this data is accessed.
6383 In order to read data located with the @code{progmem} attribute
6384 (inline) assembler must be used.
6386 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
6387 #include <avr/pgmspace.h>
6389 /* Locate var in flash memory */
6390 const int var[2] PROGMEM = @{ 1, 2 @};
6392 int read_var (int i)
6394 /* Access var[] by accessor macro from avr/pgmspace.h */
6395 return (int) pgm_read_word (& var[i]);
6399 AVR is a Harvard architecture processor and data and read-only data
6400 normally resides in the data memory (RAM).
6402 See also the @ref{AVR Named Address Spaces} section for
6403 an alternate way to locate and access data in flash memory.
6405 @item @bullet{}@tie{} AVR cores with flash memory visible in the RAM address range:
6406 On such devices, there is no need for attribute @code{progmem} or
6407 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
6408 Just use standard C / C++. The compiler will generate @code{LD*}
6409 instructions. As flash memory is visible in the RAM address range,
6410 and the default linker script does @emph{not} locate @code{.rodata} in
6411 RAM, no special features are needed in order not to waste RAM for
6412 read-only data or to read from flash. You might even get slightly better
6414 avoiding @code{progmem} and @code{__flash}. This applies to devices from
6415 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
6418 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
6419 The compiler adds @code{0x4000}
6420 to the addresses of objects and declarations in @code{progmem} and locates
6421 the objects in flash memory, namely in section @code{.progmem.data}.
6422 The offset is needed because the flash memory is visible in the RAM
6423 address space starting at address @code{0x4000}.
6425 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
6426 no special functions or macros are needed.
6429 /* var is located in flash memory */
6430 extern const int var[2] __attribute__((progmem));
6432 int read_var (int i)
6438 Please notice that on these devices, there is no need for @code{progmem}
6444 @itemx io (@var{addr})
6445 @cindex @code{io} variable attribute, AVR
6446 Variables with the @code{io} attribute are used to address
6447 memory-mapped peripherals in the io address range.
6448 If an address is specified, the variable
6449 is assigned that address, and the value is interpreted as an
6450 address in the data address space.
6454 volatile int porta __attribute__((io (0x22)));
6457 The address specified in the address in the data address range.
6459 Otherwise, the variable it is not assigned an address, but the
6460 compiler will still use in/out instructions where applicable,
6461 assuming some other module assigns an address in the io address range.
6465 extern volatile int porta __attribute__((io));
6469 @itemx io_low (@var{addr})
6470 @cindex @code{io_low} variable attribute, AVR
6471 This is like the @code{io} attribute, but additionally it informs the
6472 compiler that the object lies in the lower half of the I/O area,
6473 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
6477 @itemx address (@var{addr})
6478 @cindex @code{address} variable attribute, AVR
6479 Variables with the @code{address} attribute are used to address
6480 memory-mapped peripherals that may lie outside the io address range.
6483 volatile int porta __attribute__((address (0x600)));
6487 @cindex @code{absdata} variable attribute, AVR
6488 Variables in static storage and with the @code{absdata} attribute can
6489 be accessed by the @code{LDS} and @code{STS} instructions which take
6494 This attribute is only supported for the reduced AVR Tiny core
6498 You must make sure that respective data is located in the
6499 address range @code{0x40}@dots{}@code{0xbf} accessible by
6500 @code{LDS} and @code{STS}. One way to achieve this as an
6501 appropriate linker description file.
6504 If the location does not fit the address range of @code{LDS}
6505 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6508 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6513 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6517 @node Blackfin Variable Attributes
6518 @subsection Blackfin Variable Attributes
6520 Three attributes are currently defined for the Blackfin.
6526 @cindex @code{l1_data} variable attribute, Blackfin
6527 @cindex @code{l1_data_A} variable attribute, Blackfin
6528 @cindex @code{l1_data_B} variable attribute, Blackfin
6529 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6530 Variables with @code{l1_data} attribute are put into the specific section
6531 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6532 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6533 attribute are put into the specific section named @code{.l1.data.B}.
6536 @cindex @code{l2} variable attribute, Blackfin
6537 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6538 Variables with @code{l2} attribute are put into the specific section
6539 named @code{.l2.data}.
6542 @node H8/300 Variable Attributes
6543 @subsection H8/300 Variable Attributes
6545 These variable attributes are available for H8/300 targets:
6549 @cindex @code{eightbit_data} variable attribute, H8/300
6550 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6551 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6552 variable should be placed into the eight-bit data section.
6553 The compiler generates more efficient code for certain operations
6554 on data in the eight-bit data area. Note the eight-bit data area is limited to
6557 You must use GAS and GLD from GNU binutils version 2.7 or later for
6558 this attribute to work correctly.
6561 @cindex @code{tiny_data} variable attribute, H8/300
6562 @cindex tiny data section on the H8/300H and H8S
6563 Use this attribute on the H8/300H and H8S to indicate that the specified
6564 variable should be placed into the tiny data section.
6565 The compiler generates more efficient code for loads and stores
6566 on data in the tiny data section. Note the tiny data area is limited to
6567 slightly under 32KB of data.
6571 @node IA-64 Variable Attributes
6572 @subsection IA-64 Variable Attributes
6574 The IA-64 back end supports the following variable attribute:
6577 @item model (@var{model-name})
6578 @cindex @code{model} variable attribute, IA-64
6580 On IA-64, use this attribute to set the addressability of an object.
6581 At present, the only supported identifier for @var{model-name} is
6582 @code{small}, indicating addressability via ``small'' (22-bit)
6583 addresses (so that their addresses can be loaded with the @code{addl}
6584 instruction). Caveat: such addressing is by definition not position
6585 independent and hence this attribute must not be used for objects
6586 defined by shared libraries.
6590 @node M32R/D Variable Attributes
6591 @subsection M32R/D Variable Attributes
6593 One attribute is currently defined for the M32R/D@.
6596 @item model (@var{model-name})
6597 @cindex @code{model-name} variable attribute, M32R/D
6598 @cindex variable addressability on the M32R/D
6599 Use this attribute on the M32R/D to set the addressability of an object.
6600 The identifier @var{model-name} is one of @code{small}, @code{medium},
6601 or @code{large}, representing each of the code models.
6603 Small model objects live in the lower 16MB of memory (so that their
6604 addresses can be loaded with the @code{ld24} instruction).
6606 Medium and large model objects may live anywhere in the 32-bit address space
6607 (the compiler generates @code{seth/add3} instructions to load their
6611 @node MeP Variable Attributes
6612 @subsection MeP Variable Attributes
6614 The MeP target has a number of addressing modes and busses. The
6615 @code{near} space spans the standard memory space's first 16 megabytes
6616 (24 bits). The @code{far} space spans the entire 32-bit memory space.
6617 The @code{based} space is a 128-byte region in the memory space that
6618 is addressed relative to the @code{$tp} register. The @code{tiny}
6619 space is a 65536-byte region relative to the @code{$gp} register. In
6620 addition to these memory regions, the MeP target has a separate 16-bit
6621 control bus which is specified with @code{cb} attributes.
6626 @cindex @code{based} variable attribute, MeP
6627 Any variable with the @code{based} attribute is assigned to the
6628 @code{.based} section, and is accessed with relative to the
6629 @code{$tp} register.
6632 @cindex @code{tiny} variable attribute, MeP
6633 Likewise, the @code{tiny} attribute assigned variables to the
6634 @code{.tiny} section, relative to the @code{$gp} register.
6637 @cindex @code{near} variable attribute, MeP
6638 Variables with the @code{near} attribute are assumed to have addresses
6639 that fit in a 24-bit addressing mode. This is the default for large
6640 variables (@code{-mtiny=4} is the default) but this attribute can
6641 override @code{-mtiny=} for small variables, or override @code{-ml}.
6644 @cindex @code{far} variable attribute, MeP
6645 Variables with the @code{far} attribute are addressed using a full
6646 32-bit address. Since this covers the entire memory space, this
6647 allows modules to make no assumptions about where variables might be
6651 @cindex @code{io} variable attribute, MeP
6652 @itemx io (@var{addr})
6653 Variables with the @code{io} attribute are used to address
6654 memory-mapped peripherals. If an address is specified, the variable
6655 is assigned that address, else it is not assigned an address (it is
6656 assumed some other module assigns an address). Example:
6659 int timer_count __attribute__((io(0x123)));
6663 @itemx cb (@var{addr})
6664 @cindex @code{cb} variable attribute, MeP
6665 Variables with the @code{cb} attribute are used to access the control
6666 bus, using special instructions. @code{addr} indicates the control bus
6670 int cpu_clock __attribute__((cb(0x123)));
6675 @node Microsoft Windows Variable Attributes
6676 @subsection Microsoft Windows Variable Attributes
6678 You can use these attributes on Microsoft Windows targets.
6679 @ref{x86 Variable Attributes} for additional Windows compatibility
6680 attributes available on all x86 targets.
6685 @cindex @code{dllimport} variable attribute
6686 @cindex @code{dllexport} variable attribute
6687 The @code{dllimport} and @code{dllexport} attributes are described in
6688 @ref{Microsoft Windows Function Attributes}.
6691 @cindex @code{selectany} variable attribute
6692 The @code{selectany} attribute causes an initialized global variable to
6693 have link-once semantics. When multiple definitions of the variable are
6694 encountered by the linker, the first is selected and the remainder are
6695 discarded. Following usage by the Microsoft compiler, the linker is told
6696 @emph{not} to warn about size or content differences of the multiple
6699 Although the primary usage of this attribute is for POD types, the
6700 attribute can also be applied to global C++ objects that are initialized
6701 by a constructor. In this case, the static initialization and destruction
6702 code for the object is emitted in each translation defining the object,
6703 but the calls to the constructor and destructor are protected by a
6704 link-once guard variable.
6706 The @code{selectany} attribute is only available on Microsoft Windows
6707 targets. You can use @code{__declspec (selectany)} as a synonym for
6708 @code{__attribute__ ((selectany))} for compatibility with other
6712 @cindex @code{shared} variable attribute
6713 On Microsoft Windows, in addition to putting variable definitions in a named
6714 section, the section can also be shared among all running copies of an
6715 executable or DLL@. For example, this small program defines shared data
6716 by putting it in a named section @code{shared} and marking the section
6720 int foo __attribute__((section ("shared"), shared)) = 0;
6725 /* @r{Read and write foo. All running
6726 copies see the same value.} */
6732 You may only use the @code{shared} attribute along with @code{section}
6733 attribute with a fully-initialized global definition because of the way
6734 linkers work. See @code{section} attribute for more information.
6736 The @code{shared} attribute is only available on Microsoft Windows@.
6740 @node MSP430 Variable Attributes
6741 @subsection MSP430 Variable Attributes
6745 @cindex @code{noinit} variable attribute, MSP430
6746 Any data with the @code{noinit} attribute will not be initialised by
6747 the C runtime startup code, or the program loader. Not initialising
6748 data in this way can reduce program startup times.
6751 @cindex @code{persistent} variable attribute, MSP430
6752 Any variable with the @code{persistent} attribute will not be
6753 initialised by the C runtime startup code. Instead its value will be
6754 set once, when the application is loaded, and then never initialised
6755 again, even if the processor is reset or the program restarts.
6756 Persistent data is intended to be placed into FLASH RAM, where its
6757 value will be retained across resets. The linker script being used to
6758 create the application should ensure that persistent data is correctly
6764 @cindex @code{lower} variable attribute, MSP430
6765 @cindex @code{upper} variable attribute, MSP430
6766 @cindex @code{either} variable attribute, MSP430
6767 These attributes are the same as the MSP430 function attributes of the
6768 same name (@pxref{MSP430 Function Attributes}).
6769 These attributes can be applied to both functions and variables.
6772 @node Nvidia PTX Variable Attributes
6773 @subsection Nvidia PTX Variable Attributes
6775 These variable attributes are supported by the Nvidia PTX back end:
6779 @cindex @code{shared} attribute, Nvidia PTX
6780 Use this attribute to place a variable in the @code{.shared} memory space.
6781 This memory space is private to each cooperative thread array; only threads
6782 within one thread block refer to the same instance of the variable.
6783 The runtime does not initialize variables in this memory space.
6786 @node PowerPC Variable Attributes
6787 @subsection PowerPC Variable Attributes
6789 Three attributes currently are defined for PowerPC configurations:
6790 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6792 @cindex @code{ms_struct} variable attribute, PowerPC
6793 @cindex @code{gcc_struct} variable attribute, PowerPC
6794 For full documentation of the struct attributes please see the
6795 documentation in @ref{x86 Variable Attributes}.
6797 @cindex @code{altivec} variable attribute, PowerPC
6798 For documentation of @code{altivec} attribute please see the
6799 documentation in @ref{PowerPC Type Attributes}.
6801 @node RL78 Variable Attributes
6802 @subsection RL78 Variable Attributes
6804 @cindex @code{saddr} variable attribute, RL78
6805 The RL78 back end supports the @code{saddr} variable attribute. This
6806 specifies placement of the corresponding variable in the SADDR area,
6807 which can be accessed more efficiently than the default memory region.
6809 @node SPU Variable Attributes
6810 @subsection SPU Variable Attributes
6812 @cindex @code{spu_vector} variable attribute, SPU
6813 The SPU supports the @code{spu_vector} attribute for variables. For
6814 documentation of this attribute please see the documentation in
6815 @ref{SPU Type Attributes}.
6817 @node V850 Variable Attributes
6818 @subsection V850 Variable Attributes
6820 These variable attributes are supported by the V850 back end:
6825 @cindex @code{sda} variable attribute, V850
6826 Use this attribute to explicitly place a variable in the small data area,
6827 which can hold up to 64 kilobytes.
6830 @cindex @code{tda} variable attribute, V850
6831 Use this attribute to explicitly place a variable in the tiny data area,
6832 which can hold up to 256 bytes in total.
6835 @cindex @code{zda} variable attribute, V850
6836 Use this attribute to explicitly place a variable in the first 32 kilobytes
6840 @node x86 Variable Attributes
6841 @subsection x86 Variable Attributes
6843 Two attributes are currently defined for x86 configurations:
6844 @code{ms_struct} and @code{gcc_struct}.
6849 @cindex @code{ms_struct} variable attribute, x86
6850 @cindex @code{gcc_struct} variable attribute, x86
6852 If @code{packed} is used on a structure, or if bit-fields are used,
6853 it may be that the Microsoft ABI lays out the structure differently
6854 than the way GCC normally does. Particularly when moving packed
6855 data between functions compiled with GCC and the native Microsoft compiler
6856 (either via function call or as data in a file), it may be necessary to access
6859 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6860 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6861 command-line options, respectively;
6862 see @ref{x86 Options}, for details of how structure layout is affected.
6863 @xref{x86 Type Attributes}, for information about the corresponding
6864 attributes on types.
6868 @node Xstormy16 Variable Attributes
6869 @subsection Xstormy16 Variable Attributes
6871 One attribute is currently defined for xstormy16 configurations:
6876 @cindex @code{below100} variable attribute, Xstormy16
6878 If a variable has the @code{below100} attribute (@code{BELOW100} is
6879 allowed also), GCC places the variable in the first 0x100 bytes of
6880 memory and use special opcodes to access it. Such variables are
6881 placed in either the @code{.bss_below100} section or the
6882 @code{.data_below100} section.
6886 @node Type Attributes
6887 @section Specifying Attributes of Types
6888 @cindex attribute of types
6889 @cindex type attributes
6891 The keyword @code{__attribute__} allows you to specify special
6892 attributes of types. Some type attributes apply only to @code{struct}
6893 and @code{union} types, while others can apply to any type defined
6894 via a @code{typedef} declaration. Other attributes are defined for
6895 functions (@pxref{Function Attributes}), labels (@pxref{Label
6896 Attributes}), enumerators (@pxref{Enumerator Attributes}),
6897 statements (@pxref{Statement Attributes}), and for
6898 variables (@pxref{Variable Attributes}).
6900 The @code{__attribute__} keyword is followed by an attribute specification
6901 inside double parentheses.
6903 You may specify type attributes in an enum, struct or union type
6904 declaration or definition by placing them immediately after the
6905 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6906 syntax is to place them just past the closing curly brace of the
6909 You can also include type attributes in a @code{typedef} declaration.
6910 @xref{Attribute Syntax}, for details of the exact syntax for using
6914 * Common Type Attributes::
6915 * ARC Type Attributes::
6916 * ARM Type Attributes::
6917 * MeP Type Attributes::
6918 * PowerPC Type Attributes::
6919 * SPU Type Attributes::
6920 * x86 Type Attributes::
6923 @node Common Type Attributes
6924 @subsection Common Type Attributes
6926 The following type attributes are supported on most targets.
6929 @cindex @code{aligned} type attribute
6930 @item aligned (@var{alignment})
6931 This attribute specifies a minimum alignment (in bytes) for variables
6932 of the specified type. For example, the declarations:
6935 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6936 typedef int more_aligned_int __attribute__ ((aligned (8)));
6940 force the compiler to ensure (as far as it can) that each variable whose
6941 type is @code{struct S} or @code{more_aligned_int} is allocated and
6942 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6943 variables of type @code{struct S} aligned to 8-byte boundaries allows
6944 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6945 store) instructions when copying one variable of type @code{struct S} to
6946 another, thus improving run-time efficiency.
6948 Note that the alignment of any given @code{struct} or @code{union} type
6949 is required by the ISO C standard to be at least a perfect multiple of
6950 the lowest common multiple of the alignments of all of the members of
6951 the @code{struct} or @code{union} in question. This means that you @emph{can}
6952 effectively adjust the alignment of a @code{struct} or @code{union}
6953 type by attaching an @code{aligned} attribute to any one of the members
6954 of such a type, but the notation illustrated in the example above is a
6955 more obvious, intuitive, and readable way to request the compiler to
6956 adjust the alignment of an entire @code{struct} or @code{union} type.
6958 As in the preceding example, you can explicitly specify the alignment
6959 (in bytes) that you wish the compiler to use for a given @code{struct}
6960 or @code{union} type. Alternatively, you can leave out the alignment factor
6961 and just ask the compiler to align a type to the maximum
6962 useful alignment for the target machine you are compiling for. For
6963 example, you could write:
6966 struct S @{ short f[3]; @} __attribute__ ((aligned));
6969 Whenever you leave out the alignment factor in an @code{aligned}
6970 attribute specification, the compiler automatically sets the alignment
6971 for the type to the largest alignment that is ever used for any data
6972 type on the target machine you are compiling for. Doing this can often
6973 make copy operations more efficient, because the compiler can use
6974 whatever instructions copy the biggest chunks of memory when performing
6975 copies to or from the variables that have types that you have aligned
6978 In the example above, if the size of each @code{short} is 2 bytes, then
6979 the size of the entire @code{struct S} type is 6 bytes. The smallest
6980 power of two that is greater than or equal to that is 8, so the
6981 compiler sets the alignment for the entire @code{struct S} type to 8
6984 Note that although you can ask the compiler to select a time-efficient
6985 alignment for a given type and then declare only individual stand-alone
6986 objects of that type, the compiler's ability to select a time-efficient
6987 alignment is primarily useful only when you plan to create arrays of
6988 variables having the relevant (efficiently aligned) type. If you
6989 declare or use arrays of variables of an efficiently-aligned type, then
6990 it is likely that your program also does pointer arithmetic (or
6991 subscripting, which amounts to the same thing) on pointers to the
6992 relevant type, and the code that the compiler generates for these
6993 pointer arithmetic operations is often more efficient for
6994 efficiently-aligned types than for other types.
6996 Note that the effectiveness of @code{aligned} attributes may be limited
6997 by inherent limitations in your linker. On many systems, the linker is
6998 only able to arrange for variables to be aligned up to a certain maximum
6999 alignment. (For some linkers, the maximum supported alignment may
7000 be very very small.) If your linker is only able to align variables
7001 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
7002 in an @code{__attribute__} still only provides you with 8-byte
7003 alignment. See your linker documentation for further information.
7005 The @code{aligned} attribute can only increase alignment. Alignment
7006 can be decreased by specifying the @code{packed} attribute. See below.
7008 @cindex @code{warn_if_not_aligned} type attribute
7009 @item warn_if_not_aligned (@var{alignment})
7010 This attribute specifies a threshold for the structure field, measured
7011 in bytes. If the structure field is aligned below the threshold, a
7012 warning will be issued. For example, the declaration:
7015 typedef unsigned long long __u64
7016 __attribute__((aligned(4),warn_if_not_aligned(8)));
7027 causes the compiler to issue an warning on @code{struct foo}, like
7028 @samp{warning: alignment 4 of 'struct foo' is less than 8}.
7029 It is used to define @code{struct foo} in such a way that
7030 @code{struct foo} has the same layout and the structure field @code{x}
7031 has the same alignment when @code{__u64} is aligned at either 4 or
7032 8 bytes. Align @code{struct foo} to 8 bytes:
7040 @} __attribute__((aligned(8)));
7044 silences the warning. The compiler also issues a warning, like
7045 @samp{warning: 'x' offset 12 in 'struct foo' isn't aligned to 8},
7046 when the structure field has the misaligned offset:
7055 @} __attribute__((aligned(8)));
7058 This warning can be disabled by @option{-Wno-if-not-aligned}.
7061 @itemx deprecated (@var{msg})
7062 @cindex @code{deprecated} type attribute
7063 The @code{deprecated} attribute results in a warning if the type
7064 is used anywhere in the source file. This is useful when identifying
7065 types that are expected to be removed in a future version of a program.
7066 If possible, the warning also includes the location of the declaration
7067 of the deprecated type, to enable users to easily find further
7068 information about why the type is deprecated, or what they should do
7069 instead. Note that the warnings only occur for uses and then only
7070 if the type is being applied to an identifier that itself is not being
7071 declared as deprecated.
7074 typedef int T1 __attribute__ ((deprecated));
7078 typedef T1 T3 __attribute__ ((deprecated));
7079 T3 z __attribute__ ((deprecated));
7083 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
7084 warning is issued for line 4 because T2 is not explicitly
7085 deprecated. Line 5 has no warning because T3 is explicitly
7086 deprecated. Similarly for line 6. The optional @var{msg}
7087 argument, which must be a string, is printed in the warning if
7088 present. Control characters in the string will be replaced with
7089 escape sequences, and if the @option{-fmessage-length} option is set
7090 to 0 (its default value) then any newline characters will be ignored.
7092 The @code{deprecated} attribute can also be used for functions and
7093 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
7095 The message attached to the attribute is affected by the setting of
7096 the @option{-fmessage-length} option.
7098 @item designated_init
7099 @cindex @code{designated_init} type attribute
7100 This attribute may only be applied to structure types. It indicates
7101 that any initialization of an object of this type must use designated
7102 initializers rather than positional initializers. The intent of this
7103 attribute is to allow the programmer to indicate that a structure's
7104 layout may change, and that therefore relying on positional
7105 initialization will result in future breakage.
7107 GCC emits warnings based on this attribute by default; use
7108 @option{-Wno-designated-init} to suppress them.
7111 @cindex @code{may_alias} type attribute
7112 Accesses through pointers to types with this attribute are not subject
7113 to type-based alias analysis, but are instead assumed to be able to alias
7114 any other type of objects.
7115 In the context of section 6.5 paragraph 7 of the C99 standard,
7116 an lvalue expression
7117 dereferencing such a pointer is treated like having a character type.
7118 See @option{-fstrict-aliasing} for more information on aliasing issues.
7119 This extension exists to support some vector APIs, in which pointers to
7120 one vector type are permitted to alias pointers to a different vector type.
7122 Note that an object of a type with this attribute does not have any
7128 typedef short __attribute__((__may_alias__)) short_a;
7134 short_a *b = (short_a *) &a;
7138 if (a == 0x12345678)
7146 If you replaced @code{short_a} with @code{short} in the variable
7147 declaration, the above program would abort when compiled with
7148 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
7151 @item mode (@var{mode})
7152 @cindex @code{mode} type attribute
7153 This attribute specifies the data type for the declaration---whichever
7154 type corresponds to the mode @var{mode}. This in effect lets you
7155 request an integer or floating-point type according to its width.
7157 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
7158 for a list of the possible keywords for @var{mode}.
7159 You may also specify a mode of @code{byte} or @code{__byte__} to
7160 indicate the mode corresponding to a one-byte integer, @code{word} or
7161 @code{__word__} for the mode of a one-word integer, and @code{pointer}
7162 or @code{__pointer__} for the mode used to represent pointers.
7165 @cindex @code{packed} type attribute
7166 This attribute, attached to @code{struct} or @code{union} type
7167 definition, specifies that each member (other than zero-width bit-fields)
7168 of the structure or union is placed to minimize the memory required. When
7169 attached to an @code{enum} definition, it indicates that the smallest
7170 integral type should be used.
7172 @opindex fshort-enums
7173 Specifying the @code{packed} attribute for @code{struct} and @code{union}
7174 types is equivalent to specifying the @code{packed} attribute on each
7175 of the structure or union members. Specifying the @option{-fshort-enums}
7176 flag on the command line is equivalent to specifying the @code{packed}
7177 attribute on all @code{enum} definitions.
7179 In the following example @code{struct my_packed_struct}'s members are
7180 packed closely together, but the internal layout of its @code{s} member
7181 is not packed---to do that, @code{struct my_unpacked_struct} needs to
7185 struct my_unpacked_struct
7191 struct __attribute__ ((__packed__)) my_packed_struct
7195 struct my_unpacked_struct s;
7199 You may only specify the @code{packed} attribute attribute on the definition
7200 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
7201 that does not also define the enumerated type, structure or union.
7203 @item scalar_storage_order ("@var{endianness}")
7204 @cindex @code{scalar_storage_order} type attribute
7205 When attached to a @code{union} or a @code{struct}, this attribute sets
7206 the storage order, aka endianness, of the scalar fields of the type, as
7207 well as the array fields whose component is scalar. The supported
7208 endiannesses are @code{big-endian} and @code{little-endian}. The attribute
7209 has no effects on fields which are themselves a @code{union}, a @code{struct}
7210 or an array whose component is a @code{union} or a @code{struct}, and it is
7211 possible for these fields to have a different scalar storage order than the
7214 This attribute is supported only for targets that use a uniform default
7215 scalar storage order (fortunately, most of them), i.e. targets that store
7216 the scalars either all in big-endian or all in little-endian.
7218 Additional restrictions are enforced for types with the reverse scalar
7219 storage order with regard to the scalar storage order of the target:
7222 @item Taking the address of a scalar field of a @code{union} or a
7223 @code{struct} with reverse scalar storage order is not permitted and yields
7225 @item Taking the address of an array field, whose component is scalar, of
7226 a @code{union} or a @code{struct} with reverse scalar storage order is
7227 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
7229 @item Taking the address of a @code{union} or a @code{struct} with reverse
7230 scalar storage order is permitted.
7233 These restrictions exist because the storage order attribute is lost when
7234 the address of a scalar or the address of an array with scalar component is
7235 taken, so storing indirectly through this address generally does not work.
7236 The second case is nevertheless allowed to be able to perform a block copy
7237 from or to the array.
7239 Moreover, the use of type punning or aliasing to toggle the storage order
7240 is not supported; that is to say, a given scalar object cannot be accessed
7241 through distinct types that assign a different storage order to it.
7243 @item transparent_union
7244 @cindex @code{transparent_union} type attribute
7246 This attribute, attached to a @code{union} type definition, indicates
7247 that any function parameter having that union type causes calls to that
7248 function to be treated in a special way.
7250 First, the argument corresponding to a transparent union type can be of
7251 any type in the union; no cast is required. Also, if the union contains
7252 a pointer type, the corresponding argument can be a null pointer
7253 constant or a void pointer expression; and if the union contains a void
7254 pointer type, the corresponding argument can be any pointer expression.
7255 If the union member type is a pointer, qualifiers like @code{const} on
7256 the referenced type must be respected, just as with normal pointer
7259 Second, the argument is passed to the function using the calling
7260 conventions of the first member of the transparent union, not the calling
7261 conventions of the union itself. All members of the union must have the
7262 same machine representation; this is necessary for this argument passing
7265 Transparent unions are designed for library functions that have multiple
7266 interfaces for compatibility reasons. For example, suppose the
7267 @code{wait} function must accept either a value of type @code{int *} to
7268 comply with POSIX, or a value of type @code{union wait *} to comply with
7269 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
7270 @code{wait} would accept both kinds of arguments, but it would also
7271 accept any other pointer type and this would make argument type checking
7272 less useful. Instead, @code{<sys/wait.h>} might define the interface
7276 typedef union __attribute__ ((__transparent_union__))
7280 @} wait_status_ptr_t;
7282 pid_t wait (wait_status_ptr_t);
7286 This interface allows either @code{int *} or @code{union wait *}
7287 arguments to be passed, using the @code{int *} calling convention.
7288 The program can call @code{wait} with arguments of either type:
7291 int w1 () @{ int w; return wait (&w); @}
7292 int w2 () @{ union wait w; return wait (&w); @}
7296 With this interface, @code{wait}'s implementation might look like this:
7299 pid_t wait (wait_status_ptr_t p)
7301 return waitpid (-1, p.__ip, 0);
7306 @cindex @code{unused} type attribute
7307 When attached to a type (including a @code{union} or a @code{struct}),
7308 this attribute means that variables of that type are meant to appear
7309 possibly unused. GCC does not produce a warning for any variables of
7310 that type, even if the variable appears to do nothing. This is often
7311 the case with lock or thread classes, which are usually defined and then
7312 not referenced, but contain constructors and destructors that have
7313 nontrivial bookkeeping functions.
7316 @cindex @code{visibility} type attribute
7317 In C++, attribute visibility (@pxref{Function Attributes}) can also be
7318 applied to class, struct, union and enum types. Unlike other type
7319 attributes, the attribute must appear between the initial keyword and
7320 the name of the type; it cannot appear after the body of the type.
7322 Note that the type visibility is applied to vague linkage entities
7323 associated with the class (vtable, typeinfo node, etc.). In
7324 particular, if a class is thrown as an exception in one shared object
7325 and caught in another, the class must have default visibility.
7326 Otherwise the two shared objects are unable to use the same
7327 typeinfo node and exception handling will break.
7331 To specify multiple attributes, separate them by commas within the
7332 double parentheses: for example, @samp{__attribute__ ((aligned (16),
7335 @node ARC Type Attributes
7336 @subsection ARC Type Attributes
7338 @cindex @code{uncached} type attribute, ARC
7339 Declaring objects with @code{uncached} allows you to exclude
7340 data-cache participation in load and store operations on those objects
7341 without involving the additional semantic implications of
7342 @code{volatile}. The @code{.di} instruction suffix is used for all
7343 loads and stores of data declared @code{uncached}.
7345 @node ARM Type Attributes
7346 @subsection ARM Type Attributes
7348 @cindex @code{notshared} type attribute, ARM
7349 On those ARM targets that support @code{dllimport} (such as Symbian
7350 OS), you can use the @code{notshared} attribute to indicate that the
7351 virtual table and other similar data for a class should not be
7352 exported from a DLL@. For example:
7355 class __declspec(notshared) C @{
7357 __declspec(dllimport) C();
7361 __declspec(dllexport)
7366 In this code, @code{C::C} is exported from the current DLL, but the
7367 virtual table for @code{C} is not exported. (You can use
7368 @code{__attribute__} instead of @code{__declspec} if you prefer, but
7369 most Symbian OS code uses @code{__declspec}.)
7371 @node MeP Type Attributes
7372 @subsection MeP Type Attributes
7374 @cindex @code{based} type attribute, MeP
7375 @cindex @code{tiny} type attribute, MeP
7376 @cindex @code{near} type attribute, MeP
7377 @cindex @code{far} type attribute, MeP
7378 Many of the MeP variable attributes may be applied to types as well.
7379 Specifically, the @code{based}, @code{tiny}, @code{near}, and
7380 @code{far} attributes may be applied to either. The @code{io} and
7381 @code{cb} attributes may not be applied to types.
7383 @node PowerPC Type Attributes
7384 @subsection PowerPC Type Attributes
7386 Three attributes currently are defined for PowerPC configurations:
7387 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7389 @cindex @code{ms_struct} type attribute, PowerPC
7390 @cindex @code{gcc_struct} type attribute, PowerPC
7391 For full documentation of the @code{ms_struct} and @code{gcc_struct}
7392 attributes please see the documentation in @ref{x86 Type Attributes}.
7394 @cindex @code{altivec} type attribute, PowerPC
7395 The @code{altivec} attribute allows one to declare AltiVec vector data
7396 types supported by the AltiVec Programming Interface Manual. The
7397 attribute requires an argument to specify one of three vector types:
7398 @code{vector__}, @code{pixel__} (always followed by unsigned short),
7399 and @code{bool__} (always followed by unsigned).
7402 __attribute__((altivec(vector__)))
7403 __attribute__((altivec(pixel__))) unsigned short
7404 __attribute__((altivec(bool__))) unsigned
7407 These attributes mainly are intended to support the @code{__vector},
7408 @code{__pixel}, and @code{__bool} AltiVec keywords.
7410 @node SPU Type Attributes
7411 @subsection SPU Type Attributes
7413 @cindex @code{spu_vector} type attribute, SPU
7414 The SPU supports the @code{spu_vector} attribute for types. This attribute
7415 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
7416 Language Extensions Specification. It is intended to support the
7417 @code{__vector} keyword.
7419 @node x86 Type Attributes
7420 @subsection x86 Type Attributes
7422 Two attributes are currently defined for x86 configurations:
7423 @code{ms_struct} and @code{gcc_struct}.
7429 @cindex @code{ms_struct} type attribute, x86
7430 @cindex @code{gcc_struct} type attribute, x86
7432 If @code{packed} is used on a structure, or if bit-fields are used
7433 it may be that the Microsoft ABI packs them differently
7434 than GCC normally packs them. Particularly when moving packed
7435 data between functions compiled with GCC and the native Microsoft compiler
7436 (either via function call or as data in a file), it may be necessary to access
7439 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7440 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7441 command-line options, respectively;
7442 see @ref{x86 Options}, for details of how structure layout is affected.
7443 @xref{x86 Variable Attributes}, for information about the corresponding
7444 attributes on variables.
7448 @node Label Attributes
7449 @section Label Attributes
7450 @cindex Label Attributes
7452 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
7453 details of the exact syntax for using attributes. Other attributes are
7454 available for functions (@pxref{Function Attributes}), variables
7455 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
7456 statements (@pxref{Statement Attributes}), and for types
7457 (@pxref{Type Attributes}).
7459 This example uses the @code{cold} label attribute to indicate the
7460 @code{ErrorHandling} branch is unlikely to be taken and that the
7461 @code{ErrorHandling} label is unused:
7465 asm goto ("some asm" : : : : NoError);
7467 /* This branch (the fall-through from the asm) is less commonly used */
7469 __attribute__((cold, unused)); /* Semi-colon is required here */
7474 printf("no error\n");
7480 @cindex @code{unused} label attribute
7481 This feature is intended for program-generated code that may contain
7482 unused labels, but which is compiled with @option{-Wall}. It is
7483 not normally appropriate to use in it human-written code, though it
7484 could be useful in cases where the code that jumps to the label is
7485 contained within an @code{#ifdef} conditional.
7488 @cindex @code{hot} label attribute
7489 The @code{hot} attribute on a label is used to inform the compiler that
7490 the path following the label is more likely than paths that are not so
7491 annotated. This attribute is used in cases where @code{__builtin_expect}
7492 cannot be used, for instance with computed goto or @code{asm goto}.
7495 @cindex @code{cold} label attribute
7496 The @code{cold} attribute on labels is used to inform the compiler that
7497 the path following the label is unlikely to be executed. This attribute
7498 is used in cases where @code{__builtin_expect} cannot be used, for instance
7499 with computed goto or @code{asm goto}.
7503 @node Enumerator Attributes
7504 @section Enumerator Attributes
7505 @cindex Enumerator Attributes
7507 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
7508 details of the exact syntax for using attributes. Other attributes are
7509 available for functions (@pxref{Function Attributes}), variables
7510 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
7511 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
7513 This example uses the @code{deprecated} enumerator attribute to indicate the
7514 @code{oldval} enumerator is deprecated:
7518 oldval __attribute__((deprecated)),
7531 @cindex @code{deprecated} enumerator attribute
7532 The @code{deprecated} attribute results in a warning if the enumerator
7533 is used anywhere in the source file. This is useful when identifying
7534 enumerators that are expected to be removed in a future version of a
7535 program. The warning also includes the location of the declaration
7536 of the deprecated enumerator, to enable users to easily find further
7537 information about why the enumerator is deprecated, or what they should
7538 do instead. Note that the warnings only occurs for uses.
7542 @node Statement Attributes
7543 @section Statement Attributes
7544 @cindex Statement Attributes
7546 GCC allows attributes to be set on null statements. @xref{Attribute Syntax},
7547 for details of the exact syntax for using attributes. Other attributes are
7548 available for functions (@pxref{Function Attributes}), variables
7549 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7550 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7552 This example uses the @code{fallthrough} statement attribute to indicate that
7553 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7560 __attribute__((fallthrough));
7568 @cindex @code{fallthrough} statement attribute
7569 The @code{fallthrough} attribute with a null statement serves as a
7570 fallthrough statement. It hints to the compiler that a statement
7571 that falls through to another case label, or user-defined label
7572 in a switch statement is intentional and thus the
7573 @option{-Wimplicit-fallthrough} warning must not trigger. The
7574 fallthrough attribute may appear at most once in each attribute
7575 list, and may not be mixed with other attributes. It can only
7576 be used in a switch statement (the compiler will issue an error
7577 otherwise), after a preceding statement and before a logically
7578 succeeding case label, or user-defined label.
7582 @node Attribute Syntax
7583 @section Attribute Syntax
7584 @cindex attribute syntax
7586 This section describes the syntax with which @code{__attribute__} may be
7587 used, and the constructs to which attribute specifiers bind, for the C
7588 language. Some details may vary for C++ and Objective-C@. Because of
7589 infelicities in the grammar for attributes, some forms described here
7590 may not be successfully parsed in all cases.
7592 There are some problems with the semantics of attributes in C++. For
7593 example, there are no manglings for attributes, although they may affect
7594 code generation, so problems may arise when attributed types are used in
7595 conjunction with templates or overloading. Similarly, @code{typeid}
7596 does not distinguish between types with different attributes. Support
7597 for attributes in C++ may be restricted in future to attributes on
7598 declarations only, but not on nested declarators.
7600 @xref{Function Attributes}, for details of the semantics of attributes
7601 applying to functions. @xref{Variable Attributes}, for details of the
7602 semantics of attributes applying to variables. @xref{Type Attributes},
7603 for details of the semantics of attributes applying to structure, union
7604 and enumerated types.
7605 @xref{Label Attributes}, for details of the semantics of attributes
7607 @xref{Enumerator Attributes}, for details of the semantics of attributes
7608 applying to enumerators.
7609 @xref{Statement Attributes}, for details of the semantics of attributes
7610 applying to statements.
7612 An @dfn{attribute specifier} is of the form
7613 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
7614 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7615 each attribute is one of the following:
7619 Empty. Empty attributes are ignored.
7623 (which may be an identifier such as @code{unused}, or a reserved
7624 word such as @code{const}).
7627 An attribute name followed by a parenthesized list of
7628 parameters for the attribute.
7629 These parameters take one of the following forms:
7633 An identifier. For example, @code{mode} attributes use this form.
7636 An identifier followed by a comma and a non-empty comma-separated list
7637 of expressions. For example, @code{format} attributes use this form.
7640 A possibly empty comma-separated list of expressions. For example,
7641 @code{format_arg} attributes use this form with the list being a single
7642 integer constant expression, and @code{alias} attributes use this form
7643 with the list being a single string constant.
7647 An @dfn{attribute specifier list} is a sequence of one or more attribute
7648 specifiers, not separated by any other tokens.
7650 You may optionally specify attribute names with @samp{__}
7651 preceding and following the name.
7652 This allows you to use them in header files without
7653 being concerned about a possible macro of the same name. For example,
7654 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7657 @subsubheading Label Attributes
7659 In GNU C, an attribute specifier list may appear after the colon following a
7660 label, other than a @code{case} or @code{default} label. GNU C++ only permits
7661 attributes on labels if the attribute specifier is immediately
7662 followed by a semicolon (i.e., the label applies to an empty
7663 statement). If the semicolon is missing, C++ label attributes are
7664 ambiguous, as it is permissible for a declaration, which could begin
7665 with an attribute list, to be labelled in C++. Declarations cannot be
7666 labelled in C90 or C99, so the ambiguity does not arise there.
7668 @subsubheading Enumerator Attributes
7670 In GNU C, an attribute specifier list may appear as part of an enumerator.
7671 The attribute goes after the enumeration constant, before @code{=}, if
7672 present. The optional attribute in the enumerator appertains to the
7673 enumeration constant. It is not possible to place the attribute after
7674 the constant expression, if present.
7676 @subsubheading Statement Attributes
7677 In GNU C, an attribute specifier list may appear as part of a null
7678 statement. The attribute goes before the semicolon.
7680 @subsubheading Type Attributes
7682 An attribute specifier list may appear as part of a @code{struct},
7683 @code{union} or @code{enum} specifier. It may go either immediately
7684 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7685 the closing brace. The former syntax is preferred.
7686 Where attribute specifiers follow the closing brace, they are considered
7687 to relate to the structure, union or enumerated type defined, not to any
7688 enclosing declaration the type specifier appears in, and the type
7689 defined is not complete until after the attribute specifiers.
7690 @c Otherwise, there would be the following problems: a shift/reduce
7691 @c conflict between attributes binding the struct/union/enum and
7692 @c binding to the list of specifiers/qualifiers; and "aligned"
7693 @c attributes could use sizeof for the structure, but the size could be
7694 @c changed later by "packed" attributes.
7697 @subsubheading All other attributes
7699 Otherwise, an attribute specifier appears as part of a declaration,
7700 counting declarations of unnamed parameters and type names, and relates
7701 to that declaration (which may be nested in another declaration, for
7702 example in the case of a parameter declaration), or to a particular declarator
7703 within a declaration. Where an
7704 attribute specifier is applied to a parameter declared as a function or
7705 an array, it should apply to the function or array rather than the
7706 pointer to which the parameter is implicitly converted, but this is not
7707 yet correctly implemented.
7709 Any list of specifiers and qualifiers at the start of a declaration may
7710 contain attribute specifiers, whether or not such a list may in that
7711 context contain storage class specifiers. (Some attributes, however,
7712 are essentially in the nature of storage class specifiers, and only make
7713 sense where storage class specifiers may be used; for example,
7714 @code{section}.) There is one necessary limitation to this syntax: the
7715 first old-style parameter declaration in a function definition cannot
7716 begin with an attribute specifier, because such an attribute applies to
7717 the function instead by syntax described below (which, however, is not
7718 yet implemented in this case). In some other cases, attribute
7719 specifiers are permitted by this grammar but not yet supported by the
7720 compiler. All attribute specifiers in this place relate to the
7721 declaration as a whole. In the obsolescent usage where a type of
7722 @code{int} is implied by the absence of type specifiers, such a list of
7723 specifiers and qualifiers may be an attribute specifier list with no
7724 other specifiers or qualifiers.
7726 At present, the first parameter in a function prototype must have some
7727 type specifier that is not an attribute specifier; this resolves an
7728 ambiguity in the interpretation of @code{void f(int
7729 (__attribute__((foo)) x))}, but is subject to change. At present, if
7730 the parentheses of a function declarator contain only attributes then
7731 those attributes are ignored, rather than yielding an error or warning
7732 or implying a single parameter of type int, but this is subject to
7735 An attribute specifier list may appear immediately before a declarator
7736 (other than the first) in a comma-separated list of declarators in a
7737 declaration of more than one identifier using a single list of
7738 specifiers and qualifiers. Such attribute specifiers apply
7739 only to the identifier before whose declarator they appear. For
7743 __attribute__((noreturn)) void d0 (void),
7744 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7749 the @code{noreturn} attribute applies to all the functions
7750 declared; the @code{format} attribute only applies to @code{d1}.
7752 An attribute specifier list may appear immediately before the comma,
7753 @code{=} or semicolon terminating the declaration of an identifier other
7754 than a function definition. Such attribute specifiers apply
7755 to the declared object or function. Where an
7756 assembler name for an object or function is specified (@pxref{Asm
7757 Labels}), the attribute must follow the @code{asm}
7760 An attribute specifier list may, in future, be permitted to appear after
7761 the declarator in a function definition (before any old-style parameter
7762 declarations or the function body).
7764 Attribute specifiers may be mixed with type qualifiers appearing inside
7765 the @code{[]} of a parameter array declarator, in the C99 construct by
7766 which such qualifiers are applied to the pointer to which the array is
7767 implicitly converted. Such attribute specifiers apply to the pointer,
7768 not to the array, but at present this is not implemented and they are
7771 An attribute specifier list may appear at the start of a nested
7772 declarator. At present, there are some limitations in this usage: the
7773 attributes correctly apply to the declarator, but for most individual
7774 attributes the semantics this implies are not implemented.
7775 When attribute specifiers follow the @code{*} of a pointer
7776 declarator, they may be mixed with any type qualifiers present.
7777 The following describes the formal semantics of this syntax. It makes the
7778 most sense if you are familiar with the formal specification of
7779 declarators in the ISO C standard.
7781 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7782 D1}, where @code{T} contains declaration specifiers that specify a type
7783 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7784 contains an identifier @var{ident}. The type specified for @var{ident}
7785 for derived declarators whose type does not include an attribute
7786 specifier is as in the ISO C standard.
7788 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7789 and the declaration @code{T D} specifies the type
7790 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7791 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7792 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7794 If @code{D1} has the form @code{*
7795 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7796 declaration @code{T D} specifies the type
7797 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7798 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7799 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7805 void (__attribute__((noreturn)) ****f) (void);
7809 specifies the type ``pointer to pointer to pointer to pointer to
7810 non-returning function returning @code{void}''. As another example,
7813 char *__attribute__((aligned(8))) *f;
7817 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7818 Note again that this does not work with most attributes; for example,
7819 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7820 is not yet supported.
7822 For compatibility with existing code written for compiler versions that
7823 did not implement attributes on nested declarators, some laxity is
7824 allowed in the placing of attributes. If an attribute that only applies
7825 to types is applied to a declaration, it is treated as applying to
7826 the type of that declaration. If an attribute that only applies to
7827 declarations is applied to the type of a declaration, it is treated
7828 as applying to that declaration; and, for compatibility with code
7829 placing the attributes immediately before the identifier declared, such
7830 an attribute applied to a function return type is treated as
7831 applying to the function type, and such an attribute applied to an array
7832 element type is treated as applying to the array type. If an
7833 attribute that only applies to function types is applied to a
7834 pointer-to-function type, it is treated as applying to the pointer
7835 target type; if such an attribute is applied to a function return type
7836 that is not a pointer-to-function type, it is treated as applying
7837 to the function type.
7839 @node Function Prototypes
7840 @section Prototypes and Old-Style Function Definitions
7841 @cindex function prototype declarations
7842 @cindex old-style function definitions
7843 @cindex promotion of formal parameters
7845 GNU C extends ISO C to allow a function prototype to override a later
7846 old-style non-prototype definition. Consider the following example:
7849 /* @r{Use prototypes unless the compiler is old-fashioned.} */
7856 /* @r{Prototype function declaration.} */
7857 int isroot P((uid_t));
7859 /* @r{Old-style function definition.} */
7861 isroot (x) /* @r{??? lossage here ???} */
7868 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
7869 not allow this example, because subword arguments in old-style
7870 non-prototype definitions are promoted. Therefore in this example the
7871 function definition's argument is really an @code{int}, which does not
7872 match the prototype argument type of @code{short}.
7874 This restriction of ISO C makes it hard to write code that is portable
7875 to traditional C compilers, because the programmer does not know
7876 whether the @code{uid_t} type is @code{short}, @code{int}, or
7877 @code{long}. Therefore, in cases like these GNU C allows a prototype
7878 to override a later old-style definition. More precisely, in GNU C, a
7879 function prototype argument type overrides the argument type specified
7880 by a later old-style definition if the former type is the same as the
7881 latter type before promotion. Thus in GNU C the above example is
7882 equivalent to the following:
7895 GNU C++ does not support old-style function definitions, so this
7896 extension is irrelevant.
7899 @section C++ Style Comments
7901 @cindex C++ comments
7902 @cindex comments, C++ style
7904 In GNU C, you may use C++ style comments, which start with @samp{//} and
7905 continue until the end of the line. Many other C implementations allow
7906 such comments, and they are included in the 1999 C standard. However,
7907 C++ style comments are not recognized if you specify an @option{-std}
7908 option specifying a version of ISO C before C99, or @option{-ansi}
7909 (equivalent to @option{-std=c90}).
7912 @section Dollar Signs in Identifier Names
7914 @cindex dollar signs in identifier names
7915 @cindex identifier names, dollar signs in
7917 In GNU C, you may normally use dollar signs in identifier names.
7918 This is because many traditional C implementations allow such identifiers.
7919 However, dollar signs in identifiers are not supported on a few target
7920 machines, typically because the target assembler does not allow them.
7922 @node Character Escapes
7923 @section The Character @key{ESC} in Constants
7925 You can use the sequence @samp{\e} in a string or character constant to
7926 stand for the ASCII character @key{ESC}.
7929 @section Inquiring on Alignment of Types or Variables
7931 @cindex type alignment
7932 @cindex variable alignment
7934 The keyword @code{__alignof__} allows you to inquire about how an object
7935 is aligned, or the minimum alignment usually required by a type. Its
7936 syntax is just like @code{sizeof}.
7938 For example, if the target machine requires a @code{double} value to be
7939 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7940 This is true on many RISC machines. On more traditional machine
7941 designs, @code{__alignof__ (double)} is 4 or even 2.
7943 Some machines never actually require alignment; they allow reference to any
7944 data type even at an odd address. For these machines, @code{__alignof__}
7945 reports the smallest alignment that GCC gives the data type, usually as
7946 mandated by the target ABI.
7948 If the operand of @code{__alignof__} is an lvalue rather than a type,
7949 its value is the required alignment for its type, taking into account
7950 any minimum alignment specified with GCC's @code{__attribute__}
7951 extension (@pxref{Variable Attributes}). For example, after this
7955 struct foo @{ int x; char y; @} foo1;
7959 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7960 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7962 It is an error to ask for the alignment of an incomplete type.
7966 @section An Inline Function is As Fast As a Macro
7967 @cindex inline functions
7968 @cindex integrating function code
7970 @cindex macros, inline alternative
7972 By declaring a function inline, you can direct GCC to make
7973 calls to that function faster. One way GCC can achieve this is to
7974 integrate that function's code into the code for its callers. This
7975 makes execution faster by eliminating the function-call overhead; in
7976 addition, if any of the actual argument values are constant, their
7977 known values may permit simplifications at compile time so that not
7978 all of the inline function's code needs to be included. The effect on
7979 code size is less predictable; object code may be larger or smaller
7980 with function inlining, depending on the particular case. You can
7981 also direct GCC to try to integrate all ``simple enough'' functions
7982 into their callers with the option @option{-finline-functions}.
7984 GCC implements three different semantics of declaring a function
7985 inline. One is available with @option{-std=gnu89} or
7986 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7987 on all inline declarations, another when
7989 @option{-std=gnu99} or an option for a later C version is used
7990 (without @option{-fgnu89-inline}), and the third
7991 is used when compiling C++.
7993 To declare a function inline, use the @code{inline} keyword in its
7994 declaration, like this:
8004 If you are writing a header file to be included in ISO C90 programs, write
8005 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
8007 The three types of inlining behave similarly in two important cases:
8008 when the @code{inline} keyword is used on a @code{static} function,
8009 like the example above, and when a function is first declared without
8010 using the @code{inline} keyword and then is defined with
8011 @code{inline}, like this:
8014 extern int inc (int *a);
8022 In both of these common cases, the program behaves the same as if you
8023 had not used the @code{inline} keyword, except for its speed.
8025 @cindex inline functions, omission of
8026 @opindex fkeep-inline-functions
8027 When a function is both inline and @code{static}, if all calls to the
8028 function are integrated into the caller, and the function's address is
8029 never used, then the function's own assembler code is never referenced.
8030 In this case, GCC does not actually output assembler code for the
8031 function, unless you specify the option @option{-fkeep-inline-functions}.
8032 If there is a nonintegrated call, then the function is compiled to
8033 assembler code as usual. The function must also be compiled as usual if
8034 the program refers to its address, because that cannot be inlined.
8037 Note that certain usages in a function definition can make it unsuitable
8038 for inline substitution. Among these usages are: variadic functions,
8039 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
8040 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
8041 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
8042 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
8043 function marked @code{inline} could not be substituted, and gives the
8044 reason for the failure.
8046 @cindex automatic @code{inline} for C++ member fns
8047 @cindex @code{inline} automatic for C++ member fns
8048 @cindex member fns, automatically @code{inline}
8049 @cindex C++ member fns, automatically @code{inline}
8050 @opindex fno-default-inline
8051 As required by ISO C++, GCC considers member functions defined within
8052 the body of a class to be marked inline even if they are
8053 not explicitly declared with the @code{inline} keyword. You can
8054 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
8055 Options,,Options Controlling C++ Dialect}.
8057 GCC does not inline any functions when not optimizing unless you specify
8058 the @samp{always_inline} attribute for the function, like this:
8061 /* @r{Prototype.} */
8062 inline void foo (const char) __attribute__((always_inline));
8065 The remainder of this section is specific to GNU C90 inlining.
8067 @cindex non-static inline function
8068 When an inline function is not @code{static}, then the compiler must assume
8069 that there may be calls from other source files; since a global symbol can
8070 be defined only once in any program, the function must not be defined in
8071 the other source files, so the calls therein cannot be integrated.
8072 Therefore, a non-@code{static} inline function is always compiled on its
8073 own in the usual fashion.
8075 If you specify both @code{inline} and @code{extern} in the function
8076 definition, then the definition is used only for inlining. In no case
8077 is the function compiled on its own, not even if you refer to its
8078 address explicitly. Such an address becomes an external reference, as
8079 if you had only declared the function, and had not defined it.
8081 This combination of @code{inline} and @code{extern} has almost the
8082 effect of a macro. The way to use it is to put a function definition in
8083 a header file with these keywords, and put another copy of the
8084 definition (lacking @code{inline} and @code{extern}) in a library file.
8085 The definition in the header file causes most calls to the function
8086 to be inlined. If any uses of the function remain, they refer to
8087 the single copy in the library.
8090 @section When is a Volatile Object Accessed?
8091 @cindex accessing volatiles
8092 @cindex volatile read
8093 @cindex volatile write
8094 @cindex volatile access
8096 C has the concept of volatile objects. These are normally accessed by
8097 pointers and used for accessing hardware or inter-thread
8098 communication. The standard encourages compilers to refrain from
8099 optimizations concerning accesses to volatile objects, but leaves it
8100 implementation defined as to what constitutes a volatile access. The
8101 minimum requirement is that at a sequence point all previous accesses
8102 to volatile objects have stabilized and no subsequent accesses have
8103 occurred. Thus an implementation is free to reorder and combine
8104 volatile accesses that occur between sequence points, but cannot do
8105 so for accesses across a sequence point. The use of volatile does
8106 not allow you to violate the restriction on updating objects multiple
8107 times between two sequence points.
8109 Accesses to non-volatile objects are not ordered with respect to
8110 volatile accesses. You cannot use a volatile object as a memory
8111 barrier to order a sequence of writes to non-volatile memory. For
8115 int *ptr = @var{something};
8117 *ptr = @var{something};
8122 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
8123 that the write to @var{*ptr} occurs by the time the update
8124 of @var{vobj} happens. If you need this guarantee, you must use
8125 a stronger memory barrier such as:
8128 int *ptr = @var{something};
8130 *ptr = @var{something};
8131 asm volatile ("" : : : "memory");
8135 A scalar volatile object is read when it is accessed in a void context:
8138 volatile int *src = @var{somevalue};
8142 Such expressions are rvalues, and GCC implements this as a
8143 read of the volatile object being pointed to.
8145 Assignments are also expressions and have an rvalue. However when
8146 assigning to a scalar volatile, the volatile object is not reread,
8147 regardless of whether the assignment expression's rvalue is used or
8148 not. If the assignment's rvalue is used, the value is that assigned
8149 to the volatile object. For instance, there is no read of @var{vobj}
8150 in all the following cases:
8155 vobj = @var{something};
8156 obj = vobj = @var{something};
8157 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
8158 obj = (@var{something}, vobj = @var{anotherthing});
8161 If you need to read the volatile object after an assignment has
8162 occurred, you must use a separate expression with an intervening
8165 As bit-fields are not individually addressable, volatile bit-fields may
8166 be implicitly read when written to, or when adjacent bit-fields are
8167 accessed. Bit-field operations may be optimized such that adjacent
8168 bit-fields are only partially accessed, if they straddle a storage unit
8169 boundary. For these reasons it is unwise to use volatile bit-fields to
8172 @node Using Assembly Language with C
8173 @section How to Use Inline Assembly Language in C Code
8174 @cindex @code{asm} keyword
8175 @cindex assembly language in C
8176 @cindex inline assembly language
8177 @cindex mixing assembly language and C
8179 The @code{asm} keyword allows you to embed assembler instructions
8180 within C code. GCC provides two forms of inline @code{asm}
8181 statements. A @dfn{basic @code{asm}} statement is one with no
8182 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
8183 statement (@pxref{Extended Asm}) includes one or more operands.
8184 The extended form is preferred for mixing C and assembly language
8185 within a function, but to include assembly language at
8186 top level you must use basic @code{asm}.
8188 You can also use the @code{asm} keyword to override the assembler name
8189 for a C symbol, or to place a C variable in a specific register.
8192 * Basic Asm:: Inline assembler without operands.
8193 * Extended Asm:: Inline assembler with operands.
8194 * Constraints:: Constraints for @code{asm} operands
8195 * Asm Labels:: Specifying the assembler name to use for a C symbol.
8196 * Explicit Register Variables:: Defining variables residing in specified
8198 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
8202 @subsection Basic Asm --- Assembler Instructions Without Operands
8203 @cindex basic @code{asm}
8204 @cindex assembly language in C, basic
8206 A basic @code{asm} statement has the following syntax:
8209 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
8212 The @code{asm} keyword is a GNU extension.
8213 When writing code that can be compiled with @option{-ansi} and the
8214 various @option{-std} options, use @code{__asm__} instead of
8215 @code{asm} (@pxref{Alternate Keywords}).
8217 @subsubheading Qualifiers
8220 The optional @code{volatile} qualifier has no effect.
8221 All basic @code{asm} blocks are implicitly volatile.
8224 @subsubheading Parameters
8227 @item AssemblerInstructions
8228 This is a literal string that specifies the assembler code. The string can
8229 contain any instructions recognized by the assembler, including directives.
8230 GCC does not parse the assembler instructions themselves and
8231 does not know what they mean or even whether they are valid assembler input.
8233 You may place multiple assembler instructions together in a single @code{asm}
8234 string, separated by the characters normally used in assembly code for the
8235 system. A combination that works in most places is a newline to break the
8236 line, plus a tab character (written as @samp{\n\t}).
8237 Some assemblers allow semicolons as a line separator. However,
8238 note that some assembler dialects use semicolons to start a comment.
8241 @subsubheading Remarks
8242 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
8243 smaller, safer, and more efficient code, and in most cases it is a
8244 better solution than basic @code{asm}. However, there are two
8245 situations where only basic @code{asm} can be used:
8249 Extended @code{asm} statements have to be inside a C
8250 function, so to write inline assembly language at file scope (``top-level''),
8251 outside of C functions, you must use basic @code{asm}.
8252 You can use this technique to emit assembler directives,
8253 define assembly language macros that can be invoked elsewhere in the file,
8254 or write entire functions in assembly language.
8258 with the @code{naked} attribute also require basic @code{asm}
8259 (@pxref{Function Attributes}).
8262 Safely accessing C data and calling functions from basic @code{asm} is more
8263 complex than it may appear. To access C data, it is better to use extended
8266 Do not expect a sequence of @code{asm} statements to remain perfectly
8267 consecutive after compilation. If certain instructions need to remain
8268 consecutive in the output, put them in a single multi-instruction @code{asm}
8269 statement. Note that GCC's optimizers can move @code{asm} statements
8270 relative to other code, including across jumps.
8272 @code{asm} statements may not perform jumps into other @code{asm} statements.
8273 GCC does not know about these jumps, and therefore cannot take
8274 account of them when deciding how to optimize. Jumps from @code{asm} to C
8275 labels are only supported in extended @code{asm}.
8277 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
8278 assembly code when optimizing. This can lead to unexpected duplicate
8279 symbol errors during compilation if your assembly code defines symbols or
8282 @strong{Warning:} The C standards do not specify semantics for @code{asm},
8283 making it a potential source of incompatibilities between compilers. These
8284 incompatibilities may not produce compiler warnings/errors.
8286 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
8287 means there is no way to communicate to the compiler what is happening
8288 inside them. GCC has no visibility of symbols in the @code{asm} and may
8289 discard them as unreferenced. It also does not know about side effects of
8290 the assembler code, such as modifications to memory or registers. Unlike
8291 some compilers, GCC assumes that no changes to general purpose registers
8292 occur. This assumption may change in a future release.
8294 To avoid complications from future changes to the semantics and the
8295 compatibility issues between compilers, consider replacing basic @code{asm}
8296 with extended @code{asm}. See
8297 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
8298 from basic asm to extended asm} for information about how to perform this
8301 The compiler copies the assembler instructions in a basic @code{asm}
8302 verbatim to the assembly language output file, without
8303 processing dialects or any of the @samp{%} operators that are available with
8304 extended @code{asm}. This results in minor differences between basic
8305 @code{asm} strings and extended @code{asm} templates. For example, to refer to
8306 registers you might use @samp{%eax} in basic @code{asm} and
8307 @samp{%%eax} in extended @code{asm}.
8309 On targets such as x86 that support multiple assembler dialects,
8310 all basic @code{asm} blocks use the assembler dialect specified by the
8311 @option{-masm} command-line option (@pxref{x86 Options}).
8312 Basic @code{asm} provides no
8313 mechanism to provide different assembler strings for different dialects.
8315 For basic @code{asm} with non-empty assembler string GCC assumes
8316 the assembler block does not change any general purpose registers,
8317 but it may read or write any globally accessible variable.
8319 Here is an example of basic @code{asm} for i386:
8322 /* Note that this code will not compile with -masm=intel */
8323 #define DebugBreak() asm("int $3")
8327 @subsection Extended Asm - Assembler Instructions with C Expression Operands
8328 @cindex extended @code{asm}
8329 @cindex assembly language in C, extended
8331 With extended @code{asm} you can read and write C variables from
8332 assembler and perform jumps from assembler code to C labels.
8333 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
8334 the operand parameters after the assembler template:
8337 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
8338 : @var{OutputOperands}
8339 @r{[} : @var{InputOperands}
8340 @r{[} : @var{Clobbers} @r{]} @r{]})
8342 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
8344 : @var{InputOperands}
8349 The @code{asm} keyword is a GNU extension.
8350 When writing code that can be compiled with @option{-ansi} and the
8351 various @option{-std} options, use @code{__asm__} instead of
8352 @code{asm} (@pxref{Alternate Keywords}).
8354 @subsubheading Qualifiers
8358 The typical use of extended @code{asm} statements is to manipulate input
8359 values to produce output values. However, your @code{asm} statements may
8360 also produce side effects. If so, you may need to use the @code{volatile}
8361 qualifier to disable certain optimizations. @xref{Volatile}.
8364 This qualifier informs the compiler that the @code{asm} statement may
8365 perform a jump to one of the labels listed in the @var{GotoLabels}.
8369 @subsubheading Parameters
8371 @item AssemblerTemplate
8372 This is a literal string that is the template for the assembler code. It is a
8373 combination of fixed text and tokens that refer to the input, output,
8374 and goto parameters. @xref{AssemblerTemplate}.
8376 @item OutputOperands
8377 A comma-separated list of the C variables modified by the instructions in the
8378 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
8381 A comma-separated list of C expressions read by the instructions in the
8382 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
8385 A comma-separated list of registers or other values changed by the
8386 @var{AssemblerTemplate}, beyond those listed as outputs.
8387 An empty list is permitted. @xref{Clobbers and Scratch Registers}.
8390 When you are using the @code{goto} form of @code{asm}, this section contains
8391 the list of all C labels to which the code in the
8392 @var{AssemblerTemplate} may jump.
8395 @code{asm} statements may not perform jumps into other @code{asm} statements,
8396 only to the listed @var{GotoLabels}.
8397 GCC's optimizers do not know about other jumps; therefore they cannot take
8398 account of them when deciding how to optimize.
8401 The total number of input + output + goto operands is limited to 30.
8403 @subsubheading Remarks
8404 The @code{asm} statement allows you to include assembly instructions directly
8405 within C code. This may help you to maximize performance in time-sensitive
8406 code or to access assembly instructions that are not readily available to C
8409 Note that extended @code{asm} statements must be inside a function. Only
8410 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
8411 Functions declared with the @code{naked} attribute also require basic
8412 @code{asm} (@pxref{Function Attributes}).
8414 While the uses of @code{asm} are many and varied, it may help to think of an
8415 @code{asm} statement as a series of low-level instructions that convert input
8416 parameters to output parameters. So a simple (if not particularly useful)
8417 example for i386 using @code{asm} might look like this:
8423 asm ("mov %1, %0\n\t"
8428 printf("%d\n", dst);
8431 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
8434 @subsubsection Volatile
8435 @cindex volatile @code{asm}
8436 @cindex @code{asm} volatile
8438 GCC's optimizers sometimes discard @code{asm} statements if they determine
8439 there is no need for the output variables. Also, the optimizers may move
8440 code out of loops if they believe that the code will always return the same
8441 result (i.e. none of its input values change between calls). Using the
8442 @code{volatile} qualifier disables these optimizations. @code{asm} statements
8443 that have no output operands, including @code{asm goto} statements,
8444 are implicitly volatile.
8446 This i386 code demonstrates a case that does not use (or require) the
8447 @code{volatile} qualifier. If it is performing assertion checking, this code
8448 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
8449 unreferenced by any code. As a result, the optimizers can discard the
8450 @code{asm} statement, which in turn removes the need for the entire
8451 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
8452 isn't needed you allow the optimizers to produce the most efficient code
8456 void DoCheck(uint32_t dwSomeValue)
8460 // Assumes dwSomeValue is not zero.
8470 The next example shows a case where the optimizers can recognize that the input
8471 (@code{dwSomeValue}) never changes during the execution of the function and can
8472 therefore move the @code{asm} outside the loop to produce more efficient code.
8473 Again, using @code{volatile} disables this type of optimization.
8476 void do_print(uint32_t dwSomeValue)
8480 for (uint32_t x=0; x < 5; x++)
8482 // Assumes dwSomeValue is not zero.
8488 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
8493 The following example demonstrates a case where you need to use the
8494 @code{volatile} qualifier.
8495 It uses the x86 @code{rdtsc} instruction, which reads
8496 the computer's time-stamp counter. Without the @code{volatile} qualifier,
8497 the optimizers might assume that the @code{asm} block will always return the
8498 same value and therefore optimize away the second call.
8503 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
8504 "shl $32, %%rdx\n\t" // Shift the upper bits left.
8505 "or %%rdx, %0" // 'Or' in the lower bits.
8510 printf("msr: %llx\n", msr);
8514 // Reprint the timestamp
8515 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
8516 "shl $32, %%rdx\n\t" // Shift the upper bits left.
8517 "or %%rdx, %0" // 'Or' in the lower bits.
8522 printf("msr: %llx\n", msr);
8525 GCC's optimizers do not treat this code like the non-volatile code in the
8526 earlier examples. They do not move it out of loops or omit it on the
8527 assumption that the result from a previous call is still valid.
8529 Note that the compiler can move even volatile @code{asm} instructions relative
8530 to other code, including across jump instructions. For example, on many
8531 targets there is a system register that controls the rounding mode of
8532 floating-point operations. Setting it with a volatile @code{asm}, as in the
8533 following PowerPC example, does not work reliably.
8536 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8540 The compiler may move the addition back before the volatile @code{asm}. To
8541 make it work as expected, add an artificial dependency to the @code{asm} by
8542 referencing a variable in the subsequent code, for example:
8545 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8549 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
8550 assembly code when optimizing. This can lead to unexpected duplicate symbol
8551 errors during compilation if your asm code defines symbols or labels.
8553 (@pxref{AssemblerTemplate}) may help resolve this problem.
8555 @anchor{AssemblerTemplate}
8556 @subsubsection Assembler Template
8557 @cindex @code{asm} assembler template
8559 An assembler template is a literal string containing assembler instructions.
8560 The compiler replaces tokens in the template that refer
8561 to inputs, outputs, and goto labels,
8562 and then outputs the resulting string to the assembler. The
8563 string can contain any instructions recognized by the assembler, including
8564 directives. GCC does not parse the assembler instructions
8565 themselves and does not know what they mean or even whether they are valid
8566 assembler input. However, it does count the statements
8567 (@pxref{Size of an asm}).
8569 You may place multiple assembler instructions together in a single @code{asm}
8570 string, separated by the characters normally used in assembly code for the
8571 system. A combination that works in most places is a newline to break the
8572 line, plus a tab character to move to the instruction field (written as
8574 Some assemblers allow semicolons as a line separator. However, note
8575 that some assembler dialects use semicolons to start a comment.
8577 Do not expect a sequence of @code{asm} statements to remain perfectly
8578 consecutive after compilation, even when you are using the @code{volatile}
8579 qualifier. If certain instructions need to remain consecutive in the output,
8580 put them in a single multi-instruction asm statement.
8582 Accessing data from C programs without using input/output operands (such as
8583 by using global symbols directly from the assembler template) may not work as
8584 expected. Similarly, calling functions directly from an assembler template
8585 requires a detailed understanding of the target assembler and ABI.
8587 Since GCC does not parse the assembler template,
8588 it has no visibility of any
8589 symbols it references. This may result in GCC discarding those symbols as
8590 unreferenced unless they are also listed as input, output, or goto operands.
8592 @subsubheading Special format strings
8594 In addition to the tokens described by the input, output, and goto operands,
8595 these tokens have special meanings in the assembler template:
8599 Outputs a single @samp{%} into the assembler code.
8602 Outputs a number that is unique to each instance of the @code{asm}
8603 statement in the entire compilation. This option is useful when creating local
8604 labels and referring to them multiple times in a single template that
8605 generates multiple assembler instructions.
8610 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8611 into the assembler code. When unescaped, these characters have special
8612 meaning to indicate multiple assembler dialects, as described below.
8615 @subsubheading Multiple assembler dialects in @code{asm} templates
8617 On targets such as x86, GCC supports multiple assembler dialects.
8618 The @option{-masm} option controls which dialect GCC uses as its
8619 default for inline assembler. The target-specific documentation for the
8620 @option{-masm} option contains the list of supported dialects, as well as the
8621 default dialect if the option is not specified. This information may be
8622 important to understand, since assembler code that works correctly when
8623 compiled using one dialect will likely fail if compiled using another.
8626 If your code needs to support multiple assembler dialects (for example, if
8627 you are writing public headers that need to support a variety of compilation
8628 options), use constructs of this form:
8631 @{ dialect0 | dialect1 | dialect2... @}
8634 This construct outputs @code{dialect0}
8635 when using dialect #0 to compile the code,
8636 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
8637 braces than the number of dialects the compiler supports, the construct
8640 For example, if an x86 compiler supports two dialects
8641 (@samp{att}, @samp{intel}), an
8642 assembler template such as this:
8645 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8649 is equivalent to one of
8652 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
8653 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
8656 Using that same compiler, this code:
8659 "xchg@{l@}\t@{%%@}ebx, %1"
8663 corresponds to either
8666 "xchgl\t%%ebx, %1" @r{/* att dialect */}
8667 "xchg\tebx, %1" @r{/* intel dialect */}
8670 There is no support for nesting dialect alternatives.
8672 @anchor{OutputOperands}
8673 @subsubsection Output Operands
8674 @cindex @code{asm} output operands
8676 An @code{asm} statement has zero or more output operands indicating the names
8677 of C variables modified by the assembler code.
8679 In this i386 example, @code{old} (referred to in the template string as
8680 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
8681 (@code{%2}) is an input:
8686 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8687 "sbb %0,%0" // Use the CF to calculate old.
8688 : "=r" (old), "+rm" (*Base)
8695 Operands are separated by commas. Each operand has this format:
8698 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8702 @item asmSymbolicName
8703 Specifies a symbolic name for the operand.
8704 Reference the name in the assembler template
8705 by enclosing it in square brackets
8706 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8707 that contains the definition. Any valid C variable name is acceptable,
8708 including names already defined in the surrounding code. No two operands
8709 within the same @code{asm} statement can use the same symbolic name.
8711 When not using an @var{asmSymbolicName}, use the (zero-based) position
8713 in the list of operands in the assembler template. For example if there are
8714 three output operands, use @samp{%0} in the template to refer to the first,
8715 @samp{%1} for the second, and @samp{%2} for the third.
8718 A string constant specifying constraints on the placement of the operand;
8719 @xref{Constraints}, for details.
8721 Output constraints must begin with either @samp{=} (a variable overwriting an
8722 existing value) or @samp{+} (when reading and writing). When using
8723 @samp{=}, do not assume the location contains the existing value
8724 on entry to the @code{asm}, except
8725 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8727 After the prefix, there must be one or more additional constraints
8728 (@pxref{Constraints}) that describe where the value resides. Common
8729 constraints include @samp{r} for register and @samp{m} for memory.
8730 When you list more than one possible location (for example, @code{"=rm"}),
8731 the compiler chooses the most efficient one based on the current context.
8732 If you list as many alternates as the @code{asm} statement allows, you permit
8733 the optimizers to produce the best possible code.
8734 If you must use a specific register, but your Machine Constraints do not
8735 provide sufficient control to select the specific register you want,
8736 local register variables may provide a solution (@pxref{Local Register
8740 Specifies a C lvalue expression to hold the output, typically a variable name.
8741 The enclosing parentheses are a required part of the syntax.
8745 When the compiler selects the registers to use to
8746 represent the output operands, it does not use any of the clobbered registers
8747 (@pxref{Clobbers and Scratch Registers}).
8749 Output operand expressions must be lvalues. The compiler cannot check whether
8750 the operands have data types that are reasonable for the instruction being
8751 executed. For output expressions that are not directly addressable (for
8752 example a bit-field), the constraint must allow a register. In that case, GCC
8753 uses the register as the output of the @code{asm}, and then stores that
8754 register into the output.
8756 Operands using the @samp{+} constraint modifier count as two operands
8757 (that is, both as input and output) towards the total maximum of 30 operands
8758 per @code{asm} statement.
8760 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8761 operands that must not overlap an input. Otherwise,
8762 GCC may allocate the output operand in the same register as an unrelated
8763 input operand, on the assumption that the assembler code consumes its
8764 inputs before producing outputs. This assumption may be false if the assembler
8765 code actually consists of more than one instruction.
8767 The same problem can occur if one output parameter (@var{a}) allows a register
8768 constraint and another output parameter (@var{b}) allows a memory constraint.
8769 The code generated by GCC to access the memory address in @var{b} can contain
8770 registers which @emph{might} be shared by @var{a}, and GCC considers those
8771 registers to be inputs to the asm. As above, GCC assumes that such input
8772 registers are consumed before any outputs are written. This assumption may
8773 result in incorrect behavior if the asm writes to @var{a} before using
8774 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8775 ensures that modifying @var{a} does not affect the address referenced by
8776 @var{b}. Otherwise, the location of @var{b}
8777 is undefined if @var{a} is modified before using @var{b}.
8779 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8780 instead of simply @samp{%2}). Typically these qualifiers are hardware
8781 dependent. The list of supported modifiers for x86 is found at
8782 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8784 If the C code that follows the @code{asm} makes no use of any of the output
8785 operands, use @code{volatile} for the @code{asm} statement to prevent the
8786 optimizers from discarding the @code{asm} statement as unneeded
8787 (see @ref{Volatile}).
8789 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
8790 references the first output operand as @code{%0} (were there a second, it
8791 would be @code{%1}, etc). The number of the first input operand is one greater
8792 than that of the last output operand. In this i386 example, that makes
8793 @code{Mask} referenced as @code{%1}:
8796 uint32_t Mask = 1234;
8805 That code overwrites the variable @code{Index} (@samp{=}),
8806 placing the value in a register (@samp{r}).
8807 Using the generic @samp{r} constraint instead of a constraint for a specific
8808 register allows the compiler to pick the register to use, which can result
8809 in more efficient code. This may not be possible if an assembler instruction
8810 requires a specific register.
8812 The following i386 example uses the @var{asmSymbolicName} syntax.
8814 same result as the code above, but some may consider it more readable or more
8815 maintainable since reordering index numbers is not necessary when adding or
8816 removing operands. The names @code{aIndex} and @code{aMask}
8817 are only used in this example to emphasize which
8818 names get used where.
8819 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8822 uint32_t Mask = 1234;
8825 asm ("bsfl %[aMask], %[aIndex]"
8826 : [aIndex] "=r" (Index)
8827 : [aMask] "r" (Mask)
8831 Here are some more examples of output operands.
8838 asm ("mov %[e], %[d]"
8843 Here, @code{d} may either be in a register or in memory. Since the compiler
8844 might already have the current value of the @code{uint32_t} location
8845 pointed to by @code{e}
8846 in a register, you can enable it to choose the best location
8847 for @code{d} by specifying both constraints.
8849 @anchor{FlagOutputOperands}
8850 @subsubsection Flag Output Operands
8851 @cindex @code{asm} flag output operands
8853 Some targets have a special register that holds the ``flags'' for the
8854 result of an operation or comparison. Normally, the contents of that
8855 register are either unmodifed by the asm, or the asm is considered to
8856 clobber the contents.
8858 On some targets, a special form of output operand exists by which
8859 conditions in the flags register may be outputs of the asm. The set of
8860 conditions supported are target specific, but the general rule is that
8861 the output variable must be a scalar integer, and the value is boolean.
8862 When supported, the target defines the preprocessor symbol
8863 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8865 Because of the special nature of the flag output operands, the constraint
8866 may not include alternatives.
8868 Most often, the target has only one flags register, and thus is an implied
8869 operand of many instructions. In this case, the operand should not be
8870 referenced within the assembler template via @code{%0} etc, as there's
8871 no corresponding text in the assembly language.
8875 The flag output constraints for the x86 family are of the form
8876 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8877 conditions defined in the ISA manual for @code{j@var{cc}} or
8882 ``above'' or unsigned greater than
8884 ``above or equal'' or unsigned greater than or equal
8886 ``below'' or unsigned less than
8888 ``below or equal'' or unsigned less than or equal
8893 ``equal'' or zero flag set
8897 signed greater than or equal
8901 signed less than or equal
8922 ``not'' @var{flag}, or inverted versions of those above
8927 @anchor{InputOperands}
8928 @subsubsection Input Operands
8929 @cindex @code{asm} input operands
8930 @cindex @code{asm} expressions
8932 Input operands make values from C variables and expressions available to the
8935 Operands are separated by commas. Each operand has this format:
8938 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8942 @item asmSymbolicName
8943 Specifies a symbolic name for the operand.
8944 Reference the name in the assembler template
8945 by enclosing it in square brackets
8946 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8947 that contains the definition. Any valid C variable name is acceptable,
8948 including names already defined in the surrounding code. No two operands
8949 within the same @code{asm} statement can use the same symbolic name.
8951 When not using an @var{asmSymbolicName}, use the (zero-based) position
8953 in the list of operands in the assembler template. For example if there are
8954 two output operands and three inputs,
8955 use @samp{%2} in the template to refer to the first input operand,
8956 @samp{%3} for the second, and @samp{%4} for the third.
8959 A string constant specifying constraints on the placement of the operand;
8960 @xref{Constraints}, for details.
8962 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8963 When you list more than one possible location (for example, @samp{"irm"}),
8964 the compiler chooses the most efficient one based on the current context.
8965 If you must use a specific register, but your Machine Constraints do not
8966 provide sufficient control to select the specific register you want,
8967 local register variables may provide a solution (@pxref{Local Register
8970 Input constraints can also be digits (for example, @code{"0"}). This indicates
8971 that the specified input must be in the same place as the output constraint
8972 at the (zero-based) index in the output constraint list.
8973 When using @var{asmSymbolicName} syntax for the output operands,
8974 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8977 This is the C variable or expression being passed to the @code{asm} statement
8978 as input. The enclosing parentheses are a required part of the syntax.
8982 When the compiler selects the registers to use to represent the input
8983 operands, it does not use any of the clobbered registers
8984 (@pxref{Clobbers and Scratch Registers}).
8986 If there are no output operands but there are input operands, place two
8987 consecutive colons where the output operands would go:
8990 __asm__ ("some instructions"
8992 : "r" (Offset / 8));
8995 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8996 (except for inputs tied to outputs). The compiler assumes that on exit from
8997 the @code{asm} statement these operands contain the same values as they
8998 had before executing the statement.
8999 It is @emph{not} possible to use clobbers
9000 to inform the compiler that the values in these inputs are changing. One
9001 common work-around is to tie the changing input variable to an output variable
9002 that never gets used. Note, however, that if the code that follows the
9003 @code{asm} statement makes no use of any of the output operands, the GCC
9004 optimizers may discard the @code{asm} statement as unneeded
9005 (see @ref{Volatile}).
9007 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
9008 instead of simply @samp{%2}). Typically these qualifiers are hardware
9009 dependent. The list of supported modifiers for x86 is found at
9010 @ref{x86Operandmodifiers,x86 Operand modifiers}.
9012 In this example using the fictitious @code{combine} instruction, the
9013 constraint @code{"0"} for input operand 1 says that it must occupy the same
9014 location as output operand 0. Only input operands may use numbers in
9015 constraints, and they must each refer to an output operand. Only a number (or
9016 the symbolic assembler name) in the constraint can guarantee that one operand
9017 is in the same place as another. The mere fact that @code{foo} is the value of
9018 both operands is not enough to guarantee that they are in the same place in
9019 the generated assembler code.
9022 asm ("combine %2, %0"
9024 : "0" (foo), "g" (bar));
9027 Here is an example using symbolic names.
9030 asm ("cmoveq %1, %2, %[result]"
9031 : [result] "=r"(result)
9032 : "r" (test), "r" (new), "[result]" (old));
9035 @anchor{Clobbers and Scratch Registers}
9036 @subsubsection Clobbers and Scratch Registers
9037 @cindex @code{asm} clobbers
9038 @cindex @code{asm} scratch registers
9040 While the compiler is aware of changes to entries listed in the output
9041 operands, the inline @code{asm} code may modify more than just the outputs. For
9042 example, calculations may require additional registers, or the processor may
9043 overwrite a register as a side effect of a particular assembler instruction.
9044 In order to inform the compiler of these changes, list them in the clobber
9045 list. Clobber list items are either register names or the special clobbers
9046 (listed below). Each clobber list item is a string constant
9047 enclosed in double quotes and separated by commas.
9049 Clobber descriptions may not in any way overlap with an input or output
9050 operand. For example, you may not have an operand describing a register class
9051 with one member when listing that register in the clobber list. Variables
9052 declared to live in specific registers (@pxref{Explicit Register
9053 Variables}) and used
9054 as @code{asm} input or output operands must have no part mentioned in the
9055 clobber description. In particular, there is no way to specify that input
9056 operands get modified without also specifying them as output operands.
9058 When the compiler selects which registers to use to represent input and output
9059 operands, it does not use any of the clobbered registers. As a result,
9060 clobbered registers are available for any use in the assembler code.
9062 Here is a realistic example for the VAX showing the use of clobbered
9066 asm volatile ("movc3 %0, %1, %2"
9068 : "g" (from), "g" (to), "g" (count)
9069 : "r0", "r1", "r2", "r3", "r4", "r5", "memory");
9072 Also, there are two special clobber arguments:
9076 The @code{"cc"} clobber indicates that the assembler code modifies the flags
9077 register. On some machines, GCC represents the condition codes as a specific
9078 hardware register; @code{"cc"} serves to name this register.
9079 On other machines, condition code handling is different,
9080 and specifying @code{"cc"} has no effect. But
9081 it is valid no matter what the target.
9084 The @code{"memory"} clobber tells the compiler that the assembly code
9086 reads or writes to items other than those listed in the input and output
9087 operands (for example, accessing the memory pointed to by one of the input
9088 parameters). To ensure memory contains correct values, GCC may need to flush
9089 specific register values to memory before executing the @code{asm}. Further,
9090 the compiler does not assume that any values read from memory before an
9091 @code{asm} remain unchanged after that @code{asm}; it reloads them as
9093 Using the @code{"memory"} clobber effectively forms a read/write
9094 memory barrier for the compiler.
9096 Note that this clobber does not prevent the @emph{processor} from doing
9097 speculative reads past the @code{asm} statement. To prevent that, you need
9098 processor-specific fence instructions.
9102 Flushing registers to memory has performance implications and may be
9103 an issue for time-sensitive code. You can provide better information
9104 to GCC to avoid this, as shown in the following examples. At a
9105 minimum, aliasing rules allow GCC to know what memory @emph{doesn't}
9108 Here is a fictitious sum of squares instruction, that takes two
9109 pointers to floating point values in memory and produces a floating
9110 point register output.
9111 Notice that @code{x}, and @code{y} both appear twice in the @code{asm}
9112 parameters, once to specify memory accessed, and once to specify a
9113 base register used by the @code{asm}. You won't normally be wasting a
9114 register by doing this as GCC can use the same register for both
9115 purposes. However, it would be foolish to use both @code{%1} and
9116 @code{%3} for @code{x} in this @code{asm} and expect them to be the
9117 same. In fact, @code{%3} may well not be a register. It might be a
9118 symbolic memory reference to the object pointed to by @code{x}.
9121 asm ("sumsq %0, %1, %2"
9123 : "r" (x), "r" (y), "m" (*x), "m" (*y));
9126 Here is a fictitious @code{*z++ = *x++ * *y++} instruction.
9127 Notice that the @code{x}, @code{y} and @code{z} pointer registers
9128 must be specified as input/output because the @code{asm} modifies
9132 asm ("vecmul %0, %1, %2"
9133 : "+r" (z), "+r" (x), "+r" (y), "=m" (*z)
9134 : "m" (*x), "m" (*y));
9137 An x86 example where the string memory argument is of unknown length.
9141 : "=c" (count), "+D" (p)
9142 : "m" (*(const char (*)[]) p), "0" (-1), "a" (0));
9145 If you know the above will only be reading a ten byte array then you
9146 could instead use a memory input like:
9147 @code{"m" (*(const char (*)[10]) p)}.
9149 Here is an example of a PowerPC vector scale implemented in assembly,
9150 complete with vector and condition code clobbers, and some initialized
9151 offset registers that are unchanged by the @code{asm}.
9155 dscal (size_t n, double *x, double alpha)
9157 asm ("/* lots of asm here */"
9158 : "+m" (*(double (*)[n]) x), "+&r" (n), "+b" (x)
9159 : "d" (alpha), "b" (32), "b" (48), "b" (64),
9160 "b" (80), "b" (96), "b" (112)
9162 "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
9163 "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47");
9167 Rather than allocating fixed registers via clobbers to provide scratch
9168 registers for an @code{asm} statement, an alternative is to define a
9169 variable and make it an early-clobber output as with @code{a2} and
9170 @code{a3} in the example below. This gives the compiler register
9171 allocator more freedom. You can also define a variable and make it an
9172 output tied to an input as with @code{a0} and @code{a1}, tied
9173 respectively to @code{ap} and @code{lda}. Of course, with tied
9174 outputs your @code{asm} can't use the input value after modifying the
9175 output register since they are one and the same register. What's
9176 more, if you omit the early-clobber on the output, it is possible that
9177 GCC might allocate the same register to another of the inputs if GCC
9178 could prove they had the same value on entry to the @code{asm}. This
9179 is why @code{a1} has an early-clobber. Its tied input, @code{lda}
9180 might conceivably be known to have the value 16 and without an
9181 early-clobber share the same register as @code{%11}. On the other
9182 hand, @code{ap} can't be the same as any of the other inputs, so an
9183 early-clobber on @code{a0} is not needed. It is also not desirable in
9184 this case. An early-clobber on @code{a0} would cause GCC to allocate
9185 a separate register for the @code{"m" (*(const double (*)[]) ap)}
9186 input. Note that tying an input to an output is the way to set up an
9187 initialized temporary register modified by an @code{asm} statement.
9188 An input not tied to an output is assumed by GCC to be unchanged, for
9189 example @code{"b" (16)} below sets up @code{%11} to 16, and GCC might
9190 use that register in following code if the value 16 happened to be
9191 needed. You can even use a normal @code{asm} output for a scratch if
9192 all inputs that might share the same register are consumed before the
9193 scratch is used. The VSX registers clobbered by the @code{asm}
9194 statement could have used this technique except for GCC's limit on the
9195 number of @code{asm} parameters.
9199 dgemv_kernel_4x4 (long n, const double *ap, long lda,
9200 const double *x, double *y, double alpha)
9209 /* lots of asm here */
9210 "#n=%1 ap=%8=%12 lda=%13 x=%7=%10 y=%0=%2 alpha=%9 o16=%11\n"
9211 "#a0=%3 a1=%4 a2=%5 a3=%6"
9213 "+m" (*(double (*)[n]) y),
9221 "m" (*(const double (*)[n]) x),
9222 "m" (*(const double (*)[]) ap),
9230 "vs32","vs33","vs34","vs35","vs36","vs37",
9231 "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47"
9237 @subsubsection Goto Labels
9238 @cindex @code{asm} goto labels
9240 @code{asm goto} allows assembly code to jump to one or more C labels. The
9241 @var{GotoLabels} section in an @code{asm goto} statement contains
9243 list of all C labels to which the assembler code may jump. GCC assumes that
9244 @code{asm} execution falls through to the next statement (if this is not the
9245 case, consider using the @code{__builtin_unreachable} intrinsic after the
9246 @code{asm} statement). Optimization of @code{asm goto} may be improved by
9247 using the @code{hot} and @code{cold} label attributes (@pxref{Label
9250 An @code{asm goto} statement cannot have outputs.
9251 This is due to an internal restriction of
9252 the compiler: control transfer instructions cannot have outputs.
9253 If the assembler code does modify anything, use the @code{"memory"} clobber
9255 optimizers to flush all register values to memory and reload them if
9256 necessary after the @code{asm} statement.
9258 Also note that an @code{asm goto} statement is always implicitly
9259 considered volatile.
9261 To reference a label in the assembler template,
9262 prefix it with @samp{%l} (lowercase @samp{L}) followed
9263 by its (zero-based) position in @var{GotoLabels} plus the number of input
9264 operands. For example, if the @code{asm} has three inputs and references two
9265 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
9267 Alternately, you can reference labels using the actual C label name enclosed
9268 in brackets. For example, to reference a label named @code{carry}, you can
9269 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
9270 section when using this approach.
9272 Here is an example of @code{asm goto} for i386:
9279 : "r" (p1), "r" (p2)
9289 The following example shows an @code{asm goto} that uses a memory clobber.
9295 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
9306 @anchor{x86Operandmodifiers}
9307 @subsubsection x86 Operand Modifiers
9309 References to input, output, and goto operands in the assembler template
9310 of extended @code{asm} statements can use
9311 modifiers to affect the way the operands are formatted in
9312 the code output to the assembler. For example, the
9313 following code uses the @samp{h} and @samp{b} modifiers for x86:
9317 asm volatile ("xchg %h0, %b0" : "+a" (num) );
9321 These modifiers generate this assembler code:
9327 The rest of this discussion uses the following code for illustrative purposes.
9336 asm volatile goto ("some assembler instructions here"
9338 : "q" (iInt), "X" (sizeof(unsigned char) + 1), "i" (42)
9339 : /* No clobbers. */
9344 With no modifiers, this is what the output from the operands would be
9345 for the @samp{att} and @samp{intel} dialects of assembler:
9347 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
9348 @headitem Operand @tab @samp{att} @tab @samp{intel}
9357 @tab @code{OFFSET FLAT:.L3}
9360 The table below shows the list of supported modifiers and their effects.
9362 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
9363 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
9365 @tab Print an absolute memory reference.
9370 @tab Print the QImode name of the register.
9375 @tab Require a constant operand and print the constant expression with no punctuation.
9380 @tab Print the address in Double Integer (DImode) mode (8 bytes) when the target is 64-bit.
9381 Otherwise mode is unspecified (VOIDmode).
9386 @tab Print the QImode name for a ``high'' register.
9391 @tab Add 8 bytes to an offsettable memory reference. Useful when accessing the
9392 high 8 bytes of SSE values. For a memref in (%rax), it generates
9397 @tab Print the SImode name of the register.
9402 @tab Print the label name with no punctuation.
9407 @tab Print raw symbol name (without syntax-specific prefixes).
9412 @tab If used for a function, print the PLT suffix and generate PIC code.
9413 For example, emit @code{foo@@PLT} instead of 'foo' for the function
9414 foo(). If used for a constant, drop all syntax-specific prefixes and
9415 issue the bare constant. See @code{p} above.
9417 @tab Print the DImode name of the register.
9422 @tab Print the HImode name of the register.
9427 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
9433 @code{V} is a special modifier which prints the name of the full integer
9434 register without @code{%}.
9436 @anchor{x86floatingpointasmoperands}
9437 @subsubsection x86 Floating-Point @code{asm} Operands
9439 On x86 targets, there are several rules on the usage of stack-like registers
9440 in the operands of an @code{asm}. These rules apply only to the operands
9441 that are stack-like registers:
9445 Given a set of input registers that die in an @code{asm}, it is
9446 necessary to know which are implicitly popped by the @code{asm}, and
9447 which must be explicitly popped by GCC@.
9449 An input register that is implicitly popped by the @code{asm} must be
9450 explicitly clobbered, unless it is constrained to match an
9454 For any input register that is implicitly popped by an @code{asm}, it is
9455 necessary to know how to adjust the stack to compensate for the pop.
9456 If any non-popped input is closer to the top of the reg-stack than
9457 the implicitly popped register, it would not be possible to know what the
9458 stack looked like---it's not clear how the rest of the stack ``slides
9461 All implicitly popped input registers must be closer to the top of
9462 the reg-stack than any input that is not implicitly popped.
9464 It is possible that if an input dies in an @code{asm}, the compiler might
9465 use the input register for an output reload. Consider this example:
9468 asm ("foo" : "=t" (a) : "f" (b));
9472 This code says that input @code{b} is not popped by the @code{asm}, and that
9473 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
9474 deeper after the @code{asm} than it was before. But, it is possible that
9475 reload may think that it can use the same register for both the input and
9478 To prevent this from happening,
9479 if any input operand uses the @samp{f} constraint, all output register
9480 constraints must use the @samp{&} early-clobber modifier.
9482 The example above is correctly written as:
9485 asm ("foo" : "=&t" (a) : "f" (b));
9489 Some operands need to be in particular places on the stack. All
9490 output operands fall in this category---GCC has no other way to
9491 know which registers the outputs appear in unless you indicate
9492 this in the constraints.
9494 Output operands must specifically indicate which register an output
9495 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
9496 constraints must select a class with a single register.
9499 Output operands may not be ``inserted'' between existing stack registers.
9500 Since no 387 opcode uses a read/write operand, all output operands
9501 are dead before the @code{asm}, and are pushed by the @code{asm}.
9502 It makes no sense to push anywhere but the top of the reg-stack.
9504 Output operands must start at the top of the reg-stack: output
9505 operands may not ``skip'' a register.
9508 Some @code{asm} statements may need extra stack space for internal
9509 calculations. This can be guaranteed by clobbering stack registers
9510 unrelated to the inputs and outputs.
9515 takes one input, which is internally popped, and produces two outputs.
9518 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
9522 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
9523 and replaces them with one output. The @code{st(1)} clobber is necessary
9524 for the compiler to know that @code{fyl2xp1} pops both inputs.
9527 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
9535 @subsection Controlling Names Used in Assembler Code
9536 @cindex assembler names for identifiers
9537 @cindex names used in assembler code
9538 @cindex identifiers, names in assembler code
9540 You can specify the name to be used in the assembler code for a C
9541 function or variable by writing the @code{asm} (or @code{__asm__})
9542 keyword after the declarator.
9543 It is up to you to make sure that the assembler names you choose do not
9544 conflict with any other assembler symbols, or reference registers.
9546 @subsubheading Assembler names for data:
9548 This sample shows how to specify the assembler name for data:
9551 int foo asm ("myfoo") = 2;
9555 This specifies that the name to be used for the variable @code{foo} in
9556 the assembler code should be @samp{myfoo} rather than the usual
9559 On systems where an underscore is normally prepended to the name of a C
9560 variable, this feature allows you to define names for the
9561 linker that do not start with an underscore.
9563 GCC does not support using this feature with a non-static local variable
9564 since such variables do not have assembler names. If you are
9565 trying to put the variable in a particular register, see
9566 @ref{Explicit Register Variables}.
9568 @subsubheading Assembler names for functions:
9570 To specify the assembler name for functions, write a declaration for the
9571 function before its definition and put @code{asm} there, like this:
9574 int func (int x, int y) asm ("MYFUNC");
9576 int func (int x, int y)
9582 This specifies that the name to be used for the function @code{func} in
9583 the assembler code should be @code{MYFUNC}.
9585 @node Explicit Register Variables
9586 @subsection Variables in Specified Registers
9587 @anchor{Explicit Reg Vars}
9588 @cindex explicit register variables
9589 @cindex variables in specified registers
9590 @cindex specified registers
9592 GNU C allows you to associate specific hardware registers with C
9593 variables. In almost all cases, allowing the compiler to assign
9594 registers produces the best code. However under certain unusual
9595 circumstances, more precise control over the variable storage is
9598 Both global and local variables can be associated with a register. The
9599 consequences of performing this association are very different between
9600 the two, as explained in the sections below.
9603 * Global Register Variables:: Variables declared at global scope.
9604 * Local Register Variables:: Variables declared within a function.
9607 @node Global Register Variables
9608 @subsubsection Defining Global Register Variables
9609 @anchor{Global Reg Vars}
9610 @cindex global register variables
9611 @cindex registers, global variables in
9612 @cindex registers, global allocation
9614 You can define a global register variable and associate it with a specified
9618 register int *foo asm ("r12");
9622 Here @code{r12} is the name of the register that should be used. Note that
9623 this is the same syntax used for defining local register variables, but for
9624 a global variable the declaration appears outside a function. The
9625 @code{register} keyword is required, and cannot be combined with
9626 @code{static}. The register name must be a valid register name for the
9629 Do not use type qualifiers such as @code{const} and @code{volatile}, as
9630 the outcome may be contrary to expectations. In particular, using the
9631 @code{volatile} qualifier does not fully prevent the compiler from
9632 optimizing accesses to the register.
9634 Registers are a scarce resource on most systems and allowing the
9635 compiler to manage their usage usually results in the best code. However,
9636 under special circumstances it can make sense to reserve some globally.
9637 For example this may be useful in programs such as programming language
9638 interpreters that have a couple of global variables that are accessed
9641 After defining a global register variable, for the current compilation
9645 @item If the register is a call-saved register, call ABI is affected:
9646 the register will not be restored in function epilogue sequences after
9647 the variable has been assigned. Therefore, functions cannot safely
9648 return to callers that assume standard ABI.
9649 @item Conversely, if the register is a call-clobbered register, making
9650 calls to functions that use standard ABI may lose contents of the variable.
9651 Such calls may be created by the compiler even if none are evident in
9652 the original program, for example when libgcc functions are used to
9653 make up for unavailable instructions.
9654 @item Accesses to the variable may be optimized as usual and the register
9655 remains available for allocation and use in any computations, provided that
9656 observable values of the variable are not affected.
9657 @item If the variable is referenced in inline assembly, the type of access
9658 must be provided to the compiler via constraints (@pxref{Constraints}).
9659 Accesses from basic asms are not supported.
9662 Note that these points @emph{only} apply to code that is compiled with the
9663 definition. The behavior of code that is merely linked in (for example
9664 code from libraries) is not affected.
9666 If you want to recompile source files that do not actually use your global
9667 register variable so they do not use the specified register for any other
9668 purpose, you need not actually add the global register declaration to
9669 their source code. It suffices to specify the compiler option
9670 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
9673 @subsubheading Declaring the variable
9675 Global register variables can not have initial values, because an
9676 executable file has no means to supply initial contents for a register.
9678 When selecting a register, choose one that is normally saved and
9679 restored by function calls on your machine. This ensures that code
9680 which is unaware of this reservation (such as library routines) will
9681 restore it before returning.
9683 On machines with register windows, be sure to choose a global
9684 register that is not affected magically by the function call mechanism.
9686 @subsubheading Using the variable
9688 @cindex @code{qsort}, and global register variables
9689 When calling routines that are not aware of the reservation, be
9690 cautious if those routines call back into code which uses them. As an
9691 example, if you call the system library version of @code{qsort}, it may
9692 clobber your registers during execution, but (if you have selected
9693 appropriate registers) it will restore them before returning. However
9694 it will @emph{not} restore them before calling @code{qsort}'s comparison
9695 function. As a result, global values will not reliably be available to
9696 the comparison function unless the @code{qsort} function itself is rebuilt.
9698 Similarly, it is not safe to access the global register variables from signal
9699 handlers or from more than one thread of control. Unless you recompile
9700 them specially for the task at hand, the system library routines may
9701 temporarily use the register for other things. Furthermore, since the register
9702 is not reserved exclusively for the variable, accessing it from handlers of
9703 asynchronous signals may observe unrelated temporary values residing in the
9706 @cindex register variable after @code{longjmp}
9707 @cindex global register after @code{longjmp}
9708 @cindex value after @code{longjmp}
9711 On most machines, @code{longjmp} restores to each global register
9712 variable the value it had at the time of the @code{setjmp}. On some
9713 machines, however, @code{longjmp} does not change the value of global
9714 register variables. To be portable, the function that called @code{setjmp}
9715 should make other arrangements to save the values of the global register
9716 variables, and to restore them in a @code{longjmp}. This way, the same
9717 thing happens regardless of what @code{longjmp} does.
9719 @node Local Register Variables
9720 @subsubsection Specifying Registers for Local Variables
9721 @anchor{Local Reg Vars}
9722 @cindex local variables, specifying registers
9723 @cindex specifying registers for local variables
9724 @cindex registers for local variables
9726 You can define a local register variable and associate it with a specified
9730 register int *foo asm ("r12");
9734 Here @code{r12} is the name of the register that should be used. Note
9735 that this is the same syntax used for defining global register variables,
9736 but for a local variable the declaration appears within a function. The
9737 @code{register} keyword is required, and cannot be combined with
9738 @code{static}. The register name must be a valid register name for the
9741 Do not use type qualifiers such as @code{const} and @code{volatile}, as
9742 the outcome may be contrary to expectations. In particular, when the
9743 @code{const} qualifier is used, the compiler may substitute the
9744 variable with its initializer in @code{asm} statements, which may cause
9745 the corresponding operand to appear in a different register.
9747 As with global register variables, it is recommended that you choose
9748 a register that is normally saved and restored by function calls on your
9749 machine, so that calls to library routines will not clobber it.
9751 The only supported use for this feature is to specify registers
9752 for input and output operands when calling Extended @code{asm}
9753 (@pxref{Extended Asm}). This may be necessary if the constraints for a
9754 particular machine don't provide sufficient control to select the desired
9755 register. To force an operand into a register, create a local variable
9756 and specify the register name after the variable's declaration. Then use
9757 the local variable for the @code{asm} operand and specify any constraint
9758 letter that matches the register:
9761 register int *p1 asm ("r0") = @dots{};
9762 register int *p2 asm ("r1") = @dots{};
9763 register int *result asm ("r0");
9764 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9767 @emph{Warning:} In the above example, be aware that a register (for example
9768 @code{r0}) can be call-clobbered by subsequent code, including function
9769 calls and library calls for arithmetic operators on other variables (for
9770 example the initialization of @code{p2}). In this case, use temporary
9771 variables for expressions between the register assignments:
9775 register int *p1 asm ("r0") = @dots{};
9776 register int *p2 asm ("r1") = t1;
9777 register int *result asm ("r0");
9778 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9781 Defining a register variable does not reserve the register. Other than
9782 when invoking the Extended @code{asm}, the contents of the specified
9783 register are not guaranteed. For this reason, the following uses
9784 are explicitly @emph{not} supported. If they appear to work, it is only
9785 happenstance, and may stop working as intended due to (seemingly)
9786 unrelated changes in surrounding code, or even minor changes in the
9787 optimization of a future version of gcc:
9790 @item Passing parameters to or from Basic @code{asm}
9791 @item Passing parameters to or from Extended @code{asm} without using input
9793 @item Passing parameters to or from routines written in assembler (or
9794 other languages) using non-standard calling conventions.
9797 Some developers use Local Register Variables in an attempt to improve
9798 gcc's allocation of registers, especially in large functions. In this
9799 case the register name is essentially a hint to the register allocator.
9800 While in some instances this can generate better code, improvements are
9801 subject to the whims of the allocator/optimizers. Since there are no
9802 guarantees that your improvements won't be lost, this usage of Local
9803 Register Variables is discouraged.
9805 On the MIPS platform, there is related use for local register variables
9806 with slightly different characteristics (@pxref{MIPS Coprocessors,,
9807 Defining coprocessor specifics for MIPS targets, gccint,
9808 GNU Compiler Collection (GCC) Internals}).
9810 @node Size of an asm
9811 @subsection Size of an @code{asm}
9813 Some targets require that GCC track the size of each instruction used
9814 in order to generate correct code. Because the final length of the
9815 code produced by an @code{asm} statement is only known by the
9816 assembler, GCC must make an estimate as to how big it will be. It
9817 does this by counting the number of instructions in the pattern of the
9818 @code{asm} and multiplying that by the length of the longest
9819 instruction supported by that processor. (When working out the number
9820 of instructions, it assumes that any occurrence of a newline or of
9821 whatever statement separator character is supported by the assembler --
9822 typically @samp{;} --- indicates the end of an instruction.)
9824 Normally, GCC's estimate is adequate to ensure that correct
9825 code is generated, but it is possible to confuse the compiler if you use
9826 pseudo instructions or assembler macros that expand into multiple real
9827 instructions, or if you use assembler directives that expand to more
9828 space in the object file than is needed for a single instruction.
9829 If this happens then the assembler may produce a diagnostic saying that
9830 a label is unreachable.
9832 @node Alternate Keywords
9833 @section Alternate Keywords
9834 @cindex alternate keywords
9835 @cindex keywords, alternate
9837 @option{-ansi} and the various @option{-std} options disable certain
9838 keywords. This causes trouble when you want to use GNU C extensions, or
9839 a general-purpose header file that should be usable by all programs,
9840 including ISO C programs. The keywords @code{asm}, @code{typeof} and
9841 @code{inline} are not available in programs compiled with
9842 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9843 program compiled with @option{-std=c99} or @option{-std=c11}). The
9845 @code{restrict} is only available when @option{-std=gnu99} (which will
9846 eventually be the default) or @option{-std=c99} (or the equivalent
9847 @option{-std=iso9899:1999}), or an option for a later standard
9850 The way to solve these problems is to put @samp{__} at the beginning and
9851 end of each problematical keyword. For example, use @code{__asm__}
9852 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9854 Other C compilers won't accept these alternative keywords; if you want to
9855 compile with another compiler, you can define the alternate keywords as
9856 macros to replace them with the customary keywords. It looks like this:
9864 @findex __extension__
9866 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9868 prevent such warnings within one expression by writing
9869 @code{__extension__} before the expression. @code{__extension__} has no
9870 effect aside from this.
9872 @node Incomplete Enums
9873 @section Incomplete @code{enum} Types
9875 You can define an @code{enum} tag without specifying its possible values.
9876 This results in an incomplete type, much like what you get if you write
9877 @code{struct foo} without describing the elements. A later declaration
9878 that does specify the possible values completes the type.
9880 You cannot allocate variables or storage using the type while it is
9881 incomplete. However, you can work with pointers to that type.
9883 This extension may not be very useful, but it makes the handling of
9884 @code{enum} more consistent with the way @code{struct} and @code{union}
9887 This extension is not supported by GNU C++.
9889 @node Function Names
9890 @section Function Names as Strings
9891 @cindex @code{__func__} identifier
9892 @cindex @code{__FUNCTION__} identifier
9893 @cindex @code{__PRETTY_FUNCTION__} identifier
9895 GCC provides three magic constants that hold the name of the current
9896 function as a string. In C++11 and later modes, all three are treated
9897 as constant expressions and can be used in @code{constexpr} constexts.
9898 The first of these constants is @code{__func__}, which is part of
9901 The identifier @code{__func__} is implicitly declared by the translator
9902 as if, immediately following the opening brace of each function
9903 definition, the declaration
9906 static const char __func__[] = "function-name";
9910 appeared, where function-name is the name of the lexically-enclosing
9911 function. This name is the unadorned name of the function. As an
9912 extension, at file (or, in C++, namespace scope), @code{__func__}
9913 evaluates to the empty string.
9915 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9916 backward compatibility with old versions of GCC.
9918 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9919 @code{__func__}, except that at file (or, in C++, namespace scope),
9920 it evaluates to the string @code{"top level"}. In addition, in C++,
9921 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9922 well as its bare name. For example, this program:
9925 extern "C" int printf (const char *, ...);
9931 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9932 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9950 __PRETTY_FUNCTION__ = void a::sub(int)
9953 These identifiers are variables, not preprocessor macros, and may not
9954 be used to initialize @code{char} arrays or be concatenated with string
9957 @node Return Address
9958 @section Getting the Return or Frame Address of a Function
9960 These functions may be used to get information about the callers of a
9963 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9964 This function returns the return address of the current function, or of
9965 one of its callers. The @var{level} argument is number of frames to
9966 scan up the call stack. A value of @code{0} yields the return address
9967 of the current function, a value of @code{1} yields the return address
9968 of the caller of the current function, and so forth. When inlining
9969 the expected behavior is that the function returns the address of
9970 the function that is returned to. To work around this behavior use
9971 the @code{noinline} function attribute.
9973 The @var{level} argument must be a constant integer.
9975 On some machines it may be impossible to determine the return address of
9976 any function other than the current one; in such cases, or when the top
9977 of the stack has been reached, this function returns @code{0} or a
9978 random value. In addition, @code{__builtin_frame_address} may be used
9979 to determine if the top of the stack has been reached.
9981 Additional post-processing of the returned value may be needed, see
9982 @code{__builtin_extract_return_addr}.
9984 Calling this function with a nonzero argument can have unpredictable
9985 effects, including crashing the calling program. As a result, calls
9986 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9987 option is in effect. Such calls should only be made in debugging
9991 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9992 The address as returned by @code{__builtin_return_address} may have to be fed
9993 through this function to get the actual encoded address. For example, on the
9994 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9995 platforms an offset has to be added for the true next instruction to be
9998 If no fixup is needed, this function simply passes through @var{addr}.
10001 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
10002 This function does the reverse of @code{__builtin_extract_return_addr}.
10005 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
10006 This function is similar to @code{__builtin_return_address}, but it
10007 returns the address of the function frame rather than the return address
10008 of the function. Calling @code{__builtin_frame_address} with a value of
10009 @code{0} yields the frame address of the current function, a value of
10010 @code{1} yields the frame address of the caller of the current function,
10013 The frame is the area on the stack that holds local variables and saved
10014 registers. The frame address is normally the address of the first word
10015 pushed on to the stack by the function. However, the exact definition
10016 depends upon the processor and the calling convention. If the processor
10017 has a dedicated frame pointer register, and the function has a frame,
10018 then @code{__builtin_frame_address} returns the value of the frame
10021 On some machines it may be impossible to determine the frame address of
10022 any function other than the current one; in such cases, or when the top
10023 of the stack has been reached, this function returns @code{0} if
10024 the first frame pointer is properly initialized by the startup code.
10026 Calling this function with a nonzero argument can have unpredictable
10027 effects, including crashing the calling program. As a result, calls
10028 that are considered unsafe are diagnosed when the @option{-Wframe-address}
10029 option is in effect. Such calls should only be made in debugging
10033 @node Vector Extensions
10034 @section Using Vector Instructions through Built-in Functions
10036 On some targets, the instruction set contains SIMD vector instructions which
10037 operate on multiple values contained in one large register at the same time.
10038 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
10041 The first step in using these extensions is to provide the necessary data
10042 types. This should be done using an appropriate @code{typedef}:
10045 typedef int v4si __attribute__ ((vector_size (16)));
10049 The @code{int} type specifies the base type, while the attribute specifies
10050 the vector size for the variable, measured in bytes. For example, the
10051 declaration above causes the compiler to set the mode for the @code{v4si}
10052 type to be 16 bytes wide and divided into @code{int} sized units. For
10053 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
10054 corresponding mode of @code{foo} is @acronym{V4SI}.
10056 The @code{vector_size} attribute is only applicable to integral and
10057 float scalars, although arrays, pointers, and function return values
10058 are allowed in conjunction with this construct. Only sizes that are
10059 a power of two are currently allowed.
10061 All the basic integer types can be used as base types, both as signed
10062 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
10063 @code{long long}. In addition, @code{float} and @code{double} can be
10064 used to build floating-point vector types.
10066 Specifying a combination that is not valid for the current architecture
10067 causes GCC to synthesize the instructions using a narrower mode.
10068 For example, if you specify a variable of type @code{V4SI} and your
10069 architecture does not allow for this specific SIMD type, GCC
10070 produces code that uses 4 @code{SIs}.
10072 The types defined in this manner can be used with a subset of normal C
10073 operations. Currently, GCC allows using the following operators
10074 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
10076 The operations behave like C++ @code{valarrays}. Addition is defined as
10077 the addition of the corresponding elements of the operands. For
10078 example, in the code below, each of the 4 elements in @var{a} is
10079 added to the corresponding 4 elements in @var{b} and the resulting
10080 vector is stored in @var{c}.
10083 typedef int v4si __attribute__ ((vector_size (16)));
10090 Subtraction, multiplication, division, and the logical operations
10091 operate in a similar manner. Likewise, the result of using the unary
10092 minus or complement operators on a vector type is a vector whose
10093 elements are the negative or complemented values of the corresponding
10094 elements in the operand.
10096 It is possible to use shifting operators @code{<<}, @code{>>} on
10097 integer-type vectors. The operation is defined as following: @code{@{a0,
10098 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
10099 @dots{}, an >> bn@}}@. Vector operands must have the same number of
10102 For convenience, it is allowed to use a binary vector operation
10103 where one operand is a scalar. In that case the compiler transforms
10104 the scalar operand into a vector where each element is the scalar from
10105 the operation. The transformation happens only if the scalar could be
10106 safely converted to the vector-element type.
10107 Consider the following code.
10110 typedef int v4si __attribute__ ((vector_size (16)));
10115 a = b + 1; /* a = b + @{1,1,1,1@}; */
10116 a = 2 * b; /* a = @{2,2,2,2@} * b; */
10118 a = l + a; /* Error, cannot convert long to int. */
10121 Vectors can be subscripted as if the vector were an array with
10122 the same number of elements and base type. Out of bound accesses
10123 invoke undefined behavior at run time. Warnings for out of bound
10124 accesses for vector subscription can be enabled with
10125 @option{-Warray-bounds}.
10127 Vector comparison is supported with standard comparison
10128 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
10129 vector expressions of integer-type or real-type. Comparison between
10130 integer-type vectors and real-type vectors are not supported. The
10131 result of the comparison is a vector of the same width and number of
10132 elements as the comparison operands with a signed integral element
10135 Vectors are compared element-wise producing 0 when comparison is false
10136 and -1 (constant of the appropriate type where all bits are set)
10137 otherwise. Consider the following example.
10140 typedef int v4si __attribute__ ((vector_size (16)));
10142 v4si a = @{1,2,3,4@};
10143 v4si b = @{3,2,1,4@};
10146 c = a > b; /* The result would be @{0, 0,-1, 0@} */
10147 c = a == b; /* The result would be @{0,-1, 0,-1@} */
10150 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
10151 @code{b} and @code{c} are vectors of the same type and @code{a} is an
10152 integer vector with the same number of elements of the same size as @code{b}
10153 and @code{c}, computes all three arguments and creates a vector
10154 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
10155 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
10156 As in the case of binary operations, this syntax is also accepted when
10157 one of @code{b} or @code{c} is a scalar that is then transformed into a
10158 vector. If both @code{b} and @code{c} are scalars and the type of
10159 @code{true?b:c} has the same size as the element type of @code{a}, then
10160 @code{b} and @code{c} are converted to a vector type whose elements have
10161 this type and with the same number of elements as @code{a}.
10163 In C++, the logic operators @code{!, &&, ||} are available for vectors.
10164 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
10165 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
10166 For mixed operations between a scalar @code{s} and a vector @code{v},
10167 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
10168 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
10170 @findex __builtin_shuffle
10171 Vector shuffling is available using functions
10172 @code{__builtin_shuffle (vec, mask)} and
10173 @code{__builtin_shuffle (vec0, vec1, mask)}.
10174 Both functions construct a permutation of elements from one or two
10175 vectors and return a vector of the same type as the input vector(s).
10176 The @var{mask} is an integral vector with the same width (@var{W})
10177 and element count (@var{N}) as the output vector.
10179 The elements of the input vectors are numbered in memory ordering of
10180 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
10181 elements of @var{mask} are considered modulo @var{N} in the single-operand
10182 case and modulo @math{2*@var{N}} in the two-operand case.
10184 Consider the following example,
10187 typedef int v4si __attribute__ ((vector_size (16)));
10189 v4si a = @{1,2,3,4@};
10190 v4si b = @{5,6,7,8@};
10191 v4si mask1 = @{0,1,1,3@};
10192 v4si mask2 = @{0,4,2,5@};
10195 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
10196 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
10199 Note that @code{__builtin_shuffle} is intentionally semantically
10200 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
10202 You can declare variables and use them in function calls and returns, as
10203 well as in assignments and some casts. You can specify a vector type as
10204 a return type for a function. Vector types can also be used as function
10205 arguments. It is possible to cast from one vector type to another,
10206 provided they are of the same size (in fact, you can also cast vectors
10207 to and from other datatypes of the same size).
10209 You cannot operate between vectors of different lengths or different
10210 signedness without a cast.
10213 @section Support for @code{offsetof}
10214 @findex __builtin_offsetof
10216 GCC implements for both C and C++ a syntactic extension to implement
10217 the @code{offsetof} macro.
10221 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
10223 offsetof_member_designator:
10225 | offsetof_member_designator "." @code{identifier}
10226 | offsetof_member_designator "[" @code{expr} "]"
10229 This extension is sufficient such that
10232 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
10236 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
10237 may be dependent. In either case, @var{member} may consist of a single
10238 identifier, or a sequence of member accesses and array references.
10240 @node __sync Builtins
10241 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
10243 The following built-in functions
10244 are intended to be compatible with those described
10245 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
10246 section 7.4. As such, they depart from normal GCC practice by not using
10247 the @samp{__builtin_} prefix and also by being overloaded so that they
10248 work on multiple types.
10250 The definition given in the Intel documentation allows only for the use of
10251 the types @code{int}, @code{long}, @code{long long} or their unsigned
10252 counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
10253 size other than the C type @code{_Bool} or the C++ type @code{bool}.
10254 Operations on pointer arguments are performed as if the operands were
10255 of the @code{uintptr_t} type. That is, they are not scaled by the size
10256 of the type to which the pointer points.
10258 These functions are implemented in terms of the @samp{__atomic}
10259 builtins (@pxref{__atomic Builtins}). They should not be used for new
10260 code which should use the @samp{__atomic} builtins instead.
10262 Not all operations are supported by all target processors. If a particular
10263 operation cannot be implemented on the target processor, a warning is
10264 generated and a call to an external function is generated. The external
10265 function carries the same name as the built-in version,
10266 with an additional suffix
10267 @samp{_@var{n}} where @var{n} is the size of the data type.
10269 @c ??? Should we have a mechanism to suppress this warning? This is almost
10270 @c useful for implementing the operation under the control of an external
10273 In most cases, these built-in functions are considered a @dfn{full barrier}.
10275 no memory operand is moved across the operation, either forward or
10276 backward. Further, instructions are issued as necessary to prevent the
10277 processor from speculating loads across the operation and from queuing stores
10278 after the operation.
10280 All of the routines are described in the Intel documentation to take
10281 ``an optional list of variables protected by the memory barrier''. It's
10282 not clear what is meant by that; it could mean that @emph{only} the
10283 listed variables are protected, or it could mean a list of additional
10284 variables to be protected. The list is ignored by GCC which treats it as
10285 empty. GCC interprets an empty list as meaning that all globally
10286 accessible variables should be protected.
10289 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
10290 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
10291 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
10292 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
10293 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
10294 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
10295 @findex __sync_fetch_and_add
10296 @findex __sync_fetch_and_sub
10297 @findex __sync_fetch_and_or
10298 @findex __sync_fetch_and_and
10299 @findex __sync_fetch_and_xor
10300 @findex __sync_fetch_and_nand
10301 These built-in functions perform the operation suggested by the name, and
10302 returns the value that had previously been in memory. That is, operations
10303 on integer operands have the following semantics. Operations on pointer
10304 arguments are performed as if the operands were of the @code{uintptr_t}
10305 type. That is, they are not scaled by the size of the type to which
10306 the pointer points.
10309 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
10310 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
10313 The object pointed to by the first argument must be of integer or pointer
10314 type. It must not be a boolean type.
10316 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
10317 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
10319 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
10320 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
10321 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
10322 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
10323 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
10324 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
10325 @findex __sync_add_and_fetch
10326 @findex __sync_sub_and_fetch
10327 @findex __sync_or_and_fetch
10328 @findex __sync_and_and_fetch
10329 @findex __sync_xor_and_fetch
10330 @findex __sync_nand_and_fetch
10331 These built-in functions perform the operation suggested by the name, and
10332 return the new value. That is, operations on integer operands have
10333 the following semantics. Operations on pointer operands are performed as
10334 if the operand's type were @code{uintptr_t}.
10337 @{ *ptr @var{op}= value; return *ptr; @}
10338 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
10341 The same constraints on arguments apply as for the corresponding
10342 @code{__sync_op_and_fetch} built-in functions.
10344 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
10345 as @code{*ptr = ~(*ptr & value)} instead of
10346 @code{*ptr = ~*ptr & value}.
10348 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10349 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10350 @findex __sync_bool_compare_and_swap
10351 @findex __sync_val_compare_and_swap
10352 These built-in functions perform an atomic compare and swap.
10353 That is, if the current
10354 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
10357 The ``bool'' version returns true if the comparison is successful and
10358 @var{newval} is written. The ``val'' version returns the contents
10359 of @code{*@var{ptr}} before the operation.
10361 @item __sync_synchronize (...)
10362 @findex __sync_synchronize
10363 This built-in function issues a full memory barrier.
10365 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
10366 @findex __sync_lock_test_and_set
10367 This built-in function, as described by Intel, is not a traditional test-and-set
10368 operation, but rather an atomic exchange operation. It writes @var{value}
10369 into @code{*@var{ptr}}, and returns the previous contents of
10372 Many targets have only minimal support for such locks, and do not support
10373 a full exchange operation. In this case, a target may support reduced
10374 functionality here by which the @emph{only} valid value to store is the
10375 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
10376 is implementation defined.
10378 This built-in function is not a full barrier,
10379 but rather an @dfn{acquire barrier}.
10380 This means that references after the operation cannot move to (or be
10381 speculated to) before the operation, but previous memory stores may not
10382 be globally visible yet, and previous memory loads may not yet be
10385 @item void __sync_lock_release (@var{type} *ptr, ...)
10386 @findex __sync_lock_release
10387 This built-in function releases the lock acquired by
10388 @code{__sync_lock_test_and_set}.
10389 Normally this means writing the constant 0 to @code{*@var{ptr}}.
10391 This built-in function is not a full barrier,
10392 but rather a @dfn{release barrier}.
10393 This means that all previous memory stores are globally visible, and all
10394 previous memory loads have been satisfied, but following memory reads
10395 are not prevented from being speculated to before the barrier.
10398 @node __atomic Builtins
10399 @section Built-in Functions for Memory Model Aware Atomic Operations
10401 The following built-in functions approximately match the requirements
10402 for the C++11 memory model. They are all
10403 identified by being prefixed with @samp{__atomic} and most are
10404 overloaded so that they work with multiple types.
10406 These functions are intended to replace the legacy @samp{__sync}
10407 builtins. The main difference is that the memory order that is requested
10408 is a parameter to the functions. New code should always use the
10409 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
10411 Note that the @samp{__atomic} builtins assume that programs will
10412 conform to the C++11 memory model. In particular, they assume
10413 that programs are free of data races. See the C++11 standard for
10414 detailed requirements.
10416 The @samp{__atomic} builtins can be used with any integral scalar or
10417 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
10418 types are also allowed if @samp{__int128} (@pxref{__int128}) is
10419 supported by the architecture.
10421 The four non-arithmetic functions (load, store, exchange, and
10422 compare_exchange) all have a generic version as well. This generic
10423 version works on any data type. It uses the lock-free built-in function
10424 if the specific data type size makes that possible; otherwise, an
10425 external call is left to be resolved at run time. This external call is
10426 the same format with the addition of a @samp{size_t} parameter inserted
10427 as the first parameter indicating the size of the object being pointed to.
10428 All objects must be the same size.
10430 There are 6 different memory orders that can be specified. These map
10431 to the C++11 memory orders with the same names, see the C++11 standard
10432 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
10433 on atomic synchronization} for detailed definitions. Individual
10434 targets may also support additional memory orders for use on specific
10435 architectures. Refer to the target documentation for details of
10438 An atomic operation can both constrain code motion and
10439 be mapped to hardware instructions for synchronization between threads
10440 (e.g., a fence). To which extent this happens is controlled by the
10441 memory orders, which are listed here in approximately ascending order of
10442 strength. The description of each memory order is only meant to roughly
10443 illustrate the effects and is not a specification; see the C++11
10444 memory model for precise semantics.
10447 @item __ATOMIC_RELAXED
10448 Implies no inter-thread ordering constraints.
10449 @item __ATOMIC_CONSUME
10450 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
10451 memory order because of a deficiency in C++11's semantics for
10452 @code{memory_order_consume}.
10453 @item __ATOMIC_ACQUIRE
10454 Creates an inter-thread happens-before constraint from the release (or
10455 stronger) semantic store to this acquire load. Can prevent hoisting
10456 of code to before the operation.
10457 @item __ATOMIC_RELEASE
10458 Creates an inter-thread happens-before constraint to acquire (or stronger)
10459 semantic loads that read from this release store. Can prevent sinking
10460 of code to after the operation.
10461 @item __ATOMIC_ACQ_REL
10462 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
10463 @code{__ATOMIC_RELEASE}.
10464 @item __ATOMIC_SEQ_CST
10465 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
10468 Note that in the C++11 memory model, @emph{fences} (e.g.,
10469 @samp{__atomic_thread_fence}) take effect in combination with other
10470 atomic operations on specific memory locations (e.g., atomic loads);
10471 operations on specific memory locations do not necessarily affect other
10472 operations in the same way.
10474 Target architectures are encouraged to provide their own patterns for
10475 each of the atomic built-in functions. If no target is provided, the original
10476 non-memory model set of @samp{__sync} atomic built-in functions are
10477 used, along with any required synchronization fences surrounding it in
10478 order to achieve the proper behavior. Execution in this case is subject
10479 to the same restrictions as those built-in functions.
10481 If there is no pattern or mechanism to provide a lock-free instruction
10482 sequence, a call is made to an external routine with the same parameters
10483 to be resolved at run time.
10485 When implementing patterns for these built-in functions, the memory order
10486 parameter can be ignored as long as the pattern implements the most
10487 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
10488 orders execute correctly with this memory order but they may not execute as
10489 efficiently as they could with a more appropriate implementation of the
10490 relaxed requirements.
10492 Note that the C++11 standard allows for the memory order parameter to be
10493 determined at run time rather than at compile time. These built-in
10494 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
10495 than invoke a runtime library call or inline a switch statement. This is
10496 standard compliant, safe, and the simplest approach for now.
10498 The memory order parameter is a signed int, but only the lower 16 bits are
10499 reserved for the memory order. The remainder of the signed int is reserved
10500 for target use and should be 0. Use of the predefined atomic values
10501 ensures proper usage.
10503 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
10504 This built-in function implements an atomic load operation. It returns the
10505 contents of @code{*@var{ptr}}.
10507 The valid memory order variants are
10508 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10509 and @code{__ATOMIC_CONSUME}.
10513 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
10514 This is the generic version of an atomic load. It returns the
10515 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
10519 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
10520 This built-in function implements an atomic store operation. It writes
10521 @code{@var{val}} into @code{*@var{ptr}}.
10523 The valid memory order variants are
10524 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
10528 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
10529 This is the generic version of an atomic store. It stores the value
10530 of @code{*@var{val}} into @code{*@var{ptr}}.
10534 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
10535 This built-in function implements an atomic exchange operation. It writes
10536 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
10539 The valid memory order variants are
10540 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10541 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
10545 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
10546 This is the generic version of an atomic exchange. It stores the
10547 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
10548 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
10552 @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)
10553 This built-in function implements an atomic compare and exchange operation.
10554 This compares the contents of @code{*@var{ptr}} with the contents of
10555 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
10556 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
10557 equal, the operation is a @emph{read} and the current contents of
10558 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is true
10559 for weak compare_exchange, which may fail spuriously, and false for
10560 the strong variation, which never fails spuriously. Many targets
10561 only offer the strong variation and ignore the parameter. When in doubt, use
10562 the strong variation.
10564 If @var{desired} is written into @code{*@var{ptr}} then true is returned
10565 and memory is affected according to the
10566 memory order specified by @var{success_memorder}. There are no
10567 restrictions on what memory order can be used here.
10569 Otherwise, false is returned and memory is affected according
10570 to @var{failure_memorder}. This memory order cannot be
10571 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
10572 stronger order than that specified by @var{success_memorder}.
10576 @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)
10577 This built-in function implements the generic version of
10578 @code{__atomic_compare_exchange}. The function is virtually identical to
10579 @code{__atomic_compare_exchange_n}, except the desired value is also a
10584 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
10585 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
10586 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
10587 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
10588 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
10589 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
10590 These built-in functions perform the operation suggested by the name, and
10591 return the result of the operation. Operations on pointer arguments are
10592 performed as if the operands were of the @code{uintptr_t} type. That is,
10593 they are not scaled by the size of the type to which the pointer points.
10596 @{ *ptr @var{op}= val; return *ptr; @}
10599 The object pointed to by the first argument must be of integer or pointer
10600 type. It must not be a boolean type. All memory orders are valid.
10604 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
10605 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
10606 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
10607 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
10608 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
10609 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
10610 These built-in functions perform the operation suggested by the name, and
10611 return the value that had previously been in @code{*@var{ptr}}. Operations
10612 on pointer arguments are performed as if the operands were of
10613 the @code{uintptr_t} type. That is, they are not scaled by the size of
10614 the type to which the pointer points.
10617 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
10620 The same constraints on arguments apply as for the corresponding
10621 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
10625 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
10627 This built-in function performs an atomic test-and-set operation on
10628 the byte at @code{*@var{ptr}}. The byte is set to some implementation
10629 defined nonzero ``set'' value and the return value is @code{true} if and only
10630 if the previous contents were ``set''.
10631 It should be only used for operands of type @code{bool} or @code{char}. For
10632 other types only part of the value may be set.
10634 All memory orders are valid.
10638 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
10640 This built-in function performs an atomic clear operation on
10641 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
10642 It should be only used for operands of type @code{bool} or @code{char} and
10643 in conjunction with @code{__atomic_test_and_set}.
10644 For other types it may only clear partially. If the type is not @code{bool}
10645 prefer using @code{__atomic_store}.
10647 The valid memory order variants are
10648 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
10649 @code{__ATOMIC_RELEASE}.
10653 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
10655 This built-in function acts as a synchronization fence between threads
10656 based on the specified memory order.
10658 All memory orders are valid.
10662 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
10664 This built-in function acts as a synchronization fence between a thread
10665 and signal handlers based in the same thread.
10667 All memory orders are valid.
10671 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
10673 This built-in function returns true if objects of @var{size} bytes always
10674 generate lock-free atomic instructions for the target architecture.
10675 @var{size} must resolve to a compile-time constant and the result also
10676 resolves to a compile-time constant.
10678 @var{ptr} is an optional pointer to the object that may be used to determine
10679 alignment. A value of 0 indicates typical alignment should be used. The
10680 compiler may also ignore this parameter.
10683 if (__atomic_always_lock_free (sizeof (long long), 0))
10688 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
10690 This built-in function returns true if objects of @var{size} bytes always
10691 generate lock-free atomic instructions for the target architecture. If
10692 the built-in function is not known to be lock-free, a call is made to a
10693 runtime routine named @code{__atomic_is_lock_free}.
10695 @var{ptr} is an optional pointer to the object that may be used to determine
10696 alignment. A value of 0 indicates typical alignment should be used. The
10697 compiler may also ignore this parameter.
10700 @node Integer Overflow Builtins
10701 @section Built-in Functions to Perform Arithmetic with Overflow Checking
10703 The following built-in functions allow performing simple arithmetic operations
10704 together with checking whether the operations overflowed.
10706 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10707 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
10708 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
10709 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
10710 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
10711 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10712 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10714 These built-in functions promote the first two operands into infinite precision signed
10715 type and perform addition on those promoted operands. The result is then
10716 cast to the type the third pointer argument points to and stored there.
10717 If the stored result is equal to the infinite precision result, the built-in
10718 functions return false, otherwise they return true. As the addition is
10719 performed in infinite signed precision, these built-in functions have fully defined
10720 behavior for all argument values.
10722 The first built-in function allows arbitrary integral types for operands and
10723 the result type must be pointer to some integral type other than enumerated or
10724 boolean type, the rest of the built-in functions have explicit integer types.
10726 The compiler will attempt to use hardware instructions to implement
10727 these built-in functions where possible, like conditional jump on overflow
10728 after addition, conditional jump on carry etc.
10732 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10733 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
10734 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
10735 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
10736 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
10737 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10738 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10740 These built-in functions are similar to the add overflow checking built-in
10741 functions above, except they perform subtraction, subtract the second argument
10742 from the first one, instead of addition.
10746 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10747 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
10748 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
10749 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
10750 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
10751 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10752 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10754 These built-in functions are similar to the add overflow checking built-in
10755 functions above, except they perform multiplication, instead of addition.
10759 The following built-in functions allow checking if simple arithmetic operation
10762 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10763 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10764 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10766 These built-in functions are similar to @code{__builtin_add_overflow},
10767 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
10768 they don't store the result of the arithmetic operation anywhere and the
10769 last argument is not a pointer, but some expression with integral type other
10770 than enumerated or boolean type.
10772 The built-in functions promote the first two operands into infinite precision signed type
10773 and perform addition on those promoted operands. The result is then
10774 cast to the type of the third argument. If the cast result is equal to the infinite
10775 precision result, the built-in functions return false, otherwise they return true.
10776 The value of the third argument is ignored, just the side effects in the third argument
10777 are evaluated, and no integral argument promotions are performed on the last argument.
10778 If the third argument is a bit-field, the type used for the result cast has the
10779 precision and signedness of the given bit-field, rather than precision and signedness
10780 of the underlying type.
10782 For example, the following macro can be used to portably check, at
10783 compile-time, whether or not adding two constant integers will overflow,
10784 and perform the addition only when it is known to be safe and not to trigger
10785 a @option{-Woverflow} warning.
10788 #define INT_ADD_OVERFLOW_P(a, b) \
10789 __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
10792 A = INT_MAX, B = 3,
10793 C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
10794 D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
10798 The compiler will attempt to use hardware instructions to implement
10799 these built-in functions where possible, like conditional jump on overflow
10800 after addition, conditional jump on carry etc.
10804 @node x86 specific memory model extensions for transactional memory
10805 @section x86-Specific Memory Model Extensions for Transactional Memory
10807 The x86 architecture supports additional memory ordering flags
10808 to mark critical sections for hardware lock elision.
10809 These must be specified in addition to an existing memory order to
10813 @item __ATOMIC_HLE_ACQUIRE
10814 Start lock elision on a lock variable.
10815 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
10816 @item __ATOMIC_HLE_RELEASE
10817 End lock elision on a lock variable.
10818 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
10821 When a lock acquire fails, it is required for good performance to abort
10822 the transaction quickly. This can be done with a @code{_mm_pause}.
10825 #include <immintrin.h> // For _mm_pause
10829 /* Acquire lock with lock elision */
10830 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10831 _mm_pause(); /* Abort failed transaction */
10833 /* Free lock with lock elision */
10834 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10837 @node Object Size Checking
10838 @section Object Size Checking Built-in Functions
10839 @findex __builtin_object_size
10840 @findex __builtin___memcpy_chk
10841 @findex __builtin___mempcpy_chk
10842 @findex __builtin___memmove_chk
10843 @findex __builtin___memset_chk
10844 @findex __builtin___strcpy_chk
10845 @findex __builtin___stpcpy_chk
10846 @findex __builtin___strncpy_chk
10847 @findex __builtin___strcat_chk
10848 @findex __builtin___strncat_chk
10849 @findex __builtin___sprintf_chk
10850 @findex __builtin___snprintf_chk
10851 @findex __builtin___vsprintf_chk
10852 @findex __builtin___vsnprintf_chk
10853 @findex __builtin___printf_chk
10854 @findex __builtin___vprintf_chk
10855 @findex __builtin___fprintf_chk
10856 @findex __builtin___vfprintf_chk
10858 GCC implements a limited buffer overflow protection mechanism that can
10859 prevent some buffer overflow attacks by determining the sizes of objects
10860 into which data is about to be written and preventing the writes when
10861 the size isn't sufficient. The built-in functions described below yield
10862 the best results when used together and when optimization is enabled.
10863 For example, to detect object sizes across function boundaries or to
10864 follow pointer assignments through non-trivial control flow they rely
10865 on various optimization passes enabled with @option{-O2}. However, to
10866 a limited extent, they can be used without optimization as well.
10868 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
10869 is a built-in construct that returns a constant number of bytes from
10870 @var{ptr} to the end of the object @var{ptr} pointer points to
10871 (if known at compile time). @code{__builtin_object_size} never evaluates
10872 its arguments for side effects. If there are any side effects in them, it
10873 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10874 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
10875 point to and all of them are known at compile time, the returned number
10876 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10877 0 and minimum if nonzero. If it is not possible to determine which objects
10878 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10879 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10880 for @var{type} 2 or 3.
10882 @var{type} is an integer constant from 0 to 3. If the least significant
10883 bit is clear, objects are whole variables, if it is set, a closest
10884 surrounding subobject is considered the object a pointer points to.
10885 The second bit determines if maximum or minimum of remaining bytes
10889 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10890 char *p = &var.buf1[1], *q = &var.b;
10892 /* Here the object p points to is var. */
10893 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10894 /* The subobject p points to is var.buf1. */
10895 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10896 /* The object q points to is var. */
10897 assert (__builtin_object_size (q, 0)
10898 == (char *) (&var + 1) - (char *) &var.b);
10899 /* The subobject q points to is var.b. */
10900 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10904 There are built-in functions added for many common string operation
10905 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10906 built-in is provided. This built-in has an additional last argument,
10907 which is the number of bytes remaining in the object the @var{dest}
10908 argument points to or @code{(size_t) -1} if the size is not known.
10910 The built-in functions are optimized into the normal string functions
10911 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10912 it is known at compile time that the destination object will not
10913 be overflowed. If the compiler can determine at compile time that the
10914 object will always be overflowed, it issues a warning.
10916 The intended use can be e.g.@:
10920 #define bos0(dest) __builtin_object_size (dest, 0)
10921 #define memcpy(dest, src, n) \
10922 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10926 /* It is unknown what object p points to, so this is optimized
10927 into plain memcpy - no checking is possible. */
10928 memcpy (p, "abcde", n);
10929 /* Destination is known and length too. It is known at compile
10930 time there will be no overflow. */
10931 memcpy (&buf[5], "abcde", 5);
10932 /* Destination is known, but the length is not known at compile time.
10933 This will result in __memcpy_chk call that can check for overflow
10935 memcpy (&buf[5], "abcde", n);
10936 /* Destination is known and it is known at compile time there will
10937 be overflow. There will be a warning and __memcpy_chk call that
10938 will abort the program at run time. */
10939 memcpy (&buf[6], "abcde", 5);
10942 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10943 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10944 @code{strcat} and @code{strncat}.
10946 There are also checking built-in functions for formatted output functions.
10948 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10949 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10950 const char *fmt, ...);
10951 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10953 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10954 const char *fmt, va_list ap);
10957 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10958 etc.@: functions and can contain implementation specific flags on what
10959 additional security measures the checking function might take, such as
10960 handling @code{%n} differently.
10962 The @var{os} argument is the object size @var{s} points to, like in the
10963 other built-in functions. There is a small difference in the behavior
10964 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10965 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10966 the checking function is called with @var{os} argument set to
10967 @code{(size_t) -1}.
10969 In addition to this, there are checking built-in functions
10970 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10971 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10972 These have just one additional argument, @var{flag}, right before
10973 format string @var{fmt}. If the compiler is able to optimize them to
10974 @code{fputc} etc.@: functions, it does, otherwise the checking function
10975 is called and the @var{flag} argument passed to it.
10977 @node Other Builtins
10978 @section Other Built-in Functions Provided by GCC
10979 @cindex built-in functions
10980 @findex __builtin_alloca
10981 @findex __builtin_alloca_with_align
10982 @findex __builtin_alloca_with_align_and_max
10983 @findex __builtin_call_with_static_chain
10984 @findex __builtin_extend_pointer
10985 @findex __builtin_fpclassify
10986 @findex __builtin_isfinite
10987 @findex __builtin_isnormal
10988 @findex __builtin_isgreater
10989 @findex __builtin_isgreaterequal
10990 @findex __builtin_isinf_sign
10991 @findex __builtin_isless
10992 @findex __builtin_islessequal
10993 @findex __builtin_islessgreater
10994 @findex __builtin_isunordered
10995 @findex __builtin_powi
10996 @findex __builtin_powif
10997 @findex __builtin_powil
10998 @findex __builtin_speculation_safe_value
11159 @findex fprintf_unlocked
11161 @findex fputs_unlocked
11269 @findex nexttowardf
11270 @findex nexttowardl
11278 @findex printf_unlocked
11308 @findex signbitd128
11309 @findex significand
11310 @findex significandf
11311 @findex significandl
11339 @findex strncasecmp
11383 GCC provides a large number of built-in functions other than the ones
11384 mentioned above. Some of these are for internal use in the processing
11385 of exceptions or variable-length argument lists and are not
11386 documented here because they may change from time to time; we do not
11387 recommend general use of these functions.
11389 The remaining functions are provided for optimization purposes.
11391 With the exception of built-ins that have library equivalents such as
11392 the standard C library functions discussed below, or that expand to
11393 library calls, GCC built-in functions are always expanded inline and
11394 thus do not have corresponding entry points and their address cannot
11395 be obtained. Attempting to use them in an expression other than
11396 a function call results in a compile-time error.
11398 @opindex fno-builtin
11399 GCC includes built-in versions of many of the functions in the standard
11400 C library. These functions come in two forms: one whose names start with
11401 the @code{__builtin_} prefix, and the other without. Both forms have the
11402 same type (including prototype), the same address (when their address is
11403 taken), and the same meaning as the C library functions even if you specify
11404 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
11405 functions are only optimized in certain cases; if they are not optimized in
11406 a particular case, a call to the library function is emitted.
11410 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
11411 @option{-std=c99} or @option{-std=c11}), the functions
11412 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
11413 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
11414 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
11415 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
11416 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
11417 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
11418 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
11419 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
11420 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
11421 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
11422 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
11423 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
11424 @code{signbitd64}, @code{signbitd128}, @code{significandf},
11425 @code{significandl}, @code{significand}, @code{sincosf},
11426 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
11427 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
11428 @code{strndup}, @code{strnlen}, @code{toascii}, @code{y0f}, @code{y0l},
11429 @code{y0}, @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
11431 may be handled as built-in functions.
11432 All these functions have corresponding versions
11433 prefixed with @code{__builtin_}, which may be used even in strict C90
11436 The ISO C99 functions
11437 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
11438 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
11439 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
11440 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
11441 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
11442 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
11443 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
11444 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
11445 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
11446 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
11447 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
11448 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
11449 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
11450 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
11451 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
11452 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
11453 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
11454 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
11455 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
11456 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
11457 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
11458 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
11459 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
11460 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
11461 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
11462 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
11463 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
11464 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
11465 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
11466 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
11467 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
11468 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
11469 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
11470 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
11471 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
11472 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
11473 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
11474 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
11475 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
11476 are handled as built-in functions
11477 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11479 There are also built-in versions of the ISO C99 functions
11480 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
11481 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
11482 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
11483 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
11484 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
11485 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
11486 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
11487 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
11488 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
11489 that are recognized in any mode since ISO C90 reserves these names for
11490 the purpose to which ISO C99 puts them. All these functions have
11491 corresponding versions prefixed with @code{__builtin_}.
11493 There are also built-in functions @code{__builtin_fabsf@var{n}},
11494 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
11495 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
11496 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
11497 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
11498 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
11500 There are also GNU extension functions @code{clog10}, @code{clog10f} and
11501 @code{clog10l} which names are reserved by ISO C99 for future use.
11502 All these functions have versions prefixed with @code{__builtin_}.
11504 The ISO C94 functions
11505 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
11506 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
11507 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
11509 are handled as built-in functions
11510 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11512 The ISO C90 functions
11513 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11514 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11515 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11516 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11517 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11518 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11519 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11520 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11521 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11522 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11523 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11524 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11525 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11526 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11527 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11528 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11529 are all recognized as built-in functions unless
11530 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11531 is specified for an individual function). All of these functions have
11532 corresponding versions prefixed with @code{__builtin_}.
11534 GCC provides built-in versions of the ISO C99 floating-point comparison
11535 macros that avoid raising exceptions for unordered operands. They have
11536 the same names as the standard macros ( @code{isgreater},
11537 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11538 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11539 prefixed. We intend for a library implementor to be able to simply
11540 @code{#define} each standard macro to its built-in equivalent.
11541 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11542 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11543 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
11544 built-in functions appear both with and without the @code{__builtin_} prefix.
11546 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11547 The @code{__builtin_alloca} function must be called at block scope.
11548 The function allocates an object @var{size} bytes large on the stack
11549 of the calling function. The object is aligned on the default stack
11550 alignment boundary for the target determined by the
11551 @code{__BIGGEST_ALIGNMENT__} macro. The @code{__builtin_alloca}
11552 function returns a pointer to the first byte of the allocated object.
11553 The lifetime of the allocated object ends just before the calling
11554 function returns to its caller. This is so even when
11555 @code{__builtin_alloca} is called within a nested block.
11557 For example, the following function allocates eight objects of @code{n}
11558 bytes each on the stack, storing a pointer to each in consecutive elements
11559 of the array @code{a}. It then passes the array to function @code{g}
11560 which can safely use the storage pointed to by each of the array elements.
11563 void f (unsigned n)
11566 for (int i = 0; i != 8; ++i)
11567 a [i] = __builtin_alloca (n);
11569 g (a, n); // @r{safe}
11573 Since the @code{__builtin_alloca} function doesn't validate its argument
11574 it is the responsibility of its caller to make sure the argument doesn't
11575 cause it to exceed the stack size limit.
11576 The @code{__builtin_alloca} function is provided to make it possible to
11577 allocate on the stack arrays of bytes with an upper bound that may be
11578 computed at run time. Since C99 Variable Length Arrays offer
11579 similar functionality under a portable, more convenient, and safer
11580 interface they are recommended instead, in both C99 and C++ programs
11581 where GCC provides them as an extension.
11582 @xref{Variable Length}, for details.
11586 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11587 The @code{__builtin_alloca_with_align} function must be called at block
11588 scope. The function allocates an object @var{size} bytes large on
11589 the stack of the calling function. The allocated object is aligned on
11590 the boundary specified by the argument @var{alignment} whose unit is given
11591 in bits (not bytes). The @var{size} argument must be positive and not
11592 exceed the stack size limit. The @var{alignment} argument must be a constant
11593 integer expression that evaluates to a power of 2 greater than or equal to
11594 @code{CHAR_BIT} and less than some unspecified maximum. Invocations
11595 with other values are rejected with an error indicating the valid bounds.
11596 The function returns a pointer to the first byte of the allocated object.
11597 The lifetime of the allocated object ends at the end of the block in which
11598 the function was called. The allocated storage is released no later than
11599 just before the calling function returns to its caller, but may be released
11600 at the end of the block in which the function was called.
11602 For example, in the following function the call to @code{g} is unsafe
11603 because when @code{overalign} is non-zero, the space allocated by
11604 @code{__builtin_alloca_with_align} may have been released at the end
11605 of the @code{if} statement in which it was called.
11608 void f (unsigned n, bool overalign)
11612 p = __builtin_alloca_with_align (n, 64 /* bits */);
11614 p = __builtin_alloc (n);
11616 g (p, n); // @r{unsafe}
11620 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11621 @var{size} argument it is the responsibility of its caller to make sure
11622 the argument doesn't cause it to exceed the stack size limit.
11623 The @code{__builtin_alloca_with_align} function is provided to make
11624 it possible to allocate on the stack overaligned arrays of bytes with
11625 an upper bound that may be computed at run time. Since C99
11626 Variable Length Arrays offer the same functionality under
11627 a portable, more convenient, and safer interface they are recommended
11628 instead, in both C99 and C++ programs where GCC provides them as
11629 an extension. @xref{Variable Length}, for details.
11633 @deftypefn {Built-in Function} void *__builtin_alloca_with_align_and_max (size_t size, size_t alignment, size_t max_size)
11634 Similar to @code{__builtin_alloca_with_align} but takes an extra argument
11635 specifying an upper bound for @var{size} in case its value cannot be computed
11636 at compile time, for use by @option{-fstack-usage}, @option{-Wstack-usage}
11637 and @option{-Walloca-larger-than}. @var{max_size} must be a constant integer
11638 expression, it has no effect on code generation and no attempt is made to
11639 check its compatibility with @var{size}.
11643 @deftypefn {Built-in Function} @var{type} __builtin_speculation_safe_value (@var{type} val, @var{type} failval)
11645 This built-in function can be used to help mitigate against unsafe
11646 speculative execution. @var{type} may be any integral type or any
11651 If the CPU is not speculatively executing the code, then @var{val}
11654 If the CPU is executing speculatively then either:
11657 The function may cause execution to pause until it is known that the
11658 code is no-longer being executed speculatively (in which case
11659 @var{val} can be returned, as above); or
11661 The function may use target-dependent speculation tracking state to cause
11662 @var{failval} to be returned when it is known that speculative
11663 execution has incorrectly predicted a conditional branch operation.
11667 The second argument, @var{failval}, is optional and defaults to zero
11670 GCC defines the preprocessor macro
11671 @code{__HAVE_BUILTIN_SPECULATION_SAFE_VALUE} for targets that have been
11672 updated to support this builtin.
11674 The built-in function can be used where a variable appears to be used in a
11675 safe way, but the CPU, due to speculative execution may temporarily ignore
11676 the bounds checks. Consider, for example, the following function:
11680 int f (unsigned untrusted_index)
11682 if (untrusted_index < 500)
11683 return array[untrusted_index];
11688 If the function is called repeatedly with @code{untrusted_index} less
11689 than the limit of 500, then a branch predictor will learn that the
11690 block of code that returns a value stored in @code{array} will be
11691 executed. If the function is subsequently called with an
11692 out-of-range value it will still try to execute that block of code
11693 first until the CPU determines that the prediction was incorrect
11694 (the CPU will unwind any incorrect operations at that point).
11695 However, depending on how the result of the function is used, it might be
11696 possible to leave traces in the cache that can reveal what was stored
11697 at the out-of-bounds location. The built-in function can be used to
11698 provide some protection against leaking data in this way by changing
11703 int f (unsigned untrusted_index)
11705 if (untrusted_index < 500)
11706 return array[__builtin_speculation_safe_value (untrusted_index)];
11711 The built-in function will either cause execution to stall until the
11712 conditional branch has been fully resolved, or it may permit
11713 speculative execution to continue, but using 0 instead of
11714 @code{untrusted_value} if that exceeds the limit.
11716 If accessing any memory location is potentially unsafe when speculative
11717 execution is incorrect, then the code can be rewritten as
11721 int f (unsigned untrusted_index)
11723 if (untrusted_index < 500)
11724 return *__builtin_speculation_safe_value (&array[untrusted_index], NULL);
11729 which will cause a @code{NULL} pointer to be used for the unsafe case.
11733 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11735 You can use the built-in function @code{__builtin_types_compatible_p} to
11736 determine whether two types are the same.
11738 This built-in function returns 1 if the unqualified versions of the
11739 types @var{type1} and @var{type2} (which are types, not expressions) are
11740 compatible, 0 otherwise. The result of this built-in function can be
11741 used in integer constant expressions.
11743 This built-in function ignores top level qualifiers (e.g., @code{const},
11744 @code{volatile}). For example, @code{int} is equivalent to @code{const
11747 The type @code{int[]} and @code{int[5]} are compatible. On the other
11748 hand, @code{int} and @code{char *} are not compatible, even if the size
11749 of their types, on the particular architecture are the same. Also, the
11750 amount of pointer indirection is taken into account when determining
11751 similarity. Consequently, @code{short *} is not similar to
11752 @code{short **}. Furthermore, two types that are typedefed are
11753 considered compatible if their underlying types are compatible.
11755 An @code{enum} type is not considered to be compatible with another
11756 @code{enum} type even if both are compatible with the same integer
11757 type; this is what the C standard specifies.
11758 For example, @code{enum @{foo, bar@}} is not similar to
11759 @code{enum @{hot, dog@}}.
11761 You typically use this function in code whose execution varies
11762 depending on the arguments' types. For example:
11767 typeof (x) tmp = (x); \
11768 if (__builtin_types_compatible_p (typeof (x), long double)) \
11769 tmp = foo_long_double (tmp); \
11770 else if (__builtin_types_compatible_p (typeof (x), double)) \
11771 tmp = foo_double (tmp); \
11772 else if (__builtin_types_compatible_p (typeof (x), float)) \
11773 tmp = foo_float (tmp); \
11780 @emph{Note:} This construct is only available for C@.
11784 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11786 The @var{call_exp} expression must be a function call, and the
11787 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
11788 is passed to the function call in the target's static chain location.
11789 The result of builtin is the result of the function call.
11791 @emph{Note:} This builtin is only available for C@.
11792 This builtin can be used to call Go closures from C.
11796 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11798 You can use the built-in function @code{__builtin_choose_expr} to
11799 evaluate code depending on the value of a constant expression. This
11800 built-in function returns @var{exp1} if @var{const_exp}, which is an
11801 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
11803 This built-in function is analogous to the @samp{? :} operator in C,
11804 except that the expression returned has its type unaltered by promotion
11805 rules. Also, the built-in function does not evaluate the expression
11806 that is not chosen. For example, if @var{const_exp} evaluates to true,
11807 @var{exp2} is not evaluated even if it has side effects.
11809 This built-in function can return an lvalue if the chosen argument is an
11812 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11813 type. Similarly, if @var{exp2} is returned, its return type is the same
11820 __builtin_choose_expr ( \
11821 __builtin_types_compatible_p (typeof (x), double), \
11823 __builtin_choose_expr ( \
11824 __builtin_types_compatible_p (typeof (x), float), \
11826 /* @r{The void expression results in a compile-time error} \
11827 @r{when assigning the result to something.} */ \
11831 @emph{Note:} This construct is only available for C@. Furthermore, the
11832 unused expression (@var{exp1} or @var{exp2} depending on the value of
11833 @var{const_exp}) may still generate syntax errors. This may change in
11838 @deftypefn {Built-in Function} @var{type} __builtin_tgmath (@var{functions}, @var{arguments})
11840 The built-in function @code{__builtin_tgmath}, available only for C
11841 and Objective-C, calls a function determined according to the rules of
11842 @code{<tgmath.h>} macros. It is intended to be used in
11843 implementations of that header, so that expansions of macros from that
11844 header only expand each of their arguments once, to avoid problems
11845 when calls to such macros are nested inside the arguments of other
11846 calls to such macros; in addition, it results in better diagnostics
11847 for invalid calls to @code{<tgmath.h>} macros than implementations
11848 using other GNU C language features. For example, the @code{pow}
11849 type-generic macro might be defined as:
11852 #define pow(a, b) __builtin_tgmath (powf, pow, powl, \
11853 cpowf, cpow, cpowl, a, b)
11856 The arguments to @code{__builtin_tgmath} are at least two pointers to
11857 functions, followed by the arguments to the type-generic macro (which
11858 will be passed as arguments to the selected function). All the
11859 pointers to functions must be pointers to prototyped functions, none
11860 of which may have variable arguments, and all of which must have the
11861 same number of parameters; the number of parameters of the first
11862 function determines how many arguments to @code{__builtin_tgmath} are
11863 interpreted as function pointers, and how many as the arguments to the
11866 The types of the specified functions must all be different, but
11867 related to each other in the same way as a set of functions that may
11868 be selected between by a macro in @code{<tgmath.h>}. This means that
11869 the functions are parameterized by a floating-point type @var{t},
11870 different for each such function. The function return types may all
11871 be the same type, or they may be @var{t} for each function, or they
11872 may be the real type corresponding to @var{t} for each function (if
11873 some of the types @var{t} are complex). Likewise, for each parameter
11874 position, the type of the parameter in that position may always be the
11875 same type, or may be @var{t} for each function (this case must apply
11876 for at least one parameter position), or may be the real type
11877 corresponding to @var{t} for each function.
11879 The standard rules for @code{<tgmath.h>} macros are used to find a
11880 common type @var{u} from the types of the arguments for parameters
11881 whose types vary between the functions; complex integer types (a GNU
11882 extension) are treated like @code{_Complex double} for this purpose
11883 (or @code{_Complex _Float64} if all the function return types are the
11884 same @code{_Float@var{n}} or @code{_Float@var{n}x} type).
11885 If the function return types vary, or are all the same integer type,
11886 the function called is the one for which @var{t} is @var{u}, and it is
11887 an error if there is no such function. If the function return types
11888 are all the same floating-point type, the type-generic macro is taken
11889 to be one of those from TS 18661 that rounds the result to a narrower
11890 type; if there is a function for which @var{t} is @var{u}, it is
11891 called, and otherwise the first function, if any, for which @var{t}
11892 has at least the range and precision of @var{u} is called, and it is
11893 an error if there is no such function.
11897 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11899 The built-in function @code{__builtin_complex} is provided for use in
11900 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11901 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
11902 real binary floating-point type, and the result has the corresponding
11903 complex type with real and imaginary parts @var{real} and @var{imag}.
11904 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11905 infinities, NaNs and negative zeros are involved.
11909 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11910 You can use the built-in function @code{__builtin_constant_p} to
11911 determine if a value is known to be constant at compile time and hence
11912 that GCC can perform constant-folding on expressions involving that
11913 value. The argument of the function is the value to test. The function
11914 returns the integer 1 if the argument is known to be a compile-time
11915 constant and 0 if it is not known to be a compile-time constant. A
11916 return of 0 does not indicate that the value is @emph{not} a constant,
11917 but merely that GCC cannot prove it is a constant with the specified
11918 value of the @option{-O} option.
11920 You typically use this function in an embedded application where
11921 memory is a critical resource. If you have some complex calculation,
11922 you may want it to be folded if it involves constants, but need to call
11923 a function if it does not. For example:
11926 #define Scale_Value(X) \
11927 (__builtin_constant_p (X) \
11928 ? ((X) * SCALE + OFFSET) : Scale (X))
11931 You may use this built-in function in either a macro or an inline
11932 function. However, if you use it in an inlined function and pass an
11933 argument of the function as the argument to the built-in, GCC
11934 never returns 1 when you call the inline function with a string constant
11935 or compound literal (@pxref{Compound Literals}) and does not return 1
11936 when you pass a constant numeric value to the inline function unless you
11937 specify the @option{-O} option.
11939 You may also use @code{__builtin_constant_p} in initializers for static
11940 data. For instance, you can write
11943 static const int table[] = @{
11944 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11950 This is an acceptable initializer even if @var{EXPRESSION} is not a
11951 constant expression, including the case where
11952 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11953 folded to a constant but @var{EXPRESSION} contains operands that are
11954 not otherwise permitted in a static initializer (for example,
11955 @code{0 && foo ()}). GCC must be more conservative about evaluating the
11956 built-in in this case, because it has no opportunity to perform
11960 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11961 @opindex fprofile-arcs
11962 You may use @code{__builtin_expect} to provide the compiler with
11963 branch prediction information. In general, you should prefer to
11964 use actual profile feedback for this (@option{-fprofile-arcs}), as
11965 programmers are notoriously bad at predicting how their programs
11966 actually perform. However, there are applications in which this
11967 data is hard to collect.
11969 The return value is the value of @var{exp}, which should be an integral
11970 expression. The semantics of the built-in are that it is expected that
11971 @var{exp} == @var{c}. For example:
11974 if (__builtin_expect (x, 0))
11979 indicates that we do not expect to call @code{foo}, since
11980 we expect @code{x} to be zero. Since you are limited to integral
11981 expressions for @var{exp}, you should use constructions such as
11984 if (__builtin_expect (ptr != NULL, 1))
11989 when testing pointer or floating-point values.
11992 @deftypefn {Built-in Function} long __builtin_expect_with_probability
11993 (long @var{exp}, long @var{c}, long @var{probability})
11995 The built-in has same semantics as @code{__builtin_expect_with_probability},
11996 but user can provide expected probability (in percent) for value of @var{exp}.
11997 Last argument @var{probability} is of float type and valid values
11998 are in inclusive range 0.0f and 1.0f.
12001 @deftypefn {Built-in Function} void __builtin_trap (void)
12002 This function causes the program to exit abnormally. GCC implements
12003 this function by using a target-dependent mechanism (such as
12004 intentionally executing an illegal instruction) or by calling
12005 @code{abort}. The mechanism used may vary from release to release so
12006 you should not rely on any particular implementation.
12009 @deftypefn {Built-in Function} void __builtin_unreachable (void)
12010 If control flow reaches the point of the @code{__builtin_unreachable},
12011 the program is undefined. It is useful in situations where the
12012 compiler cannot deduce the unreachability of the code.
12014 One such case is immediately following an @code{asm} statement that
12015 either never terminates, or one that transfers control elsewhere
12016 and never returns. In this example, without the
12017 @code{__builtin_unreachable}, GCC issues a warning that control
12018 reaches the end of a non-void function. It also generates code
12019 to return after the @code{asm}.
12022 int f (int c, int v)
12030 asm("jmp error_handler");
12031 __builtin_unreachable ();
12037 Because the @code{asm} statement unconditionally transfers control out
12038 of the function, control never reaches the end of the function
12039 body. The @code{__builtin_unreachable} is in fact unreachable and
12040 communicates this fact to the compiler.
12042 Another use for @code{__builtin_unreachable} is following a call a
12043 function that never returns but that is not declared
12044 @code{__attribute__((noreturn))}, as in this example:
12047 void function_that_never_returns (void);
12057 function_that_never_returns ();
12058 __builtin_unreachable ();
12065 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
12066 This function returns its first argument, and allows the compiler
12067 to assume that the returned pointer is at least @var{align} bytes
12068 aligned. This built-in can have either two or three arguments,
12069 if it has three, the third argument should have integer type, and
12070 if it is nonzero means misalignment offset. For example:
12073 void *x = __builtin_assume_aligned (arg, 16);
12077 means that the compiler can assume @code{x}, set to @code{arg}, is at least
12078 16-byte aligned, while:
12081 void *x = __builtin_assume_aligned (arg, 32, 8);
12085 means that the compiler can assume for @code{x}, set to @code{arg}, that
12086 @code{(char *) x - 8} is 32-byte aligned.
12089 @deftypefn {Built-in Function} int __builtin_LINE ()
12090 This function is the equivalent of the preprocessor @code{__LINE__}
12091 macro and returns a constant integer expression that evaluates to
12092 the line number of the invocation of the built-in. When used as a C++
12093 default argument for a function @var{F}, it returns the line number
12094 of the call to @var{F}.
12097 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
12098 This function is the equivalent of the @code{__FUNCTION__} symbol
12099 and returns an address constant pointing to the name of the function
12100 from which the built-in was invoked, or the empty string if
12101 the invocation is not at function scope. When used as a C++ default
12102 argument for a function @var{F}, it returns the name of @var{F}'s
12103 caller or the empty string if the call was not made at function
12107 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
12108 This function is the equivalent of the preprocessor @code{__FILE__}
12109 macro and returns an address constant pointing to the file name
12110 containing the invocation of the built-in, or the empty string if
12111 the invocation is not at function scope. When used as a C++ default
12112 argument for a function @var{F}, it returns the file name of the call
12113 to @var{F} or the empty string if the call was not made at function
12116 For example, in the following, each call to function @code{foo} will
12117 print a line similar to @code{"file.c:123: foo: message"} with the name
12118 of the file and the line number of the @code{printf} call, the name of
12119 the function @code{foo}, followed by the word @code{message}.
12123 function (const char *func = __builtin_FUNCTION ())
12130 printf ("%s:%i: %s: message\n", file (), line (), function ());
12136 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
12137 This function is used to flush the processor's instruction cache for
12138 the region of memory between @var{begin} inclusive and @var{end}
12139 exclusive. Some targets require that the instruction cache be
12140 flushed, after modifying memory containing code, in order to obtain
12141 deterministic behavior.
12143 If the target does not require instruction cache flushes,
12144 @code{__builtin___clear_cache} has no effect. Otherwise either
12145 instructions are emitted in-line to clear the instruction cache or a
12146 call to the @code{__clear_cache} function in libgcc is made.
12149 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
12150 This function is used to minimize cache-miss latency by moving data into
12151 a cache before it is accessed.
12152 You can insert calls to @code{__builtin_prefetch} into code for which
12153 you know addresses of data in memory that is likely to be accessed soon.
12154 If the target supports them, data prefetch instructions are generated.
12155 If the prefetch is done early enough before the access then the data will
12156 be in the cache by the time it is accessed.
12158 The value of @var{addr} is the address of the memory to prefetch.
12159 There are two optional arguments, @var{rw} and @var{locality}.
12160 The value of @var{rw} is a compile-time constant one or zero; one
12161 means that the prefetch is preparing for a write to the memory address
12162 and zero, the default, means that the prefetch is preparing for a read.
12163 The value @var{locality} must be a compile-time constant integer between
12164 zero and three. A value of zero means that the data has no temporal
12165 locality, so it need not be left in the cache after the access. A value
12166 of three means that the data has a high degree of temporal locality and
12167 should be left in all levels of cache possible. Values of one and two
12168 mean, respectively, a low or moderate degree of temporal locality. The
12172 for (i = 0; i < n; i++)
12174 a[i] = a[i] + b[i];
12175 __builtin_prefetch (&a[i+j], 1, 1);
12176 __builtin_prefetch (&b[i+j], 0, 1);
12181 Data prefetch does not generate faults if @var{addr} is invalid, but
12182 the address expression itself must be valid. For example, a prefetch
12183 of @code{p->next} does not fault if @code{p->next} is not a valid
12184 address, but evaluation faults if @code{p} is not a valid address.
12186 If the target does not support data prefetch, the address expression
12187 is evaluated if it includes side effects but no other code is generated
12188 and GCC does not issue a warning.
12191 @deftypefn {Built-in Function} double __builtin_huge_val (void)
12192 Returns a positive infinity, if supported by the floating-point format,
12193 else @code{DBL_MAX}. This function is suitable for implementing the
12194 ISO C macro @code{HUGE_VAL}.
12197 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
12198 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
12201 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
12202 Similar to @code{__builtin_huge_val}, except the return
12203 type is @code{long double}.
12206 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
12207 Similar to @code{__builtin_huge_val}, except the return type is
12208 @code{_Float@var{n}}.
12211 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
12212 Similar to @code{__builtin_huge_val}, except the return type is
12213 @code{_Float@var{n}x}.
12216 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
12217 This built-in implements the C99 fpclassify functionality. The first
12218 five int arguments should be the target library's notion of the
12219 possible FP classes and are used for return values. They must be
12220 constant values and they must appear in this order: @code{FP_NAN},
12221 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
12222 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
12223 to classify. GCC treats the last argument as type-generic, which
12224 means it does not do default promotion from float to double.
12227 @deftypefn {Built-in Function} double __builtin_inf (void)
12228 Similar to @code{__builtin_huge_val}, except a warning is generated
12229 if the target floating-point format does not support infinities.
12232 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
12233 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
12236 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
12237 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
12240 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
12241 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
12244 @deftypefn {Built-in Function} float __builtin_inff (void)
12245 Similar to @code{__builtin_inf}, except the return type is @code{float}.
12246 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
12249 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
12250 Similar to @code{__builtin_inf}, except the return
12251 type is @code{long double}.
12254 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
12255 Similar to @code{__builtin_inf}, except the return
12256 type is @code{_Float@var{n}}.
12259 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
12260 Similar to @code{__builtin_inf}, except the return
12261 type is @code{_Float@var{n}x}.
12264 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
12265 Similar to @code{isinf}, except the return value is -1 for
12266 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
12267 Note while the parameter list is an
12268 ellipsis, this function only accepts exactly one floating-point
12269 argument. GCC treats this parameter as type-generic, which means it
12270 does not do default promotion from float to double.
12273 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
12274 This is an implementation of the ISO C99 function @code{nan}.
12276 Since ISO C99 defines this function in terms of @code{strtod}, which we
12277 do not implement, a description of the parsing is in order. The string
12278 is parsed as by @code{strtol}; that is, the base is recognized by
12279 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
12280 in the significand such that the least significant bit of the number
12281 is at the least significant bit of the significand. The number is
12282 truncated to fit the significand field provided. The significand is
12283 forced to be a quiet NaN@.
12285 This function, if given a string literal all of which would have been
12286 consumed by @code{strtol}, is evaluated early enough that it is considered a
12287 compile-time constant.
12290 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
12291 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
12294 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
12295 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
12298 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
12299 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
12302 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
12303 Similar to @code{__builtin_nan}, except the return type is @code{float}.
12306 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
12307 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
12310 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
12311 Similar to @code{__builtin_nan}, except the return type is
12312 @code{_Float@var{n}}.
12315 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
12316 Similar to @code{__builtin_nan}, except the return type is
12317 @code{_Float@var{n}x}.
12320 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
12321 Similar to @code{__builtin_nan}, except the significand is forced
12322 to be a signaling NaN@. The @code{nans} function is proposed by
12323 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
12326 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
12327 Similar to @code{__builtin_nans}, except the return type is @code{float}.
12330 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
12331 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
12334 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
12335 Similar to @code{__builtin_nans}, except the return type is
12336 @code{_Float@var{n}}.
12339 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
12340 Similar to @code{__builtin_nans}, except the return type is
12341 @code{_Float@var{n}x}.
12344 @deftypefn {Built-in Function} int __builtin_ffs (int x)
12345 Returns one plus the index of the least significant 1-bit of @var{x}, or
12346 if @var{x} is zero, returns zero.
12349 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
12350 Returns the number of leading 0-bits in @var{x}, starting at the most
12351 significant bit position. If @var{x} is 0, the result is undefined.
12354 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
12355 Returns the number of trailing 0-bits in @var{x}, starting at the least
12356 significant bit position. If @var{x} is 0, the result is undefined.
12359 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
12360 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
12361 number of bits following the most significant bit that are identical
12362 to it. There are no special cases for 0 or other values.
12365 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
12366 Returns the number of 1-bits in @var{x}.
12369 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
12370 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
12374 @deftypefn {Built-in Function} int __builtin_ffsl (long)
12375 Similar to @code{__builtin_ffs}, except the argument type is
12379 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
12380 Similar to @code{__builtin_clz}, except the argument type is
12381 @code{unsigned long}.
12384 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
12385 Similar to @code{__builtin_ctz}, except the argument type is
12386 @code{unsigned long}.
12389 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
12390 Similar to @code{__builtin_clrsb}, except the argument type is
12394 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
12395 Similar to @code{__builtin_popcount}, except the argument type is
12396 @code{unsigned long}.
12399 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
12400 Similar to @code{__builtin_parity}, except the argument type is
12401 @code{unsigned long}.
12404 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
12405 Similar to @code{__builtin_ffs}, except the argument type is
12409 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
12410 Similar to @code{__builtin_clz}, except the argument type is
12411 @code{unsigned long long}.
12414 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
12415 Similar to @code{__builtin_ctz}, except the argument type is
12416 @code{unsigned long long}.
12419 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
12420 Similar to @code{__builtin_clrsb}, except the argument type is
12424 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
12425 Similar to @code{__builtin_popcount}, except the argument type is
12426 @code{unsigned long long}.
12429 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
12430 Similar to @code{__builtin_parity}, except the argument type is
12431 @code{unsigned long long}.
12434 @deftypefn {Built-in Function} double __builtin_powi (double, int)
12435 Returns the first argument raised to the power of the second. Unlike the
12436 @code{pow} function no guarantees about precision and rounding are made.
12439 @deftypefn {Built-in Function} float __builtin_powif (float, int)
12440 Similar to @code{__builtin_powi}, except the argument and return types
12444 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
12445 Similar to @code{__builtin_powi}, except the argument and return types
12446 are @code{long double}.
12449 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
12450 Returns @var{x} with the order of the bytes reversed; for example,
12451 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
12455 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
12456 Similar to @code{__builtin_bswap16}, except the argument and return types
12460 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
12461 Similar to @code{__builtin_bswap32}, except the argument and return types
12465 @deftypefn {Built-in Function} Pmode __builtin_extend_pointer (void * x)
12466 On targets where the user visible pointer size is smaller than the size
12467 of an actual hardware address this function returns the extended user
12468 pointer. Targets where this is true included ILP32 mode on x86_64 or
12469 Aarch64. This function is mainly useful when writing inline assembly
12473 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_id (int x)
12474 Returns the openacc gang, worker or vector id depending on whether @var{x} is
12478 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_size (int x)
12479 Returns the openacc gang, worker or vector size depending on whether @var{x} is
12483 @node Target Builtins
12484 @section Built-in Functions Specific to Particular Target Machines
12486 On some target machines, GCC supports many built-in functions specific
12487 to those machines. Generally these generate calls to specific machine
12488 instructions, but allow the compiler to schedule those calls.
12491 * AArch64 Built-in Functions::
12492 * Alpha Built-in Functions::
12493 * Altera Nios II Built-in Functions::
12494 * ARC Built-in Functions::
12495 * ARC SIMD Built-in Functions::
12496 * ARM iWMMXt Built-in Functions::
12497 * ARM C Language Extensions (ACLE)::
12498 * ARM Floating Point Status and Control Intrinsics::
12499 * ARM ARMv8-M Security Extensions::
12500 * AVR Built-in Functions::
12501 * Blackfin Built-in Functions::
12502 * FR-V Built-in Functions::
12503 * MIPS DSP Built-in Functions::
12504 * MIPS Paired-Single Support::
12505 * MIPS Loongson Built-in Functions::
12506 * MIPS SIMD Architecture (MSA) Support::
12507 * Other MIPS Built-in Functions::
12508 * MSP430 Built-in Functions::
12509 * NDS32 Built-in Functions::
12510 * picoChip Built-in Functions::
12511 * Basic PowerPC Built-in Functions::
12512 * PowerPC AltiVec/VSX Built-in Functions::
12513 * PowerPC Hardware Transactional Memory Built-in Functions::
12514 * PowerPC Atomic Memory Operation Functions::
12515 * RX Built-in Functions::
12516 * S/390 System z Built-in Functions::
12517 * SH Built-in Functions::
12518 * SPARC VIS Built-in Functions::
12519 * SPU Built-in Functions::
12520 * TI C6X Built-in Functions::
12521 * TILE-Gx Built-in Functions::
12522 * TILEPro Built-in Functions::
12523 * x86 Built-in Functions::
12524 * x86 transactional memory intrinsics::
12525 * x86 control-flow protection intrinsics::
12528 @node AArch64 Built-in Functions
12529 @subsection AArch64 Built-in Functions
12531 These built-in functions are available for the AArch64 family of
12534 unsigned int __builtin_aarch64_get_fpcr ()
12535 void __builtin_aarch64_set_fpcr (unsigned int)
12536 unsigned int __builtin_aarch64_get_fpsr ()
12537 void __builtin_aarch64_set_fpsr (unsigned int)
12540 @node Alpha Built-in Functions
12541 @subsection Alpha Built-in Functions
12543 These built-in functions are available for the Alpha family of
12544 processors, depending on the command-line switches used.
12546 The following built-in functions are always available. They
12547 all generate the machine instruction that is part of the name.
12550 long __builtin_alpha_implver (void)
12551 long __builtin_alpha_rpcc (void)
12552 long __builtin_alpha_amask (long)
12553 long __builtin_alpha_cmpbge (long, long)
12554 long __builtin_alpha_extbl (long, long)
12555 long __builtin_alpha_extwl (long, long)
12556 long __builtin_alpha_extll (long, long)
12557 long __builtin_alpha_extql (long, long)
12558 long __builtin_alpha_extwh (long, long)
12559 long __builtin_alpha_extlh (long, long)
12560 long __builtin_alpha_extqh (long, long)
12561 long __builtin_alpha_insbl (long, long)
12562 long __builtin_alpha_inswl (long, long)
12563 long __builtin_alpha_insll (long, long)
12564 long __builtin_alpha_insql (long, long)
12565 long __builtin_alpha_inswh (long, long)
12566 long __builtin_alpha_inslh (long, long)
12567 long __builtin_alpha_insqh (long, long)
12568 long __builtin_alpha_mskbl (long, long)
12569 long __builtin_alpha_mskwl (long, long)
12570 long __builtin_alpha_mskll (long, long)
12571 long __builtin_alpha_mskql (long, long)
12572 long __builtin_alpha_mskwh (long, long)
12573 long __builtin_alpha_msklh (long, long)
12574 long __builtin_alpha_mskqh (long, long)
12575 long __builtin_alpha_umulh (long, long)
12576 long __builtin_alpha_zap (long, long)
12577 long __builtin_alpha_zapnot (long, long)
12580 The following built-in functions are always with @option{-mmax}
12581 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
12582 later. They all generate the machine instruction that is part
12586 long __builtin_alpha_pklb (long)
12587 long __builtin_alpha_pkwb (long)
12588 long __builtin_alpha_unpkbl (long)
12589 long __builtin_alpha_unpkbw (long)
12590 long __builtin_alpha_minub8 (long, long)
12591 long __builtin_alpha_minsb8 (long, long)
12592 long __builtin_alpha_minuw4 (long, long)
12593 long __builtin_alpha_minsw4 (long, long)
12594 long __builtin_alpha_maxub8 (long, long)
12595 long __builtin_alpha_maxsb8 (long, long)
12596 long __builtin_alpha_maxuw4 (long, long)
12597 long __builtin_alpha_maxsw4 (long, long)
12598 long __builtin_alpha_perr (long, long)
12601 The following built-in functions are always with @option{-mcix}
12602 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
12603 later. They all generate the machine instruction that is part
12607 long __builtin_alpha_cttz (long)
12608 long __builtin_alpha_ctlz (long)
12609 long __builtin_alpha_ctpop (long)
12612 The following built-in functions are available on systems that use the OSF/1
12613 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
12614 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
12615 @code{rdval} and @code{wrval}.
12618 void *__builtin_thread_pointer (void)
12619 void __builtin_set_thread_pointer (void *)
12622 @node Altera Nios II Built-in Functions
12623 @subsection Altera Nios II Built-in Functions
12625 These built-in functions are available for the Altera Nios II
12626 family of processors.
12628 The following built-in functions are always available. They
12629 all generate the machine instruction that is part of the name.
12632 int __builtin_ldbio (volatile const void *)
12633 int __builtin_ldbuio (volatile const void *)
12634 int __builtin_ldhio (volatile const void *)
12635 int __builtin_ldhuio (volatile const void *)
12636 int __builtin_ldwio (volatile const void *)
12637 void __builtin_stbio (volatile void *, int)
12638 void __builtin_sthio (volatile void *, int)
12639 void __builtin_stwio (volatile void *, int)
12640 void __builtin_sync (void)
12641 int __builtin_rdctl (int)
12642 int __builtin_rdprs (int, int)
12643 void __builtin_wrctl (int, int)
12644 void __builtin_flushd (volatile void *)
12645 void __builtin_flushda (volatile void *)
12646 int __builtin_wrpie (int);
12647 void __builtin_eni (int);
12648 int __builtin_ldex (volatile const void *)
12649 int __builtin_stex (volatile void *, int)
12650 int __builtin_ldsex (volatile const void *)
12651 int __builtin_stsex (volatile void *, int)
12654 The following built-in functions are always available. They
12655 all generate a Nios II Custom Instruction. The name of the
12656 function represents the types that the function takes and
12657 returns. The letter before the @code{n} is the return type
12658 or void if absent. The @code{n} represents the first parameter
12659 to all the custom instructions, the custom instruction number.
12660 The two letters after the @code{n} represent the up to two
12661 parameters to the function.
12663 The letters represent the following data types:
12666 @code{void} for return type and no parameter for parameter types.
12669 @code{int} for return type and parameter type
12672 @code{float} for return type and parameter type
12675 @code{void *} for return type and parameter type
12679 And the function names are:
12681 void __builtin_custom_n (void)
12682 void __builtin_custom_ni (int)
12683 void __builtin_custom_nf (float)
12684 void __builtin_custom_np (void *)
12685 void __builtin_custom_nii (int, int)
12686 void __builtin_custom_nif (int, float)
12687 void __builtin_custom_nip (int, void *)
12688 void __builtin_custom_nfi (float, int)
12689 void __builtin_custom_nff (float, float)
12690 void __builtin_custom_nfp (float, void *)
12691 void __builtin_custom_npi (void *, int)
12692 void __builtin_custom_npf (void *, float)
12693 void __builtin_custom_npp (void *, void *)
12694 int __builtin_custom_in (void)
12695 int __builtin_custom_ini (int)
12696 int __builtin_custom_inf (float)
12697 int __builtin_custom_inp (void *)
12698 int __builtin_custom_inii (int, int)
12699 int __builtin_custom_inif (int, float)
12700 int __builtin_custom_inip (int, void *)
12701 int __builtin_custom_infi (float, int)
12702 int __builtin_custom_inff (float, float)
12703 int __builtin_custom_infp (float, void *)
12704 int __builtin_custom_inpi (void *, int)
12705 int __builtin_custom_inpf (void *, float)
12706 int __builtin_custom_inpp (void *, void *)
12707 float __builtin_custom_fn (void)
12708 float __builtin_custom_fni (int)
12709 float __builtin_custom_fnf (float)
12710 float __builtin_custom_fnp (void *)
12711 float __builtin_custom_fnii (int, int)
12712 float __builtin_custom_fnif (int, float)
12713 float __builtin_custom_fnip (int, void *)
12714 float __builtin_custom_fnfi (float, int)
12715 float __builtin_custom_fnff (float, float)
12716 float __builtin_custom_fnfp (float, void *)
12717 float __builtin_custom_fnpi (void *, int)
12718 float __builtin_custom_fnpf (void *, float)
12719 float __builtin_custom_fnpp (void *, void *)
12720 void * __builtin_custom_pn (void)
12721 void * __builtin_custom_pni (int)
12722 void * __builtin_custom_pnf (float)
12723 void * __builtin_custom_pnp (void *)
12724 void * __builtin_custom_pnii (int, int)
12725 void * __builtin_custom_pnif (int, float)
12726 void * __builtin_custom_pnip (int, void *)
12727 void * __builtin_custom_pnfi (float, int)
12728 void * __builtin_custom_pnff (float, float)
12729 void * __builtin_custom_pnfp (float, void *)
12730 void * __builtin_custom_pnpi (void *, int)
12731 void * __builtin_custom_pnpf (void *, float)
12732 void * __builtin_custom_pnpp (void *, void *)
12735 @node ARC Built-in Functions
12736 @subsection ARC Built-in Functions
12738 The following built-in functions are provided for ARC targets. The
12739 built-ins generate the corresponding assembly instructions. In the
12740 examples given below, the generated code often requires an operand or
12741 result to be in a register. Where necessary further code will be
12742 generated to ensure this is true, but for brevity this is not
12743 described in each case.
12745 @emph{Note:} Using a built-in to generate an instruction not supported
12746 by a target may cause problems. At present the compiler is not
12747 guaranteed to detect such misuse, and as a result an internal compiler
12748 error may be generated.
12750 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
12751 Return 1 if @var{val} is known to have the byte alignment given
12752 by @var{alignval}, otherwise return 0.
12753 Note that this is different from
12755 __alignof__(*(char *)@var{val}) >= alignval
12757 because __alignof__ sees only the type of the dereference, whereas
12758 __builtin_arc_align uses alignment information from the pointer
12759 as well as from the pointed-to type.
12760 The information available will depend on optimization level.
12763 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
12770 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
12771 The operand is the number of a register to be read. Generates:
12773 mov @var{dest}, r@var{regno}
12775 where the value in @var{dest} will be the result returned from the
12779 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
12780 The first operand is the number of a register to be written, the
12781 second operand is a compile time constant to write into that
12782 register. Generates:
12784 mov r@var{regno}, @var{val}
12788 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
12789 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
12792 divaw @var{dest}, @var{a}, @var{b}
12794 where the value in @var{dest} will be the result returned from the
12798 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
12805 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
12806 The operand, @var{auxv}, is the address of an auxiliary register and
12807 must be a compile time constant. Generates:
12809 lr @var{dest}, [@var{auxr}]
12811 Where the value in @var{dest} will be the result returned from the
12815 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
12816 Only available with @option{-mmul64}. Generates:
12818 mul64 @var{a}, @var{b}
12822 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12823 Only available with @option{-mmul64}. Generates:
12825 mulu64 @var{a}, @var{b}
12829 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12836 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12837 Only valid if the @samp{norm} instruction is available through the
12838 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12841 norm @var{dest}, @var{src}
12843 Where the value in @var{dest} will be the result returned from the
12847 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
12848 Only valid if the @samp{normw} instruction is available through the
12849 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12852 normw @var{dest}, @var{src}
12854 Where the value in @var{dest} will be the result returned from the
12858 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
12865 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
12872 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
12873 The first argument, @var{auxv}, is the address of an auxiliary
12874 register, the second argument, @var{val}, is a compile time constant
12875 to be written to the register. Generates:
12877 sr @var{auxr}, [@var{val}]
12881 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
12882 Only valid with @option{-mswap}. Generates:
12884 swap @var{dest}, @var{src}
12886 Where the value in @var{dest} will be the result returned from the
12890 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
12897 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
12898 Only available with @option{-mcpu=ARC700}. Generates:
12904 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
12905 Only available with @option{-mcpu=ARC700}. Generates:
12911 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
12912 Only available with @option{-mcpu=ARC700}. Generates:
12918 The instructions generated by the following builtins are not
12919 considered as candidates for scheduling. They are not moved around by
12920 the compiler during scheduling, and thus can be expected to appear
12921 where they are put in the C code:
12923 __builtin_arc_brk()
12924 __builtin_arc_core_read()
12925 __builtin_arc_core_write()
12926 __builtin_arc_flag()
12928 __builtin_arc_sleep()
12930 __builtin_arc_swi()
12933 @node ARC SIMD Built-in Functions
12934 @subsection ARC SIMD Built-in Functions
12936 SIMD builtins provided by the compiler can be used to generate the
12937 vector instructions. This section describes the available builtins
12938 and their usage in programs. With the @option{-msimd} option, the
12939 compiler provides 128-bit vector types, which can be specified using
12940 the @code{vector_size} attribute. The header file @file{arc-simd.h}
12941 can be included to use the following predefined types:
12943 typedef int __v4si __attribute__((vector_size(16)));
12944 typedef short __v8hi __attribute__((vector_size(16)));
12947 These types can be used to define 128-bit variables. The built-in
12948 functions listed in the following section can be used on these
12949 variables to generate the vector operations.
12951 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12952 @file{arc-simd.h} also provides equivalent macros called
12953 @code{_@var{someinsn}} that can be used for programming ease and
12954 improved readability. The following macros for DMA control are also
12957 #define _setup_dma_in_channel_reg _vdiwr
12958 #define _setup_dma_out_channel_reg _vdowr
12961 The following is a complete list of all the SIMD built-ins provided
12962 for ARC, grouped by calling signature.
12964 The following take two @code{__v8hi} arguments and return a
12965 @code{__v8hi} result:
12967 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12968 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12969 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12970 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12971 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12972 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12973 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12974 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
12975 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
12976 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
12977 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
12978 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
12979 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
12980 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12981 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12982 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12983 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12984 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12985 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12986 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12987 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12988 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
12989 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
12990 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
12991 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
12992 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
12993 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
12994 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
12995 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
12996 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
12997 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
12998 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
12999 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
13000 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
13001 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
13002 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
13003 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
13004 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
13005 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
13006 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
13007 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
13008 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
13009 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
13010 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
13011 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
13012 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
13013 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
13014 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
13017 The following take one @code{__v8hi} and one @code{int} argument and return a
13018 @code{__v8hi} result:
13021 __v8hi __builtin_arc_vbaddw (__v8hi, int)
13022 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
13023 __v8hi __builtin_arc_vbminw (__v8hi, int)
13024 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
13025 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
13026 __v8hi __builtin_arc_vbmulw (__v8hi, int)
13027 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
13028 __v8hi __builtin_arc_vbsubw (__v8hi, int)
13031 The following take one @code{__v8hi} argument and one @code{int} argument which
13032 must be a 3-bit compile time constant indicating a register number
13033 I0-I7. They return a @code{__v8hi} result.
13035 __v8hi __builtin_arc_vasrw (__v8hi, const int)
13036 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
13037 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
13040 The following take one @code{__v8hi} argument and one @code{int}
13041 argument which must be a 6-bit compile time constant. They return a
13042 @code{__v8hi} result.
13044 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
13045 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
13046 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
13047 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
13048 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
13049 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
13050 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
13053 The following take one @code{__v8hi} argument and one @code{int} argument which
13054 must be a 8-bit compile time constant. They return a @code{__v8hi}
13057 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
13058 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
13059 __v8hi __builtin_arc_vmvw (__v8hi, const int)
13060 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
13063 The following take two @code{int} arguments, the second of which which
13064 must be a 8-bit compile time constant. They return a @code{__v8hi}
13067 __v8hi __builtin_arc_vmovaw (int, const int)
13068 __v8hi __builtin_arc_vmovw (int, const int)
13069 __v8hi __builtin_arc_vmovzw (int, const int)
13072 The following take a single @code{__v8hi} argument and return a
13073 @code{__v8hi} result:
13075 __v8hi __builtin_arc_vabsaw (__v8hi)
13076 __v8hi __builtin_arc_vabsw (__v8hi)
13077 __v8hi __builtin_arc_vaddsuw (__v8hi)
13078 __v8hi __builtin_arc_vexch1 (__v8hi)
13079 __v8hi __builtin_arc_vexch2 (__v8hi)
13080 __v8hi __builtin_arc_vexch4 (__v8hi)
13081 __v8hi __builtin_arc_vsignw (__v8hi)
13082 __v8hi __builtin_arc_vupbaw (__v8hi)
13083 __v8hi __builtin_arc_vupbw (__v8hi)
13084 __v8hi __builtin_arc_vupsbaw (__v8hi)
13085 __v8hi __builtin_arc_vupsbw (__v8hi)
13088 The following take two @code{int} arguments and return no result:
13090 void __builtin_arc_vdirun (int, int)
13091 void __builtin_arc_vdorun (int, int)
13094 The following take two @code{int} arguments and return no result. The
13095 first argument must a 3-bit compile time constant indicating one of
13096 the DR0-DR7 DMA setup channels:
13098 void __builtin_arc_vdiwr (const int, int)
13099 void __builtin_arc_vdowr (const int, int)
13102 The following take an @code{int} argument and return no result:
13104 void __builtin_arc_vendrec (int)
13105 void __builtin_arc_vrec (int)
13106 void __builtin_arc_vrecrun (int)
13107 void __builtin_arc_vrun (int)
13110 The following take a @code{__v8hi} argument and two @code{int}
13111 arguments and return a @code{__v8hi} result. The second argument must
13112 be a 3-bit compile time constants, indicating one the registers I0-I7,
13113 and the third argument must be an 8-bit compile time constant.
13115 @emph{Note:} Although the equivalent hardware instructions do not take
13116 an SIMD register as an operand, these builtins overwrite the relevant
13117 bits of the @code{__v8hi} register provided as the first argument with
13118 the value loaded from the @code{[Ib, u8]} location in the SDM.
13121 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
13122 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
13123 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
13124 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
13127 The following take two @code{int} arguments and return a @code{__v8hi}
13128 result. The first argument must be a 3-bit compile time constants,
13129 indicating one the registers I0-I7, and the second argument must be an
13130 8-bit compile time constant.
13133 __v8hi __builtin_arc_vld128 (const int, const int)
13134 __v8hi __builtin_arc_vld64w (const int, const int)
13137 The following take a @code{__v8hi} argument and two @code{int}
13138 arguments and return no result. The second argument must be a 3-bit
13139 compile time constants, indicating one the registers I0-I7, and the
13140 third argument must be an 8-bit compile time constant.
13143 void __builtin_arc_vst128 (__v8hi, const int, const int)
13144 void __builtin_arc_vst64 (__v8hi, const int, const int)
13147 The following take a @code{__v8hi} argument and three @code{int}
13148 arguments and return no result. The second argument must be a 3-bit
13149 compile-time constant, identifying the 16-bit sub-register to be
13150 stored, the third argument must be a 3-bit compile time constants,
13151 indicating one the registers I0-I7, and the fourth argument must be an
13152 8-bit compile time constant.
13155 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
13156 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
13159 @node ARM iWMMXt Built-in Functions
13160 @subsection ARM iWMMXt Built-in Functions
13162 These built-in functions are available for the ARM family of
13163 processors when the @option{-mcpu=iwmmxt} switch is used:
13166 typedef int v2si __attribute__ ((vector_size (8)));
13167 typedef short v4hi __attribute__ ((vector_size (8)));
13168 typedef char v8qi __attribute__ ((vector_size (8)));
13170 int __builtin_arm_getwcgr0 (void)
13171 void __builtin_arm_setwcgr0 (int)
13172 int __builtin_arm_getwcgr1 (void)
13173 void __builtin_arm_setwcgr1 (int)
13174 int __builtin_arm_getwcgr2 (void)
13175 void __builtin_arm_setwcgr2 (int)
13176 int __builtin_arm_getwcgr3 (void)
13177 void __builtin_arm_setwcgr3 (int)
13178 int __builtin_arm_textrmsb (v8qi, int)
13179 int __builtin_arm_textrmsh (v4hi, int)
13180 int __builtin_arm_textrmsw (v2si, int)
13181 int __builtin_arm_textrmub (v8qi, int)
13182 int __builtin_arm_textrmuh (v4hi, int)
13183 int __builtin_arm_textrmuw (v2si, int)
13184 v8qi __builtin_arm_tinsrb (v8qi, int, int)
13185 v4hi __builtin_arm_tinsrh (v4hi, int, int)
13186 v2si __builtin_arm_tinsrw (v2si, int, int)
13187 long long __builtin_arm_tmia (long long, int, int)
13188 long long __builtin_arm_tmiabb (long long, int, int)
13189 long long __builtin_arm_tmiabt (long long, int, int)
13190 long long __builtin_arm_tmiaph (long long, int, int)
13191 long long __builtin_arm_tmiatb (long long, int, int)
13192 long long __builtin_arm_tmiatt (long long, int, int)
13193 int __builtin_arm_tmovmskb (v8qi)
13194 int __builtin_arm_tmovmskh (v4hi)
13195 int __builtin_arm_tmovmskw (v2si)
13196 long long __builtin_arm_waccb (v8qi)
13197 long long __builtin_arm_wacch (v4hi)
13198 long long __builtin_arm_waccw (v2si)
13199 v8qi __builtin_arm_waddb (v8qi, v8qi)
13200 v8qi __builtin_arm_waddbss (v8qi, v8qi)
13201 v8qi __builtin_arm_waddbus (v8qi, v8qi)
13202 v4hi __builtin_arm_waddh (v4hi, v4hi)
13203 v4hi __builtin_arm_waddhss (v4hi, v4hi)
13204 v4hi __builtin_arm_waddhus (v4hi, v4hi)
13205 v2si __builtin_arm_waddw (v2si, v2si)
13206 v2si __builtin_arm_waddwss (v2si, v2si)
13207 v2si __builtin_arm_waddwus (v2si, v2si)
13208 v8qi __builtin_arm_walign (v8qi, v8qi, int)
13209 long long __builtin_arm_wand(long long, long long)
13210 long long __builtin_arm_wandn (long long, long long)
13211 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
13212 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
13213 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
13214 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
13215 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
13216 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
13217 v2si __builtin_arm_wcmpeqw (v2si, v2si)
13218 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
13219 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
13220 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
13221 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
13222 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
13223 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
13224 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
13225 long long __builtin_arm_wmacsz (v4hi, v4hi)
13226 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
13227 long long __builtin_arm_wmacuz (v4hi, v4hi)
13228 v4hi __builtin_arm_wmadds (v4hi, v4hi)
13229 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
13230 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
13231 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
13232 v2si __builtin_arm_wmaxsw (v2si, v2si)
13233 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
13234 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
13235 v2si __builtin_arm_wmaxuw (v2si, v2si)
13236 v8qi __builtin_arm_wminsb (v8qi, v8qi)
13237 v4hi __builtin_arm_wminsh (v4hi, v4hi)
13238 v2si __builtin_arm_wminsw (v2si, v2si)
13239 v8qi __builtin_arm_wminub (v8qi, v8qi)
13240 v4hi __builtin_arm_wminuh (v4hi, v4hi)
13241 v2si __builtin_arm_wminuw (v2si, v2si)
13242 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
13243 v4hi __builtin_arm_wmulul (v4hi, v4hi)
13244 v4hi __builtin_arm_wmulum (v4hi, v4hi)
13245 long long __builtin_arm_wor (long long, long long)
13246 v2si __builtin_arm_wpackdss (long long, long long)
13247 v2si __builtin_arm_wpackdus (long long, long long)
13248 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
13249 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
13250 v4hi __builtin_arm_wpackwss (v2si, v2si)
13251 v4hi __builtin_arm_wpackwus (v2si, v2si)
13252 long long __builtin_arm_wrord (long long, long long)
13253 long long __builtin_arm_wrordi (long long, int)
13254 v4hi __builtin_arm_wrorh (v4hi, long long)
13255 v4hi __builtin_arm_wrorhi (v4hi, int)
13256 v2si __builtin_arm_wrorw (v2si, long long)
13257 v2si __builtin_arm_wrorwi (v2si, int)
13258 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
13259 v2si __builtin_arm_wsadbz (v8qi, v8qi)
13260 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
13261 v2si __builtin_arm_wsadhz (v4hi, v4hi)
13262 v4hi __builtin_arm_wshufh (v4hi, int)
13263 long long __builtin_arm_wslld (long long, long long)
13264 long long __builtin_arm_wslldi (long long, int)
13265 v4hi __builtin_arm_wsllh (v4hi, long long)
13266 v4hi __builtin_arm_wsllhi (v4hi, int)
13267 v2si __builtin_arm_wsllw (v2si, long long)
13268 v2si __builtin_arm_wsllwi (v2si, int)
13269 long long __builtin_arm_wsrad (long long, long long)
13270 long long __builtin_arm_wsradi (long long, int)
13271 v4hi __builtin_arm_wsrah (v4hi, long long)
13272 v4hi __builtin_arm_wsrahi (v4hi, int)
13273 v2si __builtin_arm_wsraw (v2si, long long)
13274 v2si __builtin_arm_wsrawi (v2si, int)
13275 long long __builtin_arm_wsrld (long long, long long)
13276 long long __builtin_arm_wsrldi (long long, int)
13277 v4hi __builtin_arm_wsrlh (v4hi, long long)
13278 v4hi __builtin_arm_wsrlhi (v4hi, int)
13279 v2si __builtin_arm_wsrlw (v2si, long long)
13280 v2si __builtin_arm_wsrlwi (v2si, int)
13281 v8qi __builtin_arm_wsubb (v8qi, v8qi)
13282 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
13283 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
13284 v4hi __builtin_arm_wsubh (v4hi, v4hi)
13285 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
13286 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
13287 v2si __builtin_arm_wsubw (v2si, v2si)
13288 v2si __builtin_arm_wsubwss (v2si, v2si)
13289 v2si __builtin_arm_wsubwus (v2si, v2si)
13290 v4hi __builtin_arm_wunpckehsb (v8qi)
13291 v2si __builtin_arm_wunpckehsh (v4hi)
13292 long long __builtin_arm_wunpckehsw (v2si)
13293 v4hi __builtin_arm_wunpckehub (v8qi)
13294 v2si __builtin_arm_wunpckehuh (v4hi)
13295 long long __builtin_arm_wunpckehuw (v2si)
13296 v4hi __builtin_arm_wunpckelsb (v8qi)
13297 v2si __builtin_arm_wunpckelsh (v4hi)
13298 long long __builtin_arm_wunpckelsw (v2si)
13299 v4hi __builtin_arm_wunpckelub (v8qi)
13300 v2si __builtin_arm_wunpckeluh (v4hi)
13301 long long __builtin_arm_wunpckeluw (v2si)
13302 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
13303 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
13304 v2si __builtin_arm_wunpckihw (v2si, v2si)
13305 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
13306 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
13307 v2si __builtin_arm_wunpckilw (v2si, v2si)
13308 long long __builtin_arm_wxor (long long, long long)
13309 long long __builtin_arm_wzero ()
13313 @node ARM C Language Extensions (ACLE)
13314 @subsection ARM C Language Extensions (ACLE)
13316 GCC implements extensions for C as described in the ARM C Language
13317 Extensions (ACLE) specification, which can be found at
13318 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
13320 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
13321 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
13322 intrinsics can be found at
13323 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
13324 The built-in intrinsics for the Advanced SIMD extension are available when
13327 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
13328 back ends support CRC32 intrinsics and the ARM back end supports the
13329 Coprocessor intrinsics, all from @file{arm_acle.h}. The ARM back end's 16-bit
13330 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
13331 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
13334 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
13335 availability of extensions.
13337 @node ARM Floating Point Status and Control Intrinsics
13338 @subsection ARM Floating Point Status and Control Intrinsics
13340 These built-in functions are available for the ARM family of
13341 processors with floating-point unit.
13344 unsigned int __builtin_arm_get_fpscr ()
13345 void __builtin_arm_set_fpscr (unsigned int)
13348 @node ARM ARMv8-M Security Extensions
13349 @subsection ARM ARMv8-M Security Extensions
13351 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
13352 Security Extensions: Requirements on Development Tools Engineering
13353 Specification, which can be found at
13354 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
13356 As part of the Security Extensions GCC implements two new function attributes:
13357 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
13359 As part of the Security Extensions GCC implements the intrinsics below. FPTR
13360 is used here to mean any function pointer type.
13363 cmse_address_info_t cmse_TT (void *)
13364 cmse_address_info_t cmse_TT_fptr (FPTR)
13365 cmse_address_info_t cmse_TTT (void *)
13366 cmse_address_info_t cmse_TTT_fptr (FPTR)
13367 cmse_address_info_t cmse_TTA (void *)
13368 cmse_address_info_t cmse_TTA_fptr (FPTR)
13369 cmse_address_info_t cmse_TTAT (void *)
13370 cmse_address_info_t cmse_TTAT_fptr (FPTR)
13371 void * cmse_check_address_range (void *, size_t, int)
13372 typeof(p) cmse_nsfptr_create (FPTR p)
13373 intptr_t cmse_is_nsfptr (FPTR)
13374 int cmse_nonsecure_caller (void)
13377 @node AVR Built-in Functions
13378 @subsection AVR Built-in Functions
13380 For each built-in function for AVR, there is an equally named,
13381 uppercase built-in macro defined. That way users can easily query if
13382 or if not a specific built-in is implemented or not. For example, if
13383 @code{__builtin_avr_nop} is available the macro
13384 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
13388 @item void __builtin_avr_nop (void)
13389 @itemx void __builtin_avr_sei (void)
13390 @itemx void __builtin_avr_cli (void)
13391 @itemx void __builtin_avr_sleep (void)
13392 @itemx void __builtin_avr_wdr (void)
13393 @itemx unsigned char __builtin_avr_swap (unsigned char)
13394 @itemx unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
13395 @itemx int __builtin_avr_fmuls (char, char)
13396 @itemx int __builtin_avr_fmulsu (char, unsigned char)
13397 These built-in functions map to the respective machine
13398 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
13399 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
13400 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
13401 as library call if no hardware multiplier is available.
13403 @item void __builtin_avr_delay_cycles (unsigned long ticks)
13404 Delay execution for @var{ticks} cycles. Note that this
13405 built-in does not take into account the effect of interrupts that
13406 might increase delay time. @var{ticks} must be a compile-time
13407 integer constant; delays with a variable number of cycles are not supported.
13409 @item char __builtin_avr_flash_segment (const __memx void*)
13410 This built-in takes a byte address to the 24-bit
13411 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
13412 the number of the flash segment (the 64 KiB chunk) where the address
13413 points to. Counting starts at @code{0}.
13414 If the address does not point to flash memory, return @code{-1}.
13416 @item uint8_t __builtin_avr_insert_bits (uint32_t map, uint8_t bits, uint8_t val)
13417 Insert bits from @var{bits} into @var{val} and return the resulting
13418 value. The nibbles of @var{map} determine how the insertion is
13419 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
13421 @item If @var{X} is @code{0xf},
13422 then the @var{n}-th bit of @var{val} is returned unaltered.
13424 @item If X is in the range 0@dots{}7,
13425 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
13427 @item If X is in the range 8@dots{}@code{0xe},
13428 then the @var{n}-th result bit is undefined.
13432 One typical use case for this built-in is adjusting input and
13433 output values to non-contiguous port layouts. Some examples:
13436 // same as val, bits is unused
13437 __builtin_avr_insert_bits (0xffffffff, bits, val)
13441 // same as bits, val is unused
13442 __builtin_avr_insert_bits (0x76543210, bits, val)
13446 // same as rotating bits by 4
13447 __builtin_avr_insert_bits (0x32107654, bits, 0)
13451 // high nibble of result is the high nibble of val
13452 // low nibble of result is the low nibble of bits
13453 __builtin_avr_insert_bits (0xffff3210, bits, val)
13457 // reverse the bit order of bits
13458 __builtin_avr_insert_bits (0x01234567, bits, 0)
13461 @item void __builtin_avr_nops (unsigned count)
13462 Insert @var{count} @code{NOP} instructions.
13463 The number of instructions must be a compile-time integer constant.
13468 There are many more AVR-specific built-in functions that are used to
13469 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
13470 section 7.18a.6. You don't need to use these built-ins directly.
13471 Instead, use the declarations as supplied by the @code{stdfix.h} header
13475 #include <stdfix.h>
13477 // Re-interpret the bit representation of unsigned 16-bit
13478 // integer @var{uval} as Q-format 0.16 value.
13479 unsigned fract get_bits (uint_ur_t uval)
13481 return urbits (uval);
13485 @node Blackfin Built-in Functions
13486 @subsection Blackfin Built-in Functions
13488 Currently, there are two Blackfin-specific built-in functions. These are
13489 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
13490 using inline assembly; by using these built-in functions the compiler can
13491 automatically add workarounds for hardware errata involving these
13492 instructions. These functions are named as follows:
13495 void __builtin_bfin_csync (void)
13496 void __builtin_bfin_ssync (void)
13499 @node FR-V Built-in Functions
13500 @subsection FR-V Built-in Functions
13502 GCC provides many FR-V-specific built-in functions. In general,
13503 these functions are intended to be compatible with those described
13504 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
13505 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
13506 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
13507 pointer rather than by value.
13509 Most of the functions are named after specific FR-V instructions.
13510 Such functions are said to be ``directly mapped'' and are summarized
13511 here in tabular form.
13515 * Directly-mapped Integer Functions::
13516 * Directly-mapped Media Functions::
13517 * Raw read/write Functions::
13518 * Other Built-in Functions::
13521 @node Argument Types
13522 @subsubsection Argument Types
13524 The arguments to the built-in functions can be divided into three groups:
13525 register numbers, compile-time constants and run-time values. In order
13526 to make this classification clear at a glance, the arguments and return
13527 values are given the following pseudo types:
13529 @multitable @columnfractions .20 .30 .15 .35
13530 @item Pseudo type @tab Real C type @tab Constant? @tab Description
13531 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
13532 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
13533 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
13534 @item @code{uw2} @tab @code{unsigned long long} @tab No
13535 @tab an unsigned doubleword
13536 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
13537 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
13538 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
13539 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
13542 These pseudo types are not defined by GCC, they are simply a notational
13543 convenience used in this manual.
13545 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
13546 and @code{sw2} are evaluated at run time. They correspond to
13547 register operands in the underlying FR-V instructions.
13549 @code{const} arguments represent immediate operands in the underlying
13550 FR-V instructions. They must be compile-time constants.
13552 @code{acc} arguments are evaluated at compile time and specify the number
13553 of an accumulator register. For example, an @code{acc} argument of 2
13554 selects the ACC2 register.
13556 @code{iacc} arguments are similar to @code{acc} arguments but specify the
13557 number of an IACC register. See @pxref{Other Built-in Functions}
13560 @node Directly-mapped Integer Functions
13561 @subsubsection Directly-Mapped Integer Functions
13563 The functions listed below map directly to FR-V I-type instructions.
13565 @multitable @columnfractions .45 .32 .23
13566 @item Function prototype @tab Example usage @tab Assembly output
13567 @item @code{sw1 __ADDSS (sw1, sw1)}
13568 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
13569 @tab @code{ADDSS @var{a},@var{b},@var{c}}
13570 @item @code{sw1 __SCAN (sw1, sw1)}
13571 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
13572 @tab @code{SCAN @var{a},@var{b},@var{c}}
13573 @item @code{sw1 __SCUTSS (sw1)}
13574 @tab @code{@var{b} = __SCUTSS (@var{a})}
13575 @tab @code{SCUTSS @var{a},@var{b}}
13576 @item @code{sw1 __SLASS (sw1, sw1)}
13577 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
13578 @tab @code{SLASS @var{a},@var{b},@var{c}}
13579 @item @code{void __SMASS (sw1, sw1)}
13580 @tab @code{__SMASS (@var{a}, @var{b})}
13581 @tab @code{SMASS @var{a},@var{b}}
13582 @item @code{void __SMSSS (sw1, sw1)}
13583 @tab @code{__SMSSS (@var{a}, @var{b})}
13584 @tab @code{SMSSS @var{a},@var{b}}
13585 @item @code{void __SMU (sw1, sw1)}
13586 @tab @code{__SMU (@var{a}, @var{b})}
13587 @tab @code{SMU @var{a},@var{b}}
13588 @item @code{sw2 __SMUL (sw1, sw1)}
13589 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
13590 @tab @code{SMUL @var{a},@var{b},@var{c}}
13591 @item @code{sw1 __SUBSS (sw1, sw1)}
13592 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
13593 @tab @code{SUBSS @var{a},@var{b},@var{c}}
13594 @item @code{uw2 __UMUL (uw1, uw1)}
13595 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
13596 @tab @code{UMUL @var{a},@var{b},@var{c}}
13599 @node Directly-mapped Media Functions
13600 @subsubsection Directly-Mapped Media Functions
13602 The functions listed below map directly to FR-V M-type instructions.
13604 @multitable @columnfractions .45 .32 .23
13605 @item Function prototype @tab Example usage @tab Assembly output
13606 @item @code{uw1 __MABSHS (sw1)}
13607 @tab @code{@var{b} = __MABSHS (@var{a})}
13608 @tab @code{MABSHS @var{a},@var{b}}
13609 @item @code{void __MADDACCS (acc, acc)}
13610 @tab @code{__MADDACCS (@var{b}, @var{a})}
13611 @tab @code{MADDACCS @var{a},@var{b}}
13612 @item @code{sw1 __MADDHSS (sw1, sw1)}
13613 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
13614 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
13615 @item @code{uw1 __MADDHUS (uw1, uw1)}
13616 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
13617 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
13618 @item @code{uw1 __MAND (uw1, uw1)}
13619 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
13620 @tab @code{MAND @var{a},@var{b},@var{c}}
13621 @item @code{void __MASACCS (acc, acc)}
13622 @tab @code{__MASACCS (@var{b}, @var{a})}
13623 @tab @code{MASACCS @var{a},@var{b}}
13624 @item @code{uw1 __MAVEH (uw1, uw1)}
13625 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
13626 @tab @code{MAVEH @var{a},@var{b},@var{c}}
13627 @item @code{uw2 __MBTOH (uw1)}
13628 @tab @code{@var{b} = __MBTOH (@var{a})}
13629 @tab @code{MBTOH @var{a},@var{b}}
13630 @item @code{void __MBTOHE (uw1 *, uw1)}
13631 @tab @code{__MBTOHE (&@var{b}, @var{a})}
13632 @tab @code{MBTOHE @var{a},@var{b}}
13633 @item @code{void __MCLRACC (acc)}
13634 @tab @code{__MCLRACC (@var{a})}
13635 @tab @code{MCLRACC @var{a}}
13636 @item @code{void __MCLRACCA (void)}
13637 @tab @code{__MCLRACCA ()}
13638 @tab @code{MCLRACCA}
13639 @item @code{uw1 __Mcop1 (uw1, uw1)}
13640 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
13641 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
13642 @item @code{uw1 __Mcop2 (uw1, uw1)}
13643 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
13644 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
13645 @item @code{uw1 __MCPLHI (uw2, const)}
13646 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
13647 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
13648 @item @code{uw1 __MCPLI (uw2, const)}
13649 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
13650 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
13651 @item @code{void __MCPXIS (acc, sw1, sw1)}
13652 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
13653 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
13654 @item @code{void __MCPXIU (acc, uw1, uw1)}
13655 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
13656 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
13657 @item @code{void __MCPXRS (acc, sw1, sw1)}
13658 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
13659 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
13660 @item @code{void __MCPXRU (acc, uw1, uw1)}
13661 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
13662 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
13663 @item @code{uw1 __MCUT (acc, uw1)}
13664 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
13665 @tab @code{MCUT @var{a},@var{b},@var{c}}
13666 @item @code{uw1 __MCUTSS (acc, sw1)}
13667 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
13668 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
13669 @item @code{void __MDADDACCS (acc, acc)}
13670 @tab @code{__MDADDACCS (@var{b}, @var{a})}
13671 @tab @code{MDADDACCS @var{a},@var{b}}
13672 @item @code{void __MDASACCS (acc, acc)}
13673 @tab @code{__MDASACCS (@var{b}, @var{a})}
13674 @tab @code{MDASACCS @var{a},@var{b}}
13675 @item @code{uw2 __MDCUTSSI (acc, const)}
13676 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
13677 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
13678 @item @code{uw2 __MDPACKH (uw2, uw2)}
13679 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
13680 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
13681 @item @code{uw2 __MDROTLI (uw2, const)}
13682 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
13683 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
13684 @item @code{void __MDSUBACCS (acc, acc)}
13685 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
13686 @tab @code{MDSUBACCS @var{a},@var{b}}
13687 @item @code{void __MDUNPACKH (uw1 *, uw2)}
13688 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
13689 @tab @code{MDUNPACKH @var{a},@var{b}}
13690 @item @code{uw2 __MEXPDHD (uw1, const)}
13691 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
13692 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
13693 @item @code{uw1 __MEXPDHW (uw1, const)}
13694 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
13695 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
13696 @item @code{uw1 __MHDSETH (uw1, const)}
13697 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
13698 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
13699 @item @code{sw1 __MHDSETS (const)}
13700 @tab @code{@var{b} = __MHDSETS (@var{a})}
13701 @tab @code{MHDSETS #@var{a},@var{b}}
13702 @item @code{uw1 __MHSETHIH (uw1, const)}
13703 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
13704 @tab @code{MHSETHIH #@var{a},@var{b}}
13705 @item @code{sw1 __MHSETHIS (sw1, const)}
13706 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
13707 @tab @code{MHSETHIS #@var{a},@var{b}}
13708 @item @code{uw1 __MHSETLOH (uw1, const)}
13709 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
13710 @tab @code{MHSETLOH #@var{a},@var{b}}
13711 @item @code{sw1 __MHSETLOS (sw1, const)}
13712 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
13713 @tab @code{MHSETLOS #@var{a},@var{b}}
13714 @item @code{uw1 __MHTOB (uw2)}
13715 @tab @code{@var{b} = __MHTOB (@var{a})}
13716 @tab @code{MHTOB @var{a},@var{b}}
13717 @item @code{void __MMACHS (acc, sw1, sw1)}
13718 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
13719 @tab @code{MMACHS @var{a},@var{b},@var{c}}
13720 @item @code{void __MMACHU (acc, uw1, uw1)}
13721 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
13722 @tab @code{MMACHU @var{a},@var{b},@var{c}}
13723 @item @code{void __MMRDHS (acc, sw1, sw1)}
13724 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
13725 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
13726 @item @code{void __MMRDHU (acc, uw1, uw1)}
13727 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
13728 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
13729 @item @code{void __MMULHS (acc, sw1, sw1)}
13730 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
13731 @tab @code{MMULHS @var{a},@var{b},@var{c}}
13732 @item @code{void __MMULHU (acc, uw1, uw1)}
13733 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
13734 @tab @code{MMULHU @var{a},@var{b},@var{c}}
13735 @item @code{void __MMULXHS (acc, sw1, sw1)}
13736 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
13737 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
13738 @item @code{void __MMULXHU (acc, uw1, uw1)}
13739 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
13740 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
13741 @item @code{uw1 __MNOT (uw1)}
13742 @tab @code{@var{b} = __MNOT (@var{a})}
13743 @tab @code{MNOT @var{a},@var{b}}
13744 @item @code{uw1 __MOR (uw1, uw1)}
13745 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
13746 @tab @code{MOR @var{a},@var{b},@var{c}}
13747 @item @code{uw1 __MPACKH (uh, uh)}
13748 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
13749 @tab @code{MPACKH @var{a},@var{b},@var{c}}
13750 @item @code{sw2 __MQADDHSS (sw2, sw2)}
13751 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
13752 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
13753 @item @code{uw2 __MQADDHUS (uw2, uw2)}
13754 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
13755 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
13756 @item @code{void __MQCPXIS (acc, sw2, sw2)}
13757 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
13758 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
13759 @item @code{void __MQCPXIU (acc, uw2, uw2)}
13760 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
13761 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
13762 @item @code{void __MQCPXRS (acc, sw2, sw2)}
13763 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
13764 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
13765 @item @code{void __MQCPXRU (acc, uw2, uw2)}
13766 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
13767 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
13768 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
13769 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
13770 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
13771 @item @code{sw2 __MQLMTHS (sw2, sw2)}
13772 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
13773 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
13774 @item @code{void __MQMACHS (acc, sw2, sw2)}
13775 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
13776 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
13777 @item @code{void __MQMACHU (acc, uw2, uw2)}
13778 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
13779 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
13780 @item @code{void __MQMACXHS (acc, sw2, sw2)}
13781 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
13782 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
13783 @item @code{void __MQMULHS (acc, sw2, sw2)}
13784 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
13785 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
13786 @item @code{void __MQMULHU (acc, uw2, uw2)}
13787 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
13788 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
13789 @item @code{void __MQMULXHS (acc, sw2, sw2)}
13790 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
13791 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
13792 @item @code{void __MQMULXHU (acc, uw2, uw2)}
13793 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
13794 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
13795 @item @code{sw2 __MQSATHS (sw2, sw2)}
13796 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
13797 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
13798 @item @code{uw2 __MQSLLHI (uw2, int)}
13799 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
13800 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
13801 @item @code{sw2 __MQSRAHI (sw2, int)}
13802 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
13803 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
13804 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
13805 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
13806 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
13807 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
13808 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
13809 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
13810 @item @code{void __MQXMACHS (acc, sw2, sw2)}
13811 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
13812 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
13813 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
13814 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
13815 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
13816 @item @code{uw1 __MRDACC (acc)}
13817 @tab @code{@var{b} = __MRDACC (@var{a})}
13818 @tab @code{MRDACC @var{a},@var{b}}
13819 @item @code{uw1 __MRDACCG (acc)}
13820 @tab @code{@var{b} = __MRDACCG (@var{a})}
13821 @tab @code{MRDACCG @var{a},@var{b}}
13822 @item @code{uw1 __MROTLI (uw1, const)}
13823 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
13824 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
13825 @item @code{uw1 __MROTRI (uw1, const)}
13826 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
13827 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
13828 @item @code{sw1 __MSATHS (sw1, sw1)}
13829 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
13830 @tab @code{MSATHS @var{a},@var{b},@var{c}}
13831 @item @code{uw1 __MSATHU (uw1, uw1)}
13832 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
13833 @tab @code{MSATHU @var{a},@var{b},@var{c}}
13834 @item @code{uw1 __MSLLHI (uw1, const)}
13835 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
13836 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
13837 @item @code{sw1 __MSRAHI (sw1, const)}
13838 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
13839 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
13840 @item @code{uw1 __MSRLHI (uw1, const)}
13841 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
13842 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
13843 @item @code{void __MSUBACCS (acc, acc)}
13844 @tab @code{__MSUBACCS (@var{b}, @var{a})}
13845 @tab @code{MSUBACCS @var{a},@var{b}}
13846 @item @code{sw1 __MSUBHSS (sw1, sw1)}
13847 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
13848 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
13849 @item @code{uw1 __MSUBHUS (uw1, uw1)}
13850 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
13851 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
13852 @item @code{void __MTRAP (void)}
13853 @tab @code{__MTRAP ()}
13855 @item @code{uw2 __MUNPACKH (uw1)}
13856 @tab @code{@var{b} = __MUNPACKH (@var{a})}
13857 @tab @code{MUNPACKH @var{a},@var{b}}
13858 @item @code{uw1 __MWCUT (uw2, uw1)}
13859 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
13860 @tab @code{MWCUT @var{a},@var{b},@var{c}}
13861 @item @code{void __MWTACC (acc, uw1)}
13862 @tab @code{__MWTACC (@var{b}, @var{a})}
13863 @tab @code{MWTACC @var{a},@var{b}}
13864 @item @code{void __MWTACCG (acc, uw1)}
13865 @tab @code{__MWTACCG (@var{b}, @var{a})}
13866 @tab @code{MWTACCG @var{a},@var{b}}
13867 @item @code{uw1 __MXOR (uw1, uw1)}
13868 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
13869 @tab @code{MXOR @var{a},@var{b},@var{c}}
13872 @node Raw read/write Functions
13873 @subsubsection Raw Read/Write Functions
13875 This sections describes built-in functions related to read and write
13876 instructions to access memory. These functions generate
13877 @code{membar} instructions to flush the I/O load and stores where
13878 appropriate, as described in Fujitsu's manual described above.
13882 @item unsigned char __builtin_read8 (void *@var{data})
13883 @item unsigned short __builtin_read16 (void *@var{data})
13884 @item unsigned long __builtin_read32 (void *@var{data})
13885 @item unsigned long long __builtin_read64 (void *@var{data})
13887 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
13888 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
13889 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
13890 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
13893 @node Other Built-in Functions
13894 @subsubsection Other Built-in Functions
13896 This section describes built-in functions that are not named after
13897 a specific FR-V instruction.
13900 @item sw2 __IACCreadll (iacc @var{reg})
13901 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
13902 for future expansion and must be 0.
13904 @item sw1 __IACCreadl (iacc @var{reg})
13905 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
13906 Other values of @var{reg} are rejected as invalid.
13908 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
13909 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
13910 is reserved for future expansion and must be 0.
13912 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
13913 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
13914 is 1. Other values of @var{reg} are rejected as invalid.
13916 @item void __data_prefetch0 (const void *@var{x})
13917 Use the @code{dcpl} instruction to load the contents of address @var{x}
13918 into the data cache.
13920 @item void __data_prefetch (const void *@var{x})
13921 Use the @code{nldub} instruction to load the contents of address @var{x}
13922 into the data cache. The instruction is issued in slot I1@.
13925 @node MIPS DSP Built-in Functions
13926 @subsection MIPS DSP Built-in Functions
13928 The MIPS DSP Application-Specific Extension (ASE) includes new
13929 instructions that are designed to improve the performance of DSP and
13930 media applications. It provides instructions that operate on packed
13931 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13933 GCC supports MIPS DSP operations using both the generic
13934 vector extensions (@pxref{Vector Extensions}) and a collection of
13935 MIPS-specific built-in functions. Both kinds of support are
13936 enabled by the @option{-mdsp} command-line option.
13938 Revision 2 of the ASE was introduced in the second half of 2006.
13939 This revision adds extra instructions to the original ASE, but is
13940 otherwise backwards-compatible with it. You can select revision 2
13941 using the command-line option @option{-mdspr2}; this option implies
13944 The SCOUNT and POS bits of the DSP control register are global. The
13945 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13946 POS bits. During optimization, the compiler does not delete these
13947 instructions and it does not delete calls to functions containing
13948 these instructions.
13950 At present, GCC only provides support for operations on 32-bit
13951 vectors. The vector type associated with 8-bit integer data is
13952 usually called @code{v4i8}, the vector type associated with Q7
13953 is usually called @code{v4q7}, the vector type associated with 16-bit
13954 integer data is usually called @code{v2i16}, and the vector type
13955 associated with Q15 is usually called @code{v2q15}. They can be
13956 defined in C as follows:
13959 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13960 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13961 typedef short v2i16 __attribute__ ((vector_size(4)));
13962 typedef short v2q15 __attribute__ ((vector_size(4)));
13965 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13966 initialized in the same way as aggregates. For example:
13969 v4i8 a = @{1, 2, 3, 4@};
13971 b = (v4i8) @{5, 6, 7, 8@};
13973 v2q15 c = @{0x0fcb, 0x3a75@};
13975 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13978 @emph{Note:} The CPU's endianness determines the order in which values
13979 are packed. On little-endian targets, the first value is the least
13980 significant and the last value is the most significant. The opposite
13981 order applies to big-endian targets. For example, the code above
13982 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13983 and @code{4} on big-endian targets.
13985 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13986 representation. As shown in this example, the integer representation
13987 of a Q7 value can be obtained by multiplying the fractional value by
13988 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
13989 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
13992 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13993 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
13994 and @code{c} and @code{d} are @code{v2q15} values.
13996 @multitable @columnfractions .50 .50
13997 @item C code @tab MIPS instruction
13998 @item @code{a + b} @tab @code{addu.qb}
13999 @item @code{c + d} @tab @code{addq.ph}
14000 @item @code{a - b} @tab @code{subu.qb}
14001 @item @code{c - d} @tab @code{subq.ph}
14004 The table below lists the @code{v2i16} operation for which
14005 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
14006 @code{v2i16} values.
14008 @multitable @columnfractions .50 .50
14009 @item C code @tab MIPS instruction
14010 @item @code{e * f} @tab @code{mul.ph}
14013 It is easier to describe the DSP built-in functions if we first define
14014 the following types:
14019 typedef unsigned int ui32;
14020 typedef long long a64;
14023 @code{q31} and @code{i32} are actually the same as @code{int}, but we
14024 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
14025 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
14026 @code{long long}, but we use @code{a64} to indicate values that are
14027 placed in one of the four DSP accumulators (@code{$ac0},
14028 @code{$ac1}, @code{$ac2} or @code{$ac3}).
14030 Also, some built-in functions prefer or require immediate numbers as
14031 parameters, because the corresponding DSP instructions accept both immediate
14032 numbers and register operands, or accept immediate numbers only. The
14033 immediate parameters are listed as follows.
14041 imm0_255: 0 to 255.
14042 imm_n32_31: -32 to 31.
14043 imm_n512_511: -512 to 511.
14046 The following built-in functions map directly to a particular MIPS DSP
14047 instruction. Please refer to the architecture specification
14048 for details on what each instruction does.
14051 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
14052 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
14053 q31 __builtin_mips_addq_s_w (q31, q31)
14054 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
14055 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
14056 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
14057 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
14058 q31 __builtin_mips_subq_s_w (q31, q31)
14059 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
14060 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
14061 i32 __builtin_mips_addsc (i32, i32)
14062 i32 __builtin_mips_addwc (i32, i32)
14063 i32 __builtin_mips_modsub (i32, i32)
14064 i32 __builtin_mips_raddu_w_qb (v4i8)
14065 v2q15 __builtin_mips_absq_s_ph (v2q15)
14066 q31 __builtin_mips_absq_s_w (q31)
14067 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
14068 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
14069 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
14070 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
14071 q31 __builtin_mips_preceq_w_phl (v2q15)
14072 q31 __builtin_mips_preceq_w_phr (v2q15)
14073 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
14074 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
14075 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
14076 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
14077 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
14078 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
14079 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
14080 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
14081 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
14082 v4i8 __builtin_mips_shll_qb (v4i8, i32)
14083 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
14084 v2q15 __builtin_mips_shll_ph (v2q15, i32)
14085 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
14086 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
14087 q31 __builtin_mips_shll_s_w (q31, imm0_31)
14088 q31 __builtin_mips_shll_s_w (q31, i32)
14089 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
14090 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
14091 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
14092 v2q15 __builtin_mips_shra_ph (v2q15, i32)
14093 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
14094 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
14095 q31 __builtin_mips_shra_r_w (q31, imm0_31)
14096 q31 __builtin_mips_shra_r_w (q31, i32)
14097 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
14098 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
14099 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
14100 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
14101 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
14102 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
14103 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
14104 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
14105 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
14106 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
14107 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
14108 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
14109 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
14110 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
14111 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
14112 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
14113 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
14114 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
14115 i32 __builtin_mips_bitrev (i32)
14116 i32 __builtin_mips_insv (i32, i32)
14117 v4i8 __builtin_mips_repl_qb (imm0_255)
14118 v4i8 __builtin_mips_repl_qb (i32)
14119 v2q15 __builtin_mips_repl_ph (imm_n512_511)
14120 v2q15 __builtin_mips_repl_ph (i32)
14121 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
14122 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
14123 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
14124 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
14125 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
14126 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
14127 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
14128 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
14129 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
14130 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
14131 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
14132 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
14133 i32 __builtin_mips_extr_w (a64, imm0_31)
14134 i32 __builtin_mips_extr_w (a64, i32)
14135 i32 __builtin_mips_extr_r_w (a64, imm0_31)
14136 i32 __builtin_mips_extr_s_h (a64, i32)
14137 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
14138 i32 __builtin_mips_extr_rs_w (a64, i32)
14139 i32 __builtin_mips_extr_s_h (a64, imm0_31)
14140 i32 __builtin_mips_extr_r_w (a64, i32)
14141 i32 __builtin_mips_extp (a64, imm0_31)
14142 i32 __builtin_mips_extp (a64, i32)
14143 i32 __builtin_mips_extpdp (a64, imm0_31)
14144 i32 __builtin_mips_extpdp (a64, i32)
14145 a64 __builtin_mips_shilo (a64, imm_n32_31)
14146 a64 __builtin_mips_shilo (a64, i32)
14147 a64 __builtin_mips_mthlip (a64, i32)
14148 void __builtin_mips_wrdsp (i32, imm0_63)
14149 i32 __builtin_mips_rddsp (imm0_63)
14150 i32 __builtin_mips_lbux (void *, i32)
14151 i32 __builtin_mips_lhx (void *, i32)
14152 i32 __builtin_mips_lwx (void *, i32)
14153 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
14154 i32 __builtin_mips_bposge32 (void)
14155 a64 __builtin_mips_madd (a64, i32, i32);
14156 a64 __builtin_mips_maddu (a64, ui32, ui32);
14157 a64 __builtin_mips_msub (a64, i32, i32);
14158 a64 __builtin_mips_msubu (a64, ui32, ui32);
14159 a64 __builtin_mips_mult (i32, i32);
14160 a64 __builtin_mips_multu (ui32, ui32);
14163 The following built-in functions map directly to a particular MIPS DSP REV 2
14164 instruction. Please refer to the architecture specification
14165 for details on what each instruction does.
14168 v4q7 __builtin_mips_absq_s_qb (v4q7);
14169 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
14170 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
14171 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
14172 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
14173 i32 __builtin_mips_append (i32, i32, imm0_31);
14174 i32 __builtin_mips_balign (i32, i32, imm0_3);
14175 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
14176 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
14177 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
14178 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
14179 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
14180 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
14181 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
14182 q31 __builtin_mips_mulq_rs_w (q31, q31);
14183 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
14184 q31 __builtin_mips_mulq_s_w (q31, q31);
14185 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
14186 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
14187 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
14188 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
14189 i32 __builtin_mips_prepend (i32, i32, imm0_31);
14190 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
14191 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
14192 v4i8 __builtin_mips_shra_qb (v4i8, i32);
14193 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
14194 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
14195 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
14196 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
14197 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
14198 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
14199 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
14200 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
14201 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
14202 q31 __builtin_mips_addqh_w (q31, q31);
14203 q31 __builtin_mips_addqh_r_w (q31, q31);
14204 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
14205 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
14206 q31 __builtin_mips_subqh_w (q31, q31);
14207 q31 __builtin_mips_subqh_r_w (q31, q31);
14208 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
14209 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
14210 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
14211 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
14212 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
14213 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
14217 @node MIPS Paired-Single Support
14218 @subsection MIPS Paired-Single Support
14220 The MIPS64 architecture includes a number of instructions that
14221 operate on pairs of single-precision floating-point values.
14222 Each pair is packed into a 64-bit floating-point register,
14223 with one element being designated the ``upper half'' and
14224 the other being designated the ``lower half''.
14226 GCC supports paired-single operations using both the generic
14227 vector extensions (@pxref{Vector Extensions}) and a collection of
14228 MIPS-specific built-in functions. Both kinds of support are
14229 enabled by the @option{-mpaired-single} command-line option.
14231 The vector type associated with paired-single values is usually
14232 called @code{v2sf}. It can be defined in C as follows:
14235 typedef float v2sf __attribute__ ((vector_size (8)));
14238 @code{v2sf} values are initialized in the same way as aggregates.
14242 v2sf a = @{1.5, 9.1@};
14245 b = (v2sf) @{e, f@};
14248 @emph{Note:} The CPU's endianness determines which value is stored in
14249 the upper half of a register and which value is stored in the lower half.
14250 On little-endian targets, the first value is the lower one and the second
14251 value is the upper one. The opposite order applies to big-endian targets.
14252 For example, the code above sets the lower half of @code{a} to
14253 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
14255 @node MIPS Loongson Built-in Functions
14256 @subsection MIPS Loongson Built-in Functions
14258 GCC provides intrinsics to access the SIMD instructions provided by the
14259 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
14260 available after inclusion of the @code{loongson.h} header file,
14261 operate on the following 64-bit vector types:
14264 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
14265 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
14266 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
14267 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
14268 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
14269 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
14272 The intrinsics provided are listed below; each is named after the
14273 machine instruction to which it corresponds, with suffixes added as
14274 appropriate to distinguish intrinsics that expand to the same machine
14275 instruction yet have different argument types. Refer to the architecture
14276 documentation for a description of the functionality of each
14280 int16x4_t packsswh (int32x2_t s, int32x2_t t);
14281 int8x8_t packsshb (int16x4_t s, int16x4_t t);
14282 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
14283 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
14284 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
14285 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
14286 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
14287 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
14288 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
14289 uint64_t paddd_u (uint64_t s, uint64_t t);
14290 int64_t paddd_s (int64_t s, int64_t t);
14291 int16x4_t paddsh (int16x4_t s, int16x4_t t);
14292 int8x8_t paddsb (int8x8_t s, int8x8_t t);
14293 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
14294 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
14295 uint64_t pandn_ud (uint64_t s, uint64_t t);
14296 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
14297 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
14298 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
14299 int64_t pandn_sd (int64_t s, int64_t t);
14300 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
14301 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
14302 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
14303 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
14304 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
14305 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
14306 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
14307 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
14308 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
14309 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
14310 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
14311 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
14312 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
14313 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
14314 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
14315 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
14316 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
14317 uint16x4_t pextrh_u (uint16x4_t s, int field);
14318 int16x4_t pextrh_s (int16x4_t s, int field);
14319 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
14320 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
14321 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
14322 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
14323 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
14324 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
14325 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
14326 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
14327 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
14328 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
14329 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
14330 int16x4_t pminsh (int16x4_t s, int16x4_t t);
14331 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
14332 uint8x8_t pmovmskb_u (uint8x8_t s);
14333 int8x8_t pmovmskb_s (int8x8_t s);
14334 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
14335 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
14336 int16x4_t pmullh (int16x4_t s, int16x4_t t);
14337 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
14338 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
14339 uint16x4_t biadd (uint8x8_t s);
14340 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
14341 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
14342 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
14343 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
14344 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
14345 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
14346 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
14347 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
14348 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
14349 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
14350 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
14351 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
14352 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
14353 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
14354 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
14355 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
14356 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
14357 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
14358 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
14359 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
14360 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
14361 uint64_t psubd_u (uint64_t s, uint64_t t);
14362 int64_t psubd_s (int64_t s, int64_t t);
14363 int16x4_t psubsh (int16x4_t s, int16x4_t t);
14364 int8x8_t psubsb (int8x8_t s, int8x8_t t);
14365 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
14366 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
14367 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
14368 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
14369 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
14370 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
14371 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
14372 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
14373 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
14374 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
14375 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
14376 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
14377 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
14378 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
14382 * Paired-Single Arithmetic::
14383 * Paired-Single Built-in Functions::
14384 * MIPS-3D Built-in Functions::
14387 @node Paired-Single Arithmetic
14388 @subsubsection Paired-Single Arithmetic
14390 The table below lists the @code{v2sf} operations for which hardware
14391 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
14392 values and @code{x} is an integral value.
14394 @multitable @columnfractions .50 .50
14395 @item C code @tab MIPS instruction
14396 @item @code{a + b} @tab @code{add.ps}
14397 @item @code{a - b} @tab @code{sub.ps}
14398 @item @code{-a} @tab @code{neg.ps}
14399 @item @code{a * b} @tab @code{mul.ps}
14400 @item @code{a * b + c} @tab @code{madd.ps}
14401 @item @code{a * b - c} @tab @code{msub.ps}
14402 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
14403 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
14404 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
14407 Note that the multiply-accumulate instructions can be disabled
14408 using the command-line option @code{-mno-fused-madd}.
14410 @node Paired-Single Built-in Functions
14411 @subsubsection Paired-Single Built-in Functions
14413 The following paired-single functions map directly to a particular
14414 MIPS instruction. Please refer to the architecture specification
14415 for details on what each instruction does.
14418 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
14419 Pair lower lower (@code{pll.ps}).
14421 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
14422 Pair upper lower (@code{pul.ps}).
14424 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
14425 Pair lower upper (@code{plu.ps}).
14427 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
14428 Pair upper upper (@code{puu.ps}).
14430 @item v2sf __builtin_mips_cvt_ps_s (float, float)
14431 Convert pair to paired single (@code{cvt.ps.s}).
14433 @item float __builtin_mips_cvt_s_pl (v2sf)
14434 Convert pair lower to single (@code{cvt.s.pl}).
14436 @item float __builtin_mips_cvt_s_pu (v2sf)
14437 Convert pair upper to single (@code{cvt.s.pu}).
14439 @item v2sf __builtin_mips_abs_ps (v2sf)
14440 Absolute value (@code{abs.ps}).
14442 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
14443 Align variable (@code{alnv.ps}).
14445 @emph{Note:} The value of the third parameter must be 0 or 4
14446 modulo 8, otherwise the result is unpredictable. Please read the
14447 instruction description for details.
14450 The following multi-instruction functions are also available.
14451 In each case, @var{cond} can be any of the 16 floating-point conditions:
14452 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14453 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
14454 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14457 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14458 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14459 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
14460 @code{movt.ps}/@code{movf.ps}).
14462 The @code{movt} functions return the value @var{x} computed by:
14465 c.@var{cond}.ps @var{cc},@var{a},@var{b}
14466 mov.ps @var{x},@var{c}
14467 movt.ps @var{x},@var{d},@var{cc}
14470 The @code{movf} functions are similar but use @code{movf.ps} instead
14473 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14474 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14475 Comparison of two paired-single values (@code{c.@var{cond}.ps},
14476 @code{bc1t}/@code{bc1f}).
14478 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14479 and return either the upper or lower half of the result. For example:
14483 if (__builtin_mips_upper_c_eq_ps (a, b))
14484 upper_halves_are_equal ();
14486 upper_halves_are_unequal ();
14488 if (__builtin_mips_lower_c_eq_ps (a, b))
14489 lower_halves_are_equal ();
14491 lower_halves_are_unequal ();
14495 @node MIPS-3D Built-in Functions
14496 @subsubsection MIPS-3D Built-in Functions
14498 The MIPS-3D Application-Specific Extension (ASE) includes additional
14499 paired-single instructions that are designed to improve the performance
14500 of 3D graphics operations. Support for these instructions is controlled
14501 by the @option{-mips3d} command-line option.
14503 The functions listed below map directly to a particular MIPS-3D
14504 instruction. Please refer to the architecture specification for
14505 more details on what each instruction does.
14508 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
14509 Reduction add (@code{addr.ps}).
14511 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
14512 Reduction multiply (@code{mulr.ps}).
14514 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
14515 Convert paired single to paired word (@code{cvt.pw.ps}).
14517 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
14518 Convert paired word to paired single (@code{cvt.ps.pw}).
14520 @item float __builtin_mips_recip1_s (float)
14521 @itemx double __builtin_mips_recip1_d (double)
14522 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
14523 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
14525 @item float __builtin_mips_recip2_s (float, float)
14526 @itemx double __builtin_mips_recip2_d (double, double)
14527 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
14528 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
14530 @item float __builtin_mips_rsqrt1_s (float)
14531 @itemx double __builtin_mips_rsqrt1_d (double)
14532 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
14533 Reduced-precision reciprocal square root (sequence step 1)
14534 (@code{rsqrt1.@var{fmt}}).
14536 @item float __builtin_mips_rsqrt2_s (float, float)
14537 @itemx double __builtin_mips_rsqrt2_d (double, double)
14538 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
14539 Reduced-precision reciprocal square root (sequence step 2)
14540 (@code{rsqrt2.@var{fmt}}).
14543 The following multi-instruction functions are also available.
14544 In each case, @var{cond} can be any of the 16 floating-point conditions:
14545 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14546 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
14547 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14550 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
14551 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
14552 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
14553 @code{bc1t}/@code{bc1f}).
14555 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
14556 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
14561 if (__builtin_mips_cabs_eq_s (a, b))
14567 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14568 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14569 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
14570 @code{bc1t}/@code{bc1f}).
14572 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
14573 and return either the upper or lower half of the result. For example:
14577 if (__builtin_mips_upper_cabs_eq_ps (a, b))
14578 upper_halves_are_equal ();
14580 upper_halves_are_unequal ();
14582 if (__builtin_mips_lower_cabs_eq_ps (a, b))
14583 lower_halves_are_equal ();
14585 lower_halves_are_unequal ();
14588 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14589 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14590 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
14591 @code{movt.ps}/@code{movf.ps}).
14593 The @code{movt} functions return the value @var{x} computed by:
14596 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
14597 mov.ps @var{x},@var{c}
14598 movt.ps @var{x},@var{d},@var{cc}
14601 The @code{movf} functions are similar but use @code{movf.ps} instead
14604 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14605 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14606 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14607 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14608 Comparison of two paired-single values
14609 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14610 @code{bc1any2t}/@code{bc1any2f}).
14612 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14613 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
14614 result is true and the @code{all} forms return true if both results are true.
14619 if (__builtin_mips_any_c_eq_ps (a, b))
14624 if (__builtin_mips_all_c_eq_ps (a, b))
14630 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14631 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14632 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14633 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14634 Comparison of four paired-single values
14635 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14636 @code{bc1any4t}/@code{bc1any4f}).
14638 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
14639 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
14640 The @code{any} forms return true if any of the four results are true
14641 and the @code{all} forms return true if all four results are true.
14646 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
14651 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
14658 @node MIPS SIMD Architecture (MSA) Support
14659 @subsection MIPS SIMD Architecture (MSA) Support
14662 * MIPS SIMD Architecture Built-in Functions::
14665 GCC provides intrinsics to access the SIMD instructions provided by the
14666 MSA MIPS SIMD Architecture. The interface is made available by including
14667 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
14668 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
14671 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
14672 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
14673 data elements. The following vectors typedefs are included in @code{msa.h}:
14675 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
14676 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
14677 @item @code{v8i16}, a vector of eight signed 16-bit integers;
14678 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
14679 @item @code{v4i32}, a vector of four signed 32-bit integers;
14680 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
14681 @item @code{v2i64}, a vector of two signed 64-bit integers;
14682 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
14683 @item @code{v4f32}, a vector of four 32-bit floats;
14684 @item @code{v2f64}, a vector of two 64-bit doubles.
14687 Instructions and corresponding built-ins may have additional restrictions and/or
14688 input/output values manipulated:
14690 @item @code{imm0_1}, an integer literal in range 0 to 1;
14691 @item @code{imm0_3}, an integer literal in range 0 to 3;
14692 @item @code{imm0_7}, an integer literal in range 0 to 7;
14693 @item @code{imm0_15}, an integer literal in range 0 to 15;
14694 @item @code{imm0_31}, an integer literal in range 0 to 31;
14695 @item @code{imm0_63}, an integer literal in range 0 to 63;
14696 @item @code{imm0_255}, an integer literal in range 0 to 255;
14697 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
14698 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
14699 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
14700 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
14701 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
14702 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
14703 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
14704 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
14705 @item @code{imm1_4}, an integer literal in range 1 to 4;
14706 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
14712 #if __LONG_MAX__ == __LONG_LONG_MAX__
14715 typedef long long i64;
14718 typedef unsigned int u32;
14719 #if __LONG_MAX__ == __LONG_LONG_MAX__
14720 typedef unsigned long u64;
14722 typedef unsigned long long u64;
14725 typedef double f64;
14730 @node MIPS SIMD Architecture Built-in Functions
14731 @subsubsection MIPS SIMD Architecture Built-in Functions
14733 The intrinsics provided are listed below; each is named after the
14734 machine instruction.
14737 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
14738 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
14739 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
14740 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
14742 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
14743 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
14744 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
14745 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
14747 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
14748 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
14749 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
14750 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
14752 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
14753 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
14754 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
14755 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
14757 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
14758 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
14759 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
14760 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
14762 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
14763 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
14764 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
14765 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
14767 v16u8 __builtin_msa_and_v (v16u8, v16u8);
14769 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
14771 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
14772 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
14773 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
14774 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
14776 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
14777 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
14778 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
14779 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
14781 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
14782 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
14783 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
14784 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
14786 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
14787 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
14788 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
14789 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
14791 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
14792 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
14793 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
14794 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
14796 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
14797 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
14798 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
14799 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
14801 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
14802 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
14803 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
14804 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
14806 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
14807 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
14808 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
14809 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
14811 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
14812 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
14813 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
14814 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
14816 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
14817 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
14818 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
14819 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
14821 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
14822 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
14823 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
14824 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
14826 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
14827 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
14828 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
14829 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
14831 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
14833 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
14835 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
14837 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
14839 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
14840 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
14841 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
14842 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
14844 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
14845 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
14846 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
14847 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
14849 i32 __builtin_msa_bnz_b (v16u8);
14850 i32 __builtin_msa_bnz_h (v8u16);
14851 i32 __builtin_msa_bnz_w (v4u32);
14852 i32 __builtin_msa_bnz_d (v2u64);
14854 i32 __builtin_msa_bnz_v (v16u8);
14856 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
14858 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
14860 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
14861 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
14862 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
14863 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
14865 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
14866 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
14867 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
14868 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
14870 i32 __builtin_msa_bz_b (v16u8);
14871 i32 __builtin_msa_bz_h (v8u16);
14872 i32 __builtin_msa_bz_w (v4u32);
14873 i32 __builtin_msa_bz_d (v2u64);
14875 i32 __builtin_msa_bz_v (v16u8);
14877 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
14878 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
14879 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
14880 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
14882 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
14883 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
14884 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
14885 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
14887 i32 __builtin_msa_cfcmsa (imm0_31);
14889 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
14890 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
14891 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
14892 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
14894 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
14895 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
14896 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
14897 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
14899 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
14900 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
14901 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
14902 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
14904 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
14905 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
14906 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
14907 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
14909 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
14910 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
14911 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
14912 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
14914 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
14915 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
14916 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
14917 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
14919 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
14920 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
14921 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14922 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14924 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14925 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14926 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14927 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14929 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14930 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14931 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14932 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14934 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14935 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14936 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14937 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14939 void __builtin_msa_ctcmsa (imm0_31, i32);
14941 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14942 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14943 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14944 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14946 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14947 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14948 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14949 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14951 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14952 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14953 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14955 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14956 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14957 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14959 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14960 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14961 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14963 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14964 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14965 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14967 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14968 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14969 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14971 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14972 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14973 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14975 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
14976 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
14978 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
14979 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
14981 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
14982 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
14984 v4i32 __builtin_msa_fclass_w (v4f32);
14985 v2i64 __builtin_msa_fclass_d (v2f64);
14987 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
14988 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
14990 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
14991 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
14993 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
14994 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
14996 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
14997 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
14999 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
15000 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
15002 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
15003 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
15005 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
15006 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
15008 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
15009 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
15011 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
15012 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
15014 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
15015 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
15017 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
15018 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
15020 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
15021 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
15023 v4f32 __builtin_msa_fexupl_w (v8i16);
15024 v2f64 __builtin_msa_fexupl_d (v4f32);
15026 v4f32 __builtin_msa_fexupr_w (v8i16);
15027 v2f64 __builtin_msa_fexupr_d (v4f32);
15029 v4f32 __builtin_msa_ffint_s_w (v4i32);
15030 v2f64 __builtin_msa_ffint_s_d (v2i64);
15032 v4f32 __builtin_msa_ffint_u_w (v4u32);
15033 v2f64 __builtin_msa_ffint_u_d (v2u64);
15035 v4f32 __builtin_msa_ffql_w (v8i16);
15036 v2f64 __builtin_msa_ffql_d (v4i32);
15038 v4f32 __builtin_msa_ffqr_w (v8i16);
15039 v2f64 __builtin_msa_ffqr_d (v4i32);
15041 v16i8 __builtin_msa_fill_b (i32);
15042 v8i16 __builtin_msa_fill_h (i32);
15043 v4i32 __builtin_msa_fill_w (i32);
15044 v2i64 __builtin_msa_fill_d (i64);
15046 v4f32 __builtin_msa_flog2_w (v4f32);
15047 v2f64 __builtin_msa_flog2_d (v2f64);
15049 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
15050 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
15052 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
15053 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
15055 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
15056 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
15058 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
15059 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
15061 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
15062 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
15064 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
15065 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
15067 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
15068 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
15070 v4f32 __builtin_msa_frint_w (v4f32);
15071 v2f64 __builtin_msa_frint_d (v2f64);
15073 v4f32 __builtin_msa_frcp_w (v4f32);
15074 v2f64 __builtin_msa_frcp_d (v2f64);
15076 v4f32 __builtin_msa_frsqrt_w (v4f32);
15077 v2f64 __builtin_msa_frsqrt_d (v2f64);
15079 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
15080 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
15082 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
15083 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
15085 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
15086 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
15088 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
15089 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
15091 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
15092 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
15094 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
15095 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
15097 v4f32 __builtin_msa_fsqrt_w (v4f32);
15098 v2f64 __builtin_msa_fsqrt_d (v2f64);
15100 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
15101 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
15103 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
15104 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
15106 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
15107 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
15109 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
15110 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
15112 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
15113 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
15115 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
15116 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
15118 v4i32 __builtin_msa_ftint_s_w (v4f32);
15119 v2i64 __builtin_msa_ftint_s_d (v2f64);
15121 v4u32 __builtin_msa_ftint_u_w (v4f32);
15122 v2u64 __builtin_msa_ftint_u_d (v2f64);
15124 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
15125 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
15127 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
15128 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
15130 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
15131 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
15133 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
15134 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
15135 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
15137 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
15138 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
15139 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
15141 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
15142 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
15143 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
15145 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
15146 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
15147 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
15149 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
15150 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
15151 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
15152 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
15154 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
15155 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
15156 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
15157 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
15159 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
15160 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
15161 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
15162 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
15164 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
15165 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
15166 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
15167 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
15169 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
15170 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
15171 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
15172 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
15174 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
15175 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
15176 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
15177 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
15179 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
15180 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
15181 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
15182 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
15184 v16i8 __builtin_msa_ldi_b (imm_n512_511);
15185 v8i16 __builtin_msa_ldi_h (imm_n512_511);
15186 v4i32 __builtin_msa_ldi_w (imm_n512_511);
15187 v2i64 __builtin_msa_ldi_d (imm_n512_511);
15189 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
15190 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
15192 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
15193 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
15195 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
15196 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
15197 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
15198 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
15200 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
15201 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
15202 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
15203 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
15205 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
15206 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
15207 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
15208 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
15210 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
15211 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
15212 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
15213 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
15215 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
15216 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
15217 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
15218 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
15220 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
15221 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
15222 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
15223 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
15225 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
15226 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
15227 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
15228 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
15230 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
15231 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
15232 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
15233 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
15235 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
15236 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
15237 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
15238 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
15240 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
15241 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
15242 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
15243 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
15245 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
15246 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
15247 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
15248 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
15250 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
15251 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
15252 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
15253 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
15255 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
15256 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
15257 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
15258 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
15260 v16i8 __builtin_msa_move_v (v16i8);
15262 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
15263 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
15265 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
15266 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
15268 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
15269 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
15270 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
15271 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
15273 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
15274 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
15276 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
15277 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
15279 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
15280 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
15281 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
15282 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
15284 v16i8 __builtin_msa_nloc_b (v16i8);
15285 v8i16 __builtin_msa_nloc_h (v8i16);
15286 v4i32 __builtin_msa_nloc_w (v4i32);
15287 v2i64 __builtin_msa_nloc_d (v2i64);
15289 v16i8 __builtin_msa_nlzc_b (v16i8);
15290 v8i16 __builtin_msa_nlzc_h (v8i16);
15291 v4i32 __builtin_msa_nlzc_w (v4i32);
15292 v2i64 __builtin_msa_nlzc_d (v2i64);
15294 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
15296 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
15298 v16u8 __builtin_msa_or_v (v16u8, v16u8);
15300 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
15302 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
15303 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
15304 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
15305 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
15307 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
15308 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
15309 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
15310 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
15312 v16i8 __builtin_msa_pcnt_b (v16i8);
15313 v8i16 __builtin_msa_pcnt_h (v8i16);
15314 v4i32 __builtin_msa_pcnt_w (v4i32);
15315 v2i64 __builtin_msa_pcnt_d (v2i64);
15317 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
15318 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
15319 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
15320 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
15322 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
15323 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
15324 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
15325 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
15327 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
15328 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
15329 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
15331 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
15332 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
15333 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
15334 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
15336 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
15337 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
15338 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
15339 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
15341 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
15342 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
15343 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
15344 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
15346 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
15347 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
15348 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
15349 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
15351 v16i8 __builtin_msa_splat_b (v16i8, i32);
15352 v8i16 __builtin_msa_splat_h (v8i16, i32);
15353 v4i32 __builtin_msa_splat_w (v4i32, i32);
15354 v2i64 __builtin_msa_splat_d (v2i64, i32);
15356 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
15357 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
15358 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
15359 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
15361 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
15362 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
15363 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
15364 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
15366 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
15367 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
15368 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
15369 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
15371 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
15372 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
15373 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
15374 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
15376 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
15377 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
15378 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
15379 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
15381 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
15382 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
15383 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
15384 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
15386 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
15387 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
15388 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
15389 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
15391 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
15392 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
15393 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
15394 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
15396 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
15397 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
15398 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
15399 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
15401 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
15402 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
15403 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
15404 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
15406 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
15407 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
15408 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
15409 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
15411 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
15412 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
15413 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
15414 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
15416 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
15417 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
15418 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
15419 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
15421 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
15422 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
15423 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
15424 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
15426 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
15427 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
15428 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
15429 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
15431 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
15432 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
15433 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
15434 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
15436 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
15437 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
15438 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
15439 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
15441 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
15443 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
15446 @node Other MIPS Built-in Functions
15447 @subsection Other MIPS Built-in Functions
15449 GCC provides other MIPS-specific built-in functions:
15452 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
15453 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
15454 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
15455 when this function is available.
15457 @item unsigned int __builtin_mips_get_fcsr (void)
15458 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
15459 Get and set the contents of the floating-point control and status register
15460 (FPU control register 31). These functions are only available in hard-float
15461 code but can be called in both MIPS16 and non-MIPS16 contexts.
15463 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
15464 register except the condition codes, which GCC assumes are preserved.
15467 @node MSP430 Built-in Functions
15468 @subsection MSP430 Built-in Functions
15470 GCC provides a couple of special builtin functions to aid in the
15471 writing of interrupt handlers in C.
15474 @item __bic_SR_register_on_exit (int @var{mask})
15475 This clears the indicated bits in the saved copy of the status register
15476 currently residing on the stack. This only works inside interrupt
15477 handlers and the changes to the status register will only take affect
15478 once the handler returns.
15480 @item __bis_SR_register_on_exit (int @var{mask})
15481 This sets the indicated bits in the saved copy of the status register
15482 currently residing on the stack. This only works inside interrupt
15483 handlers and the changes to the status register will only take affect
15484 once the handler returns.
15486 @item __delay_cycles (long long @var{cycles})
15487 This inserts an instruction sequence that takes exactly @var{cycles}
15488 cycles (between 0 and about 17E9) to complete. The inserted sequence
15489 may use jumps, loops, or no-ops, and does not interfere with any other
15490 instructions. Note that @var{cycles} must be a compile-time constant
15491 integer - that is, you must pass a number, not a variable that may be
15492 optimized to a constant later. The number of cycles delayed by this
15496 @node NDS32 Built-in Functions
15497 @subsection NDS32 Built-in Functions
15499 These built-in functions are available for the NDS32 target:
15501 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
15502 Insert an ISYNC instruction into the instruction stream where
15503 @var{addr} is an instruction address for serialization.
15506 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
15507 Insert an ISB instruction into the instruction stream.
15510 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
15511 Return the content of a system register which is mapped by @var{sr}.
15514 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
15515 Return the content of a user space register which is mapped by @var{usr}.
15518 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
15519 Move the @var{value} to a system register which is mapped by @var{sr}.
15522 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
15523 Move the @var{value} to a user space register which is mapped by @var{usr}.
15526 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
15527 Enable global interrupt.
15530 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
15531 Disable global interrupt.
15534 @node picoChip Built-in Functions
15535 @subsection picoChip Built-in Functions
15537 GCC provides an interface to selected machine instructions from the
15538 picoChip instruction set.
15541 @item int __builtin_sbc (int @var{value})
15542 Sign bit count. Return the number of consecutive bits in @var{value}
15543 that have the same value as the sign bit. The result is the number of
15544 leading sign bits minus one, giving the number of redundant sign bits in
15547 @item int __builtin_byteswap (int @var{value})
15548 Byte swap. Return the result of swapping the upper and lower bytes of
15551 @item int __builtin_brev (int @var{value})
15552 Bit reversal. Return the result of reversing the bits in
15553 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
15556 @item int __builtin_adds (int @var{x}, int @var{y})
15557 Saturating addition. Return the result of adding @var{x} and @var{y},
15558 storing the value 32767 if the result overflows.
15560 @item int __builtin_subs (int @var{x}, int @var{y})
15561 Saturating subtraction. Return the result of subtracting @var{y} from
15562 @var{x}, storing the value @minus{}32768 if the result overflows.
15564 @item void __builtin_halt (void)
15565 Halt. The processor stops execution. This built-in is useful for
15566 implementing assertions.
15570 @node Basic PowerPC Built-in Functions
15571 @subsection Basic PowerPC Built-in Functions
15574 * Basic PowerPC Built-in Functions Available on all Configurations::
15575 * Basic PowerPC Built-in Functions Available on ISA 2.05::
15576 * Basic PowerPC Built-in Functions Available on ISA 2.06::
15577 * Basic PowerPC Built-in Functions Available on ISA 2.07::
15578 * Basic PowerPC Built-in Functions Available on ISA 3.0::
15581 This section describes PowerPC built-in functions that do not require
15582 the inclusion of any special header files to declare prototypes or
15583 provide macro definitions. The sections that follow describe
15584 additional PowerPC built-in functions.
15586 @node Basic PowerPC Built-in Functions Available on all Configurations
15587 @subsubsection Basic PowerPC Built-in Functions Available on all Configurations
15589 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
15590 This function is a @code{nop} on the PowerPC platform and is included solely
15591 to maintain API compatibility with the x86 builtins.
15594 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
15595 This function returns a value of @code{1} if the run-time CPU is of type
15596 @var{cpuname} and returns @code{0} otherwise
15598 The @code{__builtin_cpu_is} function requires GLIBC 2.23 or newer
15599 which exports the hardware capability bits. GCC defines the macro
15600 @code{__BUILTIN_CPU_SUPPORTS__} if the @code{__builtin_cpu_supports}
15601 built-in function is fully supported.
15603 If GCC was configured to use a GLIBC before 2.23, the built-in
15604 function @code{__builtin_cpu_is} always returns a 0 and the compiler
15607 The following CPU names can be detected:
15611 IBM POWER9 Server CPU.
15613 IBM POWER8 Server CPU.
15615 IBM POWER7 Server CPU.
15617 IBM POWER6 Server CPU (RAW mode).
15619 IBM POWER6 Server CPU (Architected mode).
15621 IBM POWER5+ Server CPU.
15623 IBM POWER5 Server CPU.
15625 IBM 970 Server CPU (ie, Apple G5).
15627 IBM POWER4 Server CPU.
15629 IBM A2 64-bit Embedded CPU
15631 IBM PowerPC 476FP 32-bit Embedded CPU.
15633 IBM PowerPC 464 32-bit Embedded CPU.
15635 PowerPC 440 32-bit Embedded CPU.
15637 PowerPC 405 32-bit Embedded CPU.
15639 IBM PowerPC Cell Broadband Engine Architecture CPU.
15642 Here is an example:
15644 #ifdef __BUILTIN_CPU_SUPPORTS__
15645 if (__builtin_cpu_is ("power8"))
15647 do_power8 (); // POWER8 specific implementation.
15652 do_generic (); // Generic implementation.
15657 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
15658 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
15659 feature @var{feature} and returns @code{0} otherwise.
15661 The @code{__builtin_cpu_supports} function requires GLIBC 2.23 or
15662 newer which exports the hardware capability bits. GCC defines the
15663 macro @code{__BUILTIN_CPU_SUPPORTS__} if the
15664 @code{__builtin_cpu_supports} built-in function is fully supported.
15666 If GCC was configured to use a GLIBC before 2.23, the built-in
15667 function @code{__builtin_cpu_suports} always returns a 0 and the
15668 compiler issues a warning.
15670 The following features can be
15675 4xx CPU has a Multiply Accumulator.
15677 CPU has a SIMD/Vector Unit.
15679 CPU supports ISA 2.05 (eg, POWER6)
15681 CPU supports ISA 2.06 (eg, POWER7)
15683 CPU supports ISA 2.07 (eg, POWER8)
15685 CPU supports ISA 3.0 (eg, POWER9)
15687 CPU supports the set of compatible performance monitoring events.
15689 CPU supports the Embedded ISA category.
15691 CPU has a CELL broadband engine.
15693 CPU supports the @code{darn} (deliver a random number) instruction.
15695 CPU has a decimal floating point unit.
15697 CPU supports the data stream control register.
15699 CPU supports event base branching.
15701 CPU has a SPE double precision floating point unit.
15703 CPU has a SPE single precision floating point unit.
15705 CPU has a floating point unit.
15707 CPU has hardware transaction memory instructions.
15709 Kernel aborts hardware transactions when a syscall is made.
15710 @item htm-no-suspend
15711 CPU supports hardware transaction memory but does not support the
15712 @code{tsuspend.} instruction.
15714 CPU supports icache snooping capabilities.
15716 CPU supports 128-bit IEEE binary floating point instructions.
15718 CPU supports the integer select instruction.
15720 CPU has a memory management unit.
15722 CPU does not have a timebase (eg, 601 and 403gx).
15724 CPU supports the PA Semi 6T CORE ISA.
15726 CPU supports ISA 2.00 (eg, POWER4)
15728 CPU supports ISA 2.02 (eg, POWER5)
15730 CPU supports ISA 2.03 (eg, POWER5+)
15732 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
15734 CPU supports 32-bit mode execution.
15736 CPU supports the old POWER ISA (eg, 601)
15738 CPU supports 64-bit mode execution.
15740 CPU supports a little-endian mode that uses address swizzling.
15742 Kernel supports system call vectored.
15744 CPU support simultaneous multi-threading.
15746 CPU has a signal processing extension unit.
15748 CPU supports the target address register.
15750 CPU supports true little-endian mode.
15752 CPU has unified I/D cache.
15754 CPU supports the vector cryptography instructions.
15756 CPU supports the vector-scalar extension.
15759 Here is an example:
15761 #ifdef __BUILTIN_CPU_SUPPORTS__
15762 if (__builtin_cpu_supports ("fpu"))
15764 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
15769 dst = __fadd (src1, src2); // Software FP addition function.
15774 The following built-in functions are also available on all PowerPC
15777 uint64_t __builtin_ppc_get_timebase ();
15778 unsigned long __builtin_ppc_mftb ();
15779 __ibm128 __builtin_unpack_ibm128 (__ibm128, int);
15780 __ibm128 __builtin_pack_ibm128 (double, double);
15783 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
15784 functions generate instructions to read the Time Base Register. The
15785 @code{__builtin_ppc_get_timebase} function may generate multiple
15786 instructions and always returns the 64 bits of the Time Base Register.
15787 The @code{__builtin_ppc_mftb} function always generates one instruction and
15788 returns the Time Base Register value as an unsigned long, throwing away
15789 the most significant word on 32-bit environments.
15791 @node Basic PowerPC Built-in Functions Available on ISA 2.05
15792 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.05
15794 The basic built-in functions described in this section are
15795 available on the PowerPC family of processors starting with ISA 2.05
15796 or later. Unless specific options are explicitly disabled on the
15797 command line, specifying option @option{-mcpu=power6} has the effect of
15798 enabling the @option{-mpowerpc64}, @option{-mpowerpc-gpopt},
15799 @option{-mpowerpc-gfxopt}, @option{-mmfcrf}, @option{-mpopcntb},
15800 @option{-mfprnd}, @option{-mcmpb}, @option{-mhard-dfp}, and
15801 @option{-mrecip-precision} options. Specify the
15802 @option{-maltivec} and @option{-mfpgpr} options explicitly in
15803 combination with the above options if they are desired.
15805 The following functions require option @option{-mcmpb}.
15807 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
15808 unsigned int __builtin_cmpb (unsigned int, unsigned int);
15811 The @code{__builtin_cmpb} function
15812 performs a byte-wise compare on the contents of its two arguments,
15813 returning the result of the byte-wise comparison as the returned
15814 value. For each byte comparison, the corresponding byte of the return
15815 value holds 0xff if the input bytes are equal and 0 if the input bytes
15816 are not equal. If either of the arguments to this built-in function
15817 is wider than 32 bits, the function call expands into the form that
15818 expects @code{unsigned long long int} arguments
15819 which is only available on 64-bit targets.
15821 The following built-in functions are available
15822 when hardware decimal floating point
15823 (@option{-mhard-dfp}) is available:
15825 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15826 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15827 _Decimal64 __builtin_denbcd (int, _Decimal64);
15828 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15829 _Decimal64 __builtin_diex (long long, _Decimal64);
15830 _Decimal128 _builtin_diexq (long long, _Decimal128);
15831 _Decimal64 __builtin_dscli (_Decimal64, int);
15832 _Decimal128 __builtin_dscliq (_Decimal128, int);
15833 _Decimal64 __builtin_dscri (_Decimal64, int);
15834 _Decimal128 __builtin_dscriq (_Decimal128, int);
15835 long long __builtin_dxex (_Decimal64);
15836 long long __builtin_dxexq (_Decimal128);
15837 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
15838 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
15841 The following functions require @option{-mhard-float},
15842 @option{-mpowerpc-gfxopt}, and @option{-mpopcntb} options.
15845 double __builtin_recipdiv (double, double);
15846 float __builtin_recipdivf (float, float);
15847 double __builtin_rsqrt (double);
15848 float __builtin_rsqrtf (float);
15851 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
15852 @code{__builtin_rsqrtf} functions generate multiple instructions to
15853 implement the reciprocal sqrt functionality using reciprocal sqrt
15854 estimate instructions.
15856 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
15857 functions generate multiple instructions to implement division using
15858 the reciprocal estimate instructions.
15860 The following functions require @option{-mhard-float} and
15861 @option{-mmultiple} options.
15863 The @code{__builtin_unpack_longdouble} function takes a
15864 @code{long double} argument and a compile time constant of 0 or 1. If
15865 the constant is 0, the first @code{double} within the
15866 @code{long double} is returned, otherwise the second @code{double}
15867 is returned. The @code{__builtin_unpack_longdouble} function is only
15868 availble if @code{long double} uses the IBM extended double
15871 The @code{__builtin_pack_longdouble} function takes two @code{double}
15872 arguments and returns a @code{long double} value that combines the two
15873 arguments. The @code{__builtin_pack_longdouble} function is only
15874 availble if @code{long double} uses the IBM extended double
15877 The @code{__builtin_unpack_ibm128} function takes a @code{__ibm128}
15878 argument and a compile time constant of 0 or 1. If the constant is 0,
15879 the first @code{double} within the @code{__ibm128} is returned,
15880 otherwise the second @code{double} is returned.
15882 The @code{__builtin_pack_ibm128} function takes two @code{double}
15883 arguments and returns a @code{__ibm128} value that combines the two
15886 Additional built-in functions are available for the 64-bit PowerPC
15887 family of processors, for efficient use of 128-bit floating point
15888 (@code{__float128}) values.
15890 @node Basic PowerPC Built-in Functions Available on ISA 2.06
15891 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.06
15893 The basic built-in functions described in this section are
15894 available on the PowerPC family of processors starting with ISA 2.05
15895 or later. Unless specific options are explicitly disabled on the
15896 command line, specifying option @option{-mcpu=power7} has the effect of
15897 enabling all the same options as for @option{-mcpu=power6} in
15898 addition to the @option{-maltivec}, @option{-mpopcntd}, and
15899 @option{-mvsx} options.
15901 The following basic built-in functions require @option{-mpopcntd}:
15903 unsigned int __builtin_addg6s (unsigned int, unsigned int);
15904 long long __builtin_bpermd (long long, long long);
15905 unsigned int __builtin_cbcdtd (unsigned int);
15906 unsigned int __builtin_cdtbcd (unsigned int);
15907 long long __builtin_divde (long long, long long);
15908 unsigned long long __builtin_divdeu (unsigned long long, unsigned long long);
15909 int __builtin_divwe (int, int);
15910 unsigned int __builtin_divweu (unsigned int, unsigned int);
15911 vector __int128 __builtin_pack_vector_int128 (long long, long long);
15912 void __builtin_rs6000_speculation_barrier (void);
15913 long long __builtin_unpack_vector_int128 (vector __int128, signed char);
15916 Of these, the @code{__builtin_divde} and @code{__builtin_divdeu} functions
15917 require a 64-bit environment.
15919 The following basic built-in functions, which are also supported on
15920 x86 targets, require @option{-mfloat128}.
15922 __float128 __builtin_fabsq (__float128);
15923 __float128 __builtin_copysignq (__float128, __float128);
15924 __float128 __builtin_infq (void);
15925 __float128 __builtin_huge_valq (void);
15926 __float128 __builtin_nanq (void);
15927 __float128 __builtin_nansq (void);
15929 __float128 __builtin_sqrtf128 (__float128);
15930 __float128 __builtin_fmaf128 (__float128, __float128, __float128);
15933 @node Basic PowerPC Built-in Functions Available on ISA 2.07
15934 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.07
15936 The basic built-in functions described in this section are
15937 available on the PowerPC family of processors starting with ISA 2.07
15938 or later. Unless specific options are explicitly disabled on the
15939 command line, specifying option @option{-mcpu=power8} has the effect of
15940 enabling all the same options as for @option{-mcpu=power7} in
15941 addition to the @option{-mpower8-fusion}, @option{-mpower8-vector},
15942 @option{-mcrypto}, @option{-mhtm}, @option{-mquad-memory}, and
15943 @option{-mquad-memory-atomic} options.
15945 This section intentionally empty.
15947 @node Basic PowerPC Built-in Functions Available on ISA 3.0
15948 @subsubsection Basic PowerPC Built-in Functions Available on ISA 3.0
15950 The basic built-in functions described in this section are
15951 available on the PowerPC family of processors starting with ISA 3.0
15952 or later. Unless specific options are explicitly disabled on the
15953 command line, specifying option @option{-mcpu=power9} has the effect of
15954 enabling all the same options as for @option{-mcpu=power8} in
15955 addition to the @option{-misel} option.
15957 The following built-in functions are available on Linux 64-bit systems
15958 that use the ISA 3.0 instruction set (@option{-mcpu=power9}):
15961 @item __float128 __builtin_addf128_round_to_odd (__float128, __float128)
15962 Perform a 128-bit IEEE floating point add using round to odd as the
15964 @findex __builtin_addf128_round_to_odd
15966 @item __float128 __builtin_subf128_round_to_odd (__float128, __float128)
15967 Perform a 128-bit IEEE floating point subtract using round to odd as
15969 @findex __builtin_subf128_round_to_odd
15971 @item __float128 __builtin_mulf128_round_to_odd (__float128, __float128)
15972 Perform a 128-bit IEEE floating point multiply using round to odd as
15974 @findex __builtin_mulf128_round_to_odd
15976 @item __float128 __builtin_divf128_round_to_odd (__float128, __float128)
15977 Perform a 128-bit IEEE floating point divide using round to odd as
15979 @findex __builtin_divf128_round_to_odd
15981 @item __float128 __builtin_sqrtf128_round_to_odd (__float128)
15982 Perform a 128-bit IEEE floating point square root using round to odd
15983 as the rounding mode.
15984 @findex __builtin_sqrtf128_round_to_odd
15986 @item __float128 __builtin_fmaf128_round_to_odd (__float128, __float128, __float128)
15987 Perform a 128-bit IEEE floating point fused multiply and add operation
15988 using round to odd as the rounding mode.
15989 @findex __builtin_fmaf128_round_to_odd
15991 @item double __builtin_truncf128_round_to_odd (__float128)
15992 Convert a 128-bit IEEE floating point value to @code{double} using
15993 round to odd as the rounding mode.
15994 @findex __builtin_truncf128_round_to_odd
15997 The following additional built-in functions are also available for the
15998 PowerPC family of processors, starting with ISA 3.0 or later:
16000 long long __builtin_darn (void);
16001 long long __builtin_darn_raw (void);
16002 int __builtin_darn_32 (void);
16005 The @code{__builtin_darn} and @code{__builtin_darn_raw}
16006 functions require a
16007 64-bit environment supporting ISA 3.0 or later.
16008 The @code{__builtin_darn} function provides a 64-bit conditioned
16009 random number. The @code{__builtin_darn_raw} function provides a
16010 64-bit raw random number. The @code{__builtin_darn_32} function
16011 provides a 32-bit conditioned random number.
16013 The following additional built-in functions are also available for the
16014 PowerPC family of processors, starting with ISA 3.0 or later:
16017 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
16018 int __builtin_byte_in_range (unsigned char u, unsigned int range);
16019 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
16021 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
16022 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
16023 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
16024 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
16026 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
16027 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
16028 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
16029 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
16031 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
16032 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
16033 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
16034 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
16036 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
16037 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
16038 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
16039 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
16041 The @code{__builtin_byte_in_set} function requires a
16042 64-bit environment supporting ISA 3.0 or later. This function returns
16043 a non-zero value if and only if its @code{u} argument exactly equals one of
16044 the eight bytes contained within its 64-bit @code{set} argument.
16046 The @code{__builtin_byte_in_range} and
16047 @code{__builtin_byte_in_either_range} require an environment
16048 supporting ISA 3.0 or later. For these two functions, the
16049 @code{range} argument is encoded as 4 bytes, organized as
16050 @code{hi_1:lo_1:hi_2:lo_2}.
16051 The @code{__builtin_byte_in_range} function returns a
16052 non-zero value if and only if its @code{u} argument is within the
16053 range bounded between @code{lo_2} and @code{hi_2} inclusive.
16054 The @code{__builtin_byte_in_either_range} function returns non-zero if
16055 and only if its @code{u} argument is within either the range bounded
16056 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
16057 between @code{lo_2} and @code{hi_2} inclusive.
16059 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
16060 if and only if the number of signficant digits of its @code{value} argument
16061 is less than its @code{comparison} argument. The
16062 @code{__builtin_dfp_dtstsfi_lt_dd} and
16063 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
16064 require that the type of the @code{value} argument be
16065 @code{__Decimal64} and @code{__Decimal128} respectively.
16067 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
16068 if and only if the number of signficant digits of its @code{value} argument
16069 is greater than its @code{comparison} argument. The
16070 @code{__builtin_dfp_dtstsfi_gt_dd} and
16071 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
16072 require that the type of the @code{value} argument be
16073 @code{__Decimal64} and @code{__Decimal128} respectively.
16075 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
16076 if and only if the number of signficant digits of its @code{value} argument
16077 equals its @code{comparison} argument. The
16078 @code{__builtin_dfp_dtstsfi_eq_dd} and
16079 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
16080 require that the type of the @code{value} argument be
16081 @code{__Decimal64} and @code{__Decimal128} respectively.
16083 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
16084 if and only if its @code{value} argument has an undefined number of
16085 significant digits, such as when @code{value} is an encoding of @code{NaN}.
16086 The @code{__builtin_dfp_dtstsfi_ov_dd} and
16087 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
16088 require that the type of the @code{value} argument be
16089 @code{__Decimal64} and @code{__Decimal128} respectively.
16091 @node PowerPC AltiVec/VSX Built-in Functions
16092 @subsection PowerPC AltiVec/VSX Built-in Functions
16094 GCC provides an interface for the PowerPC family of processors to access
16095 the AltiVec operations described in Motorola's AltiVec Programming
16096 Interface Manual. The interface is made available by including
16097 @code{<altivec.h>} and using @option{-maltivec} and
16098 @option{-mabi=altivec}. The interface supports the following vector
16102 vector unsigned char
16106 vector unsigned short
16107 vector signed short
16111 vector unsigned int
16117 GCC's implementation of the high-level language interface available from
16118 C and C++ code differs from Motorola's documentation in several ways.
16123 A vector constant is a list of constant expressions within curly braces.
16126 A vector initializer requires no cast if the vector constant is of the
16127 same type as the variable it is initializing.
16130 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16131 vector type is the default signedness of the base type. The default
16132 varies depending on the operating system, so a portable program should
16133 always specify the signedness.
16136 Compiling with @option{-maltivec} adds keywords @code{__vector},
16137 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
16138 @code{bool}. When compiling ISO C, the context-sensitive substitution
16139 of the keywords @code{vector}, @code{pixel} and @code{bool} is
16140 disabled. To use them, you must include @code{<altivec.h>} instead.
16143 GCC allows using a @code{typedef} name as the type specifier for a
16147 For C, overloaded functions are implemented with macros so the following
16151 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16155 Since @code{vec_add} is a macro, the vector constant in the example
16156 is treated as four separate arguments. Wrap the entire argument in
16157 parentheses for this to work.
16160 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
16161 Internally, GCC uses built-in functions to achieve the functionality in
16162 the aforementioned header file, but they are not supported and are
16163 subject to change without notice.
16165 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
16166 which may be found at
16167 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
16168 Appendix A of this document lists the vector API interfaces that must be
16169 provided by compliant compilers. Programmers should preferentially use
16170 the interfaces described therein. However, historically GCC has provided
16171 additional interfaces for access to vector instructions. These are
16172 briefly described below.
16175 * PowerPC AltiVec Built-in Functions on ISA 2.05::
16176 * PowerPC AltiVec Built-in Functions Available on ISA 2.06::
16177 * PowerPC AltiVec Built-in Functions Available on ISA 2.07::
16178 * PowerPC AltiVec Built-in Functions Available on ISA 3.0::
16181 @node PowerPC AltiVec Built-in Functions on ISA 2.05
16182 @subsubsection PowerPC AltiVec Built-in Functions on ISA 2.05
16184 The following interfaces are supported for the generic and specific
16185 AltiVec operations and the AltiVec predicates. In cases where there
16186 is a direct mapping between generic and specific operations, only the
16187 generic names are shown here, although the specific operations can also
16190 Arguments that are documented as @code{const int} require literal
16191 integral values within the range required for that operation.
16194 vector signed char vec_abs (vector signed char);
16195 vector signed short vec_abs (vector signed short);
16196 vector signed int vec_abs (vector signed int);
16197 vector float vec_abs (vector float);
16199 vector signed char vec_abss (vector signed char);
16200 vector signed short vec_abss (vector signed short);
16201 vector signed int vec_abss (vector signed int);
16203 vector signed char vec_add (vector bool char, vector signed char);
16204 vector signed char vec_add (vector signed char, vector bool char);
16205 vector signed char vec_add (vector signed char, vector signed char);
16206 vector unsigned char vec_add (vector bool char, vector unsigned char);
16207 vector unsigned char vec_add (vector unsigned char, vector bool char);
16208 vector unsigned char vec_add (vector unsigned char, vector unsigned char);
16209 vector signed short vec_add (vector bool short, vector signed short);
16210 vector signed short vec_add (vector signed short, vector bool short);
16211 vector signed short vec_add (vector signed short, vector signed short);
16212 vector unsigned short vec_add (vector bool short, vector unsigned short);
16213 vector unsigned short vec_add (vector unsigned short, vector bool short);
16214 vector unsigned short vec_add (vector unsigned short, vector unsigned short);
16215 vector signed int vec_add (vector bool int, vector signed int);
16216 vector signed int vec_add (vector signed int, vector bool int);
16217 vector signed int vec_add (vector signed int, vector signed int);
16218 vector unsigned int vec_add (vector bool int, vector unsigned int);
16219 vector unsigned int vec_add (vector unsigned int, vector bool int);
16220 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
16221 vector float vec_add (vector float, vector float);
16223 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
16225 vector unsigned char vec_adds (vector bool char, vector unsigned char);
16226 vector unsigned char vec_adds (vector unsigned char, vector bool char);
16227 vector unsigned char vec_adds (vector unsigned char, vector unsigned char);
16228 vector signed char vec_adds (vector bool char, vector signed char);
16229 vector signed char vec_adds (vector signed char, vector bool char);
16230 vector signed char vec_adds (vector signed char, vector signed char);
16231 vector unsigned short vec_adds (vector bool short, vector unsigned short);
16232 vector unsigned short vec_adds (vector unsigned short, vector bool short);
16233 vector unsigned short vec_adds (vector unsigned short, vector unsigned short);
16234 vector signed short vec_adds (vector bool short, vector signed short);
16235 vector signed short vec_adds (vector signed short, vector bool short);
16236 vector signed short vec_adds (vector signed short, vector signed short);
16237 vector unsigned int vec_adds (vector bool int, vector unsigned int);
16238 vector unsigned int vec_adds (vector unsigned int, vector bool int);
16239 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
16240 vector signed int vec_adds (vector bool int, vector signed int);
16241 vector signed int vec_adds (vector signed int, vector bool int);
16242 vector signed int vec_adds (vector signed int, vector signed int);
16244 int vec_all_eq (vector signed char, vector bool char);
16245 int vec_all_eq (vector signed char, vector signed char);
16246 int vec_all_eq (vector unsigned char, vector bool char);
16247 int vec_all_eq (vector unsigned char, vector unsigned char);
16248 int vec_all_eq (vector bool char, vector bool char);
16249 int vec_all_eq (vector bool char, vector unsigned char);
16250 int vec_all_eq (vector bool char, vector signed char);
16251 int vec_all_eq (vector signed short, vector bool short);
16252 int vec_all_eq (vector signed short, vector signed short);
16253 int vec_all_eq (vector unsigned short, vector bool short);
16254 int vec_all_eq (vector unsigned short, vector unsigned short);
16255 int vec_all_eq (vector bool short, vector bool short);
16256 int vec_all_eq (vector bool short, vector unsigned short);
16257 int vec_all_eq (vector bool short, vector signed short);
16258 int vec_all_eq (vector pixel, vector pixel);
16259 int vec_all_eq (vector signed int, vector bool int);
16260 int vec_all_eq (vector signed int, vector signed int);
16261 int vec_all_eq (vector unsigned int, vector bool int);
16262 int vec_all_eq (vector unsigned int, vector unsigned int);
16263 int vec_all_eq (vector bool int, vector bool int);
16264 int vec_all_eq (vector bool int, vector unsigned int);
16265 int vec_all_eq (vector bool int, vector signed int);
16266 int vec_all_eq (vector float, vector float);
16268 int vec_all_ge (vector bool char, vector unsigned char);
16269 int vec_all_ge (vector unsigned char, vector bool char);
16270 int vec_all_ge (vector unsigned char, vector unsigned char);
16271 int vec_all_ge (vector bool char, vector signed char);
16272 int vec_all_ge (vector signed char, vector bool char);
16273 int vec_all_ge (vector signed char, vector signed char);
16274 int vec_all_ge (vector bool short, vector unsigned short);
16275 int vec_all_ge (vector unsigned short, vector bool short);
16276 int vec_all_ge (vector unsigned short, vector unsigned short);
16277 int vec_all_ge (vector signed short, vector signed short);
16278 int vec_all_ge (vector bool short, vector signed short);
16279 int vec_all_ge (vector signed short, vector bool short);
16280 int vec_all_ge (vector bool int, vector unsigned int);
16281 int vec_all_ge (vector unsigned int, vector bool int);
16282 int vec_all_ge (vector unsigned int, vector unsigned int);
16283 int vec_all_ge (vector bool int, vector signed int);
16284 int vec_all_ge (vector signed int, vector bool int);
16285 int vec_all_ge (vector signed int, vector signed int);
16286 int vec_all_ge (vector float, vector float);
16288 int vec_all_gt (vector bool char, vector unsigned char);
16289 int vec_all_gt (vector unsigned char, vector bool char);
16290 int vec_all_gt (vector unsigned char, vector unsigned char);
16291 int vec_all_gt (vector bool char, vector signed char);
16292 int vec_all_gt (vector signed char, vector bool char);
16293 int vec_all_gt (vector signed char, vector signed char);
16294 int vec_all_gt (vector bool short, vector unsigned short);
16295 int vec_all_gt (vector unsigned short, vector bool short);
16296 int vec_all_gt (vector unsigned short, vector unsigned short);
16297 int vec_all_gt (vector bool short, vector signed short);
16298 int vec_all_gt (vector signed short, vector bool short);
16299 int vec_all_gt (vector signed short, vector signed short);
16300 int vec_all_gt (vector bool int, vector unsigned int);
16301 int vec_all_gt (vector unsigned int, vector bool int);
16302 int vec_all_gt (vector unsigned int, vector unsigned int);
16303 int vec_all_gt (vector bool int, vector signed int);
16304 int vec_all_gt (vector signed int, vector bool int);
16305 int vec_all_gt (vector signed int, vector signed int);
16306 int vec_all_gt (vector float, vector float);
16308 int vec_all_in (vector float, vector float);
16310 int vec_all_le (vector bool char, vector unsigned char);
16311 int vec_all_le (vector unsigned char, vector bool char);
16312 int vec_all_le (vector unsigned char, vector unsigned char);
16313 int vec_all_le (vector bool char, vector signed char);
16314 int vec_all_le (vector signed char, vector bool char);
16315 int vec_all_le (vector signed char, vector signed char);
16316 int vec_all_le (vector bool short, vector unsigned short);
16317 int vec_all_le (vector unsigned short, vector bool short);
16318 int vec_all_le (vector unsigned short, vector unsigned short);
16319 int vec_all_le (vector bool short, vector signed short);
16320 int vec_all_le (vector signed short, vector bool short);
16321 int vec_all_le (vector signed short, vector signed short);
16322 int vec_all_le (vector bool int, vector unsigned int);
16323 int vec_all_le (vector unsigned int, vector bool int);
16324 int vec_all_le (vector unsigned int, vector unsigned int);
16325 int vec_all_le (vector bool int, vector signed int);
16326 int vec_all_le (vector signed int, vector bool int);
16327 int vec_all_le (vector signed int, vector signed int);
16328 int vec_all_le (vector float, vector float);
16330 int vec_all_lt (vector bool char, vector unsigned char);
16331 int vec_all_lt (vector unsigned char, vector bool char);
16332 int vec_all_lt (vector unsigned char, vector unsigned char);
16333 int vec_all_lt (vector bool char, vector signed char);
16334 int vec_all_lt (vector signed char, vector bool char);
16335 int vec_all_lt (vector signed char, vector signed char);
16336 int vec_all_lt (vector bool short, vector unsigned short);
16337 int vec_all_lt (vector unsigned short, vector bool short);
16338 int vec_all_lt (vector unsigned short, vector unsigned short);
16339 int vec_all_lt (vector bool short, vector signed short);
16340 int vec_all_lt (vector signed short, vector bool short);
16341 int vec_all_lt (vector signed short, vector signed short);
16342 int vec_all_lt (vector bool int, vector unsigned int);
16343 int vec_all_lt (vector unsigned int, vector bool int);
16344 int vec_all_lt (vector unsigned int, vector unsigned int);
16345 int vec_all_lt (vector bool int, vector signed int);
16346 int vec_all_lt (vector signed int, vector bool int);
16347 int vec_all_lt (vector signed int, vector signed int);
16348 int vec_all_lt (vector float, vector float);
16350 int vec_all_nan (vector float);
16352 int vec_all_ne (vector signed char, vector bool char);
16353 int vec_all_ne (vector signed char, vector signed char);
16354 int vec_all_ne (vector unsigned char, vector bool char);
16355 int vec_all_ne (vector unsigned char, vector unsigned char);
16356 int vec_all_ne (vector bool char, vector bool char);
16357 int vec_all_ne (vector bool char, vector unsigned char);
16358 int vec_all_ne (vector bool char, vector signed char);
16359 int vec_all_ne (vector signed short, vector bool short);
16360 int vec_all_ne (vector signed short, vector signed short);
16361 int vec_all_ne (vector unsigned short, vector bool short);
16362 int vec_all_ne (vector unsigned short, vector unsigned short);
16363 int vec_all_ne (vector bool short, vector bool short);
16364 int vec_all_ne (vector bool short, vector unsigned short);
16365 int vec_all_ne (vector bool short, vector signed short);
16366 int vec_all_ne (vector pixel, vector pixel);
16367 int vec_all_ne (vector signed int, vector bool int);
16368 int vec_all_ne (vector signed int, vector signed int);
16369 int vec_all_ne (vector unsigned int, vector bool int);
16370 int vec_all_ne (vector unsigned int, vector unsigned int);
16371 int vec_all_ne (vector bool int, vector bool int);
16372 int vec_all_ne (vector bool int, vector unsigned int);
16373 int vec_all_ne (vector bool int, vector signed int);
16374 int vec_all_ne (vector float, vector float);
16376 int vec_all_nge (vector float, vector float);
16378 int vec_all_ngt (vector float, vector float);
16380 int vec_all_nle (vector float, vector float);
16382 int vec_all_nlt (vector float, vector float);
16384 int vec_all_numeric (vector float);
16386 vector float vec_and (vector float, vector float);
16387 vector float vec_and (vector float, vector bool int);
16388 vector float vec_and (vector bool int, vector float);
16389 vector bool int vec_and (vector bool int, vector bool int);
16390 vector signed int vec_and (vector bool int, vector signed int);
16391 vector signed int vec_and (vector signed int, vector bool int);
16392 vector signed int vec_and (vector signed int, vector signed int);
16393 vector unsigned int vec_and (vector bool int, vector unsigned int);
16394 vector unsigned int vec_and (vector unsigned int, vector bool int);
16395 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
16396 vector bool short vec_and (vector bool short, vector bool short);
16397 vector signed short vec_and (vector bool short, vector signed short);
16398 vector signed short vec_and (vector signed short, vector bool short);
16399 vector signed short vec_and (vector signed short, vector signed short);
16400 vector unsigned short vec_and (vector bool short, vector unsigned short);
16401 vector unsigned short vec_and (vector unsigned short, vector bool short);
16402 vector unsigned short vec_and (vector unsigned short, vector unsigned short);
16403 vector signed char vec_and (vector bool char, vector signed char);
16404 vector bool char vec_and (vector bool char, vector bool char);
16405 vector signed char vec_and (vector signed char, vector bool char);
16406 vector signed char vec_and (vector signed char, vector signed char);
16407 vector unsigned char vec_and (vector bool char, vector unsigned char);
16408 vector unsigned char vec_and (vector unsigned char, vector bool char);
16409 vector unsigned char vec_and (vector unsigned char, vector unsigned char);
16411 vector float vec_andc (vector float, vector float);
16412 vector float vec_andc (vector float, vector bool int);
16413 vector float vec_andc (vector bool int, vector float);
16414 vector bool int vec_andc (vector bool int, vector bool int);
16415 vector signed int vec_andc (vector bool int, vector signed int);
16416 vector signed int vec_andc (vector signed int, vector bool int);
16417 vector signed int vec_andc (vector signed int, vector signed int);
16418 vector unsigned int vec_andc (vector bool int, vector unsigned int);
16419 vector unsigned int vec_andc (vector unsigned int, vector bool int);
16420 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
16421 vector bool short vec_andc (vector bool short, vector bool short);
16422 vector signed short vec_andc (vector bool short, vector signed short);
16423 vector signed short vec_andc (vector signed short, vector bool short);
16424 vector signed short vec_andc (vector signed short, vector signed short);
16425 vector unsigned short vec_andc (vector bool short, vector unsigned short);
16426 vector unsigned short vec_andc (vector unsigned short, vector bool short);
16427 vector unsigned short vec_andc (vector unsigned short, vector unsigned short);
16428 vector signed char vec_andc (vector bool char, vector signed char);
16429 vector bool char vec_andc (vector bool char, vector bool char);
16430 vector signed char vec_andc (vector signed char, vector bool char);
16431 vector signed char vec_andc (vector signed char, vector signed char);
16432 vector unsigned char vec_andc (vector bool char, vector unsigned char);
16433 vector unsigned char vec_andc (vector unsigned char, vector bool char);
16434 vector unsigned char vec_andc (vector unsigned char, vector unsigned char);
16436 int vec_any_eq (vector signed char, vector bool char);
16437 int vec_any_eq (vector signed char, vector signed char);
16438 int vec_any_eq (vector unsigned char, vector bool char);
16439 int vec_any_eq (vector unsigned char, vector unsigned char);
16440 int vec_any_eq (vector bool char, vector bool char);
16441 int vec_any_eq (vector bool char, vector unsigned char);
16442 int vec_any_eq (vector bool char, vector signed char);
16443 int vec_any_eq (vector signed short, vector bool short);
16444 int vec_any_eq (vector signed short, vector signed short);
16445 int vec_any_eq (vector unsigned short, vector bool short);
16446 int vec_any_eq (vector unsigned short, vector unsigned short);
16447 int vec_any_eq (vector bool short, vector bool short);
16448 int vec_any_eq (vector bool short, vector unsigned short);
16449 int vec_any_eq (vector bool short, vector signed short);
16450 int vec_any_eq (vector pixel, vector pixel);
16451 int vec_any_eq (vector signed int, vector bool int);
16452 int vec_any_eq (vector signed int, vector signed int);
16453 int vec_any_eq (vector unsigned int, vector bool int);
16454 int vec_any_eq (vector unsigned int, vector unsigned int);
16455 int vec_any_eq (vector bool int, vector bool int);
16456 int vec_any_eq (vector bool int, vector unsigned int);
16457 int vec_any_eq (vector bool int, vector signed int);
16458 int vec_any_eq (vector float, vector float);
16460 int vec_any_ge (vector signed char, vector bool char);
16461 int vec_any_ge (vector unsigned char, vector bool char);
16462 int vec_any_ge (vector unsigned char, vector unsigned char);
16463 int vec_any_ge (vector signed char, vector signed char);
16464 int vec_any_ge (vector bool char, vector unsigned char);
16465 int vec_any_ge (vector bool char, vector signed char);
16466 int vec_any_ge (vector unsigned short, vector bool short);
16467 int vec_any_ge (vector unsigned short, vector unsigned short);
16468 int vec_any_ge (vector signed short, vector signed short);
16469 int vec_any_ge (vector signed short, vector bool short);
16470 int vec_any_ge (vector bool short, vector unsigned short);
16471 int vec_any_ge (vector bool short, vector signed short);
16472 int vec_any_ge (vector signed int, vector bool int);
16473 int vec_any_ge (vector unsigned int, vector bool int);
16474 int vec_any_ge (vector unsigned int, vector unsigned int);
16475 int vec_any_ge (vector signed int, vector signed int);
16476 int vec_any_ge (vector bool int, vector unsigned int);
16477 int vec_any_ge (vector bool int, vector signed int);
16478 int vec_any_ge (vector float, vector float);
16480 int vec_any_gt (vector bool char, vector unsigned char);
16481 int vec_any_gt (vector unsigned char, vector bool char);
16482 int vec_any_gt (vector unsigned char, vector unsigned char);
16483 int vec_any_gt (vector bool char, vector signed char);
16484 int vec_any_gt (vector signed char, vector bool char);
16485 int vec_any_gt (vector signed char, vector signed char);
16486 int vec_any_gt (vector bool short, vector unsigned short);
16487 int vec_any_gt (vector unsigned short, vector bool short);
16488 int vec_any_gt (vector unsigned short, vector unsigned short);
16489 int vec_any_gt (vector bool short, vector signed short);
16490 int vec_any_gt (vector signed short, vector bool short);
16491 int vec_any_gt (vector signed short, vector signed short);
16492 int vec_any_gt (vector bool int, vector unsigned int);
16493 int vec_any_gt (vector unsigned int, vector bool int);
16494 int vec_any_gt (vector unsigned int, vector unsigned int);
16495 int vec_any_gt (vector bool int, vector signed int);
16496 int vec_any_gt (vector signed int, vector bool int);
16497 int vec_any_gt (vector signed int, vector signed int);
16498 int vec_any_gt (vector float, vector float);
16500 int vec_any_le (vector bool char, vector unsigned char);
16501 int vec_any_le (vector unsigned char, vector bool char);
16502 int vec_any_le (vector unsigned char, vector unsigned char);
16503 int vec_any_le (vector bool char, vector signed char);
16504 int vec_any_le (vector signed char, vector bool char);
16505 int vec_any_le (vector signed char, vector signed char);
16506 int vec_any_le (vector bool short, vector unsigned short);
16507 int vec_any_le (vector unsigned short, vector bool short);
16508 int vec_any_le (vector unsigned short, vector unsigned short);
16509 int vec_any_le (vector bool short, vector signed short);
16510 int vec_any_le (vector signed short, vector bool short);
16511 int vec_any_le (vector signed short, vector signed short);
16512 int vec_any_le (vector bool int, vector unsigned int);
16513 int vec_any_le (vector unsigned int, vector bool int);
16514 int vec_any_le (vector unsigned int, vector unsigned int);
16515 int vec_any_le (vector bool int, vector signed int);
16516 int vec_any_le (vector signed int, vector bool int);
16517 int vec_any_le (vector signed int, vector signed int);
16518 int vec_any_le (vector float, vector float);
16520 int vec_any_lt (vector bool char, vector unsigned char);
16521 int vec_any_lt (vector unsigned char, vector bool char);
16522 int vec_any_lt (vector unsigned char, vector unsigned char);
16523 int vec_any_lt (vector bool char, vector signed char);
16524 int vec_any_lt (vector signed char, vector bool char);
16525 int vec_any_lt (vector signed char, vector signed char);
16526 int vec_any_lt (vector bool short, vector unsigned short);
16527 int vec_any_lt (vector unsigned short, vector bool short);
16528 int vec_any_lt (vector unsigned short, vector unsigned short);
16529 int vec_any_lt (vector bool short, vector signed short);
16530 int vec_any_lt (vector signed short, vector bool short);
16531 int vec_any_lt (vector signed short, vector signed short);
16532 int vec_any_lt (vector bool int, vector unsigned int);
16533 int vec_any_lt (vector unsigned int, vector bool int);
16534 int vec_any_lt (vector unsigned int, vector unsigned int);
16535 int vec_any_lt (vector bool int, vector signed int);
16536 int vec_any_lt (vector signed int, vector bool int);
16537 int vec_any_lt (vector signed int, vector signed int);
16538 int vec_any_lt (vector float, vector float);
16540 int vec_any_nan (vector float);
16542 int vec_any_ne (vector signed char, vector bool char);
16543 int vec_any_ne (vector signed char, vector signed char);
16544 int vec_any_ne (vector unsigned char, vector bool char);
16545 int vec_any_ne (vector unsigned char, vector unsigned char);
16546 int vec_any_ne (vector bool char, vector bool char);
16547 int vec_any_ne (vector bool char, vector unsigned char);
16548 int vec_any_ne (vector bool char, vector signed char);
16549 int vec_any_ne (vector signed short, vector bool short);
16550 int vec_any_ne (vector signed short, vector signed short);
16551 int vec_any_ne (vector unsigned short, vector bool short);
16552 int vec_any_ne (vector unsigned short, vector unsigned short);
16553 int vec_any_ne (vector bool short, vector bool short);
16554 int vec_any_ne (vector bool short, vector unsigned short);
16555 int vec_any_ne (vector bool short, vector signed short);
16556 int vec_any_ne (vector pixel, vector pixel);
16557 int vec_any_ne (vector signed int, vector bool int);
16558 int vec_any_ne (vector signed int, vector signed int);
16559 int vec_any_ne (vector unsigned int, vector bool int);
16560 int vec_any_ne (vector unsigned int, vector unsigned int);
16561 int vec_any_ne (vector bool int, vector bool int);
16562 int vec_any_ne (vector bool int, vector unsigned int);
16563 int vec_any_ne (vector bool int, vector signed int);
16564 int vec_any_ne (vector float, vector float);
16566 int vec_any_nge (vector float, vector float);
16568 int vec_any_ngt (vector float, vector float);
16570 int vec_any_nle (vector float, vector float);
16572 int vec_any_nlt (vector float, vector float);
16574 int vec_any_numeric (vector float);
16576 int vec_any_out (vector float, vector float);
16578 vector unsigned char vec_avg (vector unsigned char, vector unsigned char);
16579 vector signed char vec_avg (vector signed char, vector signed char);
16580 vector unsigned short vec_avg (vector unsigned short, vector unsigned short);
16581 vector signed short vec_avg (vector signed short, vector signed short);
16582 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
16583 vector signed int vec_avg (vector signed int, vector signed int);
16585 vector float vec_ceil (vector float);
16587 vector signed int vec_cmpb (vector float, vector float);
16589 vector bool char vec_cmpeq (vector bool char, vector bool char);
16590 vector bool short vec_cmpeq (vector bool short, vector bool short);
16591 vector bool int vec_cmpeq (vector bool int, vector bool int);
16592 vector bool char vec_cmpeq (vector signed char, vector signed char);
16593 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
16594 vector bool short vec_cmpeq (vector signed short, vector signed short);
16595 vector bool short vec_cmpeq (vector unsigned short, vector unsigned short);
16596 vector bool int vec_cmpeq (vector signed int, vector signed int);
16597 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
16598 vector bool int vec_cmpeq (vector float, vector float);
16600 vector bool int vec_cmpge (vector float, vector float);
16602 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
16603 vector bool char vec_cmpgt (vector signed char, vector signed char);
16604 vector bool short vec_cmpgt (vector unsigned short, vector unsigned short);
16605 vector bool short vec_cmpgt (vector signed short, vector signed short);
16606 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
16607 vector bool int vec_cmpgt (vector signed int, vector signed int);
16608 vector bool int vec_cmpgt (vector float, vector float);
16610 vector bool int vec_cmple (vector float, vector float);
16612 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
16613 vector bool char vec_cmplt (vector signed char, vector signed char);
16614 vector bool short vec_cmplt (vector unsigned short, vector unsigned short);
16615 vector bool short vec_cmplt (vector signed short, vector signed short);
16616 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
16617 vector bool int vec_cmplt (vector signed int, vector signed int);
16618 vector bool int vec_cmplt (vector float, vector float);
16620 vector float vec_cpsgn (vector float, vector float);
16622 vector float vec_ctf (vector unsigned int, const int);
16623 vector float vec_ctf (vector signed int, const int);
16625 vector signed int vec_cts (vector float, const int);
16627 vector unsigned int vec_ctu (vector float, const int);
16629 void vec_dss (const int);
16631 void vec_dssall (void);
16633 void vec_dst (const vector unsigned char *, int, const int);
16634 void vec_dst (const vector signed char *, int, const int);
16635 void vec_dst (const vector bool char *, int, const int);
16636 void vec_dst (const vector unsigned short *, int, const int);
16637 void vec_dst (const vector signed short *, int, const int);
16638 void vec_dst (const vector bool short *, int, const int);
16639 void vec_dst (const vector pixel *, int, const int);
16640 void vec_dst (const vector unsigned int *, int, const int);
16641 void vec_dst (const vector signed int *, int, const int);
16642 void vec_dst (const vector bool int *, int, const int);
16643 void vec_dst (const vector float *, int, const int);
16644 void vec_dst (const unsigned char *, int, const int);
16645 void vec_dst (const signed char *, int, const int);
16646 void vec_dst (const unsigned short *, int, const int);
16647 void vec_dst (const short *, int, const int);
16648 void vec_dst (const unsigned int *, int, const int);
16649 void vec_dst (const int *, int, const int);
16650 void vec_dst (const float *, int, const int);
16652 void vec_dstst (const vector unsigned char *, int, const int);
16653 void vec_dstst (const vector signed char *, int, const int);
16654 void vec_dstst (const vector bool char *, int, const int);
16655 void vec_dstst (const vector unsigned short *, int, const int);
16656 void vec_dstst (const vector signed short *, int, const int);
16657 void vec_dstst (const vector bool short *, int, const int);
16658 void vec_dstst (const vector pixel *, int, const int);
16659 void vec_dstst (const vector unsigned int *, int, const int);
16660 void vec_dstst (const vector signed int *, int, const int);
16661 void vec_dstst (const vector bool int *, int, const int);
16662 void vec_dstst (const vector float *, int, const int);
16663 void vec_dstst (const unsigned char *, int, const int);
16664 void vec_dstst (const signed char *, int, const int);
16665 void vec_dstst (const unsigned short *, int, const int);
16666 void vec_dstst (const short *, int, const int);
16667 void vec_dstst (const unsigned int *, int, const int);
16668 void vec_dstst (const int *, int, const int);
16669 void vec_dstst (const unsigned long *, int, const int);
16670 void vec_dstst (const long *, int, const int);
16671 void vec_dstst (const float *, int, const int);
16673 void vec_dststt (const vector unsigned char *, int, const int);
16674 void vec_dststt (const vector signed char *, int, const int);
16675 void vec_dststt (const vector bool char *, int, const int);
16676 void vec_dststt (const vector unsigned short *, int, const int);
16677 void vec_dststt (const vector signed short *, int, const int);
16678 void vec_dststt (const vector bool short *, int, const int);
16679 void vec_dststt (const vector pixel *, int, const int);
16680 void vec_dststt (const vector unsigned int *, int, const int);
16681 void vec_dststt (const vector signed int *, int, const int);
16682 void vec_dststt (const vector bool int *, int, const int);
16683 void vec_dststt (const vector float *, int, const int);
16684 void vec_dststt (const unsigned char *, int, const int);
16685 void vec_dststt (const signed char *, int, const int);
16686 void vec_dststt (const unsigned short *, int, const int);
16687 void vec_dststt (const short *, int, const int);
16688 void vec_dststt (const unsigned int *, int, const int);
16689 void vec_dststt (const int *, int, const int);
16690 void vec_dststt (const float *, int, const int);
16692 void vec_dstt (const vector unsigned char *, int, const int);
16693 void vec_dstt (const vector signed char *, int, const int);
16694 void vec_dstt (const vector bool char *, int, const int);
16695 void vec_dstt (const vector unsigned short *, int, const int);
16696 void vec_dstt (const vector signed short *, int, const int);
16697 void vec_dstt (const vector bool short *, int, const int);
16698 void vec_dstt (const vector pixel *, int, const int);
16699 void vec_dstt (const vector unsigned int *, int, const int);
16700 void vec_dstt (const vector signed int *, int, const int);
16701 void vec_dstt (const vector bool int *, int, const int);
16702 void vec_dstt (const vector float *, int, const int);
16703 void vec_dstt (const unsigned char *, int, const int);
16704 void vec_dstt (const signed char *, int, const int);
16705 void vec_dstt (const unsigned short *, int, const int);
16706 void vec_dstt (const short *, int, const int);
16707 void vec_dstt (const unsigned int *, int, const int);
16708 void vec_dstt (const int *, int, const int);
16709 void vec_dstt (const float *, int, const int);
16711 vector float vec_expte (vector float);
16713 vector float vec_floor (vector float);
16715 vector float vec_ld (int, const vector float *);
16716 vector float vec_ld (int, const float *);
16717 vector bool int vec_ld (int, const vector bool int *);
16718 vector signed int vec_ld (int, const vector signed int *);
16719 vector signed int vec_ld (int, const int *);
16720 vector unsigned int vec_ld (int, const vector unsigned int *);
16721 vector unsigned int vec_ld (int, const unsigned int *);
16722 vector bool short vec_ld (int, const vector bool short *);
16723 vector pixel vec_ld (int, const vector pixel *);
16724 vector signed short vec_ld (int, const vector signed short *);
16725 vector signed short vec_ld (int, const short *);
16726 vector unsigned short vec_ld (int, const vector unsigned short *);
16727 vector unsigned short vec_ld (int, const unsigned short *);
16728 vector bool char vec_ld (int, const vector bool char *);
16729 vector signed char vec_ld (int, const vector signed char *);
16730 vector signed char vec_ld (int, const signed char *);
16731 vector unsigned char vec_ld (int, const vector unsigned char *);
16732 vector unsigned char vec_ld (int, const unsigned char *);
16734 vector signed char vec_lde (int, const signed char *);
16735 vector unsigned char vec_lde (int, const unsigned char *);
16736 vector signed short vec_lde (int, const short *);
16737 vector unsigned short vec_lde (int, const unsigned short *);
16738 vector float vec_lde (int, const float *);
16739 vector signed int vec_lde (int, const int *);
16740 vector unsigned int vec_lde (int, const unsigned int *);
16742 vector float vec_ldl (int, const vector float *);
16743 vector float vec_ldl (int, const float *);
16744 vector bool int vec_ldl (int, const vector bool int *);
16745 vector signed int vec_ldl (int, const vector signed int *);
16746 vector signed int vec_ldl (int, const int *);
16747 vector unsigned int vec_ldl (int, const vector unsigned int *);
16748 vector unsigned int vec_ldl (int, const unsigned int *);
16749 vector bool short vec_ldl (int, const vector bool short *);
16750 vector pixel vec_ldl (int, const vector pixel *);
16751 vector signed short vec_ldl (int, const vector signed short *);
16752 vector signed short vec_ldl (int, const short *);
16753 vector unsigned short vec_ldl (int, const vector unsigned short *);
16754 vector unsigned short vec_ldl (int, const unsigned short *);
16755 vector bool char vec_ldl (int, const vector bool char *);
16756 vector signed char vec_ldl (int, const vector signed char *);
16757 vector signed char vec_ldl (int, const signed char *);
16758 vector unsigned char vec_ldl (int, const vector unsigned char *);
16759 vector unsigned char vec_ldl (int, const unsigned char *);
16761 vector float vec_loge (vector float);
16763 vector signed char vec_lvebx (int, char *);
16764 vector unsigned char vec_lvebx (int, unsigned char *);
16766 vector signed short vec_lvehx (int, short *);
16767 vector unsigned short vec_lvehx (int, unsigned short *);
16769 vector float vec_lvewx (int, float *);
16770 vector signed int vec_lvewx (int, int *);
16771 vector unsigned int vec_lvewx (int, unsigned int *);
16773 vector unsigned char vec_lvsl (int, const unsigned char *);
16774 vector unsigned char vec_lvsl (int, const signed char *);
16775 vector unsigned char vec_lvsl (int, const unsigned short *);
16776 vector unsigned char vec_lvsl (int, const short *);
16777 vector unsigned char vec_lvsl (int, const unsigned int *);
16778 vector unsigned char vec_lvsl (int, const int *);
16779 vector unsigned char vec_lvsl (int, const float *);
16781 vector unsigned char vec_lvsr (int, const unsigned char *);
16782 vector unsigned char vec_lvsr (int, const signed char *);
16783 vector unsigned char vec_lvsr (int, const unsigned short *);
16784 vector unsigned char vec_lvsr (int, const short *);
16785 vector unsigned char vec_lvsr (int, const unsigned int *);
16786 vector unsigned char vec_lvsr (int, const int *);
16787 vector unsigned char vec_lvsr (int, const float *);
16789 vector float vec_madd (vector float, vector float, vector float);
16791 vector signed short vec_madds (vector signed short, vector signed short,
16792 vector signed short);
16794 vector unsigned char vec_max (vector bool char, vector unsigned char);
16795 vector unsigned char vec_max (vector unsigned char, vector bool char);
16796 vector unsigned char vec_max (vector unsigned char, vector unsigned char);
16797 vector signed char vec_max (vector bool char, vector signed char);
16798 vector signed char vec_max (vector signed char, vector bool char);
16799 vector signed char vec_max (vector signed char, vector signed char);
16800 vector unsigned short vec_max (vector bool short, vector unsigned short);
16801 vector unsigned short vec_max (vector unsigned short, vector bool short);
16802 vector unsigned short vec_max (vector unsigned short, vector unsigned short);
16803 vector signed short vec_max (vector bool short, vector signed short);
16804 vector signed short vec_max (vector signed short, vector bool short);
16805 vector signed short vec_max (vector signed short, vector signed short);
16806 vector unsigned int vec_max (vector bool int, vector unsigned int);
16807 vector unsigned int vec_max (vector unsigned int, vector bool int);
16808 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
16809 vector signed int vec_max (vector bool int, vector signed int);
16810 vector signed int vec_max (vector signed int, vector bool int);
16811 vector signed int vec_max (vector signed int, vector signed int);
16812 vector float vec_max (vector float, vector float);
16814 vector bool char vec_mergeh (vector bool char, vector bool char);
16815 vector signed char vec_mergeh (vector signed char, vector signed char);
16816 vector unsigned char vec_mergeh (vector unsigned char, vector unsigned char);
16817 vector bool short vec_mergeh (vector bool short, vector bool short);
16818 vector pixel vec_mergeh (vector pixel, vector pixel);
16819 vector signed short vec_mergeh (vector signed short, vector signed short);
16820 vector unsigned short vec_mergeh (vector unsigned short, vector unsigned short);
16821 vector float vec_mergeh (vector float, vector float);
16822 vector bool int vec_mergeh (vector bool int, vector bool int);
16823 vector signed int vec_mergeh (vector signed int, vector signed int);
16824 vector unsigned int vec_mergeh (vector unsigned int, vector unsigned int);
16826 vector bool char vec_mergel (vector bool char, vector bool char);
16827 vector signed char vec_mergel (vector signed char, vector signed char);
16828 vector unsigned char vec_mergel (vector unsigned char, vector unsigned char);
16829 vector bool short vec_mergel (vector bool short, vector bool short);
16830 vector pixel vec_mergel (vector pixel, vector pixel);
16831 vector signed short vec_mergel (vector signed short, vector signed short);
16832 vector unsigned short vec_mergel (vector unsigned short, vector unsigned short);
16833 vector float vec_mergel (vector float, vector float);
16834 vector bool int vec_mergel (vector bool int, vector bool int);
16835 vector signed int vec_mergel (vector signed int, vector signed int);
16836 vector unsigned int vec_mergel (vector unsigned int, vector unsigned int);
16838 vector unsigned short vec_mfvscr (void);
16840 vector unsigned char vec_min (vector bool char, vector unsigned char);
16841 vector unsigned char vec_min (vector unsigned char, vector bool char);
16842 vector unsigned char vec_min (vector unsigned char, vector unsigned char);
16843 vector signed char vec_min (vector bool char, vector signed char);
16844 vector signed char vec_min (vector signed char, vector bool char);
16845 vector signed char vec_min (vector signed char, vector signed char);
16846 vector unsigned short vec_min (vector bool short, vector unsigned short);
16847 vector unsigned short vec_min (vector unsigned short, vector bool short);
16848 vector unsigned short vec_min (vector unsigned short, vector unsigned short);
16849 vector signed short vec_min (vector bool short, vector signed short);
16850 vector signed short vec_min (vector signed short, vector bool short);
16851 vector signed short vec_min (vector signed short, vector signed short);
16852 vector unsigned int vec_min (vector bool int, vector unsigned int);
16853 vector unsigned int vec_min (vector unsigned int, vector bool int);
16854 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
16855 vector signed int vec_min (vector bool int, vector signed int);
16856 vector signed int vec_min (vector signed int, vector bool int);
16857 vector signed int vec_min (vector signed int, vector signed int);
16858 vector float vec_min (vector float, vector float);
16860 vector signed short vec_mladd (vector signed short, vector signed short,
16861 vector signed short);
16862 vector signed short vec_mladd (vector signed short, vector unsigned short,
16863 vector unsigned short);
16864 vector signed short vec_mladd (vector unsigned short, vector signed short,
16865 vector signed short);
16866 vector unsigned short vec_mladd (vector unsigned short, vector unsigned short,
16867 vector unsigned short);
16869 vector signed short vec_mradds (vector signed short, vector signed short,
16870 vector signed short);
16872 vector unsigned int vec_msum (vector unsigned char, vector unsigned char,
16873 vector unsigned int);
16874 vector signed int vec_msum (vector signed char, vector unsigned char,
16875 vector signed int);
16876 vector unsigned int vec_msum (vector unsigned short, vector unsigned short,
16877 vector unsigned int);
16878 vector signed int vec_msum (vector signed short, vector signed short,
16879 vector signed int);
16881 vector unsigned int vec_msums (vector unsigned short, vector unsigned short,
16882 vector unsigned int);
16883 vector signed int vec_msums (vector signed short, vector signed short,
16884 vector signed int);
16886 void vec_mtvscr (vector signed int);
16887 void vec_mtvscr (vector unsigned int);
16888 void vec_mtvscr (vector bool int);
16889 void vec_mtvscr (vector signed short);
16890 void vec_mtvscr (vector unsigned short);
16891 void vec_mtvscr (vector bool short);
16892 void vec_mtvscr (vector pixel);
16893 void vec_mtvscr (vector signed char);
16894 void vec_mtvscr (vector unsigned char);
16895 void vec_mtvscr (vector bool char);
16897 vector float vec_mul (vector float, vector float);
16899 vector unsigned short vec_mule (vector unsigned char, vector unsigned char);
16900 vector signed short vec_mule (vector signed char, vector signed char);
16901 vector unsigned int vec_mule (vector unsigned short, vector unsigned short);
16902 vector signed int vec_mule (vector signed short, vector signed short);
16904 vector unsigned short vec_mulo (vector unsigned char, vector unsigned char);
16905 vector signed short vec_mulo (vector signed char, vector signed char);
16906 vector unsigned int vec_mulo (vector unsigned short, vector unsigned short);
16907 vector signed int vec_mulo (vector signed short, vector signed short);
16909 vector signed char vec_nabs (vector signed char);
16910 vector signed short vec_nabs (vector signed short);
16911 vector signed int vec_nabs (vector signed int);
16912 vector float vec_nabs (vector float);
16914 vector float vec_nmsub (vector float, vector float, vector float);
16916 vector float vec_nor (vector float, vector float);
16917 vector signed int vec_nor (vector signed int, vector signed int);
16918 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
16919 vector bool int vec_nor (vector bool int, vector bool int);
16920 vector signed short vec_nor (vector signed short, vector signed short);
16921 vector unsigned short vec_nor (vector unsigned short, vector unsigned short);
16922 vector bool short vec_nor (vector bool short, vector bool short);
16923 vector signed char vec_nor (vector signed char, vector signed char);
16924 vector unsigned char vec_nor (vector unsigned char, vector unsigned char);
16925 vector bool char vec_nor (vector bool char, vector bool char);
16927 vector float vec_or (vector float, vector float);
16928 vector float vec_or (vector float, vector bool int);
16929 vector float vec_or (vector bool int, vector float);
16930 vector bool int vec_or (vector bool int, vector bool int);
16931 vector signed int vec_or (vector bool int, vector signed int);
16932 vector signed int vec_or (vector signed int, vector bool int);
16933 vector signed int vec_or (vector signed int, vector signed int);
16934 vector unsigned int vec_or (vector bool int, vector unsigned int);
16935 vector unsigned int vec_or (vector unsigned int, vector bool int);
16936 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
16937 vector bool short vec_or (vector bool short, vector bool short);
16938 vector signed short vec_or (vector bool short, vector signed short);
16939 vector signed short vec_or (vector signed short, vector bool short);
16940 vector signed short vec_or (vector signed short, vector signed short);
16941 vector unsigned short vec_or (vector bool short, vector unsigned short);
16942 vector unsigned short vec_or (vector unsigned short, vector bool short);
16943 vector unsigned short vec_or (vector unsigned short, vector unsigned short);
16944 vector signed char vec_or (vector bool char, vector signed char);
16945 vector bool char vec_or (vector bool char, vector bool char);
16946 vector signed char vec_or (vector signed char, vector bool char);
16947 vector signed char vec_or (vector signed char, vector signed char);
16948 vector unsigned char vec_or (vector bool char, vector unsigned char);
16949 vector unsigned char vec_or (vector unsigned char, vector bool char);
16950 vector unsigned char vec_or (vector unsigned char, vector unsigned char);
16952 vector signed char vec_pack (vector signed short, vector signed short);
16953 vector unsigned char vec_pack (vector unsigned short, vector unsigned short);
16954 vector bool char vec_pack (vector bool short, vector bool short);
16955 vector signed short vec_pack (vector signed int, vector signed int);
16956 vector unsigned short vec_pack (vector unsigned int, vector unsigned int);
16957 vector bool short vec_pack (vector bool int, vector bool int);
16959 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
16961 vector unsigned char vec_packs (vector unsigned short, vector unsigned short);
16962 vector signed char vec_packs (vector signed short, vector signed short);
16963 vector unsigned short vec_packs (vector unsigned int, vector unsigned int);
16964 vector signed short vec_packs (vector signed int, vector signed int);
16966 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short);
16967 vector unsigned char vec_packsu (vector signed short, vector signed short);
16968 vector unsigned short vec_packsu (vector unsigned int, vector unsigned int);
16969 vector unsigned short vec_packsu (vector signed int, vector signed int);
16971 vector float vec_perm (vector float, vector float, vector unsigned char);
16972 vector signed int vec_perm (vector signed int, vector signed int, vector unsigned char);
16973 vector unsigned int vec_perm (vector unsigned int, vector unsigned int,
16974 vector unsigned char);
16975 vector bool int vec_perm (vector bool int, vector bool int, vector unsigned char);
16976 vector signed short vec_perm (vector signed short, vector signed short,
16977 vector unsigned char);
16978 vector unsigned short vec_perm (vector unsigned short, vector unsigned short,
16979 vector unsigned char);
16980 vector bool short vec_perm (vector bool short, vector bool short, vector unsigned char);
16981 vector pixel vec_perm (vector pixel, vector pixel, vector unsigned char);
16982 vector signed char vec_perm (vector signed char, vector signed char,
16983 vector unsigned char);
16984 vector unsigned char vec_perm (vector unsigned char, vector unsigned char,
16985 vector unsigned char);
16986 vector bool char vec_perm (vector bool char, vector bool char, vector unsigned char);
16988 vector float vec_re (vector float);
16990 vector bool char vec_reve (vector bool char);
16991 vector signed char vec_reve (vector signed char);
16992 vector unsigned char vec_reve (vector unsigned char);
16993 vector bool int vec_reve (vector bool int);
16994 vector signed int vec_reve (vector signed int);
16995 vector unsigned int vec_reve (vector unsigned int);
16996 vector bool short vec_reve (vector bool short);
16997 vector signed short vec_reve (vector signed short);
16998 vector unsigned short vec_reve (vector unsigned short);
17000 vector signed char vec_rl (vector signed char, vector unsigned char);
17001 vector unsigned char vec_rl (vector unsigned char, vector unsigned char);
17002 vector signed short vec_rl (vector signed short, vector unsigned short);
17003 vector unsigned short vec_rl (vector unsigned short, vector unsigned short);
17004 vector signed int vec_rl (vector signed int, vector unsigned int);
17005 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
17007 vector float vec_round (vector float);
17009 vector float vec_rsqrt (vector float);
17011 vector float vec_rsqrte (vector float);
17013 vector float vec_sel (vector float, vector float, vector bool int);
17014 vector float vec_sel (vector float, vector float, vector unsigned int);
17015 vector signed int vec_sel (vector signed int, vector signed int, vector bool int);
17016 vector signed int vec_sel (vector signed int, vector signed int, vector unsigned int);
17017 vector unsigned int vec_sel (vector unsigned int, vector unsigned int, vector bool int);
17018 vector unsigned int vec_sel (vector unsigned int, vector unsigned int,
17019 vector unsigned int);
17020 vector bool int vec_sel (vector bool int, vector bool int, vector bool int);
17021 vector bool int vec_sel (vector bool int, vector bool int, vector unsigned int);
17022 vector signed short vec_sel (vector signed short, vector signed short,
17023 vector bool short);
17024 vector signed short vec_sel (vector signed short, vector signed short,
17025 vector unsigned short);
17026 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
17027 vector bool short);
17028 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
17029 vector unsigned short);
17030 vector bool short vec_sel (vector bool short, vector bool short, vector bool short);
17031 vector bool short vec_sel (vector bool short, vector bool short, vector unsigned short);
17032 vector signed char vec_sel (vector signed char, vector signed char, vector bool char);
17033 vector signed char vec_sel (vector signed char, vector signed char,
17034 vector unsigned char);
17035 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
17037 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
17038 vector unsigned char);
17039 vector bool char vec_sel (vector bool char, vector bool char, vector bool char);
17040 vector bool char vec_sel (vector bool char, vector bool char, vector unsigned char);
17042 vector signed char vec_sl (vector signed char, vector unsigned char);
17043 vector unsigned char vec_sl (vector unsigned char, vector unsigned char);
17044 vector signed short vec_sl (vector signed short, vector unsigned short);
17045 vector unsigned short vec_sl (vector unsigned short, vector unsigned short);
17046 vector signed int vec_sl (vector signed int, vector unsigned int);
17047 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
17049 vector float vec_sld (vector float, vector float, const int);
17050 vector signed int vec_sld (vector signed int, vector signed int, const int);
17051 vector unsigned int vec_sld (vector unsigned int, vector unsigned int, const int);
17052 vector bool int vec_sld (vector bool int, vector bool int, const int);
17053 vector signed short vec_sld (vector signed short, vector signed short, const int);
17054 vector unsigned short vec_sld (vector unsigned short, vector unsigned short, const int);
17055 vector bool short vec_sld (vector bool short, vector bool short, const int);
17056 vector pixel vec_sld (vector pixel, vector pixel, const int);
17057 vector signed char vec_sld (vector signed char, vector signed char, const int);
17058 vector unsigned char vec_sld (vector unsigned char, vector unsigned char, const int);
17059 vector bool char vec_sld (vector bool char, vector bool char, const int);
17061 vector signed int vec_sll (vector signed int, vector unsigned int);
17062 vector signed int vec_sll (vector signed int, vector unsigned short);
17063 vector signed int vec_sll (vector signed int, vector unsigned char);
17064 vector unsigned int vec_sll (vector unsigned int, vector unsigned int);
17065 vector unsigned int vec_sll (vector unsigned int, vector unsigned short);
17066 vector unsigned int vec_sll (vector unsigned int, vector unsigned char);
17067 vector bool int vec_sll (vector bool int, vector unsigned int);
17068 vector bool int vec_sll (vector bool int, vector unsigned short);
17069 vector bool int vec_sll (vector bool int, vector unsigned char);
17070 vector signed short vec_sll (vector signed short, vector unsigned int);
17071 vector signed short vec_sll (vector signed short, vector unsigned short);
17072 vector signed short vec_sll (vector signed short, vector unsigned char);
17073 vector unsigned short vec_sll (vector unsigned short, vector unsigned int);
17074 vector unsigned short vec_sll (vector unsigned short, vector unsigned short);
17075 vector unsigned short vec_sll (vector unsigned short, vector unsigned char);
17076 vector bool short vec_sll (vector bool short, vector unsigned int);
17077 vector bool short vec_sll (vector bool short, vector unsigned short);
17078 vector bool short vec_sll (vector bool short, vector unsigned char);
17079 vector pixel vec_sll (vector pixel, vector unsigned int);
17080 vector pixel vec_sll (vector pixel, vector unsigned short);
17081 vector pixel vec_sll (vector pixel, vector unsigned char);
17082 vector signed char vec_sll (vector signed char, vector unsigned int);
17083 vector signed char vec_sll (vector signed char, vector unsigned short);
17084 vector signed char vec_sll (vector signed char, vector unsigned char);
17085 vector unsigned char vec_sll (vector unsigned char, vector unsigned int);
17086 vector unsigned char vec_sll (vector unsigned char, vector unsigned short);
17087 vector unsigned char vec_sll (vector unsigned char, vector unsigned char);
17088 vector bool char vec_sll (vector bool char, vector unsigned int);
17089 vector bool char vec_sll (vector bool char, vector unsigned short);
17090 vector bool char vec_sll (vector bool char, vector unsigned char);
17092 vector float vec_slo (vector float, vector signed char);
17093 vector float vec_slo (vector float, vector unsigned char);
17094 vector signed int vec_slo (vector signed int, vector signed char);
17095 vector signed int vec_slo (vector signed int, vector unsigned char);
17096 vector unsigned int vec_slo (vector unsigned int, vector signed char);
17097 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
17098 vector signed short vec_slo (vector signed short, vector signed char);
17099 vector signed short vec_slo (vector signed short, vector unsigned char);
17100 vector unsigned short vec_slo (vector unsigned short, vector signed char);
17101 vector unsigned short vec_slo (vector unsigned short, vector unsigned char);
17102 vector pixel vec_slo (vector pixel, vector signed char);
17103 vector pixel vec_slo (vector pixel, vector unsigned char);
17104 vector signed char vec_slo (vector signed char, vector signed char);
17105 vector signed char vec_slo (vector signed char, vector unsigned char);
17106 vector unsigned char vec_slo (vector unsigned char, vector signed char);
17107 vector unsigned char vec_slo (vector unsigned char, vector unsigned char);
17109 vector signed char vec_splat (vector signed char, const int);
17110 vector unsigned char vec_splat (vector unsigned char, const int);
17111 vector bool char vec_splat (vector bool char, const int);
17112 vector signed short vec_splat (vector signed short, const int);
17113 vector unsigned short vec_splat (vector unsigned short, const int);
17114 vector bool short vec_splat (vector bool short, const int);
17115 vector pixel vec_splat (vector pixel, const int);
17116 vector float vec_splat (vector float, const int);
17117 vector signed int vec_splat (vector signed int, const int);
17118 vector unsigned int vec_splat (vector unsigned int, const int);
17119 vector bool int vec_splat (vector bool int, const int);
17121 vector signed short vec_splat_s16 (const int);
17123 vector signed int vec_splat_s32 (const int);
17125 vector signed char vec_splat_s8 (const int);
17127 vector unsigned short vec_splat_u16 (const int);
17129 vector unsigned int vec_splat_u32 (const int);
17131 vector unsigned char vec_splat_u8 (const int);
17133 vector signed char vec_splats (signed char);
17134 vector unsigned char vec_splats (unsigned char);
17135 vector signed short vec_splats (signed short);
17136 vector unsigned short vec_splats (unsigned short);
17137 vector signed int vec_splats (signed int);
17138 vector unsigned int vec_splats (unsigned int);
17139 vector float vec_splats (float);
17141 vector signed char vec_sr (vector signed char, vector unsigned char);
17142 vector unsigned char vec_sr (vector unsigned char, vector unsigned char);
17143 vector signed short vec_sr (vector signed short, vector unsigned short);
17144 vector unsigned short vec_sr (vector unsigned short, vector unsigned short);
17145 vector signed int vec_sr (vector signed int, vector unsigned int);
17146 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
17148 vector signed char vec_sra (vector signed char, vector unsigned char);
17149 vector unsigned char vec_sra (vector unsigned char, vector unsigned char);
17150 vector signed short vec_sra (vector signed short, vector unsigned short);
17151 vector unsigned short vec_sra (vector unsigned short, vector unsigned short);
17152 vector signed int vec_sra (vector signed int, vector unsigned int);
17153 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
17155 vector signed int vec_srl (vector signed int, vector unsigned int);
17156 vector signed int vec_srl (vector signed int, vector unsigned short);
17157 vector signed int vec_srl (vector signed int, vector unsigned char);
17158 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
17159 vector unsigned int vec_srl (vector unsigned int, vector unsigned short);
17160 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
17161 vector bool int vec_srl (vector bool int, vector unsigned int);
17162 vector bool int vec_srl (vector bool int, vector unsigned short);
17163 vector bool int vec_srl (vector bool int, vector unsigned char);
17164 vector signed short vec_srl (vector signed short, vector unsigned int);
17165 vector signed short vec_srl (vector signed short, vector unsigned short);
17166 vector signed short vec_srl (vector signed short, vector unsigned char);
17167 vector unsigned short vec_srl (vector unsigned short, vector unsigned int);
17168 vector unsigned short vec_srl (vector unsigned short, vector unsigned short);
17169 vector unsigned short vec_srl (vector unsigned short, vector unsigned char);
17170 vector bool short vec_srl (vector bool short, vector unsigned int);
17171 vector bool short vec_srl (vector bool short, vector unsigned short);
17172 vector bool short vec_srl (vector bool short, vector unsigned char);
17173 vector pixel vec_srl (vector pixel, vector unsigned int);
17174 vector pixel vec_srl (vector pixel, vector unsigned short);
17175 vector pixel vec_srl (vector pixel, vector unsigned char);
17176 vector signed char vec_srl (vector signed char, vector unsigned int);
17177 vector signed char vec_srl (vector signed char, vector unsigned short);
17178 vector signed char vec_srl (vector signed char, vector unsigned char);
17179 vector unsigned char vec_srl (vector unsigned char, vector unsigned int);
17180 vector unsigned char vec_srl (vector unsigned char, vector unsigned short);
17181 vector unsigned char vec_srl (vector unsigned char, vector unsigned char);
17182 vector bool char vec_srl (vector bool char, vector unsigned int);
17183 vector bool char vec_srl (vector bool char, vector unsigned short);
17184 vector bool char vec_srl (vector bool char, vector unsigned char);
17186 vector float vec_sro (vector float, vector signed char);
17187 vector float vec_sro (vector float, vector unsigned char);
17188 vector signed int vec_sro (vector signed int, vector signed char);
17189 vector signed int vec_sro (vector signed int, vector unsigned char);
17190 vector unsigned int vec_sro (vector unsigned int, vector signed char);
17191 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
17192 vector signed short vec_sro (vector signed short, vector signed char);
17193 vector signed short vec_sro (vector signed short, vector unsigned char);
17194 vector unsigned short vec_sro (vector unsigned short, vector signed char);
17195 vector unsigned short vec_sro (vector unsigned short, vector unsigned char);
17196 vector pixel vec_sro (vector pixel, vector signed char);
17197 vector pixel vec_sro (vector pixel, vector unsigned char);
17198 vector signed char vec_sro (vector signed char, vector signed char);
17199 vector signed char vec_sro (vector signed char, vector unsigned char);
17200 vector unsigned char vec_sro (vector unsigned char, vector signed char);
17201 vector unsigned char vec_sro (vector unsigned char, vector unsigned char);
17203 void vec_st (vector float, int, vector float *);
17204 void vec_st (vector float, int, float *);
17205 void vec_st (vector signed int, int, vector signed int *);
17206 void vec_st (vector signed int, int, int *);
17207 void vec_st (vector unsigned int, int, vector unsigned int *);
17208 void vec_st (vector unsigned int, int, unsigned int *);
17209 void vec_st (vector bool int, int, vector bool int *);
17210 void vec_st (vector bool int, int, unsigned int *);
17211 void vec_st (vector bool int, int, int *);
17212 void vec_st (vector signed short, int, vector signed short *);
17213 void vec_st (vector signed short, int, short *);
17214 void vec_st (vector unsigned short, int, vector unsigned short *);
17215 void vec_st (vector unsigned short, int, unsigned short *);
17216 void vec_st (vector bool short, int, vector bool short *);
17217 void vec_st (vector bool short, int, unsigned short *);
17218 void vec_st (vector pixel, int, vector pixel *);
17219 void vec_st (vector bool short, int, short *);
17220 void vec_st (vector signed char, int, vector signed char *);
17221 void vec_st (vector signed char, int, signed char *);
17222 void vec_st (vector unsigned char, int, vector unsigned char *);
17223 void vec_st (vector unsigned char, int, unsigned char *);
17224 void vec_st (vector bool char, int, vector bool char *);
17225 void vec_st (vector bool char, int, unsigned char *);
17226 void vec_st (vector bool char, int, signed char *);
17228 void vec_ste (vector signed char, int, signed char *);
17229 void vec_ste (vector unsigned char, int, unsigned char *);
17230 void vec_ste (vector bool char, int, signed char *);
17231 void vec_ste (vector bool char, int, unsigned char *);
17232 void vec_ste (vector signed short, int, short *);
17233 void vec_ste (vector unsigned short, int, unsigned short *);
17234 void vec_ste (vector bool short, int, short *);
17235 void vec_ste (vector bool short, int, unsigned short *);
17236 void vec_ste (vector pixel, int, short *);
17237 void vec_ste (vector pixel, int, unsigned short *);
17238 void vec_ste (vector float, int, float *);
17239 void vec_ste (vector signed int, int, int *);
17240 void vec_ste (vector unsigned int, int, unsigned int *);
17241 void vec_ste (vector bool int, int, int *);
17242 void vec_ste (vector bool int, int, unsigned int *);
17244 void vec_stl (vector float, int, vector float *);
17245 void vec_stl (vector float, int, float *);
17246 void vec_stl (vector signed int, int, vector signed int *);
17247 void vec_stl (vector signed int, int, int *);
17248 void vec_stl (vector unsigned int, int, vector unsigned int *);
17249 void vec_stl (vector unsigned int, int, unsigned int *);
17250 void vec_stl (vector bool int, int, vector bool int *);
17251 void vec_stl (vector bool int, int, unsigned int *);
17252 void vec_stl (vector bool int, int, int *);
17253 void vec_stl (vector signed short, int, vector signed short *);
17254 void vec_stl (vector signed short, int, short *);
17255 void vec_stl (vector unsigned short, int, vector unsigned short *);
17256 void vec_stl (vector unsigned short, int, unsigned short *);
17257 void vec_stl (vector bool short, int, vector bool short *);
17258 void vec_stl (vector bool short, int, unsigned short *);
17259 void vec_stl (vector bool short, int, short *);
17260 void vec_stl (vector pixel, int, vector pixel *);
17261 void vec_stl (vector signed char, int, vector signed char *);
17262 void vec_stl (vector signed char, int, signed char *);
17263 void vec_stl (vector unsigned char, int, vector unsigned char *);
17264 void vec_stl (vector unsigned char, int, unsigned char *);
17265 void vec_stl (vector bool char, int, vector bool char *);
17266 void vec_stl (vector bool char, int, unsigned char *);
17267 void vec_stl (vector bool char, int, signed char *);
17269 void vec_stvebx (vector signed char, int, signed char *);
17270 void vec_stvebx (vector unsigned char, int, unsigned char *);
17271 void vec_stvebx (vector bool char, int, signed char *);
17272 void vec_stvebx (vector bool char, int, unsigned char *);
17274 void vec_stvehx (vector signed short, int, short *);
17275 void vec_stvehx (vector unsigned short, int, unsigned short *);
17276 void vec_stvehx (vector bool short, int, short *);
17277 void vec_stvehx (vector bool short, int, unsigned short *);
17279 void vec_stvewx (vector float, int, float *);
17280 void vec_stvewx (vector signed int, int, int *);
17281 void vec_stvewx (vector unsigned int, int, unsigned int *);
17282 void vec_stvewx (vector bool int, int, int *);
17283 void vec_stvewx (vector bool int, int, unsigned int *);
17285 vector signed char vec_sub (vector bool char, vector signed char);
17286 vector signed char vec_sub (vector signed char, vector bool char);
17287 vector signed char vec_sub (vector signed char, vector signed char);
17288 vector unsigned char vec_sub (vector bool char, vector unsigned char);
17289 vector unsigned char vec_sub (vector unsigned char, vector bool char);
17290 vector unsigned char vec_sub (vector unsigned char, vector unsigned char);
17291 vector signed short vec_sub (vector bool short, vector signed short);
17292 vector signed short vec_sub (vector signed short, vector bool short);
17293 vector signed short vec_sub (vector signed short, vector signed short);
17294 vector unsigned short vec_sub (vector bool short, vector unsigned short);
17295 vector unsigned short vec_sub (vector unsigned short, vector bool short);
17296 vector unsigned short vec_sub (vector unsigned short, vector unsigned short);
17297 vector signed int vec_sub (vector bool int, vector signed int);
17298 vector signed int vec_sub (vector signed int, vector bool int);
17299 vector signed int vec_sub (vector signed int, vector signed int);
17300 vector unsigned int vec_sub (vector bool int, vector unsigned int);
17301 vector unsigned int vec_sub (vector unsigned int, vector bool int);
17302 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
17303 vector float vec_sub (vector float, vector float);
17305 vector signed int vec_subc (vector signed int, vector signed int);
17306 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
17308 vector signed int vec_sube (vector signed int, vector signed int,
17309 vector signed int);
17310 vector unsigned int vec_sube (vector unsigned int, vector unsigned int,
17311 vector unsigned int);
17313 vector signed int vec_subec (vector signed int, vector signed int,
17314 vector signed int);
17315 vector unsigned int vec_subec (vector unsigned int, vector unsigned int,
17316 vector unsigned int);
17318 vector unsigned char vec_subs (vector bool char, vector unsigned char);
17319 vector unsigned char vec_subs (vector unsigned char, vector bool char);
17320 vector unsigned char vec_subs (vector unsigned char, vector unsigned char);
17321 vector signed char vec_subs (vector bool char, vector signed char);
17322 vector signed char vec_subs (vector signed char, vector bool char);
17323 vector signed char vec_subs (vector signed char, vector signed char);
17324 vector unsigned short vec_subs (vector bool short, vector unsigned short);
17325 vector unsigned short vec_subs (vector unsigned short, vector bool short);
17326 vector unsigned short vec_subs (vector unsigned short, vector unsigned short);
17327 vector signed short vec_subs (vector bool short, vector signed short);
17328 vector signed short vec_subs (vector signed short, vector bool short);
17329 vector signed short vec_subs (vector signed short, vector signed short);
17330 vector unsigned int vec_subs (vector bool int, vector unsigned int);
17331 vector unsigned int vec_subs (vector unsigned int, vector bool int);
17332 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
17333 vector signed int vec_subs (vector bool int, vector signed int);
17334 vector signed int vec_subs (vector signed int, vector bool int);
17335 vector signed int vec_subs (vector signed int, vector signed int);
17337 vector signed int vec_sum2s (vector signed int, vector signed int);
17339 vector unsigned int vec_sum4s (vector unsigned char, vector unsigned int);
17340 vector signed int vec_sum4s (vector signed char, vector signed int);
17341 vector signed int vec_sum4s (vector signed short, vector signed int);
17343 vector signed int vec_sums (vector signed int, vector signed int);
17345 vector float vec_trunc (vector float);
17347 vector signed short vec_unpackh (vector signed char);
17348 vector bool short vec_unpackh (vector bool char);
17349 vector signed int vec_unpackh (vector signed short);
17350 vector bool int vec_unpackh (vector bool short);
17351 vector unsigned int vec_unpackh (vector pixel);
17353 vector signed short vec_unpackl (vector signed char);
17354 vector bool short vec_unpackl (vector bool char);
17355 vector unsigned int vec_unpackl (vector pixel);
17356 vector signed int vec_unpackl (vector signed short);
17357 vector bool int vec_unpackl (vector bool short);
17359 vector float vec_vaddfp (vector float, vector float);
17361 vector signed char vec_vaddsbs (vector bool char, vector signed char);
17362 vector signed char vec_vaddsbs (vector signed char, vector bool char);
17363 vector signed char vec_vaddsbs (vector signed char, vector signed char);
17365 vector signed short vec_vaddshs (vector bool short, vector signed short);
17366 vector signed short vec_vaddshs (vector signed short, vector bool short);
17367 vector signed short vec_vaddshs (vector signed short, vector signed short);
17369 vector signed int vec_vaddsws (vector bool int, vector signed int);
17370 vector signed int vec_vaddsws (vector signed int, vector bool int);
17371 vector signed int vec_vaddsws (vector signed int, vector signed int);
17373 vector signed char vec_vaddubm (vector bool char, vector signed char);
17374 vector signed char vec_vaddubm (vector signed char, vector bool char);
17375 vector signed char vec_vaddubm (vector signed char, vector signed char);
17376 vector unsigned char vec_vaddubm (vector bool char, vector unsigned char);
17377 vector unsigned char vec_vaddubm (vector unsigned char, vector bool char);
17378 vector unsigned char vec_vaddubm (vector unsigned char, vector unsigned char);
17380 vector unsigned char vec_vaddubs (vector bool char, vector unsigned char);
17381 vector unsigned char vec_vaddubs (vector unsigned char, vector bool char);
17382 vector unsigned char vec_vaddubs (vector unsigned char, vector unsigned char);
17384 vector signed short vec_vadduhm (vector bool short, vector signed short);
17385 vector signed short vec_vadduhm (vector signed short, vector bool short);
17386 vector signed short vec_vadduhm (vector signed short, vector signed short);
17387 vector unsigned short vec_vadduhm (vector bool short, vector unsigned short);
17388 vector unsigned short vec_vadduhm (vector unsigned short, vector bool short);
17389 vector unsigned short vec_vadduhm (vector unsigned short, vector unsigned short);
17391 vector unsigned short vec_vadduhs (vector bool short, vector unsigned short);
17392 vector unsigned short vec_vadduhs (vector unsigned short, vector bool short);
17393 vector unsigned short vec_vadduhs (vector unsigned short, vector unsigned short);
17395 vector signed int vec_vadduwm (vector bool int, vector signed int);
17396 vector signed int vec_vadduwm (vector signed int, vector bool int);
17397 vector signed int vec_vadduwm (vector signed int, vector signed int);
17398 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
17399 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
17400 vector unsigned int vec_vadduwm (vector unsigned int, vector unsigned int);
17402 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
17403 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
17404 vector unsigned int vec_vadduws (vector unsigned int, vector unsigned int);
17406 vector signed char vec_vavgsb (vector signed char, vector signed char);
17408 vector signed short vec_vavgsh (vector signed short, vector signed short);
17410 vector signed int vec_vavgsw (vector signed int, vector signed int);
17412 vector unsigned char vec_vavgub (vector unsigned char, vector unsigned char);
17414 vector unsigned short vec_vavguh (vector unsigned short, vector unsigned short);
17416 vector unsigned int vec_vavguw (vector unsigned int, vector unsigned int);
17418 vector float vec_vcfsx (vector signed int, const int);
17420 vector float vec_vcfux (vector unsigned int, const int);
17422 vector bool int vec_vcmpeqfp (vector float, vector float);
17424 vector bool char vec_vcmpequb (vector signed char, vector signed char);
17425 vector bool char vec_vcmpequb (vector unsigned char, vector unsigned char);
17427 vector bool short vec_vcmpequh (vector signed short, vector signed short);
17428 vector bool short vec_vcmpequh (vector unsigned short, vector unsigned short);
17430 vector bool int vec_vcmpequw (vector signed int, vector signed int);
17431 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
17433 vector bool int vec_vcmpgtfp (vector float, vector float);
17435 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
17437 vector bool short vec_vcmpgtsh (vector signed short, vector signed short);
17439 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
17441 vector bool char vec_vcmpgtub (vector unsigned char, vector unsigned char);
17443 vector bool short vec_vcmpgtuh (vector unsigned short, vector unsigned short);
17445 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
17447 vector float vec_vmaxfp (vector float, vector float);
17449 vector signed char vec_vmaxsb (vector bool char, vector signed char);
17450 vector signed char vec_vmaxsb (vector signed char, vector bool char);
17451 vector signed char vec_vmaxsb (vector signed char, vector signed char);
17453 vector signed short vec_vmaxsh (vector bool short, vector signed short);
17454 vector signed short vec_vmaxsh (vector signed short, vector bool short);
17455 vector signed short vec_vmaxsh (vector signed short, vector signed short);
17457 vector signed int vec_vmaxsw (vector bool int, vector signed int);
17458 vector signed int vec_vmaxsw (vector signed int, vector bool int);
17459 vector signed int vec_vmaxsw (vector signed int, vector signed int);
17461 vector unsigned char vec_vmaxub (vector bool char, vector unsigned char);
17462 vector unsigned char vec_vmaxub (vector unsigned char, vector bool char);
17463 vector unsigned char vec_vmaxub (vector unsigned char, vector unsigned char);
17465 vector unsigned short vec_vmaxuh (vector bool short, vector unsigned short);
17466 vector unsigned short vec_vmaxuh (vector unsigned short, vector bool short);
17467 vector unsigned short vec_vmaxuh (vector unsigned short, vector unsigned short);
17469 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
17470 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
17471 vector unsigned int vec_vmaxuw (vector unsigned int, vector unsigned int);
17473 vector float vec_vminfp (vector float, vector float);
17475 vector signed char vec_vminsb (vector bool char, vector signed char);
17476 vector signed char vec_vminsb (vector signed char, vector bool char);
17477 vector signed char vec_vminsb (vector signed char, vector signed char);
17479 vector signed short vec_vminsh (vector bool short, vector signed short);
17480 vector signed short vec_vminsh (vector signed short, vector bool short);
17481 vector signed short vec_vminsh (vector signed short, vector signed short);
17483 vector signed int vec_vminsw (vector bool int, vector signed int);
17484 vector signed int vec_vminsw (vector signed int, vector bool int);
17485 vector signed int vec_vminsw (vector signed int, vector signed int);
17487 vector unsigned char vec_vminub (vector bool char, vector unsigned char);
17488 vector unsigned char vec_vminub (vector unsigned char, vector bool char);
17489 vector unsigned char vec_vminub (vector unsigned char, vector unsigned char);
17491 vector unsigned short vec_vminuh (vector bool short, vector unsigned short);
17492 vector unsigned short vec_vminuh (vector unsigned short, vector bool short);
17493 vector unsigned short vec_vminuh (vector unsigned short, vector unsigned short);
17495 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
17496 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
17497 vector unsigned int vec_vminuw (vector unsigned int, vector unsigned int);
17499 vector bool char vec_vmrghb (vector bool char, vector bool char);
17500 vector signed char vec_vmrghb (vector signed char, vector signed char);
17501 vector unsigned char vec_vmrghb (vector unsigned char, vector unsigned char);
17503 vector bool short vec_vmrghh (vector bool short, vector bool short);
17504 vector signed short vec_vmrghh (vector signed short, vector signed short);
17505 vector unsigned short vec_vmrghh (vector unsigned short, vector unsigned short);
17506 vector pixel vec_vmrghh (vector pixel, vector pixel);
17508 vector float vec_vmrghw (vector float, vector float);
17509 vector bool int vec_vmrghw (vector bool int, vector bool int);
17510 vector signed int vec_vmrghw (vector signed int, vector signed int);
17511 vector unsigned int vec_vmrghw (vector unsigned int, vector unsigned int);
17513 vector bool char vec_vmrglb (vector bool char, vector bool char);
17514 vector signed char vec_vmrglb (vector signed char, vector signed char);
17515 vector unsigned char vec_vmrglb (vector unsigned char, vector unsigned char);
17517 vector bool short vec_vmrglh (vector bool short, vector bool short);
17518 vector signed short vec_vmrglh (vector signed short, vector signed short);
17519 vector unsigned short vec_vmrglh (vector unsigned short, vector unsigned short);
17520 vector pixel vec_vmrglh (vector pixel, vector pixel);
17522 vector float vec_vmrglw (vector float, vector float);
17523 vector signed int vec_vmrglw (vector signed int, vector signed int);
17524 vector unsigned int vec_vmrglw (vector unsigned int, vector unsigned int);
17525 vector bool int vec_vmrglw (vector bool int, vector bool int);
17527 vector signed int vec_vmsummbm (vector signed char, vector unsigned char,
17528 vector signed int);
17530 vector signed int vec_vmsumshm (vector signed short, vector signed short,
17531 vector signed int);
17533 vector signed int vec_vmsumshs (vector signed short, vector signed short,
17534 vector signed int);
17536 vector unsigned int vec_vmsumubm (vector unsigned char, vector unsigned char,
17537 vector unsigned int);
17539 vector unsigned int vec_vmsumuhm (vector unsigned short, vector unsigned short,
17540 vector unsigned int);
17542 vector unsigned int vec_vmsumuhs (vector unsigned short, vector unsigned short,
17543 vector unsigned int);
17545 vector signed short vec_vmulesb (vector signed char, vector signed char);
17547 vector signed int vec_vmulesh (vector signed short, vector signed short);
17549 vector unsigned short vec_vmuleub (vector unsigned char, vector unsigned char);
17551 vector unsigned int vec_vmuleuh (vector unsigned short, vector unsigned short);
17553 vector signed short vec_vmulosb (vector signed char, vector signed char);
17555 vector signed int vec_vmulosh (vector signed short, vector signed short);
17557 vector unsigned short vec_vmuloub (vector unsigned char, vector unsigned char);
17559 vector unsigned int vec_vmulouh (vector unsigned short, vector unsigned short);
17561 vector signed char vec_vpkshss (vector signed short, vector signed short);
17563 vector unsigned char vec_vpkshus (vector signed short, vector signed short);
17565 vector signed short vec_vpkswss (vector signed int, vector signed int);
17567 vector unsigned short vec_vpkswus (vector signed int, vector signed int);
17569 vector bool char vec_vpkuhum (vector bool short, vector bool short);
17570 vector signed char vec_vpkuhum (vector signed short, vector signed short);
17571 vector unsigned char vec_vpkuhum (vector unsigned short, vector unsigned short);
17573 vector unsigned char vec_vpkuhus (vector unsigned short, vector unsigned short);
17575 vector bool short vec_vpkuwum (vector bool int, vector bool int);
17576 vector signed short vec_vpkuwum (vector signed int, vector signed int);
17577 vector unsigned short vec_vpkuwum (vector unsigned int, vector unsigned int);
17579 vector unsigned short vec_vpkuwus (vector unsigned int, vector unsigned int);
17581 vector signed char vec_vrlb (vector signed char, vector unsigned char);
17582 vector unsigned char vec_vrlb (vector unsigned char, vector unsigned char);
17584 vector signed short vec_vrlh (vector signed short, vector unsigned short);
17585 vector unsigned short vec_vrlh (vector unsigned short, vector unsigned short);
17587 vector signed int vec_vrlw (vector signed int, vector unsigned int);
17588 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
17590 vector signed char vec_vslb (vector signed char, vector unsigned char);
17591 vector unsigned char vec_vslb (vector unsigned char, vector unsigned char);
17593 vector signed short vec_vslh (vector signed short, vector unsigned short);
17594 vector unsigned short vec_vslh (vector unsigned short, vector unsigned short);
17596 vector signed int vec_vslw (vector signed int, vector unsigned int);
17597 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
17599 vector signed char vec_vspltb (vector signed char, const int);
17600 vector unsigned char vec_vspltb (vector unsigned char, const int);
17601 vector bool char vec_vspltb (vector bool char, const int);
17603 vector bool short vec_vsplth (vector bool short, const int);
17604 vector signed short vec_vsplth (vector signed short, const int);
17605 vector unsigned short vec_vsplth (vector unsigned short, const int);
17606 vector pixel vec_vsplth (vector pixel, const int);
17608 vector float vec_vspltw (vector float, const int);
17609 vector signed int vec_vspltw (vector signed int, const int);
17610 vector unsigned int vec_vspltw (vector unsigned int, const int);
17611 vector bool int vec_vspltw (vector bool int, const int);
17613 vector signed char vec_vsrab (vector signed char, vector unsigned char);
17614 vector unsigned char vec_vsrab (vector unsigned char, vector unsigned char);
17616 vector signed short vec_vsrah (vector signed short, vector unsigned short);
17617 vector unsigned short vec_vsrah (vector unsigned short, vector unsigned short);
17619 vector signed int vec_vsraw (vector signed int, vector unsigned int);
17620 vector unsigned int vec_vsraw (vector unsigned int, vector unsigned int);
17622 vector signed char vec_vsrb (vector signed char, vector unsigned char);
17623 vector unsigned char vec_vsrb (vector unsigned char, vector unsigned char);
17625 vector signed short vec_vsrh (vector signed short, vector unsigned short);
17626 vector unsigned short vec_vsrh (vector unsigned short, vector unsigned short);
17628 vector signed int vec_vsrw (vector signed int, vector unsigned int);
17629 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
17631 vector float vec_vsubfp (vector float, vector float);
17633 vector signed char vec_vsubsbs (vector bool char, vector signed char);
17634 vector signed char vec_vsubsbs (vector signed char, vector bool char);
17635 vector signed char vec_vsubsbs (vector signed char, vector signed char);
17637 vector signed short vec_vsubshs (vector bool short, vector signed short);
17638 vector signed short vec_vsubshs (vector signed short, vector bool short);
17639 vector signed short vec_vsubshs (vector signed short, vector signed short);
17641 vector signed int vec_vsubsws (vector bool int, vector signed int);
17642 vector signed int vec_vsubsws (vector signed int, vector bool int);
17643 vector signed int vec_vsubsws (vector signed int, vector signed int);
17645 vector signed char vec_vsububm (vector bool char, vector signed char);
17646 vector signed char vec_vsububm (vector signed char, vector bool char);
17647 vector signed char vec_vsububm (vector signed char, vector signed char);
17648 vector unsigned char vec_vsububm (vector bool char, vector unsigned char);
17649 vector unsigned char vec_vsububm (vector unsigned char, vector bool char);
17650 vector unsigned char vec_vsububm (vector unsigned char, vector unsigned char);
17652 vector unsigned char vec_vsububs (vector bool char, vector unsigned char);
17653 vector unsigned char vec_vsububs (vector unsigned char, vector bool char);
17654 vector unsigned char vec_vsububs (vector unsigned char, vector unsigned char);
17656 vector signed short vec_vsubuhm (vector bool short, vector signed short);
17657 vector signed short vec_vsubuhm (vector signed short, vector bool short);
17658 vector signed short vec_vsubuhm (vector signed short, vector signed short);
17659 vector unsigned short vec_vsubuhm (vector bool short, vector unsigned short);
17660 vector unsigned short vec_vsubuhm (vector unsigned short, vector bool short);
17661 vector unsigned short vec_vsubuhm (vector unsigned short, vector unsigned short);
17663 vector unsigned short vec_vsubuhs (vector bool short, vector unsigned short);
17664 vector unsigned short vec_vsubuhs (vector unsigned short, vector bool short);
17665 vector unsigned short vec_vsubuhs (vector unsigned short, vector unsigned short);
17667 vector signed int vec_vsubuwm (vector bool int, vector signed int);
17668 vector signed int vec_vsubuwm (vector signed int, vector bool int);
17669 vector signed int vec_vsubuwm (vector signed int, vector signed int);
17670 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
17671 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
17672 vector unsigned int vec_vsubuwm (vector unsigned int, vector unsigned int);
17674 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
17675 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
17676 vector unsigned int vec_vsubuws (vector unsigned int, vector unsigned int);
17678 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
17680 vector signed int vec_vsum4shs (vector signed short, vector signed int);
17682 vector unsigned int vec_vsum4ubs (vector unsigned char, vector unsigned int);
17684 vector unsigned int vec_vupkhpx (vector pixel);
17686 vector bool short vec_vupkhsb (vector bool char);
17687 vector signed short vec_vupkhsb (vector signed char);
17689 vector bool int vec_vupkhsh (vector bool short);
17690 vector signed int vec_vupkhsh (vector signed short);
17692 vector unsigned int vec_vupklpx (vector pixel);
17694 vector bool short vec_vupklsb (vector bool char);
17695 vector signed short vec_vupklsb (vector signed char);
17697 vector bool int vec_vupklsh (vector bool short);
17698 vector signed int vec_vupklsh (vector signed short);
17700 vector float vec_xor (vector float, vector float);
17701 vector float vec_xor (vector float, vector bool int);
17702 vector float vec_xor (vector bool int, vector float);
17703 vector bool int vec_xor (vector bool int, vector bool int);
17704 vector signed int vec_xor (vector bool int, vector signed int);
17705 vector signed int vec_xor (vector signed int, vector bool int);
17706 vector signed int vec_xor (vector signed int, vector signed int);
17707 vector unsigned int vec_xor (vector bool int, vector unsigned int);
17708 vector unsigned int vec_xor (vector unsigned int, vector bool int);
17709 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
17710 vector bool short vec_xor (vector bool short, vector bool short);
17711 vector signed short vec_xor (vector bool short, vector signed short);
17712 vector signed short vec_xor (vector signed short, vector bool short);
17713 vector signed short vec_xor (vector signed short, vector signed short);
17714 vector unsigned short vec_xor (vector bool short, vector unsigned short);
17715 vector unsigned short vec_xor (vector unsigned short, vector bool short);
17716 vector unsigned short vec_xor (vector unsigned short, vector unsigned short);
17717 vector signed char vec_xor (vector bool char, vector signed char);
17718 vector bool char vec_xor (vector bool char, vector bool char);
17719 vector signed char vec_xor (vector signed char, vector bool char);
17720 vector signed char vec_xor (vector signed char, vector signed char);
17721 vector unsigned char vec_xor (vector bool char, vector unsigned char);
17722 vector unsigned char vec_xor (vector unsigned char, vector bool char);
17723 vector unsigned char vec_xor (vector unsigned char, vector unsigned char);
17726 @node PowerPC AltiVec Built-in Functions Available on ISA 2.06
17727 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.06
17729 The AltiVec built-in functions described in this section are
17730 available on the PowerPC family of processors starting with ISA 2.06
17731 or later. These are normally enabled by adding @option{-mvsx} to the
17734 When @option{-mvsx} is used, the following additional vector types are
17738 vector unsigned __int128
17739 vector signed __int128
17740 vector unsigned long long int
17741 vector signed long long int
17745 The long long types are only implemented for 64-bit code generation.
17749 vector bool long long vec_and (vector bool long long int, vector bool long long);
17751 vector double vec_ctf (vector unsigned long, const int);
17752 vector double vec_ctf (vector signed long, const int);
17754 vector signed long vec_cts (vector double, const int);
17756 vector unsigned long vec_ctu (vector double, const int);
17758 void vec_dst (const unsigned long *, int, const int);
17759 void vec_dst (const long *, int, const int);
17761 void vec_dststt (const unsigned long *, int, const int);
17762 void vec_dststt (const long *, int, const int);
17764 void vec_dstt (const unsigned long *, int, const int);
17765 void vec_dstt (const long *, int, const int);
17767 vector unsigned char vec_lvsl (int, const unsigned long *);
17768 vector unsigned char vec_lvsl (int, const long *);
17770 vector unsigned char vec_lvsr (int, const unsigned long *);
17771 vector unsigned char vec_lvsr (int, const long *);
17773 vector double vec_mul (vector double, vector double);
17774 vector long vec_mul (vector long, vector long);
17775 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
17777 vector unsigned long long vec_mule (vector unsigned int, vector unsigned int);
17778 vector signed long long vec_mule (vector signed int, vector signed int);
17780 vector unsigned long long vec_mulo (vector unsigned int, vector unsigned int);
17781 vector signed long long vec_mulo (vector signed int, vector signed int);
17783 vector double vec_nabs (vector double);
17785 vector bool long long vec_reve (vector bool long long);
17786 vector signed long long vec_reve (vector signed long long);
17787 vector unsigned long long vec_reve (vector unsigned long long);
17788 vector double vec_sld (vector double, vector double, const int);
17790 vector bool long long int vec_sld (vector bool long long int,
17791 vector bool long long int, const int);
17792 vector long long int vec_sld (vector long long int, vector long long int, const int);
17793 vector unsigned long long int vec_sld (vector unsigned long long int,
17794 vector unsigned long long int, const int);
17796 vector long long int vec_sll (vector long long int, vector unsigned char);
17797 vector unsigned long long int vec_sll (vector unsigned long long int,
17798 vector unsigned char);
17800 vector signed long long vec_slo (vector signed long long, vector signed char);
17801 vector signed long long vec_slo (vector signed long long, vector unsigned char);
17802 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
17803 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
17805 vector signed long vec_splat (vector signed long, const int);
17806 vector unsigned long vec_splat (vector unsigned long, const int);
17808 vector long long int vec_srl (vector long long int, vector unsigned char);
17809 vector unsigned long long int vec_srl (vector unsigned long long int,
17810 vector unsigned char);
17812 vector long long int vec_sro (vector long long int, vector char);
17813 vector long long int vec_sro (vector long long int, vector unsigned char);
17814 vector unsigned long long int vec_sro (vector unsigned long long int, vector char);
17815 vector unsigned long long int vec_sro (vector unsigned long long int,
17816 vector unsigned char);
17818 vector signed __int128 vec_subc (vector signed __int128, vector signed __int128);
17819 vector unsigned __int128 vec_subc (vector unsigned __int128, vector unsigned __int128);
17821 vector signed __int128 vec_sube (vector signed __int128, vector signed __int128,
17822 vector signed __int128);
17823 vector unsigned __int128 vec_sube (vector unsigned __int128, vector unsigned __int128,
17824 vector unsigned __int128);
17826 vector signed __int128 vec_subec (vector signed __int128, vector signed __int128,
17827 vector signed __int128);
17828 vector unsigned __int128 vec_subec (vector unsigned __int128, vector unsigned __int128,
17829 vector unsigned __int128);
17831 vector double vec_unpackh (vector float);
17833 vector double vec_unpackl (vector float);
17835 vector double vec_doublee (vector float);
17836 vector double vec_doublee (vector signed int);
17837 vector double vec_doublee (vector unsigned int);
17839 vector double vec_doubleo (vector float);
17840 vector double vec_doubleo (vector signed int);
17841 vector double vec_doubleo (vector unsigned int);
17843 vector double vec_doubleh (vector float);
17844 vector double vec_doubleh (vector signed int);
17845 vector double vec_doubleh (vector unsigned int);
17847 vector double vec_doublel (vector float);
17848 vector double vec_doublel (vector signed int);
17849 vector double vec_doublel (vector unsigned int);
17851 vector float vec_float (vector signed int);
17852 vector float vec_float (vector unsigned int);
17854 vector float vec_float2 (vector signed long long, vector signed long long);
17855 vector float vec_float2 (vector unsigned long long, vector signed long long);
17857 vector float vec_floate (vector double);
17858 vector float vec_floate (vector signed long long);
17859 vector float vec_floate (vector unsigned long long);
17861 vector float vec_floato (vector double);
17862 vector float vec_floato (vector signed long long);
17863 vector float vec_floato (vector unsigned long long);
17865 vector signed long long vec_signed (vector double);
17866 vector signed int vec_signed (vector float);
17868 vector signed int vec_signede (vector double);
17870 vector signed int vec_signedo (vector double);
17872 vector signed char vec_sldw (vector signed char, vector signed char, const int);
17873 vector unsigned char vec_sldw (vector unsigned char, vector unsigned char, const int);
17874 vector signed short vec_sldw (vector signed short, vector signed short, const int);
17875 vector unsigned short vec_sldw (vector unsigned short,
17876 vector unsigned short, const int);
17877 vector signed int vec_sldw (vector signed int, vector signed int, const int);
17878 vector unsigned int vec_sldw (vector unsigned int, vector unsigned int, const int);
17879 vector signed long long vec_sldw (vector signed long long,
17880 vector signed long long, const int);
17881 vector unsigned long long vec_sldw (vector unsigned long long,
17882 vector unsigned long long, const int);
17884 vector signed long long vec_unsigned (vector double);
17885 vector signed int vec_unsigned (vector float);
17887 vector signed int vec_unsignede (vector double);
17889 vector signed int vec_unsignedo (vector double);
17891 vector double vec_abs (vector double);
17892 vector double vec_add (vector double, vector double);
17893 vector double vec_and (vector double, vector double);
17894 vector double vec_and (vector double, vector bool long);
17895 vector double vec_and (vector bool long, vector double);
17896 vector long vec_and (vector long, vector long);
17897 vector long vec_and (vector long, vector bool long);
17898 vector long vec_and (vector bool long, vector long);
17899 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
17900 vector unsigned long vec_and (vector unsigned long, vector bool long);
17901 vector unsigned long vec_and (vector bool long, vector unsigned long);
17902 vector double vec_andc (vector double, vector double);
17903 vector double vec_andc (vector double, vector bool long);
17904 vector double vec_andc (vector bool long, vector double);
17905 vector long vec_andc (vector long, vector long);
17906 vector long vec_andc (vector long, vector bool long);
17907 vector long vec_andc (vector bool long, vector long);
17908 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
17909 vector unsigned long vec_andc (vector unsigned long, vector bool long);
17910 vector unsigned long vec_andc (vector bool long, vector unsigned long);
17911 vector double vec_ceil (vector double);
17912 vector bool long vec_cmpeq (vector double, vector double);
17913 vector bool long vec_cmpge (vector double, vector double);
17914 vector bool long vec_cmpgt (vector double, vector double);
17915 vector bool long vec_cmple (vector double, vector double);
17916 vector bool long vec_cmplt (vector double, vector double);
17917 vector double vec_cpsgn (vector double, vector double);
17918 vector float vec_div (vector float, vector float);
17919 vector double vec_div (vector double, vector double);
17920 vector long vec_div (vector long, vector long);
17921 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
17922 vector double vec_floor (vector double);
17923 vector __int128 vec_ld (int, const vector __int128 *);
17924 vector unsigned __int128 vec_ld (int, const vector unsigned __int128 *);
17925 vector __int128 vec_ld (int, const __int128 *);
17926 vector unsigned __int128 vec_ld (int, const unsigned __int128 *);
17927 vector double vec_ld (int, const vector double *);
17928 vector double vec_ld (int, const double *);
17929 vector double vec_ldl (int, const vector double *);
17930 vector double vec_ldl (int, const double *);
17931 vector unsigned char vec_lvsl (int, const double *);
17932 vector unsigned char vec_lvsr (int, const double *);
17933 vector double vec_madd (vector double, vector double, vector double);
17934 vector double vec_max (vector double, vector double);
17935 vector signed long vec_mergeh (vector signed long, vector signed long);
17936 vector signed long vec_mergeh (vector signed long, vector bool long);
17937 vector signed long vec_mergeh (vector bool long, vector signed long);
17938 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
17939 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
17940 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
17941 vector signed long vec_mergel (vector signed long, vector signed long);
17942 vector signed long vec_mergel (vector signed long, vector bool long);
17943 vector signed long vec_mergel (vector bool long, vector signed long);
17944 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
17945 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
17946 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
17947 vector double vec_min (vector double, vector double);
17948 vector float vec_msub (vector float, vector float, vector float);
17949 vector double vec_msub (vector double, vector double, vector double);
17950 vector float vec_nearbyint (vector float);
17951 vector double vec_nearbyint (vector double);
17952 vector float vec_nmadd (vector float, vector float, vector float);
17953 vector double vec_nmadd (vector double, vector double, vector double);
17954 vector double vec_nmsub (vector double, vector double, vector double);
17955 vector double vec_nor (vector double, vector double);
17956 vector long vec_nor (vector long, vector long);
17957 vector long vec_nor (vector long, vector bool long);
17958 vector long vec_nor (vector bool long, vector long);
17959 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
17960 vector unsigned long vec_nor (vector unsigned long, vector bool long);
17961 vector unsigned long vec_nor (vector bool long, vector unsigned long);
17962 vector double vec_or (vector double, vector double);
17963 vector double vec_or (vector double, vector bool long);
17964 vector double vec_or (vector bool long, vector double);
17965 vector long vec_or (vector long, vector long);
17966 vector long vec_or (vector long, vector bool long);
17967 vector long vec_or (vector bool long, vector long);
17968 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
17969 vector unsigned long vec_or (vector unsigned long, vector bool long);
17970 vector unsigned long vec_or (vector bool long, vector unsigned long);
17971 vector double vec_perm (vector double, vector double, vector unsigned char);
17972 vector long vec_perm (vector long, vector long, vector unsigned char);
17973 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
17974 vector unsigned char);
17975 vector bool char vec_permxor (vector bool char, vector bool char,
17977 vector unsigned char vec_permxor (vector signed char, vector signed char,
17978 vector signed char);
17979 vector unsigned char vec_permxor (vector unsigned char, vector unsigned char,
17980 vector unsigned char);
17981 vector double vec_rint (vector double);
17982 vector double vec_recip (vector double, vector double);
17983 vector double vec_rsqrt (vector double);
17984 vector double vec_rsqrte (vector double);
17985 vector double vec_sel (vector double, vector double, vector bool long);
17986 vector double vec_sel (vector double, vector double, vector unsigned long);
17987 vector long vec_sel (vector long, vector long, vector long);
17988 vector long vec_sel (vector long, vector long, vector unsigned long);
17989 vector long vec_sel (vector long, vector long, vector bool long);
17990 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17992 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17993 vector unsigned long);
17994 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17996 vector double vec_splats (double);
17997 vector signed long vec_splats (signed long);
17998 vector unsigned long vec_splats (unsigned long);
17999 vector float vec_sqrt (vector float);
18000 vector double vec_sqrt (vector double);
18001 void vec_st (vector double, int, vector double *);
18002 void vec_st (vector double, int, double *);
18003 vector double vec_sub (vector double, vector double);
18004 vector double vec_trunc (vector double);
18005 vector double vec_xl (int, vector double *);
18006 vector double vec_xl (int, double *);
18007 vector long long vec_xl (int, vector long long *);
18008 vector long long vec_xl (int, long long *);
18009 vector unsigned long long vec_xl (int, vector unsigned long long *);
18010 vector unsigned long long vec_xl (int, unsigned long long *);
18011 vector float vec_xl (int, vector float *);
18012 vector float vec_xl (int, float *);
18013 vector int vec_xl (int, vector int *);
18014 vector int vec_xl (int, int *);
18015 vector unsigned int vec_xl (int, vector unsigned int *);
18016 vector unsigned int vec_xl (int, unsigned int *);
18017 vector double vec_xor (vector double, vector double);
18018 vector double vec_xor (vector double, vector bool long);
18019 vector double vec_xor (vector bool long, vector double);
18020 vector long vec_xor (vector long, vector long);
18021 vector long vec_xor (vector long, vector bool long);
18022 vector long vec_xor (vector bool long, vector long);
18023 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
18024 vector unsigned long vec_xor (vector unsigned long, vector bool long);
18025 vector unsigned long vec_xor (vector bool long, vector unsigned long);
18026 void vec_xst (vector double, int, vector double *);
18027 void vec_xst (vector double, int, double *);
18028 void vec_xst (vector long long, int, vector long long *);
18029 void vec_xst (vector long long, int, long long *);
18030 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
18031 void vec_xst (vector unsigned long long, int, unsigned long long *);
18032 void vec_xst (vector float, int, vector float *);
18033 void vec_xst (vector float, int, float *);
18034 void vec_xst (vector int, int, vector int *);
18035 void vec_xst (vector int, int, int *);
18036 void vec_xst (vector unsigned int, int, vector unsigned int *);
18037 void vec_xst (vector unsigned int, int, unsigned int *);
18038 int vec_all_eq (vector double, vector double);
18039 int vec_all_ge (vector double, vector double);
18040 int vec_all_gt (vector double, vector double);
18041 int vec_all_le (vector double, vector double);
18042 int vec_all_lt (vector double, vector double);
18043 int vec_all_nan (vector double);
18044 int vec_all_ne (vector double, vector double);
18045 int vec_all_nge (vector double, vector double);
18046 int vec_all_ngt (vector double, vector double);
18047 int vec_all_nle (vector double, vector double);
18048 int vec_all_nlt (vector double, vector double);
18049 int vec_all_numeric (vector double);
18050 int vec_any_eq (vector double, vector double);
18051 int vec_any_ge (vector double, vector double);
18052 int vec_any_gt (vector double, vector double);
18053 int vec_any_le (vector double, vector double);
18054 int vec_any_lt (vector double, vector double);
18055 int vec_any_nan (vector double);
18056 int vec_any_ne (vector double, vector double);
18057 int vec_any_nge (vector double, vector double);
18058 int vec_any_ngt (vector double, vector double);
18059 int vec_any_nle (vector double, vector double);
18060 int vec_any_nlt (vector double, vector double);
18061 int vec_any_numeric (vector double);
18063 vector double vec_vsx_ld (int, const vector double *);
18064 vector double vec_vsx_ld (int, const double *);
18065 vector float vec_vsx_ld (int, const vector float *);
18066 vector float vec_vsx_ld (int, const float *);
18067 vector bool int vec_vsx_ld (int, const vector bool int *);
18068 vector signed int vec_vsx_ld (int, const vector signed int *);
18069 vector signed int vec_vsx_ld (int, const int *);
18070 vector signed int vec_vsx_ld (int, const long *);
18071 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
18072 vector unsigned int vec_vsx_ld (int, const unsigned int *);
18073 vector unsigned int vec_vsx_ld (int, const unsigned long *);
18074 vector bool short vec_vsx_ld (int, const vector bool short *);
18075 vector pixel vec_vsx_ld (int, const vector pixel *);
18076 vector signed short vec_vsx_ld (int, const vector signed short *);
18077 vector signed short vec_vsx_ld (int, const short *);
18078 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
18079 vector unsigned short vec_vsx_ld (int, const unsigned short *);
18080 vector bool char vec_vsx_ld (int, const vector bool char *);
18081 vector signed char vec_vsx_ld (int, const vector signed char *);
18082 vector signed char vec_vsx_ld (int, const signed char *);
18083 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
18084 vector unsigned char vec_vsx_ld (int, const unsigned char *);
18086 void vec_vsx_st (vector double, int, vector double *);
18087 void vec_vsx_st (vector double, int, double *);
18088 void vec_vsx_st (vector float, int, vector float *);
18089 void vec_vsx_st (vector float, int, float *);
18090 void vec_vsx_st (vector signed int, int, vector signed int *);
18091 void vec_vsx_st (vector signed int, int, int *);
18092 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
18093 void vec_vsx_st (vector unsigned int, int, unsigned int *);
18094 void vec_vsx_st (vector bool int, int, vector bool int *);
18095 void vec_vsx_st (vector bool int, int, unsigned int *);
18096 void vec_vsx_st (vector bool int, int, int *);
18097 void vec_vsx_st (vector signed short, int, vector signed short *);
18098 void vec_vsx_st (vector signed short, int, short *);
18099 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
18100 void vec_vsx_st (vector unsigned short, int, unsigned short *);
18101 void vec_vsx_st (vector bool short, int, vector bool short *);
18102 void vec_vsx_st (vector bool short, int, unsigned short *);
18103 void vec_vsx_st (vector pixel, int, vector pixel *);
18104 void vec_vsx_st (vector pixel, int, unsigned short *);
18105 void vec_vsx_st (vector pixel, int, short *);
18106 void vec_vsx_st (vector bool short, int, short *);
18107 void vec_vsx_st (vector signed char, int, vector signed char *);
18108 void vec_vsx_st (vector signed char, int, signed char *);
18109 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
18110 void vec_vsx_st (vector unsigned char, int, unsigned char *);
18111 void vec_vsx_st (vector bool char, int, vector bool char *);
18112 void vec_vsx_st (vector bool char, int, unsigned char *);
18113 void vec_vsx_st (vector bool char, int, signed char *);
18115 vector double vec_xxpermdi (vector double, vector double, const int);
18116 vector float vec_xxpermdi (vector float, vector float, const int);
18117 vector long long vec_xxpermdi (vector long long, vector long long, const int);
18118 vector unsigned long long vec_xxpermdi (vector unsigned long long,
18119 vector unsigned long long, const int);
18120 vector int vec_xxpermdi (vector int, vector int, const int);
18121 vector unsigned int vec_xxpermdi (vector unsigned int,
18122 vector unsigned int, const int);
18123 vector short vec_xxpermdi (vector short, vector short, const int);
18124 vector unsigned short vec_xxpermdi (vector unsigned short,
18125 vector unsigned short, const int);
18126 vector signed char vec_xxpermdi (vector signed char, vector signed char,
18128 vector unsigned char vec_xxpermdi (vector unsigned char,
18129 vector unsigned char, const int);
18131 vector double vec_xxsldi (vector double, vector double, int);
18132 vector float vec_xxsldi (vector float, vector float, int);
18133 vector long long vec_xxsldi (vector long long, vector long long, int);
18134 vector unsigned long long vec_xxsldi (vector unsigned long long,
18135 vector unsigned long long, int);
18136 vector int vec_xxsldi (vector int, vector int, int);
18137 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
18138 vector short vec_xxsldi (vector short, vector short, int);
18139 vector unsigned short vec_xxsldi (vector unsigned short,
18140 vector unsigned short, int);
18141 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
18142 vector unsigned char vec_xxsldi (vector unsigned char,
18143 vector unsigned char, int);
18146 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
18147 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
18148 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
18149 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
18150 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
18152 @node PowerPC AltiVec Built-in Functions Available on ISA 2.07
18153 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.07
18155 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18156 instruction set are available, the following additional functions are
18157 available for both 32-bit and 64-bit targets. For 64-bit targets, you
18158 can use @var{vector long} instead of @var{vector long long},
18159 @var{vector bool long} instead of @var{vector bool long long}, and
18160 @var{vector unsigned long} instead of @var{vector unsigned long long}.
18163 vector signed char vec_neg (vector signed char);
18164 vector signed short vec_neg (vector signed short);
18165 vector signed int vec_neg (vector signed int);
18166 vector signed long long vec_neg (vector signed long long);
18167 vector float char vec_neg (vector float);
18168 vector double vec_neg (vector double);
18170 vector signed int vec_signed2 (vector double, vector double);
18172 vector signed int vec_unsigned2 (vector double, vector double);
18174 vector long long vec_abs (vector long long);
18176 vector long long vec_add (vector long long, vector long long);
18177 vector unsigned long long vec_add (vector unsigned long long,
18178 vector unsigned long long);
18180 int vec_all_eq (vector long long, vector long long);
18181 int vec_all_eq (vector unsigned long long, vector unsigned long long);
18182 int vec_all_ge (vector long long, vector long long);
18183 int vec_all_ge (vector unsigned long long, vector unsigned long long);
18184 int vec_all_gt (vector long long, vector long long);
18185 int vec_all_gt (vector unsigned long long, vector unsigned long long);
18186 int vec_all_le (vector long long, vector long long);
18187 int vec_all_le (vector unsigned long long, vector unsigned long long);
18188 int vec_all_lt (vector long long, vector long long);
18189 int vec_all_lt (vector unsigned long long, vector unsigned long long);
18190 int vec_all_ne (vector long long, vector long long);
18191 int vec_all_ne (vector unsigned long long, vector unsigned long long);
18193 int vec_any_eq (vector long long, vector long long);
18194 int vec_any_eq (vector unsigned long long, vector unsigned long long);
18195 int vec_any_ge (vector long long, vector long long);
18196 int vec_any_ge (vector unsigned long long, vector unsigned long long);
18197 int vec_any_gt (vector long long, vector long long);
18198 int vec_any_gt (vector unsigned long long, vector unsigned long long);
18199 int vec_any_le (vector long long, vector long long);
18200 int vec_any_le (vector unsigned long long, vector unsigned long long);
18201 int vec_any_lt (vector long long, vector long long);
18202 int vec_any_lt (vector unsigned long long, vector unsigned long long);
18203 int vec_any_ne (vector long long, vector long long);
18204 int vec_any_ne (vector unsigned long long, vector unsigned long long);
18206 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
18208 vector long long vec_eqv (vector long long, vector long long);
18209 vector long long vec_eqv (vector bool long long, vector long long);
18210 vector long long vec_eqv (vector long long, vector bool long long);
18211 vector unsigned long long vec_eqv (vector unsigned long long, vector unsigned long long);
18212 vector unsigned long long vec_eqv (vector bool long long, vector unsigned long long);
18213 vector unsigned long long vec_eqv (vector unsigned long long,
18214 vector bool long long);
18215 vector int vec_eqv (vector int, vector int);
18216 vector int vec_eqv (vector bool int, vector int);
18217 vector int vec_eqv (vector int, vector bool int);
18218 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
18219 vector unsigned int vec_eqv (vector bool unsigned int, vector unsigned int);
18220 vector unsigned int vec_eqv (vector unsigned int, vector bool unsigned int);
18221 vector short vec_eqv (vector short, vector short);
18222 vector short vec_eqv (vector bool short, vector short);
18223 vector short vec_eqv (vector short, vector bool short);
18224 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
18225 vector unsigned short vec_eqv (vector bool unsigned short, vector unsigned short);
18226 vector unsigned short vec_eqv (vector unsigned short, vector bool unsigned short);
18227 vector signed char vec_eqv (vector signed char, vector signed char);
18228 vector signed char vec_eqv (vector bool signed char, vector signed char);
18229 vector signed char vec_eqv (vector signed char, vector bool signed char);
18230 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
18231 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
18232 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
18234 vector long long vec_max (vector long long, vector long long);
18235 vector unsigned long long vec_max (vector unsigned long long,
18236 vector unsigned long long);
18238 vector signed int vec_mergee (vector signed int, vector signed int);
18239 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
18240 vector bool int vec_mergee (vector bool int, vector bool int);
18242 vector signed int vec_mergeo (vector signed int, vector signed int);
18243 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
18244 vector bool int vec_mergeo (vector bool int, vector bool int);
18246 vector long long vec_min (vector long long, vector long long);
18247 vector unsigned long long vec_min (vector unsigned long long,
18248 vector unsigned long long);
18250 vector signed long long vec_nabs (vector signed long long);
18252 vector long long vec_nand (vector long long, vector long long);
18253 vector long long vec_nand (vector bool long long, vector long long);
18254 vector long long vec_nand (vector long long, vector bool long long);
18255 vector unsigned long long vec_nand (vector unsigned long long,
18256 vector unsigned long long);
18257 vector unsigned long long vec_nand (vector bool long long, vector unsigned long long);
18258 vector unsigned long long vec_nand (vector unsigned long long, vector bool long long);
18259 vector int vec_nand (vector int, vector int);
18260 vector int vec_nand (vector bool int, vector int);
18261 vector int vec_nand (vector int, vector bool int);
18262 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
18263 vector unsigned int vec_nand (vector bool unsigned int, vector unsigned int);
18264 vector unsigned int vec_nand (vector unsigned int, vector bool unsigned int);
18265 vector short vec_nand (vector short, vector short);
18266 vector short vec_nand (vector bool short, vector short);
18267 vector short vec_nand (vector short, vector bool short);
18268 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
18269 vector unsigned short vec_nand (vector bool unsigned short, vector unsigned short);
18270 vector unsigned short vec_nand (vector unsigned short, vector bool unsigned short);
18271 vector signed char vec_nand (vector signed char, vector signed char);
18272 vector signed char vec_nand (vector bool signed char, vector signed char);
18273 vector signed char vec_nand (vector signed char, vector bool signed char);
18274 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
18275 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
18276 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
18278 vector long long vec_orc (vector long long, vector long long);
18279 vector long long vec_orc (vector bool long long, vector long long);
18280 vector long long vec_orc (vector long long, vector bool long long);
18281 vector unsigned long long vec_orc (vector unsigned long long,
18282 vector unsigned long long);
18283 vector unsigned long long vec_orc (vector bool long long, vector unsigned long long);
18284 vector unsigned long long vec_orc (vector unsigned long long, vector bool long long);
18285 vector int vec_orc (vector int, vector int);
18286 vector int vec_orc (vector bool int, vector int);
18287 vector int vec_orc (vector int, vector bool int);
18288 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
18289 vector unsigned int vec_orc (vector bool unsigned int, vector unsigned int);
18290 vector unsigned int vec_orc (vector unsigned int, vector bool unsigned int);
18291 vector short vec_orc (vector short, vector short);
18292 vector short vec_orc (vector bool short, vector short);
18293 vector short vec_orc (vector short, vector bool short);
18294 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
18295 vector unsigned short vec_orc (vector bool unsigned short, vector unsigned short);
18296 vector unsigned short vec_orc (vector unsigned short, vector bool unsigned short);
18297 vector signed char vec_orc (vector signed char, vector signed char);
18298 vector signed char vec_orc (vector bool signed char, vector signed char);
18299 vector signed char vec_orc (vector signed char, vector bool signed char);
18300 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
18301 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
18302 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
18304 vector int vec_pack (vector long long, vector long long);
18305 vector unsigned int vec_pack (vector unsigned long long, vector unsigned long long);
18306 vector bool int vec_pack (vector bool long long, vector bool long long);
18307 vector float vec_pack (vector double, vector double);
18309 vector int vec_packs (vector long long, vector long long);
18310 vector unsigned int vec_packs (vector unsigned long long, vector unsigned long long);
18312 vector unsigned char vec_packsu (vector signed short, vector signed short)
18313 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short)
18314 vector unsigned short int vec_packsu (vector signed int, vector signed int);
18315 vector unsigned short int vec_packsu (vector unsigned int, vector unsigned int);
18316 vector unsigned int vec_packsu (vector long long, vector long long);
18317 vector unsigned int vec_packsu (vector unsigned long long, vector unsigned long long);
18318 vector unsigned int vec_packsu (vector signed long long, vector signed long long);
18320 vector unsigned char vec_popcnt (vector signed char);
18321 vector unsigned char vec_popcnt (vector unsigned char);
18322 vector unsigned short vec_popcnt (vector signed short);
18323 vector unsigned short vec_popcnt (vector unsigned short);
18324 vector unsigned int vec_popcnt (vector signed int);
18325 vector unsigned int vec_popcnt (vector unsigned int);
18326 vector unsigned long long vec_popcnt (vector signed long long);
18327 vector unsigned long long vec_popcnt (vector unsigned long long);
18329 vector long long vec_rl (vector long long, vector unsigned long long);
18330 vector long long vec_rl (vector unsigned long long, vector unsigned long long);
18332 vector long long vec_sl (vector long long, vector unsigned long long);
18333 vector long long vec_sl (vector unsigned long long, vector unsigned long long);
18335 vector long long vec_sr (vector long long, vector unsigned long long);
18336 vector unsigned long long char vec_sr (vector unsigned long long,
18337 vector unsigned long long);
18339 vector long long vec_sra (vector long long, vector unsigned long long);
18340 vector unsigned long long vec_sra (vector unsigned long long,
18341 vector unsigned long long);
18343 vector long long vec_sub (vector long long, vector long long);
18344 vector unsigned long long vec_sub (vector unsigned long long,
18345 vector unsigned long long);
18347 vector long long vec_unpackh (vector int);
18348 vector unsigned long long vec_unpackh (vector unsigned int);
18350 vector long long vec_unpackl (vector int);
18351 vector unsigned long long vec_unpackl (vector unsigned int);
18353 vector long long vec_vaddudm (vector long long, vector long long);
18354 vector long long vec_vaddudm (vector bool long long, vector long long);
18355 vector long long vec_vaddudm (vector long long, vector bool long long);
18356 vector unsigned long long vec_vaddudm (vector unsigned long long,
18357 vector unsigned long long);
18358 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
18359 vector unsigned long long);
18360 vector unsigned long long vec_vaddudm (vector unsigned long long,
18361 vector bool unsigned long long);
18363 vector long long vec_vbpermq (vector signed char, vector signed char);
18364 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
18366 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
18367 vector unsigned char vec_bperm (vector unsigned long long, vector unsigned char);
18368 vector unsigned long long vec_bperm (vector unsigned __int128, vector unsigned char);
18370 vector long long vec_cntlz (vector long long);
18371 vector unsigned long long vec_cntlz (vector unsigned long long);
18372 vector int vec_cntlz (vector int);
18373 vector unsigned int vec_cntlz (vector int);
18374 vector short vec_cntlz (vector short);
18375 vector unsigned short vec_cntlz (vector unsigned short);
18376 vector signed char vec_cntlz (vector signed char);
18377 vector unsigned char vec_cntlz (vector unsigned char);
18379 vector long long vec_vclz (vector long long);
18380 vector unsigned long long vec_vclz (vector unsigned long long);
18381 vector int vec_vclz (vector int);
18382 vector unsigned int vec_vclz (vector int);
18383 vector short vec_vclz (vector short);
18384 vector unsigned short vec_vclz (vector unsigned short);
18385 vector signed char vec_vclz (vector signed char);
18386 vector unsigned char vec_vclz (vector unsigned char);
18388 vector signed char vec_vclzb (vector signed char);
18389 vector unsigned char vec_vclzb (vector unsigned char);
18391 vector long long vec_vclzd (vector long long);
18392 vector unsigned long long vec_vclzd (vector unsigned long long);
18394 vector short vec_vclzh (vector short);
18395 vector unsigned short vec_vclzh (vector unsigned short);
18397 vector int vec_vclzw (vector int);
18398 vector unsigned int vec_vclzw (vector int);
18400 vector signed char vec_vgbbd (vector signed char);
18401 vector unsigned char vec_vgbbd (vector unsigned char);
18403 vector long long vec_vmaxsd (vector long long, vector long long);
18405 vector unsigned long long vec_vmaxud (vector unsigned long long,
18406 unsigned vector long long);
18408 vector long long vec_vminsd (vector long long, vector long long);
18410 vector unsigned long long vec_vminud (vector long long, vector long long);
18412 vector int vec_vpksdss (vector long long, vector long long);
18413 vector unsigned int vec_vpksdss (vector long long, vector long long);
18415 vector unsigned int vec_vpkudus (vector unsigned long long,
18416 vector unsigned long long);
18418 vector int vec_vpkudum (vector long long, vector long long);
18419 vector unsigned int vec_vpkudum (vector unsigned long long,
18420 vector unsigned long long);
18421 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
18423 vector long long vec_vpopcnt (vector long long);
18424 vector unsigned long long vec_vpopcnt (vector unsigned long long);
18425 vector int vec_vpopcnt (vector int);
18426 vector unsigned int vec_vpopcnt (vector int);
18427 vector short vec_vpopcnt (vector short);
18428 vector unsigned short vec_vpopcnt (vector unsigned short);
18429 vector signed char vec_vpopcnt (vector signed char);
18430 vector unsigned char vec_vpopcnt (vector unsigned char);
18432 vector signed char vec_vpopcntb (vector signed char);
18433 vector unsigned char vec_vpopcntb (vector unsigned char);
18435 vector long long vec_vpopcntd (vector long long);
18436 vector unsigned long long vec_vpopcntd (vector unsigned long long);
18438 vector short vec_vpopcnth (vector short);
18439 vector unsigned short vec_vpopcnth (vector unsigned short);
18441 vector int vec_vpopcntw (vector int);
18442 vector unsigned int vec_vpopcntw (vector int);
18444 vector long long vec_vrld (vector long long, vector unsigned long long);
18445 vector unsigned long long vec_vrld (vector unsigned long long,
18446 vector unsigned long long);
18448 vector long long vec_vsld (vector long long, vector unsigned long long);
18449 vector long long vec_vsld (vector unsigned long long,
18450 vector unsigned long long);
18452 vector long long vec_vsrad (vector long long, vector unsigned long long);
18453 vector unsigned long long vec_vsrad (vector unsigned long long,
18454 vector unsigned long long);
18456 vector long long vec_vsrd (vector long long, vector unsigned long long);
18457 vector unsigned long long char vec_vsrd (vector unsigned long long,
18458 vector unsigned long long);
18460 vector long long vec_vsubudm (vector long long, vector long long);
18461 vector long long vec_vsubudm (vector bool long long, vector long long);
18462 vector long long vec_vsubudm (vector long long, vector bool long long);
18463 vector unsigned long long vec_vsubudm (vector unsigned long long,
18464 vector unsigned long long);
18465 vector unsigned long long vec_vsubudm (vector bool long long,
18466 vector unsigned long long);
18467 vector unsigned long long vec_vsubudm (vector unsigned long long,
18468 vector bool long long);
18470 vector long long vec_vupkhsw (vector int);
18471 vector unsigned long long vec_vupkhsw (vector unsigned int);
18473 vector long long vec_vupklsw (vector int);
18474 vector unsigned long long vec_vupklsw (vector int);
18477 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18478 instruction set are available, the following additional functions are
18479 available for 64-bit targets. New vector types
18480 (@var{vector __int128} and @var{vector __uint128}) are available
18481 to hold the @var{__int128} and @var{__uint128} types to use these
18484 The normal vector extract, and set operations work on
18485 @var{vector __int128} and @var{vector __uint128} types,
18486 but the index value must be 0.
18489 vector __int128 vec_vaddcuq (vector __int128, vector __int128);
18490 vector __uint128 vec_vaddcuq (vector __uint128, vector __uint128);
18492 vector __int128 vec_vadduqm (vector __int128, vector __int128);
18493 vector __uint128 vec_vadduqm (vector __uint128, vector __uint128);
18495 vector __int128 vec_vaddecuq (vector __int128, vector __int128,
18497 vector __uint128 vec_vaddecuq (vector __uint128, vector __uint128,
18500 vector __int128 vec_vaddeuqm (vector __int128, vector __int128,
18502 vector __uint128 vec_vaddeuqm (vector __uint128, vector __uint128,
18505 vector __int128 vec_vsubecuq (vector __int128, vector __int128,
18507 vector __uint128 vec_vsubecuq (vector __uint128, vector __uint128,
18510 vector __int128 vec_vsubeuqm (vector __int128, vector __int128,
18512 vector __uint128 vec_vsubeuqm (vector __uint128, vector __uint128,
18515 vector __int128 vec_vsubcuq (vector __int128, vector __int128);
18516 vector __uint128 vec_vsubcuq (vector __uint128, vector __uint128);
18518 __int128 vec_vsubuqm (__int128, __int128);
18519 __uint128 vec_vsubuqm (__uint128, __uint128);
18521 vector __int128 __builtin_bcdadd (vector __int128, vector __int128, const int);
18522 int __builtin_bcdadd_lt (vector __int128, vector __int128, const int);
18523 int __builtin_bcdadd_eq (vector __int128, vector __int128, const int);
18524 int __builtin_bcdadd_gt (vector __int128, vector __int128, const int);
18525 int __builtin_bcdadd_ov (vector __int128, vector __int128, const int);
18526 vector __int128 __builtin_bcdsub (vector __int128, vector __int128, const int);
18527 int __builtin_bcdsub_lt (vector __int128, vector __int128, const int);
18528 int __builtin_bcdsub_eq (vector __int128, vector __int128, const int);
18529 int __builtin_bcdsub_gt (vector __int128, vector __int128, const int);
18530 int __builtin_bcdsub_ov (vector __int128, vector __int128, const int);
18533 @node PowerPC AltiVec Built-in Functions Available on ISA 3.0
18534 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 3.0
18536 The following additional built-in functions are also available for the
18537 PowerPC family of processors, starting with ISA 3.0
18538 (@option{-mcpu=power9}) or later:
18540 unsigned int scalar_extract_exp (double source);
18541 unsigned long long int scalar_extract_exp (__ieee128 source);
18543 unsigned long long int scalar_extract_sig (double source);
18544 unsigned __int128 scalar_extract_sig (__ieee128 source);
18546 double scalar_insert_exp (unsigned long long int significand,
18547 unsigned long long int exponent);
18548 double scalar_insert_exp (double significand, unsigned long long int exponent);
18550 ieee_128 scalar_insert_exp (unsigned __int128 significand,
18551 unsigned long long int exponent);
18552 ieee_128 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent);
18554 int scalar_cmp_exp_gt (double arg1, double arg2);
18555 int scalar_cmp_exp_lt (double arg1, double arg2);
18556 int scalar_cmp_exp_eq (double arg1, double arg2);
18557 int scalar_cmp_exp_unordered (double arg1, double arg2);
18559 bool scalar_test_data_class (float source, const int condition);
18560 bool scalar_test_data_class (double source, const int condition);
18561 bool scalar_test_data_class (__ieee128 source, const int condition);
18563 bool scalar_test_neg (float source);
18564 bool scalar_test_neg (double source);
18565 bool scalar_test_neg (__ieee128 source);
18568 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
18569 functions require a 64-bit environment supporting ISA 3.0 or later.
18570 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
18571 functions return the significand and the biased exponent value
18572 respectively of their @code{source} arguments.
18573 When supplied with a 64-bit @code{source} argument, the
18574 result returned by @code{scalar_extract_sig} has
18575 the @code{0x0010000000000000} bit set if the
18576 function's @code{source} argument is in normalized form.
18577 Otherwise, this bit is set to 0.
18578 When supplied with a 128-bit @code{source} argument, the
18579 @code{0x00010000000000000000000000000000} bit of the result is
18581 Note that the sign of the significand is not represented in the result
18582 returned from the @code{scalar_extract_sig} function. Use the
18583 @code{scalar_test_neg} function to test the sign of its @code{double}
18586 The @code{scalar_insert_exp}
18587 functions require a 64-bit environment supporting ISA 3.0 or later.
18588 When supplied with a 64-bit first argument, the
18589 @code{scalar_insert_exp} built-in function returns a double-precision
18590 floating point value that is constructed by assembling the values of its
18591 @code{significand} and @code{exponent} arguments. The sign of the
18592 result is copied from the most significant bit of the
18593 @code{significand} argument. The significand and exponent components
18594 of the result are composed of the least significant 11 bits of the
18595 @code{exponent} argument and the least significant 52 bits of the
18596 @code{significand} argument respectively.
18598 When supplied with a 128-bit first argument, the
18599 @code{scalar_insert_exp} built-in function returns a quad-precision
18600 ieee floating point value. The sign bit of the result is copied from
18601 the most significant bit of the @code{significand} argument.
18602 The significand and exponent components of the result are composed of
18603 the least significant 15 bits of the @code{exponent} argument and the
18604 least significant 112 bits of the @code{significand} argument respectively.
18606 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
18607 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
18608 functions return a non-zero value if @code{arg1} is greater than, less
18609 than, equal to, or not comparable to @code{arg2} respectively. The
18610 arguments are not comparable if one or the other equals NaN (not a
18613 The @code{scalar_test_data_class} built-in function returns 1
18614 if any of the condition tests enabled by the value of the
18615 @code{condition} variable are true, and 0 otherwise. The
18616 @code{condition} argument must be a compile-time constant integer with
18617 value not exceeding 127. The
18618 @code{condition} argument is encoded as a bitmask with each bit
18619 enabling the testing of a different condition, as characterized by the
18623 0x20 Test for +Infinity
18624 0x10 Test for -Infinity
18625 0x08 Test for +Zero
18626 0x04 Test for -Zero
18627 0x02 Test for +Denormal
18628 0x01 Test for -Denormal
18631 The @code{scalar_test_neg} built-in function returns 1 if its
18632 @code{source} argument holds a negative value, 0 otherwise.
18634 The following built-in functions are also available for the PowerPC family
18635 of processors, starting with ISA 3.0 or later
18636 (@option{-mcpu=power9}). These string functions are described
18637 separately in order to group the descriptions closer to the function
18640 int vec_all_nez (vector signed char, vector signed char);
18641 int vec_all_nez (vector unsigned char, vector unsigned char);
18642 int vec_all_nez (vector signed short, vector signed short);
18643 int vec_all_nez (vector unsigned short, vector unsigned short);
18644 int vec_all_nez (vector signed int, vector signed int);
18645 int vec_all_nez (vector unsigned int, vector unsigned int);
18647 int vec_any_eqz (vector signed char, vector signed char);
18648 int vec_any_eqz (vector unsigned char, vector unsigned char);
18649 int vec_any_eqz (vector signed short, vector signed short);
18650 int vec_any_eqz (vector unsigned short, vector unsigned short);
18651 int vec_any_eqz (vector signed int, vector signed int);
18652 int vec_any_eqz (vector unsigned int, vector unsigned int);
18654 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
18655 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
18656 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
18657 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
18658 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
18659 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
18661 vector signed char vec_cnttz (vector signed char);
18662 vector unsigned char vec_cnttz (vector unsigned char);
18663 vector signed short vec_cnttz (vector signed short);
18664 vector unsigned short vec_cnttz (vector unsigned short);
18665 vector signed int vec_cnttz (vector signed int);
18666 vector unsigned int vec_cnttz (vector unsigned int);
18667 vector signed long long vec_cnttz (vector signed long long);
18668 vector unsigned long long vec_cnttz (vector unsigned long long);
18670 signed int vec_cntlz_lsbb (vector signed char);
18671 signed int vec_cntlz_lsbb (vector unsigned char);
18673 signed int vec_cnttz_lsbb (vector signed char);
18674 signed int vec_cnttz_lsbb (vector unsigned char);
18676 unsigned int vec_first_match_index (vector signed char, vector signed char);
18677 unsigned int vec_first_match_index (vector unsigned char, vector unsigned char);
18678 unsigned int vec_first_match_index (vector signed int, vector signed int);
18679 unsigned int vec_first_match_index (vector unsigned int, vector unsigned int);
18680 unsigned int vec_first_match_index (vector signed short, vector signed short);
18681 unsigned int vec_first_match_index (vector unsigned short, vector unsigned short);
18682 unsigned int vec_first_match_or_eos_index (vector signed char, vector signed char);
18683 unsigned int vec_first_match_or_eos_index (vector unsigned char, vector unsigned char);
18684 unsigned int vec_first_match_or_eos_index (vector signed int, vector signed int);
18685 unsigned int vec_first_match_or_eos_index (vector unsigned int, vector unsigned int);
18686 unsigned int vec_first_match_or_eos_index (vector signed short, vector signed short);
18687 unsigned int vec_first_match_or_eos_index (vector unsigned short,
18688 vector unsigned short);
18689 unsigned int vec_first_mismatch_index (vector signed char, vector signed char);
18690 unsigned int vec_first_mismatch_index (vector unsigned char, vector unsigned char);
18691 unsigned int vec_first_mismatch_index (vector signed int, vector signed int);
18692 unsigned int vec_first_mismatch_index (vector unsigned int, vector unsigned int);
18693 unsigned int vec_first_mismatch_index (vector signed short, vector signed short);
18694 unsigned int vec_first_mismatch_index (vector unsigned short, vector unsigned short);
18695 unsigned int vec_first_mismatch_or_eos_index (vector signed char, vector signed char);
18696 unsigned int vec_first_mismatch_or_eos_index (vector unsigned char,
18697 vector unsigned char);
18698 unsigned int vec_first_mismatch_or_eos_index (vector signed int, vector signed int);
18699 unsigned int vec_first_mismatch_or_eos_index (vector unsigned int, vector unsigned int);
18700 unsigned int vec_first_mismatch_or_eos_index (vector signed short, vector signed short);
18701 unsigned int vec_first_mismatch_or_eos_index (vector unsigned short,
18702 vector unsigned short);
18704 vector unsigned short vec_pack_to_short_fp32 (vector float, vector float);
18706 vector signed char vec_xl_be (signed long long, signed char *);
18707 vector unsigned char vec_xl_be (signed long long, unsigned char *);
18708 vector signed int vec_xl_be (signed long long, signed int *);
18709 vector unsigned int vec_xl_be (signed long long, unsigned int *);
18710 vector signed __int128 vec_xl_be (signed long long, signed __int128 *);
18711 vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *);
18712 vector signed long long vec_xl_be (signed long long, signed long long *);
18713 vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
18714 vector signed short vec_xl_be (signed long long, signed short *);
18715 vector unsigned short vec_xl_be (signed long long, unsigned short *);
18716 vector double vec_xl_be (signed long long, double *);
18717 vector float vec_xl_be (signed long long, float *);
18719 vector signed char vec_xl_len (signed char *addr, size_t len);
18720 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
18721 vector signed int vec_xl_len (signed int *addr, size_t len);
18722 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
18723 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
18724 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
18725 vector signed long long vec_xl_len (signed long long *addr, size_t len);
18726 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
18727 vector signed short vec_xl_len (signed short *addr, size_t len);
18728 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
18729 vector double vec_xl_len (double *addr, size_t len);
18730 vector float vec_xl_len (float *addr, size_t len);
18732 vector unsigned char vec_xl_len_r (unsigned char *addr, size_t len);
18734 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
18735 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
18736 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
18737 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
18738 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
18739 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
18740 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
18741 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
18742 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
18743 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
18744 void vec_xst_len (vector double data, double *addr, size_t len);
18745 void vec_xst_len (vector float data, float *addr, size_t len);
18747 void vec_xst_len_r (vector unsigned char data, unsigned char *addr, size_t len);
18749 signed char vec_xlx (unsigned int index, vector signed char data);
18750 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
18751 signed short vec_xlx (unsigned int index, vector signed short data);
18752 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
18753 signed int vec_xlx (unsigned int index, vector signed int data);
18754 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
18755 float vec_xlx (unsigned int index, vector float data);
18757 signed char vec_xrx (unsigned int index, vector signed char data);
18758 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
18759 signed short vec_xrx (unsigned int index, vector signed short data);
18760 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
18761 signed int vec_xrx (unsigned int index, vector signed int data);
18762 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
18763 float vec_xrx (unsigned int index, vector float data);
18766 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
18767 perform pairwise comparisons between the elements at the same
18768 positions within their two vector arguments.
18769 The @code{vec_all_nez} function returns a
18770 non-zero value if and only if all pairwise comparisons are not
18771 equal and no element of either vector argument contains a zero.
18772 The @code{vec_any_eqz} function returns a
18773 non-zero value if and only if at least one pairwise comparison is equal
18774 or if at least one element of either vector argument contains a zero.
18775 The @code{vec_cmpnez} function returns a vector of the same type as
18776 its two arguments, within which each element consists of all ones to
18777 denote that either the corresponding elements of the incoming arguments are
18778 not equal or that at least one of the corresponding elements contains
18779 zero. Otherwise, the element of the returned vector contains all zeros.
18781 The @code{vec_cntlz_lsbb} function returns the count of the number of
18782 consecutive leading byte elements (starting from position 0 within the
18783 supplied vector argument) for which the least-significant bit
18784 equals zero. The @code{vec_cnttz_lsbb} function returns the count of
18785 the number of consecutive trailing byte elements (starting from
18786 position 15 and counting backwards within the supplied vector
18787 argument) for which the least-significant bit equals zero.
18789 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
18790 64-bit environment supporting ISA 3.0 or later. The @code{vec_xl_len}
18791 function loads a variable length vector from memory. The
18792 @code{vec_xst_len} function stores a variable length vector to memory.
18793 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
18794 @code{addr} argument represents the memory address to or from which
18795 data will be transferred, and the
18796 @code{len} argument represents the number of bytes to be
18797 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
18798 If this expression's value is not a multiple of the vector element's
18799 size, the behavior of this function is undefined.
18800 In the case that the underlying computer is configured to run in
18801 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
18802 the corresponding vector. In little-endian mode, the data transfer
18803 moves bytes @code{(16 - len)} to @code{15} of the corresponding
18804 vector. For the load function, any bytes of the result vector that
18805 are not loaded from memory are set to zero.
18806 The value of the @code{addr} argument need not be aligned on a
18807 multiple of the vector's element size.
18809 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
18810 element selected by the @code{index} argument from the vector
18811 represented by the @code{data} argument. The @code{index} argument
18812 always specifies a byte offset, regardless of the size of the vector
18813 element. With @code{vec_xlx}, @code{index} is the offset of the first
18814 byte of the element to be extracted. With @code{vec_xrx}, @code{index}
18815 represents the last byte of the element to be extracted, measured
18816 from the right end of the vector. In other words, the last byte of
18817 the element to be extracted is found at position @code{(15 - index)}.
18818 There is no requirement that @code{index} be a multiple of the vector
18819 element size. However, if the size of the vector element added to
18820 @code{index} is greater than 15, the content of the returned value is
18823 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18827 vector unsigned long long vec_bperm (vector unsigned long long, vector unsigned char);
18829 vector bool char vec_cmpne (vector bool char, vector bool char);
18830 vector bool char vec_cmpne (vector signed char, vector signed char);
18831 vector bool char vec_cmpne (vector unsigned char, vector unsigned char);
18832 vector bool int vec_cmpne (vector bool int, vector bool int);
18833 vector bool int vec_cmpne (vector signed int, vector signed int);
18834 vector bool int vec_cmpne (vector unsigned int, vector unsigned int);
18835 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
18836 vector bool long long vec_cmpne (vector signed long long, vector signed long long);
18837 vector bool long long vec_cmpne (vector unsigned long long, vector unsigned long long);
18838 vector bool short vec_cmpne (vector bool short, vector bool short);
18839 vector bool short vec_cmpne (vector signed short, vector signed short);
18840 vector bool short vec_cmpne (vector unsigned short, vector unsigned short);
18841 vector bool long long vec_cmpne (vector double, vector double);
18842 vector bool int vec_cmpne (vector float, vector float);
18844 vector float vec_extract_fp32_from_shorth (vector unsigned short);
18845 vector float vec_extract_fp32_from_shortl (vector unsigned short);
18847 vector long long vec_vctz (vector long long);
18848 vector unsigned long long vec_vctz (vector unsigned long long);
18849 vector int vec_vctz (vector int);
18850 vector unsigned int vec_vctz (vector int);
18851 vector short vec_vctz (vector short);
18852 vector unsigned short vec_vctz (vector unsigned short);
18853 vector signed char vec_vctz (vector signed char);
18854 vector unsigned char vec_vctz (vector unsigned char);
18856 vector signed char vec_vctzb (vector signed char);
18857 vector unsigned char vec_vctzb (vector unsigned char);
18859 vector long long vec_vctzd (vector long long);
18860 vector unsigned long long vec_vctzd (vector unsigned long long);
18862 vector short vec_vctzh (vector short);
18863 vector unsigned short vec_vctzh (vector unsigned short);
18865 vector int vec_vctzw (vector int);
18866 vector unsigned int vec_vctzw (vector int);
18868 vector unsigned long long vec_extract4b (vector unsigned char, const int);
18870 vector unsigned char vec_insert4b (vector signed int, vector unsigned char,
18872 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
18875 vector unsigned int vec_parity_lsbb (vector signed int);
18876 vector unsigned int vec_parity_lsbb (vector unsigned int);
18877 vector unsigned __int128 vec_parity_lsbb (vector signed __int128);
18878 vector unsigned __int128 vec_parity_lsbb (vector unsigned __int128);
18879 vector unsigned long long vec_parity_lsbb (vector signed long long);
18880 vector unsigned long long vec_parity_lsbb (vector unsigned long long);
18882 vector int vec_vprtyb (vector int);
18883 vector unsigned int vec_vprtyb (vector unsigned int);
18884 vector long long vec_vprtyb (vector long long);
18885 vector unsigned long long vec_vprtyb (vector unsigned long long);
18887 vector int vec_vprtybw (vector int);
18888 vector unsigned int vec_vprtybw (vector unsigned int);
18890 vector long long vec_vprtybd (vector long long);
18891 vector unsigned long long vec_vprtybd (vector unsigned long long);
18894 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
18898 vector long vec_vprtyb (vector long);
18899 vector unsigned long vec_vprtyb (vector unsigned long);
18900 vector __int128 vec_vprtyb (vector __int128);
18901 vector __uint128 vec_vprtyb (vector __uint128);
18903 vector long vec_vprtybd (vector long);
18904 vector unsigned long vec_vprtybd (vector unsigned long);
18906 vector __int128 vec_vprtybq (vector __int128);
18907 vector __uint128 vec_vprtybd (vector __uint128);
18910 The following built-in vector functions are available for the PowerPC family
18911 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18913 __vector unsigned char
18914 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
18915 __vector unsigned char
18916 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
18919 The @code{vec_slv} and @code{vec_srv} functions operate on
18920 all of the bytes of their @code{src} and @code{shift_distance}
18921 arguments in parallel. The behavior of the @code{vec_slv} is as if
18922 there existed a temporary array of 17 unsigned characters
18923 @code{slv_array} within which elements 0 through 15 are the same as
18924 the entries in the @code{src} array and element 16 equals 0. The
18925 result returned from the @code{vec_slv} function is a
18926 @code{__vector} of 16 unsigned characters within which element
18927 @code{i} is computed using the C expression
18928 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
18929 shift_distance[i]))},
18930 with this resulting value coerced to the @code{unsigned char} type.
18931 The behavior of the @code{vec_srv} is as if
18932 there existed a temporary array of 17 unsigned characters
18933 @code{srv_array} within which element 0 equals zero and
18934 elements 1 through 16 equal the elements 0 through 15 of
18935 the @code{src} array. The
18936 result returned from the @code{vec_srv} function is a
18937 @code{__vector} of 16 unsigned characters within which element
18938 @code{i} is computed using the C expression
18939 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
18940 (0x07 & shift_distance[i]))},
18941 with this resulting value coerced to the @code{unsigned char} type.
18943 The following built-in functions are available for the PowerPC family
18944 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18946 __vector unsigned char
18947 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
18948 __vector unsigned short
18949 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
18950 __vector unsigned int
18951 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
18953 __vector unsigned char
18954 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
18955 __vector unsigned short
18956 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
18957 __vector unsigned int
18958 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
18961 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
18962 @code{vec_absdw} built-in functions each computes the absolute
18963 differences of the pairs of vector elements supplied in its two vector
18964 arguments, placing the absolute differences into the corresponding
18965 elements of the vector result.
18967 The following built-in functions are available for the PowerPC family
18968 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18970 __vector unsigned int vec_extract_exp (__vector float source);
18971 __vector unsigned long long int vec_extract_exp (__vector double source);
18973 __vector unsigned int vec_extract_sig (__vector float source);
18974 __vector unsigned long long int vec_extract_sig (__vector double source);
18976 __vector float vec_insert_exp (__vector unsigned int significands,
18977 __vector unsigned int exponents);
18978 __vector float vec_insert_exp (__vector unsigned float significands,
18979 __vector unsigned int exponents);
18980 __vector double vec_insert_exp (__vector unsigned long long int significands,
18981 __vector unsigned long long int exponents);
18982 __vector double vec_insert_exp (__vector unsigned double significands,
18983 __vector unsigned long long int exponents);
18985 __vector bool int vec_test_data_class (__vector float source, const int condition);
18986 __vector bool long long int vec_test_data_class (__vector double source,
18987 const int condition);
18990 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
18991 functions return vectors representing the significands and biased
18992 exponent values of their @code{source} arguments respectively.
18993 Within the result vector returned by @code{vec_extract_sig}, the
18994 @code{0x800000} bit of each vector element returned when the
18995 function's @code{source} argument is of type @code{float} is set to 1
18996 if the corresponding floating point value is in normalized form.
18997 Otherwise, this bit is set to 0. When the @code{source} argument is
18998 of type @code{double}, the @code{0x10000000000000} bit within each of
18999 the result vector's elements is set according to the same rules.
19000 Note that the sign of the significand is not represented in the result
19001 returned from the @code{vec_extract_sig} function. To extract the
19003 @code{vec_cpsgn} function, which returns a new vector within which all
19004 of the sign bits of its second argument vector are overwritten with the
19005 sign bits copied from the coresponding elements of its first argument
19006 vector, and all other (non-sign) bits of the second argument vector
19007 are copied unchanged into the result vector.
19009 The @code{vec_insert_exp} built-in functions return a vector of
19010 single- or double-precision floating
19011 point values constructed by assembling the values of their
19012 @code{significands} and @code{exponents} arguments into the
19013 corresponding elements of the returned vector.
19015 element of the result is copied from the most significant bit of the
19016 corresponding entry within the @code{significands} argument.
19017 Note that the relevant
19018 bits of the @code{significands} argument are the same, for both integer
19019 and floating point types.
19021 significand and exponent components of each element of the result are
19022 composed of the least significant bits of the corresponding
19023 @code{significands} element and the least significant bits of the
19024 corresponding @code{exponents} element.
19026 The @code{vec_test_data_class} built-in function returns a vector
19027 representing the results of testing the @code{source} vector for the
19028 condition selected by the @code{condition} argument. The
19029 @code{condition} argument must be a compile-time constant integer with
19030 value not exceeding 127. The
19031 @code{condition} argument is encoded as a bitmask with each bit
19032 enabling the testing of a different condition, as characterized by the
19036 0x20 Test for +Infinity
19037 0x10 Test for -Infinity
19038 0x08 Test for +Zero
19039 0x04 Test for -Zero
19040 0x02 Test for +Denormal
19041 0x01 Test for -Denormal
19044 If any of the enabled test conditions is true, the corresponding entry
19045 in the result vector is -1. Otherwise (all of the enabled test
19046 conditions are false), the corresponding entry of the result vector is 0.
19048 The following built-in functions are available for the PowerPC family
19049 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19051 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
19052 vector unsigned int);
19053 vector unsigned long long vec_rlmi (vector unsigned long long,
19054 vector unsigned long long,
19055 vector unsigned long long);
19056 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
19057 vector unsigned int);
19058 vector unsigned long long vec_rlnm (vector unsigned long long,
19059 vector unsigned long long,
19060 vector unsigned long long);
19061 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
19062 vector unsigned long long vec_vrlnm (vector unsigned long long,
19063 vector unsigned long long);
19066 The result of @code{vec_rlmi} is obtained by rotating each element of
19067 the first argument vector left and inserting it under mask into the
19068 second argument vector. The third argument vector contains the mask
19069 beginning in bits 11:15, the mask end in bits 19:23, and the shift
19070 count in bits 27:31, of each element.
19072 The result of @code{vec_rlnm} is obtained by rotating each element of
19073 the first argument vector left and ANDing it with a mask specified by
19074 the second and third argument vectors. The second argument vector
19075 contains the shift count for each element in the low-order byte. The
19076 third argument vector contains the mask end for each element in the
19077 low-order byte, with the mask begin in the next higher byte.
19079 The result of @code{vec_vrlnm} is obtained by rotating each element
19080 of the first argument vector left and ANDing it with a mask. The
19081 second argument vector contains the mask beginning in bits 11:15,
19082 the mask end in bits 19:23, and the shift count in bits 27:31,
19085 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19088 vector signed bool char vec_revb (vector signed char);
19089 vector signed char vec_revb (vector signed char);
19090 vector unsigned char vec_revb (vector unsigned char);
19091 vector bool short vec_revb (vector bool short);
19092 vector short vec_revb (vector short);
19093 vector unsigned short vec_revb (vector unsigned short);
19094 vector bool int vec_revb (vector bool int);
19095 vector int vec_revb (vector int);
19096 vector unsigned int vec_revb (vector unsigned int);
19097 vector float vec_revb (vector float);
19098 vector bool long long vec_revb (vector bool long long);
19099 vector long long vec_revb (vector long long);
19100 vector unsigned long long vec_revb (vector unsigned long long);
19101 vector double vec_revb (vector double);
19104 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19107 vector long vec_revb (vector long);
19108 vector unsigned long vec_revb (vector unsigned long);
19109 vector __int128 vec_revb (vector __int128);
19110 vector __uint128 vec_revb (vector __uint128);
19113 The @code{vec_revb} built-in function reverses the bytes on an element
19114 by element basis. A vector of @code{vector unsigned char} or
19115 @code{vector signed char} reverses the bytes in the whole word.
19117 If the cryptographic instructions are enabled (@option{-mcrypto} or
19118 @option{-mcpu=power8}), the following builtins are enabled.
19121 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
19123 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
19124 vector unsigned long long);
19126 vector unsigned long long __builtin_crypto_vcipherlast
19127 (vector unsigned long long,
19128 vector unsigned long long);
19130 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
19131 vector unsigned long long);
19133 vector unsigned long long __builtin_crypto_vncipherlast (vector unsigned long long,
19134 vector unsigned long long);
19136 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
19137 vector unsigned char,
19138 vector unsigned char);
19140 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
19141 vector unsigned short,
19142 vector unsigned short);
19144 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
19145 vector unsigned int,
19146 vector unsigned int);
19148 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
19149 vector unsigned long long,
19150 vector unsigned long long);
19152 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
19153 vector unsigned char);
19155 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
19156 vector unsigned short);
19158 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
19159 vector unsigned int);
19161 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
19162 vector unsigned long long);
19164 vector unsigned long long __builtin_crypto_vshasigmad (vector unsigned long long,
19167 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int, int, int);
19170 The second argument to @var{__builtin_crypto_vshasigmad} and
19171 @var{__builtin_crypto_vshasigmaw} must be a constant
19172 integer that is 0 or 1. The third argument to these built-in functions
19173 must be a constant integer in the range of 0 to 15.
19175 If the ISA 3.0 instruction set additions
19176 are enabled (@option{-mcpu=power9}), the following additional
19177 functions are available for both 32-bit and 64-bit targets.
19179 vector short vec_xl (int, vector short *);
19180 vector short vec_xl (int, short *);
19181 vector unsigned short vec_xl (int, vector unsigned short *);
19182 vector unsigned short vec_xl (int, unsigned short *);
19183 vector char vec_xl (int, vector char *);
19184 vector char vec_xl (int, char *);
19185 vector unsigned char vec_xl (int, vector unsigned char *);
19186 vector unsigned char vec_xl (int, unsigned char *);
19188 void vec_xst (vector short, int, vector short *);
19189 void vec_xst (vector short, int, short *);
19190 void vec_xst (vector unsigned short, int, vector unsigned short *);
19191 void vec_xst (vector unsigned short, int, unsigned short *);
19192 void vec_xst (vector char, int, vector char *);
19193 void vec_xst (vector char, int, char *);
19194 void vec_xst (vector unsigned char, int, vector unsigned char *);
19195 void vec_xst (vector unsigned char, int, unsigned char *);
19197 @node PowerPC Hardware Transactional Memory Built-in Functions
19198 @subsection PowerPC Hardware Transactional Memory Built-in Functions
19199 GCC provides two interfaces for accessing the Hardware Transactional
19200 Memory (HTM) instructions available on some of the PowerPC family
19201 of processors (eg, POWER8). The two interfaces come in a low level
19202 interface, consisting of built-in functions specific to PowerPC and a
19203 higher level interface consisting of inline functions that are common
19204 between PowerPC and S/390.
19206 @subsubsection PowerPC HTM Low Level Built-in Functions
19208 The following low level built-in functions are available with
19209 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
19210 They all generate the machine instruction that is part of the name.
19212 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
19213 the full 4-bit condition register value set by their associated hardware
19214 instruction. The header file @code{htmintrin.h} defines some macros that can
19215 be used to decipher the return value. The @code{__builtin_tbegin} builtin
19216 returns a simple true or false value depending on whether a transaction was
19217 successfully started or not. The arguments of the builtins match exactly the
19218 type and order of the associated hardware instruction's operands, except for
19219 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
19220 Refer to the ISA manual for a description of each instruction's operands.
19223 unsigned int __builtin_tbegin (unsigned int)
19224 unsigned int __builtin_tend (unsigned int)
19226 unsigned int __builtin_tabort (unsigned int)
19227 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
19228 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
19229 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
19230 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
19232 unsigned int __builtin_tcheck (void)
19233 unsigned int __builtin_treclaim (unsigned int)
19234 unsigned int __builtin_trechkpt (void)
19235 unsigned int __builtin_tsr (unsigned int)
19238 In addition to the above HTM built-ins, we have added built-ins for
19239 some common extended mnemonics of the HTM instructions:
19242 unsigned int __builtin_tendall (void)
19243 unsigned int __builtin_tresume (void)
19244 unsigned int __builtin_tsuspend (void)
19247 Note that the semantics of the above HTM builtins are required to mimic
19248 the locking semantics used for critical sections. Builtins that are used
19249 to create a new transaction or restart a suspended transaction must have
19250 lock acquisition like semantics while those builtins that end or suspend a
19251 transaction must have lock release like semantics. Specifically, this must
19252 mimic lock semantics as specified by C++11, for example: Lock acquisition is
19253 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
19254 that returns 0, and lock release is as-if an execution of
19255 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
19256 implicit implementation-defined lock used for all transactions. The HTM
19257 instructions associated with with the builtins inherently provide the
19258 correct acquisition and release hardware barriers required. However,
19259 the compiler must also be prohibited from moving loads and stores across
19260 the builtins in a way that would violate their semantics. This has been
19261 accomplished by adding memory barriers to the associated HTM instructions
19262 (which is a conservative approach to provide acquire and release semantics).
19263 Earlier versions of the compiler did not treat the HTM instructions as
19264 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
19265 be used to determine whether the current compiler treats HTM instructions
19266 as memory barriers or not. This allows the user to explicitly add memory
19267 barriers to their code when using an older version of the compiler.
19269 The following set of built-in functions are available to gain access
19270 to the HTM specific special purpose registers.
19273 unsigned long __builtin_get_texasr (void)
19274 unsigned long __builtin_get_texasru (void)
19275 unsigned long __builtin_get_tfhar (void)
19276 unsigned long __builtin_get_tfiar (void)
19278 void __builtin_set_texasr (unsigned long);
19279 void __builtin_set_texasru (unsigned long);
19280 void __builtin_set_tfhar (unsigned long);
19281 void __builtin_set_tfiar (unsigned long);
19284 Example usage of these low level built-in functions may look like:
19287 #include <htmintrin.h>
19289 int num_retries = 10;
19293 if (__builtin_tbegin (0))
19295 /* Transaction State Initiated. */
19296 if (is_locked (lock))
19297 __builtin_tabort (0);
19298 ... transaction code...
19299 __builtin_tend (0);
19304 /* Transaction State Failed. Use locks if the transaction
19305 failure is "persistent" or we've tried too many times. */
19306 if (num_retries-- <= 0
19307 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
19309 acquire_lock (lock);
19310 ... non transactional fallback path...
19311 release_lock (lock);
19318 One final built-in function has been added that returns the value of
19319 the 2-bit Transaction State field of the Machine Status Register (MSR)
19320 as stored in @code{CR0}.
19323 unsigned long __builtin_ttest (void)
19326 This built-in can be used to determine the current transaction state
19327 using the following code example:
19330 #include <htmintrin.h>
19332 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
19334 if (tx_state == _HTM_TRANSACTIONAL)
19336 /* Code to use in transactional state. */
19338 else if (tx_state == _HTM_NONTRANSACTIONAL)
19340 /* Code to use in non-transactional state. */
19342 else if (tx_state == _HTM_SUSPENDED)
19344 /* Code to use in transaction suspended state. */
19348 @subsubsection PowerPC HTM High Level Inline Functions
19350 The following high level HTM interface is made available by including
19351 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
19352 where CPU is `power8' or later. This interface is common between PowerPC
19353 and S/390, allowing users to write one HTM source implementation that
19354 can be compiled and executed on either system.
19357 long __TM_simple_begin (void)
19358 long __TM_begin (void* const TM_buff)
19359 long __TM_end (void)
19360 void __TM_abort (void)
19361 void __TM_named_abort (unsigned char const code)
19362 void __TM_resume (void)
19363 void __TM_suspend (void)
19365 long __TM_is_user_abort (void* const TM_buff)
19366 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
19367 long __TM_is_illegal (void* const TM_buff)
19368 long __TM_is_footprint_exceeded (void* const TM_buff)
19369 long __TM_nesting_depth (void* const TM_buff)
19370 long __TM_is_nested_too_deep(void* const TM_buff)
19371 long __TM_is_conflict(void* const TM_buff)
19372 long __TM_is_failure_persistent(void* const TM_buff)
19373 long __TM_failure_address(void* const TM_buff)
19374 long long __TM_failure_code(void* const TM_buff)
19377 Using these common set of HTM inline functions, we can create
19378 a more portable version of the HTM example in the previous
19379 section that will work on either PowerPC or S/390:
19382 #include <htmxlintrin.h>
19384 int num_retries = 10;
19385 TM_buff_type TM_buff;
19389 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
19391 /* Transaction State Initiated. */
19392 if (is_locked (lock))
19394 ... transaction code...
19400 /* Transaction State Failed. Use locks if the transaction
19401 failure is "persistent" or we've tried too many times. */
19402 if (num_retries-- <= 0
19403 || __TM_is_failure_persistent (TM_buff))
19405 acquire_lock (lock);
19406 ... non transactional fallback path...
19407 release_lock (lock);
19414 @node PowerPC Atomic Memory Operation Functions
19415 @subsection PowerPC Atomic Memory Operation Functions
19416 ISA 3.0 of the PowerPC added new atomic memory operation (amo)
19417 instructions. GCC provides support for these instructions in 64-bit
19418 environments. All of the functions are declared in the include file
19421 The functions supported are:
19426 uint32_t amo_lwat_add (uint32_t *, uint32_t);
19427 uint32_t amo_lwat_xor (uint32_t *, uint32_t);
19428 uint32_t amo_lwat_ior (uint32_t *, uint32_t);
19429 uint32_t amo_lwat_and (uint32_t *, uint32_t);
19430 uint32_t amo_lwat_umax (uint32_t *, uint32_t);
19431 uint32_t amo_lwat_umin (uint32_t *, uint32_t);
19432 uint32_t amo_lwat_swap (uint32_t *, uint32_t);
19434 int32_t amo_lwat_sadd (int32_t *, int32_t);
19435 int32_t amo_lwat_smax (int32_t *, int32_t);
19436 int32_t amo_lwat_smin (int32_t *, int32_t);
19437 int32_t amo_lwat_sswap (int32_t *, int32_t);
19439 uint64_t amo_ldat_add (uint64_t *, uint64_t);
19440 uint64_t amo_ldat_xor (uint64_t *, uint64_t);
19441 uint64_t amo_ldat_ior (uint64_t *, uint64_t);
19442 uint64_t amo_ldat_and (uint64_t *, uint64_t);
19443 uint64_t amo_ldat_umax (uint64_t *, uint64_t);
19444 uint64_t amo_ldat_umin (uint64_t *, uint64_t);
19445 uint64_t amo_ldat_swap (uint64_t *, uint64_t);
19447 int64_t amo_ldat_sadd (int64_t *, int64_t);
19448 int64_t amo_ldat_smax (int64_t *, int64_t);
19449 int64_t amo_ldat_smin (int64_t *, int64_t);
19450 int64_t amo_ldat_sswap (int64_t *, int64_t);
19452 void amo_stwat_add (uint32_t *, uint32_t);
19453 void amo_stwat_xor (uint32_t *, uint32_t);
19454 void amo_stwat_ior (uint32_t *, uint32_t);
19455 void amo_stwat_and (uint32_t *, uint32_t);
19456 void amo_stwat_umax (uint32_t *, uint32_t);
19457 void amo_stwat_umin (uint32_t *, uint32_t);
19459 void amo_stwat_sadd (int32_t *, int32_t);
19460 void amo_stwat_smax (int32_t *, int32_t);
19461 void amo_stwat_smin (int32_t *, int32_t);
19463 void amo_stdat_add (uint64_t *, uint64_t);
19464 void amo_stdat_xor (uint64_t *, uint64_t);
19465 void amo_stdat_ior (uint64_t *, uint64_t);
19466 void amo_stdat_and (uint64_t *, uint64_t);
19467 void amo_stdat_umax (uint64_t *, uint64_t);
19468 void amo_stdat_umin (uint64_t *, uint64_t);
19470 void amo_stdat_sadd (int64_t *, int64_t);
19471 void amo_stdat_smax (int64_t *, int64_t);
19472 void amo_stdat_smin (int64_t *, int64_t);
19475 @node RX Built-in Functions
19476 @subsection RX Built-in Functions
19477 GCC supports some of the RX instructions which cannot be expressed in
19478 the C programming language via the use of built-in functions. The
19479 following functions are supported:
19481 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
19482 Generates the @code{brk} machine instruction.
19485 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
19486 Generates the @code{clrpsw} machine instruction to clear the specified
19487 bit in the processor status word.
19490 @deftypefn {Built-in Function} void __builtin_rx_int (int)
19491 Generates the @code{int} machine instruction to generate an interrupt
19492 with the specified value.
19495 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
19496 Generates the @code{machi} machine instruction to add the result of
19497 multiplying the top 16 bits of the two arguments into the
19501 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
19502 Generates the @code{maclo} machine instruction to add the result of
19503 multiplying the bottom 16 bits of the two arguments into the
19507 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
19508 Generates the @code{mulhi} machine instruction to place the result of
19509 multiplying the top 16 bits of the two arguments into the
19513 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
19514 Generates the @code{mullo} machine instruction to place the result of
19515 multiplying the bottom 16 bits of the two arguments into the
19519 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
19520 Generates the @code{mvfachi} machine instruction to read the top
19521 32 bits of the accumulator.
19524 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
19525 Generates the @code{mvfacmi} machine instruction to read the middle
19526 32 bits of the accumulator.
19529 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
19530 Generates the @code{mvfc} machine instruction which reads the control
19531 register specified in its argument and returns its value.
19534 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
19535 Generates the @code{mvtachi} machine instruction to set the top
19536 32 bits of the accumulator.
19539 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
19540 Generates the @code{mvtaclo} machine instruction to set the bottom
19541 32 bits of the accumulator.
19544 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
19545 Generates the @code{mvtc} machine instruction which sets control
19546 register number @code{reg} to @code{val}.
19549 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
19550 Generates the @code{mvtipl} machine instruction set the interrupt
19554 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
19555 Generates the @code{racw} machine instruction to round the accumulator
19556 according to the specified mode.
19559 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
19560 Generates the @code{revw} machine instruction which swaps the bytes in
19561 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
19562 and also bits 16--23 occupy bits 24--31 and vice versa.
19565 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
19566 Generates the @code{rmpa} machine instruction which initiates a
19567 repeated multiply and accumulate sequence.
19570 @deftypefn {Built-in Function} void __builtin_rx_round (float)
19571 Generates the @code{round} machine instruction which returns the
19572 floating-point argument rounded according to the current rounding mode
19573 set in the floating-point status word register.
19576 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
19577 Generates the @code{sat} machine instruction which returns the
19578 saturated value of the argument.
19581 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
19582 Generates the @code{setpsw} machine instruction to set the specified
19583 bit in the processor status word.
19586 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
19587 Generates the @code{wait} machine instruction.
19590 @node S/390 System z Built-in Functions
19591 @subsection S/390 System z Built-in Functions
19592 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
19593 Generates the @code{tbegin} machine instruction starting a
19594 non-constrained hardware transaction. If the parameter is non-NULL the
19595 memory area is used to store the transaction diagnostic buffer and
19596 will be passed as first operand to @code{tbegin}. This buffer can be
19597 defined using the @code{struct __htm_tdb} C struct defined in
19598 @code{htmintrin.h} and must reside on a double-word boundary. The
19599 second tbegin operand is set to @code{0xff0c}. This enables
19600 save/restore of all GPRs and disables aborts for FPR and AR
19601 manipulations inside the transaction body. The condition code set by
19602 the tbegin instruction is returned as integer value. The tbegin
19603 instruction by definition overwrites the content of all FPRs. The
19604 compiler will generate code which saves and restores the FPRs. For
19605 soft-float code it is recommended to used the @code{*_nofloat}
19606 variant. In order to prevent a TDB from being written it is required
19607 to pass a constant zero value as parameter. Passing a zero value
19608 through a variable is not sufficient. Although modifications of
19609 access registers inside the transaction will not trigger an
19610 transaction abort it is not supported to actually modify them. Access
19611 registers do not get saved when entering a transaction. They will have
19612 undefined state when reaching the abort code.
19615 Macros for the possible return codes of tbegin are defined in the
19616 @code{htmintrin.h} header file:
19619 @item _HTM_TBEGIN_STARTED
19620 @code{tbegin} has been executed as part of normal processing. The
19621 transaction body is supposed to be executed.
19622 @item _HTM_TBEGIN_INDETERMINATE
19623 The transaction was aborted due to an indeterminate condition which
19624 might be persistent.
19625 @item _HTM_TBEGIN_TRANSIENT
19626 The transaction aborted due to a transient failure. The transaction
19627 should be re-executed in that case.
19628 @item _HTM_TBEGIN_PERSISTENT
19629 The transaction aborted due to a persistent failure. Re-execution
19630 under same circumstances will not be productive.
19633 @defmac _HTM_FIRST_USER_ABORT_CODE
19634 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
19635 specifies the first abort code which can be used for
19636 @code{__builtin_tabort}. Values below this threshold are reserved for
19640 @deftp {Data type} {struct __htm_tdb}
19641 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
19642 the structure of the transaction diagnostic block as specified in the
19643 Principles of Operation manual chapter 5-91.
19646 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
19647 Same as @code{__builtin_tbegin} but without FPR saves and restores.
19648 Using this variant in code making use of FPRs will leave the FPRs in
19649 undefined state when entering the transaction abort handler code.
19652 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
19653 In addition to @code{__builtin_tbegin} a loop for transient failures
19654 is generated. If tbegin returns a condition code of 2 the transaction
19655 will be retried as often as specified in the second argument. The
19656 perform processor assist instruction is used to tell the CPU about the
19657 number of fails so far.
19660 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
19661 Same as @code{__builtin_tbegin_retry} but without FPR saves and
19662 restores. Using this variant in code making use of FPRs will leave
19663 the FPRs in undefined state when entering the transaction abort
19667 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
19668 Generates the @code{tbeginc} machine instruction starting a constrained
19669 hardware transaction. The second operand is set to @code{0xff08}.
19672 @deftypefn {Built-in Function} int __builtin_tend (void)
19673 Generates the @code{tend} machine instruction finishing a transaction
19674 and making the changes visible to other threads. The condition code
19675 generated by tend is returned as integer value.
19678 @deftypefn {Built-in Function} void __builtin_tabort (int)
19679 Generates the @code{tabort} machine instruction with the specified
19680 abort code. Abort codes from 0 through 255 are reserved and will
19681 result in an error message.
19684 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
19685 Generates the @code{ppa rX,rY,1} machine instruction. Where the
19686 integer parameter is loaded into rX and a value of zero is loaded into
19687 rY. The integer parameter specifies the number of times the
19688 transaction repeatedly aborted.
19691 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
19692 Generates the @code{etnd} machine instruction. The current nesting
19693 depth is returned as integer value. For a nesting depth of 0 the code
19694 is not executed as part of an transaction.
19697 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
19699 Generates the @code{ntstg} machine instruction. The second argument
19700 is written to the first arguments location. The store operation will
19701 not be rolled-back in case of an transaction abort.
19704 @node SH Built-in Functions
19705 @subsection SH Built-in Functions
19706 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
19707 families of processors:
19709 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
19710 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
19711 used by system code that manages threads and execution contexts. The compiler
19712 normally does not generate code that modifies the contents of @samp{GBR} and
19713 thus the value is preserved across function calls. Changing the @samp{GBR}
19714 value in user code must be done with caution, since the compiler might use
19715 @samp{GBR} in order to access thread local variables.
19719 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
19720 Returns the value that is currently set in the @samp{GBR} register.
19721 Memory loads and stores that use the thread pointer as a base address are
19722 turned into @samp{GBR} based displacement loads and stores, if possible.
19730 int get_tcb_value (void)
19732 // Generate @samp{mov.l @@(8,gbr),r0} instruction
19733 return ((my_tcb*)__builtin_thread_pointer ())->c;
19739 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
19740 Returns the value that is currently set in the @samp{FPSCR} register.
19743 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
19744 Sets the @samp{FPSCR} register to the specified value @var{val}, while
19745 preserving the current values of the FR, SZ and PR bits.
19748 @node SPARC VIS Built-in Functions
19749 @subsection SPARC VIS Built-in Functions
19751 GCC supports SIMD operations on the SPARC using both the generic vector
19752 extensions (@pxref{Vector Extensions}) as well as built-in functions for
19753 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
19754 switch, the VIS extension is exposed as the following built-in functions:
19757 typedef int v1si __attribute__ ((vector_size (4)));
19758 typedef int v2si __attribute__ ((vector_size (8)));
19759 typedef short v4hi __attribute__ ((vector_size (8)));
19760 typedef short v2hi __attribute__ ((vector_size (4)));
19761 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
19762 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
19764 void __builtin_vis_write_gsr (int64_t);
19765 int64_t __builtin_vis_read_gsr (void);
19767 void * __builtin_vis_alignaddr (void *, long);
19768 void * __builtin_vis_alignaddrl (void *, long);
19769 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
19770 v2si __builtin_vis_faligndatav2si (v2si, v2si);
19771 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
19772 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
19774 v4hi __builtin_vis_fexpand (v4qi);
19776 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
19777 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
19778 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
19779 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
19780 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
19781 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
19782 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
19784 v4qi __builtin_vis_fpack16 (v4hi);
19785 v8qi __builtin_vis_fpack32 (v2si, v8qi);
19786 v2hi __builtin_vis_fpackfix (v2si);
19787 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
19789 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
19791 long __builtin_vis_edge8 (void *, void *);
19792 long __builtin_vis_edge8l (void *, void *);
19793 long __builtin_vis_edge16 (void *, void *);
19794 long __builtin_vis_edge16l (void *, void *);
19795 long __builtin_vis_edge32 (void *, void *);
19796 long __builtin_vis_edge32l (void *, void *);
19798 long __builtin_vis_fcmple16 (v4hi, v4hi);
19799 long __builtin_vis_fcmple32 (v2si, v2si);
19800 long __builtin_vis_fcmpne16 (v4hi, v4hi);
19801 long __builtin_vis_fcmpne32 (v2si, v2si);
19802 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
19803 long __builtin_vis_fcmpgt32 (v2si, v2si);
19804 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
19805 long __builtin_vis_fcmpeq32 (v2si, v2si);
19807 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
19808 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
19809 v2si __builtin_vis_fpadd32 (v2si, v2si);
19810 v1si __builtin_vis_fpadd32s (v1si, v1si);
19811 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
19812 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
19813 v2si __builtin_vis_fpsub32 (v2si, v2si);
19814 v1si __builtin_vis_fpsub32s (v1si, v1si);
19816 long __builtin_vis_array8 (long, long);
19817 long __builtin_vis_array16 (long, long);
19818 long __builtin_vis_array32 (long, long);
19821 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
19822 functions also become available:
19825 long __builtin_vis_bmask (long, long);
19826 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
19827 v2si __builtin_vis_bshufflev2si (v2si, v2si);
19828 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
19829 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
19831 long __builtin_vis_edge8n (void *, void *);
19832 long __builtin_vis_edge8ln (void *, void *);
19833 long __builtin_vis_edge16n (void *, void *);
19834 long __builtin_vis_edge16ln (void *, void *);
19835 long __builtin_vis_edge32n (void *, void *);
19836 long __builtin_vis_edge32ln (void *, void *);
19839 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
19840 functions also become available:
19843 void __builtin_vis_cmask8 (long);
19844 void __builtin_vis_cmask16 (long);
19845 void __builtin_vis_cmask32 (long);
19847 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
19849 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
19850 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
19851 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
19852 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
19853 v2si __builtin_vis_fsll16 (v2si, v2si);
19854 v2si __builtin_vis_fslas16 (v2si, v2si);
19855 v2si __builtin_vis_fsrl16 (v2si, v2si);
19856 v2si __builtin_vis_fsra16 (v2si, v2si);
19858 long __builtin_vis_pdistn (v8qi, v8qi);
19860 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
19862 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
19863 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
19865 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
19866 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
19867 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
19868 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
19869 v2si __builtin_vis_fpadds32 (v2si, v2si);
19870 v1si __builtin_vis_fpadds32s (v1si, v1si);
19871 v2si __builtin_vis_fpsubs32 (v2si, v2si);
19872 v1si __builtin_vis_fpsubs32s (v1si, v1si);
19874 long __builtin_vis_fucmple8 (v8qi, v8qi);
19875 long __builtin_vis_fucmpne8 (v8qi, v8qi);
19876 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
19877 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
19879 float __builtin_vis_fhadds (float, float);
19880 double __builtin_vis_fhaddd (double, double);
19881 float __builtin_vis_fhsubs (float, float);
19882 double __builtin_vis_fhsubd (double, double);
19883 float __builtin_vis_fnhadds (float, float);
19884 double __builtin_vis_fnhaddd (double, double);
19886 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
19887 int64_t __builtin_vis_xmulx (int64_t, int64_t);
19888 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
19891 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
19892 functions also become available:
19895 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
19896 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
19897 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
19898 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
19900 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
19901 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
19902 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
19903 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
19905 long __builtin_vis_fpcmple8 (v8qi, v8qi);
19906 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
19907 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
19908 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
19909 long __builtin_vis_fpcmpule32 (v2si, v2si);
19910 long __builtin_vis_fpcmpugt32 (v2si, v2si);
19912 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
19913 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
19914 v2si __builtin_vis_fpmax32 (v2si, v2si);
19916 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
19917 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
19918 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
19921 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
19922 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
19923 v2si __builtin_vis_fpmin32 (v2si, v2si);
19925 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
19926 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
19927 v2si __builtin_vis_fpminu32 (v2si, v2si);
19930 When you use the @option{-mvis4b} switch, the VIS version 4.0B
19931 built-in functions also become available:
19934 v8qi __builtin_vis_dictunpack8 (double, int);
19935 v4hi __builtin_vis_dictunpack16 (double, int);
19936 v2si __builtin_vis_dictunpack32 (double, int);
19938 long __builtin_vis_fpcmple8shl (v8qi, v8qi, int);
19939 long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int);
19940 long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int);
19941 long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int);
19943 long __builtin_vis_fpcmple16shl (v4hi, v4hi, int);
19944 long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int);
19945 long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int);
19946 long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int);
19948 long __builtin_vis_fpcmple32shl (v2si, v2si, int);
19949 long __builtin_vis_fpcmpgt32shl (v2si, v2si, int);
19950 long __builtin_vis_fpcmpeq32shl (v2si, v2si, int);
19951 long __builtin_vis_fpcmpne32shl (v2si, v2si, int);
19953 long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int);
19954 long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int);
19955 long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int);
19956 long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int);
19957 long __builtin_vis_fpcmpule32shl (v2si, v2si, int);
19958 long __builtin_vis_fpcmpugt32shl (v2si, v2si, int);
19960 long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int);
19961 long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int);
19962 long __builtin_vis_fpcmpde32shl (v2si, v2si, int);
19964 long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int);
19965 long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int);
19966 long __builtin_vis_fpcmpur32shl (v2si, v2si, int);
19969 @node SPU Built-in Functions
19970 @subsection SPU Built-in Functions
19972 GCC provides extensions for the SPU processor as described in the
19973 Sony/Toshiba/IBM SPU Language Extensions Specification. GCC's
19974 implementation differs in several ways.
19979 The optional extension of specifying vector constants in parentheses is
19983 A vector initializer requires no cast if the vector constant is of the
19984 same type as the variable it is initializing.
19987 If @code{signed} or @code{unsigned} is omitted, the signedness of the
19988 vector type is the default signedness of the base type. The default
19989 varies depending on the operating system, so a portable program should
19990 always specify the signedness.
19993 By default, the keyword @code{__vector} is added. The macro
19994 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
19998 GCC allows using a @code{typedef} name as the type specifier for a
20002 For C, overloaded functions are implemented with macros so the following
20006 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
20010 Since @code{spu_add} is a macro, the vector constant in the example
20011 is treated as four separate arguments. Wrap the entire argument in
20012 parentheses for this to work.
20015 The extended version of @code{__builtin_expect} is not supported.
20019 @emph{Note:} Only the interface described in the aforementioned
20020 specification is supported. Internally, GCC uses built-in functions to
20021 implement the required functionality, but these are not supported and
20022 are subject to change without notice.
20024 @node TI C6X Built-in Functions
20025 @subsection TI C6X Built-in Functions
20027 GCC provides intrinsics to access certain instructions of the TI C6X
20028 processors. These intrinsics, listed below, are available after
20029 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
20030 to C6X instructions.
20034 int _sadd (int, int)
20035 int _ssub (int, int)
20036 int _sadd2 (int, int)
20037 int _ssub2 (int, int)
20038 long long _mpy2 (int, int)
20039 long long _smpy2 (int, int)
20040 int _add4 (int, int)
20041 int _sub4 (int, int)
20042 int _saddu4 (int, int)
20044 int _smpy (int, int)
20045 int _smpyh (int, int)
20046 int _smpyhl (int, int)
20047 int _smpylh (int, int)
20049 int _sshl (int, int)
20050 int _subc (int, int)
20052 int _avg2 (int, int)
20053 int _avgu4 (int, int)
20055 int _clrr (int, int)
20056 int _extr (int, int)
20057 int _extru (int, int)
20063 @node TILE-Gx Built-in Functions
20064 @subsection TILE-Gx Built-in Functions
20066 GCC provides intrinsics to access every instruction of the TILE-Gx
20067 processor. The intrinsics are of the form:
20071 unsigned long long __insn_@var{op} (...)
20075 Where @var{op} is the name of the instruction. Refer to the ISA manual
20076 for the complete list of instructions.
20078 GCC also provides intrinsics to directly access the network registers.
20079 The intrinsics are:
20083 unsigned long long __tile_idn0_receive (void)
20084 unsigned long long __tile_idn1_receive (void)
20085 unsigned long long __tile_udn0_receive (void)
20086 unsigned long long __tile_udn1_receive (void)
20087 unsigned long long __tile_udn2_receive (void)
20088 unsigned long long __tile_udn3_receive (void)
20089 void __tile_idn_send (unsigned long long)
20090 void __tile_udn_send (unsigned long long)
20094 The intrinsic @code{void __tile_network_barrier (void)} is used to
20095 guarantee that no network operations before it are reordered with
20098 @node TILEPro Built-in Functions
20099 @subsection TILEPro Built-in Functions
20101 GCC provides intrinsics to access every instruction of the TILEPro
20102 processor. The intrinsics are of the form:
20106 unsigned __insn_@var{op} (...)
20111 where @var{op} is the name of the instruction. Refer to the ISA manual
20112 for the complete list of instructions.
20114 GCC also provides intrinsics to directly access the network registers.
20115 The intrinsics are:
20119 unsigned __tile_idn0_receive (void)
20120 unsigned __tile_idn1_receive (void)
20121 unsigned __tile_sn_receive (void)
20122 unsigned __tile_udn0_receive (void)
20123 unsigned __tile_udn1_receive (void)
20124 unsigned __tile_udn2_receive (void)
20125 unsigned __tile_udn3_receive (void)
20126 void __tile_idn_send (unsigned)
20127 void __tile_sn_send (unsigned)
20128 void __tile_udn_send (unsigned)
20132 The intrinsic @code{void __tile_network_barrier (void)} is used to
20133 guarantee that no network operations before it are reordered with
20136 @node x86 Built-in Functions
20137 @subsection x86 Built-in Functions
20139 These built-in functions are available for the x86-32 and x86-64 family
20140 of computers, depending on the command-line switches used.
20142 If you specify command-line switches such as @option{-msse},
20143 the compiler could use the extended instruction sets even if the built-ins
20144 are not used explicitly in the program. For this reason, applications
20145 that perform run-time CPU detection must compile separate files for each
20146 supported architecture, using the appropriate flags. In particular,
20147 the file containing the CPU detection code should be compiled without
20150 The following machine modes are available for use with MMX built-in functions
20151 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
20152 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
20153 vector of eight 8-bit integers. Some of the built-in functions operate on
20154 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
20156 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
20157 of two 32-bit floating-point values.
20159 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
20160 floating-point values. Some instructions use a vector of four 32-bit
20161 integers, these use @code{V4SI}. Finally, some instructions operate on an
20162 entire vector register, interpreting it as a 128-bit integer, these use mode
20165 The x86-32 and x86-64 family of processors use additional built-in
20166 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
20167 floating point and @code{TC} 128-bit complex floating-point values.
20169 The following floating-point built-in functions are always available. All
20170 of them implement the function that is part of the name.
20173 __float128 __builtin_fabsq (__float128)
20174 __float128 __builtin_copysignq (__float128, __float128)
20177 The following built-in functions are always available.
20180 @item __float128 __builtin_infq (void)
20181 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
20182 @findex __builtin_infq
20184 @item __float128 __builtin_huge_valq (void)
20185 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
20186 @findex __builtin_huge_valq
20188 @item __float128 __builtin_nanq (void)
20189 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
20190 @findex __builtin_nanq
20192 @item __float128 __builtin_nansq (void)
20193 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
20194 @findex __builtin_nansq
20197 The following built-in function is always available.
20200 @item void __builtin_ia32_pause (void)
20201 Generates the @code{pause} machine instruction with a compiler memory
20205 The following built-in functions are always available and can be used to
20206 check the target platform type.
20208 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
20209 This function runs the CPU detection code to check the type of CPU and the
20210 features supported. This built-in function needs to be invoked along with the built-in functions
20211 to check CPU type and features, @code{__builtin_cpu_is} and
20212 @code{__builtin_cpu_supports}, only when used in a function that is
20213 executed before any constructors are called. The CPU detection code is
20214 automatically executed in a very high priority constructor.
20216 For example, this function has to be used in @code{ifunc} resolvers that
20217 check for CPU type using the built-in functions @code{__builtin_cpu_is}
20218 and @code{__builtin_cpu_supports}, or in constructors on targets that
20219 don't support constructor priority.
20222 static void (*resolve_memcpy (void)) (void)
20224 // ifunc resolvers fire before constructors, explicitly call the init
20226 __builtin_cpu_init ();
20227 if (__builtin_cpu_supports ("ssse3"))
20228 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
20230 return default_memcpy;
20233 void *memcpy (void *, const void *, size_t)
20234 __attribute__ ((ifunc ("resolve_memcpy")));
20239 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
20240 This function returns a positive integer if the run-time CPU
20241 is of type @var{cpuname}
20242 and returns @code{0} otherwise. The following CPU names can be detected:
20258 Intel Core i7 Nehalem CPU.
20261 Intel Core i7 Westmere CPU.
20264 Intel Core i7 Sandy Bridge CPU.
20270 AMD Family 10h CPU.
20273 AMD Family 10h Barcelona CPU.
20276 AMD Family 10h Shanghai CPU.
20279 AMD Family 10h Istanbul CPU.
20282 AMD Family 14h CPU.
20285 AMD Family 15h CPU.
20288 AMD Family 15h Bulldozer version 1.
20291 AMD Family 15h Bulldozer version 2.
20294 AMD Family 15h Bulldozer version 3.
20297 AMD Family 15h Bulldozer version 4.
20300 AMD Family 16h CPU.
20303 AMD Family 17h CPU.
20306 AMD Family 17h Zen version 1.
20309 Here is an example:
20311 if (__builtin_cpu_is ("corei7"))
20313 do_corei7 (); // Core i7 specific implementation.
20317 do_generic (); // Generic implementation.
20322 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
20323 This function returns a positive integer if the run-time CPU
20324 supports @var{feature}
20325 and returns @code{0} otherwise. The following features can be detected:
20333 POPCNT instruction.
20341 SSSE3 instructions.
20343 SSE4.1 instructions.
20345 SSE4.2 instructions.
20351 AVX512F instructions.
20354 Here is an example:
20356 if (__builtin_cpu_supports ("popcnt"))
20358 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
20362 count = generic_countbits (n); //generic implementation.
20368 The following built-in functions are made available by @option{-mmmx}.
20369 All of them generate the machine instruction that is part of the name.
20372 v8qi __builtin_ia32_paddb (v8qi, v8qi)
20373 v4hi __builtin_ia32_paddw (v4hi, v4hi)
20374 v2si __builtin_ia32_paddd (v2si, v2si)
20375 v8qi __builtin_ia32_psubb (v8qi, v8qi)
20376 v4hi __builtin_ia32_psubw (v4hi, v4hi)
20377 v2si __builtin_ia32_psubd (v2si, v2si)
20378 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
20379 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
20380 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
20381 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
20382 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
20383 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
20384 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
20385 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
20386 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
20387 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
20388 di __builtin_ia32_pand (di, di)
20389 di __builtin_ia32_pandn (di,di)
20390 di __builtin_ia32_por (di, di)
20391 di __builtin_ia32_pxor (di, di)
20392 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
20393 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
20394 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
20395 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
20396 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
20397 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
20398 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
20399 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
20400 v2si __builtin_ia32_punpckhdq (v2si, v2si)
20401 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
20402 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
20403 v2si __builtin_ia32_punpckldq (v2si, v2si)
20404 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
20405 v4hi __builtin_ia32_packssdw (v2si, v2si)
20406 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
20408 v4hi __builtin_ia32_psllw (v4hi, v4hi)
20409 v2si __builtin_ia32_pslld (v2si, v2si)
20410 v1di __builtin_ia32_psllq (v1di, v1di)
20411 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
20412 v2si __builtin_ia32_psrld (v2si, v2si)
20413 v1di __builtin_ia32_psrlq (v1di, v1di)
20414 v4hi __builtin_ia32_psraw (v4hi, v4hi)
20415 v2si __builtin_ia32_psrad (v2si, v2si)
20416 v4hi __builtin_ia32_psllwi (v4hi, int)
20417 v2si __builtin_ia32_pslldi (v2si, int)
20418 v1di __builtin_ia32_psllqi (v1di, int)
20419 v4hi __builtin_ia32_psrlwi (v4hi, int)
20420 v2si __builtin_ia32_psrldi (v2si, int)
20421 v1di __builtin_ia32_psrlqi (v1di, int)
20422 v4hi __builtin_ia32_psrawi (v4hi, int)
20423 v2si __builtin_ia32_psradi (v2si, int)
20427 The following built-in functions are made available either with
20428 @option{-msse}, or with @option{-m3dnowa}. All of them generate
20429 the machine instruction that is part of the name.
20432 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
20433 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
20434 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
20435 v1di __builtin_ia32_psadbw (v8qi, v8qi)
20436 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
20437 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
20438 v8qi __builtin_ia32_pminub (v8qi, v8qi)
20439 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
20440 int __builtin_ia32_pmovmskb (v8qi)
20441 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
20442 void __builtin_ia32_movntq (di *, di)
20443 void __builtin_ia32_sfence (void)
20446 The following built-in functions are available when @option{-msse} is used.
20447 All of them generate the machine instruction that is part of the name.
20450 int __builtin_ia32_comieq (v4sf, v4sf)
20451 int __builtin_ia32_comineq (v4sf, v4sf)
20452 int __builtin_ia32_comilt (v4sf, v4sf)
20453 int __builtin_ia32_comile (v4sf, v4sf)
20454 int __builtin_ia32_comigt (v4sf, v4sf)
20455 int __builtin_ia32_comige (v4sf, v4sf)
20456 int __builtin_ia32_ucomieq (v4sf, v4sf)
20457 int __builtin_ia32_ucomineq (v4sf, v4sf)
20458 int __builtin_ia32_ucomilt (v4sf, v4sf)
20459 int __builtin_ia32_ucomile (v4sf, v4sf)
20460 int __builtin_ia32_ucomigt (v4sf, v4sf)
20461 int __builtin_ia32_ucomige (v4sf, v4sf)
20462 v4sf __builtin_ia32_addps (v4sf, v4sf)
20463 v4sf __builtin_ia32_subps (v4sf, v4sf)
20464 v4sf __builtin_ia32_mulps (v4sf, v4sf)
20465 v4sf __builtin_ia32_divps (v4sf, v4sf)
20466 v4sf __builtin_ia32_addss (v4sf, v4sf)
20467 v4sf __builtin_ia32_subss (v4sf, v4sf)
20468 v4sf __builtin_ia32_mulss (v4sf, v4sf)
20469 v4sf __builtin_ia32_divss (v4sf, v4sf)
20470 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
20471 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
20472 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
20473 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
20474 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
20475 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
20476 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
20477 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
20478 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
20479 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
20480 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
20481 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
20482 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
20483 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
20484 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
20485 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
20486 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
20487 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
20488 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
20489 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
20490 v4sf __builtin_ia32_maxps (v4sf, v4sf)
20491 v4sf __builtin_ia32_maxss (v4sf, v4sf)
20492 v4sf __builtin_ia32_minps (v4sf, v4sf)
20493 v4sf __builtin_ia32_minss (v4sf, v4sf)
20494 v4sf __builtin_ia32_andps (v4sf, v4sf)
20495 v4sf __builtin_ia32_andnps (v4sf, v4sf)
20496 v4sf __builtin_ia32_orps (v4sf, v4sf)
20497 v4sf __builtin_ia32_xorps (v4sf, v4sf)
20498 v4sf __builtin_ia32_movss (v4sf, v4sf)
20499 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
20500 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
20501 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
20502 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
20503 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
20504 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
20505 v2si __builtin_ia32_cvtps2pi (v4sf)
20506 int __builtin_ia32_cvtss2si (v4sf)
20507 v2si __builtin_ia32_cvttps2pi (v4sf)
20508 int __builtin_ia32_cvttss2si (v4sf)
20509 v4sf __builtin_ia32_rcpps (v4sf)
20510 v4sf __builtin_ia32_rsqrtps (v4sf)
20511 v4sf __builtin_ia32_sqrtps (v4sf)
20512 v4sf __builtin_ia32_rcpss (v4sf)
20513 v4sf __builtin_ia32_rsqrtss (v4sf)
20514 v4sf __builtin_ia32_sqrtss (v4sf)
20515 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
20516 void __builtin_ia32_movntps (float *, v4sf)
20517 int __builtin_ia32_movmskps (v4sf)
20520 The following built-in functions are available when @option{-msse} is used.
20523 @item v4sf __builtin_ia32_loadups (float *)
20524 Generates the @code{movups} machine instruction as a load from memory.
20525 @item void __builtin_ia32_storeups (float *, v4sf)
20526 Generates the @code{movups} machine instruction as a store to memory.
20527 @item v4sf __builtin_ia32_loadss (float *)
20528 Generates the @code{movss} machine instruction as a load from memory.
20529 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
20530 Generates the @code{movhps} machine instruction as a load from memory.
20531 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
20532 Generates the @code{movlps} machine instruction as a load from memory
20533 @item void __builtin_ia32_storehps (v2sf *, v4sf)
20534 Generates the @code{movhps} machine instruction as a store to memory.
20535 @item void __builtin_ia32_storelps (v2sf *, v4sf)
20536 Generates the @code{movlps} machine instruction as a store to memory.
20539 The following built-in functions are available when @option{-msse2} is used.
20540 All of them generate the machine instruction that is part of the name.
20543 int __builtin_ia32_comisdeq (v2df, v2df)
20544 int __builtin_ia32_comisdlt (v2df, v2df)
20545 int __builtin_ia32_comisdle (v2df, v2df)
20546 int __builtin_ia32_comisdgt (v2df, v2df)
20547 int __builtin_ia32_comisdge (v2df, v2df)
20548 int __builtin_ia32_comisdneq (v2df, v2df)
20549 int __builtin_ia32_ucomisdeq (v2df, v2df)
20550 int __builtin_ia32_ucomisdlt (v2df, v2df)
20551 int __builtin_ia32_ucomisdle (v2df, v2df)
20552 int __builtin_ia32_ucomisdgt (v2df, v2df)
20553 int __builtin_ia32_ucomisdge (v2df, v2df)
20554 int __builtin_ia32_ucomisdneq (v2df, v2df)
20555 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
20556 v2df __builtin_ia32_cmpltpd (v2df, v2df)
20557 v2df __builtin_ia32_cmplepd (v2df, v2df)
20558 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
20559 v2df __builtin_ia32_cmpgepd (v2df, v2df)
20560 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
20561 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
20562 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
20563 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
20564 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
20565 v2df __builtin_ia32_cmpngepd (v2df, v2df)
20566 v2df __builtin_ia32_cmpordpd (v2df, v2df)
20567 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
20568 v2df __builtin_ia32_cmpltsd (v2df, v2df)
20569 v2df __builtin_ia32_cmplesd (v2df, v2df)
20570 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
20571 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
20572 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
20573 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
20574 v2df __builtin_ia32_cmpordsd (v2df, v2df)
20575 v2di __builtin_ia32_paddq (v2di, v2di)
20576 v2di __builtin_ia32_psubq (v2di, v2di)
20577 v2df __builtin_ia32_addpd (v2df, v2df)
20578 v2df __builtin_ia32_subpd (v2df, v2df)
20579 v2df __builtin_ia32_mulpd (v2df, v2df)
20580 v2df __builtin_ia32_divpd (v2df, v2df)
20581 v2df __builtin_ia32_addsd (v2df, v2df)
20582 v2df __builtin_ia32_subsd (v2df, v2df)
20583 v2df __builtin_ia32_mulsd (v2df, v2df)
20584 v2df __builtin_ia32_divsd (v2df, v2df)
20585 v2df __builtin_ia32_minpd (v2df, v2df)
20586 v2df __builtin_ia32_maxpd (v2df, v2df)
20587 v2df __builtin_ia32_minsd (v2df, v2df)
20588 v2df __builtin_ia32_maxsd (v2df, v2df)
20589 v2df __builtin_ia32_andpd (v2df, v2df)
20590 v2df __builtin_ia32_andnpd (v2df, v2df)
20591 v2df __builtin_ia32_orpd (v2df, v2df)
20592 v2df __builtin_ia32_xorpd (v2df, v2df)
20593 v2df __builtin_ia32_movsd (v2df, v2df)
20594 v2df __builtin_ia32_unpckhpd (v2df, v2df)
20595 v2df __builtin_ia32_unpcklpd (v2df, v2df)
20596 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
20597 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
20598 v4si __builtin_ia32_paddd128 (v4si, v4si)
20599 v2di __builtin_ia32_paddq128 (v2di, v2di)
20600 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
20601 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
20602 v4si __builtin_ia32_psubd128 (v4si, v4si)
20603 v2di __builtin_ia32_psubq128 (v2di, v2di)
20604 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
20605 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
20606 v2di __builtin_ia32_pand128 (v2di, v2di)
20607 v2di __builtin_ia32_pandn128 (v2di, v2di)
20608 v2di __builtin_ia32_por128 (v2di, v2di)
20609 v2di __builtin_ia32_pxor128 (v2di, v2di)
20610 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
20611 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
20612 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
20613 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
20614 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
20615 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
20616 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
20617 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
20618 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
20619 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
20620 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
20621 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
20622 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
20623 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
20624 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
20625 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
20626 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
20627 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
20628 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
20629 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
20630 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
20631 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
20632 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
20633 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
20634 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
20635 v2df __builtin_ia32_loadupd (double *)
20636 void __builtin_ia32_storeupd (double *, v2df)
20637 v2df __builtin_ia32_loadhpd (v2df, double const *)
20638 v2df __builtin_ia32_loadlpd (v2df, double const *)
20639 int __builtin_ia32_movmskpd (v2df)
20640 int __builtin_ia32_pmovmskb128 (v16qi)
20641 void __builtin_ia32_movnti (int *, int)
20642 void __builtin_ia32_movnti64 (long long int *, long long int)
20643 void __builtin_ia32_movntpd (double *, v2df)
20644 void __builtin_ia32_movntdq (v2df *, v2df)
20645 v4si __builtin_ia32_pshufd (v4si, int)
20646 v8hi __builtin_ia32_pshuflw (v8hi, int)
20647 v8hi __builtin_ia32_pshufhw (v8hi, int)
20648 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
20649 v2df __builtin_ia32_sqrtpd (v2df)
20650 v2df __builtin_ia32_sqrtsd (v2df)
20651 v2df __builtin_ia32_shufpd (v2df, v2df, int)
20652 v2df __builtin_ia32_cvtdq2pd (v4si)
20653 v4sf __builtin_ia32_cvtdq2ps (v4si)
20654 v4si __builtin_ia32_cvtpd2dq (v2df)
20655 v2si __builtin_ia32_cvtpd2pi (v2df)
20656 v4sf __builtin_ia32_cvtpd2ps (v2df)
20657 v4si __builtin_ia32_cvttpd2dq (v2df)
20658 v2si __builtin_ia32_cvttpd2pi (v2df)
20659 v2df __builtin_ia32_cvtpi2pd (v2si)
20660 int __builtin_ia32_cvtsd2si (v2df)
20661 int __builtin_ia32_cvttsd2si (v2df)
20662 long long __builtin_ia32_cvtsd2si64 (v2df)
20663 long long __builtin_ia32_cvttsd2si64 (v2df)
20664 v4si __builtin_ia32_cvtps2dq (v4sf)
20665 v2df __builtin_ia32_cvtps2pd (v4sf)
20666 v4si __builtin_ia32_cvttps2dq (v4sf)
20667 v2df __builtin_ia32_cvtsi2sd (v2df, int)
20668 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
20669 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
20670 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
20671 void __builtin_ia32_clflush (const void *)
20672 void __builtin_ia32_lfence (void)
20673 void __builtin_ia32_mfence (void)
20674 v16qi __builtin_ia32_loaddqu (const char *)
20675 void __builtin_ia32_storedqu (char *, v16qi)
20676 v1di __builtin_ia32_pmuludq (v2si, v2si)
20677 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
20678 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
20679 v4si __builtin_ia32_pslld128 (v4si, v4si)
20680 v2di __builtin_ia32_psllq128 (v2di, v2di)
20681 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
20682 v4si __builtin_ia32_psrld128 (v4si, v4si)
20683 v2di __builtin_ia32_psrlq128 (v2di, v2di)
20684 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
20685 v4si __builtin_ia32_psrad128 (v4si, v4si)
20686 v2di __builtin_ia32_pslldqi128 (v2di, int)
20687 v8hi __builtin_ia32_psllwi128 (v8hi, int)
20688 v4si __builtin_ia32_pslldi128 (v4si, int)
20689 v2di __builtin_ia32_psllqi128 (v2di, int)
20690 v2di __builtin_ia32_psrldqi128 (v2di, int)
20691 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
20692 v4si __builtin_ia32_psrldi128 (v4si, int)
20693 v2di __builtin_ia32_psrlqi128 (v2di, int)
20694 v8hi __builtin_ia32_psrawi128 (v8hi, int)
20695 v4si __builtin_ia32_psradi128 (v4si, int)
20696 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
20697 v2di __builtin_ia32_movq128 (v2di)
20700 The following built-in functions are available when @option{-msse3} is used.
20701 All of them generate the machine instruction that is part of the name.
20704 v2df __builtin_ia32_addsubpd (v2df, v2df)
20705 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
20706 v2df __builtin_ia32_haddpd (v2df, v2df)
20707 v4sf __builtin_ia32_haddps (v4sf, v4sf)
20708 v2df __builtin_ia32_hsubpd (v2df, v2df)
20709 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
20710 v16qi __builtin_ia32_lddqu (char const *)
20711 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
20712 v4sf __builtin_ia32_movshdup (v4sf)
20713 v4sf __builtin_ia32_movsldup (v4sf)
20714 void __builtin_ia32_mwait (unsigned int, unsigned int)
20717 The following built-in functions are available when @option{-mssse3} is used.
20718 All of them generate the machine instruction that is part of the name.
20721 v2si __builtin_ia32_phaddd (v2si, v2si)
20722 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
20723 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
20724 v2si __builtin_ia32_phsubd (v2si, v2si)
20725 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
20726 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
20727 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
20728 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
20729 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
20730 v8qi __builtin_ia32_psignb (v8qi, v8qi)
20731 v2si __builtin_ia32_psignd (v2si, v2si)
20732 v4hi __builtin_ia32_psignw (v4hi, v4hi)
20733 v1di __builtin_ia32_palignr (v1di, v1di, int)
20734 v8qi __builtin_ia32_pabsb (v8qi)
20735 v2si __builtin_ia32_pabsd (v2si)
20736 v4hi __builtin_ia32_pabsw (v4hi)
20739 The following built-in functions are available when @option{-mssse3} is used.
20740 All of them generate the machine instruction that is part of the name.
20743 v4si __builtin_ia32_phaddd128 (v4si, v4si)
20744 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
20745 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
20746 v4si __builtin_ia32_phsubd128 (v4si, v4si)
20747 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
20748 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
20749 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
20750 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
20751 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
20752 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
20753 v4si __builtin_ia32_psignd128 (v4si, v4si)
20754 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
20755 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
20756 v16qi __builtin_ia32_pabsb128 (v16qi)
20757 v4si __builtin_ia32_pabsd128 (v4si)
20758 v8hi __builtin_ia32_pabsw128 (v8hi)
20761 The following built-in functions are available when @option{-msse4.1} is
20762 used. All of them generate the machine instruction that is part of the
20766 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
20767 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
20768 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
20769 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
20770 v2df __builtin_ia32_dppd (v2df, v2df, const int)
20771 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
20772 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
20773 v2di __builtin_ia32_movntdqa (v2di *);
20774 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
20775 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
20776 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
20777 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
20778 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
20779 v8hi __builtin_ia32_phminposuw128 (v8hi)
20780 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
20781 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
20782 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
20783 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
20784 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
20785 v4si __builtin_ia32_pminsd128 (v4si, v4si)
20786 v4si __builtin_ia32_pminud128 (v4si, v4si)
20787 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
20788 v4si __builtin_ia32_pmovsxbd128 (v16qi)
20789 v2di __builtin_ia32_pmovsxbq128 (v16qi)
20790 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
20791 v2di __builtin_ia32_pmovsxdq128 (v4si)
20792 v4si __builtin_ia32_pmovsxwd128 (v8hi)
20793 v2di __builtin_ia32_pmovsxwq128 (v8hi)
20794 v4si __builtin_ia32_pmovzxbd128 (v16qi)
20795 v2di __builtin_ia32_pmovzxbq128 (v16qi)
20796 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
20797 v2di __builtin_ia32_pmovzxdq128 (v4si)
20798 v4si __builtin_ia32_pmovzxwd128 (v8hi)
20799 v2di __builtin_ia32_pmovzxwq128 (v8hi)
20800 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
20801 v4si __builtin_ia32_pmulld128 (v4si, v4si)
20802 int __builtin_ia32_ptestc128 (v2di, v2di)
20803 int __builtin_ia32_ptestnzc128 (v2di, v2di)
20804 int __builtin_ia32_ptestz128 (v2di, v2di)
20805 v2df __builtin_ia32_roundpd (v2df, const int)
20806 v4sf __builtin_ia32_roundps (v4sf, const int)
20807 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
20808 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
20811 The following built-in functions are available when @option{-msse4.1} is
20815 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
20816 Generates the @code{insertps} machine instruction.
20817 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
20818 Generates the @code{pextrb} machine instruction.
20819 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
20820 Generates the @code{pinsrb} machine instruction.
20821 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
20822 Generates the @code{pinsrd} machine instruction.
20823 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
20824 Generates the @code{pinsrq} machine instruction in 64bit mode.
20827 The following built-in functions are changed to generate new SSE4.1
20828 instructions when @option{-msse4.1} is used.
20831 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
20832 Generates the @code{extractps} machine instruction.
20833 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
20834 Generates the @code{pextrd} machine instruction.
20835 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
20836 Generates the @code{pextrq} machine instruction in 64bit mode.
20839 The following built-in functions are available when @option{-msse4.2} is
20840 used. All of them generate the machine instruction that is part of the
20844 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
20845 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
20846 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
20847 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
20848 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
20849 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
20850 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
20851 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
20852 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
20853 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
20854 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
20855 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
20856 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
20857 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
20858 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
20861 The following built-in functions are available when @option{-msse4.2} is
20865 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
20866 Generates the @code{crc32b} machine instruction.
20867 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
20868 Generates the @code{crc32w} machine instruction.
20869 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
20870 Generates the @code{crc32l} machine instruction.
20871 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
20872 Generates the @code{crc32q} machine instruction.
20875 The following built-in functions are changed to generate new SSE4.2
20876 instructions when @option{-msse4.2} is used.
20879 @item int __builtin_popcount (unsigned int)
20880 Generates the @code{popcntl} machine instruction.
20881 @item int __builtin_popcountl (unsigned long)
20882 Generates the @code{popcntl} or @code{popcntq} machine instruction,
20883 depending on the size of @code{unsigned long}.
20884 @item int __builtin_popcountll (unsigned long long)
20885 Generates the @code{popcntq} machine instruction.
20888 The following built-in functions are available when @option{-mavx} is
20889 used. All of them generate the machine instruction that is part of the
20893 v4df __builtin_ia32_addpd256 (v4df,v4df)
20894 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
20895 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
20896 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
20897 v4df __builtin_ia32_andnpd256 (v4df,v4df)
20898 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
20899 v4df __builtin_ia32_andpd256 (v4df,v4df)
20900 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
20901 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
20902 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
20903 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
20904 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
20905 v2df __builtin_ia32_cmppd (v2df,v2df,int)
20906 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
20907 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
20908 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
20909 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
20910 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
20911 v4df __builtin_ia32_cvtdq2pd256 (v4si)
20912 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
20913 v4si __builtin_ia32_cvtpd2dq256 (v4df)
20914 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
20915 v8si __builtin_ia32_cvtps2dq256 (v8sf)
20916 v4df __builtin_ia32_cvtps2pd256 (v4sf)
20917 v4si __builtin_ia32_cvttpd2dq256 (v4df)
20918 v8si __builtin_ia32_cvttps2dq256 (v8sf)
20919 v4df __builtin_ia32_divpd256 (v4df,v4df)
20920 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
20921 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
20922 v4df __builtin_ia32_haddpd256 (v4df,v4df)
20923 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
20924 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
20925 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
20926 v32qi __builtin_ia32_lddqu256 (pcchar)
20927 v32qi __builtin_ia32_loaddqu256 (pcchar)
20928 v4df __builtin_ia32_loadupd256 (pcdouble)
20929 v8sf __builtin_ia32_loadups256 (pcfloat)
20930 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
20931 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
20932 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
20933 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
20934 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
20935 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
20936 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
20937 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
20938 v4df __builtin_ia32_maxpd256 (v4df,v4df)
20939 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
20940 v4df __builtin_ia32_minpd256 (v4df,v4df)
20941 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
20942 v4df __builtin_ia32_movddup256 (v4df)
20943 int __builtin_ia32_movmskpd256 (v4df)
20944 int __builtin_ia32_movmskps256 (v8sf)
20945 v8sf __builtin_ia32_movshdup256 (v8sf)
20946 v8sf __builtin_ia32_movsldup256 (v8sf)
20947 v4df __builtin_ia32_mulpd256 (v4df,v4df)
20948 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
20949 v4df __builtin_ia32_orpd256 (v4df,v4df)
20950 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
20951 v2df __builtin_ia32_pd_pd256 (v4df)
20952 v4df __builtin_ia32_pd256_pd (v2df)
20953 v4sf __builtin_ia32_ps_ps256 (v8sf)
20954 v8sf __builtin_ia32_ps256_ps (v4sf)
20955 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
20956 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
20957 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
20958 v8sf __builtin_ia32_rcpps256 (v8sf)
20959 v4df __builtin_ia32_roundpd256 (v4df,int)
20960 v8sf __builtin_ia32_roundps256 (v8sf,int)
20961 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
20962 v8sf __builtin_ia32_rsqrtps256 (v8sf)
20963 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
20964 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
20965 v4si __builtin_ia32_si_si256 (v8si)
20966 v8si __builtin_ia32_si256_si (v4si)
20967 v4df __builtin_ia32_sqrtpd256 (v4df)
20968 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
20969 v8sf __builtin_ia32_sqrtps256 (v8sf)
20970 void __builtin_ia32_storedqu256 (pchar,v32qi)
20971 void __builtin_ia32_storeupd256 (pdouble,v4df)
20972 void __builtin_ia32_storeups256 (pfloat,v8sf)
20973 v4df __builtin_ia32_subpd256 (v4df,v4df)
20974 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
20975 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
20976 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
20977 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
20978 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
20979 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
20980 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
20981 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
20982 v4sf __builtin_ia32_vbroadcastss (pcfloat)
20983 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
20984 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
20985 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
20986 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
20987 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
20988 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
20989 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
20990 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
20991 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
20992 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
20993 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
20994 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
20995 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
20996 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
20997 v2df __builtin_ia32_vpermilpd (v2df,int)
20998 v4df __builtin_ia32_vpermilpd256 (v4df,int)
20999 v4sf __builtin_ia32_vpermilps (v4sf,int)
21000 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
21001 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
21002 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
21003 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
21004 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
21005 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
21006 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
21007 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
21008 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
21009 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
21010 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
21011 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
21012 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
21013 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
21014 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
21015 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
21016 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
21017 void __builtin_ia32_vzeroall (void)
21018 void __builtin_ia32_vzeroupper (void)
21019 v4df __builtin_ia32_xorpd256 (v4df,v4df)
21020 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
21023 The following built-in functions are available when @option{-mavx2} is
21024 used. All of them generate the machine instruction that is part of the
21028 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
21029 v32qi __builtin_ia32_pabsb256 (v32qi)
21030 v16hi __builtin_ia32_pabsw256 (v16hi)
21031 v8si __builtin_ia32_pabsd256 (v8si)
21032 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
21033 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
21034 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
21035 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
21036 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
21037 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
21038 v8si __builtin_ia32_paddd256 (v8si,v8si)
21039 v4di __builtin_ia32_paddq256 (v4di,v4di)
21040 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
21041 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
21042 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
21043 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
21044 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
21045 v4di __builtin_ia32_andsi256 (v4di,v4di)
21046 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
21047 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
21048 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
21049 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
21050 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
21051 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
21052 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
21053 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
21054 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
21055 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
21056 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
21057 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
21058 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
21059 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
21060 v8si __builtin_ia32_phaddd256 (v8si,v8si)
21061 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
21062 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
21063 v8si __builtin_ia32_phsubd256 (v8si,v8si)
21064 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
21065 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
21066 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
21067 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
21068 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
21069 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
21070 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
21071 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
21072 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
21073 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
21074 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
21075 v8si __builtin_ia32_pminsd256 (v8si,v8si)
21076 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
21077 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
21078 v8si __builtin_ia32_pminud256 (v8si,v8si)
21079 int __builtin_ia32_pmovmskb256 (v32qi)
21080 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
21081 v8si __builtin_ia32_pmovsxbd256 (v16qi)
21082 v4di __builtin_ia32_pmovsxbq256 (v16qi)
21083 v8si __builtin_ia32_pmovsxwd256 (v8hi)
21084 v4di __builtin_ia32_pmovsxwq256 (v8hi)
21085 v4di __builtin_ia32_pmovsxdq256 (v4si)
21086 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
21087 v8si __builtin_ia32_pmovzxbd256 (v16qi)
21088 v4di __builtin_ia32_pmovzxbq256 (v16qi)
21089 v8si __builtin_ia32_pmovzxwd256 (v8hi)
21090 v4di __builtin_ia32_pmovzxwq256 (v8hi)
21091 v4di __builtin_ia32_pmovzxdq256 (v4si)
21092 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
21093 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
21094 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
21095 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
21096 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
21097 v8si __builtin_ia32_pmulld256 (v8si,v8si)
21098 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
21099 v4di __builtin_ia32_por256 (v4di,v4di)
21100 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
21101 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
21102 v8si __builtin_ia32_pshufd256 (v8si,int)
21103 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
21104 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
21105 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
21106 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
21107 v8si __builtin_ia32_psignd256 (v8si,v8si)
21108 v4di __builtin_ia32_pslldqi256 (v4di,int)
21109 v16hi __builtin_ia32_psllwi256 (16hi,int)
21110 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
21111 v8si __builtin_ia32_pslldi256 (v8si,int)
21112 v8si __builtin_ia32_pslld256(v8si,v4si)
21113 v4di __builtin_ia32_psllqi256 (v4di,int)
21114 v4di __builtin_ia32_psllq256(v4di,v2di)
21115 v16hi __builtin_ia32_psrawi256 (v16hi,int)
21116 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
21117 v8si __builtin_ia32_psradi256 (v8si,int)
21118 v8si __builtin_ia32_psrad256 (v8si,v4si)
21119 v4di __builtin_ia32_psrldqi256 (v4di, int)
21120 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
21121 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
21122 v8si __builtin_ia32_psrldi256 (v8si,int)
21123 v8si __builtin_ia32_psrld256 (v8si,v4si)
21124 v4di __builtin_ia32_psrlqi256 (v4di,int)
21125 v4di __builtin_ia32_psrlq256(v4di,v2di)
21126 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
21127 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
21128 v8si __builtin_ia32_psubd256 (v8si,v8si)
21129 v4di __builtin_ia32_psubq256 (v4di,v4di)
21130 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
21131 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
21132 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
21133 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
21134 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
21135 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
21136 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
21137 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
21138 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
21139 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
21140 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
21141 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
21142 v4di __builtin_ia32_pxor256 (v4di,v4di)
21143 v4di __builtin_ia32_movntdqa256 (pv4di)
21144 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
21145 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
21146 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
21147 v4di __builtin_ia32_vbroadcastsi256 (v2di)
21148 v4si __builtin_ia32_pblendd128 (v4si,v4si)
21149 v8si __builtin_ia32_pblendd256 (v8si,v8si)
21150 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
21151 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
21152 v8si __builtin_ia32_pbroadcastd256 (v4si)
21153 v4di __builtin_ia32_pbroadcastq256 (v2di)
21154 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
21155 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
21156 v4si __builtin_ia32_pbroadcastd128 (v4si)
21157 v2di __builtin_ia32_pbroadcastq128 (v2di)
21158 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
21159 v4df __builtin_ia32_permdf256 (v4df,int)
21160 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
21161 v4di __builtin_ia32_permdi256 (v4di,int)
21162 v4di __builtin_ia32_permti256 (v4di,v4di,int)
21163 v4di __builtin_ia32_extract128i256 (v4di,int)
21164 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
21165 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
21166 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
21167 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
21168 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
21169 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
21170 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
21171 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
21172 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
21173 v8si __builtin_ia32_psllv8si (v8si,v8si)
21174 v4si __builtin_ia32_psllv4si (v4si,v4si)
21175 v4di __builtin_ia32_psllv4di (v4di,v4di)
21176 v2di __builtin_ia32_psllv2di (v2di,v2di)
21177 v8si __builtin_ia32_psrav8si (v8si,v8si)
21178 v4si __builtin_ia32_psrav4si (v4si,v4si)
21179 v8si __builtin_ia32_psrlv8si (v8si,v8si)
21180 v4si __builtin_ia32_psrlv4si (v4si,v4si)
21181 v4di __builtin_ia32_psrlv4di (v4di,v4di)
21182 v2di __builtin_ia32_psrlv2di (v2di,v2di)
21183 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
21184 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
21185 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
21186 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
21187 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
21188 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
21189 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
21190 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
21191 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
21192 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
21193 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
21194 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
21195 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
21196 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
21197 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
21198 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
21201 The following built-in functions are available when @option{-maes} is
21202 used. All of them generate the machine instruction that is part of the
21206 v2di __builtin_ia32_aesenc128 (v2di, v2di)
21207 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
21208 v2di __builtin_ia32_aesdec128 (v2di, v2di)
21209 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
21210 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
21211 v2di __builtin_ia32_aesimc128 (v2di)
21214 The following built-in function is available when @option{-mpclmul} is
21218 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
21219 Generates the @code{pclmulqdq} machine instruction.
21222 The following built-in function is available when @option{-mfsgsbase} is
21223 used. All of them generate the machine instruction that is part of the
21227 unsigned int __builtin_ia32_rdfsbase32 (void)
21228 unsigned long long __builtin_ia32_rdfsbase64 (void)
21229 unsigned int __builtin_ia32_rdgsbase32 (void)
21230 unsigned long long __builtin_ia32_rdgsbase64 (void)
21231 void _writefsbase_u32 (unsigned int)
21232 void _writefsbase_u64 (unsigned long long)
21233 void _writegsbase_u32 (unsigned int)
21234 void _writegsbase_u64 (unsigned long long)
21237 The following built-in function is available when @option{-mrdrnd} is
21238 used. All of them generate the machine instruction that is part of the
21242 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
21243 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
21244 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
21247 The following built-in functions are available when @option{-msse4a} is used.
21248 All of them generate the machine instruction that is part of the name.
21251 void __builtin_ia32_movntsd (double *, v2df)
21252 void __builtin_ia32_movntss (float *, v4sf)
21253 v2di __builtin_ia32_extrq (v2di, v16qi)
21254 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
21255 v2di __builtin_ia32_insertq (v2di, v2di)
21256 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
21259 The following built-in functions are available when @option{-mxop} is used.
21261 v2df __builtin_ia32_vfrczpd (v2df)
21262 v4sf __builtin_ia32_vfrczps (v4sf)
21263 v2df __builtin_ia32_vfrczsd (v2df)
21264 v4sf __builtin_ia32_vfrczss (v4sf)
21265 v4df __builtin_ia32_vfrczpd256 (v4df)
21266 v8sf __builtin_ia32_vfrczps256 (v8sf)
21267 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
21268 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
21269 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
21270 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
21271 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
21272 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
21273 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
21274 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
21275 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
21276 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
21277 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
21278 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
21279 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
21280 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
21281 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21282 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
21283 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
21284 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
21285 v4si __builtin_ia32_vpcomequd (v4si, v4si)
21286 v2di __builtin_ia32_vpcomequq (v2di, v2di)
21287 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
21288 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21289 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
21290 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
21291 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
21292 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
21293 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
21294 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
21295 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
21296 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
21297 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
21298 v4si __builtin_ia32_vpcomged (v4si, v4si)
21299 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
21300 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
21301 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
21302 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
21303 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
21304 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
21305 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
21306 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
21307 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
21308 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
21309 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
21310 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
21311 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
21312 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
21313 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
21314 v4si __builtin_ia32_vpcomled (v4si, v4si)
21315 v2di __builtin_ia32_vpcomleq (v2di, v2di)
21316 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
21317 v4si __builtin_ia32_vpcomleud (v4si, v4si)
21318 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
21319 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
21320 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
21321 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
21322 v4si __builtin_ia32_vpcomltd (v4si, v4si)
21323 v2di __builtin_ia32_vpcomltq (v2di, v2di)
21324 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
21325 v4si __builtin_ia32_vpcomltud (v4si, v4si)
21326 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
21327 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
21328 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
21329 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
21330 v4si __builtin_ia32_vpcomned (v4si, v4si)
21331 v2di __builtin_ia32_vpcomneq (v2di, v2di)
21332 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
21333 v4si __builtin_ia32_vpcomneud (v4si, v4si)
21334 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
21335 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
21336 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
21337 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
21338 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
21339 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
21340 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
21341 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
21342 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
21343 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
21344 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
21345 v4si __builtin_ia32_vphaddbd (v16qi)
21346 v2di __builtin_ia32_vphaddbq (v16qi)
21347 v8hi __builtin_ia32_vphaddbw (v16qi)
21348 v2di __builtin_ia32_vphadddq (v4si)
21349 v4si __builtin_ia32_vphaddubd (v16qi)
21350 v2di __builtin_ia32_vphaddubq (v16qi)
21351 v8hi __builtin_ia32_vphaddubw (v16qi)
21352 v2di __builtin_ia32_vphaddudq (v4si)
21353 v4si __builtin_ia32_vphadduwd (v8hi)
21354 v2di __builtin_ia32_vphadduwq (v8hi)
21355 v4si __builtin_ia32_vphaddwd (v8hi)
21356 v2di __builtin_ia32_vphaddwq (v8hi)
21357 v8hi __builtin_ia32_vphsubbw (v16qi)
21358 v2di __builtin_ia32_vphsubdq (v4si)
21359 v4si __builtin_ia32_vphsubwd (v8hi)
21360 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
21361 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
21362 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
21363 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
21364 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
21365 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
21366 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
21367 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
21368 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
21369 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
21370 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
21371 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
21372 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
21373 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
21374 v4si __builtin_ia32_vprotd (v4si, v4si)
21375 v2di __builtin_ia32_vprotq (v2di, v2di)
21376 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
21377 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
21378 v4si __builtin_ia32_vpshad (v4si, v4si)
21379 v2di __builtin_ia32_vpshaq (v2di, v2di)
21380 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
21381 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
21382 v4si __builtin_ia32_vpshld (v4si, v4si)
21383 v2di __builtin_ia32_vpshlq (v2di, v2di)
21384 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
21387 The following built-in functions are available when @option{-mfma4} is used.
21388 All of them generate the machine instruction that is part of the name.
21391 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
21392 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
21393 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
21394 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
21395 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
21396 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
21397 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
21398 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
21399 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
21400 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
21401 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
21402 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
21403 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
21404 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
21405 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
21406 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
21407 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
21408 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
21409 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
21410 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
21411 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
21412 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
21413 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
21414 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
21415 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
21416 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
21417 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
21418 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
21419 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
21420 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
21421 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
21422 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
21426 The following built-in functions are available when @option{-mlwp} is used.
21429 void __builtin_ia32_llwpcb16 (void *);
21430 void __builtin_ia32_llwpcb32 (void *);
21431 void __builtin_ia32_llwpcb64 (void *);
21432 void * __builtin_ia32_llwpcb16 (void);
21433 void * __builtin_ia32_llwpcb32 (void);
21434 void * __builtin_ia32_llwpcb64 (void);
21435 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
21436 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
21437 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
21438 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
21439 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
21440 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
21443 The following built-in functions are available when @option{-mbmi} is used.
21444 All of them generate the machine instruction that is part of the name.
21446 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
21447 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
21450 The following built-in functions are available when @option{-mbmi2} is used.
21451 All of them generate the machine instruction that is part of the name.
21453 unsigned int _bzhi_u32 (unsigned int, unsigned int)
21454 unsigned int _pdep_u32 (unsigned int, unsigned int)
21455 unsigned int _pext_u32 (unsigned int, unsigned int)
21456 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
21457 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
21458 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
21461 The following built-in functions are available when @option{-mlzcnt} is used.
21462 All of them generate the machine instruction that is part of the name.
21464 unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
21465 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
21466 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
21469 The following built-in functions are available when @option{-mfxsr} is used.
21470 All of them generate the machine instruction that is part of the name.
21472 void __builtin_ia32_fxsave (void *)
21473 void __builtin_ia32_fxrstor (void *)
21474 void __builtin_ia32_fxsave64 (void *)
21475 void __builtin_ia32_fxrstor64 (void *)
21478 The following built-in functions are available when @option{-mxsave} is used.
21479 All of them generate the machine instruction that is part of the name.
21481 void __builtin_ia32_xsave (void *, long long)
21482 void __builtin_ia32_xrstor (void *, long long)
21483 void __builtin_ia32_xsave64 (void *, long long)
21484 void __builtin_ia32_xrstor64 (void *, long long)
21487 The following built-in functions are available when @option{-mxsaveopt} is used.
21488 All of them generate the machine instruction that is part of the name.
21490 void __builtin_ia32_xsaveopt (void *, long long)
21491 void __builtin_ia32_xsaveopt64 (void *, long long)
21494 The following built-in functions are available when @option{-mtbm} is used.
21495 Both of them generate the immediate form of the bextr machine instruction.
21497 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
21498 const unsigned int);
21499 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
21500 const unsigned long long);
21504 The following built-in functions are available when @option{-m3dnow} is used.
21505 All of them generate the machine instruction that is part of the name.
21508 void __builtin_ia32_femms (void)
21509 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
21510 v2si __builtin_ia32_pf2id (v2sf)
21511 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
21512 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
21513 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
21514 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
21515 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
21516 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
21517 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
21518 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
21519 v2sf __builtin_ia32_pfrcp (v2sf)
21520 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
21521 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
21522 v2sf __builtin_ia32_pfrsqrt (v2sf)
21523 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
21524 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
21525 v2sf __builtin_ia32_pi2fd (v2si)
21526 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
21529 The following built-in functions are available when @option{-m3dnowa} is used.
21530 All of them generate the machine instruction that is part of the name.
21533 v2si __builtin_ia32_pf2iw (v2sf)
21534 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
21535 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
21536 v2sf __builtin_ia32_pi2fw (v2si)
21537 v2sf __builtin_ia32_pswapdsf (v2sf)
21538 v2si __builtin_ia32_pswapdsi (v2si)
21541 The following built-in functions are available when @option{-mrtm} is used
21542 They are used for restricted transactional memory. These are the internal
21543 low level functions. Normally the functions in
21544 @ref{x86 transactional memory intrinsics} should be used instead.
21547 int __builtin_ia32_xbegin ()
21548 void __builtin_ia32_xend ()
21549 void __builtin_ia32_xabort (status)
21550 int __builtin_ia32_xtest ()
21553 The following built-in functions are available when @option{-mmwaitx} is used.
21554 All of them generate the machine instruction that is part of the name.
21556 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
21557 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
21560 The following built-in functions are available when @option{-mclzero} is used.
21561 All of them generate the machine instruction that is part of the name.
21563 void __builtin_i32_clzero (void *)
21566 The following built-in functions are available when @option{-mpku} is used.
21567 They generate reads and writes to PKRU.
21569 void __builtin_ia32_wrpkru (unsigned int)
21570 unsigned int __builtin_ia32_rdpkru ()
21573 The following built-in functions are available when @option{-mcet} or
21574 @option{-mshstk} option is used. They support shadow stack
21575 machine instructions from Intel Control-flow Enforcement Technology (CET).
21576 Each built-in function generates the machine instruction that is part
21577 of the function's name. These are the internal low-level functions.
21578 Normally the functions in @ref{x86 control-flow protection intrinsics}
21579 should be used instead.
21582 unsigned int __builtin_ia32_rdsspd (void)
21583 unsigned long long __builtin_ia32_rdsspq (void)
21584 void __builtin_ia32_incsspd (unsigned int)
21585 void __builtin_ia32_incsspq (unsigned long long)
21586 void __builtin_ia32_saveprevssp(void);
21587 void __builtin_ia32_rstorssp(void *);
21588 void __builtin_ia32_wrssd(unsigned int, void *);
21589 void __builtin_ia32_wrssq(unsigned long long, void *);
21590 void __builtin_ia32_wrussd(unsigned int, void *);
21591 void __builtin_ia32_wrussq(unsigned long long, void *);
21592 void __builtin_ia32_setssbsy(void);
21593 void __builtin_ia32_clrssbsy(void *);
21596 @node x86 transactional memory intrinsics
21597 @subsection x86 Transactional Memory Intrinsics
21599 These hardware transactional memory intrinsics for x86 allow you to use
21600 memory transactions with RTM (Restricted Transactional Memory).
21601 This support is enabled with the @option{-mrtm} option.
21602 For using HLE (Hardware Lock Elision) see
21603 @ref{x86 specific memory model extensions for transactional memory} instead.
21605 A memory transaction commits all changes to memory in an atomic way,
21606 as visible to other threads. If the transaction fails it is rolled back
21607 and all side effects discarded.
21609 Generally there is no guarantee that a memory transaction ever succeeds
21610 and suitable fallback code always needs to be supplied.
21612 @deftypefn {RTM Function} {unsigned} _xbegin ()
21613 Start a RTM (Restricted Transactional Memory) transaction.
21614 Returns @code{_XBEGIN_STARTED} when the transaction
21615 started successfully (note this is not 0, so the constant has to be
21616 explicitly tested).
21618 If the transaction aborts, all side effects
21619 are undone and an abort code encoded as a bit mask is returned.
21620 The following macros are defined:
21623 @item _XABORT_EXPLICIT
21624 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
21625 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
21626 @item _XABORT_RETRY
21627 Transaction retry is possible.
21628 @item _XABORT_CONFLICT
21629 Transaction abort due to a memory conflict with another thread.
21630 @item _XABORT_CAPACITY
21631 Transaction abort due to the transaction using too much memory.
21632 @item _XABORT_DEBUG
21633 Transaction abort due to a debug trap.
21634 @item _XABORT_NESTED
21635 Transaction abort in an inner nested transaction.
21638 There is no guarantee
21639 any transaction ever succeeds, so there always needs to be a valid
21643 @deftypefn {RTM Function} {void} _xend ()
21644 Commit the current transaction. When no transaction is active this faults.
21645 All memory side effects of the transaction become visible
21646 to other threads in an atomic manner.
21649 @deftypefn {RTM Function} {int} _xtest ()
21650 Return a nonzero value if a transaction is currently active, otherwise 0.
21653 @deftypefn {RTM Function} {void} _xabort (status)
21654 Abort the current transaction. When no transaction is active this is a no-op.
21655 The @var{status} is an 8-bit constant; its value is encoded in the return
21656 value from @code{_xbegin}.
21659 Here is an example showing handling for @code{_XABORT_RETRY}
21660 and a fallback path for other failures:
21663 #include <immintrin.h>
21665 int n_tries, max_tries;
21666 unsigned status = _XABORT_EXPLICIT;
21669 for (n_tries = 0; n_tries < max_tries; n_tries++)
21671 status = _xbegin ();
21672 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
21675 if (status == _XBEGIN_STARTED)
21677 ... transaction code...
21682 ... non-transactional fallback path...
21687 Note that, in most cases, the transactional and non-transactional code
21688 must synchronize together to ensure consistency.
21690 @node x86 control-flow protection intrinsics
21691 @subsection x86 Control-Flow Protection Intrinsics
21693 @deftypefn {CET Function} {ret_type} _get_ssp (void)
21694 Get the current value of shadow stack pointer if shadow stack support
21695 from Intel CET is enabled in the hardware or @code{0} otherwise.
21696 The @code{ret_type} is @code{unsigned long long} for 64-bit targets
21697 and @code{unsigned int} for 32-bit targets.
21700 @deftypefn {CET Function} void _inc_ssp (unsigned int)
21701 Increment the current shadow stack pointer by the size specified by the
21702 function argument. The argument is masked to a byte value for security
21703 reasons, so to increment by more than 255 bytes you must call the function
21707 The shadow stack unwind code looks like:
21710 #include <immintrin.h>
21712 /* Unwind the shadow stack for EH. */
21713 #define _Unwind_Frames_Extra(x) \
21716 _Unwind_Word ssp = _get_ssp (); \
21719 _Unwind_Word tmp = (x); \
21720 while (tmp > 255) \
21732 This code runs unconditionally on all 64-bit processors. For 32-bit
21733 processors the code runs on those that support multi-byte NOP instructions.
21735 @node Target Format Checks
21736 @section Format Checks Specific to Particular Target Machines
21738 For some target machines, GCC supports additional options to the
21740 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
21743 * Solaris Format Checks::
21744 * Darwin Format Checks::
21747 @node Solaris Format Checks
21748 @subsection Solaris Format Checks
21750 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
21751 check. @code{cmn_err} accepts a subset of the standard @code{printf}
21752 conversions, and the two-argument @code{%b} conversion for displaying
21753 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
21755 @node Darwin Format Checks
21756 @subsection Darwin Format Checks
21758 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
21759 attribute context. Declarations made with such attribution are parsed for correct syntax
21760 and format argument types. However, parsing of the format string itself is currently undefined
21761 and is not carried out by this version of the compiler.
21763 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
21764 also be used as format arguments. Note that the relevant headers are only likely to be
21765 available on Darwin (OSX) installations. On such installations, the XCode and system
21766 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
21767 associated functions.
21770 @section Pragmas Accepted by GCC
21772 @cindex @code{#pragma}
21774 GCC supports several types of pragmas, primarily in order to compile
21775 code originally written for other compilers. Note that in general
21776 we do not recommend the use of pragmas; @xref{Function Attributes},
21777 for further explanation.
21780 * AArch64 Pragmas::
21784 * RS/6000 and PowerPC Pragmas::
21787 * Solaris Pragmas::
21788 * Symbol-Renaming Pragmas::
21789 * Structure-Layout Pragmas::
21791 * Diagnostic Pragmas::
21792 * Visibility Pragmas::
21793 * Push/Pop Macro Pragmas::
21794 * Function Specific Option Pragmas::
21795 * Loop-Specific Pragmas::
21798 @node AArch64 Pragmas
21799 @subsection AArch64 Pragmas
21801 The pragmas defined by the AArch64 target correspond to the AArch64
21802 target function attributes. They can be specified as below:
21804 #pragma GCC target("string")
21807 where @code{@var{string}} can be any string accepted as an AArch64 target
21808 attribute. @xref{AArch64 Function Attributes}, for more details
21809 on the permissible values of @code{string}.
21812 @subsection ARM Pragmas
21814 The ARM target defines pragmas for controlling the default addition of
21815 @code{long_call} and @code{short_call} attributes to functions.
21816 @xref{Function Attributes}, for information about the effects of these
21821 @cindex pragma, long_calls
21822 Set all subsequent functions to have the @code{long_call} attribute.
21824 @item no_long_calls
21825 @cindex pragma, no_long_calls
21826 Set all subsequent functions to have the @code{short_call} attribute.
21828 @item long_calls_off
21829 @cindex pragma, long_calls_off
21830 Do not affect the @code{long_call} or @code{short_call} attributes of
21831 subsequent functions.
21835 @subsection M32C Pragmas
21838 @item GCC memregs @var{number}
21839 @cindex pragma, memregs
21840 Overrides the command-line option @code{-memregs=} for the current
21841 file. Use with care! This pragma must be before any function in the
21842 file, and mixing different memregs values in different objects may
21843 make them incompatible. This pragma is useful when a
21844 performance-critical function uses a memreg for temporary values,
21845 as it may allow you to reduce the number of memregs used.
21847 @item ADDRESS @var{name} @var{address}
21848 @cindex pragma, address
21849 For any declared symbols matching @var{name}, this does three things
21850 to that symbol: it forces the symbol to be located at the given
21851 address (a number), it forces the symbol to be volatile, and it
21852 changes the symbol's scope to be static. This pragma exists for
21853 compatibility with other compilers, but note that the common
21854 @code{1234H} numeric syntax is not supported (use @code{0x1234}
21858 #pragma ADDRESS port3 0x103
21865 @subsection MeP Pragmas
21869 @item custom io_volatile (on|off)
21870 @cindex pragma, custom io_volatile
21871 Overrides the command-line option @code{-mio-volatile} for the current
21872 file. Note that for compatibility with future GCC releases, this
21873 option should only be used once before any @code{io} variables in each
21876 @item GCC coprocessor available @var{registers}
21877 @cindex pragma, coprocessor available
21878 Specifies which coprocessor registers are available to the register
21879 allocator. @var{registers} may be a single register, register range
21880 separated by ellipses, or comma-separated list of those. Example:
21883 #pragma GCC coprocessor available $c0...$c10, $c28
21886 @item GCC coprocessor call_saved @var{registers}
21887 @cindex pragma, coprocessor call_saved
21888 Specifies which coprocessor registers are to be saved and restored by
21889 any function using them. @var{registers} may be a single register,
21890 register range separated by ellipses, or comma-separated list of
21894 #pragma GCC coprocessor call_saved $c4...$c6, $c31
21897 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
21898 @cindex pragma, coprocessor subclass
21899 Creates and defines a register class. These register classes can be
21900 used by inline @code{asm} constructs. @var{registers} may be a single
21901 register, register range separated by ellipses, or comma-separated
21902 list of those. Example:
21905 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
21907 asm ("cpfoo %0" : "=B" (x));
21910 @item GCC disinterrupt @var{name} , @var{name} @dots{}
21911 @cindex pragma, disinterrupt
21912 For the named functions, the compiler adds code to disable interrupts
21913 for the duration of those functions. If any functions so named
21914 are not encountered in the source, a warning is emitted that the pragma is
21915 not used. Examples:
21918 #pragma disinterrupt foo
21919 #pragma disinterrupt bar, grill
21920 int foo () @{ @dots{} @}
21923 @item GCC call @var{name} , @var{name} @dots{}
21924 @cindex pragma, call
21925 For the named functions, the compiler always uses a register-indirect
21926 call model when calling the named functions. Examples:
21935 @node RS/6000 and PowerPC Pragmas
21936 @subsection RS/6000 and PowerPC Pragmas
21938 The RS/6000 and PowerPC targets define one pragma for controlling
21939 whether or not the @code{longcall} attribute is added to function
21940 declarations by default. This pragma overrides the @option{-mlongcall}
21941 option, but not the @code{longcall} and @code{shortcall} attributes.
21942 @xref{RS/6000 and PowerPC Options}, for more information about when long
21943 calls are and are not necessary.
21947 @cindex pragma, longcall
21948 Apply the @code{longcall} attribute to all subsequent function
21952 Do not apply the @code{longcall} attribute to subsequent function
21956 @c Describe h8300 pragmas here.
21957 @c Describe sh pragmas here.
21958 @c Describe v850 pragmas here.
21960 @node S/390 Pragmas
21961 @subsection S/390 Pragmas
21963 The pragmas defined by the S/390 target correspond to the S/390
21964 target function attributes and some the additional options:
21971 Note that options of the pragma, unlike options of the target
21972 attribute, do change the value of preprocessor macros like
21973 @code{__VEC__}. They can be specified as below:
21976 #pragma GCC target("string[,string]...")
21977 #pragma GCC target("string"[,"string"]...)
21980 @node Darwin Pragmas
21981 @subsection Darwin Pragmas
21983 The following pragmas are available for all architectures running the
21984 Darwin operating system. These are useful for compatibility with other
21988 @item mark @var{tokens}@dots{}
21989 @cindex pragma, mark
21990 This pragma is accepted, but has no effect.
21992 @item options align=@var{alignment}
21993 @cindex pragma, options align
21994 This pragma sets the alignment of fields in structures. The values of
21995 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
21996 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
21997 properly; to restore the previous setting, use @code{reset} for the
22000 @item segment @var{tokens}@dots{}
22001 @cindex pragma, segment
22002 This pragma is accepted, but has no effect.
22004 @item unused (@var{var} [, @var{var}]@dots{})
22005 @cindex pragma, unused
22006 This pragma declares variables to be possibly unused. GCC does not
22007 produce warnings for the listed variables. The effect is similar to
22008 that of the @code{unused} attribute, except that this pragma may appear
22009 anywhere within the variables' scopes.
22012 @node Solaris Pragmas
22013 @subsection Solaris Pragmas
22015 The Solaris target supports @code{#pragma redefine_extname}
22016 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
22017 @code{#pragma} directives for compatibility with the system compiler.
22020 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
22021 @cindex pragma, align
22023 Increase the minimum alignment of each @var{variable} to @var{alignment}.
22024 This is the same as GCC's @code{aligned} attribute @pxref{Variable
22025 Attributes}). Macro expansion occurs on the arguments to this pragma
22026 when compiling C and Objective-C@. It does not currently occur when
22027 compiling C++, but this is a bug which may be fixed in a future
22030 @item fini (@var{function} [, @var{function}]...)
22031 @cindex pragma, fini
22033 This pragma causes each listed @var{function} to be called after
22034 main, or during shared module unloading, by adding a call to the
22035 @code{.fini} section.
22037 @item init (@var{function} [, @var{function}]...)
22038 @cindex pragma, init
22040 This pragma causes each listed @var{function} to be called during
22041 initialization (before @code{main}) or during shared module loading, by
22042 adding a call to the @code{.init} section.
22046 @node Symbol-Renaming Pragmas
22047 @subsection Symbol-Renaming Pragmas
22049 GCC supports a @code{#pragma} directive that changes the name used in
22050 assembly for a given declaration. While this pragma is supported on all
22051 platforms, it is intended primarily to provide compatibility with the
22052 Solaris system headers. This effect can also be achieved using the asm
22053 labels extension (@pxref{Asm Labels}).
22056 @item redefine_extname @var{oldname} @var{newname}
22057 @cindex pragma, redefine_extname
22059 This pragma gives the C function @var{oldname} the assembly symbol
22060 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
22061 is defined if this pragma is available (currently on all platforms).
22064 This pragma and the asm labels extension interact in a complicated
22065 manner. Here are some corner cases you may want to be aware of:
22068 @item This pragma silently applies only to declarations with external
22069 linkage. Asm labels do not have this restriction.
22071 @item In C++, this pragma silently applies only to declarations with
22072 ``C'' linkage. Again, asm labels do not have this restriction.
22074 @item If either of the ways of changing the assembly name of a
22075 declaration are applied to a declaration whose assembly name has
22076 already been determined (either by a previous use of one of these
22077 features, or because the compiler needed the assembly name in order to
22078 generate code), and the new name is different, a warning issues and
22079 the name does not change.
22081 @item The @var{oldname} used by @code{#pragma redefine_extname} is
22082 always the C-language name.
22085 @node Structure-Layout Pragmas
22086 @subsection Structure-Layout Pragmas
22088 For compatibility with Microsoft Windows compilers, GCC supports a
22089 set of @code{#pragma} directives that change the maximum alignment of
22090 members of structures (other than zero-width bit-fields), unions, and
22091 classes subsequently defined. The @var{n} value below always is required
22092 to be a small power of two and specifies the new alignment in bytes.
22095 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
22096 @item @code{#pragma pack()} sets the alignment to the one that was in
22097 effect when compilation started (see also command-line option
22098 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
22099 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
22100 setting on an internal stack and then optionally sets the new alignment.
22101 @item @code{#pragma pack(pop)} restores the alignment setting to the one
22102 saved at the top of the internal stack (and removes that stack entry).
22103 Note that @code{#pragma pack([@var{n}])} does not influence this internal
22104 stack; thus it is possible to have @code{#pragma pack(push)} followed by
22105 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
22106 @code{#pragma pack(pop)}.
22109 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
22110 directive which lays out structures and unions subsequently defined as the
22111 documented @code{__attribute__ ((ms_struct))}.
22114 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
22115 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
22116 @item @code{#pragma ms_struct reset} goes back to the default layout.
22119 Most targets also support the @code{#pragma scalar_storage_order} directive
22120 which lays out structures and unions subsequently defined as the documented
22121 @code{__attribute__ ((scalar_storage_order))}.
22124 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
22125 of the scalar fields to big-endian.
22126 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
22127 of the scalar fields to little-endian.
22128 @item @code{#pragma scalar_storage_order default} goes back to the endianness
22129 that was in effect when compilation started (see also command-line option
22130 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
22134 @subsection Weak Pragmas
22136 For compatibility with SVR4, GCC supports a set of @code{#pragma}
22137 directives for declaring symbols to be weak, and defining weak
22141 @item #pragma weak @var{symbol}
22142 @cindex pragma, weak
22143 This pragma declares @var{symbol} to be weak, as if the declaration
22144 had the attribute of the same name. The pragma may appear before
22145 or after the declaration of @var{symbol}. It is not an error for
22146 @var{symbol} to never be defined at all.
22148 @item #pragma weak @var{symbol1} = @var{symbol2}
22149 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
22150 It is an error if @var{symbol2} is not defined in the current
22154 @node Diagnostic Pragmas
22155 @subsection Diagnostic Pragmas
22157 GCC allows the user to selectively enable or disable certain types of
22158 diagnostics, and change the kind of the diagnostic. For example, a
22159 project's policy might require that all sources compile with
22160 @option{-Werror} but certain files might have exceptions allowing
22161 specific types of warnings. Or, a project might selectively enable
22162 diagnostics and treat them as errors depending on which preprocessor
22163 macros are defined.
22166 @item #pragma GCC diagnostic @var{kind} @var{option}
22167 @cindex pragma, diagnostic
22169 Modifies the disposition of a diagnostic. Note that not all
22170 diagnostics are modifiable; at the moment only warnings (normally
22171 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
22172 Use @option{-fdiagnostics-show-option} to determine which diagnostics
22173 are controllable and which option controls them.
22175 @var{kind} is @samp{error} to treat this diagnostic as an error,
22176 @samp{warning} to treat it like a warning (even if @option{-Werror} is
22177 in effect), or @samp{ignored} if the diagnostic is to be ignored.
22178 @var{option} is a double quoted string that matches the command-line
22182 #pragma GCC diagnostic warning "-Wformat"
22183 #pragma GCC diagnostic error "-Wformat"
22184 #pragma GCC diagnostic ignored "-Wformat"
22187 Note that these pragmas override any command-line options. GCC keeps
22188 track of the location of each pragma, and issues diagnostics according
22189 to the state as of that point in the source file. Thus, pragmas occurring
22190 after a line do not affect diagnostics caused by that line.
22192 @item #pragma GCC diagnostic push
22193 @itemx #pragma GCC diagnostic pop
22195 Causes GCC to remember the state of the diagnostics as of each
22196 @code{push}, and restore to that point at each @code{pop}. If a
22197 @code{pop} has no matching @code{push}, the command-line options are
22201 #pragma GCC diagnostic error "-Wuninitialized"
22202 foo(a); /* error is given for this one */
22203 #pragma GCC diagnostic push
22204 #pragma GCC diagnostic ignored "-Wuninitialized"
22205 foo(b); /* no diagnostic for this one */
22206 #pragma GCC diagnostic pop
22207 foo(c); /* error is given for this one */
22208 #pragma GCC diagnostic pop
22209 foo(d); /* depends on command-line options */
22214 GCC also offers a simple mechanism for printing messages during
22218 @item #pragma message @var{string}
22219 @cindex pragma, diagnostic
22221 Prints @var{string} as a compiler message on compilation. The message
22222 is informational only, and is neither a compilation warning nor an
22223 error. Newlines can be included in the string by using the @samp{\n}
22227 #pragma message "Compiling " __FILE__ "..."
22230 @var{string} may be parenthesized, and is printed with location
22231 information. For example,
22234 #define DO_PRAGMA(x) _Pragma (#x)
22235 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
22237 TODO(Remember to fix this)
22241 prints @samp{/tmp/file.c:4: note: #pragma message:
22242 TODO - Remember to fix this}.
22244 @item #pragma GCC error @var{message}
22245 @cindex pragma, diagnostic
22246 Generates an error message. This pragma @emph{is} considered to
22247 indicate an error in the compilation, and it will be treated as such.
22249 Newlines can be included in the string by using the @samp{\n}
22250 escape sequence. They will be displayed as newlines even if the
22251 @option{-fmessage-length} option is set to zero.
22253 The error is only generated if the pragma is present in the code after
22254 pre-processing has been completed. It does not matter however if the
22255 code containing the pragma is unreachable:
22259 #pragma GCC error "this error is not seen"
22264 #pragma GCC error "this error is seen"
22268 @item #pragma GCC warning @var{message}
22269 @cindex pragma, diagnostic
22270 This is just like @samp{pragma GCC error} except that a warning
22271 message is issued instead of an error message. Unless
22272 @option{-Werror} is in effect, in which case this pragma will generate
22277 @node Visibility Pragmas
22278 @subsection Visibility Pragmas
22281 @item #pragma GCC visibility push(@var{visibility})
22282 @itemx #pragma GCC visibility pop
22283 @cindex pragma, visibility
22285 This pragma allows the user to set the visibility for multiple
22286 declarations without having to give each a visibility attribute
22287 (@pxref{Function Attributes}).
22289 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
22290 declarations. Class members and template specializations are not
22291 affected; if you want to override the visibility for a particular
22292 member or instantiation, you must use an attribute.
22297 @node Push/Pop Macro Pragmas
22298 @subsection Push/Pop Macro Pragmas
22300 For compatibility with Microsoft Windows compilers, GCC supports
22301 @samp{#pragma push_macro(@var{"macro_name"})}
22302 and @samp{#pragma pop_macro(@var{"macro_name"})}.
22305 @item #pragma push_macro(@var{"macro_name"})
22306 @cindex pragma, push_macro
22307 This pragma saves the value of the macro named as @var{macro_name} to
22308 the top of the stack for this macro.
22310 @item #pragma pop_macro(@var{"macro_name"})
22311 @cindex pragma, pop_macro
22312 This pragma sets the value of the macro named as @var{macro_name} to
22313 the value on top of the stack for this macro. If the stack for
22314 @var{macro_name} is empty, the value of the macro remains unchanged.
22321 #pragma push_macro("X")
22324 #pragma pop_macro("X")
22329 In this example, the definition of X as 1 is saved by @code{#pragma
22330 push_macro} and restored by @code{#pragma pop_macro}.
22332 @node Function Specific Option Pragmas
22333 @subsection Function Specific Option Pragmas
22336 @item #pragma GCC target (@var{"string"}...)
22337 @cindex pragma GCC target
22339 This pragma allows you to set target specific options for functions
22340 defined later in the source file. One or more strings can be
22341 specified. Each function that is defined after this point is as
22342 if @code{attribute((target("STRING")))} was specified for that
22343 function. The parenthesis around the options is optional.
22344 @xref{Function Attributes}, for more information about the
22345 @code{target} attribute and the attribute syntax.
22347 The @code{#pragma GCC target} pragma is presently implemented for
22348 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
22350 @item #pragma GCC optimize (@var{"string"}...)
22351 @cindex pragma GCC optimize
22353 This pragma allows you to set global optimization options for functions
22354 defined later in the source file. One or more strings can be
22355 specified. Each function that is defined after this point is as
22356 if @code{attribute((optimize("STRING")))} was specified for that
22357 function. The parenthesis around the options is optional.
22358 @xref{Function Attributes}, for more information about the
22359 @code{optimize} attribute and the attribute syntax.
22361 @item #pragma GCC push_options
22362 @itemx #pragma GCC pop_options
22363 @cindex pragma GCC push_options
22364 @cindex pragma GCC pop_options
22366 These pragmas maintain a stack of the current target and optimization
22367 options. It is intended for include files where you temporarily want
22368 to switch to using a different @samp{#pragma GCC target} or
22369 @samp{#pragma GCC optimize} and then to pop back to the previous
22372 @item #pragma GCC reset_options
22373 @cindex pragma GCC reset_options
22375 This pragma clears the current @code{#pragma GCC target} and
22376 @code{#pragma GCC optimize} to use the default switches as specified
22377 on the command line.
22381 @node Loop-Specific Pragmas
22382 @subsection Loop-Specific Pragmas
22385 @item #pragma GCC ivdep
22386 @cindex pragma GCC ivdep
22388 With this pragma, the programmer asserts that there are no loop-carried
22389 dependencies which would prevent consecutive iterations of
22390 the following loop from executing concurrently with SIMD
22391 (single instruction multiple data) instructions.
22393 For example, the compiler can only unconditionally vectorize the following
22394 loop with the pragma:
22397 void foo (int n, int *a, int *b, int *c)
22401 for (i = 0; i < n; ++i)
22402 a[i] = b[i] + c[i];
22407 In this example, using the @code{restrict} qualifier had the same
22408 effect. In the following example, that would not be possible. Assume
22409 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
22410 that it can unconditionally vectorize the following loop:
22413 void ignore_vec_dep (int *a, int k, int c, int m)
22416 for (int i = 0; i < m; i++)
22417 a[i] = a[i + k] * c;
22421 @item #pragma GCC unroll @var{n}
22422 @cindex pragma GCC unroll @var{n}
22424 You can use this pragma to control how many times a loop should be unrolled.
22425 It must be placed immediately before a @code{for}, @code{while} or @code{do}
22426 loop or a @code{#pragma GCC ivdep}, and applies only to the loop that follows.
22427 @var{n} is an integer constant expression specifying the unrolling factor.
22428 The values of @math{0} and @math{1} block any unrolling of the loop.
22432 @node Unnamed Fields
22433 @section Unnamed Structure and Union Fields
22434 @cindex @code{struct}
22435 @cindex @code{union}
22437 As permitted by ISO C11 and for compatibility with other compilers,
22438 GCC allows you to define
22439 a structure or union that contains, as fields, structures and unions
22440 without names. For example:
22454 In this example, you are able to access members of the unnamed
22455 union with code like @samp{foo.b}. Note that only unnamed structs and
22456 unions are allowed, you may not have, for example, an unnamed
22459 You must never create such structures that cause ambiguous field definitions.
22460 For example, in this structure:
22472 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
22473 The compiler gives errors for such constructs.
22475 @opindex fms-extensions
22476 Unless @option{-fms-extensions} is used, the unnamed field must be a
22477 structure or union definition without a tag (for example, @samp{struct
22478 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
22479 also be a definition with a tag such as @samp{struct foo @{ int a;
22480 @};}, a reference to a previously defined structure or union such as
22481 @samp{struct foo;}, or a reference to a @code{typedef} name for a
22482 previously defined structure or union type.
22484 @opindex fplan9-extensions
22485 The option @option{-fplan9-extensions} enables
22486 @option{-fms-extensions} as well as two other extensions. First, a
22487 pointer to a structure is automatically converted to a pointer to an
22488 anonymous field for assignments and function calls. For example:
22491 struct s1 @{ int a; @};
22492 struct s2 @{ struct s1; @};
22493 extern void f1 (struct s1 *);
22494 void f2 (struct s2 *p) @{ f1 (p); @}
22498 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
22499 converted into a pointer to the anonymous field.
22501 Second, when the type of an anonymous field is a @code{typedef} for a
22502 @code{struct} or @code{union}, code may refer to the field using the
22503 name of the @code{typedef}.
22506 typedef struct @{ int a; @} s1;
22507 struct s2 @{ s1; @};
22508 s1 f1 (struct s2 *p) @{ return p->s1; @}
22511 These usages are only permitted when they are not ambiguous.
22514 @section Thread-Local Storage
22515 @cindex Thread-Local Storage
22516 @cindex @acronym{TLS}
22517 @cindex @code{__thread}
22519 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
22520 are allocated such that there is one instance of the variable per extant
22521 thread. The runtime model GCC uses to implement this originates
22522 in the IA-64 processor-specific ABI, but has since been migrated
22523 to other processors as well. It requires significant support from
22524 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
22525 system libraries (@file{libc.so} and @file{libpthread.so}), so it
22526 is not available everywhere.
22528 At the user level, the extension is visible with a new storage
22529 class keyword: @code{__thread}. For example:
22533 extern __thread struct state s;
22534 static __thread char *p;
22537 The @code{__thread} specifier may be used alone, with the @code{extern}
22538 or @code{static} specifiers, but with no other storage class specifier.
22539 When used with @code{extern} or @code{static}, @code{__thread} must appear
22540 immediately after the other storage class specifier.
22542 The @code{__thread} specifier may be applied to any global, file-scoped
22543 static, function-scoped static, or static data member of a class. It may
22544 not be applied to block-scoped automatic or non-static data member.
22546 When the address-of operator is applied to a thread-local variable, it is
22547 evaluated at run time and returns the address of the current thread's
22548 instance of that variable. An address so obtained may be used by any
22549 thread. When a thread terminates, any pointers to thread-local variables
22550 in that thread become invalid.
22552 No static initialization may refer to the address of a thread-local variable.
22554 In C++, if an initializer is present for a thread-local variable, it must
22555 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
22558 See @uref{https://www.akkadia.org/drepper/tls.pdf,
22559 ELF Handling For Thread-Local Storage} for a detailed explanation of
22560 the four thread-local storage addressing models, and how the runtime
22561 is expected to function.
22564 * C99 Thread-Local Edits::
22565 * C++98 Thread-Local Edits::
22568 @node C99 Thread-Local Edits
22569 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
22571 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
22572 that document the exact semantics of the language extension.
22576 @cite{5.1.2 Execution environments}
22578 Add new text after paragraph 1
22581 Within either execution environment, a @dfn{thread} is a flow of
22582 control within a program. It is implementation defined whether
22583 or not there may be more than one thread associated with a program.
22584 It is implementation defined how threads beyond the first are
22585 created, the name and type of the function called at thread
22586 startup, and how threads may be terminated. However, objects
22587 with thread storage duration shall be initialized before thread
22592 @cite{6.2.4 Storage durations of objects}
22594 Add new text before paragraph 3
22597 An object whose identifier is declared with the storage-class
22598 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
22599 Its lifetime is the entire execution of the thread, and its
22600 stored value is initialized only once, prior to thread startup.
22604 @cite{6.4.1 Keywords}
22606 Add @code{__thread}.
22609 @cite{6.7.1 Storage-class specifiers}
22611 Add @code{__thread} to the list of storage class specifiers in
22614 Change paragraph 2 to
22617 With the exception of @code{__thread}, at most one storage-class
22618 specifier may be given [@dots{}]. The @code{__thread} specifier may
22619 be used alone, or immediately following @code{extern} or
22623 Add new text after paragraph 6
22626 The declaration of an identifier for a variable that has
22627 block scope that specifies @code{__thread} shall also
22628 specify either @code{extern} or @code{static}.
22630 The @code{__thread} specifier shall be used only with
22635 @node C++98 Thread-Local Edits
22636 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
22638 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
22639 that document the exact semantics of the language extension.
22643 @b{[intro.execution]}
22645 New text after paragraph 4
22648 A @dfn{thread} is a flow of control within the abstract machine.
22649 It is implementation defined whether or not there may be more than
22653 New text after paragraph 7
22656 It is unspecified whether additional action must be taken to
22657 ensure when and whether side effects are visible to other threads.
22663 Add @code{__thread}.
22666 @b{[basic.start.main]}
22668 Add after paragraph 5
22671 The thread that begins execution at the @code{main} function is called
22672 the @dfn{main thread}. It is implementation defined how functions
22673 beginning threads other than the main thread are designated or typed.
22674 A function so designated, as well as the @code{main} function, is called
22675 a @dfn{thread startup function}. It is implementation defined what
22676 happens if a thread startup function returns. It is implementation
22677 defined what happens to other threads when any thread calls @code{exit}.
22681 @b{[basic.start.init]}
22683 Add after paragraph 4
22686 The storage for an object of thread storage duration shall be
22687 statically initialized before the first statement of the thread startup
22688 function. An object of thread storage duration shall not require
22689 dynamic initialization.
22693 @b{[basic.start.term]}
22695 Add after paragraph 3
22698 The type of an object with thread storage duration shall not have a
22699 non-trivial destructor, nor shall it be an array type whose elements
22700 (directly or indirectly) have non-trivial destructors.
22706 Add ``thread storage duration'' to the list in paragraph 1.
22711 Thread, static, and automatic storage durations are associated with
22712 objects introduced by declarations [@dots{}].
22715 Add @code{__thread} to the list of specifiers in paragraph 3.
22718 @b{[basic.stc.thread]}
22720 New section before @b{[basic.stc.static]}
22723 The keyword @code{__thread} applied to a non-local object gives the
22724 object thread storage duration.
22726 A local variable or class data member declared both @code{static}
22727 and @code{__thread} gives the variable or member thread storage
22732 @b{[basic.stc.static]}
22737 All objects that have neither thread storage duration, dynamic
22738 storage duration nor are local [@dots{}].
22744 Add @code{__thread} to the list in paragraph 1.
22749 With the exception of @code{__thread}, at most one
22750 @var{storage-class-specifier} shall appear in a given
22751 @var{decl-specifier-seq}. The @code{__thread} specifier may
22752 be used alone, or immediately following the @code{extern} or
22753 @code{static} specifiers. [@dots{}]
22756 Add after paragraph 5
22759 The @code{__thread} specifier can be applied only to the names of objects
22760 and to anonymous unions.
22766 Add after paragraph 6
22769 Non-@code{static} members shall not be @code{__thread}.
22773 @node Binary constants
22774 @section Binary Constants using the @samp{0b} Prefix
22775 @cindex Binary constants using the @samp{0b} prefix
22777 Integer constants can be written as binary constants, consisting of a
22778 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
22779 @samp{0B}. This is particularly useful in environments that operate a
22780 lot on the bit level (like microcontrollers).
22782 The following statements are identical:
22791 The type of these constants follows the same rules as for octal or
22792 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
22795 @node C++ Extensions
22796 @chapter Extensions to the C++ Language
22797 @cindex extensions, C++ language
22798 @cindex C++ language extensions
22800 The GNU compiler provides these extensions to the C++ language (and you
22801 can also use most of the C language extensions in your C++ programs). If you
22802 want to write code that checks whether these features are available, you can
22803 test for the GNU compiler the same way as for C programs: check for a
22804 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
22805 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
22806 Predefined Macros,cpp,The GNU C Preprocessor}).
22809 * C++ Volatiles:: What constitutes an access to a volatile object.
22810 * Restricted Pointers:: C99 restricted pointers and references.
22811 * Vague Linkage:: Where G++ puts inlines, vtables and such.
22812 * C++ Interface:: You can use a single C++ header file for both
22813 declarations and definitions.
22814 * Template Instantiation:: Methods for ensuring that exactly one copy of
22815 each needed template instantiation is emitted.
22816 * Bound member functions:: You can extract a function pointer to the
22817 method denoted by a @samp{->*} or @samp{.*} expression.
22818 * C++ Attributes:: Variable, function, and type attributes for C++ only.
22819 * Function Multiversioning:: Declaring multiple function versions.
22820 * Type Traits:: Compiler support for type traits.
22821 * C++ Concepts:: Improved support for generic programming.
22822 * Deprecated Features:: Things will disappear from G++.
22823 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
22826 @node C++ Volatiles
22827 @section When is a Volatile C++ Object Accessed?
22828 @cindex accessing volatiles
22829 @cindex volatile read
22830 @cindex volatile write
22831 @cindex volatile access
22833 The C++ standard differs from the C standard in its treatment of
22834 volatile objects. It fails to specify what constitutes a volatile
22835 access, except to say that C++ should behave in a similar manner to C
22836 with respect to volatiles, where possible. However, the different
22837 lvalueness of expressions between C and C++ complicate the behavior.
22838 G++ behaves the same as GCC for volatile access, @xref{C
22839 Extensions,,Volatiles}, for a description of GCC's behavior.
22841 The C and C++ language specifications differ when an object is
22842 accessed in a void context:
22845 volatile int *src = @var{somevalue};
22849 The C++ standard specifies that such expressions do not undergo lvalue
22850 to rvalue conversion, and that the type of the dereferenced object may
22851 be incomplete. The C++ standard does not specify explicitly that it
22852 is lvalue to rvalue conversion that is responsible for causing an
22853 access. There is reason to believe that it is, because otherwise
22854 certain simple expressions become undefined. However, because it
22855 would surprise most programmers, G++ treats dereferencing a pointer to
22856 volatile object of complete type as GCC would do for an equivalent
22857 type in C@. When the object has incomplete type, G++ issues a
22858 warning; if you wish to force an error, you must force a conversion to
22859 rvalue with, for instance, a static cast.
22861 When using a reference to volatile, G++ does not treat equivalent
22862 expressions as accesses to volatiles, but instead issues a warning that
22863 no volatile is accessed. The rationale for this is that otherwise it
22864 becomes difficult to determine where volatile access occur, and not
22865 possible to ignore the return value from functions returning volatile
22866 references. Again, if you wish to force a read, cast the reference to
22869 G++ implements the same behavior as GCC does when assigning to a
22870 volatile object---there is no reread of the assigned-to object, the
22871 assigned rvalue is reused. Note that in C++ assignment expressions
22872 are lvalues, and if used as an lvalue, the volatile object is
22873 referred to. For instance, @var{vref} refers to @var{vobj}, as
22874 expected, in the following example:
22878 volatile int &vref = vobj = @var{something};
22881 @node Restricted Pointers
22882 @section Restricting Pointer Aliasing
22883 @cindex restricted pointers
22884 @cindex restricted references
22885 @cindex restricted this pointer
22887 As with the C front end, G++ understands the C99 feature of restricted pointers,
22888 specified with the @code{__restrict__}, or @code{__restrict} type
22889 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
22890 language flag, @code{restrict} is not a keyword in C++.
22892 In addition to allowing restricted pointers, you can specify restricted
22893 references, which indicate that the reference is not aliased in the local
22897 void fn (int *__restrict__ rptr, int &__restrict__ rref)
22904 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
22905 @var{rref} refers to a (different) unaliased integer.
22907 You may also specify whether a member function's @var{this} pointer is
22908 unaliased by using @code{__restrict__} as a member function qualifier.
22911 void T::fn () __restrict__
22918 Within the body of @code{T::fn}, @var{this} has the effective
22919 definition @code{T *__restrict__ const this}. Notice that the
22920 interpretation of a @code{__restrict__} member function qualifier is
22921 different to that of @code{const} or @code{volatile} qualifier, in that it
22922 is applied to the pointer rather than the object. This is consistent with
22923 other compilers that implement restricted pointers.
22925 As with all outermost parameter qualifiers, @code{__restrict__} is
22926 ignored in function definition matching. This means you only need to
22927 specify @code{__restrict__} in a function definition, rather than
22928 in a function prototype as well.
22930 @node Vague Linkage
22931 @section Vague Linkage
22932 @cindex vague linkage
22934 There are several constructs in C++ that require space in the object
22935 file but are not clearly tied to a single translation unit. We say that
22936 these constructs have ``vague linkage''. Typically such constructs are
22937 emitted wherever they are needed, though sometimes we can be more
22941 @item Inline Functions
22942 Inline functions are typically defined in a header file which can be
22943 included in many different compilations. Hopefully they can usually be
22944 inlined, but sometimes an out-of-line copy is necessary, if the address
22945 of the function is taken or if inlining fails. In general, we emit an
22946 out-of-line copy in all translation units where one is needed. As an
22947 exception, we only emit inline virtual functions with the vtable, since
22948 it always requires a copy.
22950 Local static variables and string constants used in an inline function
22951 are also considered to have vague linkage, since they must be shared
22952 between all inlined and out-of-line instances of the function.
22956 C++ virtual functions are implemented in most compilers using a lookup
22957 table, known as a vtable. The vtable contains pointers to the virtual
22958 functions provided by a class, and each object of the class contains a
22959 pointer to its vtable (or vtables, in some multiple-inheritance
22960 situations). If the class declares any non-inline, non-pure virtual
22961 functions, the first one is chosen as the ``key method'' for the class,
22962 and the vtable is only emitted in the translation unit where the key
22965 @emph{Note:} If the chosen key method is later defined as inline, the
22966 vtable is still emitted in every translation unit that defines it.
22967 Make sure that any inline virtuals are declared inline in the class
22968 body, even if they are not defined there.
22970 @item @code{type_info} objects
22971 @cindex @code{type_info}
22973 C++ requires information about types to be written out in order to
22974 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
22975 For polymorphic classes (classes with virtual functions), the @samp{type_info}
22976 object is written out along with the vtable so that @samp{dynamic_cast}
22977 can determine the dynamic type of a class object at run time. For all
22978 other types, we write out the @samp{type_info} object when it is used: when
22979 applying @samp{typeid} to an expression, throwing an object, or
22980 referring to a type in a catch clause or exception specification.
22982 @item Template Instantiations
22983 Most everything in this section also applies to template instantiations,
22984 but there are other options as well.
22985 @xref{Template Instantiation,,Where's the Template?}.
22989 When used with GNU ld version 2.8 or later on an ELF system such as
22990 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
22991 these constructs will be discarded at link time. This is known as
22994 On targets that don't support COMDAT, but do support weak symbols, GCC
22995 uses them. This way one copy overrides all the others, but
22996 the unused copies still take up space in the executable.
22998 For targets that do not support either COMDAT or weak symbols,
22999 most entities with vague linkage are emitted as local symbols to
23000 avoid duplicate definition errors from the linker. This does not happen
23001 for local statics in inlines, however, as having multiple copies
23002 almost certainly breaks things.
23004 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
23005 another way to control placement of these constructs.
23007 @node C++ Interface
23008 @section C++ Interface and Implementation Pragmas
23010 @cindex interface and implementation headers, C++
23011 @cindex C++ interface and implementation headers
23012 @cindex pragmas, interface and implementation
23014 @code{#pragma interface} and @code{#pragma implementation} provide the
23015 user with a way of explicitly directing the compiler to emit entities
23016 with vague linkage (and debugging information) in a particular
23019 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
23020 by COMDAT support and the ``key method'' heuristic
23021 mentioned in @ref{Vague Linkage}. Using them can actually cause your
23022 program to grow due to unnecessary out-of-line copies of inline
23026 @item #pragma interface
23027 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
23028 @kindex #pragma interface
23029 Use this directive in @emph{header files} that define object classes, to save
23030 space in most of the object files that use those classes. Normally,
23031 local copies of certain information (backup copies of inline member
23032 functions, debugging information, and the internal tables that implement
23033 virtual functions) must be kept in each object file that includes class
23034 definitions. You can use this pragma to avoid such duplication. When a
23035 header file containing @samp{#pragma interface} is included in a
23036 compilation, this auxiliary information is not generated (unless
23037 the main input source file itself uses @samp{#pragma implementation}).
23038 Instead, the object files contain references to be resolved at link
23041 The second form of this directive is useful for the case where you have
23042 multiple headers with the same name in different directories. If you
23043 use this form, you must specify the same string to @samp{#pragma
23046 @item #pragma implementation
23047 @itemx #pragma implementation "@var{objects}.h"
23048 @kindex #pragma implementation
23049 Use this pragma in a @emph{main input file}, when you want full output from
23050 included header files to be generated (and made globally visible). The
23051 included header file, in turn, should use @samp{#pragma interface}.
23052 Backup copies of inline member functions, debugging information, and the
23053 internal tables used to implement virtual functions are all generated in
23054 implementation files.
23056 @cindex implied @code{#pragma implementation}
23057 @cindex @code{#pragma implementation}, implied
23058 @cindex naming convention, implementation headers
23059 If you use @samp{#pragma implementation} with no argument, it applies to
23060 an include file with the same basename@footnote{A file's @dfn{basename}
23061 is the name stripped of all leading path information and of trailing
23062 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
23063 file. For example, in @file{allclass.cc}, giving just
23064 @samp{#pragma implementation}
23065 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
23067 Use the string argument if you want a single implementation file to
23068 include code from multiple header files. (You must also use
23069 @samp{#include} to include the header file; @samp{#pragma
23070 implementation} only specifies how to use the file---it doesn't actually
23073 There is no way to split up the contents of a single header file into
23074 multiple implementation files.
23077 @cindex inlining and C++ pragmas
23078 @cindex C++ pragmas, effect on inlining
23079 @cindex pragmas in C++, effect on inlining
23080 @samp{#pragma implementation} and @samp{#pragma interface} also have an
23081 effect on function inlining.
23083 If you define a class in a header file marked with @samp{#pragma
23084 interface}, the effect on an inline function defined in that class is
23085 similar to an explicit @code{extern} declaration---the compiler emits
23086 no code at all to define an independent version of the function. Its
23087 definition is used only for inlining with its callers.
23089 @opindex fno-implement-inlines
23090 Conversely, when you include the same header file in a main source file
23091 that declares it as @samp{#pragma implementation}, the compiler emits
23092 code for the function itself; this defines a version of the function
23093 that can be found via pointers (or by callers compiled without
23094 inlining). If all calls to the function can be inlined, you can avoid
23095 emitting the function by compiling with @option{-fno-implement-inlines}.
23096 If any calls are not inlined, you will get linker errors.
23098 @node Template Instantiation
23099 @section Where's the Template?
23100 @cindex template instantiation
23102 C++ templates were the first language feature to require more
23103 intelligence from the environment than was traditionally found on a UNIX
23104 system. Somehow the compiler and linker have to make sure that each
23105 template instance occurs exactly once in the executable if it is needed,
23106 and not at all otherwise. There are two basic approaches to this
23107 problem, which are referred to as the Borland model and the Cfront model.
23110 @item Borland model
23111 Borland C++ solved the template instantiation problem by adding the code
23112 equivalent of common blocks to their linker; the compiler emits template
23113 instances in each translation unit that uses them, and the linker
23114 collapses them together. The advantage of this model is that the linker
23115 only has to consider the object files themselves; there is no external
23116 complexity to worry about. The disadvantage is that compilation time
23117 is increased because the template code is being compiled repeatedly.
23118 Code written for this model tends to include definitions of all
23119 templates in the header file, since they must be seen to be
23123 The AT&T C++ translator, Cfront, solved the template instantiation
23124 problem by creating the notion of a template repository, an
23125 automatically maintained place where template instances are stored. A
23126 more modern version of the repository works as follows: As individual
23127 object files are built, the compiler places any template definitions and
23128 instantiations encountered in the repository. At link time, the link
23129 wrapper adds in the objects in the repository and compiles any needed
23130 instances that were not previously emitted. The advantages of this
23131 model are more optimal compilation speed and the ability to use the
23132 system linker; to implement the Borland model a compiler vendor also
23133 needs to replace the linker. The disadvantages are vastly increased
23134 complexity, and thus potential for error; for some code this can be
23135 just as transparent, but in practice it can been very difficult to build
23136 multiple programs in one directory and one program in multiple
23137 directories. Code written for this model tends to separate definitions
23138 of non-inline member templates into a separate file, which should be
23139 compiled separately.
23142 G++ implements the Borland model on targets where the linker supports it,
23143 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
23144 Otherwise G++ implements neither automatic model.
23146 You have the following options for dealing with template instantiations:
23150 Do nothing. Code written for the Borland model works fine, but
23151 each translation unit contains instances of each of the templates it
23152 uses. The duplicate instances will be discarded by the linker, but in
23153 a large program, this can lead to an unacceptable amount of code
23154 duplication in object files or shared libraries.
23156 Duplicate instances of a template can be avoided by defining an explicit
23157 instantiation in one object file, and preventing the compiler from doing
23158 implicit instantiations in any other object files by using an explicit
23159 instantiation declaration, using the @code{extern template} syntax:
23162 extern template int max (int, int);
23165 This syntax is defined in the C++ 2011 standard, but has been supported by
23166 G++ and other compilers since well before 2011.
23168 Explicit instantiations can be used for the largest or most frequently
23169 duplicated instances, without having to know exactly which other instances
23170 are used in the rest of the program. You can scatter the explicit
23171 instantiations throughout your program, perhaps putting them in the
23172 translation units where the instances are used or the translation units
23173 that define the templates themselves; you can put all of the explicit
23174 instantiations you need into one big file; or you can create small files
23181 template class Foo<int>;
23182 template ostream& operator <<
23183 (ostream&, const Foo<int>&);
23187 for each of the instances you need, and create a template instantiation
23188 library from those.
23190 This is the simplest option, but also offers flexibility and
23191 fine-grained control when necessary. It is also the most portable
23192 alternative and programs using this approach will work with most modern
23197 Compile your template-using code with @option{-frepo}. The compiler
23198 generates files with the extension @samp{.rpo} listing all of the
23199 template instantiations used in the corresponding object files that
23200 could be instantiated there; the link wrapper, @samp{collect2},
23201 then updates the @samp{.rpo} files to tell the compiler where to place
23202 those instantiations and rebuild any affected object files. The
23203 link-time overhead is negligible after the first pass, as the compiler
23204 continues to place the instantiations in the same files.
23206 This can be a suitable option for application code written for the Borland
23207 model, as it usually just works. Code written for the Cfront model
23208 needs to be modified so that the template definitions are available at
23209 one or more points of instantiation; usually this is as simple as adding
23210 @code{#include <tmethods.cc>} to the end of each template header.
23212 For library code, if you want the library to provide all of the template
23213 instantiations it needs, just try to link all of its object files
23214 together; the link will fail, but cause the instantiations to be
23215 generated as a side effect. Be warned, however, that this may cause
23216 conflicts if multiple libraries try to provide the same instantiations.
23217 For greater control, use explicit instantiation as described in the next
23221 @opindex fno-implicit-templates
23222 Compile your code with @option{-fno-implicit-templates} to disable the
23223 implicit generation of template instances, and explicitly instantiate
23224 all the ones you use. This approach requires more knowledge of exactly
23225 which instances you need than do the others, but it's less
23226 mysterious and allows greater control if you want to ensure that only
23227 the intended instances are used.
23229 If you are using Cfront-model code, you can probably get away with not
23230 using @option{-fno-implicit-templates} when compiling files that don't
23231 @samp{#include} the member template definitions.
23233 If you use one big file to do the instantiations, you may want to
23234 compile it without @option{-fno-implicit-templates} so you get all of the
23235 instances required by your explicit instantiations (but not by any
23236 other files) without having to specify them as well.
23238 In addition to forward declaration of explicit instantiations
23239 (with @code{extern}), G++ has extended the template instantiation
23240 syntax to support instantiation of the compiler support data for a
23241 template class (i.e.@: the vtable) without instantiating any of its
23242 members (with @code{inline}), and instantiation of only the static data
23243 members of a template class, without the support data or member
23244 functions (with @code{static}):
23247 inline template class Foo<int>;
23248 static template class Foo<int>;
23252 @node Bound member functions
23253 @section Extracting the Function Pointer from a Bound Pointer to Member Function
23255 @cindex pointer to member function
23256 @cindex bound pointer to member function
23258 In C++, pointer to member functions (PMFs) are implemented using a wide
23259 pointer of sorts to handle all the possible call mechanisms; the PMF
23260 needs to store information about how to adjust the @samp{this} pointer,
23261 and if the function pointed to is virtual, where to find the vtable, and
23262 where in the vtable to look for the member function. If you are using
23263 PMFs in an inner loop, you should really reconsider that decision. If
23264 that is not an option, you can extract the pointer to the function that
23265 would be called for a given object/PMF pair and call it directly inside
23266 the inner loop, to save a bit of time.
23268 Note that you still pay the penalty for the call through a
23269 function pointer; on most modern architectures, such a call defeats the
23270 branch prediction features of the CPU@. This is also true of normal
23271 virtual function calls.
23273 The syntax for this extension is
23277 extern int (A::*fp)();
23278 typedef int (*fptr)(A *);
23280 fptr p = (fptr)(a.*fp);
23283 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
23284 no object is needed to obtain the address of the function. They can be
23285 converted to function pointers directly:
23288 fptr p1 = (fptr)(&A::foo);
23291 @opindex Wno-pmf-conversions
23292 You must specify @option{-Wno-pmf-conversions} to use this extension.
23294 @node C++ Attributes
23295 @section C++-Specific Variable, Function, and Type Attributes
23297 Some attributes only make sense for C++ programs.
23300 @item abi_tag ("@var{tag}", ...)
23301 @cindex @code{abi_tag} function attribute
23302 @cindex @code{abi_tag} variable attribute
23303 @cindex @code{abi_tag} type attribute
23304 The @code{abi_tag} attribute can be applied to a function, variable, or class
23305 declaration. It modifies the mangled name of the entity to
23306 incorporate the tag name, in order to distinguish the function or
23307 class from an earlier version with a different ABI; perhaps the class
23308 has changed size, or the function has a different return type that is
23309 not encoded in the mangled name.
23311 The attribute can also be applied to an inline namespace, but does not
23312 affect the mangled name of the namespace; in this case it is only used
23313 for @option{-Wabi-tag} warnings and automatic tagging of functions and
23314 variables. Tagging inline namespaces is generally preferable to
23315 tagging individual declarations, but the latter is sometimes
23316 necessary, such as when only certain members of a class need to be
23319 The argument can be a list of strings of arbitrary length. The
23320 strings are sorted on output, so the order of the list is
23323 A redeclaration of an entity must not add new ABI tags,
23324 since doing so would change the mangled name.
23326 The ABI tags apply to a name, so all instantiations and
23327 specializations of a template have the same tags. The attribute will
23328 be ignored if applied to an explicit specialization or instantiation.
23330 The @option{-Wabi-tag} flag enables a warning about a class which does
23331 not have all the ABI tags used by its subobjects and virtual functions; for users with code
23332 that needs to coexist with an earlier ABI, using this option can help
23333 to find all affected types that need to be tagged.
23335 When a type involving an ABI tag is used as the type of a variable or
23336 return type of a function where that tag is not already present in the
23337 signature of the function, the tag is automatically applied to the
23338 variable or function. @option{-Wabi-tag} also warns about this
23339 situation; this warning can be avoided by explicitly tagging the
23340 variable or function or moving it into a tagged inline namespace.
23342 @item init_priority (@var{priority})
23343 @cindex @code{init_priority} variable attribute
23345 In Standard C++, objects defined at namespace scope are guaranteed to be
23346 initialized in an order in strict accordance with that of their definitions
23347 @emph{in a given translation unit}. No guarantee is made for initializations
23348 across translation units. However, GNU C++ allows users to control the
23349 order of initialization of objects defined at namespace scope with the
23350 @code{init_priority} attribute by specifying a relative @var{priority},
23351 a constant integral expression currently bounded between 101 and 65535
23352 inclusive. Lower numbers indicate a higher priority.
23354 In the following example, @code{A} would normally be created before
23355 @code{B}, but the @code{init_priority} attribute reverses that order:
23358 Some_Class A __attribute__ ((init_priority (2000)));
23359 Some_Class B __attribute__ ((init_priority (543)));
23363 Note that the particular values of @var{priority} do not matter; only their
23367 @cindex @code{warn_unused} type attribute
23369 For C++ types with non-trivial constructors and/or destructors it is
23370 impossible for the compiler to determine whether a variable of this
23371 type is truly unused if it is not referenced. This type attribute
23372 informs the compiler that variables of this type should be warned
23373 about if they appear to be unused, just like variables of fundamental
23376 This attribute is appropriate for types which just represent a value,
23377 such as @code{std::string}; it is not appropriate for types which
23378 control a resource, such as @code{std::lock_guard}.
23380 This attribute is also accepted in C, but it is unnecessary because C
23381 does not have constructors or destructors.
23385 @node Function Multiversioning
23386 @section Function Multiversioning
23387 @cindex function versions
23389 With the GNU C++ front end, for x86 targets, you may specify multiple
23390 versions of a function, where each function is specialized for a
23391 specific target feature. At runtime, the appropriate version of the
23392 function is automatically executed depending on the characteristics of
23393 the execution platform. Here is an example.
23396 __attribute__ ((target ("default")))
23399 // The default version of foo.
23403 __attribute__ ((target ("sse4.2")))
23406 // foo version for SSE4.2
23410 __attribute__ ((target ("arch=atom")))
23413 // foo version for the Intel ATOM processor
23417 __attribute__ ((target ("arch=amdfam10")))
23420 // foo version for the AMD Family 0x10 processors.
23427 assert ((*p) () == foo ());
23432 In the above example, four versions of function foo are created. The
23433 first version of foo with the target attribute "default" is the default
23434 version. This version gets executed when no other target specific
23435 version qualifies for execution on a particular platform. A new version
23436 of foo is created by using the same function signature but with a
23437 different target string. Function foo is called or a pointer to it is
23438 taken just like a regular function. GCC takes care of doing the
23439 dispatching to call the right version at runtime. Refer to the
23440 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
23441 Function Multiversioning} for more details.
23444 @section Type Traits
23446 The C++ front end implements syntactic extensions that allow
23447 compile-time determination of
23448 various characteristics of a type (or of a
23452 @item __has_nothrow_assign (type)
23453 If @code{type} is const qualified or is a reference type then the trait is
23454 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
23455 is true, else if @code{type} is a cv class or union type with copy assignment
23456 operators that are known not to throw an exception then the trait is true,
23457 else it is false. Requires: @code{type} shall be a complete type,
23458 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23460 @item __has_nothrow_copy (type)
23461 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
23462 @code{type} is a cv class or union type with copy constructors that
23463 are known not to throw an exception then the trait is true, else it is false.
23464 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23465 @code{void}, or an array of unknown bound.
23467 @item __has_nothrow_constructor (type)
23468 If @code{__has_trivial_constructor (type)} is true then the trait is
23469 true, else if @code{type} is a cv class or union type (or array
23470 thereof) with a default constructor that is known not to throw an
23471 exception then the trait is true, else it is false. Requires:
23472 @code{type} shall be a complete type, (possibly cv-qualified)
23473 @code{void}, or an array of unknown bound.
23475 @item __has_trivial_assign (type)
23476 If @code{type} is const qualified or is a reference type then the trait is
23477 false. Otherwise if @code{__is_pod (type)} is true then the trait is
23478 true, else if @code{type} is a cv class or union type with a trivial
23479 copy assignment ([class.copy]) then the trait is true, else it is
23480 false. Requires: @code{type} shall be a complete type, (possibly
23481 cv-qualified) @code{void}, or an array of unknown bound.
23483 @item __has_trivial_copy (type)
23484 If @code{__is_pod (type)} is true or @code{type} is a reference type
23485 then the trait is true, else if @code{type} is a cv class or union type
23486 with a trivial copy constructor ([class.copy]) then the trait
23487 is true, else it is false. Requires: @code{type} shall be a complete
23488 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23490 @item __has_trivial_constructor (type)
23491 If @code{__is_pod (type)} is true then the trait is true, else if
23492 @code{type} is a cv class or union type (or array thereof) with a
23493 trivial default constructor ([class.ctor]) then the trait is true,
23494 else it is false. Requires: @code{type} shall be a complete
23495 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23497 @item __has_trivial_destructor (type)
23498 If @code{__is_pod (type)} is true or @code{type} is a reference type then
23499 the trait is true, else if @code{type} is a cv class or union type (or
23500 array thereof) with a trivial destructor ([class.dtor]) then the trait
23501 is true, else it is false. Requires: @code{type} shall be a complete
23502 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23504 @item __has_virtual_destructor (type)
23505 If @code{type} is a class type with a virtual destructor
23506 ([class.dtor]) then the trait is true, else it is false. Requires:
23507 @code{type} shall be a complete type, (possibly cv-qualified)
23508 @code{void}, or an array of unknown bound.
23510 @item __is_abstract (type)
23511 If @code{type} is an abstract class ([class.abstract]) then the trait
23512 is true, else it is false. Requires: @code{type} shall be a complete
23513 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23515 @item __is_base_of (base_type, derived_type)
23516 If @code{base_type} is a base class of @code{derived_type}
23517 ([class.derived]) then the trait is true, otherwise it is false.
23518 Top-level cv qualifications of @code{base_type} and
23519 @code{derived_type} are ignored. For the purposes of this trait, a
23520 class type is considered is own base. Requires: if @code{__is_class
23521 (base_type)} and @code{__is_class (derived_type)} are true and
23522 @code{base_type} and @code{derived_type} are not the same type
23523 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
23524 type. A diagnostic is produced if this requirement is not met.
23526 @item __is_class (type)
23527 If @code{type} is a cv class type, and not a union type
23528 ([basic.compound]) the trait is true, else it is false.
23530 @item __is_empty (type)
23531 If @code{__is_class (type)} is false then the trait is false.
23532 Otherwise @code{type} is considered empty if and only if: @code{type}
23533 has no non-static data members, or all non-static data members, if
23534 any, are bit-fields of length 0, and @code{type} has no virtual
23535 members, and @code{type} has no virtual base classes, and @code{type}
23536 has no base classes @code{base_type} for which
23537 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
23538 be a complete type, (possibly cv-qualified) @code{void}, or an array
23541 @item __is_enum (type)
23542 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
23543 true, else it is false.
23545 @item __is_literal_type (type)
23546 If @code{type} is a literal type ([basic.types]) the trait is
23547 true, else it is false. Requires: @code{type} shall be a complete type,
23548 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23550 @item __is_pod (type)
23551 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
23552 else it is false. Requires: @code{type} shall be a complete type,
23553 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23555 @item __is_polymorphic (type)
23556 If @code{type} is a polymorphic class ([class.virtual]) then the trait
23557 is true, else it is false. Requires: @code{type} shall be a complete
23558 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23560 @item __is_standard_layout (type)
23561 If @code{type} is a standard-layout type ([basic.types]) the trait is
23562 true, else it is false. Requires: @code{type} shall be a complete
23563 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23565 @item __is_trivial (type)
23566 If @code{type} is a trivial type ([basic.types]) the trait is
23567 true, else it is false. Requires: @code{type} shall be a complete
23568 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23570 @item __is_union (type)
23571 If @code{type} is a cv union type ([basic.compound]) the trait is
23572 true, else it is false.
23574 @item __underlying_type (type)
23575 The underlying type of @code{type}. Requires: @code{type} shall be
23576 an enumeration type ([dcl.enum]).
23578 @item __integer_pack (length)
23579 When used as the pattern of a pack expansion within a template
23580 definition, expands to a template argument pack containing integers
23581 from @code{0} to @code{length-1}. This is provided for efficient
23582 implementation of @code{std::make_integer_sequence}.
23588 @section C++ Concepts
23590 C++ concepts provide much-improved support for generic programming. In
23591 particular, they allow the specification of constraints on template arguments.
23592 The constraints are used to extend the usual overloading and partial
23593 specialization capabilities of the language, allowing generic data structures
23594 and algorithms to be ``refined'' based on their properties rather than their
23597 The following keywords are reserved for concepts.
23601 States an expression as an assumption, and if possible, verifies that the
23602 assumption is valid. For example, @code{assume(n > 0)}.
23605 Introduces an axiom definition. Axioms introduce requirements on values.
23608 Introduces a universally quantified object in an axiom. For example,
23609 @code{forall (int n) n + 0 == n}).
23612 Introduces a concept definition. Concepts are sets of syntactic and semantic
23613 requirements on types and their values.
23616 Introduces constraints on template arguments or requirements for a member
23617 function of a class template.
23621 The front end also exposes a number of internal mechanism that can be used
23622 to simplify the writing of type traits. Note that some of these traits are
23623 likely to be removed in the future.
23626 @item __is_same (type1, type2)
23627 A binary type trait: true whenever the type arguments are the same.
23632 @node Deprecated Features
23633 @section Deprecated Features
23635 In the past, the GNU C++ compiler was extended to experiment with new
23636 features, at a time when the C++ language was still evolving. Now that
23637 the C++ standard is complete, some of those features are superseded by
23638 superior alternatives. Using the old features might cause a warning in
23639 some cases that the feature will be dropped in the future. In other
23640 cases, the feature might be gone already.
23642 G++ allows a virtual function returning @samp{void *} to be overridden
23643 by one returning a different pointer type. This extension to the
23644 covariant return type rules is now deprecated and will be removed from a
23647 The use of default arguments in function pointers, function typedefs
23648 and other places where they are not permitted by the standard is
23649 deprecated and will be removed from a future version of G++.
23651 G++ allows floating-point literals to appear in integral constant expressions,
23652 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
23653 This extension is deprecated and will be removed from a future version.
23655 G++ allows static data members of const floating-point type to be declared
23656 with an initializer in a class definition. The standard only allows
23657 initializers for static members of const integral types and const
23658 enumeration types so this extension has been deprecated and will be removed
23659 from a future version.
23661 G++ allows attributes to follow a parenthesized direct initializer,
23662 e.g.@: @samp{ int f (0) __attribute__ ((something)); } This extension
23663 has been ignored since G++ 3.3 and is deprecated.
23665 G++ allows anonymous structs and unions to have members that are not
23666 public non-static data members (i.e.@: fields). These extensions are
23669 @node Backwards Compatibility
23670 @section Backwards Compatibility
23671 @cindex Backwards Compatibility
23672 @cindex ARM [Annotated C++ Reference Manual]
23674 Now that there is a definitive ISO standard C++, G++ has a specification
23675 to adhere to. The C++ language evolved over time, and features that
23676 used to be acceptable in previous drafts of the standard, such as the ARM
23677 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
23678 compilation of C++ written to such drafts, G++ contains some backwards
23679 compatibilities. @emph{All such backwards compatibility features are
23680 liable to disappear in future versions of G++.} They should be considered
23681 deprecated. @xref{Deprecated Features}.
23685 @item Implicit C language
23686 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
23687 scope to set the language. On such systems, all system header files are
23688 implicitly scoped inside a C language scope. Also, an empty prototype
23689 @code{()} is treated as an unspecified number of arguments, rather
23690 than no arguments, as C++ demands.
23694 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
23695 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr