1 @c Copyright (C) 1988-2016 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 * Attribute Syntax:: Formal syntax for attributes.
64 * Function Prototypes:: Prototype declarations and old-style definitions.
65 * C++ Comments:: C++ comments are recognized.
66 * Dollar Signs:: Dollar sign is allowed in identifiers.
67 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
68 * Alignment:: Inquiring about the alignment of a type or variable.
69 * Inline:: Defining inline functions (as fast as macros).
70 * Volatiles:: What constitutes an access to a volatile object.
71 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
72 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
73 * Incomplete Enums:: @code{enum foo;}, with details to follow.
74 * Function Names:: Printable strings which are the name of the current
76 * Return Address:: Getting the return or frame address of a function.
77 * Vector Extensions:: Using vector instructions through built-in functions.
78 * Offsetof:: Special syntax for implementing @code{offsetof}.
79 * __sync Builtins:: Legacy built-in functions for atomic memory access.
80 * __atomic Builtins:: Atomic built-in functions with memory model.
81 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
82 arithmetic overflow checking.
83 * x86 specific memory model extensions for transactional memory:: x86 memory models.
84 * Object Size Checking:: Built-in functions for limited buffer overflow
86 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
87 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
88 * Other Builtins:: Other built-in functions.
89 * Target Builtins:: Built-in functions specific to particular targets.
90 * Target Format Checks:: Format checks specific to particular targets.
91 * Pragmas:: Pragmas accepted by GCC.
92 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
93 * Thread-Local:: Per-thread variables.
94 * Binary constants:: Binary constants using the @samp{0b} prefix.
98 @section Statements and Declarations in Expressions
99 @cindex statements inside expressions
100 @cindex declarations inside expressions
101 @cindex expressions containing statements
102 @cindex macros, statements in expressions
104 @c the above section title wrapped and causes an underfull hbox.. i
105 @c changed it from "within" to "in". --mew 4feb93
106 A compound statement enclosed in parentheses may appear as an expression
107 in GNU C@. This allows you to use loops, switches, and local variables
108 within an expression.
110 Recall that a compound statement is a sequence of statements surrounded
111 by braces; in this construct, parentheses go around the braces. For
115 (@{ int y = foo (); int z;
122 is a valid (though slightly more complex than necessary) expression
123 for the absolute value of @code{foo ()}.
125 The last thing in the compound statement should be an expression
126 followed by a semicolon; the value of this subexpression serves as the
127 value of the entire construct. (If you use some other kind of statement
128 last within the braces, the construct has type @code{void}, and thus
129 effectively no value.)
131 This feature is especially useful in making macro definitions ``safe'' (so
132 that they evaluate each operand exactly once). For example, the
133 ``maximum'' function is commonly defined as a macro in standard C as
137 #define max(a,b) ((a) > (b) ? (a) : (b))
141 @cindex side effects, macro argument
142 But this definition computes either @var{a} or @var{b} twice, with bad
143 results if the operand has side effects. In GNU C, if you know the
144 type of the operands (here taken as @code{int}), you can define
145 the macro safely as follows:
148 #define maxint(a,b) \
149 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
152 Embedded statements are not allowed in constant expressions, such as
153 the value of an enumeration constant, the width of a bit-field, or
154 the initial value of a static variable.
156 If you don't know the type of the operand, you can still do this, but you
157 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
159 In G++, the result value of a statement expression undergoes array and
160 function pointer decay, and is returned by value to the enclosing
161 expression. For instance, if @code{A} is a class, then
170 constructs a temporary @code{A} object to hold the result of the
171 statement expression, and that is used to invoke @code{Foo}.
172 Therefore the @code{this} pointer observed by @code{Foo} is not the
175 In a statement expression, any temporaries created within a statement
176 are destroyed at that statement's end. This makes statement
177 expressions inside macros slightly different from function calls. In
178 the latter case temporaries introduced during argument evaluation are
179 destroyed at the end of the statement that includes the function
180 call. In the statement expression case they are destroyed during
181 the statement expression. For instance,
184 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
185 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
195 has different places where temporaries are destroyed. For the
196 @code{macro} case, the temporary @code{X} is destroyed just after
197 the initialization of @code{b}. In the @code{function} case that
198 temporary is destroyed when the function returns.
200 These considerations mean that it is probably a bad idea to use
201 statement expressions of this form in header files that are designed to
202 work with C++. (Note that some versions of the GNU C Library contained
203 header files using statement expressions that lead to precisely this
206 Jumping into a statement expression with @code{goto} or using a
207 @code{switch} statement outside the statement expression with a
208 @code{case} or @code{default} label inside the statement expression is
209 not permitted. Jumping into a statement expression with a computed
210 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
211 Jumping out of a statement expression is permitted, but if the
212 statement expression is part of a larger expression then it is
213 unspecified which other subexpressions of that expression have been
214 evaluated except where the language definition requires certain
215 subexpressions to be evaluated before or after the statement
216 expression. In any case, as with a function call, the evaluation of a
217 statement expression is not interleaved with the evaluation of other
218 parts of the containing expression. For example,
221 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
225 calls @code{foo} and @code{bar1} and does not call @code{baz} but
226 may or may not call @code{bar2}. If @code{bar2} is called, it is
227 called after @code{foo} and before @code{bar1}.
230 @section Locally Declared Labels
232 @cindex macros, local labels
234 GCC allows you to declare @dfn{local labels} in any nested block
235 scope. A local label is just like an ordinary label, but you can
236 only reference it (with a @code{goto} statement, or by taking its
237 address) within the block in which it is declared.
239 A local label declaration looks like this:
242 __label__ @var{label};
249 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
252 Local label declarations must come at the beginning of the block,
253 before any ordinary declarations or statements.
255 The label declaration defines the label @emph{name}, but does not define
256 the label itself. You must do this in the usual way, with
257 @code{@var{label}:}, within the statements of the statement expression.
259 The local label feature is useful for complex macros. If a macro
260 contains nested loops, a @code{goto} can be useful for breaking out of
261 them. However, an ordinary label whose scope is the whole function
262 cannot be used: if the macro can be expanded several times in one
263 function, the label is multiply defined in that function. A
264 local label avoids this problem. For example:
267 #define SEARCH(value, array, target) \
270 typeof (target) _SEARCH_target = (target); \
271 typeof (*(array)) *_SEARCH_array = (array); \
274 for (i = 0; i < max; i++) \
275 for (j = 0; j < max; j++) \
276 if (_SEARCH_array[i][j] == _SEARCH_target) \
277 @{ (value) = i; goto found; @} \
283 This could also be written using a statement expression:
286 #define SEARCH(array, target) \
289 typeof (target) _SEARCH_target = (target); \
290 typeof (*(array)) *_SEARCH_array = (array); \
293 for (i = 0; i < max; i++) \
294 for (j = 0; j < max; j++) \
295 if (_SEARCH_array[i][j] == _SEARCH_target) \
296 @{ value = i; goto found; @} \
303 Local label declarations also make the labels they declare visible to
304 nested functions, if there are any. @xref{Nested Functions}, for details.
306 @node Labels as Values
307 @section Labels as Values
308 @cindex labels as values
309 @cindex computed gotos
310 @cindex goto with computed label
311 @cindex address of a label
313 You can get the address of a label defined in the current function
314 (or a containing function) with the unary operator @samp{&&}. The
315 value has type @code{void *}. This value is a constant and can be used
316 wherever a constant of that type is valid. For example:
324 To use these values, you need to be able to jump to one. This is done
325 with the computed goto statement@footnote{The analogous feature in
326 Fortran is called an assigned goto, but that name seems inappropriate in
327 C, where one can do more than simply store label addresses in label
328 variables.}, @code{goto *@var{exp};}. For example,
335 Any expression of type @code{void *} is allowed.
337 One way of using these constants is in initializing a static array that
338 serves as a jump table:
341 static void *array[] = @{ &&foo, &&bar, &&hack @};
345 Then you can select a label with indexing, like this:
352 Note that this does not check whether the subscript is in bounds---array
353 indexing in C never does that.
355 Such an array of label values serves a purpose much like that of the
356 @code{switch} statement. The @code{switch} statement is cleaner, so
357 use that rather than an array unless the problem does not fit a
358 @code{switch} statement very well.
360 Another use of label values is in an interpreter for threaded code.
361 The labels within the interpreter function can be stored in the
362 threaded code for super-fast dispatching.
364 You may not use this mechanism to jump to code in a different function.
365 If you do that, totally unpredictable things happen. The best way to
366 avoid this is to store the label address only in automatic variables and
367 never pass it as an argument.
369 An alternate way to write the above example is
372 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
374 goto *(&&foo + array[i]);
378 This is more friendly to code living in shared libraries, as it reduces
379 the number of dynamic relocations that are needed, and by consequence,
380 allows the data to be read-only.
381 This alternative with label differences is not supported for the AVR target,
382 please use the first approach for AVR programs.
384 The @code{&&foo} expressions for the same label might have different
385 values if the containing function is inlined or cloned. If a program
386 relies on them being always the same,
387 @code{__attribute__((__noinline__,__noclone__))} should be used to
388 prevent inlining and cloning. If @code{&&foo} is used in a static
389 variable initializer, inlining and cloning is forbidden.
391 @node Nested Functions
392 @section Nested Functions
393 @cindex nested functions
394 @cindex downward funargs
397 A @dfn{nested function} is a function defined inside another function.
398 Nested functions are supported as an extension in GNU C, but are not
399 supported by GNU C++.
401 The nested function's name is local to the block where it is defined.
402 For example, here we define a nested function named @code{square}, and
407 foo (double a, double b)
409 double square (double z) @{ return z * z; @}
411 return square (a) + square (b);
416 The nested function can access all the variables of the containing
417 function that are visible at the point of its definition. This is
418 called @dfn{lexical scoping}. For example, here we show a nested
419 function which uses an inherited variable named @code{offset}:
423 bar (int *array, int offset, int size)
425 int access (int *array, int index)
426 @{ return array[index + offset]; @}
429 for (i = 0; i < size; i++)
430 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
435 Nested function definitions are permitted within functions in the places
436 where variable definitions are allowed; that is, in any block, mixed
437 with the other declarations and statements in the block.
439 It is possible to call the nested function from outside the scope of its
440 name by storing its address or passing the address to another function:
443 hack (int *array, int size)
445 void store (int index, int value)
446 @{ array[index] = value; @}
448 intermediate (store, size);
452 Here, the function @code{intermediate} receives the address of
453 @code{store} as an argument. If @code{intermediate} calls @code{store},
454 the arguments given to @code{store} are used to store into @code{array}.
455 But this technique works only so long as the containing function
456 (@code{hack}, in this example) does not exit.
458 If you try to call the nested function through its address after the
459 containing function exits, all hell breaks loose. If you try
460 to call it after a containing scope level exits, and if it refers
461 to some of the variables that are no longer in scope, you may be lucky,
462 but it's not wise to take the risk. If, however, the nested function
463 does not refer to anything that has gone out of scope, you should be
466 GCC implements taking the address of a nested function using a technique
467 called @dfn{trampolines}. This technique was described in
468 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
469 C++ Conference Proceedings, October 17-21, 1988).
471 A nested function can jump to a label inherited from a containing
472 function, provided the label is explicitly declared in the containing
473 function (@pxref{Local Labels}). Such a jump returns instantly to the
474 containing function, exiting the nested function that did the
475 @code{goto} and any intermediate functions as well. Here is an example:
479 bar (int *array, int offset, int size)
482 int access (int *array, int index)
486 return array[index + offset];
490 for (i = 0; i < size; i++)
491 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
495 /* @r{Control comes here from @code{access}
496 if it detects an error.} */
503 A nested function always has no linkage. Declaring one with
504 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
505 before its definition, use @code{auto} (which is otherwise meaningless
506 for function declarations).
509 bar (int *array, int offset, int size)
512 auto int access (int *, int);
514 int access (int *array, int index)
518 return array[index + offset];
524 @node Constructing Calls
525 @section Constructing Function Calls
526 @cindex constructing calls
527 @cindex forwarding calls
529 Using the built-in functions described below, you can record
530 the arguments a function received, and call another function
531 with the same arguments, without knowing the number or types
534 You can also record the return value of that function call,
535 and later return that value, without knowing what data type
536 the function tried to return (as long as your caller expects
539 However, these built-in functions may interact badly with some
540 sophisticated features or other extensions of the language. It
541 is, therefore, not recommended to use them outside very simple
542 functions acting as mere forwarders for their arguments.
544 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
545 This built-in function returns a pointer to data
546 describing how to perform a call with the same arguments as are passed
547 to the current function.
549 The function saves the arg pointer register, structure value address,
550 and all registers that might be used to pass arguments to a function
551 into a block of memory allocated on the stack. Then it returns the
552 address of that block.
555 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
556 This built-in function invokes @var{function}
557 with a copy of the parameters described by @var{arguments}
560 The value of @var{arguments} should be the value returned by
561 @code{__builtin_apply_args}. The argument @var{size} specifies the size
562 of the stack argument data, in bytes.
564 This function returns a pointer to data describing
565 how to return whatever value is returned by @var{function}. The data
566 is saved in a block of memory allocated on the stack.
568 It is not always simple to compute the proper value for @var{size}. The
569 value is used by @code{__builtin_apply} to compute the amount of data
570 that should be pushed on the stack and copied from the incoming argument
574 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
575 This built-in function returns the value described by @var{result} from
576 the containing function. You should specify, for @var{result}, a value
577 returned by @code{__builtin_apply}.
580 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
581 This built-in function represents all anonymous arguments of an inline
582 function. It can be used only in inline functions that are always
583 inlined, never compiled as a separate function, such as those using
584 @code{__attribute__ ((__always_inline__))} or
585 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
586 It must be only passed as last argument to some other function
587 with variable arguments. This is useful for writing small wrapper
588 inlines for variable argument functions, when using preprocessor
589 macros is undesirable. For example:
591 extern int myprintf (FILE *f, const char *format, ...);
592 extern inline __attribute__ ((__gnu_inline__)) int
593 myprintf (FILE *f, const char *format, ...)
595 int r = fprintf (f, "myprintf: ");
598 int s = fprintf (f, format, __builtin_va_arg_pack ());
606 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
607 This built-in function returns the number of anonymous arguments of
608 an inline function. It can be used only in inline functions that
609 are always inlined, never compiled as a separate function, such
610 as those using @code{__attribute__ ((__always_inline__))} or
611 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
612 For example following does link- or run-time checking of open
613 arguments for optimized code:
616 extern inline __attribute__((__gnu_inline__)) int
617 myopen (const char *path, int oflag, ...)
619 if (__builtin_va_arg_pack_len () > 1)
620 warn_open_too_many_arguments ();
622 if (__builtin_constant_p (oflag))
624 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
626 warn_open_missing_mode ();
627 return __open_2 (path, oflag);
629 return open (path, oflag, __builtin_va_arg_pack ());
632 if (__builtin_va_arg_pack_len () < 1)
633 return __open_2 (path, oflag);
635 return open (path, oflag, __builtin_va_arg_pack ());
642 @section Referring to a Type with @code{typeof}
645 @cindex macros, types of arguments
647 Another way to refer to the type of an expression is with @code{typeof}.
648 The syntax of using of this keyword looks like @code{sizeof}, but the
649 construct acts semantically like a type name defined with @code{typedef}.
651 There are two ways of writing the argument to @code{typeof}: with an
652 expression or with a type. Here is an example with an expression:
659 This assumes that @code{x} is an array of pointers to functions;
660 the type described is that of the values of the functions.
662 Here is an example with a typename as the argument:
669 Here the type described is that of pointers to @code{int}.
671 If you are writing a header file that must work when included in ISO C
672 programs, write @code{__typeof__} instead of @code{typeof}.
673 @xref{Alternate Keywords}.
675 A @code{typeof} construct can be used anywhere a typedef name can be
676 used. For example, you can use it in a declaration, in a cast, or inside
677 of @code{sizeof} or @code{typeof}.
679 The operand of @code{typeof} is evaluated for its side effects if and
680 only if it is an expression of variably modified type or the name of
683 @code{typeof} is often useful in conjunction with
684 statement expressions (@pxref{Statement Exprs}).
685 Here is how the two together can
686 be used to define a safe ``maximum'' macro which operates on any
687 arithmetic type and evaluates each of its arguments exactly once:
691 (@{ typeof (a) _a = (a); \
692 typeof (b) _b = (b); \
693 _a > _b ? _a : _b; @})
696 @cindex underscores in variables in macros
697 @cindex @samp{_} in variables in macros
698 @cindex local variables in macros
699 @cindex variables, local, in macros
700 @cindex macros, local variables in
702 The reason for using names that start with underscores for the local
703 variables is to avoid conflicts with variable names that occur within the
704 expressions that are substituted for @code{a} and @code{b}. Eventually we
705 hope to design a new form of declaration syntax that allows you to declare
706 variables whose scopes start only after their initializers; this will be a
707 more reliable way to prevent such conflicts.
710 Some more examples of the use of @code{typeof}:
714 This declares @code{y} with the type of what @code{x} points to.
721 This declares @code{y} as an array of such values.
728 This declares @code{y} as an array of pointers to characters:
731 typeof (typeof (char *)[4]) y;
735 It is equivalent to the following traditional C declaration:
741 To see the meaning of the declaration using @code{typeof}, and why it
742 might be a useful way to write, rewrite it with these macros:
745 #define pointer(T) typeof(T *)
746 #define array(T, N) typeof(T [N])
750 Now the declaration can be rewritten this way:
753 array (pointer (char), 4) y;
757 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
758 pointers to @code{char}.
761 In GNU C, but not GNU C++, you may also declare the type of a variable
762 as @code{__auto_type}. In that case, the declaration must declare
763 only one variable, whose declarator must just be an identifier, the
764 declaration must be initialized, and the type of the variable is
765 determined by the initializer; the name of the variable is not in
766 scope until after the initializer. (In C++, you should use C++11
767 @code{auto} for this purpose.) Using @code{__auto_type}, the
768 ``maximum'' macro above could be written as:
772 (@{ __auto_type _a = (a); \
773 __auto_type _b = (b); \
774 _a > _b ? _a : _b; @})
777 Using @code{__auto_type} instead of @code{typeof} has two advantages:
780 @item Each argument to the macro appears only once in the expansion of
781 the macro. This prevents the size of the macro expansion growing
782 exponentially when calls to such macros are nested inside arguments of
785 @item If the argument to the macro has variably modified type, it is
786 evaluated only once when using @code{__auto_type}, but twice if
787 @code{typeof} is used.
791 @section Conditionals with Omitted Operands
792 @cindex conditional expressions, extensions
793 @cindex omitted middle-operands
794 @cindex middle-operands, omitted
795 @cindex extensions, @code{?:}
796 @cindex @code{?:} extensions
798 The middle operand in a conditional expression may be omitted. Then
799 if the first operand is nonzero, its value is the value of the conditional
802 Therefore, the expression
809 has the value of @code{x} if that is nonzero; otherwise, the value of
812 This example is perfectly equivalent to
818 @cindex side effect in @code{?:}
819 @cindex @code{?:} side effect
821 In this simple case, the ability to omit the middle operand is not
822 especially useful. When it becomes useful is when the first operand does,
823 or may (if it is a macro argument), contain a side effect. Then repeating
824 the operand in the middle would perform the side effect twice. Omitting
825 the middle operand uses the value already computed without the undesirable
826 effects of recomputing it.
829 @section 128-bit Integers
830 @cindex @code{__int128} data types
832 As an extension the integer scalar type @code{__int128} is supported for
833 targets which have an integer mode wide enough to hold 128 bits.
834 Simply write @code{__int128} for a signed 128-bit integer, or
835 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
836 support in GCC for expressing an integer constant of type @code{__int128}
837 for targets with @code{long long} integer less than 128 bits wide.
840 @section Double-Word Integers
841 @cindex @code{long long} data types
842 @cindex double-word arithmetic
843 @cindex multiprecision arithmetic
844 @cindex @code{LL} integer suffix
845 @cindex @code{ULL} integer suffix
847 ISO C99 supports data types for integers that are at least 64 bits wide,
848 and as an extension GCC supports them in C90 mode and in C++.
849 Simply write @code{long long int} for a signed integer, or
850 @code{unsigned long long int} for an unsigned integer. To make an
851 integer constant of type @code{long long int}, add the suffix @samp{LL}
852 to the integer. To make an integer constant of type @code{unsigned long
853 long int}, add the suffix @samp{ULL} to the integer.
855 You can use these types in arithmetic like any other integer types.
856 Addition, subtraction, and bitwise boolean operations on these types
857 are open-coded on all types of machines. Multiplication is open-coded
858 if the machine supports a fullword-to-doubleword widening multiply
859 instruction. Division and shifts are open-coded only on machines that
860 provide special support. The operations that are not open-coded use
861 special library routines that come with GCC@.
863 There may be pitfalls when you use @code{long long} types for function
864 arguments without function prototypes. If a function
865 expects type @code{int} for its argument, and you pass a value of type
866 @code{long long int}, confusion results because the caller and the
867 subroutine disagree about the number of bytes for the argument.
868 Likewise, if the function expects @code{long long int} and you pass
869 @code{int}. The best way to avoid such problems is to use prototypes.
872 @section Complex Numbers
873 @cindex complex numbers
874 @cindex @code{_Complex} keyword
875 @cindex @code{__complex__} keyword
877 ISO C99 supports complex floating data types, and as an extension GCC
878 supports them in C90 mode and in C++. GCC also supports complex integer data
879 types which are not part of ISO C99. You can declare complex types
880 using the keyword @code{_Complex}. As an extension, the older GNU
881 keyword @code{__complex__} is also supported.
883 For example, @samp{_Complex double x;} declares @code{x} as a
884 variable whose real part and imaginary part are both of type
885 @code{double}. @samp{_Complex short int y;} declares @code{y} to
886 have real and imaginary parts of type @code{short int}; this is not
887 likely to be useful, but it shows that the set of complex types is
890 To write a constant with a complex data type, use the suffix @samp{i} or
891 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
892 has type @code{_Complex float} and @code{3i} has type
893 @code{_Complex int}. Such a constant always has a pure imaginary
894 value, but you can form any complex value you like by adding one to a
895 real constant. This is a GNU extension; if you have an ISO C99
896 conforming C library (such as the GNU C Library), and want to construct complex
897 constants of floating type, you should include @code{<complex.h>} and
898 use the macros @code{I} or @code{_Complex_I} instead.
900 @cindex @code{__real__} keyword
901 @cindex @code{__imag__} keyword
902 To extract the real part of a complex-valued expression @var{exp}, write
903 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
904 extract the imaginary part. This is a GNU extension; for values of
905 floating type, you should use the ISO C99 functions @code{crealf},
906 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
907 @code{cimagl}, declared in @code{<complex.h>} and also provided as
908 built-in functions by GCC@.
910 @cindex complex conjugation
911 The operator @samp{~} performs complex conjugation when used on a value
912 with a complex type. This is a GNU extension; for values of
913 floating type, you should use the ISO C99 functions @code{conjf},
914 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
915 provided as built-in functions by GCC@.
917 GCC can allocate complex automatic variables in a noncontiguous
918 fashion; it's even possible for the real part to be in a register while
919 the imaginary part is on the stack (or vice versa). Only the DWARF
920 debug info format can represent this, so use of DWARF is recommended.
921 If you are using the stabs debug info format, GCC describes a noncontiguous
922 complex variable as if it were two separate variables of noncomplex type.
923 If the variable's actual name is @code{foo}, the two fictitious
924 variables are named @code{foo$real} and @code{foo$imag}. You can
925 examine and set these two fictitious variables with your debugger.
928 @section Additional Floating Types
929 @cindex additional floating types
930 @cindex @code{__float80} data type
931 @cindex @code{__float128} data type
932 @cindex @code{__ibm128} data type
933 @cindex @code{w} floating point suffix
934 @cindex @code{q} floating point suffix
935 @cindex @code{W} floating point suffix
936 @cindex @code{Q} floating point suffix
938 As an extension, GNU C supports additional floating
939 types, @code{__float80} and @code{__float128} to support 80-bit
940 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
941 Support for additional types includes the arithmetic operators:
942 add, subtract, multiply, divide; unary arithmetic operators;
943 relational operators; equality operators; and conversions to and from
944 integer and other floating types. Use a suffix @samp{w} or @samp{W}
945 in a literal constant of type @code{__float80} or type
946 @code{__ibm128}. Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
948 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
949 types using the corresponding internal complex type, @code{XCmode} for
950 @code{__float80} type and @code{TCmode} for @code{__float128} type:
953 typedef _Complex float __attribute__((mode(TC))) _Complex128;
954 typedef _Complex float __attribute__((mode(XC))) _Complex80;
957 In order to use @code{__float128} and @code{__ibm128} on PowerPC Linux
958 systems, you must use the @option{-mfloat128}. It is expected in
959 future versions of GCC that @code{__float128} will be enabled
960 automatically. In addition, there are currently problems in using the
961 complex @code{__float128} type. When these problems are fixed, you
962 would use the following syntax to declare @code{_Complex128} to be a
963 complex @code{__float128} type:
965 On the PowerPC Linux VSX targets, you can declare complex types using
966 the corresponding internal complex type, @code{KCmode} for
967 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
970 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
971 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
974 Not all targets support additional floating-point types.
975 @code{__float80} and @code{__float128} types are supported on x86 and
976 IA-64 targets. The @code{__float128} type is supported on hppa HP-UX.
977 The @code{__float128} type is supported on PowerPC 64-bit Linux
978 systems by default if the vector scalar instruction set (VSX) is
981 On the PowerPC, @code{__ibm128} provides access to the IBM extended
982 double format, and it is intended to be used by the library functions
983 that handle conversions if/when long double is changed to be IEEE
984 128-bit floating point.
987 @section Half-Precision Floating Point
988 @cindex half-precision floating point
989 @cindex @code{__fp16} data type
991 On ARM targets, GCC supports half-precision (16-bit) floating point via
992 the @code{__fp16} type. You must enable this type explicitly
993 with the @option{-mfp16-format} command-line option in order to use it.
995 ARM supports two incompatible representations for half-precision
996 floating-point values. You must choose one of the representations and
997 use it consistently in your program.
999 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1000 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1001 There are 11 bits of significand precision, approximately 3
1004 Specifying @option{-mfp16-format=alternative} selects the ARM
1005 alternative format. This representation is similar to the IEEE
1006 format, but does not support infinities or NaNs. Instead, the range
1007 of exponents is extended, so that this format can represent normalized
1008 values in the range of @math{2^{-14}} to 131008.
1010 The @code{__fp16} type is a storage format only. For purposes
1011 of arithmetic and other operations, @code{__fp16} values in C or C++
1012 expressions are automatically promoted to @code{float}. In addition,
1013 you cannot declare a function with a return value or parameters
1014 of type @code{__fp16}.
1016 Note that conversions from @code{double} to @code{__fp16}
1017 involve an intermediate conversion to @code{float}. Because
1018 of rounding, this can sometimes produce a different result than a
1021 ARM provides hardware support for conversions between
1022 @code{__fp16} and @code{float} values
1023 as an extension to VFP and NEON (Advanced SIMD). GCC generates
1024 code using these hardware instructions if you compile with
1025 options to select an FPU that provides them;
1026 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1027 in addition to the @option{-mfp16-format} option to select
1028 a half-precision format.
1030 Language-level support for the @code{__fp16} data type is
1031 independent of whether GCC generates code using hardware floating-point
1032 instructions. In cases where hardware support is not specified, GCC
1033 implements conversions between @code{__fp16} and @code{float} values
1037 @section Decimal Floating Types
1038 @cindex decimal floating types
1039 @cindex @code{_Decimal32} data type
1040 @cindex @code{_Decimal64} data type
1041 @cindex @code{_Decimal128} data type
1042 @cindex @code{df} integer suffix
1043 @cindex @code{dd} integer suffix
1044 @cindex @code{dl} integer suffix
1045 @cindex @code{DF} integer suffix
1046 @cindex @code{DD} integer suffix
1047 @cindex @code{DL} integer suffix
1049 As an extension, GNU C supports decimal floating types as
1050 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1051 floating types in GCC will evolve as the draft technical report changes.
1052 Calling conventions for any target might also change. Not all targets
1053 support decimal floating types.
1055 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1056 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1057 @code{float}, @code{double}, and @code{long double} whose radix is not
1058 specified by the C standard but is usually two.
1060 Support for decimal floating types includes the arithmetic operators
1061 add, subtract, multiply, divide; unary arithmetic operators;
1062 relational operators; equality operators; and conversions to and from
1063 integer and other floating types. Use a suffix @samp{df} or
1064 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1065 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1068 GCC support of decimal float as specified by the draft technical report
1073 When the value of a decimal floating type cannot be represented in the
1074 integer type to which it is being converted, the result is undefined
1075 rather than the result value specified by the draft technical report.
1078 GCC does not provide the C library functionality associated with
1079 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1080 @file{wchar.h}, which must come from a separate C library implementation.
1081 Because of this the GNU C compiler does not define macro
1082 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1083 the technical report.
1086 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1087 are supported by the DWARF debug information format.
1093 ISO C99 supports floating-point numbers written not only in the usual
1094 decimal notation, such as @code{1.55e1}, but also numbers such as
1095 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1096 supports this in C90 mode (except in some cases when strictly
1097 conforming) and in C++. In that format the
1098 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1099 mandatory. The exponent is a decimal number that indicates the power of
1100 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1107 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1108 is the same as @code{1.55e1}.
1110 Unlike for floating-point numbers in the decimal notation the exponent
1111 is always required in the hexadecimal notation. Otherwise the compiler
1112 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1113 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1114 extension for floating-point constants of type @code{float}.
1117 @section Fixed-Point Types
1118 @cindex fixed-point types
1119 @cindex @code{_Fract} data type
1120 @cindex @code{_Accum} data type
1121 @cindex @code{_Sat} data type
1122 @cindex @code{hr} fixed-suffix
1123 @cindex @code{r} fixed-suffix
1124 @cindex @code{lr} fixed-suffix
1125 @cindex @code{llr} fixed-suffix
1126 @cindex @code{uhr} fixed-suffix
1127 @cindex @code{ur} fixed-suffix
1128 @cindex @code{ulr} fixed-suffix
1129 @cindex @code{ullr} fixed-suffix
1130 @cindex @code{hk} fixed-suffix
1131 @cindex @code{k} fixed-suffix
1132 @cindex @code{lk} fixed-suffix
1133 @cindex @code{llk} fixed-suffix
1134 @cindex @code{uhk} fixed-suffix
1135 @cindex @code{uk} fixed-suffix
1136 @cindex @code{ulk} fixed-suffix
1137 @cindex @code{ullk} fixed-suffix
1138 @cindex @code{HR} fixed-suffix
1139 @cindex @code{R} fixed-suffix
1140 @cindex @code{LR} fixed-suffix
1141 @cindex @code{LLR} fixed-suffix
1142 @cindex @code{UHR} fixed-suffix
1143 @cindex @code{UR} fixed-suffix
1144 @cindex @code{ULR} fixed-suffix
1145 @cindex @code{ULLR} fixed-suffix
1146 @cindex @code{HK} fixed-suffix
1147 @cindex @code{K} fixed-suffix
1148 @cindex @code{LK} fixed-suffix
1149 @cindex @code{LLK} fixed-suffix
1150 @cindex @code{UHK} fixed-suffix
1151 @cindex @code{UK} fixed-suffix
1152 @cindex @code{ULK} fixed-suffix
1153 @cindex @code{ULLK} fixed-suffix
1155 As an extension, GNU C supports fixed-point types as
1156 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1157 types in GCC will evolve as the draft technical report changes.
1158 Calling conventions for any target might also change. Not all targets
1159 support fixed-point types.
1161 The fixed-point types are
1162 @code{short _Fract},
1165 @code{long long _Fract},
1166 @code{unsigned short _Fract},
1167 @code{unsigned _Fract},
1168 @code{unsigned long _Fract},
1169 @code{unsigned long long _Fract},
1170 @code{_Sat short _Fract},
1172 @code{_Sat long _Fract},
1173 @code{_Sat long long _Fract},
1174 @code{_Sat unsigned short _Fract},
1175 @code{_Sat unsigned _Fract},
1176 @code{_Sat unsigned long _Fract},
1177 @code{_Sat unsigned long long _Fract},
1178 @code{short _Accum},
1181 @code{long long _Accum},
1182 @code{unsigned short _Accum},
1183 @code{unsigned _Accum},
1184 @code{unsigned long _Accum},
1185 @code{unsigned long long _Accum},
1186 @code{_Sat short _Accum},
1188 @code{_Sat long _Accum},
1189 @code{_Sat long long _Accum},
1190 @code{_Sat unsigned short _Accum},
1191 @code{_Sat unsigned _Accum},
1192 @code{_Sat unsigned long _Accum},
1193 @code{_Sat unsigned long long _Accum}.
1195 Fixed-point data values contain fractional and optional integral parts.
1196 The format of fixed-point data varies and depends on the target machine.
1198 Support for fixed-point types includes:
1201 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1203 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1205 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1207 binary shift operators (@code{<<}, @code{>>})
1209 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1211 equality operators (@code{==}, @code{!=})
1213 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1214 @code{<<=}, @code{>>=})
1216 conversions to and from integer, floating-point, or fixed-point types
1219 Use a suffix in a fixed-point literal constant:
1221 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1222 @code{_Sat short _Fract}
1223 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1224 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1225 @code{_Sat long _Fract}
1226 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1227 @code{_Sat long long _Fract}
1228 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1229 @code{_Sat unsigned short _Fract}
1230 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1231 @code{_Sat unsigned _Fract}
1232 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1233 @code{_Sat unsigned long _Fract}
1234 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1235 and @code{_Sat unsigned long long _Fract}
1236 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1237 @code{_Sat short _Accum}
1238 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1239 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1240 @code{_Sat long _Accum}
1241 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1242 @code{_Sat long long _Accum}
1243 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1244 @code{_Sat unsigned short _Accum}
1245 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1246 @code{_Sat unsigned _Accum}
1247 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1248 @code{_Sat unsigned long _Accum}
1249 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1250 and @code{_Sat unsigned long long _Accum}
1253 GCC support of fixed-point types as specified by the draft technical report
1258 Pragmas to control overflow and rounding behaviors are not implemented.
1261 Fixed-point types are supported by the DWARF debug information format.
1263 @node Named Address Spaces
1264 @section Named Address Spaces
1265 @cindex Named Address Spaces
1267 As an extension, GNU C supports named address spaces as
1268 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1269 address spaces in GCC will evolve as the draft technical report
1270 changes. Calling conventions for any target might also change. At
1271 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1272 address spaces other than the generic address space.
1274 Address space identifiers may be used exactly like any other C type
1275 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1276 document for more details.
1278 @anchor{AVR Named Address Spaces}
1279 @subsection AVR Named Address Spaces
1281 On the AVR target, there are several address spaces that can be used
1282 in order to put read-only data into the flash memory and access that
1283 data by means of the special instructions @code{LPM} or @code{ELPM}
1284 needed to read from flash.
1286 Per default, any data including read-only data is located in RAM
1287 (the generic address space) so that non-generic address spaces are
1288 needed to locate read-only data in flash memory
1289 @emph{and} to generate the right instructions to access this data
1290 without using (inline) assembler code.
1294 @cindex @code{__flash} AVR Named Address Spaces
1295 The @code{__flash} qualifier locates data in the
1296 @code{.progmem.data} section. Data is read using the @code{LPM}
1297 instruction. Pointers to this address space are 16 bits wide.
1304 @cindex @code{__flash1} AVR Named Address Spaces
1305 @cindex @code{__flash2} AVR Named Address Spaces
1306 @cindex @code{__flash3} AVR Named Address Spaces
1307 @cindex @code{__flash4} AVR Named Address Spaces
1308 @cindex @code{__flash5} AVR Named Address Spaces
1309 These are 16-bit address spaces locating data in section
1310 @code{.progmem@var{N}.data} where @var{N} refers to
1311 address space @code{__flash@var{N}}.
1312 The compiler sets the @code{RAMPZ} segment register appropriately
1313 before reading data by means of the @code{ELPM} instruction.
1316 @cindex @code{__memx} AVR Named Address Spaces
1317 This is a 24-bit address space that linearizes flash and RAM:
1318 If the high bit of the address is set, data is read from
1319 RAM using the lower two bytes as RAM address.
1320 If the high bit of the address is clear, data is read from flash
1321 with @code{RAMPZ} set according to the high byte of the address.
1322 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1324 Objects in this address space are located in @code{.progmemx.data}.
1330 char my_read (const __flash char ** p)
1332 /* p is a pointer to RAM that points to a pointer to flash.
1333 The first indirection of p reads that flash pointer
1334 from RAM and the second indirection reads a char from this
1340 /* Locate array[] in flash memory */
1341 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1347 /* Return 17 by reading from flash memory */
1348 return array[array[i]];
1353 For each named address space supported by avr-gcc there is an equally
1354 named but uppercase built-in macro defined.
1355 The purpose is to facilitate testing if respective address space
1356 support is available or not:
1360 const __flash int var = 1;
1367 #include <avr/pgmspace.h> /* From AVR-LibC */
1369 const int var PROGMEM = 1;
1373 return (int) pgm_read_word (&var);
1375 #endif /* __FLASH */
1379 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1380 locates data in flash but
1381 accesses to these data read from generic address space, i.e.@:
1383 so that you need special accessors like @code{pgm_read_byte}
1384 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1385 together with attribute @code{progmem}.
1388 @b{Limitations and caveats}
1392 Reading across the 64@tie{}KiB section boundary of
1393 the @code{__flash} or @code{__flash@var{N}} address spaces
1394 shows undefined behavior. The only address space that
1395 supports reading across the 64@tie{}KiB flash segment boundaries is
1399 If you use one of the @code{__flash@var{N}} address spaces
1400 you must arrange your linker script to locate the
1401 @code{.progmem@var{N}.data} sections according to your needs.
1404 Any data or pointers to the non-generic address spaces must
1405 be qualified as @code{const}, i.e.@: as read-only data.
1406 This still applies if the data in one of these address
1407 spaces like software version number or calibration lookup table are intended to
1408 be changed after load time by, say, a boot loader. In this case
1409 the right qualification is @code{const} @code{volatile} so that the compiler
1410 must not optimize away known values or insert them
1411 as immediates into operands of instructions.
1414 The following code initializes a variable @code{pfoo}
1415 located in static storage with a 24-bit address:
1417 extern const __memx char foo;
1418 const __memx void *pfoo = &foo;
1422 Such code requires at least binutils 2.23, see
1423 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1427 @subsection M32C Named Address Spaces
1428 @cindex @code{__far} M32C Named Address Spaces
1430 On the M32C target, with the R8C and M16C CPU variants, variables
1431 qualified with @code{__far} are accessed using 32-bit addresses in
1432 order to access memory beyond the first 64@tie{}Ki bytes. If
1433 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1436 @subsection RL78 Named Address Spaces
1437 @cindex @code{__far} RL78 Named Address Spaces
1439 On the RL78 target, variables qualified with @code{__far} are accessed
1440 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1441 addresses. Non-far variables are assumed to appear in the topmost
1442 64@tie{}KiB of the address space.
1444 @subsection SPU Named Address Spaces
1445 @cindex @code{__ea} SPU Named Address Spaces
1447 On the SPU target variables may be declared as
1448 belonging to another address space by qualifying the type with the
1449 @code{__ea} address space identifier:
1456 The compiler generates special code to access the variable @code{i}.
1457 It may use runtime library
1458 support, or generate special machine instructions to access that address
1461 @subsection x86 Named Address Spaces
1462 @cindex x86 named address spaces
1464 On the x86 target, variables may be declared as being relative
1465 to the @code{%fs} or @code{%gs} segments.
1470 @cindex @code{__seg_fs} x86 named address space
1471 @cindex @code{__seg_gs} x86 named address space
1472 The object is accessed with the respective segment override prefix.
1474 The respective segment base must be set via some method specific to
1475 the operating system. Rather than require an expensive system call
1476 to retrieve the segment base, these address spaces are not considered
1477 to be subspaces of the generic (flat) address space. This means that
1478 explicit casts are required to convert pointers between these address
1479 spaces and the generic address space. In practice the application
1480 should cast to @code{uintptr_t} and apply the segment base offset
1481 that it installed previously.
1483 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1484 defined when these address spaces are supported.
1488 @section Arrays of Length Zero
1489 @cindex arrays of length zero
1490 @cindex zero-length arrays
1491 @cindex length-zero arrays
1492 @cindex flexible array members
1494 Zero-length arrays are allowed in GNU C@. They are very useful as the
1495 last element of a structure that is really a header for a variable-length
1504 struct line *thisline = (struct line *)
1505 malloc (sizeof (struct line) + this_length);
1506 thisline->length = this_length;
1509 In ISO C90, you would have to give @code{contents} a length of 1, which
1510 means either you waste space or complicate the argument to @code{malloc}.
1512 In ISO C99, you would use a @dfn{flexible array member}, which is
1513 slightly different in syntax and semantics:
1517 Flexible array members are written as @code{contents[]} without
1521 Flexible array members have incomplete type, and so the @code{sizeof}
1522 operator may not be applied. As a quirk of the original implementation
1523 of zero-length arrays, @code{sizeof} evaluates to zero.
1526 Flexible array members may only appear as the last member of a
1527 @code{struct} that is otherwise non-empty.
1530 A structure containing a flexible array member, or a union containing
1531 such a structure (possibly recursively), may not be a member of a
1532 structure or an element of an array. (However, these uses are
1533 permitted by GCC as extensions.)
1536 Non-empty initialization of zero-length
1537 arrays is treated like any case where there are more initializer
1538 elements than the array holds, in that a suitable warning about ``excess
1539 elements in array'' is given, and the excess elements (all of them, in
1540 this case) are ignored.
1542 GCC allows static initialization of flexible array members.
1543 This is equivalent to defining a new structure containing the original
1544 structure followed by an array of sufficient size to contain the data.
1545 E.g.@: in the following, @code{f1} is constructed as if it were declared
1551 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1554 struct f1 f1; int data[3];
1555 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1559 The convenience of this extension is that @code{f1} has the desired
1560 type, eliminating the need to consistently refer to @code{f2.f1}.
1562 This has symmetry with normal static arrays, in that an array of
1563 unknown size is also written with @code{[]}.
1565 Of course, this extension only makes sense if the extra data comes at
1566 the end of a top-level object, as otherwise we would be overwriting
1567 data at subsequent offsets. To avoid undue complication and confusion
1568 with initialization of deeply nested arrays, we simply disallow any
1569 non-empty initialization except when the structure is the top-level
1570 object. For example:
1573 struct foo @{ int x; int y[]; @};
1574 struct bar @{ struct foo z; @};
1576 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1577 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1578 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1579 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1582 @node Empty Structures
1583 @section Structures with No Members
1584 @cindex empty structures
1585 @cindex zero-size structures
1587 GCC permits a C structure to have no members:
1594 The structure has size zero. In C++, empty structures are part
1595 of the language. G++ treats empty structures as if they had a single
1596 member of type @code{char}.
1598 @node Variable Length
1599 @section Arrays of Variable Length
1600 @cindex variable-length arrays
1601 @cindex arrays of variable length
1604 Variable-length automatic arrays are allowed in ISO C99, and as an
1605 extension GCC accepts them in C90 mode and in C++. These arrays are
1606 declared like any other automatic arrays, but with a length that is not
1607 a constant expression. The storage is allocated at the point of
1608 declaration and deallocated when the block scope containing the declaration
1614 concat_fopen (char *s1, char *s2, char *mode)
1616 char str[strlen (s1) + strlen (s2) + 1];
1619 return fopen (str, mode);
1623 @cindex scope of a variable length array
1624 @cindex variable-length array scope
1625 @cindex deallocating variable length arrays
1626 Jumping or breaking out of the scope of the array name deallocates the
1627 storage. Jumping into the scope is not allowed; you get an error
1630 @cindex variable-length array in a structure
1631 As an extension, GCC accepts variable-length arrays as a member of
1632 a structure or a union. For example:
1638 struct S @{ int x[n]; @};
1642 @cindex @code{alloca} vs variable-length arrays
1643 You can use the function @code{alloca} to get an effect much like
1644 variable-length arrays. The function @code{alloca} is available in
1645 many other C implementations (but not in all). On the other hand,
1646 variable-length arrays are more elegant.
1648 There are other differences between these two methods. Space allocated
1649 with @code{alloca} exists until the containing @emph{function} returns.
1650 The space for a variable-length array is deallocated as soon as the array
1651 name's scope ends, unless you also use @code{alloca} in this scope.
1653 You can also use variable-length arrays as arguments to functions:
1657 tester (int len, char data[len][len])
1663 The length of an array is computed once when the storage is allocated
1664 and is remembered for the scope of the array in case you access it with
1667 If you want to pass the array first and the length afterward, you can
1668 use a forward declaration in the parameter list---another GNU extension.
1672 tester (int len; char data[len][len], int len)
1678 @cindex parameter forward declaration
1679 The @samp{int len} before the semicolon is a @dfn{parameter forward
1680 declaration}, and it serves the purpose of making the name @code{len}
1681 known when the declaration of @code{data} is parsed.
1683 You can write any number of such parameter forward declarations in the
1684 parameter list. They can be separated by commas or semicolons, but the
1685 last one must end with a semicolon, which is followed by the ``real''
1686 parameter declarations. Each forward declaration must match a ``real''
1687 declaration in parameter name and data type. ISO C99 does not support
1688 parameter forward declarations.
1690 @node Variadic Macros
1691 @section Macros with a Variable Number of Arguments.
1692 @cindex variable number of arguments
1693 @cindex macro with variable arguments
1694 @cindex rest argument (in macro)
1695 @cindex variadic macros
1697 In the ISO C standard of 1999, a macro can be declared to accept a
1698 variable number of arguments much as a function can. The syntax for
1699 defining the macro is similar to that of a function. Here is an
1703 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1707 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1708 such a macro, it represents the zero or more tokens until the closing
1709 parenthesis that ends the invocation, including any commas. This set of
1710 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1711 wherever it appears. See the CPP manual for more information.
1713 GCC has long supported variadic macros, and used a different syntax that
1714 allowed you to give a name to the variable arguments just like any other
1715 argument. Here is an example:
1718 #define debug(format, args...) fprintf (stderr, format, args)
1722 This is in all ways equivalent to the ISO C example above, but arguably
1723 more readable and descriptive.
1725 GNU CPP has two further variadic macro extensions, and permits them to
1726 be used with either of the above forms of macro definition.
1728 In standard C, you are not allowed to leave the variable argument out
1729 entirely; but you are allowed to pass an empty argument. For example,
1730 this invocation is invalid in ISO C, because there is no comma after
1737 GNU CPP permits you to completely omit the variable arguments in this
1738 way. In the above examples, the compiler would complain, though since
1739 the expansion of the macro still has the extra comma after the format
1742 To help solve this problem, CPP behaves specially for variable arguments
1743 used with the token paste operator, @samp{##}. If instead you write
1746 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1750 and if the variable arguments are omitted or empty, the @samp{##}
1751 operator causes the preprocessor to remove the comma before it. If you
1752 do provide some variable arguments in your macro invocation, GNU CPP
1753 does not complain about the paste operation and instead places the
1754 variable arguments after the comma. Just like any other pasted macro
1755 argument, these arguments are not macro expanded.
1757 @node Escaped Newlines
1758 @section Slightly Looser Rules for Escaped Newlines
1759 @cindex escaped newlines
1760 @cindex newlines (escaped)
1762 The preprocessor treatment of escaped newlines is more relaxed
1763 than that specified by the C90 standard, which requires the newline
1764 to immediately follow a backslash.
1765 GCC's implementation allows whitespace in the form
1766 of spaces, horizontal and vertical tabs, and form feeds between the
1767 backslash and the subsequent newline. The preprocessor issues a
1768 warning, but treats it as a valid escaped newline and combines the two
1769 lines to form a single logical line. This works within comments and
1770 tokens, as well as between tokens. Comments are @emph{not} treated as
1771 whitespace for the purposes of this relaxation, since they have not
1772 yet been replaced with spaces.
1775 @section Non-Lvalue Arrays May Have Subscripts
1776 @cindex subscripting
1777 @cindex arrays, non-lvalue
1779 @cindex subscripting and function values
1780 In ISO C99, arrays that are not lvalues still decay to pointers, and
1781 may be subscripted, although they may not be modified or used after
1782 the next sequence point and the unary @samp{&} operator may not be
1783 applied to them. As an extension, GNU C allows such arrays to be
1784 subscripted in C90 mode, though otherwise they do not decay to
1785 pointers outside C99 mode. For example,
1786 this is valid in GNU C though not valid in C90:
1790 struct foo @{int a[4];@};
1796 return f().a[index];
1802 @section Arithmetic on @code{void}- and Function-Pointers
1803 @cindex void pointers, arithmetic
1804 @cindex void, size of pointer to
1805 @cindex function pointers, arithmetic
1806 @cindex function, size of pointer to
1808 In GNU C, addition and subtraction operations are supported on pointers to
1809 @code{void} and on pointers to functions. This is done by treating the
1810 size of a @code{void} or of a function as 1.
1812 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1813 and on function types, and returns 1.
1815 @opindex Wpointer-arith
1816 The option @option{-Wpointer-arith} requests a warning if these extensions
1819 @node Pointers to Arrays
1820 @section Pointers to Arrays with Qualifiers Work as Expected
1821 @cindex pointers to arrays
1822 @cindex const qualifier
1824 In GNU C, pointers to arrays with qualifiers work similar to pointers
1825 to other qualified types. For example, a value of type @code{int (*)[5]}
1826 can be used to initialize a variable of type @code{const int (*)[5]}.
1827 These types are incompatible in ISO C because the @code{const} qualifier
1828 is formally attached to the element type of the array and not the
1833 transpose (int N, int M, double out[M][N], const double in[N][M]);
1837 transpose(3, 2, y, x);
1841 @section Non-Constant Initializers
1842 @cindex initializers, non-constant
1843 @cindex non-constant initializers
1845 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1846 automatic variable are not required to be constant expressions in GNU C@.
1847 Here is an example of an initializer with run-time varying elements:
1850 foo (float f, float g)
1852 float beat_freqs[2] = @{ f-g, f+g @};
1857 @node Compound Literals
1858 @section Compound Literals
1859 @cindex constructor expressions
1860 @cindex initializations in expressions
1861 @cindex structures, constructor expression
1862 @cindex expressions, constructor
1863 @cindex compound literals
1864 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1866 ISO C99 supports compound literals. A compound literal looks like
1867 a cast containing an initializer. Its value is an object of the
1868 type specified in the cast, containing the elements specified in
1869 the initializer; it is an lvalue. As an extension, GCC supports
1870 compound literals in C90 mode and in C++, though the semantics are
1871 somewhat different in C++.
1873 Usually, the specified type is a structure. Assume that
1874 @code{struct foo} and @code{structure} are declared as shown:
1877 struct foo @{int a; char b[2];@} structure;
1881 Here is an example of constructing a @code{struct foo} with a compound literal:
1884 structure = ((struct foo) @{x + y, 'a', 0@});
1888 This is equivalent to writing the following:
1892 struct foo temp = @{x + y, 'a', 0@};
1897 You can also construct an array, though this is dangerous in C++, as
1898 explained below. If all the elements of the compound literal are
1899 (made up of) simple constant expressions, suitable for use in
1900 initializers of objects of static storage duration, then the compound
1901 literal can be coerced to a pointer to its first element and used in
1902 such an initializer, as shown here:
1905 char **foo = (char *[]) @{ "x", "y", "z" @};
1908 Compound literals for scalar types and union types are
1909 also allowed, but then the compound literal is equivalent
1912 As a GNU extension, GCC allows initialization of objects with static storage
1913 duration by compound literals (which is not possible in ISO C99, because
1914 the initializer is not a constant).
1915 It is handled as if the object is initialized only with the bracket
1916 enclosed list if the types of the compound literal and the object match.
1917 The initializer list of the compound literal must be constant.
1918 If the object being initialized has array type of unknown size, the size is
1919 determined by compound literal size.
1922 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1923 static int y[] = (int []) @{1, 2, 3@};
1924 static int z[] = (int [3]) @{1@};
1928 The above lines are equivalent to the following:
1930 static struct foo x = @{1, 'a', 'b'@};
1931 static int y[] = @{1, 2, 3@};
1932 static int z[] = @{1, 0, 0@};
1935 In C, a compound literal designates an unnamed object with static or
1936 automatic storage duration. In C++, a compound literal designates a
1937 temporary object, which only lives until the end of its
1938 full-expression. As a result, well-defined C code that takes the
1939 address of a subobject of a compound literal can be undefined in C++,
1940 so the C++ compiler rejects the conversion of a temporary array to a pointer.
1941 For instance, if the array compound literal example above appeared
1942 inside a function, any subsequent use of @samp{foo} in C++ has
1943 undefined behavior because the lifetime of the array ends after the
1944 declaration of @samp{foo}.
1946 As an optimization, the C++ compiler sometimes gives array compound
1947 literals longer lifetimes: when the array either appears outside a
1948 function or has const-qualified type. If @samp{foo} and its
1949 initializer had elements of @samp{char *const} type rather than
1950 @samp{char *}, or if @samp{foo} were a global variable, the array
1951 would have static storage duration. But it is probably safest just to
1952 avoid the use of array compound literals in code compiled as C++.
1954 @node Designated Inits
1955 @section Designated Initializers
1956 @cindex initializers with labeled elements
1957 @cindex labeled elements in initializers
1958 @cindex case labels in initializers
1959 @cindex designated initializers
1961 Standard C90 requires the elements of an initializer to appear in a fixed
1962 order, the same as the order of the elements in the array or structure
1965 In ISO C99 you can give the elements in any order, specifying the array
1966 indices or structure field names they apply to, and GNU C allows this as
1967 an extension in C90 mode as well. This extension is not
1968 implemented in GNU C++.
1970 To specify an array index, write
1971 @samp{[@var{index}] =} before the element value. For example,
1974 int a[6] = @{ [4] = 29, [2] = 15 @};
1981 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1985 The index values must be constant expressions, even if the array being
1986 initialized is automatic.
1988 An alternative syntax for this that has been obsolete since GCC 2.5 but
1989 GCC still accepts is to write @samp{[@var{index}]} before the element
1990 value, with no @samp{=}.
1992 To initialize a range of elements to the same value, write
1993 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
1994 extension. For example,
1997 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2001 If the value in it has side-effects, the side-effects happen only once,
2002 not for each initialized field by the range initializer.
2005 Note that the length of the array is the highest value specified
2008 In a structure initializer, specify the name of a field to initialize
2009 with @samp{.@var{fieldname} =} before the element value. For example,
2010 given the following structure,
2013 struct point @{ int x, y; @};
2017 the following initialization
2020 struct point p = @{ .y = yvalue, .x = xvalue @};
2027 struct point p = @{ xvalue, yvalue @};
2030 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2031 @samp{@var{fieldname}:}, as shown here:
2034 struct point p = @{ y: yvalue, x: xvalue @};
2037 Omitted field members are implicitly initialized the same as objects
2038 that have static storage duration.
2041 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2042 @dfn{designator}. You can also use a designator (or the obsolete colon
2043 syntax) when initializing a union, to specify which element of the union
2044 should be used. For example,
2047 union foo @{ int i; double d; @};
2049 union foo f = @{ .d = 4 @};
2053 converts 4 to a @code{double} to store it in the union using
2054 the second element. By contrast, casting 4 to type @code{union foo}
2055 stores it into the union as the integer @code{i}, since it is
2056 an integer. (@xref{Cast to Union}.)
2058 You can combine this technique of naming elements with ordinary C
2059 initialization of successive elements. Each initializer element that
2060 does not have a designator applies to the next consecutive element of the
2061 array or structure. For example,
2064 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2071 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2074 Labeling the elements of an array initializer is especially useful
2075 when the indices are characters or belong to an @code{enum} type.
2080 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2081 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2084 @cindex designator lists
2085 You can also write a series of @samp{.@var{fieldname}} and
2086 @samp{[@var{index}]} designators before an @samp{=} to specify a
2087 nested subobject to initialize; the list is taken relative to the
2088 subobject corresponding to the closest surrounding brace pair. For
2089 example, with the @samp{struct point} declaration above:
2092 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2096 If the same field is initialized multiple times, it has the value from
2097 the last initialization. If any such overridden initialization has
2098 side-effect, it is unspecified whether the side-effect happens or not.
2099 Currently, GCC discards them and issues a warning.
2102 @section Case Ranges
2104 @cindex ranges in case statements
2106 You can specify a range of consecutive values in a single @code{case} label,
2110 case @var{low} ... @var{high}:
2114 This has the same effect as the proper number of individual @code{case}
2115 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2117 This feature is especially useful for ranges of ASCII character codes:
2123 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2124 it may be parsed wrong when you use it with integer values. For example,
2139 @section Cast to a Union Type
2140 @cindex cast to a union
2141 @cindex union, casting to a
2143 A cast to union type is similar to other casts, except that the type
2144 specified is a union type. You can specify the type either with
2145 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2146 a constructor, not a cast, and hence does not yield an lvalue like
2147 normal casts. (@xref{Compound Literals}.)
2149 The types that may be cast to the union type are those of the members
2150 of the union. Thus, given the following union and variables:
2153 union foo @{ int i; double d; @};
2159 both @code{x} and @code{y} can be cast to type @code{union foo}.
2161 Using the cast as the right-hand side of an assignment to a variable of
2162 union type is equivalent to storing in a member of the union:
2167 u = (union foo) x @equiv{} u.i = x
2168 u = (union foo) y @equiv{} u.d = y
2171 You can also use the union cast as a function argument:
2174 void hack (union foo);
2176 hack ((union foo) x);
2179 @node Mixed Declarations
2180 @section Mixed Declarations and Code
2181 @cindex mixed declarations and code
2182 @cindex declarations, mixed with code
2183 @cindex code, mixed with declarations
2185 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2186 within compound statements. As an extension, GNU C also allows this in
2187 C90 mode. For example, you could do:
2196 Each identifier is visible from where it is declared until the end of
2197 the enclosing block.
2199 @node Function Attributes
2200 @section Declaring Attributes of Functions
2201 @cindex function attributes
2202 @cindex declaring attributes of functions
2203 @cindex @code{volatile} applied to function
2204 @cindex @code{const} applied to function
2206 In GNU C, you can use function attributes to declare certain things
2207 about functions called in your program which help the compiler
2208 optimize calls and check your code more carefully. For example, you
2209 can use attributes to declare that a function never returns
2210 (@code{noreturn}), returns a value depending only on its arguments
2211 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2213 You can also use attributes to control memory placement, code
2214 generation options or call/return conventions within the function
2215 being annotated. Many of these attributes are target-specific. For
2216 example, many targets support attributes for defining interrupt
2217 handler functions, which typically must follow special register usage
2218 and return conventions.
2220 Function attributes are introduced by the @code{__attribute__} keyword
2221 on a declaration, followed by an attribute specification inside double
2222 parentheses. You can specify multiple attributes in a declaration by
2223 separating them by commas within the double parentheses or by
2224 immediately following an attribute declaration with another attribute
2225 declaration. @xref{Attribute Syntax}, for the exact rules on
2226 attribute syntax and placement.
2228 GCC also supports attributes on
2229 variable declarations (@pxref{Variable Attributes}),
2230 labels (@pxref{Label Attributes}),
2231 enumerators (@pxref{Enumerator Attributes}),
2232 and types (@pxref{Type Attributes}).
2234 There is some overlap between the purposes of attributes and pragmas
2235 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2236 found convenient to use @code{__attribute__} to achieve a natural
2237 attachment of attributes to their corresponding declarations, whereas
2238 @code{#pragma} is of use for compatibility with other compilers
2239 or constructs that do not naturally form part of the grammar.
2241 In addition to the attributes documented here,
2242 GCC plugins may provide their own attributes.
2245 * Common Function Attributes::
2246 * AArch64 Function Attributes::
2247 * ARC Function Attributes::
2248 * ARM Function Attributes::
2249 * AVR Function Attributes::
2250 * Blackfin Function Attributes::
2251 * CR16 Function Attributes::
2252 * Epiphany Function Attributes::
2253 * H8/300 Function Attributes::
2254 * IA-64 Function Attributes::
2255 * M32C Function Attributes::
2256 * M32R/D Function Attributes::
2257 * m68k Function Attributes::
2258 * MCORE Function Attributes::
2259 * MeP Function Attributes::
2260 * MicroBlaze Function Attributes::
2261 * Microsoft Windows Function Attributes::
2262 * MIPS Function Attributes::
2263 * MSP430 Function Attributes::
2264 * NDS32 Function Attributes::
2265 * Nios II Function Attributes::
2266 * Nvidia PTX Function Attributes::
2267 * PowerPC Function Attributes::
2268 * RL78 Function Attributes::
2269 * RX Function Attributes::
2270 * S/390 Function Attributes::
2271 * SH Function Attributes::
2272 * SPU Function Attributes::
2273 * Symbian OS Function Attributes::
2274 * V850 Function Attributes::
2275 * Visium Function Attributes::
2276 * x86 Function Attributes::
2277 * Xstormy16 Function Attributes::
2280 @node Common Function Attributes
2281 @subsection Common Function Attributes
2283 The following attributes are supported on most targets.
2286 @c Keep this table alphabetized by attribute name. Treat _ as space.
2288 @item alias ("@var{target}")
2289 @cindex @code{alias} function attribute
2290 The @code{alias} attribute causes the declaration to be emitted as an
2291 alias for another symbol, which must be specified. For instance,
2294 void __f () @{ /* @r{Do something.} */; @}
2295 void f () __attribute__ ((weak, alias ("__f")));
2299 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2300 mangled name for the target must be used. It is an error if @samp{__f}
2301 is not defined in the same translation unit.
2303 This attribute requires assembler and object file support,
2304 and may not be available on all targets.
2306 @item aligned (@var{alignment})
2307 @cindex @code{aligned} function attribute
2308 This attribute specifies a minimum alignment for the function,
2311 You cannot use this attribute to decrease the alignment of a function,
2312 only to increase it. However, when you explicitly specify a function
2313 alignment this overrides the effect of the
2314 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2317 Note that the effectiveness of @code{aligned} attributes may be
2318 limited by inherent limitations in your linker. On many systems, the
2319 linker is only able to arrange for functions to be aligned up to a
2320 certain maximum alignment. (For some linkers, the maximum supported
2321 alignment may be very very small.) See your linker documentation for
2322 further information.
2324 The @code{aligned} attribute can also be used for variables and fields
2325 (@pxref{Variable Attributes}.)
2328 @cindex @code{alloc_align} function attribute
2329 The @code{alloc_align} attribute is used to tell the compiler that the
2330 function return value points to memory, where the returned pointer minimum
2331 alignment is given by one of the functions parameters. GCC uses this
2332 information to improve pointer alignment analysis.
2334 The function parameter denoting the allocated alignment is specified by
2335 one integer argument, whose number is the argument of the attribute.
2336 Argument numbering starts at one.
2341 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2345 declares that @code{my_memalign} returns memory with minimum alignment
2346 given by parameter 1.
2349 @cindex @code{alloc_size} function attribute
2350 The @code{alloc_size} attribute is used to tell the compiler that the
2351 function return value points to memory, where the size is given by
2352 one or two of the functions parameters. GCC uses this
2353 information to improve the correctness of @code{__builtin_object_size}.
2355 The function parameter(s) denoting the allocated size are specified by
2356 one or two integer arguments supplied to the attribute. The allocated size
2357 is either the value of the single function argument specified or the product
2358 of the two function arguments specified. Argument numbering starts at
2364 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2365 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2369 declares that @code{my_calloc} returns memory of the size given by
2370 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2371 of the size given by parameter 2.
2374 @cindex @code{always_inline} function attribute
2375 Generally, functions are not inlined unless optimization is specified.
2376 For functions declared inline, this attribute inlines the function
2377 independent of any restrictions that otherwise apply to inlining.
2378 Failure to inline such a function is diagnosed as an error.
2379 Note that if such a function is called indirectly the compiler may
2380 or may not inline it depending on optimization level and a failure
2381 to inline an indirect call may or may not be diagnosed.
2384 @cindex @code{artificial} function attribute
2385 This attribute is useful for small inline wrappers that if possible
2386 should appear during debugging as a unit. Depending on the debug
2387 info format it either means marking the function as artificial
2388 or using the caller location for all instructions within the inlined
2391 @item assume_aligned
2392 @cindex @code{assume_aligned} function attribute
2393 The @code{assume_aligned} attribute is used to tell the compiler that the
2394 function return value points to memory, where the returned pointer minimum
2395 alignment is given by the first argument.
2396 If the attribute has two arguments, the second argument is misalignment offset.
2401 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2402 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2406 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2407 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2410 @item bnd_instrument
2411 @cindex @code{bnd_instrument} function attribute
2412 The @code{bnd_instrument} attribute on functions is used to inform the
2413 compiler that the function should be instrumented when compiled
2414 with the @option{-fchkp-instrument-marked-only} option.
2417 @cindex @code{bnd_legacy} function attribute
2418 @cindex Pointer Bounds Checker attributes
2419 The @code{bnd_legacy} attribute on functions is used to inform the
2420 compiler that the function should not be instrumented when compiled
2421 with the @option{-fcheck-pointer-bounds} option.
2424 @cindex @code{cold} function attribute
2425 The @code{cold} attribute on functions is used to inform the compiler that
2426 the function is unlikely to be executed. The function is optimized for
2427 size rather than speed and on many targets it is placed into a special
2428 subsection of the text section so all cold functions appear close together,
2429 improving code locality of non-cold parts of program. The paths leading
2430 to calls of cold functions within code are marked as unlikely by the branch
2431 prediction mechanism. It is thus useful to mark functions used to handle
2432 unlikely conditions, such as @code{perror}, as cold to improve optimization
2433 of hot functions that do call marked functions in rare occasions.
2435 When profile feedback is available, via @option{-fprofile-use}, cold functions
2436 are automatically detected and this attribute is ignored.
2439 @cindex @code{const} function attribute
2440 @cindex functions that have no side effects
2441 Many functions do not examine any values except their arguments, and
2442 have no effects except the return value. Basically this is just slightly
2443 more strict class than the @code{pure} attribute below, since function is not
2444 allowed to read global memory.
2446 @cindex pointer arguments
2447 Note that a function that has pointer arguments and examines the data
2448 pointed to must @emph{not} be declared @code{const}. Likewise, a
2449 function that calls a non-@code{const} function usually must not be
2450 @code{const}. It does not make sense for a @code{const} function to
2455 @itemx constructor (@var{priority})
2456 @itemx destructor (@var{priority})
2457 @cindex @code{constructor} function attribute
2458 @cindex @code{destructor} function attribute
2459 The @code{constructor} attribute causes the function to be called
2460 automatically before execution enters @code{main ()}. Similarly, the
2461 @code{destructor} attribute causes the function to be called
2462 automatically after @code{main ()} completes or @code{exit ()} is
2463 called. Functions with these attributes are useful for
2464 initializing data that is used implicitly during the execution of
2467 You may provide an optional integer priority to control the order in
2468 which constructor and destructor functions are run. A constructor
2469 with a smaller priority number runs before a constructor with a larger
2470 priority number; the opposite relationship holds for destructors. So,
2471 if you have a constructor that allocates a resource and a destructor
2472 that deallocates the same resource, both functions typically have the
2473 same priority. The priorities for constructor and destructor
2474 functions are the same as those specified for namespace-scope C++
2475 objects (@pxref{C++ Attributes}).
2477 These attributes are not currently implemented for Objective-C@.
2480 @itemx deprecated (@var{msg})
2481 @cindex @code{deprecated} function attribute
2482 The @code{deprecated} attribute results in a warning if the function
2483 is used anywhere in the source file. This is useful when identifying
2484 functions that are expected to be removed in a future version of a
2485 program. The warning also includes the location of the declaration
2486 of the deprecated function, to enable users to easily find further
2487 information about why the function is deprecated, or what they should
2488 do instead. Note that the warnings only occurs for uses:
2491 int old_fn () __attribute__ ((deprecated));
2493 int (*fn_ptr)() = old_fn;
2497 results in a warning on line 3 but not line 2. The optional @var{msg}
2498 argument, which must be a string, is printed in the warning if
2501 The @code{deprecated} attribute can also be used for variables and
2502 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2504 @item error ("@var{message}")
2505 @itemx warning ("@var{message}")
2506 @cindex @code{error} function attribute
2507 @cindex @code{warning} function attribute
2508 If the @code{error} or @code{warning} attribute
2509 is used on a function declaration and a call to such a function
2510 is not eliminated through dead code elimination or other optimizations,
2511 an error or warning (respectively) that includes @var{message} is diagnosed.
2513 for compile-time checking, especially together with @code{__builtin_constant_p}
2514 and inline functions where checking the inline function arguments is not
2515 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2517 While it is possible to leave the function undefined and thus invoke
2518 a link failure (to define the function with
2519 a message in @code{.gnu.warning*} section),
2520 when using these attributes the problem is diagnosed
2521 earlier and with exact location of the call even in presence of inline
2522 functions or when not emitting debugging information.
2524 @item externally_visible
2525 @cindex @code{externally_visible} function attribute
2526 This attribute, attached to a global variable or function, nullifies
2527 the effect of the @option{-fwhole-program} command-line option, so the
2528 object remains visible outside the current compilation unit.
2530 If @option{-fwhole-program} is used together with @option{-flto} and
2531 @command{gold} is used as the linker plugin,
2532 @code{externally_visible} attributes are automatically added to functions
2533 (not variable yet due to a current @command{gold} issue)
2534 that are accessed outside of LTO objects according to resolution file
2535 produced by @command{gold}.
2536 For other linkers that cannot generate resolution file,
2537 explicit @code{externally_visible} attributes are still necessary.
2540 @cindex @code{flatten} function attribute
2541 Generally, inlining into a function is limited. For a function marked with
2542 this attribute, every call inside this function is inlined, if possible.
2543 Whether the function itself is considered for inlining depends on its size and
2544 the current inlining parameters.
2546 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2547 @cindex @code{format} function attribute
2548 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2550 The @code{format} attribute specifies that a function takes @code{printf},
2551 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2552 should be type-checked against a format string. For example, the
2557 my_printf (void *my_object, const char *my_format, ...)
2558 __attribute__ ((format (printf, 2, 3)));
2562 causes the compiler to check the arguments in calls to @code{my_printf}
2563 for consistency with the @code{printf} style format string argument
2566 The parameter @var{archetype} determines how the format string is
2567 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2568 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2569 @code{strfmon}. (You can also use @code{__printf__},
2570 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2571 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2572 @code{ms_strftime} are also present.
2573 @var{archetype} values such as @code{printf} refer to the formats accepted
2574 by the system's C runtime library,
2575 while values prefixed with @samp{gnu_} always refer
2576 to the formats accepted by the GNU C Library. On Microsoft Windows
2577 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2578 @file{msvcrt.dll} library.
2579 The parameter @var{string-index}
2580 specifies which argument is the format string argument (starting
2581 from 1), while @var{first-to-check} is the number of the first
2582 argument to check against the format string. For functions
2583 where the arguments are not available to be checked (such as
2584 @code{vprintf}), specify the third parameter as zero. In this case the
2585 compiler only checks the format string for consistency. For
2586 @code{strftime} formats, the third parameter is required to be zero.
2587 Since non-static C++ methods have an implicit @code{this} argument, the
2588 arguments of such methods should be counted from two, not one, when
2589 giving values for @var{string-index} and @var{first-to-check}.
2591 In the example above, the format string (@code{my_format}) is the second
2592 argument of the function @code{my_print}, and the arguments to check
2593 start with the third argument, so the correct parameters for the format
2594 attribute are 2 and 3.
2596 @opindex ffreestanding
2597 @opindex fno-builtin
2598 The @code{format} attribute allows you to identify your own functions
2599 that take format strings as arguments, so that GCC can check the
2600 calls to these functions for errors. The compiler always (unless
2601 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2602 for the standard library functions @code{printf}, @code{fprintf},
2603 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2604 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2605 warnings are requested (using @option{-Wformat}), so there is no need to
2606 modify the header file @file{stdio.h}. In C99 mode, the functions
2607 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2608 @code{vsscanf} are also checked. Except in strictly conforming C
2609 standard modes, the X/Open function @code{strfmon} is also checked as
2610 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2611 @xref{C Dialect Options,,Options Controlling C Dialect}.
2613 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2614 recognized in the same context. Declarations including these format attributes
2615 are parsed for correct syntax, however the result of checking of such format
2616 strings is not yet defined, and is not carried out by this version of the
2619 The target may also provide additional types of format checks.
2620 @xref{Target Format Checks,,Format Checks Specific to Particular
2623 @item format_arg (@var{string-index})
2624 @cindex @code{format_arg} function attribute
2625 @opindex Wformat-nonliteral
2626 The @code{format_arg} attribute specifies that a function takes a format
2627 string for a @code{printf}, @code{scanf}, @code{strftime} or
2628 @code{strfmon} style function and modifies it (for example, to translate
2629 it into another language), so the result can be passed to a
2630 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2631 function (with the remaining arguments to the format function the same
2632 as they would have been for the unmodified string). For example, the
2637 my_dgettext (char *my_domain, const char *my_format)
2638 __attribute__ ((format_arg (2)));
2642 causes the compiler to check the arguments in calls to a @code{printf},
2643 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2644 format string argument is a call to the @code{my_dgettext} function, for
2645 consistency with the format string argument @code{my_format}. If the
2646 @code{format_arg} attribute had not been specified, all the compiler
2647 could tell in such calls to format functions would be that the format
2648 string argument is not constant; this would generate a warning when
2649 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2650 without the attribute.
2652 The parameter @var{string-index} specifies which argument is the format
2653 string argument (starting from one). Since non-static C++ methods have
2654 an implicit @code{this} argument, the arguments of such methods should
2655 be counted from two.
2657 The @code{format_arg} attribute allows you to identify your own
2658 functions that modify format strings, so that GCC can check the
2659 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2660 type function whose operands are a call to one of your own function.
2661 The compiler always treats @code{gettext}, @code{dgettext}, and
2662 @code{dcgettext} in this manner except when strict ISO C support is
2663 requested by @option{-ansi} or an appropriate @option{-std} option, or
2664 @option{-ffreestanding} or @option{-fno-builtin}
2665 is used. @xref{C Dialect Options,,Options
2666 Controlling C Dialect}.
2668 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2669 @code{NSString} reference for compatibility with the @code{format} attribute
2672 The target may also allow additional types in @code{format-arg} attributes.
2673 @xref{Target Format Checks,,Format Checks Specific to Particular
2677 @cindex @code{gnu_inline} function attribute
2678 This attribute should be used with a function that is also declared
2679 with the @code{inline} keyword. It directs GCC to treat the function
2680 as if it were defined in gnu90 mode even when compiling in C99 or
2683 If the function is declared @code{extern}, then this definition of the
2684 function is used only for inlining. In no case is the function
2685 compiled as a standalone function, not even if you take its address
2686 explicitly. Such an address becomes an external reference, as if you
2687 had only declared the function, and had not defined it. This has
2688 almost the effect of a macro. The way to use this is to put a
2689 function definition in a header file with this attribute, and put
2690 another copy of the function, without @code{extern}, in a library
2691 file. The definition in the header file causes most calls to the
2692 function to be inlined. If any uses of the function remain, they
2693 refer to the single copy in the library. Note that the two
2694 definitions of the functions need not be precisely the same, although
2695 if they do not have the same effect your program may behave oddly.
2697 In C, if the function is neither @code{extern} nor @code{static}, then
2698 the function is compiled as a standalone function, as well as being
2699 inlined where possible.
2701 This is how GCC traditionally handled functions declared
2702 @code{inline}. Since ISO C99 specifies a different semantics for
2703 @code{inline}, this function attribute is provided as a transition
2704 measure and as a useful feature in its own right. This attribute is
2705 available in GCC 4.1.3 and later. It is available if either of the
2706 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2707 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2708 Function is As Fast As a Macro}.
2710 In C++, this attribute does not depend on @code{extern} in any way,
2711 but it still requires the @code{inline} keyword to enable its special
2715 @cindex @code{hot} function attribute
2716 The @code{hot} attribute on a function is used to inform the compiler that
2717 the function is a hot spot of the compiled program. The function is
2718 optimized more aggressively and on many targets it is placed into a special
2719 subsection of the text section so all hot functions appear close together,
2722 When profile feedback is available, via @option{-fprofile-use}, hot functions
2723 are automatically detected and this attribute is ignored.
2725 @item ifunc ("@var{resolver}")
2726 @cindex @code{ifunc} function attribute
2727 @cindex indirect functions
2728 @cindex functions that are dynamically resolved
2729 The @code{ifunc} attribute is used to mark a function as an indirect
2730 function using the STT_GNU_IFUNC symbol type extension to the ELF
2731 standard. This allows the resolution of the symbol value to be
2732 determined dynamically at load time, and an optimized version of the
2733 routine can be selected for the particular processor or other system
2734 characteristics determined then. To use this attribute, first define
2735 the implementation functions available, and a resolver function that
2736 returns a pointer to the selected implementation function. The
2737 implementation functions' declarations must match the API of the
2738 function being implemented, the resolver's declaration is be a
2739 function returning pointer to void function returning void:
2742 void *my_memcpy (void *dst, const void *src, size_t len)
2747 static void (*resolve_memcpy (void)) (void)
2749 return my_memcpy; // we'll just always select this routine
2754 The exported header file declaring the function the user calls would
2758 extern void *memcpy (void *, const void *, size_t);
2762 allowing the user to call this as a regular function, unaware of the
2763 implementation. Finally, the indirect function needs to be defined in
2764 the same translation unit as the resolver function:
2767 void *memcpy (void *, const void *, size_t)
2768 __attribute__ ((ifunc ("resolve_memcpy")));
2771 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
2772 and GNU C Library version 2.11.1 are required to use this feature.
2775 @itemx interrupt_handler
2776 Many GCC back ends support attributes to indicate that a function is
2777 an interrupt handler, which tells the compiler to generate function
2778 entry and exit sequences that differ from those from regular
2779 functions. The exact syntax and behavior are target-specific;
2780 refer to the following subsections for details.
2783 @cindex @code{leaf} function attribute
2784 Calls to external functions with this attribute must return to the
2785 current compilation unit only by return or by exception handling. In
2786 particular, a leaf function is not allowed to invoke callback functions
2787 passed to it from the current compilation unit, directly call functions
2788 exported by the unit, or @code{longjmp} into the unit. Leaf functions
2789 might still call functions from other compilation units and thus they
2790 are not necessarily leaf in the sense that they contain no function
2793 The attribute is intended for library functions to improve dataflow
2794 analysis. The compiler takes the hint that any data not escaping the
2795 current compilation unit cannot be used or modified by the leaf
2796 function. For example, the @code{sin} function is a leaf function, but
2797 @code{qsort} is not.
2799 Note that leaf functions might indirectly run a signal handler defined
2800 in the current compilation unit that uses static variables. Similarly,
2801 when lazy symbol resolution is in effect, leaf functions might invoke
2802 indirect functions whose resolver function or implementation function is
2803 defined in the current compilation unit and uses static variables. There
2804 is no standard-compliant way to write such a signal handler, resolver
2805 function, or implementation function, and the best that you can do is to
2806 remove the @code{leaf} attribute or mark all such static variables
2807 @code{volatile}. Lastly, for ELF-based systems that support symbol
2808 interposition, care should be taken that functions defined in the
2809 current compilation unit do not unexpectedly interpose other symbols
2810 based on the defined standards mode and defined feature test macros;
2811 otherwise an inadvertent callback would be added.
2813 The attribute has no effect on functions defined within the current
2814 compilation unit. This is to allow easy merging of multiple compilation
2815 units into one, for example, by using the link-time optimization. For
2816 this reason the attribute is not allowed on types to annotate indirect
2820 @cindex @code{malloc} function attribute
2821 @cindex functions that behave like malloc
2822 This tells the compiler that a function is @code{malloc}-like, i.e.,
2823 that the pointer @var{P} returned by the function cannot alias any
2824 other pointer valid when the function returns, and moreover no
2825 pointers to valid objects occur in any storage addressed by @var{P}.
2827 Using this attribute can improve optimization. Functions like
2828 @code{malloc} and @code{calloc} have this property because they return
2829 a pointer to uninitialized or zeroed-out storage. However, functions
2830 like @code{realloc} do not have this property, as they can return a
2831 pointer to storage containing pointers.
2834 @cindex @code{no_icf} function attribute
2835 This function attribute prevents a functions from being merged with another
2836 semantically equivalent function.
2838 @item no_instrument_function
2839 @cindex @code{no_instrument_function} function attribute
2840 @opindex finstrument-functions
2841 If @option{-finstrument-functions} is given, profiling function calls are
2842 generated at entry and exit of most user-compiled functions.
2843 Functions with this attribute are not so instrumented.
2846 @cindex @code{no_reorder} function attribute
2847 Do not reorder functions or variables marked @code{no_reorder}
2848 against each other or top level assembler statements the executable.
2849 The actual order in the program will depend on the linker command
2850 line. Static variables marked like this are also not removed.
2851 This has a similar effect
2852 as the @option{-fno-toplevel-reorder} option, but only applies to the
2855 @item no_sanitize_address
2856 @itemx no_address_safety_analysis
2857 @cindex @code{no_sanitize_address} function attribute
2858 The @code{no_sanitize_address} attribute on functions is used
2859 to inform the compiler that it should not instrument memory accesses
2860 in the function when compiling with the @option{-fsanitize=address} option.
2861 The @code{no_address_safety_analysis} is a deprecated alias of the
2862 @code{no_sanitize_address} attribute, new code should use
2863 @code{no_sanitize_address}.
2865 @item no_sanitize_thread
2866 @cindex @code{no_sanitize_thread} function attribute
2867 The @code{no_sanitize_thread} attribute on functions is used
2868 to inform the compiler that it should not instrument memory accesses
2869 in the function when compiling with the @option{-fsanitize=thread} option.
2871 @item no_sanitize_undefined
2872 @cindex @code{no_sanitize_undefined} function attribute
2873 The @code{no_sanitize_undefined} attribute on functions is used
2874 to inform the compiler that it should not check for undefined behavior
2875 in the function when compiling with the @option{-fsanitize=undefined} option.
2877 @item no_split_stack
2878 @cindex @code{no_split_stack} function attribute
2879 @opindex fsplit-stack
2880 If @option{-fsplit-stack} is given, functions have a small
2881 prologue which decides whether to split the stack. Functions with the
2882 @code{no_split_stack} attribute do not have that prologue, and thus
2883 may run with only a small amount of stack space available.
2885 @item no_stack_limit
2886 @cindex @code{no_stack_limit} function attribute
2887 This attribute locally overrides the @option{-fstack-limit-register}
2888 and @option{-fstack-limit-symbol} command-line options; it has the effect
2889 of disabling stack limit checking in the function it applies to.
2892 @cindex @code{noclone} function attribute
2893 This function attribute prevents a function from being considered for
2894 cloning---a mechanism that produces specialized copies of functions
2895 and which is (currently) performed by interprocedural constant
2899 @cindex @code{noinline} function attribute
2900 This function attribute prevents a function from being considered for
2902 @c Don't enumerate the optimizations by name here; we try to be
2903 @c future-compatible with this mechanism.
2904 If the function does not have side-effects, there are optimizations
2905 other than inlining that cause function calls to be optimized away,
2906 although the function call is live. To keep such calls from being
2913 (@pxref{Extended Asm}) in the called function, to serve as a special
2916 @item nonnull (@var{arg-index}, @dots{})
2917 @cindex @code{nonnull} function attribute
2918 @cindex functions with non-null pointer arguments
2919 The @code{nonnull} attribute specifies that some function parameters should
2920 be non-null pointers. For instance, the declaration:
2924 my_memcpy (void *dest, const void *src, size_t len)
2925 __attribute__((nonnull (1, 2)));
2929 causes the compiler to check that, in calls to @code{my_memcpy},
2930 arguments @var{dest} and @var{src} are non-null. If the compiler
2931 determines that a null pointer is passed in an argument slot marked
2932 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2933 is issued. The compiler may also choose to make optimizations based
2934 on the knowledge that certain function arguments will never be null.
2936 If no argument index list is given to the @code{nonnull} attribute,
2937 all pointer arguments are marked as non-null. To illustrate, the
2938 following declaration is equivalent to the previous example:
2942 my_memcpy (void *dest, const void *src, size_t len)
2943 __attribute__((nonnull));
2947 @cindex @code{noplt} function attribute
2948 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
2949 Calls to functions marked with this attribute in position-independent code
2954 /* Externally defined function foo. */
2955 int foo () __attribute__ ((noplt));
2958 main (/* @r{@dots{}} */)
2967 The @code{noplt} attribute on function @code{foo}
2968 tells the compiler to assume that
2969 the function @code{foo} is externally defined and that the call to
2970 @code{foo} must avoid the PLT
2971 in position-independent code.
2973 In position-dependent code, a few targets also convert calls to
2974 functions that are marked to not use the PLT to use the GOT instead.
2977 @cindex @code{noreturn} function attribute
2978 @cindex functions that never return
2979 A few standard library functions, such as @code{abort} and @code{exit},
2980 cannot return. GCC knows this automatically. Some programs define
2981 their own functions that never return. You can declare them
2982 @code{noreturn} to tell the compiler this fact. For example,
2986 void fatal () __attribute__ ((noreturn));
2989 fatal (/* @r{@dots{}} */)
2991 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
2997 The @code{noreturn} keyword tells the compiler to assume that
2998 @code{fatal} cannot return. It can then optimize without regard to what
2999 would happen if @code{fatal} ever did return. This makes slightly
3000 better code. More importantly, it helps avoid spurious warnings of
3001 uninitialized variables.
3003 The @code{noreturn} keyword does not affect the exceptional path when that
3004 applies: a @code{noreturn}-marked function may still return to the caller
3005 by throwing an exception or calling @code{longjmp}.
3007 Do not assume that registers saved by the calling function are
3008 restored before calling the @code{noreturn} function.
3010 It does not make sense for a @code{noreturn} function to have a return
3011 type other than @code{void}.
3014 @cindex @code{nothrow} function attribute
3015 The @code{nothrow} attribute is used to inform the compiler that a
3016 function cannot throw an exception. For example, most functions in
3017 the standard C library can be guaranteed not to throw an exception
3018 with the notable exceptions of @code{qsort} and @code{bsearch} that
3019 take function pointer arguments.
3022 @cindex @code{optimize} function attribute
3023 The @code{optimize} attribute is used to specify that a function is to
3024 be compiled with different optimization options than specified on the
3025 command line. Arguments can either be numbers or strings. Numbers
3026 are assumed to be an optimization level. Strings that begin with
3027 @code{O} are assumed to be an optimization option, while other options
3028 are assumed to be used with a @code{-f} prefix. You can also use the
3029 @samp{#pragma GCC optimize} pragma to set the optimization options
3030 that affect more than one function.
3031 @xref{Function Specific Option Pragmas}, for details about the
3032 @samp{#pragma GCC optimize} pragma.
3034 This attribute should be used for debugging purposes only. It is not
3035 suitable in production code.
3038 @cindex @code{pure} function attribute
3039 @cindex functions that have no side effects
3040 Many functions have no effects except the return value and their
3041 return value depends only on the parameters and/or global variables.
3042 Such a function can be subject
3043 to common subexpression elimination and loop optimization just as an
3044 arithmetic operator would be. These functions should be declared
3045 with the attribute @code{pure}. For example,
3048 int square (int) __attribute__ ((pure));
3052 says that the hypothetical function @code{square} is safe to call
3053 fewer times than the program says.
3055 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3056 Interesting non-pure functions are functions with infinite loops or those
3057 depending on volatile memory or other system resource, that may change between
3058 two consecutive calls (such as @code{feof} in a multithreading environment).
3060 @item returns_nonnull
3061 @cindex @code{returns_nonnull} function attribute
3062 The @code{returns_nonnull} attribute specifies that the function
3063 return value should be a non-null pointer. For instance, the declaration:
3067 mymalloc (size_t len) __attribute__((returns_nonnull));
3071 lets the compiler optimize callers based on the knowledge
3072 that the return value will never be null.
3075 @cindex @code{returns_twice} function attribute
3076 @cindex functions that return more than once
3077 The @code{returns_twice} attribute tells the compiler that a function may
3078 return more than one time. The compiler ensures that all registers
3079 are dead before calling such a function and emits a warning about
3080 the variables that may be clobbered after the second return from the
3081 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3082 The @code{longjmp}-like counterpart of such function, if any, might need
3083 to be marked with the @code{noreturn} attribute.
3085 @item section ("@var{section-name}")
3086 @cindex @code{section} function attribute
3087 @cindex functions in arbitrary sections
3088 Normally, the compiler places the code it generates in the @code{text} section.
3089 Sometimes, however, you need additional sections, or you need certain
3090 particular functions to appear in special sections. The @code{section}
3091 attribute specifies that a function lives in a particular section.
3092 For example, the declaration:
3095 extern void foobar (void) __attribute__ ((section ("bar")));
3099 puts the function @code{foobar} in the @code{bar} section.
3101 Some file formats do not support arbitrary sections so the @code{section}
3102 attribute is not available on all platforms.
3103 If you need to map the entire contents of a module to a particular
3104 section, consider using the facilities of the linker instead.
3107 @cindex @code{sentinel} function attribute
3108 This function attribute ensures that a parameter in a function call is
3109 an explicit @code{NULL}. The attribute is only valid on variadic
3110 functions. By default, the sentinel is located at position zero, the
3111 last parameter of the function call. If an optional integer position
3112 argument P is supplied to the attribute, the sentinel must be located at
3113 position P counting backwards from the end of the argument list.
3116 __attribute__ ((sentinel))
3118 __attribute__ ((sentinel(0)))
3121 The attribute is automatically set with a position of 0 for the built-in
3122 functions @code{execl} and @code{execlp}. The built-in function
3123 @code{execle} has the attribute set with a position of 1.
3125 A valid @code{NULL} in this context is defined as zero with any pointer
3126 type. If your system defines the @code{NULL} macro with an integer type
3127 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3128 with a copy that redefines NULL appropriately.
3130 The warnings for missing or incorrect sentinels are enabled with
3134 @itemx simd("@var{mask}")
3135 @cindex @code{simd} function attribute
3136 This attribute enables creation of one or more function versions that
3137 can process multiple arguments using SIMD instructions from a
3138 single invocation. Specifying this attribute allows compiler to
3139 assume that such versions are available at link time (provided
3140 in the same or another translation unit). Generated versions are
3141 target-dependent and described in the corresponding Vector ABI document. For
3142 x86_64 target this document can be found
3143 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3145 The optional argument @var{mask} may have the value
3146 @code{notinbranch} or @code{inbranch},
3147 and instructs the compiler to generate non-masked or masked
3148 clones correspondingly. By default, all clones are generated.
3150 The attribute should not be used together with Cilk Plus @code{vector}
3151 attribute on the same function.
3153 If the attribute is specified and @code{#pragma omp declare simd} is
3154 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3155 switch is specified, then the attribute is ignored.
3158 @cindex @code{stack_protect} function attribute
3159 This attribute adds stack protection code to the function if
3160 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3161 or @option{-fstack-protector-explicit} are set.
3163 @item target (@var{options})
3164 @cindex @code{target} function attribute
3165 Multiple target back ends implement the @code{target} attribute
3166 to specify that a function is to
3167 be compiled with different target options than specified on the
3168 command line. This can be used for instance to have functions
3169 compiled with a different ISA (instruction set architecture) than the
3170 default. You can also use the @samp{#pragma GCC target} pragma to set
3171 more than one function to be compiled with specific target options.
3172 @xref{Function Specific Option Pragmas}, for details about the
3173 @samp{#pragma GCC target} pragma.
3175 For instance, on an x86, you could declare one function with the
3176 @code{target("sse4.1,arch=core2")} attribute and another with
3177 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3178 compiling the first function with @option{-msse4.1} and
3179 @option{-march=core2} options, and the second function with
3180 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3181 to make sure that a function is only invoked on a machine that
3182 supports the particular ISA it is compiled for (for example by using
3183 @code{cpuid} on x86 to determine what feature bits and architecture
3187 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3188 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3191 You can either use multiple
3192 strings separated by commas to specify multiple options,
3193 or separate the options with a comma (@samp{,}) within a single string.
3195 The options supported are specific to each target; refer to @ref{x86
3196 Function Attributes}, @ref{PowerPC Function Attributes},
3197 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3200 @item target_clones (@var{options})
3201 @cindex @code{target_clones} function attribute
3202 The @code{target_clones} attribute is used to specify that a function
3203 be cloned into multiple versions compiled with different target options
3204 than specified on the command line. The supported options and restrictions
3205 are the same as for @code{target} attribute.
3207 For instance, on an x86, you could compile a function with
3208 @code{target_clones("sse4.1,avx")}. GCC creates two function clones,
3209 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3210 It also creates a resolver function (see the @code{ifunc} attribute
3211 above) that dynamically selects a clone suitable for current architecture.
3214 @cindex @code{unused} function attribute
3215 This attribute, attached to a function, means that the function is meant
3216 to be possibly unused. GCC does not produce a warning for this
3220 @cindex @code{used} function attribute
3221 This attribute, attached to a function, means that code must be emitted
3222 for the function even if it appears that the function is not referenced.
3223 This is useful, for example, when the function is referenced only in
3226 When applied to a member function of a C++ class template, the
3227 attribute also means that the function is instantiated if the
3228 class itself is instantiated.
3230 @item visibility ("@var{visibility_type}")
3231 @cindex @code{visibility} function attribute
3232 This attribute affects the linkage of the declaration to which it is attached.
3233 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3234 (@pxref{Common Type Attributes}) as well as functions.
3236 There are four supported @var{visibility_type} values: default,
3237 hidden, protected or internal visibility.
3240 void __attribute__ ((visibility ("protected")))
3241 f () @{ /* @r{Do something.} */; @}
3242 int i __attribute__ ((visibility ("hidden")));
3245 The possible values of @var{visibility_type} correspond to the
3246 visibility settings in the ELF gABI.
3249 @c keep this list of visibilities in alphabetical order.
3252 Default visibility is the normal case for the object file format.
3253 This value is available for the visibility attribute to override other
3254 options that may change the assumed visibility of entities.
3256 On ELF, default visibility means that the declaration is visible to other
3257 modules and, in shared libraries, means that the declared entity may be
3260 On Darwin, default visibility means that the declaration is visible to
3263 Default visibility corresponds to ``external linkage'' in the language.
3266 Hidden visibility indicates that the entity declared has a new
3267 form of linkage, which we call ``hidden linkage''. Two
3268 declarations of an object with hidden linkage refer to the same object
3269 if they are in the same shared object.
3272 Internal visibility is like hidden visibility, but with additional
3273 processor specific semantics. Unless otherwise specified by the
3274 psABI, GCC defines internal visibility to mean that a function is
3275 @emph{never} called from another module. Compare this with hidden
3276 functions which, while they cannot be referenced directly by other
3277 modules, can be referenced indirectly via function pointers. By
3278 indicating that a function cannot be called from outside the module,
3279 GCC may for instance omit the load of a PIC register since it is known
3280 that the calling function loaded the correct value.
3283 Protected visibility is like default visibility except that it
3284 indicates that references within the defining module bind to the
3285 definition in that module. That is, the declared entity cannot be
3286 overridden by another module.
3290 All visibilities are supported on many, but not all, ELF targets
3291 (supported when the assembler supports the @samp{.visibility}
3292 pseudo-op). Default visibility is supported everywhere. Hidden
3293 visibility is supported on Darwin targets.
3295 The visibility attribute should be applied only to declarations that
3296 would otherwise have external linkage. The attribute should be applied
3297 consistently, so that the same entity should not be declared with
3298 different settings of the attribute.
3300 In C++, the visibility attribute applies to types as well as functions
3301 and objects, because in C++ types have linkage. A class must not have
3302 greater visibility than its non-static data member types and bases,
3303 and class members default to the visibility of their class. Also, a
3304 declaration without explicit visibility is limited to the visibility
3307 In C++, you can mark member functions and static member variables of a
3308 class with the visibility attribute. This is useful if you know a
3309 particular method or static member variable should only be used from
3310 one shared object; then you can mark it hidden while the rest of the
3311 class has default visibility. Care must be taken to avoid breaking
3312 the One Definition Rule; for example, it is usually not useful to mark
3313 an inline method as hidden without marking the whole class as hidden.
3315 A C++ namespace declaration can also have the visibility attribute.
3318 namespace nspace1 __attribute__ ((visibility ("protected")))
3319 @{ /* @r{Do something.} */; @}
3322 This attribute applies only to the particular namespace body, not to
3323 other definitions of the same namespace; it is equivalent to using
3324 @samp{#pragma GCC visibility} before and after the namespace
3325 definition (@pxref{Visibility Pragmas}).
3327 In C++, if a template argument has limited visibility, this
3328 restriction is implicitly propagated to the template instantiation.
3329 Otherwise, template instantiations and specializations default to the
3330 visibility of their template.
3332 If both the template and enclosing class have explicit visibility, the
3333 visibility from the template is used.
3335 @item warn_unused_result
3336 @cindex @code{warn_unused_result} function attribute
3337 The @code{warn_unused_result} attribute causes a warning to be emitted
3338 if a caller of the function with this attribute does not use its
3339 return value. This is useful for functions where not checking
3340 the result is either a security problem or always a bug, such as
3344 int fn () __attribute__ ((warn_unused_result));
3347 if (fn () < 0) return -1;
3354 results in warning on line 5.
3357 @cindex @code{weak} function attribute
3358 The @code{weak} attribute causes the declaration to be emitted as a weak
3359 symbol rather than a global. This is primarily useful in defining
3360 library functions that can be overridden in user code, though it can
3361 also be used with non-function declarations. Weak symbols are supported
3362 for ELF targets, and also for a.out targets when using the GNU assembler
3366 @itemx weakref ("@var{target}")
3367 @cindex @code{weakref} function attribute
3368 The @code{weakref} attribute marks a declaration as a weak reference.
3369 Without arguments, it should be accompanied by an @code{alias} attribute
3370 naming the target symbol. Optionally, the @var{target} may be given as
3371 an argument to @code{weakref} itself. In either case, @code{weakref}
3372 implicitly marks the declaration as @code{weak}. Without a
3373 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3374 @code{weakref} is equivalent to @code{weak}.
3377 static int x() __attribute__ ((weakref ("y")));
3378 /* is equivalent to... */
3379 static int x() __attribute__ ((weak, weakref, alias ("y")));
3381 static int x() __attribute__ ((weakref));
3382 static int x() __attribute__ ((alias ("y")));
3385 A weak reference is an alias that does not by itself require a
3386 definition to be given for the target symbol. If the target symbol is
3387 only referenced through weak references, then it becomes a @code{weak}
3388 undefined symbol. If it is directly referenced, however, then such
3389 strong references prevail, and a definition is required for the
3390 symbol, not necessarily in the same translation unit.
3392 The effect is equivalent to moving all references to the alias to a
3393 separate translation unit, renaming the alias to the aliased symbol,
3394 declaring it as weak, compiling the two separate translation units and
3395 performing a reloadable link on them.
3397 At present, a declaration to which @code{weakref} is attached can
3398 only be @code{static}.
3403 @c This is the end of the target-independent attribute table
3405 @node AArch64 Function Attributes
3406 @subsection AArch64 Function Attributes
3408 The following target-specific function attributes are available for the
3409 AArch64 target. For the most part, these options mirror the behavior of
3410 similar command-line options (@pxref{AArch64 Options}), but on a
3414 @item general-regs-only
3415 @cindex @code{general-regs-only} function attribute, AArch64
3416 Indicates that no floating-point or Advanced SIMD registers should be
3417 used when generating code for this function. If the function explicitly
3418 uses floating-point code, then the compiler gives an error. This is
3419 the same behavior as that of the command-line option
3420 @option{-mgeneral-regs-only}.
3422 @item fix-cortex-a53-835769
3423 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3424 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3425 applied to this function. To explicitly disable the workaround for this
3426 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3427 This corresponds to the behavior of the command line options
3428 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3431 @cindex @code{cmodel=} function attribute, AArch64
3432 Indicates that code should be generated for a particular code model for
3433 this function. The behavior and permissible arguments are the same as
3434 for the command line option @option{-mcmodel=}.
3437 @cindex @code{strict-align} function attribute, AArch64
3438 Indicates that the compiler should not assume that unaligned memory references
3439 are handled by the system. The behavior is the same as for the command-line
3440 option @option{-mstrict-align}.
3442 @item omit-leaf-frame-pointer
3443 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3444 Indicates that the frame pointer should be omitted for a leaf function call.
3445 To keep the frame pointer, the inverse attribute
3446 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3447 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3448 and @option{-mno-omit-leaf-frame-pointer}.
3451 @cindex @code{tls-dialect=} function attribute, AArch64
3452 Specifies the TLS dialect to use for this function. The behavior and
3453 permissible arguments are the same as for the command-line option
3454 @option{-mtls-dialect=}.
3457 @cindex @code{arch=} function attribute, AArch64
3458 Specifies the architecture version and architectural extensions to use
3459 for this function. The behavior and permissible arguments are the same as
3460 for the @option{-march=} command-line option.
3463 @cindex @code{tune=} function attribute, AArch64
3464 Specifies the core for which to tune the performance of this function.
3465 The behavior and permissible arguments are the same as for the @option{-mtune=}
3466 command-line option.
3469 @cindex @code{cpu=} function attribute, AArch64
3470 Specifies the core for which to tune the performance of this function and also
3471 whose architectural features to use. The behavior and valid arguments are the
3472 same as for the @option{-mcpu=} command-line option.
3476 The above target attributes can be specified as follows:
3479 __attribute__((target("@var{attr-string}")))
3487 where @code{@var{attr-string}} is one of the attribute strings specified above.
3489 Additionally, the architectural extension string may be specified on its
3490 own. This can be used to turn on and off particular architectural extensions
3491 without having to specify a particular architecture version or core. Example:
3494 __attribute__((target("+crc+nocrypto")))
3502 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3503 extension and disables the @code{crypto} extension for the function @code{foo}
3504 without modifying an existing @option{-march=} or @option{-mcpu} option.
3506 Multiple target function attributes can be specified by separating them with
3507 a comma. For example:
3509 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3517 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3518 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3520 @subsubsection Inlining rules
3521 Specifying target attributes on individual functions or performing link-time
3522 optimization across translation units compiled with different target options
3523 can affect function inlining rules:
3525 In particular, a caller function can inline a callee function only if the
3526 architectural features available to the callee are a subset of the features
3527 available to the caller.
3528 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3529 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3530 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3531 because the all the architectural features that function @code{bar} requires
3532 are available to function @code{foo}. Conversely, function @code{bar} cannot
3533 inline function @code{foo}.
3535 Additionally inlining a function compiled with @option{-mstrict-align} into a
3536 function compiled without @code{-mstrict-align} is not allowed.
3537 However, inlining a function compiled without @option{-mstrict-align} into a
3538 function compiled with @option{-mstrict-align} is allowed.
3540 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3541 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3542 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3543 architectural feature rules specified above.
3545 @node ARC Function Attributes
3546 @subsection ARC Function Attributes
3548 These function attributes are supported by the ARC back end:
3552 @cindex @code{interrupt} function attribute, ARC
3553 Use this attribute to indicate
3554 that the specified function is an interrupt handler. The compiler generates
3555 function entry and exit sequences suitable for use in an interrupt handler
3556 when this attribute is present.
3558 On the ARC, you must specify the kind of interrupt to be handled
3559 in a parameter to the interrupt attribute like this:
3562 void f () __attribute__ ((interrupt ("ilink1")));
3565 Permissible values for this parameter are: @w{@code{ilink1}} and
3571 @cindex @code{long_call} function attribute, ARC
3572 @cindex @code{medium_call} function attribute, ARC
3573 @cindex @code{short_call} function attribute, ARC
3574 @cindex indirect calls, ARC
3575 These attributes specify how a particular function is called.
3576 These attributes override the
3577 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3578 command-line switches and @code{#pragma long_calls} settings.
3580 For ARC, a function marked with the @code{long_call} attribute is
3581 always called using register-indirect jump-and-link instructions,
3582 thereby enabling the called function to be placed anywhere within the
3583 32-bit address space. A function marked with the @code{medium_call}
3584 attribute will always be close enough to be called with an unconditional
3585 branch-and-link instruction, which has a 25-bit offset from
3586 the call site. A function marked with the @code{short_call}
3587 attribute will always be close enough to be called with a conditional
3588 branch-and-link instruction, which has a 21-bit offset from
3592 @node ARM Function Attributes
3593 @subsection ARM Function Attributes
3595 These function attributes are supported for ARM targets:
3599 @cindex @code{interrupt} function attribute, ARM
3600 Use this attribute to indicate
3601 that the specified function is an interrupt handler. The compiler generates
3602 function entry and exit sequences suitable for use in an interrupt handler
3603 when this attribute is present.
3605 You can specify the kind of interrupt to be handled by
3606 adding an optional parameter to the interrupt attribute like this:
3609 void f () __attribute__ ((interrupt ("IRQ")));
3613 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3614 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3616 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3617 may be called with a word-aligned stack pointer.
3620 @cindex @code{isr} function attribute, ARM
3621 Use this attribute on ARM to write Interrupt Service Routines. This is an
3622 alias to the @code{interrupt} attribute above.
3626 @cindex @code{long_call} function attribute, ARM
3627 @cindex @code{short_call} function attribute, ARM
3628 @cindex indirect calls, ARM
3629 These attributes specify how a particular function is called.
3630 These attributes override the
3631 @option{-mlong-calls} (@pxref{ARM Options})
3632 command-line switch and @code{#pragma long_calls} settings. For ARM, the
3633 @code{long_call} attribute indicates that the function might be far
3634 away from the call site and require a different (more expensive)
3635 calling sequence. The @code{short_call} attribute always places
3636 the offset to the function from the call site into the @samp{BL}
3637 instruction directly.
3640 @cindex @code{naked} function attribute, ARM
3641 This attribute allows the compiler to construct the
3642 requisite function declaration, while allowing the body of the
3643 function to be assembly code. The specified function will not have
3644 prologue/epilogue sequences generated by the compiler. Only basic
3645 @code{asm} statements can safely be included in naked functions
3646 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3647 basic @code{asm} and C code may appear to work, they cannot be
3648 depended upon to work reliably and are not supported.
3651 @cindex @code{pcs} function attribute, ARM
3653 The @code{pcs} attribute can be used to control the calling convention
3654 used for a function on ARM. The attribute takes an argument that specifies
3655 the calling convention to use.
3657 When compiling using the AAPCS ABI (or a variant of it) then valid
3658 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3659 order to use a variant other than @code{"aapcs"} then the compiler must
3660 be permitted to use the appropriate co-processor registers (i.e., the
3661 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3665 /* Argument passed in r0, and result returned in r0+r1. */
3666 double f2d (float) __attribute__((pcs("aapcs")));
3669 Variadic functions always use the @code{"aapcs"} calling convention and
3670 the compiler rejects attempts to specify an alternative.
3672 @item target (@var{options})
3673 @cindex @code{target} function attribute
3674 As discussed in @ref{Common Function Attributes}, this attribute
3675 allows specification of target-specific compilation options.
3677 On ARM, the following options are allowed:
3681 @cindex @code{target("thumb")} function attribute, ARM
3682 Force code generation in the Thumb (T16/T32) ISA, depending on the
3686 @cindex @code{target("arm")} function attribute, ARM
3687 Force code generation in the ARM (A32) ISA.
3689 Functions from different modes can be inlined in the caller's mode.
3692 @cindex @code{target("fpu=")} function attribute, ARM
3693 Specifies the fpu for which to tune the performance of this function.
3694 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3695 command-line option.
3701 @node AVR Function Attributes
3702 @subsection AVR Function Attributes
3704 These function attributes are supported by the AVR back end:
3708 @cindex @code{interrupt} function attribute, AVR
3709 Use this attribute to indicate
3710 that the specified function is an interrupt handler. The compiler generates
3711 function entry and exit sequences suitable for use in an interrupt handler
3712 when this attribute is present.
3714 On the AVR, the hardware globally disables interrupts when an
3715 interrupt is executed. The first instruction of an interrupt handler
3716 declared with this attribute is a @code{SEI} instruction to
3717 re-enable interrupts. See also the @code{signal} function attribute
3718 that does not insert a @code{SEI} instruction. If both @code{signal} and
3719 @code{interrupt} are specified for the same function, @code{signal}
3720 is silently ignored.
3723 @cindex @code{naked} function attribute, AVR
3724 This attribute allows the compiler to construct the
3725 requisite function declaration, while allowing the body of the
3726 function to be assembly code. The specified function will not have
3727 prologue/epilogue sequences generated by the compiler. Only basic
3728 @code{asm} statements can safely be included in naked functions
3729 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3730 basic @code{asm} and C code may appear to work, they cannot be
3731 depended upon to work reliably and are not supported.
3735 @cindex @code{OS_main} function attribute, AVR
3736 @cindex @code{OS_task} function attribute, AVR
3737 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3738 do not save/restore any call-saved register in their prologue/epilogue.
3740 The @code{OS_main} attribute can be used when there @emph{is
3741 guarantee} that interrupts are disabled at the time when the function
3742 is entered. This saves resources when the stack pointer has to be
3743 changed to set up a frame for local variables.
3745 The @code{OS_task} attribute can be used when there is @emph{no
3746 guarantee} that interrupts are disabled at that time when the function
3747 is entered like for, e@.g@. task functions in a multi-threading operating
3748 system. In that case, changing the stack pointer register is
3749 guarded by save/clear/restore of the global interrupt enable flag.
3751 The differences to the @code{naked} function attribute are:
3753 @item @code{naked} functions do not have a return instruction whereas
3754 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3755 @code{RETI} return instruction.
3756 @item @code{naked} functions do not set up a frame for local variables
3757 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3762 @cindex @code{signal} function attribute, AVR
3763 Use this attribute on the AVR to indicate that the specified
3764 function is an interrupt handler. The compiler generates function
3765 entry and exit sequences suitable for use in an interrupt handler when this
3766 attribute is present.
3768 See also the @code{interrupt} function attribute.
3770 The AVR hardware globally disables interrupts when an interrupt is executed.
3771 Interrupt handler functions defined with the @code{signal} attribute
3772 do not re-enable interrupts. It is save to enable interrupts in a
3773 @code{signal} handler. This ``save'' only applies to the code
3774 generated by the compiler and not to the IRQ layout of the
3775 application which is responsibility of the application.
3777 If both @code{signal} and @code{interrupt} are specified for the same
3778 function, @code{signal} is silently ignored.
3781 @node Blackfin Function Attributes
3782 @subsection Blackfin Function Attributes
3784 These function attributes are supported by the Blackfin back end:
3788 @item exception_handler
3789 @cindex @code{exception_handler} function attribute
3790 @cindex exception handler functions, Blackfin
3791 Use this attribute on the Blackfin to indicate that the specified function
3792 is an exception handler. The compiler generates function entry and
3793 exit sequences suitable for use in an exception handler when this
3794 attribute is present.
3796 @item interrupt_handler
3797 @cindex @code{interrupt_handler} function attribute, Blackfin
3798 Use this attribute to
3799 indicate that the specified function is an interrupt handler. The compiler
3800 generates function entry and exit sequences suitable for use in an
3801 interrupt handler when this attribute is present.
3804 @cindex @code{kspisusp} function attribute, Blackfin
3805 @cindex User stack pointer in interrupts on the Blackfin
3806 When used together with @code{interrupt_handler}, @code{exception_handler}
3807 or @code{nmi_handler}, code is generated to load the stack pointer
3808 from the USP register in the function prologue.
3811 @cindex @code{l1_text} function attribute, Blackfin
3812 This attribute specifies a function to be placed into L1 Instruction
3813 SRAM@. The function is put into a specific section named @code{.l1.text}.
3814 With @option{-mfdpic}, function calls with a such function as the callee
3815 or caller uses inlined PLT.
3818 @cindex @code{l2} function attribute, Blackfin
3819 This attribute specifies a function to be placed into L2
3820 SRAM. The function is put into a specific section named
3821 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3826 @cindex indirect calls, Blackfin
3827 @cindex @code{longcall} function attribute, Blackfin
3828 @cindex @code{shortcall} function attribute, Blackfin
3829 The @code{longcall} attribute
3830 indicates that the function might be far away from the call site and
3831 require a different (more expensive) calling sequence. The
3832 @code{shortcall} attribute indicates that the function is always close
3833 enough for the shorter calling sequence to be used. These attributes
3834 override the @option{-mlongcall} switch.
3837 @cindex @code{nesting} function attribute, Blackfin
3838 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3839 Use this attribute together with @code{interrupt_handler},
3840 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3841 entry code should enable nested interrupts or exceptions.
3844 @cindex @code{nmi_handler} function attribute, Blackfin
3845 @cindex NMI handler functions on the Blackfin processor
3846 Use this attribute on the Blackfin to indicate that the specified function
3847 is an NMI handler. The compiler generates function entry and
3848 exit sequences suitable for use in an NMI handler when this
3849 attribute is present.
3852 @cindex @code{saveall} function attribute, Blackfin
3853 @cindex save all registers on the Blackfin
3854 Use this attribute to indicate that
3855 all registers except the stack pointer should be saved in the prologue
3856 regardless of whether they are used or not.
3859 @node CR16 Function Attributes
3860 @subsection CR16 Function Attributes
3862 These function attributes are supported by the CR16 back end:
3866 @cindex @code{interrupt} function attribute, CR16
3867 Use this attribute to indicate
3868 that the specified function is an interrupt handler. The compiler generates
3869 function entry and exit sequences suitable for use in an interrupt handler
3870 when this attribute is present.
3873 @node Epiphany Function Attributes
3874 @subsection Epiphany Function Attributes
3876 These function attributes are supported by the Epiphany back end:
3880 @cindex @code{disinterrupt} function attribute, Epiphany
3881 This attribute causes the compiler to emit
3882 instructions to disable interrupts for the duration of the given
3885 @item forwarder_section
3886 @cindex @code{forwarder_section} function attribute, Epiphany
3887 This attribute modifies the behavior of an interrupt handler.
3888 The interrupt handler may be in external memory which cannot be
3889 reached by a branch instruction, so generate a local memory trampoline
3890 to transfer control. The single parameter identifies the section where
3891 the trampoline is placed.
3894 @cindex @code{interrupt} function attribute, Epiphany
3895 Use this attribute to indicate
3896 that the specified function is an interrupt handler. The compiler generates
3897 function entry and exit sequences suitable for use in an interrupt handler
3898 when this attribute is present. It may also generate
3899 a special section with code to initialize the interrupt vector table.
3901 On Epiphany targets one or more optional parameters can be added like this:
3904 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3907 Permissible values for these parameters are: @w{@code{reset}},
3908 @w{@code{software_exception}}, @w{@code{page_miss}},
3909 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3910 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3911 Multiple parameters indicate that multiple entries in the interrupt
3912 vector table should be initialized for this function, i.e.@: for each
3913 parameter @w{@var{name}}, a jump to the function is emitted in
3914 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
3915 entirely, in which case no interrupt vector table entry is provided.
3917 Note that interrupts are enabled inside the function
3918 unless the @code{disinterrupt} attribute is also specified.
3920 The following examples are all valid uses of these attributes on
3923 void __attribute__ ((interrupt)) universal_handler ();
3924 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3925 void __attribute__ ((interrupt ("dma0, dma1")))
3926 universal_dma_handler ();
3927 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3928 fast_timer_handler ();
3929 void __attribute__ ((interrupt ("dma0, dma1"),
3930 forwarder_section ("tramp")))
3931 external_dma_handler ();
3936 @cindex @code{long_call} function attribute, Epiphany
3937 @cindex @code{short_call} function attribute, Epiphany
3938 @cindex indirect calls, Epiphany
3939 These attributes specify how a particular function is called.
3940 These attributes override the
3941 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3942 command-line switch and @code{#pragma long_calls} settings.
3946 @node H8/300 Function Attributes
3947 @subsection H8/300 Function Attributes
3949 These function attributes are available for H8/300 targets:
3952 @item function_vector
3953 @cindex @code{function_vector} function attribute, H8/300
3954 Use this attribute on the H8/300, H8/300H, and H8S to indicate
3955 that the specified function should be called through the function vector.
3956 Calling a function through the function vector reduces code size; however,
3957 the function vector has a limited size (maximum 128 entries on the H8/300
3958 and 64 entries on the H8/300H and H8S)
3959 and shares space with the interrupt vector.
3961 @item interrupt_handler
3962 @cindex @code{interrupt_handler} function attribute, H8/300
3963 Use this attribute on the H8/300, H8/300H, and H8S to
3964 indicate that the specified function is an interrupt handler. The compiler
3965 generates function entry and exit sequences suitable for use in an
3966 interrupt handler when this attribute is present.
3969 @cindex @code{saveall} function attribute, H8/300
3970 @cindex save all registers on the H8/300, H8/300H, and H8S
3971 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
3972 all registers except the stack pointer should be saved in the prologue
3973 regardless of whether they are used or not.
3976 @node IA-64 Function Attributes
3977 @subsection IA-64 Function Attributes
3979 These function attributes are supported on IA-64 targets:
3982 @item syscall_linkage
3983 @cindex @code{syscall_linkage} function attribute, IA-64
3984 This attribute is used to modify the IA-64 calling convention by marking
3985 all input registers as live at all function exits. This makes it possible
3986 to restart a system call after an interrupt without having to save/restore
3987 the input registers. This also prevents kernel data from leaking into
3991 @cindex @code{version_id} function attribute, IA-64
3992 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
3993 symbol to contain a version string, thus allowing for function level
3994 versioning. HP-UX system header files may use function level versioning
3995 for some system calls.
3998 extern int foo () __attribute__((version_id ("20040821")));
4002 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4005 @node M32C Function Attributes
4006 @subsection M32C Function Attributes
4008 These function attributes are supported by the M32C back end:
4012 @cindex @code{bank_switch} function attribute, M32C
4013 When added to an interrupt handler with the M32C port, causes the
4014 prologue and epilogue to use bank switching to preserve the registers
4015 rather than saving them on the stack.
4017 @item fast_interrupt
4018 @cindex @code{fast_interrupt} function attribute, M32C
4019 Use this attribute on the M32C port to indicate that the specified
4020 function is a fast interrupt handler. This is just like the
4021 @code{interrupt} attribute, except that @code{freit} is used to return
4022 instead of @code{reit}.
4024 @item function_vector
4025 @cindex @code{function_vector} function attribute, M16C/M32C
4026 On M16C/M32C targets, the @code{function_vector} attribute declares a
4027 special page subroutine call function. Use of this attribute reduces
4028 the code size by 2 bytes for each call generated to the
4029 subroutine. The argument to the attribute is the vector number entry
4030 from the special page vector table which contains the 16 low-order
4031 bits of the subroutine's entry address. Each vector table has special
4032 page number (18 to 255) that is used in @code{jsrs} instructions.
4033 Jump addresses of the routines are generated by adding 0x0F0000 (in
4034 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4035 2-byte addresses set in the vector table. Therefore you need to ensure
4036 that all the special page vector routines should get mapped within the
4037 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4040 In the following example 2 bytes are saved for each call to
4041 function @code{foo}.
4044 void foo (void) __attribute__((function_vector(0x18)));
4055 If functions are defined in one file and are called in another file,
4056 then be sure to write this declaration in both files.
4058 This attribute is ignored for R8C target.
4061 @cindex @code{interrupt} function attribute, M32C
4062 Use this attribute to indicate
4063 that the specified function is an interrupt handler. The compiler generates
4064 function entry and exit sequences suitable for use in an interrupt handler
4065 when this attribute is present.
4068 @node M32R/D Function Attributes
4069 @subsection M32R/D Function Attributes
4071 These function attributes are supported by the M32R/D back end:
4075 @cindex @code{interrupt} function attribute, M32R/D
4076 Use this attribute to indicate
4077 that the specified function is an interrupt handler. The compiler generates
4078 function entry and exit sequences suitable for use in an interrupt handler
4079 when this attribute is present.
4081 @item model (@var{model-name})
4082 @cindex @code{model} function attribute, M32R/D
4083 @cindex function addressability on the M32R/D
4085 On the M32R/D, use this attribute to set the addressability of an
4086 object, and of the code generated for a function. The identifier
4087 @var{model-name} is one of @code{small}, @code{medium}, or
4088 @code{large}, representing each of the code models.
4090 Small model objects live in the lower 16MB of memory (so that their
4091 addresses can be loaded with the @code{ld24} instruction), and are
4092 callable with the @code{bl} instruction.
4094 Medium model objects may live anywhere in the 32-bit address space (the
4095 compiler generates @code{seth/add3} instructions to load their addresses),
4096 and are callable with the @code{bl} instruction.
4098 Large model objects may live anywhere in the 32-bit address space (the
4099 compiler generates @code{seth/add3} instructions to load their addresses),
4100 and may not be reachable with the @code{bl} instruction (the compiler
4101 generates the much slower @code{seth/add3/jl} instruction sequence).
4104 @node m68k Function Attributes
4105 @subsection m68k Function Attributes
4107 These function attributes are supported by the m68k back end:
4111 @itemx interrupt_handler
4112 @cindex @code{interrupt} function attribute, m68k
4113 @cindex @code{interrupt_handler} function attribute, m68k
4114 Use this attribute to
4115 indicate that the specified function is an interrupt handler. The compiler
4116 generates function entry and exit sequences suitable for use in an
4117 interrupt handler when this attribute is present. Either name may be used.
4119 @item interrupt_thread
4120 @cindex @code{interrupt_thread} function attribute, fido
4121 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4122 that the specified function is an interrupt handler that is designed
4123 to run as a thread. The compiler omits generate prologue/epilogue
4124 sequences and replaces the return instruction with a @code{sleep}
4125 instruction. This attribute is available only on fido.
4128 @node MCORE Function Attributes
4129 @subsection MCORE Function Attributes
4131 These function attributes are supported by the MCORE back end:
4135 @cindex @code{naked} function attribute, MCORE
4136 This attribute allows the compiler to construct the
4137 requisite function declaration, while allowing the body of the
4138 function to be assembly code. The specified function will not have
4139 prologue/epilogue sequences generated by the compiler. Only basic
4140 @code{asm} statements can safely be included in naked functions
4141 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4142 basic @code{asm} and C code may appear to work, they cannot be
4143 depended upon to work reliably and are not supported.
4146 @node MeP Function Attributes
4147 @subsection MeP Function Attributes
4149 These function attributes are supported by the MeP back end:
4153 @cindex @code{disinterrupt} function attribute, MeP
4154 On MeP targets, this attribute causes the compiler to emit
4155 instructions to disable interrupts for the duration of the given
4159 @cindex @code{interrupt} function attribute, MeP
4160 Use this attribute to indicate
4161 that the specified function is an interrupt handler. The compiler generates
4162 function entry and exit sequences suitable for use in an interrupt handler
4163 when this attribute is present.
4166 @cindex @code{near} function attribute, MeP
4167 This attribute causes the compiler to assume the called
4168 function is close enough to use the normal calling convention,
4169 overriding the @option{-mtf} command-line option.
4172 @cindex @code{far} function attribute, MeP
4173 On MeP targets this causes the compiler to use a calling convention
4174 that assumes the called function is too far away for the built-in
4178 @cindex @code{vliw} function attribute, MeP
4179 The @code{vliw} attribute tells the compiler to emit
4180 instructions in VLIW mode instead of core mode. Note that this
4181 attribute is not allowed unless a VLIW coprocessor has been configured
4182 and enabled through command-line options.
4185 @node MicroBlaze Function Attributes
4186 @subsection MicroBlaze Function Attributes
4188 These function attributes are supported on MicroBlaze targets:
4191 @item save_volatiles
4192 @cindex @code{save_volatiles} function attribute, MicroBlaze
4193 Use this attribute to indicate that the function is
4194 an interrupt handler. All volatile registers (in addition to non-volatile
4195 registers) are saved in the function prologue. If the function is a leaf
4196 function, only volatiles used by the function are saved. A normal function
4197 return is generated instead of a return from interrupt.
4200 @cindex @code{break_handler} function attribute, MicroBlaze
4201 @cindex break handler functions
4202 Use this attribute to indicate that
4203 the specified function is a break handler. The compiler generates function
4204 entry and exit sequences suitable for use in an break handler when this
4205 attribute is present. The return from @code{break_handler} is done through
4206 the @code{rtbd} instead of @code{rtsd}.
4209 void f () __attribute__ ((break_handler));
4212 @item interrupt_handler
4213 @itemx fast_interrupt
4214 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4215 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4216 These attributes indicate that the specified function is an interrupt
4217 handler. Use the @code{fast_interrupt} attribute to indicate handlers
4218 used in low-latency interrupt mode, and @code{interrupt_handler} for
4219 interrupts that do not use low-latency handlers. In both cases, GCC
4220 emits appropriate prologue code and generates a return from the handler
4221 using @code{rtid} instead of @code{rtsd}.
4224 @node Microsoft Windows Function Attributes
4225 @subsection Microsoft Windows Function Attributes
4227 The following attributes are available on Microsoft Windows and Symbian OS
4232 @cindex @code{dllexport} function attribute
4233 @cindex @code{__declspec(dllexport)}
4234 On Microsoft Windows targets and Symbian OS targets the
4235 @code{dllexport} attribute causes the compiler to provide a global
4236 pointer to a pointer in a DLL, so that it can be referenced with the
4237 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4238 name is formed by combining @code{_imp__} and the function or variable
4241 You can use @code{__declspec(dllexport)} as a synonym for
4242 @code{__attribute__ ((dllexport))} for compatibility with other
4245 On systems that support the @code{visibility} attribute, this
4246 attribute also implies ``default'' visibility. It is an error to
4247 explicitly specify any other visibility.
4249 GCC's default behavior is to emit all inline functions with the
4250 @code{dllexport} attribute. Since this can cause object file-size bloat,
4251 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4252 ignore the attribute for inlined functions unless the
4253 @option{-fkeep-inline-functions} flag is used instead.
4255 The attribute is ignored for undefined symbols.
4257 When applied to C++ classes, the attribute marks defined non-inlined
4258 member functions and static data members as exports. Static consts
4259 initialized in-class are not marked unless they are also defined
4262 For Microsoft Windows targets there are alternative methods for
4263 including the symbol in the DLL's export table such as using a
4264 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4265 the @option{--export-all} linker flag.
4268 @cindex @code{dllimport} function attribute
4269 @cindex @code{__declspec(dllimport)}
4270 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4271 attribute causes the compiler to reference a function or variable via
4272 a global pointer to a pointer that is set up by the DLL exporting the
4273 symbol. The attribute implies @code{extern}. On Microsoft Windows
4274 targets, the pointer name is formed by combining @code{_imp__} and the
4275 function or variable name.
4277 You can use @code{__declspec(dllimport)} as a synonym for
4278 @code{__attribute__ ((dllimport))} for compatibility with other
4281 On systems that support the @code{visibility} attribute, this
4282 attribute also implies ``default'' visibility. It is an error to
4283 explicitly specify any other visibility.
4285 Currently, the attribute is ignored for inlined functions. If the
4286 attribute is applied to a symbol @emph{definition}, an error is reported.
4287 If a symbol previously declared @code{dllimport} is later defined, the
4288 attribute is ignored in subsequent references, and a warning is emitted.
4289 The attribute is also overridden by a subsequent declaration as
4292 When applied to C++ classes, the attribute marks non-inlined
4293 member functions and static data members as imports. However, the
4294 attribute is ignored for virtual methods to allow creation of vtables
4297 On the SH Symbian OS target the @code{dllimport} attribute also has
4298 another affect---it can cause the vtable and run-time type information
4299 for a class to be exported. This happens when the class has a
4300 dllimported constructor or a non-inline, non-pure virtual function
4301 and, for either of those two conditions, the class also has an inline
4302 constructor or destructor and has a key function that is defined in
4303 the current translation unit.
4305 For Microsoft Windows targets the use of the @code{dllimport}
4306 attribute on functions is not necessary, but provides a small
4307 performance benefit by eliminating a thunk in the DLL@. The use of the
4308 @code{dllimport} attribute on imported variables can be avoided by passing the
4309 @option{--enable-auto-import} switch to the GNU linker. As with
4310 functions, using the attribute for a variable eliminates a thunk in
4313 One drawback to using this attribute is that a pointer to a
4314 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4315 address. However, a pointer to a @emph{function} with the
4316 @code{dllimport} attribute can be used as a constant initializer; in
4317 this case, the address of a stub function in the import lib is
4318 referenced. On Microsoft Windows targets, the attribute can be disabled
4319 for functions by setting the @option{-mnop-fun-dllimport} flag.
4322 @node MIPS Function Attributes
4323 @subsection MIPS Function Attributes
4325 These function attributes are supported by the MIPS back end:
4329 @cindex @code{interrupt} function attribute, MIPS
4330 Use this attribute to indicate that the specified function is an interrupt
4331 handler. The compiler generates function entry and exit sequences suitable
4332 for use in an interrupt handler when this attribute is present.
4333 An optional argument is supported for the interrupt attribute which allows
4334 the interrupt mode to be described. By default GCC assumes the external
4335 interrupt controller (EIC) mode is in use, this can be explicitly set using
4336 @code{eic}. When interrupts are non-masked then the requested Interrupt
4337 Priority Level (IPL) is copied to the current IPL which has the effect of only
4338 enabling higher priority interrupts. To use vectored interrupt mode use
4339 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4340 the behavior of the non-masked interrupt support and GCC will arrange to mask
4341 all interrupts from sw0 up to and including the specified interrupt vector.
4343 You can use the following attributes to modify the behavior
4344 of an interrupt handler:
4346 @item use_shadow_register_set
4347 @cindex @code{use_shadow_register_set} function attribute, MIPS
4348 Assume that the handler uses a shadow register set, instead of
4349 the main general-purpose registers. An optional argument @code{intstack} is
4350 supported to indicate that the shadow register set contains a valid stack
4353 @item keep_interrupts_masked
4354 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4355 Keep interrupts masked for the whole function. Without this attribute,
4356 GCC tries to reenable interrupts for as much of the function as it can.
4358 @item use_debug_exception_return
4359 @cindex @code{use_debug_exception_return} function attribute, MIPS
4360 Return using the @code{deret} instruction. Interrupt handlers that don't
4361 have this attribute return using @code{eret} instead.
4364 You can use any combination of these attributes, as shown below:
4366 void __attribute__ ((interrupt)) v0 ();
4367 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4368 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4369 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4370 void __attribute__ ((interrupt, use_shadow_register_set,
4371 keep_interrupts_masked)) v4 ();
4372 void __attribute__ ((interrupt, use_shadow_register_set,
4373 use_debug_exception_return)) v5 ();
4374 void __attribute__ ((interrupt, keep_interrupts_masked,
4375 use_debug_exception_return)) v6 ();
4376 void __attribute__ ((interrupt, use_shadow_register_set,
4377 keep_interrupts_masked,
4378 use_debug_exception_return)) v7 ();
4379 void __attribute__ ((interrupt("eic"))) v8 ();
4380 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4386 @cindex indirect calls, MIPS
4387 @cindex @code{long_call} function attribute, MIPS
4388 @cindex @code{near} function attribute, MIPS
4389 @cindex @code{far} function attribute, MIPS
4390 These attributes specify how a particular function is called on MIPS@.
4391 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4392 command-line switch. The @code{long_call} and @code{far} attributes are
4393 synonyms, and cause the compiler to always call
4394 the function by first loading its address into a register, and then using
4395 the contents of that register. The @code{near} attribute has the opposite
4396 effect; it specifies that non-PIC calls should be made using the more
4397 efficient @code{jal} instruction.
4401 @cindex @code{mips16} function attribute, MIPS
4402 @cindex @code{nomips16} function attribute, MIPS
4404 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4405 function attributes to locally select or turn off MIPS16 code generation.
4406 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4407 while MIPS16 code generation is disabled for functions with the
4408 @code{nomips16} attribute. These attributes override the
4409 @option{-mips16} and @option{-mno-mips16} options on the command line
4410 (@pxref{MIPS Options}).
4412 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4413 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4414 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4415 may interact badly with some GCC extensions such as @code{__builtin_apply}
4416 (@pxref{Constructing Calls}).
4418 @item micromips, MIPS
4419 @itemx nomicromips, MIPS
4420 @cindex @code{micromips} function attribute
4421 @cindex @code{nomicromips} function attribute
4423 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4424 function attributes to locally select or turn off microMIPS code generation.
4425 A function with the @code{micromips} attribute is emitted as microMIPS code,
4426 while microMIPS code generation is disabled for functions with the
4427 @code{nomicromips} attribute. These attributes override the
4428 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4429 (@pxref{MIPS Options}).
4431 When compiling files containing mixed microMIPS and non-microMIPS code, the
4432 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4434 not that within individual functions. Mixed microMIPS and non-microMIPS code
4435 may interact badly with some GCC extensions such as @code{__builtin_apply}
4436 (@pxref{Constructing Calls}).
4439 @cindex @code{nocompression} function attribute, MIPS
4440 On MIPS targets, you can use the @code{nocompression} function attribute
4441 to locally turn off MIPS16 and microMIPS code generation. This attribute
4442 overrides the @option{-mips16} and @option{-mmicromips} options on the
4443 command line (@pxref{MIPS Options}).
4446 @node MSP430 Function Attributes
4447 @subsection MSP430 Function Attributes
4449 These function attributes are supported by the MSP430 back end:
4453 @cindex @code{critical} function attribute, MSP430
4454 Critical functions disable interrupts upon entry and restore the
4455 previous interrupt state upon exit. Critical functions cannot also
4456 have the @code{naked} or @code{reentrant} attributes. They can have
4457 the @code{interrupt} attribute.
4460 @cindex @code{interrupt} function attribute, MSP430
4461 Use this attribute to indicate
4462 that the specified function is an interrupt handler. The compiler generates
4463 function entry and exit sequences suitable for use in an interrupt handler
4464 when this attribute is present.
4466 You can provide an argument to the interrupt
4467 attribute which specifies a name or number. If the argument is a
4468 number it indicates the slot in the interrupt vector table (0 - 31) to
4469 which this handler should be assigned. If the argument is a name it
4470 is treated as a symbolic name for the vector slot. These names should
4471 match up with appropriate entries in the linker script. By default
4472 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4473 @code{reset} for vector 31 are recognized.
4476 @cindex @code{naked} function attribute, MSP430
4477 This attribute allows the compiler to construct the
4478 requisite function declaration, while allowing the body of the
4479 function to be assembly code. The specified function will not have
4480 prologue/epilogue sequences generated by the compiler. Only basic
4481 @code{asm} statements can safely be included in naked functions
4482 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4483 basic @code{asm} and C code may appear to work, they cannot be
4484 depended upon to work reliably and are not supported.
4487 @cindex @code{reentrant} function attribute, MSP430
4488 Reentrant functions disable interrupts upon entry and enable them
4489 upon exit. Reentrant functions cannot also have the @code{naked}
4490 or @code{critical} attributes. They can have the @code{interrupt}
4494 @cindex @code{wakeup} function attribute, MSP430
4495 This attribute only applies to interrupt functions. It is silently
4496 ignored if applied to a non-interrupt function. A wakeup interrupt
4497 function will rouse the processor from any low-power state that it
4498 might be in when the function exits.
4503 @cindex @code{lower} function attribute, MSP430
4504 @cindex @code{upper} function attribute, MSP430
4505 @cindex @code{either} function attribute, MSP430
4506 On the MSP430 target these attributes can be used to specify whether
4507 the function or variable should be placed into low memory, high
4508 memory, or the placement should be left to the linker to decide. The
4509 attributes are only significant if compiling for the MSP430X
4512 The attributes work in conjunction with a linker script that has been
4513 augmented to specify where to place sections with a @code{.lower} and
4514 a @code{.upper} prefix. So, for example, as well as placing the
4515 @code{.data} section, the script also specifies the placement of a
4516 @code{.lower.data} and a @code{.upper.data} section. The intention
4517 is that @code{lower} sections are placed into a small but easier to
4518 access memory region and the upper sections are placed into a larger, but
4519 slower to access, region.
4521 The @code{either} attribute is special. It tells the linker to place
4522 the object into the corresponding @code{lower} section if there is
4523 room for it. If there is insufficient room then the object is placed
4524 into the corresponding @code{upper} section instead. Note that the
4525 placement algorithm is not very sophisticated. It does not attempt to
4526 find an optimal packing of the @code{lower} sections. It just makes
4527 one pass over the objects and does the best that it can. Using the
4528 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4529 options can help the packing, however, since they produce smaller,
4530 easier to pack regions.
4533 @node NDS32 Function Attributes
4534 @subsection NDS32 Function Attributes
4536 These function attributes are supported by the NDS32 back end:
4540 @cindex @code{exception} function attribute
4541 @cindex exception handler functions, NDS32
4542 Use this attribute on the NDS32 target to indicate that the specified function
4543 is an exception handler. The compiler will generate corresponding sections
4544 for use in an exception handler.
4547 @cindex @code{interrupt} function attribute, NDS32
4548 On NDS32 target, this attribute indicates that the specified function
4549 is an interrupt handler. The compiler generates corresponding sections
4550 for use in an interrupt handler. You can use the following attributes
4551 to modify the behavior:
4554 @cindex @code{nested} function attribute, NDS32
4555 This interrupt service routine is interruptible.
4557 @cindex @code{not_nested} function attribute, NDS32
4558 This interrupt service routine is not interruptible.
4560 @cindex @code{nested_ready} function attribute, NDS32
4561 This interrupt service routine is interruptible after @code{PSW.GIE}
4562 (global interrupt enable) is set. This allows interrupt service routine to
4563 finish some short critical code before enabling interrupts.
4565 @cindex @code{save_all} function attribute, NDS32
4566 The system will help save all registers into stack before entering
4569 @cindex @code{partial_save} function attribute, NDS32
4570 The system will help save caller registers into stack before entering
4575 @cindex @code{naked} function attribute, NDS32
4576 This attribute allows the compiler to construct the
4577 requisite function declaration, while allowing the body of the
4578 function to be assembly code. The specified function will not have
4579 prologue/epilogue sequences generated by the compiler. Only basic
4580 @code{asm} statements can safely be included in naked functions
4581 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4582 basic @code{asm} and C code may appear to work, they cannot be
4583 depended upon to work reliably and are not supported.
4586 @cindex @code{reset} function attribute, NDS32
4587 @cindex reset handler functions
4588 Use this attribute on the NDS32 target to indicate that the specified function
4589 is a reset handler. The compiler will generate corresponding sections
4590 for use in a reset handler. You can use the following attributes
4591 to provide extra exception handling:
4594 @cindex @code{nmi} function attribute, NDS32
4595 Provide a user-defined function to handle NMI exception.
4597 @cindex @code{warm} function attribute, NDS32
4598 Provide a user-defined function to handle warm reset exception.
4602 @node Nios II Function Attributes
4603 @subsection Nios II Function Attributes
4605 These function attributes are supported by the Nios II back end:
4608 @item target (@var{options})
4609 @cindex @code{target} function attribute
4610 As discussed in @ref{Common Function Attributes}, this attribute
4611 allows specification of target-specific compilation options.
4613 When compiling for Nios II, the following options are allowed:
4616 @item custom-@var{insn}=@var{N}
4617 @itemx no-custom-@var{insn}
4618 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4619 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4620 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4621 custom instruction with encoding @var{N} when generating code that uses
4622 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4623 the custom instruction @var{insn}.
4624 These target attributes correspond to the
4625 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4626 command-line options, and support the same set of @var{insn} keywords.
4627 @xref{Nios II Options}, for more information.
4629 @item custom-fpu-cfg=@var{name}
4630 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4631 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4632 command-line option, to select a predefined set of custom instructions
4634 @xref{Nios II Options}, for more information.
4638 @node Nvidia PTX Function Attributes
4639 @subsection Nvidia PTX Function Attributes
4641 These function attributes are supported by the Nvidia PTX back end:
4645 @cindex @code{kernel} attribute, Nvidia PTX
4646 This attribute indicates that the corresponding function should be compiled
4647 as a kernel function, which can be invoked from the host via the CUDA RT
4649 By default functions are only callable only from other PTX functions.
4651 Kernel functions must have @code{void} return type.
4654 @node PowerPC Function Attributes
4655 @subsection PowerPC Function Attributes
4657 These function attributes are supported by the PowerPC back end:
4662 @cindex indirect calls, PowerPC
4663 @cindex @code{longcall} function attribute, PowerPC
4664 @cindex @code{shortcall} function attribute, PowerPC
4665 The @code{longcall} attribute
4666 indicates that the function might be far away from the call site and
4667 require a different (more expensive) calling sequence. The
4668 @code{shortcall} attribute indicates that the function is always close
4669 enough for the shorter calling sequence to be used. These attributes
4670 override both the @option{-mlongcall} switch and
4671 the @code{#pragma longcall} setting.
4673 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4674 calls are necessary.
4676 @item target (@var{options})
4677 @cindex @code{target} function attribute
4678 As discussed in @ref{Common Function Attributes}, this attribute
4679 allows specification of target-specific compilation options.
4681 On the PowerPC, the following options are allowed:
4686 @cindex @code{target("altivec")} function attribute, PowerPC
4687 Generate code that uses (does not use) AltiVec instructions. In
4688 32-bit code, you cannot enable AltiVec instructions unless
4689 @option{-mabi=altivec} is used on the command line.
4693 @cindex @code{target("cmpb")} function attribute, PowerPC
4694 Generate code that uses (does not use) the compare bytes instruction
4695 implemented on the POWER6 processor and other processors that support
4696 the PowerPC V2.05 architecture.
4700 @cindex @code{target("dlmzb")} function attribute, PowerPC
4701 Generate code that uses (does not use) the string-search @samp{dlmzb}
4702 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4703 generated by default when targeting those processors.
4707 @cindex @code{target("fprnd")} function attribute, PowerPC
4708 Generate code that uses (does not use) the FP round to integer
4709 instructions implemented on the POWER5+ processor and other processors
4710 that support the PowerPC V2.03 architecture.
4714 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4715 Generate code that uses (does not use) the decimal floating-point
4716 instructions implemented on some POWER processors.
4720 @cindex @code{target("isel")} function attribute, PowerPC
4721 Generate code that uses (does not use) ISEL instruction.
4725 @cindex @code{target("mfcrf")} function attribute, PowerPC
4726 Generate code that uses (does not use) the move from condition
4727 register field instruction implemented on the POWER4 processor and
4728 other processors that support the PowerPC V2.01 architecture.
4732 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4733 Generate code that uses (does not use) the FP move to/from general
4734 purpose register instructions implemented on the POWER6X processor and
4735 other processors that support the extended PowerPC V2.05 architecture.
4739 @cindex @code{target("mulhw")} function attribute, PowerPC
4740 Generate code that uses (does not use) the half-word multiply and
4741 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4742 These instructions are generated by default when targeting those
4747 @cindex @code{target("multiple")} function attribute, PowerPC
4748 Generate code that uses (does not use) the load multiple word
4749 instructions and the store multiple word instructions.
4753 @cindex @code{target("update")} function attribute, PowerPC
4754 Generate code that uses (does not use) the load or store instructions
4755 that update the base register to the address of the calculated memory
4760 @cindex @code{target("popcntb")} function attribute, PowerPC
4761 Generate code that uses (does not use) the popcount and double-precision
4762 FP reciprocal estimate instruction implemented on the POWER5
4763 processor and other processors that support the PowerPC V2.02
4768 @cindex @code{target("popcntd")} function attribute, PowerPC
4769 Generate code that uses (does not use) the popcount instruction
4770 implemented on the POWER7 processor and other processors that support
4771 the PowerPC V2.06 architecture.
4773 @item powerpc-gfxopt
4774 @itemx no-powerpc-gfxopt
4775 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4776 Generate code that uses (does not use) the optional PowerPC
4777 architecture instructions in the Graphics group, including
4778 floating-point select.
4781 @itemx no-powerpc-gpopt
4782 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4783 Generate code that uses (does not use) the optional PowerPC
4784 architecture instructions in the General Purpose group, including
4785 floating-point square root.
4787 @item recip-precision
4788 @itemx no-recip-precision
4789 @cindex @code{target("recip-precision")} function attribute, PowerPC
4790 Assume (do not assume) that the reciprocal estimate instructions
4791 provide higher-precision estimates than is mandated by the PowerPC
4796 @cindex @code{target("string")} function attribute, PowerPC
4797 Generate code that uses (does not use) the load string instructions
4798 and the store string word instructions to save multiple registers and
4799 do small block moves.
4803 @cindex @code{target("vsx")} function attribute, PowerPC
4804 Generate code that uses (does not use) vector/scalar (VSX)
4805 instructions, and also enable the use of built-in functions that allow
4806 more direct access to the VSX instruction set. In 32-bit code, you
4807 cannot enable VSX or AltiVec instructions unless
4808 @option{-mabi=altivec} is used on the command line.
4812 @cindex @code{target("friz")} function attribute, PowerPC
4813 Generate (do not generate) the @code{friz} instruction when the
4814 @option{-funsafe-math-optimizations} option is used to optimize
4815 rounding a floating-point value to 64-bit integer and back to floating
4816 point. The @code{friz} instruction does not return the same value if
4817 the floating-point number is too large to fit in an integer.
4819 @item avoid-indexed-addresses
4820 @itemx no-avoid-indexed-addresses
4821 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4822 Generate code that tries to avoid (not avoid) the use of indexed load
4823 or store instructions.
4827 @cindex @code{target("paired")} function attribute, PowerPC
4828 Generate code that uses (does not use) the generation of PAIRED simd
4833 @cindex @code{target("longcall")} function attribute, PowerPC
4834 Generate code that assumes (does not assume) that all calls are far
4835 away so that a longer more expensive calling sequence is required.
4838 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4839 Specify the architecture to generate code for when compiling the
4840 function. If you select the @code{target("cpu=power7")} attribute when
4841 generating 32-bit code, VSX and AltiVec instructions are not generated
4842 unless you use the @option{-mabi=altivec} option on the command line.
4844 @item tune=@var{TUNE}
4845 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4846 Specify the architecture to tune for when compiling the function. If
4847 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4848 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4849 compilation tunes for the @var{CPU} architecture, and not the
4850 default tuning specified on the command line.
4853 On the PowerPC, the inliner does not inline a
4854 function that has different target options than the caller, unless the
4855 callee has a subset of the target options of the caller.
4858 @node RL78 Function Attributes
4859 @subsection RL78 Function Attributes
4861 These function attributes are supported by the RL78 back end:
4865 @itemx brk_interrupt
4866 @cindex @code{interrupt} function attribute, RL78
4867 @cindex @code{brk_interrupt} function attribute, RL78
4868 These attributes indicate
4869 that the specified function is an interrupt handler. The compiler generates
4870 function entry and exit sequences suitable for use in an interrupt handler
4871 when this attribute is present.
4873 Use @code{brk_interrupt} instead of @code{interrupt} for
4874 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4875 that must end with @code{RETB} instead of @code{RETI}).
4878 @cindex @code{naked} function attribute, RL78
4879 This attribute allows the compiler to construct the
4880 requisite function declaration, while allowing the body of the
4881 function to be assembly code. The specified function will not have
4882 prologue/epilogue sequences generated by the compiler. Only basic
4883 @code{asm} statements can safely be included in naked functions
4884 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4885 basic @code{asm} and C code may appear to work, they cannot be
4886 depended upon to work reliably and are not supported.
4889 @node RX Function Attributes
4890 @subsection RX Function Attributes
4892 These function attributes are supported by the RX back end:
4895 @item fast_interrupt
4896 @cindex @code{fast_interrupt} function attribute, RX
4897 Use this attribute on the RX port to indicate that the specified
4898 function is a fast interrupt handler. This is just like the
4899 @code{interrupt} attribute, except that @code{freit} is used to return
4900 instead of @code{reit}.
4903 @cindex @code{interrupt} function attribute, RX
4904 Use this attribute to indicate
4905 that the specified function is an interrupt handler. The compiler generates
4906 function entry and exit sequences suitable for use in an interrupt handler
4907 when this attribute is present.
4909 On RX targets, you may specify one or more vector numbers as arguments
4910 to the attribute, as well as naming an alternate table name.
4911 Parameters are handled sequentially, so one handler can be assigned to
4912 multiple entries in multiple tables. One may also pass the magic
4913 string @code{"$default"} which causes the function to be used for any
4914 unfilled slots in the current table.
4916 This example shows a simple assignment of a function to one vector in
4917 the default table (note that preprocessor macros may be used for
4918 chip-specific symbolic vector names):
4920 void __attribute__ ((interrupt (5))) txd1_handler ();
4923 This example assigns a function to two slots in the default table
4924 (using preprocessor macros defined elsewhere) and makes it the default
4925 for the @code{dct} table:
4927 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4932 @cindex @code{naked} function attribute, RX
4933 This attribute allows the compiler to construct the
4934 requisite function declaration, while allowing the body of the
4935 function to be assembly code. The specified function will not have
4936 prologue/epilogue sequences generated by the compiler. Only basic
4937 @code{asm} statements can safely be included in naked functions
4938 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4939 basic @code{asm} and C code may appear to work, they cannot be
4940 depended upon to work reliably and are not supported.
4943 @cindex @code{vector} function attribute, RX
4944 This RX attribute is similar to the @code{interrupt} attribute, including its
4945 parameters, but does not make the function an interrupt-handler type
4946 function (i.e. it retains the normal C function calling ABI). See the
4947 @code{interrupt} attribute for a description of its arguments.
4950 @node S/390 Function Attributes
4951 @subsection S/390 Function Attributes
4953 These function attributes are supported on the S/390:
4956 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4957 @cindex @code{hotpatch} function attribute, S/390
4959 On S/390 System z targets, you can use this function attribute to
4960 make GCC generate a ``hot-patching'' function prologue. If the
4961 @option{-mhotpatch=} command-line option is used at the same time,
4962 the @code{hotpatch} attribute takes precedence. The first of the
4963 two arguments specifies the number of halfwords to be added before
4964 the function label. A second argument can be used to specify the
4965 number of halfwords to be added after the function label. For
4966 both arguments the maximum allowed value is 1000000.
4968 If both arguments are zero, hotpatching is disabled.
4970 @item target (@var{options})
4971 @cindex @code{target} function attribute
4972 As discussed in @ref{Common Function Attributes}, this attribute
4973 allows specification of target-specific compilation options.
4975 On S/390, the following options are supported:
4983 @item warn-framesize=
4995 @itemx no-packed-stack
4997 @itemx no-small-exec
5000 @item warn-dynamicstack
5001 @itemx no-warn-dynamicstack
5004 The options work exactly like the S/390 specific command line
5005 options (without the prefix @option{-m}) except that they do not
5006 change any feature macros. For example,
5009 @code{target("no-vx")}
5012 does not undefine the @code{__VEC__} macro.
5015 @node SH Function Attributes
5016 @subsection SH Function Attributes
5018 These function attributes are supported on the SH family of processors:
5021 @item function_vector
5022 @cindex @code{function_vector} function attribute, SH
5023 @cindex calling functions through the function vector on SH2A
5024 On SH2A targets, this attribute declares a function to be called using the
5025 TBR relative addressing mode. The argument to this attribute is the entry
5026 number of the same function in a vector table containing all the TBR
5027 relative addressable functions. For correct operation the TBR must be setup
5028 accordingly to point to the start of the vector table before any functions with
5029 this attribute are invoked. Usually a good place to do the initialization is
5030 the startup routine. The TBR relative vector table can have at max 256 function
5031 entries. The jumps to these functions are generated using a SH2A specific,
5032 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
5033 from GNU binutils version 2.7 or later for this attribute to work correctly.
5035 In an application, for a function being called once, this attribute
5036 saves at least 8 bytes of code; and if other successive calls are being
5037 made to the same function, it saves 2 bytes of code per each of these
5040 @item interrupt_handler
5041 @cindex @code{interrupt_handler} function attribute, SH
5042 Use this attribute to
5043 indicate that the specified function is an interrupt handler. The compiler
5044 generates function entry and exit sequences suitable for use in an
5045 interrupt handler when this attribute is present.
5047 @item nosave_low_regs
5048 @cindex @code{nosave_low_regs} function attribute, SH
5049 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5050 function should not save and restore registers R0..R7. This can be used on SH3*
5051 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5055 @cindex @code{renesas} function attribute, SH
5056 On SH targets this attribute specifies that the function or struct follows the
5060 @cindex @code{resbank} function attribute, SH
5061 On the SH2A target, this attribute enables the high-speed register
5062 saving and restoration using a register bank for @code{interrupt_handler}
5063 routines. Saving to the bank is performed automatically after the CPU
5064 accepts an interrupt that uses a register bank.
5066 The nineteen 32-bit registers comprising general register R0 to R14,
5067 control register GBR, and system registers MACH, MACL, and PR and the
5068 vector table address offset are saved into a register bank. Register
5069 banks are stacked in first-in last-out (FILO) sequence. Restoration
5070 from the bank is executed by issuing a RESBANK instruction.
5073 @cindex @code{sp_switch} function attribute, SH
5074 Use this attribute on the SH to indicate an @code{interrupt_handler}
5075 function should switch to an alternate stack. It expects a string
5076 argument that names a global variable holding the address of the
5081 void f () __attribute__ ((interrupt_handler,
5082 sp_switch ("alt_stack")));
5086 @cindex @code{trap_exit} function attribute, SH
5087 Use this attribute on the SH for an @code{interrupt_handler} to return using
5088 @code{trapa} instead of @code{rte}. This attribute expects an integer
5089 argument specifying the trap number to be used.
5092 @cindex @code{trapa_handler} function attribute, SH
5093 On SH targets this function attribute is similar to @code{interrupt_handler}
5094 but it does not save and restore all registers.
5097 @node SPU Function Attributes
5098 @subsection SPU Function Attributes
5100 These function attributes are supported by the SPU back end:
5104 @cindex @code{naked} function attribute, SPU
5105 This attribute allows the compiler to construct the
5106 requisite function declaration, while allowing the body of the
5107 function to be assembly code. The specified function will not have
5108 prologue/epilogue sequences generated by the compiler. Only basic
5109 @code{asm} statements can safely be included in naked functions
5110 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5111 basic @code{asm} and C code may appear to work, they cannot be
5112 depended upon to work reliably and are not supported.
5115 @node Symbian OS Function Attributes
5116 @subsection Symbian OS Function Attributes
5118 @xref{Microsoft Windows Function Attributes}, for discussion of the
5119 @code{dllexport} and @code{dllimport} attributes.
5121 @node V850 Function Attributes
5122 @subsection V850 Function Attributes
5124 The V850 back end supports these function attributes:
5128 @itemx interrupt_handler
5129 @cindex @code{interrupt} function attribute, V850
5130 @cindex @code{interrupt_handler} function attribute, V850
5131 Use these attributes to indicate
5132 that the specified function is an interrupt handler. The compiler generates
5133 function entry and exit sequences suitable for use in an interrupt handler
5134 when either attribute is present.
5137 @node Visium Function Attributes
5138 @subsection Visium Function Attributes
5140 These function attributes are supported by the Visium back end:
5144 @cindex @code{interrupt} function attribute, Visium
5145 Use this attribute to indicate
5146 that the specified function is an interrupt handler. The compiler generates
5147 function entry and exit sequences suitable for use in an interrupt handler
5148 when this attribute is present.
5151 @node x86 Function Attributes
5152 @subsection x86 Function Attributes
5154 These function attributes are supported by the x86 back end:
5158 @cindex @code{cdecl} function attribute, x86-32
5159 @cindex functions that pop the argument stack on x86-32
5161 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5162 assume that the calling function pops off the stack space used to
5163 pass arguments. This is
5164 useful to override the effects of the @option{-mrtd} switch.
5167 @cindex @code{fastcall} function attribute, x86-32
5168 @cindex functions that pop the argument stack on x86-32
5169 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5170 pass the first argument (if of integral type) in the register ECX and
5171 the second argument (if of integral type) in the register EDX@. Subsequent
5172 and other typed arguments are passed on the stack. The called function
5173 pops the arguments off the stack. If the number of arguments is variable all
5174 arguments are pushed on the stack.
5177 @cindex @code{thiscall} function attribute, x86-32
5178 @cindex functions that pop the argument stack on x86-32
5179 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5180 pass the first argument (if of integral type) in the register ECX.
5181 Subsequent and other typed arguments are passed on the stack. The called
5182 function pops the arguments off the stack.
5183 If the number of arguments is variable all arguments are pushed on the
5185 The @code{thiscall} attribute is intended for C++ non-static member functions.
5186 As a GCC extension, this calling convention can be used for C functions
5187 and for static member methods.
5191 @cindex @code{ms_abi} function attribute, x86
5192 @cindex @code{sysv_abi} function attribute, x86
5194 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5195 to indicate which calling convention should be used for a function. The
5196 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5197 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5198 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5199 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5201 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5202 requires the @option{-maccumulate-outgoing-args} option.
5204 @item callee_pop_aggregate_return (@var{number})
5205 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5207 On x86-32 targets, you can use this attribute to control how
5208 aggregates are returned in memory. If the caller is responsible for
5209 popping the hidden pointer together with the rest of the arguments, specify
5210 @var{number} equal to zero. If callee is responsible for popping the
5211 hidden pointer, specify @var{number} equal to one.
5213 The default x86-32 ABI assumes that the callee pops the
5214 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5215 the compiler assumes that the
5216 caller pops the stack for hidden pointer.
5218 @item ms_hook_prologue
5219 @cindex @code{ms_hook_prologue} function attribute, x86
5221 On 32-bit and 64-bit x86 targets, you can use
5222 this function attribute to make GCC generate the ``hot-patching'' function
5223 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5226 @item regparm (@var{number})
5227 @cindex @code{regparm} function attribute, x86
5228 @cindex functions that are passed arguments in registers on x86-32
5229 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5230 pass arguments number one to @var{number} if they are of integral type
5231 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5232 take a variable number of arguments continue to be passed all of their
5233 arguments on the stack.
5235 Beware that on some ELF systems this attribute is unsuitable for
5236 global functions in shared libraries with lazy binding (which is the
5237 default). Lazy binding sends the first call via resolving code in
5238 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5239 per the standard calling conventions. Solaris 8 is affected by this.
5240 Systems with the GNU C Library version 2.1 or higher
5241 and FreeBSD are believed to be
5242 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5243 disabled with the linker or the loader if desired, to avoid the
5247 @cindex @code{sseregparm} function attribute, x86
5248 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5249 causes the compiler to pass up to 3 floating-point arguments in
5250 SSE registers instead of on the stack. Functions that take a
5251 variable number of arguments continue to pass all of their
5252 floating-point arguments on the stack.
5254 @item force_align_arg_pointer
5255 @cindex @code{force_align_arg_pointer} function attribute, x86
5256 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5257 applied to individual function definitions, generating an alternate
5258 prologue and epilogue that realigns the run-time stack if necessary.
5259 This supports mixing legacy codes that run with a 4-byte aligned stack
5260 with modern codes that keep a 16-byte stack for SSE compatibility.
5263 @cindex @code{stdcall} function attribute, x86-32
5264 @cindex functions that pop the argument stack on x86-32
5265 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5266 assume that the called function pops off the stack space used to
5267 pass arguments, unless it takes a variable number of arguments.
5269 @item target (@var{options})
5270 @cindex @code{target} function attribute
5271 As discussed in @ref{Common Function Attributes}, this attribute
5272 allows specification of target-specific compilation options.
5274 On the x86, the following options are allowed:
5278 @cindex @code{target("abm")} function attribute, x86
5279 Enable/disable the generation of the advanced bit instructions.
5283 @cindex @code{target("aes")} function attribute, x86
5284 Enable/disable the generation of the AES instructions.
5287 @cindex @code{target("default")} function attribute, x86
5288 @xref{Function Multiversioning}, where it is used to specify the
5289 default function version.
5293 @cindex @code{target("mmx")} function attribute, x86
5294 Enable/disable the generation of the MMX instructions.
5298 @cindex @code{target("pclmul")} function attribute, x86
5299 Enable/disable the generation of the PCLMUL instructions.
5303 @cindex @code{target("popcnt")} function attribute, x86
5304 Enable/disable the generation of the POPCNT instruction.
5308 @cindex @code{target("sse")} function attribute, x86
5309 Enable/disable the generation of the SSE instructions.
5313 @cindex @code{target("sse2")} function attribute, x86
5314 Enable/disable the generation of the SSE2 instructions.
5318 @cindex @code{target("sse3")} function attribute, x86
5319 Enable/disable the generation of the SSE3 instructions.
5323 @cindex @code{target("sse4")} function attribute, x86
5324 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5329 @cindex @code{target("sse4.1")} function attribute, x86
5330 Enable/disable the generation of the sse4.1 instructions.
5334 @cindex @code{target("sse4.2")} function attribute, x86
5335 Enable/disable the generation of the sse4.2 instructions.
5339 @cindex @code{target("sse4a")} function attribute, x86
5340 Enable/disable the generation of the SSE4A instructions.
5344 @cindex @code{target("fma4")} function attribute, x86
5345 Enable/disable the generation of the FMA4 instructions.
5349 @cindex @code{target("xop")} function attribute, x86
5350 Enable/disable the generation of the XOP instructions.
5354 @cindex @code{target("lwp")} function attribute, x86
5355 Enable/disable the generation of the LWP instructions.
5359 @cindex @code{target("ssse3")} function attribute, x86
5360 Enable/disable the generation of the SSSE3 instructions.
5364 @cindex @code{target("cld")} function attribute, x86
5365 Enable/disable the generation of the CLD before string moves.
5367 @item fancy-math-387
5368 @itemx no-fancy-math-387
5369 @cindex @code{target("fancy-math-387")} function attribute, x86
5370 Enable/disable the generation of the @code{sin}, @code{cos}, and
5371 @code{sqrt} instructions on the 387 floating-point unit.
5374 @itemx no-fused-madd
5375 @cindex @code{target("fused-madd")} function attribute, x86
5376 Enable/disable the generation of the fused multiply/add instructions.
5380 @cindex @code{target("ieee-fp")} function attribute, x86
5381 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5383 @item inline-all-stringops
5384 @itemx no-inline-all-stringops
5385 @cindex @code{target("inline-all-stringops")} function attribute, x86
5386 Enable/disable inlining of string operations.
5388 @item inline-stringops-dynamically
5389 @itemx no-inline-stringops-dynamically
5390 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5391 Enable/disable the generation of the inline code to do small string
5392 operations and calling the library routines for large operations.
5394 @item align-stringops
5395 @itemx no-align-stringops
5396 @cindex @code{target("align-stringops")} function attribute, x86
5397 Do/do not align destination of inlined string operations.
5401 @cindex @code{target("recip")} function attribute, x86
5402 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5403 instructions followed an additional Newton-Raphson step instead of
5404 doing a floating-point division.
5406 @item arch=@var{ARCH}
5407 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5408 Specify the architecture to generate code for in compiling the function.
5410 @item tune=@var{TUNE}
5411 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5412 Specify the architecture to tune for in compiling the function.
5414 @item fpmath=@var{FPMATH}
5415 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5416 Specify which floating-point unit to use. You must specify the
5417 @code{target("fpmath=sse,387")} option as
5418 @code{target("fpmath=sse+387")} because the comma would separate
5422 On the x86, the inliner does not inline a
5423 function that has different target options than the caller, unless the
5424 callee has a subset of the target options of the caller. For example
5425 a function declared with @code{target("sse3")} can inline a function
5426 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5429 @node Xstormy16 Function Attributes
5430 @subsection Xstormy16 Function Attributes
5432 These function attributes are supported by the Xstormy16 back end:
5436 @cindex @code{interrupt} function attribute, Xstormy16
5437 Use this attribute to indicate
5438 that the specified function is an interrupt handler. The compiler generates
5439 function entry and exit sequences suitable for use in an interrupt handler
5440 when this attribute is present.
5443 @node Variable Attributes
5444 @section Specifying Attributes of Variables
5445 @cindex attribute of variables
5446 @cindex variable attributes
5448 The keyword @code{__attribute__} allows you to specify special
5449 attributes of variables or structure fields. This keyword is followed
5450 by an attribute specification inside double parentheses. Some
5451 attributes are currently defined generically for variables.
5452 Other attributes are defined for variables on particular target
5453 systems. Other attributes are available for functions
5454 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5455 enumerators (@pxref{Enumerator Attributes}), and for types
5456 (@pxref{Type Attributes}).
5457 Other front ends might define more attributes
5458 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5460 @xref{Attribute Syntax}, for details of the exact syntax for using
5464 * Common Variable Attributes::
5465 * AVR Variable Attributes::
5466 * Blackfin Variable Attributes::
5467 * H8/300 Variable Attributes::
5468 * IA-64 Variable Attributes::
5469 * M32R/D Variable Attributes::
5470 * MeP Variable Attributes::
5471 * Microsoft Windows Variable Attributes::
5472 * MSP430 Variable Attributes::
5473 * PowerPC Variable Attributes::
5474 * RL78 Variable Attributes::
5475 * SPU Variable Attributes::
5476 * V850 Variable Attributes::
5477 * x86 Variable Attributes::
5478 * Xstormy16 Variable Attributes::
5481 @node Common Variable Attributes
5482 @subsection Common Variable Attributes
5484 The following attributes are supported on most targets.
5487 @cindex @code{aligned} variable attribute
5488 @item aligned (@var{alignment})
5489 This attribute specifies a minimum alignment for the variable or
5490 structure field, measured in bytes. For example, the declaration:
5493 int x __attribute__ ((aligned (16))) = 0;
5497 causes the compiler to allocate the global variable @code{x} on a
5498 16-byte boundary. On a 68040, this could be used in conjunction with
5499 an @code{asm} expression to access the @code{move16} instruction which
5500 requires 16-byte aligned operands.
5502 You can also specify the alignment of structure fields. For example, to
5503 create a double-word aligned @code{int} pair, you could write:
5506 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5510 This is an alternative to creating a union with a @code{double} member,
5511 which forces the union to be double-word aligned.
5513 As in the preceding examples, you can explicitly specify the alignment
5514 (in bytes) that you wish the compiler to use for a given variable or
5515 structure field. Alternatively, you can leave out the alignment factor
5516 and just ask the compiler to align a variable or field to the
5517 default alignment for the target architecture you are compiling for.
5518 The default alignment is sufficient for all scalar types, but may not be
5519 enough for all vector types on a target that supports vector operations.
5520 The default alignment is fixed for a particular target ABI.
5522 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5523 which is the largest alignment ever used for any data type on the
5524 target machine you are compiling for. For example, you could write:
5527 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5530 The compiler automatically sets the alignment for the declared
5531 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5532 often make copy operations more efficient, because the compiler can
5533 use whatever instructions copy the biggest chunks of memory when
5534 performing copies to or from the variables or fields that you have
5535 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5536 may change depending on command-line options.
5538 When used on a struct, or struct member, the @code{aligned} attribute can
5539 only increase the alignment; in order to decrease it, the @code{packed}
5540 attribute must be specified as well. When used as part of a typedef, the
5541 @code{aligned} attribute can both increase and decrease alignment, and
5542 specifying the @code{packed} attribute generates a warning.
5544 Note that the effectiveness of @code{aligned} attributes may be limited
5545 by inherent limitations in your linker. On many systems, the linker is
5546 only able to arrange for variables to be aligned up to a certain maximum
5547 alignment. (For some linkers, the maximum supported alignment may
5548 be very very small.) If your linker is only able to align variables
5549 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5550 in an @code{__attribute__} still only provides you with 8-byte
5551 alignment. See your linker documentation for further information.
5553 The @code{aligned} attribute can also be used for functions
5554 (@pxref{Common Function Attributes}.)
5556 @item cleanup (@var{cleanup_function})
5557 @cindex @code{cleanup} variable attribute
5558 The @code{cleanup} attribute runs a function when the variable goes
5559 out of scope. This attribute can only be applied to auto function
5560 scope variables; it may not be applied to parameters or variables
5561 with static storage duration. The function must take one parameter,
5562 a pointer to a type compatible with the variable. The return value
5563 of the function (if any) is ignored.
5565 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5566 is run during the stack unwinding that happens during the
5567 processing of the exception. Note that the @code{cleanup} attribute
5568 does not allow the exception to be caught, only to perform an action.
5569 It is undefined what happens if @var{cleanup_function} does not
5574 @cindex @code{common} variable attribute
5575 @cindex @code{nocommon} variable attribute
5578 The @code{common} attribute requests GCC to place a variable in
5579 ``common'' storage. The @code{nocommon} attribute requests the
5580 opposite---to allocate space for it directly.
5582 These attributes override the default chosen by the
5583 @option{-fno-common} and @option{-fcommon} flags respectively.
5586 @itemx deprecated (@var{msg})
5587 @cindex @code{deprecated} variable attribute
5588 The @code{deprecated} attribute results in a warning if the variable
5589 is used anywhere in the source file. This is useful when identifying
5590 variables that are expected to be removed in a future version of a
5591 program. The warning also includes the location of the declaration
5592 of the deprecated variable, to enable users to easily find further
5593 information about why the variable is deprecated, or what they should
5594 do instead. Note that the warning only occurs for uses:
5597 extern int old_var __attribute__ ((deprecated));
5599 int new_fn () @{ return old_var; @}
5603 results in a warning on line 3 but not line 2. The optional @var{msg}
5604 argument, which must be a string, is printed in the warning if
5607 The @code{deprecated} attribute can also be used for functions and
5608 types (@pxref{Common Function Attributes},
5609 @pxref{Common Type Attributes}).
5611 @item mode (@var{mode})
5612 @cindex @code{mode} variable attribute
5613 This attribute specifies the data type for the declaration---whichever
5614 type corresponds to the mode @var{mode}. This in effect lets you
5615 request an integer or floating-point type according to its width.
5617 You may also specify a mode of @code{byte} or @code{__byte__} to
5618 indicate the mode corresponding to a one-byte integer, @code{word} or
5619 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5620 or @code{__pointer__} for the mode used to represent pointers.
5623 @cindex @code{packed} variable attribute
5624 The @code{packed} attribute specifies that a variable or structure field
5625 should have the smallest possible alignment---one byte for a variable,
5626 and one bit for a field, unless you specify a larger value with the
5627 @code{aligned} attribute.
5629 Here is a structure in which the field @code{x} is packed, so that it
5630 immediately follows @code{a}:
5636 int x[2] __attribute__ ((packed));
5640 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5641 @code{packed} attribute on bit-fields of type @code{char}. This has
5642 been fixed in GCC 4.4 but the change can lead to differences in the
5643 structure layout. See the documentation of
5644 @option{-Wpacked-bitfield-compat} for more information.
5646 @item section ("@var{section-name}")
5647 @cindex @code{section} variable attribute
5648 Normally, the compiler places the objects it generates in sections like
5649 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5650 or you need certain particular variables to appear in special sections,
5651 for example to map to special hardware. The @code{section}
5652 attribute specifies that a variable (or function) lives in a particular
5653 section. For example, this small program uses several specific section names:
5656 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5657 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5658 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5659 int init_data __attribute__ ((section ("INITDATA")));
5663 /* @r{Initialize stack pointer} */
5664 init_sp (stack + sizeof (stack));
5666 /* @r{Initialize initialized data} */
5667 memcpy (&init_data, &data, &edata - &data);
5669 /* @r{Turn on the serial ports} */
5676 Use the @code{section} attribute with
5677 @emph{global} variables and not @emph{local} variables,
5678 as shown in the example.
5680 You may use the @code{section} attribute with initialized or
5681 uninitialized global variables but the linker requires
5682 each object be defined once, with the exception that uninitialized
5683 variables tentatively go in the @code{common} (or @code{bss}) section
5684 and can be multiply ``defined''. Using the @code{section} attribute
5685 changes what section the variable goes into and may cause the
5686 linker to issue an error if an uninitialized variable has multiple
5687 definitions. You can force a variable to be initialized with the
5688 @option{-fno-common} flag or the @code{nocommon} attribute.
5690 Some file formats do not support arbitrary sections so the @code{section}
5691 attribute is not available on all platforms.
5692 If you need to map the entire contents of a module to a particular
5693 section, consider using the facilities of the linker instead.
5695 @item tls_model ("@var{tls_model}")
5696 @cindex @code{tls_model} variable attribute
5697 The @code{tls_model} attribute sets thread-local storage model
5698 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5699 overriding @option{-ftls-model=} command-line switch on a per-variable
5701 The @var{tls_model} argument should be one of @code{global-dynamic},
5702 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5704 Not all targets support this attribute.
5707 @cindex @code{unused} variable attribute
5708 This attribute, attached to a variable, means that the variable is meant
5709 to be possibly unused. GCC does not produce a warning for this
5713 @cindex @code{used} variable attribute
5714 This attribute, attached to a variable with static storage, means that
5715 the variable must be emitted even if it appears that the variable is not
5718 When applied to a static data member of a C++ class template, the
5719 attribute also means that the member is instantiated if the
5720 class itself is instantiated.
5722 @item vector_size (@var{bytes})
5723 @cindex @code{vector_size} variable attribute
5724 This attribute specifies the vector size for the variable, measured in
5725 bytes. For example, the declaration:
5728 int foo __attribute__ ((vector_size (16)));
5732 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5733 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5734 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5736 This attribute is only applicable to integral and float scalars,
5737 although arrays, pointers, and function return values are allowed in
5738 conjunction with this construct.
5740 Aggregates with this attribute are invalid, even if they are of the same
5741 size as a corresponding scalar. For example, the declaration:
5744 struct S @{ int a; @};
5745 struct S __attribute__ ((vector_size (16))) foo;
5749 is invalid even if the size of the structure is the same as the size of
5752 @item visibility ("@var{visibility_type}")
5753 @cindex @code{visibility} variable attribute
5754 This attribute affects the linkage of the declaration to which it is attached.
5755 The @code{visibility} attribute is described in
5756 @ref{Common Function Attributes}.
5759 @cindex @code{weak} variable attribute
5760 The @code{weak} attribute is described in
5761 @ref{Common Function Attributes}.
5765 @node AVR Variable Attributes
5766 @subsection AVR Variable Attributes
5770 @cindex @code{progmem} variable attribute, AVR
5771 The @code{progmem} attribute is used on the AVR to place read-only
5772 data in the non-volatile program memory (flash). The @code{progmem}
5773 attribute accomplishes this by putting respective variables into a
5774 section whose name starts with @code{.progmem}.
5776 This attribute works similar to the @code{section} attribute
5777 but adds additional checking. Notice that just like the
5778 @code{section} attribute, @code{progmem} affects the location
5779 of the data but not how this data is accessed.
5781 In order to read data located with the @code{progmem} attribute
5782 (inline) assembler must be used.
5784 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5785 #include <avr/pgmspace.h>
5787 /* Locate var in flash memory */
5788 const int var[2] PROGMEM = @{ 1, 2 @};
5790 int read_var (int i)
5792 /* Access var[] by accessor macro from avr/pgmspace.h */
5793 return (int) pgm_read_word (& var[i]);
5797 AVR is a Harvard architecture processor and data and read-only data
5798 normally resides in the data memory (RAM).
5800 See also the @ref{AVR Named Address Spaces} section for
5801 an alternate way to locate and access data in flash memory.
5804 @itemx io (@var{addr})
5805 @cindex @code{io} variable attribute, AVR
5806 Variables with the @code{io} attribute are used to address
5807 memory-mapped peripherals in the io address range.
5808 If an address is specified, the variable
5809 is assigned that address, and the value is interpreted as an
5810 address in the data address space.
5814 volatile int porta __attribute__((io (0x22)));
5817 The address specified in the address in the data address range.
5819 Otherwise, the variable it is not assigned an address, but the
5820 compiler will still use in/out instructions where applicable,
5821 assuming some other module assigns an address in the io address range.
5825 extern volatile int porta __attribute__((io));
5829 @itemx io_low (@var{addr})
5830 @cindex @code{io_low} variable attribute, AVR
5831 This is like the @code{io} attribute, but additionally it informs the
5832 compiler that the object lies in the lower half of the I/O area,
5833 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5837 @itemx address (@var{addr})
5838 @cindex @code{address} variable attribute, AVR
5839 Variables with the @code{address} attribute are used to address
5840 memory-mapped peripherals that may lie outside the io address range.
5843 volatile int porta __attribute__((address (0x600)));
5848 @node Blackfin Variable Attributes
5849 @subsection Blackfin Variable Attributes
5851 Three attributes are currently defined for the Blackfin.
5857 @cindex @code{l1_data} variable attribute, Blackfin
5858 @cindex @code{l1_data_A} variable attribute, Blackfin
5859 @cindex @code{l1_data_B} variable attribute, Blackfin
5860 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5861 Variables with @code{l1_data} attribute are put into the specific section
5862 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5863 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5864 attribute are put into the specific section named @code{.l1.data.B}.
5867 @cindex @code{l2} variable attribute, Blackfin
5868 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5869 Variables with @code{l2} attribute are put into the specific section
5870 named @code{.l2.data}.
5873 @node H8/300 Variable Attributes
5874 @subsection H8/300 Variable Attributes
5876 These variable attributes are available for H8/300 targets:
5880 @cindex @code{eightbit_data} variable attribute, H8/300
5881 @cindex eight-bit data on the H8/300, H8/300H, and H8S
5882 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
5883 variable should be placed into the eight-bit data section.
5884 The compiler generates more efficient code for certain operations
5885 on data in the eight-bit data area. Note the eight-bit data area is limited to
5888 You must use GAS and GLD from GNU binutils version 2.7 or later for
5889 this attribute to work correctly.
5892 @cindex @code{tiny_data} variable attribute, H8/300
5893 @cindex tiny data section on the H8/300H and H8S
5894 Use this attribute on the H8/300H and H8S to indicate that the specified
5895 variable should be placed into the tiny data section.
5896 The compiler generates more efficient code for loads and stores
5897 on data in the tiny data section. Note the tiny data area is limited to
5898 slightly under 32KB of data.
5902 @node IA-64 Variable Attributes
5903 @subsection IA-64 Variable Attributes
5905 The IA-64 back end supports the following variable attribute:
5908 @item model (@var{model-name})
5909 @cindex @code{model} variable attribute, IA-64
5911 On IA-64, use this attribute to set the addressability of an object.
5912 At present, the only supported identifier for @var{model-name} is
5913 @code{small}, indicating addressability via ``small'' (22-bit)
5914 addresses (so that their addresses can be loaded with the @code{addl}
5915 instruction). Caveat: such addressing is by definition not position
5916 independent and hence this attribute must not be used for objects
5917 defined by shared libraries.
5921 @node M32R/D Variable Attributes
5922 @subsection M32R/D Variable Attributes
5924 One attribute is currently defined for the M32R/D@.
5927 @item model (@var{model-name})
5928 @cindex @code{model-name} variable attribute, M32R/D
5929 @cindex variable addressability on the M32R/D
5930 Use this attribute on the M32R/D to set the addressability of an object.
5931 The identifier @var{model-name} is one of @code{small}, @code{medium},
5932 or @code{large}, representing each of the code models.
5934 Small model objects live in the lower 16MB of memory (so that their
5935 addresses can be loaded with the @code{ld24} instruction).
5937 Medium and large model objects may live anywhere in the 32-bit address space
5938 (the compiler generates @code{seth/add3} instructions to load their
5942 @node MeP Variable Attributes
5943 @subsection MeP Variable Attributes
5945 The MeP target has a number of addressing modes and busses. The
5946 @code{near} space spans the standard memory space's first 16 megabytes
5947 (24 bits). The @code{far} space spans the entire 32-bit memory space.
5948 The @code{based} space is a 128-byte region in the memory space that
5949 is addressed relative to the @code{$tp} register. The @code{tiny}
5950 space is a 65536-byte region relative to the @code{$gp} register. In
5951 addition to these memory regions, the MeP target has a separate 16-bit
5952 control bus which is specified with @code{cb} attributes.
5957 @cindex @code{based} variable attribute, MeP
5958 Any variable with the @code{based} attribute is assigned to the
5959 @code{.based} section, and is accessed with relative to the
5960 @code{$tp} register.
5963 @cindex @code{tiny} variable attribute, MeP
5964 Likewise, the @code{tiny} attribute assigned variables to the
5965 @code{.tiny} section, relative to the @code{$gp} register.
5968 @cindex @code{near} variable attribute, MeP
5969 Variables with the @code{near} attribute are assumed to have addresses
5970 that fit in a 24-bit addressing mode. This is the default for large
5971 variables (@code{-mtiny=4} is the default) but this attribute can
5972 override @code{-mtiny=} for small variables, or override @code{-ml}.
5975 @cindex @code{far} variable attribute, MeP
5976 Variables with the @code{far} attribute are addressed using a full
5977 32-bit address. Since this covers the entire memory space, this
5978 allows modules to make no assumptions about where variables might be
5982 @cindex @code{io} variable attribute, MeP
5983 @itemx io (@var{addr})
5984 Variables with the @code{io} attribute are used to address
5985 memory-mapped peripherals. If an address is specified, the variable
5986 is assigned that address, else it is not assigned an address (it is
5987 assumed some other module assigns an address). Example:
5990 int timer_count __attribute__((io(0x123)));
5994 @itemx cb (@var{addr})
5995 @cindex @code{cb} variable attribute, MeP
5996 Variables with the @code{cb} attribute are used to access the control
5997 bus, using special instructions. @code{addr} indicates the control bus
6001 int cpu_clock __attribute__((cb(0x123)));
6006 @node Microsoft Windows Variable Attributes
6007 @subsection Microsoft Windows Variable Attributes
6009 You can use these attributes on Microsoft Windows targets.
6010 @ref{x86 Variable Attributes} for additional Windows compatibility
6011 attributes available on all x86 targets.
6016 @cindex @code{dllimport} variable attribute
6017 @cindex @code{dllexport} variable attribute
6018 The @code{dllimport} and @code{dllexport} attributes are described in
6019 @ref{Microsoft Windows Function Attributes}.
6022 @cindex @code{selectany} variable attribute
6023 The @code{selectany} attribute causes an initialized global variable to
6024 have link-once semantics. When multiple definitions of the variable are
6025 encountered by the linker, the first is selected and the remainder are
6026 discarded. Following usage by the Microsoft compiler, the linker is told
6027 @emph{not} to warn about size or content differences of the multiple
6030 Although the primary usage of this attribute is for POD types, the
6031 attribute can also be applied to global C++ objects that are initialized
6032 by a constructor. In this case, the static initialization and destruction
6033 code for the object is emitted in each translation defining the object,
6034 but the calls to the constructor and destructor are protected by a
6035 link-once guard variable.
6037 The @code{selectany} attribute is only available on Microsoft Windows
6038 targets. You can use @code{__declspec (selectany)} as a synonym for
6039 @code{__attribute__ ((selectany))} for compatibility with other
6043 @cindex @code{shared} variable attribute
6044 On Microsoft Windows, in addition to putting variable definitions in a named
6045 section, the section can also be shared among all running copies of an
6046 executable or DLL@. For example, this small program defines shared data
6047 by putting it in a named section @code{shared} and marking the section
6051 int foo __attribute__((section ("shared"), shared)) = 0;
6056 /* @r{Read and write foo. All running
6057 copies see the same value.} */
6063 You may only use the @code{shared} attribute along with @code{section}
6064 attribute with a fully-initialized global definition because of the way
6065 linkers work. See @code{section} attribute for more information.
6067 The @code{shared} attribute is only available on Microsoft Windows@.
6071 @node MSP430 Variable Attributes
6072 @subsection MSP430 Variable Attributes
6076 @cindex @code{noinit} variable attribute, MSP430
6077 Any data with the @code{noinit} attribute will not be initialised by
6078 the C runtime startup code, or the program loader. Not initialising
6079 data in this way can reduce program startup times.
6082 @cindex @code{persistent} variable attribute, MSP430
6083 Any variable with the @code{persistent} attribute will not be
6084 initialised by the C runtime startup code. Instead its value will be
6085 set once, when the application is loaded, and then never initialised
6086 again, even if the processor is reset or the program restarts.
6087 Persistent data is intended to be placed into FLASH RAM, where its
6088 value will be retained across resets. The linker script being used to
6089 create the application should ensure that persistent data is correctly
6095 @cindex @code{lower} variable attribute, MSP430
6096 @cindex @code{upper} variable attribute, MSP430
6097 @cindex @code{either} variable attribute, MSP430
6098 These attributes are the same as the MSP430 function attributes of the
6099 same name (@pxref{MSP430 Function Attributes}).
6100 These attributes can be applied to both functions and variables.
6103 @node PowerPC Variable Attributes
6104 @subsection PowerPC Variable Attributes
6106 Three attributes currently are defined for PowerPC configurations:
6107 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6109 @cindex @code{ms_struct} variable attribute, PowerPC
6110 @cindex @code{gcc_struct} variable attribute, PowerPC
6111 For full documentation of the struct attributes please see the
6112 documentation in @ref{x86 Variable Attributes}.
6114 @cindex @code{altivec} variable attribute, PowerPC
6115 For documentation of @code{altivec} attribute please see the
6116 documentation in @ref{PowerPC Type Attributes}.
6118 @node RL78 Variable Attributes
6119 @subsection RL78 Variable Attributes
6121 @cindex @code{saddr} variable attribute, RL78
6122 The RL78 back end supports the @code{saddr} variable attribute. This
6123 specifies placement of the corresponding variable in the SADDR area,
6124 which can be accessed more efficiently than the default memory region.
6126 @node SPU Variable Attributes
6127 @subsection SPU Variable Attributes
6129 @cindex @code{spu_vector} variable attribute, SPU
6130 The SPU supports the @code{spu_vector} attribute for variables. For
6131 documentation of this attribute please see the documentation in
6132 @ref{SPU Type Attributes}.
6134 @node V850 Variable Attributes
6135 @subsection V850 Variable Attributes
6137 These variable attributes are supported by the V850 back end:
6142 @cindex @code{sda} variable attribute, V850
6143 Use this attribute to explicitly place a variable in the small data area,
6144 which can hold up to 64 kilobytes.
6147 @cindex @code{tda} variable attribute, V850
6148 Use this attribute to explicitly place a variable in the tiny data area,
6149 which can hold up to 256 bytes in total.
6152 @cindex @code{zda} variable attribute, V850
6153 Use this attribute to explicitly place a variable in the first 32 kilobytes
6157 @node x86 Variable Attributes
6158 @subsection x86 Variable Attributes
6160 Two attributes are currently defined for x86 configurations:
6161 @code{ms_struct} and @code{gcc_struct}.
6166 @cindex @code{ms_struct} variable attribute, x86
6167 @cindex @code{gcc_struct} variable attribute, x86
6169 If @code{packed} is used on a structure, or if bit-fields are used,
6170 it may be that the Microsoft ABI lays out the structure differently
6171 than the way GCC normally does. Particularly when moving packed
6172 data between functions compiled with GCC and the native Microsoft compiler
6173 (either via function call or as data in a file), it may be necessary to access
6176 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6177 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6178 command-line options, respectively;
6179 see @ref{x86 Options}, for details of how structure layout is affected.
6180 @xref{x86 Type Attributes}, for information about the corresponding
6181 attributes on types.
6185 @node Xstormy16 Variable Attributes
6186 @subsection Xstormy16 Variable Attributes
6188 One attribute is currently defined for xstormy16 configurations:
6193 @cindex @code{below100} variable attribute, Xstormy16
6195 If a variable has the @code{below100} attribute (@code{BELOW100} is
6196 allowed also), GCC places the variable in the first 0x100 bytes of
6197 memory and use special opcodes to access it. Such variables are
6198 placed in either the @code{.bss_below100} section or the
6199 @code{.data_below100} section.
6203 @node Type Attributes
6204 @section Specifying Attributes of Types
6205 @cindex attribute of types
6206 @cindex type attributes
6208 The keyword @code{__attribute__} allows you to specify special
6209 attributes of types. Some type attributes apply only to @code{struct}
6210 and @code{union} types, while others can apply to any type defined
6211 via a @code{typedef} declaration. Other attributes are defined for
6212 functions (@pxref{Function Attributes}), labels (@pxref{Label
6213 Attributes}), enumerators (@pxref{Enumerator Attributes}), and for
6214 variables (@pxref{Variable Attributes}).
6216 The @code{__attribute__} keyword is followed by an attribute specification
6217 inside double parentheses.
6219 You may specify type attributes in an enum, struct or union type
6220 declaration or definition by placing them immediately after the
6221 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6222 syntax is to place them just past the closing curly brace of the
6225 You can also include type attributes in a @code{typedef} declaration.
6226 @xref{Attribute Syntax}, for details of the exact syntax for using
6230 * Common Type Attributes::
6231 * ARM Type Attributes::
6232 * MeP Type Attributes::
6233 * PowerPC Type Attributes::
6234 * SPU Type Attributes::
6235 * x86 Type Attributes::
6238 @node Common Type Attributes
6239 @subsection Common Type Attributes
6241 The following type attributes are supported on most targets.
6244 @cindex @code{aligned} type attribute
6245 @item aligned (@var{alignment})
6246 This attribute specifies a minimum alignment (in bytes) for variables
6247 of the specified type. For example, the declarations:
6250 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6251 typedef int more_aligned_int __attribute__ ((aligned (8)));
6255 force the compiler to ensure (as far as it can) that each variable whose
6256 type is @code{struct S} or @code{more_aligned_int} is allocated and
6257 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6258 variables of type @code{struct S} aligned to 8-byte boundaries allows
6259 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6260 store) instructions when copying one variable of type @code{struct S} to
6261 another, thus improving run-time efficiency.
6263 Note that the alignment of any given @code{struct} or @code{union} type
6264 is required by the ISO C standard to be at least a perfect multiple of
6265 the lowest common multiple of the alignments of all of the members of
6266 the @code{struct} or @code{union} in question. This means that you @emph{can}
6267 effectively adjust the alignment of a @code{struct} or @code{union}
6268 type by attaching an @code{aligned} attribute to any one of the members
6269 of such a type, but the notation illustrated in the example above is a
6270 more obvious, intuitive, and readable way to request the compiler to
6271 adjust the alignment of an entire @code{struct} or @code{union} type.
6273 As in the preceding example, you can explicitly specify the alignment
6274 (in bytes) that you wish the compiler to use for a given @code{struct}
6275 or @code{union} type. Alternatively, you can leave out the alignment factor
6276 and just ask the compiler to align a type to the maximum
6277 useful alignment for the target machine you are compiling for. For
6278 example, you could write:
6281 struct S @{ short f[3]; @} __attribute__ ((aligned));
6284 Whenever you leave out the alignment factor in an @code{aligned}
6285 attribute specification, the compiler automatically sets the alignment
6286 for the type to the largest alignment that is ever used for any data
6287 type on the target machine you are compiling for. Doing this can often
6288 make copy operations more efficient, because the compiler can use
6289 whatever instructions copy the biggest chunks of memory when performing
6290 copies to or from the variables that have types that you have aligned
6293 In the example above, if the size of each @code{short} is 2 bytes, then
6294 the size of the entire @code{struct S} type is 6 bytes. The smallest
6295 power of two that is greater than or equal to that is 8, so the
6296 compiler sets the alignment for the entire @code{struct S} type to 8
6299 Note that although you can ask the compiler to select a time-efficient
6300 alignment for a given type and then declare only individual stand-alone
6301 objects of that type, the compiler's ability to select a time-efficient
6302 alignment is primarily useful only when you plan to create arrays of
6303 variables having the relevant (efficiently aligned) type. If you
6304 declare or use arrays of variables of an efficiently-aligned type, then
6305 it is likely that your program also does pointer arithmetic (or
6306 subscripting, which amounts to the same thing) on pointers to the
6307 relevant type, and the code that the compiler generates for these
6308 pointer arithmetic operations is often more efficient for
6309 efficiently-aligned types than for other types.
6311 Note that the effectiveness of @code{aligned} attributes may be limited
6312 by inherent limitations in your linker. On many systems, the linker is
6313 only able to arrange for variables to be aligned up to a certain maximum
6314 alignment. (For some linkers, the maximum supported alignment may
6315 be very very small.) If your linker is only able to align variables
6316 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6317 in an @code{__attribute__} still only provides you with 8-byte
6318 alignment. See your linker documentation for further information.
6320 The @code{aligned} attribute can only increase alignment. Alignment
6321 can be decreased by specifying the @code{packed} attribute. See below.
6323 @item bnd_variable_size
6324 @cindex @code{bnd_variable_size} type attribute
6325 @cindex Pointer Bounds Checker attributes
6326 When applied to a structure field, this attribute tells Pointer
6327 Bounds Checker that the size of this field should not be computed
6328 using static type information. It may be used to mark variably-sized
6329 static array fields placed at the end of a structure.
6337 S *p = (S *)malloc (sizeof(S) + 100);
6338 p->data[10] = 0; //Bounds violation
6342 By using an attribute for the field we may avoid unwanted bound
6349 char data[1] __attribute__((bnd_variable_size));
6351 S *p = (S *)malloc (sizeof(S) + 100);
6352 p->data[10] = 0; //OK
6356 @itemx deprecated (@var{msg})
6357 @cindex @code{deprecated} type attribute
6358 The @code{deprecated} attribute results in a warning if the type
6359 is used anywhere in the source file. This is useful when identifying
6360 types that are expected to be removed in a future version of a program.
6361 If possible, the warning also includes the location of the declaration
6362 of the deprecated type, to enable users to easily find further
6363 information about why the type is deprecated, or what they should do
6364 instead. Note that the warnings only occur for uses and then only
6365 if the type is being applied to an identifier that itself is not being
6366 declared as deprecated.
6369 typedef int T1 __attribute__ ((deprecated));
6373 typedef T1 T3 __attribute__ ((deprecated));
6374 T3 z __attribute__ ((deprecated));
6378 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
6379 warning is issued for line 4 because T2 is not explicitly
6380 deprecated. Line 5 has no warning because T3 is explicitly
6381 deprecated. Similarly for line 6. The optional @var{msg}
6382 argument, which must be a string, is printed in the warning if
6385 The @code{deprecated} attribute can also be used for functions and
6386 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6388 @item designated_init
6389 @cindex @code{designated_init} type attribute
6390 This attribute may only be applied to structure types. It indicates
6391 that any initialization of an object of this type must use designated
6392 initializers rather than positional initializers. The intent of this
6393 attribute is to allow the programmer to indicate that a structure's
6394 layout may change, and that therefore relying on positional
6395 initialization will result in future breakage.
6397 GCC emits warnings based on this attribute by default; use
6398 @option{-Wno-designated-init} to suppress them.
6401 @cindex @code{may_alias} type attribute
6402 Accesses through pointers to types with this attribute are not subject
6403 to type-based alias analysis, but are instead assumed to be able to alias
6404 any other type of objects.
6405 In the context of section 6.5 paragraph 7 of the C99 standard,
6406 an lvalue expression
6407 dereferencing such a pointer is treated like having a character type.
6408 See @option{-fstrict-aliasing} for more information on aliasing issues.
6409 This extension exists to support some vector APIs, in which pointers to
6410 one vector type are permitted to alias pointers to a different vector type.
6412 Note that an object of a type with this attribute does not have any
6418 typedef short __attribute__((__may_alias__)) short_a;
6424 short_a *b = (short_a *) &a;
6428 if (a == 0x12345678)
6436 If you replaced @code{short_a} with @code{short} in the variable
6437 declaration, the above program would abort when compiled with
6438 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6442 @cindex @code{packed} type attribute
6443 This attribute, attached to @code{struct} or @code{union} type
6444 definition, specifies that each member (other than zero-width bit-fields)
6445 of the structure or union is placed to minimize the memory required. When
6446 attached to an @code{enum} definition, it indicates that the smallest
6447 integral type should be used.
6449 @opindex fshort-enums
6450 Specifying the @code{packed} attribute for @code{struct} and @code{union}
6451 types is equivalent to specifying the @code{packed} attribute on each
6452 of the structure or union members. Specifying the @option{-fshort-enums}
6453 flag on the command line is equivalent to specifying the @code{packed}
6454 attribute on all @code{enum} definitions.
6456 In the following example @code{struct my_packed_struct}'s members are
6457 packed closely together, but the internal layout of its @code{s} member
6458 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6462 struct my_unpacked_struct
6468 struct __attribute__ ((__packed__)) my_packed_struct
6472 struct my_unpacked_struct s;
6476 You may only specify the @code{packed} attribute attribute on the definition
6477 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
6478 that does not also define the enumerated type, structure or union.
6480 @item scalar_storage_order ("@var{endianness}")
6481 @cindex @code{scalar_storage_order} type attribute
6482 When attached to a @code{union} or a @code{struct}, this attribute sets
6483 the storage order, aka endianness, of the scalar fields of the type, as
6484 well as the array fields whose component is scalar. The supported
6485 endiannesses are @code{big-endian} and @code{little-endian}. The attribute
6486 has no effects on fields which are themselves a @code{union}, a @code{struct}
6487 or an array whose component is a @code{union} or a @code{struct}, and it is
6488 possible for these fields to have a different scalar storage order than the
6491 This attribute is supported only for targets that use a uniform default
6492 scalar storage order (fortunately, most of them), i.e. targets that store
6493 the scalars either all in big-endian or all in little-endian.
6495 Additional restrictions are enforced for types with the reverse scalar
6496 storage order with regard to the scalar storage order of the target:
6499 @item Taking the address of a scalar field of a @code{union} or a
6500 @code{struct} with reverse scalar storage order is not permitted and yields
6502 @item Taking the address of an array field, whose component is scalar, of
6503 a @code{union} or a @code{struct} with reverse scalar storage order is
6504 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
6506 @item Taking the address of a @code{union} or a @code{struct} with reverse
6507 scalar storage order is permitted.
6510 These restrictions exist because the storage order attribute is lost when
6511 the address of a scalar or the address of an array with scalar component is
6512 taken, so storing indirectly through this address generally does not work.
6513 The second case is nevertheless allowed to be able to perform a block copy
6514 from or to the array.
6516 Moreover, the use of type punning or aliasing to toggle the storage order
6517 is not supported; that is to say, a given scalar object cannot be accessed
6518 through distinct types that assign a different storage order to it.
6520 @item transparent_union
6521 @cindex @code{transparent_union} type attribute
6523 This attribute, attached to a @code{union} type definition, indicates
6524 that any function parameter having that union type causes calls to that
6525 function to be treated in a special way.
6527 First, the argument corresponding to a transparent union type can be of
6528 any type in the union; no cast is required. Also, if the union contains
6529 a pointer type, the corresponding argument can be a null pointer
6530 constant or a void pointer expression; and if the union contains a void
6531 pointer type, the corresponding argument can be any pointer expression.
6532 If the union member type is a pointer, qualifiers like @code{const} on
6533 the referenced type must be respected, just as with normal pointer
6536 Second, the argument is passed to the function using the calling
6537 conventions of the first member of the transparent union, not the calling
6538 conventions of the union itself. All members of the union must have the
6539 same machine representation; this is necessary for this argument passing
6542 Transparent unions are designed for library functions that have multiple
6543 interfaces for compatibility reasons. For example, suppose the
6544 @code{wait} function must accept either a value of type @code{int *} to
6545 comply with POSIX, or a value of type @code{union wait *} to comply with
6546 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
6547 @code{wait} would accept both kinds of arguments, but it would also
6548 accept any other pointer type and this would make argument type checking
6549 less useful. Instead, @code{<sys/wait.h>} might define the interface
6553 typedef union __attribute__ ((__transparent_union__))
6557 @} wait_status_ptr_t;
6559 pid_t wait (wait_status_ptr_t);
6563 This interface allows either @code{int *} or @code{union wait *}
6564 arguments to be passed, using the @code{int *} calling convention.
6565 The program can call @code{wait} with arguments of either type:
6568 int w1 () @{ int w; return wait (&w); @}
6569 int w2 () @{ union wait w; return wait (&w); @}
6573 With this interface, @code{wait}'s implementation might look like this:
6576 pid_t wait (wait_status_ptr_t p)
6578 return waitpid (-1, p.__ip, 0);
6583 @cindex @code{unused} type attribute
6584 When attached to a type (including a @code{union} or a @code{struct}),
6585 this attribute means that variables of that type are meant to appear
6586 possibly unused. GCC does not produce a warning for any variables of
6587 that type, even if the variable appears to do nothing. This is often
6588 the case with lock or thread classes, which are usually defined and then
6589 not referenced, but contain constructors and destructors that have
6590 nontrivial bookkeeping functions.
6593 @cindex @code{visibility} type attribute
6594 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6595 applied to class, struct, union and enum types. Unlike other type
6596 attributes, the attribute must appear between the initial keyword and
6597 the name of the type; it cannot appear after the body of the type.
6599 Note that the type visibility is applied to vague linkage entities
6600 associated with the class (vtable, typeinfo node, etc.). In
6601 particular, if a class is thrown as an exception in one shared object
6602 and caught in another, the class must have default visibility.
6603 Otherwise the two shared objects are unable to use the same
6604 typeinfo node and exception handling will break.
6608 To specify multiple attributes, separate them by commas within the
6609 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6612 @node ARM Type Attributes
6613 @subsection ARM Type Attributes
6615 @cindex @code{notshared} type attribute, ARM
6616 On those ARM targets that support @code{dllimport} (such as Symbian
6617 OS), you can use the @code{notshared} attribute to indicate that the
6618 virtual table and other similar data for a class should not be
6619 exported from a DLL@. For example:
6622 class __declspec(notshared) C @{
6624 __declspec(dllimport) C();
6628 __declspec(dllexport)
6633 In this code, @code{C::C} is exported from the current DLL, but the
6634 virtual table for @code{C} is not exported. (You can use
6635 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6636 most Symbian OS code uses @code{__declspec}.)
6638 @node MeP Type Attributes
6639 @subsection MeP Type Attributes
6641 @cindex @code{based} type attribute, MeP
6642 @cindex @code{tiny} type attribute, MeP
6643 @cindex @code{near} type attribute, MeP
6644 @cindex @code{far} type attribute, MeP
6645 Many of the MeP variable attributes may be applied to types as well.
6646 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6647 @code{far} attributes may be applied to either. The @code{io} and
6648 @code{cb} attributes may not be applied to types.
6650 @node PowerPC Type Attributes
6651 @subsection PowerPC Type Attributes
6653 Three attributes currently are defined for PowerPC configurations:
6654 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6656 @cindex @code{ms_struct} type attribute, PowerPC
6657 @cindex @code{gcc_struct} type attribute, PowerPC
6658 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6659 attributes please see the documentation in @ref{x86 Type Attributes}.
6661 @cindex @code{altivec} type attribute, PowerPC
6662 The @code{altivec} attribute allows one to declare AltiVec vector data
6663 types supported by the AltiVec Programming Interface Manual. The
6664 attribute requires an argument to specify one of three vector types:
6665 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6666 and @code{bool__} (always followed by unsigned).
6669 __attribute__((altivec(vector__)))
6670 __attribute__((altivec(pixel__))) unsigned short
6671 __attribute__((altivec(bool__))) unsigned
6674 These attributes mainly are intended to support the @code{__vector},
6675 @code{__pixel}, and @code{__bool} AltiVec keywords.
6677 @node SPU Type Attributes
6678 @subsection SPU Type Attributes
6680 @cindex @code{spu_vector} type attribute, SPU
6681 The SPU supports the @code{spu_vector} attribute for types. This attribute
6682 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6683 Language Extensions Specification. It is intended to support the
6684 @code{__vector} keyword.
6686 @node x86 Type Attributes
6687 @subsection x86 Type Attributes
6689 Two attributes are currently defined for x86 configurations:
6690 @code{ms_struct} and @code{gcc_struct}.
6696 @cindex @code{ms_struct} type attribute, x86
6697 @cindex @code{gcc_struct} type attribute, x86
6699 If @code{packed} is used on a structure, or if bit-fields are used
6700 it may be that the Microsoft ABI packs them differently
6701 than GCC normally packs them. Particularly when moving packed
6702 data between functions compiled with GCC and the native Microsoft compiler
6703 (either via function call or as data in a file), it may be necessary to access
6706 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6707 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6708 command-line options, respectively;
6709 see @ref{x86 Options}, for details of how structure layout is affected.
6710 @xref{x86 Variable Attributes}, for information about the corresponding
6711 attributes on variables.
6715 @node Label Attributes
6716 @section Label Attributes
6717 @cindex Label Attributes
6719 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
6720 details of the exact syntax for using attributes. Other attributes are
6721 available for functions (@pxref{Function Attributes}), variables
6722 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6723 and for types (@pxref{Type Attributes}).
6725 This example uses the @code{cold} label attribute to indicate the
6726 @code{ErrorHandling} branch is unlikely to be taken and that the
6727 @code{ErrorHandling} label is unused:
6731 asm goto ("some asm" : : : : NoError);
6733 /* This branch (the fall-through from the asm) is less commonly used */
6735 __attribute__((cold, unused)); /* Semi-colon is required here */
6740 printf("no error\n");
6746 @cindex @code{unused} label attribute
6747 This feature is intended for program-generated code that may contain
6748 unused labels, but which is compiled with @option{-Wall}. It is
6749 not normally appropriate to use in it human-written code, though it
6750 could be useful in cases where the code that jumps to the label is
6751 contained within an @code{#ifdef} conditional.
6754 @cindex @code{hot} label attribute
6755 The @code{hot} attribute on a label is used to inform the compiler that
6756 the path following the label is more likely than paths that are not so
6757 annotated. This attribute is used in cases where @code{__builtin_expect}
6758 cannot be used, for instance with computed goto or @code{asm goto}.
6761 @cindex @code{cold} label attribute
6762 The @code{cold} attribute on labels is used to inform the compiler that
6763 the path following the label is unlikely to be executed. This attribute
6764 is used in cases where @code{__builtin_expect} cannot be used, for instance
6765 with computed goto or @code{asm goto}.
6769 @node Enumerator Attributes
6770 @section Enumerator Attributes
6771 @cindex Enumerator Attributes
6773 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
6774 details of the exact syntax for using attributes. Other attributes are
6775 available for functions (@pxref{Function Attributes}), variables
6776 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}),
6777 and for types (@pxref{Type Attributes}).
6779 This example uses the @code{deprecated} enumerator attribute to indicate the
6780 @code{oldval} enumerator is deprecated:
6784 oldval __attribute__((deprecated)),
6797 @cindex @code{deprecated} enumerator attribute
6798 The @code{deprecated} attribute results in a warning if the enumerator
6799 is used anywhere in the source file. This is useful when identifying
6800 enumerators that are expected to be removed in a future version of a
6801 program. The warning also includes the location of the declaration
6802 of the deprecated enumerator, to enable users to easily find further
6803 information about why the enumerator is deprecated, or what they should
6804 do instead. Note that the warnings only occurs for uses.
6808 @node Attribute Syntax
6809 @section Attribute Syntax
6810 @cindex attribute syntax
6812 This section describes the syntax with which @code{__attribute__} may be
6813 used, and the constructs to which attribute specifiers bind, for the C
6814 language. Some details may vary for C++ and Objective-C@. Because of
6815 infelicities in the grammar for attributes, some forms described here
6816 may not be successfully parsed in all cases.
6818 There are some problems with the semantics of attributes in C++. For
6819 example, there are no manglings for attributes, although they may affect
6820 code generation, so problems may arise when attributed types are used in
6821 conjunction with templates or overloading. Similarly, @code{typeid}
6822 does not distinguish between types with different attributes. Support
6823 for attributes in C++ may be restricted in future to attributes on
6824 declarations only, but not on nested declarators.
6826 @xref{Function Attributes}, for details of the semantics of attributes
6827 applying to functions. @xref{Variable Attributes}, for details of the
6828 semantics of attributes applying to variables. @xref{Type Attributes},
6829 for details of the semantics of attributes applying to structure, union
6830 and enumerated types.
6831 @xref{Label Attributes}, for details of the semantics of attributes
6833 @xref{Enumerator Attributes}, for details of the semantics of attributes
6834 applying to enumerators.
6836 An @dfn{attribute specifier} is of the form
6837 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
6838 is a possibly empty comma-separated sequence of @dfn{attributes}, where
6839 each attribute is one of the following:
6843 Empty. Empty attributes are ignored.
6847 (which may be an identifier such as @code{unused}, or a reserved
6848 word such as @code{const}).
6851 An attribute name followed by a parenthesized list of
6852 parameters for the attribute.
6853 These parameters take one of the following forms:
6857 An identifier. For example, @code{mode} attributes use this form.
6860 An identifier followed by a comma and a non-empty comma-separated list
6861 of expressions. For example, @code{format} attributes use this form.
6864 A possibly empty comma-separated list of expressions. For example,
6865 @code{format_arg} attributes use this form with the list being a single
6866 integer constant expression, and @code{alias} attributes use this form
6867 with the list being a single string constant.
6871 An @dfn{attribute specifier list} is a sequence of one or more attribute
6872 specifiers, not separated by any other tokens.
6874 You may optionally specify attribute names with @samp{__}
6875 preceding and following the name.
6876 This allows you to use them in header files without
6877 being concerned about a possible macro of the same name. For example,
6878 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
6881 @subsubheading Label Attributes
6883 In GNU C, an attribute specifier list may appear after the colon following a
6884 label, other than a @code{case} or @code{default} label. GNU C++ only permits
6885 attributes on labels if the attribute specifier is immediately
6886 followed by a semicolon (i.e., the label applies to an empty
6887 statement). If the semicolon is missing, C++ label attributes are
6888 ambiguous, as it is permissible for a declaration, which could begin
6889 with an attribute list, to be labelled in C++. Declarations cannot be
6890 labelled in C90 or C99, so the ambiguity does not arise there.
6892 @subsubheading Enumerator Attributes
6894 In GNU C, an attribute specifier list may appear as part of an enumerator.
6895 The attribute goes after the enumeration constant, before @code{=}, if
6896 present. The optional attribute in the enumerator appertains to the
6897 enumeration constant. It is not possible to place the attribute after
6898 the constant expression, if present.
6900 @subsubheading Type Attributes
6902 An attribute specifier list may appear as part of a @code{struct},
6903 @code{union} or @code{enum} specifier. It may go either immediately
6904 after the @code{struct}, @code{union} or @code{enum} keyword, or after
6905 the closing brace. The former syntax is preferred.
6906 Where attribute specifiers follow the closing brace, they are considered
6907 to relate to the structure, union or enumerated type defined, not to any
6908 enclosing declaration the type specifier appears in, and the type
6909 defined is not complete until after the attribute specifiers.
6910 @c Otherwise, there would be the following problems: a shift/reduce
6911 @c conflict between attributes binding the struct/union/enum and
6912 @c binding to the list of specifiers/qualifiers; and "aligned"
6913 @c attributes could use sizeof for the structure, but the size could be
6914 @c changed later by "packed" attributes.
6917 @subsubheading All other attributes
6919 Otherwise, an attribute specifier appears as part of a declaration,
6920 counting declarations of unnamed parameters and type names, and relates
6921 to that declaration (which may be nested in another declaration, for
6922 example in the case of a parameter declaration), or to a particular declarator
6923 within a declaration. Where an
6924 attribute specifier is applied to a parameter declared as a function or
6925 an array, it should apply to the function or array rather than the
6926 pointer to which the parameter is implicitly converted, but this is not
6927 yet correctly implemented.
6929 Any list of specifiers and qualifiers at the start of a declaration may
6930 contain attribute specifiers, whether or not such a list may in that
6931 context contain storage class specifiers. (Some attributes, however,
6932 are essentially in the nature of storage class specifiers, and only make
6933 sense where storage class specifiers may be used; for example,
6934 @code{section}.) There is one necessary limitation to this syntax: the
6935 first old-style parameter declaration in a function definition cannot
6936 begin with an attribute specifier, because such an attribute applies to
6937 the function instead by syntax described below (which, however, is not
6938 yet implemented in this case). In some other cases, attribute
6939 specifiers are permitted by this grammar but not yet supported by the
6940 compiler. All attribute specifiers in this place relate to the
6941 declaration as a whole. In the obsolescent usage where a type of
6942 @code{int} is implied by the absence of type specifiers, such a list of
6943 specifiers and qualifiers may be an attribute specifier list with no
6944 other specifiers or qualifiers.
6946 At present, the first parameter in a function prototype must have some
6947 type specifier that is not an attribute specifier; this resolves an
6948 ambiguity in the interpretation of @code{void f(int
6949 (__attribute__((foo)) x))}, but is subject to change. At present, if
6950 the parentheses of a function declarator contain only attributes then
6951 those attributes are ignored, rather than yielding an error or warning
6952 or implying a single parameter of type int, but this is subject to
6955 An attribute specifier list may appear immediately before a declarator
6956 (other than the first) in a comma-separated list of declarators in a
6957 declaration of more than one identifier using a single list of
6958 specifiers and qualifiers. Such attribute specifiers apply
6959 only to the identifier before whose declarator they appear. For
6963 __attribute__((noreturn)) void d0 (void),
6964 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
6969 the @code{noreturn} attribute applies to all the functions
6970 declared; the @code{format} attribute only applies to @code{d1}.
6972 An attribute specifier list may appear immediately before the comma,
6973 @code{=} or semicolon terminating the declaration of an identifier other
6974 than a function definition. Such attribute specifiers apply
6975 to the declared object or function. Where an
6976 assembler name for an object or function is specified (@pxref{Asm
6977 Labels}), the attribute must follow the @code{asm}
6980 An attribute specifier list may, in future, be permitted to appear after
6981 the declarator in a function definition (before any old-style parameter
6982 declarations or the function body).
6984 Attribute specifiers may be mixed with type qualifiers appearing inside
6985 the @code{[]} of a parameter array declarator, in the C99 construct by
6986 which such qualifiers are applied to the pointer to which the array is
6987 implicitly converted. Such attribute specifiers apply to the pointer,
6988 not to the array, but at present this is not implemented and they are
6991 An attribute specifier list may appear at the start of a nested
6992 declarator. At present, there are some limitations in this usage: the
6993 attributes correctly apply to the declarator, but for most individual
6994 attributes the semantics this implies are not implemented.
6995 When attribute specifiers follow the @code{*} of a pointer
6996 declarator, they may be mixed with any type qualifiers present.
6997 The following describes the formal semantics of this syntax. It makes the
6998 most sense if you are familiar with the formal specification of
6999 declarators in the ISO C standard.
7001 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7002 D1}, where @code{T} contains declaration specifiers that specify a type
7003 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7004 contains an identifier @var{ident}. The type specified for @var{ident}
7005 for derived declarators whose type does not include an attribute
7006 specifier is as in the ISO C standard.
7008 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7009 and the declaration @code{T D} specifies the type
7010 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7011 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7012 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7014 If @code{D1} has the form @code{*
7015 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7016 declaration @code{T D} specifies the type
7017 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7018 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7019 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7025 void (__attribute__((noreturn)) ****f) (void);
7029 specifies the type ``pointer to pointer to pointer to pointer to
7030 non-returning function returning @code{void}''. As another example,
7033 char *__attribute__((aligned(8))) *f;
7037 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7038 Note again that this does not work with most attributes; for example,
7039 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7040 is not yet supported.
7042 For compatibility with existing code written for compiler versions that
7043 did not implement attributes on nested declarators, some laxity is
7044 allowed in the placing of attributes. If an attribute that only applies
7045 to types is applied to a declaration, it is treated as applying to
7046 the type of that declaration. If an attribute that only applies to
7047 declarations is applied to the type of a declaration, it is treated
7048 as applying to that declaration; and, for compatibility with code
7049 placing the attributes immediately before the identifier declared, such
7050 an attribute applied to a function return type is treated as
7051 applying to the function type, and such an attribute applied to an array
7052 element type is treated as applying to the array type. If an
7053 attribute that only applies to function types is applied to a
7054 pointer-to-function type, it is treated as applying to the pointer
7055 target type; if such an attribute is applied to a function return type
7056 that is not a pointer-to-function type, it is treated as applying
7057 to the function type.
7059 @node Function Prototypes
7060 @section Prototypes and Old-Style Function Definitions
7061 @cindex function prototype declarations
7062 @cindex old-style function definitions
7063 @cindex promotion of formal parameters
7065 GNU C extends ISO C to allow a function prototype to override a later
7066 old-style non-prototype definition. Consider the following example:
7069 /* @r{Use prototypes unless the compiler is old-fashioned.} */
7076 /* @r{Prototype function declaration.} */
7077 int isroot P((uid_t));
7079 /* @r{Old-style function definition.} */
7081 isroot (x) /* @r{??? lossage here ???} */
7088 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
7089 not allow this example, because subword arguments in old-style
7090 non-prototype definitions are promoted. Therefore in this example the
7091 function definition's argument is really an @code{int}, which does not
7092 match the prototype argument type of @code{short}.
7094 This restriction of ISO C makes it hard to write code that is portable
7095 to traditional C compilers, because the programmer does not know
7096 whether the @code{uid_t} type is @code{short}, @code{int}, or
7097 @code{long}. Therefore, in cases like these GNU C allows a prototype
7098 to override a later old-style definition. More precisely, in GNU C, a
7099 function prototype argument type overrides the argument type specified
7100 by a later old-style definition if the former type is the same as the
7101 latter type before promotion. Thus in GNU C the above example is
7102 equivalent to the following:
7115 GNU C++ does not support old-style function definitions, so this
7116 extension is irrelevant.
7119 @section C++ Style Comments
7121 @cindex C++ comments
7122 @cindex comments, C++ style
7124 In GNU C, you may use C++ style comments, which start with @samp{//} and
7125 continue until the end of the line. Many other C implementations allow
7126 such comments, and they are included in the 1999 C standard. However,
7127 C++ style comments are not recognized if you specify an @option{-std}
7128 option specifying a version of ISO C before C99, or @option{-ansi}
7129 (equivalent to @option{-std=c90}).
7132 @section Dollar Signs in Identifier Names
7134 @cindex dollar signs in identifier names
7135 @cindex identifier names, dollar signs in
7137 In GNU C, you may normally use dollar signs in identifier names.
7138 This is because many traditional C implementations allow such identifiers.
7139 However, dollar signs in identifiers are not supported on a few target
7140 machines, typically because the target assembler does not allow them.
7142 @node Character Escapes
7143 @section The Character @key{ESC} in Constants
7145 You can use the sequence @samp{\e} in a string or character constant to
7146 stand for the ASCII character @key{ESC}.
7149 @section Inquiring on Alignment of Types or Variables
7151 @cindex type alignment
7152 @cindex variable alignment
7154 The keyword @code{__alignof__} allows you to inquire about how an object
7155 is aligned, or the minimum alignment usually required by a type. Its
7156 syntax is just like @code{sizeof}.
7158 For example, if the target machine requires a @code{double} value to be
7159 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7160 This is true on many RISC machines. On more traditional machine
7161 designs, @code{__alignof__ (double)} is 4 or even 2.
7163 Some machines never actually require alignment; they allow reference to any
7164 data type even at an odd address. For these machines, @code{__alignof__}
7165 reports the smallest alignment that GCC gives the data type, usually as
7166 mandated by the target ABI.
7168 If the operand of @code{__alignof__} is an lvalue rather than a type,
7169 its value is the required alignment for its type, taking into account
7170 any minimum alignment specified with GCC's @code{__attribute__}
7171 extension (@pxref{Variable Attributes}). For example, after this
7175 struct foo @{ int x; char y; @} foo1;
7179 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7180 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7182 It is an error to ask for the alignment of an incomplete type.
7186 @section An Inline Function is As Fast As a Macro
7187 @cindex inline functions
7188 @cindex integrating function code
7190 @cindex macros, inline alternative
7192 By declaring a function inline, you can direct GCC to make
7193 calls to that function faster. One way GCC can achieve this is to
7194 integrate that function's code into the code for its callers. This
7195 makes execution faster by eliminating the function-call overhead; in
7196 addition, if any of the actual argument values are constant, their
7197 known values may permit simplifications at compile time so that not
7198 all of the inline function's code needs to be included. The effect on
7199 code size is less predictable; object code may be larger or smaller
7200 with function inlining, depending on the particular case. You can
7201 also direct GCC to try to integrate all ``simple enough'' functions
7202 into their callers with the option @option{-finline-functions}.
7204 GCC implements three different semantics of declaring a function
7205 inline. One is available with @option{-std=gnu89} or
7206 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7207 on all inline declarations, another when
7208 @option{-std=c99}, @option{-std=c11},
7209 @option{-std=gnu99} or @option{-std=gnu11}
7210 (without @option{-fgnu89-inline}), and the third
7211 is used when compiling C++.
7213 To declare a function inline, use the @code{inline} keyword in its
7214 declaration, like this:
7224 If you are writing a header file to be included in ISO C90 programs, write
7225 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
7227 The three types of inlining behave similarly in two important cases:
7228 when the @code{inline} keyword is used on a @code{static} function,
7229 like the example above, and when a function is first declared without
7230 using the @code{inline} keyword and then is defined with
7231 @code{inline}, like this:
7234 extern int inc (int *a);
7242 In both of these common cases, the program behaves the same as if you
7243 had not used the @code{inline} keyword, except for its speed.
7245 @cindex inline functions, omission of
7246 @opindex fkeep-inline-functions
7247 When a function is both inline and @code{static}, if all calls to the
7248 function are integrated into the caller, and the function's address is
7249 never used, then the function's own assembler code is never referenced.
7250 In this case, GCC does not actually output assembler code for the
7251 function, unless you specify the option @option{-fkeep-inline-functions}.
7252 If there is a nonintegrated call, then the function is compiled to
7253 assembler code as usual. The function must also be compiled as usual if
7254 the program refers to its address, because that can't be inlined.
7257 Note that certain usages in a function definition can make it unsuitable
7258 for inline substitution. Among these usages are: variadic functions,
7259 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7260 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7261 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7262 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
7263 function marked @code{inline} could not be substituted, and gives the
7264 reason for the failure.
7266 @cindex automatic @code{inline} for C++ member fns
7267 @cindex @code{inline} automatic for C++ member fns
7268 @cindex member fns, automatically @code{inline}
7269 @cindex C++ member fns, automatically @code{inline}
7270 @opindex fno-default-inline
7271 As required by ISO C++, GCC considers member functions defined within
7272 the body of a class to be marked inline even if they are
7273 not explicitly declared with the @code{inline} keyword. You can
7274 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7275 Options,,Options Controlling C++ Dialect}.
7277 GCC does not inline any functions when not optimizing unless you specify
7278 the @samp{always_inline} attribute for the function, like this:
7281 /* @r{Prototype.} */
7282 inline void foo (const char) __attribute__((always_inline));
7285 The remainder of this section is specific to GNU C90 inlining.
7287 @cindex non-static inline function
7288 When an inline function is not @code{static}, then the compiler must assume
7289 that there may be calls from other source files; since a global symbol can
7290 be defined only once in any program, the function must not be defined in
7291 the other source files, so the calls therein cannot be integrated.
7292 Therefore, a non-@code{static} inline function is always compiled on its
7293 own in the usual fashion.
7295 If you specify both @code{inline} and @code{extern} in the function
7296 definition, then the definition is used only for inlining. In no case
7297 is the function compiled on its own, not even if you refer to its
7298 address explicitly. Such an address becomes an external reference, as
7299 if you had only declared the function, and had not defined it.
7301 This combination of @code{inline} and @code{extern} has almost the
7302 effect of a macro. The way to use it is to put a function definition in
7303 a header file with these keywords, and put another copy of the
7304 definition (lacking @code{inline} and @code{extern}) in a library file.
7305 The definition in the header file causes most calls to the function
7306 to be inlined. If any uses of the function remain, they refer to
7307 the single copy in the library.
7310 @section When is a Volatile Object Accessed?
7311 @cindex accessing volatiles
7312 @cindex volatile read
7313 @cindex volatile write
7314 @cindex volatile access
7316 C has the concept of volatile objects. These are normally accessed by
7317 pointers and used for accessing hardware or inter-thread
7318 communication. The standard encourages compilers to refrain from
7319 optimizations concerning accesses to volatile objects, but leaves it
7320 implementation defined as to what constitutes a volatile access. The
7321 minimum requirement is that at a sequence point all previous accesses
7322 to volatile objects have stabilized and no subsequent accesses have
7323 occurred. Thus an implementation is free to reorder and combine
7324 volatile accesses that occur between sequence points, but cannot do
7325 so for accesses across a sequence point. The use of volatile does
7326 not allow you to violate the restriction on updating objects multiple
7327 times between two sequence points.
7329 Accesses to non-volatile objects are not ordered with respect to
7330 volatile accesses. You cannot use a volatile object as a memory
7331 barrier to order a sequence of writes to non-volatile memory. For
7335 int *ptr = @var{something};
7337 *ptr = @var{something};
7342 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7343 that the write to @var{*ptr} occurs by the time the update
7344 of @var{vobj} happens. If you need this guarantee, you must use
7345 a stronger memory barrier such as:
7348 int *ptr = @var{something};
7350 *ptr = @var{something};
7351 asm volatile ("" : : : "memory");
7355 A scalar volatile object is read when it is accessed in a void context:
7358 volatile int *src = @var{somevalue};
7362 Such expressions are rvalues, and GCC implements this as a
7363 read of the volatile object being pointed to.
7365 Assignments are also expressions and have an rvalue. However when
7366 assigning to a scalar volatile, the volatile object is not reread,
7367 regardless of whether the assignment expression's rvalue is used or
7368 not. If the assignment's rvalue is used, the value is that assigned
7369 to the volatile object. For instance, there is no read of @var{vobj}
7370 in all the following cases:
7375 vobj = @var{something};
7376 obj = vobj = @var{something};
7377 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7378 obj = (@var{something}, vobj = @var{anotherthing});
7381 If you need to read the volatile object after an assignment has
7382 occurred, you must use a separate expression with an intervening
7385 As bit-fields are not individually addressable, volatile bit-fields may
7386 be implicitly read when written to, or when adjacent bit-fields are
7387 accessed. Bit-field operations may be optimized such that adjacent
7388 bit-fields are only partially accessed, if they straddle a storage unit
7389 boundary. For these reasons it is unwise to use volatile bit-fields to
7392 @node Using Assembly Language with C
7393 @section How to Use Inline Assembly Language in C Code
7394 @cindex @code{asm} keyword
7395 @cindex assembly language in C
7396 @cindex inline assembly language
7397 @cindex mixing assembly language and C
7399 The @code{asm} keyword allows you to embed assembler instructions
7400 within C code. GCC provides two forms of inline @code{asm}
7401 statements. A @dfn{basic @code{asm}} statement is one with no
7402 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7403 statement (@pxref{Extended Asm}) includes one or more operands.
7404 The extended form is preferred for mixing C and assembly language
7405 within a function, but to include assembly language at
7406 top level you must use basic @code{asm}.
7408 You can also use the @code{asm} keyword to override the assembler name
7409 for a C symbol, or to place a C variable in a specific register.
7412 * Basic Asm:: Inline assembler without operands.
7413 * Extended Asm:: Inline assembler with operands.
7414 * Constraints:: Constraints for @code{asm} operands
7415 * Asm Labels:: Specifying the assembler name to use for a C symbol.
7416 * Explicit Register Variables:: Defining variables residing in specified
7418 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
7422 @subsection Basic Asm --- Assembler Instructions Without Operands
7423 @cindex basic @code{asm}
7424 @cindex assembly language in C, basic
7426 A basic @code{asm} statement has the following syntax:
7429 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7432 The @code{asm} keyword is a GNU extension.
7433 When writing code that can be compiled with @option{-ansi} and the
7434 various @option{-std} options, use @code{__asm__} instead of
7435 @code{asm} (@pxref{Alternate Keywords}).
7437 @subsubheading Qualifiers
7440 The optional @code{volatile} qualifier has no effect.
7441 All basic @code{asm} blocks are implicitly volatile.
7444 @subsubheading Parameters
7447 @item AssemblerInstructions
7448 This is a literal string that specifies the assembler code. The string can
7449 contain any instructions recognized by the assembler, including directives.
7450 GCC does not parse the assembler instructions themselves and
7451 does not know what they mean or even whether they are valid assembler input.
7453 You may place multiple assembler instructions together in a single @code{asm}
7454 string, separated by the characters normally used in assembly code for the
7455 system. A combination that works in most places is a newline to break the
7456 line, plus a tab character (written as @samp{\n\t}).
7457 Some assemblers allow semicolons as a line separator. However,
7458 note that some assembler dialects use semicolons to start a comment.
7461 @subsubheading Remarks
7462 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
7463 smaller, safer, and more efficient code, and in most cases it is a
7464 better solution than basic @code{asm}. However, there are two
7465 situations where only basic @code{asm} can be used:
7469 Extended @code{asm} statements have to be inside a C
7470 function, so to write inline assembly language at file scope (``top-level''),
7471 outside of C functions, you must use basic @code{asm}.
7472 You can use this technique to emit assembler directives,
7473 define assembly language macros that can be invoked elsewhere in the file,
7474 or write entire functions in assembly language.
7478 with the @code{naked} attribute also require basic @code{asm}
7479 (@pxref{Function Attributes}).
7482 Safely accessing C data and calling functions from basic @code{asm} is more
7483 complex than it may appear. To access C data, it is better to use extended
7486 Do not expect a sequence of @code{asm} statements to remain perfectly
7487 consecutive after compilation. If certain instructions need to remain
7488 consecutive in the output, put them in a single multi-instruction @code{asm}
7489 statement. Note that GCC's optimizers can move @code{asm} statements
7490 relative to other code, including across jumps.
7492 @code{asm} statements may not perform jumps into other @code{asm} statements.
7493 GCC does not know about these jumps, and therefore cannot take
7494 account of them when deciding how to optimize. Jumps from @code{asm} to C
7495 labels are only supported in extended @code{asm}.
7497 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7498 assembly code when optimizing. This can lead to unexpected duplicate
7499 symbol errors during compilation if your assembly code defines symbols or
7502 @strong{Warning:} The C standards do not specify semantics for @code{asm},
7503 making it a potential source of incompatibilities between compilers. These
7504 incompatibilities may not produce compiler warnings/errors.
7506 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
7507 means there is no way to communicate to the compiler what is happening
7508 inside them. GCC has no visibility of symbols in the @code{asm} and may
7509 discard them as unreferenced. It also does not know about side effects of
7510 the assembler code, such as modifications to memory or registers. Unlike
7511 some compilers, GCC assumes that no changes to either memory or registers
7512 occur. This assumption may change in a future release.
7514 To avoid complications from future changes to the semantics and the
7515 compatibility issues between compilers, consider replacing basic @code{asm}
7516 with extended @code{asm}. See
7517 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
7518 from basic asm to extended asm} for information about how to perform this
7521 The compiler copies the assembler instructions in a basic @code{asm}
7522 verbatim to the assembly language output file, without
7523 processing dialects or any of the @samp{%} operators that are available with
7524 extended @code{asm}. This results in minor differences between basic
7525 @code{asm} strings and extended @code{asm} templates. For example, to refer to
7526 registers you might use @samp{%eax} in basic @code{asm} and
7527 @samp{%%eax} in extended @code{asm}.
7529 On targets such as x86 that support multiple assembler dialects,
7530 all basic @code{asm} blocks use the assembler dialect specified by the
7531 @option{-masm} command-line option (@pxref{x86 Options}).
7532 Basic @code{asm} provides no
7533 mechanism to provide different assembler strings for different dialects.
7535 Here is an example of basic @code{asm} for i386:
7538 /* Note that this code will not compile with -masm=intel */
7539 #define DebugBreak() asm("int $3")
7543 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7544 @cindex extended @code{asm}
7545 @cindex assembly language in C, extended
7547 With extended @code{asm} you can read and write C variables from
7548 assembler and perform jumps from assembler code to C labels.
7549 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7550 the operand parameters after the assembler template:
7553 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
7554 : @var{OutputOperands}
7555 @r{[} : @var{InputOperands}
7556 @r{[} : @var{Clobbers} @r{]} @r{]})
7558 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
7560 : @var{InputOperands}
7565 The @code{asm} keyword is a GNU extension.
7566 When writing code that can be compiled with @option{-ansi} and the
7567 various @option{-std} options, use @code{__asm__} instead of
7568 @code{asm} (@pxref{Alternate Keywords}).
7570 @subsubheading Qualifiers
7574 The typical use of extended @code{asm} statements is to manipulate input
7575 values to produce output values. However, your @code{asm} statements may
7576 also produce side effects. If so, you may need to use the @code{volatile}
7577 qualifier to disable certain optimizations. @xref{Volatile}.
7580 This qualifier informs the compiler that the @code{asm} statement may
7581 perform a jump to one of the labels listed in the @var{GotoLabels}.
7585 @subsubheading Parameters
7587 @item AssemblerTemplate
7588 This is a literal string that is the template for the assembler code. It is a
7589 combination of fixed text and tokens that refer to the input, output,
7590 and goto parameters. @xref{AssemblerTemplate}.
7592 @item OutputOperands
7593 A comma-separated list of the C variables modified by the instructions in the
7594 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
7597 A comma-separated list of C expressions read by the instructions in the
7598 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
7601 A comma-separated list of registers or other values changed by the
7602 @var{AssemblerTemplate}, beyond those listed as outputs.
7603 An empty list is permitted. @xref{Clobbers}.
7606 When you are using the @code{goto} form of @code{asm}, this section contains
7607 the list of all C labels to which the code in the
7608 @var{AssemblerTemplate} may jump.
7611 @code{asm} statements may not perform jumps into other @code{asm} statements,
7612 only to the listed @var{GotoLabels}.
7613 GCC's optimizers do not know about other jumps; therefore they cannot take
7614 account of them when deciding how to optimize.
7617 The total number of input + output + goto operands is limited to 30.
7619 @subsubheading Remarks
7620 The @code{asm} statement allows you to include assembly instructions directly
7621 within C code. This may help you to maximize performance in time-sensitive
7622 code or to access assembly instructions that are not readily available to C
7625 Note that extended @code{asm} statements must be inside a function. Only
7626 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7627 Functions declared with the @code{naked} attribute also require basic
7628 @code{asm} (@pxref{Function Attributes}).
7630 While the uses of @code{asm} are many and varied, it may help to think of an
7631 @code{asm} statement as a series of low-level instructions that convert input
7632 parameters to output parameters. So a simple (if not particularly useful)
7633 example for i386 using @code{asm} might look like this:
7639 asm ("mov %1, %0\n\t"
7644 printf("%d\n", dst);
7647 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7650 @subsubsection Volatile
7651 @cindex volatile @code{asm}
7652 @cindex @code{asm} volatile
7654 GCC's optimizers sometimes discard @code{asm} statements if they determine
7655 there is no need for the output variables. Also, the optimizers may move
7656 code out of loops if they believe that the code will always return the same
7657 result (i.e. none of its input values change between calls). Using the
7658 @code{volatile} qualifier disables these optimizations. @code{asm} statements
7659 that have no output operands, including @code{asm goto} statements,
7660 are implicitly volatile.
7662 This i386 code demonstrates a case that does not use (or require) the
7663 @code{volatile} qualifier. If it is performing assertion checking, this code
7664 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
7665 unreferenced by any code. As a result, the optimizers can discard the
7666 @code{asm} statement, which in turn removes the need for the entire
7667 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
7668 isn't needed you allow the optimizers to produce the most efficient code
7672 void DoCheck(uint32_t dwSomeValue)
7676 // Assumes dwSomeValue is not zero.
7686 The next example shows a case where the optimizers can recognize that the input
7687 (@code{dwSomeValue}) never changes during the execution of the function and can
7688 therefore move the @code{asm} outside the loop to produce more efficient code.
7689 Again, using @code{volatile} disables this type of optimization.
7692 void do_print(uint32_t dwSomeValue)
7696 for (uint32_t x=0; x < 5; x++)
7698 // Assumes dwSomeValue is not zero.
7704 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7709 The following example demonstrates a case where you need to use the
7710 @code{volatile} qualifier.
7711 It uses the x86 @code{rdtsc} instruction, which reads
7712 the computer's time-stamp counter. Without the @code{volatile} qualifier,
7713 the optimizers might assume that the @code{asm} block will always return the
7714 same value and therefore optimize away the second call.
7719 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7720 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7721 "or %%rdx, %0" // 'Or' in the lower bits.
7726 printf("msr: %llx\n", msr);
7730 // Reprint the timestamp
7731 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7732 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7733 "or %%rdx, %0" // 'Or' in the lower bits.
7738 printf("msr: %llx\n", msr);
7741 GCC's optimizers do not treat this code like the non-volatile code in the
7742 earlier examples. They do not move it out of loops or omit it on the
7743 assumption that the result from a previous call is still valid.
7745 Note that the compiler can move even volatile @code{asm} instructions relative
7746 to other code, including across jump instructions. For example, on many
7747 targets there is a system register that controls the rounding mode of
7748 floating-point operations. Setting it with a volatile @code{asm}, as in the
7749 following PowerPC example, does not work reliably.
7752 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7756 The compiler may move the addition back before the volatile @code{asm}. To
7757 make it work as expected, add an artificial dependency to the @code{asm} by
7758 referencing a variable in the subsequent code, for example:
7761 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7765 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7766 assembly code when optimizing. This can lead to unexpected duplicate symbol
7767 errors during compilation if your asm code defines symbols or labels.
7769 (@pxref{AssemblerTemplate}) may help resolve this problem.
7771 @anchor{AssemblerTemplate}
7772 @subsubsection Assembler Template
7773 @cindex @code{asm} assembler template
7775 An assembler template is a literal string containing assembler instructions.
7776 The compiler replaces tokens in the template that refer
7777 to inputs, outputs, and goto labels,
7778 and then outputs the resulting string to the assembler. The
7779 string can contain any instructions recognized by the assembler, including
7780 directives. GCC does not parse the assembler instructions
7781 themselves and does not know what they mean or even whether they are valid
7782 assembler input. However, it does count the statements
7783 (@pxref{Size of an asm}).
7785 You may place multiple assembler instructions together in a single @code{asm}
7786 string, separated by the characters normally used in assembly code for the
7787 system. A combination that works in most places is a newline to break the
7788 line, plus a tab character to move to the instruction field (written as
7790 Some assemblers allow semicolons as a line separator. However, note
7791 that some assembler dialects use semicolons to start a comment.
7793 Do not expect a sequence of @code{asm} statements to remain perfectly
7794 consecutive after compilation, even when you are using the @code{volatile}
7795 qualifier. If certain instructions need to remain consecutive in the output,
7796 put them in a single multi-instruction asm statement.
7798 Accessing data from C programs without using input/output operands (such as
7799 by using global symbols directly from the assembler template) may not work as
7800 expected. Similarly, calling functions directly from an assembler template
7801 requires a detailed understanding of the target assembler and ABI.
7803 Since GCC does not parse the assembler template,
7804 it has no visibility of any
7805 symbols it references. This may result in GCC discarding those symbols as
7806 unreferenced unless they are also listed as input, output, or goto operands.
7808 @subsubheading Special format strings
7810 In addition to the tokens described by the input, output, and goto operands,
7811 these tokens have special meanings in the assembler template:
7815 Outputs a single @samp{%} into the assembler code.
7818 Outputs a number that is unique to each instance of the @code{asm}
7819 statement in the entire compilation. This option is useful when creating local
7820 labels and referring to them multiple times in a single template that
7821 generates multiple assembler instructions.
7826 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
7827 into the assembler code. When unescaped, these characters have special
7828 meaning to indicate multiple assembler dialects, as described below.
7831 @subsubheading Multiple assembler dialects in @code{asm} templates
7833 On targets such as x86, GCC supports multiple assembler dialects.
7834 The @option{-masm} option controls which dialect GCC uses as its
7835 default for inline assembler. The target-specific documentation for the
7836 @option{-masm} option contains the list of supported dialects, as well as the
7837 default dialect if the option is not specified. This information may be
7838 important to understand, since assembler code that works correctly when
7839 compiled using one dialect will likely fail if compiled using another.
7842 If your code needs to support multiple assembler dialects (for example, if
7843 you are writing public headers that need to support a variety of compilation
7844 options), use constructs of this form:
7847 @{ dialect0 | dialect1 | dialect2... @}
7850 This construct outputs @code{dialect0}
7851 when using dialect #0 to compile the code,
7852 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
7853 braces than the number of dialects the compiler supports, the construct
7856 For example, if an x86 compiler supports two dialects
7857 (@samp{att}, @samp{intel}), an
7858 assembler template such as this:
7861 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
7865 is equivalent to one of
7868 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
7869 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
7872 Using that same compiler, this code:
7875 "xchg@{l@}\t@{%%@}ebx, %1"
7879 corresponds to either
7882 "xchgl\t%%ebx, %1" @r{/* att dialect */}
7883 "xchg\tebx, %1" @r{/* intel dialect */}
7886 There is no support for nesting dialect alternatives.
7888 @anchor{OutputOperands}
7889 @subsubsection Output Operands
7890 @cindex @code{asm} output operands
7892 An @code{asm} statement has zero or more output operands indicating the names
7893 of C variables modified by the assembler code.
7895 In this i386 example, @code{old} (referred to in the template string as
7896 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
7897 (@code{%2}) is an input:
7902 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
7903 "sbb %0,%0" // Use the CF to calculate old.
7904 : "=r" (old), "+rm" (*Base)
7911 Operands are separated by commas. Each operand has this format:
7914 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
7918 @item asmSymbolicName
7919 Specifies a symbolic name for the operand.
7920 Reference the name in the assembler template
7921 by enclosing it in square brackets
7922 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
7923 that contains the definition. Any valid C variable name is acceptable,
7924 including names already defined in the surrounding code. No two operands
7925 within the same @code{asm} statement can use the same symbolic name.
7927 When not using an @var{asmSymbolicName}, use the (zero-based) position
7929 in the list of operands in the assembler template. For example if there are
7930 three output operands, use @samp{%0} in the template to refer to the first,
7931 @samp{%1} for the second, and @samp{%2} for the third.
7934 A string constant specifying constraints on the placement of the operand;
7935 @xref{Constraints}, for details.
7937 Output constraints must begin with either @samp{=} (a variable overwriting an
7938 existing value) or @samp{+} (when reading and writing). When using
7939 @samp{=}, do not assume the location contains the existing value
7940 on entry to the @code{asm}, except
7941 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
7943 After the prefix, there must be one or more additional constraints
7944 (@pxref{Constraints}) that describe where the value resides. Common
7945 constraints include @samp{r} for register and @samp{m} for memory.
7946 When you list more than one possible location (for example, @code{"=rm"}),
7947 the compiler chooses the most efficient one based on the current context.
7948 If you list as many alternates as the @code{asm} statement allows, you permit
7949 the optimizers to produce the best possible code.
7950 If you must use a specific register, but your Machine Constraints do not
7951 provide sufficient control to select the specific register you want,
7952 local register variables may provide a solution (@pxref{Local Register
7956 Specifies a C lvalue expression to hold the output, typically a variable name.
7957 The enclosing parentheses are a required part of the syntax.
7961 When the compiler selects the registers to use to
7962 represent the output operands, it does not use any of the clobbered registers
7965 Output operand expressions must be lvalues. The compiler cannot check whether
7966 the operands have data types that are reasonable for the instruction being
7967 executed. For output expressions that are not directly addressable (for
7968 example a bit-field), the constraint must allow a register. In that case, GCC
7969 uses the register as the output of the @code{asm}, and then stores that
7970 register into the output.
7972 Operands using the @samp{+} constraint modifier count as two operands
7973 (that is, both as input and output) towards the total maximum of 30 operands
7974 per @code{asm} statement.
7976 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
7977 operands that must not overlap an input. Otherwise,
7978 GCC may allocate the output operand in the same register as an unrelated
7979 input operand, on the assumption that the assembler code consumes its
7980 inputs before producing outputs. This assumption may be false if the assembler
7981 code actually consists of more than one instruction.
7983 The same problem can occur if one output parameter (@var{a}) allows a register
7984 constraint and another output parameter (@var{b}) allows a memory constraint.
7985 The code generated by GCC to access the memory address in @var{b} can contain
7986 registers which @emph{might} be shared by @var{a}, and GCC considers those
7987 registers to be inputs to the asm. As above, GCC assumes that such input
7988 registers are consumed before any outputs are written. This assumption may
7989 result in incorrect behavior if the asm writes to @var{a} before using
7990 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
7991 ensures that modifying @var{a} does not affect the address referenced by
7992 @var{b}. Otherwise, the location of @var{b}
7993 is undefined if @var{a} is modified before using @var{b}.
7995 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
7996 instead of simply @samp{%2}). Typically these qualifiers are hardware
7997 dependent. The list of supported modifiers for x86 is found at
7998 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8000 If the C code that follows the @code{asm} makes no use of any of the output
8001 operands, use @code{volatile} for the @code{asm} statement to prevent the
8002 optimizers from discarding the @code{asm} statement as unneeded
8003 (see @ref{Volatile}).
8005 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
8006 references the first output operand as @code{%0} (were there a second, it
8007 would be @code{%1}, etc). The number of the first input operand is one greater
8008 than that of the last output operand. In this i386 example, that makes
8009 @code{Mask} referenced as @code{%1}:
8012 uint32_t Mask = 1234;
8021 That code overwrites the variable @code{Index} (@samp{=}),
8022 placing the value in a register (@samp{r}).
8023 Using the generic @samp{r} constraint instead of a constraint for a specific
8024 register allows the compiler to pick the register to use, which can result
8025 in more efficient code. This may not be possible if an assembler instruction
8026 requires a specific register.
8028 The following i386 example uses the @var{asmSymbolicName} syntax.
8030 same result as the code above, but some may consider it more readable or more
8031 maintainable since reordering index numbers is not necessary when adding or
8032 removing operands. The names @code{aIndex} and @code{aMask}
8033 are only used in this example to emphasize which
8034 names get used where.
8035 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8038 uint32_t Mask = 1234;
8041 asm ("bsfl %[aMask], %[aIndex]"
8042 : [aIndex] "=r" (Index)
8043 : [aMask] "r" (Mask)
8047 Here are some more examples of output operands.
8054 asm ("mov %[e], %[d]"
8059 Here, @code{d} may either be in a register or in memory. Since the compiler
8060 might already have the current value of the @code{uint32_t} location
8061 pointed to by @code{e}
8062 in a register, you can enable it to choose the best location
8063 for @code{d} by specifying both constraints.
8065 @anchor{FlagOutputOperands}
8066 @subsubsection Flag Output Operands
8067 @cindex @code{asm} flag output operands
8069 Some targets have a special register that holds the ``flags'' for the
8070 result of an operation or comparison. Normally, the contents of that
8071 register are either unmodifed by the asm, or the asm is considered to
8072 clobber the contents.
8074 On some targets, a special form of output operand exists by which
8075 conditions in the flags register may be outputs of the asm. The set of
8076 conditions supported are target specific, but the general rule is that
8077 the output variable must be a scalar integer, and the value is boolean.
8078 When supported, the target defines the preprocessor symbol
8079 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8081 Because of the special nature of the flag output operands, the constraint
8082 may not include alternatives.
8084 Most often, the target has only one flags register, and thus is an implied
8085 operand of many instructions. In this case, the operand should not be
8086 referenced within the assembler template via @code{%0} etc, as there's
8087 no corresponding text in the assembly language.
8091 The flag output constraints for the x86 family are of the form
8092 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8093 conditions defined in the ISA manual for @code{j@var{cc}} or
8098 ``above'' or unsigned greater than
8100 ``above or equal'' or unsigned greater than or equal
8102 ``below'' or unsigned less than
8104 ``below or equal'' or unsigned less than or equal
8109 ``equal'' or zero flag set
8113 signed greater than or equal
8117 signed less than or equal
8138 ``not'' @var{flag}, or inverted versions of those above
8143 @anchor{InputOperands}
8144 @subsubsection Input Operands
8145 @cindex @code{asm} input operands
8146 @cindex @code{asm} expressions
8148 Input operands make values from C variables and expressions available to the
8151 Operands are separated by commas. Each operand has this format:
8154 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8158 @item asmSymbolicName
8159 Specifies a symbolic name for the operand.
8160 Reference the name in the assembler template
8161 by enclosing it in square brackets
8162 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8163 that contains the definition. Any valid C variable name is acceptable,
8164 including names already defined in the surrounding code. No two operands
8165 within the same @code{asm} statement can use the same symbolic name.
8167 When not using an @var{asmSymbolicName}, use the (zero-based) position
8169 in the list of operands in the assembler template. For example if there are
8170 two output operands and three inputs,
8171 use @samp{%2} in the template to refer to the first input operand,
8172 @samp{%3} for the second, and @samp{%4} for the third.
8175 A string constant specifying constraints on the placement of the operand;
8176 @xref{Constraints}, for details.
8178 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8179 When you list more than one possible location (for example, @samp{"irm"}),
8180 the compiler chooses the most efficient one based on the current context.
8181 If you must use a specific register, but your Machine Constraints do not
8182 provide sufficient control to select the specific register you want,
8183 local register variables may provide a solution (@pxref{Local Register
8186 Input constraints can also be digits (for example, @code{"0"}). This indicates
8187 that the specified input must be in the same place as the output constraint
8188 at the (zero-based) index in the output constraint list.
8189 When using @var{asmSymbolicName} syntax for the output operands,
8190 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8193 This is the C variable or expression being passed to the @code{asm} statement
8194 as input. The enclosing parentheses are a required part of the syntax.
8198 When the compiler selects the registers to use to represent the input
8199 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8201 If there are no output operands but there are input operands, place two
8202 consecutive colons where the output operands would go:
8205 __asm__ ("some instructions"
8207 : "r" (Offset / 8));
8210 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8211 (except for inputs tied to outputs). The compiler assumes that on exit from
8212 the @code{asm} statement these operands contain the same values as they
8213 had before executing the statement.
8214 It is @emph{not} possible to use clobbers
8215 to inform the compiler that the values in these inputs are changing. One
8216 common work-around is to tie the changing input variable to an output variable
8217 that never gets used. Note, however, that if the code that follows the
8218 @code{asm} statement makes no use of any of the output operands, the GCC
8219 optimizers may discard the @code{asm} statement as unneeded
8220 (see @ref{Volatile}).
8222 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8223 instead of simply @samp{%2}). Typically these qualifiers are hardware
8224 dependent. The list of supported modifiers for x86 is found at
8225 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8227 In this example using the fictitious @code{combine} instruction, the
8228 constraint @code{"0"} for input operand 1 says that it must occupy the same
8229 location as output operand 0. Only input operands may use numbers in
8230 constraints, and they must each refer to an output operand. Only a number (or
8231 the symbolic assembler name) in the constraint can guarantee that one operand
8232 is in the same place as another. The mere fact that @code{foo} is the value of
8233 both operands is not enough to guarantee that they are in the same place in
8234 the generated assembler code.
8237 asm ("combine %2, %0"
8239 : "0" (foo), "g" (bar));
8242 Here is an example using symbolic names.
8245 asm ("cmoveq %1, %2, %[result]"
8246 : [result] "=r"(result)
8247 : "r" (test), "r" (new), "[result]" (old));
8251 @subsubsection Clobbers
8252 @cindex @code{asm} clobbers
8254 While the compiler is aware of changes to entries listed in the output
8255 operands, the inline @code{asm} code may modify more than just the outputs. For
8256 example, calculations may require additional registers, or the processor may
8257 overwrite a register as a side effect of a particular assembler instruction.
8258 In order to inform the compiler of these changes, list them in the clobber
8259 list. Clobber list items are either register names or the special clobbers
8260 (listed below). Each clobber list item is a string constant
8261 enclosed in double quotes and separated by commas.
8263 Clobber descriptions may not in any way overlap with an input or output
8264 operand. For example, you may not have an operand describing a register class
8265 with one member when listing that register in the clobber list. Variables
8266 declared to live in specific registers (@pxref{Explicit Register
8267 Variables}) and used
8268 as @code{asm} input or output operands must have no part mentioned in the
8269 clobber description. In particular, there is no way to specify that input
8270 operands get modified without also specifying them as output operands.
8272 When the compiler selects which registers to use to represent input and output
8273 operands, it does not use any of the clobbered registers. As a result,
8274 clobbered registers are available for any use in the assembler code.
8276 Here is a realistic example for the VAX showing the use of clobbered
8280 asm volatile ("movc3 %0, %1, %2"
8282 : "g" (from), "g" (to), "g" (count)
8283 : "r0", "r1", "r2", "r3", "r4", "r5");
8286 Also, there are two special clobber arguments:
8290 The @code{"cc"} clobber indicates that the assembler code modifies the flags
8291 register. On some machines, GCC represents the condition codes as a specific
8292 hardware register; @code{"cc"} serves to name this register.
8293 On other machines, condition code handling is different,
8294 and specifying @code{"cc"} has no effect. But
8295 it is valid no matter what the target.
8298 The @code{"memory"} clobber tells the compiler that the assembly code
8300 reads or writes to items other than those listed in the input and output
8301 operands (for example, accessing the memory pointed to by one of the input
8302 parameters). To ensure memory contains correct values, GCC may need to flush
8303 specific register values to memory before executing the @code{asm}. Further,
8304 the compiler does not assume that any values read from memory before an
8305 @code{asm} remain unchanged after that @code{asm}; it reloads them as
8307 Using the @code{"memory"} clobber effectively forms a read/write
8308 memory barrier for the compiler.
8310 Note that this clobber does not prevent the @emph{processor} from doing
8311 speculative reads past the @code{asm} statement. To prevent that, you need
8312 processor-specific fence instructions.
8314 Flushing registers to memory has performance implications and may be an issue
8315 for time-sensitive code. You can use a trick to avoid this if the size of
8316 the memory being accessed is known at compile time. For example, if accessing
8317 ten bytes of a string, use a memory input like:
8319 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8324 @subsubsection Goto Labels
8325 @cindex @code{asm} goto labels
8327 @code{asm goto} allows assembly code to jump to one or more C labels. The
8328 @var{GotoLabels} section in an @code{asm goto} statement contains
8330 list of all C labels to which the assembler code may jump. GCC assumes that
8331 @code{asm} execution falls through to the next statement (if this is not the
8332 case, consider using the @code{__builtin_unreachable} intrinsic after the
8333 @code{asm} statement). Optimization of @code{asm goto} may be improved by
8334 using the @code{hot} and @code{cold} label attributes (@pxref{Label
8337 An @code{asm goto} statement cannot have outputs.
8338 This is due to an internal restriction of
8339 the compiler: control transfer instructions cannot have outputs.
8340 If the assembler code does modify anything, use the @code{"memory"} clobber
8342 optimizers to flush all register values to memory and reload them if
8343 necessary after the @code{asm} statement.
8345 Also note that an @code{asm goto} statement is always implicitly
8346 considered volatile.
8348 To reference a label in the assembler template,
8349 prefix it with @samp{%l} (lowercase @samp{L}) followed
8350 by its (zero-based) position in @var{GotoLabels} plus the number of input
8351 operands. For example, if the @code{asm} has three inputs and references two
8352 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8354 Alternately, you can reference labels using the actual C label name enclosed
8355 in brackets. For example, to reference a label named @code{carry}, you can
8356 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
8357 section when using this approach.
8359 Here is an example of @code{asm goto} for i386:
8366 : "r" (p1), "r" (p2)
8376 The following example shows an @code{asm goto} that uses a memory clobber.
8382 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8393 @anchor{x86Operandmodifiers}
8394 @subsubsection x86 Operand Modifiers
8396 References to input, output, and goto operands in the assembler template
8397 of extended @code{asm} statements can use
8398 modifiers to affect the way the operands are formatted in
8399 the code output to the assembler. For example, the
8400 following code uses the @samp{h} and @samp{b} modifiers for x86:
8404 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8408 These modifiers generate this assembler code:
8414 The rest of this discussion uses the following code for illustrative purposes.
8423 asm volatile goto ("some assembler instructions here"
8425 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8426 : /* No clobbers. */
8431 With no modifiers, this is what the output from the operands would be for the
8432 @samp{att} and @samp{intel} dialects of assembler:
8434 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
8435 @headitem Operand @tab masm=att @tab masm=intel
8444 @tab @code{OFFSET FLAT:.L2}
8447 The table below shows the list of supported modifiers and their effects.
8449 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
8450 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
8452 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8457 @tab Print the QImode name of the register.
8462 @tab Print the QImode name for a ``high'' register.
8467 @tab Print the HImode name of the register.
8472 @tab Print the SImode name of the register.
8477 @tab Print the DImode name of the register.
8482 @tab Print the label name with no punctuation.
8487 @tab Require a constant operand and print the constant expression with no punctuation.
8493 @anchor{x86floatingpointasmoperands}
8494 @subsubsection x86 Floating-Point @code{asm} Operands
8496 On x86 targets, there are several rules on the usage of stack-like registers
8497 in the operands of an @code{asm}. These rules apply only to the operands
8498 that are stack-like registers:
8502 Given a set of input registers that die in an @code{asm}, it is
8503 necessary to know which are implicitly popped by the @code{asm}, and
8504 which must be explicitly popped by GCC@.
8506 An input register that is implicitly popped by the @code{asm} must be
8507 explicitly clobbered, unless it is constrained to match an
8511 For any input register that is implicitly popped by an @code{asm}, it is
8512 necessary to know how to adjust the stack to compensate for the pop.
8513 If any non-popped input is closer to the top of the reg-stack than
8514 the implicitly popped register, it would not be possible to know what the
8515 stack looked like---it's not clear how the rest of the stack ``slides
8518 All implicitly popped input registers must be closer to the top of
8519 the reg-stack than any input that is not implicitly popped.
8521 It is possible that if an input dies in an @code{asm}, the compiler might
8522 use the input register for an output reload. Consider this example:
8525 asm ("foo" : "=t" (a) : "f" (b));
8529 This code says that input @code{b} is not popped by the @code{asm}, and that
8530 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8531 deeper after the @code{asm} than it was before. But, it is possible that
8532 reload may think that it can use the same register for both the input and
8535 To prevent this from happening,
8536 if any input operand uses the @samp{f} constraint, all output register
8537 constraints must use the @samp{&} early-clobber modifier.
8539 The example above is correctly written as:
8542 asm ("foo" : "=&t" (a) : "f" (b));
8546 Some operands need to be in particular places on the stack. All
8547 output operands fall in this category---GCC has no other way to
8548 know which registers the outputs appear in unless you indicate
8549 this in the constraints.
8551 Output operands must specifically indicate which register an output
8552 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
8553 constraints must select a class with a single register.
8556 Output operands may not be ``inserted'' between existing stack registers.
8557 Since no 387 opcode uses a read/write operand, all output operands
8558 are dead before the @code{asm}, and are pushed by the @code{asm}.
8559 It makes no sense to push anywhere but the top of the reg-stack.
8561 Output operands must start at the top of the reg-stack: output
8562 operands may not ``skip'' a register.
8565 Some @code{asm} statements may need extra stack space for internal
8566 calculations. This can be guaranteed by clobbering stack registers
8567 unrelated to the inputs and outputs.
8572 takes one input, which is internally popped, and produces two outputs.
8575 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8579 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8580 and replaces them with one output. The @code{st(1)} clobber is necessary
8581 for the compiler to know that @code{fyl2xp1} pops both inputs.
8584 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8592 @subsection Controlling Names Used in Assembler Code
8593 @cindex assembler names for identifiers
8594 @cindex names used in assembler code
8595 @cindex identifiers, names in assembler code
8597 You can specify the name to be used in the assembler code for a C
8598 function or variable by writing the @code{asm} (or @code{__asm__})
8599 keyword after the declarator.
8600 It is up to you to make sure that the assembler names you choose do not
8601 conflict with any other assembler symbols, or reference registers.
8603 @subsubheading Assembler names for data:
8605 This sample shows how to specify the assembler name for data:
8608 int foo asm ("myfoo") = 2;
8612 This specifies that the name to be used for the variable @code{foo} in
8613 the assembler code should be @samp{myfoo} rather than the usual
8616 On systems where an underscore is normally prepended to the name of a C
8617 variable, this feature allows you to define names for the
8618 linker that do not start with an underscore.
8620 GCC does not support using this feature with a non-static local variable
8621 since such variables do not have assembler names. If you are
8622 trying to put the variable in a particular register, see
8623 @ref{Explicit Register Variables}.
8625 @subsubheading Assembler names for functions:
8627 To specify the assembler name for functions, write a declaration for the
8628 function before its definition and put @code{asm} there, like this:
8631 int func (int x, int y) asm ("MYFUNC");
8633 int func (int x, int y)
8639 This specifies that the name to be used for the function @code{func} in
8640 the assembler code should be @code{MYFUNC}.
8642 @node Explicit Register Variables
8643 @subsection Variables in Specified Registers
8644 @anchor{Explicit Reg Vars}
8645 @cindex explicit register variables
8646 @cindex variables in specified registers
8647 @cindex specified registers
8649 GNU C allows you to associate specific hardware registers with C
8650 variables. In almost all cases, allowing the compiler to assign
8651 registers produces the best code. However under certain unusual
8652 circumstances, more precise control over the variable storage is
8655 Both global and local variables can be associated with a register. The
8656 consequences of performing this association are very different between
8657 the two, as explained in the sections below.
8660 * Global Register Variables:: Variables declared at global scope.
8661 * Local Register Variables:: Variables declared within a function.
8664 @node Global Register Variables
8665 @subsubsection Defining Global Register Variables
8666 @anchor{Global Reg Vars}
8667 @cindex global register variables
8668 @cindex registers, global variables in
8669 @cindex registers, global allocation
8671 You can define a global register variable and associate it with a specified
8675 register int *foo asm ("r12");
8679 Here @code{r12} is the name of the register that should be used. Note that
8680 this is the same syntax used for defining local register variables, but for
8681 a global variable the declaration appears outside a function. The
8682 @code{register} keyword is required, and cannot be combined with
8683 @code{static}. The register name must be a valid register name for the
8686 Registers are a scarce resource on most systems and allowing the
8687 compiler to manage their usage usually results in the best code. However,
8688 under special circumstances it can make sense to reserve some globally.
8689 For example this may be useful in programs such as programming language
8690 interpreters that have a couple of global variables that are accessed
8693 After defining a global register variable, for the current compilation
8697 @item The register is reserved entirely for this use, and will not be
8698 allocated for any other purpose.
8699 @item The register is not saved and restored by any functions.
8700 @item Stores into this register are never deleted even if they appear to be
8701 dead, but references may be deleted, moved or simplified.
8704 Note that these points @emph{only} apply to code that is compiled with the
8705 definition. The behavior of code that is merely linked in (for example
8706 code from libraries) is not affected.
8708 If you want to recompile source files that do not actually use your global
8709 register variable so they do not use the specified register for any other
8710 purpose, you need not actually add the global register declaration to
8711 their source code. It suffices to specify the compiler option
8712 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
8715 @subsubheading Declaring the variable
8717 Global register variables can not have initial values, because an
8718 executable file has no means to supply initial contents for a register.
8720 When selecting a register, choose one that is normally saved and
8721 restored by function calls on your machine. This ensures that code
8722 which is unaware of this reservation (such as library routines) will
8723 restore it before returning.
8725 On machines with register windows, be sure to choose a global
8726 register that is not affected magically by the function call mechanism.
8728 @subsubheading Using the variable
8730 @cindex @code{qsort}, and global register variables
8731 When calling routines that are not aware of the reservation, be
8732 cautious if those routines call back into code which uses them. As an
8733 example, if you call the system library version of @code{qsort}, it may
8734 clobber your registers during execution, but (if you have selected
8735 appropriate registers) it will restore them before returning. However
8736 it will @emph{not} restore them before calling @code{qsort}'s comparison
8737 function. As a result, global values will not reliably be available to
8738 the comparison function unless the @code{qsort} function itself is rebuilt.
8740 Similarly, it is not safe to access the global register variables from signal
8741 handlers or from more than one thread of control. Unless you recompile
8742 them specially for the task at hand, the system library routines may
8743 temporarily use the register for other things.
8745 @cindex register variable after @code{longjmp}
8746 @cindex global register after @code{longjmp}
8747 @cindex value after @code{longjmp}
8750 On most machines, @code{longjmp} restores to each global register
8751 variable the value it had at the time of the @code{setjmp}. On some
8752 machines, however, @code{longjmp} does not change the value of global
8753 register variables. To be portable, the function that called @code{setjmp}
8754 should make other arrangements to save the values of the global register
8755 variables, and to restore them in a @code{longjmp}. This way, the same
8756 thing happens regardless of what @code{longjmp} does.
8758 Eventually there may be a way of asking the compiler to choose a register
8759 automatically, but first we need to figure out how it should choose and
8760 how to enable you to guide the choice. No solution is evident.
8762 @node Local Register Variables
8763 @subsubsection Specifying Registers for Local Variables
8764 @anchor{Local Reg Vars}
8765 @cindex local variables, specifying registers
8766 @cindex specifying registers for local variables
8767 @cindex registers for local variables
8769 You can define a local register variable and associate it with a specified
8773 register int *foo asm ("r12");
8777 Here @code{r12} is the name of the register that should be used. Note
8778 that this is the same syntax used for defining global register variables,
8779 but for a local variable the declaration appears within a function. The
8780 @code{register} keyword is required, and cannot be combined with
8781 @code{static}. The register name must be a valid register name for the
8784 As with global register variables, it is recommended that you choose
8785 a register that is normally saved and restored by function calls on your
8786 machine, so that calls to library routines will not clobber it.
8788 The only supported use for this feature is to specify registers
8789 for input and output operands when calling Extended @code{asm}
8790 (@pxref{Extended Asm}). This may be necessary if the constraints for a
8791 particular machine don't provide sufficient control to select the desired
8792 register. To force an operand into a register, create a local variable
8793 and specify the register name after the variable's declaration. Then use
8794 the local variable for the @code{asm} operand and specify any constraint
8795 letter that matches the register:
8798 register int *p1 asm ("r0") = @dots{};
8799 register int *p2 asm ("r1") = @dots{};
8800 register int *result asm ("r0");
8801 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8804 @emph{Warning:} In the above example, be aware that a register (for example
8805 @code{r0}) can be call-clobbered by subsequent code, including function
8806 calls and library calls for arithmetic operators on other variables (for
8807 example the initialization of @code{p2}). In this case, use temporary
8808 variables for expressions between the register assignments:
8812 register int *p1 asm ("r0") = @dots{};
8813 register int *p2 asm ("r1") = t1;
8814 register int *result asm ("r0");
8815 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8818 Defining a register variable does not reserve the register. Other than
8819 when invoking the Extended @code{asm}, the contents of the specified
8820 register are not guaranteed. For this reason, the following uses
8821 are explicitly @emph{not} supported. If they appear to work, it is only
8822 happenstance, and may stop working as intended due to (seemingly)
8823 unrelated changes in surrounding code, or even minor changes in the
8824 optimization of a future version of gcc:
8827 @item Passing parameters to or from Basic @code{asm}
8828 @item Passing parameters to or from Extended @code{asm} without using input
8830 @item Passing parameters to or from routines written in assembler (or
8831 other languages) using non-standard calling conventions.
8834 Some developers use Local Register Variables in an attempt to improve
8835 gcc's allocation of registers, especially in large functions. In this
8836 case the register name is essentially a hint to the register allocator.
8837 While in some instances this can generate better code, improvements are
8838 subject to the whims of the allocator/optimizers. Since there are no
8839 guarantees that your improvements won't be lost, this usage of Local
8840 Register Variables is discouraged.
8842 On the MIPS platform, there is related use for local register variables
8843 with slightly different characteristics (@pxref{MIPS Coprocessors,,
8844 Defining coprocessor specifics for MIPS targets, gccint,
8845 GNU Compiler Collection (GCC) Internals}).
8847 @node Size of an asm
8848 @subsection Size of an @code{asm}
8850 Some targets require that GCC track the size of each instruction used
8851 in order to generate correct code. Because the final length of the
8852 code produced by an @code{asm} statement is only known by the
8853 assembler, GCC must make an estimate as to how big it will be. It
8854 does this by counting the number of instructions in the pattern of the
8855 @code{asm} and multiplying that by the length of the longest
8856 instruction supported by that processor. (When working out the number
8857 of instructions, it assumes that any occurrence of a newline or of
8858 whatever statement separator character is supported by the assembler --
8859 typically @samp{;} --- indicates the end of an instruction.)
8861 Normally, GCC's estimate is adequate to ensure that correct
8862 code is generated, but it is possible to confuse the compiler if you use
8863 pseudo instructions or assembler macros that expand into multiple real
8864 instructions, or if you use assembler directives that expand to more
8865 space in the object file than is needed for a single instruction.
8866 If this happens then the assembler may produce a diagnostic saying that
8867 a label is unreachable.
8869 @node Alternate Keywords
8870 @section Alternate Keywords
8871 @cindex alternate keywords
8872 @cindex keywords, alternate
8874 @option{-ansi} and the various @option{-std} options disable certain
8875 keywords. This causes trouble when you want to use GNU C extensions, or
8876 a general-purpose header file that should be usable by all programs,
8877 including ISO C programs. The keywords @code{asm}, @code{typeof} and
8878 @code{inline} are not available in programs compiled with
8879 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
8880 program compiled with @option{-std=c99} or @option{-std=c11}). The
8882 @code{restrict} is only available when @option{-std=gnu99} (which will
8883 eventually be the default) or @option{-std=c99} (or the equivalent
8884 @option{-std=iso9899:1999}), or an option for a later standard
8887 The way to solve these problems is to put @samp{__} at the beginning and
8888 end of each problematical keyword. For example, use @code{__asm__}
8889 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
8891 Other C compilers won't accept these alternative keywords; if you want to
8892 compile with another compiler, you can define the alternate keywords as
8893 macros to replace them with the customary keywords. It looks like this:
8901 @findex __extension__
8903 @option{-pedantic} and other options cause warnings for many GNU C extensions.
8905 prevent such warnings within one expression by writing
8906 @code{__extension__} before the expression. @code{__extension__} has no
8907 effect aside from this.
8909 @node Incomplete Enums
8910 @section Incomplete @code{enum} Types
8912 You can define an @code{enum} tag without specifying its possible values.
8913 This results in an incomplete type, much like what you get if you write
8914 @code{struct foo} without describing the elements. A later declaration
8915 that does specify the possible values completes the type.
8917 You can't allocate variables or storage using the type while it is
8918 incomplete. However, you can work with pointers to that type.
8920 This extension may not be very useful, but it makes the handling of
8921 @code{enum} more consistent with the way @code{struct} and @code{union}
8924 This extension is not supported by GNU C++.
8926 @node Function Names
8927 @section Function Names as Strings
8928 @cindex @code{__func__} identifier
8929 @cindex @code{__FUNCTION__} identifier
8930 @cindex @code{__PRETTY_FUNCTION__} identifier
8932 GCC provides three magic variables that hold the name of the current
8933 function, as a string. The first of these is @code{__func__}, which
8934 is part of the C99 standard:
8936 The identifier @code{__func__} is implicitly declared by the translator
8937 as if, immediately following the opening brace of each function
8938 definition, the declaration
8941 static const char __func__[] = "function-name";
8945 appeared, where function-name is the name of the lexically-enclosing
8946 function. This name is the unadorned name of the function.
8948 @code{__FUNCTION__} is another name for @code{__func__}, provided for
8949 backward compatibility with old versions of GCC.
8951 In C, @code{__PRETTY_FUNCTION__} is yet another name for
8952 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
8953 the type signature of the function as well as its bare name. For
8954 example, this program:
8958 extern int printf (char *, ...);
8965 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
8966 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
8984 __PRETTY_FUNCTION__ = void a::sub(int)
8987 These identifiers are variables, not preprocessor macros, and may not
8988 be used to initialize @code{char} arrays or be concatenated with other string
8991 @node Return Address
8992 @section Getting the Return or Frame Address of a Function
8994 These functions may be used to get information about the callers of a
8997 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
8998 This function returns the return address of the current function, or of
8999 one of its callers. The @var{level} argument is number of frames to
9000 scan up the call stack. A value of @code{0} yields the return address
9001 of the current function, a value of @code{1} yields the return address
9002 of the caller of the current function, and so forth. When inlining
9003 the expected behavior is that the function returns the address of
9004 the function that is returned to. To work around this behavior use
9005 the @code{noinline} function attribute.
9007 The @var{level} argument must be a constant integer.
9009 On some machines it may be impossible to determine the return address of
9010 any function other than the current one; in such cases, or when the top
9011 of the stack has been reached, this function returns @code{0} or a
9012 random value. In addition, @code{__builtin_frame_address} may be used
9013 to determine if the top of the stack has been reached.
9015 Additional post-processing of the returned value may be needed, see
9016 @code{__builtin_extract_return_addr}.
9018 Calling this function with a nonzero argument can have unpredictable
9019 effects, including crashing the calling program. As a result, calls
9020 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9021 option is in effect. Such calls should only be made in debugging
9025 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9026 The address as returned by @code{__builtin_return_address} may have to be fed
9027 through this function to get the actual encoded address. For example, on the
9028 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9029 platforms an offset has to be added for the true next instruction to be
9032 If no fixup is needed, this function simply passes through @var{addr}.
9035 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9036 This function does the reverse of @code{__builtin_extract_return_addr}.
9039 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9040 This function is similar to @code{__builtin_return_address}, but it
9041 returns the address of the function frame rather than the return address
9042 of the function. Calling @code{__builtin_frame_address} with a value of
9043 @code{0} yields the frame address of the current function, a value of
9044 @code{1} yields the frame address of the caller of the current function,
9047 The frame is the area on the stack that holds local variables and saved
9048 registers. The frame address is normally the address of the first word
9049 pushed on to the stack by the function. However, the exact definition
9050 depends upon the processor and the calling convention. If the processor
9051 has a dedicated frame pointer register, and the function has a frame,
9052 then @code{__builtin_frame_address} returns the value of the frame
9055 On some machines it may be impossible to determine the frame address of
9056 any function other than the current one; in such cases, or when the top
9057 of the stack has been reached, this function returns @code{0} if
9058 the first frame pointer is properly initialized by the startup code.
9060 Calling this function with a nonzero argument can have unpredictable
9061 effects, including crashing the calling program. As a result, calls
9062 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9063 option is in effect. Such calls should only be made in debugging
9067 @node Vector Extensions
9068 @section Using Vector Instructions through Built-in Functions
9070 On some targets, the instruction set contains SIMD vector instructions which
9071 operate on multiple values contained in one large register at the same time.
9072 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9075 The first step in using these extensions is to provide the necessary data
9076 types. This should be done using an appropriate @code{typedef}:
9079 typedef int v4si __attribute__ ((vector_size (16)));
9083 The @code{int} type specifies the base type, while the attribute specifies
9084 the vector size for the variable, measured in bytes. For example, the
9085 declaration above causes the compiler to set the mode for the @code{v4si}
9086 type to be 16 bytes wide and divided into @code{int} sized units. For
9087 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9088 corresponding mode of @code{foo} is @acronym{V4SI}.
9090 The @code{vector_size} attribute is only applicable to integral and
9091 float scalars, although arrays, pointers, and function return values
9092 are allowed in conjunction with this construct. Only sizes that are
9093 a power of two are currently allowed.
9095 All the basic integer types can be used as base types, both as signed
9096 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9097 @code{long long}. In addition, @code{float} and @code{double} can be
9098 used to build floating-point vector types.
9100 Specifying a combination that is not valid for the current architecture
9101 causes GCC to synthesize the instructions using a narrower mode.
9102 For example, if you specify a variable of type @code{V4SI} and your
9103 architecture does not allow for this specific SIMD type, GCC
9104 produces code that uses 4 @code{SIs}.
9106 The types defined in this manner can be used with a subset of normal C
9107 operations. Currently, GCC allows using the following operators
9108 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9110 The operations behave like C++ @code{valarrays}. Addition is defined as
9111 the addition of the corresponding elements of the operands. For
9112 example, in the code below, each of the 4 elements in @var{a} is
9113 added to the corresponding 4 elements in @var{b} and the resulting
9114 vector is stored in @var{c}.
9117 typedef int v4si __attribute__ ((vector_size (16)));
9124 Subtraction, multiplication, division, and the logical operations
9125 operate in a similar manner. Likewise, the result of using the unary
9126 minus or complement operators on a vector type is a vector whose
9127 elements are the negative or complemented values of the corresponding
9128 elements in the operand.
9130 It is possible to use shifting operators @code{<<}, @code{>>} on
9131 integer-type vectors. The operation is defined as following: @code{@{a0,
9132 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9133 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9136 For convenience, it is allowed to use a binary vector operation
9137 where one operand is a scalar. In that case the compiler transforms
9138 the scalar operand into a vector where each element is the scalar from
9139 the operation. The transformation happens only if the scalar could be
9140 safely converted to the vector-element type.
9141 Consider the following code.
9144 typedef int v4si __attribute__ ((vector_size (16)));
9149 a = b + 1; /* a = b + @{1,1,1,1@}; */
9150 a = 2 * b; /* a = @{2,2,2,2@} * b; */
9152 a = l + a; /* Error, cannot convert long to int. */
9155 Vectors can be subscripted as if the vector were an array with
9156 the same number of elements and base type. Out of bound accesses
9157 invoke undefined behavior at run time. Warnings for out of bound
9158 accesses for vector subscription can be enabled with
9159 @option{-Warray-bounds}.
9161 Vector comparison is supported with standard comparison
9162 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9163 vector expressions of integer-type or real-type. Comparison between
9164 integer-type vectors and real-type vectors are not supported. The
9165 result of the comparison is a vector of the same width and number of
9166 elements as the comparison operands with a signed integral element
9169 Vectors are compared element-wise producing 0 when comparison is false
9170 and -1 (constant of the appropriate type where all bits are set)
9171 otherwise. Consider the following example.
9174 typedef int v4si __attribute__ ((vector_size (16)));
9176 v4si a = @{1,2,3,4@};
9177 v4si b = @{3,2,1,4@};
9180 c = a > b; /* The result would be @{0, 0,-1, 0@} */
9181 c = a == b; /* The result would be @{0,-1, 0,-1@} */
9184 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9185 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9186 integer vector with the same number of elements of the same size as @code{b}
9187 and @code{c}, computes all three arguments and creates a vector
9188 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
9189 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9190 As in the case of binary operations, this syntax is also accepted when
9191 one of @code{b} or @code{c} is a scalar that is then transformed into a
9192 vector. If both @code{b} and @code{c} are scalars and the type of
9193 @code{true?b:c} has the same size as the element type of @code{a}, then
9194 @code{b} and @code{c} are converted to a vector type whose elements have
9195 this type and with the same number of elements as @code{a}.
9197 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9198 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9199 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9200 For mixed operations between a scalar @code{s} and a vector @code{v},
9201 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9202 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9204 Vector shuffling is available using functions
9205 @code{__builtin_shuffle (vec, mask)} and
9206 @code{__builtin_shuffle (vec0, vec1, mask)}.
9207 Both functions construct a permutation of elements from one or two
9208 vectors and return a vector of the same type as the input vector(s).
9209 The @var{mask} is an integral vector with the same width (@var{W})
9210 and element count (@var{N}) as the output vector.
9212 The elements of the input vectors are numbered in memory ordering of
9213 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
9214 elements of @var{mask} are considered modulo @var{N} in the single-operand
9215 case and modulo @math{2*@var{N}} in the two-operand case.
9217 Consider the following example,
9220 typedef int v4si __attribute__ ((vector_size (16)));
9222 v4si a = @{1,2,3,4@};
9223 v4si b = @{5,6,7,8@};
9224 v4si mask1 = @{0,1,1,3@};
9225 v4si mask2 = @{0,4,2,5@};
9228 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
9229 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
9232 Note that @code{__builtin_shuffle} is intentionally semantically
9233 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9235 You can declare variables and use them in function calls and returns, as
9236 well as in assignments and some casts. You can specify a vector type as
9237 a return type for a function. Vector types can also be used as function
9238 arguments. It is possible to cast from one vector type to another,
9239 provided they are of the same size (in fact, you can also cast vectors
9240 to and from other datatypes of the same size).
9242 You cannot operate between vectors of different lengths or different
9243 signedness without a cast.
9246 @section Support for @code{offsetof}
9247 @findex __builtin_offsetof
9249 GCC implements for both C and C++ a syntactic extension to implement
9250 the @code{offsetof} macro.
9254 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9256 offsetof_member_designator:
9258 | offsetof_member_designator "." @code{identifier}
9259 | offsetof_member_designator "[" @code{expr} "]"
9262 This extension is sufficient such that
9265 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
9269 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
9270 may be dependent. In either case, @var{member} may consist of a single
9271 identifier, or a sequence of member accesses and array references.
9273 @node __sync Builtins
9274 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9276 The following built-in functions
9277 are intended to be compatible with those described
9278 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9279 section 7.4. As such, they depart from normal GCC practice by not using
9280 the @samp{__builtin_} prefix and also by being overloaded so that they
9281 work on multiple types.
9283 The definition given in the Intel documentation allows only for the use of
9284 the types @code{int}, @code{long}, @code{long long} or their unsigned
9285 counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
9286 size other than the C type @code{_Bool} or the C++ type @code{bool}.
9287 Operations on pointer arguments are performed as if the operands were
9288 of the @code{uintptr_t} type. That is, they are not scaled by the size
9289 of the type to which the pointer points.
9291 These functions are implemented in terms of the @samp{__atomic}
9292 builtins (@pxref{__atomic Builtins}). They should not be used for new
9293 code which should use the @samp{__atomic} builtins instead.
9295 Not all operations are supported by all target processors. If a particular
9296 operation cannot be implemented on the target processor, a warning is
9297 generated and a call to an external function is generated. The external
9298 function carries the same name as the built-in version,
9299 with an additional suffix
9300 @samp{_@var{n}} where @var{n} is the size of the data type.
9302 @c ??? Should we have a mechanism to suppress this warning? This is almost
9303 @c useful for implementing the operation under the control of an external
9306 In most cases, these built-in functions are considered a @dfn{full barrier}.
9308 no memory operand is moved across the operation, either forward or
9309 backward. Further, instructions are issued as necessary to prevent the
9310 processor from speculating loads across the operation and from queuing stores
9311 after the operation.
9313 All of the routines are described in the Intel documentation to take
9314 ``an optional list of variables protected by the memory barrier''. It's
9315 not clear what is meant by that; it could mean that @emph{only} the
9316 listed variables are protected, or it could mean a list of additional
9317 variables to be protected. The list is ignored by GCC which treats it as
9318 empty. GCC interprets an empty list as meaning that all globally
9319 accessible variables should be protected.
9322 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9323 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9324 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9325 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9326 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9327 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9328 @findex __sync_fetch_and_add
9329 @findex __sync_fetch_and_sub
9330 @findex __sync_fetch_and_or
9331 @findex __sync_fetch_and_and
9332 @findex __sync_fetch_and_xor
9333 @findex __sync_fetch_and_nand
9334 These built-in functions perform the operation suggested by the name, and
9335 returns the value that had previously been in memory. That is, operations
9336 on integer operands have the following semantics. Operations on pointer
9337 arguments are performed as if the operands were of the @code{uintptr_t}
9338 type. That is, they are not scaled by the size of the type to which
9342 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9343 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
9346 The object pointed to by the first argument must be of integer or pointer
9347 type. It must not be a Boolean type.
9349 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9350 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9352 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9353 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9354 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9355 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9356 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9357 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9358 @findex __sync_add_and_fetch
9359 @findex __sync_sub_and_fetch
9360 @findex __sync_or_and_fetch
9361 @findex __sync_and_and_fetch
9362 @findex __sync_xor_and_fetch
9363 @findex __sync_nand_and_fetch
9364 These built-in functions perform the operation suggested by the name, and
9365 return the new value. That is, operations on integer operands have
9366 the following semantics. Operations on pointer operands are performed as
9367 if the operand's type were @code{uintptr_t}.
9370 @{ *ptr @var{op}= value; return *ptr; @}
9371 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
9374 The same constraints on arguments apply as for the corresponding
9375 @code{__sync_op_and_fetch} built-in functions.
9377 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9378 as @code{*ptr = ~(*ptr & value)} instead of
9379 @code{*ptr = ~*ptr & value}.
9381 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9382 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9383 @findex __sync_bool_compare_and_swap
9384 @findex __sync_val_compare_and_swap
9385 These built-in functions perform an atomic compare and swap.
9386 That is, if the current
9387 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9390 The ``bool'' version returns true if the comparison is successful and
9391 @var{newval} is written. The ``val'' version returns the contents
9392 of @code{*@var{ptr}} before the operation.
9394 @item __sync_synchronize (...)
9395 @findex __sync_synchronize
9396 This built-in function issues a full memory barrier.
9398 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9399 @findex __sync_lock_test_and_set
9400 This built-in function, as described by Intel, is not a traditional test-and-set
9401 operation, but rather an atomic exchange operation. It writes @var{value}
9402 into @code{*@var{ptr}}, and returns the previous contents of
9405 Many targets have only minimal support for such locks, and do not support
9406 a full exchange operation. In this case, a target may support reduced
9407 functionality here by which the @emph{only} valid value to store is the
9408 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
9409 is implementation defined.
9411 This built-in function is not a full barrier,
9412 but rather an @dfn{acquire barrier}.
9413 This means that references after the operation cannot move to (or be
9414 speculated to) before the operation, but previous memory stores may not
9415 be globally visible yet, and previous memory loads may not yet be
9418 @item void __sync_lock_release (@var{type} *ptr, ...)
9419 @findex __sync_lock_release
9420 This built-in function releases the lock acquired by
9421 @code{__sync_lock_test_and_set}.
9422 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9424 This built-in function is not a full barrier,
9425 but rather a @dfn{release barrier}.
9426 This means that all previous memory stores are globally visible, and all
9427 previous memory loads have been satisfied, but following memory reads
9428 are not prevented from being speculated to before the barrier.
9431 @node __atomic Builtins
9432 @section Built-in Functions for Memory Model Aware Atomic Operations
9434 The following built-in functions approximately match the requirements
9435 for the C++11 memory model. They are all
9436 identified by being prefixed with @samp{__atomic} and most are
9437 overloaded so that they work with multiple types.
9439 These functions are intended to replace the legacy @samp{__sync}
9440 builtins. The main difference is that the memory order that is requested
9441 is a parameter to the functions. New code should always use the
9442 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9444 Note that the @samp{__atomic} builtins assume that programs will
9445 conform to the C++11 memory model. In particular, they assume
9446 that programs are free of data races. See the C++11 standard for
9447 detailed requirements.
9449 The @samp{__atomic} builtins can be used with any integral scalar or
9450 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
9451 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9452 supported by the architecture.
9454 The four non-arithmetic functions (load, store, exchange, and
9455 compare_exchange) all have a generic version as well. This generic
9456 version works on any data type. It uses the lock-free built-in function
9457 if the specific data type size makes that possible; otherwise, an
9458 external call is left to be resolved at run time. This external call is
9459 the same format with the addition of a @samp{size_t} parameter inserted
9460 as the first parameter indicating the size of the object being pointed to.
9461 All objects must be the same size.
9463 There are 6 different memory orders that can be specified. These map
9464 to the C++11 memory orders with the same names, see the C++11 standard
9465 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9466 on atomic synchronization} for detailed definitions. Individual
9467 targets may also support additional memory orders for use on specific
9468 architectures. Refer to the target documentation for details of
9471 An atomic operation can both constrain code motion and
9472 be mapped to hardware instructions for synchronization between threads
9473 (e.g., a fence). To which extent this happens is controlled by the
9474 memory orders, which are listed here in approximately ascending order of
9475 strength. The description of each memory order is only meant to roughly
9476 illustrate the effects and is not a specification; see the C++11
9477 memory model for precise semantics.
9480 @item __ATOMIC_RELAXED
9481 Implies no inter-thread ordering constraints.
9482 @item __ATOMIC_CONSUME
9483 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9484 memory order because of a deficiency in C++11's semantics for
9485 @code{memory_order_consume}.
9486 @item __ATOMIC_ACQUIRE
9487 Creates an inter-thread happens-before constraint from the release (or
9488 stronger) semantic store to this acquire load. Can prevent hoisting
9489 of code to before the operation.
9490 @item __ATOMIC_RELEASE
9491 Creates an inter-thread happens-before constraint to acquire (or stronger)
9492 semantic loads that read from this release store. Can prevent sinking
9493 of code to after the operation.
9494 @item __ATOMIC_ACQ_REL
9495 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9496 @code{__ATOMIC_RELEASE}.
9497 @item __ATOMIC_SEQ_CST
9498 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9501 Note that in the C++11 memory model, @emph{fences} (e.g.,
9502 @samp{__atomic_thread_fence}) take effect in combination with other
9503 atomic operations on specific memory locations (e.g., atomic loads);
9504 operations on specific memory locations do not necessarily affect other
9505 operations in the same way.
9507 Target architectures are encouraged to provide their own patterns for
9508 each of the atomic built-in functions. If no target is provided, the original
9509 non-memory model set of @samp{__sync} atomic built-in functions are
9510 used, along with any required synchronization fences surrounding it in
9511 order to achieve the proper behavior. Execution in this case is subject
9512 to the same restrictions as those built-in functions.
9514 If there is no pattern or mechanism to provide a lock-free instruction
9515 sequence, a call is made to an external routine with the same parameters
9516 to be resolved at run time.
9518 When implementing patterns for these built-in functions, the memory order
9519 parameter can be ignored as long as the pattern implements the most
9520 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
9521 orders execute correctly with this memory order but they may not execute as
9522 efficiently as they could with a more appropriate implementation of the
9523 relaxed requirements.
9525 Note that the C++11 standard allows for the memory order parameter to be
9526 determined at run time rather than at compile time. These built-in
9527 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9528 than invoke a runtime library call or inline a switch statement. This is
9529 standard compliant, safe, and the simplest approach for now.
9531 The memory order parameter is a signed int, but only the lower 16 bits are
9532 reserved for the memory order. The remainder of the signed int is reserved
9533 for target use and should be 0. Use of the predefined atomic values
9534 ensures proper usage.
9536 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9537 This built-in function implements an atomic load operation. It returns the
9538 contents of @code{*@var{ptr}}.
9540 The valid memory order variants are
9541 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9542 and @code{__ATOMIC_CONSUME}.
9546 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9547 This is the generic version of an atomic load. It returns the
9548 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9552 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9553 This built-in function implements an atomic store operation. It writes
9554 @code{@var{val}} into @code{*@var{ptr}}.
9556 The valid memory order variants are
9557 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9561 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9562 This is the generic version of an atomic store. It stores the value
9563 of @code{*@var{val}} into @code{*@var{ptr}}.
9567 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9568 This built-in function implements an atomic exchange operation. It writes
9569 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9572 The valid memory order variants are
9573 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9574 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9578 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9579 This is the generic version of an atomic exchange. It stores the
9580 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9581 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9585 @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)
9586 This built-in function implements an atomic compare and exchange operation.
9587 This compares the contents of @code{*@var{ptr}} with the contents of
9588 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9589 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
9590 equal, the operation is a @emph{read} and the current contents of
9591 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is true
9592 for weak compare_exchange, which may fail spuriously, and false for
9593 the strong variation, which never fails spuriously. Many targets
9594 only offer the strong variation and ignore the parameter. When in doubt, use
9595 the strong variation.
9597 If @var{desired} is written into @code{*@var{ptr}} then true is returned
9598 and memory is affected according to the
9599 memory order specified by @var{success_memorder}. There are no
9600 restrictions on what memory order can be used here.
9602 Otherwise, false is returned and memory is affected according
9603 to @var{failure_memorder}. This memory order cannot be
9604 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
9605 stronger order than that specified by @var{success_memorder}.
9609 @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)
9610 This built-in function implements the generic version of
9611 @code{__atomic_compare_exchange}. The function is virtually identical to
9612 @code{__atomic_compare_exchange_n}, except the desired value is also a
9617 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9618 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9619 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9620 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9621 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9622 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9623 These built-in functions perform the operation suggested by the name, and
9624 return the result of the operation. Operations on pointer arguments are
9625 performed as if the operands were of the @code{uintptr_t} type. That is,
9626 they are not scaled by the size of the type to which the pointer points.
9629 @{ *ptr @var{op}= val; return *ptr; @}
9632 The object pointed to by the first argument must be of integer or pointer
9633 type. It must not be a Boolean type. All memory orders are valid.
9637 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9638 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9639 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9640 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9641 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9642 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9643 These built-in functions perform the operation suggested by the name, and
9644 return the value that had previously been in @code{*@var{ptr}}. Operations
9645 on pointer arguments are performed as if the operands were of
9646 the @code{uintptr_t} type. That is, they are not scaled by the size of
9647 the type to which the pointer points.
9650 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9653 The same constraints on arguments apply as for the corresponding
9654 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
9658 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9660 This built-in function performs an atomic test-and-set operation on
9661 the byte at @code{*@var{ptr}}. The byte is set to some implementation
9662 defined nonzero ``set'' value and the return value is @code{true} if and only
9663 if the previous contents were ``set''.
9664 It should be only used for operands of type @code{bool} or @code{char}. For
9665 other types only part of the value may be set.
9667 All memory orders are valid.
9671 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9673 This built-in function performs an atomic clear operation on
9674 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
9675 It should be only used for operands of type @code{bool} or @code{char} and
9676 in conjunction with @code{__atomic_test_and_set}.
9677 For other types it may only clear partially. If the type is not @code{bool}
9678 prefer using @code{__atomic_store}.
9680 The valid memory order variants are
9681 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9682 @code{__ATOMIC_RELEASE}.
9686 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9688 This built-in function acts as a synchronization fence between threads
9689 based on the specified memory order.
9691 All memory orders are valid.
9695 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9697 This built-in function acts as a synchronization fence between a thread
9698 and signal handlers based in the same thread.
9700 All memory orders are valid.
9704 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
9706 This built-in function returns true if objects of @var{size} bytes always
9707 generate lock-free atomic instructions for the target architecture.
9708 @var{size} must resolve to a compile-time constant and the result also
9709 resolves to a compile-time constant.
9711 @var{ptr} is an optional pointer to the object that may be used to determine
9712 alignment. A value of 0 indicates typical alignment should be used. The
9713 compiler may also ignore this parameter.
9716 if (__atomic_always_lock_free (sizeof (long long), 0))
9721 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9723 This built-in function returns true if objects of @var{size} bytes always
9724 generate lock-free atomic instructions for the target architecture. If
9725 the built-in function is not known to be lock-free, a call is made to a
9726 runtime routine named @code{__atomic_is_lock_free}.
9728 @var{ptr} is an optional pointer to the object that may be used to determine
9729 alignment. A value of 0 indicates typical alignment should be used. The
9730 compiler may also ignore this parameter.
9733 @node Integer Overflow Builtins
9734 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9736 The following built-in functions allow performing simple arithmetic operations
9737 together with checking whether the operations overflowed.
9739 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9740 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9741 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9742 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
9743 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9744 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9745 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9747 These built-in functions promote the first two operands into infinite precision signed
9748 type and perform addition on those promoted operands. The result is then
9749 cast to the type the third pointer argument points to and stored there.
9750 If the stored result is equal to the infinite precision result, the built-in
9751 functions return false, otherwise they return true. As the addition is
9752 performed in infinite signed precision, these built-in functions have fully defined
9753 behavior for all argument values.
9755 The first built-in function allows arbitrary integral types for operands and
9756 the result type must be pointer to some integer type, the rest of the built-in
9757 functions have explicit integer types.
9759 The compiler will attempt to use hardware instructions to implement
9760 these built-in functions where possible, like conditional jump on overflow
9761 after addition, conditional jump on carry etc.
9765 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9766 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9767 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9768 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
9769 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9770 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9771 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9773 These built-in functions are similar to the add overflow checking built-in
9774 functions above, except they perform subtraction, subtract the second argument
9775 from the first one, instead of addition.
9779 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9780 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9781 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9782 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
9783 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9784 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9785 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9787 These built-in functions are similar to the add overflow checking built-in
9788 functions above, except they perform multiplication, instead of addition.
9792 @node x86 specific memory model extensions for transactional memory
9793 @section x86-Specific Memory Model Extensions for Transactional Memory
9795 The x86 architecture supports additional memory ordering flags
9796 to mark lock critical sections for hardware lock elision.
9797 These must be specified in addition to an existing memory order to
9801 @item __ATOMIC_HLE_ACQUIRE
9802 Start lock elision on a lock variable.
9803 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
9804 @item __ATOMIC_HLE_RELEASE
9805 End lock elision on a lock variable.
9806 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
9809 When a lock acquire fails, it is required for good performance to abort
9810 the transaction quickly. This can be done with a @code{_mm_pause}.
9813 #include <immintrin.h> // For _mm_pause
9817 /* Acquire lock with lock elision */
9818 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
9819 _mm_pause(); /* Abort failed transaction */
9821 /* Free lock with lock elision */
9822 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
9825 @node Object Size Checking
9826 @section Object Size Checking Built-in Functions
9827 @findex __builtin_object_size
9828 @findex __builtin___memcpy_chk
9829 @findex __builtin___mempcpy_chk
9830 @findex __builtin___memmove_chk
9831 @findex __builtin___memset_chk
9832 @findex __builtin___strcpy_chk
9833 @findex __builtin___stpcpy_chk
9834 @findex __builtin___strncpy_chk
9835 @findex __builtin___strcat_chk
9836 @findex __builtin___strncat_chk
9837 @findex __builtin___sprintf_chk
9838 @findex __builtin___snprintf_chk
9839 @findex __builtin___vsprintf_chk
9840 @findex __builtin___vsnprintf_chk
9841 @findex __builtin___printf_chk
9842 @findex __builtin___vprintf_chk
9843 @findex __builtin___fprintf_chk
9844 @findex __builtin___vfprintf_chk
9846 GCC implements a limited buffer overflow protection mechanism
9847 that can prevent some buffer overflow attacks.
9849 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
9850 is a built-in construct that returns a constant number of bytes from
9851 @var{ptr} to the end of the object @var{ptr} pointer points to
9852 (if known at compile time). @code{__builtin_object_size} never evaluates
9853 its arguments for side-effects. If there are any side-effects in them, it
9854 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9855 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
9856 point to and all of them are known at compile time, the returned number
9857 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
9858 0 and minimum if nonzero. If it is not possible to determine which objects
9859 @var{ptr} points to at compile time, @code{__builtin_object_size} should
9860 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9861 for @var{type} 2 or 3.
9863 @var{type} is an integer constant from 0 to 3. If the least significant
9864 bit is clear, objects are whole variables, if it is set, a closest
9865 surrounding subobject is considered the object a pointer points to.
9866 The second bit determines if maximum or minimum of remaining bytes
9870 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
9871 char *p = &var.buf1[1], *q = &var.b;
9873 /* Here the object p points to is var. */
9874 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
9875 /* The subobject p points to is var.buf1. */
9876 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
9877 /* The object q points to is var. */
9878 assert (__builtin_object_size (q, 0)
9879 == (char *) (&var + 1) - (char *) &var.b);
9880 /* The subobject q points to is var.b. */
9881 assert (__builtin_object_size (q, 1) == sizeof (var.b));
9885 There are built-in functions added for many common string operation
9886 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
9887 built-in is provided. This built-in has an additional last argument,
9888 which is the number of bytes remaining in object the @var{dest}
9889 argument points to or @code{(size_t) -1} if the size is not known.
9891 The built-in functions are optimized into the normal string functions
9892 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
9893 it is known at compile time that the destination object will not
9894 be overflown. If the compiler can determine at compile time the
9895 object will be always overflown, it issues a warning.
9897 The intended use can be e.g.@:
9901 #define bos0(dest) __builtin_object_size (dest, 0)
9902 #define memcpy(dest, src, n) \
9903 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
9907 /* It is unknown what object p points to, so this is optimized
9908 into plain memcpy - no checking is possible. */
9909 memcpy (p, "abcde", n);
9910 /* Destination is known and length too. It is known at compile
9911 time there will be no overflow. */
9912 memcpy (&buf[5], "abcde", 5);
9913 /* Destination is known, but the length is not known at compile time.
9914 This will result in __memcpy_chk call that can check for overflow
9916 memcpy (&buf[5], "abcde", n);
9917 /* Destination is known and it is known at compile time there will
9918 be overflow. There will be a warning and __memcpy_chk call that
9919 will abort the program at run time. */
9920 memcpy (&buf[6], "abcde", 5);
9923 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
9924 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
9925 @code{strcat} and @code{strncat}.
9927 There are also checking built-in functions for formatted output functions.
9929 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
9930 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9931 const char *fmt, ...);
9932 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
9934 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9935 const char *fmt, va_list ap);
9938 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
9939 etc.@: functions and can contain implementation specific flags on what
9940 additional security measures the checking function might take, such as
9941 handling @code{%n} differently.
9943 The @var{os} argument is the object size @var{s} points to, like in the
9944 other built-in functions. There is a small difference in the behavior
9945 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
9946 optimized into the non-checking functions only if @var{flag} is 0, otherwise
9947 the checking function is called with @var{os} argument set to
9950 In addition to this, there are checking built-in functions
9951 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
9952 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
9953 These have just one additional argument, @var{flag}, right before
9954 format string @var{fmt}. If the compiler is able to optimize them to
9955 @code{fputc} etc.@: functions, it does, otherwise the checking function
9956 is called and the @var{flag} argument passed to it.
9958 @node Pointer Bounds Checker builtins
9959 @section Pointer Bounds Checker Built-in Functions
9960 @cindex Pointer Bounds Checker builtins
9961 @findex __builtin___bnd_set_ptr_bounds
9962 @findex __builtin___bnd_narrow_ptr_bounds
9963 @findex __builtin___bnd_copy_ptr_bounds
9964 @findex __builtin___bnd_init_ptr_bounds
9965 @findex __builtin___bnd_null_ptr_bounds
9966 @findex __builtin___bnd_store_ptr_bounds
9967 @findex __builtin___bnd_chk_ptr_lbounds
9968 @findex __builtin___bnd_chk_ptr_ubounds
9969 @findex __builtin___bnd_chk_ptr_bounds
9970 @findex __builtin___bnd_get_ptr_lbound
9971 @findex __builtin___bnd_get_ptr_ubound
9973 GCC provides a set of built-in functions to control Pointer Bounds Checker
9974 instrumentation. Note that all Pointer Bounds Checker builtins can be used
9975 even if you compile with Pointer Bounds Checker off
9976 (@option{-fno-check-pointer-bounds}).
9977 The behavior may differ in such case as documented below.
9979 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
9981 This built-in function returns a new pointer with the value of @var{q}, and
9982 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
9983 Bounds Checker off, the built-in function just returns the first argument.
9986 extern void *__wrap_malloc (size_t n)
9988 void *p = (void *)__real_malloc (n);
9989 if (!p) return __builtin___bnd_null_ptr_bounds (p);
9990 return __builtin___bnd_set_ptr_bounds (p, n);
9996 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
9998 This built-in function returns a new pointer with the value of @var{p}
9999 and associates it with the narrowed bounds formed by the intersection
10000 of bounds associated with @var{q} and the bounds
10001 [@var{p}, @var{p} + @var{size} - 1].
10002 With Pointer Bounds Checker off, the built-in function just returns the first
10006 void init_objects (object *objs, size_t size)
10009 /* Initialize objects one-by-one passing pointers with bounds of
10010 an object, not the full array of objects. */
10011 for (i = 0; i < size; i++)
10012 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10019 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10021 This built-in function returns a new pointer with the value of @var{q},
10022 and associates it with the bounds already associated with pointer @var{r}.
10023 With Pointer Bounds Checker off, the built-in function just returns the first
10027 /* Here is a way to get pointer to object's field but
10028 still with the full object's bounds. */
10029 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
10035 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10037 This built-in function returns a new pointer with the value of @var{q}, and
10038 associates it with INIT (allowing full memory access) bounds. With Pointer
10039 Bounds Checker off, the built-in function just returns the first argument.
10043 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10045 This built-in function returns a new pointer with the value of @var{q}, and
10046 associates it with NULL (allowing no memory access) bounds. With Pointer
10047 Bounds Checker off, the built-in function just returns the first argument.
10051 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10053 This built-in function stores the bounds associated with pointer @var{ptr_val}
10054 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
10055 bounds from legacy code without touching the associated pointer's memory when
10056 pointers are copied as integers. With Pointer Bounds Checker off, the built-in
10057 function call is ignored.
10061 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10063 This built-in function checks if the pointer @var{q} is within the lower
10064 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10065 function call is ignored.
10068 extern void *__wrap_memset (void *dst, int c, size_t len)
10072 __builtin___bnd_chk_ptr_lbounds (dst);
10073 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10074 __real_memset (dst, c, len);
10082 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10084 This built-in function checks if the pointer @var{q} is within the upper
10085 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10086 function call is ignored.
10090 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10092 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10093 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
10094 off, the built-in function call is ignored.
10097 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10101 __bnd_chk_ptr_bounds (dst, n);
10102 __bnd_chk_ptr_bounds (src, n);
10103 __real_memcpy (dst, src, n);
10111 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10113 This built-in function returns the lower bound associated
10114 with the pointer @var{q}, as a pointer value.
10115 This is useful for debugging using @code{printf}.
10116 With Pointer Bounds Checker off, the built-in function returns 0.
10119 void *lb = __builtin___bnd_get_ptr_lbound (q);
10120 void *ub = __builtin___bnd_get_ptr_ubound (q);
10121 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
10126 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10128 This built-in function returns the upper bound (which is a pointer) associated
10129 with the pointer @var{q}. With Pointer Bounds Checker off,
10130 the built-in function returns -1.
10134 @node Cilk Plus Builtins
10135 @section Cilk Plus C/C++ Language Extension Built-in Functions
10137 GCC provides support for the following built-in reduction functions if Cilk Plus
10138 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10141 @item @code{__sec_implicit_index}
10142 @item @code{__sec_reduce}
10143 @item @code{__sec_reduce_add}
10144 @item @code{__sec_reduce_all_nonzero}
10145 @item @code{__sec_reduce_all_zero}
10146 @item @code{__sec_reduce_any_nonzero}
10147 @item @code{__sec_reduce_any_zero}
10148 @item @code{__sec_reduce_max}
10149 @item @code{__sec_reduce_min}
10150 @item @code{__sec_reduce_max_ind}
10151 @item @code{__sec_reduce_min_ind}
10152 @item @code{__sec_reduce_mul}
10153 @item @code{__sec_reduce_mutating}
10156 Further details and examples about these built-in functions are described
10157 in the Cilk Plus language manual which can be found at
10158 @uref{http://www.cilkplus.org}.
10160 @node Other Builtins
10161 @section Other Built-in Functions Provided by GCC
10162 @cindex built-in functions
10163 @findex __builtin_alloca
10164 @findex __builtin_alloca_with_align
10165 @findex __builtin_call_with_static_chain
10166 @findex __builtin_fpclassify
10167 @findex __builtin_isfinite
10168 @findex __builtin_isnormal
10169 @findex __builtin_isgreater
10170 @findex __builtin_isgreaterequal
10171 @findex __builtin_isinf_sign
10172 @findex __builtin_isless
10173 @findex __builtin_islessequal
10174 @findex __builtin_islessgreater
10175 @findex __builtin_isunordered
10176 @findex __builtin_powi
10177 @findex __builtin_powif
10178 @findex __builtin_powil
10339 @findex fprintf_unlocked
10341 @findex fputs_unlocked
10449 @findex nexttowardf
10450 @findex nexttowardl
10458 @findex printf_unlocked
10488 @findex signbitd128
10489 @findex significand
10490 @findex significandf
10491 @findex significandl
10519 @findex strncasecmp
10562 GCC provides a large number of built-in functions other than the ones
10563 mentioned above. Some of these are for internal use in the processing
10564 of exceptions or variable-length argument lists and are not
10565 documented here because they may change from time to time; we do not
10566 recommend general use of these functions.
10568 The remaining functions are provided for optimization purposes.
10570 With the exception of built-ins that have library equivalents such as
10571 the standard C library functions discussed below, or that expand to
10572 library calls, GCC built-in functions are always expanded inline and
10573 thus do not have corresponding entry points and their address cannot
10574 be obtained. Attempting to use them in an expression other than
10575 a function call results in a compile-time error.
10577 @opindex fno-builtin
10578 GCC includes built-in versions of many of the functions in the standard
10579 C library. These functions come in two forms: one whose names start with
10580 the @code{__builtin_} prefix, and the other without. Both forms have the
10581 same type (including prototype), the same address (when their address is
10582 taken), and the same meaning as the C library functions even if you specify
10583 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
10584 functions are only optimized in certain cases; if they are not optimized in
10585 a particular case, a call to the library function is emitted.
10589 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10590 @option{-std=c99} or @option{-std=c11}), the functions
10591 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10592 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10593 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10594 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10595 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10596 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10597 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10598 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10599 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10600 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10601 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10602 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10603 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10604 @code{significandl}, @code{significand}, @code{sincosf},
10605 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10606 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10607 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10608 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10610 may be handled as built-in functions.
10611 All these functions have corresponding versions
10612 prefixed with @code{__builtin_}, which may be used even in strict C90
10615 The ISO C99 functions
10616 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10617 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10618 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10619 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10620 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10621 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10622 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10623 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10624 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10625 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10626 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10627 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10628 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10629 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10630 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10631 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10632 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10633 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10634 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10635 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10636 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10637 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10638 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10639 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10640 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10641 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10642 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10643 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10644 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10645 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10646 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10647 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10648 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10649 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10650 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10651 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10652 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10653 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10654 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10655 are handled as built-in functions
10656 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10658 There are also built-in versions of the ISO C99 functions
10659 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10660 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10661 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10662 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10663 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10664 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10665 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10666 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10667 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10668 that are recognized in any mode since ISO C90 reserves these names for
10669 the purpose to which ISO C99 puts them. All these functions have
10670 corresponding versions prefixed with @code{__builtin_}.
10672 There are also GNU extension functions @code{clog10}, @code{clog10f} and
10673 @code{clog10l} which names are reserved by ISO C99 for future use.
10674 All these functions have versions prefixed with @code{__builtin_}.
10676 The ISO C94 functions
10677 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10678 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10679 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10681 are handled as built-in functions
10682 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10684 The ISO C90 functions
10685 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10686 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10687 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10688 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10689 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10690 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10691 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10692 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10693 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10694 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10695 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10696 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10697 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10698 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10699 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10700 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10701 are all recognized as built-in functions unless
10702 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10703 is specified for an individual function). All of these functions have
10704 corresponding versions prefixed with @code{__builtin_}.
10706 GCC provides built-in versions of the ISO C99 floating-point comparison
10707 macros that avoid raising exceptions for unordered operands. They have
10708 the same names as the standard macros ( @code{isgreater},
10709 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10710 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10711 prefixed. We intend for a library implementor to be able to simply
10712 @code{#define} each standard macro to its built-in equivalent.
10713 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10714 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
10715 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
10716 built-in functions appear both with and without the @code{__builtin_} prefix.
10718 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
10719 The @code{__builtin_alloca} function must be called at block scope.
10720 The function allocates an object @var{size} bytes large on the stack
10721 of the calling function. The object is aligned on the default stack
10722 alignment boundary for the target determined by the
10723 @code{__BIGGEST_ALIGNMENT__} macro. The @code{__builtin_alloca}
10724 function returns a pointer to the first byte of the allocated object.
10725 The lifetime of the allocated object ends just before the calling
10726 function returns to its caller. This is so even when
10727 @code{__builtin_alloca} is called within a nested block.
10729 For example, the following function allocates eight objects of @code{n}
10730 bytes each on the stack, storing a pointer to each in consecutive elements
10731 of the array @code{a}. It then passes the array to function @code{g}
10732 which can safely use the storage pointed to by each of the array elements.
10735 void f (unsigned n)
10738 for (int i = 0; i != 8; ++i)
10739 a [i] = __builtin_alloca (n);
10741 g (a, n); // @r{safe}
10745 Since the @code{__builtin_alloca} function doesn't validate its argument
10746 it is the responsibility of its caller to make sure the argument doesn't
10747 cause it to exceed the stack size limit.
10748 The @code{__builtin_alloca} function is provided to make it possible to
10749 allocate on the stack arrays of bytes with an upper bound that may be
10750 computed at run time. Since C99 Variable Length Arrays offer
10751 similar functionality under a portable, more convenient, and safer
10752 interface they are recommended instead, in both C99 and C++ programs
10753 where GCC provides them as an extension.
10754 @xref{Variable Length}, for details.
10758 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
10759 The @code{__builtin_alloca_with_align} function must be called at block
10760 scope. The function allocates an object @var{size} bytes large on
10761 the stack of the calling function. The allocated object is aligned on
10762 the boundary specified by the argument @var{alignment} whose unit is given
10763 in bits (not bytes). The @var{size} argument must be positive and not
10764 exceed the stack size limit. The @var{alignment} argument must be a constant
10765 integer expression that evaluates to a power of 2 greater than or equal to
10766 @code{CHAR_BIT} and less than some unspecified maximum. Invocations
10767 with other values are rejected with an error indicating the valid bounds.
10768 The function returns a pointer to the first byte of the allocated object.
10769 The lifetime of the allocated object ends at the end of the block in which
10770 the function was called. The allocated storage is released no later than
10771 just before the calling function returns to its caller, but may be released
10772 at the end of the block in which the function was called.
10774 For example, in the following function the call to @code{g} is unsafe
10775 because when @code{overalign} is non-zero, the space allocated by
10776 @code{__builtin_alloca_with_align} may have been released at the end
10777 of the @code{if} statement in which it was called.
10780 void f (unsigned n, bool overalign)
10784 p = __builtin_alloca_with_align (n, 64 /* bits */);
10786 p = __builtin_alloc (n);
10788 g (p, n); // @r{unsafe}
10792 Since the @code{__builtin_alloca_with_align} function doesn't validate its
10793 @var{size} argument it is the responsibility of its caller to make sure
10794 the argument doesn't cause it to exceed the stack size limit.
10795 The @code{__builtin_alloca_with_align} function is provided to make
10796 it possible to allocate on the stack overaligned arrays of bytes with
10797 an upper bound that may be computed at run time. Since C99
10798 Variable Length Arrays offer the same functionality under
10799 a portable, more convenient, and safer interface they are recommended
10800 instead, in both C99 and C++ programs where GCC provides them as
10801 an extension. @xref{Variable Length}, for details.
10805 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
10807 You can use the built-in function @code{__builtin_types_compatible_p} to
10808 determine whether two types are the same.
10810 This built-in function returns 1 if the unqualified versions of the
10811 types @var{type1} and @var{type2} (which are types, not expressions) are
10812 compatible, 0 otherwise. The result of this built-in function can be
10813 used in integer constant expressions.
10815 This built-in function ignores top level qualifiers (e.g., @code{const},
10816 @code{volatile}). For example, @code{int} is equivalent to @code{const
10819 The type @code{int[]} and @code{int[5]} are compatible. On the other
10820 hand, @code{int} and @code{char *} are not compatible, even if the size
10821 of their types, on the particular architecture are the same. Also, the
10822 amount of pointer indirection is taken into account when determining
10823 similarity. Consequently, @code{short *} is not similar to
10824 @code{short **}. Furthermore, two types that are typedefed are
10825 considered compatible if their underlying types are compatible.
10827 An @code{enum} type is not considered to be compatible with another
10828 @code{enum} type even if both are compatible with the same integer
10829 type; this is what the C standard specifies.
10830 For example, @code{enum @{foo, bar@}} is not similar to
10831 @code{enum @{hot, dog@}}.
10833 You typically use this function in code whose execution varies
10834 depending on the arguments' types. For example:
10839 typeof (x) tmp = (x); \
10840 if (__builtin_types_compatible_p (typeof (x), long double)) \
10841 tmp = foo_long_double (tmp); \
10842 else if (__builtin_types_compatible_p (typeof (x), double)) \
10843 tmp = foo_double (tmp); \
10844 else if (__builtin_types_compatible_p (typeof (x), float)) \
10845 tmp = foo_float (tmp); \
10852 @emph{Note:} This construct is only available for C@.
10856 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
10858 The @var{call_exp} expression must be a function call, and the
10859 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
10860 is passed to the function call in the target's static chain location.
10861 The result of builtin is the result of the function call.
10863 @emph{Note:} This builtin is only available for C@.
10864 This builtin can be used to call Go closures from C.
10868 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
10870 You can use the built-in function @code{__builtin_choose_expr} to
10871 evaluate code depending on the value of a constant expression. This
10872 built-in function returns @var{exp1} if @var{const_exp}, which is an
10873 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
10875 This built-in function is analogous to the @samp{? :} operator in C,
10876 except that the expression returned has its type unaltered by promotion
10877 rules. Also, the built-in function does not evaluate the expression
10878 that is not chosen. For example, if @var{const_exp} evaluates to true,
10879 @var{exp2} is not evaluated even if it has side-effects.
10881 This built-in function can return an lvalue if the chosen argument is an
10884 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
10885 type. Similarly, if @var{exp2} is returned, its return type is the same
10892 __builtin_choose_expr ( \
10893 __builtin_types_compatible_p (typeof (x), double), \
10895 __builtin_choose_expr ( \
10896 __builtin_types_compatible_p (typeof (x), float), \
10898 /* @r{The void expression results in a compile-time error} \
10899 @r{when assigning the result to something.} */ \
10903 @emph{Note:} This construct is only available for C@. Furthermore, the
10904 unused expression (@var{exp1} or @var{exp2} depending on the value of
10905 @var{const_exp}) may still generate syntax errors. This may change in
10910 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
10912 The built-in function @code{__builtin_complex} is provided for use in
10913 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
10914 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
10915 real binary floating-point type, and the result has the corresponding
10916 complex type with real and imaginary parts @var{real} and @var{imag}.
10917 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
10918 infinities, NaNs and negative zeros are involved.
10922 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
10923 You can use the built-in function @code{__builtin_constant_p} to
10924 determine if a value is known to be constant at compile time and hence
10925 that GCC can perform constant-folding on expressions involving that
10926 value. The argument of the function is the value to test. The function
10927 returns the integer 1 if the argument is known to be a compile-time
10928 constant and 0 if it is not known to be a compile-time constant. A
10929 return of 0 does not indicate that the value is @emph{not} a constant,
10930 but merely that GCC cannot prove it is a constant with the specified
10931 value of the @option{-O} option.
10933 You typically use this function in an embedded application where
10934 memory is a critical resource. If you have some complex calculation,
10935 you may want it to be folded if it involves constants, but need to call
10936 a function if it does not. For example:
10939 #define Scale_Value(X) \
10940 (__builtin_constant_p (X) \
10941 ? ((X) * SCALE + OFFSET) : Scale (X))
10944 You may use this built-in function in either a macro or an inline
10945 function. However, if you use it in an inlined function and pass an
10946 argument of the function as the argument to the built-in, GCC
10947 never returns 1 when you call the inline function with a string constant
10948 or compound literal (@pxref{Compound Literals}) and does not return 1
10949 when you pass a constant numeric value to the inline function unless you
10950 specify the @option{-O} option.
10952 You may also use @code{__builtin_constant_p} in initializers for static
10953 data. For instance, you can write
10956 static const int table[] = @{
10957 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
10963 This is an acceptable initializer even if @var{EXPRESSION} is not a
10964 constant expression, including the case where
10965 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
10966 folded to a constant but @var{EXPRESSION} contains operands that are
10967 not otherwise permitted in a static initializer (for example,
10968 @code{0 && foo ()}). GCC must be more conservative about evaluating the
10969 built-in in this case, because it has no opportunity to perform
10973 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
10974 @opindex fprofile-arcs
10975 You may use @code{__builtin_expect} to provide the compiler with
10976 branch prediction information. In general, you should prefer to
10977 use actual profile feedback for this (@option{-fprofile-arcs}), as
10978 programmers are notoriously bad at predicting how their programs
10979 actually perform. However, there are applications in which this
10980 data is hard to collect.
10982 The return value is the value of @var{exp}, which should be an integral
10983 expression. The semantics of the built-in are that it is expected that
10984 @var{exp} == @var{c}. For example:
10987 if (__builtin_expect (x, 0))
10992 indicates that we do not expect to call @code{foo}, since
10993 we expect @code{x} to be zero. Since you are limited to integral
10994 expressions for @var{exp}, you should use constructions such as
10997 if (__builtin_expect (ptr != NULL, 1))
11002 when testing pointer or floating-point values.
11005 @deftypefn {Built-in Function} void __builtin_trap (void)
11006 This function causes the program to exit abnormally. GCC implements
11007 this function by using a target-dependent mechanism (such as
11008 intentionally executing an illegal instruction) or by calling
11009 @code{abort}. The mechanism used may vary from release to release so
11010 you should not rely on any particular implementation.
11013 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11014 If control flow reaches the point of the @code{__builtin_unreachable},
11015 the program is undefined. It is useful in situations where the
11016 compiler cannot deduce the unreachability of the code.
11018 One such case is immediately following an @code{asm} statement that
11019 either never terminates, or one that transfers control elsewhere
11020 and never returns. In this example, without the
11021 @code{__builtin_unreachable}, GCC issues a warning that control
11022 reaches the end of a non-void function. It also generates code
11023 to return after the @code{asm}.
11026 int f (int c, int v)
11034 asm("jmp error_handler");
11035 __builtin_unreachable ();
11041 Because the @code{asm} statement unconditionally transfers control out
11042 of the function, control never reaches the end of the function
11043 body. The @code{__builtin_unreachable} is in fact unreachable and
11044 communicates this fact to the compiler.
11046 Another use for @code{__builtin_unreachable} is following a call a
11047 function that never returns but that is not declared
11048 @code{__attribute__((noreturn))}, as in this example:
11051 void function_that_never_returns (void);
11061 function_that_never_returns ();
11062 __builtin_unreachable ();
11069 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11070 This function returns its first argument, and allows the compiler
11071 to assume that the returned pointer is at least @var{align} bytes
11072 aligned. This built-in can have either two or three arguments,
11073 if it has three, the third argument should have integer type, and
11074 if it is nonzero means misalignment offset. For example:
11077 void *x = __builtin_assume_aligned (arg, 16);
11081 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11082 16-byte aligned, while:
11085 void *x = __builtin_assume_aligned (arg, 32, 8);
11089 means that the compiler can assume for @code{x}, set to @code{arg}, that
11090 @code{(char *) x - 8} is 32-byte aligned.
11093 @deftypefn {Built-in Function} int __builtin_LINE ()
11094 This function is the equivalent to the preprocessor @code{__LINE__}
11095 macro and returns the line number of the invocation of the built-in.
11096 In a C++ default argument for a function @var{F}, it gets the line number of
11097 the call to @var{F}.
11100 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11101 This function is the equivalent to the preprocessor @code{__FUNCTION__}
11102 macro and returns the function name the invocation of the built-in is in.
11105 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11106 This function is the equivalent to the preprocessor @code{__FILE__}
11107 macro and returns the file name the invocation of the built-in is in.
11108 In a C++ default argument for a function @var{F}, it gets the file name of
11109 the call to @var{F}.
11112 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11113 This function is used to flush the processor's instruction cache for
11114 the region of memory between @var{begin} inclusive and @var{end}
11115 exclusive. Some targets require that the instruction cache be
11116 flushed, after modifying memory containing code, in order to obtain
11117 deterministic behavior.
11119 If the target does not require instruction cache flushes,
11120 @code{__builtin___clear_cache} has no effect. Otherwise either
11121 instructions are emitted in-line to clear the instruction cache or a
11122 call to the @code{__clear_cache} function in libgcc is made.
11125 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11126 This function is used to minimize cache-miss latency by moving data into
11127 a cache before it is accessed.
11128 You can insert calls to @code{__builtin_prefetch} into code for which
11129 you know addresses of data in memory that is likely to be accessed soon.
11130 If the target supports them, data prefetch instructions are generated.
11131 If the prefetch is done early enough before the access then the data will
11132 be in the cache by the time it is accessed.
11134 The value of @var{addr} is the address of the memory to prefetch.
11135 There are two optional arguments, @var{rw} and @var{locality}.
11136 The value of @var{rw} is a compile-time constant one or zero; one
11137 means that the prefetch is preparing for a write to the memory address
11138 and zero, the default, means that the prefetch is preparing for a read.
11139 The value @var{locality} must be a compile-time constant integer between
11140 zero and three. A value of zero means that the data has no temporal
11141 locality, so it need not be left in the cache after the access. A value
11142 of three means that the data has a high degree of temporal locality and
11143 should be left in all levels of cache possible. Values of one and two
11144 mean, respectively, a low or moderate degree of temporal locality. The
11148 for (i = 0; i < n; i++)
11150 a[i] = a[i] + b[i];
11151 __builtin_prefetch (&a[i+j], 1, 1);
11152 __builtin_prefetch (&b[i+j], 0, 1);
11157 Data prefetch does not generate faults if @var{addr} is invalid, but
11158 the address expression itself must be valid. For example, a prefetch
11159 of @code{p->next} does not fault if @code{p->next} is not a valid
11160 address, but evaluation faults if @code{p} is not a valid address.
11162 If the target does not support data prefetch, the address expression
11163 is evaluated if it includes side effects but no other code is generated
11164 and GCC does not issue a warning.
11167 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11168 Returns a positive infinity, if supported by the floating-point format,
11169 else @code{DBL_MAX}. This function is suitable for implementing the
11170 ISO C macro @code{HUGE_VAL}.
11173 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11174 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11177 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11178 Similar to @code{__builtin_huge_val}, except the return
11179 type is @code{long double}.
11182 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11183 This built-in implements the C99 fpclassify functionality. The first
11184 five int arguments should be the target library's notion of the
11185 possible FP classes and are used for return values. They must be
11186 constant values and they must appear in this order: @code{FP_NAN},
11187 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11188 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
11189 to classify. GCC treats the last argument as type-generic, which
11190 means it does not do default promotion from float to double.
11193 @deftypefn {Built-in Function} double __builtin_inf (void)
11194 Similar to @code{__builtin_huge_val}, except a warning is generated
11195 if the target floating-point format does not support infinities.
11198 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11199 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11202 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11203 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11206 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11207 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11210 @deftypefn {Built-in Function} float __builtin_inff (void)
11211 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11212 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11215 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11216 Similar to @code{__builtin_inf}, except the return
11217 type is @code{long double}.
11220 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11221 Similar to @code{isinf}, except the return value is -1 for
11222 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11223 Note while the parameter list is an
11224 ellipsis, this function only accepts exactly one floating-point
11225 argument. GCC treats this parameter as type-generic, which means it
11226 does not do default promotion from float to double.
11229 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11230 This is an implementation of the ISO C99 function @code{nan}.
11232 Since ISO C99 defines this function in terms of @code{strtod}, which we
11233 do not implement, a description of the parsing is in order. The string
11234 is parsed as by @code{strtol}; that is, the base is recognized by
11235 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
11236 in the significand such that the least significant bit of the number
11237 is at the least significant bit of the significand. The number is
11238 truncated to fit the significand field provided. The significand is
11239 forced to be a quiet NaN@.
11241 This function, if given a string literal all of which would have been
11242 consumed by @code{strtol}, is evaluated early enough that it is considered a
11243 compile-time constant.
11246 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11247 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11250 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11251 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11254 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11255 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11258 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11259 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11262 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11263 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11266 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11267 Similar to @code{__builtin_nan}, except the significand is forced
11268 to be a signaling NaN@. The @code{nans} function is proposed by
11269 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11272 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11273 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11276 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11277 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11280 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11281 Returns one plus the index of the least significant 1-bit of @var{x}, or
11282 if @var{x} is zero, returns zero.
11285 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11286 Returns the number of leading 0-bits in @var{x}, starting at the most
11287 significant bit position. If @var{x} is 0, the result is undefined.
11290 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11291 Returns the number of trailing 0-bits in @var{x}, starting at the least
11292 significant bit position. If @var{x} is 0, the result is undefined.
11295 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11296 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11297 number of bits following the most significant bit that are identical
11298 to it. There are no special cases for 0 or other values.
11301 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11302 Returns the number of 1-bits in @var{x}.
11305 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11306 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11310 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11311 Similar to @code{__builtin_ffs}, except the argument type is
11315 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11316 Similar to @code{__builtin_clz}, except the argument type is
11317 @code{unsigned long}.
11320 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11321 Similar to @code{__builtin_ctz}, except the argument type is
11322 @code{unsigned long}.
11325 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11326 Similar to @code{__builtin_clrsb}, except the argument type is
11330 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11331 Similar to @code{__builtin_popcount}, except the argument type is
11332 @code{unsigned long}.
11335 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11336 Similar to @code{__builtin_parity}, except the argument type is
11337 @code{unsigned long}.
11340 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11341 Similar to @code{__builtin_ffs}, except the argument type is
11345 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11346 Similar to @code{__builtin_clz}, except the argument type is
11347 @code{unsigned long long}.
11350 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11351 Similar to @code{__builtin_ctz}, except the argument type is
11352 @code{unsigned long long}.
11355 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11356 Similar to @code{__builtin_clrsb}, except the argument type is
11360 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11361 Similar to @code{__builtin_popcount}, except the argument type is
11362 @code{unsigned long long}.
11365 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11366 Similar to @code{__builtin_parity}, except the argument type is
11367 @code{unsigned long long}.
11370 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11371 Returns the first argument raised to the power of the second. Unlike the
11372 @code{pow} function no guarantees about precision and rounding are made.
11375 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11376 Similar to @code{__builtin_powi}, except the argument and return types
11380 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11381 Similar to @code{__builtin_powi}, except the argument and return types
11382 are @code{long double}.
11385 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11386 Returns @var{x} with the order of the bytes reversed; for example,
11387 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
11391 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11392 Similar to @code{__builtin_bswap16}, except the argument and return types
11396 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11397 Similar to @code{__builtin_bswap32}, except the argument and return types
11401 @node Target Builtins
11402 @section Built-in Functions Specific to Particular Target Machines
11404 On some target machines, GCC supports many built-in functions specific
11405 to those machines. Generally these generate calls to specific machine
11406 instructions, but allow the compiler to schedule those calls.
11409 * AArch64 Built-in Functions::
11410 * Alpha Built-in Functions::
11411 * Altera Nios II Built-in Functions::
11412 * ARC Built-in Functions::
11413 * ARC SIMD Built-in Functions::
11414 * ARM iWMMXt Built-in Functions::
11415 * ARM C Language Extensions (ACLE)::
11416 * ARM Floating Point Status and Control Intrinsics::
11417 * AVR Built-in Functions::
11418 * Blackfin Built-in Functions::
11419 * FR-V Built-in Functions::
11420 * MIPS DSP Built-in Functions::
11421 * MIPS Paired-Single Support::
11422 * MIPS Loongson Built-in Functions::
11423 * Other MIPS Built-in Functions::
11424 * MSP430 Built-in Functions::
11425 * NDS32 Built-in Functions::
11426 * picoChip Built-in Functions::
11427 * PowerPC Built-in Functions::
11428 * PowerPC AltiVec/VSX Built-in Functions::
11429 * PowerPC Hardware Transactional Memory Built-in Functions::
11430 * RX Built-in Functions::
11431 * S/390 System z Built-in Functions::
11432 * SH Built-in Functions::
11433 * SPARC VIS Built-in Functions::
11434 * SPU Built-in Functions::
11435 * TI C6X Built-in Functions::
11436 * TILE-Gx Built-in Functions::
11437 * TILEPro Built-in Functions::
11438 * x86 Built-in Functions::
11439 * x86 transactional memory intrinsics::
11442 @node AArch64 Built-in Functions
11443 @subsection AArch64 Built-in Functions
11445 These built-in functions are available for the AArch64 family of
11448 unsigned int __builtin_aarch64_get_fpcr ()
11449 void __builtin_aarch64_set_fpcr (unsigned int)
11450 unsigned int __builtin_aarch64_get_fpsr ()
11451 void __builtin_aarch64_set_fpsr (unsigned int)
11454 @node Alpha Built-in Functions
11455 @subsection Alpha Built-in Functions
11457 These built-in functions are available for the Alpha family of
11458 processors, depending on the command-line switches used.
11460 The following built-in functions are always available. They
11461 all generate the machine instruction that is part of the name.
11464 long __builtin_alpha_implver (void)
11465 long __builtin_alpha_rpcc (void)
11466 long __builtin_alpha_amask (long)
11467 long __builtin_alpha_cmpbge (long, long)
11468 long __builtin_alpha_extbl (long, long)
11469 long __builtin_alpha_extwl (long, long)
11470 long __builtin_alpha_extll (long, long)
11471 long __builtin_alpha_extql (long, long)
11472 long __builtin_alpha_extwh (long, long)
11473 long __builtin_alpha_extlh (long, long)
11474 long __builtin_alpha_extqh (long, long)
11475 long __builtin_alpha_insbl (long, long)
11476 long __builtin_alpha_inswl (long, long)
11477 long __builtin_alpha_insll (long, long)
11478 long __builtin_alpha_insql (long, long)
11479 long __builtin_alpha_inswh (long, long)
11480 long __builtin_alpha_inslh (long, long)
11481 long __builtin_alpha_insqh (long, long)
11482 long __builtin_alpha_mskbl (long, long)
11483 long __builtin_alpha_mskwl (long, long)
11484 long __builtin_alpha_mskll (long, long)
11485 long __builtin_alpha_mskql (long, long)
11486 long __builtin_alpha_mskwh (long, long)
11487 long __builtin_alpha_msklh (long, long)
11488 long __builtin_alpha_mskqh (long, long)
11489 long __builtin_alpha_umulh (long, long)
11490 long __builtin_alpha_zap (long, long)
11491 long __builtin_alpha_zapnot (long, long)
11494 The following built-in functions are always with @option{-mmax}
11495 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11496 later. They all generate the machine instruction that is part
11500 long __builtin_alpha_pklb (long)
11501 long __builtin_alpha_pkwb (long)
11502 long __builtin_alpha_unpkbl (long)
11503 long __builtin_alpha_unpkbw (long)
11504 long __builtin_alpha_minub8 (long, long)
11505 long __builtin_alpha_minsb8 (long, long)
11506 long __builtin_alpha_minuw4 (long, long)
11507 long __builtin_alpha_minsw4 (long, long)
11508 long __builtin_alpha_maxub8 (long, long)
11509 long __builtin_alpha_maxsb8 (long, long)
11510 long __builtin_alpha_maxuw4 (long, long)
11511 long __builtin_alpha_maxsw4 (long, long)
11512 long __builtin_alpha_perr (long, long)
11515 The following built-in functions are always with @option{-mcix}
11516 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11517 later. They all generate the machine instruction that is part
11521 long __builtin_alpha_cttz (long)
11522 long __builtin_alpha_ctlz (long)
11523 long __builtin_alpha_ctpop (long)
11526 The following built-in functions are available on systems that use the OSF/1
11527 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
11528 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11529 @code{rdval} and @code{wrval}.
11532 void *__builtin_thread_pointer (void)
11533 void __builtin_set_thread_pointer (void *)
11536 @node Altera Nios II Built-in Functions
11537 @subsection Altera Nios II Built-in Functions
11539 These built-in functions are available for the Altera Nios II
11540 family of processors.
11542 The following built-in functions are always available. They
11543 all generate the machine instruction that is part of the name.
11546 int __builtin_ldbio (volatile const void *)
11547 int __builtin_ldbuio (volatile const void *)
11548 int __builtin_ldhio (volatile const void *)
11549 int __builtin_ldhuio (volatile const void *)
11550 int __builtin_ldwio (volatile const void *)
11551 void __builtin_stbio (volatile void *, int)
11552 void __builtin_sthio (volatile void *, int)
11553 void __builtin_stwio (volatile void *, int)
11554 void __builtin_sync (void)
11555 int __builtin_rdctl (int)
11556 int __builtin_rdprs (int, int)
11557 void __builtin_wrctl (int, int)
11558 void __builtin_flushd (volatile void *)
11559 void __builtin_flushda (volatile void *)
11560 int __builtin_wrpie (int);
11561 void __builtin_eni (int);
11562 int __builtin_ldex (volatile const void *)
11563 int __builtin_stex (volatile void *, int)
11564 int __builtin_ldsex (volatile const void *)
11565 int __builtin_stsex (volatile void *, int)
11568 The following built-in functions are always available. They
11569 all generate a Nios II Custom Instruction. The name of the
11570 function represents the types that the function takes and
11571 returns. The letter before the @code{n} is the return type
11572 or void if absent. The @code{n} represents the first parameter
11573 to all the custom instructions, the custom instruction number.
11574 The two letters after the @code{n} represent the up to two
11575 parameters to the function.
11577 The letters represent the following data types:
11580 @code{void} for return type and no parameter for parameter types.
11583 @code{int} for return type and parameter type
11586 @code{float} for return type and parameter type
11589 @code{void *} for return type and parameter type
11593 And the function names are:
11595 void __builtin_custom_n (void)
11596 void __builtin_custom_ni (int)
11597 void __builtin_custom_nf (float)
11598 void __builtin_custom_np (void *)
11599 void __builtin_custom_nii (int, int)
11600 void __builtin_custom_nif (int, float)
11601 void __builtin_custom_nip (int, void *)
11602 void __builtin_custom_nfi (float, int)
11603 void __builtin_custom_nff (float, float)
11604 void __builtin_custom_nfp (float, void *)
11605 void __builtin_custom_npi (void *, int)
11606 void __builtin_custom_npf (void *, float)
11607 void __builtin_custom_npp (void *, void *)
11608 int __builtin_custom_in (void)
11609 int __builtin_custom_ini (int)
11610 int __builtin_custom_inf (float)
11611 int __builtin_custom_inp (void *)
11612 int __builtin_custom_inii (int, int)
11613 int __builtin_custom_inif (int, float)
11614 int __builtin_custom_inip (int, void *)
11615 int __builtin_custom_infi (float, int)
11616 int __builtin_custom_inff (float, float)
11617 int __builtin_custom_infp (float, void *)
11618 int __builtin_custom_inpi (void *, int)
11619 int __builtin_custom_inpf (void *, float)
11620 int __builtin_custom_inpp (void *, void *)
11621 float __builtin_custom_fn (void)
11622 float __builtin_custom_fni (int)
11623 float __builtin_custom_fnf (float)
11624 float __builtin_custom_fnp (void *)
11625 float __builtin_custom_fnii (int, int)
11626 float __builtin_custom_fnif (int, float)
11627 float __builtin_custom_fnip (int, void *)
11628 float __builtin_custom_fnfi (float, int)
11629 float __builtin_custom_fnff (float, float)
11630 float __builtin_custom_fnfp (float, void *)
11631 float __builtin_custom_fnpi (void *, int)
11632 float __builtin_custom_fnpf (void *, float)
11633 float __builtin_custom_fnpp (void *, void *)
11634 void * __builtin_custom_pn (void)
11635 void * __builtin_custom_pni (int)
11636 void * __builtin_custom_pnf (float)
11637 void * __builtin_custom_pnp (void *)
11638 void * __builtin_custom_pnii (int, int)
11639 void * __builtin_custom_pnif (int, float)
11640 void * __builtin_custom_pnip (int, void *)
11641 void * __builtin_custom_pnfi (float, int)
11642 void * __builtin_custom_pnff (float, float)
11643 void * __builtin_custom_pnfp (float, void *)
11644 void * __builtin_custom_pnpi (void *, int)
11645 void * __builtin_custom_pnpf (void *, float)
11646 void * __builtin_custom_pnpp (void *, void *)
11649 @node ARC Built-in Functions
11650 @subsection ARC Built-in Functions
11652 The following built-in functions are provided for ARC targets. The
11653 built-ins generate the corresponding assembly instructions. In the
11654 examples given below, the generated code often requires an operand or
11655 result to be in a register. Where necessary further code will be
11656 generated to ensure this is true, but for brevity this is not
11657 described in each case.
11659 @emph{Note:} Using a built-in to generate an instruction not supported
11660 by a target may cause problems. At present the compiler is not
11661 guaranteed to detect such misuse, and as a result an internal compiler
11662 error may be generated.
11664 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
11665 Return 1 if @var{val} is known to have the byte alignment given
11666 by @var{alignval}, otherwise return 0.
11667 Note that this is different from
11669 __alignof__(*(char *)@var{val}) >= alignval
11671 because __alignof__ sees only the type of the dereference, whereas
11672 __builtin_arc_align uses alignment information from the pointer
11673 as well as from the pointed-to type.
11674 The information available will depend on optimization level.
11677 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
11684 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
11685 The operand is the number of a register to be read. Generates:
11687 mov @var{dest}, r@var{regno}
11689 where the value in @var{dest} will be the result returned from the
11693 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
11694 The first operand is the number of a register to be written, the
11695 second operand is a compile time constant to write into that
11696 register. Generates:
11698 mov r@var{regno}, @var{val}
11702 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
11703 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
11706 divaw @var{dest}, @var{a}, @var{b}
11708 where the value in @var{dest} will be the result returned from the
11712 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
11719 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
11720 The operand, @var{auxv}, is the address of an auxiliary register and
11721 must be a compile time constant. Generates:
11723 lr @var{dest}, [@var{auxr}]
11725 Where the value in @var{dest} will be the result returned from the
11729 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
11730 Only available with @option{-mmul64}. Generates:
11732 mul64 @var{a}, @var{b}
11736 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
11737 Only available with @option{-mmul64}. Generates:
11739 mulu64 @var{a}, @var{b}
11743 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
11750 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
11751 Only valid if the @samp{norm} instruction is available through the
11752 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11755 norm @var{dest}, @var{src}
11757 Where the value in @var{dest} will be the result returned from the
11761 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
11762 Only valid if the @samp{normw} instruction is available through the
11763 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11766 normw @var{dest}, @var{src}
11768 Where the value in @var{dest} will be the result returned from the
11772 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
11779 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
11786 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
11787 The first argument, @var{auxv}, is the address of an auxiliary
11788 register, the second argument, @var{val}, is a compile time constant
11789 to be written to the register. Generates:
11791 sr @var{auxr}, [@var{val}]
11795 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
11796 Only valid with @option{-mswap}. Generates:
11798 swap @var{dest}, @var{src}
11800 Where the value in @var{dest} will be the result returned from the
11804 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
11811 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
11812 Only available with @option{-mcpu=ARC700}. Generates:
11818 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
11819 Only available with @option{-mcpu=ARC700}. Generates:
11825 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
11826 Only available with @option{-mcpu=ARC700}. Generates:
11832 The instructions generated by the following builtins are not
11833 considered as candidates for scheduling. They are not moved around by
11834 the compiler during scheduling, and thus can be expected to appear
11835 where they are put in the C code:
11837 __builtin_arc_brk()
11838 __builtin_arc_core_read()
11839 __builtin_arc_core_write()
11840 __builtin_arc_flag()
11842 __builtin_arc_sleep()
11844 __builtin_arc_swi()
11847 @node ARC SIMD Built-in Functions
11848 @subsection ARC SIMD Built-in Functions
11850 SIMD builtins provided by the compiler can be used to generate the
11851 vector instructions. This section describes the available builtins
11852 and their usage in programs. With the @option{-msimd} option, the
11853 compiler provides 128-bit vector types, which can be specified using
11854 the @code{vector_size} attribute. The header file @file{arc-simd.h}
11855 can be included to use the following predefined types:
11857 typedef int __v4si __attribute__((vector_size(16)));
11858 typedef short __v8hi __attribute__((vector_size(16)));
11861 These types can be used to define 128-bit variables. The built-in
11862 functions listed in the following section can be used on these
11863 variables to generate the vector operations.
11865 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
11866 @file{arc-simd.h} also provides equivalent macros called
11867 @code{_@var{someinsn}} that can be used for programming ease and
11868 improved readability. The following macros for DMA control are also
11871 #define _setup_dma_in_channel_reg _vdiwr
11872 #define _setup_dma_out_channel_reg _vdowr
11875 The following is a complete list of all the SIMD built-ins provided
11876 for ARC, grouped by calling signature.
11878 The following take two @code{__v8hi} arguments and return a
11879 @code{__v8hi} result:
11881 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
11882 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
11883 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
11884 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
11885 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
11886 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
11887 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
11888 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
11889 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
11890 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
11891 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
11892 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
11893 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
11894 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
11895 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
11896 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
11897 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
11898 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
11899 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
11900 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
11901 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
11902 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
11903 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
11904 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
11905 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
11906 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
11907 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
11908 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
11909 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
11910 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
11911 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
11912 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
11913 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
11914 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
11915 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
11916 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
11917 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
11918 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
11919 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
11920 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
11921 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
11922 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
11923 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
11924 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
11925 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
11926 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
11927 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
11928 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
11931 The following take one @code{__v8hi} and one @code{int} argument and return a
11932 @code{__v8hi} result:
11935 __v8hi __builtin_arc_vbaddw (__v8hi, int)
11936 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
11937 __v8hi __builtin_arc_vbminw (__v8hi, int)
11938 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
11939 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
11940 __v8hi __builtin_arc_vbmulw (__v8hi, int)
11941 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
11942 __v8hi __builtin_arc_vbsubw (__v8hi, int)
11945 The following take one @code{__v8hi} argument and one @code{int} argument which
11946 must be a 3-bit compile time constant indicating a register number
11947 I0-I7. They return a @code{__v8hi} result.
11949 __v8hi __builtin_arc_vasrw (__v8hi, const int)
11950 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
11951 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
11954 The following take one @code{__v8hi} argument and one @code{int}
11955 argument which must be a 6-bit compile time constant. They return a
11956 @code{__v8hi} result.
11958 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
11959 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
11960 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
11961 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
11962 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
11963 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
11964 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
11967 The following take one @code{__v8hi} argument and one @code{int} argument which
11968 must be a 8-bit compile time constant. They return a @code{__v8hi}
11971 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
11972 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
11973 __v8hi __builtin_arc_vmvw (__v8hi, const int)
11974 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
11977 The following take two @code{int} arguments, the second of which which
11978 must be a 8-bit compile time constant. They return a @code{__v8hi}
11981 __v8hi __builtin_arc_vmovaw (int, const int)
11982 __v8hi __builtin_arc_vmovw (int, const int)
11983 __v8hi __builtin_arc_vmovzw (int, const int)
11986 The following take a single @code{__v8hi} argument and return a
11987 @code{__v8hi} result:
11989 __v8hi __builtin_arc_vabsaw (__v8hi)
11990 __v8hi __builtin_arc_vabsw (__v8hi)
11991 __v8hi __builtin_arc_vaddsuw (__v8hi)
11992 __v8hi __builtin_arc_vexch1 (__v8hi)
11993 __v8hi __builtin_arc_vexch2 (__v8hi)
11994 __v8hi __builtin_arc_vexch4 (__v8hi)
11995 __v8hi __builtin_arc_vsignw (__v8hi)
11996 __v8hi __builtin_arc_vupbaw (__v8hi)
11997 __v8hi __builtin_arc_vupbw (__v8hi)
11998 __v8hi __builtin_arc_vupsbaw (__v8hi)
11999 __v8hi __builtin_arc_vupsbw (__v8hi)
12002 The following take two @code{int} arguments and return no result:
12004 void __builtin_arc_vdirun (int, int)
12005 void __builtin_arc_vdorun (int, int)
12008 The following take two @code{int} arguments and return no result. The
12009 first argument must a 3-bit compile time constant indicating one of
12010 the DR0-DR7 DMA setup channels:
12012 void __builtin_arc_vdiwr (const int, int)
12013 void __builtin_arc_vdowr (const int, int)
12016 The following take an @code{int} argument and return no result:
12018 void __builtin_arc_vendrec (int)
12019 void __builtin_arc_vrec (int)
12020 void __builtin_arc_vrecrun (int)
12021 void __builtin_arc_vrun (int)
12024 The following take a @code{__v8hi} argument and two @code{int}
12025 arguments and return a @code{__v8hi} result. The second argument must
12026 be a 3-bit compile time constants, indicating one the registers I0-I7,
12027 and the third argument must be an 8-bit compile time constant.
12029 @emph{Note:} Although the equivalent hardware instructions do not take
12030 an SIMD register as an operand, these builtins overwrite the relevant
12031 bits of the @code{__v8hi} register provided as the first argument with
12032 the value loaded from the @code{[Ib, u8]} location in the SDM.
12035 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12036 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12037 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12038 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12041 The following take two @code{int} arguments and return a @code{__v8hi}
12042 result. The first argument must be a 3-bit compile time constants,
12043 indicating one the registers I0-I7, and the second argument must be an
12044 8-bit compile time constant.
12047 __v8hi __builtin_arc_vld128 (const int, const int)
12048 __v8hi __builtin_arc_vld64w (const int, const int)
12051 The following take a @code{__v8hi} argument and two @code{int}
12052 arguments and return no result. The second argument must be a 3-bit
12053 compile time constants, indicating one the registers I0-I7, and the
12054 third argument must be an 8-bit compile time constant.
12057 void __builtin_arc_vst128 (__v8hi, const int, const int)
12058 void __builtin_arc_vst64 (__v8hi, const int, const int)
12061 The following take a @code{__v8hi} argument and three @code{int}
12062 arguments and return no result. The second argument must be a 3-bit
12063 compile-time constant, identifying the 16-bit sub-register to be
12064 stored, the third argument must be a 3-bit compile time constants,
12065 indicating one the registers I0-I7, and the fourth argument must be an
12066 8-bit compile time constant.
12069 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12070 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12073 @node ARM iWMMXt Built-in Functions
12074 @subsection ARM iWMMXt Built-in Functions
12076 These built-in functions are available for the ARM family of
12077 processors when the @option{-mcpu=iwmmxt} switch is used:
12080 typedef int v2si __attribute__ ((vector_size (8)));
12081 typedef short v4hi __attribute__ ((vector_size (8)));
12082 typedef char v8qi __attribute__ ((vector_size (8)));
12084 int __builtin_arm_getwcgr0 (void)
12085 void __builtin_arm_setwcgr0 (int)
12086 int __builtin_arm_getwcgr1 (void)
12087 void __builtin_arm_setwcgr1 (int)
12088 int __builtin_arm_getwcgr2 (void)
12089 void __builtin_arm_setwcgr2 (int)
12090 int __builtin_arm_getwcgr3 (void)
12091 void __builtin_arm_setwcgr3 (int)
12092 int __builtin_arm_textrmsb (v8qi, int)
12093 int __builtin_arm_textrmsh (v4hi, int)
12094 int __builtin_arm_textrmsw (v2si, int)
12095 int __builtin_arm_textrmub (v8qi, int)
12096 int __builtin_arm_textrmuh (v4hi, int)
12097 int __builtin_arm_textrmuw (v2si, int)
12098 v8qi __builtin_arm_tinsrb (v8qi, int, int)
12099 v4hi __builtin_arm_tinsrh (v4hi, int, int)
12100 v2si __builtin_arm_tinsrw (v2si, int, int)
12101 long long __builtin_arm_tmia (long long, int, int)
12102 long long __builtin_arm_tmiabb (long long, int, int)
12103 long long __builtin_arm_tmiabt (long long, int, int)
12104 long long __builtin_arm_tmiaph (long long, int, int)
12105 long long __builtin_arm_tmiatb (long long, int, int)
12106 long long __builtin_arm_tmiatt (long long, int, int)
12107 int __builtin_arm_tmovmskb (v8qi)
12108 int __builtin_arm_tmovmskh (v4hi)
12109 int __builtin_arm_tmovmskw (v2si)
12110 long long __builtin_arm_waccb (v8qi)
12111 long long __builtin_arm_wacch (v4hi)
12112 long long __builtin_arm_waccw (v2si)
12113 v8qi __builtin_arm_waddb (v8qi, v8qi)
12114 v8qi __builtin_arm_waddbss (v8qi, v8qi)
12115 v8qi __builtin_arm_waddbus (v8qi, v8qi)
12116 v4hi __builtin_arm_waddh (v4hi, v4hi)
12117 v4hi __builtin_arm_waddhss (v4hi, v4hi)
12118 v4hi __builtin_arm_waddhus (v4hi, v4hi)
12119 v2si __builtin_arm_waddw (v2si, v2si)
12120 v2si __builtin_arm_waddwss (v2si, v2si)
12121 v2si __builtin_arm_waddwus (v2si, v2si)
12122 v8qi __builtin_arm_walign (v8qi, v8qi, int)
12123 long long __builtin_arm_wand(long long, long long)
12124 long long __builtin_arm_wandn (long long, long long)
12125 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
12126 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
12127 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
12128 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
12129 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12130 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12131 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12132 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12133 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12134 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12135 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12136 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12137 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12138 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12139 long long __builtin_arm_wmacsz (v4hi, v4hi)
12140 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12141 long long __builtin_arm_wmacuz (v4hi, v4hi)
12142 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12143 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12144 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12145 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12146 v2si __builtin_arm_wmaxsw (v2si, v2si)
12147 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12148 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12149 v2si __builtin_arm_wmaxuw (v2si, v2si)
12150 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12151 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12152 v2si __builtin_arm_wminsw (v2si, v2si)
12153 v8qi __builtin_arm_wminub (v8qi, v8qi)
12154 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12155 v2si __builtin_arm_wminuw (v2si, v2si)
12156 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12157 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12158 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12159 long long __builtin_arm_wor (long long, long long)
12160 v2si __builtin_arm_wpackdss (long long, long long)
12161 v2si __builtin_arm_wpackdus (long long, long long)
12162 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12163 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12164 v4hi __builtin_arm_wpackwss (v2si, v2si)
12165 v4hi __builtin_arm_wpackwus (v2si, v2si)
12166 long long __builtin_arm_wrord (long long, long long)
12167 long long __builtin_arm_wrordi (long long, int)
12168 v4hi __builtin_arm_wrorh (v4hi, long long)
12169 v4hi __builtin_arm_wrorhi (v4hi, int)
12170 v2si __builtin_arm_wrorw (v2si, long long)
12171 v2si __builtin_arm_wrorwi (v2si, int)
12172 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12173 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12174 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12175 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12176 v4hi __builtin_arm_wshufh (v4hi, int)
12177 long long __builtin_arm_wslld (long long, long long)
12178 long long __builtin_arm_wslldi (long long, int)
12179 v4hi __builtin_arm_wsllh (v4hi, long long)
12180 v4hi __builtin_arm_wsllhi (v4hi, int)
12181 v2si __builtin_arm_wsllw (v2si, long long)
12182 v2si __builtin_arm_wsllwi (v2si, int)
12183 long long __builtin_arm_wsrad (long long, long long)
12184 long long __builtin_arm_wsradi (long long, int)
12185 v4hi __builtin_arm_wsrah (v4hi, long long)
12186 v4hi __builtin_arm_wsrahi (v4hi, int)
12187 v2si __builtin_arm_wsraw (v2si, long long)
12188 v2si __builtin_arm_wsrawi (v2si, int)
12189 long long __builtin_arm_wsrld (long long, long long)
12190 long long __builtin_arm_wsrldi (long long, int)
12191 v4hi __builtin_arm_wsrlh (v4hi, long long)
12192 v4hi __builtin_arm_wsrlhi (v4hi, int)
12193 v2si __builtin_arm_wsrlw (v2si, long long)
12194 v2si __builtin_arm_wsrlwi (v2si, int)
12195 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12196 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12197 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12198 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12199 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12200 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12201 v2si __builtin_arm_wsubw (v2si, v2si)
12202 v2si __builtin_arm_wsubwss (v2si, v2si)
12203 v2si __builtin_arm_wsubwus (v2si, v2si)
12204 v4hi __builtin_arm_wunpckehsb (v8qi)
12205 v2si __builtin_arm_wunpckehsh (v4hi)
12206 long long __builtin_arm_wunpckehsw (v2si)
12207 v4hi __builtin_arm_wunpckehub (v8qi)
12208 v2si __builtin_arm_wunpckehuh (v4hi)
12209 long long __builtin_arm_wunpckehuw (v2si)
12210 v4hi __builtin_arm_wunpckelsb (v8qi)
12211 v2si __builtin_arm_wunpckelsh (v4hi)
12212 long long __builtin_arm_wunpckelsw (v2si)
12213 v4hi __builtin_arm_wunpckelub (v8qi)
12214 v2si __builtin_arm_wunpckeluh (v4hi)
12215 long long __builtin_arm_wunpckeluw (v2si)
12216 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12217 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12218 v2si __builtin_arm_wunpckihw (v2si, v2si)
12219 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12220 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12221 v2si __builtin_arm_wunpckilw (v2si, v2si)
12222 long long __builtin_arm_wxor (long long, long long)
12223 long long __builtin_arm_wzero ()
12227 @node ARM C Language Extensions (ACLE)
12228 @subsection ARM C Language Extensions (ACLE)
12230 GCC implements extensions for C as described in the ARM C Language
12231 Extensions (ACLE) specification, which can be found at
12232 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12234 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12235 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
12236 intrinsics can be found at
12237 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12238 The built-in intrinsics for the Advanced SIMD extension are available when
12241 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
12242 back ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM back end's
12243 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12244 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12247 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12248 availability of extensions.
12250 @node ARM Floating Point Status and Control Intrinsics
12251 @subsection ARM Floating Point Status and Control Intrinsics
12253 These built-in functions are available for the ARM family of
12254 processors with floating-point unit.
12257 unsigned int __builtin_arm_get_fpscr ()
12258 void __builtin_arm_set_fpscr (unsigned int)
12261 @node AVR Built-in Functions
12262 @subsection AVR Built-in Functions
12264 For each built-in function for AVR, there is an equally named,
12265 uppercase built-in macro defined. That way users can easily query if
12266 or if not a specific built-in is implemented or not. For example, if
12267 @code{__builtin_avr_nop} is available the macro
12268 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12270 The following built-in functions map to the respective machine
12271 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12272 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12273 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12274 as library call if no hardware multiplier is available.
12277 void __builtin_avr_nop (void)
12278 void __builtin_avr_sei (void)
12279 void __builtin_avr_cli (void)
12280 void __builtin_avr_sleep (void)
12281 void __builtin_avr_wdr (void)
12282 unsigned char __builtin_avr_swap (unsigned char)
12283 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12284 int __builtin_avr_fmuls (char, char)
12285 int __builtin_avr_fmulsu (char, unsigned char)
12288 In order to delay execution for a specific number of cycles, GCC
12291 void __builtin_avr_delay_cycles (unsigned long ticks)
12295 @code{ticks} is the number of ticks to delay execution. Note that this
12296 built-in does not take into account the effect of interrupts that
12297 might increase delay time. @code{ticks} must be a compile-time
12298 integer constant; delays with a variable number of cycles are not supported.
12301 char __builtin_avr_flash_segment (const __memx void*)
12305 This built-in takes a byte address to the 24-bit
12306 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12307 the number of the flash segment (the 64 KiB chunk) where the address
12308 points to. Counting starts at @code{0}.
12309 If the address does not point to flash memory, return @code{-1}.
12312 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
12316 Insert bits from @var{bits} into @var{val} and return the resulting
12317 value. The nibbles of @var{map} determine how the insertion is
12318 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12320 @item If @var{X} is @code{0xf},
12321 then the @var{n}-th bit of @var{val} is returned unaltered.
12323 @item If X is in the range 0@dots{}7,
12324 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12326 @item If X is in the range 8@dots{}@code{0xe},
12327 then the @var{n}-th result bit is undefined.
12331 One typical use case for this built-in is adjusting input and
12332 output values to non-contiguous port layouts. Some examples:
12335 // same as val, bits is unused
12336 __builtin_avr_insert_bits (0xffffffff, bits, val)
12340 // same as bits, val is unused
12341 __builtin_avr_insert_bits (0x76543210, bits, val)
12345 // same as rotating bits by 4
12346 __builtin_avr_insert_bits (0x32107654, bits, 0)
12350 // high nibble of result is the high nibble of val
12351 // low nibble of result is the low nibble of bits
12352 __builtin_avr_insert_bits (0xffff3210, bits, val)
12356 // reverse the bit order of bits
12357 __builtin_avr_insert_bits (0x01234567, bits, 0)
12360 @node Blackfin Built-in Functions
12361 @subsection Blackfin Built-in Functions
12363 Currently, there are two Blackfin-specific built-in functions. These are
12364 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12365 using inline assembly; by using these built-in functions the compiler can
12366 automatically add workarounds for hardware errata involving these
12367 instructions. These functions are named as follows:
12370 void __builtin_bfin_csync (void)
12371 void __builtin_bfin_ssync (void)
12374 @node FR-V Built-in Functions
12375 @subsection FR-V Built-in Functions
12377 GCC provides many FR-V-specific built-in functions. In general,
12378 these functions are intended to be compatible with those described
12379 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12380 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
12381 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12382 pointer rather than by value.
12384 Most of the functions are named after specific FR-V instructions.
12385 Such functions are said to be ``directly mapped'' and are summarized
12386 here in tabular form.
12390 * Directly-mapped Integer Functions::
12391 * Directly-mapped Media Functions::
12392 * Raw read/write Functions::
12393 * Other Built-in Functions::
12396 @node Argument Types
12397 @subsubsection Argument Types
12399 The arguments to the built-in functions can be divided into three groups:
12400 register numbers, compile-time constants and run-time values. In order
12401 to make this classification clear at a glance, the arguments and return
12402 values are given the following pseudo types:
12404 @multitable @columnfractions .20 .30 .15 .35
12405 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12406 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12407 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12408 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12409 @item @code{uw2} @tab @code{unsigned long long} @tab No
12410 @tab an unsigned doubleword
12411 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12412 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12413 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12414 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12417 These pseudo types are not defined by GCC, they are simply a notational
12418 convenience used in this manual.
12420 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12421 and @code{sw2} are evaluated at run time. They correspond to
12422 register operands in the underlying FR-V instructions.
12424 @code{const} arguments represent immediate operands in the underlying
12425 FR-V instructions. They must be compile-time constants.
12427 @code{acc} arguments are evaluated at compile time and specify the number
12428 of an accumulator register. For example, an @code{acc} argument of 2
12429 selects the ACC2 register.
12431 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12432 number of an IACC register. See @pxref{Other Built-in Functions}
12435 @node Directly-mapped Integer Functions
12436 @subsubsection Directly-Mapped Integer Functions
12438 The functions listed below map directly to FR-V I-type instructions.
12440 @multitable @columnfractions .45 .32 .23
12441 @item Function prototype @tab Example usage @tab Assembly output
12442 @item @code{sw1 __ADDSS (sw1, sw1)}
12443 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12444 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12445 @item @code{sw1 __SCAN (sw1, sw1)}
12446 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12447 @tab @code{SCAN @var{a},@var{b},@var{c}}
12448 @item @code{sw1 __SCUTSS (sw1)}
12449 @tab @code{@var{b} = __SCUTSS (@var{a})}
12450 @tab @code{SCUTSS @var{a},@var{b}}
12451 @item @code{sw1 __SLASS (sw1, sw1)}
12452 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12453 @tab @code{SLASS @var{a},@var{b},@var{c}}
12454 @item @code{void __SMASS (sw1, sw1)}
12455 @tab @code{__SMASS (@var{a}, @var{b})}
12456 @tab @code{SMASS @var{a},@var{b}}
12457 @item @code{void __SMSSS (sw1, sw1)}
12458 @tab @code{__SMSSS (@var{a}, @var{b})}
12459 @tab @code{SMSSS @var{a},@var{b}}
12460 @item @code{void __SMU (sw1, sw1)}
12461 @tab @code{__SMU (@var{a}, @var{b})}
12462 @tab @code{SMU @var{a},@var{b}}
12463 @item @code{sw2 __SMUL (sw1, sw1)}
12464 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12465 @tab @code{SMUL @var{a},@var{b},@var{c}}
12466 @item @code{sw1 __SUBSS (sw1, sw1)}
12467 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12468 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12469 @item @code{uw2 __UMUL (uw1, uw1)}
12470 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12471 @tab @code{UMUL @var{a},@var{b},@var{c}}
12474 @node Directly-mapped Media Functions
12475 @subsubsection Directly-Mapped Media Functions
12477 The functions listed below map directly to FR-V M-type instructions.
12479 @multitable @columnfractions .45 .32 .23
12480 @item Function prototype @tab Example usage @tab Assembly output
12481 @item @code{uw1 __MABSHS (sw1)}
12482 @tab @code{@var{b} = __MABSHS (@var{a})}
12483 @tab @code{MABSHS @var{a},@var{b}}
12484 @item @code{void __MADDACCS (acc, acc)}
12485 @tab @code{__MADDACCS (@var{b}, @var{a})}
12486 @tab @code{MADDACCS @var{a},@var{b}}
12487 @item @code{sw1 __MADDHSS (sw1, sw1)}
12488 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12489 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12490 @item @code{uw1 __MADDHUS (uw1, uw1)}
12491 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12492 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12493 @item @code{uw1 __MAND (uw1, uw1)}
12494 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12495 @tab @code{MAND @var{a},@var{b},@var{c}}
12496 @item @code{void __MASACCS (acc, acc)}
12497 @tab @code{__MASACCS (@var{b}, @var{a})}
12498 @tab @code{MASACCS @var{a},@var{b}}
12499 @item @code{uw1 __MAVEH (uw1, uw1)}
12500 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12501 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12502 @item @code{uw2 __MBTOH (uw1)}
12503 @tab @code{@var{b} = __MBTOH (@var{a})}
12504 @tab @code{MBTOH @var{a},@var{b}}
12505 @item @code{void __MBTOHE (uw1 *, uw1)}
12506 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12507 @tab @code{MBTOHE @var{a},@var{b}}
12508 @item @code{void __MCLRACC (acc)}
12509 @tab @code{__MCLRACC (@var{a})}
12510 @tab @code{MCLRACC @var{a}}
12511 @item @code{void __MCLRACCA (void)}
12512 @tab @code{__MCLRACCA ()}
12513 @tab @code{MCLRACCA}
12514 @item @code{uw1 __Mcop1 (uw1, uw1)}
12515 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12516 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12517 @item @code{uw1 __Mcop2 (uw1, uw1)}
12518 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12519 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12520 @item @code{uw1 __MCPLHI (uw2, const)}
12521 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12522 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12523 @item @code{uw1 __MCPLI (uw2, const)}
12524 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12525 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12526 @item @code{void __MCPXIS (acc, sw1, sw1)}
12527 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12528 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12529 @item @code{void __MCPXIU (acc, uw1, uw1)}
12530 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12531 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12532 @item @code{void __MCPXRS (acc, sw1, sw1)}
12533 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12534 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12535 @item @code{void __MCPXRU (acc, uw1, uw1)}
12536 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12537 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12538 @item @code{uw1 __MCUT (acc, uw1)}
12539 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12540 @tab @code{MCUT @var{a},@var{b},@var{c}}
12541 @item @code{uw1 __MCUTSS (acc, sw1)}
12542 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12543 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12544 @item @code{void __MDADDACCS (acc, acc)}
12545 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12546 @tab @code{MDADDACCS @var{a},@var{b}}
12547 @item @code{void __MDASACCS (acc, acc)}
12548 @tab @code{__MDASACCS (@var{b}, @var{a})}
12549 @tab @code{MDASACCS @var{a},@var{b}}
12550 @item @code{uw2 __MDCUTSSI (acc, const)}
12551 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12552 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12553 @item @code{uw2 __MDPACKH (uw2, uw2)}
12554 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12555 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12556 @item @code{uw2 __MDROTLI (uw2, const)}
12557 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12558 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12559 @item @code{void __MDSUBACCS (acc, acc)}
12560 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12561 @tab @code{MDSUBACCS @var{a},@var{b}}
12562 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12563 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12564 @tab @code{MDUNPACKH @var{a},@var{b}}
12565 @item @code{uw2 __MEXPDHD (uw1, const)}
12566 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
12567 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
12568 @item @code{uw1 __MEXPDHW (uw1, const)}
12569 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
12570 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
12571 @item @code{uw1 __MHDSETH (uw1, const)}
12572 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
12573 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
12574 @item @code{sw1 __MHDSETS (const)}
12575 @tab @code{@var{b} = __MHDSETS (@var{a})}
12576 @tab @code{MHDSETS #@var{a},@var{b}}
12577 @item @code{uw1 __MHSETHIH (uw1, const)}
12578 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
12579 @tab @code{MHSETHIH #@var{a},@var{b}}
12580 @item @code{sw1 __MHSETHIS (sw1, const)}
12581 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
12582 @tab @code{MHSETHIS #@var{a},@var{b}}
12583 @item @code{uw1 __MHSETLOH (uw1, const)}
12584 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
12585 @tab @code{MHSETLOH #@var{a},@var{b}}
12586 @item @code{sw1 __MHSETLOS (sw1, const)}
12587 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
12588 @tab @code{MHSETLOS #@var{a},@var{b}}
12589 @item @code{uw1 __MHTOB (uw2)}
12590 @tab @code{@var{b} = __MHTOB (@var{a})}
12591 @tab @code{MHTOB @var{a},@var{b}}
12592 @item @code{void __MMACHS (acc, sw1, sw1)}
12593 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
12594 @tab @code{MMACHS @var{a},@var{b},@var{c}}
12595 @item @code{void __MMACHU (acc, uw1, uw1)}
12596 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
12597 @tab @code{MMACHU @var{a},@var{b},@var{c}}
12598 @item @code{void __MMRDHS (acc, sw1, sw1)}
12599 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
12600 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
12601 @item @code{void __MMRDHU (acc, uw1, uw1)}
12602 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
12603 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
12604 @item @code{void __MMULHS (acc, sw1, sw1)}
12605 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
12606 @tab @code{MMULHS @var{a},@var{b},@var{c}}
12607 @item @code{void __MMULHU (acc, uw1, uw1)}
12608 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
12609 @tab @code{MMULHU @var{a},@var{b},@var{c}}
12610 @item @code{void __MMULXHS (acc, sw1, sw1)}
12611 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
12612 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
12613 @item @code{void __MMULXHU (acc, uw1, uw1)}
12614 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
12615 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
12616 @item @code{uw1 __MNOT (uw1)}
12617 @tab @code{@var{b} = __MNOT (@var{a})}
12618 @tab @code{MNOT @var{a},@var{b}}
12619 @item @code{uw1 __MOR (uw1, uw1)}
12620 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
12621 @tab @code{MOR @var{a},@var{b},@var{c}}
12622 @item @code{uw1 __MPACKH (uh, uh)}
12623 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
12624 @tab @code{MPACKH @var{a},@var{b},@var{c}}
12625 @item @code{sw2 __MQADDHSS (sw2, sw2)}
12626 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
12627 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
12628 @item @code{uw2 __MQADDHUS (uw2, uw2)}
12629 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
12630 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
12631 @item @code{void __MQCPXIS (acc, sw2, sw2)}
12632 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
12633 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
12634 @item @code{void __MQCPXIU (acc, uw2, uw2)}
12635 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
12636 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
12637 @item @code{void __MQCPXRS (acc, sw2, sw2)}
12638 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
12639 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
12640 @item @code{void __MQCPXRU (acc, uw2, uw2)}
12641 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
12642 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
12643 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
12644 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
12645 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
12646 @item @code{sw2 __MQLMTHS (sw2, sw2)}
12647 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
12648 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
12649 @item @code{void __MQMACHS (acc, sw2, sw2)}
12650 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
12651 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
12652 @item @code{void __MQMACHU (acc, uw2, uw2)}
12653 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
12654 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
12655 @item @code{void __MQMACXHS (acc, sw2, sw2)}
12656 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
12657 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
12658 @item @code{void __MQMULHS (acc, sw2, sw2)}
12659 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
12660 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
12661 @item @code{void __MQMULHU (acc, uw2, uw2)}
12662 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
12663 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
12664 @item @code{void __MQMULXHS (acc, sw2, sw2)}
12665 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
12666 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
12667 @item @code{void __MQMULXHU (acc, uw2, uw2)}
12668 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
12669 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
12670 @item @code{sw2 __MQSATHS (sw2, sw2)}
12671 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
12672 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
12673 @item @code{uw2 __MQSLLHI (uw2, int)}
12674 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
12675 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
12676 @item @code{sw2 __MQSRAHI (sw2, int)}
12677 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
12678 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
12679 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
12680 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
12681 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
12682 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
12683 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
12684 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
12685 @item @code{void __MQXMACHS (acc, sw2, sw2)}
12686 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
12687 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
12688 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
12689 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
12690 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
12691 @item @code{uw1 __MRDACC (acc)}
12692 @tab @code{@var{b} = __MRDACC (@var{a})}
12693 @tab @code{MRDACC @var{a},@var{b}}
12694 @item @code{uw1 __MRDACCG (acc)}
12695 @tab @code{@var{b} = __MRDACCG (@var{a})}
12696 @tab @code{MRDACCG @var{a},@var{b}}
12697 @item @code{uw1 __MROTLI (uw1, const)}
12698 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
12699 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
12700 @item @code{uw1 __MROTRI (uw1, const)}
12701 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
12702 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
12703 @item @code{sw1 __MSATHS (sw1, sw1)}
12704 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
12705 @tab @code{MSATHS @var{a},@var{b},@var{c}}
12706 @item @code{uw1 __MSATHU (uw1, uw1)}
12707 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
12708 @tab @code{MSATHU @var{a},@var{b},@var{c}}
12709 @item @code{uw1 __MSLLHI (uw1, const)}
12710 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
12711 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
12712 @item @code{sw1 __MSRAHI (sw1, const)}
12713 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
12714 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
12715 @item @code{uw1 __MSRLHI (uw1, const)}
12716 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
12717 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
12718 @item @code{void __MSUBACCS (acc, acc)}
12719 @tab @code{__MSUBACCS (@var{b}, @var{a})}
12720 @tab @code{MSUBACCS @var{a},@var{b}}
12721 @item @code{sw1 __MSUBHSS (sw1, sw1)}
12722 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
12723 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
12724 @item @code{uw1 __MSUBHUS (uw1, uw1)}
12725 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
12726 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
12727 @item @code{void __MTRAP (void)}
12728 @tab @code{__MTRAP ()}
12730 @item @code{uw2 __MUNPACKH (uw1)}
12731 @tab @code{@var{b} = __MUNPACKH (@var{a})}
12732 @tab @code{MUNPACKH @var{a},@var{b}}
12733 @item @code{uw1 __MWCUT (uw2, uw1)}
12734 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
12735 @tab @code{MWCUT @var{a},@var{b},@var{c}}
12736 @item @code{void __MWTACC (acc, uw1)}
12737 @tab @code{__MWTACC (@var{b}, @var{a})}
12738 @tab @code{MWTACC @var{a},@var{b}}
12739 @item @code{void __MWTACCG (acc, uw1)}
12740 @tab @code{__MWTACCG (@var{b}, @var{a})}
12741 @tab @code{MWTACCG @var{a},@var{b}}
12742 @item @code{uw1 __MXOR (uw1, uw1)}
12743 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
12744 @tab @code{MXOR @var{a},@var{b},@var{c}}
12747 @node Raw read/write Functions
12748 @subsubsection Raw Read/Write Functions
12750 This sections describes built-in functions related to read and write
12751 instructions to access memory. These functions generate
12752 @code{membar} instructions to flush the I/O load and stores where
12753 appropriate, as described in Fujitsu's manual described above.
12757 @item unsigned char __builtin_read8 (void *@var{data})
12758 @item unsigned short __builtin_read16 (void *@var{data})
12759 @item unsigned long __builtin_read32 (void *@var{data})
12760 @item unsigned long long __builtin_read64 (void *@var{data})
12762 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
12763 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
12764 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
12765 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
12768 @node Other Built-in Functions
12769 @subsubsection Other Built-in Functions
12771 This section describes built-in functions that are not named after
12772 a specific FR-V instruction.
12775 @item sw2 __IACCreadll (iacc @var{reg})
12776 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
12777 for future expansion and must be 0.
12779 @item sw1 __IACCreadl (iacc @var{reg})
12780 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
12781 Other values of @var{reg} are rejected as invalid.
12783 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
12784 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
12785 is reserved for future expansion and must be 0.
12787 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
12788 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
12789 is 1. Other values of @var{reg} are rejected as invalid.
12791 @item void __data_prefetch0 (const void *@var{x})
12792 Use the @code{dcpl} instruction to load the contents of address @var{x}
12793 into the data cache.
12795 @item void __data_prefetch (const void *@var{x})
12796 Use the @code{nldub} instruction to load the contents of address @var{x}
12797 into the data cache. The instruction is issued in slot I1@.
12800 @node MIPS DSP Built-in Functions
12801 @subsection MIPS DSP Built-in Functions
12803 The MIPS DSP Application-Specific Extension (ASE) includes new
12804 instructions that are designed to improve the performance of DSP and
12805 media applications. It provides instructions that operate on packed
12806 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12808 GCC supports MIPS DSP operations using both the generic
12809 vector extensions (@pxref{Vector Extensions}) and a collection of
12810 MIPS-specific built-in functions. Both kinds of support are
12811 enabled by the @option{-mdsp} command-line option.
12813 Revision 2 of the ASE was introduced in the second half of 2006.
12814 This revision adds extra instructions to the original ASE, but is
12815 otherwise backwards-compatible with it. You can select revision 2
12816 using the command-line option @option{-mdspr2}; this option implies
12819 The SCOUNT and POS bits of the DSP control register are global. The
12820 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12821 POS bits. During optimization, the compiler does not delete these
12822 instructions and it does not delete calls to functions containing
12823 these instructions.
12825 At present, GCC only provides support for operations on 32-bit
12826 vectors. The vector type associated with 8-bit integer data is
12827 usually called @code{v4i8}, the vector type associated with Q7
12828 is usually called @code{v4q7}, the vector type associated with 16-bit
12829 integer data is usually called @code{v2i16}, and the vector type
12830 associated with Q15 is usually called @code{v2q15}. They can be
12831 defined in C as follows:
12834 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12835 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12836 typedef short v2i16 __attribute__ ((vector_size(4)));
12837 typedef short v2q15 __attribute__ ((vector_size(4)));
12840 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12841 initialized in the same way as aggregates. For example:
12844 v4i8 a = @{1, 2, 3, 4@};
12846 b = (v4i8) @{5, 6, 7, 8@};
12848 v2q15 c = @{0x0fcb, 0x3a75@};
12850 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12853 @emph{Note:} The CPU's endianness determines the order in which values
12854 are packed. On little-endian targets, the first value is the least
12855 significant and the last value is the most significant. The opposite
12856 order applies to big-endian targets. For example, the code above
12857 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12858 and @code{4} on big-endian targets.
12860 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12861 representation. As shown in this example, the integer representation
12862 of a Q7 value can be obtained by multiplying the fractional value by
12863 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
12864 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
12867 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12868 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
12869 and @code{c} and @code{d} are @code{v2q15} values.
12871 @multitable @columnfractions .50 .50
12872 @item C code @tab MIPS instruction
12873 @item @code{a + b} @tab @code{addu.qb}
12874 @item @code{c + d} @tab @code{addq.ph}
12875 @item @code{a - b} @tab @code{subu.qb}
12876 @item @code{c - d} @tab @code{subq.ph}
12879 The table below lists the @code{v2i16} operation for which
12880 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
12881 @code{v2i16} values.
12883 @multitable @columnfractions .50 .50
12884 @item C code @tab MIPS instruction
12885 @item @code{e * f} @tab @code{mul.ph}
12888 It is easier to describe the DSP built-in functions if we first define
12889 the following types:
12894 typedef unsigned int ui32;
12895 typedef long long a64;
12898 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12899 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12900 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
12901 @code{long long}, but we use @code{a64} to indicate values that are
12902 placed in one of the four DSP accumulators (@code{$ac0},
12903 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12905 Also, some built-in functions prefer or require immediate numbers as
12906 parameters, because the corresponding DSP instructions accept both immediate
12907 numbers and register operands, or accept immediate numbers only. The
12908 immediate parameters are listed as follows.
12916 imm0_255: 0 to 255.
12917 imm_n32_31: -32 to 31.
12918 imm_n512_511: -512 to 511.
12921 The following built-in functions map directly to a particular MIPS DSP
12922 instruction. Please refer to the architecture specification
12923 for details on what each instruction does.
12926 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12927 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12928 q31 __builtin_mips_addq_s_w (q31, q31)
12929 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12930 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12931 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12932 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12933 q31 __builtin_mips_subq_s_w (q31, q31)
12934 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12935 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12936 i32 __builtin_mips_addsc (i32, i32)
12937 i32 __builtin_mips_addwc (i32, i32)
12938 i32 __builtin_mips_modsub (i32, i32)
12939 i32 __builtin_mips_raddu_w_qb (v4i8)
12940 v2q15 __builtin_mips_absq_s_ph (v2q15)
12941 q31 __builtin_mips_absq_s_w (q31)
12942 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12943 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12944 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12945 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12946 q31 __builtin_mips_preceq_w_phl (v2q15)
12947 q31 __builtin_mips_preceq_w_phr (v2q15)
12948 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12949 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12950 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12951 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12952 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12953 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12954 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12955 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12956 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12957 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12958 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12959 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12960 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12961 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12962 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12963 q31 __builtin_mips_shll_s_w (q31, i32)
12964 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12965 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12966 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12967 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12968 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12969 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12970 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12971 q31 __builtin_mips_shra_r_w (q31, i32)
12972 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12973 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12974 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12975 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12976 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12977 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12978 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12979 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12980 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12981 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12982 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12983 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12984 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12985 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12986 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12987 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12988 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12989 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12990 i32 __builtin_mips_bitrev (i32)
12991 i32 __builtin_mips_insv (i32, i32)
12992 v4i8 __builtin_mips_repl_qb (imm0_255)
12993 v4i8 __builtin_mips_repl_qb (i32)
12994 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12995 v2q15 __builtin_mips_repl_ph (i32)
12996 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12997 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12998 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12999 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13000 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13001 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13002 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13003 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13004 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13005 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13006 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13007 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13008 i32 __builtin_mips_extr_w (a64, imm0_31)
13009 i32 __builtin_mips_extr_w (a64, i32)
13010 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13011 i32 __builtin_mips_extr_s_h (a64, i32)
13012 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13013 i32 __builtin_mips_extr_rs_w (a64, i32)
13014 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13015 i32 __builtin_mips_extr_r_w (a64, i32)
13016 i32 __builtin_mips_extp (a64, imm0_31)
13017 i32 __builtin_mips_extp (a64, i32)
13018 i32 __builtin_mips_extpdp (a64, imm0_31)
13019 i32 __builtin_mips_extpdp (a64, i32)
13020 a64 __builtin_mips_shilo (a64, imm_n32_31)
13021 a64 __builtin_mips_shilo (a64, i32)
13022 a64 __builtin_mips_mthlip (a64, i32)
13023 void __builtin_mips_wrdsp (i32, imm0_63)
13024 i32 __builtin_mips_rddsp (imm0_63)
13025 i32 __builtin_mips_lbux (void *, i32)
13026 i32 __builtin_mips_lhx (void *, i32)
13027 i32 __builtin_mips_lwx (void *, i32)
13028 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13029 i32 __builtin_mips_bposge32 (void)
13030 a64 __builtin_mips_madd (a64, i32, i32);
13031 a64 __builtin_mips_maddu (a64, ui32, ui32);
13032 a64 __builtin_mips_msub (a64, i32, i32);
13033 a64 __builtin_mips_msubu (a64, ui32, ui32);
13034 a64 __builtin_mips_mult (i32, i32);
13035 a64 __builtin_mips_multu (ui32, ui32);
13038 The following built-in functions map directly to a particular MIPS DSP REV 2
13039 instruction. Please refer to the architecture specification
13040 for details on what each instruction does.
13043 v4q7 __builtin_mips_absq_s_qb (v4q7);
13044 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13045 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13046 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13047 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13048 i32 __builtin_mips_append (i32, i32, imm0_31);
13049 i32 __builtin_mips_balign (i32, i32, imm0_3);
13050 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13051 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13052 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13053 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13054 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13055 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13056 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13057 q31 __builtin_mips_mulq_rs_w (q31, q31);
13058 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13059 q31 __builtin_mips_mulq_s_w (q31, q31);
13060 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13061 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13062 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13063 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13064 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13065 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13066 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13067 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13068 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13069 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13070 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13071 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13072 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13073 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13074 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13075 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13076 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13077 q31 __builtin_mips_addqh_w (q31, q31);
13078 q31 __builtin_mips_addqh_r_w (q31, q31);
13079 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13080 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13081 q31 __builtin_mips_subqh_w (q31, q31);
13082 q31 __builtin_mips_subqh_r_w (q31, q31);
13083 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13084 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13085 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13086 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13087 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13088 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13092 @node MIPS Paired-Single Support
13093 @subsection MIPS Paired-Single Support
13095 The MIPS64 architecture includes a number of instructions that
13096 operate on pairs of single-precision floating-point values.
13097 Each pair is packed into a 64-bit floating-point register,
13098 with one element being designated the ``upper half'' and
13099 the other being designated the ``lower half''.
13101 GCC supports paired-single operations using both the generic
13102 vector extensions (@pxref{Vector Extensions}) and a collection of
13103 MIPS-specific built-in functions. Both kinds of support are
13104 enabled by the @option{-mpaired-single} command-line option.
13106 The vector type associated with paired-single values is usually
13107 called @code{v2sf}. It can be defined in C as follows:
13110 typedef float v2sf __attribute__ ((vector_size (8)));
13113 @code{v2sf} values are initialized in the same way as aggregates.
13117 v2sf a = @{1.5, 9.1@};
13120 b = (v2sf) @{e, f@};
13123 @emph{Note:} The CPU's endianness determines which value is stored in
13124 the upper half of a register and which value is stored in the lower half.
13125 On little-endian targets, the first value is the lower one and the second
13126 value is the upper one. The opposite order applies to big-endian targets.
13127 For example, the code above sets the lower half of @code{a} to
13128 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13130 @node MIPS Loongson Built-in Functions
13131 @subsection MIPS Loongson Built-in Functions
13133 GCC provides intrinsics to access the SIMD instructions provided by the
13134 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
13135 available after inclusion of the @code{loongson.h} header file,
13136 operate on the following 64-bit vector types:
13139 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13140 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13141 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13142 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13143 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13144 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13147 The intrinsics provided are listed below; each is named after the
13148 machine instruction to which it corresponds, with suffixes added as
13149 appropriate to distinguish intrinsics that expand to the same machine
13150 instruction yet have different argument types. Refer to the architecture
13151 documentation for a description of the functionality of each
13155 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13156 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13157 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13158 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13159 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13160 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13161 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13162 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13163 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13164 uint64_t paddd_u (uint64_t s, uint64_t t);
13165 int64_t paddd_s (int64_t s, int64_t t);
13166 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13167 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13168 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13169 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13170 uint64_t pandn_ud (uint64_t s, uint64_t t);
13171 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13172 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13173 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13174 int64_t pandn_sd (int64_t s, int64_t t);
13175 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13176 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13177 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13178 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13179 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13180 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13181 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13182 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13183 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13184 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13185 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13186 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13187 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13188 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13189 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13190 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13191 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13192 uint16x4_t pextrh_u (uint16x4_t s, int field);
13193 int16x4_t pextrh_s (int16x4_t s, int field);
13194 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13195 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13196 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13197 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13198 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13199 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13200 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13201 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13202 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13203 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13204 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13205 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13206 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13207 uint8x8_t pmovmskb_u (uint8x8_t s);
13208 int8x8_t pmovmskb_s (int8x8_t s);
13209 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13210 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13211 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13212 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13213 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13214 uint16x4_t biadd (uint8x8_t s);
13215 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13216 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13217 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13218 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13219 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13220 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13221 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13222 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13223 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13224 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13225 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13226 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13227 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13228 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13229 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13230 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13231 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13232 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13233 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13234 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13235 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13236 uint64_t psubd_u (uint64_t s, uint64_t t);
13237 int64_t psubd_s (int64_t s, int64_t t);
13238 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13239 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13240 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13241 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13242 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13243 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13244 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13245 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13246 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13247 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13248 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13249 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13250 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13251 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13252 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13253 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13257 * Paired-Single Arithmetic::
13258 * Paired-Single Built-in Functions::
13259 * MIPS-3D Built-in Functions::
13262 @node Paired-Single Arithmetic
13263 @subsubsection Paired-Single Arithmetic
13265 The table below lists the @code{v2sf} operations for which hardware
13266 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13267 values and @code{x} is an integral value.
13269 @multitable @columnfractions .50 .50
13270 @item C code @tab MIPS instruction
13271 @item @code{a + b} @tab @code{add.ps}
13272 @item @code{a - b} @tab @code{sub.ps}
13273 @item @code{-a} @tab @code{neg.ps}
13274 @item @code{a * b} @tab @code{mul.ps}
13275 @item @code{a * b + c} @tab @code{madd.ps}
13276 @item @code{a * b - c} @tab @code{msub.ps}
13277 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13278 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13279 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13282 Note that the multiply-accumulate instructions can be disabled
13283 using the command-line option @code{-mno-fused-madd}.
13285 @node Paired-Single Built-in Functions
13286 @subsubsection Paired-Single Built-in Functions
13288 The following paired-single functions map directly to a particular
13289 MIPS instruction. Please refer to the architecture specification
13290 for details on what each instruction does.
13293 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13294 Pair lower lower (@code{pll.ps}).
13296 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13297 Pair upper lower (@code{pul.ps}).
13299 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13300 Pair lower upper (@code{plu.ps}).
13302 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13303 Pair upper upper (@code{puu.ps}).
13305 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13306 Convert pair to paired single (@code{cvt.ps.s}).
13308 @item float __builtin_mips_cvt_s_pl (v2sf)
13309 Convert pair lower to single (@code{cvt.s.pl}).
13311 @item float __builtin_mips_cvt_s_pu (v2sf)
13312 Convert pair upper to single (@code{cvt.s.pu}).
13314 @item v2sf __builtin_mips_abs_ps (v2sf)
13315 Absolute value (@code{abs.ps}).
13317 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13318 Align variable (@code{alnv.ps}).
13320 @emph{Note:} The value of the third parameter must be 0 or 4
13321 modulo 8, otherwise the result is unpredictable. Please read the
13322 instruction description for details.
13325 The following multi-instruction functions are also available.
13326 In each case, @var{cond} can be any of the 16 floating-point conditions:
13327 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13328 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13329 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13332 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13333 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13334 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13335 @code{movt.ps}/@code{movf.ps}).
13337 The @code{movt} functions return the value @var{x} computed by:
13340 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13341 mov.ps @var{x},@var{c}
13342 movt.ps @var{x},@var{d},@var{cc}
13345 The @code{movf} functions are similar but use @code{movf.ps} instead
13348 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13349 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13350 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13351 @code{bc1t}/@code{bc1f}).
13353 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13354 and return either the upper or lower half of the result. For example:
13358 if (__builtin_mips_upper_c_eq_ps (a, b))
13359 upper_halves_are_equal ();
13361 upper_halves_are_unequal ();
13363 if (__builtin_mips_lower_c_eq_ps (a, b))
13364 lower_halves_are_equal ();
13366 lower_halves_are_unequal ();
13370 @node MIPS-3D Built-in Functions
13371 @subsubsection MIPS-3D Built-in Functions
13373 The MIPS-3D Application-Specific Extension (ASE) includes additional
13374 paired-single instructions that are designed to improve the performance
13375 of 3D graphics operations. Support for these instructions is controlled
13376 by the @option{-mips3d} command-line option.
13378 The functions listed below map directly to a particular MIPS-3D
13379 instruction. Please refer to the architecture specification for
13380 more details on what each instruction does.
13383 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13384 Reduction add (@code{addr.ps}).
13386 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13387 Reduction multiply (@code{mulr.ps}).
13389 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13390 Convert paired single to paired word (@code{cvt.pw.ps}).
13392 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13393 Convert paired word to paired single (@code{cvt.ps.pw}).
13395 @item float __builtin_mips_recip1_s (float)
13396 @itemx double __builtin_mips_recip1_d (double)
13397 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13398 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13400 @item float __builtin_mips_recip2_s (float, float)
13401 @itemx double __builtin_mips_recip2_d (double, double)
13402 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13403 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13405 @item float __builtin_mips_rsqrt1_s (float)
13406 @itemx double __builtin_mips_rsqrt1_d (double)
13407 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13408 Reduced-precision reciprocal square root (sequence step 1)
13409 (@code{rsqrt1.@var{fmt}}).
13411 @item float __builtin_mips_rsqrt2_s (float, float)
13412 @itemx double __builtin_mips_rsqrt2_d (double, double)
13413 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13414 Reduced-precision reciprocal square root (sequence step 2)
13415 (@code{rsqrt2.@var{fmt}}).
13418 The following multi-instruction functions are also available.
13419 In each case, @var{cond} can be any of the 16 floating-point conditions:
13420 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13421 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13422 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13425 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13426 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13427 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13428 @code{bc1t}/@code{bc1f}).
13430 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13431 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13436 if (__builtin_mips_cabs_eq_s (a, b))
13442 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13443 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13444 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13445 @code{bc1t}/@code{bc1f}).
13447 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13448 and return either the upper or lower half of the result. For example:
13452 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13453 upper_halves_are_equal ();
13455 upper_halves_are_unequal ();
13457 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13458 lower_halves_are_equal ();
13460 lower_halves_are_unequal ();
13463 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13464 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13465 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13466 @code{movt.ps}/@code{movf.ps}).
13468 The @code{movt} functions return the value @var{x} computed by:
13471 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13472 mov.ps @var{x},@var{c}
13473 movt.ps @var{x},@var{d},@var{cc}
13476 The @code{movf} functions are similar but use @code{movf.ps} instead
13479 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13480 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13481 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13482 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13483 Comparison of two paired-single values
13484 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13485 @code{bc1any2t}/@code{bc1any2f}).
13487 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13488 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13489 result is true and the @code{all} forms return true if both results are true.
13494 if (__builtin_mips_any_c_eq_ps (a, b))
13499 if (__builtin_mips_all_c_eq_ps (a, b))
13505 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13506 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13507 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13508 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13509 Comparison of four paired-single values
13510 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13511 @code{bc1any4t}/@code{bc1any4f}).
13513 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13514 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13515 The @code{any} forms return true if any of the four results are true
13516 and the @code{all} forms return true if all four results are true.
13521 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13526 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13533 @node Other MIPS Built-in Functions
13534 @subsection Other MIPS Built-in Functions
13536 GCC provides other MIPS-specific built-in functions:
13539 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13540 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13541 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13542 when this function is available.
13544 @item unsigned int __builtin_mips_get_fcsr (void)
13545 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13546 Get and set the contents of the floating-point control and status register
13547 (FPU control register 31). These functions are only available in hard-float
13548 code but can be called in both MIPS16 and non-MIPS16 contexts.
13550 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13551 register except the condition codes, which GCC assumes are preserved.
13554 @node MSP430 Built-in Functions
13555 @subsection MSP430 Built-in Functions
13557 GCC provides a couple of special builtin functions to aid in the
13558 writing of interrupt handlers in C.
13561 @item __bic_SR_register_on_exit (int @var{mask})
13562 This clears the indicated bits in the saved copy of the status register
13563 currently residing on the stack. This only works inside interrupt
13564 handlers and the changes to the status register will only take affect
13565 once the handler returns.
13567 @item __bis_SR_register_on_exit (int @var{mask})
13568 This sets the indicated bits in the saved copy of the status register
13569 currently residing on the stack. This only works inside interrupt
13570 handlers and the changes to the status register will only take affect
13571 once the handler returns.
13573 @item __delay_cycles (long long @var{cycles})
13574 This inserts an instruction sequence that takes exactly @var{cycles}
13575 cycles (between 0 and about 17E9) to complete. The inserted sequence
13576 may use jumps, loops, or no-ops, and does not interfere with any other
13577 instructions. Note that @var{cycles} must be a compile-time constant
13578 integer - that is, you must pass a number, not a variable that may be
13579 optimized to a constant later. The number of cycles delayed by this
13583 @node NDS32 Built-in Functions
13584 @subsection NDS32 Built-in Functions
13586 These built-in functions are available for the NDS32 target:
13588 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13589 Insert an ISYNC instruction into the instruction stream where
13590 @var{addr} is an instruction address for serialization.
13593 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13594 Insert an ISB instruction into the instruction stream.
13597 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13598 Return the content of a system register which is mapped by @var{sr}.
13601 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13602 Return the content of a user space register which is mapped by @var{usr}.
13605 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13606 Move the @var{value} to a system register which is mapped by @var{sr}.
13609 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13610 Move the @var{value} to a user space register which is mapped by @var{usr}.
13613 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13614 Enable global interrupt.
13617 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13618 Disable global interrupt.
13621 @node picoChip Built-in Functions
13622 @subsection picoChip Built-in Functions
13624 GCC provides an interface to selected machine instructions from the
13625 picoChip instruction set.
13628 @item int __builtin_sbc (int @var{value})
13629 Sign bit count. Return the number of consecutive bits in @var{value}
13630 that have the same value as the sign bit. The result is the number of
13631 leading sign bits minus one, giving the number of redundant sign bits in
13634 @item int __builtin_byteswap (int @var{value})
13635 Byte swap. Return the result of swapping the upper and lower bytes of
13638 @item int __builtin_brev (int @var{value})
13639 Bit reversal. Return the result of reversing the bits in
13640 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13643 @item int __builtin_adds (int @var{x}, int @var{y})
13644 Saturating addition. Return the result of adding @var{x} and @var{y},
13645 storing the value 32767 if the result overflows.
13647 @item int __builtin_subs (int @var{x}, int @var{y})
13648 Saturating subtraction. Return the result of subtracting @var{y} from
13649 @var{x}, storing the value @minus{}32768 if the result overflows.
13651 @item void __builtin_halt (void)
13652 Halt. The processor stops execution. This built-in is useful for
13653 implementing assertions.
13657 @node PowerPC Built-in Functions
13658 @subsection PowerPC Built-in Functions
13660 The following built-in functions are always available and can be used to
13661 check the PowerPC target platform type:
13663 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
13664 This function is a @code{nop} on the PowerPC platform and is included solely
13665 to maintain API compatibility with the x86 builtins.
13668 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
13669 This function returns a value of @code{1} if the run-time CPU is of type
13670 @var{cpuname} and returns @code{0} otherwise. The following CPU names can be
13675 IBM POWER9 Server CPU.
13677 IBM POWER8 Server CPU.
13679 IBM POWER7 Server CPU.
13681 IBM POWER6 Server CPU (RAW mode).
13683 IBM POWER6 Server CPU (Architected mode).
13685 IBM POWER5+ Server CPU.
13687 IBM POWER5 Server CPU.
13689 IBM 970 Server CPU (ie, Apple G5).
13691 IBM POWER4 Server CPU.
13693 IBM A2 64-bit Embedded CPU
13695 IBM PowerPC 476FP 32-bit Embedded CPU.
13697 IBM PowerPC 464 32-bit Embedded CPU.
13699 PowerPC 440 32-bit Embedded CPU.
13701 PowerPC 405 32-bit Embedded CPU.
13703 IBM PowerPC Cell Broadband Engine Architecture CPU.
13706 Here is an example:
13708 if (__builtin_cpu_is ("power8"))
13710 do_power8 (); // POWER8 specific implementation.
13714 do_generic (); // Generic implementation.
13719 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
13720 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
13721 feature @var{feature} and returns @code{0} otherwise. The following features can be
13726 4xx CPU has a Multiply Accumulator.
13728 CPU has a SIMD/Vector Unit.
13730 CPU supports ISA 2.05 (eg, POWER6)
13732 CPU supports ISA 2.06 (eg, POWER7)
13734 CPU supports ISA 2.07 (eg, POWER8)
13736 CPU supports ISA 3.0 (eg, POWER9)
13738 CPU supports the set of compatible performance monitoring events.
13740 CPU supports the Embedded ISA category.
13742 CPU has a CELL broadband engine.
13744 CPU has a decimal floating point unit.
13746 CPU supports the data stream control register.
13748 CPU supports event base branching.
13750 CPU has a SPE double precision floating point unit.
13752 CPU has a SPE single precision floating point unit.
13754 CPU has a floating point unit.
13756 CPU has hardware transaction memory instructions.
13758 Kernel aborts hardware transactions when a syscall is made.
13760 CPU supports icache snooping capabilities.
13762 CPU supports 128-bit IEEE binary floating point instructions.
13764 CPU supports the integer select instruction.
13766 CPU has a memory management unit.
13768 CPU does not have a timebase (eg, 601 and 403gx).
13770 CPU supports the PA Semi 6T CORE ISA.
13772 CPU supports ISA 2.00 (eg, POWER4)
13774 CPU supports ISA 2.02 (eg, POWER5)
13776 CPU supports ISA 2.03 (eg, POWER5+)
13778 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
13780 CPU supports 32-bit mode execution.
13782 CPU supports the old POWER ISA (eg, 601)
13784 CPU supports 64-bit mode execution.
13786 CPU supports a little-endian mode that uses address swizzling.
13788 CPU support simultaneous multi-threading.
13790 CPU has a signal processing extension unit.
13792 CPU supports the target address register.
13794 CPU supports true little-endian mode.
13796 CPU has unified I/D cache.
13798 CPU supports the vector cryptography instructions.
13800 CPU supports the vector-scalar extension.
13803 Here is an example:
13805 if (__builtin_cpu_supports ("fpu"))
13807 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
13811 dst = __fadd (src1, src2); // Software FP addition function.
13816 These built-in functions are available for the PowerPC family of
13819 float __builtin_recipdivf (float, float);
13820 float __builtin_rsqrtf (float);
13821 double __builtin_recipdiv (double, double);
13822 double __builtin_rsqrt (double);
13823 uint64_t __builtin_ppc_get_timebase ();
13824 unsigned long __builtin_ppc_mftb ();
13825 double __builtin_unpack_longdouble (long double, int);
13826 long double __builtin_pack_longdouble (double, double);
13829 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13830 @code{__builtin_rsqrtf} functions generate multiple instructions to
13831 implement the reciprocal sqrt functionality using reciprocal sqrt
13832 estimate instructions.
13834 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13835 functions generate multiple instructions to implement division using
13836 the reciprocal estimate instructions.
13838 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13839 functions generate instructions to read the Time Base Register. The
13840 @code{__builtin_ppc_get_timebase} function may generate multiple
13841 instructions and always returns the 64 bits of the Time Base Register.
13842 The @code{__builtin_ppc_mftb} function always generates one instruction and
13843 returns the Time Base Register value as an unsigned long, throwing away
13844 the most significant word on 32-bit environments.
13846 The following built-in functions are available for the PowerPC family
13847 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13848 or @option{-mpopcntd}):
13850 long __builtin_bpermd (long, long);
13851 int __builtin_divwe (int, int);
13852 int __builtin_divweo (int, int);
13853 unsigned int __builtin_divweu (unsigned int, unsigned int);
13854 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13855 long __builtin_divde (long, long);
13856 long __builtin_divdeo (long, long);
13857 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13858 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13859 unsigned int cdtbcd (unsigned int);
13860 unsigned int cbcdtd (unsigned int);
13861 unsigned int addg6s (unsigned int, unsigned int);
13864 The @code{__builtin_divde}, @code{__builtin_divdeo},
13865 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
13866 64-bit environment support ISA 2.06 or later.
13868 The following built-in functions are available for the PowerPC family
13869 of processors when hardware decimal floating point
13870 (@option{-mhard-dfp}) is available:
13872 _Decimal64 __builtin_dxex (_Decimal64);
13873 _Decimal128 __builtin_dxexq (_Decimal128);
13874 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13875 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13876 _Decimal64 __builtin_denbcd (int, _Decimal64);
13877 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13878 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13879 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13880 _Decimal64 __builtin_dscli (_Decimal64, int);
13881 _Decimal128 __builtin_dscliq (_Decimal128, int);
13882 _Decimal64 __builtin_dscri (_Decimal64, int);
13883 _Decimal128 __builtin_dscriq (_Decimal128, int);
13884 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13885 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13888 The following built-in functions are available for the PowerPC family
13889 of processors when the Vector Scalar (vsx) instruction set is
13892 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13893 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13894 unsigned long long);
13897 @node PowerPC AltiVec/VSX Built-in Functions
13898 @subsection PowerPC AltiVec Built-in Functions
13900 GCC provides an interface for the PowerPC family of processors to access
13901 the AltiVec operations described in Motorola's AltiVec Programming
13902 Interface Manual. The interface is made available by including
13903 @code{<altivec.h>} and using @option{-maltivec} and
13904 @option{-mabi=altivec}. The interface supports the following vector
13908 vector unsigned char
13912 vector unsigned short
13913 vector signed short
13917 vector unsigned int
13923 If @option{-mvsx} is used the following additional vector types are
13927 vector unsigned long
13932 The long types are only implemented for 64-bit code generation, and
13933 the long type is only used in the floating point/integer conversion
13936 GCC's implementation of the high-level language interface available from
13937 C and C++ code differs from Motorola's documentation in several ways.
13942 A vector constant is a list of constant expressions within curly braces.
13945 A vector initializer requires no cast if the vector constant is of the
13946 same type as the variable it is initializing.
13949 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13950 vector type is the default signedness of the base type. The default
13951 varies depending on the operating system, so a portable program should
13952 always specify the signedness.
13955 Compiling with @option{-maltivec} adds keywords @code{__vector},
13956 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13957 @code{bool}. When compiling ISO C, the context-sensitive substitution
13958 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13959 disabled. To use them, you must include @code{<altivec.h>} instead.
13962 GCC allows using a @code{typedef} name as the type specifier for a
13966 For C, overloaded functions are implemented with macros so the following
13970 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13974 Since @code{vec_add} is a macro, the vector constant in the example
13975 is treated as four separate arguments. Wrap the entire argument in
13976 parentheses for this to work.
13979 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13980 Internally, GCC uses built-in functions to achieve the functionality in
13981 the aforementioned header file, but they are not supported and are
13982 subject to change without notice.
13984 The following interfaces are supported for the generic and specific
13985 AltiVec operations and the AltiVec predicates. In cases where there
13986 is a direct mapping between generic and specific operations, only the
13987 generic names are shown here, although the specific operations can also
13990 Arguments that are documented as @code{const int} require literal
13991 integral values within the range required for that operation.
13994 vector signed char vec_abs (vector signed char);
13995 vector signed short vec_abs (vector signed short);
13996 vector signed int vec_abs (vector signed int);
13997 vector float vec_abs (vector float);
13999 vector signed char vec_abss (vector signed char);
14000 vector signed short vec_abss (vector signed short);
14001 vector signed int vec_abss (vector signed int);
14003 vector signed char vec_add (vector bool char, vector signed char);
14004 vector signed char vec_add (vector signed char, vector bool char);
14005 vector signed char vec_add (vector signed char, vector signed char);
14006 vector unsigned char vec_add (vector bool char, vector unsigned char);
14007 vector unsigned char vec_add (vector unsigned char, vector bool char);
14008 vector unsigned char vec_add (vector unsigned char,
14009 vector unsigned char);
14010 vector signed short vec_add (vector bool short, vector signed short);
14011 vector signed short vec_add (vector signed short, vector bool short);
14012 vector signed short vec_add (vector signed short, vector signed short);
14013 vector unsigned short vec_add (vector bool short,
14014 vector unsigned short);
14015 vector unsigned short vec_add (vector unsigned short,
14016 vector bool short);
14017 vector unsigned short vec_add (vector unsigned short,
14018 vector unsigned short);
14019 vector signed int vec_add (vector bool int, vector signed int);
14020 vector signed int vec_add (vector signed int, vector bool int);
14021 vector signed int vec_add (vector signed int, vector signed int);
14022 vector unsigned int vec_add (vector bool int, vector unsigned int);
14023 vector unsigned int vec_add (vector unsigned int, vector bool int);
14024 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
14025 vector float vec_add (vector float, vector float);
14027 vector float vec_vaddfp (vector float, vector float);
14029 vector signed int vec_vadduwm (vector bool int, vector signed int);
14030 vector signed int vec_vadduwm (vector signed int, vector bool int);
14031 vector signed int vec_vadduwm (vector signed int, vector signed int);
14032 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
14033 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
14034 vector unsigned int vec_vadduwm (vector unsigned int,
14035 vector unsigned int);
14037 vector signed short vec_vadduhm (vector bool short,
14038 vector signed short);
14039 vector signed short vec_vadduhm (vector signed short,
14040 vector bool short);
14041 vector signed short vec_vadduhm (vector signed short,
14042 vector signed short);
14043 vector unsigned short vec_vadduhm (vector bool short,
14044 vector unsigned short);
14045 vector unsigned short vec_vadduhm (vector unsigned short,
14046 vector bool short);
14047 vector unsigned short vec_vadduhm (vector unsigned short,
14048 vector unsigned short);
14050 vector signed char vec_vaddubm (vector bool char, vector signed char);
14051 vector signed char vec_vaddubm (vector signed char, vector bool char);
14052 vector signed char vec_vaddubm (vector signed char, vector signed char);
14053 vector unsigned char vec_vaddubm (vector bool char,
14054 vector unsigned char);
14055 vector unsigned char vec_vaddubm (vector unsigned char,
14057 vector unsigned char vec_vaddubm (vector unsigned char,
14058 vector unsigned char);
14060 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
14062 vector unsigned char vec_adds (vector bool char, vector unsigned char);
14063 vector unsigned char vec_adds (vector unsigned char, vector bool char);
14064 vector unsigned char vec_adds (vector unsigned char,
14065 vector unsigned char);
14066 vector signed char vec_adds (vector bool char, vector signed char);
14067 vector signed char vec_adds (vector signed char, vector bool char);
14068 vector signed char vec_adds (vector signed char, vector signed char);
14069 vector unsigned short vec_adds (vector bool short,
14070 vector unsigned short);
14071 vector unsigned short vec_adds (vector unsigned short,
14072 vector bool short);
14073 vector unsigned short vec_adds (vector unsigned short,
14074 vector unsigned short);
14075 vector signed short vec_adds (vector bool short, vector signed short);
14076 vector signed short vec_adds (vector signed short, vector bool short);
14077 vector signed short vec_adds (vector signed short, vector signed short);
14078 vector unsigned int vec_adds (vector bool int, vector unsigned int);
14079 vector unsigned int vec_adds (vector unsigned int, vector bool int);
14080 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
14081 vector signed int vec_adds (vector bool int, vector signed int);
14082 vector signed int vec_adds (vector signed int, vector bool int);
14083 vector signed int vec_adds (vector signed int, vector signed int);
14085 vector signed int vec_vaddsws (vector bool int, vector signed int);
14086 vector signed int vec_vaddsws (vector signed int, vector bool int);
14087 vector signed int vec_vaddsws (vector signed int, vector signed int);
14089 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
14090 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
14091 vector unsigned int vec_vadduws (vector unsigned int,
14092 vector unsigned int);
14094 vector signed short vec_vaddshs (vector bool short,
14095 vector signed short);
14096 vector signed short vec_vaddshs (vector signed short,
14097 vector bool short);
14098 vector signed short vec_vaddshs (vector signed short,
14099 vector signed short);
14101 vector unsigned short vec_vadduhs (vector bool short,
14102 vector unsigned short);
14103 vector unsigned short vec_vadduhs (vector unsigned short,
14104 vector bool short);
14105 vector unsigned short vec_vadduhs (vector unsigned short,
14106 vector unsigned short);
14108 vector signed char vec_vaddsbs (vector bool char, vector signed char);
14109 vector signed char vec_vaddsbs (vector signed char, vector bool char);
14110 vector signed char vec_vaddsbs (vector signed char, vector signed char);
14112 vector unsigned char vec_vaddubs (vector bool char,
14113 vector unsigned char);
14114 vector unsigned char vec_vaddubs (vector unsigned char,
14116 vector unsigned char vec_vaddubs (vector unsigned char,
14117 vector unsigned char);
14119 vector float vec_and (vector float, vector float);
14120 vector float vec_and (vector float, vector bool int);
14121 vector float vec_and (vector bool int, vector float);
14122 vector bool int vec_and (vector bool int, vector bool int);
14123 vector signed int vec_and (vector bool int, vector signed int);
14124 vector signed int vec_and (vector signed int, vector bool int);
14125 vector signed int vec_and (vector signed int, vector signed int);
14126 vector unsigned int vec_and (vector bool int, vector unsigned int);
14127 vector unsigned int vec_and (vector unsigned int, vector bool int);
14128 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
14129 vector bool short vec_and (vector bool short, vector bool short);
14130 vector signed short vec_and (vector bool short, vector signed short);
14131 vector signed short vec_and (vector signed short, vector bool short);
14132 vector signed short vec_and (vector signed short, vector signed short);
14133 vector unsigned short vec_and (vector bool short,
14134 vector unsigned short);
14135 vector unsigned short vec_and (vector unsigned short,
14136 vector bool short);
14137 vector unsigned short vec_and (vector unsigned short,
14138 vector unsigned short);
14139 vector signed char vec_and (vector bool char, vector signed char);
14140 vector bool char vec_and (vector bool char, vector bool char);
14141 vector signed char vec_and (vector signed char, vector bool char);
14142 vector signed char vec_and (vector signed char, vector signed char);
14143 vector unsigned char vec_and (vector bool char, vector unsigned char);
14144 vector unsigned char vec_and (vector unsigned char, vector bool char);
14145 vector unsigned char vec_and (vector unsigned char,
14146 vector unsigned char);
14148 vector float vec_andc (vector float, vector float);
14149 vector float vec_andc (vector float, vector bool int);
14150 vector float vec_andc (vector bool int, vector float);
14151 vector bool int vec_andc (vector bool int, vector bool int);
14152 vector signed int vec_andc (vector bool int, vector signed int);
14153 vector signed int vec_andc (vector signed int, vector bool int);
14154 vector signed int vec_andc (vector signed int, vector signed int);
14155 vector unsigned int vec_andc (vector bool int, vector unsigned int);
14156 vector unsigned int vec_andc (vector unsigned int, vector bool int);
14157 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
14158 vector bool short vec_andc (vector bool short, vector bool short);
14159 vector signed short vec_andc (vector bool short, vector signed short);
14160 vector signed short vec_andc (vector signed short, vector bool short);
14161 vector signed short vec_andc (vector signed short, vector signed short);
14162 vector unsigned short vec_andc (vector bool short,
14163 vector unsigned short);
14164 vector unsigned short vec_andc (vector unsigned short,
14165 vector bool short);
14166 vector unsigned short vec_andc (vector unsigned short,
14167 vector unsigned short);
14168 vector signed char vec_andc (vector bool char, vector signed char);
14169 vector bool char vec_andc (vector bool char, vector bool char);
14170 vector signed char vec_andc (vector signed char, vector bool char);
14171 vector signed char vec_andc (vector signed char, vector signed char);
14172 vector unsigned char vec_andc (vector bool char, vector unsigned char);
14173 vector unsigned char vec_andc (vector unsigned char, vector bool char);
14174 vector unsigned char vec_andc (vector unsigned char,
14175 vector unsigned char);
14177 vector unsigned char vec_avg (vector unsigned char,
14178 vector unsigned char);
14179 vector signed char vec_avg (vector signed char, vector signed char);
14180 vector unsigned short vec_avg (vector unsigned short,
14181 vector unsigned short);
14182 vector signed short vec_avg (vector signed short, vector signed short);
14183 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
14184 vector signed int vec_avg (vector signed int, vector signed int);
14186 vector signed int vec_vavgsw (vector signed int, vector signed int);
14188 vector unsigned int vec_vavguw (vector unsigned int,
14189 vector unsigned int);
14191 vector signed short vec_vavgsh (vector signed short,
14192 vector signed short);
14194 vector unsigned short vec_vavguh (vector unsigned short,
14195 vector unsigned short);
14197 vector signed char vec_vavgsb (vector signed char, vector signed char);
14199 vector unsigned char vec_vavgub (vector unsigned char,
14200 vector unsigned char);
14202 vector float vec_copysign (vector float);
14204 vector float vec_ceil (vector float);
14206 vector signed int vec_cmpb (vector float, vector float);
14208 vector bool char vec_cmpeq (vector signed char, vector signed char);
14209 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
14210 vector bool short vec_cmpeq (vector signed short, vector signed short);
14211 vector bool short vec_cmpeq (vector unsigned short,
14212 vector unsigned short);
14213 vector bool int vec_cmpeq (vector signed int, vector signed int);
14214 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
14215 vector bool int vec_cmpeq (vector float, vector float);
14217 vector bool int vec_vcmpeqfp (vector float, vector float);
14219 vector bool int vec_vcmpequw (vector signed int, vector signed int);
14220 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
14222 vector bool short vec_vcmpequh (vector signed short,
14223 vector signed short);
14224 vector bool short vec_vcmpequh (vector unsigned short,
14225 vector unsigned short);
14227 vector bool char vec_vcmpequb (vector signed char, vector signed char);
14228 vector bool char vec_vcmpequb (vector unsigned char,
14229 vector unsigned char);
14231 vector bool int vec_cmpge (vector float, vector float);
14233 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
14234 vector bool char vec_cmpgt (vector signed char, vector signed char);
14235 vector bool short vec_cmpgt (vector unsigned short,
14236 vector unsigned short);
14237 vector bool short vec_cmpgt (vector signed short, vector signed short);
14238 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
14239 vector bool int vec_cmpgt (vector signed int, vector signed int);
14240 vector bool int vec_cmpgt (vector float, vector float);
14242 vector bool int vec_vcmpgtfp (vector float, vector float);
14244 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
14246 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
14248 vector bool short vec_vcmpgtsh (vector signed short,
14249 vector signed short);
14251 vector bool short vec_vcmpgtuh (vector unsigned short,
14252 vector unsigned short);
14254 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
14256 vector bool char vec_vcmpgtub (vector unsigned char,
14257 vector unsigned char);
14259 vector bool int vec_cmple (vector float, vector float);
14261 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
14262 vector bool char vec_cmplt (vector signed char, vector signed char);
14263 vector bool short vec_cmplt (vector unsigned short,
14264 vector unsigned short);
14265 vector bool short vec_cmplt (vector signed short, vector signed short);
14266 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
14267 vector bool int vec_cmplt (vector signed int, vector signed int);
14268 vector bool int vec_cmplt (vector float, vector float);
14270 vector float vec_cpsgn (vector float, vector float);
14272 vector float vec_ctf (vector unsigned int, const int);
14273 vector float vec_ctf (vector signed int, const int);
14274 vector double vec_ctf (vector unsigned long, const int);
14275 vector double vec_ctf (vector signed long, const int);
14277 vector float vec_vcfsx (vector signed int, const int);
14279 vector float vec_vcfux (vector unsigned int, const int);
14281 vector signed int vec_cts (vector float, const int);
14282 vector signed long vec_cts (vector double, const int);
14284 vector unsigned int vec_ctu (vector float, const int);
14285 vector unsigned long vec_ctu (vector double, const int);
14287 void vec_dss (const int);
14289 void vec_dssall (void);
14291 void vec_dst (const vector unsigned char *, int, const int);
14292 void vec_dst (const vector signed char *, int, const int);
14293 void vec_dst (const vector bool char *, int, const int);
14294 void vec_dst (const vector unsigned short *, int, const int);
14295 void vec_dst (const vector signed short *, int, const int);
14296 void vec_dst (const vector bool short *, int, const int);
14297 void vec_dst (const vector pixel *, int, const int);
14298 void vec_dst (const vector unsigned int *, int, const int);
14299 void vec_dst (const vector signed int *, int, const int);
14300 void vec_dst (const vector bool int *, int, const int);
14301 void vec_dst (const vector float *, int, const int);
14302 void vec_dst (const unsigned char *, int, const int);
14303 void vec_dst (const signed char *, int, const int);
14304 void vec_dst (const unsigned short *, int, const int);
14305 void vec_dst (const short *, int, const int);
14306 void vec_dst (const unsigned int *, int, const int);
14307 void vec_dst (const int *, int, const int);
14308 void vec_dst (const unsigned long *, int, const int);
14309 void vec_dst (const long *, int, const int);
14310 void vec_dst (const float *, int, const int);
14312 void vec_dstst (const vector unsigned char *, int, const int);
14313 void vec_dstst (const vector signed char *, int, const int);
14314 void vec_dstst (const vector bool char *, int, const int);
14315 void vec_dstst (const vector unsigned short *, int, const int);
14316 void vec_dstst (const vector signed short *, int, const int);
14317 void vec_dstst (const vector bool short *, int, const int);
14318 void vec_dstst (const vector pixel *, int, const int);
14319 void vec_dstst (const vector unsigned int *, int, const int);
14320 void vec_dstst (const vector signed int *, int, const int);
14321 void vec_dstst (const vector bool int *, int, const int);
14322 void vec_dstst (const vector float *, int, const int);
14323 void vec_dstst (const unsigned char *, int, const int);
14324 void vec_dstst (const signed char *, int, const int);
14325 void vec_dstst (const unsigned short *, int, const int);
14326 void vec_dstst (const short *, int, const int);
14327 void vec_dstst (const unsigned int *, int, const int);
14328 void vec_dstst (const int *, int, const int);
14329 void vec_dstst (const unsigned long *, int, const int);
14330 void vec_dstst (const long *, int, const int);
14331 void vec_dstst (const float *, int, const int);
14333 void vec_dststt (const vector unsigned char *, int, const int);
14334 void vec_dststt (const vector signed char *, int, const int);
14335 void vec_dststt (const vector bool char *, int, const int);
14336 void vec_dststt (const vector unsigned short *, int, const int);
14337 void vec_dststt (const vector signed short *, int, const int);
14338 void vec_dststt (const vector bool short *, int, const int);
14339 void vec_dststt (const vector pixel *, int, const int);
14340 void vec_dststt (const vector unsigned int *, int, const int);
14341 void vec_dststt (const vector signed int *, int, const int);
14342 void vec_dststt (const vector bool int *, int, const int);
14343 void vec_dststt (const vector float *, int, const int);
14344 void vec_dststt (const unsigned char *, int, const int);
14345 void vec_dststt (const signed char *, int, const int);
14346 void vec_dststt (const unsigned short *, int, const int);
14347 void vec_dststt (const short *, int, const int);
14348 void vec_dststt (const unsigned int *, int, const int);
14349 void vec_dststt (const int *, int, const int);
14350 void vec_dststt (const unsigned long *, int, const int);
14351 void vec_dststt (const long *, int, const int);
14352 void vec_dststt (const float *, int, const int);
14354 void vec_dstt (const vector unsigned char *, int, const int);
14355 void vec_dstt (const vector signed char *, int, const int);
14356 void vec_dstt (const vector bool char *, int, const int);
14357 void vec_dstt (const vector unsigned short *, int, const int);
14358 void vec_dstt (const vector signed short *, int, const int);
14359 void vec_dstt (const vector bool short *, int, const int);
14360 void vec_dstt (const vector pixel *, int, const int);
14361 void vec_dstt (const vector unsigned int *, int, const int);
14362 void vec_dstt (const vector signed int *, int, const int);
14363 void vec_dstt (const vector bool int *, int, const int);
14364 void vec_dstt (const vector float *, int, const int);
14365 void vec_dstt (const unsigned char *, int, const int);
14366 void vec_dstt (const signed char *, int, const int);
14367 void vec_dstt (const unsigned short *, int, const int);
14368 void vec_dstt (const short *, int, const int);
14369 void vec_dstt (const unsigned int *, int, const int);
14370 void vec_dstt (const int *, int, const int);
14371 void vec_dstt (const unsigned long *, int, const int);
14372 void vec_dstt (const long *, int, const int);
14373 void vec_dstt (const float *, int, const int);
14375 vector float vec_expte (vector float);
14377 vector float vec_floor (vector float);
14379 vector float vec_ld (int, const vector float *);
14380 vector float vec_ld (int, const float *);
14381 vector bool int vec_ld (int, const vector bool int *);
14382 vector signed int vec_ld (int, const vector signed int *);
14383 vector signed int vec_ld (int, const int *);
14384 vector signed int vec_ld (int, const long *);
14385 vector unsigned int vec_ld (int, const vector unsigned int *);
14386 vector unsigned int vec_ld (int, const unsigned int *);
14387 vector unsigned int vec_ld (int, const unsigned long *);
14388 vector bool short vec_ld (int, const vector bool short *);
14389 vector pixel vec_ld (int, const vector pixel *);
14390 vector signed short vec_ld (int, const vector signed short *);
14391 vector signed short vec_ld (int, const short *);
14392 vector unsigned short vec_ld (int, const vector unsigned short *);
14393 vector unsigned short vec_ld (int, const unsigned short *);
14394 vector bool char vec_ld (int, const vector bool char *);
14395 vector signed char vec_ld (int, const vector signed char *);
14396 vector signed char vec_ld (int, const signed char *);
14397 vector unsigned char vec_ld (int, const vector unsigned char *);
14398 vector unsigned char vec_ld (int, const unsigned char *);
14400 vector signed char vec_lde (int, const signed char *);
14401 vector unsigned char vec_lde (int, const unsigned char *);
14402 vector signed short vec_lde (int, const short *);
14403 vector unsigned short vec_lde (int, const unsigned short *);
14404 vector float vec_lde (int, const float *);
14405 vector signed int vec_lde (int, const int *);
14406 vector unsigned int vec_lde (int, const unsigned int *);
14407 vector signed int vec_lde (int, const long *);
14408 vector unsigned int vec_lde (int, const unsigned long *);
14410 vector float vec_lvewx (int, float *);
14411 vector signed int vec_lvewx (int, int *);
14412 vector unsigned int vec_lvewx (int, unsigned int *);
14413 vector signed int vec_lvewx (int, long *);
14414 vector unsigned int vec_lvewx (int, unsigned long *);
14416 vector signed short vec_lvehx (int, short *);
14417 vector unsigned short vec_lvehx (int, unsigned short *);
14419 vector signed char vec_lvebx (int, char *);
14420 vector unsigned char vec_lvebx (int, unsigned char *);
14422 vector float vec_ldl (int, const vector float *);
14423 vector float vec_ldl (int, const float *);
14424 vector bool int vec_ldl (int, const vector bool int *);
14425 vector signed int vec_ldl (int, const vector signed int *);
14426 vector signed int vec_ldl (int, const int *);
14427 vector signed int vec_ldl (int, const long *);
14428 vector unsigned int vec_ldl (int, const vector unsigned int *);
14429 vector unsigned int vec_ldl (int, const unsigned int *);
14430 vector unsigned int vec_ldl (int, const unsigned long *);
14431 vector bool short vec_ldl (int, const vector bool short *);
14432 vector pixel vec_ldl (int, const vector pixel *);
14433 vector signed short vec_ldl (int, const vector signed short *);
14434 vector signed short vec_ldl (int, const short *);
14435 vector unsigned short vec_ldl (int, const vector unsigned short *);
14436 vector unsigned short vec_ldl (int, const unsigned short *);
14437 vector bool char vec_ldl (int, const vector bool char *);
14438 vector signed char vec_ldl (int, const vector signed char *);
14439 vector signed char vec_ldl (int, const signed char *);
14440 vector unsigned char vec_ldl (int, const vector unsigned char *);
14441 vector unsigned char vec_ldl (int, const unsigned char *);
14443 vector float vec_loge (vector float);
14445 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14446 vector unsigned char vec_lvsl (int, const volatile signed char *);
14447 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14448 vector unsigned char vec_lvsl (int, const volatile short *);
14449 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14450 vector unsigned char vec_lvsl (int, const volatile int *);
14451 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14452 vector unsigned char vec_lvsl (int, const volatile long *);
14453 vector unsigned char vec_lvsl (int, const volatile float *);
14455 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14456 vector unsigned char vec_lvsr (int, const volatile signed char *);
14457 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14458 vector unsigned char vec_lvsr (int, const volatile short *);
14459 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14460 vector unsigned char vec_lvsr (int, const volatile int *);
14461 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14462 vector unsigned char vec_lvsr (int, const volatile long *);
14463 vector unsigned char vec_lvsr (int, const volatile float *);
14465 vector float vec_madd (vector float, vector float, vector float);
14467 vector signed short vec_madds (vector signed short,
14468 vector signed short,
14469 vector signed short);
14471 vector unsigned char vec_max (vector bool char, vector unsigned char);
14472 vector unsigned char vec_max (vector unsigned char, vector bool char);
14473 vector unsigned char vec_max (vector unsigned char,
14474 vector unsigned char);
14475 vector signed char vec_max (vector bool char, vector signed char);
14476 vector signed char vec_max (vector signed char, vector bool char);
14477 vector signed char vec_max (vector signed char, vector signed char);
14478 vector unsigned short vec_max (vector bool short,
14479 vector unsigned short);
14480 vector unsigned short vec_max (vector unsigned short,
14481 vector bool short);
14482 vector unsigned short vec_max (vector unsigned short,
14483 vector unsigned short);
14484 vector signed short vec_max (vector bool short, vector signed short);
14485 vector signed short vec_max (vector signed short, vector bool short);
14486 vector signed short vec_max (vector signed short, vector signed short);
14487 vector unsigned int vec_max (vector bool int, vector unsigned int);
14488 vector unsigned int vec_max (vector unsigned int, vector bool int);
14489 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14490 vector signed int vec_max (vector bool int, vector signed int);
14491 vector signed int vec_max (vector signed int, vector bool int);
14492 vector signed int vec_max (vector signed int, vector signed int);
14493 vector float vec_max (vector float, vector float);
14495 vector float vec_vmaxfp (vector float, vector float);
14497 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14498 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14499 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14501 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14502 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14503 vector unsigned int vec_vmaxuw (vector unsigned int,
14504 vector unsigned int);
14506 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14507 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14508 vector signed short vec_vmaxsh (vector signed short,
14509 vector signed short);
14511 vector unsigned short vec_vmaxuh (vector bool short,
14512 vector unsigned short);
14513 vector unsigned short vec_vmaxuh (vector unsigned short,
14514 vector bool short);
14515 vector unsigned short vec_vmaxuh (vector unsigned short,
14516 vector unsigned short);
14518 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14519 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14520 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14522 vector unsigned char vec_vmaxub (vector bool char,
14523 vector unsigned char);
14524 vector unsigned char vec_vmaxub (vector unsigned char,
14526 vector unsigned char vec_vmaxub (vector unsigned char,
14527 vector unsigned char);
14529 vector bool char vec_mergeh (vector bool char, vector bool char);
14530 vector signed char vec_mergeh (vector signed char, vector signed char);
14531 vector unsigned char vec_mergeh (vector unsigned char,
14532 vector unsigned char);
14533 vector bool short vec_mergeh (vector bool short, vector bool short);
14534 vector pixel vec_mergeh (vector pixel, vector pixel);
14535 vector signed short vec_mergeh (vector signed short,
14536 vector signed short);
14537 vector unsigned short vec_mergeh (vector unsigned short,
14538 vector unsigned short);
14539 vector float vec_mergeh (vector float, vector float);
14540 vector bool int vec_mergeh (vector bool int, vector bool int);
14541 vector signed int vec_mergeh (vector signed int, vector signed int);
14542 vector unsigned int vec_mergeh (vector unsigned int,
14543 vector unsigned int);
14545 vector float vec_vmrghw (vector float, vector float);
14546 vector bool int vec_vmrghw (vector bool int, vector bool int);
14547 vector signed int vec_vmrghw (vector signed int, vector signed int);
14548 vector unsigned int vec_vmrghw (vector unsigned int,
14549 vector unsigned int);
14551 vector bool short vec_vmrghh (vector bool short, vector bool short);
14552 vector signed short vec_vmrghh (vector signed short,
14553 vector signed short);
14554 vector unsigned short vec_vmrghh (vector unsigned short,
14555 vector unsigned short);
14556 vector pixel vec_vmrghh (vector pixel, vector pixel);
14558 vector bool char vec_vmrghb (vector bool char, vector bool char);
14559 vector signed char vec_vmrghb (vector signed char, vector signed char);
14560 vector unsigned char vec_vmrghb (vector unsigned char,
14561 vector unsigned char);
14563 vector bool char vec_mergel (vector bool char, vector bool char);
14564 vector signed char vec_mergel (vector signed char, vector signed char);
14565 vector unsigned char vec_mergel (vector unsigned char,
14566 vector unsigned char);
14567 vector bool short vec_mergel (vector bool short, vector bool short);
14568 vector pixel vec_mergel (vector pixel, vector pixel);
14569 vector signed short vec_mergel (vector signed short,
14570 vector signed short);
14571 vector unsigned short vec_mergel (vector unsigned short,
14572 vector unsigned short);
14573 vector float vec_mergel (vector float, vector float);
14574 vector bool int vec_mergel (vector bool int, vector bool int);
14575 vector signed int vec_mergel (vector signed int, vector signed int);
14576 vector unsigned int vec_mergel (vector unsigned int,
14577 vector unsigned int);
14579 vector float vec_vmrglw (vector float, vector float);
14580 vector signed int vec_vmrglw (vector signed int, vector signed int);
14581 vector unsigned int vec_vmrglw (vector unsigned int,
14582 vector unsigned int);
14583 vector bool int vec_vmrglw (vector bool int, vector bool int);
14585 vector bool short vec_vmrglh (vector bool short, vector bool short);
14586 vector signed short vec_vmrglh (vector signed short,
14587 vector signed short);
14588 vector unsigned short vec_vmrglh (vector unsigned short,
14589 vector unsigned short);
14590 vector pixel vec_vmrglh (vector pixel, vector pixel);
14592 vector bool char vec_vmrglb (vector bool char, vector bool char);
14593 vector signed char vec_vmrglb (vector signed char, vector signed char);
14594 vector unsigned char vec_vmrglb (vector unsigned char,
14595 vector unsigned char);
14597 vector unsigned short vec_mfvscr (void);
14599 vector unsigned char vec_min (vector bool char, vector unsigned char);
14600 vector unsigned char vec_min (vector unsigned char, vector bool char);
14601 vector unsigned char vec_min (vector unsigned char,
14602 vector unsigned char);
14603 vector signed char vec_min (vector bool char, vector signed char);
14604 vector signed char vec_min (vector signed char, vector bool char);
14605 vector signed char vec_min (vector signed char, vector signed char);
14606 vector unsigned short vec_min (vector bool short,
14607 vector unsigned short);
14608 vector unsigned short vec_min (vector unsigned short,
14609 vector bool short);
14610 vector unsigned short vec_min (vector unsigned short,
14611 vector unsigned short);
14612 vector signed short vec_min (vector bool short, vector signed short);
14613 vector signed short vec_min (vector signed short, vector bool short);
14614 vector signed short vec_min (vector signed short, vector signed short);
14615 vector unsigned int vec_min (vector bool int, vector unsigned int);
14616 vector unsigned int vec_min (vector unsigned int, vector bool int);
14617 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14618 vector signed int vec_min (vector bool int, vector signed int);
14619 vector signed int vec_min (vector signed int, vector bool int);
14620 vector signed int vec_min (vector signed int, vector signed int);
14621 vector float vec_min (vector float, vector float);
14623 vector float vec_vminfp (vector float, vector float);
14625 vector signed int vec_vminsw (vector bool int, vector signed int);
14626 vector signed int vec_vminsw (vector signed int, vector bool int);
14627 vector signed int vec_vminsw (vector signed int, vector signed int);
14629 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14630 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14631 vector unsigned int vec_vminuw (vector unsigned int,
14632 vector unsigned int);
14634 vector signed short vec_vminsh (vector bool short, vector signed short);
14635 vector signed short vec_vminsh (vector signed short, vector bool short);
14636 vector signed short vec_vminsh (vector signed short,
14637 vector signed short);
14639 vector unsigned short vec_vminuh (vector bool short,
14640 vector unsigned short);
14641 vector unsigned short vec_vminuh (vector unsigned short,
14642 vector bool short);
14643 vector unsigned short vec_vminuh (vector unsigned short,
14644 vector unsigned short);
14646 vector signed char vec_vminsb (vector bool char, vector signed char);
14647 vector signed char vec_vminsb (vector signed char, vector bool char);
14648 vector signed char vec_vminsb (vector signed char, vector signed char);
14650 vector unsigned char vec_vminub (vector bool char,
14651 vector unsigned char);
14652 vector unsigned char vec_vminub (vector unsigned char,
14654 vector unsigned char vec_vminub (vector unsigned char,
14655 vector unsigned char);
14657 vector signed short vec_mladd (vector signed short,
14658 vector signed short,
14659 vector signed short);
14660 vector signed short vec_mladd (vector signed short,
14661 vector unsigned short,
14662 vector unsigned short);
14663 vector signed short vec_mladd (vector unsigned short,
14664 vector signed short,
14665 vector signed short);
14666 vector unsigned short vec_mladd (vector unsigned short,
14667 vector unsigned short,
14668 vector unsigned short);
14670 vector signed short vec_mradds (vector signed short,
14671 vector signed short,
14672 vector signed short);
14674 vector unsigned int vec_msum (vector unsigned char,
14675 vector unsigned char,
14676 vector unsigned int);
14677 vector signed int vec_msum (vector signed char,
14678 vector unsigned char,
14679 vector signed int);
14680 vector unsigned int vec_msum (vector unsigned short,
14681 vector unsigned short,
14682 vector unsigned int);
14683 vector signed int vec_msum (vector signed short,
14684 vector signed short,
14685 vector signed int);
14687 vector signed int vec_vmsumshm (vector signed short,
14688 vector signed short,
14689 vector signed int);
14691 vector unsigned int vec_vmsumuhm (vector unsigned short,
14692 vector unsigned short,
14693 vector unsigned int);
14695 vector signed int vec_vmsummbm (vector signed char,
14696 vector unsigned char,
14697 vector signed int);
14699 vector unsigned int vec_vmsumubm (vector unsigned char,
14700 vector unsigned char,
14701 vector unsigned int);
14703 vector unsigned int vec_msums (vector unsigned short,
14704 vector unsigned short,
14705 vector unsigned int);
14706 vector signed int vec_msums (vector signed short,
14707 vector signed short,
14708 vector signed int);
14710 vector signed int vec_vmsumshs (vector signed short,
14711 vector signed short,
14712 vector signed int);
14714 vector unsigned int vec_vmsumuhs (vector unsigned short,
14715 vector unsigned short,
14716 vector unsigned int);
14718 void vec_mtvscr (vector signed int);
14719 void vec_mtvscr (vector unsigned int);
14720 void vec_mtvscr (vector bool int);
14721 void vec_mtvscr (vector signed short);
14722 void vec_mtvscr (vector unsigned short);
14723 void vec_mtvscr (vector bool short);
14724 void vec_mtvscr (vector pixel);
14725 void vec_mtvscr (vector signed char);
14726 void vec_mtvscr (vector unsigned char);
14727 void vec_mtvscr (vector bool char);
14729 vector unsigned short vec_mule (vector unsigned char,
14730 vector unsigned char);
14731 vector signed short vec_mule (vector signed char,
14732 vector signed char);
14733 vector unsigned int vec_mule (vector unsigned short,
14734 vector unsigned short);
14735 vector signed int vec_mule (vector signed short, vector signed short);
14737 vector signed int vec_vmulesh (vector signed short,
14738 vector signed short);
14740 vector unsigned int vec_vmuleuh (vector unsigned short,
14741 vector unsigned short);
14743 vector signed short vec_vmulesb (vector signed char,
14744 vector signed char);
14746 vector unsigned short vec_vmuleub (vector unsigned char,
14747 vector unsigned char);
14749 vector unsigned short vec_mulo (vector unsigned char,
14750 vector unsigned char);
14751 vector signed short vec_mulo (vector signed char, vector signed char);
14752 vector unsigned int vec_mulo (vector unsigned short,
14753 vector unsigned short);
14754 vector signed int vec_mulo (vector signed short, vector signed short);
14756 vector signed int vec_vmulosh (vector signed short,
14757 vector signed short);
14759 vector unsigned int vec_vmulouh (vector unsigned short,
14760 vector unsigned short);
14762 vector signed short vec_vmulosb (vector signed char,
14763 vector signed char);
14765 vector unsigned short vec_vmuloub (vector unsigned char,
14766 vector unsigned char);
14768 vector float vec_nmsub (vector float, vector float, vector float);
14770 vector float vec_nor (vector float, vector float);
14771 vector signed int vec_nor (vector signed int, vector signed int);
14772 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14773 vector bool int vec_nor (vector bool int, vector bool int);
14774 vector signed short vec_nor (vector signed short, vector signed short);
14775 vector unsigned short vec_nor (vector unsigned short,
14776 vector unsigned short);
14777 vector bool short vec_nor (vector bool short, vector bool short);
14778 vector signed char vec_nor (vector signed char, vector signed char);
14779 vector unsigned char vec_nor (vector unsigned char,
14780 vector unsigned char);
14781 vector bool char vec_nor (vector bool char, vector bool char);
14783 vector float vec_or (vector float, vector float);
14784 vector float vec_or (vector float, vector bool int);
14785 vector float vec_or (vector bool int, vector float);
14786 vector bool int vec_or (vector bool int, vector bool int);
14787 vector signed int vec_or (vector bool int, vector signed int);
14788 vector signed int vec_or (vector signed int, vector bool int);
14789 vector signed int vec_or (vector signed int, vector signed int);
14790 vector unsigned int vec_or (vector bool int, vector unsigned int);
14791 vector unsigned int vec_or (vector unsigned int, vector bool int);
14792 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14793 vector bool short vec_or (vector bool short, vector bool short);
14794 vector signed short vec_or (vector bool short, vector signed short);
14795 vector signed short vec_or (vector signed short, vector bool short);
14796 vector signed short vec_or (vector signed short, vector signed short);
14797 vector unsigned short vec_or (vector bool short, vector unsigned short);
14798 vector unsigned short vec_or (vector unsigned short, vector bool short);
14799 vector unsigned short vec_or (vector unsigned short,
14800 vector unsigned short);
14801 vector signed char vec_or (vector bool char, vector signed char);
14802 vector bool char vec_or (vector bool char, vector bool char);
14803 vector signed char vec_or (vector signed char, vector bool char);
14804 vector signed char vec_or (vector signed char, vector signed char);
14805 vector unsigned char vec_or (vector bool char, vector unsigned char);
14806 vector unsigned char vec_or (vector unsigned char, vector bool char);
14807 vector unsigned char vec_or (vector unsigned char,
14808 vector unsigned char);
14810 vector signed char vec_pack (vector signed short, vector signed short);
14811 vector unsigned char vec_pack (vector unsigned short,
14812 vector unsigned short);
14813 vector bool char vec_pack (vector bool short, vector bool short);
14814 vector signed short vec_pack (vector signed int, vector signed int);
14815 vector unsigned short vec_pack (vector unsigned int,
14816 vector unsigned int);
14817 vector bool short vec_pack (vector bool int, vector bool int);
14819 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14820 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14821 vector unsigned short vec_vpkuwum (vector unsigned int,
14822 vector unsigned int);
14824 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14825 vector signed char vec_vpkuhum (vector signed short,
14826 vector signed short);
14827 vector unsigned char vec_vpkuhum (vector unsigned short,
14828 vector unsigned short);
14830 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14832 vector unsigned char vec_packs (vector unsigned short,
14833 vector unsigned short);
14834 vector signed char vec_packs (vector signed short, vector signed short);
14835 vector unsigned short vec_packs (vector unsigned int,
14836 vector unsigned int);
14837 vector signed short vec_packs (vector signed int, vector signed int);
14839 vector signed short vec_vpkswss (vector signed int, vector signed int);
14841 vector unsigned short vec_vpkuwus (vector unsigned int,
14842 vector unsigned int);
14844 vector signed char vec_vpkshss (vector signed short,
14845 vector signed short);
14847 vector unsigned char vec_vpkuhus (vector unsigned short,
14848 vector unsigned short);
14850 vector unsigned char vec_packsu (vector unsigned short,
14851 vector unsigned short);
14852 vector unsigned char vec_packsu (vector signed short,
14853 vector signed short);
14854 vector unsigned short vec_packsu (vector unsigned int,
14855 vector unsigned int);
14856 vector unsigned short vec_packsu (vector signed int, vector signed int);
14858 vector unsigned short vec_vpkswus (vector signed int,
14859 vector signed int);
14861 vector unsigned char vec_vpkshus (vector signed short,
14862 vector signed short);
14864 vector float vec_perm (vector float,
14866 vector unsigned char);
14867 vector signed int vec_perm (vector signed int,
14869 vector unsigned char);
14870 vector unsigned int vec_perm (vector unsigned int,
14871 vector unsigned int,
14872 vector unsigned char);
14873 vector bool int vec_perm (vector bool int,
14875 vector unsigned char);
14876 vector signed short vec_perm (vector signed short,
14877 vector signed short,
14878 vector unsigned char);
14879 vector unsigned short vec_perm (vector unsigned short,
14880 vector unsigned short,
14881 vector unsigned char);
14882 vector bool short vec_perm (vector bool short,
14884 vector unsigned char);
14885 vector pixel vec_perm (vector pixel,
14887 vector unsigned char);
14888 vector signed char vec_perm (vector signed char,
14889 vector signed char,
14890 vector unsigned char);
14891 vector unsigned char vec_perm (vector unsigned char,
14892 vector unsigned char,
14893 vector unsigned char);
14894 vector bool char vec_perm (vector bool char,
14896 vector unsigned char);
14898 vector float vec_re (vector float);
14900 vector signed char vec_rl (vector signed char,
14901 vector unsigned char);
14902 vector unsigned char vec_rl (vector unsigned char,
14903 vector unsigned char);
14904 vector signed short vec_rl (vector signed short, vector unsigned short);
14905 vector unsigned short vec_rl (vector unsigned short,
14906 vector unsigned short);
14907 vector signed int vec_rl (vector signed int, vector unsigned int);
14908 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14910 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14911 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14913 vector signed short vec_vrlh (vector signed short,
14914 vector unsigned short);
14915 vector unsigned short vec_vrlh (vector unsigned short,
14916 vector unsigned short);
14918 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14919 vector unsigned char vec_vrlb (vector unsigned char,
14920 vector unsigned char);
14922 vector float vec_round (vector float);
14924 vector float vec_recip (vector float, vector float);
14926 vector float vec_rsqrt (vector float);
14928 vector float vec_rsqrte (vector float);
14930 vector float vec_sel (vector float, vector float, vector bool int);
14931 vector float vec_sel (vector float, vector float, vector unsigned int);
14932 vector signed int vec_sel (vector signed int,
14935 vector signed int vec_sel (vector signed int,
14937 vector unsigned int);
14938 vector unsigned int vec_sel (vector unsigned int,
14939 vector unsigned int,
14941 vector unsigned int vec_sel (vector unsigned int,
14942 vector unsigned int,
14943 vector unsigned int);
14944 vector bool int vec_sel (vector bool int,
14947 vector bool int vec_sel (vector bool int,
14949 vector unsigned int);
14950 vector signed short vec_sel (vector signed short,
14951 vector signed short,
14952 vector bool short);
14953 vector signed short vec_sel (vector signed short,
14954 vector signed short,
14955 vector unsigned short);
14956 vector unsigned short vec_sel (vector unsigned short,
14957 vector unsigned short,
14958 vector bool short);
14959 vector unsigned short vec_sel (vector unsigned short,
14960 vector unsigned short,
14961 vector unsigned short);
14962 vector bool short vec_sel (vector bool short,
14964 vector bool short);
14965 vector bool short vec_sel (vector bool short,
14967 vector unsigned short);
14968 vector signed char vec_sel (vector signed char,
14969 vector signed char,
14971 vector signed char vec_sel (vector signed char,
14972 vector signed char,
14973 vector unsigned char);
14974 vector unsigned char vec_sel (vector unsigned char,
14975 vector unsigned char,
14977 vector unsigned char vec_sel (vector unsigned char,
14978 vector unsigned char,
14979 vector unsigned char);
14980 vector bool char vec_sel (vector bool char,
14983 vector bool char vec_sel (vector bool char,
14985 vector unsigned char);
14987 vector signed char vec_sl (vector signed char,
14988 vector unsigned char);
14989 vector unsigned char vec_sl (vector unsigned char,
14990 vector unsigned char);
14991 vector signed short vec_sl (vector signed short, vector unsigned short);
14992 vector unsigned short vec_sl (vector unsigned short,
14993 vector unsigned short);
14994 vector signed int vec_sl (vector signed int, vector unsigned int);
14995 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14997 vector signed int vec_vslw (vector signed int, vector unsigned int);
14998 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
15000 vector signed short vec_vslh (vector signed short,
15001 vector unsigned short);
15002 vector unsigned short vec_vslh (vector unsigned short,
15003 vector unsigned short);
15005 vector signed char vec_vslb (vector signed char, vector unsigned char);
15006 vector unsigned char vec_vslb (vector unsigned char,
15007 vector unsigned char);
15009 vector float vec_sld (vector float, vector float, const int);
15010 vector signed int vec_sld (vector signed int,
15013 vector unsigned int vec_sld (vector unsigned int,
15014 vector unsigned int,
15016 vector bool int vec_sld (vector bool int,
15019 vector signed short vec_sld (vector signed short,
15020 vector signed short,
15022 vector unsigned short vec_sld (vector unsigned short,
15023 vector unsigned short,
15025 vector bool short vec_sld (vector bool short,
15028 vector pixel vec_sld (vector pixel,
15031 vector signed char vec_sld (vector signed char,
15032 vector signed char,
15034 vector unsigned char vec_sld (vector unsigned char,
15035 vector unsigned char,
15037 vector bool char vec_sld (vector bool char,
15041 vector signed int vec_sll (vector signed int,
15042 vector unsigned int);
15043 vector signed int vec_sll (vector signed int,
15044 vector unsigned short);
15045 vector signed int vec_sll (vector signed int,
15046 vector unsigned char);
15047 vector unsigned int vec_sll (vector unsigned int,
15048 vector unsigned int);
15049 vector unsigned int vec_sll (vector unsigned int,
15050 vector unsigned short);
15051 vector unsigned int vec_sll (vector unsigned int,
15052 vector unsigned char);
15053 vector bool int vec_sll (vector bool int,
15054 vector unsigned int);
15055 vector bool int vec_sll (vector bool int,
15056 vector unsigned short);
15057 vector bool int vec_sll (vector bool int,
15058 vector unsigned char);
15059 vector signed short vec_sll (vector signed short,
15060 vector unsigned int);
15061 vector signed short vec_sll (vector signed short,
15062 vector unsigned short);
15063 vector signed short vec_sll (vector signed short,
15064 vector unsigned char);
15065 vector unsigned short vec_sll (vector unsigned short,
15066 vector unsigned int);
15067 vector unsigned short vec_sll (vector unsigned short,
15068 vector unsigned short);
15069 vector unsigned short vec_sll (vector unsigned short,
15070 vector unsigned char);
15071 vector bool short vec_sll (vector bool short, vector unsigned int);
15072 vector bool short vec_sll (vector bool short, vector unsigned short);
15073 vector bool short vec_sll (vector bool short, vector unsigned char);
15074 vector pixel vec_sll (vector pixel, vector unsigned int);
15075 vector pixel vec_sll (vector pixel, vector unsigned short);
15076 vector pixel vec_sll (vector pixel, vector unsigned char);
15077 vector signed char vec_sll (vector signed char, vector unsigned int);
15078 vector signed char vec_sll (vector signed char, vector unsigned short);
15079 vector signed char vec_sll (vector signed char, vector unsigned char);
15080 vector unsigned char vec_sll (vector unsigned char,
15081 vector unsigned int);
15082 vector unsigned char vec_sll (vector unsigned char,
15083 vector unsigned short);
15084 vector unsigned char vec_sll (vector unsigned char,
15085 vector unsigned char);
15086 vector bool char vec_sll (vector bool char, vector unsigned int);
15087 vector bool char vec_sll (vector bool char, vector unsigned short);
15088 vector bool char vec_sll (vector bool char, vector unsigned char);
15090 vector float vec_slo (vector float, vector signed char);
15091 vector float vec_slo (vector float, vector unsigned char);
15092 vector signed int vec_slo (vector signed int, vector signed char);
15093 vector signed int vec_slo (vector signed int, vector unsigned char);
15094 vector unsigned int vec_slo (vector unsigned int, vector signed char);
15095 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
15096 vector signed short vec_slo (vector signed short, vector signed char);
15097 vector signed short vec_slo (vector signed short, vector unsigned char);
15098 vector unsigned short vec_slo (vector unsigned short,
15099 vector signed char);
15100 vector unsigned short vec_slo (vector unsigned short,
15101 vector unsigned char);
15102 vector pixel vec_slo (vector pixel, vector signed char);
15103 vector pixel vec_slo (vector pixel, vector unsigned char);
15104 vector signed char vec_slo (vector signed char, vector signed char);
15105 vector signed char vec_slo (vector signed char, vector unsigned char);
15106 vector unsigned char vec_slo (vector unsigned char, vector signed char);
15107 vector unsigned char vec_slo (vector unsigned char,
15108 vector unsigned char);
15110 vector signed char vec_splat (vector signed char, const int);
15111 vector unsigned char vec_splat (vector unsigned char, const int);
15112 vector bool char vec_splat (vector bool char, const int);
15113 vector signed short vec_splat (vector signed short, const int);
15114 vector unsigned short vec_splat (vector unsigned short, const int);
15115 vector bool short vec_splat (vector bool short, const int);
15116 vector pixel vec_splat (vector pixel, const int);
15117 vector float vec_splat (vector float, const int);
15118 vector signed int vec_splat (vector signed int, const int);
15119 vector unsigned int vec_splat (vector unsigned int, const int);
15120 vector bool int vec_splat (vector bool int, const int);
15121 vector signed long vec_splat (vector signed long, const int);
15122 vector unsigned long vec_splat (vector unsigned long, const int);
15124 vector signed char vec_splats (signed char);
15125 vector unsigned char vec_splats (unsigned char);
15126 vector signed short vec_splats (signed short);
15127 vector unsigned short vec_splats (unsigned short);
15128 vector signed int vec_splats (signed int);
15129 vector unsigned int vec_splats (unsigned int);
15130 vector float vec_splats (float);
15132 vector float vec_vspltw (vector float, const int);
15133 vector signed int vec_vspltw (vector signed int, const int);
15134 vector unsigned int vec_vspltw (vector unsigned int, const int);
15135 vector bool int vec_vspltw (vector bool int, const int);
15137 vector bool short vec_vsplth (vector bool short, const int);
15138 vector signed short vec_vsplth (vector signed short, const int);
15139 vector unsigned short vec_vsplth (vector unsigned short, const int);
15140 vector pixel vec_vsplth (vector pixel, const int);
15142 vector signed char vec_vspltb (vector signed char, const int);
15143 vector unsigned char vec_vspltb (vector unsigned char, const int);
15144 vector bool char vec_vspltb (vector bool char, const int);
15146 vector signed char vec_splat_s8 (const int);
15148 vector signed short vec_splat_s16 (const int);
15150 vector signed int vec_splat_s32 (const int);
15152 vector unsigned char vec_splat_u8 (const int);
15154 vector unsigned short vec_splat_u16 (const int);
15156 vector unsigned int vec_splat_u32 (const int);
15158 vector signed char vec_sr (vector signed char, vector unsigned char);
15159 vector unsigned char vec_sr (vector unsigned char,
15160 vector unsigned char);
15161 vector signed short vec_sr (vector signed short,
15162 vector unsigned short);
15163 vector unsigned short vec_sr (vector unsigned short,
15164 vector unsigned short);
15165 vector signed int vec_sr (vector signed int, vector unsigned int);
15166 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
15168 vector signed int vec_vsrw (vector signed int, vector unsigned int);
15169 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
15171 vector signed short vec_vsrh (vector signed short,
15172 vector unsigned short);
15173 vector unsigned short vec_vsrh (vector unsigned short,
15174 vector unsigned short);
15176 vector signed char vec_vsrb (vector signed char, vector unsigned char);
15177 vector unsigned char vec_vsrb (vector unsigned char,
15178 vector unsigned char);
15180 vector signed char vec_sra (vector signed char, vector unsigned char);
15181 vector unsigned char vec_sra (vector unsigned char,
15182 vector unsigned char);
15183 vector signed short vec_sra (vector signed short,
15184 vector unsigned short);
15185 vector unsigned short vec_sra (vector unsigned short,
15186 vector unsigned short);
15187 vector signed int vec_sra (vector signed int, vector unsigned int);
15188 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
15190 vector signed int vec_vsraw (vector signed int, vector unsigned int);
15191 vector unsigned int vec_vsraw (vector unsigned int,
15192 vector unsigned int);
15194 vector signed short vec_vsrah (vector signed short,
15195 vector unsigned short);
15196 vector unsigned short vec_vsrah (vector unsigned short,
15197 vector unsigned short);
15199 vector signed char vec_vsrab (vector signed char, vector unsigned char);
15200 vector unsigned char vec_vsrab (vector unsigned char,
15201 vector unsigned char);
15203 vector signed int vec_srl (vector signed int, vector unsigned int);
15204 vector signed int vec_srl (vector signed int, vector unsigned short);
15205 vector signed int vec_srl (vector signed int, vector unsigned char);
15206 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
15207 vector unsigned int vec_srl (vector unsigned int,
15208 vector unsigned short);
15209 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
15210 vector bool int vec_srl (vector bool int, vector unsigned int);
15211 vector bool int vec_srl (vector bool int, vector unsigned short);
15212 vector bool int vec_srl (vector bool int, vector unsigned char);
15213 vector signed short vec_srl (vector signed short, vector unsigned int);
15214 vector signed short vec_srl (vector signed short,
15215 vector unsigned short);
15216 vector signed short vec_srl (vector signed short, vector unsigned char);
15217 vector unsigned short vec_srl (vector unsigned short,
15218 vector unsigned int);
15219 vector unsigned short vec_srl (vector unsigned short,
15220 vector unsigned short);
15221 vector unsigned short vec_srl (vector unsigned short,
15222 vector unsigned char);
15223 vector bool short vec_srl (vector bool short, vector unsigned int);
15224 vector bool short vec_srl (vector bool short, vector unsigned short);
15225 vector bool short vec_srl (vector bool short, vector unsigned char);
15226 vector pixel vec_srl (vector pixel, vector unsigned int);
15227 vector pixel vec_srl (vector pixel, vector unsigned short);
15228 vector pixel vec_srl (vector pixel, vector unsigned char);
15229 vector signed char vec_srl (vector signed char, vector unsigned int);
15230 vector signed char vec_srl (vector signed char, vector unsigned short);
15231 vector signed char vec_srl (vector signed char, vector unsigned char);
15232 vector unsigned char vec_srl (vector unsigned char,
15233 vector unsigned int);
15234 vector unsigned char vec_srl (vector unsigned char,
15235 vector unsigned short);
15236 vector unsigned char vec_srl (vector unsigned char,
15237 vector unsigned char);
15238 vector bool char vec_srl (vector bool char, vector unsigned int);
15239 vector bool char vec_srl (vector bool char, vector unsigned short);
15240 vector bool char vec_srl (vector bool char, vector unsigned char);
15242 vector float vec_sro (vector float, vector signed char);
15243 vector float vec_sro (vector float, vector unsigned char);
15244 vector signed int vec_sro (vector signed int, vector signed char);
15245 vector signed int vec_sro (vector signed int, vector unsigned char);
15246 vector unsigned int vec_sro (vector unsigned int, vector signed char);
15247 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
15248 vector signed short vec_sro (vector signed short, vector signed char);
15249 vector signed short vec_sro (vector signed short, vector unsigned char);
15250 vector unsigned short vec_sro (vector unsigned short,
15251 vector signed char);
15252 vector unsigned short vec_sro (vector unsigned short,
15253 vector unsigned char);
15254 vector pixel vec_sro (vector pixel, vector signed char);
15255 vector pixel vec_sro (vector pixel, vector unsigned char);
15256 vector signed char vec_sro (vector signed char, vector signed char);
15257 vector signed char vec_sro (vector signed char, vector unsigned char);
15258 vector unsigned char vec_sro (vector unsigned char, vector signed char);
15259 vector unsigned char vec_sro (vector unsigned char,
15260 vector unsigned char);
15262 void vec_st (vector float, int, vector float *);
15263 void vec_st (vector float, int, float *);
15264 void vec_st (vector signed int, int, vector signed int *);
15265 void vec_st (vector signed int, int, int *);
15266 void vec_st (vector unsigned int, int, vector unsigned int *);
15267 void vec_st (vector unsigned int, int, unsigned int *);
15268 void vec_st (vector bool int, int, vector bool int *);
15269 void vec_st (vector bool int, int, unsigned int *);
15270 void vec_st (vector bool int, int, int *);
15271 void vec_st (vector signed short, int, vector signed short *);
15272 void vec_st (vector signed short, int, short *);
15273 void vec_st (vector unsigned short, int, vector unsigned short *);
15274 void vec_st (vector unsigned short, int, unsigned short *);
15275 void vec_st (vector bool short, int, vector bool short *);
15276 void vec_st (vector bool short, int, unsigned short *);
15277 void vec_st (vector pixel, int, vector pixel *);
15278 void vec_st (vector pixel, int, unsigned short *);
15279 void vec_st (vector pixel, int, short *);
15280 void vec_st (vector bool short, int, short *);
15281 void vec_st (vector signed char, int, vector signed char *);
15282 void vec_st (vector signed char, int, signed char *);
15283 void vec_st (vector unsigned char, int, vector unsigned char *);
15284 void vec_st (vector unsigned char, int, unsigned char *);
15285 void vec_st (vector bool char, int, vector bool char *);
15286 void vec_st (vector bool char, int, unsigned char *);
15287 void vec_st (vector bool char, int, signed char *);
15289 void vec_ste (vector signed char, int, signed char *);
15290 void vec_ste (vector unsigned char, int, unsigned char *);
15291 void vec_ste (vector bool char, int, signed char *);
15292 void vec_ste (vector bool char, int, unsigned char *);
15293 void vec_ste (vector signed short, int, short *);
15294 void vec_ste (vector unsigned short, int, unsigned short *);
15295 void vec_ste (vector bool short, int, short *);
15296 void vec_ste (vector bool short, int, unsigned short *);
15297 void vec_ste (vector pixel, int, short *);
15298 void vec_ste (vector pixel, int, unsigned short *);
15299 void vec_ste (vector float, int, float *);
15300 void vec_ste (vector signed int, int, int *);
15301 void vec_ste (vector unsigned int, int, unsigned int *);
15302 void vec_ste (vector bool int, int, int *);
15303 void vec_ste (vector bool int, int, unsigned int *);
15305 void vec_stvewx (vector float, int, float *);
15306 void vec_stvewx (vector signed int, int, int *);
15307 void vec_stvewx (vector unsigned int, int, unsigned int *);
15308 void vec_stvewx (vector bool int, int, int *);
15309 void vec_stvewx (vector bool int, int, unsigned int *);
15311 void vec_stvehx (vector signed short, int, short *);
15312 void vec_stvehx (vector unsigned short, int, unsigned short *);
15313 void vec_stvehx (vector bool short, int, short *);
15314 void vec_stvehx (vector bool short, int, unsigned short *);
15315 void vec_stvehx (vector pixel, int, short *);
15316 void vec_stvehx (vector pixel, int, unsigned short *);
15318 void vec_stvebx (vector signed char, int, signed char *);
15319 void vec_stvebx (vector unsigned char, int, unsigned char *);
15320 void vec_stvebx (vector bool char, int, signed char *);
15321 void vec_stvebx (vector bool char, int, unsigned char *);
15323 void vec_stl (vector float, int, vector float *);
15324 void vec_stl (vector float, int, float *);
15325 void vec_stl (vector signed int, int, vector signed int *);
15326 void vec_stl (vector signed int, int, int *);
15327 void vec_stl (vector unsigned int, int, vector unsigned int *);
15328 void vec_stl (vector unsigned int, int, unsigned int *);
15329 void vec_stl (vector bool int, int, vector bool int *);
15330 void vec_stl (vector bool int, int, unsigned int *);
15331 void vec_stl (vector bool int, int, int *);
15332 void vec_stl (vector signed short, int, vector signed short *);
15333 void vec_stl (vector signed short, int, short *);
15334 void vec_stl (vector unsigned short, int, vector unsigned short *);
15335 void vec_stl (vector unsigned short, int, unsigned short *);
15336 void vec_stl (vector bool short, int, vector bool short *);
15337 void vec_stl (vector bool short, int, unsigned short *);
15338 void vec_stl (vector bool short, int, short *);
15339 void vec_stl (vector pixel, int, vector pixel *);
15340 void vec_stl (vector pixel, int, unsigned short *);
15341 void vec_stl (vector pixel, int, short *);
15342 void vec_stl (vector signed char, int, vector signed char *);
15343 void vec_stl (vector signed char, int, signed char *);
15344 void vec_stl (vector unsigned char, int, vector unsigned char *);
15345 void vec_stl (vector unsigned char, int, unsigned char *);
15346 void vec_stl (vector bool char, int, vector bool char *);
15347 void vec_stl (vector bool char, int, unsigned char *);
15348 void vec_stl (vector bool char, int, signed char *);
15350 vector signed char vec_sub (vector bool char, vector signed char);
15351 vector signed char vec_sub (vector signed char, vector bool char);
15352 vector signed char vec_sub (vector signed char, vector signed char);
15353 vector unsigned char vec_sub (vector bool char, vector unsigned char);
15354 vector unsigned char vec_sub (vector unsigned char, vector bool char);
15355 vector unsigned char vec_sub (vector unsigned char,
15356 vector unsigned char);
15357 vector signed short vec_sub (vector bool short, vector signed short);
15358 vector signed short vec_sub (vector signed short, vector bool short);
15359 vector signed short vec_sub (vector signed short, vector signed short);
15360 vector unsigned short vec_sub (vector bool short,
15361 vector unsigned short);
15362 vector unsigned short vec_sub (vector unsigned short,
15363 vector bool short);
15364 vector unsigned short vec_sub (vector unsigned short,
15365 vector unsigned short);
15366 vector signed int vec_sub (vector bool int, vector signed int);
15367 vector signed int vec_sub (vector signed int, vector bool int);
15368 vector signed int vec_sub (vector signed int, vector signed int);
15369 vector unsigned int vec_sub (vector bool int, vector unsigned int);
15370 vector unsigned int vec_sub (vector unsigned int, vector bool int);
15371 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
15372 vector float vec_sub (vector float, vector float);
15374 vector float vec_vsubfp (vector float, vector float);
15376 vector signed int vec_vsubuwm (vector bool int, vector signed int);
15377 vector signed int vec_vsubuwm (vector signed int, vector bool int);
15378 vector signed int vec_vsubuwm (vector signed int, vector signed int);
15379 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
15380 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
15381 vector unsigned int vec_vsubuwm (vector unsigned int,
15382 vector unsigned int);
15384 vector signed short vec_vsubuhm (vector bool short,
15385 vector signed short);
15386 vector signed short vec_vsubuhm (vector signed short,
15387 vector bool short);
15388 vector signed short vec_vsubuhm (vector signed short,
15389 vector signed short);
15390 vector unsigned short vec_vsubuhm (vector bool short,
15391 vector unsigned short);
15392 vector unsigned short vec_vsubuhm (vector unsigned short,
15393 vector bool short);
15394 vector unsigned short vec_vsubuhm (vector unsigned short,
15395 vector unsigned short);
15397 vector signed char vec_vsububm (vector bool char, vector signed char);
15398 vector signed char vec_vsububm (vector signed char, vector bool char);
15399 vector signed char vec_vsububm (vector signed char, vector signed char);
15400 vector unsigned char vec_vsububm (vector bool char,
15401 vector unsigned char);
15402 vector unsigned char vec_vsububm (vector unsigned char,
15404 vector unsigned char vec_vsububm (vector unsigned char,
15405 vector unsigned char);
15407 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
15409 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15410 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15411 vector unsigned char vec_subs (vector unsigned char,
15412 vector unsigned char);
15413 vector signed char vec_subs (vector bool char, vector signed char);
15414 vector signed char vec_subs (vector signed char, vector bool char);
15415 vector signed char vec_subs (vector signed char, vector signed char);
15416 vector unsigned short vec_subs (vector bool short,
15417 vector unsigned short);
15418 vector unsigned short vec_subs (vector unsigned short,
15419 vector bool short);
15420 vector unsigned short vec_subs (vector unsigned short,
15421 vector unsigned short);
15422 vector signed short vec_subs (vector bool short, vector signed short);
15423 vector signed short vec_subs (vector signed short, vector bool short);
15424 vector signed short vec_subs (vector signed short, vector signed short);
15425 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15426 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15427 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15428 vector signed int vec_subs (vector bool int, vector signed int);
15429 vector signed int vec_subs (vector signed int, vector bool int);
15430 vector signed int vec_subs (vector signed int, vector signed int);
15432 vector signed int vec_vsubsws (vector bool int, vector signed int);
15433 vector signed int vec_vsubsws (vector signed int, vector bool int);
15434 vector signed int vec_vsubsws (vector signed int, vector signed int);
15436 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15437 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15438 vector unsigned int vec_vsubuws (vector unsigned int,
15439 vector unsigned int);
15441 vector signed short vec_vsubshs (vector bool short,
15442 vector signed short);
15443 vector signed short vec_vsubshs (vector signed short,
15444 vector bool short);
15445 vector signed short vec_vsubshs (vector signed short,
15446 vector signed short);
15448 vector unsigned short vec_vsubuhs (vector bool short,
15449 vector unsigned short);
15450 vector unsigned short vec_vsubuhs (vector unsigned short,
15451 vector bool short);
15452 vector unsigned short vec_vsubuhs (vector unsigned short,
15453 vector unsigned short);
15455 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15456 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15457 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15459 vector unsigned char vec_vsububs (vector bool char,
15460 vector unsigned char);
15461 vector unsigned char vec_vsububs (vector unsigned char,
15463 vector unsigned char vec_vsububs (vector unsigned char,
15464 vector unsigned char);
15466 vector unsigned int vec_sum4s (vector unsigned char,
15467 vector unsigned int);
15468 vector signed int vec_sum4s (vector signed char, vector signed int);
15469 vector signed int vec_sum4s (vector signed short, vector signed int);
15471 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15473 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15475 vector unsigned int vec_vsum4ubs (vector unsigned char,
15476 vector unsigned int);
15478 vector signed int vec_sum2s (vector signed int, vector signed int);
15480 vector signed int vec_sums (vector signed int, vector signed int);
15482 vector float vec_trunc (vector float);
15484 vector signed short vec_unpackh (vector signed char);
15485 vector bool short vec_unpackh (vector bool char);
15486 vector signed int vec_unpackh (vector signed short);
15487 vector bool int vec_unpackh (vector bool short);
15488 vector unsigned int vec_unpackh (vector pixel);
15490 vector bool int vec_vupkhsh (vector bool short);
15491 vector signed int vec_vupkhsh (vector signed short);
15493 vector unsigned int vec_vupkhpx (vector pixel);
15495 vector bool short vec_vupkhsb (vector bool char);
15496 vector signed short vec_vupkhsb (vector signed char);
15498 vector signed short vec_unpackl (vector signed char);
15499 vector bool short vec_unpackl (vector bool char);
15500 vector unsigned int vec_unpackl (vector pixel);
15501 vector signed int vec_unpackl (vector signed short);
15502 vector bool int vec_unpackl (vector bool short);
15504 vector unsigned int vec_vupklpx (vector pixel);
15506 vector bool int vec_vupklsh (vector bool short);
15507 vector signed int vec_vupklsh (vector signed short);
15509 vector bool short vec_vupklsb (vector bool char);
15510 vector signed short vec_vupklsb (vector signed char);
15512 vector float vec_xor (vector float, vector float);
15513 vector float vec_xor (vector float, vector bool int);
15514 vector float vec_xor (vector bool int, vector float);
15515 vector bool int vec_xor (vector bool int, vector bool int);
15516 vector signed int vec_xor (vector bool int, vector signed int);
15517 vector signed int vec_xor (vector signed int, vector bool int);
15518 vector signed int vec_xor (vector signed int, vector signed int);
15519 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15520 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15521 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15522 vector bool short vec_xor (vector bool short, vector bool short);
15523 vector signed short vec_xor (vector bool short, vector signed short);
15524 vector signed short vec_xor (vector signed short, vector bool short);
15525 vector signed short vec_xor (vector signed short, vector signed short);
15526 vector unsigned short vec_xor (vector bool short,
15527 vector unsigned short);
15528 vector unsigned short vec_xor (vector unsigned short,
15529 vector bool short);
15530 vector unsigned short vec_xor (vector unsigned short,
15531 vector unsigned short);
15532 vector signed char vec_xor (vector bool char, vector signed char);
15533 vector bool char vec_xor (vector bool char, vector bool char);
15534 vector signed char vec_xor (vector signed char, vector bool char);
15535 vector signed char vec_xor (vector signed char, vector signed char);
15536 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15537 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15538 vector unsigned char vec_xor (vector unsigned char,
15539 vector unsigned char);
15541 int vec_all_eq (vector signed char, vector bool char);
15542 int vec_all_eq (vector signed char, vector signed char);
15543 int vec_all_eq (vector unsigned char, vector bool char);
15544 int vec_all_eq (vector unsigned char, vector unsigned char);
15545 int vec_all_eq (vector bool char, vector bool char);
15546 int vec_all_eq (vector bool char, vector unsigned char);
15547 int vec_all_eq (vector bool char, vector signed char);
15548 int vec_all_eq (vector signed short, vector bool short);
15549 int vec_all_eq (vector signed short, vector signed short);
15550 int vec_all_eq (vector unsigned short, vector bool short);
15551 int vec_all_eq (vector unsigned short, vector unsigned short);
15552 int vec_all_eq (vector bool short, vector bool short);
15553 int vec_all_eq (vector bool short, vector unsigned short);
15554 int vec_all_eq (vector bool short, vector signed short);
15555 int vec_all_eq (vector pixel, vector pixel);
15556 int vec_all_eq (vector signed int, vector bool int);
15557 int vec_all_eq (vector signed int, vector signed int);
15558 int vec_all_eq (vector unsigned int, vector bool int);
15559 int vec_all_eq (vector unsigned int, vector unsigned int);
15560 int vec_all_eq (vector bool int, vector bool int);
15561 int vec_all_eq (vector bool int, vector unsigned int);
15562 int vec_all_eq (vector bool int, vector signed int);
15563 int vec_all_eq (vector float, vector float);
15565 int vec_all_ge (vector bool char, vector unsigned char);
15566 int vec_all_ge (vector unsigned char, vector bool char);
15567 int vec_all_ge (vector unsigned char, vector unsigned char);
15568 int vec_all_ge (vector bool char, vector signed char);
15569 int vec_all_ge (vector signed char, vector bool char);
15570 int vec_all_ge (vector signed char, vector signed char);
15571 int vec_all_ge (vector bool short, vector unsigned short);
15572 int vec_all_ge (vector unsigned short, vector bool short);
15573 int vec_all_ge (vector unsigned short, vector unsigned short);
15574 int vec_all_ge (vector signed short, vector signed short);
15575 int vec_all_ge (vector bool short, vector signed short);
15576 int vec_all_ge (vector signed short, vector bool short);
15577 int vec_all_ge (vector bool int, vector unsigned int);
15578 int vec_all_ge (vector unsigned int, vector bool int);
15579 int vec_all_ge (vector unsigned int, vector unsigned int);
15580 int vec_all_ge (vector bool int, vector signed int);
15581 int vec_all_ge (vector signed int, vector bool int);
15582 int vec_all_ge (vector signed int, vector signed int);
15583 int vec_all_ge (vector float, vector float);
15585 int vec_all_gt (vector bool char, vector unsigned char);
15586 int vec_all_gt (vector unsigned char, vector bool char);
15587 int vec_all_gt (vector unsigned char, vector unsigned char);
15588 int vec_all_gt (vector bool char, vector signed char);
15589 int vec_all_gt (vector signed char, vector bool char);
15590 int vec_all_gt (vector signed char, vector signed char);
15591 int vec_all_gt (vector bool short, vector unsigned short);
15592 int vec_all_gt (vector unsigned short, vector bool short);
15593 int vec_all_gt (vector unsigned short, vector unsigned short);
15594 int vec_all_gt (vector bool short, vector signed short);
15595 int vec_all_gt (vector signed short, vector bool short);
15596 int vec_all_gt (vector signed short, vector signed short);
15597 int vec_all_gt (vector bool int, vector unsigned int);
15598 int vec_all_gt (vector unsigned int, vector bool int);
15599 int vec_all_gt (vector unsigned int, vector unsigned int);
15600 int vec_all_gt (vector bool int, vector signed int);
15601 int vec_all_gt (vector signed int, vector bool int);
15602 int vec_all_gt (vector signed int, vector signed int);
15603 int vec_all_gt (vector float, vector float);
15605 int vec_all_in (vector float, vector float);
15607 int vec_all_le (vector bool char, vector unsigned char);
15608 int vec_all_le (vector unsigned char, vector bool char);
15609 int vec_all_le (vector unsigned char, vector unsigned char);
15610 int vec_all_le (vector bool char, vector signed char);
15611 int vec_all_le (vector signed char, vector bool char);
15612 int vec_all_le (vector signed char, vector signed char);
15613 int vec_all_le (vector bool short, vector unsigned short);
15614 int vec_all_le (vector unsigned short, vector bool short);
15615 int vec_all_le (vector unsigned short, vector unsigned short);
15616 int vec_all_le (vector bool short, vector signed short);
15617 int vec_all_le (vector signed short, vector bool short);
15618 int vec_all_le (vector signed short, vector signed short);
15619 int vec_all_le (vector bool int, vector unsigned int);
15620 int vec_all_le (vector unsigned int, vector bool int);
15621 int vec_all_le (vector unsigned int, vector unsigned int);
15622 int vec_all_le (vector bool int, vector signed int);
15623 int vec_all_le (vector signed int, vector bool int);
15624 int vec_all_le (vector signed int, vector signed int);
15625 int vec_all_le (vector float, vector float);
15627 int vec_all_lt (vector bool char, vector unsigned char);
15628 int vec_all_lt (vector unsigned char, vector bool char);
15629 int vec_all_lt (vector unsigned char, vector unsigned char);
15630 int vec_all_lt (vector bool char, vector signed char);
15631 int vec_all_lt (vector signed char, vector bool char);
15632 int vec_all_lt (vector signed char, vector signed char);
15633 int vec_all_lt (vector bool short, vector unsigned short);
15634 int vec_all_lt (vector unsigned short, vector bool short);
15635 int vec_all_lt (vector unsigned short, vector unsigned short);
15636 int vec_all_lt (vector bool short, vector signed short);
15637 int vec_all_lt (vector signed short, vector bool short);
15638 int vec_all_lt (vector signed short, vector signed short);
15639 int vec_all_lt (vector bool int, vector unsigned int);
15640 int vec_all_lt (vector unsigned int, vector bool int);
15641 int vec_all_lt (vector unsigned int, vector unsigned int);
15642 int vec_all_lt (vector bool int, vector signed int);
15643 int vec_all_lt (vector signed int, vector bool int);
15644 int vec_all_lt (vector signed int, vector signed int);
15645 int vec_all_lt (vector float, vector float);
15647 int vec_all_nan (vector float);
15649 int vec_all_ne (vector signed char, vector bool char);
15650 int vec_all_ne (vector signed char, vector signed char);
15651 int vec_all_ne (vector unsigned char, vector bool char);
15652 int vec_all_ne (vector unsigned char, vector unsigned char);
15653 int vec_all_ne (vector bool char, vector bool char);
15654 int vec_all_ne (vector bool char, vector unsigned char);
15655 int vec_all_ne (vector bool char, vector signed char);
15656 int vec_all_ne (vector signed short, vector bool short);
15657 int vec_all_ne (vector signed short, vector signed short);
15658 int vec_all_ne (vector unsigned short, vector bool short);
15659 int vec_all_ne (vector unsigned short, vector unsigned short);
15660 int vec_all_ne (vector bool short, vector bool short);
15661 int vec_all_ne (vector bool short, vector unsigned short);
15662 int vec_all_ne (vector bool short, vector signed short);
15663 int vec_all_ne (vector pixel, vector pixel);
15664 int vec_all_ne (vector signed int, vector bool int);
15665 int vec_all_ne (vector signed int, vector signed int);
15666 int vec_all_ne (vector unsigned int, vector bool int);
15667 int vec_all_ne (vector unsigned int, vector unsigned int);
15668 int vec_all_ne (vector bool int, vector bool int);
15669 int vec_all_ne (vector bool int, vector unsigned int);
15670 int vec_all_ne (vector bool int, vector signed int);
15671 int vec_all_ne (vector float, vector float);
15673 int vec_all_nge (vector float, vector float);
15675 int vec_all_ngt (vector float, vector float);
15677 int vec_all_nle (vector float, vector float);
15679 int vec_all_nlt (vector float, vector float);
15681 int vec_all_numeric (vector float);
15683 int vec_any_eq (vector signed char, vector bool char);
15684 int vec_any_eq (vector signed char, vector signed char);
15685 int vec_any_eq (vector unsigned char, vector bool char);
15686 int vec_any_eq (vector unsigned char, vector unsigned char);
15687 int vec_any_eq (vector bool char, vector bool char);
15688 int vec_any_eq (vector bool char, vector unsigned char);
15689 int vec_any_eq (vector bool char, vector signed char);
15690 int vec_any_eq (vector signed short, vector bool short);
15691 int vec_any_eq (vector signed short, vector signed short);
15692 int vec_any_eq (vector unsigned short, vector bool short);
15693 int vec_any_eq (vector unsigned short, vector unsigned short);
15694 int vec_any_eq (vector bool short, vector bool short);
15695 int vec_any_eq (vector bool short, vector unsigned short);
15696 int vec_any_eq (vector bool short, vector signed short);
15697 int vec_any_eq (vector pixel, vector pixel);
15698 int vec_any_eq (vector signed int, vector bool int);
15699 int vec_any_eq (vector signed int, vector signed int);
15700 int vec_any_eq (vector unsigned int, vector bool int);
15701 int vec_any_eq (vector unsigned int, vector unsigned int);
15702 int vec_any_eq (vector bool int, vector bool int);
15703 int vec_any_eq (vector bool int, vector unsigned int);
15704 int vec_any_eq (vector bool int, vector signed int);
15705 int vec_any_eq (vector float, vector float);
15707 int vec_any_ge (vector signed char, vector bool char);
15708 int vec_any_ge (vector unsigned char, vector bool char);
15709 int vec_any_ge (vector unsigned char, vector unsigned char);
15710 int vec_any_ge (vector signed char, vector signed char);
15711 int vec_any_ge (vector bool char, vector unsigned char);
15712 int vec_any_ge (vector bool char, vector signed char);
15713 int vec_any_ge (vector unsigned short, vector bool short);
15714 int vec_any_ge (vector unsigned short, vector unsigned short);
15715 int vec_any_ge (vector signed short, vector signed short);
15716 int vec_any_ge (vector signed short, vector bool short);
15717 int vec_any_ge (vector bool short, vector unsigned short);
15718 int vec_any_ge (vector bool short, vector signed short);
15719 int vec_any_ge (vector signed int, vector bool int);
15720 int vec_any_ge (vector unsigned int, vector bool int);
15721 int vec_any_ge (vector unsigned int, vector unsigned int);
15722 int vec_any_ge (vector signed int, vector signed int);
15723 int vec_any_ge (vector bool int, vector unsigned int);
15724 int vec_any_ge (vector bool int, vector signed int);
15725 int vec_any_ge (vector float, vector float);
15727 int vec_any_gt (vector bool char, vector unsigned char);
15728 int vec_any_gt (vector unsigned char, vector bool char);
15729 int vec_any_gt (vector unsigned char, vector unsigned char);
15730 int vec_any_gt (vector bool char, vector signed char);
15731 int vec_any_gt (vector signed char, vector bool char);
15732 int vec_any_gt (vector signed char, vector signed char);
15733 int vec_any_gt (vector bool short, vector unsigned short);
15734 int vec_any_gt (vector unsigned short, vector bool short);
15735 int vec_any_gt (vector unsigned short, vector unsigned short);
15736 int vec_any_gt (vector bool short, vector signed short);
15737 int vec_any_gt (vector signed short, vector bool short);
15738 int vec_any_gt (vector signed short, vector signed short);
15739 int vec_any_gt (vector bool int, vector unsigned int);
15740 int vec_any_gt (vector unsigned int, vector bool int);
15741 int vec_any_gt (vector unsigned int, vector unsigned int);
15742 int vec_any_gt (vector bool int, vector signed int);
15743 int vec_any_gt (vector signed int, vector bool int);
15744 int vec_any_gt (vector signed int, vector signed int);
15745 int vec_any_gt (vector float, vector float);
15747 int vec_any_le (vector bool char, vector unsigned char);
15748 int vec_any_le (vector unsigned char, vector bool char);
15749 int vec_any_le (vector unsigned char, vector unsigned char);
15750 int vec_any_le (vector bool char, vector signed char);
15751 int vec_any_le (vector signed char, vector bool char);
15752 int vec_any_le (vector signed char, vector signed char);
15753 int vec_any_le (vector bool short, vector unsigned short);
15754 int vec_any_le (vector unsigned short, vector bool short);
15755 int vec_any_le (vector unsigned short, vector unsigned short);
15756 int vec_any_le (vector bool short, vector signed short);
15757 int vec_any_le (vector signed short, vector bool short);
15758 int vec_any_le (vector signed short, vector signed short);
15759 int vec_any_le (vector bool int, vector unsigned int);
15760 int vec_any_le (vector unsigned int, vector bool int);
15761 int vec_any_le (vector unsigned int, vector unsigned int);
15762 int vec_any_le (vector bool int, vector signed int);
15763 int vec_any_le (vector signed int, vector bool int);
15764 int vec_any_le (vector signed int, vector signed int);
15765 int vec_any_le (vector float, vector float);
15767 int vec_any_lt (vector bool char, vector unsigned char);
15768 int vec_any_lt (vector unsigned char, vector bool char);
15769 int vec_any_lt (vector unsigned char, vector unsigned char);
15770 int vec_any_lt (vector bool char, vector signed char);
15771 int vec_any_lt (vector signed char, vector bool char);
15772 int vec_any_lt (vector signed char, vector signed char);
15773 int vec_any_lt (vector bool short, vector unsigned short);
15774 int vec_any_lt (vector unsigned short, vector bool short);
15775 int vec_any_lt (vector unsigned short, vector unsigned short);
15776 int vec_any_lt (vector bool short, vector signed short);
15777 int vec_any_lt (vector signed short, vector bool short);
15778 int vec_any_lt (vector signed short, vector signed short);
15779 int vec_any_lt (vector bool int, vector unsigned int);
15780 int vec_any_lt (vector unsigned int, vector bool int);
15781 int vec_any_lt (vector unsigned int, vector unsigned int);
15782 int vec_any_lt (vector bool int, vector signed int);
15783 int vec_any_lt (vector signed int, vector bool int);
15784 int vec_any_lt (vector signed int, vector signed int);
15785 int vec_any_lt (vector float, vector float);
15787 int vec_any_nan (vector float);
15789 int vec_any_ne (vector signed char, vector bool char);
15790 int vec_any_ne (vector signed char, vector signed char);
15791 int vec_any_ne (vector unsigned char, vector bool char);
15792 int vec_any_ne (vector unsigned char, vector unsigned char);
15793 int vec_any_ne (vector bool char, vector bool char);
15794 int vec_any_ne (vector bool char, vector unsigned char);
15795 int vec_any_ne (vector bool char, vector signed char);
15796 int vec_any_ne (vector signed short, vector bool short);
15797 int vec_any_ne (vector signed short, vector signed short);
15798 int vec_any_ne (vector unsigned short, vector bool short);
15799 int vec_any_ne (vector unsigned short, vector unsigned short);
15800 int vec_any_ne (vector bool short, vector bool short);
15801 int vec_any_ne (vector bool short, vector unsigned short);
15802 int vec_any_ne (vector bool short, vector signed short);
15803 int vec_any_ne (vector pixel, vector pixel);
15804 int vec_any_ne (vector signed int, vector bool int);
15805 int vec_any_ne (vector signed int, vector signed int);
15806 int vec_any_ne (vector unsigned int, vector bool int);
15807 int vec_any_ne (vector unsigned int, vector unsigned int);
15808 int vec_any_ne (vector bool int, vector bool int);
15809 int vec_any_ne (vector bool int, vector unsigned int);
15810 int vec_any_ne (vector bool int, vector signed int);
15811 int vec_any_ne (vector float, vector float);
15813 int vec_any_nge (vector float, vector float);
15815 int vec_any_ngt (vector float, vector float);
15817 int vec_any_nle (vector float, vector float);
15819 int vec_any_nlt (vector float, vector float);
15821 int vec_any_numeric (vector float);
15823 int vec_any_out (vector float, vector float);
15826 If the vector/scalar (VSX) instruction set is available, the following
15827 additional functions are available:
15830 vector double vec_abs (vector double);
15831 vector double vec_add (vector double, vector double);
15832 vector double vec_and (vector double, vector double);
15833 vector double vec_and (vector double, vector bool long);
15834 vector double vec_and (vector bool long, vector double);
15835 vector long vec_and (vector long, vector long);
15836 vector long vec_and (vector long, vector bool long);
15837 vector long vec_and (vector bool long, vector long);
15838 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15839 vector unsigned long vec_and (vector unsigned long, vector bool long);
15840 vector unsigned long vec_and (vector bool long, vector unsigned long);
15841 vector double vec_andc (vector double, vector double);
15842 vector double vec_andc (vector double, vector bool long);
15843 vector double vec_andc (vector bool long, vector double);
15844 vector long vec_andc (vector long, vector long);
15845 vector long vec_andc (vector long, vector bool long);
15846 vector long vec_andc (vector bool long, vector long);
15847 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15848 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15849 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15850 vector double vec_ceil (vector double);
15851 vector bool long vec_cmpeq (vector double, vector double);
15852 vector bool long vec_cmpge (vector double, vector double);
15853 vector bool long vec_cmpgt (vector double, vector double);
15854 vector bool long vec_cmple (vector double, vector double);
15855 vector bool long vec_cmplt (vector double, vector double);
15856 vector double vec_cpsgn (vector double, vector double);
15857 vector float vec_div (vector float, vector float);
15858 vector double vec_div (vector double, vector double);
15859 vector long vec_div (vector long, vector long);
15860 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15861 vector double vec_floor (vector double);
15862 vector double vec_ld (int, const vector double *);
15863 vector double vec_ld (int, const double *);
15864 vector double vec_ldl (int, const vector double *);
15865 vector double vec_ldl (int, const double *);
15866 vector unsigned char vec_lvsl (int, const volatile double *);
15867 vector unsigned char vec_lvsr (int, const volatile double *);
15868 vector double vec_madd (vector double, vector double, vector double);
15869 vector double vec_max (vector double, vector double);
15870 vector signed long vec_mergeh (vector signed long, vector signed long);
15871 vector signed long vec_mergeh (vector signed long, vector bool long);
15872 vector signed long vec_mergeh (vector bool long, vector signed long);
15873 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15874 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15875 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15876 vector signed long vec_mergel (vector signed long, vector signed long);
15877 vector signed long vec_mergel (vector signed long, vector bool long);
15878 vector signed long vec_mergel (vector bool long, vector signed long);
15879 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15880 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15881 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15882 vector double vec_min (vector double, vector double);
15883 vector float vec_msub (vector float, vector float, vector float);
15884 vector double vec_msub (vector double, vector double, vector double);
15885 vector float vec_mul (vector float, vector float);
15886 vector double vec_mul (vector double, vector double);
15887 vector long vec_mul (vector long, vector long);
15888 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15889 vector float vec_nearbyint (vector float);
15890 vector double vec_nearbyint (vector double);
15891 vector float vec_nmadd (vector float, vector float, vector float);
15892 vector double vec_nmadd (vector double, vector double, vector double);
15893 vector double vec_nmsub (vector double, vector double, vector double);
15894 vector double vec_nor (vector double, vector double);
15895 vector long vec_nor (vector long, vector long);
15896 vector long vec_nor (vector long, vector bool long);
15897 vector long vec_nor (vector bool long, vector long);
15898 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15899 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15900 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15901 vector double vec_or (vector double, vector double);
15902 vector double vec_or (vector double, vector bool long);
15903 vector double vec_or (vector bool long, vector double);
15904 vector long vec_or (vector long, vector long);
15905 vector long vec_or (vector long, vector bool long);
15906 vector long vec_or (vector bool long, vector long);
15907 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15908 vector unsigned long vec_or (vector unsigned long, vector bool long);
15909 vector unsigned long vec_or (vector bool long, vector unsigned long);
15910 vector double vec_perm (vector double, vector double, vector unsigned char);
15911 vector long vec_perm (vector long, vector long, vector unsigned char);
15912 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15913 vector unsigned char);
15914 vector double vec_rint (vector double);
15915 vector double vec_recip (vector double, vector double);
15916 vector double vec_rsqrt (vector double);
15917 vector double vec_rsqrte (vector double);
15918 vector double vec_sel (vector double, vector double, vector bool long);
15919 vector double vec_sel (vector double, vector double, vector unsigned long);
15920 vector long vec_sel (vector long, vector long, vector long);
15921 vector long vec_sel (vector long, vector long, vector unsigned long);
15922 vector long vec_sel (vector long, vector long, vector bool long);
15923 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15925 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15926 vector unsigned long);
15927 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15929 vector double vec_splats (double);
15930 vector signed long vec_splats (signed long);
15931 vector unsigned long vec_splats (unsigned long);
15932 vector float vec_sqrt (vector float);
15933 vector double vec_sqrt (vector double);
15934 void vec_st (vector double, int, vector double *);
15935 void vec_st (vector double, int, double *);
15936 vector double vec_sub (vector double, vector double);
15937 vector double vec_trunc (vector double);
15938 vector double vec_xl (int, vector double *);
15939 vector double vec_xl (int, double *);
15940 vector long long vec_xl (int, vector long long *);
15941 vector long long vec_xl (int, long long *);
15942 vector unsigned long long vec_xl (int, vector unsigned long long *);
15943 vector unsigned long long vec_xl (int, unsigned long long *);
15944 vector float vec_xl (int, vector float *);
15945 vector float vec_xl (int, float *);
15946 vector int vec_xl (int, vector int *);
15947 vector int vec_xl (int, int *);
15948 vector unsigned int vec_xl (int, vector unsigned int *);
15949 vector unsigned int vec_xl (int, unsigned int *);
15950 vector double vec_xor (vector double, vector double);
15951 vector double vec_xor (vector double, vector bool long);
15952 vector double vec_xor (vector bool long, vector double);
15953 vector long vec_xor (vector long, vector long);
15954 vector long vec_xor (vector long, vector bool long);
15955 vector long vec_xor (vector bool long, vector long);
15956 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15957 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15958 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15959 void vec_xst (vector double, int, vector double *);
15960 void vec_xst (vector double, int, double *);
15961 void vec_xst (vector long long, int, vector long long *);
15962 void vec_xst (vector long long, int, long long *);
15963 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
15964 void vec_xst (vector unsigned long long, int, unsigned long long *);
15965 void vec_xst (vector float, int, vector float *);
15966 void vec_xst (vector float, int, float *);
15967 void vec_xst (vector int, int, vector int *);
15968 void vec_xst (vector int, int, int *);
15969 void vec_xst (vector unsigned int, int, vector unsigned int *);
15970 void vec_xst (vector unsigned int, int, unsigned int *);
15971 int vec_all_eq (vector double, vector double);
15972 int vec_all_ge (vector double, vector double);
15973 int vec_all_gt (vector double, vector double);
15974 int vec_all_le (vector double, vector double);
15975 int vec_all_lt (vector double, vector double);
15976 int vec_all_nan (vector double);
15977 int vec_all_ne (vector double, vector double);
15978 int vec_all_nge (vector double, vector double);
15979 int vec_all_ngt (vector double, vector double);
15980 int vec_all_nle (vector double, vector double);
15981 int vec_all_nlt (vector double, vector double);
15982 int vec_all_numeric (vector double);
15983 int vec_any_eq (vector double, vector double);
15984 int vec_any_ge (vector double, vector double);
15985 int vec_any_gt (vector double, vector double);
15986 int vec_any_le (vector double, vector double);
15987 int vec_any_lt (vector double, vector double);
15988 int vec_any_nan (vector double);
15989 int vec_any_ne (vector double, vector double);
15990 int vec_any_nge (vector double, vector double);
15991 int vec_any_ngt (vector double, vector double);
15992 int vec_any_nle (vector double, vector double);
15993 int vec_any_nlt (vector double, vector double);
15994 int vec_any_numeric (vector double);
15996 vector double vec_vsx_ld (int, const vector double *);
15997 vector double vec_vsx_ld (int, const double *);
15998 vector float vec_vsx_ld (int, const vector float *);
15999 vector float vec_vsx_ld (int, const float *);
16000 vector bool int vec_vsx_ld (int, const vector bool int *);
16001 vector signed int vec_vsx_ld (int, const vector signed int *);
16002 vector signed int vec_vsx_ld (int, const int *);
16003 vector signed int vec_vsx_ld (int, const long *);
16004 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
16005 vector unsigned int vec_vsx_ld (int, const unsigned int *);
16006 vector unsigned int vec_vsx_ld (int, const unsigned long *);
16007 vector bool short vec_vsx_ld (int, const vector bool short *);
16008 vector pixel vec_vsx_ld (int, const vector pixel *);
16009 vector signed short vec_vsx_ld (int, const vector signed short *);
16010 vector signed short vec_vsx_ld (int, const short *);
16011 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
16012 vector unsigned short vec_vsx_ld (int, const unsigned short *);
16013 vector bool char vec_vsx_ld (int, const vector bool char *);
16014 vector signed char vec_vsx_ld (int, const vector signed char *);
16015 vector signed char vec_vsx_ld (int, const signed char *);
16016 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
16017 vector unsigned char vec_vsx_ld (int, const unsigned char *);
16019 void vec_vsx_st (vector double, int, vector double *);
16020 void vec_vsx_st (vector double, int, double *);
16021 void vec_vsx_st (vector float, int, vector float *);
16022 void vec_vsx_st (vector float, int, float *);
16023 void vec_vsx_st (vector signed int, int, vector signed int *);
16024 void vec_vsx_st (vector signed int, int, int *);
16025 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
16026 void vec_vsx_st (vector unsigned int, int, unsigned int *);
16027 void vec_vsx_st (vector bool int, int, vector bool int *);
16028 void vec_vsx_st (vector bool int, int, unsigned int *);
16029 void vec_vsx_st (vector bool int, int, int *);
16030 void vec_vsx_st (vector signed short, int, vector signed short *);
16031 void vec_vsx_st (vector signed short, int, short *);
16032 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
16033 void vec_vsx_st (vector unsigned short, int, unsigned short *);
16034 void vec_vsx_st (vector bool short, int, vector bool short *);
16035 void vec_vsx_st (vector bool short, int, unsigned short *);
16036 void vec_vsx_st (vector pixel, int, vector pixel *);
16037 void vec_vsx_st (vector pixel, int, unsigned short *);
16038 void vec_vsx_st (vector pixel, int, short *);
16039 void vec_vsx_st (vector bool short, int, short *);
16040 void vec_vsx_st (vector signed char, int, vector signed char *);
16041 void vec_vsx_st (vector signed char, int, signed char *);
16042 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
16043 void vec_vsx_st (vector unsigned char, int, unsigned char *);
16044 void vec_vsx_st (vector bool char, int, vector bool char *);
16045 void vec_vsx_st (vector bool char, int, unsigned char *);
16046 void vec_vsx_st (vector bool char, int, signed char *);
16048 vector double vec_xxpermdi (vector double, vector double, int);
16049 vector float vec_xxpermdi (vector float, vector float, int);
16050 vector long long vec_xxpermdi (vector long long, vector long long, int);
16051 vector unsigned long long vec_xxpermdi (vector unsigned long long,
16052 vector unsigned long long, int);
16053 vector int vec_xxpermdi (vector int, vector int, int);
16054 vector unsigned int vec_xxpermdi (vector unsigned int,
16055 vector unsigned int, int);
16056 vector short vec_xxpermdi (vector short, vector short, int);
16057 vector unsigned short vec_xxpermdi (vector unsigned short,
16058 vector unsigned short, int);
16059 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
16060 vector unsigned char vec_xxpermdi (vector unsigned char,
16061 vector unsigned char, int);
16063 vector double vec_xxsldi (vector double, vector double, int);
16064 vector float vec_xxsldi (vector float, vector float, int);
16065 vector long long vec_xxsldi (vector long long, vector long long, int);
16066 vector unsigned long long vec_xxsldi (vector unsigned long long,
16067 vector unsigned long long, int);
16068 vector int vec_xxsldi (vector int, vector int, int);
16069 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
16070 vector short vec_xxsldi (vector short, vector short, int);
16071 vector unsigned short vec_xxsldi (vector unsigned short,
16072 vector unsigned short, int);
16073 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
16074 vector unsigned char vec_xxsldi (vector unsigned char,
16075 vector unsigned char, int);
16078 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
16079 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
16080 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
16081 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
16082 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
16084 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16085 instruction set are available, the following additional functions are
16086 available for both 32-bit and 64-bit targets. For 64-bit targets, you
16087 can use @var{vector long} instead of @var{vector long long},
16088 @var{vector bool long} instead of @var{vector bool long long}, and
16089 @var{vector unsigned long} instead of @var{vector unsigned long long}.
16092 vector long long vec_abs (vector long long);
16094 vector long long vec_add (vector long long, vector long long);
16095 vector unsigned long long vec_add (vector unsigned long long,
16096 vector unsigned long long);
16098 int vec_all_eq (vector long long, vector long long);
16099 int vec_all_eq (vector unsigned long long, vector unsigned long long);
16100 int vec_all_ge (vector long long, vector long long);
16101 int vec_all_ge (vector unsigned long long, vector unsigned long long);
16102 int vec_all_gt (vector long long, vector long long);
16103 int vec_all_gt (vector unsigned long long, vector unsigned long long);
16104 int vec_all_le (vector long long, vector long long);
16105 int vec_all_le (vector unsigned long long, vector unsigned long long);
16106 int vec_all_lt (vector long long, vector long long);
16107 int vec_all_lt (vector unsigned long long, vector unsigned long long);
16108 int vec_all_ne (vector long long, vector long long);
16109 int vec_all_ne (vector unsigned long long, vector unsigned long long);
16111 int vec_any_eq (vector long long, vector long long);
16112 int vec_any_eq (vector unsigned long long, vector unsigned long long);
16113 int vec_any_ge (vector long long, vector long long);
16114 int vec_any_ge (vector unsigned long long, vector unsigned long long);
16115 int vec_any_gt (vector long long, vector long long);
16116 int vec_any_gt (vector unsigned long long, vector unsigned long long);
16117 int vec_any_le (vector long long, vector long long);
16118 int vec_any_le (vector unsigned long long, vector unsigned long long);
16119 int vec_any_lt (vector long long, vector long long);
16120 int vec_any_lt (vector unsigned long long, vector unsigned long long);
16121 int vec_any_ne (vector long long, vector long long);
16122 int vec_any_ne (vector unsigned long long, vector unsigned long long);
16124 vector long long vec_eqv (vector long long, vector long long);
16125 vector long long vec_eqv (vector bool long long, vector long long);
16126 vector long long vec_eqv (vector long long, vector bool long long);
16127 vector unsigned long long vec_eqv (vector unsigned long long,
16128 vector unsigned long long);
16129 vector unsigned long long vec_eqv (vector bool long long,
16130 vector unsigned long long);
16131 vector unsigned long long vec_eqv (vector unsigned long long,
16132 vector bool long long);
16133 vector int vec_eqv (vector int, vector int);
16134 vector int vec_eqv (vector bool int, vector int);
16135 vector int vec_eqv (vector int, vector bool int);
16136 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
16137 vector unsigned int vec_eqv (vector bool unsigned int,
16138 vector unsigned int);
16139 vector unsigned int vec_eqv (vector unsigned int,
16140 vector bool unsigned int);
16141 vector short vec_eqv (vector short, vector short);
16142 vector short vec_eqv (vector bool short, vector short);
16143 vector short vec_eqv (vector short, vector bool short);
16144 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
16145 vector unsigned short vec_eqv (vector bool unsigned short,
16146 vector unsigned short);
16147 vector unsigned short vec_eqv (vector unsigned short,
16148 vector bool unsigned short);
16149 vector signed char vec_eqv (vector signed char, vector signed char);
16150 vector signed char vec_eqv (vector bool signed char, vector signed char);
16151 vector signed char vec_eqv (vector signed char, vector bool signed char);
16152 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
16153 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
16154 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
16156 vector long long vec_max (vector long long, vector long long);
16157 vector unsigned long long vec_max (vector unsigned long long,
16158 vector unsigned long long);
16160 vector signed int vec_mergee (vector signed int, vector signed int);
16161 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
16162 vector bool int vec_mergee (vector bool int, vector bool int);
16164 vector signed int vec_mergeo (vector signed int, vector signed int);
16165 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
16166 vector bool int vec_mergeo (vector bool int, vector bool int);
16168 vector long long vec_min (vector long long, vector long long);
16169 vector unsigned long long vec_min (vector unsigned long long,
16170 vector unsigned long long);
16172 vector long long vec_nand (vector long long, vector long long);
16173 vector long long vec_nand (vector bool long long, vector long long);
16174 vector long long vec_nand (vector long long, vector bool long long);
16175 vector unsigned long long vec_nand (vector unsigned long long,
16176 vector unsigned long long);
16177 vector unsigned long long vec_nand (vector bool long long,
16178 vector unsigned long long);
16179 vector unsigned long long vec_nand (vector unsigned long long,
16180 vector bool long long);
16181 vector int vec_nand (vector int, vector int);
16182 vector int vec_nand (vector bool int, vector int);
16183 vector int vec_nand (vector int, vector bool int);
16184 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
16185 vector unsigned int vec_nand (vector bool unsigned int,
16186 vector unsigned int);
16187 vector unsigned int vec_nand (vector unsigned int,
16188 vector bool unsigned int);
16189 vector short vec_nand (vector short, vector short);
16190 vector short vec_nand (vector bool short, vector short);
16191 vector short vec_nand (vector short, vector bool short);
16192 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
16193 vector unsigned short vec_nand (vector bool unsigned short,
16194 vector unsigned short);
16195 vector unsigned short vec_nand (vector unsigned short,
16196 vector bool unsigned short);
16197 vector signed char vec_nand (vector signed char, vector signed char);
16198 vector signed char vec_nand (vector bool signed char, vector signed char);
16199 vector signed char vec_nand (vector signed char, vector bool signed char);
16200 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
16201 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
16202 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
16204 vector long long vec_orc (vector long long, vector long long);
16205 vector long long vec_orc (vector bool long long, vector long long);
16206 vector long long vec_orc (vector long long, vector bool long long);
16207 vector unsigned long long vec_orc (vector unsigned long long,
16208 vector unsigned long long);
16209 vector unsigned long long vec_orc (vector bool long long,
16210 vector unsigned long long);
16211 vector unsigned long long vec_orc (vector unsigned long long,
16212 vector bool long long);
16213 vector int vec_orc (vector int, vector int);
16214 vector int vec_orc (vector bool int, vector int);
16215 vector int vec_orc (vector int, vector bool int);
16216 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
16217 vector unsigned int vec_orc (vector bool unsigned int,
16218 vector unsigned int);
16219 vector unsigned int vec_orc (vector unsigned int,
16220 vector bool unsigned int);
16221 vector short vec_orc (vector short, vector short);
16222 vector short vec_orc (vector bool short, vector short);
16223 vector short vec_orc (vector short, vector bool short);
16224 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
16225 vector unsigned short vec_orc (vector bool unsigned short,
16226 vector unsigned short);
16227 vector unsigned short vec_orc (vector unsigned short,
16228 vector bool unsigned short);
16229 vector signed char vec_orc (vector signed char, vector signed char);
16230 vector signed char vec_orc (vector bool signed char, vector signed char);
16231 vector signed char vec_orc (vector signed char, vector bool signed char);
16232 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
16233 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
16234 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
16236 vector int vec_pack (vector long long, vector long long);
16237 vector unsigned int vec_pack (vector unsigned long long,
16238 vector unsigned long long);
16239 vector bool int vec_pack (vector bool long long, vector bool long long);
16241 vector int vec_packs (vector long long, vector long long);
16242 vector unsigned int vec_packs (vector unsigned long long,
16243 vector unsigned long long);
16245 vector unsigned int vec_packsu (vector long long, vector long long);
16246 vector unsigned int vec_packsu (vector unsigned long long,
16247 vector unsigned long long);
16249 vector long long vec_rl (vector long long,
16250 vector unsigned long long);
16251 vector long long vec_rl (vector unsigned long long,
16252 vector unsigned long long);
16254 vector long long vec_sl (vector long long, vector unsigned long long);
16255 vector long long vec_sl (vector unsigned long long,
16256 vector unsigned long long);
16258 vector long long vec_sr (vector long long, vector unsigned long long);
16259 vector unsigned long long char vec_sr (vector unsigned long long,
16260 vector unsigned long long);
16262 vector long long vec_sra (vector long long, vector unsigned long long);
16263 vector unsigned long long vec_sra (vector unsigned long long,
16264 vector unsigned long long);
16266 vector long long vec_sub (vector long long, vector long long);
16267 vector unsigned long long vec_sub (vector unsigned long long,
16268 vector unsigned long long);
16270 vector long long vec_unpackh (vector int);
16271 vector unsigned long long vec_unpackh (vector unsigned int);
16273 vector long long vec_unpackl (vector int);
16274 vector unsigned long long vec_unpackl (vector unsigned int);
16276 vector long long vec_vaddudm (vector long long, vector long long);
16277 vector long long vec_vaddudm (vector bool long long, vector long long);
16278 vector long long vec_vaddudm (vector long long, vector bool long long);
16279 vector unsigned long long vec_vaddudm (vector unsigned long long,
16280 vector unsigned long long);
16281 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
16282 vector unsigned long long);
16283 vector unsigned long long vec_vaddudm (vector unsigned long long,
16284 vector bool unsigned long long);
16286 vector long long vec_vbpermq (vector signed char, vector signed char);
16287 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
16289 vector long long vec_cntlz (vector long long);
16290 vector unsigned long long vec_cntlz (vector unsigned long long);
16291 vector int vec_cntlz (vector int);
16292 vector unsigned int vec_cntlz (vector int);
16293 vector short vec_cntlz (vector short);
16294 vector unsigned short vec_cntlz (vector unsigned short);
16295 vector signed char vec_cntlz (vector signed char);
16296 vector unsigned char vec_cntlz (vector unsigned char);
16298 vector long long vec_vclz (vector long long);
16299 vector unsigned long long vec_vclz (vector unsigned long long);
16300 vector int vec_vclz (vector int);
16301 vector unsigned int vec_vclz (vector int);
16302 vector short vec_vclz (vector short);
16303 vector unsigned short vec_vclz (vector unsigned short);
16304 vector signed char vec_vclz (vector signed char);
16305 vector unsigned char vec_vclz (vector unsigned char);
16307 vector signed char vec_vclzb (vector signed char);
16308 vector unsigned char vec_vclzb (vector unsigned char);
16310 vector long long vec_vclzd (vector long long);
16311 vector unsigned long long vec_vclzd (vector unsigned long long);
16313 vector short vec_vclzh (vector short);
16314 vector unsigned short vec_vclzh (vector unsigned short);
16316 vector int vec_vclzw (vector int);
16317 vector unsigned int vec_vclzw (vector int);
16319 vector signed char vec_vgbbd (vector signed char);
16320 vector unsigned char vec_vgbbd (vector unsigned char);
16322 vector long long vec_vmaxsd (vector long long, vector long long);
16324 vector unsigned long long vec_vmaxud (vector unsigned long long,
16325 unsigned vector long long);
16327 vector long long vec_vminsd (vector long long, vector long long);
16329 vector unsigned long long vec_vminud (vector long long,
16332 vector int vec_vpksdss (vector long long, vector long long);
16333 vector unsigned int vec_vpksdss (vector long long, vector long long);
16335 vector unsigned int vec_vpkudus (vector unsigned long long,
16336 vector unsigned long long);
16338 vector int vec_vpkudum (vector long long, vector long long);
16339 vector unsigned int vec_vpkudum (vector unsigned long long,
16340 vector unsigned long long);
16341 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
16343 vector long long vec_vpopcnt (vector long long);
16344 vector unsigned long long vec_vpopcnt (vector unsigned long long);
16345 vector int vec_vpopcnt (vector int);
16346 vector unsigned int vec_vpopcnt (vector int);
16347 vector short vec_vpopcnt (vector short);
16348 vector unsigned short vec_vpopcnt (vector unsigned short);
16349 vector signed char vec_vpopcnt (vector signed char);
16350 vector unsigned char vec_vpopcnt (vector unsigned char);
16352 vector signed char vec_vpopcntb (vector signed char);
16353 vector unsigned char vec_vpopcntb (vector unsigned char);
16355 vector long long vec_vpopcntd (vector long long);
16356 vector unsigned long long vec_vpopcntd (vector unsigned long long);
16358 vector short vec_vpopcnth (vector short);
16359 vector unsigned short vec_vpopcnth (vector unsigned short);
16361 vector int vec_vpopcntw (vector int);
16362 vector unsigned int vec_vpopcntw (vector int);
16364 vector long long vec_vrld (vector long long, vector unsigned long long);
16365 vector unsigned long long vec_vrld (vector unsigned long long,
16366 vector unsigned long long);
16368 vector long long vec_vsld (vector long long, vector unsigned long long);
16369 vector long long vec_vsld (vector unsigned long long,
16370 vector unsigned long long);
16372 vector long long vec_vsrad (vector long long, vector unsigned long long);
16373 vector unsigned long long vec_vsrad (vector unsigned long long,
16374 vector unsigned long long);
16376 vector long long vec_vsrd (vector long long, vector unsigned long long);
16377 vector unsigned long long char vec_vsrd (vector unsigned long long,
16378 vector unsigned long long);
16380 vector long long vec_vsubudm (vector long long, vector long long);
16381 vector long long vec_vsubudm (vector bool long long, vector long long);
16382 vector long long vec_vsubudm (vector long long, vector bool long long);
16383 vector unsigned long long vec_vsubudm (vector unsigned long long,
16384 vector unsigned long long);
16385 vector unsigned long long vec_vsubudm (vector bool long long,
16386 vector unsigned long long);
16387 vector unsigned long long vec_vsubudm (vector unsigned long long,
16388 vector bool long long);
16390 vector long long vec_vupkhsw (vector int);
16391 vector unsigned long long vec_vupkhsw (vector unsigned int);
16393 vector long long vec_vupklsw (vector int);
16394 vector unsigned long long vec_vupklsw (vector int);
16397 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16398 instruction set are available, the following additional functions are
16399 available for 64-bit targets. New vector types
16400 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
16401 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
16404 The normal vector extract, and set operations work on
16405 @var{vector __int128_t} and @var{vector __uint128_t} types,
16406 but the index value must be 0.
16409 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
16410 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
16412 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
16413 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
16415 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
16416 vector __int128_t);
16417 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
16418 vector __uint128_t);
16420 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
16421 vector __int128_t);
16422 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
16423 vector __uint128_t);
16425 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
16426 vector __int128_t);
16427 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
16428 vector __uint128_t);
16430 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
16431 vector __int128_t);
16432 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16433 vector __uint128_t);
16435 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16436 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16438 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16439 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16441 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16442 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16443 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16444 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16445 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16446 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16447 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16448 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16449 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16450 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16453 If the cryptographic instructions are enabled (@option{-mcrypto} or
16454 @option{-mcpu=power8}), the following builtins are enabled.
16457 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16459 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16460 vector unsigned long long);
16462 vector unsigned long long __builtin_crypto_vcipherlast
16463 (vector unsigned long long,
16464 vector unsigned long long);
16466 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16467 vector unsigned long long);
16469 vector unsigned long long __builtin_crypto_vncipherlast
16470 (vector unsigned long long,
16471 vector unsigned long long);
16473 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16474 vector unsigned char,
16475 vector unsigned char);
16477 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16478 vector unsigned short,
16479 vector unsigned short);
16481 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16482 vector unsigned int,
16483 vector unsigned int);
16485 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16486 vector unsigned long long,
16487 vector unsigned long long);
16489 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16490 vector unsigned char);
16492 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16493 vector unsigned short);
16495 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16496 vector unsigned int);
16498 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16499 vector unsigned long long);
16501 vector unsigned long long __builtin_crypto_vshasigmad
16502 (vector unsigned long long, int, int);
16504 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16508 The second argument to the @var{__builtin_crypto_vshasigmad} and
16509 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16510 integer that is 0 or 1. The third argument to these builtin functions
16511 must be a constant integer in the range of 0 to 15.
16513 If the ISA 3.0 additions to the vector/scalar (power9-vector)
16514 instruction set are available, the following additional functions are
16515 available for both 32-bit and 64-bit targets.
16517 vector short vec_xl (int, vector short *);
16518 vector short vec_xl (int, short *);
16519 vector unsigned short vec_xl (int, vector unsigned short *);
16520 vector unsigned short vec_xl (int, unsigned short *);
16521 vector char vec_xl (int, vector char *);
16522 vector char vec_xl (int, char *);
16523 vector unsigned char vec_xl (int, vector unsigned char *);
16524 vector unsigned char vec_xl (int, unsigned char *);
16526 void vec_xst (vector short, int, vector short *);
16527 void vec_xst (vector short, int, short *);
16528 void vec_xst (vector unsigned short, int, vector unsigned short *);
16529 void vec_xst (vector unsigned short, int, unsigned short *);
16530 void vec_xst (vector char, int, vector char *);
16531 void vec_xst (vector char, int, char *);
16532 void vec_xst (vector unsigned char, int, vector unsigned char *);
16533 void vec_xst (vector unsigned char, int, unsigned char *);
16535 @node PowerPC Hardware Transactional Memory Built-in Functions
16536 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16537 GCC provides two interfaces for accessing the Hardware Transactional
16538 Memory (HTM) instructions available on some of the PowerPC family
16539 of processors (eg, POWER8). The two interfaces come in a low level
16540 interface, consisting of built-in functions specific to PowerPC and a
16541 higher level interface consisting of inline functions that are common
16542 between PowerPC and S/390.
16544 @subsubsection PowerPC HTM Low Level Built-in Functions
16546 The following low level built-in functions are available with
16547 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16548 They all generate the machine instruction that is part of the name.
16550 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
16551 the full 4-bit condition register value set by their associated hardware
16552 instruction. The header file @code{htmintrin.h} defines some macros that can
16553 be used to decipher the return value. The @code{__builtin_tbegin} builtin
16554 returns a simple true or false value depending on whether a transaction was
16555 successfully started or not. The arguments of the builtins match exactly the
16556 type and order of the associated hardware instruction's operands, except for
16557 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
16558 Refer to the ISA manual for a description of each instruction's operands.
16561 unsigned int __builtin_tbegin (unsigned int)
16562 unsigned int __builtin_tend (unsigned int)
16564 unsigned int __builtin_tabort (unsigned int)
16565 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16566 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16567 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16568 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16570 unsigned int __builtin_tcheck (void)
16571 unsigned int __builtin_treclaim (unsigned int)
16572 unsigned int __builtin_trechkpt (void)
16573 unsigned int __builtin_tsr (unsigned int)
16576 In addition to the above HTM built-ins, we have added built-ins for
16577 some common extended mnemonics of the HTM instructions:
16580 unsigned int __builtin_tendall (void)
16581 unsigned int __builtin_tresume (void)
16582 unsigned int __builtin_tsuspend (void)
16585 Note that the semantics of the above HTM builtins are required to mimic
16586 the locking semantics used for critical sections. Builtins that are used
16587 to create a new transaction or restart a suspended transaction must have
16588 lock acquisition like semantics while those builtins that end or suspend a
16589 transaction must have lock release like semantics. Specifically, this must
16590 mimic lock semantics as specified by C++11, for example: Lock acquisition is
16591 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
16592 that returns 0, and lock release is as-if an execution of
16593 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
16594 implicit implementation-defined lock used for all transactions. The HTM
16595 instructions associated with with the builtins inherently provide the
16596 correct acquisition and release hardware barriers required. However,
16597 the compiler must also be prohibited from moving loads and stores across
16598 the builtins in a way that would violate their semantics. This has been
16599 accomplished by adding memory barriers to the associated HTM instructions
16600 (which is a conservative approach to provide acquire and release semantics).
16601 Earlier versions of the compiler did not treat the HTM instructions as
16602 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
16603 be used to determine whether the current compiler treats HTM instructions
16604 as memory barriers or not. This allows the user to explicitly add memory
16605 barriers to their code when using an older version of the compiler.
16607 The following set of built-in functions are available to gain access
16608 to the HTM specific special purpose registers.
16611 unsigned long __builtin_get_texasr (void)
16612 unsigned long __builtin_get_texasru (void)
16613 unsigned long __builtin_get_tfhar (void)
16614 unsigned long __builtin_get_tfiar (void)
16616 void __builtin_set_texasr (unsigned long);
16617 void __builtin_set_texasru (unsigned long);
16618 void __builtin_set_tfhar (unsigned long);
16619 void __builtin_set_tfiar (unsigned long);
16622 Example usage of these low level built-in functions may look like:
16625 #include <htmintrin.h>
16627 int num_retries = 10;
16631 if (__builtin_tbegin (0))
16633 /* Transaction State Initiated. */
16634 if (is_locked (lock))
16635 __builtin_tabort (0);
16636 ... transaction code...
16637 __builtin_tend (0);
16642 /* Transaction State Failed. Use locks if the transaction
16643 failure is "persistent" or we've tried too many times. */
16644 if (num_retries-- <= 0
16645 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16647 acquire_lock (lock);
16648 ... non transactional fallback path...
16649 release_lock (lock);
16656 One final built-in function has been added that returns the value of
16657 the 2-bit Transaction State field of the Machine Status Register (MSR)
16658 as stored in @code{CR0}.
16661 unsigned long __builtin_ttest (void)
16664 This built-in can be used to determine the current transaction state
16665 using the following code example:
16668 #include <htmintrin.h>
16670 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16672 if (tx_state == _HTM_TRANSACTIONAL)
16674 /* Code to use in transactional state. */
16676 else if (tx_state == _HTM_NONTRANSACTIONAL)
16678 /* Code to use in non-transactional state. */
16680 else if (tx_state == _HTM_SUSPENDED)
16682 /* Code to use in transaction suspended state. */
16686 @subsubsection PowerPC HTM High Level Inline Functions
16688 The following high level HTM interface is made available by including
16689 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16690 where CPU is `power8' or later. This interface is common between PowerPC
16691 and S/390, allowing users to write one HTM source implementation that
16692 can be compiled and executed on either system.
16695 long __TM_simple_begin (void)
16696 long __TM_begin (void* const TM_buff)
16697 long __TM_end (void)
16698 void __TM_abort (void)
16699 void __TM_named_abort (unsigned char const code)
16700 void __TM_resume (void)
16701 void __TM_suspend (void)
16703 long __TM_is_user_abort (void* const TM_buff)
16704 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16705 long __TM_is_illegal (void* const TM_buff)
16706 long __TM_is_footprint_exceeded (void* const TM_buff)
16707 long __TM_nesting_depth (void* const TM_buff)
16708 long __TM_is_nested_too_deep(void* const TM_buff)
16709 long __TM_is_conflict(void* const TM_buff)
16710 long __TM_is_failure_persistent(void* const TM_buff)
16711 long __TM_failure_address(void* const TM_buff)
16712 long long __TM_failure_code(void* const TM_buff)
16715 Using these common set of HTM inline functions, we can create
16716 a more portable version of the HTM example in the previous
16717 section that will work on either PowerPC or S/390:
16720 #include <htmxlintrin.h>
16722 int num_retries = 10;
16723 TM_buff_type TM_buff;
16727 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
16729 /* Transaction State Initiated. */
16730 if (is_locked (lock))
16732 ... transaction code...
16738 /* Transaction State Failed. Use locks if the transaction
16739 failure is "persistent" or we've tried too many times. */
16740 if (num_retries-- <= 0
16741 || __TM_is_failure_persistent (TM_buff))
16743 acquire_lock (lock);
16744 ... non transactional fallback path...
16745 release_lock (lock);
16752 @node RX Built-in Functions
16753 @subsection RX Built-in Functions
16754 GCC supports some of the RX instructions which cannot be expressed in
16755 the C programming language via the use of built-in functions. The
16756 following functions are supported:
16758 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
16759 Generates the @code{brk} machine instruction.
16762 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
16763 Generates the @code{clrpsw} machine instruction to clear the specified
16764 bit in the processor status word.
16767 @deftypefn {Built-in Function} void __builtin_rx_int (int)
16768 Generates the @code{int} machine instruction to generate an interrupt
16769 with the specified value.
16772 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
16773 Generates the @code{machi} machine instruction to add the result of
16774 multiplying the top 16 bits of the two arguments into the
16778 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
16779 Generates the @code{maclo} machine instruction to add the result of
16780 multiplying the bottom 16 bits of the two arguments into the
16784 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
16785 Generates the @code{mulhi} machine instruction to place the result of
16786 multiplying the top 16 bits of the two arguments into the
16790 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
16791 Generates the @code{mullo} machine instruction to place the result of
16792 multiplying the bottom 16 bits of the two arguments into the
16796 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
16797 Generates the @code{mvfachi} machine instruction to read the top
16798 32 bits of the accumulator.
16801 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
16802 Generates the @code{mvfacmi} machine instruction to read the middle
16803 32 bits of the accumulator.
16806 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
16807 Generates the @code{mvfc} machine instruction which reads the control
16808 register specified in its argument and returns its value.
16811 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
16812 Generates the @code{mvtachi} machine instruction to set the top
16813 32 bits of the accumulator.
16816 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
16817 Generates the @code{mvtaclo} machine instruction to set the bottom
16818 32 bits of the accumulator.
16821 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
16822 Generates the @code{mvtc} machine instruction which sets control
16823 register number @code{reg} to @code{val}.
16826 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
16827 Generates the @code{mvtipl} machine instruction set the interrupt
16831 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
16832 Generates the @code{racw} machine instruction to round the accumulator
16833 according to the specified mode.
16836 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
16837 Generates the @code{revw} machine instruction which swaps the bytes in
16838 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16839 and also bits 16--23 occupy bits 24--31 and vice versa.
16842 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
16843 Generates the @code{rmpa} machine instruction which initiates a
16844 repeated multiply and accumulate sequence.
16847 @deftypefn {Built-in Function} void __builtin_rx_round (float)
16848 Generates the @code{round} machine instruction which returns the
16849 floating-point argument rounded according to the current rounding mode
16850 set in the floating-point status word register.
16853 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
16854 Generates the @code{sat} machine instruction which returns the
16855 saturated value of the argument.
16858 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
16859 Generates the @code{setpsw} machine instruction to set the specified
16860 bit in the processor status word.
16863 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
16864 Generates the @code{wait} machine instruction.
16867 @node S/390 System z Built-in Functions
16868 @subsection S/390 System z Built-in Functions
16869 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16870 Generates the @code{tbegin} machine instruction starting a
16871 non-constrained hardware transaction. If the parameter is non-NULL the
16872 memory area is used to store the transaction diagnostic buffer and
16873 will be passed as first operand to @code{tbegin}. This buffer can be
16874 defined using the @code{struct __htm_tdb} C struct defined in
16875 @code{htmintrin.h} and must reside on a double-word boundary. The
16876 second tbegin operand is set to @code{0xff0c}. This enables
16877 save/restore of all GPRs and disables aborts for FPR and AR
16878 manipulations inside the transaction body. The condition code set by
16879 the tbegin instruction is returned as integer value. The tbegin
16880 instruction by definition overwrites the content of all FPRs. The
16881 compiler will generate code which saves and restores the FPRs. For
16882 soft-float code it is recommended to used the @code{*_nofloat}
16883 variant. In order to prevent a TDB from being written it is required
16884 to pass a constant zero value as parameter. Passing a zero value
16885 through a variable is not sufficient. Although modifications of
16886 access registers inside the transaction will not trigger an
16887 transaction abort it is not supported to actually modify them. Access
16888 registers do not get saved when entering a transaction. They will have
16889 undefined state when reaching the abort code.
16892 Macros for the possible return codes of tbegin are defined in the
16893 @code{htmintrin.h} header file:
16896 @item _HTM_TBEGIN_STARTED
16897 @code{tbegin} has been executed as part of normal processing. The
16898 transaction body is supposed to be executed.
16899 @item _HTM_TBEGIN_INDETERMINATE
16900 The transaction was aborted due to an indeterminate condition which
16901 might be persistent.
16902 @item _HTM_TBEGIN_TRANSIENT
16903 The transaction aborted due to a transient failure. The transaction
16904 should be re-executed in that case.
16905 @item _HTM_TBEGIN_PERSISTENT
16906 The transaction aborted due to a persistent failure. Re-execution
16907 under same circumstances will not be productive.
16910 @defmac _HTM_FIRST_USER_ABORT_CODE
16911 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16912 specifies the first abort code which can be used for
16913 @code{__builtin_tabort}. Values below this threshold are reserved for
16917 @deftp {Data type} {struct __htm_tdb}
16918 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16919 the structure of the transaction diagnostic block as specified in the
16920 Principles of Operation manual chapter 5-91.
16923 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16924 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16925 Using this variant in code making use of FPRs will leave the FPRs in
16926 undefined state when entering the transaction abort handler code.
16929 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16930 In addition to @code{__builtin_tbegin} a loop for transient failures
16931 is generated. If tbegin returns a condition code of 2 the transaction
16932 will be retried as often as specified in the second argument. The
16933 perform processor assist instruction is used to tell the CPU about the
16934 number of fails so far.
16937 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16938 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16939 restores. Using this variant in code making use of FPRs will leave
16940 the FPRs in undefined state when entering the transaction abort
16944 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16945 Generates the @code{tbeginc} machine instruction starting a constrained
16946 hardware transaction. The second operand is set to @code{0xff08}.
16949 @deftypefn {Built-in Function} int __builtin_tend (void)
16950 Generates the @code{tend} machine instruction finishing a transaction
16951 and making the changes visible to other threads. The condition code
16952 generated by tend is returned as integer value.
16955 @deftypefn {Built-in Function} void __builtin_tabort (int)
16956 Generates the @code{tabort} machine instruction with the specified
16957 abort code. Abort codes from 0 through 255 are reserved and will
16958 result in an error message.
16961 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16962 Generates the @code{ppa rX,rY,1} machine instruction. Where the
16963 integer parameter is loaded into rX and a value of zero is loaded into
16964 rY. The integer parameter specifies the number of times the
16965 transaction repeatedly aborted.
16968 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16969 Generates the @code{etnd} machine instruction. The current nesting
16970 depth is returned as integer value. For a nesting depth of 0 the code
16971 is not executed as part of an transaction.
16974 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16976 Generates the @code{ntstg} machine instruction. The second argument
16977 is written to the first arguments location. The store operation will
16978 not be rolled-back in case of an transaction abort.
16981 @node SH Built-in Functions
16982 @subsection SH Built-in Functions
16983 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16984 families of processors:
16986 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16987 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
16988 used by system code that manages threads and execution contexts. The compiler
16989 normally does not generate code that modifies the contents of @samp{GBR} and
16990 thus the value is preserved across function calls. Changing the @samp{GBR}
16991 value in user code must be done with caution, since the compiler might use
16992 @samp{GBR} in order to access thread local variables.
16996 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16997 Returns the value that is currently set in the @samp{GBR} register.
16998 Memory loads and stores that use the thread pointer as a base address are
16999 turned into @samp{GBR} based displacement loads and stores, if possible.
17007 int get_tcb_value (void)
17009 // Generate @samp{mov.l @@(8,gbr),r0} instruction
17010 return ((my_tcb*)__builtin_thread_pointer ())->c;
17016 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
17017 Returns the value that is currently set in the @samp{FPSCR} register.
17020 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
17021 Sets the @samp{FPSCR} register to the specified value @var{val}, while
17022 preserving the current values of the FR, SZ and PR bits.
17025 @node SPARC VIS Built-in Functions
17026 @subsection SPARC VIS Built-in Functions
17028 GCC supports SIMD operations on the SPARC using both the generic vector
17029 extensions (@pxref{Vector Extensions}) as well as built-in functions for
17030 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
17031 switch, the VIS extension is exposed as the following built-in functions:
17034 typedef int v1si __attribute__ ((vector_size (4)));
17035 typedef int v2si __attribute__ ((vector_size (8)));
17036 typedef short v4hi __attribute__ ((vector_size (8)));
17037 typedef short v2hi __attribute__ ((vector_size (4)));
17038 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
17039 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
17041 void __builtin_vis_write_gsr (int64_t);
17042 int64_t __builtin_vis_read_gsr (void);
17044 void * __builtin_vis_alignaddr (void *, long);
17045 void * __builtin_vis_alignaddrl (void *, long);
17046 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
17047 v2si __builtin_vis_faligndatav2si (v2si, v2si);
17048 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
17049 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
17051 v4hi __builtin_vis_fexpand (v4qi);
17053 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
17054 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
17055 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
17056 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
17057 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
17058 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
17059 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
17061 v4qi __builtin_vis_fpack16 (v4hi);
17062 v8qi __builtin_vis_fpack32 (v2si, v8qi);
17063 v2hi __builtin_vis_fpackfix (v2si);
17064 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
17066 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
17068 long __builtin_vis_edge8 (void *, void *);
17069 long __builtin_vis_edge8l (void *, void *);
17070 long __builtin_vis_edge16 (void *, void *);
17071 long __builtin_vis_edge16l (void *, void *);
17072 long __builtin_vis_edge32 (void *, void *);
17073 long __builtin_vis_edge32l (void *, void *);
17075 long __builtin_vis_fcmple16 (v4hi, v4hi);
17076 long __builtin_vis_fcmple32 (v2si, v2si);
17077 long __builtin_vis_fcmpne16 (v4hi, v4hi);
17078 long __builtin_vis_fcmpne32 (v2si, v2si);
17079 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
17080 long __builtin_vis_fcmpgt32 (v2si, v2si);
17081 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
17082 long __builtin_vis_fcmpeq32 (v2si, v2si);
17084 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
17085 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
17086 v2si __builtin_vis_fpadd32 (v2si, v2si);
17087 v1si __builtin_vis_fpadd32s (v1si, v1si);
17088 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
17089 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
17090 v2si __builtin_vis_fpsub32 (v2si, v2si);
17091 v1si __builtin_vis_fpsub32s (v1si, v1si);
17093 long __builtin_vis_array8 (long, long);
17094 long __builtin_vis_array16 (long, long);
17095 long __builtin_vis_array32 (long, long);
17098 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
17099 functions also become available:
17102 long __builtin_vis_bmask (long, long);
17103 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
17104 v2si __builtin_vis_bshufflev2si (v2si, v2si);
17105 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
17106 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
17108 long __builtin_vis_edge8n (void *, void *);
17109 long __builtin_vis_edge8ln (void *, void *);
17110 long __builtin_vis_edge16n (void *, void *);
17111 long __builtin_vis_edge16ln (void *, void *);
17112 long __builtin_vis_edge32n (void *, void *);
17113 long __builtin_vis_edge32ln (void *, void *);
17116 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
17117 functions also become available:
17120 void __builtin_vis_cmask8 (long);
17121 void __builtin_vis_cmask16 (long);
17122 void __builtin_vis_cmask32 (long);
17124 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
17126 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
17127 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
17128 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
17129 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
17130 v2si __builtin_vis_fsll16 (v2si, v2si);
17131 v2si __builtin_vis_fslas16 (v2si, v2si);
17132 v2si __builtin_vis_fsrl16 (v2si, v2si);
17133 v2si __builtin_vis_fsra16 (v2si, v2si);
17135 long __builtin_vis_pdistn (v8qi, v8qi);
17137 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
17139 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
17140 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
17142 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
17143 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
17144 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
17145 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
17146 v2si __builtin_vis_fpadds32 (v2si, v2si);
17147 v1si __builtin_vis_fpadds32s (v1si, v1si);
17148 v2si __builtin_vis_fpsubs32 (v2si, v2si);
17149 v1si __builtin_vis_fpsubs32s (v1si, v1si);
17151 long __builtin_vis_fucmple8 (v8qi, v8qi);
17152 long __builtin_vis_fucmpne8 (v8qi, v8qi);
17153 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
17154 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
17156 float __builtin_vis_fhadds (float, float);
17157 double __builtin_vis_fhaddd (double, double);
17158 float __builtin_vis_fhsubs (float, float);
17159 double __builtin_vis_fhsubd (double, double);
17160 float __builtin_vis_fnhadds (float, float);
17161 double __builtin_vis_fnhaddd (double, double);
17163 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
17164 int64_t __builtin_vis_xmulx (int64_t, int64_t);
17165 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
17168 @node SPU Built-in Functions
17169 @subsection SPU Built-in Functions
17171 GCC provides extensions for the SPU processor as described in the
17172 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
17173 found at @uref{http://cell.scei.co.jp/} or
17174 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
17175 implementation differs in several ways.
17180 The optional extension of specifying vector constants in parentheses is
17184 A vector initializer requires no cast if the vector constant is of the
17185 same type as the variable it is initializing.
17188 If @code{signed} or @code{unsigned} is omitted, the signedness of the
17189 vector type is the default signedness of the base type. The default
17190 varies depending on the operating system, so a portable program should
17191 always specify the signedness.
17194 By default, the keyword @code{__vector} is added. The macro
17195 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
17199 GCC allows using a @code{typedef} name as the type specifier for a
17203 For C, overloaded functions are implemented with macros so the following
17207 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
17211 Since @code{spu_add} is a macro, the vector constant in the example
17212 is treated as four separate arguments. Wrap the entire argument in
17213 parentheses for this to work.
17216 The extended version of @code{__builtin_expect} is not supported.
17220 @emph{Note:} Only the interface described in the aforementioned
17221 specification is supported. Internally, GCC uses built-in functions to
17222 implement the required functionality, but these are not supported and
17223 are subject to change without notice.
17225 @node TI C6X Built-in Functions
17226 @subsection TI C6X Built-in Functions
17228 GCC provides intrinsics to access certain instructions of the TI C6X
17229 processors. These intrinsics, listed below, are available after
17230 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
17231 to C6X instructions.
17235 int _sadd (int, int)
17236 int _ssub (int, int)
17237 int _sadd2 (int, int)
17238 int _ssub2 (int, int)
17239 long long _mpy2 (int, int)
17240 long long _smpy2 (int, int)
17241 int _add4 (int, int)
17242 int _sub4 (int, int)
17243 int _saddu4 (int, int)
17245 int _smpy (int, int)
17246 int _smpyh (int, int)
17247 int _smpyhl (int, int)
17248 int _smpylh (int, int)
17250 int _sshl (int, int)
17251 int _subc (int, int)
17253 int _avg2 (int, int)
17254 int _avgu4 (int, int)
17256 int _clrr (int, int)
17257 int _extr (int, int)
17258 int _extru (int, int)
17264 @node TILE-Gx Built-in Functions
17265 @subsection TILE-Gx Built-in Functions
17267 GCC provides intrinsics to access every instruction of the TILE-Gx
17268 processor. The intrinsics are of the form:
17272 unsigned long long __insn_@var{op} (...)
17276 Where @var{op} is the name of the instruction. Refer to the ISA manual
17277 for the complete list of instructions.
17279 GCC also provides intrinsics to directly access the network registers.
17280 The intrinsics are:
17284 unsigned long long __tile_idn0_receive (void)
17285 unsigned long long __tile_idn1_receive (void)
17286 unsigned long long __tile_udn0_receive (void)
17287 unsigned long long __tile_udn1_receive (void)
17288 unsigned long long __tile_udn2_receive (void)
17289 unsigned long long __tile_udn3_receive (void)
17290 void __tile_idn_send (unsigned long long)
17291 void __tile_udn_send (unsigned long long)
17295 The intrinsic @code{void __tile_network_barrier (void)} is used to
17296 guarantee that no network operations before it are reordered with
17299 @node TILEPro Built-in Functions
17300 @subsection TILEPro Built-in Functions
17302 GCC provides intrinsics to access every instruction of the TILEPro
17303 processor. The intrinsics are of the form:
17307 unsigned __insn_@var{op} (...)
17312 where @var{op} is the name of the instruction. Refer to the ISA manual
17313 for the complete list of instructions.
17315 GCC also provides intrinsics to directly access the network registers.
17316 The intrinsics are:
17320 unsigned __tile_idn0_receive (void)
17321 unsigned __tile_idn1_receive (void)
17322 unsigned __tile_sn_receive (void)
17323 unsigned __tile_udn0_receive (void)
17324 unsigned __tile_udn1_receive (void)
17325 unsigned __tile_udn2_receive (void)
17326 unsigned __tile_udn3_receive (void)
17327 void __tile_idn_send (unsigned)
17328 void __tile_sn_send (unsigned)
17329 void __tile_udn_send (unsigned)
17333 The intrinsic @code{void __tile_network_barrier (void)} is used to
17334 guarantee that no network operations before it are reordered with
17337 @node x86 Built-in Functions
17338 @subsection x86 Built-in Functions
17340 These built-in functions are available for the x86-32 and x86-64 family
17341 of computers, depending on the command-line switches used.
17343 If you specify command-line switches such as @option{-msse},
17344 the compiler could use the extended instruction sets even if the built-ins
17345 are not used explicitly in the program. For this reason, applications
17346 that perform run-time CPU detection must compile separate files for each
17347 supported architecture, using the appropriate flags. In particular,
17348 the file containing the CPU detection code should be compiled without
17351 The following machine modes are available for use with MMX built-in functions
17352 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
17353 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
17354 vector of eight 8-bit integers. Some of the built-in functions operate on
17355 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
17357 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
17358 of two 32-bit floating-point values.
17360 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
17361 floating-point values. Some instructions use a vector of four 32-bit
17362 integers, these use @code{V4SI}. Finally, some instructions operate on an
17363 entire vector register, interpreting it as a 128-bit integer, these use mode
17366 In 64-bit mode, the x86-64 family of processors uses additional built-in
17367 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
17368 floating point and @code{TC} 128-bit complex floating-point values.
17370 The following floating-point built-in functions are available in 64-bit
17371 mode. All of them implement the function that is part of the name.
17374 __float128 __builtin_fabsq (__float128)
17375 __float128 __builtin_copysignq (__float128, __float128)
17378 The following built-in function is always available.
17381 @item void __builtin_ia32_pause (void)
17382 Generates the @code{pause} machine instruction with a compiler memory
17386 The following floating-point built-in functions are made available in the
17390 @item __float128 __builtin_infq (void)
17391 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
17392 @findex __builtin_infq
17394 @item __float128 __builtin_huge_valq (void)
17395 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
17396 @findex __builtin_huge_valq
17399 The following built-in functions are always available and can be used to
17400 check the target platform type.
17402 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
17403 This function runs the CPU detection code to check the type of CPU and the
17404 features supported. This built-in function needs to be invoked along with the built-in functions
17405 to check CPU type and features, @code{__builtin_cpu_is} and
17406 @code{__builtin_cpu_supports}, only when used in a function that is
17407 executed before any constructors are called. The CPU detection code is
17408 automatically executed in a very high priority constructor.
17410 For example, this function has to be used in @code{ifunc} resolvers that
17411 check for CPU type using the built-in functions @code{__builtin_cpu_is}
17412 and @code{__builtin_cpu_supports}, or in constructors on targets that
17413 don't support constructor priority.
17416 static void (*resolve_memcpy (void)) (void)
17418 // ifunc resolvers fire before constructors, explicitly call the init
17420 __builtin_cpu_init ();
17421 if (__builtin_cpu_supports ("ssse3"))
17422 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
17424 return default_memcpy;
17427 void *memcpy (void *, const void *, size_t)
17428 __attribute__ ((ifunc ("resolve_memcpy")));
17433 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
17434 This function returns a positive integer if the run-time CPU
17435 is of type @var{cpuname}
17436 and returns @code{0} otherwise. The following CPU names can be detected:
17452 Intel Core i7 Nehalem CPU.
17455 Intel Core i7 Westmere CPU.
17458 Intel Core i7 Sandy Bridge CPU.
17464 AMD Family 10h CPU.
17467 AMD Family 10h Barcelona CPU.
17470 AMD Family 10h Shanghai CPU.
17473 AMD Family 10h Istanbul CPU.
17476 AMD Family 14h CPU.
17479 AMD Family 15h CPU.
17482 AMD Family 15h Bulldozer version 1.
17485 AMD Family 15h Bulldozer version 2.
17488 AMD Family 15h Bulldozer version 3.
17491 AMD Family 15h Bulldozer version 4.
17494 AMD Family 16h CPU.
17497 AMD Family 17h CPU.
17500 Here is an example:
17502 if (__builtin_cpu_is ("corei7"))
17504 do_corei7 (); // Core i7 specific implementation.
17508 do_generic (); // Generic implementation.
17513 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
17514 This function returns a positive integer if the run-time CPU
17515 supports @var{feature}
17516 and returns @code{0} otherwise. The following features can be detected:
17524 POPCNT instruction.
17532 SSSE3 instructions.
17534 SSE4.1 instructions.
17536 SSE4.2 instructions.
17542 AVX512F instructions.
17545 Here is an example:
17547 if (__builtin_cpu_supports ("popcnt"))
17549 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
17553 count = generic_countbits (n); //generic implementation.
17559 The following built-in functions are made available by @option{-mmmx}.
17560 All of them generate the machine instruction that is part of the name.
17563 v8qi __builtin_ia32_paddb (v8qi, v8qi)
17564 v4hi __builtin_ia32_paddw (v4hi, v4hi)
17565 v2si __builtin_ia32_paddd (v2si, v2si)
17566 v8qi __builtin_ia32_psubb (v8qi, v8qi)
17567 v4hi __builtin_ia32_psubw (v4hi, v4hi)
17568 v2si __builtin_ia32_psubd (v2si, v2si)
17569 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
17570 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
17571 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
17572 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
17573 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
17574 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
17575 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
17576 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
17577 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
17578 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
17579 di __builtin_ia32_pand (di, di)
17580 di __builtin_ia32_pandn (di,di)
17581 di __builtin_ia32_por (di, di)
17582 di __builtin_ia32_pxor (di, di)
17583 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
17584 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
17585 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
17586 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
17587 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
17588 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
17589 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
17590 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
17591 v2si __builtin_ia32_punpckhdq (v2si, v2si)
17592 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
17593 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
17594 v2si __builtin_ia32_punpckldq (v2si, v2si)
17595 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
17596 v4hi __builtin_ia32_packssdw (v2si, v2si)
17597 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
17599 v4hi __builtin_ia32_psllw (v4hi, v4hi)
17600 v2si __builtin_ia32_pslld (v2si, v2si)
17601 v1di __builtin_ia32_psllq (v1di, v1di)
17602 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
17603 v2si __builtin_ia32_psrld (v2si, v2si)
17604 v1di __builtin_ia32_psrlq (v1di, v1di)
17605 v4hi __builtin_ia32_psraw (v4hi, v4hi)
17606 v2si __builtin_ia32_psrad (v2si, v2si)
17607 v4hi __builtin_ia32_psllwi (v4hi, int)
17608 v2si __builtin_ia32_pslldi (v2si, int)
17609 v1di __builtin_ia32_psllqi (v1di, int)
17610 v4hi __builtin_ia32_psrlwi (v4hi, int)
17611 v2si __builtin_ia32_psrldi (v2si, int)
17612 v1di __builtin_ia32_psrlqi (v1di, int)
17613 v4hi __builtin_ia32_psrawi (v4hi, int)
17614 v2si __builtin_ia32_psradi (v2si, int)
17618 The following built-in functions are made available either with
17619 @option{-msse}, or with a combination of @option{-m3dnow} and
17620 @option{-march=athlon}. All of them generate the machine
17621 instruction that is part of the name.
17624 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
17625 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
17626 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
17627 v1di __builtin_ia32_psadbw (v8qi, v8qi)
17628 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
17629 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
17630 v8qi __builtin_ia32_pminub (v8qi, v8qi)
17631 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
17632 int __builtin_ia32_pmovmskb (v8qi)
17633 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
17634 void __builtin_ia32_movntq (di *, di)
17635 void __builtin_ia32_sfence (void)
17638 The following built-in functions are available when @option{-msse} is used.
17639 All of them generate the machine instruction that is part of the name.
17642 int __builtin_ia32_comieq (v4sf, v4sf)
17643 int __builtin_ia32_comineq (v4sf, v4sf)
17644 int __builtin_ia32_comilt (v4sf, v4sf)
17645 int __builtin_ia32_comile (v4sf, v4sf)
17646 int __builtin_ia32_comigt (v4sf, v4sf)
17647 int __builtin_ia32_comige (v4sf, v4sf)
17648 int __builtin_ia32_ucomieq (v4sf, v4sf)
17649 int __builtin_ia32_ucomineq (v4sf, v4sf)
17650 int __builtin_ia32_ucomilt (v4sf, v4sf)
17651 int __builtin_ia32_ucomile (v4sf, v4sf)
17652 int __builtin_ia32_ucomigt (v4sf, v4sf)
17653 int __builtin_ia32_ucomige (v4sf, v4sf)
17654 v4sf __builtin_ia32_addps (v4sf, v4sf)
17655 v4sf __builtin_ia32_subps (v4sf, v4sf)
17656 v4sf __builtin_ia32_mulps (v4sf, v4sf)
17657 v4sf __builtin_ia32_divps (v4sf, v4sf)
17658 v4sf __builtin_ia32_addss (v4sf, v4sf)
17659 v4sf __builtin_ia32_subss (v4sf, v4sf)
17660 v4sf __builtin_ia32_mulss (v4sf, v4sf)
17661 v4sf __builtin_ia32_divss (v4sf, v4sf)
17662 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
17663 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
17664 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
17665 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
17666 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
17667 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
17668 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
17669 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
17670 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
17671 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
17672 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
17673 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
17674 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
17675 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
17676 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
17677 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
17678 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
17679 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
17680 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
17681 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
17682 v4sf __builtin_ia32_maxps (v4sf, v4sf)
17683 v4sf __builtin_ia32_maxss (v4sf, v4sf)
17684 v4sf __builtin_ia32_minps (v4sf, v4sf)
17685 v4sf __builtin_ia32_minss (v4sf, v4sf)
17686 v4sf __builtin_ia32_andps (v4sf, v4sf)
17687 v4sf __builtin_ia32_andnps (v4sf, v4sf)
17688 v4sf __builtin_ia32_orps (v4sf, v4sf)
17689 v4sf __builtin_ia32_xorps (v4sf, v4sf)
17690 v4sf __builtin_ia32_movss (v4sf, v4sf)
17691 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
17692 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
17693 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
17694 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
17695 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
17696 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
17697 v2si __builtin_ia32_cvtps2pi (v4sf)
17698 int __builtin_ia32_cvtss2si (v4sf)
17699 v2si __builtin_ia32_cvttps2pi (v4sf)
17700 int __builtin_ia32_cvttss2si (v4sf)
17701 v4sf __builtin_ia32_rcpps (v4sf)
17702 v4sf __builtin_ia32_rsqrtps (v4sf)
17703 v4sf __builtin_ia32_sqrtps (v4sf)
17704 v4sf __builtin_ia32_rcpss (v4sf)
17705 v4sf __builtin_ia32_rsqrtss (v4sf)
17706 v4sf __builtin_ia32_sqrtss (v4sf)
17707 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
17708 void __builtin_ia32_movntps (float *, v4sf)
17709 int __builtin_ia32_movmskps (v4sf)
17712 The following built-in functions are available when @option{-msse} is used.
17715 @item v4sf __builtin_ia32_loadups (float *)
17716 Generates the @code{movups} machine instruction as a load from memory.
17717 @item void __builtin_ia32_storeups (float *, v4sf)
17718 Generates the @code{movups} machine instruction as a store to memory.
17719 @item v4sf __builtin_ia32_loadss (float *)
17720 Generates the @code{movss} machine instruction as a load from memory.
17721 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
17722 Generates the @code{movhps} machine instruction as a load from memory.
17723 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
17724 Generates the @code{movlps} machine instruction as a load from memory
17725 @item void __builtin_ia32_storehps (v2sf *, v4sf)
17726 Generates the @code{movhps} machine instruction as a store to memory.
17727 @item void __builtin_ia32_storelps (v2sf *, v4sf)
17728 Generates the @code{movlps} machine instruction as a store to memory.
17731 The following built-in functions are available when @option{-msse2} is used.
17732 All of them generate the machine instruction that is part of the name.
17735 int __builtin_ia32_comisdeq (v2df, v2df)
17736 int __builtin_ia32_comisdlt (v2df, v2df)
17737 int __builtin_ia32_comisdle (v2df, v2df)
17738 int __builtin_ia32_comisdgt (v2df, v2df)
17739 int __builtin_ia32_comisdge (v2df, v2df)
17740 int __builtin_ia32_comisdneq (v2df, v2df)
17741 int __builtin_ia32_ucomisdeq (v2df, v2df)
17742 int __builtin_ia32_ucomisdlt (v2df, v2df)
17743 int __builtin_ia32_ucomisdle (v2df, v2df)
17744 int __builtin_ia32_ucomisdgt (v2df, v2df)
17745 int __builtin_ia32_ucomisdge (v2df, v2df)
17746 int __builtin_ia32_ucomisdneq (v2df, v2df)
17747 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
17748 v2df __builtin_ia32_cmpltpd (v2df, v2df)
17749 v2df __builtin_ia32_cmplepd (v2df, v2df)
17750 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
17751 v2df __builtin_ia32_cmpgepd (v2df, v2df)
17752 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
17753 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
17754 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
17755 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
17756 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
17757 v2df __builtin_ia32_cmpngepd (v2df, v2df)
17758 v2df __builtin_ia32_cmpordpd (v2df, v2df)
17759 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
17760 v2df __builtin_ia32_cmpltsd (v2df, v2df)
17761 v2df __builtin_ia32_cmplesd (v2df, v2df)
17762 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
17763 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
17764 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
17765 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
17766 v2df __builtin_ia32_cmpordsd (v2df, v2df)
17767 v2di __builtin_ia32_paddq (v2di, v2di)
17768 v2di __builtin_ia32_psubq (v2di, v2di)
17769 v2df __builtin_ia32_addpd (v2df, v2df)
17770 v2df __builtin_ia32_subpd (v2df, v2df)
17771 v2df __builtin_ia32_mulpd (v2df, v2df)
17772 v2df __builtin_ia32_divpd (v2df, v2df)
17773 v2df __builtin_ia32_addsd (v2df, v2df)
17774 v2df __builtin_ia32_subsd (v2df, v2df)
17775 v2df __builtin_ia32_mulsd (v2df, v2df)
17776 v2df __builtin_ia32_divsd (v2df, v2df)
17777 v2df __builtin_ia32_minpd (v2df, v2df)
17778 v2df __builtin_ia32_maxpd (v2df, v2df)
17779 v2df __builtin_ia32_minsd (v2df, v2df)
17780 v2df __builtin_ia32_maxsd (v2df, v2df)
17781 v2df __builtin_ia32_andpd (v2df, v2df)
17782 v2df __builtin_ia32_andnpd (v2df, v2df)
17783 v2df __builtin_ia32_orpd (v2df, v2df)
17784 v2df __builtin_ia32_xorpd (v2df, v2df)
17785 v2df __builtin_ia32_movsd (v2df, v2df)
17786 v2df __builtin_ia32_unpckhpd (v2df, v2df)
17787 v2df __builtin_ia32_unpcklpd (v2df, v2df)
17788 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
17789 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
17790 v4si __builtin_ia32_paddd128 (v4si, v4si)
17791 v2di __builtin_ia32_paddq128 (v2di, v2di)
17792 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
17793 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
17794 v4si __builtin_ia32_psubd128 (v4si, v4si)
17795 v2di __builtin_ia32_psubq128 (v2di, v2di)
17796 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
17797 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
17798 v2di __builtin_ia32_pand128 (v2di, v2di)
17799 v2di __builtin_ia32_pandn128 (v2di, v2di)
17800 v2di __builtin_ia32_por128 (v2di, v2di)
17801 v2di __builtin_ia32_pxor128 (v2di, v2di)
17802 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
17803 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
17804 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
17805 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
17806 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
17807 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
17808 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
17809 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
17810 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
17811 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
17812 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
17813 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
17814 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
17815 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
17816 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
17817 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
17818 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
17819 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
17820 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
17821 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
17822 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
17823 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
17824 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
17825 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
17826 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
17827 v2df __builtin_ia32_loadupd (double *)
17828 void __builtin_ia32_storeupd (double *, v2df)
17829 v2df __builtin_ia32_loadhpd (v2df, double const *)
17830 v2df __builtin_ia32_loadlpd (v2df, double const *)
17831 int __builtin_ia32_movmskpd (v2df)
17832 int __builtin_ia32_pmovmskb128 (v16qi)
17833 void __builtin_ia32_movnti (int *, int)
17834 void __builtin_ia32_movnti64 (long long int *, long long int)
17835 void __builtin_ia32_movntpd (double *, v2df)
17836 void __builtin_ia32_movntdq (v2df *, v2df)
17837 v4si __builtin_ia32_pshufd (v4si, int)
17838 v8hi __builtin_ia32_pshuflw (v8hi, int)
17839 v8hi __builtin_ia32_pshufhw (v8hi, int)
17840 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
17841 v2df __builtin_ia32_sqrtpd (v2df)
17842 v2df __builtin_ia32_sqrtsd (v2df)
17843 v2df __builtin_ia32_shufpd (v2df, v2df, int)
17844 v2df __builtin_ia32_cvtdq2pd (v4si)
17845 v4sf __builtin_ia32_cvtdq2ps (v4si)
17846 v4si __builtin_ia32_cvtpd2dq (v2df)
17847 v2si __builtin_ia32_cvtpd2pi (v2df)
17848 v4sf __builtin_ia32_cvtpd2ps (v2df)
17849 v4si __builtin_ia32_cvttpd2dq (v2df)
17850 v2si __builtin_ia32_cvttpd2pi (v2df)
17851 v2df __builtin_ia32_cvtpi2pd (v2si)
17852 int __builtin_ia32_cvtsd2si (v2df)
17853 int __builtin_ia32_cvttsd2si (v2df)
17854 long long __builtin_ia32_cvtsd2si64 (v2df)
17855 long long __builtin_ia32_cvttsd2si64 (v2df)
17856 v4si __builtin_ia32_cvtps2dq (v4sf)
17857 v2df __builtin_ia32_cvtps2pd (v4sf)
17858 v4si __builtin_ia32_cvttps2dq (v4sf)
17859 v2df __builtin_ia32_cvtsi2sd (v2df, int)
17860 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
17861 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
17862 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
17863 void __builtin_ia32_clflush (const void *)
17864 void __builtin_ia32_lfence (void)
17865 void __builtin_ia32_mfence (void)
17866 v16qi __builtin_ia32_loaddqu (const char *)
17867 void __builtin_ia32_storedqu (char *, v16qi)
17868 v1di __builtin_ia32_pmuludq (v2si, v2si)
17869 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
17870 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
17871 v4si __builtin_ia32_pslld128 (v4si, v4si)
17872 v2di __builtin_ia32_psllq128 (v2di, v2di)
17873 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
17874 v4si __builtin_ia32_psrld128 (v4si, v4si)
17875 v2di __builtin_ia32_psrlq128 (v2di, v2di)
17876 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
17877 v4si __builtin_ia32_psrad128 (v4si, v4si)
17878 v2di __builtin_ia32_pslldqi128 (v2di, int)
17879 v8hi __builtin_ia32_psllwi128 (v8hi, int)
17880 v4si __builtin_ia32_pslldi128 (v4si, int)
17881 v2di __builtin_ia32_psllqi128 (v2di, int)
17882 v2di __builtin_ia32_psrldqi128 (v2di, int)
17883 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
17884 v4si __builtin_ia32_psrldi128 (v4si, int)
17885 v2di __builtin_ia32_psrlqi128 (v2di, int)
17886 v8hi __builtin_ia32_psrawi128 (v8hi, int)
17887 v4si __builtin_ia32_psradi128 (v4si, int)
17888 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
17889 v2di __builtin_ia32_movq128 (v2di)
17892 The following built-in functions are available when @option{-msse3} is used.
17893 All of them generate the machine instruction that is part of the name.
17896 v2df __builtin_ia32_addsubpd (v2df, v2df)
17897 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
17898 v2df __builtin_ia32_haddpd (v2df, v2df)
17899 v4sf __builtin_ia32_haddps (v4sf, v4sf)
17900 v2df __builtin_ia32_hsubpd (v2df, v2df)
17901 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
17902 v16qi __builtin_ia32_lddqu (char const *)
17903 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
17904 v4sf __builtin_ia32_movshdup (v4sf)
17905 v4sf __builtin_ia32_movsldup (v4sf)
17906 void __builtin_ia32_mwait (unsigned int, unsigned int)
17909 The following built-in functions are available when @option{-mssse3} is used.
17910 All of them generate the machine instruction that is part of the name.
17913 v2si __builtin_ia32_phaddd (v2si, v2si)
17914 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
17915 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
17916 v2si __builtin_ia32_phsubd (v2si, v2si)
17917 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
17918 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
17919 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
17920 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
17921 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
17922 v8qi __builtin_ia32_psignb (v8qi, v8qi)
17923 v2si __builtin_ia32_psignd (v2si, v2si)
17924 v4hi __builtin_ia32_psignw (v4hi, v4hi)
17925 v1di __builtin_ia32_palignr (v1di, v1di, int)
17926 v8qi __builtin_ia32_pabsb (v8qi)
17927 v2si __builtin_ia32_pabsd (v2si)
17928 v4hi __builtin_ia32_pabsw (v4hi)
17931 The following built-in functions are available when @option{-mssse3} is used.
17932 All of them generate the machine instruction that is part of the name.
17935 v4si __builtin_ia32_phaddd128 (v4si, v4si)
17936 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
17937 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
17938 v4si __builtin_ia32_phsubd128 (v4si, v4si)
17939 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
17940 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
17941 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
17942 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
17943 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
17944 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
17945 v4si __builtin_ia32_psignd128 (v4si, v4si)
17946 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
17947 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
17948 v16qi __builtin_ia32_pabsb128 (v16qi)
17949 v4si __builtin_ia32_pabsd128 (v4si)
17950 v8hi __builtin_ia32_pabsw128 (v8hi)
17953 The following built-in functions are available when @option{-msse4.1} is
17954 used. All of them generate the machine instruction that is part of the
17958 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
17959 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
17960 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
17961 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
17962 v2df __builtin_ia32_dppd (v2df, v2df, const int)
17963 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
17964 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
17965 v2di __builtin_ia32_movntdqa (v2di *);
17966 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
17967 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
17968 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
17969 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
17970 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
17971 v8hi __builtin_ia32_phminposuw128 (v8hi)
17972 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
17973 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
17974 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
17975 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
17976 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
17977 v4si __builtin_ia32_pminsd128 (v4si, v4si)
17978 v4si __builtin_ia32_pminud128 (v4si, v4si)
17979 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
17980 v4si __builtin_ia32_pmovsxbd128 (v16qi)
17981 v2di __builtin_ia32_pmovsxbq128 (v16qi)
17982 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
17983 v2di __builtin_ia32_pmovsxdq128 (v4si)
17984 v4si __builtin_ia32_pmovsxwd128 (v8hi)
17985 v2di __builtin_ia32_pmovsxwq128 (v8hi)
17986 v4si __builtin_ia32_pmovzxbd128 (v16qi)
17987 v2di __builtin_ia32_pmovzxbq128 (v16qi)
17988 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
17989 v2di __builtin_ia32_pmovzxdq128 (v4si)
17990 v4si __builtin_ia32_pmovzxwd128 (v8hi)
17991 v2di __builtin_ia32_pmovzxwq128 (v8hi)
17992 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
17993 v4si __builtin_ia32_pmulld128 (v4si, v4si)
17994 int __builtin_ia32_ptestc128 (v2di, v2di)
17995 int __builtin_ia32_ptestnzc128 (v2di, v2di)
17996 int __builtin_ia32_ptestz128 (v2di, v2di)
17997 v2df __builtin_ia32_roundpd (v2df, const int)
17998 v4sf __builtin_ia32_roundps (v4sf, const int)
17999 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
18000 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
18003 The following built-in functions are available when @option{-msse4.1} is
18007 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
18008 Generates the @code{insertps} machine instruction.
18009 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
18010 Generates the @code{pextrb} machine instruction.
18011 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
18012 Generates the @code{pinsrb} machine instruction.
18013 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
18014 Generates the @code{pinsrd} machine instruction.
18015 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
18016 Generates the @code{pinsrq} machine instruction in 64bit mode.
18019 The following built-in functions are changed to generate new SSE4.1
18020 instructions when @option{-msse4.1} is used.
18023 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
18024 Generates the @code{extractps} machine instruction.
18025 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
18026 Generates the @code{pextrd} machine instruction.
18027 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
18028 Generates the @code{pextrq} machine instruction in 64bit mode.
18031 The following built-in functions are available when @option{-msse4.2} is
18032 used. All of them generate the machine instruction that is part of the
18036 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
18037 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
18038 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
18039 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
18040 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
18041 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
18042 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
18043 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
18044 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
18045 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
18046 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
18047 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
18048 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
18049 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
18050 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
18053 The following built-in functions are available when @option{-msse4.2} is
18057 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
18058 Generates the @code{crc32b} machine instruction.
18059 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
18060 Generates the @code{crc32w} machine instruction.
18061 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
18062 Generates the @code{crc32l} machine instruction.
18063 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
18064 Generates the @code{crc32q} machine instruction.
18067 The following built-in functions are changed to generate new SSE4.2
18068 instructions when @option{-msse4.2} is used.
18071 @item int __builtin_popcount (unsigned int)
18072 Generates the @code{popcntl} machine instruction.
18073 @item int __builtin_popcountl (unsigned long)
18074 Generates the @code{popcntl} or @code{popcntq} machine instruction,
18075 depending on the size of @code{unsigned long}.
18076 @item int __builtin_popcountll (unsigned long long)
18077 Generates the @code{popcntq} machine instruction.
18080 The following built-in functions are available when @option{-mavx} is
18081 used. All of them generate the machine instruction that is part of the
18085 v4df __builtin_ia32_addpd256 (v4df,v4df)
18086 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
18087 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
18088 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
18089 v4df __builtin_ia32_andnpd256 (v4df,v4df)
18090 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
18091 v4df __builtin_ia32_andpd256 (v4df,v4df)
18092 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
18093 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
18094 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
18095 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
18096 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
18097 v2df __builtin_ia32_cmppd (v2df,v2df,int)
18098 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
18099 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
18100 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
18101 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
18102 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
18103 v4df __builtin_ia32_cvtdq2pd256 (v4si)
18104 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
18105 v4si __builtin_ia32_cvtpd2dq256 (v4df)
18106 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
18107 v8si __builtin_ia32_cvtps2dq256 (v8sf)
18108 v4df __builtin_ia32_cvtps2pd256 (v4sf)
18109 v4si __builtin_ia32_cvttpd2dq256 (v4df)
18110 v8si __builtin_ia32_cvttps2dq256 (v8sf)
18111 v4df __builtin_ia32_divpd256 (v4df,v4df)
18112 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
18113 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
18114 v4df __builtin_ia32_haddpd256 (v4df,v4df)
18115 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
18116 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
18117 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
18118 v32qi __builtin_ia32_lddqu256 (pcchar)
18119 v32qi __builtin_ia32_loaddqu256 (pcchar)
18120 v4df __builtin_ia32_loadupd256 (pcdouble)
18121 v8sf __builtin_ia32_loadups256 (pcfloat)
18122 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
18123 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
18124 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
18125 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
18126 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
18127 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
18128 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
18129 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
18130 v4df __builtin_ia32_maxpd256 (v4df,v4df)
18131 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
18132 v4df __builtin_ia32_minpd256 (v4df,v4df)
18133 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
18134 v4df __builtin_ia32_movddup256 (v4df)
18135 int __builtin_ia32_movmskpd256 (v4df)
18136 int __builtin_ia32_movmskps256 (v8sf)
18137 v8sf __builtin_ia32_movshdup256 (v8sf)
18138 v8sf __builtin_ia32_movsldup256 (v8sf)
18139 v4df __builtin_ia32_mulpd256 (v4df,v4df)
18140 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
18141 v4df __builtin_ia32_orpd256 (v4df,v4df)
18142 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
18143 v2df __builtin_ia32_pd_pd256 (v4df)
18144 v4df __builtin_ia32_pd256_pd (v2df)
18145 v4sf __builtin_ia32_ps_ps256 (v8sf)
18146 v8sf __builtin_ia32_ps256_ps (v4sf)
18147 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
18148 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
18149 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
18150 v8sf __builtin_ia32_rcpps256 (v8sf)
18151 v4df __builtin_ia32_roundpd256 (v4df,int)
18152 v8sf __builtin_ia32_roundps256 (v8sf,int)
18153 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
18154 v8sf __builtin_ia32_rsqrtps256 (v8sf)
18155 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
18156 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
18157 v4si __builtin_ia32_si_si256 (v8si)
18158 v8si __builtin_ia32_si256_si (v4si)
18159 v4df __builtin_ia32_sqrtpd256 (v4df)
18160 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
18161 v8sf __builtin_ia32_sqrtps256 (v8sf)
18162 void __builtin_ia32_storedqu256 (pchar,v32qi)
18163 void __builtin_ia32_storeupd256 (pdouble,v4df)
18164 void __builtin_ia32_storeups256 (pfloat,v8sf)
18165 v4df __builtin_ia32_subpd256 (v4df,v4df)
18166 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
18167 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
18168 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
18169 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
18170 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
18171 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
18172 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
18173 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
18174 v4sf __builtin_ia32_vbroadcastss (pcfloat)
18175 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
18176 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
18177 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
18178 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
18179 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
18180 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
18181 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
18182 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
18183 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
18184 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
18185 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
18186 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
18187 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
18188 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
18189 v2df __builtin_ia32_vpermilpd (v2df,int)
18190 v4df __builtin_ia32_vpermilpd256 (v4df,int)
18191 v4sf __builtin_ia32_vpermilps (v4sf,int)
18192 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
18193 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
18194 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
18195 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
18196 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
18197 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
18198 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
18199 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
18200 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
18201 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
18202 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
18203 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
18204 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
18205 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
18206 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
18207 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
18208 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
18209 void __builtin_ia32_vzeroall (void)
18210 void __builtin_ia32_vzeroupper (void)
18211 v4df __builtin_ia32_xorpd256 (v4df,v4df)
18212 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
18215 The following built-in functions are available when @option{-mavx2} is
18216 used. All of them generate the machine instruction that is part of the
18220 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
18221 v32qi __builtin_ia32_pabsb256 (v32qi)
18222 v16hi __builtin_ia32_pabsw256 (v16hi)
18223 v8si __builtin_ia32_pabsd256 (v8si)
18224 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
18225 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
18226 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
18227 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
18228 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
18229 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
18230 v8si __builtin_ia32_paddd256 (v8si,v8si)
18231 v4di __builtin_ia32_paddq256 (v4di,v4di)
18232 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
18233 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
18234 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
18235 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
18236 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
18237 v4di __builtin_ia32_andsi256 (v4di,v4di)
18238 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
18239 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
18240 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
18241 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
18242 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
18243 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
18244 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
18245 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
18246 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
18247 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
18248 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
18249 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
18250 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
18251 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
18252 v8si __builtin_ia32_phaddd256 (v8si,v8si)
18253 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
18254 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
18255 v8si __builtin_ia32_phsubd256 (v8si,v8si)
18256 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
18257 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
18258 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
18259 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
18260 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
18261 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
18262 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
18263 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
18264 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
18265 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
18266 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
18267 v8si __builtin_ia32_pminsd256 (v8si,v8si)
18268 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
18269 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
18270 v8si __builtin_ia32_pminud256 (v8si,v8si)
18271 int __builtin_ia32_pmovmskb256 (v32qi)
18272 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
18273 v8si __builtin_ia32_pmovsxbd256 (v16qi)
18274 v4di __builtin_ia32_pmovsxbq256 (v16qi)
18275 v8si __builtin_ia32_pmovsxwd256 (v8hi)
18276 v4di __builtin_ia32_pmovsxwq256 (v8hi)
18277 v4di __builtin_ia32_pmovsxdq256 (v4si)
18278 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
18279 v8si __builtin_ia32_pmovzxbd256 (v16qi)
18280 v4di __builtin_ia32_pmovzxbq256 (v16qi)
18281 v8si __builtin_ia32_pmovzxwd256 (v8hi)
18282 v4di __builtin_ia32_pmovzxwq256 (v8hi)
18283 v4di __builtin_ia32_pmovzxdq256 (v4si)
18284 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
18285 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
18286 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
18287 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
18288 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
18289 v8si __builtin_ia32_pmulld256 (v8si,v8si)
18290 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
18291 v4di __builtin_ia32_por256 (v4di,v4di)
18292 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
18293 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
18294 v8si __builtin_ia32_pshufd256 (v8si,int)
18295 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
18296 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
18297 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
18298 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
18299 v8si __builtin_ia32_psignd256 (v8si,v8si)
18300 v4di __builtin_ia32_pslldqi256 (v4di,int)
18301 v16hi __builtin_ia32_psllwi256 (16hi,int)
18302 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
18303 v8si __builtin_ia32_pslldi256 (v8si,int)
18304 v8si __builtin_ia32_pslld256(v8si,v4si)
18305 v4di __builtin_ia32_psllqi256 (v4di,int)
18306 v4di __builtin_ia32_psllq256(v4di,v2di)
18307 v16hi __builtin_ia32_psrawi256 (v16hi,int)
18308 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
18309 v8si __builtin_ia32_psradi256 (v8si,int)
18310 v8si __builtin_ia32_psrad256 (v8si,v4si)
18311 v4di __builtin_ia32_psrldqi256 (v4di, int)
18312 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
18313 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
18314 v8si __builtin_ia32_psrldi256 (v8si,int)
18315 v8si __builtin_ia32_psrld256 (v8si,v4si)
18316 v4di __builtin_ia32_psrlqi256 (v4di,int)
18317 v4di __builtin_ia32_psrlq256(v4di,v2di)
18318 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
18319 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
18320 v8si __builtin_ia32_psubd256 (v8si,v8si)
18321 v4di __builtin_ia32_psubq256 (v4di,v4di)
18322 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
18323 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
18324 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
18325 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
18326 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
18327 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
18328 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
18329 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
18330 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
18331 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
18332 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
18333 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
18334 v4di __builtin_ia32_pxor256 (v4di,v4di)
18335 v4di __builtin_ia32_movntdqa256 (pv4di)
18336 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
18337 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
18338 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
18339 v4di __builtin_ia32_vbroadcastsi256 (v2di)
18340 v4si __builtin_ia32_pblendd128 (v4si,v4si)
18341 v8si __builtin_ia32_pblendd256 (v8si,v8si)
18342 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
18343 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
18344 v8si __builtin_ia32_pbroadcastd256 (v4si)
18345 v4di __builtin_ia32_pbroadcastq256 (v2di)
18346 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
18347 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
18348 v4si __builtin_ia32_pbroadcastd128 (v4si)
18349 v2di __builtin_ia32_pbroadcastq128 (v2di)
18350 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
18351 v4df __builtin_ia32_permdf256 (v4df,int)
18352 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
18353 v4di __builtin_ia32_permdi256 (v4di,int)
18354 v4di __builtin_ia32_permti256 (v4di,v4di,int)
18355 v4di __builtin_ia32_extract128i256 (v4di,int)
18356 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
18357 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
18358 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
18359 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
18360 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
18361 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
18362 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
18363 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
18364 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
18365 v8si __builtin_ia32_psllv8si (v8si,v8si)
18366 v4si __builtin_ia32_psllv4si (v4si,v4si)
18367 v4di __builtin_ia32_psllv4di (v4di,v4di)
18368 v2di __builtin_ia32_psllv2di (v2di,v2di)
18369 v8si __builtin_ia32_psrav8si (v8si,v8si)
18370 v4si __builtin_ia32_psrav4si (v4si,v4si)
18371 v8si __builtin_ia32_psrlv8si (v8si,v8si)
18372 v4si __builtin_ia32_psrlv4si (v4si,v4si)
18373 v4di __builtin_ia32_psrlv4di (v4di,v4di)
18374 v2di __builtin_ia32_psrlv2di (v2di,v2di)
18375 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
18376 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
18377 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
18378 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
18379 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
18380 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
18381 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
18382 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
18383 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
18384 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
18385 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
18386 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
18387 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
18388 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
18389 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
18390 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
18393 The following built-in functions are available when @option{-maes} is
18394 used. All of them generate the machine instruction that is part of the
18398 v2di __builtin_ia32_aesenc128 (v2di, v2di)
18399 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
18400 v2di __builtin_ia32_aesdec128 (v2di, v2di)
18401 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
18402 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
18403 v2di __builtin_ia32_aesimc128 (v2di)
18406 The following built-in function is available when @option{-mpclmul} is
18410 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
18411 Generates the @code{pclmulqdq} machine instruction.
18414 The following built-in function is available when @option{-mfsgsbase} is
18415 used. All of them generate the machine instruction that is part of the
18419 unsigned int __builtin_ia32_rdfsbase32 (void)
18420 unsigned long long __builtin_ia32_rdfsbase64 (void)
18421 unsigned int __builtin_ia32_rdgsbase32 (void)
18422 unsigned long long __builtin_ia32_rdgsbase64 (void)
18423 void _writefsbase_u32 (unsigned int)
18424 void _writefsbase_u64 (unsigned long long)
18425 void _writegsbase_u32 (unsigned int)
18426 void _writegsbase_u64 (unsigned long long)
18429 The following built-in function is available when @option{-mrdrnd} is
18430 used. All of them generate the machine instruction that is part of the
18434 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
18435 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
18436 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
18439 The following built-in functions are available when @option{-msse4a} is used.
18440 All of them generate the machine instruction that is part of the name.
18443 void __builtin_ia32_movntsd (double *, v2df)
18444 void __builtin_ia32_movntss (float *, v4sf)
18445 v2di __builtin_ia32_extrq (v2di, v16qi)
18446 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
18447 v2di __builtin_ia32_insertq (v2di, v2di)
18448 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
18451 The following built-in functions are available when @option{-mxop} is used.
18453 v2df __builtin_ia32_vfrczpd (v2df)
18454 v4sf __builtin_ia32_vfrczps (v4sf)
18455 v2df __builtin_ia32_vfrczsd (v2df)
18456 v4sf __builtin_ia32_vfrczss (v4sf)
18457 v4df __builtin_ia32_vfrczpd256 (v4df)
18458 v8sf __builtin_ia32_vfrczps256 (v8sf)
18459 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
18460 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
18461 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
18462 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
18463 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
18464 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
18465 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
18466 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
18467 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
18468 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
18469 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
18470 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
18471 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
18472 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
18473 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
18474 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
18475 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
18476 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
18477 v4si __builtin_ia32_vpcomequd (v4si, v4si)
18478 v2di __builtin_ia32_vpcomequq (v2di, v2di)
18479 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
18480 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
18481 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
18482 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
18483 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
18484 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
18485 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
18486 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
18487 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
18488 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
18489 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
18490 v4si __builtin_ia32_vpcomged (v4si, v4si)
18491 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
18492 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
18493 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
18494 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
18495 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
18496 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
18497 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
18498 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
18499 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
18500 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
18501 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
18502 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
18503 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
18504 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
18505 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
18506 v4si __builtin_ia32_vpcomled (v4si, v4si)
18507 v2di __builtin_ia32_vpcomleq (v2di, v2di)
18508 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
18509 v4si __builtin_ia32_vpcomleud (v4si, v4si)
18510 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
18511 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
18512 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
18513 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
18514 v4si __builtin_ia32_vpcomltd (v4si, v4si)
18515 v2di __builtin_ia32_vpcomltq (v2di, v2di)
18516 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
18517 v4si __builtin_ia32_vpcomltud (v4si, v4si)
18518 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
18519 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
18520 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
18521 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
18522 v4si __builtin_ia32_vpcomned (v4si, v4si)
18523 v2di __builtin_ia32_vpcomneq (v2di, v2di)
18524 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
18525 v4si __builtin_ia32_vpcomneud (v4si, v4si)
18526 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
18527 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
18528 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
18529 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
18530 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
18531 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
18532 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
18533 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
18534 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
18535 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
18536 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
18537 v4si __builtin_ia32_vphaddbd (v16qi)
18538 v2di __builtin_ia32_vphaddbq (v16qi)
18539 v8hi __builtin_ia32_vphaddbw (v16qi)
18540 v2di __builtin_ia32_vphadddq (v4si)
18541 v4si __builtin_ia32_vphaddubd (v16qi)
18542 v2di __builtin_ia32_vphaddubq (v16qi)
18543 v8hi __builtin_ia32_vphaddubw (v16qi)
18544 v2di __builtin_ia32_vphaddudq (v4si)
18545 v4si __builtin_ia32_vphadduwd (v8hi)
18546 v2di __builtin_ia32_vphadduwq (v8hi)
18547 v4si __builtin_ia32_vphaddwd (v8hi)
18548 v2di __builtin_ia32_vphaddwq (v8hi)
18549 v8hi __builtin_ia32_vphsubbw (v16qi)
18550 v2di __builtin_ia32_vphsubdq (v4si)
18551 v4si __builtin_ia32_vphsubwd (v8hi)
18552 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
18553 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
18554 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
18555 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
18556 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
18557 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
18558 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
18559 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
18560 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
18561 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
18562 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
18563 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
18564 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
18565 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
18566 v4si __builtin_ia32_vprotd (v4si, v4si)
18567 v2di __builtin_ia32_vprotq (v2di, v2di)
18568 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
18569 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
18570 v4si __builtin_ia32_vpshad (v4si, v4si)
18571 v2di __builtin_ia32_vpshaq (v2di, v2di)
18572 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
18573 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
18574 v4si __builtin_ia32_vpshld (v4si, v4si)
18575 v2di __builtin_ia32_vpshlq (v2di, v2di)
18576 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
18579 The following built-in functions are available when @option{-mfma4} is used.
18580 All of them generate the machine instruction that is part of the name.
18583 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
18584 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
18585 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
18586 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
18587 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
18588 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
18589 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
18590 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
18591 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
18592 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
18593 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
18594 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
18595 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
18596 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
18597 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
18598 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
18599 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
18600 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
18601 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
18602 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
18603 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
18604 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
18605 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
18606 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
18607 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
18608 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
18609 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
18610 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
18611 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
18612 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
18613 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
18614 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
18618 The following built-in functions are available when @option{-mlwp} is used.
18621 void __builtin_ia32_llwpcb16 (void *);
18622 void __builtin_ia32_llwpcb32 (void *);
18623 void __builtin_ia32_llwpcb64 (void *);
18624 void * __builtin_ia32_llwpcb16 (void);
18625 void * __builtin_ia32_llwpcb32 (void);
18626 void * __builtin_ia32_llwpcb64 (void);
18627 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
18628 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
18629 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
18630 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
18631 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
18632 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
18635 The following built-in functions are available when @option{-mbmi} is used.
18636 All of them generate the machine instruction that is part of the name.
18638 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
18639 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
18642 The following built-in functions are available when @option{-mbmi2} is used.
18643 All of them generate the machine instruction that is part of the name.
18645 unsigned int _bzhi_u32 (unsigned int, unsigned int)
18646 unsigned int _pdep_u32 (unsigned int, unsigned int)
18647 unsigned int _pext_u32 (unsigned int, unsigned int)
18648 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
18649 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
18650 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
18653 The following built-in functions are available when @option{-mlzcnt} is used.
18654 All of them generate the machine instruction that is part of the name.
18656 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
18657 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
18658 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
18661 The following built-in functions are available when @option{-mfxsr} is used.
18662 All of them generate the machine instruction that is part of the name.
18664 void __builtin_ia32_fxsave (void *)
18665 void __builtin_ia32_fxrstor (void *)
18666 void __builtin_ia32_fxsave64 (void *)
18667 void __builtin_ia32_fxrstor64 (void *)
18670 The following built-in functions are available when @option{-mxsave} is used.
18671 All of them generate the machine instruction that is part of the name.
18673 void __builtin_ia32_xsave (void *, long long)
18674 void __builtin_ia32_xrstor (void *, long long)
18675 void __builtin_ia32_xsave64 (void *, long long)
18676 void __builtin_ia32_xrstor64 (void *, long long)
18679 The following built-in functions are available when @option{-mxsaveopt} is used.
18680 All of them generate the machine instruction that is part of the name.
18682 void __builtin_ia32_xsaveopt (void *, long long)
18683 void __builtin_ia32_xsaveopt64 (void *, long long)
18686 The following built-in functions are available when @option{-mtbm} is used.
18687 Both of them generate the immediate form of the bextr machine instruction.
18689 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
18690 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
18694 The following built-in functions are available when @option{-m3dnow} is used.
18695 All of them generate the machine instruction that is part of the name.
18698 void __builtin_ia32_femms (void)
18699 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
18700 v2si __builtin_ia32_pf2id (v2sf)
18701 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
18702 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
18703 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
18704 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
18705 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
18706 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
18707 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
18708 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
18709 v2sf __builtin_ia32_pfrcp (v2sf)
18710 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
18711 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
18712 v2sf __builtin_ia32_pfrsqrt (v2sf)
18713 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
18714 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
18715 v2sf __builtin_ia32_pi2fd (v2si)
18716 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
18719 The following built-in functions are available when both @option{-m3dnow}
18720 and @option{-march=athlon} are used. All of them generate the machine
18721 instruction that is part of the name.
18724 v2si __builtin_ia32_pf2iw (v2sf)
18725 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
18726 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
18727 v2sf __builtin_ia32_pi2fw (v2si)
18728 v2sf __builtin_ia32_pswapdsf (v2sf)
18729 v2si __builtin_ia32_pswapdsi (v2si)
18732 The following built-in functions are available when @option{-mrtm} is used
18733 They are used for restricted transactional memory. These are the internal
18734 low level functions. Normally the functions in
18735 @ref{x86 transactional memory intrinsics} should be used instead.
18738 int __builtin_ia32_xbegin ()
18739 void __builtin_ia32_xend ()
18740 void __builtin_ia32_xabort (status)
18741 int __builtin_ia32_xtest ()
18744 The following built-in functions are available when @option{-mmwaitx} is used.
18745 All of them generate the machine instruction that is part of the name.
18747 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
18748 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
18751 The following built-in functions are available when @option{-mclzero} is used.
18752 All of them generate the machine instruction that is part of the name.
18754 void __builtin_i32_clzero (void *)
18757 The following built-in functions are available when @option{-mpku} is used.
18758 They generate reads and writes to PKRU.
18760 void __builtin_ia32_wrpkru (unsigned int)
18761 unsigned int __builtin_ia32_rdpkru ()
18764 @node x86 transactional memory intrinsics
18765 @subsection x86 Transactional Memory Intrinsics
18767 These hardware transactional memory intrinsics for x86 allow you to use
18768 memory transactions with RTM (Restricted Transactional Memory).
18769 This support is enabled with the @option{-mrtm} option.
18770 For using HLE (Hardware Lock Elision) see
18771 @ref{x86 specific memory model extensions for transactional memory} instead.
18773 A memory transaction commits all changes to memory in an atomic way,
18774 as visible to other threads. If the transaction fails it is rolled back
18775 and all side effects discarded.
18777 Generally there is no guarantee that a memory transaction ever succeeds
18778 and suitable fallback code always needs to be supplied.
18780 @deftypefn {RTM Function} {unsigned} _xbegin ()
18781 Start a RTM (Restricted Transactional Memory) transaction.
18782 Returns @code{_XBEGIN_STARTED} when the transaction
18783 started successfully (note this is not 0, so the constant has to be
18784 explicitly tested).
18786 If the transaction aborts, all side-effects
18787 are undone and an abort code encoded as a bit mask is returned.
18788 The following macros are defined:
18791 @item _XABORT_EXPLICIT
18792 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
18793 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
18794 @item _XABORT_RETRY
18795 Transaction retry is possible.
18796 @item _XABORT_CONFLICT
18797 Transaction abort due to a memory conflict with another thread.
18798 @item _XABORT_CAPACITY
18799 Transaction abort due to the transaction using too much memory.
18800 @item _XABORT_DEBUG
18801 Transaction abort due to a debug trap.
18802 @item _XABORT_NESTED
18803 Transaction abort in an inner nested transaction.
18806 There is no guarantee
18807 any transaction ever succeeds, so there always needs to be a valid
18811 @deftypefn {RTM Function} {void} _xend ()
18812 Commit the current transaction. When no transaction is active this faults.
18813 All memory side-effects of the transaction become visible
18814 to other threads in an atomic manner.
18817 @deftypefn {RTM Function} {int} _xtest ()
18818 Return a nonzero value if a transaction is currently active, otherwise 0.
18821 @deftypefn {RTM Function} {void} _xabort (status)
18822 Abort the current transaction. When no transaction is active this is a no-op.
18823 The @var{status} is an 8-bit constant; its value is encoded in the return
18824 value from @code{_xbegin}.
18827 Here is an example showing handling for @code{_XABORT_RETRY}
18828 and a fallback path for other failures:
18831 #include <immintrin.h>
18833 int n_tries, max_tries;
18834 unsigned status = _XABORT_EXPLICIT;
18837 for (n_tries = 0; n_tries < max_tries; n_tries++)
18839 status = _xbegin ();
18840 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
18843 if (status == _XBEGIN_STARTED)
18845 ... transaction code...
18850 ... non-transactional fallback path...
18855 Note that, in most cases, the transactional and non-transactional code
18856 must synchronize together to ensure consistency.
18858 @node Target Format Checks
18859 @section Format Checks Specific to Particular Target Machines
18861 For some target machines, GCC supports additional options to the
18863 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
18866 * Solaris Format Checks::
18867 * Darwin Format Checks::
18870 @node Solaris Format Checks
18871 @subsection Solaris Format Checks
18873 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
18874 check. @code{cmn_err} accepts a subset of the standard @code{printf}
18875 conversions, and the two-argument @code{%b} conversion for displaying
18876 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
18878 @node Darwin Format Checks
18879 @subsection Darwin Format Checks
18881 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
18882 attribute context. Declarations made with such attribution are parsed for correct syntax
18883 and format argument types. However, parsing of the format string itself is currently undefined
18884 and is not carried out by this version of the compiler.
18886 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
18887 also be used as format arguments. Note that the relevant headers are only likely to be
18888 available on Darwin (OSX) installations. On such installations, the XCode and system
18889 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
18890 associated functions.
18893 @section Pragmas Accepted by GCC
18895 @cindex @code{#pragma}
18897 GCC supports several types of pragmas, primarily in order to compile
18898 code originally written for other compilers. Note that in general
18899 we do not recommend the use of pragmas; @xref{Function Attributes},
18900 for further explanation.
18903 * AArch64 Pragmas::
18907 * RS/6000 and PowerPC Pragmas::
18910 * Solaris Pragmas::
18911 * Symbol-Renaming Pragmas::
18912 * Structure-Layout Pragmas::
18914 * Diagnostic Pragmas::
18915 * Visibility Pragmas::
18916 * Push/Pop Macro Pragmas::
18917 * Function Specific Option Pragmas::
18918 * Loop-Specific Pragmas::
18921 @node AArch64 Pragmas
18922 @subsection AArch64 Pragmas
18924 The pragmas defined by the AArch64 target correspond to the AArch64
18925 target function attributes. They can be specified as below:
18927 #pragma GCC target("string")
18930 where @code{@var{string}} can be any string accepted as an AArch64 target
18931 attribute. @xref{AArch64 Function Attributes}, for more details
18932 on the permissible values of @code{string}.
18935 @subsection ARM Pragmas
18937 The ARM target defines pragmas for controlling the default addition of
18938 @code{long_call} and @code{short_call} attributes to functions.
18939 @xref{Function Attributes}, for information about the effects of these
18944 @cindex pragma, long_calls
18945 Set all subsequent functions to have the @code{long_call} attribute.
18947 @item no_long_calls
18948 @cindex pragma, no_long_calls
18949 Set all subsequent functions to have the @code{short_call} attribute.
18951 @item long_calls_off
18952 @cindex pragma, long_calls_off
18953 Do not affect the @code{long_call} or @code{short_call} attributes of
18954 subsequent functions.
18958 @subsection M32C Pragmas
18961 @item GCC memregs @var{number}
18962 @cindex pragma, memregs
18963 Overrides the command-line option @code{-memregs=} for the current
18964 file. Use with care! This pragma must be before any function in the
18965 file, and mixing different memregs values in different objects may
18966 make them incompatible. This pragma is useful when a
18967 performance-critical function uses a memreg for temporary values,
18968 as it may allow you to reduce the number of memregs used.
18970 @item ADDRESS @var{name} @var{address}
18971 @cindex pragma, address
18972 For any declared symbols matching @var{name}, this does three things
18973 to that symbol: it forces the symbol to be located at the given
18974 address (a number), it forces the symbol to be volatile, and it
18975 changes the symbol's scope to be static. This pragma exists for
18976 compatibility with other compilers, but note that the common
18977 @code{1234H} numeric syntax is not supported (use @code{0x1234}
18981 #pragma ADDRESS port3 0x103
18988 @subsection MeP Pragmas
18992 @item custom io_volatile (on|off)
18993 @cindex pragma, custom io_volatile
18994 Overrides the command-line option @code{-mio-volatile} for the current
18995 file. Note that for compatibility with future GCC releases, this
18996 option should only be used once before any @code{io} variables in each
18999 @item GCC coprocessor available @var{registers}
19000 @cindex pragma, coprocessor available
19001 Specifies which coprocessor registers are available to the register
19002 allocator. @var{registers} may be a single register, register range
19003 separated by ellipses, or comma-separated list of those. Example:
19006 #pragma GCC coprocessor available $c0...$c10, $c28
19009 @item GCC coprocessor call_saved @var{registers}
19010 @cindex pragma, coprocessor call_saved
19011 Specifies which coprocessor registers are to be saved and restored by
19012 any function using them. @var{registers} may be a single register,
19013 register range separated by ellipses, or comma-separated list of
19017 #pragma GCC coprocessor call_saved $c4...$c6, $c31
19020 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
19021 @cindex pragma, coprocessor subclass
19022 Creates and defines a register class. These register classes can be
19023 used by inline @code{asm} constructs. @var{registers} may be a single
19024 register, register range separated by ellipses, or comma-separated
19025 list of those. Example:
19028 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
19030 asm ("cpfoo %0" : "=B" (x));
19033 @item GCC disinterrupt @var{name} , @var{name} @dots{}
19034 @cindex pragma, disinterrupt
19035 For the named functions, the compiler adds code to disable interrupts
19036 for the duration of those functions. If any functions so named
19037 are not encountered in the source, a warning is emitted that the pragma is
19038 not used. Examples:
19041 #pragma disinterrupt foo
19042 #pragma disinterrupt bar, grill
19043 int foo () @{ @dots{} @}
19046 @item GCC call @var{name} , @var{name} @dots{}
19047 @cindex pragma, call
19048 For the named functions, the compiler always uses a register-indirect
19049 call model when calling the named functions. Examples:
19058 @node RS/6000 and PowerPC Pragmas
19059 @subsection RS/6000 and PowerPC Pragmas
19061 The RS/6000 and PowerPC targets define one pragma for controlling
19062 whether or not the @code{longcall} attribute is added to function
19063 declarations by default. This pragma overrides the @option{-mlongcall}
19064 option, but not the @code{longcall} and @code{shortcall} attributes.
19065 @xref{RS/6000 and PowerPC Options}, for more information about when long
19066 calls are and are not necessary.
19070 @cindex pragma, longcall
19071 Apply the @code{longcall} attribute to all subsequent function
19075 Do not apply the @code{longcall} attribute to subsequent function
19079 @c Describe h8300 pragmas here.
19080 @c Describe sh pragmas here.
19081 @c Describe v850 pragmas here.
19083 @node S/390 Pragmas
19084 @subsection S/390 Pragmas
19086 The pragmas defined by the S/390 target correspond to the S/390
19087 target function attributes and some the additional options:
19094 Note that options of the pragma, unlike options of the target
19095 attribute, do change the value of preprocessor macros like
19096 @code{__VEC__}. They can be specified as below:
19099 #pragma GCC target("string[,string]...")
19100 #pragma GCC target("string"[,"string"]...)
19103 @node Darwin Pragmas
19104 @subsection Darwin Pragmas
19106 The following pragmas are available for all architectures running the
19107 Darwin operating system. These are useful for compatibility with other
19111 @item mark @var{tokens}@dots{}
19112 @cindex pragma, mark
19113 This pragma is accepted, but has no effect.
19115 @item options align=@var{alignment}
19116 @cindex pragma, options align
19117 This pragma sets the alignment of fields in structures. The values of
19118 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
19119 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
19120 properly; to restore the previous setting, use @code{reset} for the
19123 @item segment @var{tokens}@dots{}
19124 @cindex pragma, segment
19125 This pragma is accepted, but has no effect.
19127 @item unused (@var{var} [, @var{var}]@dots{})
19128 @cindex pragma, unused
19129 This pragma declares variables to be possibly unused. GCC does not
19130 produce warnings for the listed variables. The effect is similar to
19131 that of the @code{unused} attribute, except that this pragma may appear
19132 anywhere within the variables' scopes.
19135 @node Solaris Pragmas
19136 @subsection Solaris Pragmas
19138 The Solaris target supports @code{#pragma redefine_extname}
19139 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
19140 @code{#pragma} directives for compatibility with the system compiler.
19143 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
19144 @cindex pragma, align
19146 Increase the minimum alignment of each @var{variable} to @var{alignment}.
19147 This is the same as GCC's @code{aligned} attribute @pxref{Variable
19148 Attributes}). Macro expansion occurs on the arguments to this pragma
19149 when compiling C and Objective-C@. It does not currently occur when
19150 compiling C++, but this is a bug which may be fixed in a future
19153 @item fini (@var{function} [, @var{function}]...)
19154 @cindex pragma, fini
19156 This pragma causes each listed @var{function} to be called after
19157 main, or during shared module unloading, by adding a call to the
19158 @code{.fini} section.
19160 @item init (@var{function} [, @var{function}]...)
19161 @cindex pragma, init
19163 This pragma causes each listed @var{function} to be called during
19164 initialization (before @code{main}) or during shared module loading, by
19165 adding a call to the @code{.init} section.
19169 @node Symbol-Renaming Pragmas
19170 @subsection Symbol-Renaming Pragmas
19172 GCC supports a @code{#pragma} directive that changes the name used in
19173 assembly for a given declaration. While this pragma is supported on all
19174 platforms, it is intended primarily to provide compatibility with the
19175 Solaris system headers. This effect can also be achieved using the asm
19176 labels extension (@pxref{Asm Labels}).
19179 @item redefine_extname @var{oldname} @var{newname}
19180 @cindex pragma, redefine_extname
19182 This pragma gives the C function @var{oldname} the assembly symbol
19183 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
19184 is defined if this pragma is available (currently on all platforms).
19187 This pragma and the asm labels extension interact in a complicated
19188 manner. Here are some corner cases you may want to be aware of:
19191 @item This pragma silently applies only to declarations with external
19192 linkage. Asm labels do not have this restriction.
19194 @item In C++, this pragma silently applies only to declarations with
19195 ``C'' linkage. Again, asm labels do not have this restriction.
19197 @item If either of the ways of changing the assembly name of a
19198 declaration are applied to a declaration whose assembly name has
19199 already been determined (either by a previous use of one of these
19200 features, or because the compiler needed the assembly name in order to
19201 generate code), and the new name is different, a warning issues and
19202 the name does not change.
19204 @item The @var{oldname} used by @code{#pragma redefine_extname} is
19205 always the C-language name.
19208 @node Structure-Layout Pragmas
19209 @subsection Structure-Layout Pragmas
19211 For compatibility with Microsoft Windows compilers, GCC supports a
19212 set of @code{#pragma} directives that change the maximum alignment of
19213 members of structures (other than zero-width bit-fields), unions, and
19214 classes subsequently defined. The @var{n} value below always is required
19215 to be a small power of two and specifies the new alignment in bytes.
19218 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
19219 @item @code{#pragma pack()} sets the alignment to the one that was in
19220 effect when compilation started (see also command-line option
19221 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
19222 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
19223 setting on an internal stack and then optionally sets the new alignment.
19224 @item @code{#pragma pack(pop)} restores the alignment setting to the one
19225 saved at the top of the internal stack (and removes that stack entry).
19226 Note that @code{#pragma pack([@var{n}])} does not influence this internal
19227 stack; thus it is possible to have @code{#pragma pack(push)} followed by
19228 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
19229 @code{#pragma pack(pop)}.
19232 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
19233 directive which lays out structures and unions subsequently defined as the
19234 documented @code{__attribute__ ((ms_struct))}.
19237 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
19238 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
19239 @item @code{#pragma ms_struct reset} goes back to the default layout.
19242 Most targets also support the @code{#pragma scalar_storage_order} directive
19243 which lays out structures and unions subsequently defined as the documented
19244 @code{__attribute__ ((scalar_storage_order))}.
19247 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
19248 of the scalar fields to big-endian.
19249 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
19250 of the scalar fields to little-endian.
19251 @item @code{#pragma scalar_storage_order default} goes back to the endianness
19252 that was in effect when compilation started (see also command-line option
19253 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
19257 @subsection Weak Pragmas
19259 For compatibility with SVR4, GCC supports a set of @code{#pragma}
19260 directives for declaring symbols to be weak, and defining weak
19264 @item #pragma weak @var{symbol}
19265 @cindex pragma, weak
19266 This pragma declares @var{symbol} to be weak, as if the declaration
19267 had the attribute of the same name. The pragma may appear before
19268 or after the declaration of @var{symbol}. It is not an error for
19269 @var{symbol} to never be defined at all.
19271 @item #pragma weak @var{symbol1} = @var{symbol2}
19272 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
19273 It is an error if @var{symbol2} is not defined in the current
19277 @node Diagnostic Pragmas
19278 @subsection Diagnostic Pragmas
19280 GCC allows the user to selectively enable or disable certain types of
19281 diagnostics, and change the kind of the diagnostic. For example, a
19282 project's policy might require that all sources compile with
19283 @option{-Werror} but certain files might have exceptions allowing
19284 specific types of warnings. Or, a project might selectively enable
19285 diagnostics and treat them as errors depending on which preprocessor
19286 macros are defined.
19289 @item #pragma GCC diagnostic @var{kind} @var{option}
19290 @cindex pragma, diagnostic
19292 Modifies the disposition of a diagnostic. Note that not all
19293 diagnostics are modifiable; at the moment only warnings (normally
19294 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
19295 Use @option{-fdiagnostics-show-option} to determine which diagnostics
19296 are controllable and which option controls them.
19298 @var{kind} is @samp{error} to treat this diagnostic as an error,
19299 @samp{warning} to treat it like a warning (even if @option{-Werror} is
19300 in effect), or @samp{ignored} if the diagnostic is to be ignored.
19301 @var{option} is a double quoted string that matches the command-line
19305 #pragma GCC diagnostic warning "-Wformat"
19306 #pragma GCC diagnostic error "-Wformat"
19307 #pragma GCC diagnostic ignored "-Wformat"
19310 Note that these pragmas override any command-line options. GCC keeps
19311 track of the location of each pragma, and issues diagnostics according
19312 to the state as of that point in the source file. Thus, pragmas occurring
19313 after a line do not affect diagnostics caused by that line.
19315 @item #pragma GCC diagnostic push
19316 @itemx #pragma GCC diagnostic pop
19318 Causes GCC to remember the state of the diagnostics as of each
19319 @code{push}, and restore to that point at each @code{pop}. If a
19320 @code{pop} has no matching @code{push}, the command-line options are
19324 #pragma GCC diagnostic error "-Wuninitialized"
19325 foo(a); /* error is given for this one */
19326 #pragma GCC diagnostic push
19327 #pragma GCC diagnostic ignored "-Wuninitialized"
19328 foo(b); /* no diagnostic for this one */
19329 #pragma GCC diagnostic pop
19330 foo(c); /* error is given for this one */
19331 #pragma GCC diagnostic pop
19332 foo(d); /* depends on command-line options */
19337 GCC also offers a simple mechanism for printing messages during
19341 @item #pragma message @var{string}
19342 @cindex pragma, diagnostic
19344 Prints @var{string} as a compiler message on compilation. The message
19345 is informational only, and is neither a compilation warning nor an error.
19348 #pragma message "Compiling " __FILE__ "..."
19351 @var{string} may be parenthesized, and is printed with location
19352 information. For example,
19355 #define DO_PRAGMA(x) _Pragma (#x)
19356 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
19358 TODO(Remember to fix this)
19362 prints @samp{/tmp/file.c:4: note: #pragma message:
19363 TODO - Remember to fix this}.
19367 @node Visibility Pragmas
19368 @subsection Visibility Pragmas
19371 @item #pragma GCC visibility push(@var{visibility})
19372 @itemx #pragma GCC visibility pop
19373 @cindex pragma, visibility
19375 This pragma allows the user to set the visibility for multiple
19376 declarations without having to give each a visibility attribute
19377 (@pxref{Function Attributes}).
19379 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
19380 declarations. Class members and template specializations are not
19381 affected; if you want to override the visibility for a particular
19382 member or instantiation, you must use an attribute.
19387 @node Push/Pop Macro Pragmas
19388 @subsection Push/Pop Macro Pragmas
19390 For compatibility with Microsoft Windows compilers, GCC supports
19391 @samp{#pragma push_macro(@var{"macro_name"})}
19392 and @samp{#pragma pop_macro(@var{"macro_name"})}.
19395 @item #pragma push_macro(@var{"macro_name"})
19396 @cindex pragma, push_macro
19397 This pragma saves the value of the macro named as @var{macro_name} to
19398 the top of the stack for this macro.
19400 @item #pragma pop_macro(@var{"macro_name"})
19401 @cindex pragma, pop_macro
19402 This pragma sets the value of the macro named as @var{macro_name} to
19403 the value on top of the stack for this macro. If the stack for
19404 @var{macro_name} is empty, the value of the macro remains unchanged.
19411 #pragma push_macro("X")
19414 #pragma pop_macro("X")
19419 In this example, the definition of X as 1 is saved by @code{#pragma
19420 push_macro} and restored by @code{#pragma pop_macro}.
19422 @node Function Specific Option Pragmas
19423 @subsection Function Specific Option Pragmas
19426 @item #pragma GCC target (@var{"string"}...)
19427 @cindex pragma GCC target
19429 This pragma allows you to set target specific options for functions
19430 defined later in the source file. One or more strings can be
19431 specified. Each function that is defined after this point is as
19432 if @code{attribute((target("STRING")))} was specified for that
19433 function. The parenthesis around the options is optional.
19434 @xref{Function Attributes}, for more information about the
19435 @code{target} attribute and the attribute syntax.
19437 The @code{#pragma GCC target} pragma is presently implemented for
19438 x86, PowerPC, and Nios II targets only.
19442 @item #pragma GCC optimize (@var{"string"}...)
19443 @cindex pragma GCC optimize
19445 This pragma allows you to set global optimization options for functions
19446 defined later in the source file. One or more strings can be
19447 specified. Each function that is defined after this point is as
19448 if @code{attribute((optimize("STRING")))} was specified for that
19449 function. The parenthesis around the options is optional.
19450 @xref{Function Attributes}, for more information about the
19451 @code{optimize} attribute and the attribute syntax.
19455 @item #pragma GCC push_options
19456 @itemx #pragma GCC pop_options
19457 @cindex pragma GCC push_options
19458 @cindex pragma GCC pop_options
19460 These pragmas maintain a stack of the current target and optimization
19461 options. It is intended for include files where you temporarily want
19462 to switch to using a different @samp{#pragma GCC target} or
19463 @samp{#pragma GCC optimize} and then to pop back to the previous
19468 @item #pragma GCC reset_options
19469 @cindex pragma GCC reset_options
19471 This pragma clears the current @code{#pragma GCC target} and
19472 @code{#pragma GCC optimize} to use the default switches as specified
19473 on the command line.
19476 @node Loop-Specific Pragmas
19477 @subsection Loop-Specific Pragmas
19480 @item #pragma GCC ivdep
19481 @cindex pragma GCC ivdep
19484 With this pragma, the programmer asserts that there are no loop-carried
19485 dependencies which would prevent consecutive iterations of
19486 the following loop from executing concurrently with SIMD
19487 (single instruction multiple data) instructions.
19489 For example, the compiler can only unconditionally vectorize the following
19490 loop with the pragma:
19493 void foo (int n, int *a, int *b, int *c)
19497 for (i = 0; i < n; ++i)
19498 a[i] = b[i] + c[i];
19503 In this example, using the @code{restrict} qualifier had the same
19504 effect. In the following example, that would not be possible. Assume
19505 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
19506 that it can unconditionally vectorize the following loop:
19509 void ignore_vec_dep (int *a, int k, int c, int m)
19512 for (int i = 0; i < m; i++)
19513 a[i] = a[i + k] * c;
19518 @node Unnamed Fields
19519 @section Unnamed Structure and Union Fields
19520 @cindex @code{struct}
19521 @cindex @code{union}
19523 As permitted by ISO C11 and for compatibility with other compilers,
19524 GCC allows you to define
19525 a structure or union that contains, as fields, structures and unions
19526 without names. For example:
19540 In this example, you are able to access members of the unnamed
19541 union with code like @samp{foo.b}. Note that only unnamed structs and
19542 unions are allowed, you may not have, for example, an unnamed
19545 You must never create such structures that cause ambiguous field definitions.
19546 For example, in this structure:
19558 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
19559 The compiler gives errors for such constructs.
19561 @opindex fms-extensions
19562 Unless @option{-fms-extensions} is used, the unnamed field must be a
19563 structure or union definition without a tag (for example, @samp{struct
19564 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
19565 also be a definition with a tag such as @samp{struct foo @{ int a;
19566 @};}, a reference to a previously defined structure or union such as
19567 @samp{struct foo;}, or a reference to a @code{typedef} name for a
19568 previously defined structure or union type.
19570 @opindex fplan9-extensions
19571 The option @option{-fplan9-extensions} enables
19572 @option{-fms-extensions} as well as two other extensions. First, a
19573 pointer to a structure is automatically converted to a pointer to an
19574 anonymous field for assignments and function calls. For example:
19577 struct s1 @{ int a; @};
19578 struct s2 @{ struct s1; @};
19579 extern void f1 (struct s1 *);
19580 void f2 (struct s2 *p) @{ f1 (p); @}
19584 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
19585 converted into a pointer to the anonymous field.
19587 Second, when the type of an anonymous field is a @code{typedef} for a
19588 @code{struct} or @code{union}, code may refer to the field using the
19589 name of the @code{typedef}.
19592 typedef struct @{ int a; @} s1;
19593 struct s2 @{ s1; @};
19594 s1 f1 (struct s2 *p) @{ return p->s1; @}
19597 These usages are only permitted when they are not ambiguous.
19600 @section Thread-Local Storage
19601 @cindex Thread-Local Storage
19602 @cindex @acronym{TLS}
19603 @cindex @code{__thread}
19605 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
19606 are allocated such that there is one instance of the variable per extant
19607 thread. The runtime model GCC uses to implement this originates
19608 in the IA-64 processor-specific ABI, but has since been migrated
19609 to other processors as well. It requires significant support from
19610 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
19611 system libraries (@file{libc.so} and @file{libpthread.so}), so it
19612 is not available everywhere.
19614 At the user level, the extension is visible with a new storage
19615 class keyword: @code{__thread}. For example:
19619 extern __thread struct state s;
19620 static __thread char *p;
19623 The @code{__thread} specifier may be used alone, with the @code{extern}
19624 or @code{static} specifiers, but with no other storage class specifier.
19625 When used with @code{extern} or @code{static}, @code{__thread} must appear
19626 immediately after the other storage class specifier.
19628 The @code{__thread} specifier may be applied to any global, file-scoped
19629 static, function-scoped static, or static data member of a class. It may
19630 not be applied to block-scoped automatic or non-static data member.
19632 When the address-of operator is applied to a thread-local variable, it is
19633 evaluated at run time and returns the address of the current thread's
19634 instance of that variable. An address so obtained may be used by any
19635 thread. When a thread terminates, any pointers to thread-local variables
19636 in that thread become invalid.
19638 No static initialization may refer to the address of a thread-local variable.
19640 In C++, if an initializer is present for a thread-local variable, it must
19641 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
19644 See @uref{http://www.akkadia.org/drepper/tls.pdf,
19645 ELF Handling For Thread-Local Storage} for a detailed explanation of
19646 the four thread-local storage addressing models, and how the runtime
19647 is expected to function.
19650 * C99 Thread-Local Edits::
19651 * C++98 Thread-Local Edits::
19654 @node C99 Thread-Local Edits
19655 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
19657 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
19658 that document the exact semantics of the language extension.
19662 @cite{5.1.2 Execution environments}
19664 Add new text after paragraph 1
19667 Within either execution environment, a @dfn{thread} is a flow of
19668 control within a program. It is implementation defined whether
19669 or not there may be more than one thread associated with a program.
19670 It is implementation defined how threads beyond the first are
19671 created, the name and type of the function called at thread
19672 startup, and how threads may be terminated. However, objects
19673 with thread storage duration shall be initialized before thread
19678 @cite{6.2.4 Storage durations of objects}
19680 Add new text before paragraph 3
19683 An object whose identifier is declared with the storage-class
19684 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
19685 Its lifetime is the entire execution of the thread, and its
19686 stored value is initialized only once, prior to thread startup.
19690 @cite{6.4.1 Keywords}
19692 Add @code{__thread}.
19695 @cite{6.7.1 Storage-class specifiers}
19697 Add @code{__thread} to the list of storage class specifiers in
19700 Change paragraph 2 to
19703 With the exception of @code{__thread}, at most one storage-class
19704 specifier may be given [@dots{}]. The @code{__thread} specifier may
19705 be used alone, or immediately following @code{extern} or
19709 Add new text after paragraph 6
19712 The declaration of an identifier for a variable that has
19713 block scope that specifies @code{__thread} shall also
19714 specify either @code{extern} or @code{static}.
19716 The @code{__thread} specifier shall be used only with
19721 @node C++98 Thread-Local Edits
19722 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
19724 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
19725 that document the exact semantics of the language extension.
19729 @b{[intro.execution]}
19731 New text after paragraph 4
19734 A @dfn{thread} is a flow of control within the abstract machine.
19735 It is implementation defined whether or not there may be more than
19739 New text after paragraph 7
19742 It is unspecified whether additional action must be taken to
19743 ensure when and whether side effects are visible to other threads.
19749 Add @code{__thread}.
19752 @b{[basic.start.main]}
19754 Add after paragraph 5
19757 The thread that begins execution at the @code{main} function is called
19758 the @dfn{main thread}. It is implementation defined how functions
19759 beginning threads other than the main thread are designated or typed.
19760 A function so designated, as well as the @code{main} function, is called
19761 a @dfn{thread startup function}. It is implementation defined what
19762 happens if a thread startup function returns. It is implementation
19763 defined what happens to other threads when any thread calls @code{exit}.
19767 @b{[basic.start.init]}
19769 Add after paragraph 4
19772 The storage for an object of thread storage duration shall be
19773 statically initialized before the first statement of the thread startup
19774 function. An object of thread storage duration shall not require
19775 dynamic initialization.
19779 @b{[basic.start.term]}
19781 Add after paragraph 3
19784 The type of an object with thread storage duration shall not have a
19785 non-trivial destructor, nor shall it be an array type whose elements
19786 (directly or indirectly) have non-trivial destructors.
19792 Add ``thread storage duration'' to the list in paragraph 1.
19797 Thread, static, and automatic storage durations are associated with
19798 objects introduced by declarations [@dots{}].
19801 Add @code{__thread} to the list of specifiers in paragraph 3.
19804 @b{[basic.stc.thread]}
19806 New section before @b{[basic.stc.static]}
19809 The keyword @code{__thread} applied to a non-local object gives the
19810 object thread storage duration.
19812 A local variable or class data member declared both @code{static}
19813 and @code{__thread} gives the variable or member thread storage
19818 @b{[basic.stc.static]}
19823 All objects that have neither thread storage duration, dynamic
19824 storage duration nor are local [@dots{}].
19830 Add @code{__thread} to the list in paragraph 1.
19835 With the exception of @code{__thread}, at most one
19836 @var{storage-class-specifier} shall appear in a given
19837 @var{decl-specifier-seq}. The @code{__thread} specifier may
19838 be used alone, or immediately following the @code{extern} or
19839 @code{static} specifiers. [@dots{}]
19842 Add after paragraph 5
19845 The @code{__thread} specifier can be applied only to the names of objects
19846 and to anonymous unions.
19852 Add after paragraph 6
19855 Non-@code{static} members shall not be @code{__thread}.
19859 @node Binary constants
19860 @section Binary Constants using the @samp{0b} Prefix
19861 @cindex Binary constants using the @samp{0b} prefix
19863 Integer constants can be written as binary constants, consisting of a
19864 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
19865 @samp{0B}. This is particularly useful in environments that operate a
19866 lot on the bit level (like microcontrollers).
19868 The following statements are identical:
19877 The type of these constants follows the same rules as for octal or
19878 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
19881 @node C++ Extensions
19882 @chapter Extensions to the C++ Language
19883 @cindex extensions, C++ language
19884 @cindex C++ language extensions
19886 The GNU compiler provides these extensions to the C++ language (and you
19887 can also use most of the C language extensions in your C++ programs). If you
19888 want to write code that checks whether these features are available, you can
19889 test for the GNU compiler the same way as for C programs: check for a
19890 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
19891 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
19892 Predefined Macros,cpp,The GNU C Preprocessor}).
19895 * C++ Volatiles:: What constitutes an access to a volatile object.
19896 * Restricted Pointers:: C99 restricted pointers and references.
19897 * Vague Linkage:: Where G++ puts inlines, vtables and such.
19898 * C++ Interface:: You can use a single C++ header file for both
19899 declarations and definitions.
19900 * Template Instantiation:: Methods for ensuring that exactly one copy of
19901 each needed template instantiation is emitted.
19902 * Bound member functions:: You can extract a function pointer to the
19903 method denoted by a @samp{->*} or @samp{.*} expression.
19904 * C++ Attributes:: Variable, function, and type attributes for C++ only.
19905 * Function Multiversioning:: Declaring multiple function versions.
19906 * Namespace Association:: Strong using-directives for namespace association.
19907 * Type Traits:: Compiler support for type traits.
19908 * C++ Concepts:: Improved support for generic programming.
19909 * Java Exceptions:: Tweaking exception handling to work with Java.
19910 * Deprecated Features:: Things will disappear from G++.
19911 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
19914 @node C++ Volatiles
19915 @section When is a Volatile C++ Object Accessed?
19916 @cindex accessing volatiles
19917 @cindex volatile read
19918 @cindex volatile write
19919 @cindex volatile access
19921 The C++ standard differs from the C standard in its treatment of
19922 volatile objects. It fails to specify what constitutes a volatile
19923 access, except to say that C++ should behave in a similar manner to C
19924 with respect to volatiles, where possible. However, the different
19925 lvalueness of expressions between C and C++ complicate the behavior.
19926 G++ behaves the same as GCC for volatile access, @xref{C
19927 Extensions,,Volatiles}, for a description of GCC's behavior.
19929 The C and C++ language specifications differ when an object is
19930 accessed in a void context:
19933 volatile int *src = @var{somevalue};
19937 The C++ standard specifies that such expressions do not undergo lvalue
19938 to rvalue conversion, and that the type of the dereferenced object may
19939 be incomplete. The C++ standard does not specify explicitly that it
19940 is lvalue to rvalue conversion that is responsible for causing an
19941 access. There is reason to believe that it is, because otherwise
19942 certain simple expressions become undefined. However, because it
19943 would surprise most programmers, G++ treats dereferencing a pointer to
19944 volatile object of complete type as GCC would do for an equivalent
19945 type in C@. When the object has incomplete type, G++ issues a
19946 warning; if you wish to force an error, you must force a conversion to
19947 rvalue with, for instance, a static cast.
19949 When using a reference to volatile, G++ does not treat equivalent
19950 expressions as accesses to volatiles, but instead issues a warning that
19951 no volatile is accessed. The rationale for this is that otherwise it
19952 becomes difficult to determine where volatile access occur, and not
19953 possible to ignore the return value from functions returning volatile
19954 references. Again, if you wish to force a read, cast the reference to
19957 G++ implements the same behavior as GCC does when assigning to a
19958 volatile object---there is no reread of the assigned-to object, the
19959 assigned rvalue is reused. Note that in C++ assignment expressions
19960 are lvalues, and if used as an lvalue, the volatile object is
19961 referred to. For instance, @var{vref} refers to @var{vobj}, as
19962 expected, in the following example:
19966 volatile int &vref = vobj = @var{something};
19969 @node Restricted Pointers
19970 @section Restricting Pointer Aliasing
19971 @cindex restricted pointers
19972 @cindex restricted references
19973 @cindex restricted this pointer
19975 As with the C front end, G++ understands the C99 feature of restricted pointers,
19976 specified with the @code{__restrict__}, or @code{__restrict} type
19977 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
19978 language flag, @code{restrict} is not a keyword in C++.
19980 In addition to allowing restricted pointers, you can specify restricted
19981 references, which indicate that the reference is not aliased in the local
19985 void fn (int *__restrict__ rptr, int &__restrict__ rref)
19992 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
19993 @var{rref} refers to a (different) unaliased integer.
19995 You may also specify whether a member function's @var{this} pointer is
19996 unaliased by using @code{__restrict__} as a member function qualifier.
19999 void T::fn () __restrict__
20006 Within the body of @code{T::fn}, @var{this} has the effective
20007 definition @code{T *__restrict__ const this}. Notice that the
20008 interpretation of a @code{__restrict__} member function qualifier is
20009 different to that of @code{const} or @code{volatile} qualifier, in that it
20010 is applied to the pointer rather than the object. This is consistent with
20011 other compilers that implement restricted pointers.
20013 As with all outermost parameter qualifiers, @code{__restrict__} is
20014 ignored in function definition matching. This means you only need to
20015 specify @code{__restrict__} in a function definition, rather than
20016 in a function prototype as well.
20018 @node Vague Linkage
20019 @section Vague Linkage
20020 @cindex vague linkage
20022 There are several constructs in C++ that require space in the object
20023 file but are not clearly tied to a single translation unit. We say that
20024 these constructs have ``vague linkage''. Typically such constructs are
20025 emitted wherever they are needed, though sometimes we can be more
20029 @item Inline Functions
20030 Inline functions are typically defined in a header file which can be
20031 included in many different compilations. Hopefully they can usually be
20032 inlined, but sometimes an out-of-line copy is necessary, if the address
20033 of the function is taken or if inlining fails. In general, we emit an
20034 out-of-line copy in all translation units where one is needed. As an
20035 exception, we only emit inline virtual functions with the vtable, since
20036 it always requires a copy.
20038 Local static variables and string constants used in an inline function
20039 are also considered to have vague linkage, since they must be shared
20040 between all inlined and out-of-line instances of the function.
20044 C++ virtual functions are implemented in most compilers using a lookup
20045 table, known as a vtable. The vtable contains pointers to the virtual
20046 functions provided by a class, and each object of the class contains a
20047 pointer to its vtable (or vtables, in some multiple-inheritance
20048 situations). If the class declares any non-inline, non-pure virtual
20049 functions, the first one is chosen as the ``key method'' for the class,
20050 and the vtable is only emitted in the translation unit where the key
20053 @emph{Note:} If the chosen key method is later defined as inline, the
20054 vtable is still emitted in every translation unit that defines it.
20055 Make sure that any inline virtuals are declared inline in the class
20056 body, even if they are not defined there.
20058 @item @code{type_info} objects
20059 @cindex @code{type_info}
20061 C++ requires information about types to be written out in order to
20062 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
20063 For polymorphic classes (classes with virtual functions), the @samp{type_info}
20064 object is written out along with the vtable so that @samp{dynamic_cast}
20065 can determine the dynamic type of a class object at run time. For all
20066 other types, we write out the @samp{type_info} object when it is used: when
20067 applying @samp{typeid} to an expression, throwing an object, or
20068 referring to a type in a catch clause or exception specification.
20070 @item Template Instantiations
20071 Most everything in this section also applies to template instantiations,
20072 but there are other options as well.
20073 @xref{Template Instantiation,,Where's the Template?}.
20077 When used with GNU ld version 2.8 or later on an ELF system such as
20078 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
20079 these constructs will be discarded at link time. This is known as
20082 On targets that don't support COMDAT, but do support weak symbols, GCC
20083 uses them. This way one copy overrides all the others, but
20084 the unused copies still take up space in the executable.
20086 For targets that do not support either COMDAT or weak symbols,
20087 most entities with vague linkage are emitted as local symbols to
20088 avoid duplicate definition errors from the linker. This does not happen
20089 for local statics in inlines, however, as having multiple copies
20090 almost certainly breaks things.
20092 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
20093 another way to control placement of these constructs.
20095 @node C++ Interface
20096 @section C++ Interface and Implementation Pragmas
20098 @cindex interface and implementation headers, C++
20099 @cindex C++ interface and implementation headers
20100 @cindex pragmas, interface and implementation
20102 @code{#pragma interface} and @code{#pragma implementation} provide the
20103 user with a way of explicitly directing the compiler to emit entities
20104 with vague linkage (and debugging information) in a particular
20107 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
20108 by COMDAT support and the ``key method'' heuristic
20109 mentioned in @ref{Vague Linkage}. Using them can actually cause your
20110 program to grow due to unnecessary out-of-line copies of inline
20114 @item #pragma interface
20115 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
20116 @kindex #pragma interface
20117 Use this directive in @emph{header files} that define object classes, to save
20118 space in most of the object files that use those classes. Normally,
20119 local copies of certain information (backup copies of inline member
20120 functions, debugging information, and the internal tables that implement
20121 virtual functions) must be kept in each object file that includes class
20122 definitions. You can use this pragma to avoid such duplication. When a
20123 header file containing @samp{#pragma interface} is included in a
20124 compilation, this auxiliary information is not generated (unless
20125 the main input source file itself uses @samp{#pragma implementation}).
20126 Instead, the object files contain references to be resolved at link
20129 The second form of this directive is useful for the case where you have
20130 multiple headers with the same name in different directories. If you
20131 use this form, you must specify the same string to @samp{#pragma
20134 @item #pragma implementation
20135 @itemx #pragma implementation "@var{objects}.h"
20136 @kindex #pragma implementation
20137 Use this pragma in a @emph{main input file}, when you want full output from
20138 included header files to be generated (and made globally visible). The
20139 included header file, in turn, should use @samp{#pragma interface}.
20140 Backup copies of inline member functions, debugging information, and the
20141 internal tables used to implement virtual functions are all generated in
20142 implementation files.
20144 @cindex implied @code{#pragma implementation}
20145 @cindex @code{#pragma implementation}, implied
20146 @cindex naming convention, implementation headers
20147 If you use @samp{#pragma implementation} with no argument, it applies to
20148 an include file with the same basename@footnote{A file's @dfn{basename}
20149 is the name stripped of all leading path information and of trailing
20150 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
20151 file. For example, in @file{allclass.cc}, giving just
20152 @samp{#pragma implementation}
20153 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
20155 Use the string argument if you want a single implementation file to
20156 include code from multiple header files. (You must also use
20157 @samp{#include} to include the header file; @samp{#pragma
20158 implementation} only specifies how to use the file---it doesn't actually
20161 There is no way to split up the contents of a single header file into
20162 multiple implementation files.
20165 @cindex inlining and C++ pragmas
20166 @cindex C++ pragmas, effect on inlining
20167 @cindex pragmas in C++, effect on inlining
20168 @samp{#pragma implementation} and @samp{#pragma interface} also have an
20169 effect on function inlining.
20171 If you define a class in a header file marked with @samp{#pragma
20172 interface}, the effect on an inline function defined in that class is
20173 similar to an explicit @code{extern} declaration---the compiler emits
20174 no code at all to define an independent version of the function. Its
20175 definition is used only for inlining with its callers.
20177 @opindex fno-implement-inlines
20178 Conversely, when you include the same header file in a main source file
20179 that declares it as @samp{#pragma implementation}, the compiler emits
20180 code for the function itself; this defines a version of the function
20181 that can be found via pointers (or by callers compiled without
20182 inlining). If all calls to the function can be inlined, you can avoid
20183 emitting the function by compiling with @option{-fno-implement-inlines}.
20184 If any calls are not inlined, you will get linker errors.
20186 @node Template Instantiation
20187 @section Where's the Template?
20188 @cindex template instantiation
20190 C++ templates were the first language feature to require more
20191 intelligence from the environment than was traditionally found on a UNIX
20192 system. Somehow the compiler and linker have to make sure that each
20193 template instance occurs exactly once in the executable if it is needed,
20194 and not at all otherwise. There are two basic approaches to this
20195 problem, which are referred to as the Borland model and the Cfront model.
20198 @item Borland model
20199 Borland C++ solved the template instantiation problem by adding the code
20200 equivalent of common blocks to their linker; the compiler emits template
20201 instances in each translation unit that uses them, and the linker
20202 collapses them together. The advantage of this model is that the linker
20203 only has to consider the object files themselves; there is no external
20204 complexity to worry about. The disadvantage is that compilation time
20205 is increased because the template code is being compiled repeatedly.
20206 Code written for this model tends to include definitions of all
20207 templates in the header file, since they must be seen to be
20211 The AT&T C++ translator, Cfront, solved the template instantiation
20212 problem by creating the notion of a template repository, an
20213 automatically maintained place where template instances are stored. A
20214 more modern version of the repository works as follows: As individual
20215 object files are built, the compiler places any template definitions and
20216 instantiations encountered in the repository. At link time, the link
20217 wrapper adds in the objects in the repository and compiles any needed
20218 instances that were not previously emitted. The advantages of this
20219 model are more optimal compilation speed and the ability to use the
20220 system linker; to implement the Borland model a compiler vendor also
20221 needs to replace the linker. The disadvantages are vastly increased
20222 complexity, and thus potential for error; for some code this can be
20223 just as transparent, but in practice it can been very difficult to build
20224 multiple programs in one directory and one program in multiple
20225 directories. Code written for this model tends to separate definitions
20226 of non-inline member templates into a separate file, which should be
20227 compiled separately.
20230 G++ implements the Borland model on targets where the linker supports it,
20231 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
20232 Otherwise G++ implements neither automatic model.
20234 You have the following options for dealing with template instantiations:
20238 Do nothing. Code written for the Borland model works fine, but
20239 each translation unit contains instances of each of the templates it
20240 uses. The duplicate instances will be discarded by the linker, but in
20241 a large program, this can lead to an unacceptable amount of code
20242 duplication in object files or shared libraries.
20244 Duplicate instances of a template can be avoided by defining an explicit
20245 instantiation in one object file, and preventing the compiler from doing
20246 implicit instantiations in any other object files by using an explicit
20247 instantiation declaration, using the @code{extern template} syntax:
20250 extern template int max (int, int);
20253 This syntax is defined in the C++ 2011 standard, but has been supported by
20254 G++ and other compilers since well before 2011.
20256 Explicit instantiations can be used for the largest or most frequently
20257 duplicated instances, without having to know exactly which other instances
20258 are used in the rest of the program. You can scatter the explicit
20259 instantiations throughout your program, perhaps putting them in the
20260 translation units where the instances are used or the translation units
20261 that define the templates themselves; you can put all of the explicit
20262 instantiations you need into one big file; or you can create small files
20269 template class Foo<int>;
20270 template ostream& operator <<
20271 (ostream&, const Foo<int>&);
20275 for each of the instances you need, and create a template instantiation
20276 library from those.
20278 This is the simplest option, but also offers flexibility and
20279 fine-grained control when necessary. It is also the most portable
20280 alternative and programs using this approach will work with most modern
20285 Compile your template-using code with @option{-frepo}. The compiler
20286 generates files with the extension @samp{.rpo} listing all of the
20287 template instantiations used in the corresponding object files that
20288 could be instantiated there; the link wrapper, @samp{collect2},
20289 then updates the @samp{.rpo} files to tell the compiler where to place
20290 those instantiations and rebuild any affected object files. The
20291 link-time overhead is negligible after the first pass, as the compiler
20292 continues to place the instantiations in the same files.
20294 This can be a suitable option for application code written for the Borland
20295 model, as it usually just works. Code written for the Cfront model
20296 needs to be modified so that the template definitions are available at
20297 one or more points of instantiation; usually this is as simple as adding
20298 @code{#include <tmethods.cc>} to the end of each template header.
20300 For library code, if you want the library to provide all of the template
20301 instantiations it needs, just try to link all of its object files
20302 together; the link will fail, but cause the instantiations to be
20303 generated as a side effect. Be warned, however, that this may cause
20304 conflicts if multiple libraries try to provide the same instantiations.
20305 For greater control, use explicit instantiation as described in the next
20309 @opindex fno-implicit-templates
20310 Compile your code with @option{-fno-implicit-templates} to disable the
20311 implicit generation of template instances, and explicitly instantiate
20312 all the ones you use. This approach requires more knowledge of exactly
20313 which instances you need than do the others, but it's less
20314 mysterious and allows greater control if you want to ensure that only
20315 the intended instances are used.
20317 If you are using Cfront-model code, you can probably get away with not
20318 using @option{-fno-implicit-templates} when compiling files that don't
20319 @samp{#include} the member template definitions.
20321 If you use one big file to do the instantiations, you may want to
20322 compile it without @option{-fno-implicit-templates} so you get all of the
20323 instances required by your explicit instantiations (but not by any
20324 other files) without having to specify them as well.
20326 In addition to forward declaration of explicit instantiations
20327 (with @code{extern}), G++ has extended the template instantiation
20328 syntax to support instantiation of the compiler support data for a
20329 template class (i.e.@: the vtable) without instantiating any of its
20330 members (with @code{inline}), and instantiation of only the static data
20331 members of a template class, without the support data or member
20332 functions (with @code{static}):
20335 inline template class Foo<int>;
20336 static template class Foo<int>;
20340 @node Bound member functions
20341 @section Extracting the Function Pointer from a Bound Pointer to Member Function
20343 @cindex pointer to member function
20344 @cindex bound pointer to member function
20346 In C++, pointer to member functions (PMFs) are implemented using a wide
20347 pointer of sorts to handle all the possible call mechanisms; the PMF
20348 needs to store information about how to adjust the @samp{this} pointer,
20349 and if the function pointed to is virtual, where to find the vtable, and
20350 where in the vtable to look for the member function. If you are using
20351 PMFs in an inner loop, you should really reconsider that decision. If
20352 that is not an option, you can extract the pointer to the function that
20353 would be called for a given object/PMF pair and call it directly inside
20354 the inner loop, to save a bit of time.
20356 Note that you still pay the penalty for the call through a
20357 function pointer; on most modern architectures, such a call defeats the
20358 branch prediction features of the CPU@. This is also true of normal
20359 virtual function calls.
20361 The syntax for this extension is
20365 extern int (A::*fp)();
20366 typedef int (*fptr)(A *);
20368 fptr p = (fptr)(a.*fp);
20371 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
20372 no object is needed to obtain the address of the function. They can be
20373 converted to function pointers directly:
20376 fptr p1 = (fptr)(&A::foo);
20379 @opindex Wno-pmf-conversions
20380 You must specify @option{-Wno-pmf-conversions} to use this extension.
20382 @node C++ Attributes
20383 @section C++-Specific Variable, Function, and Type Attributes
20385 Some attributes only make sense for C++ programs.
20388 @item abi_tag ("@var{tag}", ...)
20389 @cindex @code{abi_tag} function attribute
20390 @cindex @code{abi_tag} variable attribute
20391 @cindex @code{abi_tag} type attribute
20392 The @code{abi_tag} attribute can be applied to a function, variable, or class
20393 declaration. It modifies the mangled name of the entity to
20394 incorporate the tag name, in order to distinguish the function or
20395 class from an earlier version with a different ABI; perhaps the class
20396 has changed size, or the function has a different return type that is
20397 not encoded in the mangled name.
20399 The attribute can also be applied to an inline namespace, but does not
20400 affect the mangled name of the namespace; in this case it is only used
20401 for @option{-Wabi-tag} warnings and automatic tagging of functions and
20402 variables. Tagging inline namespaces is generally preferable to
20403 tagging individual declarations, but the latter is sometimes
20404 necessary, such as when only certain members of a class need to be
20407 The argument can be a list of strings of arbitrary length. The
20408 strings are sorted on output, so the order of the list is
20411 A redeclaration of an entity must not add new ABI tags,
20412 since doing so would change the mangled name.
20414 The ABI tags apply to a name, so all instantiations and
20415 specializations of a template have the same tags. The attribute will
20416 be ignored if applied to an explicit specialization or instantiation.
20418 The @option{-Wabi-tag} flag enables a warning about a class which does
20419 not have all the ABI tags used by its subobjects and virtual functions; for users with code
20420 that needs to coexist with an earlier ABI, using this option can help
20421 to find all affected types that need to be tagged.
20423 When a type involving an ABI tag is used as the type of a variable or
20424 return type of a function where that tag is not already present in the
20425 signature of the function, the tag is automatically applied to the
20426 variable or function. @option{-Wabi-tag} also warns about this
20427 situation; this warning can be avoided by explicitly tagging the
20428 variable or function or moving it into a tagged inline namespace.
20430 @item init_priority (@var{priority})
20431 @cindex @code{init_priority} variable attribute
20433 In Standard C++, objects defined at namespace scope are guaranteed to be
20434 initialized in an order in strict accordance with that of their definitions
20435 @emph{in a given translation unit}. No guarantee is made for initializations
20436 across translation units. However, GNU C++ allows users to control the
20437 order of initialization of objects defined at namespace scope with the
20438 @code{init_priority} attribute by specifying a relative @var{priority},
20439 a constant integral expression currently bounded between 101 and 65535
20440 inclusive. Lower numbers indicate a higher priority.
20442 In the following example, @code{A} would normally be created before
20443 @code{B}, but the @code{init_priority} attribute reverses that order:
20446 Some_Class A __attribute__ ((init_priority (2000)));
20447 Some_Class B __attribute__ ((init_priority (543)));
20451 Note that the particular values of @var{priority} do not matter; only their
20454 @item java_interface
20455 @cindex @code{java_interface} type attribute
20457 This type attribute informs C++ that the class is a Java interface. It may
20458 only be applied to classes declared within an @code{extern "Java"} block.
20459 Calls to methods declared in this interface are dispatched using GCJ's
20460 interface table mechanism, instead of regular virtual table dispatch.
20463 @cindex @code{warn_unused} type attribute
20465 For C++ types with non-trivial constructors and/or destructors it is
20466 impossible for the compiler to determine whether a variable of this
20467 type is truly unused if it is not referenced. This type attribute
20468 informs the compiler that variables of this type should be warned
20469 about if they appear to be unused, just like variables of fundamental
20472 This attribute is appropriate for types which just represent a value,
20473 such as @code{std::string}; it is not appropriate for types which
20474 control a resource, such as @code{std::lock_guard}.
20476 This attribute is also accepted in C, but it is unnecessary because C
20477 does not have constructors or destructors.
20481 See also @ref{Namespace Association}.
20483 @node Function Multiversioning
20484 @section Function Multiversioning
20485 @cindex function versions
20487 With the GNU C++ front end, for x86 targets, you may specify multiple
20488 versions of a function, where each function is specialized for a
20489 specific target feature. At runtime, the appropriate version of the
20490 function is automatically executed depending on the characteristics of
20491 the execution platform. Here is an example.
20494 __attribute__ ((target ("default")))
20497 // The default version of foo.
20501 __attribute__ ((target ("sse4.2")))
20504 // foo version for SSE4.2
20508 __attribute__ ((target ("arch=atom")))
20511 // foo version for the Intel ATOM processor
20515 __attribute__ ((target ("arch=amdfam10")))
20518 // foo version for the AMD Family 0x10 processors.
20525 assert ((*p) () == foo ());
20530 In the above example, four versions of function foo are created. The
20531 first version of foo with the target attribute "default" is the default
20532 version. This version gets executed when no other target specific
20533 version qualifies for execution on a particular platform. A new version
20534 of foo is created by using the same function signature but with a
20535 different target string. Function foo is called or a pointer to it is
20536 taken just like a regular function. GCC takes care of doing the
20537 dispatching to call the right version at runtime. Refer to the
20538 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
20539 Function Multiversioning} for more details.
20541 @node Namespace Association
20542 @section Namespace Association
20544 @strong{Caution:} The semantics of this extension are equivalent
20545 to C++ 2011 inline namespaces. Users should use inline namespaces
20546 instead as this extension will be removed in future versions of G++.
20548 A using-directive with @code{__attribute ((strong))} is stronger
20549 than a normal using-directive in two ways:
20553 Templates from the used namespace can be specialized and explicitly
20554 instantiated as though they were members of the using namespace.
20557 The using namespace is considered an associated namespace of all
20558 templates in the used namespace for purposes of argument-dependent
20562 The used namespace must be nested within the using namespace so that
20563 normal unqualified lookup works properly.
20565 This is useful for composing a namespace transparently from
20566 implementation namespaces. For example:
20571 template <class T> struct A @{ @};
20573 using namespace debug __attribute ((__strong__));
20574 template <> struct A<int> @{ @}; // @r{OK to specialize}
20576 template <class T> void f (A<T>);
20581 f (std::A<float>()); // @r{lookup finds} std::f
20587 @section Type Traits
20589 The C++ front end implements syntactic extensions that allow
20590 compile-time determination of
20591 various characteristics of a type (or of a
20595 @item __has_nothrow_assign (type)
20596 If @code{type} is const qualified or is a reference type then the trait is
20597 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
20598 is true, else if @code{type} is a cv class or union type with copy assignment
20599 operators that are known not to throw an exception then the trait is true,
20600 else it is false. Requires: @code{type} shall be a complete type,
20601 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20603 @item __has_nothrow_copy (type)
20604 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
20605 @code{type} is a cv class or union type with copy constructors that
20606 are known not to throw an exception then the trait is true, else it is false.
20607 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
20608 @code{void}, or an array of unknown bound.
20610 @item __has_nothrow_constructor (type)
20611 If @code{__has_trivial_constructor (type)} is true then the trait is
20612 true, else if @code{type} is a cv class or union type (or array
20613 thereof) with a default constructor that is known not to throw an
20614 exception then the trait is true, else it is false. Requires:
20615 @code{type} shall be a complete type, (possibly cv-qualified)
20616 @code{void}, or an array of unknown bound.
20618 @item __has_trivial_assign (type)
20619 If @code{type} is const qualified or is a reference type then the trait is
20620 false. Otherwise if @code{__is_pod (type)} is true then the trait is
20621 true, else if @code{type} is a cv class or union type with a trivial
20622 copy assignment ([class.copy]) then the trait is true, else it is
20623 false. Requires: @code{type} shall be a complete type, (possibly
20624 cv-qualified) @code{void}, or an array of unknown bound.
20626 @item __has_trivial_copy (type)
20627 If @code{__is_pod (type)} is true or @code{type} is a reference type
20628 then the trait is true, else if @code{type} is a cv class or union type
20629 with a trivial copy constructor ([class.copy]) then the trait
20630 is true, else it is false. Requires: @code{type} shall be a complete
20631 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20633 @item __has_trivial_constructor (type)
20634 If @code{__is_pod (type)} is true then the trait is true, else if
20635 @code{type} is a cv class or union type (or array thereof) with a
20636 trivial default constructor ([class.ctor]) then the trait is true,
20637 else it is false. Requires: @code{type} shall be a complete
20638 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20640 @item __has_trivial_destructor (type)
20641 If @code{__is_pod (type)} is true or @code{type} is a reference type then
20642 the trait is true, else if @code{type} is a cv class or union type (or
20643 array thereof) with a trivial destructor ([class.dtor]) then the trait
20644 is true, else it is false. Requires: @code{type} shall be a complete
20645 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20647 @item __has_virtual_destructor (type)
20648 If @code{type} is a class type with a virtual destructor
20649 ([class.dtor]) then the trait is true, else it is false. Requires:
20650 @code{type} shall be a complete type, (possibly cv-qualified)
20651 @code{void}, or an array of unknown bound.
20653 @item __is_abstract (type)
20654 If @code{type} is an abstract class ([class.abstract]) then the trait
20655 is true, else it is false. Requires: @code{type} shall be a complete
20656 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20658 @item __is_base_of (base_type, derived_type)
20659 If @code{base_type} is a base class of @code{derived_type}
20660 ([class.derived]) then the trait is true, otherwise it is false.
20661 Top-level cv qualifications of @code{base_type} and
20662 @code{derived_type} are ignored. For the purposes of this trait, a
20663 class type is considered is own base. Requires: if @code{__is_class
20664 (base_type)} and @code{__is_class (derived_type)} are true and
20665 @code{base_type} and @code{derived_type} are not the same type
20666 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
20667 type. A diagnostic is produced if this requirement is not met.
20669 @item __is_class (type)
20670 If @code{type} is a cv class type, and not a union type
20671 ([basic.compound]) the trait is true, else it is false.
20673 @item __is_empty (type)
20674 If @code{__is_class (type)} is false then the trait is false.
20675 Otherwise @code{type} is considered empty if and only if: @code{type}
20676 has no non-static data members, or all non-static data members, if
20677 any, are bit-fields of length 0, and @code{type} has no virtual
20678 members, and @code{type} has no virtual base classes, and @code{type}
20679 has no base classes @code{base_type} for which
20680 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
20681 be a complete type, (possibly cv-qualified) @code{void}, or an array
20684 @item __is_enum (type)
20685 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
20686 true, else it is false.
20688 @item __is_literal_type (type)
20689 If @code{type} is a literal type ([basic.types]) the trait is
20690 true, else it is false. Requires: @code{type} shall be a complete type,
20691 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20693 @item __is_pod (type)
20694 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
20695 else it is false. Requires: @code{type} shall be a complete type,
20696 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20698 @item __is_polymorphic (type)
20699 If @code{type} is a polymorphic class ([class.virtual]) then the trait
20700 is true, else it is false. Requires: @code{type} shall be a complete
20701 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20703 @item __is_standard_layout (type)
20704 If @code{type} is a standard-layout type ([basic.types]) the trait is
20705 true, else it is false. Requires: @code{type} shall be a complete
20706 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20708 @item __is_trivial (type)
20709 If @code{type} is a trivial type ([basic.types]) the trait is
20710 true, else it is false. Requires: @code{type} shall be a complete
20711 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20713 @item __is_union (type)
20714 If @code{type} is a cv union type ([basic.compound]) the trait is
20715 true, else it is false.
20717 @item __underlying_type (type)
20718 The underlying type of @code{type}. Requires: @code{type} shall be
20719 an enumeration type ([dcl.enum]).
20725 @section C++ Concepts
20727 C++ concepts provide much-improved support for generic programming. In
20728 particular, they allow the specification of constraints on template arguments.
20729 The constraints are used to extend the usual overloading and partial
20730 specialization capabilities of the language, allowing generic data structures
20731 and algorithms to be ``refined'' based on their properties rather than their
20734 The following keywords are reserved for concepts.
20738 States an expression as an assumption, and if possible, verifies that the
20739 assumption is valid. For example, @code{assume(n > 0)}.
20742 Introduces an axiom definition. Axioms introduce requirements on values.
20745 Introduces a universally quantified object in an axiom. For example,
20746 @code{forall (int n) n + 0 == n}).
20749 Introduces a concept definition. Concepts are sets of syntactic and semantic
20750 requirements on types and their values.
20753 Introduces constraints on template arguments or requirements for a member
20754 function of a class template.
20758 The front end also exposes a number of internal mechanism that can be used
20759 to simplify the writing of type traits. Note that some of these traits are
20760 likely to be removed in the future.
20763 @item __is_same (type1, type2)
20764 A binary type trait: true whenever the type arguments are the same.
20769 @node Java Exceptions
20770 @section Java Exceptions
20772 The Java language uses a slightly different exception handling model
20773 from C++. Normally, GNU C++ automatically detects when you are
20774 writing C++ code that uses Java exceptions, and handle them
20775 appropriately. However, if C++ code only needs to execute destructors
20776 when Java exceptions are thrown through it, GCC guesses incorrectly.
20777 Sample problematic code is:
20780 struct S @{ ~S(); @};
20781 extern void bar(); // @r{is written in Java, and may throw exceptions}
20790 The usual effect of an incorrect guess is a link failure, complaining of
20791 a missing routine called @samp{__gxx_personality_v0}.
20793 You can inform the compiler that Java exceptions are to be used in a
20794 translation unit, irrespective of what it might think, by writing
20795 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
20796 @samp{#pragma} must appear before any functions that throw or catch
20797 exceptions, or run destructors when exceptions are thrown through them.
20799 You cannot mix Java and C++ exceptions in the same translation unit. It
20800 is believed to be safe to throw a C++ exception from one file through
20801 another file compiled for the Java exception model, or vice versa, but
20802 there may be bugs in this area.
20804 @node Deprecated Features
20805 @section Deprecated Features
20807 In the past, the GNU C++ compiler was extended to experiment with new
20808 features, at a time when the C++ language was still evolving. Now that
20809 the C++ standard is complete, some of those features are superseded by
20810 superior alternatives. Using the old features might cause a warning in
20811 some cases that the feature will be dropped in the future. In other
20812 cases, the feature might be gone already.
20814 While the list below is not exhaustive, it documents some of the options
20815 that are now deprecated:
20818 @item -fexternal-templates
20819 @itemx -falt-external-templates
20820 These are two of the many ways for G++ to implement template
20821 instantiation. @xref{Template Instantiation}. The C++ standard clearly
20822 defines how template definitions have to be organized across
20823 implementation units. G++ has an implicit instantiation mechanism that
20824 should work just fine for standard-conforming code.
20826 @item -fstrict-prototype
20827 @itemx -fno-strict-prototype
20828 Previously it was possible to use an empty prototype parameter list to
20829 indicate an unspecified number of parameters (like C), rather than no
20830 parameters, as C++ demands. This feature has been removed, except where
20831 it is required for backwards compatibility. @xref{Backwards Compatibility}.
20834 G++ allows a virtual function returning @samp{void *} to be overridden
20835 by one returning a different pointer type. This extension to the
20836 covariant return type rules is now deprecated and will be removed from a
20839 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
20840 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
20841 and are now removed from G++. Code using these operators should be
20842 modified to use @code{std::min} and @code{std::max} instead.
20844 The named return value extension has been deprecated, and is now
20847 The use of initializer lists with new expressions has been deprecated,
20848 and is now removed from G++.
20850 Floating and complex non-type template parameters have been deprecated,
20851 and are now removed from G++.
20853 The implicit typename extension has been deprecated and is now
20856 The use of default arguments in function pointers, function typedefs
20857 and other places where they are not permitted by the standard is
20858 deprecated and will be removed from a future version of G++.
20860 G++ allows floating-point literals to appear in integral constant expressions,
20861 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
20862 This extension is deprecated and will be removed from a future version.
20864 G++ allows static data members of const floating-point type to be declared
20865 with an initializer in a class definition. The standard only allows
20866 initializers for static members of const integral types and const
20867 enumeration types so this extension has been deprecated and will be removed
20868 from a future version.
20870 @node Backwards Compatibility
20871 @section Backwards Compatibility
20872 @cindex Backwards Compatibility
20873 @cindex ARM [Annotated C++ Reference Manual]
20875 Now that there is a definitive ISO standard C++, G++ has a specification
20876 to adhere to. The C++ language evolved over time, and features that
20877 used to be acceptable in previous drafts of the standard, such as the ARM
20878 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
20879 compilation of C++ written to such drafts, G++ contains some backwards
20880 compatibilities. @emph{All such backwards compatibility features are
20881 liable to disappear in future versions of G++.} They should be considered
20882 deprecated. @xref{Deprecated Features}.
20886 If a variable is declared at for scope, it used to remain in scope until
20887 the end of the scope that contained the for statement (rather than just
20888 within the for scope). G++ retains this, but issues a warning, if such a
20889 variable is accessed outside the for scope.
20891 @item Implicit C language
20892 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
20893 scope to set the language. On such systems, all header files are
20894 implicitly scoped inside a C language scope. Also, an empty prototype
20895 @code{()} is treated as an unspecified number of arguments, rather
20896 than no arguments, as C++ demands.
20899 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
20900 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr