1 @c Copyright (C) 1988-2017 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.) To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@. Most of them are
19 also available in C++. @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
26 * Statement Exprs:: Putting statements and declarations inside expressions.
27 * Local Labels:: Labels local to a block.
28 * Labels as Values:: Getting pointers to labels, and computed gotos.
29 * Nested Functions:: As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls:: Dispatching a call to another function.
31 * Typeof:: @code{typeof}: referring to the type of an expression.
32 * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
33 * __int128:: 128-bit integers---@code{__int128}.
34 * Long Long:: Double-word integers---@code{long long int}.
35 * Complex:: Data types for complex numbers.
36 * Floating Types:: Additional Floating Types.
37 * Half-Precision:: Half-Precision Floating Point.
38 * Decimal Float:: Decimal Floating Types.
39 * Hex Floats:: Hexadecimal floating-point constants.
40 * Fixed-Point:: Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length:: Zero-length arrays.
43 * Empty Structures:: Structures with no members.
44 * Variable Length:: Arrays whose length is computed at run time.
45 * Variadic Macros:: Macros with a variable number of arguments.
46 * Escaped Newlines:: Slightly looser rules for escaped newlines.
47 * Subscripting:: Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays:: Pointers to arrays with qualifiers work as expected.
50 * Initializers:: Non-constant initializers.
51 * Compound Literals:: Compound literals give structures, unions
53 * Designated Inits:: Labeling elements of initializers.
54 * Case Ranges:: `case 1 ... 9' and such.
55 * Cast to Union:: Casting to union type from any member of the union.
56 * Mixed Declarations:: Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58 or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes:: Specifying attributes of types.
61 * Label Attributes:: Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Statement Attributes:: Specifying attributes on statements.
64 * Attribute Syntax:: Formal syntax for attributes.
65 * Function Prototypes:: Prototype declarations and old-style definitions.
66 * C++ Comments:: C++ comments are recognized.
67 * Dollar Signs:: Dollar sign is allowed in identifiers.
68 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
69 * Alignment:: Inquiring about the alignment of a type or variable.
70 * Inline:: Defining inline functions (as fast as macros).
71 * Volatiles:: What constitutes an access to a volatile object.
72 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
73 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums:: @code{enum foo;}, with details to follow.
75 * Function Names:: Printable strings which are the name of the current
77 * Return Address:: Getting the return or frame address of a function.
78 * Vector Extensions:: Using vector instructions through built-in functions.
79 * Offsetof:: Special syntax for implementing @code{offsetof}.
80 * __sync Builtins:: Legacy built-in functions for atomic memory access.
81 * __atomic Builtins:: Atomic built-in functions with memory model.
82 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
83 arithmetic overflow checking.
84 * x86 specific memory model extensions for transactional memory:: x86 memory models.
85 * Object Size Checking:: Built-in functions for limited buffer overflow
87 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
88 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
89 * Other Builtins:: Other built-in functions.
90 * Target Builtins:: Built-in functions specific to particular targets.
91 * Target Format Checks:: Format checks specific to particular targets.
92 * Pragmas:: Pragmas accepted by GCC.
93 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
94 * Thread-Local:: Per-thread variables.
95 * Binary constants:: Binary constants using the @samp{0b} prefix.
99 @section Statements and Declarations in Expressions
100 @cindex statements inside expressions
101 @cindex declarations inside expressions
102 @cindex expressions containing statements
103 @cindex macros, statements in expressions
105 @c the above section title wrapped and causes an underfull hbox.. i
106 @c changed it from "within" to "in". --mew 4feb93
107 A compound statement enclosed in parentheses may appear as an expression
108 in GNU C@. This allows you to use loops, switches, and local variables
109 within an expression.
111 Recall that a compound statement is a sequence of statements surrounded
112 by braces; in this construct, parentheses go around the braces. For
116 (@{ int y = foo (); int z;
123 is a valid (though slightly more complex than necessary) expression
124 for the absolute value of @code{foo ()}.
126 The last thing in the compound statement should be an expression
127 followed by a semicolon; the value of this subexpression serves as the
128 value of the entire construct. (If you use some other kind of statement
129 last within the braces, the construct has type @code{void}, and thus
130 effectively no value.)
132 This feature is especially useful in making macro definitions ``safe'' (so
133 that they evaluate each operand exactly once). For example, the
134 ``maximum'' function is commonly defined as a macro in standard C as
138 #define max(a,b) ((a) > (b) ? (a) : (b))
142 @cindex side effects, macro argument
143 But this definition computes either @var{a} or @var{b} twice, with bad
144 results if the operand has side effects. In GNU C, if you know the
145 type of the operands (here taken as @code{int}), you can define
146 the macro safely as follows:
149 #define maxint(a,b) \
150 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
153 Embedded statements are not allowed in constant expressions, such as
154 the value of an enumeration constant, the width of a bit-field, or
155 the initial value of a static variable.
157 If you don't know the type of the operand, you can still do this, but you
158 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
160 In G++, the result value of a statement expression undergoes array and
161 function pointer decay, and is returned by value to the enclosing
162 expression. For instance, if @code{A} is a class, then
171 constructs a temporary @code{A} object to hold the result of the
172 statement expression, and that is used to invoke @code{Foo}.
173 Therefore the @code{this} pointer observed by @code{Foo} is not the
176 In a statement expression, any temporaries created within a statement
177 are destroyed at that statement's end. This makes statement
178 expressions inside macros slightly different from function calls. In
179 the latter case temporaries introduced during argument evaluation are
180 destroyed at the end of the statement that includes the function
181 call. In the statement expression case they are destroyed during
182 the statement expression. For instance,
185 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
186 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
196 has different places where temporaries are destroyed. For the
197 @code{macro} case, the temporary @code{X} is destroyed just after
198 the initialization of @code{b}. In the @code{function} case that
199 temporary is destroyed when the function returns.
201 These considerations mean that it is probably a bad idea to use
202 statement expressions of this form in header files that are designed to
203 work with C++. (Note that some versions of the GNU C Library contained
204 header files using statement expressions that lead to precisely this
207 Jumping into a statement expression with @code{goto} or using a
208 @code{switch} statement outside the statement expression with a
209 @code{case} or @code{default} label inside the statement expression is
210 not permitted. Jumping into a statement expression with a computed
211 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
212 Jumping out of a statement expression is permitted, but if the
213 statement expression is part of a larger expression then it is
214 unspecified which other subexpressions of that expression have been
215 evaluated except where the language definition requires certain
216 subexpressions to be evaluated before or after the statement
217 expression. In any case, as with a function call, the evaluation of a
218 statement expression is not interleaved with the evaluation of other
219 parts of the containing expression. For example,
222 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
226 calls @code{foo} and @code{bar1} and does not call @code{baz} but
227 may or may not call @code{bar2}. If @code{bar2} is called, it is
228 called after @code{foo} and before @code{bar1}.
231 @section Locally Declared Labels
233 @cindex macros, local labels
235 GCC allows you to declare @dfn{local labels} in any nested block
236 scope. A local label is just like an ordinary label, but you can
237 only reference it (with a @code{goto} statement, or by taking its
238 address) within the block in which it is declared.
240 A local label declaration looks like this:
243 __label__ @var{label};
250 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
253 Local label declarations must come at the beginning of the block,
254 before any ordinary declarations or statements.
256 The label declaration defines the label @emph{name}, but does not define
257 the label itself. You must do this in the usual way, with
258 @code{@var{label}:}, within the statements of the statement expression.
260 The local label feature is useful for complex macros. If a macro
261 contains nested loops, a @code{goto} can be useful for breaking out of
262 them. However, an ordinary label whose scope is the whole function
263 cannot be used: if the macro can be expanded several times in one
264 function, the label is multiply defined in that function. A
265 local label avoids this problem. For example:
268 #define SEARCH(value, array, target) \
271 typeof (target) _SEARCH_target = (target); \
272 typeof (*(array)) *_SEARCH_array = (array); \
275 for (i = 0; i < max; i++) \
276 for (j = 0; j < max; j++) \
277 if (_SEARCH_array[i][j] == _SEARCH_target) \
278 @{ (value) = i; goto found; @} \
284 This could also be written using a statement expression:
287 #define SEARCH(array, target) \
290 typeof (target) _SEARCH_target = (target); \
291 typeof (*(array)) *_SEARCH_array = (array); \
294 for (i = 0; i < max; i++) \
295 for (j = 0; j < max; j++) \
296 if (_SEARCH_array[i][j] == _SEARCH_target) \
297 @{ value = i; goto found; @} \
304 Local label declarations also make the labels they declare visible to
305 nested functions, if there are any. @xref{Nested Functions}, for details.
307 @node Labels as Values
308 @section Labels as Values
309 @cindex labels as values
310 @cindex computed gotos
311 @cindex goto with computed label
312 @cindex address of a label
314 You can get the address of a label defined in the current function
315 (or a containing function) with the unary operator @samp{&&}. The
316 value has type @code{void *}. This value is a constant and can be used
317 wherever a constant of that type is valid. For example:
325 To use these values, you need to be able to jump to one. This is done
326 with the computed goto statement@footnote{The analogous feature in
327 Fortran is called an assigned goto, but that name seems inappropriate in
328 C, where one can do more than simply store label addresses in label
329 variables.}, @code{goto *@var{exp};}. For example,
336 Any expression of type @code{void *} is allowed.
338 One way of using these constants is in initializing a static array that
339 serves as a jump table:
342 static void *array[] = @{ &&foo, &&bar, &&hack @};
346 Then you can select a label with indexing, like this:
353 Note that this does not check whether the subscript is in bounds---array
354 indexing in C never does that.
356 Such an array of label values serves a purpose much like that of the
357 @code{switch} statement. The @code{switch} statement is cleaner, so
358 use that rather than an array unless the problem does not fit a
359 @code{switch} statement very well.
361 Another use of label values is in an interpreter for threaded code.
362 The labels within the interpreter function can be stored in the
363 threaded code for super-fast dispatching.
365 You may not use this mechanism to jump to code in a different function.
366 If you do that, totally unpredictable things happen. The best way to
367 avoid this is to store the label address only in automatic variables and
368 never pass it as an argument.
370 An alternate way to write the above example is
373 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
375 goto *(&&foo + array[i]);
379 This is more friendly to code living in shared libraries, as it reduces
380 the number of dynamic relocations that are needed, and by consequence,
381 allows the data to be read-only.
382 This alternative with label differences is not supported for the AVR target,
383 please use the first approach for AVR programs.
385 The @code{&&foo} expressions for the same label might have different
386 values if the containing function is inlined or cloned. If a program
387 relies on them being always the same,
388 @code{__attribute__((__noinline__,__noclone__))} should be used to
389 prevent inlining and cloning. If @code{&&foo} is used in a static
390 variable initializer, inlining and cloning is forbidden.
392 @node Nested Functions
393 @section Nested Functions
394 @cindex nested functions
395 @cindex downward funargs
398 A @dfn{nested function} is a function defined inside another function.
399 Nested functions are supported as an extension in GNU C, but are not
400 supported by GNU C++.
402 The nested function's name is local to the block where it is defined.
403 For example, here we define a nested function named @code{square}, and
408 foo (double a, double b)
410 double square (double z) @{ return z * z; @}
412 return square (a) + square (b);
417 The nested function can access all the variables of the containing
418 function that are visible at the point of its definition. This is
419 called @dfn{lexical scoping}. For example, here we show a nested
420 function which uses an inherited variable named @code{offset}:
424 bar (int *array, int offset, int size)
426 int access (int *array, int index)
427 @{ return array[index + offset]; @}
430 for (i = 0; i < size; i++)
431 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
436 Nested function definitions are permitted within functions in the places
437 where variable definitions are allowed; that is, in any block, mixed
438 with the other declarations and statements in the block.
440 It is possible to call the nested function from outside the scope of its
441 name by storing its address or passing the address to another function:
444 hack (int *array, int size)
446 void store (int index, int value)
447 @{ array[index] = value; @}
449 intermediate (store, size);
453 Here, the function @code{intermediate} receives the address of
454 @code{store} as an argument. If @code{intermediate} calls @code{store},
455 the arguments given to @code{store} are used to store into @code{array}.
456 But this technique works only so long as the containing function
457 (@code{hack}, in this example) does not exit.
459 If you try to call the nested function through its address after the
460 containing function exits, all hell breaks loose. If you try
461 to call it after a containing scope level exits, and if it refers
462 to some of the variables that are no longer in scope, you may be lucky,
463 but it's not wise to take the risk. If, however, the nested function
464 does not refer to anything that has gone out of scope, you should be
467 GCC implements taking the address of a nested function using a technique
468 called @dfn{trampolines}. This technique was described in
469 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
470 C++ Conference Proceedings, October 17-21, 1988).
472 A nested function can jump to a label inherited from a containing
473 function, provided the label is explicitly declared in the containing
474 function (@pxref{Local Labels}). Such a jump returns instantly to the
475 containing function, exiting the nested function that did the
476 @code{goto} and any intermediate functions as well. Here is an example:
480 bar (int *array, int offset, int size)
483 int access (int *array, int index)
487 return array[index + offset];
491 for (i = 0; i < size; i++)
492 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
496 /* @r{Control comes here from @code{access}
497 if it detects an error.} */
504 A nested function always has no linkage. Declaring one with
505 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
506 before its definition, use @code{auto} (which is otherwise meaningless
507 for function declarations).
510 bar (int *array, int offset, int size)
513 auto int access (int *, int);
515 int access (int *array, int index)
519 return array[index + offset];
525 @node Constructing Calls
526 @section Constructing Function Calls
527 @cindex constructing calls
528 @cindex forwarding calls
530 Using the built-in functions described below, you can record
531 the arguments a function received, and call another function
532 with the same arguments, without knowing the number or types
535 You can also record the return value of that function call,
536 and later return that value, without knowing what data type
537 the function tried to return (as long as your caller expects
540 However, these built-in functions may interact badly with some
541 sophisticated features or other extensions of the language. It
542 is, therefore, not recommended to use them outside very simple
543 functions acting as mere forwarders for their arguments.
545 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
546 This built-in function returns a pointer to data
547 describing how to perform a call with the same arguments as are passed
548 to the current function.
550 The function saves the arg pointer register, structure value address,
551 and all registers that might be used to pass arguments to a function
552 into a block of memory allocated on the stack. Then it returns the
553 address of that block.
556 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
557 This built-in function invokes @var{function}
558 with a copy of the parameters described by @var{arguments}
561 The value of @var{arguments} should be the value returned by
562 @code{__builtin_apply_args}. The argument @var{size} specifies the size
563 of the stack argument data, in bytes.
565 This function returns a pointer to data describing
566 how to return whatever value is returned by @var{function}. The data
567 is saved in a block of memory allocated on the stack.
569 It is not always simple to compute the proper value for @var{size}. The
570 value is used by @code{__builtin_apply} to compute the amount of data
571 that should be pushed on the stack and copied from the incoming argument
575 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
576 This built-in function returns the value described by @var{result} from
577 the containing function. You should specify, for @var{result}, a value
578 returned by @code{__builtin_apply}.
581 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
582 This built-in function represents all anonymous arguments of an inline
583 function. It can be used only in inline functions that are always
584 inlined, never compiled as a separate function, such as those using
585 @code{__attribute__ ((__always_inline__))} or
586 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
587 It must be only passed as last argument to some other function
588 with variable arguments. This is useful for writing small wrapper
589 inlines for variable argument functions, when using preprocessor
590 macros is undesirable. For example:
592 extern int myprintf (FILE *f, const char *format, ...);
593 extern inline __attribute__ ((__gnu_inline__)) int
594 myprintf (FILE *f, const char *format, ...)
596 int r = fprintf (f, "myprintf: ");
599 int s = fprintf (f, format, __builtin_va_arg_pack ());
607 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
608 This built-in function returns the number of anonymous arguments of
609 an inline function. It can be used only in inline functions that
610 are always inlined, never compiled as a separate function, such
611 as those using @code{__attribute__ ((__always_inline__))} or
612 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
613 For example following does link- or run-time checking of open
614 arguments for optimized code:
617 extern inline __attribute__((__gnu_inline__)) int
618 myopen (const char *path, int oflag, ...)
620 if (__builtin_va_arg_pack_len () > 1)
621 warn_open_too_many_arguments ();
623 if (__builtin_constant_p (oflag))
625 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
627 warn_open_missing_mode ();
628 return __open_2 (path, oflag);
630 return open (path, oflag, __builtin_va_arg_pack ());
633 if (__builtin_va_arg_pack_len () < 1)
634 return __open_2 (path, oflag);
636 return open (path, oflag, __builtin_va_arg_pack ());
643 @section Referring to a Type with @code{typeof}
646 @cindex macros, types of arguments
648 Another way to refer to the type of an expression is with @code{typeof}.
649 The syntax of using of this keyword looks like @code{sizeof}, but the
650 construct acts semantically like a type name defined with @code{typedef}.
652 There are two ways of writing the argument to @code{typeof}: with an
653 expression or with a type. Here is an example with an expression:
660 This assumes that @code{x} is an array of pointers to functions;
661 the type described is that of the values of the functions.
663 Here is an example with a typename as the argument:
670 Here the type described is that of pointers to @code{int}.
672 If you are writing a header file that must work when included in ISO C
673 programs, write @code{__typeof__} instead of @code{typeof}.
674 @xref{Alternate Keywords}.
676 A @code{typeof} construct can be used anywhere a typedef name can be
677 used. For example, you can use it in a declaration, in a cast, or inside
678 of @code{sizeof} or @code{typeof}.
680 The operand of @code{typeof} is evaluated for its side effects if and
681 only if it is an expression of variably modified type or the name of
684 @code{typeof} is often useful in conjunction with
685 statement expressions (@pxref{Statement Exprs}).
686 Here is how the two together can
687 be used to define a safe ``maximum'' macro which operates on any
688 arithmetic type and evaluates each of its arguments exactly once:
692 (@{ typeof (a) _a = (a); \
693 typeof (b) _b = (b); \
694 _a > _b ? _a : _b; @})
697 @cindex underscores in variables in macros
698 @cindex @samp{_} in variables in macros
699 @cindex local variables in macros
700 @cindex variables, local, in macros
701 @cindex macros, local variables in
703 The reason for using names that start with underscores for the local
704 variables is to avoid conflicts with variable names that occur within the
705 expressions that are substituted for @code{a} and @code{b}. Eventually we
706 hope to design a new form of declaration syntax that allows you to declare
707 variables whose scopes start only after their initializers; this will be a
708 more reliable way to prevent such conflicts.
711 Some more examples of the use of @code{typeof}:
715 This declares @code{y} with the type of what @code{x} points to.
722 This declares @code{y} as an array of such values.
729 This declares @code{y} as an array of pointers to characters:
732 typeof (typeof (char *)[4]) y;
736 It is equivalent to the following traditional C declaration:
742 To see the meaning of the declaration using @code{typeof}, and why it
743 might be a useful way to write, rewrite it with these macros:
746 #define pointer(T) typeof(T *)
747 #define array(T, N) typeof(T [N])
751 Now the declaration can be rewritten this way:
754 array (pointer (char), 4) y;
758 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
759 pointers to @code{char}.
762 In GNU C, but not GNU C++, you may also declare the type of a variable
763 as @code{__auto_type}. In that case, the declaration must declare
764 only one variable, whose declarator must just be an identifier, the
765 declaration must be initialized, and the type of the variable is
766 determined by the initializer; the name of the variable is not in
767 scope until after the initializer. (In C++, you should use C++11
768 @code{auto} for this purpose.) Using @code{__auto_type}, the
769 ``maximum'' macro above could be written as:
773 (@{ __auto_type _a = (a); \
774 __auto_type _b = (b); \
775 _a > _b ? _a : _b; @})
778 Using @code{__auto_type} instead of @code{typeof} has two advantages:
781 @item Each argument to the macro appears only once in the expansion of
782 the macro. This prevents the size of the macro expansion growing
783 exponentially when calls to such macros are nested inside arguments of
786 @item If the argument to the macro has variably modified type, it is
787 evaluated only once when using @code{__auto_type}, but twice if
788 @code{typeof} is used.
792 @section Conditionals with Omitted Operands
793 @cindex conditional expressions, extensions
794 @cindex omitted middle-operands
795 @cindex middle-operands, omitted
796 @cindex extensions, @code{?:}
797 @cindex @code{?:} extensions
799 The middle operand in a conditional expression may be omitted. Then
800 if the first operand is nonzero, its value is the value of the conditional
803 Therefore, the expression
810 has the value of @code{x} if that is nonzero; otherwise, the value of
813 This example is perfectly equivalent to
819 @cindex side effect in @code{?:}
820 @cindex @code{?:} side effect
822 In this simple case, the ability to omit the middle operand is not
823 especially useful. When it becomes useful is when the first operand does,
824 or may (if it is a macro argument), contain a side effect. Then repeating
825 the operand in the middle would perform the side effect twice. Omitting
826 the middle operand uses the value already computed without the undesirable
827 effects of recomputing it.
830 @section 128-bit Integers
831 @cindex @code{__int128} data types
833 As an extension the integer scalar type @code{__int128} is supported for
834 targets which have an integer mode wide enough to hold 128 bits.
835 Simply write @code{__int128} for a signed 128-bit integer, or
836 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
837 support in GCC for expressing an integer constant of type @code{__int128}
838 for targets with @code{long long} integer less than 128 bits wide.
841 @section Double-Word Integers
842 @cindex @code{long long} data types
843 @cindex double-word arithmetic
844 @cindex multiprecision arithmetic
845 @cindex @code{LL} integer suffix
846 @cindex @code{ULL} integer suffix
848 ISO C99 supports data types for integers that are at least 64 bits wide,
849 and as an extension GCC supports them in C90 mode and in C++.
850 Simply write @code{long long int} for a signed integer, or
851 @code{unsigned long long int} for an unsigned integer. To make an
852 integer constant of type @code{long long int}, add the suffix @samp{LL}
853 to the integer. To make an integer constant of type @code{unsigned long
854 long int}, add the suffix @samp{ULL} to the integer.
856 You can use these types in arithmetic like any other integer types.
857 Addition, subtraction, and bitwise boolean operations on these types
858 are open-coded on all types of machines. Multiplication is open-coded
859 if the machine supports a fullword-to-doubleword widening multiply
860 instruction. Division and shifts are open-coded only on machines that
861 provide special support. The operations that are not open-coded use
862 special library routines that come with GCC@.
864 There may be pitfalls when you use @code{long long} types for function
865 arguments without function prototypes. If a function
866 expects type @code{int} for its argument, and you pass a value of type
867 @code{long long int}, confusion results because the caller and the
868 subroutine disagree about the number of bytes for the argument.
869 Likewise, if the function expects @code{long long int} and you pass
870 @code{int}. The best way to avoid such problems is to use prototypes.
873 @section Complex Numbers
874 @cindex complex numbers
875 @cindex @code{_Complex} keyword
876 @cindex @code{__complex__} keyword
878 ISO C99 supports complex floating data types, and as an extension GCC
879 supports them in C90 mode and in C++. GCC also supports complex integer data
880 types which are not part of ISO C99. You can declare complex types
881 using the keyword @code{_Complex}. As an extension, the older GNU
882 keyword @code{__complex__} is also supported.
884 For example, @samp{_Complex double x;} declares @code{x} as a
885 variable whose real part and imaginary part are both of type
886 @code{double}. @samp{_Complex short int y;} declares @code{y} to
887 have real and imaginary parts of type @code{short int}; this is not
888 likely to be useful, but it shows that the set of complex types is
891 To write a constant with a complex data type, use the suffix @samp{i} or
892 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
893 has type @code{_Complex float} and @code{3i} has type
894 @code{_Complex int}. Such a constant always has a pure imaginary
895 value, but you can form any complex value you like by adding one to a
896 real constant. This is a GNU extension; if you have an ISO C99
897 conforming C library (such as the GNU C Library), and want to construct complex
898 constants of floating type, you should include @code{<complex.h>} and
899 use the macros @code{I} or @code{_Complex_I} instead.
901 @cindex @code{__real__} keyword
902 @cindex @code{__imag__} keyword
903 To extract the real part of a complex-valued expression @var{exp}, write
904 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
905 extract the imaginary part. This is a GNU extension; for values of
906 floating type, you should use the ISO C99 functions @code{crealf},
907 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
908 @code{cimagl}, declared in @code{<complex.h>} and also provided as
909 built-in functions by GCC@.
911 @cindex complex conjugation
912 The operator @samp{~} performs complex conjugation when used on a value
913 with a complex type. This is a GNU extension; for values of
914 floating type, you should use the ISO C99 functions @code{conjf},
915 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
916 provided as built-in functions by GCC@.
918 GCC can allocate complex automatic variables in a noncontiguous
919 fashion; it's even possible for the real part to be in a register while
920 the imaginary part is on the stack (or vice versa). Only the DWARF
921 debug info format can represent this, so use of DWARF is recommended.
922 If you are using the stabs debug info format, GCC describes a noncontiguous
923 complex variable as if it were two separate variables of noncomplex type.
924 If the variable's actual name is @code{foo}, the two fictitious
925 variables are named @code{foo$real} and @code{foo$imag}. You can
926 examine and set these two fictitious variables with your debugger.
929 @section Additional Floating Types
930 @cindex additional floating types
931 @cindex @code{_Float@var{n}} data types
932 @cindex @code{_Float@var{n}x} data types
933 @cindex @code{__float80} data type
934 @cindex @code{__float128} data type
935 @cindex @code{__ibm128} data type
936 @cindex @code{w} floating point suffix
937 @cindex @code{q} floating point suffix
938 @cindex @code{W} floating point suffix
939 @cindex @code{Q} floating point suffix
941 ISO/IEC TS 18661-3:2015 defines C support for additional floating
942 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
943 these type names; the set of types supported depends on the target
944 architecture. These types are not supported when compiling C++.
945 Constants with these types use suffixes @code{f@var{n}} or
946 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}. These type
947 names can be used together with @code{_Complex} to declare complex
950 As an extension, GNU C and GNU C++ support additional floating
951 types, @code{__float80} and @code{__float128} to support 80-bit
952 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types; these are
953 aliases for the type names @code{_Float64x} and @code{_Float128}.
954 Support for additional types includes the arithmetic operators:
955 add, subtract, multiply, divide; unary arithmetic operators;
956 relational operators; equality operators; and conversions to and from
957 integer and other floating types. Use a suffix @samp{w} or @samp{W}
958 in a literal constant of type @code{__float80} or type
959 @code{__ibm128}. Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
961 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
962 types using the corresponding internal complex type, @code{XCmode} for
963 @code{__float80} type and @code{TCmode} for @code{__float128} type:
966 typedef _Complex float __attribute__((mode(TC))) _Complex128;
967 typedef _Complex float __attribute__((mode(XC))) _Complex80;
970 In order to use @code{_Float128}, @code{__float128} and
971 @code{__ibm128} on PowerPC Linux
972 systems, you must use the @option{-mfloat128}. It is expected in
973 future versions of GCC that @code{_Float128} and @code{__float128}
975 automatically. In addition, there are currently problems in using the
976 complex @code{__float128} type. When these problems are fixed, you
977 would use the following syntax to declare @code{_Complex128} to be a
978 complex @code{__float128} type:
980 On the PowerPC Linux VSX targets, you can declare complex types using
981 the corresponding internal complex type, @code{KCmode} for
982 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
985 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
986 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
989 Not all targets support additional floating-point types.
990 @code{__float80} and @code{__float128} types are supported on x86 and
991 IA-64 targets. The @code{__float128} type is supported on hppa HP-UX.
992 The @code{__float128} type is supported on PowerPC 64-bit Linux
993 systems by default if the vector scalar instruction set (VSX) is
994 enabled. The @code{_Float128} type is supported on all systems where
995 @code{__float128} is supported or where @code{long double} has the
996 IEEE binary128 format. The @code{_Float64x} type is supported on all
997 systems where @code{__float128} is supported. The @code{_Float32}
998 type is supported on all systems supporting IEEE binary32; the
999 @code{_Float64} and @code{Float32x} types are supported on all systems
1000 supporting IEEE binary64. The @code{_Float16} type is supported on AArch64
1001 systems by default, and on ARM systems when the IEEE format for 16-bit
1002 floating-point types is selected with @option{-mfp16-format=ieee}.
1003 GCC does not currently support @code{_Float128x} on any systems.
1005 On the PowerPC, @code{__ibm128} provides access to the IBM extended
1006 double format, and it is intended to be used by the library functions
1007 that handle conversions if/when long double is changed to be IEEE
1008 128-bit floating point.
1010 @node Half-Precision
1011 @section Half-Precision Floating Point
1012 @cindex half-precision floating point
1013 @cindex @code{__fp16} data type
1015 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1016 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1017 On ARM systems, you must enable this type explicitly with the
1018 @option{-mfp16-format} command-line option in order to use it.
1020 ARM targets support two incompatible representations for half-precision
1021 floating-point values. You must choose one of the representations and
1022 use it consistently in your program.
1024 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1025 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1026 There are 11 bits of significand precision, approximately 3
1029 Specifying @option{-mfp16-format=alternative} selects the ARM
1030 alternative format. This representation is similar to the IEEE
1031 format, but does not support infinities or NaNs. Instead, the range
1032 of exponents is extended, so that this format can represent normalized
1033 values in the range of @math{2^{-14}} to 131008.
1035 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1036 not require use of the @option{-mfp16-format} command-line option.
1038 The @code{__fp16} type may only be used as an argument to intrinsics defined
1039 in @code{<arm_fp16.h>}, or as a storage format. For purposes of
1040 arithmetic and other operations, @code{__fp16} values in C or C++
1041 expressions are automatically promoted to @code{float}.
1043 The ARM target provides hardware support for conversions between
1044 @code{__fp16} and @code{float} values
1045 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8 provides
1046 hardware support for conversions between @code{__fp16} and @code{double}
1047 values. GCC generates code using these hardware instructions if you
1048 compile with options to select an FPU that provides them;
1049 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1050 in addition to the @option{-mfp16-format} option to select
1051 a half-precision format.
1053 Language-level support for the @code{__fp16} data type is
1054 independent of whether GCC generates code using hardware floating-point
1055 instructions. In cases where hardware support is not specified, GCC
1056 implements conversions between @code{__fp16} and other types as library
1059 It is recommended that portable code use the @code{_Float16} type defined
1060 by ISO/IEC TS 18661-3:2015. @xref{Floating Types}.
1063 @section Decimal Floating Types
1064 @cindex decimal floating types
1065 @cindex @code{_Decimal32} data type
1066 @cindex @code{_Decimal64} data type
1067 @cindex @code{_Decimal128} data type
1068 @cindex @code{df} integer suffix
1069 @cindex @code{dd} integer suffix
1070 @cindex @code{dl} integer suffix
1071 @cindex @code{DF} integer suffix
1072 @cindex @code{DD} integer suffix
1073 @cindex @code{DL} integer suffix
1075 As an extension, GNU C supports decimal floating types as
1076 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1077 floating types in GCC will evolve as the draft technical report changes.
1078 Calling conventions for any target might also change. Not all targets
1079 support decimal floating types.
1081 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1082 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1083 @code{float}, @code{double}, and @code{long double} whose radix is not
1084 specified by the C standard but is usually two.
1086 Support for decimal floating types includes the arithmetic operators
1087 add, subtract, multiply, divide; unary arithmetic operators;
1088 relational operators; equality operators; and conversions to and from
1089 integer and other floating types. Use a suffix @samp{df} or
1090 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1091 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1094 GCC support of decimal float as specified by the draft technical report
1099 When the value of a decimal floating type cannot be represented in the
1100 integer type to which it is being converted, the result is undefined
1101 rather than the result value specified by the draft technical report.
1104 GCC does not provide the C library functionality associated with
1105 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1106 @file{wchar.h}, which must come from a separate C library implementation.
1107 Because of this the GNU C compiler does not define macro
1108 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1109 the technical report.
1112 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1113 are supported by the DWARF debug information format.
1119 ISO C99 supports floating-point numbers written not only in the usual
1120 decimal notation, such as @code{1.55e1}, but also numbers such as
1121 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1122 supports this in C90 mode (except in some cases when strictly
1123 conforming) and in C++. In that format the
1124 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1125 mandatory. The exponent is a decimal number that indicates the power of
1126 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1133 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1134 is the same as @code{1.55e1}.
1136 Unlike for floating-point numbers in the decimal notation the exponent
1137 is always required in the hexadecimal notation. Otherwise the compiler
1138 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1139 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1140 extension for floating-point constants of type @code{float}.
1143 @section Fixed-Point Types
1144 @cindex fixed-point types
1145 @cindex @code{_Fract} data type
1146 @cindex @code{_Accum} data type
1147 @cindex @code{_Sat} data type
1148 @cindex @code{hr} fixed-suffix
1149 @cindex @code{r} fixed-suffix
1150 @cindex @code{lr} fixed-suffix
1151 @cindex @code{llr} fixed-suffix
1152 @cindex @code{uhr} fixed-suffix
1153 @cindex @code{ur} fixed-suffix
1154 @cindex @code{ulr} fixed-suffix
1155 @cindex @code{ullr} fixed-suffix
1156 @cindex @code{hk} fixed-suffix
1157 @cindex @code{k} fixed-suffix
1158 @cindex @code{lk} fixed-suffix
1159 @cindex @code{llk} fixed-suffix
1160 @cindex @code{uhk} fixed-suffix
1161 @cindex @code{uk} fixed-suffix
1162 @cindex @code{ulk} fixed-suffix
1163 @cindex @code{ullk} fixed-suffix
1164 @cindex @code{HR} fixed-suffix
1165 @cindex @code{R} fixed-suffix
1166 @cindex @code{LR} fixed-suffix
1167 @cindex @code{LLR} fixed-suffix
1168 @cindex @code{UHR} fixed-suffix
1169 @cindex @code{UR} fixed-suffix
1170 @cindex @code{ULR} fixed-suffix
1171 @cindex @code{ULLR} fixed-suffix
1172 @cindex @code{HK} fixed-suffix
1173 @cindex @code{K} fixed-suffix
1174 @cindex @code{LK} fixed-suffix
1175 @cindex @code{LLK} fixed-suffix
1176 @cindex @code{UHK} fixed-suffix
1177 @cindex @code{UK} fixed-suffix
1178 @cindex @code{ULK} fixed-suffix
1179 @cindex @code{ULLK} fixed-suffix
1181 As an extension, GNU C supports fixed-point types as
1182 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1183 types in GCC will evolve as the draft technical report changes.
1184 Calling conventions for any target might also change. Not all targets
1185 support fixed-point types.
1187 The fixed-point types are
1188 @code{short _Fract},
1191 @code{long long _Fract},
1192 @code{unsigned short _Fract},
1193 @code{unsigned _Fract},
1194 @code{unsigned long _Fract},
1195 @code{unsigned long long _Fract},
1196 @code{_Sat short _Fract},
1198 @code{_Sat long _Fract},
1199 @code{_Sat long long _Fract},
1200 @code{_Sat unsigned short _Fract},
1201 @code{_Sat unsigned _Fract},
1202 @code{_Sat unsigned long _Fract},
1203 @code{_Sat unsigned long long _Fract},
1204 @code{short _Accum},
1207 @code{long long _Accum},
1208 @code{unsigned short _Accum},
1209 @code{unsigned _Accum},
1210 @code{unsigned long _Accum},
1211 @code{unsigned long long _Accum},
1212 @code{_Sat short _Accum},
1214 @code{_Sat long _Accum},
1215 @code{_Sat long long _Accum},
1216 @code{_Sat unsigned short _Accum},
1217 @code{_Sat unsigned _Accum},
1218 @code{_Sat unsigned long _Accum},
1219 @code{_Sat unsigned long long _Accum}.
1221 Fixed-point data values contain fractional and optional integral parts.
1222 The format of fixed-point data varies and depends on the target machine.
1224 Support for fixed-point types includes:
1227 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1229 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1231 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1233 binary shift operators (@code{<<}, @code{>>})
1235 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1237 equality operators (@code{==}, @code{!=})
1239 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1240 @code{<<=}, @code{>>=})
1242 conversions to and from integer, floating-point, or fixed-point types
1245 Use a suffix in a fixed-point literal constant:
1247 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1248 @code{_Sat short _Fract}
1249 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1250 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1251 @code{_Sat long _Fract}
1252 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1253 @code{_Sat long long _Fract}
1254 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1255 @code{_Sat unsigned short _Fract}
1256 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1257 @code{_Sat unsigned _Fract}
1258 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1259 @code{_Sat unsigned long _Fract}
1260 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1261 and @code{_Sat unsigned long long _Fract}
1262 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1263 @code{_Sat short _Accum}
1264 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1265 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1266 @code{_Sat long _Accum}
1267 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1268 @code{_Sat long long _Accum}
1269 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1270 @code{_Sat unsigned short _Accum}
1271 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1272 @code{_Sat unsigned _Accum}
1273 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1274 @code{_Sat unsigned long _Accum}
1275 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1276 and @code{_Sat unsigned long long _Accum}
1279 GCC support of fixed-point types as specified by the draft technical report
1284 Pragmas to control overflow and rounding behaviors are not implemented.
1287 Fixed-point types are supported by the DWARF debug information format.
1289 @node Named Address Spaces
1290 @section Named Address Spaces
1291 @cindex Named Address Spaces
1293 As an extension, GNU C supports named address spaces as
1294 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1295 address spaces in GCC will evolve as the draft technical report
1296 changes. Calling conventions for any target might also change. At
1297 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1298 address spaces other than the generic address space.
1300 Address space identifiers may be used exactly like any other C type
1301 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1302 document for more details.
1304 @anchor{AVR Named Address Spaces}
1305 @subsection AVR Named Address Spaces
1307 On the AVR target, there are several address spaces that can be used
1308 in order to put read-only data into the flash memory and access that
1309 data by means of the special instructions @code{LPM} or @code{ELPM}
1310 needed to read from flash.
1312 Per default, any data including read-only data is located in RAM
1313 (the generic address space) so that non-generic address spaces are
1314 needed to locate read-only data in flash memory
1315 @emph{and} to generate the right instructions to access this data
1316 without using (inline) assembler code.
1320 @cindex @code{__flash} AVR Named Address Spaces
1321 The @code{__flash} qualifier locates data in the
1322 @code{.progmem.data} section. Data is read using the @code{LPM}
1323 instruction. Pointers to this address space are 16 bits wide.
1330 @cindex @code{__flash1} AVR Named Address Spaces
1331 @cindex @code{__flash2} AVR Named Address Spaces
1332 @cindex @code{__flash3} AVR Named Address Spaces
1333 @cindex @code{__flash4} AVR Named Address Spaces
1334 @cindex @code{__flash5} AVR Named Address Spaces
1335 These are 16-bit address spaces locating data in section
1336 @code{.progmem@var{N}.data} where @var{N} refers to
1337 address space @code{__flash@var{N}}.
1338 The compiler sets the @code{RAMPZ} segment register appropriately
1339 before reading data by means of the @code{ELPM} instruction.
1342 @cindex @code{__memx} AVR Named Address Spaces
1343 This is a 24-bit address space that linearizes flash and RAM:
1344 If the high bit of the address is set, data is read from
1345 RAM using the lower two bytes as RAM address.
1346 If the high bit of the address is clear, data is read from flash
1347 with @code{RAMPZ} set according to the high byte of the address.
1348 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1350 Objects in this address space are located in @code{.progmemx.data}.
1356 char my_read (const __flash char ** p)
1358 /* p is a pointer to RAM that points to a pointer to flash.
1359 The first indirection of p reads that flash pointer
1360 from RAM and the second indirection reads a char from this
1366 /* Locate array[] in flash memory */
1367 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1373 /* Return 17 by reading from flash memory */
1374 return array[array[i]];
1379 For each named address space supported by avr-gcc there is an equally
1380 named but uppercase built-in macro defined.
1381 The purpose is to facilitate testing if respective address space
1382 support is available or not:
1386 const __flash int var = 1;
1393 #include <avr/pgmspace.h> /* From AVR-LibC */
1395 const int var PROGMEM = 1;
1399 return (int) pgm_read_word (&var);
1401 #endif /* __FLASH */
1405 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1406 locates data in flash but
1407 accesses to these data read from generic address space, i.e.@:
1409 so that you need special accessors like @code{pgm_read_byte}
1410 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1411 together with attribute @code{progmem}.
1414 @b{Limitations and caveats}
1418 Reading across the 64@tie{}KiB section boundary of
1419 the @code{__flash} or @code{__flash@var{N}} address spaces
1420 shows undefined behavior. The only address space that
1421 supports reading across the 64@tie{}KiB flash segment boundaries is
1425 If you use one of the @code{__flash@var{N}} address spaces
1426 you must arrange your linker script to locate the
1427 @code{.progmem@var{N}.data} sections according to your needs.
1430 Any data or pointers to the non-generic address spaces must
1431 be qualified as @code{const}, i.e.@: as read-only data.
1432 This still applies if the data in one of these address
1433 spaces like software version number or calibration lookup table are intended to
1434 be changed after load time by, say, a boot loader. In this case
1435 the right qualification is @code{const} @code{volatile} so that the compiler
1436 must not optimize away known values or insert them
1437 as immediates into operands of instructions.
1440 The following code initializes a variable @code{pfoo}
1441 located in static storage with a 24-bit address:
1443 extern const __memx char foo;
1444 const __memx void *pfoo = &foo;
1448 Such code requires at least binutils 2.23, see
1449 @w{@uref{https://sourceware.org/PR13503,PR13503}}.
1452 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1453 Data can be put into and read from flash memory by means of
1454 attribute @code{progmem}, see @ref{AVR Variable Attributes}.
1458 @subsection M32C Named Address Spaces
1459 @cindex @code{__far} M32C Named Address Spaces
1461 On the M32C target, with the R8C and M16C CPU variants, variables
1462 qualified with @code{__far} are accessed using 32-bit addresses in
1463 order to access memory beyond the first 64@tie{}Ki bytes. If
1464 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1467 @subsection RL78 Named Address Spaces
1468 @cindex @code{__far} RL78 Named Address Spaces
1470 On the RL78 target, variables qualified with @code{__far} are accessed
1471 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1472 addresses. Non-far variables are assumed to appear in the topmost
1473 64@tie{}KiB of the address space.
1475 @subsection SPU Named Address Spaces
1476 @cindex @code{__ea} SPU Named Address Spaces
1478 On the SPU target variables may be declared as
1479 belonging to another address space by qualifying the type with the
1480 @code{__ea} address space identifier:
1487 The compiler generates special code to access the variable @code{i}.
1488 It may use runtime library
1489 support, or generate special machine instructions to access that address
1492 @subsection x86 Named Address Spaces
1493 @cindex x86 named address spaces
1495 On the x86 target, variables may be declared as being relative
1496 to the @code{%fs} or @code{%gs} segments.
1501 @cindex @code{__seg_fs} x86 named address space
1502 @cindex @code{__seg_gs} x86 named address space
1503 The object is accessed with the respective segment override prefix.
1505 The respective segment base must be set via some method specific to
1506 the operating system. Rather than require an expensive system call
1507 to retrieve the segment base, these address spaces are not considered
1508 to be subspaces of the generic (flat) address space. This means that
1509 explicit casts are required to convert pointers between these address
1510 spaces and the generic address space. In practice the application
1511 should cast to @code{uintptr_t} and apply the segment base offset
1512 that it installed previously.
1514 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1515 defined when these address spaces are supported.
1519 @section Arrays of Length Zero
1520 @cindex arrays of length zero
1521 @cindex zero-length arrays
1522 @cindex length-zero arrays
1523 @cindex flexible array members
1525 Zero-length arrays are allowed in GNU C@. They are very useful as the
1526 last element of a structure that is really a header for a variable-length
1535 struct line *thisline = (struct line *)
1536 malloc (sizeof (struct line) + this_length);
1537 thisline->length = this_length;
1540 In ISO C90, you would have to give @code{contents} a length of 1, which
1541 means either you waste space or complicate the argument to @code{malloc}.
1543 In ISO C99, you would use a @dfn{flexible array member}, which is
1544 slightly different in syntax and semantics:
1548 Flexible array members are written as @code{contents[]} without
1552 Flexible array members have incomplete type, and so the @code{sizeof}
1553 operator may not be applied. As a quirk of the original implementation
1554 of zero-length arrays, @code{sizeof} evaluates to zero.
1557 Flexible array members may only appear as the last member of a
1558 @code{struct} that is otherwise non-empty.
1561 A structure containing a flexible array member, or a union containing
1562 such a structure (possibly recursively), may not be a member of a
1563 structure or an element of an array. (However, these uses are
1564 permitted by GCC as extensions.)
1567 Non-empty initialization of zero-length
1568 arrays is treated like any case where there are more initializer
1569 elements than the array holds, in that a suitable warning about ``excess
1570 elements in array'' is given, and the excess elements (all of them, in
1571 this case) are ignored.
1573 GCC allows static initialization of flexible array members.
1574 This is equivalent to defining a new structure containing the original
1575 structure followed by an array of sufficient size to contain the data.
1576 E.g.@: in the following, @code{f1} is constructed as if it were declared
1582 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1585 struct f1 f1; int data[3];
1586 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1590 The convenience of this extension is that @code{f1} has the desired
1591 type, eliminating the need to consistently refer to @code{f2.f1}.
1593 This has symmetry with normal static arrays, in that an array of
1594 unknown size is also written with @code{[]}.
1596 Of course, this extension only makes sense if the extra data comes at
1597 the end of a top-level object, as otherwise we would be overwriting
1598 data at subsequent offsets. To avoid undue complication and confusion
1599 with initialization of deeply nested arrays, we simply disallow any
1600 non-empty initialization except when the structure is the top-level
1601 object. For example:
1604 struct foo @{ int x; int y[]; @};
1605 struct bar @{ struct foo z; @};
1607 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1608 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1609 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1610 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1613 @node Empty Structures
1614 @section Structures with No Members
1615 @cindex empty structures
1616 @cindex zero-size structures
1618 GCC permits a C structure to have no members:
1625 The structure has size zero. In C++, empty structures are part
1626 of the language. G++ treats empty structures as if they had a single
1627 member of type @code{char}.
1629 @node Variable Length
1630 @section Arrays of Variable Length
1631 @cindex variable-length arrays
1632 @cindex arrays of variable length
1635 Variable-length automatic arrays are allowed in ISO C99, and as an
1636 extension GCC accepts them in C90 mode and in C++. These arrays are
1637 declared like any other automatic arrays, but with a length that is not
1638 a constant expression. The storage is allocated at the point of
1639 declaration and deallocated when the block scope containing the declaration
1645 concat_fopen (char *s1, char *s2, char *mode)
1647 char str[strlen (s1) + strlen (s2) + 1];
1650 return fopen (str, mode);
1654 @cindex scope of a variable length array
1655 @cindex variable-length array scope
1656 @cindex deallocating variable length arrays
1657 Jumping or breaking out of the scope of the array name deallocates the
1658 storage. Jumping into the scope is not allowed; you get an error
1661 @cindex variable-length array in a structure
1662 As an extension, GCC accepts variable-length arrays as a member of
1663 a structure or a union. For example:
1669 struct S @{ int x[n]; @};
1673 @cindex @code{alloca} vs variable-length arrays
1674 You can use the function @code{alloca} to get an effect much like
1675 variable-length arrays. The function @code{alloca} is available in
1676 many other C implementations (but not in all). On the other hand,
1677 variable-length arrays are more elegant.
1679 There are other differences between these two methods. Space allocated
1680 with @code{alloca} exists until the containing @emph{function} returns.
1681 The space for a variable-length array is deallocated as soon as the array
1682 name's scope ends, unless you also use @code{alloca} in this scope.
1684 You can also use variable-length arrays as arguments to functions:
1688 tester (int len, char data[len][len])
1694 The length of an array is computed once when the storage is allocated
1695 and is remembered for the scope of the array in case you access it with
1698 If you want to pass the array first and the length afterward, you can
1699 use a forward declaration in the parameter list---another GNU extension.
1703 tester (int len; char data[len][len], int len)
1709 @cindex parameter forward declaration
1710 The @samp{int len} before the semicolon is a @dfn{parameter forward
1711 declaration}, and it serves the purpose of making the name @code{len}
1712 known when the declaration of @code{data} is parsed.
1714 You can write any number of such parameter forward declarations in the
1715 parameter list. They can be separated by commas or semicolons, but the
1716 last one must end with a semicolon, which is followed by the ``real''
1717 parameter declarations. Each forward declaration must match a ``real''
1718 declaration in parameter name and data type. ISO C99 does not support
1719 parameter forward declarations.
1721 @node Variadic Macros
1722 @section Macros with a Variable Number of Arguments.
1723 @cindex variable number of arguments
1724 @cindex macro with variable arguments
1725 @cindex rest argument (in macro)
1726 @cindex variadic macros
1728 In the ISO C standard of 1999, a macro can be declared to accept a
1729 variable number of arguments much as a function can. The syntax for
1730 defining the macro is similar to that of a function. Here is an
1734 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1738 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1739 such a macro, it represents the zero or more tokens until the closing
1740 parenthesis that ends the invocation, including any commas. This set of
1741 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1742 wherever it appears. See the CPP manual for more information.
1744 GCC has long supported variadic macros, and used a different syntax that
1745 allowed you to give a name to the variable arguments just like any other
1746 argument. Here is an example:
1749 #define debug(format, args...) fprintf (stderr, format, args)
1753 This is in all ways equivalent to the ISO C example above, but arguably
1754 more readable and descriptive.
1756 GNU CPP has two further variadic macro extensions, and permits them to
1757 be used with either of the above forms of macro definition.
1759 In standard C, you are not allowed to leave the variable argument out
1760 entirely; but you are allowed to pass an empty argument. For example,
1761 this invocation is invalid in ISO C, because there is no comma after
1768 GNU CPP permits you to completely omit the variable arguments in this
1769 way. In the above examples, the compiler would complain, though since
1770 the expansion of the macro still has the extra comma after the format
1773 To help solve this problem, CPP behaves specially for variable arguments
1774 used with the token paste operator, @samp{##}. If instead you write
1777 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1781 and if the variable arguments are omitted or empty, the @samp{##}
1782 operator causes the preprocessor to remove the comma before it. If you
1783 do provide some variable arguments in your macro invocation, GNU CPP
1784 does not complain about the paste operation and instead places the
1785 variable arguments after the comma. Just like any other pasted macro
1786 argument, these arguments are not macro expanded.
1788 @node Escaped Newlines
1789 @section Slightly Looser Rules for Escaped Newlines
1790 @cindex escaped newlines
1791 @cindex newlines (escaped)
1793 The preprocessor treatment of escaped newlines is more relaxed
1794 than that specified by the C90 standard, which requires the newline
1795 to immediately follow a backslash.
1796 GCC's implementation allows whitespace in the form
1797 of spaces, horizontal and vertical tabs, and form feeds between the
1798 backslash and the subsequent newline. The preprocessor issues a
1799 warning, but treats it as a valid escaped newline and combines the two
1800 lines to form a single logical line. This works within comments and
1801 tokens, as well as between tokens. Comments are @emph{not} treated as
1802 whitespace for the purposes of this relaxation, since they have not
1803 yet been replaced with spaces.
1806 @section Non-Lvalue Arrays May Have Subscripts
1807 @cindex subscripting
1808 @cindex arrays, non-lvalue
1810 @cindex subscripting and function values
1811 In ISO C99, arrays that are not lvalues still decay to pointers, and
1812 may be subscripted, although they may not be modified or used after
1813 the next sequence point and the unary @samp{&} operator may not be
1814 applied to them. As an extension, GNU C allows such arrays to be
1815 subscripted in C90 mode, though otherwise they do not decay to
1816 pointers outside C99 mode. For example,
1817 this is valid in GNU C though not valid in C90:
1821 struct foo @{int a[4];@};
1827 return f().a[index];
1833 @section Arithmetic on @code{void}- and Function-Pointers
1834 @cindex void pointers, arithmetic
1835 @cindex void, size of pointer to
1836 @cindex function pointers, arithmetic
1837 @cindex function, size of pointer to
1839 In GNU C, addition and subtraction operations are supported on pointers to
1840 @code{void} and on pointers to functions. This is done by treating the
1841 size of a @code{void} or of a function as 1.
1843 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1844 and on function types, and returns 1.
1846 @opindex Wpointer-arith
1847 The option @option{-Wpointer-arith} requests a warning if these extensions
1850 @node Pointers to Arrays
1851 @section Pointers to Arrays with Qualifiers Work as Expected
1852 @cindex pointers to arrays
1853 @cindex const qualifier
1855 In GNU C, pointers to arrays with qualifiers work similar to pointers
1856 to other qualified types. For example, a value of type @code{int (*)[5]}
1857 can be used to initialize a variable of type @code{const int (*)[5]}.
1858 These types are incompatible in ISO C because the @code{const} qualifier
1859 is formally attached to the element type of the array and not the
1864 transpose (int N, int M, double out[M][N], const double in[N][M]);
1868 transpose(3, 2, y, x);
1872 @section Non-Constant Initializers
1873 @cindex initializers, non-constant
1874 @cindex non-constant initializers
1876 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1877 automatic variable are not required to be constant expressions in GNU C@.
1878 Here is an example of an initializer with run-time varying elements:
1881 foo (float f, float g)
1883 float beat_freqs[2] = @{ f-g, f+g @};
1888 @node Compound Literals
1889 @section Compound Literals
1890 @cindex constructor expressions
1891 @cindex initializations in expressions
1892 @cindex structures, constructor expression
1893 @cindex expressions, constructor
1894 @cindex compound literals
1895 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1897 A compound literal looks like a cast of a brace-enclosed aggregate
1898 initializer list. Its value is an object of the type specified in
1899 the cast, containing the elements specified in the initializer.
1900 Unlike the result of a cast, a compound literal is an lvalue. ISO
1901 C99 and later support compound literals. As an extension, GCC
1902 supports compound literals also in C90 mode and in C++, although
1903 as explained below, the C++ semantics are somewhat different.
1905 Usually, the specified type of a compound literal is a structure. Assume
1906 that @code{struct foo} and @code{structure} are declared as shown:
1909 struct foo @{int a; char b[2];@} structure;
1913 Here is an example of constructing a @code{struct foo} with a compound literal:
1916 structure = ((struct foo) @{x + y, 'a', 0@});
1920 This is equivalent to writing the following:
1924 struct foo temp = @{x + y, 'a', 0@};
1929 You can also construct an array, though this is dangerous in C++, as
1930 explained below. If all the elements of the compound literal are
1931 (made up of) simple constant expressions suitable for use in
1932 initializers of objects of static storage duration, then the compound
1933 literal can be coerced to a pointer to its first element and used in
1934 such an initializer, as shown here:
1937 char **foo = (char *[]) @{ "x", "y", "z" @};
1940 Compound literals for scalar types and union types are also allowed. In
1941 the following example the variable @code{i} is initialized to the value
1942 @code{2}, the result of incrementing the unnamed object created by
1943 the compound literal.
1946 int i = ++(int) @{ 1 @};
1949 As a GNU extension, GCC allows initialization of objects with static storage
1950 duration by compound literals (which is not possible in ISO C99 because
1951 the initializer is not a constant).
1952 It is handled as if the object were initialized only with the brace-enclosed
1953 list if the types of the compound literal and the object match.
1954 The elements of the compound literal must be constant.
1955 If the object being initialized has array type of unknown size, the size is
1956 determined by the size of the compound literal.
1959 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1960 static int y[] = (int []) @{1, 2, 3@};
1961 static int z[] = (int [3]) @{1@};
1965 The above lines are equivalent to the following:
1967 static struct foo x = @{1, 'a', 'b'@};
1968 static int y[] = @{1, 2, 3@};
1969 static int z[] = @{1, 0, 0@};
1972 In C, a compound literal designates an unnamed object with static or
1973 automatic storage duration. In C++, a compound literal designates a
1974 temporary object that only lives until the end of its full-expression.
1975 As a result, well-defined C code that takes the address of a subobject
1976 of a compound literal can be undefined in C++, so G++ rejects
1977 the conversion of a temporary array to a pointer. For instance, if
1978 the array compound literal example above appeared inside a function,
1979 any subsequent use of @code{foo} in C++ would have undefined behavior
1980 because the lifetime of the array ends after the declaration of @code{foo}.
1982 As an optimization, G++ sometimes gives array compound literals longer
1983 lifetimes: when the array either appears outside a function or has
1984 a @code{const}-qualified type. If @code{foo} and its initializer had
1985 elements of type @code{char *const} rather than @code{char *}, or if
1986 @code{foo} were a global variable, the array would have static storage
1987 duration. But it is probably safest just to avoid the use of array
1988 compound literals in C++ code.
1990 @node Designated Inits
1991 @section Designated Initializers
1992 @cindex initializers with labeled elements
1993 @cindex labeled elements in initializers
1994 @cindex case labels in initializers
1995 @cindex designated initializers
1997 Standard C90 requires the elements of an initializer to appear in a fixed
1998 order, the same as the order of the elements in the array or structure
2001 In ISO C99 you can give the elements in any order, specifying the array
2002 indices or structure field names they apply to, and GNU C allows this as
2003 an extension in C90 mode as well. This extension is not
2004 implemented in GNU C++.
2006 To specify an array index, write
2007 @samp{[@var{index}] =} before the element value. For example,
2010 int a[6] = @{ [4] = 29, [2] = 15 @};
2017 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2021 The index values must be constant expressions, even if the array being
2022 initialized is automatic.
2024 An alternative syntax for this that has been obsolete since GCC 2.5 but
2025 GCC still accepts is to write @samp{[@var{index}]} before the element
2026 value, with no @samp{=}.
2028 To initialize a range of elements to the same value, write
2029 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
2030 extension. For example,
2033 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2037 If the value in it has side-effects, the side-effects happen only once,
2038 not for each initialized field by the range initializer.
2041 Note that the length of the array is the highest value specified
2044 In a structure initializer, specify the name of a field to initialize
2045 with @samp{.@var{fieldname} =} before the element value. For example,
2046 given the following structure,
2049 struct point @{ int x, y; @};
2053 the following initialization
2056 struct point p = @{ .y = yvalue, .x = xvalue @};
2063 struct point p = @{ xvalue, yvalue @};
2066 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2067 @samp{@var{fieldname}:}, as shown here:
2070 struct point p = @{ y: yvalue, x: xvalue @};
2073 Omitted field members are implicitly initialized the same as objects
2074 that have static storage duration.
2077 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2078 @dfn{designator}. You can also use a designator (or the obsolete colon
2079 syntax) when initializing a union, to specify which element of the union
2080 should be used. For example,
2083 union foo @{ int i; double d; @};
2085 union foo f = @{ .d = 4 @};
2089 converts 4 to a @code{double} to store it in the union using
2090 the second element. By contrast, casting 4 to type @code{union foo}
2091 stores it into the union as the integer @code{i}, since it is
2092 an integer. @xref{Cast to Union}.
2094 You can combine this technique of naming elements with ordinary C
2095 initialization of successive elements. Each initializer element that
2096 does not have a designator applies to the next consecutive element of the
2097 array or structure. For example,
2100 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2107 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2110 Labeling the elements of an array initializer is especially useful
2111 when the indices are characters or belong to an @code{enum} type.
2116 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2117 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2120 @cindex designator lists
2121 You can also write a series of @samp{.@var{fieldname}} and
2122 @samp{[@var{index}]} designators before an @samp{=} to specify a
2123 nested subobject to initialize; the list is taken relative to the
2124 subobject corresponding to the closest surrounding brace pair. For
2125 example, with the @samp{struct point} declaration above:
2128 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2132 If the same field is initialized multiple times, it has the value from
2133 the last initialization. If any such overridden initialization has
2134 side-effect, it is unspecified whether the side-effect happens or not.
2135 Currently, GCC discards them and issues a warning.
2138 @section Case Ranges
2140 @cindex ranges in case statements
2142 You can specify a range of consecutive values in a single @code{case} label,
2146 case @var{low} ... @var{high}:
2150 This has the same effect as the proper number of individual @code{case}
2151 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2153 This feature is especially useful for ranges of ASCII character codes:
2159 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2160 it may be parsed wrong when you use it with integer values. For example,
2175 @section Cast to a Union Type
2176 @cindex cast to a union
2177 @cindex union, casting to a
2179 A cast to union type looks similar to other casts, except that the type
2180 specified is a union type. You can specify the type either with the
2181 @code{union} keyword or with a @code{typedef} name that refers to
2182 a union. A cast to a union actually creates a compound literal and
2183 yields an lvalue, not an rvalue like true casts do.
2184 @xref{Compound Literals}.
2186 The types that may be cast to the union type are those of the members
2187 of the union. Thus, given the following union and variables:
2190 union foo @{ int i; double d; @};
2196 both @code{x} and @code{y} can be cast to type @code{union foo}.
2198 Using the cast as the right-hand side of an assignment to a variable of
2199 union type is equivalent to storing in a member of the union:
2204 u = (union foo) x @equiv{} u.i = x
2205 u = (union foo) y @equiv{} u.d = y
2208 You can also use the union cast as a function argument:
2211 void hack (union foo);
2213 hack ((union foo) x);
2216 @node Mixed Declarations
2217 @section Mixed Declarations and Code
2218 @cindex mixed declarations and code
2219 @cindex declarations, mixed with code
2220 @cindex code, mixed with declarations
2222 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2223 within compound statements. As an extension, GNU C also allows this in
2224 C90 mode. For example, you could do:
2233 Each identifier is visible from where it is declared until the end of
2234 the enclosing block.
2236 @node Function Attributes
2237 @section Declaring Attributes of Functions
2238 @cindex function attributes
2239 @cindex declaring attributes of functions
2240 @cindex @code{volatile} applied to function
2241 @cindex @code{const} applied to function
2243 In GNU C, you can use function attributes to declare certain things
2244 about functions called in your program which help the compiler
2245 optimize calls and check your code more carefully. For example, you
2246 can use attributes to declare that a function never returns
2247 (@code{noreturn}), returns a value depending only on its arguments
2248 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2250 You can also use attributes to control memory placement, code
2251 generation options or call/return conventions within the function
2252 being annotated. Many of these attributes are target-specific. For
2253 example, many targets support attributes for defining interrupt
2254 handler functions, which typically must follow special register usage
2255 and return conventions.
2257 Function attributes are introduced by the @code{__attribute__} keyword
2258 on a declaration, followed by an attribute specification inside double
2259 parentheses. You can specify multiple attributes in a declaration by
2260 separating them by commas within the double parentheses or by
2261 immediately following an attribute declaration with another attribute
2262 declaration. @xref{Attribute Syntax}, for the exact rules on
2263 attribute syntax and placement.
2265 GCC also supports attributes on
2266 variable declarations (@pxref{Variable Attributes}),
2267 labels (@pxref{Label Attributes}),
2268 enumerators (@pxref{Enumerator Attributes}),
2269 statements (@pxref{Statement Attributes}),
2270 and types (@pxref{Type Attributes}).
2272 There is some overlap between the purposes of attributes and pragmas
2273 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2274 found convenient to use @code{__attribute__} to achieve a natural
2275 attachment of attributes to their corresponding declarations, whereas
2276 @code{#pragma} is of use for compatibility with other compilers
2277 or constructs that do not naturally form part of the grammar.
2279 In addition to the attributes documented here,
2280 GCC plugins may provide their own attributes.
2283 * Common Function Attributes::
2284 * AArch64 Function Attributes::
2285 * ARC Function Attributes::
2286 * ARM Function Attributes::
2287 * AVR Function Attributes::
2288 * Blackfin Function Attributes::
2289 * CR16 Function Attributes::
2290 * Epiphany Function Attributes::
2291 * H8/300 Function Attributes::
2292 * IA-64 Function Attributes::
2293 * M32C Function Attributes::
2294 * M32R/D Function Attributes::
2295 * m68k Function Attributes::
2296 * MCORE Function Attributes::
2297 * MeP Function Attributes::
2298 * MicroBlaze Function Attributes::
2299 * Microsoft Windows Function Attributes::
2300 * MIPS Function Attributes::
2301 * MSP430 Function Attributes::
2302 * NDS32 Function Attributes::
2303 * Nios II Function Attributes::
2304 * Nvidia PTX Function Attributes::
2305 * PowerPC Function Attributes::
2306 * RL78 Function Attributes::
2307 * RX Function Attributes::
2308 * S/390 Function Attributes::
2309 * SH Function Attributes::
2310 * SPU Function Attributes::
2311 * Symbian OS Function Attributes::
2312 * V850 Function Attributes::
2313 * Visium Function Attributes::
2314 * x86 Function Attributes::
2315 * Xstormy16 Function Attributes::
2318 @node Common Function Attributes
2319 @subsection Common Function Attributes
2321 The following attributes are supported on most targets.
2324 @c Keep this table alphabetized by attribute name. Treat _ as space.
2326 @item alias ("@var{target}")
2327 @cindex @code{alias} function attribute
2328 The @code{alias} attribute causes the declaration to be emitted as an
2329 alias for another symbol, which must be specified. For instance,
2332 void __f () @{ /* @r{Do something.} */; @}
2333 void f () __attribute__ ((weak, alias ("__f")));
2337 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2338 mangled name for the target must be used. It is an error if @samp{__f}
2339 is not defined in the same translation unit.
2341 This attribute requires assembler and object file support,
2342 and may not be available on all targets.
2344 @item aligned (@var{alignment})
2345 @cindex @code{aligned} function attribute
2346 This attribute specifies a minimum alignment for the function,
2349 You cannot use this attribute to decrease the alignment of a function,
2350 only to increase it. However, when you explicitly specify a function
2351 alignment this overrides the effect of the
2352 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2355 Note that the effectiveness of @code{aligned} attributes may be
2356 limited by inherent limitations in your linker. On many systems, the
2357 linker is only able to arrange for functions to be aligned up to a
2358 certain maximum alignment. (For some linkers, the maximum supported
2359 alignment may be very very small.) See your linker documentation for
2360 further information.
2362 The @code{aligned} attribute can also be used for variables and fields
2363 (@pxref{Variable Attributes}.)
2366 @cindex @code{alloc_align} function attribute
2367 The @code{alloc_align} attribute is used to tell the compiler that the
2368 function return value points to memory, where the returned pointer minimum
2369 alignment is given by one of the functions parameters. GCC uses this
2370 information to improve pointer alignment analysis.
2372 The function parameter denoting the allocated alignment is specified by
2373 one integer argument, whose number is the argument of the attribute.
2374 Argument numbering starts at one.
2379 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2383 declares that @code{my_memalign} returns memory with minimum alignment
2384 given by parameter 1.
2387 @cindex @code{alloc_size} function attribute
2388 The @code{alloc_size} attribute is used to tell the compiler that the
2389 function return value points to memory, where the size is given by
2390 one or two of the functions parameters. GCC uses this
2391 information to improve the correctness of @code{__builtin_object_size}.
2393 The function parameter(s) denoting the allocated size are specified by
2394 one or two integer arguments supplied to the attribute. The allocated size
2395 is either the value of the single function argument specified or the product
2396 of the two function arguments specified. Argument numbering starts at
2402 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2403 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2407 declares that @code{my_calloc} returns memory of the size given by
2408 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2409 of the size given by parameter 2.
2412 @cindex @code{always_inline} function attribute
2413 Generally, functions are not inlined unless optimization is specified.
2414 For functions declared inline, this attribute inlines the function
2415 independent of any restrictions that otherwise apply to inlining.
2416 Failure to inline such a function is diagnosed as an error.
2417 Note that if such a function is called indirectly the compiler may
2418 or may not inline it depending on optimization level and a failure
2419 to inline an indirect call may or may not be diagnosed.
2422 @cindex @code{artificial} function attribute
2423 This attribute is useful for small inline wrappers that if possible
2424 should appear during debugging as a unit. Depending on the debug
2425 info format it either means marking the function as artificial
2426 or using the caller location for all instructions within the inlined
2429 @item assume_aligned
2430 @cindex @code{assume_aligned} function attribute
2431 The @code{assume_aligned} attribute is used to tell the compiler that the
2432 function return value points to memory, where the returned pointer minimum
2433 alignment is given by the first argument.
2434 If the attribute has two arguments, the second argument is misalignment offset.
2439 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2440 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2444 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2445 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2448 @item bnd_instrument
2449 @cindex @code{bnd_instrument} function attribute
2450 The @code{bnd_instrument} attribute on functions is used to inform the
2451 compiler that the function should be instrumented when compiled
2452 with the @option{-fchkp-instrument-marked-only} option.
2455 @cindex @code{bnd_legacy} function attribute
2456 @cindex Pointer Bounds Checker attributes
2457 The @code{bnd_legacy} attribute on functions is used to inform the
2458 compiler that the function should not be instrumented when compiled
2459 with the @option{-fcheck-pointer-bounds} option.
2462 @cindex @code{cold} function attribute
2463 The @code{cold} attribute on functions is used to inform the compiler that
2464 the function is unlikely to be executed. The function is optimized for
2465 size rather than speed and on many targets it is placed into a special
2466 subsection of the text section so all cold functions appear close together,
2467 improving code locality of non-cold parts of program. The paths leading
2468 to calls of cold functions within code are marked as unlikely by the branch
2469 prediction mechanism. It is thus useful to mark functions used to handle
2470 unlikely conditions, such as @code{perror}, as cold to improve optimization
2471 of hot functions that do call marked functions in rare occasions.
2473 When profile feedback is available, via @option{-fprofile-use}, cold functions
2474 are automatically detected and this attribute is ignored.
2477 @cindex @code{const} function attribute
2478 @cindex functions that have no side effects
2479 Many functions do not examine any values except their arguments, and
2480 have no effects except the return value. Basically this is just slightly
2481 more strict class than the @code{pure} attribute below, since function is not
2482 allowed to read global memory.
2484 @cindex pointer arguments
2485 Note that a function that has pointer arguments and examines the data
2486 pointed to must @emph{not} be declared @code{const}. Likewise, a
2487 function that calls a non-@code{const} function usually must not be
2488 @code{const}. It does not make sense for a @code{const} function to
2493 @itemx constructor (@var{priority})
2494 @itemx destructor (@var{priority})
2495 @cindex @code{constructor} function attribute
2496 @cindex @code{destructor} function attribute
2497 The @code{constructor} attribute causes the function to be called
2498 automatically before execution enters @code{main ()}. Similarly, the
2499 @code{destructor} attribute causes the function to be called
2500 automatically after @code{main ()} completes or @code{exit ()} is
2501 called. Functions with these attributes are useful for
2502 initializing data that is used implicitly during the execution of
2505 You may provide an optional integer priority to control the order in
2506 which constructor and destructor functions are run. A constructor
2507 with a smaller priority number runs before a constructor with a larger
2508 priority number; the opposite relationship holds for destructors. So,
2509 if you have a constructor that allocates a resource and a destructor
2510 that deallocates the same resource, both functions typically have the
2511 same priority. The priorities for constructor and destructor
2512 functions are the same as those specified for namespace-scope C++
2513 objects (@pxref{C++ Attributes}).
2516 @itemx deprecated (@var{msg})
2517 @cindex @code{deprecated} function attribute
2518 The @code{deprecated} attribute results in a warning if the function
2519 is used anywhere in the source file. This is useful when identifying
2520 functions that are expected to be removed in a future version of a
2521 program. The warning also includes the location of the declaration
2522 of the deprecated function, to enable users to easily find further
2523 information about why the function is deprecated, or what they should
2524 do instead. Note that the warnings only occurs for uses:
2527 int old_fn () __attribute__ ((deprecated));
2529 int (*fn_ptr)() = old_fn;
2533 results in a warning on line 3 but not line 2. The optional @var{msg}
2534 argument, which must be a string, is printed in the warning if
2537 The @code{deprecated} attribute can also be used for variables and
2538 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2540 @item error ("@var{message}")
2541 @itemx warning ("@var{message}")
2542 @cindex @code{error} function attribute
2543 @cindex @code{warning} function attribute
2544 If the @code{error} or @code{warning} attribute
2545 is used on a function declaration and a call to such a function
2546 is not eliminated through dead code elimination or other optimizations,
2547 an error or warning (respectively) that includes @var{message} is diagnosed.
2549 for compile-time checking, especially together with @code{__builtin_constant_p}
2550 and inline functions where checking the inline function arguments is not
2551 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2553 While it is possible to leave the function undefined and thus invoke
2554 a link failure (to define the function with
2555 a message in @code{.gnu.warning*} section),
2556 when using these attributes the problem is diagnosed
2557 earlier and with exact location of the call even in presence of inline
2558 functions or when not emitting debugging information.
2560 @item externally_visible
2561 @cindex @code{externally_visible} function attribute
2562 This attribute, attached to a global variable or function, nullifies
2563 the effect of the @option{-fwhole-program} command-line option, so the
2564 object remains visible outside the current compilation unit.
2566 If @option{-fwhole-program} is used together with @option{-flto} and
2567 @command{gold} is used as the linker plugin,
2568 @code{externally_visible} attributes are automatically added to functions
2569 (not variable yet due to a current @command{gold} issue)
2570 that are accessed outside of LTO objects according to resolution file
2571 produced by @command{gold}.
2572 For other linkers that cannot generate resolution file,
2573 explicit @code{externally_visible} attributes are still necessary.
2576 @cindex @code{flatten} function attribute
2577 Generally, inlining into a function is limited. For a function marked with
2578 this attribute, every call inside this function is inlined, if possible.
2579 Whether the function itself is considered for inlining depends on its size and
2580 the current inlining parameters.
2582 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2583 @cindex @code{format} function attribute
2584 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2586 The @code{format} attribute specifies that a function takes @code{printf},
2587 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2588 should be type-checked against a format string. For example, the
2593 my_printf (void *my_object, const char *my_format, ...)
2594 __attribute__ ((format (printf, 2, 3)));
2598 causes the compiler to check the arguments in calls to @code{my_printf}
2599 for consistency with the @code{printf} style format string argument
2602 The parameter @var{archetype} determines how the format string is
2603 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2604 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2605 @code{strfmon}. (You can also use @code{__printf__},
2606 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2607 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2608 @code{ms_strftime} are also present.
2609 @var{archetype} values such as @code{printf} refer to the formats accepted
2610 by the system's C runtime library,
2611 while values prefixed with @samp{gnu_} always refer
2612 to the formats accepted by the GNU C Library. On Microsoft Windows
2613 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2614 @file{msvcrt.dll} library.
2615 The parameter @var{string-index}
2616 specifies which argument is the format string argument (starting
2617 from 1), while @var{first-to-check} is the number of the first
2618 argument to check against the format string. For functions
2619 where the arguments are not available to be checked (such as
2620 @code{vprintf}), specify the third parameter as zero. In this case the
2621 compiler only checks the format string for consistency. For
2622 @code{strftime} formats, the third parameter is required to be zero.
2623 Since non-static C++ methods have an implicit @code{this} argument, the
2624 arguments of such methods should be counted from two, not one, when
2625 giving values for @var{string-index} and @var{first-to-check}.
2627 In the example above, the format string (@code{my_format}) is the second
2628 argument of the function @code{my_print}, and the arguments to check
2629 start with the third argument, so the correct parameters for the format
2630 attribute are 2 and 3.
2632 @opindex ffreestanding
2633 @opindex fno-builtin
2634 The @code{format} attribute allows you to identify your own functions
2635 that take format strings as arguments, so that GCC can check the
2636 calls to these functions for errors. The compiler always (unless
2637 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2638 for the standard library functions @code{printf}, @code{fprintf},
2639 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2640 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2641 warnings are requested (using @option{-Wformat}), so there is no need to
2642 modify the header file @file{stdio.h}. In C99 mode, the functions
2643 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2644 @code{vsscanf} are also checked. Except in strictly conforming C
2645 standard modes, the X/Open function @code{strfmon} is also checked as
2646 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2647 @xref{C Dialect Options,,Options Controlling C Dialect}.
2649 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2650 recognized in the same context. Declarations including these format attributes
2651 are parsed for correct syntax, however the result of checking of such format
2652 strings is not yet defined, and is not carried out by this version of the
2655 The target may also provide additional types of format checks.
2656 @xref{Target Format Checks,,Format Checks Specific to Particular
2659 @item format_arg (@var{string-index})
2660 @cindex @code{format_arg} function attribute
2661 @opindex Wformat-nonliteral
2662 The @code{format_arg} attribute specifies that a function takes a format
2663 string for a @code{printf}, @code{scanf}, @code{strftime} or
2664 @code{strfmon} style function and modifies it (for example, to translate
2665 it into another language), so the result can be passed to a
2666 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2667 function (with the remaining arguments to the format function the same
2668 as they would have been for the unmodified string). For example, the
2673 my_dgettext (char *my_domain, const char *my_format)
2674 __attribute__ ((format_arg (2)));
2678 causes the compiler to check the arguments in calls to a @code{printf},
2679 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2680 format string argument is a call to the @code{my_dgettext} function, for
2681 consistency with the format string argument @code{my_format}. If the
2682 @code{format_arg} attribute had not been specified, all the compiler
2683 could tell in such calls to format functions would be that the format
2684 string argument is not constant; this would generate a warning when
2685 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2686 without the attribute.
2688 The parameter @var{string-index} specifies which argument is the format
2689 string argument (starting from one). Since non-static C++ methods have
2690 an implicit @code{this} argument, the arguments of such methods should
2691 be counted from two.
2693 The @code{format_arg} attribute allows you to identify your own
2694 functions that modify format strings, so that GCC can check the
2695 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2696 type function whose operands are a call to one of your own function.
2697 The compiler always treats @code{gettext}, @code{dgettext}, and
2698 @code{dcgettext} in this manner except when strict ISO C support is
2699 requested by @option{-ansi} or an appropriate @option{-std} option, or
2700 @option{-ffreestanding} or @option{-fno-builtin}
2701 is used. @xref{C Dialect Options,,Options
2702 Controlling C Dialect}.
2704 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2705 @code{NSString} reference for compatibility with the @code{format} attribute
2708 The target may also allow additional types in @code{format-arg} attributes.
2709 @xref{Target Format Checks,,Format Checks Specific to Particular
2713 @cindex @code{gnu_inline} function attribute
2714 This attribute should be used with a function that is also declared
2715 with the @code{inline} keyword. It directs GCC to treat the function
2716 as if it were defined in gnu90 mode even when compiling in C99 or
2719 If the function is declared @code{extern}, then this definition of the
2720 function is used only for inlining. In no case is the function
2721 compiled as a standalone function, not even if you take its address
2722 explicitly. Such an address becomes an external reference, as if you
2723 had only declared the function, and had not defined it. This has
2724 almost the effect of a macro. The way to use this is to put a
2725 function definition in a header file with this attribute, and put
2726 another copy of the function, without @code{extern}, in a library
2727 file. The definition in the header file causes most calls to the
2728 function to be inlined. If any uses of the function remain, they
2729 refer to the single copy in the library. Note that the two
2730 definitions of the functions need not be precisely the same, although
2731 if they do not have the same effect your program may behave oddly.
2733 In C, if the function is neither @code{extern} nor @code{static}, then
2734 the function is compiled as a standalone function, as well as being
2735 inlined where possible.
2737 This is how GCC traditionally handled functions declared
2738 @code{inline}. Since ISO C99 specifies a different semantics for
2739 @code{inline}, this function attribute is provided as a transition
2740 measure and as a useful feature in its own right. This attribute is
2741 available in GCC 4.1.3 and later. It is available if either of the
2742 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2743 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2744 Function is As Fast As a Macro}.
2746 In C++, this attribute does not depend on @code{extern} in any way,
2747 but it still requires the @code{inline} keyword to enable its special
2751 @cindex @code{hot} function attribute
2752 The @code{hot} attribute on a function is used to inform the compiler that
2753 the function is a hot spot of the compiled program. The function is
2754 optimized more aggressively and on many targets it is placed into a special
2755 subsection of the text section so all hot functions appear close together,
2758 When profile feedback is available, via @option{-fprofile-use}, hot functions
2759 are automatically detected and this attribute is ignored.
2761 @item ifunc ("@var{resolver}")
2762 @cindex @code{ifunc} function attribute
2763 @cindex indirect functions
2764 @cindex functions that are dynamically resolved
2765 The @code{ifunc} attribute is used to mark a function as an indirect
2766 function using the STT_GNU_IFUNC symbol type extension to the ELF
2767 standard. This allows the resolution of the symbol value to be
2768 determined dynamically at load time, and an optimized version of the
2769 routine can be selected for the particular processor or other system
2770 characteristics determined then. To use this attribute, first define
2771 the implementation functions available, and a resolver function that
2772 returns a pointer to the selected implementation function. The
2773 implementation functions' declarations must match the API of the
2774 function being implemented, the resolver's declaration is be a
2775 function returning pointer to void function returning void:
2778 void *my_memcpy (void *dst, const void *src, size_t len)
2783 static void (*resolve_memcpy (void)) (void)
2785 return my_memcpy; // we'll just always select this routine
2790 The exported header file declaring the function the user calls would
2794 extern void *memcpy (void *, const void *, size_t);
2798 allowing the user to call this as a regular function, unaware of the
2799 implementation. Finally, the indirect function needs to be defined in
2800 the same translation unit as the resolver function:
2803 void *memcpy (void *, const void *, size_t)
2804 __attribute__ ((ifunc ("resolve_memcpy")));
2807 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
2808 and GNU C Library version 2.11.1 are required to use this feature.
2811 @itemx interrupt_handler
2812 Many GCC back ends support attributes to indicate that a function is
2813 an interrupt handler, which tells the compiler to generate function
2814 entry and exit sequences that differ from those from regular
2815 functions. The exact syntax and behavior are target-specific;
2816 refer to the following subsections for details.
2819 @cindex @code{leaf} function attribute
2820 Calls to external functions with this attribute must return to the
2821 current compilation unit only by return or by exception handling. In
2822 particular, a leaf function is not allowed to invoke callback functions
2823 passed to it from the current compilation unit, directly call functions
2824 exported by the unit, or @code{longjmp} into the unit. Leaf functions
2825 might still call functions from other compilation units and thus they
2826 are not necessarily leaf in the sense that they contain no function
2829 The attribute is intended for library functions to improve dataflow
2830 analysis. The compiler takes the hint that any data not escaping the
2831 current compilation unit cannot be used or modified by the leaf
2832 function. For example, the @code{sin} function is a leaf function, but
2833 @code{qsort} is not.
2835 Note that leaf functions might indirectly run a signal handler defined
2836 in the current compilation unit that uses static variables. Similarly,
2837 when lazy symbol resolution is in effect, leaf functions might invoke
2838 indirect functions whose resolver function or implementation function is
2839 defined in the current compilation unit and uses static variables. There
2840 is no standard-compliant way to write such a signal handler, resolver
2841 function, or implementation function, and the best that you can do is to
2842 remove the @code{leaf} attribute or mark all such static variables
2843 @code{volatile}. Lastly, for ELF-based systems that support symbol
2844 interposition, care should be taken that functions defined in the
2845 current compilation unit do not unexpectedly interpose other symbols
2846 based on the defined standards mode and defined feature test macros;
2847 otherwise an inadvertent callback would be added.
2849 The attribute has no effect on functions defined within the current
2850 compilation unit. This is to allow easy merging of multiple compilation
2851 units into one, for example, by using the link-time optimization. For
2852 this reason the attribute is not allowed on types to annotate indirect
2856 @cindex @code{malloc} function attribute
2857 @cindex functions that behave like malloc
2858 This tells the compiler that a function is @code{malloc}-like, i.e.,
2859 that the pointer @var{P} returned by the function cannot alias any
2860 other pointer valid when the function returns, and moreover no
2861 pointers to valid objects occur in any storage addressed by @var{P}.
2863 Using this attribute can improve optimization. Functions like
2864 @code{malloc} and @code{calloc} have this property because they return
2865 a pointer to uninitialized or zeroed-out storage. However, functions
2866 like @code{realloc} do not have this property, as they can return a
2867 pointer to storage containing pointers.
2870 @cindex @code{no_icf} function attribute
2871 This function attribute prevents a functions from being merged with another
2872 semantically equivalent function.
2874 @item no_instrument_function
2875 @cindex @code{no_instrument_function} function attribute
2876 @opindex finstrument-functions
2877 If @option{-finstrument-functions} is given, profiling function calls are
2878 generated at entry and exit of most user-compiled functions.
2879 Functions with this attribute are not so instrumented.
2881 @item no_profile_instrument_function
2882 @cindex @code{no_profile_instrument_function} function attribute
2883 The @code{no_profile_instrument_function} attribute on functions is used
2884 to inform the compiler that it should not process any profile feedback based
2885 optimization code instrumentation.
2888 @cindex @code{no_reorder} function attribute
2889 Do not reorder functions or variables marked @code{no_reorder}
2890 against each other or top level assembler statements the executable.
2891 The actual order in the program will depend on the linker command
2892 line. Static variables marked like this are also not removed.
2893 This has a similar effect
2894 as the @option{-fno-toplevel-reorder} option, but only applies to the
2897 @item no_sanitize_address
2898 @itemx no_address_safety_analysis
2899 @cindex @code{no_sanitize_address} function attribute
2900 The @code{no_sanitize_address} attribute on functions is used
2901 to inform the compiler that it should not instrument memory accesses
2902 in the function when compiling with the @option{-fsanitize=address} option.
2903 The @code{no_address_safety_analysis} is a deprecated alias of the
2904 @code{no_sanitize_address} attribute, new code should use
2905 @code{no_sanitize_address}.
2907 @item no_sanitize_thread
2908 @cindex @code{no_sanitize_thread} function attribute
2909 The @code{no_sanitize_thread} attribute on functions is used
2910 to inform the compiler that it should not instrument memory accesses
2911 in the function when compiling with the @option{-fsanitize=thread} option.
2913 @item no_sanitize_undefined
2914 @cindex @code{no_sanitize_undefined} function attribute
2915 The @code{no_sanitize_undefined} attribute on functions is used
2916 to inform the compiler that it should not check for undefined behavior
2917 in the function when compiling with the @option{-fsanitize=undefined} option.
2919 @item no_split_stack
2920 @cindex @code{no_split_stack} function attribute
2921 @opindex fsplit-stack
2922 If @option{-fsplit-stack} is given, functions have a small
2923 prologue which decides whether to split the stack. Functions with the
2924 @code{no_split_stack} attribute do not have that prologue, and thus
2925 may run with only a small amount of stack space available.
2927 @item no_stack_limit
2928 @cindex @code{no_stack_limit} function attribute
2929 This attribute locally overrides the @option{-fstack-limit-register}
2930 and @option{-fstack-limit-symbol} command-line options; it has the effect
2931 of disabling stack limit checking in the function it applies to.
2934 @cindex @code{noclone} function attribute
2935 This function attribute prevents a function from being considered for
2936 cloning---a mechanism that produces specialized copies of functions
2937 and which is (currently) performed by interprocedural constant
2941 @cindex @code{noinline} function attribute
2942 This function attribute prevents a function from being considered for
2944 @c Don't enumerate the optimizations by name here; we try to be
2945 @c future-compatible with this mechanism.
2946 If the function does not have side-effects, there are optimizations
2947 other than inlining that cause function calls to be optimized away,
2948 although the function call is live. To keep such calls from being
2955 (@pxref{Extended Asm}) in the called function, to serve as a special
2958 @item nonnull (@var{arg-index}, @dots{})
2959 @cindex @code{nonnull} function attribute
2960 @cindex functions with non-null pointer arguments
2961 The @code{nonnull} attribute specifies that some function parameters should
2962 be non-null pointers. For instance, the declaration:
2966 my_memcpy (void *dest, const void *src, size_t len)
2967 __attribute__((nonnull (1, 2)));
2971 causes the compiler to check that, in calls to @code{my_memcpy},
2972 arguments @var{dest} and @var{src} are non-null. If the compiler
2973 determines that a null pointer is passed in an argument slot marked
2974 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2975 is issued. The compiler may also choose to make optimizations based
2976 on the knowledge that certain function arguments will never be null.
2978 If no argument index list is given to the @code{nonnull} attribute,
2979 all pointer arguments are marked as non-null. To illustrate, the
2980 following declaration is equivalent to the previous example:
2984 my_memcpy (void *dest, const void *src, size_t len)
2985 __attribute__((nonnull));
2989 @cindex @code{noplt} function attribute
2990 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
2991 Calls to functions marked with this attribute in position-independent code
2996 /* Externally defined function foo. */
2997 int foo () __attribute__ ((noplt));
3000 main (/* @r{@dots{}} */)
3009 The @code{noplt} attribute on function @code{foo}
3010 tells the compiler to assume that
3011 the function @code{foo} is externally defined and that the call to
3012 @code{foo} must avoid the PLT
3013 in position-independent code.
3015 In position-dependent code, a few targets also convert calls to
3016 functions that are marked to not use the PLT to use the GOT instead.
3019 @cindex @code{noreturn} function attribute
3020 @cindex functions that never return
3021 A few standard library functions, such as @code{abort} and @code{exit},
3022 cannot return. GCC knows this automatically. Some programs define
3023 their own functions that never return. You can declare them
3024 @code{noreturn} to tell the compiler this fact. For example,
3028 void fatal () __attribute__ ((noreturn));
3031 fatal (/* @r{@dots{}} */)
3033 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3039 The @code{noreturn} keyword tells the compiler to assume that
3040 @code{fatal} cannot return. It can then optimize without regard to what
3041 would happen if @code{fatal} ever did return. This makes slightly
3042 better code. More importantly, it helps avoid spurious warnings of
3043 uninitialized variables.
3045 The @code{noreturn} keyword does not affect the exceptional path when that
3046 applies: a @code{noreturn}-marked function may still return to the caller
3047 by throwing an exception or calling @code{longjmp}.
3049 Do not assume that registers saved by the calling function are
3050 restored before calling the @code{noreturn} function.
3052 It does not make sense for a @code{noreturn} function to have a return
3053 type other than @code{void}.
3056 @cindex @code{nothrow} function attribute
3057 The @code{nothrow} attribute is used to inform the compiler that a
3058 function cannot throw an exception. For example, most functions in
3059 the standard C library can be guaranteed not to throw an exception
3060 with the notable exceptions of @code{qsort} and @code{bsearch} that
3061 take function pointer arguments.
3064 @cindex @code{optimize} function attribute
3065 The @code{optimize} attribute is used to specify that a function is to
3066 be compiled with different optimization options than specified on the
3067 command line. Arguments can either be numbers or strings. Numbers
3068 are assumed to be an optimization level. Strings that begin with
3069 @code{O} are assumed to be an optimization option, while other options
3070 are assumed to be used with a @code{-f} prefix. You can also use the
3071 @samp{#pragma GCC optimize} pragma to set the optimization options
3072 that affect more than one function.
3073 @xref{Function Specific Option Pragmas}, for details about the
3074 @samp{#pragma GCC optimize} pragma.
3076 This attribute should be used for debugging purposes only. It is not
3077 suitable in production code.
3080 @cindex @code{pure} function attribute
3081 @cindex functions that have no side effects
3082 Many functions have no effects except the return value and their
3083 return value depends only on the parameters and/or global variables.
3084 Such a function can be subject
3085 to common subexpression elimination and loop optimization just as an
3086 arithmetic operator would be. These functions should be declared
3087 with the attribute @code{pure}. For example,
3090 int square (int) __attribute__ ((pure));
3094 says that the hypothetical function @code{square} is safe to call
3095 fewer times than the program says.
3097 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3098 Interesting non-pure functions are functions with infinite loops or those
3099 depending on volatile memory or other system resource, that may change between
3100 two consecutive calls (such as @code{feof} in a multithreading environment).
3102 @item returns_nonnull
3103 @cindex @code{returns_nonnull} function attribute
3104 The @code{returns_nonnull} attribute specifies that the function
3105 return value should be a non-null pointer. For instance, the declaration:
3109 mymalloc (size_t len) __attribute__((returns_nonnull));
3113 lets the compiler optimize callers based on the knowledge
3114 that the return value will never be null.
3117 @cindex @code{returns_twice} function attribute
3118 @cindex functions that return more than once
3119 The @code{returns_twice} attribute tells the compiler that a function may
3120 return more than one time. The compiler ensures that all registers
3121 are dead before calling such a function and emits a warning about
3122 the variables that may be clobbered after the second return from the
3123 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3124 The @code{longjmp}-like counterpart of such function, if any, might need
3125 to be marked with the @code{noreturn} attribute.
3127 @item section ("@var{section-name}")
3128 @cindex @code{section} function attribute
3129 @cindex functions in arbitrary sections
3130 Normally, the compiler places the code it generates in the @code{text} section.
3131 Sometimes, however, you need additional sections, or you need certain
3132 particular functions to appear in special sections. The @code{section}
3133 attribute specifies that a function lives in a particular section.
3134 For example, the declaration:
3137 extern void foobar (void) __attribute__ ((section ("bar")));
3141 puts the function @code{foobar} in the @code{bar} section.
3143 Some file formats do not support arbitrary sections so the @code{section}
3144 attribute is not available on all platforms.
3145 If you need to map the entire contents of a module to a particular
3146 section, consider using the facilities of the linker instead.
3149 @cindex @code{sentinel} function attribute
3150 This function attribute ensures that a parameter in a function call is
3151 an explicit @code{NULL}. The attribute is only valid on variadic
3152 functions. By default, the sentinel is located at position zero, the
3153 last parameter of the function call. If an optional integer position
3154 argument P is supplied to the attribute, the sentinel must be located at
3155 position P counting backwards from the end of the argument list.
3158 __attribute__ ((sentinel))
3160 __attribute__ ((sentinel(0)))
3163 The attribute is automatically set with a position of 0 for the built-in
3164 functions @code{execl} and @code{execlp}. The built-in function
3165 @code{execle} has the attribute set with a position of 1.
3167 A valid @code{NULL} in this context is defined as zero with any pointer
3168 type. If your system defines the @code{NULL} macro with an integer type
3169 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3170 with a copy that redefines NULL appropriately.
3172 The warnings for missing or incorrect sentinels are enabled with
3176 @itemx simd("@var{mask}")
3177 @cindex @code{simd} function attribute
3178 This attribute enables creation of one or more function versions that
3179 can process multiple arguments using SIMD instructions from a
3180 single invocation. Specifying this attribute allows compiler to
3181 assume that such versions are available at link time (provided
3182 in the same or another translation unit). Generated versions are
3183 target-dependent and described in the corresponding Vector ABI document. For
3184 x86_64 target this document can be found
3185 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3187 The optional argument @var{mask} may have the value
3188 @code{notinbranch} or @code{inbranch},
3189 and instructs the compiler to generate non-masked or masked
3190 clones correspondingly. By default, all clones are generated.
3192 The attribute should not be used together with Cilk Plus @code{vector}
3193 attribute on the same function.
3195 If the attribute is specified and @code{#pragma omp declare simd} is
3196 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3197 switch is specified, then the attribute is ignored.
3200 @cindex @code{stack_protect} function attribute
3201 This attribute adds stack protection code to the function if
3202 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3203 or @option{-fstack-protector-explicit} are set.
3205 @item target (@var{options})
3206 @cindex @code{target} function attribute
3207 Multiple target back ends implement the @code{target} attribute
3208 to specify that a function is to
3209 be compiled with different target options than specified on the
3210 command line. This can be used for instance to have functions
3211 compiled with a different ISA (instruction set architecture) than the
3212 default. You can also use the @samp{#pragma GCC target} pragma to set
3213 more than one function to be compiled with specific target options.
3214 @xref{Function Specific Option Pragmas}, for details about the
3215 @samp{#pragma GCC target} pragma.
3217 For instance, on an x86, you could declare one function with the
3218 @code{target("sse4.1,arch=core2")} attribute and another with
3219 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3220 compiling the first function with @option{-msse4.1} and
3221 @option{-march=core2} options, and the second function with
3222 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3223 to make sure that a function is only invoked on a machine that
3224 supports the particular ISA it is compiled for (for example by using
3225 @code{cpuid} on x86 to determine what feature bits and architecture
3229 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3230 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3233 You can either use multiple
3234 strings separated by commas to specify multiple options,
3235 or separate the options with a comma (@samp{,}) within a single string.
3237 The options supported are specific to each target; refer to @ref{x86
3238 Function Attributes}, @ref{PowerPC Function Attributes},
3239 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3242 @item target_clones (@var{options})
3243 @cindex @code{target_clones} function attribute
3244 The @code{target_clones} attribute is used to specify that a function
3245 be cloned into multiple versions compiled with different target options
3246 than specified on the command line. The supported options and restrictions
3247 are the same as for @code{target} attribute.
3249 For instance, on an x86, you could compile a function with
3250 @code{target_clones("sse4.1,avx")}. GCC creates two function clones,
3251 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3252 It also creates a resolver function (see the @code{ifunc} attribute
3253 above) that dynamically selects a clone suitable for current architecture.
3256 @cindex @code{unused} function attribute
3257 This attribute, attached to a function, means that the function is meant
3258 to be possibly unused. GCC does not produce a warning for this
3262 @cindex @code{used} function attribute
3263 This attribute, attached to a function, means that code must be emitted
3264 for the function even if it appears that the function is not referenced.
3265 This is useful, for example, when the function is referenced only in
3268 When applied to a member function of a C++ class template, the
3269 attribute also means that the function is instantiated if the
3270 class itself is instantiated.
3272 @item visibility ("@var{visibility_type}")
3273 @cindex @code{visibility} function attribute
3274 This attribute affects the linkage of the declaration to which it is attached.
3275 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3276 (@pxref{Common Type Attributes}) as well as functions.
3278 There are four supported @var{visibility_type} values: default,
3279 hidden, protected or internal visibility.
3282 void __attribute__ ((visibility ("protected")))
3283 f () @{ /* @r{Do something.} */; @}
3284 int i __attribute__ ((visibility ("hidden")));
3287 The possible values of @var{visibility_type} correspond to the
3288 visibility settings in the ELF gABI.
3291 @c keep this list of visibilities in alphabetical order.
3294 Default visibility is the normal case for the object file format.
3295 This value is available for the visibility attribute to override other
3296 options that may change the assumed visibility of entities.
3298 On ELF, default visibility means that the declaration is visible to other
3299 modules and, in shared libraries, means that the declared entity may be
3302 On Darwin, default visibility means that the declaration is visible to
3305 Default visibility corresponds to ``external linkage'' in the language.
3308 Hidden visibility indicates that the entity declared has a new
3309 form of linkage, which we call ``hidden linkage''. Two
3310 declarations of an object with hidden linkage refer to the same object
3311 if they are in the same shared object.
3314 Internal visibility is like hidden visibility, but with additional
3315 processor specific semantics. Unless otherwise specified by the
3316 psABI, GCC defines internal visibility to mean that a function is
3317 @emph{never} called from another module. Compare this with hidden
3318 functions which, while they cannot be referenced directly by other
3319 modules, can be referenced indirectly via function pointers. By
3320 indicating that a function cannot be called from outside the module,
3321 GCC may for instance omit the load of a PIC register since it is known
3322 that the calling function loaded the correct value.
3325 Protected visibility is like default visibility except that it
3326 indicates that references within the defining module bind to the
3327 definition in that module. That is, the declared entity cannot be
3328 overridden by another module.
3332 All visibilities are supported on many, but not all, ELF targets
3333 (supported when the assembler supports the @samp{.visibility}
3334 pseudo-op). Default visibility is supported everywhere. Hidden
3335 visibility is supported on Darwin targets.
3337 The visibility attribute should be applied only to declarations that
3338 would otherwise have external linkage. The attribute should be applied
3339 consistently, so that the same entity should not be declared with
3340 different settings of the attribute.
3342 In C++, the visibility attribute applies to types as well as functions
3343 and objects, because in C++ types have linkage. A class must not have
3344 greater visibility than its non-static data member types and bases,
3345 and class members default to the visibility of their class. Also, a
3346 declaration without explicit visibility is limited to the visibility
3349 In C++, you can mark member functions and static member variables of a
3350 class with the visibility attribute. This is useful if you know a
3351 particular method or static member variable should only be used from
3352 one shared object; then you can mark it hidden while the rest of the
3353 class has default visibility. Care must be taken to avoid breaking
3354 the One Definition Rule; for example, it is usually not useful to mark
3355 an inline method as hidden without marking the whole class as hidden.
3357 A C++ namespace declaration can also have the visibility attribute.
3360 namespace nspace1 __attribute__ ((visibility ("protected")))
3361 @{ /* @r{Do something.} */; @}
3364 This attribute applies only to the particular namespace body, not to
3365 other definitions of the same namespace; it is equivalent to using
3366 @samp{#pragma GCC visibility} before and after the namespace
3367 definition (@pxref{Visibility Pragmas}).
3369 In C++, if a template argument has limited visibility, this
3370 restriction is implicitly propagated to the template instantiation.
3371 Otherwise, template instantiations and specializations default to the
3372 visibility of their template.
3374 If both the template and enclosing class have explicit visibility, the
3375 visibility from the template is used.
3377 @item warn_unused_result
3378 @cindex @code{warn_unused_result} function attribute
3379 The @code{warn_unused_result} attribute causes a warning to be emitted
3380 if a caller of the function with this attribute does not use its
3381 return value. This is useful for functions where not checking
3382 the result is either a security problem or always a bug, such as
3386 int fn () __attribute__ ((warn_unused_result));
3389 if (fn () < 0) return -1;
3396 results in warning on line 5.
3399 @cindex @code{weak} function attribute
3400 The @code{weak} attribute causes the declaration to be emitted as a weak
3401 symbol rather than a global. This is primarily useful in defining
3402 library functions that can be overridden in user code, though it can
3403 also be used with non-function declarations. Weak symbols are supported
3404 for ELF targets, and also for a.out targets when using the GNU assembler
3408 @itemx weakref ("@var{target}")
3409 @cindex @code{weakref} function attribute
3410 The @code{weakref} attribute marks a declaration as a weak reference.
3411 Without arguments, it should be accompanied by an @code{alias} attribute
3412 naming the target symbol. Optionally, the @var{target} may be given as
3413 an argument to @code{weakref} itself. In either case, @code{weakref}
3414 implicitly marks the declaration as @code{weak}. Without a
3415 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3416 @code{weakref} is equivalent to @code{weak}.
3419 static int x() __attribute__ ((weakref ("y")));
3420 /* is equivalent to... */
3421 static int x() __attribute__ ((weak, weakref, alias ("y")));
3423 static int x() __attribute__ ((weakref));
3424 static int x() __attribute__ ((alias ("y")));
3427 A weak reference is an alias that does not by itself require a
3428 definition to be given for the target symbol. If the target symbol is
3429 only referenced through weak references, then it becomes a @code{weak}
3430 undefined symbol. If it is directly referenced, however, then such
3431 strong references prevail, and a definition is required for the
3432 symbol, not necessarily in the same translation unit.
3434 The effect is equivalent to moving all references to the alias to a
3435 separate translation unit, renaming the alias to the aliased symbol,
3436 declaring it as weak, compiling the two separate translation units and
3437 performing a reloadable link on them.
3439 At present, a declaration to which @code{weakref} is attached can
3440 only be @code{static}.
3445 @c This is the end of the target-independent attribute table
3447 @node AArch64 Function Attributes
3448 @subsection AArch64 Function Attributes
3450 The following target-specific function attributes are available for the
3451 AArch64 target. For the most part, these options mirror the behavior of
3452 similar command-line options (@pxref{AArch64 Options}), but on a
3456 @item general-regs-only
3457 @cindex @code{general-regs-only} function attribute, AArch64
3458 Indicates that no floating-point or Advanced SIMD registers should be
3459 used when generating code for this function. If the function explicitly
3460 uses floating-point code, then the compiler gives an error. This is
3461 the same behavior as that of the command-line option
3462 @option{-mgeneral-regs-only}.
3464 @item fix-cortex-a53-835769
3465 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3466 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3467 applied to this function. To explicitly disable the workaround for this
3468 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3469 This corresponds to the behavior of the command line options
3470 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3473 @cindex @code{cmodel=} function attribute, AArch64
3474 Indicates that code should be generated for a particular code model for
3475 this function. The behavior and permissible arguments are the same as
3476 for the command line option @option{-mcmodel=}.
3479 @cindex @code{strict-align} function attribute, AArch64
3480 Indicates that the compiler should not assume that unaligned memory references
3481 are handled by the system. The behavior is the same as for the command-line
3482 option @option{-mstrict-align}.
3484 @item omit-leaf-frame-pointer
3485 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3486 Indicates that the frame pointer should be omitted for a leaf function call.
3487 To keep the frame pointer, the inverse attribute
3488 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3489 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3490 and @option{-mno-omit-leaf-frame-pointer}.
3493 @cindex @code{tls-dialect=} function attribute, AArch64
3494 Specifies the TLS dialect to use for this function. The behavior and
3495 permissible arguments are the same as for the command-line option
3496 @option{-mtls-dialect=}.
3499 @cindex @code{arch=} function attribute, AArch64
3500 Specifies the architecture version and architectural extensions to use
3501 for this function. The behavior and permissible arguments are the same as
3502 for the @option{-march=} command-line option.
3505 @cindex @code{tune=} function attribute, AArch64
3506 Specifies the core for which to tune the performance of this function.
3507 The behavior and permissible arguments are the same as for the @option{-mtune=}
3508 command-line option.
3511 @cindex @code{cpu=} function attribute, AArch64
3512 Specifies the core for which to tune the performance of this function and also
3513 whose architectural features to use. The behavior and valid arguments are the
3514 same as for the @option{-mcpu=} command-line option.
3516 @item sign-return-address
3517 @cindex @code{sign-return-address} function attribute, AArch64
3518 Select the function scope on which return address signing will be applied. The
3519 behavior and permissible arguments are the same as for the command-line option
3520 @option{-msign-return-address=}. The default value is @code{none}.
3524 The above target attributes can be specified as follows:
3527 __attribute__((target("@var{attr-string}")))
3535 where @code{@var{attr-string}} is one of the attribute strings specified above.
3537 Additionally, the architectural extension string may be specified on its
3538 own. This can be used to turn on and off particular architectural extensions
3539 without having to specify a particular architecture version or core. Example:
3542 __attribute__((target("+crc+nocrypto")))
3550 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3551 extension and disables the @code{crypto} extension for the function @code{foo}
3552 without modifying an existing @option{-march=} or @option{-mcpu} option.
3554 Multiple target function attributes can be specified by separating them with
3555 a comma. For example:
3557 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3565 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3566 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3568 @subsubsection Inlining rules
3569 Specifying target attributes on individual functions or performing link-time
3570 optimization across translation units compiled with different target options
3571 can affect function inlining rules:
3573 In particular, a caller function can inline a callee function only if the
3574 architectural features available to the callee are a subset of the features
3575 available to the caller.
3576 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3577 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3578 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3579 because the all the architectural features that function @code{bar} requires
3580 are available to function @code{foo}. Conversely, function @code{bar} cannot
3581 inline function @code{foo}.
3583 Additionally inlining a function compiled with @option{-mstrict-align} into a
3584 function compiled without @code{-mstrict-align} is not allowed.
3585 However, inlining a function compiled without @option{-mstrict-align} into a
3586 function compiled with @option{-mstrict-align} is allowed.
3588 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3589 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3590 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3591 architectural feature rules specified above.
3593 @node ARC Function Attributes
3594 @subsection ARC Function Attributes
3596 These function attributes are supported by the ARC back end:
3600 @cindex @code{interrupt} function attribute, ARC
3601 Use this attribute to indicate
3602 that the specified function is an interrupt handler. The compiler generates
3603 function entry and exit sequences suitable for use in an interrupt handler
3604 when this attribute is present.
3606 On the ARC, you must specify the kind of interrupt to be handled
3607 in a parameter to the interrupt attribute like this:
3610 void f () __attribute__ ((interrupt ("ilink1")));
3613 Permissible values for this parameter are: @w{@code{ilink1}} and
3619 @cindex @code{long_call} function attribute, ARC
3620 @cindex @code{medium_call} function attribute, ARC
3621 @cindex @code{short_call} function attribute, ARC
3622 @cindex indirect calls, ARC
3623 These attributes specify how a particular function is called.
3624 These attributes override the
3625 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3626 command-line switches and @code{#pragma long_calls} settings.
3628 For ARC, a function marked with the @code{long_call} attribute is
3629 always called using register-indirect jump-and-link instructions,
3630 thereby enabling the called function to be placed anywhere within the
3631 32-bit address space. A function marked with the @code{medium_call}
3632 attribute will always be close enough to be called with an unconditional
3633 branch-and-link instruction, which has a 25-bit offset from
3634 the call site. A function marked with the @code{short_call}
3635 attribute will always be close enough to be called with a conditional
3636 branch-and-link instruction, which has a 21-bit offset from
3640 @node ARM Function Attributes
3641 @subsection ARM Function Attributes
3643 These function attributes are supported for ARM targets:
3647 @cindex @code{interrupt} function attribute, ARM
3648 Use this attribute to indicate
3649 that the specified function is an interrupt handler. The compiler generates
3650 function entry and exit sequences suitable for use in an interrupt handler
3651 when this attribute is present.
3653 You can specify the kind of interrupt to be handled by
3654 adding an optional parameter to the interrupt attribute like this:
3657 void f () __attribute__ ((interrupt ("IRQ")));
3661 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3662 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3664 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3665 may be called with a word-aligned stack pointer.
3668 @cindex @code{isr} function attribute, ARM
3669 Use this attribute on ARM to write Interrupt Service Routines. This is an
3670 alias to the @code{interrupt} attribute above.
3674 @cindex @code{long_call} function attribute, ARM
3675 @cindex @code{short_call} function attribute, ARM
3676 @cindex indirect calls, ARM
3677 These attributes specify how a particular function is called.
3678 These attributes override the
3679 @option{-mlong-calls} (@pxref{ARM Options})
3680 command-line switch and @code{#pragma long_calls} settings. For ARM, the
3681 @code{long_call} attribute indicates that the function might be far
3682 away from the call site and require a different (more expensive)
3683 calling sequence. The @code{short_call} attribute always places
3684 the offset to the function from the call site into the @samp{BL}
3685 instruction directly.
3688 @cindex @code{naked} function attribute, ARM
3689 This attribute allows the compiler to construct the
3690 requisite function declaration, while allowing the body of the
3691 function to be assembly code. The specified function will not have
3692 prologue/epilogue sequences generated by the compiler. Only basic
3693 @code{asm} statements can safely be included in naked functions
3694 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3695 basic @code{asm} and C code may appear to work, they cannot be
3696 depended upon to work reliably and are not supported.
3699 @cindex @code{pcs} function attribute, ARM
3701 The @code{pcs} attribute can be used to control the calling convention
3702 used for a function on ARM. The attribute takes an argument that specifies
3703 the calling convention to use.
3705 When compiling using the AAPCS ABI (or a variant of it) then valid
3706 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3707 order to use a variant other than @code{"aapcs"} then the compiler must
3708 be permitted to use the appropriate co-processor registers (i.e., the
3709 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3713 /* Argument passed in r0, and result returned in r0+r1. */
3714 double f2d (float) __attribute__((pcs("aapcs")));
3717 Variadic functions always use the @code{"aapcs"} calling convention and
3718 the compiler rejects attempts to specify an alternative.
3720 @item target (@var{options})
3721 @cindex @code{target} function attribute
3722 As discussed in @ref{Common Function Attributes}, this attribute
3723 allows specification of target-specific compilation options.
3725 On ARM, the following options are allowed:
3729 @cindex @code{target("thumb")} function attribute, ARM
3730 Force code generation in the Thumb (T16/T32) ISA, depending on the
3734 @cindex @code{target("arm")} function attribute, ARM
3735 Force code generation in the ARM (A32) ISA.
3737 Functions from different modes can be inlined in the caller's mode.
3740 @cindex @code{target("fpu=")} function attribute, ARM
3741 Specifies the fpu for which to tune the performance of this function.
3742 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3743 command-line option.
3749 @node AVR Function Attributes
3750 @subsection AVR Function Attributes
3752 These function attributes are supported by the AVR back end:
3756 @cindex @code{interrupt} function attribute, AVR
3757 Use this attribute to indicate
3758 that the specified function is an interrupt handler. The compiler generates
3759 function entry and exit sequences suitable for use in an interrupt handler
3760 when this attribute is present.
3762 On the AVR, the hardware globally disables interrupts when an
3763 interrupt is executed. The first instruction of an interrupt handler
3764 declared with this attribute is a @code{SEI} instruction to
3765 re-enable interrupts. See also the @code{signal} function attribute
3766 that does not insert a @code{SEI} instruction. If both @code{signal} and
3767 @code{interrupt} are specified for the same function, @code{signal}
3768 is silently ignored.
3771 @cindex @code{naked} function attribute, AVR
3772 This attribute allows the compiler to construct the
3773 requisite function declaration, while allowing the body of the
3774 function to be assembly code. The specified function will not have
3775 prologue/epilogue sequences generated by the compiler. Only basic
3776 @code{asm} statements can safely be included in naked functions
3777 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3778 basic @code{asm} and C code may appear to work, they cannot be
3779 depended upon to work reliably and are not supported.
3783 @cindex @code{OS_main} function attribute, AVR
3784 @cindex @code{OS_task} function attribute, AVR
3785 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3786 do not save/restore any call-saved register in their prologue/epilogue.
3788 The @code{OS_main} attribute can be used when there @emph{is
3789 guarantee} that interrupts are disabled at the time when the function
3790 is entered. This saves resources when the stack pointer has to be
3791 changed to set up a frame for local variables.
3793 The @code{OS_task} attribute can be used when there is @emph{no
3794 guarantee} that interrupts are disabled at that time when the function
3795 is entered like for, e@.g@. task functions in a multi-threading operating
3796 system. In that case, changing the stack pointer register is
3797 guarded by save/clear/restore of the global interrupt enable flag.
3799 The differences to the @code{naked} function attribute are:
3801 @item @code{naked} functions do not have a return instruction whereas
3802 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3803 @code{RETI} return instruction.
3804 @item @code{naked} functions do not set up a frame for local variables
3805 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3810 @cindex @code{signal} function attribute, AVR
3811 Use this attribute on the AVR to indicate that the specified
3812 function is an interrupt handler. The compiler generates function
3813 entry and exit sequences suitable for use in an interrupt handler when this
3814 attribute is present.
3816 See also the @code{interrupt} function attribute.
3818 The AVR hardware globally disables interrupts when an interrupt is executed.
3819 Interrupt handler functions defined with the @code{signal} attribute
3820 do not re-enable interrupts. It is save to enable interrupts in a
3821 @code{signal} handler. This ``save'' only applies to the code
3822 generated by the compiler and not to the IRQ layout of the
3823 application which is responsibility of the application.
3825 If both @code{signal} and @code{interrupt} are specified for the same
3826 function, @code{signal} is silently ignored.
3829 @node Blackfin Function Attributes
3830 @subsection Blackfin Function Attributes
3832 These function attributes are supported by the Blackfin back end:
3836 @item exception_handler
3837 @cindex @code{exception_handler} function attribute
3838 @cindex exception handler functions, Blackfin
3839 Use this attribute on the Blackfin to indicate that the specified function
3840 is an exception handler. The compiler generates function entry and
3841 exit sequences suitable for use in an exception handler when this
3842 attribute is present.
3844 @item interrupt_handler
3845 @cindex @code{interrupt_handler} function attribute, Blackfin
3846 Use this attribute to
3847 indicate that the specified function is an interrupt handler. The compiler
3848 generates function entry and exit sequences suitable for use in an
3849 interrupt handler when this attribute is present.
3852 @cindex @code{kspisusp} function attribute, Blackfin
3853 @cindex User stack pointer in interrupts on the Blackfin
3854 When used together with @code{interrupt_handler}, @code{exception_handler}
3855 or @code{nmi_handler}, code is generated to load the stack pointer
3856 from the USP register in the function prologue.
3859 @cindex @code{l1_text} function attribute, Blackfin
3860 This attribute specifies a function to be placed into L1 Instruction
3861 SRAM@. The function is put into a specific section named @code{.l1.text}.
3862 With @option{-mfdpic}, function calls with a such function as the callee
3863 or caller uses inlined PLT.
3866 @cindex @code{l2} function attribute, Blackfin
3867 This attribute specifies a function to be placed into L2
3868 SRAM. The function is put into a specific section named
3869 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3874 @cindex indirect calls, Blackfin
3875 @cindex @code{longcall} function attribute, Blackfin
3876 @cindex @code{shortcall} function attribute, Blackfin
3877 The @code{longcall} attribute
3878 indicates that the function might be far away from the call site and
3879 require a different (more expensive) calling sequence. The
3880 @code{shortcall} attribute indicates that the function is always close
3881 enough for the shorter calling sequence to be used. These attributes
3882 override the @option{-mlongcall} switch.
3885 @cindex @code{nesting} function attribute, Blackfin
3886 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3887 Use this attribute together with @code{interrupt_handler},
3888 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3889 entry code should enable nested interrupts or exceptions.
3892 @cindex @code{nmi_handler} function attribute, Blackfin
3893 @cindex NMI handler functions on the Blackfin processor
3894 Use this attribute on the Blackfin to indicate that the specified function
3895 is an NMI handler. The compiler generates function entry and
3896 exit sequences suitable for use in an NMI handler when this
3897 attribute is present.
3900 @cindex @code{saveall} function attribute, Blackfin
3901 @cindex save all registers on the Blackfin
3902 Use this attribute to indicate that
3903 all registers except the stack pointer should be saved in the prologue
3904 regardless of whether they are used or not.
3907 @node CR16 Function Attributes
3908 @subsection CR16 Function Attributes
3910 These function attributes are supported by the CR16 back end:
3914 @cindex @code{interrupt} function attribute, CR16
3915 Use this attribute to indicate
3916 that the specified function is an interrupt handler. The compiler generates
3917 function entry and exit sequences suitable for use in an interrupt handler
3918 when this attribute is present.
3921 @node Epiphany Function Attributes
3922 @subsection Epiphany Function Attributes
3924 These function attributes are supported by the Epiphany back end:
3928 @cindex @code{disinterrupt} function attribute, Epiphany
3929 This attribute causes the compiler to emit
3930 instructions to disable interrupts for the duration of the given
3933 @item forwarder_section
3934 @cindex @code{forwarder_section} function attribute, Epiphany
3935 This attribute modifies the behavior of an interrupt handler.
3936 The interrupt handler may be in external memory which cannot be
3937 reached by a branch instruction, so generate a local memory trampoline
3938 to transfer control. The single parameter identifies the section where
3939 the trampoline is placed.
3942 @cindex @code{interrupt} function attribute, Epiphany
3943 Use this attribute to indicate
3944 that the specified function is an interrupt handler. The compiler generates
3945 function entry and exit sequences suitable for use in an interrupt handler
3946 when this attribute is present. It may also generate
3947 a special section with code to initialize the interrupt vector table.
3949 On Epiphany targets one or more optional parameters can be added like this:
3952 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3955 Permissible values for these parameters are: @w{@code{reset}},
3956 @w{@code{software_exception}}, @w{@code{page_miss}},
3957 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3958 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3959 Multiple parameters indicate that multiple entries in the interrupt
3960 vector table should be initialized for this function, i.e.@: for each
3961 parameter @w{@var{name}}, a jump to the function is emitted in
3962 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
3963 entirely, in which case no interrupt vector table entry is provided.
3965 Note that interrupts are enabled inside the function
3966 unless the @code{disinterrupt} attribute is also specified.
3968 The following examples are all valid uses of these attributes on
3971 void __attribute__ ((interrupt)) universal_handler ();
3972 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3973 void __attribute__ ((interrupt ("dma0, dma1")))
3974 universal_dma_handler ();
3975 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3976 fast_timer_handler ();
3977 void __attribute__ ((interrupt ("dma0, dma1"),
3978 forwarder_section ("tramp")))
3979 external_dma_handler ();
3984 @cindex @code{long_call} function attribute, Epiphany
3985 @cindex @code{short_call} function attribute, Epiphany
3986 @cindex indirect calls, Epiphany
3987 These attributes specify how a particular function is called.
3988 These attributes override the
3989 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3990 command-line switch and @code{#pragma long_calls} settings.
3994 @node H8/300 Function Attributes
3995 @subsection H8/300 Function Attributes
3997 These function attributes are available for H8/300 targets:
4000 @item function_vector
4001 @cindex @code{function_vector} function attribute, H8/300
4002 Use this attribute on the H8/300, H8/300H, and H8S to indicate
4003 that the specified function should be called through the function vector.
4004 Calling a function through the function vector reduces code size; however,
4005 the function vector has a limited size (maximum 128 entries on the H8/300
4006 and 64 entries on the H8/300H and H8S)
4007 and shares space with the interrupt vector.
4009 @item interrupt_handler
4010 @cindex @code{interrupt_handler} function attribute, H8/300
4011 Use this attribute on the H8/300, H8/300H, and H8S to
4012 indicate that the specified function is an interrupt handler. The compiler
4013 generates function entry and exit sequences suitable for use in an
4014 interrupt handler when this attribute is present.
4017 @cindex @code{saveall} function attribute, H8/300
4018 @cindex save all registers on the H8/300, H8/300H, and H8S
4019 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4020 all registers except the stack pointer should be saved in the prologue
4021 regardless of whether they are used or not.
4024 @node IA-64 Function Attributes
4025 @subsection IA-64 Function Attributes
4027 These function attributes are supported on IA-64 targets:
4030 @item syscall_linkage
4031 @cindex @code{syscall_linkage} function attribute, IA-64
4032 This attribute is used to modify the IA-64 calling convention by marking
4033 all input registers as live at all function exits. This makes it possible
4034 to restart a system call after an interrupt without having to save/restore
4035 the input registers. This also prevents kernel data from leaking into
4039 @cindex @code{version_id} function attribute, IA-64
4040 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4041 symbol to contain a version string, thus allowing for function level
4042 versioning. HP-UX system header files may use function level versioning
4043 for some system calls.
4046 extern int foo () __attribute__((version_id ("20040821")));
4050 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4053 @node M32C Function Attributes
4054 @subsection M32C Function Attributes
4056 These function attributes are supported by the M32C back end:
4060 @cindex @code{bank_switch} function attribute, M32C
4061 When added to an interrupt handler with the M32C port, causes the
4062 prologue and epilogue to use bank switching to preserve the registers
4063 rather than saving them on the stack.
4065 @item fast_interrupt
4066 @cindex @code{fast_interrupt} function attribute, M32C
4067 Use this attribute on the M32C port to indicate that the specified
4068 function is a fast interrupt handler. This is just like the
4069 @code{interrupt} attribute, except that @code{freit} is used to return
4070 instead of @code{reit}.
4072 @item function_vector
4073 @cindex @code{function_vector} function attribute, M16C/M32C
4074 On M16C/M32C targets, the @code{function_vector} attribute declares a
4075 special page subroutine call function. Use of this attribute reduces
4076 the code size by 2 bytes for each call generated to the
4077 subroutine. The argument to the attribute is the vector number entry
4078 from the special page vector table which contains the 16 low-order
4079 bits of the subroutine's entry address. Each vector table has special
4080 page number (18 to 255) that is used in @code{jsrs} instructions.
4081 Jump addresses of the routines are generated by adding 0x0F0000 (in
4082 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4083 2-byte addresses set in the vector table. Therefore you need to ensure
4084 that all the special page vector routines should get mapped within the
4085 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4088 In the following example 2 bytes are saved for each call to
4089 function @code{foo}.
4092 void foo (void) __attribute__((function_vector(0x18)));
4103 If functions are defined in one file and are called in another file,
4104 then be sure to write this declaration in both files.
4106 This attribute is ignored for R8C target.
4109 @cindex @code{interrupt} function attribute, M32C
4110 Use this attribute to indicate
4111 that the specified function is an interrupt handler. The compiler generates
4112 function entry and exit sequences suitable for use in an interrupt handler
4113 when this attribute is present.
4116 @node M32R/D Function Attributes
4117 @subsection M32R/D Function Attributes
4119 These function attributes are supported by the M32R/D back end:
4123 @cindex @code{interrupt} function attribute, M32R/D
4124 Use this attribute to indicate
4125 that the specified function is an interrupt handler. The compiler generates
4126 function entry and exit sequences suitable for use in an interrupt handler
4127 when this attribute is present.
4129 @item model (@var{model-name})
4130 @cindex @code{model} function attribute, M32R/D
4131 @cindex function addressability on the M32R/D
4133 On the M32R/D, use this attribute to set the addressability of an
4134 object, and of the code generated for a function. The identifier
4135 @var{model-name} is one of @code{small}, @code{medium}, or
4136 @code{large}, representing each of the code models.
4138 Small model objects live in the lower 16MB of memory (so that their
4139 addresses can be loaded with the @code{ld24} instruction), and are
4140 callable with the @code{bl} instruction.
4142 Medium model objects may live anywhere in the 32-bit address space (the
4143 compiler generates @code{seth/add3} instructions to load their addresses),
4144 and are callable with the @code{bl} instruction.
4146 Large model objects may live anywhere in the 32-bit address space (the
4147 compiler generates @code{seth/add3} instructions to load their addresses),
4148 and may not be reachable with the @code{bl} instruction (the compiler
4149 generates the much slower @code{seth/add3/jl} instruction sequence).
4152 @node m68k Function Attributes
4153 @subsection m68k Function Attributes
4155 These function attributes are supported by the m68k back end:
4159 @itemx interrupt_handler
4160 @cindex @code{interrupt} function attribute, m68k
4161 @cindex @code{interrupt_handler} function attribute, m68k
4162 Use this attribute to
4163 indicate that the specified function is an interrupt handler. The compiler
4164 generates function entry and exit sequences suitable for use in an
4165 interrupt handler when this attribute is present. Either name may be used.
4167 @item interrupt_thread
4168 @cindex @code{interrupt_thread} function attribute, fido
4169 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4170 that the specified function is an interrupt handler that is designed
4171 to run as a thread. The compiler omits generate prologue/epilogue
4172 sequences and replaces the return instruction with a @code{sleep}
4173 instruction. This attribute is available only on fido.
4176 @node MCORE Function Attributes
4177 @subsection MCORE Function Attributes
4179 These function attributes are supported by the MCORE back end:
4183 @cindex @code{naked} function attribute, MCORE
4184 This attribute allows the compiler to construct the
4185 requisite function declaration, while allowing the body of the
4186 function to be assembly code. The specified function will not have
4187 prologue/epilogue sequences generated by the compiler. Only basic
4188 @code{asm} statements can safely be included in naked functions
4189 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4190 basic @code{asm} and C code may appear to work, they cannot be
4191 depended upon to work reliably and are not supported.
4194 @node MeP Function Attributes
4195 @subsection MeP Function Attributes
4197 These function attributes are supported by the MeP back end:
4201 @cindex @code{disinterrupt} function attribute, MeP
4202 On MeP targets, this attribute causes the compiler to emit
4203 instructions to disable interrupts for the duration of the given
4207 @cindex @code{interrupt} function attribute, MeP
4208 Use this attribute to indicate
4209 that the specified function is an interrupt handler. The compiler generates
4210 function entry and exit sequences suitable for use in an interrupt handler
4211 when this attribute is present.
4214 @cindex @code{near} function attribute, MeP
4215 This attribute causes the compiler to assume the called
4216 function is close enough to use the normal calling convention,
4217 overriding the @option{-mtf} command-line option.
4220 @cindex @code{far} function attribute, MeP
4221 On MeP targets this causes the compiler to use a calling convention
4222 that assumes the called function is too far away for the built-in
4226 @cindex @code{vliw} function attribute, MeP
4227 The @code{vliw} attribute tells the compiler to emit
4228 instructions in VLIW mode instead of core mode. Note that this
4229 attribute is not allowed unless a VLIW coprocessor has been configured
4230 and enabled through command-line options.
4233 @node MicroBlaze Function Attributes
4234 @subsection MicroBlaze Function Attributes
4236 These function attributes are supported on MicroBlaze targets:
4239 @item save_volatiles
4240 @cindex @code{save_volatiles} function attribute, MicroBlaze
4241 Use this attribute to indicate that the function is
4242 an interrupt handler. All volatile registers (in addition to non-volatile
4243 registers) are saved in the function prologue. If the function is a leaf
4244 function, only volatiles used by the function are saved. A normal function
4245 return is generated instead of a return from interrupt.
4248 @cindex @code{break_handler} function attribute, MicroBlaze
4249 @cindex break handler functions
4250 Use this attribute to indicate that
4251 the specified function is a break handler. The compiler generates function
4252 entry and exit sequences suitable for use in an break handler when this
4253 attribute is present. The return from @code{break_handler} is done through
4254 the @code{rtbd} instead of @code{rtsd}.
4257 void f () __attribute__ ((break_handler));
4260 @item interrupt_handler
4261 @itemx fast_interrupt
4262 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4263 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4264 These attributes indicate that the specified function is an interrupt
4265 handler. Use the @code{fast_interrupt} attribute to indicate handlers
4266 used in low-latency interrupt mode, and @code{interrupt_handler} for
4267 interrupts that do not use low-latency handlers. In both cases, GCC
4268 emits appropriate prologue code and generates a return from the handler
4269 using @code{rtid} instead of @code{rtsd}.
4272 @node Microsoft Windows Function Attributes
4273 @subsection Microsoft Windows Function Attributes
4275 The following attributes are available on Microsoft Windows and Symbian OS
4280 @cindex @code{dllexport} function attribute
4281 @cindex @code{__declspec(dllexport)}
4282 On Microsoft Windows targets and Symbian OS targets the
4283 @code{dllexport} attribute causes the compiler to provide a global
4284 pointer to a pointer in a DLL, so that it can be referenced with the
4285 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4286 name is formed by combining @code{_imp__} and the function or variable
4289 You can use @code{__declspec(dllexport)} as a synonym for
4290 @code{__attribute__ ((dllexport))} for compatibility with other
4293 On systems that support the @code{visibility} attribute, this
4294 attribute also implies ``default'' visibility. It is an error to
4295 explicitly specify any other visibility.
4297 GCC's default behavior is to emit all inline functions with the
4298 @code{dllexport} attribute. Since this can cause object file-size bloat,
4299 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4300 ignore the attribute for inlined functions unless the
4301 @option{-fkeep-inline-functions} flag is used instead.
4303 The attribute is ignored for undefined symbols.
4305 When applied to C++ classes, the attribute marks defined non-inlined
4306 member functions and static data members as exports. Static consts
4307 initialized in-class are not marked unless they are also defined
4310 For Microsoft Windows targets there are alternative methods for
4311 including the symbol in the DLL's export table such as using a
4312 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4313 the @option{--export-all} linker flag.
4316 @cindex @code{dllimport} function attribute
4317 @cindex @code{__declspec(dllimport)}
4318 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4319 attribute causes the compiler to reference a function or variable via
4320 a global pointer to a pointer that is set up by the DLL exporting the
4321 symbol. The attribute implies @code{extern}. On Microsoft Windows
4322 targets, the pointer name is formed by combining @code{_imp__} and the
4323 function or variable name.
4325 You can use @code{__declspec(dllimport)} as a synonym for
4326 @code{__attribute__ ((dllimport))} for compatibility with other
4329 On systems that support the @code{visibility} attribute, this
4330 attribute also implies ``default'' visibility. It is an error to
4331 explicitly specify any other visibility.
4333 Currently, the attribute is ignored for inlined functions. If the
4334 attribute is applied to a symbol @emph{definition}, an error is reported.
4335 If a symbol previously declared @code{dllimport} is later defined, the
4336 attribute is ignored in subsequent references, and a warning is emitted.
4337 The attribute is also overridden by a subsequent declaration as
4340 When applied to C++ classes, the attribute marks non-inlined
4341 member functions and static data members as imports. However, the
4342 attribute is ignored for virtual methods to allow creation of vtables
4345 On the SH Symbian OS target the @code{dllimport} attribute also has
4346 another affect---it can cause the vtable and run-time type information
4347 for a class to be exported. This happens when the class has a
4348 dllimported constructor or a non-inline, non-pure virtual function
4349 and, for either of those two conditions, the class also has an inline
4350 constructor or destructor and has a key function that is defined in
4351 the current translation unit.
4353 For Microsoft Windows targets the use of the @code{dllimport}
4354 attribute on functions is not necessary, but provides a small
4355 performance benefit by eliminating a thunk in the DLL@. The use of the
4356 @code{dllimport} attribute on imported variables can be avoided by passing the
4357 @option{--enable-auto-import} switch to the GNU linker. As with
4358 functions, using the attribute for a variable eliminates a thunk in
4361 One drawback to using this attribute is that a pointer to a
4362 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4363 address. However, a pointer to a @emph{function} with the
4364 @code{dllimport} attribute can be used as a constant initializer; in
4365 this case, the address of a stub function in the import lib is
4366 referenced. On Microsoft Windows targets, the attribute can be disabled
4367 for functions by setting the @option{-mnop-fun-dllimport} flag.
4370 @node MIPS Function Attributes
4371 @subsection MIPS Function Attributes
4373 These function attributes are supported by the MIPS back end:
4377 @cindex @code{interrupt} function attribute, MIPS
4378 Use this attribute to indicate that the specified function is an interrupt
4379 handler. The compiler generates function entry and exit sequences suitable
4380 for use in an interrupt handler when this attribute is present.
4381 An optional argument is supported for the interrupt attribute which allows
4382 the interrupt mode to be described. By default GCC assumes the external
4383 interrupt controller (EIC) mode is in use, this can be explicitly set using
4384 @code{eic}. When interrupts are non-masked then the requested Interrupt
4385 Priority Level (IPL) is copied to the current IPL which has the effect of only
4386 enabling higher priority interrupts. To use vectored interrupt mode use
4387 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4388 the behavior of the non-masked interrupt support and GCC will arrange to mask
4389 all interrupts from sw0 up to and including the specified interrupt vector.
4391 You can use the following attributes to modify the behavior
4392 of an interrupt handler:
4394 @item use_shadow_register_set
4395 @cindex @code{use_shadow_register_set} function attribute, MIPS
4396 Assume that the handler uses a shadow register set, instead of
4397 the main general-purpose registers. An optional argument @code{intstack} is
4398 supported to indicate that the shadow register set contains a valid stack
4401 @item keep_interrupts_masked
4402 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4403 Keep interrupts masked for the whole function. Without this attribute,
4404 GCC tries to reenable interrupts for as much of the function as it can.
4406 @item use_debug_exception_return
4407 @cindex @code{use_debug_exception_return} function attribute, MIPS
4408 Return using the @code{deret} instruction. Interrupt handlers that don't
4409 have this attribute return using @code{eret} instead.
4412 You can use any combination of these attributes, as shown below:
4414 void __attribute__ ((interrupt)) v0 ();
4415 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4416 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4417 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4418 void __attribute__ ((interrupt, use_shadow_register_set,
4419 keep_interrupts_masked)) v4 ();
4420 void __attribute__ ((interrupt, use_shadow_register_set,
4421 use_debug_exception_return)) v5 ();
4422 void __attribute__ ((interrupt, keep_interrupts_masked,
4423 use_debug_exception_return)) v6 ();
4424 void __attribute__ ((interrupt, use_shadow_register_set,
4425 keep_interrupts_masked,
4426 use_debug_exception_return)) v7 ();
4427 void __attribute__ ((interrupt("eic"))) v8 ();
4428 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4434 @cindex indirect calls, MIPS
4435 @cindex @code{long_call} function attribute, MIPS
4436 @cindex @code{near} function attribute, MIPS
4437 @cindex @code{far} function attribute, MIPS
4438 These attributes specify how a particular function is called on MIPS@.
4439 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4440 command-line switch. The @code{long_call} and @code{far} attributes are
4441 synonyms, and cause the compiler to always call
4442 the function by first loading its address into a register, and then using
4443 the contents of that register. The @code{near} attribute has the opposite
4444 effect; it specifies that non-PIC calls should be made using the more
4445 efficient @code{jal} instruction.
4449 @cindex @code{mips16} function attribute, MIPS
4450 @cindex @code{nomips16} function attribute, MIPS
4452 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4453 function attributes to locally select or turn off MIPS16 code generation.
4454 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4455 while MIPS16 code generation is disabled for functions with the
4456 @code{nomips16} attribute. These attributes override the
4457 @option{-mips16} and @option{-mno-mips16} options on the command line
4458 (@pxref{MIPS Options}).
4460 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4461 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4462 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4463 may interact badly with some GCC extensions such as @code{__builtin_apply}
4464 (@pxref{Constructing Calls}).
4466 @item micromips, MIPS
4467 @itemx nomicromips, MIPS
4468 @cindex @code{micromips} function attribute
4469 @cindex @code{nomicromips} function attribute
4471 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4472 function attributes to locally select or turn off microMIPS code generation.
4473 A function with the @code{micromips} attribute is emitted as microMIPS code,
4474 while microMIPS code generation is disabled for functions with the
4475 @code{nomicromips} attribute. These attributes override the
4476 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4477 (@pxref{MIPS Options}).
4479 When compiling files containing mixed microMIPS and non-microMIPS code, the
4480 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4482 not that within individual functions. Mixed microMIPS and non-microMIPS code
4483 may interact badly with some GCC extensions such as @code{__builtin_apply}
4484 (@pxref{Constructing Calls}).
4487 @cindex @code{nocompression} function attribute, MIPS
4488 On MIPS targets, you can use the @code{nocompression} function attribute
4489 to locally turn off MIPS16 and microMIPS code generation. This attribute
4490 overrides the @option{-mips16} and @option{-mmicromips} options on the
4491 command line (@pxref{MIPS Options}).
4494 @node MSP430 Function Attributes
4495 @subsection MSP430 Function Attributes
4497 These function attributes are supported by the MSP430 back end:
4501 @cindex @code{critical} function attribute, MSP430
4502 Critical functions disable interrupts upon entry and restore the
4503 previous interrupt state upon exit. Critical functions cannot also
4504 have the @code{naked} or @code{reentrant} attributes. They can have
4505 the @code{interrupt} attribute.
4508 @cindex @code{interrupt} function attribute, MSP430
4509 Use this attribute to indicate
4510 that the specified function is an interrupt handler. The compiler generates
4511 function entry and exit sequences suitable for use in an interrupt handler
4512 when this attribute is present.
4514 You can provide an argument to the interrupt
4515 attribute which specifies a name or number. If the argument is a
4516 number it indicates the slot in the interrupt vector table (0 - 31) to
4517 which this handler should be assigned. If the argument is a name it
4518 is treated as a symbolic name for the vector slot. These names should
4519 match up with appropriate entries in the linker script. By default
4520 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4521 @code{reset} for vector 31 are recognized.
4524 @cindex @code{naked} function attribute, MSP430
4525 This attribute allows the compiler to construct the
4526 requisite function declaration, while allowing the body of the
4527 function to be assembly code. The specified function will not have
4528 prologue/epilogue sequences generated by the compiler. Only basic
4529 @code{asm} statements can safely be included in naked functions
4530 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4531 basic @code{asm} and C code may appear to work, they cannot be
4532 depended upon to work reliably and are not supported.
4535 @cindex @code{reentrant} function attribute, MSP430
4536 Reentrant functions disable interrupts upon entry and enable them
4537 upon exit. Reentrant functions cannot also have the @code{naked}
4538 or @code{critical} attributes. They can have the @code{interrupt}
4542 @cindex @code{wakeup} function attribute, MSP430
4543 This attribute only applies to interrupt functions. It is silently
4544 ignored if applied to a non-interrupt function. A wakeup interrupt
4545 function will rouse the processor from any low-power state that it
4546 might be in when the function exits.
4551 @cindex @code{lower} function attribute, MSP430
4552 @cindex @code{upper} function attribute, MSP430
4553 @cindex @code{either} function attribute, MSP430
4554 On the MSP430 target these attributes can be used to specify whether
4555 the function or variable should be placed into low memory, high
4556 memory, or the placement should be left to the linker to decide. The
4557 attributes are only significant if compiling for the MSP430X
4560 The attributes work in conjunction with a linker script that has been
4561 augmented to specify where to place sections with a @code{.lower} and
4562 a @code{.upper} prefix. So, for example, as well as placing the
4563 @code{.data} section, the script also specifies the placement of a
4564 @code{.lower.data} and a @code{.upper.data} section. The intention
4565 is that @code{lower} sections are placed into a small but easier to
4566 access memory region and the upper sections are placed into a larger, but
4567 slower to access, region.
4569 The @code{either} attribute is special. It tells the linker to place
4570 the object into the corresponding @code{lower} section if there is
4571 room for it. If there is insufficient room then the object is placed
4572 into the corresponding @code{upper} section instead. Note that the
4573 placement algorithm is not very sophisticated. It does not attempt to
4574 find an optimal packing of the @code{lower} sections. It just makes
4575 one pass over the objects and does the best that it can. Using the
4576 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4577 options can help the packing, however, since they produce smaller,
4578 easier to pack regions.
4581 @node NDS32 Function Attributes
4582 @subsection NDS32 Function Attributes
4584 These function attributes are supported by the NDS32 back end:
4588 @cindex @code{exception} function attribute
4589 @cindex exception handler functions, NDS32
4590 Use this attribute on the NDS32 target to indicate that the specified function
4591 is an exception handler. The compiler will generate corresponding sections
4592 for use in an exception handler.
4595 @cindex @code{interrupt} function attribute, NDS32
4596 On NDS32 target, this attribute indicates that the specified function
4597 is an interrupt handler. The compiler generates corresponding sections
4598 for use in an interrupt handler. You can use the following attributes
4599 to modify the behavior:
4602 @cindex @code{nested} function attribute, NDS32
4603 This interrupt service routine is interruptible.
4605 @cindex @code{not_nested} function attribute, NDS32
4606 This interrupt service routine is not interruptible.
4608 @cindex @code{nested_ready} function attribute, NDS32
4609 This interrupt service routine is interruptible after @code{PSW.GIE}
4610 (global interrupt enable) is set. This allows interrupt service routine to
4611 finish some short critical code before enabling interrupts.
4613 @cindex @code{save_all} function attribute, NDS32
4614 The system will help save all registers into stack before entering
4617 @cindex @code{partial_save} function attribute, NDS32
4618 The system will help save caller registers into stack before entering
4623 @cindex @code{naked} function attribute, NDS32
4624 This attribute allows the compiler to construct the
4625 requisite function declaration, while allowing the body of the
4626 function to be assembly code. The specified function will not have
4627 prologue/epilogue sequences generated by the compiler. Only basic
4628 @code{asm} statements can safely be included in naked functions
4629 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4630 basic @code{asm} and C code may appear to work, they cannot be
4631 depended upon to work reliably and are not supported.
4634 @cindex @code{reset} function attribute, NDS32
4635 @cindex reset handler functions
4636 Use this attribute on the NDS32 target to indicate that the specified function
4637 is a reset handler. The compiler will generate corresponding sections
4638 for use in a reset handler. You can use the following attributes
4639 to provide extra exception handling:
4642 @cindex @code{nmi} function attribute, NDS32
4643 Provide a user-defined function to handle NMI exception.
4645 @cindex @code{warm} function attribute, NDS32
4646 Provide a user-defined function to handle warm reset exception.
4650 @node Nios II Function Attributes
4651 @subsection Nios II Function Attributes
4653 These function attributes are supported by the Nios II back end:
4656 @item target (@var{options})
4657 @cindex @code{target} function attribute
4658 As discussed in @ref{Common Function Attributes}, this attribute
4659 allows specification of target-specific compilation options.
4661 When compiling for Nios II, the following options are allowed:
4664 @item custom-@var{insn}=@var{N}
4665 @itemx no-custom-@var{insn}
4666 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4667 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4668 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4669 custom instruction with encoding @var{N} when generating code that uses
4670 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4671 the custom instruction @var{insn}.
4672 These target attributes correspond to the
4673 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4674 command-line options, and support the same set of @var{insn} keywords.
4675 @xref{Nios II Options}, for more information.
4677 @item custom-fpu-cfg=@var{name}
4678 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4679 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4680 command-line option, to select a predefined set of custom instructions
4682 @xref{Nios II Options}, for more information.
4686 @node Nvidia PTX Function Attributes
4687 @subsection Nvidia PTX Function Attributes
4689 These function attributes are supported by the Nvidia PTX back end:
4693 @cindex @code{kernel} attribute, Nvidia PTX
4694 This attribute indicates that the corresponding function should be compiled
4695 as a kernel function, which can be invoked from the host via the CUDA RT
4697 By default functions are only callable only from other PTX functions.
4699 Kernel functions must have @code{void} return type.
4702 @node PowerPC Function Attributes
4703 @subsection PowerPC Function Attributes
4705 These function attributes are supported by the PowerPC back end:
4710 @cindex indirect calls, PowerPC
4711 @cindex @code{longcall} function attribute, PowerPC
4712 @cindex @code{shortcall} function attribute, PowerPC
4713 The @code{longcall} attribute
4714 indicates that the function might be far away from the call site and
4715 require a different (more expensive) calling sequence. The
4716 @code{shortcall} attribute indicates that the function is always close
4717 enough for the shorter calling sequence to be used. These attributes
4718 override both the @option{-mlongcall} switch and
4719 the @code{#pragma longcall} setting.
4721 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4722 calls are necessary.
4724 @item target (@var{options})
4725 @cindex @code{target} function attribute
4726 As discussed in @ref{Common Function Attributes}, this attribute
4727 allows specification of target-specific compilation options.
4729 On the PowerPC, the following options are allowed:
4734 @cindex @code{target("altivec")} function attribute, PowerPC
4735 Generate code that uses (does not use) AltiVec instructions. In
4736 32-bit code, you cannot enable AltiVec instructions unless
4737 @option{-mabi=altivec} is used on the command line.
4741 @cindex @code{target("cmpb")} function attribute, PowerPC
4742 Generate code that uses (does not use) the compare bytes instruction
4743 implemented on the POWER6 processor and other processors that support
4744 the PowerPC V2.05 architecture.
4748 @cindex @code{target("dlmzb")} function attribute, PowerPC
4749 Generate code that uses (does not use) the string-search @samp{dlmzb}
4750 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4751 generated by default when targeting those processors.
4755 @cindex @code{target("fprnd")} function attribute, PowerPC
4756 Generate code that uses (does not use) the FP round to integer
4757 instructions implemented on the POWER5+ processor and other processors
4758 that support the PowerPC V2.03 architecture.
4762 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4763 Generate code that uses (does not use) the decimal floating-point
4764 instructions implemented on some POWER processors.
4768 @cindex @code{target("isel")} function attribute, PowerPC
4769 Generate code that uses (does not use) ISEL instruction.
4773 @cindex @code{target("mfcrf")} function attribute, PowerPC
4774 Generate code that uses (does not use) the move from condition
4775 register field instruction implemented on the POWER4 processor and
4776 other processors that support the PowerPC V2.01 architecture.
4780 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4781 Generate code that uses (does not use) the FP move to/from general
4782 purpose register instructions implemented on the POWER6X processor and
4783 other processors that support the extended PowerPC V2.05 architecture.
4787 @cindex @code{target("mulhw")} function attribute, PowerPC
4788 Generate code that uses (does not use) the half-word multiply and
4789 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4790 These instructions are generated by default when targeting those
4795 @cindex @code{target("multiple")} function attribute, PowerPC
4796 Generate code that uses (does not use) the load multiple word
4797 instructions and the store multiple word instructions.
4801 @cindex @code{target("update")} function attribute, PowerPC
4802 Generate code that uses (does not use) the load or store instructions
4803 that update the base register to the address of the calculated memory
4808 @cindex @code{target("popcntb")} function attribute, PowerPC
4809 Generate code that uses (does not use) the popcount and double-precision
4810 FP reciprocal estimate instruction implemented on the POWER5
4811 processor and other processors that support the PowerPC V2.02
4816 @cindex @code{target("popcntd")} function attribute, PowerPC
4817 Generate code that uses (does not use) the popcount instruction
4818 implemented on the POWER7 processor and other processors that support
4819 the PowerPC V2.06 architecture.
4821 @item powerpc-gfxopt
4822 @itemx no-powerpc-gfxopt
4823 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4824 Generate code that uses (does not use) the optional PowerPC
4825 architecture instructions in the Graphics group, including
4826 floating-point select.
4829 @itemx no-powerpc-gpopt
4830 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4831 Generate code that uses (does not use) the optional PowerPC
4832 architecture instructions in the General Purpose group, including
4833 floating-point square root.
4835 @item recip-precision
4836 @itemx no-recip-precision
4837 @cindex @code{target("recip-precision")} function attribute, PowerPC
4838 Assume (do not assume) that the reciprocal estimate instructions
4839 provide higher-precision estimates than is mandated by the PowerPC
4844 @cindex @code{target("string")} function attribute, PowerPC
4845 Generate code that uses (does not use) the load string instructions
4846 and the store string word instructions to save multiple registers and
4847 do small block moves.
4851 @cindex @code{target("vsx")} function attribute, PowerPC
4852 Generate code that uses (does not use) vector/scalar (VSX)
4853 instructions, and also enable the use of built-in functions that allow
4854 more direct access to the VSX instruction set. In 32-bit code, you
4855 cannot enable VSX or AltiVec instructions unless
4856 @option{-mabi=altivec} is used on the command line.
4860 @cindex @code{target("friz")} function attribute, PowerPC
4861 Generate (do not generate) the @code{friz} instruction when the
4862 @option{-funsafe-math-optimizations} option is used to optimize
4863 rounding a floating-point value to 64-bit integer and back to floating
4864 point. The @code{friz} instruction does not return the same value if
4865 the floating-point number is too large to fit in an integer.
4867 @item avoid-indexed-addresses
4868 @itemx no-avoid-indexed-addresses
4869 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4870 Generate code that tries to avoid (not avoid) the use of indexed load
4871 or store instructions.
4875 @cindex @code{target("paired")} function attribute, PowerPC
4876 Generate code that uses (does not use) the generation of PAIRED simd
4881 @cindex @code{target("longcall")} function attribute, PowerPC
4882 Generate code that assumes (does not assume) that all calls are far
4883 away so that a longer more expensive calling sequence is required.
4886 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4887 Specify the architecture to generate code for when compiling the
4888 function. If you select the @code{target("cpu=power7")} attribute when
4889 generating 32-bit code, VSX and AltiVec instructions are not generated
4890 unless you use the @option{-mabi=altivec} option on the command line.
4892 @item tune=@var{TUNE}
4893 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4894 Specify the architecture to tune for when compiling the function. If
4895 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4896 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4897 compilation tunes for the @var{CPU} architecture, and not the
4898 default tuning specified on the command line.
4901 On the PowerPC, the inliner does not inline a
4902 function that has different target options than the caller, unless the
4903 callee has a subset of the target options of the caller.
4906 @node RL78 Function Attributes
4907 @subsection RL78 Function Attributes
4909 These function attributes are supported by the RL78 back end:
4913 @itemx brk_interrupt
4914 @cindex @code{interrupt} function attribute, RL78
4915 @cindex @code{brk_interrupt} function attribute, RL78
4916 These attributes indicate
4917 that the specified function is an interrupt handler. The compiler generates
4918 function entry and exit sequences suitable for use in an interrupt handler
4919 when this attribute is present.
4921 Use @code{brk_interrupt} instead of @code{interrupt} for
4922 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4923 that must end with @code{RETB} instead of @code{RETI}).
4926 @cindex @code{naked} function attribute, RL78
4927 This attribute allows the compiler to construct the
4928 requisite function declaration, while allowing the body of the
4929 function to be assembly code. The specified function will not have
4930 prologue/epilogue sequences generated by the compiler. Only basic
4931 @code{asm} statements can safely be included in naked functions
4932 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4933 basic @code{asm} and C code may appear to work, they cannot be
4934 depended upon to work reliably and are not supported.
4937 @node RX Function Attributes
4938 @subsection RX Function Attributes
4940 These function attributes are supported by the RX back end:
4943 @item fast_interrupt
4944 @cindex @code{fast_interrupt} function attribute, RX
4945 Use this attribute on the RX port to indicate that the specified
4946 function is a fast interrupt handler. This is just like the
4947 @code{interrupt} attribute, except that @code{freit} is used to return
4948 instead of @code{reit}.
4951 @cindex @code{interrupt} function attribute, RX
4952 Use this attribute to indicate
4953 that the specified function is an interrupt handler. The compiler generates
4954 function entry and exit sequences suitable for use in an interrupt handler
4955 when this attribute is present.
4957 On RX targets, you may specify one or more vector numbers as arguments
4958 to the attribute, as well as naming an alternate table name.
4959 Parameters are handled sequentially, so one handler can be assigned to
4960 multiple entries in multiple tables. One may also pass the magic
4961 string @code{"$default"} which causes the function to be used for any
4962 unfilled slots in the current table.
4964 This example shows a simple assignment of a function to one vector in
4965 the default table (note that preprocessor macros may be used for
4966 chip-specific symbolic vector names):
4968 void __attribute__ ((interrupt (5))) txd1_handler ();
4971 This example assigns a function to two slots in the default table
4972 (using preprocessor macros defined elsewhere) and makes it the default
4973 for the @code{dct} table:
4975 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4980 @cindex @code{naked} function attribute, RX
4981 This attribute allows the compiler to construct the
4982 requisite function declaration, while allowing the body of the
4983 function to be assembly code. The specified function will not have
4984 prologue/epilogue sequences generated by the compiler. Only basic
4985 @code{asm} statements can safely be included in naked functions
4986 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4987 basic @code{asm} and C code may appear to work, they cannot be
4988 depended upon to work reliably and are not supported.
4991 @cindex @code{vector} function attribute, RX
4992 This RX attribute is similar to the @code{interrupt} attribute, including its
4993 parameters, but does not make the function an interrupt-handler type
4994 function (i.e. it retains the normal C function calling ABI). See the
4995 @code{interrupt} attribute for a description of its arguments.
4998 @node S/390 Function Attributes
4999 @subsection S/390 Function Attributes
5001 These function attributes are supported on the S/390:
5004 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5005 @cindex @code{hotpatch} function attribute, S/390
5007 On S/390 System z targets, you can use this function attribute to
5008 make GCC generate a ``hot-patching'' function prologue. If the
5009 @option{-mhotpatch=} command-line option is used at the same time,
5010 the @code{hotpatch} attribute takes precedence. The first of the
5011 two arguments specifies the number of halfwords to be added before
5012 the function label. A second argument can be used to specify the
5013 number of halfwords to be added after the function label. For
5014 both arguments the maximum allowed value is 1000000.
5016 If both arguments are zero, hotpatching is disabled.
5018 @item target (@var{options})
5019 @cindex @code{target} function attribute
5020 As discussed in @ref{Common Function Attributes}, this attribute
5021 allows specification of target-specific compilation options.
5023 On S/390, the following options are supported:
5031 @item warn-framesize=
5043 @itemx no-packed-stack
5045 @itemx no-small-exec
5048 @item warn-dynamicstack
5049 @itemx no-warn-dynamicstack
5052 The options work exactly like the S/390 specific command line
5053 options (without the prefix @option{-m}) except that they do not
5054 change any feature macros. For example,
5057 @code{target("no-vx")}
5060 does not undefine the @code{__VEC__} macro.
5063 @node SH Function Attributes
5064 @subsection SH Function Attributes
5066 These function attributes are supported on the SH family of processors:
5069 @item function_vector
5070 @cindex @code{function_vector} function attribute, SH
5071 @cindex calling functions through the function vector on SH2A
5072 On SH2A targets, this attribute declares a function to be called using the
5073 TBR relative addressing mode. The argument to this attribute is the entry
5074 number of the same function in a vector table containing all the TBR
5075 relative addressable functions. For correct operation the TBR must be setup
5076 accordingly to point to the start of the vector table before any functions with
5077 this attribute are invoked. Usually a good place to do the initialization is
5078 the startup routine. The TBR relative vector table can have at max 256 function
5079 entries. The jumps to these functions are generated using a SH2A specific,
5080 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
5081 from GNU binutils version 2.7 or later for this attribute to work correctly.
5083 In an application, for a function being called once, this attribute
5084 saves at least 8 bytes of code; and if other successive calls are being
5085 made to the same function, it saves 2 bytes of code per each of these
5088 @item interrupt_handler
5089 @cindex @code{interrupt_handler} function attribute, SH
5090 Use this attribute to
5091 indicate that the specified function is an interrupt handler. The compiler
5092 generates function entry and exit sequences suitable for use in an
5093 interrupt handler when this attribute is present.
5095 @item nosave_low_regs
5096 @cindex @code{nosave_low_regs} function attribute, SH
5097 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5098 function should not save and restore registers R0..R7. This can be used on SH3*
5099 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5103 @cindex @code{renesas} function attribute, SH
5104 On SH targets this attribute specifies that the function or struct follows the
5108 @cindex @code{resbank} function attribute, SH
5109 On the SH2A target, this attribute enables the high-speed register
5110 saving and restoration using a register bank for @code{interrupt_handler}
5111 routines. Saving to the bank is performed automatically after the CPU
5112 accepts an interrupt that uses a register bank.
5114 The nineteen 32-bit registers comprising general register R0 to R14,
5115 control register GBR, and system registers MACH, MACL, and PR and the
5116 vector table address offset are saved into a register bank. Register
5117 banks are stacked in first-in last-out (FILO) sequence. Restoration
5118 from the bank is executed by issuing a RESBANK instruction.
5121 @cindex @code{sp_switch} function attribute, SH
5122 Use this attribute on the SH to indicate an @code{interrupt_handler}
5123 function should switch to an alternate stack. It expects a string
5124 argument that names a global variable holding the address of the
5129 void f () __attribute__ ((interrupt_handler,
5130 sp_switch ("alt_stack")));
5134 @cindex @code{trap_exit} function attribute, SH
5135 Use this attribute on the SH for an @code{interrupt_handler} to return using
5136 @code{trapa} instead of @code{rte}. This attribute expects an integer
5137 argument specifying the trap number to be used.
5140 @cindex @code{trapa_handler} function attribute, SH
5141 On SH targets this function attribute is similar to @code{interrupt_handler}
5142 but it does not save and restore all registers.
5145 @node SPU Function Attributes
5146 @subsection SPU Function Attributes
5148 These function attributes are supported by the SPU back end:
5152 @cindex @code{naked} function attribute, SPU
5153 This attribute allows the compiler to construct the
5154 requisite function declaration, while allowing the body of the
5155 function to be assembly code. The specified function will not have
5156 prologue/epilogue sequences generated by the compiler. Only basic
5157 @code{asm} statements can safely be included in naked functions
5158 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5159 basic @code{asm} and C code may appear to work, they cannot be
5160 depended upon to work reliably and are not supported.
5163 @node Symbian OS Function Attributes
5164 @subsection Symbian OS Function Attributes
5166 @xref{Microsoft Windows Function Attributes}, for discussion of the
5167 @code{dllexport} and @code{dllimport} attributes.
5169 @node V850 Function Attributes
5170 @subsection V850 Function Attributes
5172 The V850 back end supports these function attributes:
5176 @itemx interrupt_handler
5177 @cindex @code{interrupt} function attribute, V850
5178 @cindex @code{interrupt_handler} function attribute, V850
5179 Use these attributes to indicate
5180 that the specified function is an interrupt handler. The compiler generates
5181 function entry and exit sequences suitable for use in an interrupt handler
5182 when either attribute is present.
5185 @node Visium Function Attributes
5186 @subsection Visium Function Attributes
5188 These function attributes are supported by the Visium back end:
5192 @cindex @code{interrupt} function attribute, Visium
5193 Use this attribute to indicate
5194 that the specified function is an interrupt handler. The compiler generates
5195 function entry and exit sequences suitable for use in an interrupt handler
5196 when this attribute is present.
5199 @node x86 Function Attributes
5200 @subsection x86 Function Attributes
5202 These function attributes are supported by the x86 back end:
5206 @cindex @code{cdecl} function attribute, x86-32
5207 @cindex functions that pop the argument stack on x86-32
5209 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5210 assume that the calling function pops off the stack space used to
5211 pass arguments. This is
5212 useful to override the effects of the @option{-mrtd} switch.
5215 @cindex @code{fastcall} function attribute, x86-32
5216 @cindex functions that pop the argument stack on x86-32
5217 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5218 pass the first argument (if of integral type) in the register ECX and
5219 the second argument (if of integral type) in the register EDX@. Subsequent
5220 and other typed arguments are passed on the stack. The called function
5221 pops the arguments off the stack. If the number of arguments is variable all
5222 arguments are pushed on the stack.
5225 @cindex @code{thiscall} function attribute, x86-32
5226 @cindex functions that pop the argument stack on x86-32
5227 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5228 pass the first argument (if of integral type) in the register ECX.
5229 Subsequent and other typed arguments are passed on the stack. The called
5230 function pops the arguments off the stack.
5231 If the number of arguments is variable all arguments are pushed on the
5233 The @code{thiscall} attribute is intended for C++ non-static member functions.
5234 As a GCC extension, this calling convention can be used for C functions
5235 and for static member methods.
5239 @cindex @code{ms_abi} function attribute, x86
5240 @cindex @code{sysv_abi} function attribute, x86
5242 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5243 to indicate which calling convention should be used for a function. The
5244 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5245 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5246 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5247 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5249 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5250 requires the @option{-maccumulate-outgoing-args} option.
5252 @item callee_pop_aggregate_return (@var{number})
5253 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5255 On x86-32 targets, you can use this attribute to control how
5256 aggregates are returned in memory. If the caller is responsible for
5257 popping the hidden pointer together with the rest of the arguments, specify
5258 @var{number} equal to zero. If callee is responsible for popping the
5259 hidden pointer, specify @var{number} equal to one.
5261 The default x86-32 ABI assumes that the callee pops the
5262 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5263 the compiler assumes that the
5264 caller pops the stack for hidden pointer.
5266 @item ms_hook_prologue
5267 @cindex @code{ms_hook_prologue} function attribute, x86
5269 On 32-bit and 64-bit x86 targets, you can use
5270 this function attribute to make GCC generate the ``hot-patching'' function
5271 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5274 @item regparm (@var{number})
5275 @cindex @code{regparm} function attribute, x86
5276 @cindex functions that are passed arguments in registers on x86-32
5277 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5278 pass arguments number one to @var{number} if they are of integral type
5279 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5280 take a variable number of arguments continue to be passed all of their
5281 arguments on the stack.
5283 Beware that on some ELF systems this attribute is unsuitable for
5284 global functions in shared libraries with lazy binding (which is the
5285 default). Lazy binding sends the first call via resolving code in
5286 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5287 per the standard calling conventions. Solaris 8 is affected by this.
5288 Systems with the GNU C Library version 2.1 or higher
5289 and FreeBSD are believed to be
5290 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5291 disabled with the linker or the loader if desired, to avoid the
5295 @cindex @code{sseregparm} function attribute, x86
5296 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5297 causes the compiler to pass up to 3 floating-point arguments in
5298 SSE registers instead of on the stack. Functions that take a
5299 variable number of arguments continue to pass all of their
5300 floating-point arguments on the stack.
5302 @item force_align_arg_pointer
5303 @cindex @code{force_align_arg_pointer} function attribute, x86
5304 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5305 applied to individual function definitions, generating an alternate
5306 prologue and epilogue that realigns the run-time stack if necessary.
5307 This supports mixing legacy codes that run with a 4-byte aligned stack
5308 with modern codes that keep a 16-byte stack for SSE compatibility.
5311 @cindex @code{stdcall} function attribute, x86-32
5312 @cindex functions that pop the argument stack on x86-32
5313 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5314 assume that the called function pops off the stack space used to
5315 pass arguments, unless it takes a variable number of arguments.
5317 @item no_caller_saved_registers
5318 @cindex @code{no_caller_saved_registers} function attribute, x86
5319 Use this attribute to indicate that the specified function has no
5320 caller-saved registers. That is, all registers are callee-saved. For
5321 example, this attribute can be used for a function called from an
5322 interrupt handler. The compiler generates proper function entry and
5323 exit sequences to save and restore any modified registers, except for
5324 the EFLAGS register. Since GCC doesn't preserve MPX, SSE, MMX nor x87
5325 states, the GCC option @option{-mgeneral-regs-only} should be used to
5326 compile functions with @code{no_caller_saved_registers} attribute.
5329 @cindex @code{interrupt} function attribute, x86
5330 Use this attribute to indicate that the specified function is an
5331 interrupt handler or an exception handler (depending on parameters passed
5332 to the function, explained further). The compiler generates function
5333 entry and exit sequences suitable for use in an interrupt handler when
5334 this attribute is present. The @code{IRET} instruction, instead of the
5335 @code{RET} instruction, is used to return from interrupt handlers. All
5336 registers, except for the EFLAGS register which is restored by the
5337 @code{IRET} instruction, are preserved by the compiler. Since GCC
5338 doesn't preserve MPX, SSE, MMX nor x87 states, the GCC option
5339 @option{-mgeneral-regs-only} should be used to compile interrupt and
5342 Any interruptible-without-stack-switch code must be compiled with
5343 @option{-mno-red-zone} since interrupt handlers can and will, because
5344 of the hardware design, touch the red zone.
5346 An interrupt handler must be declared with a mandatory pointer
5350 struct interrupt_frame;
5352 __attribute__ ((interrupt))
5354 f (struct interrupt_frame *frame)
5360 and you must define @code{struct interrupt_frame} as described in the
5363 Exception handlers differ from interrupt handlers because the system
5364 pushes an error code on the stack. An exception handler declaration is
5365 similar to that for an interrupt handler, but with a different mandatory
5366 function signature. The compiler arranges to pop the error code off the
5367 stack before the @code{IRET} instruction.
5371 typedef unsigned long long int uword_t;
5373 typedef unsigned int uword_t;
5376 struct interrupt_frame;
5378 __attribute__ ((interrupt))
5380 f (struct interrupt_frame *frame, uword_t error_code)
5386 Exception handlers should only be used for exceptions that push an error
5387 code; you should use an interrupt handler in other cases. The system
5388 will crash if the wrong kind of handler is used.
5390 @item target (@var{options})
5391 @cindex @code{target} function attribute
5392 As discussed in @ref{Common Function Attributes}, this attribute
5393 allows specification of target-specific compilation options.
5395 On the x86, the following options are allowed:
5399 @cindex @code{target("abm")} function attribute, x86
5400 Enable/disable the generation of the advanced bit instructions.
5404 @cindex @code{target("aes")} function attribute, x86
5405 Enable/disable the generation of the AES instructions.
5408 @cindex @code{target("default")} function attribute, x86
5409 @xref{Function Multiversioning}, where it is used to specify the
5410 default function version.
5414 @cindex @code{target("mmx")} function attribute, x86
5415 Enable/disable the generation of the MMX instructions.
5419 @cindex @code{target("pclmul")} function attribute, x86
5420 Enable/disable the generation of the PCLMUL instructions.
5424 @cindex @code{target("popcnt")} function attribute, x86
5425 Enable/disable the generation of the POPCNT instruction.
5429 @cindex @code{target("sse")} function attribute, x86
5430 Enable/disable the generation of the SSE instructions.
5434 @cindex @code{target("sse2")} function attribute, x86
5435 Enable/disable the generation of the SSE2 instructions.
5439 @cindex @code{target("sse3")} function attribute, x86
5440 Enable/disable the generation of the SSE3 instructions.
5444 @cindex @code{target("sse4")} function attribute, x86
5445 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5450 @cindex @code{target("sse4.1")} function attribute, x86
5451 Enable/disable the generation of the sse4.1 instructions.
5455 @cindex @code{target("sse4.2")} function attribute, x86
5456 Enable/disable the generation of the sse4.2 instructions.
5460 @cindex @code{target("sse4a")} function attribute, x86
5461 Enable/disable the generation of the SSE4A instructions.
5465 @cindex @code{target("fma4")} function attribute, x86
5466 Enable/disable the generation of the FMA4 instructions.
5470 @cindex @code{target("xop")} function attribute, x86
5471 Enable/disable the generation of the XOP instructions.
5475 @cindex @code{target("lwp")} function attribute, x86
5476 Enable/disable the generation of the LWP instructions.
5480 @cindex @code{target("ssse3")} function attribute, x86
5481 Enable/disable the generation of the SSSE3 instructions.
5485 @cindex @code{target("cld")} function attribute, x86
5486 Enable/disable the generation of the CLD before string moves.
5488 @item fancy-math-387
5489 @itemx no-fancy-math-387
5490 @cindex @code{target("fancy-math-387")} function attribute, x86
5491 Enable/disable the generation of the @code{sin}, @code{cos}, and
5492 @code{sqrt} instructions on the 387 floating-point unit.
5496 @cindex @code{target("ieee-fp")} function attribute, x86
5497 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5499 @item inline-all-stringops
5500 @itemx no-inline-all-stringops
5501 @cindex @code{target("inline-all-stringops")} function attribute, x86
5502 Enable/disable inlining of string operations.
5504 @item inline-stringops-dynamically
5505 @itemx no-inline-stringops-dynamically
5506 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5507 Enable/disable the generation of the inline code to do small string
5508 operations and calling the library routines for large operations.
5510 @item align-stringops
5511 @itemx no-align-stringops
5512 @cindex @code{target("align-stringops")} function attribute, x86
5513 Do/do not align destination of inlined string operations.
5517 @cindex @code{target("recip")} function attribute, x86
5518 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5519 instructions followed an additional Newton-Raphson step instead of
5520 doing a floating-point division.
5522 @item arch=@var{ARCH}
5523 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5524 Specify the architecture to generate code for in compiling the function.
5526 @item tune=@var{TUNE}
5527 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5528 Specify the architecture to tune for in compiling the function.
5530 @item fpmath=@var{FPMATH}
5531 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5532 Specify which floating-point unit to use. You must specify the
5533 @code{target("fpmath=sse,387")} option as
5534 @code{target("fpmath=sse+387")} because the comma would separate
5538 On the x86, the inliner does not inline a
5539 function that has different target options than the caller, unless the
5540 callee has a subset of the target options of the caller. For example
5541 a function declared with @code{target("sse3")} can inline a function
5542 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5545 @node Xstormy16 Function Attributes
5546 @subsection Xstormy16 Function Attributes
5548 These function attributes are supported by the Xstormy16 back end:
5552 @cindex @code{interrupt} function attribute, Xstormy16
5553 Use this attribute to indicate
5554 that the specified function is an interrupt handler. The compiler generates
5555 function entry and exit sequences suitable for use in an interrupt handler
5556 when this attribute is present.
5559 @node Variable Attributes
5560 @section Specifying Attributes of Variables
5561 @cindex attribute of variables
5562 @cindex variable attributes
5564 The keyword @code{__attribute__} allows you to specify special
5565 attributes of variables or structure fields. This keyword is followed
5566 by an attribute specification inside double parentheses. Some
5567 attributes are currently defined generically for variables.
5568 Other attributes are defined for variables on particular target
5569 systems. Other attributes are available for functions
5570 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5571 enumerators (@pxref{Enumerator Attributes}), statements
5572 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
5573 Other front ends might define more attributes
5574 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5576 @xref{Attribute Syntax}, for details of the exact syntax for using
5580 * Common Variable Attributes::
5581 * AVR Variable Attributes::
5582 * Blackfin Variable Attributes::
5583 * H8/300 Variable Attributes::
5584 * IA-64 Variable Attributes::
5585 * M32R/D Variable Attributes::
5586 * MeP Variable Attributes::
5587 * Microsoft Windows Variable Attributes::
5588 * MSP430 Variable Attributes::
5589 * Nvidia PTX Variable Attributes::
5590 * PowerPC Variable Attributes::
5591 * RL78 Variable Attributes::
5592 * SPU Variable Attributes::
5593 * V850 Variable Attributes::
5594 * x86 Variable Attributes::
5595 * Xstormy16 Variable Attributes::
5598 @node Common Variable Attributes
5599 @subsection Common Variable Attributes
5601 The following attributes are supported on most targets.
5604 @cindex @code{aligned} variable attribute
5605 @item aligned (@var{alignment})
5606 This attribute specifies a minimum alignment for the variable or
5607 structure field, measured in bytes. For example, the declaration:
5610 int x __attribute__ ((aligned (16))) = 0;
5614 causes the compiler to allocate the global variable @code{x} on a
5615 16-byte boundary. On a 68040, this could be used in conjunction with
5616 an @code{asm} expression to access the @code{move16} instruction which
5617 requires 16-byte aligned operands.
5619 You can also specify the alignment of structure fields. For example, to
5620 create a double-word aligned @code{int} pair, you could write:
5623 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5627 This is an alternative to creating a union with a @code{double} member,
5628 which forces the union to be double-word aligned.
5630 As in the preceding examples, you can explicitly specify the alignment
5631 (in bytes) that you wish the compiler to use for a given variable or
5632 structure field. Alternatively, you can leave out the alignment factor
5633 and just ask the compiler to align a variable or field to the
5634 default alignment for the target architecture you are compiling for.
5635 The default alignment is sufficient for all scalar types, but may not be
5636 enough for all vector types on a target that supports vector operations.
5637 The default alignment is fixed for a particular target ABI.
5639 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5640 which is the largest alignment ever used for any data type on the
5641 target machine you are compiling for. For example, you could write:
5644 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5647 The compiler automatically sets the alignment for the declared
5648 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5649 often make copy operations more efficient, because the compiler can
5650 use whatever instructions copy the biggest chunks of memory when
5651 performing copies to or from the variables or fields that you have
5652 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5653 may change depending on command-line options.
5655 When used on a struct, or struct member, the @code{aligned} attribute can
5656 only increase the alignment; in order to decrease it, the @code{packed}
5657 attribute must be specified as well. When used as part of a typedef, the
5658 @code{aligned} attribute can both increase and decrease alignment, and
5659 specifying the @code{packed} attribute generates a warning.
5661 Note that the effectiveness of @code{aligned} attributes may be limited
5662 by inherent limitations in your linker. On many systems, the linker is
5663 only able to arrange for variables to be aligned up to a certain maximum
5664 alignment. (For some linkers, the maximum supported alignment may
5665 be very very small.) If your linker is only able to align variables
5666 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5667 in an @code{__attribute__} still only provides you with 8-byte
5668 alignment. See your linker documentation for further information.
5670 The @code{aligned} attribute can also be used for functions
5671 (@pxref{Common Function Attributes}.)
5673 @item cleanup (@var{cleanup_function})
5674 @cindex @code{cleanup} variable attribute
5675 The @code{cleanup} attribute runs a function when the variable goes
5676 out of scope. This attribute can only be applied to auto function
5677 scope variables; it may not be applied to parameters or variables
5678 with static storage duration. The function must take one parameter,
5679 a pointer to a type compatible with the variable. The return value
5680 of the function (if any) is ignored.
5682 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5683 is run during the stack unwinding that happens during the
5684 processing of the exception. Note that the @code{cleanup} attribute
5685 does not allow the exception to be caught, only to perform an action.
5686 It is undefined what happens if @var{cleanup_function} does not
5691 @cindex @code{common} variable attribute
5692 @cindex @code{nocommon} variable attribute
5695 The @code{common} attribute requests GCC to place a variable in
5696 ``common'' storage. The @code{nocommon} attribute requests the
5697 opposite---to allocate space for it directly.
5699 These attributes override the default chosen by the
5700 @option{-fno-common} and @option{-fcommon} flags respectively.
5703 @itemx deprecated (@var{msg})
5704 @cindex @code{deprecated} variable attribute
5705 The @code{deprecated} attribute results in a warning if the variable
5706 is used anywhere in the source file. This is useful when identifying
5707 variables that are expected to be removed in a future version of a
5708 program. The warning also includes the location of the declaration
5709 of the deprecated variable, to enable users to easily find further
5710 information about why the variable is deprecated, or what they should
5711 do instead. Note that the warning only occurs for uses:
5714 extern int old_var __attribute__ ((deprecated));
5716 int new_fn () @{ return old_var; @}
5720 results in a warning on line 3 but not line 2. The optional @var{msg}
5721 argument, which must be a string, is printed in the warning if
5724 The @code{deprecated} attribute can also be used for functions and
5725 types (@pxref{Common Function Attributes},
5726 @pxref{Common Type Attributes}).
5728 @item mode (@var{mode})
5729 @cindex @code{mode} variable attribute
5730 This attribute specifies the data type for the declaration---whichever
5731 type corresponds to the mode @var{mode}. This in effect lets you
5732 request an integer or floating-point type according to its width.
5734 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
5735 for a list of the possible keywords for @var{mode}.
5736 You may also specify a mode of @code{byte} or @code{__byte__} to
5737 indicate the mode corresponding to a one-byte integer, @code{word} or
5738 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5739 or @code{__pointer__} for the mode used to represent pointers.
5742 @cindex @code{packed} variable attribute
5743 The @code{packed} attribute specifies that a variable or structure field
5744 should have the smallest possible alignment---one byte for a variable,
5745 and one bit for a field, unless you specify a larger value with the
5746 @code{aligned} attribute.
5748 Here is a structure in which the field @code{x} is packed, so that it
5749 immediately follows @code{a}:
5755 int x[2] __attribute__ ((packed));
5759 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5760 @code{packed} attribute on bit-fields of type @code{char}. This has
5761 been fixed in GCC 4.4 but the change can lead to differences in the
5762 structure layout. See the documentation of
5763 @option{-Wpacked-bitfield-compat} for more information.
5765 @item section ("@var{section-name}")
5766 @cindex @code{section} variable attribute
5767 Normally, the compiler places the objects it generates in sections like
5768 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5769 or you need certain particular variables to appear in special sections,
5770 for example to map to special hardware. The @code{section}
5771 attribute specifies that a variable (or function) lives in a particular
5772 section. For example, this small program uses several specific section names:
5775 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5776 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5777 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5778 int init_data __attribute__ ((section ("INITDATA")));
5782 /* @r{Initialize stack pointer} */
5783 init_sp (stack + sizeof (stack));
5785 /* @r{Initialize initialized data} */
5786 memcpy (&init_data, &data, &edata - &data);
5788 /* @r{Turn on the serial ports} */
5795 Use the @code{section} attribute with
5796 @emph{global} variables and not @emph{local} variables,
5797 as shown in the example.
5799 You may use the @code{section} attribute with initialized or
5800 uninitialized global variables but the linker requires
5801 each object be defined once, with the exception that uninitialized
5802 variables tentatively go in the @code{common} (or @code{bss}) section
5803 and can be multiply ``defined''. Using the @code{section} attribute
5804 changes what section the variable goes into and may cause the
5805 linker to issue an error if an uninitialized variable has multiple
5806 definitions. You can force a variable to be initialized with the
5807 @option{-fno-common} flag or the @code{nocommon} attribute.
5809 Some file formats do not support arbitrary sections so the @code{section}
5810 attribute is not available on all platforms.
5811 If you need to map the entire contents of a module to a particular
5812 section, consider using the facilities of the linker instead.
5814 @item tls_model ("@var{tls_model}")
5815 @cindex @code{tls_model} variable attribute
5816 The @code{tls_model} attribute sets thread-local storage model
5817 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5818 overriding @option{-ftls-model=} command-line switch on a per-variable
5820 The @var{tls_model} argument should be one of @code{global-dynamic},
5821 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5823 Not all targets support this attribute.
5826 @cindex @code{unused} variable attribute
5827 This attribute, attached to a variable, means that the variable is meant
5828 to be possibly unused. GCC does not produce a warning for this
5832 @cindex @code{used} variable attribute
5833 This attribute, attached to a variable with static storage, means that
5834 the variable must be emitted even if it appears that the variable is not
5837 When applied to a static data member of a C++ class template, the
5838 attribute also means that the member is instantiated if the
5839 class itself is instantiated.
5841 @item vector_size (@var{bytes})
5842 @cindex @code{vector_size} variable attribute
5843 This attribute specifies the vector size for the variable, measured in
5844 bytes. For example, the declaration:
5847 int foo __attribute__ ((vector_size (16)));
5851 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5852 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5853 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5855 This attribute is only applicable to integral and float scalars,
5856 although arrays, pointers, and function return values are allowed in
5857 conjunction with this construct.
5859 Aggregates with this attribute are invalid, even if they are of the same
5860 size as a corresponding scalar. For example, the declaration:
5863 struct S @{ int a; @};
5864 struct S __attribute__ ((vector_size (16))) foo;
5868 is invalid even if the size of the structure is the same as the size of
5871 @item visibility ("@var{visibility_type}")
5872 @cindex @code{visibility} variable attribute
5873 This attribute affects the linkage of the declaration to which it is attached.
5874 The @code{visibility} attribute is described in
5875 @ref{Common Function Attributes}.
5878 @cindex @code{weak} variable attribute
5879 The @code{weak} attribute is described in
5880 @ref{Common Function Attributes}.
5884 @node AVR Variable Attributes
5885 @subsection AVR Variable Attributes
5889 @cindex @code{progmem} variable attribute, AVR
5890 The @code{progmem} attribute is used on the AVR to place read-only
5891 data in the non-volatile program memory (flash). The @code{progmem}
5892 attribute accomplishes this by putting respective variables into a
5893 section whose name starts with @code{.progmem}.
5895 This attribute works similar to the @code{section} attribute
5896 but adds additional checking.
5899 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
5900 @code{progmem} affects the location
5901 of the data but not how this data is accessed.
5902 In order to read data located with the @code{progmem} attribute
5903 (inline) assembler must be used.
5905 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5906 #include <avr/pgmspace.h>
5908 /* Locate var in flash memory */
5909 const int var[2] PROGMEM = @{ 1, 2 @};
5911 int read_var (int i)
5913 /* Access var[] by accessor macro from avr/pgmspace.h */
5914 return (int) pgm_read_word (& var[i]);
5918 AVR is a Harvard architecture processor and data and read-only data
5919 normally resides in the data memory (RAM).
5921 See also the @ref{AVR Named Address Spaces} section for
5922 an alternate way to locate and access data in flash memory.
5924 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
5925 The compiler adds @code{0x4000}
5926 to the addresses of objects and declarations in @code{progmem} and locates
5927 the objects in flash memory, namely in section @code{.progmem.data}.
5928 The offset is needed because the flash memory is visible in the RAM
5929 address space starting at address @code{0x4000}.
5931 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
5932 no special functions or macros are needed.
5935 /* var is located in flash memory */
5936 extern const int var[2] __attribute__((progmem));
5938 int read_var (int i)
5944 Please notice that on these devices, there is no need for @code{progmem}
5945 at all. Just use an appropriate linker description file like outlined below.
5951 /* Leave .rodata in flash and add an offset of 0x4000 to all
5952 addresses so that respective objects can be accessed by
5953 LD instructions and open coded C/C++. This means there
5954 is no need for progmem in the source and no overhead by
5955 read-only data in RAM. */
5956 .rodata ADDR(.text) + SIZEOF (.text) + 0x4000 :
5962 /* No more need to put .rodata into .data:
5963 Removed all .rodata entries from .data. */
5971 @itemx io (@var{addr})
5972 @cindex @code{io} variable attribute, AVR
5973 Variables with the @code{io} attribute are used to address
5974 memory-mapped peripherals in the io address range.
5975 If an address is specified, the variable
5976 is assigned that address, and the value is interpreted as an
5977 address in the data address space.
5981 volatile int porta __attribute__((io (0x22)));
5984 The address specified in the address in the data address range.
5986 Otherwise, the variable it is not assigned an address, but the
5987 compiler will still use in/out instructions where applicable,
5988 assuming some other module assigns an address in the io address range.
5992 extern volatile int porta __attribute__((io));
5996 @itemx io_low (@var{addr})
5997 @cindex @code{io_low} variable attribute, AVR
5998 This is like the @code{io} attribute, but additionally it informs the
5999 compiler that the object lies in the lower half of the I/O area,
6000 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
6004 @itemx address (@var{addr})
6005 @cindex @code{address} variable attribute, AVR
6006 Variables with the @code{address} attribute are used to address
6007 memory-mapped peripherals that may lie outside the io address range.
6010 volatile int porta __attribute__((address (0x600)));
6014 @cindex @code{absdata} variable attribute, AVR
6015 Variables in static storage and with the @code{absdata} attribute can
6016 be accessed by the @code{LDS} and @code{STS} instructions which take
6021 This attribute is only supported for the reduced AVR Tiny core
6025 You must make sure that respective data is located in the
6026 address range @code{0x40}@dots{}@code{0xbf} accessible by
6027 @code{LDS} and @code{STS}. One way to achieve this as an
6028 appropriate linker description file.
6031 If the location does not fit the address range of @code{LDS}
6032 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6035 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6040 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6044 @node Blackfin Variable Attributes
6045 @subsection Blackfin Variable Attributes
6047 Three attributes are currently defined for the Blackfin.
6053 @cindex @code{l1_data} variable attribute, Blackfin
6054 @cindex @code{l1_data_A} variable attribute, Blackfin
6055 @cindex @code{l1_data_B} variable attribute, Blackfin
6056 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6057 Variables with @code{l1_data} attribute are put into the specific section
6058 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6059 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6060 attribute are put into the specific section named @code{.l1.data.B}.
6063 @cindex @code{l2} variable attribute, Blackfin
6064 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6065 Variables with @code{l2} attribute are put into the specific section
6066 named @code{.l2.data}.
6069 @node H8/300 Variable Attributes
6070 @subsection H8/300 Variable Attributes
6072 These variable attributes are available for H8/300 targets:
6076 @cindex @code{eightbit_data} variable attribute, H8/300
6077 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6078 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6079 variable should be placed into the eight-bit data section.
6080 The compiler generates more efficient code for certain operations
6081 on data in the eight-bit data area. Note the eight-bit data area is limited to
6084 You must use GAS and GLD from GNU binutils version 2.7 or later for
6085 this attribute to work correctly.
6088 @cindex @code{tiny_data} variable attribute, H8/300
6089 @cindex tiny data section on the H8/300H and H8S
6090 Use this attribute on the H8/300H and H8S to indicate that the specified
6091 variable should be placed into the tiny data section.
6092 The compiler generates more efficient code for loads and stores
6093 on data in the tiny data section. Note the tiny data area is limited to
6094 slightly under 32KB of data.
6098 @node IA-64 Variable Attributes
6099 @subsection IA-64 Variable Attributes
6101 The IA-64 back end supports the following variable attribute:
6104 @item model (@var{model-name})
6105 @cindex @code{model} variable attribute, IA-64
6107 On IA-64, use this attribute to set the addressability of an object.
6108 At present, the only supported identifier for @var{model-name} is
6109 @code{small}, indicating addressability via ``small'' (22-bit)
6110 addresses (so that their addresses can be loaded with the @code{addl}
6111 instruction). Caveat: such addressing is by definition not position
6112 independent and hence this attribute must not be used for objects
6113 defined by shared libraries.
6117 @node M32R/D Variable Attributes
6118 @subsection M32R/D Variable Attributes
6120 One attribute is currently defined for the M32R/D@.
6123 @item model (@var{model-name})
6124 @cindex @code{model-name} variable attribute, M32R/D
6125 @cindex variable addressability on the M32R/D
6126 Use this attribute on the M32R/D to set the addressability of an object.
6127 The identifier @var{model-name} is one of @code{small}, @code{medium},
6128 or @code{large}, representing each of the code models.
6130 Small model objects live in the lower 16MB of memory (so that their
6131 addresses can be loaded with the @code{ld24} instruction).
6133 Medium and large model objects may live anywhere in the 32-bit address space
6134 (the compiler generates @code{seth/add3} instructions to load their
6138 @node MeP Variable Attributes
6139 @subsection MeP Variable Attributes
6141 The MeP target has a number of addressing modes and busses. The
6142 @code{near} space spans the standard memory space's first 16 megabytes
6143 (24 bits). The @code{far} space spans the entire 32-bit memory space.
6144 The @code{based} space is a 128-byte region in the memory space that
6145 is addressed relative to the @code{$tp} register. The @code{tiny}
6146 space is a 65536-byte region relative to the @code{$gp} register. In
6147 addition to these memory regions, the MeP target has a separate 16-bit
6148 control bus which is specified with @code{cb} attributes.
6153 @cindex @code{based} variable attribute, MeP
6154 Any variable with the @code{based} attribute is assigned to the
6155 @code{.based} section, and is accessed with relative to the
6156 @code{$tp} register.
6159 @cindex @code{tiny} variable attribute, MeP
6160 Likewise, the @code{tiny} attribute assigned variables to the
6161 @code{.tiny} section, relative to the @code{$gp} register.
6164 @cindex @code{near} variable attribute, MeP
6165 Variables with the @code{near} attribute are assumed to have addresses
6166 that fit in a 24-bit addressing mode. This is the default for large
6167 variables (@code{-mtiny=4} is the default) but this attribute can
6168 override @code{-mtiny=} for small variables, or override @code{-ml}.
6171 @cindex @code{far} variable attribute, MeP
6172 Variables with the @code{far} attribute are addressed using a full
6173 32-bit address. Since this covers the entire memory space, this
6174 allows modules to make no assumptions about where variables might be
6178 @cindex @code{io} variable attribute, MeP
6179 @itemx io (@var{addr})
6180 Variables with the @code{io} attribute are used to address
6181 memory-mapped peripherals. If an address is specified, the variable
6182 is assigned that address, else it is not assigned an address (it is
6183 assumed some other module assigns an address). Example:
6186 int timer_count __attribute__((io(0x123)));
6190 @itemx cb (@var{addr})
6191 @cindex @code{cb} variable attribute, MeP
6192 Variables with the @code{cb} attribute are used to access the control
6193 bus, using special instructions. @code{addr} indicates the control bus
6197 int cpu_clock __attribute__((cb(0x123)));
6202 @node Microsoft Windows Variable Attributes
6203 @subsection Microsoft Windows Variable Attributes
6205 You can use these attributes on Microsoft Windows targets.
6206 @ref{x86 Variable Attributes} for additional Windows compatibility
6207 attributes available on all x86 targets.
6212 @cindex @code{dllimport} variable attribute
6213 @cindex @code{dllexport} variable attribute
6214 The @code{dllimport} and @code{dllexport} attributes are described in
6215 @ref{Microsoft Windows Function Attributes}.
6218 @cindex @code{selectany} variable attribute
6219 The @code{selectany} attribute causes an initialized global variable to
6220 have link-once semantics. When multiple definitions of the variable are
6221 encountered by the linker, the first is selected and the remainder are
6222 discarded. Following usage by the Microsoft compiler, the linker is told
6223 @emph{not} to warn about size or content differences of the multiple
6226 Although the primary usage of this attribute is for POD types, the
6227 attribute can also be applied to global C++ objects that are initialized
6228 by a constructor. In this case, the static initialization and destruction
6229 code for the object is emitted in each translation defining the object,
6230 but the calls to the constructor and destructor are protected by a
6231 link-once guard variable.
6233 The @code{selectany} attribute is only available on Microsoft Windows
6234 targets. You can use @code{__declspec (selectany)} as a synonym for
6235 @code{__attribute__ ((selectany))} for compatibility with other
6239 @cindex @code{shared} variable attribute
6240 On Microsoft Windows, in addition to putting variable definitions in a named
6241 section, the section can also be shared among all running copies of an
6242 executable or DLL@. For example, this small program defines shared data
6243 by putting it in a named section @code{shared} and marking the section
6247 int foo __attribute__((section ("shared"), shared)) = 0;
6252 /* @r{Read and write foo. All running
6253 copies see the same value.} */
6259 You may only use the @code{shared} attribute along with @code{section}
6260 attribute with a fully-initialized global definition because of the way
6261 linkers work. See @code{section} attribute for more information.
6263 The @code{shared} attribute is only available on Microsoft Windows@.
6267 @node MSP430 Variable Attributes
6268 @subsection MSP430 Variable Attributes
6272 @cindex @code{noinit} variable attribute, MSP430
6273 Any data with the @code{noinit} attribute will not be initialised by
6274 the C runtime startup code, or the program loader. Not initialising
6275 data in this way can reduce program startup times.
6278 @cindex @code{persistent} variable attribute, MSP430
6279 Any variable with the @code{persistent} attribute will not be
6280 initialised by the C runtime startup code. Instead its value will be
6281 set once, when the application is loaded, and then never initialised
6282 again, even if the processor is reset or the program restarts.
6283 Persistent data is intended to be placed into FLASH RAM, where its
6284 value will be retained across resets. The linker script being used to
6285 create the application should ensure that persistent data is correctly
6291 @cindex @code{lower} variable attribute, MSP430
6292 @cindex @code{upper} variable attribute, MSP430
6293 @cindex @code{either} variable attribute, MSP430
6294 These attributes are the same as the MSP430 function attributes of the
6295 same name (@pxref{MSP430 Function Attributes}).
6296 These attributes can be applied to both functions and variables.
6299 @node Nvidia PTX Variable Attributes
6300 @subsection Nvidia PTX Variable Attributes
6302 These variable attributes are supported by the Nvidia PTX back end:
6306 @cindex @code{shared} attribute, Nvidia PTX
6307 Use this attribute to place a variable in the @code{.shared} memory space.
6308 This memory space is private to each cooperative thread array; only threads
6309 within one thread block refer to the same instance of the variable.
6310 The runtime does not initialize variables in this memory space.
6313 @node PowerPC Variable Attributes
6314 @subsection PowerPC Variable Attributes
6316 Three attributes currently are defined for PowerPC configurations:
6317 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6319 @cindex @code{ms_struct} variable attribute, PowerPC
6320 @cindex @code{gcc_struct} variable attribute, PowerPC
6321 For full documentation of the struct attributes please see the
6322 documentation in @ref{x86 Variable Attributes}.
6324 @cindex @code{altivec} variable attribute, PowerPC
6325 For documentation of @code{altivec} attribute please see the
6326 documentation in @ref{PowerPC Type Attributes}.
6328 @node RL78 Variable Attributes
6329 @subsection RL78 Variable Attributes
6331 @cindex @code{saddr} variable attribute, RL78
6332 The RL78 back end supports the @code{saddr} variable attribute. This
6333 specifies placement of the corresponding variable in the SADDR area,
6334 which can be accessed more efficiently than the default memory region.
6336 @node SPU Variable Attributes
6337 @subsection SPU Variable Attributes
6339 @cindex @code{spu_vector} variable attribute, SPU
6340 The SPU supports the @code{spu_vector} attribute for variables. For
6341 documentation of this attribute please see the documentation in
6342 @ref{SPU Type Attributes}.
6344 @node V850 Variable Attributes
6345 @subsection V850 Variable Attributes
6347 These variable attributes are supported by the V850 back end:
6352 @cindex @code{sda} variable attribute, V850
6353 Use this attribute to explicitly place a variable in the small data area,
6354 which can hold up to 64 kilobytes.
6357 @cindex @code{tda} variable attribute, V850
6358 Use this attribute to explicitly place a variable in the tiny data area,
6359 which can hold up to 256 bytes in total.
6362 @cindex @code{zda} variable attribute, V850
6363 Use this attribute to explicitly place a variable in the first 32 kilobytes
6367 @node x86 Variable Attributes
6368 @subsection x86 Variable Attributes
6370 Two attributes are currently defined for x86 configurations:
6371 @code{ms_struct} and @code{gcc_struct}.
6376 @cindex @code{ms_struct} variable attribute, x86
6377 @cindex @code{gcc_struct} variable attribute, x86
6379 If @code{packed} is used on a structure, or if bit-fields are used,
6380 it may be that the Microsoft ABI lays out the structure differently
6381 than the way GCC normally does. Particularly when moving packed
6382 data between functions compiled with GCC and the native Microsoft compiler
6383 (either via function call or as data in a file), it may be necessary to access
6386 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6387 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6388 command-line options, respectively;
6389 see @ref{x86 Options}, for details of how structure layout is affected.
6390 @xref{x86 Type Attributes}, for information about the corresponding
6391 attributes on types.
6395 @node Xstormy16 Variable Attributes
6396 @subsection Xstormy16 Variable Attributes
6398 One attribute is currently defined for xstormy16 configurations:
6403 @cindex @code{below100} variable attribute, Xstormy16
6405 If a variable has the @code{below100} attribute (@code{BELOW100} is
6406 allowed also), GCC places the variable in the first 0x100 bytes of
6407 memory and use special opcodes to access it. Such variables are
6408 placed in either the @code{.bss_below100} section or the
6409 @code{.data_below100} section.
6413 @node Type Attributes
6414 @section Specifying Attributes of Types
6415 @cindex attribute of types
6416 @cindex type attributes
6418 The keyword @code{__attribute__} allows you to specify special
6419 attributes of types. Some type attributes apply only to @code{struct}
6420 and @code{union} types, while others can apply to any type defined
6421 via a @code{typedef} declaration. Other attributes are defined for
6422 functions (@pxref{Function Attributes}), labels (@pxref{Label
6423 Attributes}), enumerators (@pxref{Enumerator Attributes}),
6424 statements (@pxref{Statement Attributes}), and for
6425 variables (@pxref{Variable Attributes}).
6427 The @code{__attribute__} keyword is followed by an attribute specification
6428 inside double parentheses.
6430 You may specify type attributes in an enum, struct or union type
6431 declaration or definition by placing them immediately after the
6432 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6433 syntax is to place them just past the closing curly brace of the
6436 You can also include type attributes in a @code{typedef} declaration.
6437 @xref{Attribute Syntax}, for details of the exact syntax for using
6441 * Common Type Attributes::
6442 * ARM Type Attributes::
6443 * MeP Type Attributes::
6444 * PowerPC Type Attributes::
6445 * SPU Type Attributes::
6446 * x86 Type Attributes::
6449 @node Common Type Attributes
6450 @subsection Common Type Attributes
6452 The following type attributes are supported on most targets.
6455 @cindex @code{aligned} type attribute
6456 @item aligned (@var{alignment})
6457 This attribute specifies a minimum alignment (in bytes) for variables
6458 of the specified type. For example, the declarations:
6461 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6462 typedef int more_aligned_int __attribute__ ((aligned (8)));
6466 force the compiler to ensure (as far as it can) that each variable whose
6467 type is @code{struct S} or @code{more_aligned_int} is allocated and
6468 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6469 variables of type @code{struct S} aligned to 8-byte boundaries allows
6470 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6471 store) instructions when copying one variable of type @code{struct S} to
6472 another, thus improving run-time efficiency.
6474 Note that the alignment of any given @code{struct} or @code{union} type
6475 is required by the ISO C standard to be at least a perfect multiple of
6476 the lowest common multiple of the alignments of all of the members of
6477 the @code{struct} or @code{union} in question. This means that you @emph{can}
6478 effectively adjust the alignment of a @code{struct} or @code{union}
6479 type by attaching an @code{aligned} attribute to any one of the members
6480 of such a type, but the notation illustrated in the example above is a
6481 more obvious, intuitive, and readable way to request the compiler to
6482 adjust the alignment of an entire @code{struct} or @code{union} type.
6484 As in the preceding example, you can explicitly specify the alignment
6485 (in bytes) that you wish the compiler to use for a given @code{struct}
6486 or @code{union} type. Alternatively, you can leave out the alignment factor
6487 and just ask the compiler to align a type to the maximum
6488 useful alignment for the target machine you are compiling for. For
6489 example, you could write:
6492 struct S @{ short f[3]; @} __attribute__ ((aligned));
6495 Whenever you leave out the alignment factor in an @code{aligned}
6496 attribute specification, the compiler automatically sets the alignment
6497 for the type to the largest alignment that is ever used for any data
6498 type on the target machine you are compiling for. Doing this can often
6499 make copy operations more efficient, because the compiler can use
6500 whatever instructions copy the biggest chunks of memory when performing
6501 copies to or from the variables that have types that you have aligned
6504 In the example above, if the size of each @code{short} is 2 bytes, then
6505 the size of the entire @code{struct S} type is 6 bytes. The smallest
6506 power of two that is greater than or equal to that is 8, so the
6507 compiler sets the alignment for the entire @code{struct S} type to 8
6510 Note that although you can ask the compiler to select a time-efficient
6511 alignment for a given type and then declare only individual stand-alone
6512 objects of that type, the compiler's ability to select a time-efficient
6513 alignment is primarily useful only when you plan to create arrays of
6514 variables having the relevant (efficiently aligned) type. If you
6515 declare or use arrays of variables of an efficiently-aligned type, then
6516 it is likely that your program also does pointer arithmetic (or
6517 subscripting, which amounts to the same thing) on pointers to the
6518 relevant type, and the code that the compiler generates for these
6519 pointer arithmetic operations is often more efficient for
6520 efficiently-aligned types than for other types.
6522 Note that the effectiveness of @code{aligned} attributes may be limited
6523 by inherent limitations in your linker. On many systems, the linker is
6524 only able to arrange for variables to be aligned up to a certain maximum
6525 alignment. (For some linkers, the maximum supported alignment may
6526 be very very small.) If your linker is only able to align variables
6527 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6528 in an @code{__attribute__} still only provides you with 8-byte
6529 alignment. See your linker documentation for further information.
6531 The @code{aligned} attribute can only increase alignment. Alignment
6532 can be decreased by specifying the @code{packed} attribute. See below.
6534 @item bnd_variable_size
6535 @cindex @code{bnd_variable_size} type attribute
6536 @cindex Pointer Bounds Checker attributes
6537 When applied to a structure field, this attribute tells Pointer
6538 Bounds Checker that the size of this field should not be computed
6539 using static type information. It may be used to mark variably-sized
6540 static array fields placed at the end of a structure.
6548 S *p = (S *)malloc (sizeof(S) + 100);
6549 p->data[10] = 0; //Bounds violation
6553 By using an attribute for the field we may avoid unwanted bound
6560 char data[1] __attribute__((bnd_variable_size));
6562 S *p = (S *)malloc (sizeof(S) + 100);
6563 p->data[10] = 0; //OK
6567 @itemx deprecated (@var{msg})
6568 @cindex @code{deprecated} type attribute
6569 The @code{deprecated} attribute results in a warning if the type
6570 is used anywhere in the source file. This is useful when identifying
6571 types that are expected to be removed in a future version of a program.
6572 If possible, the warning also includes the location of the declaration
6573 of the deprecated type, to enable users to easily find further
6574 information about why the type is deprecated, or what they should do
6575 instead. Note that the warnings only occur for uses and then only
6576 if the type is being applied to an identifier that itself is not being
6577 declared as deprecated.
6580 typedef int T1 __attribute__ ((deprecated));
6584 typedef T1 T3 __attribute__ ((deprecated));
6585 T3 z __attribute__ ((deprecated));
6589 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
6590 warning is issued for line 4 because T2 is not explicitly
6591 deprecated. Line 5 has no warning because T3 is explicitly
6592 deprecated. Similarly for line 6. The optional @var{msg}
6593 argument, which must be a string, is printed in the warning if
6596 The @code{deprecated} attribute can also be used for functions and
6597 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6599 @item designated_init
6600 @cindex @code{designated_init} type attribute
6601 This attribute may only be applied to structure types. It indicates
6602 that any initialization of an object of this type must use designated
6603 initializers rather than positional initializers. The intent of this
6604 attribute is to allow the programmer to indicate that a structure's
6605 layout may change, and that therefore relying on positional
6606 initialization will result in future breakage.
6608 GCC emits warnings based on this attribute by default; use
6609 @option{-Wno-designated-init} to suppress them.
6612 @cindex @code{may_alias} type attribute
6613 Accesses through pointers to types with this attribute are not subject
6614 to type-based alias analysis, but are instead assumed to be able to alias
6615 any other type of objects.
6616 In the context of section 6.5 paragraph 7 of the C99 standard,
6617 an lvalue expression
6618 dereferencing such a pointer is treated like having a character type.
6619 See @option{-fstrict-aliasing} for more information on aliasing issues.
6620 This extension exists to support some vector APIs, in which pointers to
6621 one vector type are permitted to alias pointers to a different vector type.
6623 Note that an object of a type with this attribute does not have any
6629 typedef short __attribute__((__may_alias__)) short_a;
6635 short_a *b = (short_a *) &a;
6639 if (a == 0x12345678)
6647 If you replaced @code{short_a} with @code{short} in the variable
6648 declaration, the above program would abort when compiled with
6649 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6653 @cindex @code{packed} type attribute
6654 This attribute, attached to @code{struct} or @code{union} type
6655 definition, specifies that each member (other than zero-width bit-fields)
6656 of the structure or union is placed to minimize the memory required. When
6657 attached to an @code{enum} definition, it indicates that the smallest
6658 integral type should be used.
6660 @opindex fshort-enums
6661 Specifying the @code{packed} attribute for @code{struct} and @code{union}
6662 types is equivalent to specifying the @code{packed} attribute on each
6663 of the structure or union members. Specifying the @option{-fshort-enums}
6664 flag on the command line is equivalent to specifying the @code{packed}
6665 attribute on all @code{enum} definitions.
6667 In the following example @code{struct my_packed_struct}'s members are
6668 packed closely together, but the internal layout of its @code{s} member
6669 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6673 struct my_unpacked_struct
6679 struct __attribute__ ((__packed__)) my_packed_struct
6683 struct my_unpacked_struct s;
6687 You may only specify the @code{packed} attribute attribute on the definition
6688 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
6689 that does not also define the enumerated type, structure or union.
6691 @item scalar_storage_order ("@var{endianness}")
6692 @cindex @code{scalar_storage_order} type attribute
6693 When attached to a @code{union} or a @code{struct}, this attribute sets
6694 the storage order, aka endianness, of the scalar fields of the type, as
6695 well as the array fields whose component is scalar. The supported
6696 endiannesses are @code{big-endian} and @code{little-endian}. The attribute
6697 has no effects on fields which are themselves a @code{union}, a @code{struct}
6698 or an array whose component is a @code{union} or a @code{struct}, and it is
6699 possible for these fields to have a different scalar storage order than the
6702 This attribute is supported only for targets that use a uniform default
6703 scalar storage order (fortunately, most of them), i.e. targets that store
6704 the scalars either all in big-endian or all in little-endian.
6706 Additional restrictions are enforced for types with the reverse scalar
6707 storage order with regard to the scalar storage order of the target:
6710 @item Taking the address of a scalar field of a @code{union} or a
6711 @code{struct} with reverse scalar storage order is not permitted and yields
6713 @item Taking the address of an array field, whose component is scalar, of
6714 a @code{union} or a @code{struct} with reverse scalar storage order is
6715 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
6717 @item Taking the address of a @code{union} or a @code{struct} with reverse
6718 scalar storage order is permitted.
6721 These restrictions exist because the storage order attribute is lost when
6722 the address of a scalar or the address of an array with scalar component is
6723 taken, so storing indirectly through this address generally does not work.
6724 The second case is nevertheless allowed to be able to perform a block copy
6725 from or to the array.
6727 Moreover, the use of type punning or aliasing to toggle the storage order
6728 is not supported; that is to say, a given scalar object cannot be accessed
6729 through distinct types that assign a different storage order to it.
6731 @item transparent_union
6732 @cindex @code{transparent_union} type attribute
6734 This attribute, attached to a @code{union} type definition, indicates
6735 that any function parameter having that union type causes calls to that
6736 function to be treated in a special way.
6738 First, the argument corresponding to a transparent union type can be of
6739 any type in the union; no cast is required. Also, if the union contains
6740 a pointer type, the corresponding argument can be a null pointer
6741 constant or a void pointer expression; and if the union contains a void
6742 pointer type, the corresponding argument can be any pointer expression.
6743 If the union member type is a pointer, qualifiers like @code{const} on
6744 the referenced type must be respected, just as with normal pointer
6747 Second, the argument is passed to the function using the calling
6748 conventions of the first member of the transparent union, not the calling
6749 conventions of the union itself. All members of the union must have the
6750 same machine representation; this is necessary for this argument passing
6753 Transparent unions are designed for library functions that have multiple
6754 interfaces for compatibility reasons. For example, suppose the
6755 @code{wait} function must accept either a value of type @code{int *} to
6756 comply with POSIX, or a value of type @code{union wait *} to comply with
6757 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
6758 @code{wait} would accept both kinds of arguments, but it would also
6759 accept any other pointer type and this would make argument type checking
6760 less useful. Instead, @code{<sys/wait.h>} might define the interface
6764 typedef union __attribute__ ((__transparent_union__))
6768 @} wait_status_ptr_t;
6770 pid_t wait (wait_status_ptr_t);
6774 This interface allows either @code{int *} or @code{union wait *}
6775 arguments to be passed, using the @code{int *} calling convention.
6776 The program can call @code{wait} with arguments of either type:
6779 int w1 () @{ int w; return wait (&w); @}
6780 int w2 () @{ union wait w; return wait (&w); @}
6784 With this interface, @code{wait}'s implementation might look like this:
6787 pid_t wait (wait_status_ptr_t p)
6789 return waitpid (-1, p.__ip, 0);
6794 @cindex @code{unused} type attribute
6795 When attached to a type (including a @code{union} or a @code{struct}),
6796 this attribute means that variables of that type are meant to appear
6797 possibly unused. GCC does not produce a warning for any variables of
6798 that type, even if the variable appears to do nothing. This is often
6799 the case with lock or thread classes, which are usually defined and then
6800 not referenced, but contain constructors and destructors that have
6801 nontrivial bookkeeping functions.
6804 @cindex @code{visibility} type attribute
6805 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6806 applied to class, struct, union and enum types. Unlike other type
6807 attributes, the attribute must appear between the initial keyword and
6808 the name of the type; it cannot appear after the body of the type.
6810 Note that the type visibility is applied to vague linkage entities
6811 associated with the class (vtable, typeinfo node, etc.). In
6812 particular, if a class is thrown as an exception in one shared object
6813 and caught in another, the class must have default visibility.
6814 Otherwise the two shared objects are unable to use the same
6815 typeinfo node and exception handling will break.
6819 To specify multiple attributes, separate them by commas within the
6820 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6823 @node ARM Type Attributes
6824 @subsection ARM Type Attributes
6826 @cindex @code{notshared} type attribute, ARM
6827 On those ARM targets that support @code{dllimport} (such as Symbian
6828 OS), you can use the @code{notshared} attribute to indicate that the
6829 virtual table and other similar data for a class should not be
6830 exported from a DLL@. For example:
6833 class __declspec(notshared) C @{
6835 __declspec(dllimport) C();
6839 __declspec(dllexport)
6844 In this code, @code{C::C} is exported from the current DLL, but the
6845 virtual table for @code{C} is not exported. (You can use
6846 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6847 most Symbian OS code uses @code{__declspec}.)
6849 @node MeP Type Attributes
6850 @subsection MeP Type Attributes
6852 @cindex @code{based} type attribute, MeP
6853 @cindex @code{tiny} type attribute, MeP
6854 @cindex @code{near} type attribute, MeP
6855 @cindex @code{far} type attribute, MeP
6856 Many of the MeP variable attributes may be applied to types as well.
6857 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6858 @code{far} attributes may be applied to either. The @code{io} and
6859 @code{cb} attributes may not be applied to types.
6861 @node PowerPC Type Attributes
6862 @subsection PowerPC Type Attributes
6864 Three attributes currently are defined for PowerPC configurations:
6865 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6867 @cindex @code{ms_struct} type attribute, PowerPC
6868 @cindex @code{gcc_struct} type attribute, PowerPC
6869 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6870 attributes please see the documentation in @ref{x86 Type Attributes}.
6872 @cindex @code{altivec} type attribute, PowerPC
6873 The @code{altivec} attribute allows one to declare AltiVec vector data
6874 types supported by the AltiVec Programming Interface Manual. The
6875 attribute requires an argument to specify one of three vector types:
6876 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6877 and @code{bool__} (always followed by unsigned).
6880 __attribute__((altivec(vector__)))
6881 __attribute__((altivec(pixel__))) unsigned short
6882 __attribute__((altivec(bool__))) unsigned
6885 These attributes mainly are intended to support the @code{__vector},
6886 @code{__pixel}, and @code{__bool} AltiVec keywords.
6888 @node SPU Type Attributes
6889 @subsection SPU Type Attributes
6891 @cindex @code{spu_vector} type attribute, SPU
6892 The SPU supports the @code{spu_vector} attribute for types. This attribute
6893 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6894 Language Extensions Specification. It is intended to support the
6895 @code{__vector} keyword.
6897 @node x86 Type Attributes
6898 @subsection x86 Type Attributes
6900 Two attributes are currently defined for x86 configurations:
6901 @code{ms_struct} and @code{gcc_struct}.
6907 @cindex @code{ms_struct} type attribute, x86
6908 @cindex @code{gcc_struct} type attribute, x86
6910 If @code{packed} is used on a structure, or if bit-fields are used
6911 it may be that the Microsoft ABI packs them differently
6912 than GCC normally packs them. Particularly when moving packed
6913 data between functions compiled with GCC and the native Microsoft compiler
6914 (either via function call or as data in a file), it may be necessary to access
6917 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6918 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6919 command-line options, respectively;
6920 see @ref{x86 Options}, for details of how structure layout is affected.
6921 @xref{x86 Variable Attributes}, for information about the corresponding
6922 attributes on variables.
6926 @node Label Attributes
6927 @section Label Attributes
6928 @cindex Label Attributes
6930 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
6931 details of the exact syntax for using attributes. Other attributes are
6932 available for functions (@pxref{Function Attributes}), variables
6933 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6934 statements (@pxref{Statement Attributes}), and for types
6935 (@pxref{Type Attributes}).
6937 This example uses the @code{cold} label attribute to indicate the
6938 @code{ErrorHandling} branch is unlikely to be taken and that the
6939 @code{ErrorHandling} label is unused:
6943 asm goto ("some asm" : : : : NoError);
6945 /* This branch (the fall-through from the asm) is less commonly used */
6947 __attribute__((cold, unused)); /* Semi-colon is required here */
6952 printf("no error\n");
6958 @cindex @code{unused} label attribute
6959 This feature is intended for program-generated code that may contain
6960 unused labels, but which is compiled with @option{-Wall}. It is
6961 not normally appropriate to use in it human-written code, though it
6962 could be useful in cases where the code that jumps to the label is
6963 contained within an @code{#ifdef} conditional.
6966 @cindex @code{hot} label attribute
6967 The @code{hot} attribute on a label is used to inform the compiler that
6968 the path following the label is more likely than paths that are not so
6969 annotated. This attribute is used in cases where @code{__builtin_expect}
6970 cannot be used, for instance with computed goto or @code{asm goto}.
6973 @cindex @code{cold} label attribute
6974 The @code{cold} attribute on labels is used to inform the compiler that
6975 the path following the label is unlikely to be executed. This attribute
6976 is used in cases where @code{__builtin_expect} cannot be used, for instance
6977 with computed goto or @code{asm goto}.
6981 @node Enumerator Attributes
6982 @section Enumerator Attributes
6983 @cindex Enumerator Attributes
6985 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
6986 details of the exact syntax for using attributes. Other attributes are
6987 available for functions (@pxref{Function Attributes}), variables
6988 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
6989 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
6991 This example uses the @code{deprecated} enumerator attribute to indicate the
6992 @code{oldval} enumerator is deprecated:
6996 oldval __attribute__((deprecated)),
7009 @cindex @code{deprecated} enumerator attribute
7010 The @code{deprecated} attribute results in a warning if the enumerator
7011 is used anywhere in the source file. This is useful when identifying
7012 enumerators that are expected to be removed in a future version of a
7013 program. The warning also includes the location of the declaration
7014 of the deprecated enumerator, to enable users to easily find further
7015 information about why the enumerator is deprecated, or what they should
7016 do instead. Note that the warnings only occurs for uses.
7020 @node Statement Attributes
7021 @section Statement Attributes
7022 @cindex Statement Attributes
7024 GCC allows attributes to be set on null statements. @xref{Attribute Syntax},
7025 for details of the exact syntax for using attributes. Other attributes are
7026 available for functions (@pxref{Function Attributes}), variables
7027 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7028 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7030 This example uses the @code{fallthrough} statement attribute to indicate that
7031 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7038 __attribute__((fallthrough));
7046 @cindex @code{fallthrough} statement attribute
7047 The @code{fallthrough} attribute with a null statement serves as a
7048 fallthrough statement. It hints to the compiler that a statement
7049 that falls through to another case label, or user-defined label
7050 in a switch statement is intentional and thus the
7051 @option{-Wimplicit-fallthrough} warning must not trigger. The
7052 fallthrough attribute may appear at most once in each attribute
7053 list, and may not be mixed with other attributes. It can only
7054 be used in a switch statement (the compiler will issue an error
7055 otherwise), after a preceding statement and before a logically
7056 succeeding case label, or user-defined label.
7060 @node Attribute Syntax
7061 @section Attribute Syntax
7062 @cindex attribute syntax
7064 This section describes the syntax with which @code{__attribute__} may be
7065 used, and the constructs to which attribute specifiers bind, for the C
7066 language. Some details may vary for C++ and Objective-C@. Because of
7067 infelicities in the grammar for attributes, some forms described here
7068 may not be successfully parsed in all cases.
7070 There are some problems with the semantics of attributes in C++. For
7071 example, there are no manglings for attributes, although they may affect
7072 code generation, so problems may arise when attributed types are used in
7073 conjunction with templates or overloading. Similarly, @code{typeid}
7074 does not distinguish between types with different attributes. Support
7075 for attributes in C++ may be restricted in future to attributes on
7076 declarations only, but not on nested declarators.
7078 @xref{Function Attributes}, for details of the semantics of attributes
7079 applying to functions. @xref{Variable Attributes}, for details of the
7080 semantics of attributes applying to variables. @xref{Type Attributes},
7081 for details of the semantics of attributes applying to structure, union
7082 and enumerated types.
7083 @xref{Label Attributes}, for details of the semantics of attributes
7085 @xref{Enumerator Attributes}, for details of the semantics of attributes
7086 applying to enumerators.
7087 @xref{Statement Attributes}, for details of the semantics of attributes
7088 applying to statements.
7090 An @dfn{attribute specifier} is of the form
7091 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
7092 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7093 each attribute is one of the following:
7097 Empty. Empty attributes are ignored.
7101 (which may be an identifier such as @code{unused}, or a reserved
7102 word such as @code{const}).
7105 An attribute name followed by a parenthesized list of
7106 parameters for the attribute.
7107 These parameters take one of the following forms:
7111 An identifier. For example, @code{mode} attributes use this form.
7114 An identifier followed by a comma and a non-empty comma-separated list
7115 of expressions. For example, @code{format} attributes use this form.
7118 A possibly empty comma-separated list of expressions. For example,
7119 @code{format_arg} attributes use this form with the list being a single
7120 integer constant expression, and @code{alias} attributes use this form
7121 with the list being a single string constant.
7125 An @dfn{attribute specifier list} is a sequence of one or more attribute
7126 specifiers, not separated by any other tokens.
7128 You may optionally specify attribute names with @samp{__}
7129 preceding and following the name.
7130 This allows you to use them in header files without
7131 being concerned about a possible macro of the same name. For example,
7132 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7135 @subsubheading Label Attributes
7137 In GNU C, an attribute specifier list may appear after the colon following a
7138 label, other than a @code{case} or @code{default} label. GNU C++ only permits
7139 attributes on labels if the attribute specifier is immediately
7140 followed by a semicolon (i.e., the label applies to an empty
7141 statement). If the semicolon is missing, C++ label attributes are
7142 ambiguous, as it is permissible for a declaration, which could begin
7143 with an attribute list, to be labelled in C++. Declarations cannot be
7144 labelled in C90 or C99, so the ambiguity does not arise there.
7146 @subsubheading Enumerator Attributes
7148 In GNU C, an attribute specifier list may appear as part of an enumerator.
7149 The attribute goes after the enumeration constant, before @code{=}, if
7150 present. The optional attribute in the enumerator appertains to the
7151 enumeration constant. It is not possible to place the attribute after
7152 the constant expression, if present.
7154 @subsubheading Statement Attributes
7155 In GNU C, an attribute specifier list may appear as part of a null
7156 statement. The attribute goes before the semicolon.
7158 @subsubheading Type Attributes
7160 An attribute specifier list may appear as part of a @code{struct},
7161 @code{union} or @code{enum} specifier. It may go either immediately
7162 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7163 the closing brace. The former syntax is preferred.
7164 Where attribute specifiers follow the closing brace, they are considered
7165 to relate to the structure, union or enumerated type defined, not to any
7166 enclosing declaration the type specifier appears in, and the type
7167 defined is not complete until after the attribute specifiers.
7168 @c Otherwise, there would be the following problems: a shift/reduce
7169 @c conflict between attributes binding the struct/union/enum and
7170 @c binding to the list of specifiers/qualifiers; and "aligned"
7171 @c attributes could use sizeof for the structure, but the size could be
7172 @c changed later by "packed" attributes.
7175 @subsubheading All other attributes
7177 Otherwise, an attribute specifier appears as part of a declaration,
7178 counting declarations of unnamed parameters and type names, and relates
7179 to that declaration (which may be nested in another declaration, for
7180 example in the case of a parameter declaration), or to a particular declarator
7181 within a declaration. Where an
7182 attribute specifier is applied to a parameter declared as a function or
7183 an array, it should apply to the function or array rather than the
7184 pointer to which the parameter is implicitly converted, but this is not
7185 yet correctly implemented.
7187 Any list of specifiers and qualifiers at the start of a declaration may
7188 contain attribute specifiers, whether or not such a list may in that
7189 context contain storage class specifiers. (Some attributes, however,
7190 are essentially in the nature of storage class specifiers, and only make
7191 sense where storage class specifiers may be used; for example,
7192 @code{section}.) There is one necessary limitation to this syntax: the
7193 first old-style parameter declaration in a function definition cannot
7194 begin with an attribute specifier, because such an attribute applies to
7195 the function instead by syntax described below (which, however, is not
7196 yet implemented in this case). In some other cases, attribute
7197 specifiers are permitted by this grammar but not yet supported by the
7198 compiler. All attribute specifiers in this place relate to the
7199 declaration as a whole. In the obsolescent usage where a type of
7200 @code{int} is implied by the absence of type specifiers, such a list of
7201 specifiers and qualifiers may be an attribute specifier list with no
7202 other specifiers or qualifiers.
7204 At present, the first parameter in a function prototype must have some
7205 type specifier that is not an attribute specifier; this resolves an
7206 ambiguity in the interpretation of @code{void f(int
7207 (__attribute__((foo)) x))}, but is subject to change. At present, if
7208 the parentheses of a function declarator contain only attributes then
7209 those attributes are ignored, rather than yielding an error or warning
7210 or implying a single parameter of type int, but this is subject to
7213 An attribute specifier list may appear immediately before a declarator
7214 (other than the first) in a comma-separated list of declarators in a
7215 declaration of more than one identifier using a single list of
7216 specifiers and qualifiers. Such attribute specifiers apply
7217 only to the identifier before whose declarator they appear. For
7221 __attribute__((noreturn)) void d0 (void),
7222 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7227 the @code{noreturn} attribute applies to all the functions
7228 declared; the @code{format} attribute only applies to @code{d1}.
7230 An attribute specifier list may appear immediately before the comma,
7231 @code{=} or semicolon terminating the declaration of an identifier other
7232 than a function definition. Such attribute specifiers apply
7233 to the declared object or function. Where an
7234 assembler name for an object or function is specified (@pxref{Asm
7235 Labels}), the attribute must follow the @code{asm}
7238 An attribute specifier list may, in future, be permitted to appear after
7239 the declarator in a function definition (before any old-style parameter
7240 declarations or the function body).
7242 Attribute specifiers may be mixed with type qualifiers appearing inside
7243 the @code{[]} of a parameter array declarator, in the C99 construct by
7244 which such qualifiers are applied to the pointer to which the array is
7245 implicitly converted. Such attribute specifiers apply to the pointer,
7246 not to the array, but at present this is not implemented and they are
7249 An attribute specifier list may appear at the start of a nested
7250 declarator. At present, there are some limitations in this usage: the
7251 attributes correctly apply to the declarator, but for most individual
7252 attributes the semantics this implies are not implemented.
7253 When attribute specifiers follow the @code{*} of a pointer
7254 declarator, they may be mixed with any type qualifiers present.
7255 The following describes the formal semantics of this syntax. It makes the
7256 most sense if you are familiar with the formal specification of
7257 declarators in the ISO C standard.
7259 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7260 D1}, where @code{T} contains declaration specifiers that specify a type
7261 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7262 contains an identifier @var{ident}. The type specified for @var{ident}
7263 for derived declarators whose type does not include an attribute
7264 specifier is as in the ISO C standard.
7266 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7267 and the declaration @code{T D} specifies the type
7268 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7269 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7270 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7272 If @code{D1} has the form @code{*
7273 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7274 declaration @code{T D} specifies the type
7275 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7276 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7277 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7283 void (__attribute__((noreturn)) ****f) (void);
7287 specifies the type ``pointer to pointer to pointer to pointer to
7288 non-returning function returning @code{void}''. As another example,
7291 char *__attribute__((aligned(8))) *f;
7295 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7296 Note again that this does not work with most attributes; for example,
7297 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7298 is not yet supported.
7300 For compatibility with existing code written for compiler versions that
7301 did not implement attributes on nested declarators, some laxity is
7302 allowed in the placing of attributes. If an attribute that only applies
7303 to types is applied to a declaration, it is treated as applying to
7304 the type of that declaration. If an attribute that only applies to
7305 declarations is applied to the type of a declaration, it is treated
7306 as applying to that declaration; and, for compatibility with code
7307 placing the attributes immediately before the identifier declared, such
7308 an attribute applied to a function return type is treated as
7309 applying to the function type, and such an attribute applied to an array
7310 element type is treated as applying to the array type. If an
7311 attribute that only applies to function types is applied to a
7312 pointer-to-function type, it is treated as applying to the pointer
7313 target type; if such an attribute is applied to a function return type
7314 that is not a pointer-to-function type, it is treated as applying
7315 to the function type.
7317 @node Function Prototypes
7318 @section Prototypes and Old-Style Function Definitions
7319 @cindex function prototype declarations
7320 @cindex old-style function definitions
7321 @cindex promotion of formal parameters
7323 GNU C extends ISO C to allow a function prototype to override a later
7324 old-style non-prototype definition. Consider the following example:
7327 /* @r{Use prototypes unless the compiler is old-fashioned.} */
7334 /* @r{Prototype function declaration.} */
7335 int isroot P((uid_t));
7337 /* @r{Old-style function definition.} */
7339 isroot (x) /* @r{??? lossage here ???} */
7346 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
7347 not allow this example, because subword arguments in old-style
7348 non-prototype definitions are promoted. Therefore in this example the
7349 function definition's argument is really an @code{int}, which does not
7350 match the prototype argument type of @code{short}.
7352 This restriction of ISO C makes it hard to write code that is portable
7353 to traditional C compilers, because the programmer does not know
7354 whether the @code{uid_t} type is @code{short}, @code{int}, or
7355 @code{long}. Therefore, in cases like these GNU C allows a prototype
7356 to override a later old-style definition. More precisely, in GNU C, a
7357 function prototype argument type overrides the argument type specified
7358 by a later old-style definition if the former type is the same as the
7359 latter type before promotion. Thus in GNU C the above example is
7360 equivalent to the following:
7373 GNU C++ does not support old-style function definitions, so this
7374 extension is irrelevant.
7377 @section C++ Style Comments
7379 @cindex C++ comments
7380 @cindex comments, C++ style
7382 In GNU C, you may use C++ style comments, which start with @samp{//} and
7383 continue until the end of the line. Many other C implementations allow
7384 such comments, and they are included in the 1999 C standard. However,
7385 C++ style comments are not recognized if you specify an @option{-std}
7386 option specifying a version of ISO C before C99, or @option{-ansi}
7387 (equivalent to @option{-std=c90}).
7390 @section Dollar Signs in Identifier Names
7392 @cindex dollar signs in identifier names
7393 @cindex identifier names, dollar signs in
7395 In GNU C, you may normally use dollar signs in identifier names.
7396 This is because many traditional C implementations allow such identifiers.
7397 However, dollar signs in identifiers are not supported on a few target
7398 machines, typically because the target assembler does not allow them.
7400 @node Character Escapes
7401 @section The Character @key{ESC} in Constants
7403 You can use the sequence @samp{\e} in a string or character constant to
7404 stand for the ASCII character @key{ESC}.
7407 @section Inquiring on Alignment of Types or Variables
7409 @cindex type alignment
7410 @cindex variable alignment
7412 The keyword @code{__alignof__} allows you to inquire about how an object
7413 is aligned, or the minimum alignment usually required by a type. Its
7414 syntax is just like @code{sizeof}.
7416 For example, if the target machine requires a @code{double} value to be
7417 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7418 This is true on many RISC machines. On more traditional machine
7419 designs, @code{__alignof__ (double)} is 4 or even 2.
7421 Some machines never actually require alignment; they allow reference to any
7422 data type even at an odd address. For these machines, @code{__alignof__}
7423 reports the smallest alignment that GCC gives the data type, usually as
7424 mandated by the target ABI.
7426 If the operand of @code{__alignof__} is an lvalue rather than a type,
7427 its value is the required alignment for its type, taking into account
7428 any minimum alignment specified with GCC's @code{__attribute__}
7429 extension (@pxref{Variable Attributes}). For example, after this
7433 struct foo @{ int x; char y; @} foo1;
7437 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7438 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7440 It is an error to ask for the alignment of an incomplete type.
7444 @section An Inline Function is As Fast As a Macro
7445 @cindex inline functions
7446 @cindex integrating function code
7448 @cindex macros, inline alternative
7450 By declaring a function inline, you can direct GCC to make
7451 calls to that function faster. One way GCC can achieve this is to
7452 integrate that function's code into the code for its callers. This
7453 makes execution faster by eliminating the function-call overhead; in
7454 addition, if any of the actual argument values are constant, their
7455 known values may permit simplifications at compile time so that not
7456 all of the inline function's code needs to be included. The effect on
7457 code size is less predictable; object code may be larger or smaller
7458 with function inlining, depending on the particular case. You can
7459 also direct GCC to try to integrate all ``simple enough'' functions
7460 into their callers with the option @option{-finline-functions}.
7462 GCC implements three different semantics of declaring a function
7463 inline. One is available with @option{-std=gnu89} or
7464 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7465 on all inline declarations, another when
7466 @option{-std=c99}, @option{-std=c11},
7467 @option{-std=gnu99} or @option{-std=gnu11}
7468 (without @option{-fgnu89-inline}), and the third
7469 is used when compiling C++.
7471 To declare a function inline, use the @code{inline} keyword in its
7472 declaration, like this:
7482 If you are writing a header file to be included in ISO C90 programs, write
7483 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
7485 The three types of inlining behave similarly in two important cases:
7486 when the @code{inline} keyword is used on a @code{static} function,
7487 like the example above, and when a function is first declared without
7488 using the @code{inline} keyword and then is defined with
7489 @code{inline}, like this:
7492 extern int inc (int *a);
7500 In both of these common cases, the program behaves the same as if you
7501 had not used the @code{inline} keyword, except for its speed.
7503 @cindex inline functions, omission of
7504 @opindex fkeep-inline-functions
7505 When a function is both inline and @code{static}, if all calls to the
7506 function are integrated into the caller, and the function's address is
7507 never used, then the function's own assembler code is never referenced.
7508 In this case, GCC does not actually output assembler code for the
7509 function, unless you specify the option @option{-fkeep-inline-functions}.
7510 If there is a nonintegrated call, then the function is compiled to
7511 assembler code as usual. The function must also be compiled as usual if
7512 the program refers to its address, because that can't be inlined.
7515 Note that certain usages in a function definition can make it unsuitable
7516 for inline substitution. Among these usages are: variadic functions,
7517 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7518 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7519 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7520 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
7521 function marked @code{inline} could not be substituted, and gives the
7522 reason for the failure.
7524 @cindex automatic @code{inline} for C++ member fns
7525 @cindex @code{inline} automatic for C++ member fns
7526 @cindex member fns, automatically @code{inline}
7527 @cindex C++ member fns, automatically @code{inline}
7528 @opindex fno-default-inline
7529 As required by ISO C++, GCC considers member functions defined within
7530 the body of a class to be marked inline even if they are
7531 not explicitly declared with the @code{inline} keyword. You can
7532 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7533 Options,,Options Controlling C++ Dialect}.
7535 GCC does not inline any functions when not optimizing unless you specify
7536 the @samp{always_inline} attribute for the function, like this:
7539 /* @r{Prototype.} */
7540 inline void foo (const char) __attribute__((always_inline));
7543 The remainder of this section is specific to GNU C90 inlining.
7545 @cindex non-static inline function
7546 When an inline function is not @code{static}, then the compiler must assume
7547 that there may be calls from other source files; since a global symbol can
7548 be defined only once in any program, the function must not be defined in
7549 the other source files, so the calls therein cannot be integrated.
7550 Therefore, a non-@code{static} inline function is always compiled on its
7551 own in the usual fashion.
7553 If you specify both @code{inline} and @code{extern} in the function
7554 definition, then the definition is used only for inlining. In no case
7555 is the function compiled on its own, not even if you refer to its
7556 address explicitly. Such an address becomes an external reference, as
7557 if you had only declared the function, and had not defined it.
7559 This combination of @code{inline} and @code{extern} has almost the
7560 effect of a macro. The way to use it is to put a function definition in
7561 a header file with these keywords, and put another copy of the
7562 definition (lacking @code{inline} and @code{extern}) in a library file.
7563 The definition in the header file causes most calls to the function
7564 to be inlined. If any uses of the function remain, they refer to
7565 the single copy in the library.
7568 @section When is a Volatile Object Accessed?
7569 @cindex accessing volatiles
7570 @cindex volatile read
7571 @cindex volatile write
7572 @cindex volatile access
7574 C has the concept of volatile objects. These are normally accessed by
7575 pointers and used for accessing hardware or inter-thread
7576 communication. The standard encourages compilers to refrain from
7577 optimizations concerning accesses to volatile objects, but leaves it
7578 implementation defined as to what constitutes a volatile access. The
7579 minimum requirement is that at a sequence point all previous accesses
7580 to volatile objects have stabilized and no subsequent accesses have
7581 occurred. Thus an implementation is free to reorder and combine
7582 volatile accesses that occur between sequence points, but cannot do
7583 so for accesses across a sequence point. The use of volatile does
7584 not allow you to violate the restriction on updating objects multiple
7585 times between two sequence points.
7587 Accesses to non-volatile objects are not ordered with respect to
7588 volatile accesses. You cannot use a volatile object as a memory
7589 barrier to order a sequence of writes to non-volatile memory. For
7593 int *ptr = @var{something};
7595 *ptr = @var{something};
7600 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7601 that the write to @var{*ptr} occurs by the time the update
7602 of @var{vobj} happens. If you need this guarantee, you must use
7603 a stronger memory barrier such as:
7606 int *ptr = @var{something};
7608 *ptr = @var{something};
7609 asm volatile ("" : : : "memory");
7613 A scalar volatile object is read when it is accessed in a void context:
7616 volatile int *src = @var{somevalue};
7620 Such expressions are rvalues, and GCC implements this as a
7621 read of the volatile object being pointed to.
7623 Assignments are also expressions and have an rvalue. However when
7624 assigning to a scalar volatile, the volatile object is not reread,
7625 regardless of whether the assignment expression's rvalue is used or
7626 not. If the assignment's rvalue is used, the value is that assigned
7627 to the volatile object. For instance, there is no read of @var{vobj}
7628 in all the following cases:
7633 vobj = @var{something};
7634 obj = vobj = @var{something};
7635 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7636 obj = (@var{something}, vobj = @var{anotherthing});
7639 If you need to read the volatile object after an assignment has
7640 occurred, you must use a separate expression with an intervening
7643 As bit-fields are not individually addressable, volatile bit-fields may
7644 be implicitly read when written to, or when adjacent bit-fields are
7645 accessed. Bit-field operations may be optimized such that adjacent
7646 bit-fields are only partially accessed, if they straddle a storage unit
7647 boundary. For these reasons it is unwise to use volatile bit-fields to
7650 @node Using Assembly Language with C
7651 @section How to Use Inline Assembly Language in C Code
7652 @cindex @code{asm} keyword
7653 @cindex assembly language in C
7654 @cindex inline assembly language
7655 @cindex mixing assembly language and C
7657 The @code{asm} keyword allows you to embed assembler instructions
7658 within C code. GCC provides two forms of inline @code{asm}
7659 statements. A @dfn{basic @code{asm}} statement is one with no
7660 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7661 statement (@pxref{Extended Asm}) includes one or more operands.
7662 The extended form is preferred for mixing C and assembly language
7663 within a function, but to include assembly language at
7664 top level you must use basic @code{asm}.
7666 You can also use the @code{asm} keyword to override the assembler name
7667 for a C symbol, or to place a C variable in a specific register.
7670 * Basic Asm:: Inline assembler without operands.
7671 * Extended Asm:: Inline assembler with operands.
7672 * Constraints:: Constraints for @code{asm} operands
7673 * Asm Labels:: Specifying the assembler name to use for a C symbol.
7674 * Explicit Register Variables:: Defining variables residing in specified
7676 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
7680 @subsection Basic Asm --- Assembler Instructions Without Operands
7681 @cindex basic @code{asm}
7682 @cindex assembly language in C, basic
7684 A basic @code{asm} statement has the following syntax:
7687 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7690 The @code{asm} keyword is a GNU extension.
7691 When writing code that can be compiled with @option{-ansi} and the
7692 various @option{-std} options, use @code{__asm__} instead of
7693 @code{asm} (@pxref{Alternate Keywords}).
7695 @subsubheading Qualifiers
7698 The optional @code{volatile} qualifier has no effect.
7699 All basic @code{asm} blocks are implicitly volatile.
7702 @subsubheading Parameters
7705 @item AssemblerInstructions
7706 This is a literal string that specifies the assembler code. The string can
7707 contain any instructions recognized by the assembler, including directives.
7708 GCC does not parse the assembler instructions themselves and
7709 does not know what they mean or even whether they are valid assembler input.
7711 You may place multiple assembler instructions together in a single @code{asm}
7712 string, separated by the characters normally used in assembly code for the
7713 system. A combination that works in most places is a newline to break the
7714 line, plus a tab character (written as @samp{\n\t}).
7715 Some assemblers allow semicolons as a line separator. However,
7716 note that some assembler dialects use semicolons to start a comment.
7719 @subsubheading Remarks
7720 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
7721 smaller, safer, and more efficient code, and in most cases it is a
7722 better solution than basic @code{asm}. However, there are two
7723 situations where only basic @code{asm} can be used:
7727 Extended @code{asm} statements have to be inside a C
7728 function, so to write inline assembly language at file scope (``top-level''),
7729 outside of C functions, you must use basic @code{asm}.
7730 You can use this technique to emit assembler directives,
7731 define assembly language macros that can be invoked elsewhere in the file,
7732 or write entire functions in assembly language.
7736 with the @code{naked} attribute also require basic @code{asm}
7737 (@pxref{Function Attributes}).
7740 Safely accessing C data and calling functions from basic @code{asm} is more
7741 complex than it may appear. To access C data, it is better to use extended
7744 Do not expect a sequence of @code{asm} statements to remain perfectly
7745 consecutive after compilation. If certain instructions need to remain
7746 consecutive in the output, put them in a single multi-instruction @code{asm}
7747 statement. Note that GCC's optimizers can move @code{asm} statements
7748 relative to other code, including across jumps.
7750 @code{asm} statements may not perform jumps into other @code{asm} statements.
7751 GCC does not know about these jumps, and therefore cannot take
7752 account of them when deciding how to optimize. Jumps from @code{asm} to C
7753 labels are only supported in extended @code{asm}.
7755 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7756 assembly code when optimizing. This can lead to unexpected duplicate
7757 symbol errors during compilation if your assembly code defines symbols or
7760 @strong{Warning:} The C standards do not specify semantics for @code{asm},
7761 making it a potential source of incompatibilities between compilers. These
7762 incompatibilities may not produce compiler warnings/errors.
7764 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
7765 means there is no way to communicate to the compiler what is happening
7766 inside them. GCC has no visibility of symbols in the @code{asm} and may
7767 discard them as unreferenced. It also does not know about side effects of
7768 the assembler code, such as modifications to memory or registers. Unlike
7769 some compilers, GCC assumes that no changes to general purpose registers
7770 occur. This assumption may change in a future release.
7772 To avoid complications from future changes to the semantics and the
7773 compatibility issues between compilers, consider replacing basic @code{asm}
7774 with extended @code{asm}. See
7775 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
7776 from basic asm to extended asm} for information about how to perform this
7779 The compiler copies the assembler instructions in a basic @code{asm}
7780 verbatim to the assembly language output file, without
7781 processing dialects or any of the @samp{%} operators that are available with
7782 extended @code{asm}. This results in minor differences between basic
7783 @code{asm} strings and extended @code{asm} templates. For example, to refer to
7784 registers you might use @samp{%eax} in basic @code{asm} and
7785 @samp{%%eax} in extended @code{asm}.
7787 On targets such as x86 that support multiple assembler dialects,
7788 all basic @code{asm} blocks use the assembler dialect specified by the
7789 @option{-masm} command-line option (@pxref{x86 Options}).
7790 Basic @code{asm} provides no
7791 mechanism to provide different assembler strings for different dialects.
7793 For basic @code{asm} with non-empty assembler string GCC assumes
7794 the assembler block does not change any general purpose registers,
7795 but it may read or write any globally accessible variable.
7797 Here is an example of basic @code{asm} for i386:
7800 /* Note that this code will not compile with -masm=intel */
7801 #define DebugBreak() asm("int $3")
7805 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7806 @cindex extended @code{asm}
7807 @cindex assembly language in C, extended
7809 With extended @code{asm} you can read and write C variables from
7810 assembler and perform jumps from assembler code to C labels.
7811 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7812 the operand parameters after the assembler template:
7815 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
7816 : @var{OutputOperands}
7817 @r{[} : @var{InputOperands}
7818 @r{[} : @var{Clobbers} @r{]} @r{]})
7820 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
7822 : @var{InputOperands}
7827 The @code{asm} keyword is a GNU extension.
7828 When writing code that can be compiled with @option{-ansi} and the
7829 various @option{-std} options, use @code{__asm__} instead of
7830 @code{asm} (@pxref{Alternate Keywords}).
7832 @subsubheading Qualifiers
7836 The typical use of extended @code{asm} statements is to manipulate input
7837 values to produce output values. However, your @code{asm} statements may
7838 also produce side effects. If so, you may need to use the @code{volatile}
7839 qualifier to disable certain optimizations. @xref{Volatile}.
7842 This qualifier informs the compiler that the @code{asm} statement may
7843 perform a jump to one of the labels listed in the @var{GotoLabels}.
7847 @subsubheading Parameters
7849 @item AssemblerTemplate
7850 This is a literal string that is the template for the assembler code. It is a
7851 combination of fixed text and tokens that refer to the input, output,
7852 and goto parameters. @xref{AssemblerTemplate}.
7854 @item OutputOperands
7855 A comma-separated list of the C variables modified by the instructions in the
7856 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
7859 A comma-separated list of C expressions read by the instructions in the
7860 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
7863 A comma-separated list of registers or other values changed by the
7864 @var{AssemblerTemplate}, beyond those listed as outputs.
7865 An empty list is permitted. @xref{Clobbers}.
7868 When you are using the @code{goto} form of @code{asm}, this section contains
7869 the list of all C labels to which the code in the
7870 @var{AssemblerTemplate} may jump.
7873 @code{asm} statements may not perform jumps into other @code{asm} statements,
7874 only to the listed @var{GotoLabels}.
7875 GCC's optimizers do not know about other jumps; therefore they cannot take
7876 account of them when deciding how to optimize.
7879 The total number of input + output + goto operands is limited to 30.
7881 @subsubheading Remarks
7882 The @code{asm} statement allows you to include assembly instructions directly
7883 within C code. This may help you to maximize performance in time-sensitive
7884 code or to access assembly instructions that are not readily available to C
7887 Note that extended @code{asm} statements must be inside a function. Only
7888 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7889 Functions declared with the @code{naked} attribute also require basic
7890 @code{asm} (@pxref{Function Attributes}).
7892 While the uses of @code{asm} are many and varied, it may help to think of an
7893 @code{asm} statement as a series of low-level instructions that convert input
7894 parameters to output parameters. So a simple (if not particularly useful)
7895 example for i386 using @code{asm} might look like this:
7901 asm ("mov %1, %0\n\t"
7906 printf("%d\n", dst);
7909 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7912 @subsubsection Volatile
7913 @cindex volatile @code{asm}
7914 @cindex @code{asm} volatile
7916 GCC's optimizers sometimes discard @code{asm} statements if they determine
7917 there is no need for the output variables. Also, the optimizers may move
7918 code out of loops if they believe that the code will always return the same
7919 result (i.e. none of its input values change between calls). Using the
7920 @code{volatile} qualifier disables these optimizations. @code{asm} statements
7921 that have no output operands, including @code{asm goto} statements,
7922 are implicitly volatile.
7924 This i386 code demonstrates a case that does not use (or require) the
7925 @code{volatile} qualifier. If it is performing assertion checking, this code
7926 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
7927 unreferenced by any code. As a result, the optimizers can discard the
7928 @code{asm} statement, which in turn removes the need for the entire
7929 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
7930 isn't needed you allow the optimizers to produce the most efficient code
7934 void DoCheck(uint32_t dwSomeValue)
7938 // Assumes dwSomeValue is not zero.
7948 The next example shows a case where the optimizers can recognize that the input
7949 (@code{dwSomeValue}) never changes during the execution of the function and can
7950 therefore move the @code{asm} outside the loop to produce more efficient code.
7951 Again, using @code{volatile} disables this type of optimization.
7954 void do_print(uint32_t dwSomeValue)
7958 for (uint32_t x=0; x < 5; x++)
7960 // Assumes dwSomeValue is not zero.
7966 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7971 The following example demonstrates a case where you need to use the
7972 @code{volatile} qualifier.
7973 It uses the x86 @code{rdtsc} instruction, which reads
7974 the computer's time-stamp counter. Without the @code{volatile} qualifier,
7975 the optimizers might assume that the @code{asm} block will always return the
7976 same value and therefore optimize away the second call.
7981 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7982 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7983 "or %%rdx, %0" // 'Or' in the lower bits.
7988 printf("msr: %llx\n", msr);
7992 // Reprint the timestamp
7993 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7994 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7995 "or %%rdx, %0" // 'Or' in the lower bits.
8000 printf("msr: %llx\n", msr);
8003 GCC's optimizers do not treat this code like the non-volatile code in the
8004 earlier examples. They do not move it out of loops or omit it on the
8005 assumption that the result from a previous call is still valid.
8007 Note that the compiler can move even volatile @code{asm} instructions relative
8008 to other code, including across jump instructions. For example, on many
8009 targets there is a system register that controls the rounding mode of
8010 floating-point operations. Setting it with a volatile @code{asm}, as in the
8011 following PowerPC example, does not work reliably.
8014 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8018 The compiler may move the addition back before the volatile @code{asm}. To
8019 make it work as expected, add an artificial dependency to the @code{asm} by
8020 referencing a variable in the subsequent code, for example:
8023 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8027 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
8028 assembly code when optimizing. This can lead to unexpected duplicate symbol
8029 errors during compilation if your asm code defines symbols or labels.
8031 (@pxref{AssemblerTemplate}) may help resolve this problem.
8033 @anchor{AssemblerTemplate}
8034 @subsubsection Assembler Template
8035 @cindex @code{asm} assembler template
8037 An assembler template is a literal string containing assembler instructions.
8038 The compiler replaces tokens in the template that refer
8039 to inputs, outputs, and goto labels,
8040 and then outputs the resulting string to the assembler. The
8041 string can contain any instructions recognized by the assembler, including
8042 directives. GCC does not parse the assembler instructions
8043 themselves and does not know what they mean or even whether they are valid
8044 assembler input. However, it does count the statements
8045 (@pxref{Size of an asm}).
8047 You may place multiple assembler instructions together in a single @code{asm}
8048 string, separated by the characters normally used in assembly code for the
8049 system. A combination that works in most places is a newline to break the
8050 line, plus a tab character to move to the instruction field (written as
8052 Some assemblers allow semicolons as a line separator. However, note
8053 that some assembler dialects use semicolons to start a comment.
8055 Do not expect a sequence of @code{asm} statements to remain perfectly
8056 consecutive after compilation, even when you are using the @code{volatile}
8057 qualifier. If certain instructions need to remain consecutive in the output,
8058 put them in a single multi-instruction asm statement.
8060 Accessing data from C programs without using input/output operands (such as
8061 by using global symbols directly from the assembler template) may not work as
8062 expected. Similarly, calling functions directly from an assembler template
8063 requires a detailed understanding of the target assembler and ABI.
8065 Since GCC does not parse the assembler template,
8066 it has no visibility of any
8067 symbols it references. This may result in GCC discarding those symbols as
8068 unreferenced unless they are also listed as input, output, or goto operands.
8070 @subsubheading Special format strings
8072 In addition to the tokens described by the input, output, and goto operands,
8073 these tokens have special meanings in the assembler template:
8077 Outputs a single @samp{%} into the assembler code.
8080 Outputs a number that is unique to each instance of the @code{asm}
8081 statement in the entire compilation. This option is useful when creating local
8082 labels and referring to them multiple times in a single template that
8083 generates multiple assembler instructions.
8088 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8089 into the assembler code. When unescaped, these characters have special
8090 meaning to indicate multiple assembler dialects, as described below.
8093 @subsubheading Multiple assembler dialects in @code{asm} templates
8095 On targets such as x86, GCC supports multiple assembler dialects.
8096 The @option{-masm} option controls which dialect GCC uses as its
8097 default for inline assembler. The target-specific documentation for the
8098 @option{-masm} option contains the list of supported dialects, as well as the
8099 default dialect if the option is not specified. This information may be
8100 important to understand, since assembler code that works correctly when
8101 compiled using one dialect will likely fail if compiled using another.
8104 If your code needs to support multiple assembler dialects (for example, if
8105 you are writing public headers that need to support a variety of compilation
8106 options), use constructs of this form:
8109 @{ dialect0 | dialect1 | dialect2... @}
8112 This construct outputs @code{dialect0}
8113 when using dialect #0 to compile the code,
8114 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
8115 braces than the number of dialects the compiler supports, the construct
8118 For example, if an x86 compiler supports two dialects
8119 (@samp{att}, @samp{intel}), an
8120 assembler template such as this:
8123 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8127 is equivalent to one of
8130 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
8131 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
8134 Using that same compiler, this code:
8137 "xchg@{l@}\t@{%%@}ebx, %1"
8141 corresponds to either
8144 "xchgl\t%%ebx, %1" @r{/* att dialect */}
8145 "xchg\tebx, %1" @r{/* intel dialect */}
8148 There is no support for nesting dialect alternatives.
8150 @anchor{OutputOperands}
8151 @subsubsection Output Operands
8152 @cindex @code{asm} output operands
8154 An @code{asm} statement has zero or more output operands indicating the names
8155 of C variables modified by the assembler code.
8157 In this i386 example, @code{old} (referred to in the template string as
8158 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
8159 (@code{%2}) is an input:
8164 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8165 "sbb %0,%0" // Use the CF to calculate old.
8166 : "=r" (old), "+rm" (*Base)
8173 Operands are separated by commas. Each operand has this format:
8176 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8180 @item asmSymbolicName
8181 Specifies a symbolic name for the operand.
8182 Reference the name in the assembler template
8183 by enclosing it in square brackets
8184 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8185 that contains the definition. Any valid C variable name is acceptable,
8186 including names already defined in the surrounding code. No two operands
8187 within the same @code{asm} statement can use the same symbolic name.
8189 When not using an @var{asmSymbolicName}, use the (zero-based) position
8191 in the list of operands in the assembler template. For example if there are
8192 three output operands, use @samp{%0} in the template to refer to the first,
8193 @samp{%1} for the second, and @samp{%2} for the third.
8196 A string constant specifying constraints on the placement of the operand;
8197 @xref{Constraints}, for details.
8199 Output constraints must begin with either @samp{=} (a variable overwriting an
8200 existing value) or @samp{+} (when reading and writing). When using
8201 @samp{=}, do not assume the location contains the existing value
8202 on entry to the @code{asm}, except
8203 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8205 After the prefix, there must be one or more additional constraints
8206 (@pxref{Constraints}) that describe where the value resides. Common
8207 constraints include @samp{r} for register and @samp{m} for memory.
8208 When you list more than one possible location (for example, @code{"=rm"}),
8209 the compiler chooses the most efficient one based on the current context.
8210 If you list as many alternates as the @code{asm} statement allows, you permit
8211 the optimizers to produce the best possible code.
8212 If you must use a specific register, but your Machine Constraints do not
8213 provide sufficient control to select the specific register you want,
8214 local register variables may provide a solution (@pxref{Local Register
8218 Specifies a C lvalue expression to hold the output, typically a variable name.
8219 The enclosing parentheses are a required part of the syntax.
8223 When the compiler selects the registers to use to
8224 represent the output operands, it does not use any of the clobbered registers
8227 Output operand expressions must be lvalues. The compiler cannot check whether
8228 the operands have data types that are reasonable for the instruction being
8229 executed. For output expressions that are not directly addressable (for
8230 example a bit-field), the constraint must allow a register. In that case, GCC
8231 uses the register as the output of the @code{asm}, and then stores that
8232 register into the output.
8234 Operands using the @samp{+} constraint modifier count as two operands
8235 (that is, both as input and output) towards the total maximum of 30 operands
8236 per @code{asm} statement.
8238 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8239 operands that must not overlap an input. Otherwise,
8240 GCC may allocate the output operand in the same register as an unrelated
8241 input operand, on the assumption that the assembler code consumes its
8242 inputs before producing outputs. This assumption may be false if the assembler
8243 code actually consists of more than one instruction.
8245 The same problem can occur if one output parameter (@var{a}) allows a register
8246 constraint and another output parameter (@var{b}) allows a memory constraint.
8247 The code generated by GCC to access the memory address in @var{b} can contain
8248 registers which @emph{might} be shared by @var{a}, and GCC considers those
8249 registers to be inputs to the asm. As above, GCC assumes that such input
8250 registers are consumed before any outputs are written. This assumption may
8251 result in incorrect behavior if the asm writes to @var{a} before using
8252 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8253 ensures that modifying @var{a} does not affect the address referenced by
8254 @var{b}. Otherwise, the location of @var{b}
8255 is undefined if @var{a} is modified before using @var{b}.
8257 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8258 instead of simply @samp{%2}). Typically these qualifiers are hardware
8259 dependent. The list of supported modifiers for x86 is found at
8260 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8262 If the C code that follows the @code{asm} makes no use of any of the output
8263 operands, use @code{volatile} for the @code{asm} statement to prevent the
8264 optimizers from discarding the @code{asm} statement as unneeded
8265 (see @ref{Volatile}).
8267 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
8268 references the first output operand as @code{%0} (were there a second, it
8269 would be @code{%1}, etc). The number of the first input operand is one greater
8270 than that of the last output operand. In this i386 example, that makes
8271 @code{Mask} referenced as @code{%1}:
8274 uint32_t Mask = 1234;
8283 That code overwrites the variable @code{Index} (@samp{=}),
8284 placing the value in a register (@samp{r}).
8285 Using the generic @samp{r} constraint instead of a constraint for a specific
8286 register allows the compiler to pick the register to use, which can result
8287 in more efficient code. This may not be possible if an assembler instruction
8288 requires a specific register.
8290 The following i386 example uses the @var{asmSymbolicName} syntax.
8292 same result as the code above, but some may consider it more readable or more
8293 maintainable since reordering index numbers is not necessary when adding or
8294 removing operands. The names @code{aIndex} and @code{aMask}
8295 are only used in this example to emphasize which
8296 names get used where.
8297 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8300 uint32_t Mask = 1234;
8303 asm ("bsfl %[aMask], %[aIndex]"
8304 : [aIndex] "=r" (Index)
8305 : [aMask] "r" (Mask)
8309 Here are some more examples of output operands.
8316 asm ("mov %[e], %[d]"
8321 Here, @code{d} may either be in a register or in memory. Since the compiler
8322 might already have the current value of the @code{uint32_t} location
8323 pointed to by @code{e}
8324 in a register, you can enable it to choose the best location
8325 for @code{d} by specifying both constraints.
8327 @anchor{FlagOutputOperands}
8328 @subsubsection Flag Output Operands
8329 @cindex @code{asm} flag output operands
8331 Some targets have a special register that holds the ``flags'' for the
8332 result of an operation or comparison. Normally, the contents of that
8333 register are either unmodifed by the asm, or the asm is considered to
8334 clobber the contents.
8336 On some targets, a special form of output operand exists by which
8337 conditions in the flags register may be outputs of the asm. The set of
8338 conditions supported are target specific, but the general rule is that
8339 the output variable must be a scalar integer, and the value is boolean.
8340 When supported, the target defines the preprocessor symbol
8341 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8343 Because of the special nature of the flag output operands, the constraint
8344 may not include alternatives.
8346 Most often, the target has only one flags register, and thus is an implied
8347 operand of many instructions. In this case, the operand should not be
8348 referenced within the assembler template via @code{%0} etc, as there's
8349 no corresponding text in the assembly language.
8353 The flag output constraints for the x86 family are of the form
8354 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8355 conditions defined in the ISA manual for @code{j@var{cc}} or
8360 ``above'' or unsigned greater than
8362 ``above or equal'' or unsigned greater than or equal
8364 ``below'' or unsigned less than
8366 ``below or equal'' or unsigned less than or equal
8371 ``equal'' or zero flag set
8375 signed greater than or equal
8379 signed less than or equal
8400 ``not'' @var{flag}, or inverted versions of those above
8405 @anchor{InputOperands}
8406 @subsubsection Input Operands
8407 @cindex @code{asm} input operands
8408 @cindex @code{asm} expressions
8410 Input operands make values from C variables and expressions available to the
8413 Operands are separated by commas. Each operand has this format:
8416 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8420 @item asmSymbolicName
8421 Specifies a symbolic name for the operand.
8422 Reference the name in the assembler template
8423 by enclosing it in square brackets
8424 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8425 that contains the definition. Any valid C variable name is acceptable,
8426 including names already defined in the surrounding code. No two operands
8427 within the same @code{asm} statement can use the same symbolic name.
8429 When not using an @var{asmSymbolicName}, use the (zero-based) position
8431 in the list of operands in the assembler template. For example if there are
8432 two output operands and three inputs,
8433 use @samp{%2} in the template to refer to the first input operand,
8434 @samp{%3} for the second, and @samp{%4} for the third.
8437 A string constant specifying constraints on the placement of the operand;
8438 @xref{Constraints}, for details.
8440 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8441 When you list more than one possible location (for example, @samp{"irm"}),
8442 the compiler chooses the most efficient one based on the current context.
8443 If you must use a specific register, but your Machine Constraints do not
8444 provide sufficient control to select the specific register you want,
8445 local register variables may provide a solution (@pxref{Local Register
8448 Input constraints can also be digits (for example, @code{"0"}). This indicates
8449 that the specified input must be in the same place as the output constraint
8450 at the (zero-based) index in the output constraint list.
8451 When using @var{asmSymbolicName} syntax for the output operands,
8452 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8455 This is the C variable or expression being passed to the @code{asm} statement
8456 as input. The enclosing parentheses are a required part of the syntax.
8460 When the compiler selects the registers to use to represent the input
8461 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8463 If there are no output operands but there are input operands, place two
8464 consecutive colons where the output operands would go:
8467 __asm__ ("some instructions"
8469 : "r" (Offset / 8));
8472 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8473 (except for inputs tied to outputs). The compiler assumes that on exit from
8474 the @code{asm} statement these operands contain the same values as they
8475 had before executing the statement.
8476 It is @emph{not} possible to use clobbers
8477 to inform the compiler that the values in these inputs are changing. One
8478 common work-around is to tie the changing input variable to an output variable
8479 that never gets used. Note, however, that if the code that follows the
8480 @code{asm} statement makes no use of any of the output operands, the GCC
8481 optimizers may discard the @code{asm} statement as unneeded
8482 (see @ref{Volatile}).
8484 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8485 instead of simply @samp{%2}). Typically these qualifiers are hardware
8486 dependent. The list of supported modifiers for x86 is found at
8487 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8489 In this example using the fictitious @code{combine} instruction, the
8490 constraint @code{"0"} for input operand 1 says that it must occupy the same
8491 location as output operand 0. Only input operands may use numbers in
8492 constraints, and they must each refer to an output operand. Only a number (or
8493 the symbolic assembler name) in the constraint can guarantee that one operand
8494 is in the same place as another. The mere fact that @code{foo} is the value of
8495 both operands is not enough to guarantee that they are in the same place in
8496 the generated assembler code.
8499 asm ("combine %2, %0"
8501 : "0" (foo), "g" (bar));
8504 Here is an example using symbolic names.
8507 asm ("cmoveq %1, %2, %[result]"
8508 : [result] "=r"(result)
8509 : "r" (test), "r" (new), "[result]" (old));
8513 @subsubsection Clobbers
8514 @cindex @code{asm} clobbers
8516 While the compiler is aware of changes to entries listed in the output
8517 operands, the inline @code{asm} code may modify more than just the outputs. For
8518 example, calculations may require additional registers, or the processor may
8519 overwrite a register as a side effect of a particular assembler instruction.
8520 In order to inform the compiler of these changes, list them in the clobber
8521 list. Clobber list items are either register names or the special clobbers
8522 (listed below). Each clobber list item is a string constant
8523 enclosed in double quotes and separated by commas.
8525 Clobber descriptions may not in any way overlap with an input or output
8526 operand. For example, you may not have an operand describing a register class
8527 with one member when listing that register in the clobber list. Variables
8528 declared to live in specific registers (@pxref{Explicit Register
8529 Variables}) and used
8530 as @code{asm} input or output operands must have no part mentioned in the
8531 clobber description. In particular, there is no way to specify that input
8532 operands get modified without also specifying them as output operands.
8534 When the compiler selects which registers to use to represent input and output
8535 operands, it does not use any of the clobbered registers. As a result,
8536 clobbered registers are available for any use in the assembler code.
8538 Here is a realistic example for the VAX showing the use of clobbered
8542 asm volatile ("movc3 %0, %1, %2"
8544 : "g" (from), "g" (to), "g" (count)
8545 : "r0", "r1", "r2", "r3", "r4", "r5");
8548 Also, there are two special clobber arguments:
8552 The @code{"cc"} clobber indicates that the assembler code modifies the flags
8553 register. On some machines, GCC represents the condition codes as a specific
8554 hardware register; @code{"cc"} serves to name this register.
8555 On other machines, condition code handling is different,
8556 and specifying @code{"cc"} has no effect. But
8557 it is valid no matter what the target.
8560 The @code{"memory"} clobber tells the compiler that the assembly code
8562 reads or writes to items other than those listed in the input and output
8563 operands (for example, accessing the memory pointed to by one of the input
8564 parameters). To ensure memory contains correct values, GCC may need to flush
8565 specific register values to memory before executing the @code{asm}. Further,
8566 the compiler does not assume that any values read from memory before an
8567 @code{asm} remain unchanged after that @code{asm}; it reloads them as
8569 Using the @code{"memory"} clobber effectively forms a read/write
8570 memory barrier for the compiler.
8572 Note that this clobber does not prevent the @emph{processor} from doing
8573 speculative reads past the @code{asm} statement. To prevent that, you need
8574 processor-specific fence instructions.
8576 Flushing registers to memory has performance implications and may be an issue
8577 for time-sensitive code. You can use a trick to avoid this if the size of
8578 the memory being accessed is known at compile time. For example, if accessing
8579 ten bytes of a string, use a memory input like:
8581 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8586 @subsubsection Goto Labels
8587 @cindex @code{asm} goto labels
8589 @code{asm goto} allows assembly code to jump to one or more C labels. The
8590 @var{GotoLabels} section in an @code{asm goto} statement contains
8592 list of all C labels to which the assembler code may jump. GCC assumes that
8593 @code{asm} execution falls through to the next statement (if this is not the
8594 case, consider using the @code{__builtin_unreachable} intrinsic after the
8595 @code{asm} statement). Optimization of @code{asm goto} may be improved by
8596 using the @code{hot} and @code{cold} label attributes (@pxref{Label
8599 An @code{asm goto} statement cannot have outputs.
8600 This is due to an internal restriction of
8601 the compiler: control transfer instructions cannot have outputs.
8602 If the assembler code does modify anything, use the @code{"memory"} clobber
8604 optimizers to flush all register values to memory and reload them if
8605 necessary after the @code{asm} statement.
8607 Also note that an @code{asm goto} statement is always implicitly
8608 considered volatile.
8610 To reference a label in the assembler template,
8611 prefix it with @samp{%l} (lowercase @samp{L}) followed
8612 by its (zero-based) position in @var{GotoLabels} plus the number of input
8613 operands. For example, if the @code{asm} has three inputs and references two
8614 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8616 Alternately, you can reference labels using the actual C label name enclosed
8617 in brackets. For example, to reference a label named @code{carry}, you can
8618 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
8619 section when using this approach.
8621 Here is an example of @code{asm goto} for i386:
8628 : "r" (p1), "r" (p2)
8638 The following example shows an @code{asm goto} that uses a memory clobber.
8644 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8655 @anchor{x86Operandmodifiers}
8656 @subsubsection x86 Operand Modifiers
8658 References to input, output, and goto operands in the assembler template
8659 of extended @code{asm} statements can use
8660 modifiers to affect the way the operands are formatted in
8661 the code output to the assembler. For example, the
8662 following code uses the @samp{h} and @samp{b} modifiers for x86:
8666 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8670 These modifiers generate this assembler code:
8676 The rest of this discussion uses the following code for illustrative purposes.
8685 asm volatile goto ("some assembler instructions here"
8687 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8688 : /* No clobbers. */
8693 With no modifiers, this is what the output from the operands would be for the
8694 @samp{att} and @samp{intel} dialects of assembler:
8696 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
8697 @headitem Operand @tab @samp{att} @tab @samp{intel}
8706 @tab @code{OFFSET FLAT:.L2}
8709 The table below shows the list of supported modifiers and their effects.
8711 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
8712 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
8714 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8719 @tab Print the QImode name of the register.
8724 @tab Print the QImode name for a ``high'' register.
8729 @tab Print the HImode name of the register.
8734 @tab Print the SImode name of the register.
8739 @tab Print the DImode name of the register.
8744 @tab Print the label name with no punctuation.
8749 @tab Require a constant operand and print the constant expression with no punctuation.
8755 @anchor{x86floatingpointasmoperands}
8756 @subsubsection x86 Floating-Point @code{asm} Operands
8758 On x86 targets, there are several rules on the usage of stack-like registers
8759 in the operands of an @code{asm}. These rules apply only to the operands
8760 that are stack-like registers:
8764 Given a set of input registers that die in an @code{asm}, it is
8765 necessary to know which are implicitly popped by the @code{asm}, and
8766 which must be explicitly popped by GCC@.
8768 An input register that is implicitly popped by the @code{asm} must be
8769 explicitly clobbered, unless it is constrained to match an
8773 For any input register that is implicitly popped by an @code{asm}, it is
8774 necessary to know how to adjust the stack to compensate for the pop.
8775 If any non-popped input is closer to the top of the reg-stack than
8776 the implicitly popped register, it would not be possible to know what the
8777 stack looked like---it's not clear how the rest of the stack ``slides
8780 All implicitly popped input registers must be closer to the top of
8781 the reg-stack than any input that is not implicitly popped.
8783 It is possible that if an input dies in an @code{asm}, the compiler might
8784 use the input register for an output reload. Consider this example:
8787 asm ("foo" : "=t" (a) : "f" (b));
8791 This code says that input @code{b} is not popped by the @code{asm}, and that
8792 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8793 deeper after the @code{asm} than it was before. But, it is possible that
8794 reload may think that it can use the same register for both the input and
8797 To prevent this from happening,
8798 if any input operand uses the @samp{f} constraint, all output register
8799 constraints must use the @samp{&} early-clobber modifier.
8801 The example above is correctly written as:
8804 asm ("foo" : "=&t" (a) : "f" (b));
8808 Some operands need to be in particular places on the stack. All
8809 output operands fall in this category---GCC has no other way to
8810 know which registers the outputs appear in unless you indicate
8811 this in the constraints.
8813 Output operands must specifically indicate which register an output
8814 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
8815 constraints must select a class with a single register.
8818 Output operands may not be ``inserted'' between existing stack registers.
8819 Since no 387 opcode uses a read/write operand, all output operands
8820 are dead before the @code{asm}, and are pushed by the @code{asm}.
8821 It makes no sense to push anywhere but the top of the reg-stack.
8823 Output operands must start at the top of the reg-stack: output
8824 operands may not ``skip'' a register.
8827 Some @code{asm} statements may need extra stack space for internal
8828 calculations. This can be guaranteed by clobbering stack registers
8829 unrelated to the inputs and outputs.
8834 takes one input, which is internally popped, and produces two outputs.
8837 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8841 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8842 and replaces them with one output. The @code{st(1)} clobber is necessary
8843 for the compiler to know that @code{fyl2xp1} pops both inputs.
8846 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8854 @subsection Controlling Names Used in Assembler Code
8855 @cindex assembler names for identifiers
8856 @cindex names used in assembler code
8857 @cindex identifiers, names in assembler code
8859 You can specify the name to be used in the assembler code for a C
8860 function or variable by writing the @code{asm} (or @code{__asm__})
8861 keyword after the declarator.
8862 It is up to you to make sure that the assembler names you choose do not
8863 conflict with any other assembler symbols, or reference registers.
8865 @subsubheading Assembler names for data:
8867 This sample shows how to specify the assembler name for data:
8870 int foo asm ("myfoo") = 2;
8874 This specifies that the name to be used for the variable @code{foo} in
8875 the assembler code should be @samp{myfoo} rather than the usual
8878 On systems where an underscore is normally prepended to the name of a C
8879 variable, this feature allows you to define names for the
8880 linker that do not start with an underscore.
8882 GCC does not support using this feature with a non-static local variable
8883 since such variables do not have assembler names. If you are
8884 trying to put the variable in a particular register, see
8885 @ref{Explicit Register Variables}.
8887 @subsubheading Assembler names for functions:
8889 To specify the assembler name for functions, write a declaration for the
8890 function before its definition and put @code{asm} there, like this:
8893 int func (int x, int y) asm ("MYFUNC");
8895 int func (int x, int y)
8901 This specifies that the name to be used for the function @code{func} in
8902 the assembler code should be @code{MYFUNC}.
8904 @node Explicit Register Variables
8905 @subsection Variables in Specified Registers
8906 @anchor{Explicit Reg Vars}
8907 @cindex explicit register variables
8908 @cindex variables in specified registers
8909 @cindex specified registers
8911 GNU C allows you to associate specific hardware registers with C
8912 variables. In almost all cases, allowing the compiler to assign
8913 registers produces the best code. However under certain unusual
8914 circumstances, more precise control over the variable storage is
8917 Both global and local variables can be associated with a register. The
8918 consequences of performing this association are very different between
8919 the two, as explained in the sections below.
8922 * Global Register Variables:: Variables declared at global scope.
8923 * Local Register Variables:: Variables declared within a function.
8926 @node Global Register Variables
8927 @subsubsection Defining Global Register Variables
8928 @anchor{Global Reg Vars}
8929 @cindex global register variables
8930 @cindex registers, global variables in
8931 @cindex registers, global allocation
8933 You can define a global register variable and associate it with a specified
8937 register int *foo asm ("r12");
8941 Here @code{r12} is the name of the register that should be used. Note that
8942 this is the same syntax used for defining local register variables, but for
8943 a global variable the declaration appears outside a function. The
8944 @code{register} keyword is required, and cannot be combined with
8945 @code{static}. The register name must be a valid register name for the
8948 Registers are a scarce resource on most systems and allowing the
8949 compiler to manage their usage usually results in the best code. However,
8950 under special circumstances it can make sense to reserve some globally.
8951 For example this may be useful in programs such as programming language
8952 interpreters that have a couple of global variables that are accessed
8955 After defining a global register variable, for the current compilation
8959 @item The register is reserved entirely for this use, and will not be
8960 allocated for any other purpose.
8961 @item The register is not saved and restored by any functions.
8962 @item Stores into this register are never deleted even if they appear to be
8963 dead, but references may be deleted, moved or simplified.
8966 Note that these points @emph{only} apply to code that is compiled with the
8967 definition. The behavior of code that is merely linked in (for example
8968 code from libraries) is not affected.
8970 If you want to recompile source files that do not actually use your global
8971 register variable so they do not use the specified register for any other
8972 purpose, you need not actually add the global register declaration to
8973 their source code. It suffices to specify the compiler option
8974 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
8977 @subsubheading Declaring the variable
8979 Global register variables can not have initial values, because an
8980 executable file has no means to supply initial contents for a register.
8982 When selecting a register, choose one that is normally saved and
8983 restored by function calls on your machine. This ensures that code
8984 which is unaware of this reservation (such as library routines) will
8985 restore it before returning.
8987 On machines with register windows, be sure to choose a global
8988 register that is not affected magically by the function call mechanism.
8990 @subsubheading Using the variable
8992 @cindex @code{qsort}, and global register variables
8993 When calling routines that are not aware of the reservation, be
8994 cautious if those routines call back into code which uses them. As an
8995 example, if you call the system library version of @code{qsort}, it may
8996 clobber your registers during execution, but (if you have selected
8997 appropriate registers) it will restore them before returning. However
8998 it will @emph{not} restore them before calling @code{qsort}'s comparison
8999 function. As a result, global values will not reliably be available to
9000 the comparison function unless the @code{qsort} function itself is rebuilt.
9002 Similarly, it is not safe to access the global register variables from signal
9003 handlers or from more than one thread of control. Unless you recompile
9004 them specially for the task at hand, the system library routines may
9005 temporarily use the register for other things.
9007 @cindex register variable after @code{longjmp}
9008 @cindex global register after @code{longjmp}
9009 @cindex value after @code{longjmp}
9012 On most machines, @code{longjmp} restores to each global register
9013 variable the value it had at the time of the @code{setjmp}. On some
9014 machines, however, @code{longjmp} does not change the value of global
9015 register variables. To be portable, the function that called @code{setjmp}
9016 should make other arrangements to save the values of the global register
9017 variables, and to restore them in a @code{longjmp}. This way, the same
9018 thing happens regardless of what @code{longjmp} does.
9020 Eventually there may be a way of asking the compiler to choose a register
9021 automatically, but first we need to figure out how it should choose and
9022 how to enable you to guide the choice. No solution is evident.
9024 @node Local Register Variables
9025 @subsubsection Specifying Registers for Local Variables
9026 @anchor{Local Reg Vars}
9027 @cindex local variables, specifying registers
9028 @cindex specifying registers for local variables
9029 @cindex registers for local variables
9031 You can define a local register variable and associate it with a specified
9035 register int *foo asm ("r12");
9039 Here @code{r12} is the name of the register that should be used. Note
9040 that this is the same syntax used for defining global register variables,
9041 but for a local variable the declaration appears within a function. The
9042 @code{register} keyword is required, and cannot be combined with
9043 @code{static}. The register name must be a valid register name for the
9046 As with global register variables, it is recommended that you choose
9047 a register that is normally saved and restored by function calls on your
9048 machine, so that calls to library routines will not clobber it.
9050 The only supported use for this feature is to specify registers
9051 for input and output operands when calling Extended @code{asm}
9052 (@pxref{Extended Asm}). This may be necessary if the constraints for a
9053 particular machine don't provide sufficient control to select the desired
9054 register. To force an operand into a register, create a local variable
9055 and specify the register name after the variable's declaration. Then use
9056 the local variable for the @code{asm} operand and specify any constraint
9057 letter that matches the register:
9060 register int *p1 asm ("r0") = @dots{};
9061 register int *p2 asm ("r1") = @dots{};
9062 register int *result asm ("r0");
9063 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9066 @emph{Warning:} In the above example, be aware that a register (for example
9067 @code{r0}) can be call-clobbered by subsequent code, including function
9068 calls and library calls for arithmetic operators on other variables (for
9069 example the initialization of @code{p2}). In this case, use temporary
9070 variables for expressions between the register assignments:
9074 register int *p1 asm ("r0") = @dots{};
9075 register int *p2 asm ("r1") = t1;
9076 register int *result asm ("r0");
9077 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9080 Defining a register variable does not reserve the register. Other than
9081 when invoking the Extended @code{asm}, the contents of the specified
9082 register are not guaranteed. For this reason, the following uses
9083 are explicitly @emph{not} supported. If they appear to work, it is only
9084 happenstance, and may stop working as intended due to (seemingly)
9085 unrelated changes in surrounding code, or even minor changes in the
9086 optimization of a future version of gcc:
9089 @item Passing parameters to or from Basic @code{asm}
9090 @item Passing parameters to or from Extended @code{asm} without using input
9092 @item Passing parameters to or from routines written in assembler (or
9093 other languages) using non-standard calling conventions.
9096 Some developers use Local Register Variables in an attempt to improve
9097 gcc's allocation of registers, especially in large functions. In this
9098 case the register name is essentially a hint to the register allocator.
9099 While in some instances this can generate better code, improvements are
9100 subject to the whims of the allocator/optimizers. Since there are no
9101 guarantees that your improvements won't be lost, this usage of Local
9102 Register Variables is discouraged.
9104 On the MIPS platform, there is related use for local register variables
9105 with slightly different characteristics (@pxref{MIPS Coprocessors,,
9106 Defining coprocessor specifics for MIPS targets, gccint,
9107 GNU Compiler Collection (GCC) Internals}).
9109 @node Size of an asm
9110 @subsection Size of an @code{asm}
9112 Some targets require that GCC track the size of each instruction used
9113 in order to generate correct code. Because the final length of the
9114 code produced by an @code{asm} statement is only known by the
9115 assembler, GCC must make an estimate as to how big it will be. It
9116 does this by counting the number of instructions in the pattern of the
9117 @code{asm} and multiplying that by the length of the longest
9118 instruction supported by that processor. (When working out the number
9119 of instructions, it assumes that any occurrence of a newline or of
9120 whatever statement separator character is supported by the assembler --
9121 typically @samp{;} --- indicates the end of an instruction.)
9123 Normally, GCC's estimate is adequate to ensure that correct
9124 code is generated, but it is possible to confuse the compiler if you use
9125 pseudo instructions or assembler macros that expand into multiple real
9126 instructions, or if you use assembler directives that expand to more
9127 space in the object file than is needed for a single instruction.
9128 If this happens then the assembler may produce a diagnostic saying that
9129 a label is unreachable.
9131 @node Alternate Keywords
9132 @section Alternate Keywords
9133 @cindex alternate keywords
9134 @cindex keywords, alternate
9136 @option{-ansi} and the various @option{-std} options disable certain
9137 keywords. This causes trouble when you want to use GNU C extensions, or
9138 a general-purpose header file that should be usable by all programs,
9139 including ISO C programs. The keywords @code{asm}, @code{typeof} and
9140 @code{inline} are not available in programs compiled with
9141 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9142 program compiled with @option{-std=c99} or @option{-std=c11}). The
9144 @code{restrict} is only available when @option{-std=gnu99} (which will
9145 eventually be the default) or @option{-std=c99} (or the equivalent
9146 @option{-std=iso9899:1999}), or an option for a later standard
9149 The way to solve these problems is to put @samp{__} at the beginning and
9150 end of each problematical keyword. For example, use @code{__asm__}
9151 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9153 Other C compilers won't accept these alternative keywords; if you want to
9154 compile with another compiler, you can define the alternate keywords as
9155 macros to replace them with the customary keywords. It looks like this:
9163 @findex __extension__
9165 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9167 prevent such warnings within one expression by writing
9168 @code{__extension__} before the expression. @code{__extension__} has no
9169 effect aside from this.
9171 @node Incomplete Enums
9172 @section Incomplete @code{enum} Types
9174 You can define an @code{enum} tag without specifying its possible values.
9175 This results in an incomplete type, much like what you get if you write
9176 @code{struct foo} without describing the elements. A later declaration
9177 that does specify the possible values completes the type.
9179 You can't allocate variables or storage using the type while it is
9180 incomplete. However, you can work with pointers to that type.
9182 This extension may not be very useful, but it makes the handling of
9183 @code{enum} more consistent with the way @code{struct} and @code{union}
9186 This extension is not supported by GNU C++.
9188 @node Function Names
9189 @section Function Names as Strings
9190 @cindex @code{__func__} identifier
9191 @cindex @code{__FUNCTION__} identifier
9192 @cindex @code{__PRETTY_FUNCTION__} identifier
9194 GCC provides three magic constants that hold the name of the current
9195 function as a string. In C++11 and later modes, all three are treated
9196 as constant expressions and can be used in @code{constexpr} constexts.
9197 The first of these constants is @code{__func__}, which is part of
9200 The identifier @code{__func__} is implicitly declared by the translator
9201 as if, immediately following the opening brace of each function
9202 definition, the declaration
9205 static const char __func__[] = "function-name";
9209 appeared, where function-name is the name of the lexically-enclosing
9210 function. This name is the unadorned name of the function. As an
9211 extension, at file (or, in C++, namespace scope), @code{__func__}
9212 evaluates to the empty string.
9214 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9215 backward compatibility with old versions of GCC.
9217 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9218 @code{__func__}, except that at file (or, in C++, namespace scope),
9219 it evaluates to the string @code{"top level"}. In addition, in C++,
9220 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9221 well as its bare name. For example, this program:
9224 extern "C" int printf (const char *, ...);
9230 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9231 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9249 __PRETTY_FUNCTION__ = void a::sub(int)
9252 These identifiers are variables, not preprocessor macros, and may not
9253 be used to initialize @code{char} arrays or be concatenated with string
9256 @node Return Address
9257 @section Getting the Return or Frame Address of a Function
9259 These functions may be used to get information about the callers of a
9262 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9263 This function returns the return address of the current function, or of
9264 one of its callers. The @var{level} argument is number of frames to
9265 scan up the call stack. A value of @code{0} yields the return address
9266 of the current function, a value of @code{1} yields the return address
9267 of the caller of the current function, and so forth. When inlining
9268 the expected behavior is that the function returns the address of
9269 the function that is returned to. To work around this behavior use
9270 the @code{noinline} function attribute.
9272 The @var{level} argument must be a constant integer.
9274 On some machines it may be impossible to determine the return address of
9275 any function other than the current one; in such cases, or when the top
9276 of the stack has been reached, this function returns @code{0} or a
9277 random value. In addition, @code{__builtin_frame_address} may be used
9278 to determine if the top of the stack has been reached.
9280 Additional post-processing of the returned value may be needed, see
9281 @code{__builtin_extract_return_addr}.
9283 Calling this function with a nonzero argument can have unpredictable
9284 effects, including crashing the calling program. As a result, calls
9285 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9286 option is in effect. Such calls should only be made in debugging
9290 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9291 The address as returned by @code{__builtin_return_address} may have to be fed
9292 through this function to get the actual encoded address. For example, on the
9293 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9294 platforms an offset has to be added for the true next instruction to be
9297 If no fixup is needed, this function simply passes through @var{addr}.
9300 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9301 This function does the reverse of @code{__builtin_extract_return_addr}.
9304 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9305 This function is similar to @code{__builtin_return_address}, but it
9306 returns the address of the function frame rather than the return address
9307 of the function. Calling @code{__builtin_frame_address} with a value of
9308 @code{0} yields the frame address of the current function, a value of
9309 @code{1} yields the frame address of the caller of the current function,
9312 The frame is the area on the stack that holds local variables and saved
9313 registers. The frame address is normally the address of the first word
9314 pushed on to the stack by the function. However, the exact definition
9315 depends upon the processor and the calling convention. If the processor
9316 has a dedicated frame pointer register, and the function has a frame,
9317 then @code{__builtin_frame_address} returns the value of the frame
9320 On some machines it may be impossible to determine the frame address of
9321 any function other than the current one; in such cases, or when the top
9322 of the stack has been reached, this function returns @code{0} if
9323 the first frame pointer is properly initialized by the startup code.
9325 Calling this function with a nonzero argument can have unpredictable
9326 effects, including crashing the calling program. As a result, calls
9327 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9328 option is in effect. Such calls should only be made in debugging
9332 @node Vector Extensions
9333 @section Using Vector Instructions through Built-in Functions
9335 On some targets, the instruction set contains SIMD vector instructions which
9336 operate on multiple values contained in one large register at the same time.
9337 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9340 The first step in using these extensions is to provide the necessary data
9341 types. This should be done using an appropriate @code{typedef}:
9344 typedef int v4si __attribute__ ((vector_size (16)));
9348 The @code{int} type specifies the base type, while the attribute specifies
9349 the vector size for the variable, measured in bytes. For example, the
9350 declaration above causes the compiler to set the mode for the @code{v4si}
9351 type to be 16 bytes wide and divided into @code{int} sized units. For
9352 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9353 corresponding mode of @code{foo} is @acronym{V4SI}.
9355 The @code{vector_size} attribute is only applicable to integral and
9356 float scalars, although arrays, pointers, and function return values
9357 are allowed in conjunction with this construct. Only sizes that are
9358 a power of two are currently allowed.
9360 All the basic integer types can be used as base types, both as signed
9361 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9362 @code{long long}. In addition, @code{float} and @code{double} can be
9363 used to build floating-point vector types.
9365 Specifying a combination that is not valid for the current architecture
9366 causes GCC to synthesize the instructions using a narrower mode.
9367 For example, if you specify a variable of type @code{V4SI} and your
9368 architecture does not allow for this specific SIMD type, GCC
9369 produces code that uses 4 @code{SIs}.
9371 The types defined in this manner can be used with a subset of normal C
9372 operations. Currently, GCC allows using the following operators
9373 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9375 The operations behave like C++ @code{valarrays}. Addition is defined as
9376 the addition of the corresponding elements of the operands. For
9377 example, in the code below, each of the 4 elements in @var{a} is
9378 added to the corresponding 4 elements in @var{b} and the resulting
9379 vector is stored in @var{c}.
9382 typedef int v4si __attribute__ ((vector_size (16)));
9389 Subtraction, multiplication, division, and the logical operations
9390 operate in a similar manner. Likewise, the result of using the unary
9391 minus or complement operators on a vector type is a vector whose
9392 elements are the negative or complemented values of the corresponding
9393 elements in the operand.
9395 It is possible to use shifting operators @code{<<}, @code{>>} on
9396 integer-type vectors. The operation is defined as following: @code{@{a0,
9397 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9398 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9401 For convenience, it is allowed to use a binary vector operation
9402 where one operand is a scalar. In that case the compiler transforms
9403 the scalar operand into a vector where each element is the scalar from
9404 the operation. The transformation happens only if the scalar could be
9405 safely converted to the vector-element type.
9406 Consider the following code.
9409 typedef int v4si __attribute__ ((vector_size (16)));
9414 a = b + 1; /* a = b + @{1,1,1,1@}; */
9415 a = 2 * b; /* a = @{2,2,2,2@} * b; */
9417 a = l + a; /* Error, cannot convert long to int. */
9420 Vectors can be subscripted as if the vector were an array with
9421 the same number of elements and base type. Out of bound accesses
9422 invoke undefined behavior at run time. Warnings for out of bound
9423 accesses for vector subscription can be enabled with
9424 @option{-Warray-bounds}.
9426 Vector comparison is supported with standard comparison
9427 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9428 vector expressions of integer-type or real-type. Comparison between
9429 integer-type vectors and real-type vectors are not supported. The
9430 result of the comparison is a vector of the same width and number of
9431 elements as the comparison operands with a signed integral element
9434 Vectors are compared element-wise producing 0 when comparison is false
9435 and -1 (constant of the appropriate type where all bits are set)
9436 otherwise. Consider the following example.
9439 typedef int v4si __attribute__ ((vector_size (16)));
9441 v4si a = @{1,2,3,4@};
9442 v4si b = @{3,2,1,4@};
9445 c = a > b; /* The result would be @{0, 0,-1, 0@} */
9446 c = a == b; /* The result would be @{0,-1, 0,-1@} */
9449 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9450 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9451 integer vector with the same number of elements of the same size as @code{b}
9452 and @code{c}, computes all three arguments and creates a vector
9453 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
9454 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9455 As in the case of binary operations, this syntax is also accepted when
9456 one of @code{b} or @code{c} is a scalar that is then transformed into a
9457 vector. If both @code{b} and @code{c} are scalars and the type of
9458 @code{true?b:c} has the same size as the element type of @code{a}, then
9459 @code{b} and @code{c} are converted to a vector type whose elements have
9460 this type and with the same number of elements as @code{a}.
9462 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9463 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9464 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9465 For mixed operations between a scalar @code{s} and a vector @code{v},
9466 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9467 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9469 Vector shuffling is available using functions
9470 @code{__builtin_shuffle (vec, mask)} and
9471 @code{__builtin_shuffle (vec0, vec1, mask)}.
9472 Both functions construct a permutation of elements from one or two
9473 vectors and return a vector of the same type as the input vector(s).
9474 The @var{mask} is an integral vector with the same width (@var{W})
9475 and element count (@var{N}) as the output vector.
9477 The elements of the input vectors are numbered in memory ordering of
9478 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
9479 elements of @var{mask} are considered modulo @var{N} in the single-operand
9480 case and modulo @math{2*@var{N}} in the two-operand case.
9482 Consider the following example,
9485 typedef int v4si __attribute__ ((vector_size (16)));
9487 v4si a = @{1,2,3,4@};
9488 v4si b = @{5,6,7,8@};
9489 v4si mask1 = @{0,1,1,3@};
9490 v4si mask2 = @{0,4,2,5@};
9493 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
9494 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
9497 Note that @code{__builtin_shuffle} is intentionally semantically
9498 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9500 You can declare variables and use them in function calls and returns, as
9501 well as in assignments and some casts. You can specify a vector type as
9502 a return type for a function. Vector types can also be used as function
9503 arguments. It is possible to cast from one vector type to another,
9504 provided they are of the same size (in fact, you can also cast vectors
9505 to and from other datatypes of the same size).
9507 You cannot operate between vectors of different lengths or different
9508 signedness without a cast.
9511 @section Support for @code{offsetof}
9512 @findex __builtin_offsetof
9514 GCC implements for both C and C++ a syntactic extension to implement
9515 the @code{offsetof} macro.
9519 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9521 offsetof_member_designator:
9523 | offsetof_member_designator "." @code{identifier}
9524 | offsetof_member_designator "[" @code{expr} "]"
9527 This extension is sufficient such that
9530 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
9534 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
9535 may be dependent. In either case, @var{member} may consist of a single
9536 identifier, or a sequence of member accesses and array references.
9538 @node __sync Builtins
9539 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9541 The following built-in functions
9542 are intended to be compatible with those described
9543 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9544 section 7.4. As such, they depart from normal GCC practice by not using
9545 the @samp{__builtin_} prefix and also by being overloaded so that they
9546 work on multiple types.
9548 The definition given in the Intel documentation allows only for the use of
9549 the types @code{int}, @code{long}, @code{long long} or their unsigned
9550 counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
9551 size other than the C type @code{_Bool} or the C++ type @code{bool}.
9552 Operations on pointer arguments are performed as if the operands were
9553 of the @code{uintptr_t} type. That is, they are not scaled by the size
9554 of the type to which the pointer points.
9556 These functions are implemented in terms of the @samp{__atomic}
9557 builtins (@pxref{__atomic Builtins}). They should not be used for new
9558 code which should use the @samp{__atomic} builtins instead.
9560 Not all operations are supported by all target processors. If a particular
9561 operation cannot be implemented on the target processor, a warning is
9562 generated and a call to an external function is generated. The external
9563 function carries the same name as the built-in version,
9564 with an additional suffix
9565 @samp{_@var{n}} where @var{n} is the size of the data type.
9567 @c ??? Should we have a mechanism to suppress this warning? This is almost
9568 @c useful for implementing the operation under the control of an external
9571 In most cases, these built-in functions are considered a @dfn{full barrier}.
9573 no memory operand is moved across the operation, either forward or
9574 backward. Further, instructions are issued as necessary to prevent the
9575 processor from speculating loads across the operation and from queuing stores
9576 after the operation.
9578 All of the routines are described in the Intel documentation to take
9579 ``an optional list of variables protected by the memory barrier''. It's
9580 not clear what is meant by that; it could mean that @emph{only} the
9581 listed variables are protected, or it could mean a list of additional
9582 variables to be protected. The list is ignored by GCC which treats it as
9583 empty. GCC interprets an empty list as meaning that all globally
9584 accessible variables should be protected.
9587 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9588 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9589 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9590 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9591 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9592 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9593 @findex __sync_fetch_and_add
9594 @findex __sync_fetch_and_sub
9595 @findex __sync_fetch_and_or
9596 @findex __sync_fetch_and_and
9597 @findex __sync_fetch_and_xor
9598 @findex __sync_fetch_and_nand
9599 These built-in functions perform the operation suggested by the name, and
9600 returns the value that had previously been in memory. That is, operations
9601 on integer operands have the following semantics. Operations on pointer
9602 arguments are performed as if the operands were of the @code{uintptr_t}
9603 type. That is, they are not scaled by the size of the type to which
9607 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9608 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
9611 The object pointed to by the first argument must be of integer or pointer
9612 type. It must not be a boolean type.
9614 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9615 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9617 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9618 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9619 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9620 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9621 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9622 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9623 @findex __sync_add_and_fetch
9624 @findex __sync_sub_and_fetch
9625 @findex __sync_or_and_fetch
9626 @findex __sync_and_and_fetch
9627 @findex __sync_xor_and_fetch
9628 @findex __sync_nand_and_fetch
9629 These built-in functions perform the operation suggested by the name, and
9630 return the new value. That is, operations on integer operands have
9631 the following semantics. Operations on pointer operands are performed as
9632 if the operand's type were @code{uintptr_t}.
9635 @{ *ptr @var{op}= value; return *ptr; @}
9636 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
9639 The same constraints on arguments apply as for the corresponding
9640 @code{__sync_op_and_fetch} built-in functions.
9642 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9643 as @code{*ptr = ~(*ptr & value)} instead of
9644 @code{*ptr = ~*ptr & value}.
9646 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9647 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9648 @findex __sync_bool_compare_and_swap
9649 @findex __sync_val_compare_and_swap
9650 These built-in functions perform an atomic compare and swap.
9651 That is, if the current
9652 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9655 The ``bool'' version returns true if the comparison is successful and
9656 @var{newval} is written. The ``val'' version returns the contents
9657 of @code{*@var{ptr}} before the operation.
9659 @item __sync_synchronize (...)
9660 @findex __sync_synchronize
9661 This built-in function issues a full memory barrier.
9663 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9664 @findex __sync_lock_test_and_set
9665 This built-in function, as described by Intel, is not a traditional test-and-set
9666 operation, but rather an atomic exchange operation. It writes @var{value}
9667 into @code{*@var{ptr}}, and returns the previous contents of
9670 Many targets have only minimal support for such locks, and do not support
9671 a full exchange operation. In this case, a target may support reduced
9672 functionality here by which the @emph{only} valid value to store is the
9673 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
9674 is implementation defined.
9676 This built-in function is not a full barrier,
9677 but rather an @dfn{acquire barrier}.
9678 This means that references after the operation cannot move to (or be
9679 speculated to) before the operation, but previous memory stores may not
9680 be globally visible yet, and previous memory loads may not yet be
9683 @item void __sync_lock_release (@var{type} *ptr, ...)
9684 @findex __sync_lock_release
9685 This built-in function releases the lock acquired by
9686 @code{__sync_lock_test_and_set}.
9687 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9689 This built-in function is not a full barrier,
9690 but rather a @dfn{release barrier}.
9691 This means that all previous memory stores are globally visible, and all
9692 previous memory loads have been satisfied, but following memory reads
9693 are not prevented from being speculated to before the barrier.
9696 @node __atomic Builtins
9697 @section Built-in Functions for Memory Model Aware Atomic Operations
9699 The following built-in functions approximately match the requirements
9700 for the C++11 memory model. They are all
9701 identified by being prefixed with @samp{__atomic} and most are
9702 overloaded so that they work with multiple types.
9704 These functions are intended to replace the legacy @samp{__sync}
9705 builtins. The main difference is that the memory order that is requested
9706 is a parameter to the functions. New code should always use the
9707 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9709 Note that the @samp{__atomic} builtins assume that programs will
9710 conform to the C++11 memory model. In particular, they assume
9711 that programs are free of data races. See the C++11 standard for
9712 detailed requirements.
9714 The @samp{__atomic} builtins can be used with any integral scalar or
9715 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
9716 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9717 supported by the architecture.
9719 The four non-arithmetic functions (load, store, exchange, and
9720 compare_exchange) all have a generic version as well. This generic
9721 version works on any data type. It uses the lock-free built-in function
9722 if the specific data type size makes that possible; otherwise, an
9723 external call is left to be resolved at run time. This external call is
9724 the same format with the addition of a @samp{size_t} parameter inserted
9725 as the first parameter indicating the size of the object being pointed to.
9726 All objects must be the same size.
9728 There are 6 different memory orders that can be specified. These map
9729 to the C++11 memory orders with the same names, see the C++11 standard
9730 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9731 on atomic synchronization} for detailed definitions. Individual
9732 targets may also support additional memory orders for use on specific
9733 architectures. Refer to the target documentation for details of
9736 An atomic operation can both constrain code motion and
9737 be mapped to hardware instructions for synchronization between threads
9738 (e.g., a fence). To which extent this happens is controlled by the
9739 memory orders, which are listed here in approximately ascending order of
9740 strength. The description of each memory order is only meant to roughly
9741 illustrate the effects and is not a specification; see the C++11
9742 memory model for precise semantics.
9745 @item __ATOMIC_RELAXED
9746 Implies no inter-thread ordering constraints.
9747 @item __ATOMIC_CONSUME
9748 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9749 memory order because of a deficiency in C++11's semantics for
9750 @code{memory_order_consume}.
9751 @item __ATOMIC_ACQUIRE
9752 Creates an inter-thread happens-before constraint from the release (or
9753 stronger) semantic store to this acquire load. Can prevent hoisting
9754 of code to before the operation.
9755 @item __ATOMIC_RELEASE
9756 Creates an inter-thread happens-before constraint to acquire (or stronger)
9757 semantic loads that read from this release store. Can prevent sinking
9758 of code to after the operation.
9759 @item __ATOMIC_ACQ_REL
9760 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9761 @code{__ATOMIC_RELEASE}.
9762 @item __ATOMIC_SEQ_CST
9763 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9766 Note that in the C++11 memory model, @emph{fences} (e.g.,
9767 @samp{__atomic_thread_fence}) take effect in combination with other
9768 atomic operations on specific memory locations (e.g., atomic loads);
9769 operations on specific memory locations do not necessarily affect other
9770 operations in the same way.
9772 Target architectures are encouraged to provide their own patterns for
9773 each of the atomic built-in functions. If no target is provided, the original
9774 non-memory model set of @samp{__sync} atomic built-in functions are
9775 used, along with any required synchronization fences surrounding it in
9776 order to achieve the proper behavior. Execution in this case is subject
9777 to the same restrictions as those built-in functions.
9779 If there is no pattern or mechanism to provide a lock-free instruction
9780 sequence, a call is made to an external routine with the same parameters
9781 to be resolved at run time.
9783 When implementing patterns for these built-in functions, the memory order
9784 parameter can be ignored as long as the pattern implements the most
9785 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
9786 orders execute correctly with this memory order but they may not execute as
9787 efficiently as they could with a more appropriate implementation of the
9788 relaxed requirements.
9790 Note that the C++11 standard allows for the memory order parameter to be
9791 determined at run time rather than at compile time. These built-in
9792 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9793 than invoke a runtime library call or inline a switch statement. This is
9794 standard compliant, safe, and the simplest approach for now.
9796 The memory order parameter is a signed int, but only the lower 16 bits are
9797 reserved for the memory order. The remainder of the signed int is reserved
9798 for target use and should be 0. Use of the predefined atomic values
9799 ensures proper usage.
9801 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9802 This built-in function implements an atomic load operation. It returns the
9803 contents of @code{*@var{ptr}}.
9805 The valid memory order variants are
9806 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9807 and @code{__ATOMIC_CONSUME}.
9811 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9812 This is the generic version of an atomic load. It returns the
9813 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9817 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9818 This built-in function implements an atomic store operation. It writes
9819 @code{@var{val}} into @code{*@var{ptr}}.
9821 The valid memory order variants are
9822 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9826 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9827 This is the generic version of an atomic store. It stores the value
9828 of @code{*@var{val}} into @code{*@var{ptr}}.
9832 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9833 This built-in function implements an atomic exchange operation. It writes
9834 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9837 The valid memory order variants are
9838 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9839 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9843 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9844 This is the generic version of an atomic exchange. It stores the
9845 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9846 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9850 @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)
9851 This built-in function implements an atomic compare and exchange operation.
9852 This compares the contents of @code{*@var{ptr}} with the contents of
9853 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9854 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
9855 equal, the operation is a @emph{read} and the current contents of
9856 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is true
9857 for weak compare_exchange, which may fail spuriously, and false for
9858 the strong variation, which never fails spuriously. Many targets
9859 only offer the strong variation and ignore the parameter. When in doubt, use
9860 the strong variation.
9862 If @var{desired} is written into @code{*@var{ptr}} then true is returned
9863 and memory is affected according to the
9864 memory order specified by @var{success_memorder}. There are no
9865 restrictions on what memory order can be used here.
9867 Otherwise, false is returned and memory is affected according
9868 to @var{failure_memorder}. This memory order cannot be
9869 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
9870 stronger order than that specified by @var{success_memorder}.
9874 @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)
9875 This built-in function implements the generic version of
9876 @code{__atomic_compare_exchange}. The function is virtually identical to
9877 @code{__atomic_compare_exchange_n}, except the desired value is also a
9882 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9883 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9884 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9885 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9886 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9887 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9888 These built-in functions perform the operation suggested by the name, and
9889 return the result of the operation. Operations on pointer arguments are
9890 performed as if the operands were of the @code{uintptr_t} type. That is,
9891 they are not scaled by the size of the type to which the pointer points.
9894 @{ *ptr @var{op}= val; return *ptr; @}
9897 The object pointed to by the first argument must be of integer or pointer
9898 type. It must not be a boolean type. All memory orders are valid.
9902 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9903 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9904 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9905 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9906 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9907 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9908 These built-in functions perform the operation suggested by the name, and
9909 return the value that had previously been in @code{*@var{ptr}}. Operations
9910 on pointer arguments are performed as if the operands were of
9911 the @code{uintptr_t} type. That is, they are not scaled by the size of
9912 the type to which the pointer points.
9915 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9918 The same constraints on arguments apply as for the corresponding
9919 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
9923 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9925 This built-in function performs an atomic test-and-set operation on
9926 the byte at @code{*@var{ptr}}. The byte is set to some implementation
9927 defined nonzero ``set'' value and the return value is @code{true} if and only
9928 if the previous contents were ``set''.
9929 It should be only used for operands of type @code{bool} or @code{char}. For
9930 other types only part of the value may be set.
9932 All memory orders are valid.
9936 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9938 This built-in function performs an atomic clear operation on
9939 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
9940 It should be only used for operands of type @code{bool} or @code{char} and
9941 in conjunction with @code{__atomic_test_and_set}.
9942 For other types it may only clear partially. If the type is not @code{bool}
9943 prefer using @code{__atomic_store}.
9945 The valid memory order variants are
9946 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9947 @code{__ATOMIC_RELEASE}.
9951 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9953 This built-in function acts as a synchronization fence between threads
9954 based on the specified memory order.
9956 All memory orders are valid.
9960 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9962 This built-in function acts as a synchronization fence between a thread
9963 and signal handlers based in the same thread.
9965 All memory orders are valid.
9969 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
9971 This built-in function returns true if objects of @var{size} bytes always
9972 generate lock-free atomic instructions for the target architecture.
9973 @var{size} must resolve to a compile-time constant and the result also
9974 resolves to a compile-time constant.
9976 @var{ptr} is an optional pointer to the object that may be used to determine
9977 alignment. A value of 0 indicates typical alignment should be used. The
9978 compiler may also ignore this parameter.
9981 if (__atomic_always_lock_free (sizeof (long long), 0))
9986 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9988 This built-in function returns true if objects of @var{size} bytes always
9989 generate lock-free atomic instructions for the target architecture. If
9990 the built-in function is not known to be lock-free, a call is made to a
9991 runtime routine named @code{__atomic_is_lock_free}.
9993 @var{ptr} is an optional pointer to the object that may be used to determine
9994 alignment. A value of 0 indicates typical alignment should be used. The
9995 compiler may also ignore this parameter.
9998 @node Integer Overflow Builtins
9999 @section Built-in Functions to Perform Arithmetic with Overflow Checking
10001 The following built-in functions allow performing simple arithmetic operations
10002 together with checking whether the operations overflowed.
10004 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10005 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
10006 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
10007 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
10008 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
10009 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10010 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10012 These built-in functions promote the first two operands into infinite precision signed
10013 type and perform addition on those promoted operands. The result is then
10014 cast to the type the third pointer argument points to and stored there.
10015 If the stored result is equal to the infinite precision result, the built-in
10016 functions return false, otherwise they return true. As the addition is
10017 performed in infinite signed precision, these built-in functions have fully defined
10018 behavior for all argument values.
10020 The first built-in function allows arbitrary integral types for operands and
10021 the result type must be pointer to some integral type other than enumerated or
10022 boolean type, the rest of the built-in functions have explicit integer types.
10024 The compiler will attempt to use hardware instructions to implement
10025 these built-in functions where possible, like conditional jump on overflow
10026 after addition, conditional jump on carry etc.
10030 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10031 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
10032 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
10033 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
10034 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
10035 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10036 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10038 These built-in functions are similar to the add overflow checking built-in
10039 functions above, except they perform subtraction, subtract the second argument
10040 from the first one, instead of addition.
10044 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10045 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
10046 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
10047 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
10048 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
10049 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10050 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10052 These built-in functions are similar to the add overflow checking built-in
10053 functions above, except they perform multiplication, instead of addition.
10057 The following built-in functions allow checking if simple arithmetic operation
10060 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10061 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10062 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10064 These built-in functions are similar to @code{__builtin_add_overflow},
10065 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
10066 they don't store the result of the arithmetic operation anywhere and the
10067 last argument is not a pointer, but some expression with integral type other
10068 than enumerated or boolean type.
10070 The built-in functions promote the first two operands into infinite precision signed type
10071 and perform addition on those promoted operands. The result is then
10072 cast to the type of the third argument. If the cast result is equal to the infinite
10073 precision result, the built-in functions return false, otherwise they return true.
10074 The value of the third argument is ignored, just the side-effects in the third argument
10075 are evaluated, and no integral argument promotions are performed on the last argument.
10076 If the third argument is a bit-field, the type used for the result cast has the
10077 precision and signedness of the given bit-field, rather than precision and signedness
10078 of the underlying type.
10080 For example, the following macro can be used to portably check, at
10081 compile-time, whether or not adding two constant integers will overflow,
10082 and perform the addition only when it is known to be safe and not to trigger
10083 a @option{-Woverflow} warning.
10086 #define INT_ADD_OVERFLOW_P(a, b) \
10087 __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
10090 A = INT_MAX, B = 3,
10091 C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
10092 D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
10096 The compiler will attempt to use hardware instructions to implement
10097 these built-in functions where possible, like conditional jump on overflow
10098 after addition, conditional jump on carry etc.
10102 @node x86 specific memory model extensions for transactional memory
10103 @section x86-Specific Memory Model Extensions for Transactional Memory
10105 The x86 architecture supports additional memory ordering flags
10106 to mark critical sections for hardware lock elision.
10107 These must be specified in addition to an existing memory order to
10111 @item __ATOMIC_HLE_ACQUIRE
10112 Start lock elision on a lock variable.
10113 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
10114 @item __ATOMIC_HLE_RELEASE
10115 End lock elision on a lock variable.
10116 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
10119 When a lock acquire fails, it is required for good performance to abort
10120 the transaction quickly. This can be done with a @code{_mm_pause}.
10123 #include <immintrin.h> // For _mm_pause
10127 /* Acquire lock with lock elision */
10128 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10129 _mm_pause(); /* Abort failed transaction */
10131 /* Free lock with lock elision */
10132 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10135 @node Object Size Checking
10136 @section Object Size Checking Built-in Functions
10137 @findex __builtin_object_size
10138 @findex __builtin___memcpy_chk
10139 @findex __builtin___mempcpy_chk
10140 @findex __builtin___memmove_chk
10141 @findex __builtin___memset_chk
10142 @findex __builtin___strcpy_chk
10143 @findex __builtin___stpcpy_chk
10144 @findex __builtin___strncpy_chk
10145 @findex __builtin___strcat_chk
10146 @findex __builtin___strncat_chk
10147 @findex __builtin___sprintf_chk
10148 @findex __builtin___snprintf_chk
10149 @findex __builtin___vsprintf_chk
10150 @findex __builtin___vsnprintf_chk
10151 @findex __builtin___printf_chk
10152 @findex __builtin___vprintf_chk
10153 @findex __builtin___fprintf_chk
10154 @findex __builtin___vfprintf_chk
10156 GCC implements a limited buffer overflow protection mechanism that can
10157 prevent some buffer overflow attacks by determining the sizes of objects
10158 into which data is about to be written and preventing the writes when
10159 the size isn't sufficient. The built-in functions described below yield
10160 the best results when used together and when optimization is enabled.
10161 For example, to detect object sizes across function boundaries or to
10162 follow pointer assignments through non-trivial control flow they rely
10163 on various optimization passes enabled with @option{-O2}. However, to
10164 a limited extent, they can be used without optimization as well.
10166 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
10167 is a built-in construct that returns a constant number of bytes from
10168 @var{ptr} to the end of the object @var{ptr} pointer points to
10169 (if known at compile time). @code{__builtin_object_size} never evaluates
10170 its arguments for side-effects. If there are any side-effects in them, it
10171 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10172 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
10173 point to and all of them are known at compile time, the returned number
10174 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10175 0 and minimum if nonzero. If it is not possible to determine which objects
10176 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10177 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10178 for @var{type} 2 or 3.
10180 @var{type} is an integer constant from 0 to 3. If the least significant
10181 bit is clear, objects are whole variables, if it is set, a closest
10182 surrounding subobject is considered the object a pointer points to.
10183 The second bit determines if maximum or minimum of remaining bytes
10187 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10188 char *p = &var.buf1[1], *q = &var.b;
10190 /* Here the object p points to is var. */
10191 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10192 /* The subobject p points to is var.buf1. */
10193 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10194 /* The object q points to is var. */
10195 assert (__builtin_object_size (q, 0)
10196 == (char *) (&var + 1) - (char *) &var.b);
10197 /* The subobject q points to is var.b. */
10198 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10202 There are built-in functions added for many common string operation
10203 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10204 built-in is provided. This built-in has an additional last argument,
10205 which is the number of bytes remaining in object the @var{dest}
10206 argument points to or @code{(size_t) -1} if the size is not known.
10208 The built-in functions are optimized into the normal string functions
10209 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10210 it is known at compile time that the destination object will not
10211 be overflown. If the compiler can determine at compile time the
10212 object will be always overflown, it issues a warning.
10214 The intended use can be e.g.@:
10218 #define bos0(dest) __builtin_object_size (dest, 0)
10219 #define memcpy(dest, src, n) \
10220 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10224 /* It is unknown what object p points to, so this is optimized
10225 into plain memcpy - no checking is possible. */
10226 memcpy (p, "abcde", n);
10227 /* Destination is known and length too. It is known at compile
10228 time there will be no overflow. */
10229 memcpy (&buf[5], "abcde", 5);
10230 /* Destination is known, but the length is not known at compile time.
10231 This will result in __memcpy_chk call that can check for overflow
10233 memcpy (&buf[5], "abcde", n);
10234 /* Destination is known and it is known at compile time there will
10235 be overflow. There will be a warning and __memcpy_chk call that
10236 will abort the program at run time. */
10237 memcpy (&buf[6], "abcde", 5);
10240 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10241 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10242 @code{strcat} and @code{strncat}.
10244 There are also checking built-in functions for formatted output functions.
10246 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10247 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10248 const char *fmt, ...);
10249 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10251 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10252 const char *fmt, va_list ap);
10255 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10256 etc.@: functions and can contain implementation specific flags on what
10257 additional security measures the checking function might take, such as
10258 handling @code{%n} differently.
10260 The @var{os} argument is the object size @var{s} points to, like in the
10261 other built-in functions. There is a small difference in the behavior
10262 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10263 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10264 the checking function is called with @var{os} argument set to
10265 @code{(size_t) -1}.
10267 In addition to this, there are checking built-in functions
10268 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10269 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10270 These have just one additional argument, @var{flag}, right before
10271 format string @var{fmt}. If the compiler is able to optimize them to
10272 @code{fputc} etc.@: functions, it does, otherwise the checking function
10273 is called and the @var{flag} argument passed to it.
10275 @node Pointer Bounds Checker builtins
10276 @section Pointer Bounds Checker Built-in Functions
10277 @cindex Pointer Bounds Checker builtins
10278 @findex __builtin___bnd_set_ptr_bounds
10279 @findex __builtin___bnd_narrow_ptr_bounds
10280 @findex __builtin___bnd_copy_ptr_bounds
10281 @findex __builtin___bnd_init_ptr_bounds
10282 @findex __builtin___bnd_null_ptr_bounds
10283 @findex __builtin___bnd_store_ptr_bounds
10284 @findex __builtin___bnd_chk_ptr_lbounds
10285 @findex __builtin___bnd_chk_ptr_ubounds
10286 @findex __builtin___bnd_chk_ptr_bounds
10287 @findex __builtin___bnd_get_ptr_lbound
10288 @findex __builtin___bnd_get_ptr_ubound
10290 GCC provides a set of built-in functions to control Pointer Bounds Checker
10291 instrumentation. Note that all Pointer Bounds Checker builtins can be used
10292 even if you compile with Pointer Bounds Checker off
10293 (@option{-fno-check-pointer-bounds}).
10294 The behavior may differ in such case as documented below.
10296 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
10298 This built-in function returns a new pointer with the value of @var{q}, and
10299 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
10300 Bounds Checker off, the built-in function just returns the first argument.
10303 extern void *__wrap_malloc (size_t n)
10305 void *p = (void *)__real_malloc (n);
10306 if (!p) return __builtin___bnd_null_ptr_bounds (p);
10307 return __builtin___bnd_set_ptr_bounds (p, n);
10313 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
10315 This built-in function returns a new pointer with the value of @var{p}
10316 and associates it with the narrowed bounds formed by the intersection
10317 of bounds associated with @var{q} and the bounds
10318 [@var{p}, @var{p} + @var{size} - 1].
10319 With Pointer Bounds Checker off, the built-in function just returns the first
10323 void init_objects (object *objs, size_t size)
10326 /* Initialize objects one-by-one passing pointers with bounds of
10327 an object, not the full array of objects. */
10328 for (i = 0; i < size; i++)
10329 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10336 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10338 This built-in function returns a new pointer with the value of @var{q},
10339 and associates it with the bounds already associated with pointer @var{r}.
10340 With Pointer Bounds Checker off, the built-in function just returns the first
10344 /* Here is a way to get pointer to object's field but
10345 still with the full object's bounds. */
10346 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
10352 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10354 This built-in function returns a new pointer with the value of @var{q}, and
10355 associates it with INIT (allowing full memory access) bounds. With Pointer
10356 Bounds Checker off, the built-in function just returns the first argument.
10360 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10362 This built-in function returns a new pointer with the value of @var{q}, and
10363 associates it with NULL (allowing no memory access) bounds. With Pointer
10364 Bounds Checker off, the built-in function just returns the first argument.
10368 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10370 This built-in function stores the bounds associated with pointer @var{ptr_val}
10371 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
10372 bounds from legacy code without touching the associated pointer's memory when
10373 pointers are copied as integers. With Pointer Bounds Checker off, the built-in
10374 function call is ignored.
10378 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10380 This built-in function checks if the pointer @var{q} is within the lower
10381 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10382 function call is ignored.
10385 extern void *__wrap_memset (void *dst, int c, size_t len)
10389 __builtin___bnd_chk_ptr_lbounds (dst);
10390 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10391 __real_memset (dst, c, len);
10399 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10401 This built-in function checks if the pointer @var{q} is within the upper
10402 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10403 function call is ignored.
10407 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10409 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10410 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
10411 off, the built-in function call is ignored.
10414 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10418 __bnd_chk_ptr_bounds (dst, n);
10419 __bnd_chk_ptr_bounds (src, n);
10420 __real_memcpy (dst, src, n);
10428 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10430 This built-in function returns the lower bound associated
10431 with the pointer @var{q}, as a pointer value.
10432 This is useful for debugging using @code{printf}.
10433 With Pointer Bounds Checker off, the built-in function returns 0.
10436 void *lb = __builtin___bnd_get_ptr_lbound (q);
10437 void *ub = __builtin___bnd_get_ptr_ubound (q);
10438 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
10443 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10445 This built-in function returns the upper bound (which is a pointer) associated
10446 with the pointer @var{q}. With Pointer Bounds Checker off,
10447 the built-in function returns -1.
10451 @node Cilk Plus Builtins
10452 @section Cilk Plus C/C++ Language Extension Built-in Functions
10454 GCC provides support for the following built-in reduction functions if Cilk Plus
10455 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10458 @item @code{__sec_implicit_index}
10459 @item @code{__sec_reduce}
10460 @item @code{__sec_reduce_add}
10461 @item @code{__sec_reduce_all_nonzero}
10462 @item @code{__sec_reduce_all_zero}
10463 @item @code{__sec_reduce_any_nonzero}
10464 @item @code{__sec_reduce_any_zero}
10465 @item @code{__sec_reduce_max}
10466 @item @code{__sec_reduce_min}
10467 @item @code{__sec_reduce_max_ind}
10468 @item @code{__sec_reduce_min_ind}
10469 @item @code{__sec_reduce_mul}
10470 @item @code{__sec_reduce_mutating}
10473 Further details and examples about these built-in functions are described
10474 in the Cilk Plus language manual which can be found at
10475 @uref{https://www.cilkplus.org}.
10477 @node Other Builtins
10478 @section Other Built-in Functions Provided by GCC
10479 @cindex built-in functions
10480 @findex __builtin_alloca
10481 @findex __builtin_alloca_with_align
10482 @findex __builtin_call_with_static_chain
10483 @findex __builtin_fpclassify
10484 @findex __builtin_isfinite
10485 @findex __builtin_isnormal
10486 @findex __builtin_isgreater
10487 @findex __builtin_isgreaterequal
10488 @findex __builtin_isinf_sign
10489 @findex __builtin_isless
10490 @findex __builtin_islessequal
10491 @findex __builtin_islessgreater
10492 @findex __builtin_isunordered
10493 @findex __builtin_powi
10494 @findex __builtin_powif
10495 @findex __builtin_powil
10656 @findex fprintf_unlocked
10658 @findex fputs_unlocked
10766 @findex nexttowardf
10767 @findex nexttowardl
10775 @findex printf_unlocked
10805 @findex signbitd128
10806 @findex significand
10807 @findex significandf
10808 @findex significandl
10836 @findex strncasecmp
10879 GCC provides a large number of built-in functions other than the ones
10880 mentioned above. Some of these are for internal use in the processing
10881 of exceptions or variable-length argument lists and are not
10882 documented here because they may change from time to time; we do not
10883 recommend general use of these functions.
10885 The remaining functions are provided for optimization purposes.
10887 With the exception of built-ins that have library equivalents such as
10888 the standard C library functions discussed below, or that expand to
10889 library calls, GCC built-in functions are always expanded inline and
10890 thus do not have corresponding entry points and their address cannot
10891 be obtained. Attempting to use them in an expression other than
10892 a function call results in a compile-time error.
10894 @opindex fno-builtin
10895 GCC includes built-in versions of many of the functions in the standard
10896 C library. These functions come in two forms: one whose names start with
10897 the @code{__builtin_} prefix, and the other without. Both forms have the
10898 same type (including prototype), the same address (when their address is
10899 taken), and the same meaning as the C library functions even if you specify
10900 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
10901 functions are only optimized in certain cases; if they are not optimized in
10902 a particular case, a call to the library function is emitted.
10906 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10907 @option{-std=c99} or @option{-std=c11}), the functions
10908 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10909 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10910 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10911 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10912 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10913 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10914 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10915 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10916 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10917 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10918 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10919 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10920 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10921 @code{significandl}, @code{significand}, @code{sincosf},
10922 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10923 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10924 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10925 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10927 may be handled as built-in functions.
10928 All these functions have corresponding versions
10929 prefixed with @code{__builtin_}, which may be used even in strict C90
10932 The ISO C99 functions
10933 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10934 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10935 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10936 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10937 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10938 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10939 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10940 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10941 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10942 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10943 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10944 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10945 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10946 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10947 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10948 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10949 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10950 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10951 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10952 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10953 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10954 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10955 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10956 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10957 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10958 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10959 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10960 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10961 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10962 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10963 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10964 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10965 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10966 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10967 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10968 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10969 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10970 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10971 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10972 are handled as built-in functions
10973 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10975 There are also built-in versions of the ISO C99 functions
10976 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10977 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10978 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10979 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10980 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10981 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10982 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10983 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10984 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10985 that are recognized in any mode since ISO C90 reserves these names for
10986 the purpose to which ISO C99 puts them. All these functions have
10987 corresponding versions prefixed with @code{__builtin_}.
10989 There are also built-in functions @code{__builtin_fabsf@var{n}},
10990 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
10991 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
10992 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
10993 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
10994 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
10996 There are also GNU extension functions @code{clog10}, @code{clog10f} and
10997 @code{clog10l} which names are reserved by ISO C99 for future use.
10998 All these functions have versions prefixed with @code{__builtin_}.
11000 The ISO C94 functions
11001 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
11002 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
11003 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
11005 are handled as built-in functions
11006 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11008 The ISO C90 functions
11009 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11010 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11011 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11012 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11013 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11014 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11015 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11016 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11017 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11018 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11019 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11020 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11021 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11022 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11023 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11024 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11025 are all recognized as built-in functions unless
11026 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11027 is specified for an individual function). All of these functions have
11028 corresponding versions prefixed with @code{__builtin_}.
11030 GCC provides built-in versions of the ISO C99 floating-point comparison
11031 macros that avoid raising exceptions for unordered operands. They have
11032 the same names as the standard macros ( @code{isgreater},
11033 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11034 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11035 prefixed. We intend for a library implementor to be able to simply
11036 @code{#define} each standard macro to its built-in equivalent.
11037 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11038 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11039 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
11040 built-in functions appear both with and without the @code{__builtin_} prefix.
11042 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11043 The @code{__builtin_alloca} function must be called at block scope.
11044 The function allocates an object @var{size} bytes large on the stack
11045 of the calling function. The object is aligned on the default stack
11046 alignment boundary for the target determined by the
11047 @code{__BIGGEST_ALIGNMENT__} macro. The @code{__builtin_alloca}
11048 function returns a pointer to the first byte of the allocated object.
11049 The lifetime of the allocated object ends just before the calling
11050 function returns to its caller. This is so even when
11051 @code{__builtin_alloca} is called within a nested block.
11053 For example, the following function allocates eight objects of @code{n}
11054 bytes each on the stack, storing a pointer to each in consecutive elements
11055 of the array @code{a}. It then passes the array to function @code{g}
11056 which can safely use the storage pointed to by each of the array elements.
11059 void f (unsigned n)
11062 for (int i = 0; i != 8; ++i)
11063 a [i] = __builtin_alloca (n);
11065 g (a, n); // @r{safe}
11069 Since the @code{__builtin_alloca} function doesn't validate its argument
11070 it is the responsibility of its caller to make sure the argument doesn't
11071 cause it to exceed the stack size limit.
11072 The @code{__builtin_alloca} function is provided to make it possible to
11073 allocate on the stack arrays of bytes with an upper bound that may be
11074 computed at run time. Since C99 Variable Length Arrays offer
11075 similar functionality under a portable, more convenient, and safer
11076 interface they are recommended instead, in both C99 and C++ programs
11077 where GCC provides them as an extension.
11078 @xref{Variable Length}, for details.
11082 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11083 The @code{__builtin_alloca_with_align} function must be called at block
11084 scope. The function allocates an object @var{size} bytes large on
11085 the stack of the calling function. The allocated object is aligned on
11086 the boundary specified by the argument @var{alignment} whose unit is given
11087 in bits (not bytes). The @var{size} argument must be positive and not
11088 exceed the stack size limit. The @var{alignment} argument must be a constant
11089 integer expression that evaluates to a power of 2 greater than or equal to
11090 @code{CHAR_BIT} and less than some unspecified maximum. Invocations
11091 with other values are rejected with an error indicating the valid bounds.
11092 The function returns a pointer to the first byte of the allocated object.
11093 The lifetime of the allocated object ends at the end of the block in which
11094 the function was called. The allocated storage is released no later than
11095 just before the calling function returns to its caller, but may be released
11096 at the end of the block in which the function was called.
11098 For example, in the following function the call to @code{g} is unsafe
11099 because when @code{overalign} is non-zero, the space allocated by
11100 @code{__builtin_alloca_with_align} may have been released at the end
11101 of the @code{if} statement in which it was called.
11104 void f (unsigned n, bool overalign)
11108 p = __builtin_alloca_with_align (n, 64 /* bits */);
11110 p = __builtin_alloc (n);
11112 g (p, n); // @r{unsafe}
11116 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11117 @var{size} argument it is the responsibility of its caller to make sure
11118 the argument doesn't cause it to exceed the stack size limit.
11119 The @code{__builtin_alloca_with_align} function is provided to make
11120 it possible to allocate on the stack overaligned arrays of bytes with
11121 an upper bound that may be computed at run time. Since C99
11122 Variable Length Arrays offer the same functionality under
11123 a portable, more convenient, and safer interface they are recommended
11124 instead, in both C99 and C++ programs where GCC provides them as
11125 an extension. @xref{Variable Length}, for details.
11129 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11131 You can use the built-in function @code{__builtin_types_compatible_p} to
11132 determine whether two types are the same.
11134 This built-in function returns 1 if the unqualified versions of the
11135 types @var{type1} and @var{type2} (which are types, not expressions) are
11136 compatible, 0 otherwise. The result of this built-in function can be
11137 used in integer constant expressions.
11139 This built-in function ignores top level qualifiers (e.g., @code{const},
11140 @code{volatile}). For example, @code{int} is equivalent to @code{const
11143 The type @code{int[]} and @code{int[5]} are compatible. On the other
11144 hand, @code{int} and @code{char *} are not compatible, even if the size
11145 of their types, on the particular architecture are the same. Also, the
11146 amount of pointer indirection is taken into account when determining
11147 similarity. Consequently, @code{short *} is not similar to
11148 @code{short **}. Furthermore, two types that are typedefed are
11149 considered compatible if their underlying types are compatible.
11151 An @code{enum} type is not considered to be compatible with another
11152 @code{enum} type even if both are compatible with the same integer
11153 type; this is what the C standard specifies.
11154 For example, @code{enum @{foo, bar@}} is not similar to
11155 @code{enum @{hot, dog@}}.
11157 You typically use this function in code whose execution varies
11158 depending on the arguments' types. For example:
11163 typeof (x) tmp = (x); \
11164 if (__builtin_types_compatible_p (typeof (x), long double)) \
11165 tmp = foo_long_double (tmp); \
11166 else if (__builtin_types_compatible_p (typeof (x), double)) \
11167 tmp = foo_double (tmp); \
11168 else if (__builtin_types_compatible_p (typeof (x), float)) \
11169 tmp = foo_float (tmp); \
11176 @emph{Note:} This construct is only available for C@.
11180 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11182 The @var{call_exp} expression must be a function call, and the
11183 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
11184 is passed to the function call in the target's static chain location.
11185 The result of builtin is the result of the function call.
11187 @emph{Note:} This builtin is only available for C@.
11188 This builtin can be used to call Go closures from C.
11192 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11194 You can use the built-in function @code{__builtin_choose_expr} to
11195 evaluate code depending on the value of a constant expression. This
11196 built-in function returns @var{exp1} if @var{const_exp}, which is an
11197 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
11199 This built-in function is analogous to the @samp{? :} operator in C,
11200 except that the expression returned has its type unaltered by promotion
11201 rules. Also, the built-in function does not evaluate the expression
11202 that is not chosen. For example, if @var{const_exp} evaluates to true,
11203 @var{exp2} is not evaluated even if it has side-effects.
11205 This built-in function can return an lvalue if the chosen argument is an
11208 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11209 type. Similarly, if @var{exp2} is returned, its return type is the same
11216 __builtin_choose_expr ( \
11217 __builtin_types_compatible_p (typeof (x), double), \
11219 __builtin_choose_expr ( \
11220 __builtin_types_compatible_p (typeof (x), float), \
11222 /* @r{The void expression results in a compile-time error} \
11223 @r{when assigning the result to something.} */ \
11227 @emph{Note:} This construct is only available for C@. Furthermore, the
11228 unused expression (@var{exp1} or @var{exp2} depending on the value of
11229 @var{const_exp}) may still generate syntax errors. This may change in
11234 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11236 The built-in function @code{__builtin_complex} is provided for use in
11237 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11238 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
11239 real binary floating-point type, and the result has the corresponding
11240 complex type with real and imaginary parts @var{real} and @var{imag}.
11241 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11242 infinities, NaNs and negative zeros are involved.
11246 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11247 You can use the built-in function @code{__builtin_constant_p} to
11248 determine if a value is known to be constant at compile time and hence
11249 that GCC can perform constant-folding on expressions involving that
11250 value. The argument of the function is the value to test. The function
11251 returns the integer 1 if the argument is known to be a compile-time
11252 constant and 0 if it is not known to be a compile-time constant. A
11253 return of 0 does not indicate that the value is @emph{not} a constant,
11254 but merely that GCC cannot prove it is a constant with the specified
11255 value of the @option{-O} option.
11257 You typically use this function in an embedded application where
11258 memory is a critical resource. If you have some complex calculation,
11259 you may want it to be folded if it involves constants, but need to call
11260 a function if it does not. For example:
11263 #define Scale_Value(X) \
11264 (__builtin_constant_p (X) \
11265 ? ((X) * SCALE + OFFSET) : Scale (X))
11268 You may use this built-in function in either a macro or an inline
11269 function. However, if you use it in an inlined function and pass an
11270 argument of the function as the argument to the built-in, GCC
11271 never returns 1 when you call the inline function with a string constant
11272 or compound literal (@pxref{Compound Literals}) and does not return 1
11273 when you pass a constant numeric value to the inline function unless you
11274 specify the @option{-O} option.
11276 You may also use @code{__builtin_constant_p} in initializers for static
11277 data. For instance, you can write
11280 static const int table[] = @{
11281 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11287 This is an acceptable initializer even if @var{EXPRESSION} is not a
11288 constant expression, including the case where
11289 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11290 folded to a constant but @var{EXPRESSION} contains operands that are
11291 not otherwise permitted in a static initializer (for example,
11292 @code{0 && foo ()}). GCC must be more conservative about evaluating the
11293 built-in in this case, because it has no opportunity to perform
11297 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11298 @opindex fprofile-arcs
11299 You may use @code{__builtin_expect} to provide the compiler with
11300 branch prediction information. In general, you should prefer to
11301 use actual profile feedback for this (@option{-fprofile-arcs}), as
11302 programmers are notoriously bad at predicting how their programs
11303 actually perform. However, there are applications in which this
11304 data is hard to collect.
11306 The return value is the value of @var{exp}, which should be an integral
11307 expression. The semantics of the built-in are that it is expected that
11308 @var{exp} == @var{c}. For example:
11311 if (__builtin_expect (x, 0))
11316 indicates that we do not expect to call @code{foo}, since
11317 we expect @code{x} to be zero. Since you are limited to integral
11318 expressions for @var{exp}, you should use constructions such as
11321 if (__builtin_expect (ptr != NULL, 1))
11326 when testing pointer or floating-point values.
11329 @deftypefn {Built-in Function} void __builtin_trap (void)
11330 This function causes the program to exit abnormally. GCC implements
11331 this function by using a target-dependent mechanism (such as
11332 intentionally executing an illegal instruction) or by calling
11333 @code{abort}. The mechanism used may vary from release to release so
11334 you should not rely on any particular implementation.
11337 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11338 If control flow reaches the point of the @code{__builtin_unreachable},
11339 the program is undefined. It is useful in situations where the
11340 compiler cannot deduce the unreachability of the code.
11342 One such case is immediately following an @code{asm} statement that
11343 either never terminates, or one that transfers control elsewhere
11344 and never returns. In this example, without the
11345 @code{__builtin_unreachable}, GCC issues a warning that control
11346 reaches the end of a non-void function. It also generates code
11347 to return after the @code{asm}.
11350 int f (int c, int v)
11358 asm("jmp error_handler");
11359 __builtin_unreachable ();
11365 Because the @code{asm} statement unconditionally transfers control out
11366 of the function, control never reaches the end of the function
11367 body. The @code{__builtin_unreachable} is in fact unreachable and
11368 communicates this fact to the compiler.
11370 Another use for @code{__builtin_unreachable} is following a call a
11371 function that never returns but that is not declared
11372 @code{__attribute__((noreturn))}, as in this example:
11375 void function_that_never_returns (void);
11385 function_that_never_returns ();
11386 __builtin_unreachable ();
11393 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11394 This function returns its first argument, and allows the compiler
11395 to assume that the returned pointer is at least @var{align} bytes
11396 aligned. This built-in can have either two or three arguments,
11397 if it has three, the third argument should have integer type, and
11398 if it is nonzero means misalignment offset. For example:
11401 void *x = __builtin_assume_aligned (arg, 16);
11405 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11406 16-byte aligned, while:
11409 void *x = __builtin_assume_aligned (arg, 32, 8);
11413 means that the compiler can assume for @code{x}, set to @code{arg}, that
11414 @code{(char *) x - 8} is 32-byte aligned.
11417 @deftypefn {Built-in Function} int __builtin_LINE ()
11418 This function is the equivalent of the preprocessor @code{__LINE__}
11419 macro and returns a constant integer expression that evaluates to
11420 the line number of the invocation of the built-in. When used as a C++
11421 default argument for a function @var{F}, it returns the line number
11422 of the call to @var{F}.
11425 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11426 This function is the equivalent of the @code{__FUNCTION__} symbol
11427 and returns an address constant pointing to the name of the function
11428 from which the built-in was invoked, or the empty string if
11429 the invocation is not at function scope. When used as a C++ default
11430 argument for a function @var{F}, it returns the name of @var{F}'s
11431 caller or the empty string if the call was not made at function
11435 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11436 This function is the equivalent of the preprocessor @code{__FILE__}
11437 macro and returns an address constant pointing to the file name
11438 containing the invocation of the built-in, or the empty string if
11439 the invocation is not at function scope. When used as a C++ default
11440 argument for a function @var{F}, it returns the file name of the call
11441 to @var{F} or the empty string if the call was not made at function
11444 For example, in the following, each call to function @code{foo} will
11445 print a line similar to @code{"file.c:123: foo: message"} with the name
11446 of the file and the line number of the @code{printf} call, the name of
11447 the function @code{foo}, followed by the word @code{message}.
11451 function (const char *func = __builtin_FUNCTION ())
11458 printf ("%s:%i: %s: message\n", file (), line (), function ());
11464 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11465 This function is used to flush the processor's instruction cache for
11466 the region of memory between @var{begin} inclusive and @var{end}
11467 exclusive. Some targets require that the instruction cache be
11468 flushed, after modifying memory containing code, in order to obtain
11469 deterministic behavior.
11471 If the target does not require instruction cache flushes,
11472 @code{__builtin___clear_cache} has no effect. Otherwise either
11473 instructions are emitted in-line to clear the instruction cache or a
11474 call to the @code{__clear_cache} function in libgcc is made.
11477 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11478 This function is used to minimize cache-miss latency by moving data into
11479 a cache before it is accessed.
11480 You can insert calls to @code{__builtin_prefetch} into code for which
11481 you know addresses of data in memory that is likely to be accessed soon.
11482 If the target supports them, data prefetch instructions are generated.
11483 If the prefetch is done early enough before the access then the data will
11484 be in the cache by the time it is accessed.
11486 The value of @var{addr} is the address of the memory to prefetch.
11487 There are two optional arguments, @var{rw} and @var{locality}.
11488 The value of @var{rw} is a compile-time constant one or zero; one
11489 means that the prefetch is preparing for a write to the memory address
11490 and zero, the default, means that the prefetch is preparing for a read.
11491 The value @var{locality} must be a compile-time constant integer between
11492 zero and three. A value of zero means that the data has no temporal
11493 locality, so it need not be left in the cache after the access. A value
11494 of three means that the data has a high degree of temporal locality and
11495 should be left in all levels of cache possible. Values of one and two
11496 mean, respectively, a low or moderate degree of temporal locality. The
11500 for (i = 0; i < n; i++)
11502 a[i] = a[i] + b[i];
11503 __builtin_prefetch (&a[i+j], 1, 1);
11504 __builtin_prefetch (&b[i+j], 0, 1);
11509 Data prefetch does not generate faults if @var{addr} is invalid, but
11510 the address expression itself must be valid. For example, a prefetch
11511 of @code{p->next} does not fault if @code{p->next} is not a valid
11512 address, but evaluation faults if @code{p} is not a valid address.
11514 If the target does not support data prefetch, the address expression
11515 is evaluated if it includes side effects but no other code is generated
11516 and GCC does not issue a warning.
11519 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11520 Returns a positive infinity, if supported by the floating-point format,
11521 else @code{DBL_MAX}. This function is suitable for implementing the
11522 ISO C macro @code{HUGE_VAL}.
11525 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11526 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11529 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11530 Similar to @code{__builtin_huge_val}, except the return
11531 type is @code{long double}.
11534 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
11535 Similar to @code{__builtin_huge_val}, except the return type is
11536 @code{_Float@var{n}}.
11539 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
11540 Similar to @code{__builtin_huge_val}, except the return type is
11541 @code{_Float@var{n}x}.
11544 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11545 This built-in implements the C99 fpclassify functionality. The first
11546 five int arguments should be the target library's notion of the
11547 possible FP classes and are used for return values. They must be
11548 constant values and they must appear in this order: @code{FP_NAN},
11549 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11550 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
11551 to classify. GCC treats the last argument as type-generic, which
11552 means it does not do default promotion from float to double.
11555 @deftypefn {Built-in Function} double __builtin_inf (void)
11556 Similar to @code{__builtin_huge_val}, except a warning is generated
11557 if the target floating-point format does not support infinities.
11560 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11561 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11564 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11565 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11568 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11569 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11572 @deftypefn {Built-in Function} float __builtin_inff (void)
11573 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11574 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11577 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11578 Similar to @code{__builtin_inf}, except the return
11579 type is @code{long double}.
11582 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
11583 Similar to @code{__builtin_inf}, except the return
11584 type is @code{_Float@var{n}}.
11587 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
11588 Similar to @code{__builtin_inf}, except the return
11589 type is @code{_Float@var{n}x}.
11592 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11593 Similar to @code{isinf}, except the return value is -1 for
11594 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11595 Note while the parameter list is an
11596 ellipsis, this function only accepts exactly one floating-point
11597 argument. GCC treats this parameter as type-generic, which means it
11598 does not do default promotion from float to double.
11601 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11602 This is an implementation of the ISO C99 function @code{nan}.
11604 Since ISO C99 defines this function in terms of @code{strtod}, which we
11605 do not implement, a description of the parsing is in order. The string
11606 is parsed as by @code{strtol}; that is, the base is recognized by
11607 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
11608 in the significand such that the least significant bit of the number
11609 is at the least significant bit of the significand. The number is
11610 truncated to fit the significand field provided. The significand is
11611 forced to be a quiet NaN@.
11613 This function, if given a string literal all of which would have been
11614 consumed by @code{strtol}, is evaluated early enough that it is considered a
11615 compile-time constant.
11618 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11619 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11622 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11623 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11626 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11627 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11630 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11631 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11634 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11635 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11638 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
11639 Similar to @code{__builtin_nan}, except the return type is
11640 @code{_Float@var{n}}.
11643 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
11644 Similar to @code{__builtin_nan}, except the return type is
11645 @code{_Float@var{n}x}.
11648 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11649 Similar to @code{__builtin_nan}, except the significand is forced
11650 to be a signaling NaN@. The @code{nans} function is proposed by
11651 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11654 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11655 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11658 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11659 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11662 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
11663 Similar to @code{__builtin_nans}, except the return type is
11664 @code{_Float@var{n}}.
11667 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
11668 Similar to @code{__builtin_nans}, except the return type is
11669 @code{_Float@var{n}x}.
11672 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11673 Returns one plus the index of the least significant 1-bit of @var{x}, or
11674 if @var{x} is zero, returns zero.
11677 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11678 Returns the number of leading 0-bits in @var{x}, starting at the most
11679 significant bit position. If @var{x} is 0, the result is undefined.
11682 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11683 Returns the number of trailing 0-bits in @var{x}, starting at the least
11684 significant bit position. If @var{x} is 0, the result is undefined.
11687 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11688 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11689 number of bits following the most significant bit that are identical
11690 to it. There are no special cases for 0 or other values.
11693 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11694 Returns the number of 1-bits in @var{x}.
11697 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11698 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11702 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11703 Similar to @code{__builtin_ffs}, except the argument type is
11707 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11708 Similar to @code{__builtin_clz}, except the argument type is
11709 @code{unsigned long}.
11712 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11713 Similar to @code{__builtin_ctz}, except the argument type is
11714 @code{unsigned long}.
11717 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11718 Similar to @code{__builtin_clrsb}, except the argument type is
11722 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11723 Similar to @code{__builtin_popcount}, except the argument type is
11724 @code{unsigned long}.
11727 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11728 Similar to @code{__builtin_parity}, except the argument type is
11729 @code{unsigned long}.
11732 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11733 Similar to @code{__builtin_ffs}, except the argument type is
11737 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11738 Similar to @code{__builtin_clz}, except the argument type is
11739 @code{unsigned long long}.
11742 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11743 Similar to @code{__builtin_ctz}, except the argument type is
11744 @code{unsigned long long}.
11747 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11748 Similar to @code{__builtin_clrsb}, except the argument type is
11752 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11753 Similar to @code{__builtin_popcount}, except the argument type is
11754 @code{unsigned long long}.
11757 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11758 Similar to @code{__builtin_parity}, except the argument type is
11759 @code{unsigned long long}.
11762 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11763 Returns the first argument raised to the power of the second. Unlike the
11764 @code{pow} function no guarantees about precision and rounding are made.
11767 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11768 Similar to @code{__builtin_powi}, except the argument and return types
11772 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11773 Similar to @code{__builtin_powi}, except the argument and return types
11774 are @code{long double}.
11777 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11778 Returns @var{x} with the order of the bytes reversed; for example,
11779 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
11783 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11784 Similar to @code{__builtin_bswap16}, except the argument and return types
11788 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11789 Similar to @code{__builtin_bswap32}, except the argument and return types
11793 @node Target Builtins
11794 @section Built-in Functions Specific to Particular Target Machines
11796 On some target machines, GCC supports many built-in functions specific
11797 to those machines. Generally these generate calls to specific machine
11798 instructions, but allow the compiler to schedule those calls.
11801 * AArch64 Built-in Functions::
11802 * Alpha Built-in Functions::
11803 * Altera Nios II Built-in Functions::
11804 * ARC Built-in Functions::
11805 * ARC SIMD Built-in Functions::
11806 * ARM iWMMXt Built-in Functions::
11807 * ARM C Language Extensions (ACLE)::
11808 * ARM Floating Point Status and Control Intrinsics::
11809 * ARM ARMv8-M Security Extensions::
11810 * AVR Built-in Functions::
11811 * Blackfin Built-in Functions::
11812 * FR-V Built-in Functions::
11813 * MIPS DSP Built-in Functions::
11814 * MIPS Paired-Single Support::
11815 * MIPS Loongson Built-in Functions::
11816 * MIPS SIMD Architecture (MSA) Support::
11817 * Other MIPS Built-in Functions::
11818 * MSP430 Built-in Functions::
11819 * NDS32 Built-in Functions::
11820 * picoChip Built-in Functions::
11821 * PowerPC Built-in Functions::
11822 * PowerPC AltiVec/VSX Built-in Functions::
11823 * PowerPC Hardware Transactional Memory Built-in Functions::
11824 * RX Built-in Functions::
11825 * S/390 System z Built-in Functions::
11826 * SH Built-in Functions::
11827 * SPARC VIS Built-in Functions::
11828 * SPU Built-in Functions::
11829 * TI C6X Built-in Functions::
11830 * TILE-Gx Built-in Functions::
11831 * TILEPro Built-in Functions::
11832 * x86 Built-in Functions::
11833 * x86 transactional memory intrinsics::
11836 @node AArch64 Built-in Functions
11837 @subsection AArch64 Built-in Functions
11839 These built-in functions are available for the AArch64 family of
11842 unsigned int __builtin_aarch64_get_fpcr ()
11843 void __builtin_aarch64_set_fpcr (unsigned int)
11844 unsigned int __builtin_aarch64_get_fpsr ()
11845 void __builtin_aarch64_set_fpsr (unsigned int)
11848 @node Alpha Built-in Functions
11849 @subsection Alpha Built-in Functions
11851 These built-in functions are available for the Alpha family of
11852 processors, depending on the command-line switches used.
11854 The following built-in functions are always available. They
11855 all generate the machine instruction that is part of the name.
11858 long __builtin_alpha_implver (void)
11859 long __builtin_alpha_rpcc (void)
11860 long __builtin_alpha_amask (long)
11861 long __builtin_alpha_cmpbge (long, long)
11862 long __builtin_alpha_extbl (long, long)
11863 long __builtin_alpha_extwl (long, long)
11864 long __builtin_alpha_extll (long, long)
11865 long __builtin_alpha_extql (long, long)
11866 long __builtin_alpha_extwh (long, long)
11867 long __builtin_alpha_extlh (long, long)
11868 long __builtin_alpha_extqh (long, long)
11869 long __builtin_alpha_insbl (long, long)
11870 long __builtin_alpha_inswl (long, long)
11871 long __builtin_alpha_insll (long, long)
11872 long __builtin_alpha_insql (long, long)
11873 long __builtin_alpha_inswh (long, long)
11874 long __builtin_alpha_inslh (long, long)
11875 long __builtin_alpha_insqh (long, long)
11876 long __builtin_alpha_mskbl (long, long)
11877 long __builtin_alpha_mskwl (long, long)
11878 long __builtin_alpha_mskll (long, long)
11879 long __builtin_alpha_mskql (long, long)
11880 long __builtin_alpha_mskwh (long, long)
11881 long __builtin_alpha_msklh (long, long)
11882 long __builtin_alpha_mskqh (long, long)
11883 long __builtin_alpha_umulh (long, long)
11884 long __builtin_alpha_zap (long, long)
11885 long __builtin_alpha_zapnot (long, long)
11888 The following built-in functions are always with @option{-mmax}
11889 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11890 later. They all generate the machine instruction that is part
11894 long __builtin_alpha_pklb (long)
11895 long __builtin_alpha_pkwb (long)
11896 long __builtin_alpha_unpkbl (long)
11897 long __builtin_alpha_unpkbw (long)
11898 long __builtin_alpha_minub8 (long, long)
11899 long __builtin_alpha_minsb8 (long, long)
11900 long __builtin_alpha_minuw4 (long, long)
11901 long __builtin_alpha_minsw4 (long, long)
11902 long __builtin_alpha_maxub8 (long, long)
11903 long __builtin_alpha_maxsb8 (long, long)
11904 long __builtin_alpha_maxuw4 (long, long)
11905 long __builtin_alpha_maxsw4 (long, long)
11906 long __builtin_alpha_perr (long, long)
11909 The following built-in functions are always with @option{-mcix}
11910 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11911 later. They all generate the machine instruction that is part
11915 long __builtin_alpha_cttz (long)
11916 long __builtin_alpha_ctlz (long)
11917 long __builtin_alpha_ctpop (long)
11920 The following built-in functions are available on systems that use the OSF/1
11921 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
11922 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11923 @code{rdval} and @code{wrval}.
11926 void *__builtin_thread_pointer (void)
11927 void __builtin_set_thread_pointer (void *)
11930 @node Altera Nios II Built-in Functions
11931 @subsection Altera Nios II Built-in Functions
11933 These built-in functions are available for the Altera Nios II
11934 family of processors.
11936 The following built-in functions are always available. They
11937 all generate the machine instruction that is part of the name.
11940 int __builtin_ldbio (volatile const void *)
11941 int __builtin_ldbuio (volatile const void *)
11942 int __builtin_ldhio (volatile const void *)
11943 int __builtin_ldhuio (volatile const void *)
11944 int __builtin_ldwio (volatile const void *)
11945 void __builtin_stbio (volatile void *, int)
11946 void __builtin_sthio (volatile void *, int)
11947 void __builtin_stwio (volatile void *, int)
11948 void __builtin_sync (void)
11949 int __builtin_rdctl (int)
11950 int __builtin_rdprs (int, int)
11951 void __builtin_wrctl (int, int)
11952 void __builtin_flushd (volatile void *)
11953 void __builtin_flushda (volatile void *)
11954 int __builtin_wrpie (int);
11955 void __builtin_eni (int);
11956 int __builtin_ldex (volatile const void *)
11957 int __builtin_stex (volatile void *, int)
11958 int __builtin_ldsex (volatile const void *)
11959 int __builtin_stsex (volatile void *, int)
11962 The following built-in functions are always available. They
11963 all generate a Nios II Custom Instruction. The name of the
11964 function represents the types that the function takes and
11965 returns. The letter before the @code{n} is the return type
11966 or void if absent. The @code{n} represents the first parameter
11967 to all the custom instructions, the custom instruction number.
11968 The two letters after the @code{n} represent the up to two
11969 parameters to the function.
11971 The letters represent the following data types:
11974 @code{void} for return type and no parameter for parameter types.
11977 @code{int} for return type and parameter type
11980 @code{float} for return type and parameter type
11983 @code{void *} for return type and parameter type
11987 And the function names are:
11989 void __builtin_custom_n (void)
11990 void __builtin_custom_ni (int)
11991 void __builtin_custom_nf (float)
11992 void __builtin_custom_np (void *)
11993 void __builtin_custom_nii (int, int)
11994 void __builtin_custom_nif (int, float)
11995 void __builtin_custom_nip (int, void *)
11996 void __builtin_custom_nfi (float, int)
11997 void __builtin_custom_nff (float, float)
11998 void __builtin_custom_nfp (float, void *)
11999 void __builtin_custom_npi (void *, int)
12000 void __builtin_custom_npf (void *, float)
12001 void __builtin_custom_npp (void *, void *)
12002 int __builtin_custom_in (void)
12003 int __builtin_custom_ini (int)
12004 int __builtin_custom_inf (float)
12005 int __builtin_custom_inp (void *)
12006 int __builtin_custom_inii (int, int)
12007 int __builtin_custom_inif (int, float)
12008 int __builtin_custom_inip (int, void *)
12009 int __builtin_custom_infi (float, int)
12010 int __builtin_custom_inff (float, float)
12011 int __builtin_custom_infp (float, void *)
12012 int __builtin_custom_inpi (void *, int)
12013 int __builtin_custom_inpf (void *, float)
12014 int __builtin_custom_inpp (void *, void *)
12015 float __builtin_custom_fn (void)
12016 float __builtin_custom_fni (int)
12017 float __builtin_custom_fnf (float)
12018 float __builtin_custom_fnp (void *)
12019 float __builtin_custom_fnii (int, int)
12020 float __builtin_custom_fnif (int, float)
12021 float __builtin_custom_fnip (int, void *)
12022 float __builtin_custom_fnfi (float, int)
12023 float __builtin_custom_fnff (float, float)
12024 float __builtin_custom_fnfp (float, void *)
12025 float __builtin_custom_fnpi (void *, int)
12026 float __builtin_custom_fnpf (void *, float)
12027 float __builtin_custom_fnpp (void *, void *)
12028 void * __builtin_custom_pn (void)
12029 void * __builtin_custom_pni (int)
12030 void * __builtin_custom_pnf (float)
12031 void * __builtin_custom_pnp (void *)
12032 void * __builtin_custom_pnii (int, int)
12033 void * __builtin_custom_pnif (int, float)
12034 void * __builtin_custom_pnip (int, void *)
12035 void * __builtin_custom_pnfi (float, int)
12036 void * __builtin_custom_pnff (float, float)
12037 void * __builtin_custom_pnfp (float, void *)
12038 void * __builtin_custom_pnpi (void *, int)
12039 void * __builtin_custom_pnpf (void *, float)
12040 void * __builtin_custom_pnpp (void *, void *)
12043 @node ARC Built-in Functions
12044 @subsection ARC Built-in Functions
12046 The following built-in functions are provided for ARC targets. The
12047 built-ins generate the corresponding assembly instructions. In the
12048 examples given below, the generated code often requires an operand or
12049 result to be in a register. Where necessary further code will be
12050 generated to ensure this is true, but for brevity this is not
12051 described in each case.
12053 @emph{Note:} Using a built-in to generate an instruction not supported
12054 by a target may cause problems. At present the compiler is not
12055 guaranteed to detect such misuse, and as a result an internal compiler
12056 error may be generated.
12058 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
12059 Return 1 if @var{val} is known to have the byte alignment given
12060 by @var{alignval}, otherwise return 0.
12061 Note that this is different from
12063 __alignof__(*(char *)@var{val}) >= alignval
12065 because __alignof__ sees only the type of the dereference, whereas
12066 __builtin_arc_align uses alignment information from the pointer
12067 as well as from the pointed-to type.
12068 The information available will depend on optimization level.
12071 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
12078 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
12079 The operand is the number of a register to be read. Generates:
12081 mov @var{dest}, r@var{regno}
12083 where the value in @var{dest} will be the result returned from the
12087 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
12088 The first operand is the number of a register to be written, the
12089 second operand is a compile time constant to write into that
12090 register. Generates:
12092 mov r@var{regno}, @var{val}
12096 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
12097 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
12100 divaw @var{dest}, @var{a}, @var{b}
12102 where the value in @var{dest} will be the result returned from the
12106 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
12113 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
12114 The operand, @var{auxv}, is the address of an auxiliary register and
12115 must be a compile time constant. Generates:
12117 lr @var{dest}, [@var{auxr}]
12119 Where the value in @var{dest} will be the result returned from the
12123 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
12124 Only available with @option{-mmul64}. Generates:
12126 mul64 @var{a}, @var{b}
12130 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12131 Only available with @option{-mmul64}. Generates:
12133 mulu64 @var{a}, @var{b}
12137 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12144 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12145 Only valid if the @samp{norm} instruction is available through the
12146 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12149 norm @var{dest}, @var{src}
12151 Where the value in @var{dest} will be the result returned from the
12155 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
12156 Only valid if the @samp{normw} instruction is available through the
12157 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12160 normw @var{dest}, @var{src}
12162 Where the value in @var{dest} will be the result returned from the
12166 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
12173 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
12180 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
12181 The first argument, @var{auxv}, is the address of an auxiliary
12182 register, the second argument, @var{val}, is a compile time constant
12183 to be written to the register. Generates:
12185 sr @var{auxr}, [@var{val}]
12189 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
12190 Only valid with @option{-mswap}. Generates:
12192 swap @var{dest}, @var{src}
12194 Where the value in @var{dest} will be the result returned from the
12198 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
12205 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
12206 Only available with @option{-mcpu=ARC700}. Generates:
12212 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
12213 Only available with @option{-mcpu=ARC700}. Generates:
12219 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
12220 Only available with @option{-mcpu=ARC700}. Generates:
12226 The instructions generated by the following builtins are not
12227 considered as candidates for scheduling. They are not moved around by
12228 the compiler during scheduling, and thus can be expected to appear
12229 where they are put in the C code:
12231 __builtin_arc_brk()
12232 __builtin_arc_core_read()
12233 __builtin_arc_core_write()
12234 __builtin_arc_flag()
12236 __builtin_arc_sleep()
12238 __builtin_arc_swi()
12241 @node ARC SIMD Built-in Functions
12242 @subsection ARC SIMD Built-in Functions
12244 SIMD builtins provided by the compiler can be used to generate the
12245 vector instructions. This section describes the available builtins
12246 and their usage in programs. With the @option{-msimd} option, the
12247 compiler provides 128-bit vector types, which can be specified using
12248 the @code{vector_size} attribute. The header file @file{arc-simd.h}
12249 can be included to use the following predefined types:
12251 typedef int __v4si __attribute__((vector_size(16)));
12252 typedef short __v8hi __attribute__((vector_size(16)));
12255 These types can be used to define 128-bit variables. The built-in
12256 functions listed in the following section can be used on these
12257 variables to generate the vector operations.
12259 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12260 @file{arc-simd.h} also provides equivalent macros called
12261 @code{_@var{someinsn}} that can be used for programming ease and
12262 improved readability. The following macros for DMA control are also
12265 #define _setup_dma_in_channel_reg _vdiwr
12266 #define _setup_dma_out_channel_reg _vdowr
12269 The following is a complete list of all the SIMD built-ins provided
12270 for ARC, grouped by calling signature.
12272 The following take two @code{__v8hi} arguments and return a
12273 @code{__v8hi} result:
12275 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12276 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12277 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12278 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12279 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12280 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12281 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12282 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
12283 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
12284 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
12285 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
12286 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
12287 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
12288 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12289 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12290 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12291 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12292 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12293 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12294 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12295 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12296 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
12297 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
12298 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
12299 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
12300 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
12301 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
12302 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
12303 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
12304 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
12305 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
12306 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
12307 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
12308 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
12309 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
12310 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
12311 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
12312 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
12313 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
12314 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
12315 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
12316 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
12317 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
12318 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
12319 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
12320 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
12321 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
12322 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
12325 The following take one @code{__v8hi} and one @code{int} argument and return a
12326 @code{__v8hi} result:
12329 __v8hi __builtin_arc_vbaddw (__v8hi, int)
12330 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
12331 __v8hi __builtin_arc_vbminw (__v8hi, int)
12332 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
12333 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
12334 __v8hi __builtin_arc_vbmulw (__v8hi, int)
12335 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
12336 __v8hi __builtin_arc_vbsubw (__v8hi, int)
12339 The following take one @code{__v8hi} argument and one @code{int} argument which
12340 must be a 3-bit compile time constant indicating a register number
12341 I0-I7. They return a @code{__v8hi} result.
12343 __v8hi __builtin_arc_vasrw (__v8hi, const int)
12344 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
12345 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
12348 The following take one @code{__v8hi} argument and one @code{int}
12349 argument which must be a 6-bit compile time constant. They return a
12350 @code{__v8hi} result.
12352 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
12353 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
12354 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
12355 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
12356 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
12357 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
12358 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
12361 The following take one @code{__v8hi} argument and one @code{int} argument which
12362 must be a 8-bit compile time constant. They return a @code{__v8hi}
12365 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
12366 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
12367 __v8hi __builtin_arc_vmvw (__v8hi, const int)
12368 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
12371 The following take two @code{int} arguments, the second of which which
12372 must be a 8-bit compile time constant. They return a @code{__v8hi}
12375 __v8hi __builtin_arc_vmovaw (int, const int)
12376 __v8hi __builtin_arc_vmovw (int, const int)
12377 __v8hi __builtin_arc_vmovzw (int, const int)
12380 The following take a single @code{__v8hi} argument and return a
12381 @code{__v8hi} result:
12383 __v8hi __builtin_arc_vabsaw (__v8hi)
12384 __v8hi __builtin_arc_vabsw (__v8hi)
12385 __v8hi __builtin_arc_vaddsuw (__v8hi)
12386 __v8hi __builtin_arc_vexch1 (__v8hi)
12387 __v8hi __builtin_arc_vexch2 (__v8hi)
12388 __v8hi __builtin_arc_vexch4 (__v8hi)
12389 __v8hi __builtin_arc_vsignw (__v8hi)
12390 __v8hi __builtin_arc_vupbaw (__v8hi)
12391 __v8hi __builtin_arc_vupbw (__v8hi)
12392 __v8hi __builtin_arc_vupsbaw (__v8hi)
12393 __v8hi __builtin_arc_vupsbw (__v8hi)
12396 The following take two @code{int} arguments and return no result:
12398 void __builtin_arc_vdirun (int, int)
12399 void __builtin_arc_vdorun (int, int)
12402 The following take two @code{int} arguments and return no result. The
12403 first argument must a 3-bit compile time constant indicating one of
12404 the DR0-DR7 DMA setup channels:
12406 void __builtin_arc_vdiwr (const int, int)
12407 void __builtin_arc_vdowr (const int, int)
12410 The following take an @code{int} argument and return no result:
12412 void __builtin_arc_vendrec (int)
12413 void __builtin_arc_vrec (int)
12414 void __builtin_arc_vrecrun (int)
12415 void __builtin_arc_vrun (int)
12418 The following take a @code{__v8hi} argument and two @code{int}
12419 arguments and return a @code{__v8hi} result. The second argument must
12420 be a 3-bit compile time constants, indicating one the registers I0-I7,
12421 and the third argument must be an 8-bit compile time constant.
12423 @emph{Note:} Although the equivalent hardware instructions do not take
12424 an SIMD register as an operand, these builtins overwrite the relevant
12425 bits of the @code{__v8hi} register provided as the first argument with
12426 the value loaded from the @code{[Ib, u8]} location in the SDM.
12429 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12430 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12431 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12432 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12435 The following take two @code{int} arguments and return a @code{__v8hi}
12436 result. The first argument must be a 3-bit compile time constants,
12437 indicating one the registers I0-I7, and the second argument must be an
12438 8-bit compile time constant.
12441 __v8hi __builtin_arc_vld128 (const int, const int)
12442 __v8hi __builtin_arc_vld64w (const int, const int)
12445 The following take a @code{__v8hi} argument and two @code{int}
12446 arguments and return no result. The second argument must be a 3-bit
12447 compile time constants, indicating one the registers I0-I7, and the
12448 third argument must be an 8-bit compile time constant.
12451 void __builtin_arc_vst128 (__v8hi, const int, const int)
12452 void __builtin_arc_vst64 (__v8hi, const int, const int)
12455 The following take a @code{__v8hi} argument and three @code{int}
12456 arguments and return no result. The second argument must be a 3-bit
12457 compile-time constant, identifying the 16-bit sub-register to be
12458 stored, the third argument must be a 3-bit compile time constants,
12459 indicating one the registers I0-I7, and the fourth argument must be an
12460 8-bit compile time constant.
12463 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12464 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12467 @node ARM iWMMXt Built-in Functions
12468 @subsection ARM iWMMXt Built-in Functions
12470 These built-in functions are available for the ARM family of
12471 processors when the @option{-mcpu=iwmmxt} switch is used:
12474 typedef int v2si __attribute__ ((vector_size (8)));
12475 typedef short v4hi __attribute__ ((vector_size (8)));
12476 typedef char v8qi __attribute__ ((vector_size (8)));
12478 int __builtin_arm_getwcgr0 (void)
12479 void __builtin_arm_setwcgr0 (int)
12480 int __builtin_arm_getwcgr1 (void)
12481 void __builtin_arm_setwcgr1 (int)
12482 int __builtin_arm_getwcgr2 (void)
12483 void __builtin_arm_setwcgr2 (int)
12484 int __builtin_arm_getwcgr3 (void)
12485 void __builtin_arm_setwcgr3 (int)
12486 int __builtin_arm_textrmsb (v8qi, int)
12487 int __builtin_arm_textrmsh (v4hi, int)
12488 int __builtin_arm_textrmsw (v2si, int)
12489 int __builtin_arm_textrmub (v8qi, int)
12490 int __builtin_arm_textrmuh (v4hi, int)
12491 int __builtin_arm_textrmuw (v2si, int)
12492 v8qi __builtin_arm_tinsrb (v8qi, int, int)
12493 v4hi __builtin_arm_tinsrh (v4hi, int, int)
12494 v2si __builtin_arm_tinsrw (v2si, int, int)
12495 long long __builtin_arm_tmia (long long, int, int)
12496 long long __builtin_arm_tmiabb (long long, int, int)
12497 long long __builtin_arm_tmiabt (long long, int, int)
12498 long long __builtin_arm_tmiaph (long long, int, int)
12499 long long __builtin_arm_tmiatb (long long, int, int)
12500 long long __builtin_arm_tmiatt (long long, int, int)
12501 int __builtin_arm_tmovmskb (v8qi)
12502 int __builtin_arm_tmovmskh (v4hi)
12503 int __builtin_arm_tmovmskw (v2si)
12504 long long __builtin_arm_waccb (v8qi)
12505 long long __builtin_arm_wacch (v4hi)
12506 long long __builtin_arm_waccw (v2si)
12507 v8qi __builtin_arm_waddb (v8qi, v8qi)
12508 v8qi __builtin_arm_waddbss (v8qi, v8qi)
12509 v8qi __builtin_arm_waddbus (v8qi, v8qi)
12510 v4hi __builtin_arm_waddh (v4hi, v4hi)
12511 v4hi __builtin_arm_waddhss (v4hi, v4hi)
12512 v4hi __builtin_arm_waddhus (v4hi, v4hi)
12513 v2si __builtin_arm_waddw (v2si, v2si)
12514 v2si __builtin_arm_waddwss (v2si, v2si)
12515 v2si __builtin_arm_waddwus (v2si, v2si)
12516 v8qi __builtin_arm_walign (v8qi, v8qi, int)
12517 long long __builtin_arm_wand(long long, long long)
12518 long long __builtin_arm_wandn (long long, long long)
12519 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
12520 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
12521 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
12522 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
12523 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12524 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12525 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12526 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12527 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12528 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12529 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12530 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12531 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12532 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12533 long long __builtin_arm_wmacsz (v4hi, v4hi)
12534 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12535 long long __builtin_arm_wmacuz (v4hi, v4hi)
12536 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12537 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12538 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12539 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12540 v2si __builtin_arm_wmaxsw (v2si, v2si)
12541 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12542 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12543 v2si __builtin_arm_wmaxuw (v2si, v2si)
12544 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12545 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12546 v2si __builtin_arm_wminsw (v2si, v2si)
12547 v8qi __builtin_arm_wminub (v8qi, v8qi)
12548 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12549 v2si __builtin_arm_wminuw (v2si, v2si)
12550 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12551 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12552 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12553 long long __builtin_arm_wor (long long, long long)
12554 v2si __builtin_arm_wpackdss (long long, long long)
12555 v2si __builtin_arm_wpackdus (long long, long long)
12556 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12557 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12558 v4hi __builtin_arm_wpackwss (v2si, v2si)
12559 v4hi __builtin_arm_wpackwus (v2si, v2si)
12560 long long __builtin_arm_wrord (long long, long long)
12561 long long __builtin_arm_wrordi (long long, int)
12562 v4hi __builtin_arm_wrorh (v4hi, long long)
12563 v4hi __builtin_arm_wrorhi (v4hi, int)
12564 v2si __builtin_arm_wrorw (v2si, long long)
12565 v2si __builtin_arm_wrorwi (v2si, int)
12566 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12567 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12568 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12569 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12570 v4hi __builtin_arm_wshufh (v4hi, int)
12571 long long __builtin_arm_wslld (long long, long long)
12572 long long __builtin_arm_wslldi (long long, int)
12573 v4hi __builtin_arm_wsllh (v4hi, long long)
12574 v4hi __builtin_arm_wsllhi (v4hi, int)
12575 v2si __builtin_arm_wsllw (v2si, long long)
12576 v2si __builtin_arm_wsllwi (v2si, int)
12577 long long __builtin_arm_wsrad (long long, long long)
12578 long long __builtin_arm_wsradi (long long, int)
12579 v4hi __builtin_arm_wsrah (v4hi, long long)
12580 v4hi __builtin_arm_wsrahi (v4hi, int)
12581 v2si __builtin_arm_wsraw (v2si, long long)
12582 v2si __builtin_arm_wsrawi (v2si, int)
12583 long long __builtin_arm_wsrld (long long, long long)
12584 long long __builtin_arm_wsrldi (long long, int)
12585 v4hi __builtin_arm_wsrlh (v4hi, long long)
12586 v4hi __builtin_arm_wsrlhi (v4hi, int)
12587 v2si __builtin_arm_wsrlw (v2si, long long)
12588 v2si __builtin_arm_wsrlwi (v2si, int)
12589 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12590 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12591 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12592 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12593 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12594 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12595 v2si __builtin_arm_wsubw (v2si, v2si)
12596 v2si __builtin_arm_wsubwss (v2si, v2si)
12597 v2si __builtin_arm_wsubwus (v2si, v2si)
12598 v4hi __builtin_arm_wunpckehsb (v8qi)
12599 v2si __builtin_arm_wunpckehsh (v4hi)
12600 long long __builtin_arm_wunpckehsw (v2si)
12601 v4hi __builtin_arm_wunpckehub (v8qi)
12602 v2si __builtin_arm_wunpckehuh (v4hi)
12603 long long __builtin_arm_wunpckehuw (v2si)
12604 v4hi __builtin_arm_wunpckelsb (v8qi)
12605 v2si __builtin_arm_wunpckelsh (v4hi)
12606 long long __builtin_arm_wunpckelsw (v2si)
12607 v4hi __builtin_arm_wunpckelub (v8qi)
12608 v2si __builtin_arm_wunpckeluh (v4hi)
12609 long long __builtin_arm_wunpckeluw (v2si)
12610 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12611 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12612 v2si __builtin_arm_wunpckihw (v2si, v2si)
12613 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12614 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12615 v2si __builtin_arm_wunpckilw (v2si, v2si)
12616 long long __builtin_arm_wxor (long long, long long)
12617 long long __builtin_arm_wzero ()
12621 @node ARM C Language Extensions (ACLE)
12622 @subsection ARM C Language Extensions (ACLE)
12624 GCC implements extensions for C as described in the ARM C Language
12625 Extensions (ACLE) specification, which can be found at
12626 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12628 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12629 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
12630 intrinsics can be found at
12631 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12632 The built-in intrinsics for the Advanced SIMD extension are available when
12635 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
12636 back ends support CRC32 intrinsics and the ARM back end supports the
12637 Coprocessor intrinsics, all from @file{arm_acle.h}. The ARM back end's 16-bit
12638 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12639 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12642 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12643 availability of extensions.
12645 @node ARM Floating Point Status and Control Intrinsics
12646 @subsection ARM Floating Point Status and Control Intrinsics
12648 These built-in functions are available for the ARM family of
12649 processors with floating-point unit.
12652 unsigned int __builtin_arm_get_fpscr ()
12653 void __builtin_arm_set_fpscr (unsigned int)
12656 @node ARM ARMv8-M Security Extensions
12657 @subsection ARM ARMv8-M Security Extensions
12659 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
12660 Security Extensions: Requirements on Development Tools Engineering
12661 Specification, which can be found at
12662 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
12664 As part of the Security Extensions GCC implements two new function attributes:
12665 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
12667 As part of the Security Extensions GCC implements the intrinsics below. FPTR
12668 is used here to mean any function pointer type.
12671 cmse_address_info_t cmse_TT (void *)
12672 cmse_address_info_t cmse_TT_fptr (FPTR)
12673 cmse_address_info_t cmse_TTT (void *)
12674 cmse_address_info_t cmse_TTT_fptr (FPTR)
12675 cmse_address_info_t cmse_TTA (void *)
12676 cmse_address_info_t cmse_TTA_fptr (FPTR)
12677 cmse_address_info_t cmse_TTAT (void *)
12678 cmse_address_info_t cmse_TTAT_fptr (FPTR)
12679 void * cmse_check_address_range (void *, size_t, int)
12680 typeof(p) cmse_nsfptr_create (FPTR p)
12681 intptr_t cmse_is_nsfptr (FPTR)
12682 int cmse_nonsecure_caller (void)
12685 @node AVR Built-in Functions
12686 @subsection AVR Built-in Functions
12688 For each built-in function for AVR, there is an equally named,
12689 uppercase built-in macro defined. That way users can easily query if
12690 or if not a specific built-in is implemented or not. For example, if
12691 @code{__builtin_avr_nop} is available the macro
12692 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12694 The following built-in functions map to the respective machine
12695 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12696 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12697 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12698 as library call if no hardware multiplier is available.
12701 void __builtin_avr_nop (void)
12702 void __builtin_avr_sei (void)
12703 void __builtin_avr_cli (void)
12704 void __builtin_avr_sleep (void)
12705 void __builtin_avr_wdr (void)
12706 unsigned char __builtin_avr_swap (unsigned char)
12707 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12708 int __builtin_avr_fmuls (char, char)
12709 int __builtin_avr_fmulsu (char, unsigned char)
12712 In order to delay execution for a specific number of cycles, GCC
12715 void __builtin_avr_delay_cycles (unsigned long ticks)
12719 @code{ticks} is the number of ticks to delay execution. Note that this
12720 built-in does not take into account the effect of interrupts that
12721 might increase delay time. @code{ticks} must be a compile-time
12722 integer constant; delays with a variable number of cycles are not supported.
12725 char __builtin_avr_flash_segment (const __memx void*)
12729 This built-in takes a byte address to the 24-bit
12730 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12731 the number of the flash segment (the 64 KiB chunk) where the address
12732 points to. Counting starts at @code{0}.
12733 If the address does not point to flash memory, return @code{-1}.
12736 unsigned char __builtin_avr_insert_bits (unsigned long map,
12737 unsigned char bits,
12742 Insert bits from @var{bits} into @var{val} and return the resulting
12743 value. The nibbles of @var{map} determine how the insertion is
12744 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12746 @item If @var{X} is @code{0xf},
12747 then the @var{n}-th bit of @var{val} is returned unaltered.
12749 @item If X is in the range 0@dots{}7,
12750 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12752 @item If X is in the range 8@dots{}@code{0xe},
12753 then the @var{n}-th result bit is undefined.
12757 One typical use case for this built-in is adjusting input and
12758 output values to non-contiguous port layouts. Some examples:
12761 // same as val, bits is unused
12762 __builtin_avr_insert_bits (0xffffffff, bits, val)
12766 // same as bits, val is unused
12767 __builtin_avr_insert_bits (0x76543210, bits, val)
12771 // same as rotating bits by 4
12772 __builtin_avr_insert_bits (0x32107654, bits, 0)
12776 // high nibble of result is the high nibble of val
12777 // low nibble of result is the low nibble of bits
12778 __builtin_avr_insert_bits (0xffff3210, bits, val)
12782 // reverse the bit order of bits
12783 __builtin_avr_insert_bits (0x01234567, bits, 0)
12787 void __builtin_avr_nops (unsigned count)
12791 Insert @code{count} @code{NOP} instructions.
12792 The number of instructions must be a compile-time integer constant.
12794 @node Blackfin Built-in Functions
12795 @subsection Blackfin Built-in Functions
12797 Currently, there are two Blackfin-specific built-in functions. These are
12798 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12799 using inline assembly; by using these built-in functions the compiler can
12800 automatically add workarounds for hardware errata involving these
12801 instructions. These functions are named as follows:
12804 void __builtin_bfin_csync (void)
12805 void __builtin_bfin_ssync (void)
12808 @node FR-V Built-in Functions
12809 @subsection FR-V Built-in Functions
12811 GCC provides many FR-V-specific built-in functions. In general,
12812 these functions are intended to be compatible with those described
12813 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12814 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
12815 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12816 pointer rather than by value.
12818 Most of the functions are named after specific FR-V instructions.
12819 Such functions are said to be ``directly mapped'' and are summarized
12820 here in tabular form.
12824 * Directly-mapped Integer Functions::
12825 * Directly-mapped Media Functions::
12826 * Raw read/write Functions::
12827 * Other Built-in Functions::
12830 @node Argument Types
12831 @subsubsection Argument Types
12833 The arguments to the built-in functions can be divided into three groups:
12834 register numbers, compile-time constants and run-time values. In order
12835 to make this classification clear at a glance, the arguments and return
12836 values are given the following pseudo types:
12838 @multitable @columnfractions .20 .30 .15 .35
12839 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12840 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12841 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12842 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12843 @item @code{uw2} @tab @code{unsigned long long} @tab No
12844 @tab an unsigned doubleword
12845 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12846 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12847 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12848 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12851 These pseudo types are not defined by GCC, they are simply a notational
12852 convenience used in this manual.
12854 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12855 and @code{sw2} are evaluated at run time. They correspond to
12856 register operands in the underlying FR-V instructions.
12858 @code{const} arguments represent immediate operands in the underlying
12859 FR-V instructions. They must be compile-time constants.
12861 @code{acc} arguments are evaluated at compile time and specify the number
12862 of an accumulator register. For example, an @code{acc} argument of 2
12863 selects the ACC2 register.
12865 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12866 number of an IACC register. See @pxref{Other Built-in Functions}
12869 @node Directly-mapped Integer Functions
12870 @subsubsection Directly-Mapped Integer Functions
12872 The functions listed below map directly to FR-V I-type instructions.
12874 @multitable @columnfractions .45 .32 .23
12875 @item Function prototype @tab Example usage @tab Assembly output
12876 @item @code{sw1 __ADDSS (sw1, sw1)}
12877 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12878 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12879 @item @code{sw1 __SCAN (sw1, sw1)}
12880 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12881 @tab @code{SCAN @var{a},@var{b},@var{c}}
12882 @item @code{sw1 __SCUTSS (sw1)}
12883 @tab @code{@var{b} = __SCUTSS (@var{a})}
12884 @tab @code{SCUTSS @var{a},@var{b}}
12885 @item @code{sw1 __SLASS (sw1, sw1)}
12886 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12887 @tab @code{SLASS @var{a},@var{b},@var{c}}
12888 @item @code{void __SMASS (sw1, sw1)}
12889 @tab @code{__SMASS (@var{a}, @var{b})}
12890 @tab @code{SMASS @var{a},@var{b}}
12891 @item @code{void __SMSSS (sw1, sw1)}
12892 @tab @code{__SMSSS (@var{a}, @var{b})}
12893 @tab @code{SMSSS @var{a},@var{b}}
12894 @item @code{void __SMU (sw1, sw1)}
12895 @tab @code{__SMU (@var{a}, @var{b})}
12896 @tab @code{SMU @var{a},@var{b}}
12897 @item @code{sw2 __SMUL (sw1, sw1)}
12898 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12899 @tab @code{SMUL @var{a},@var{b},@var{c}}
12900 @item @code{sw1 __SUBSS (sw1, sw1)}
12901 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12902 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12903 @item @code{uw2 __UMUL (uw1, uw1)}
12904 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12905 @tab @code{UMUL @var{a},@var{b},@var{c}}
12908 @node Directly-mapped Media Functions
12909 @subsubsection Directly-Mapped Media Functions
12911 The functions listed below map directly to FR-V M-type instructions.
12913 @multitable @columnfractions .45 .32 .23
12914 @item Function prototype @tab Example usage @tab Assembly output
12915 @item @code{uw1 __MABSHS (sw1)}
12916 @tab @code{@var{b} = __MABSHS (@var{a})}
12917 @tab @code{MABSHS @var{a},@var{b}}
12918 @item @code{void __MADDACCS (acc, acc)}
12919 @tab @code{__MADDACCS (@var{b}, @var{a})}
12920 @tab @code{MADDACCS @var{a},@var{b}}
12921 @item @code{sw1 __MADDHSS (sw1, sw1)}
12922 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12923 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12924 @item @code{uw1 __MADDHUS (uw1, uw1)}
12925 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12926 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12927 @item @code{uw1 __MAND (uw1, uw1)}
12928 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12929 @tab @code{MAND @var{a},@var{b},@var{c}}
12930 @item @code{void __MASACCS (acc, acc)}
12931 @tab @code{__MASACCS (@var{b}, @var{a})}
12932 @tab @code{MASACCS @var{a},@var{b}}
12933 @item @code{uw1 __MAVEH (uw1, uw1)}
12934 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12935 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12936 @item @code{uw2 __MBTOH (uw1)}
12937 @tab @code{@var{b} = __MBTOH (@var{a})}
12938 @tab @code{MBTOH @var{a},@var{b}}
12939 @item @code{void __MBTOHE (uw1 *, uw1)}
12940 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12941 @tab @code{MBTOHE @var{a},@var{b}}
12942 @item @code{void __MCLRACC (acc)}
12943 @tab @code{__MCLRACC (@var{a})}
12944 @tab @code{MCLRACC @var{a}}
12945 @item @code{void __MCLRACCA (void)}
12946 @tab @code{__MCLRACCA ()}
12947 @tab @code{MCLRACCA}
12948 @item @code{uw1 __Mcop1 (uw1, uw1)}
12949 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12950 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12951 @item @code{uw1 __Mcop2 (uw1, uw1)}
12952 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12953 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12954 @item @code{uw1 __MCPLHI (uw2, const)}
12955 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12956 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12957 @item @code{uw1 __MCPLI (uw2, const)}
12958 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12959 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12960 @item @code{void __MCPXIS (acc, sw1, sw1)}
12961 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12962 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12963 @item @code{void __MCPXIU (acc, uw1, uw1)}
12964 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12965 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12966 @item @code{void __MCPXRS (acc, sw1, sw1)}
12967 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12968 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12969 @item @code{void __MCPXRU (acc, uw1, uw1)}
12970 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12971 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12972 @item @code{uw1 __MCUT (acc, uw1)}
12973 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12974 @tab @code{MCUT @var{a},@var{b},@var{c}}
12975 @item @code{uw1 __MCUTSS (acc, sw1)}
12976 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12977 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12978 @item @code{void __MDADDACCS (acc, acc)}
12979 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12980 @tab @code{MDADDACCS @var{a},@var{b}}
12981 @item @code{void __MDASACCS (acc, acc)}
12982 @tab @code{__MDASACCS (@var{b}, @var{a})}
12983 @tab @code{MDASACCS @var{a},@var{b}}
12984 @item @code{uw2 __MDCUTSSI (acc, const)}
12985 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12986 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12987 @item @code{uw2 __MDPACKH (uw2, uw2)}
12988 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12989 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12990 @item @code{uw2 __MDROTLI (uw2, const)}
12991 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12992 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12993 @item @code{void __MDSUBACCS (acc, acc)}
12994 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12995 @tab @code{MDSUBACCS @var{a},@var{b}}
12996 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12997 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12998 @tab @code{MDUNPACKH @var{a},@var{b}}
12999 @item @code{uw2 __MEXPDHD (uw1, const)}
13000 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
13001 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
13002 @item @code{uw1 __MEXPDHW (uw1, const)}
13003 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
13004 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
13005 @item @code{uw1 __MHDSETH (uw1, const)}
13006 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
13007 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
13008 @item @code{sw1 __MHDSETS (const)}
13009 @tab @code{@var{b} = __MHDSETS (@var{a})}
13010 @tab @code{MHDSETS #@var{a},@var{b}}
13011 @item @code{uw1 __MHSETHIH (uw1, const)}
13012 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
13013 @tab @code{MHSETHIH #@var{a},@var{b}}
13014 @item @code{sw1 __MHSETHIS (sw1, const)}
13015 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
13016 @tab @code{MHSETHIS #@var{a},@var{b}}
13017 @item @code{uw1 __MHSETLOH (uw1, const)}
13018 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
13019 @tab @code{MHSETLOH #@var{a},@var{b}}
13020 @item @code{sw1 __MHSETLOS (sw1, const)}
13021 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
13022 @tab @code{MHSETLOS #@var{a},@var{b}}
13023 @item @code{uw1 __MHTOB (uw2)}
13024 @tab @code{@var{b} = __MHTOB (@var{a})}
13025 @tab @code{MHTOB @var{a},@var{b}}
13026 @item @code{void __MMACHS (acc, sw1, sw1)}
13027 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
13028 @tab @code{MMACHS @var{a},@var{b},@var{c}}
13029 @item @code{void __MMACHU (acc, uw1, uw1)}
13030 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
13031 @tab @code{MMACHU @var{a},@var{b},@var{c}}
13032 @item @code{void __MMRDHS (acc, sw1, sw1)}
13033 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
13034 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
13035 @item @code{void __MMRDHU (acc, uw1, uw1)}
13036 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
13037 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
13038 @item @code{void __MMULHS (acc, sw1, sw1)}
13039 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
13040 @tab @code{MMULHS @var{a},@var{b},@var{c}}
13041 @item @code{void __MMULHU (acc, uw1, uw1)}
13042 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
13043 @tab @code{MMULHU @var{a},@var{b},@var{c}}
13044 @item @code{void __MMULXHS (acc, sw1, sw1)}
13045 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
13046 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
13047 @item @code{void __MMULXHU (acc, uw1, uw1)}
13048 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
13049 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
13050 @item @code{uw1 __MNOT (uw1)}
13051 @tab @code{@var{b} = __MNOT (@var{a})}
13052 @tab @code{MNOT @var{a},@var{b}}
13053 @item @code{uw1 __MOR (uw1, uw1)}
13054 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
13055 @tab @code{MOR @var{a},@var{b},@var{c}}
13056 @item @code{uw1 __MPACKH (uh, uh)}
13057 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
13058 @tab @code{MPACKH @var{a},@var{b},@var{c}}
13059 @item @code{sw2 __MQADDHSS (sw2, sw2)}
13060 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
13061 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
13062 @item @code{uw2 __MQADDHUS (uw2, uw2)}
13063 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
13064 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
13065 @item @code{void __MQCPXIS (acc, sw2, sw2)}
13066 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
13067 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
13068 @item @code{void __MQCPXIU (acc, uw2, uw2)}
13069 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
13070 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
13071 @item @code{void __MQCPXRS (acc, sw2, sw2)}
13072 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
13073 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
13074 @item @code{void __MQCPXRU (acc, uw2, uw2)}
13075 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
13076 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
13077 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
13078 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
13079 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
13080 @item @code{sw2 __MQLMTHS (sw2, sw2)}
13081 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
13082 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
13083 @item @code{void __MQMACHS (acc, sw2, sw2)}
13084 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
13085 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
13086 @item @code{void __MQMACHU (acc, uw2, uw2)}
13087 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
13088 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
13089 @item @code{void __MQMACXHS (acc, sw2, sw2)}
13090 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
13091 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
13092 @item @code{void __MQMULHS (acc, sw2, sw2)}
13093 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
13094 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
13095 @item @code{void __MQMULHU (acc, uw2, uw2)}
13096 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
13097 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
13098 @item @code{void __MQMULXHS (acc, sw2, sw2)}
13099 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
13100 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
13101 @item @code{void __MQMULXHU (acc, uw2, uw2)}
13102 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
13103 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
13104 @item @code{sw2 __MQSATHS (sw2, sw2)}
13105 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
13106 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
13107 @item @code{uw2 __MQSLLHI (uw2, int)}
13108 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
13109 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
13110 @item @code{sw2 __MQSRAHI (sw2, int)}
13111 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
13112 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
13113 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
13114 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
13115 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
13116 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
13117 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
13118 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
13119 @item @code{void __MQXMACHS (acc, sw2, sw2)}
13120 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
13121 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
13122 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
13123 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
13124 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
13125 @item @code{uw1 __MRDACC (acc)}
13126 @tab @code{@var{b} = __MRDACC (@var{a})}
13127 @tab @code{MRDACC @var{a},@var{b}}
13128 @item @code{uw1 __MRDACCG (acc)}
13129 @tab @code{@var{b} = __MRDACCG (@var{a})}
13130 @tab @code{MRDACCG @var{a},@var{b}}
13131 @item @code{uw1 __MROTLI (uw1, const)}
13132 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
13133 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
13134 @item @code{uw1 __MROTRI (uw1, const)}
13135 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
13136 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
13137 @item @code{sw1 __MSATHS (sw1, sw1)}
13138 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
13139 @tab @code{MSATHS @var{a},@var{b},@var{c}}
13140 @item @code{uw1 __MSATHU (uw1, uw1)}
13141 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
13142 @tab @code{MSATHU @var{a},@var{b},@var{c}}
13143 @item @code{uw1 __MSLLHI (uw1, const)}
13144 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
13145 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
13146 @item @code{sw1 __MSRAHI (sw1, const)}
13147 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
13148 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
13149 @item @code{uw1 __MSRLHI (uw1, const)}
13150 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
13151 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
13152 @item @code{void __MSUBACCS (acc, acc)}
13153 @tab @code{__MSUBACCS (@var{b}, @var{a})}
13154 @tab @code{MSUBACCS @var{a},@var{b}}
13155 @item @code{sw1 __MSUBHSS (sw1, sw1)}
13156 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
13157 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
13158 @item @code{uw1 __MSUBHUS (uw1, uw1)}
13159 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
13160 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
13161 @item @code{void __MTRAP (void)}
13162 @tab @code{__MTRAP ()}
13164 @item @code{uw2 __MUNPACKH (uw1)}
13165 @tab @code{@var{b} = __MUNPACKH (@var{a})}
13166 @tab @code{MUNPACKH @var{a},@var{b}}
13167 @item @code{uw1 __MWCUT (uw2, uw1)}
13168 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
13169 @tab @code{MWCUT @var{a},@var{b},@var{c}}
13170 @item @code{void __MWTACC (acc, uw1)}
13171 @tab @code{__MWTACC (@var{b}, @var{a})}
13172 @tab @code{MWTACC @var{a},@var{b}}
13173 @item @code{void __MWTACCG (acc, uw1)}
13174 @tab @code{__MWTACCG (@var{b}, @var{a})}
13175 @tab @code{MWTACCG @var{a},@var{b}}
13176 @item @code{uw1 __MXOR (uw1, uw1)}
13177 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
13178 @tab @code{MXOR @var{a},@var{b},@var{c}}
13181 @node Raw read/write Functions
13182 @subsubsection Raw Read/Write Functions
13184 This sections describes built-in functions related to read and write
13185 instructions to access memory. These functions generate
13186 @code{membar} instructions to flush the I/O load and stores where
13187 appropriate, as described in Fujitsu's manual described above.
13191 @item unsigned char __builtin_read8 (void *@var{data})
13192 @item unsigned short __builtin_read16 (void *@var{data})
13193 @item unsigned long __builtin_read32 (void *@var{data})
13194 @item unsigned long long __builtin_read64 (void *@var{data})
13196 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
13197 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
13198 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
13199 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
13202 @node Other Built-in Functions
13203 @subsubsection Other Built-in Functions
13205 This section describes built-in functions that are not named after
13206 a specific FR-V instruction.
13209 @item sw2 __IACCreadll (iacc @var{reg})
13210 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
13211 for future expansion and must be 0.
13213 @item sw1 __IACCreadl (iacc @var{reg})
13214 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
13215 Other values of @var{reg} are rejected as invalid.
13217 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
13218 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
13219 is reserved for future expansion and must be 0.
13221 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
13222 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
13223 is 1. Other values of @var{reg} are rejected as invalid.
13225 @item void __data_prefetch0 (const void *@var{x})
13226 Use the @code{dcpl} instruction to load the contents of address @var{x}
13227 into the data cache.
13229 @item void __data_prefetch (const void *@var{x})
13230 Use the @code{nldub} instruction to load the contents of address @var{x}
13231 into the data cache. The instruction is issued in slot I1@.
13234 @node MIPS DSP Built-in Functions
13235 @subsection MIPS DSP Built-in Functions
13237 The MIPS DSP Application-Specific Extension (ASE) includes new
13238 instructions that are designed to improve the performance of DSP and
13239 media applications. It provides instructions that operate on packed
13240 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13242 GCC supports MIPS DSP operations using both the generic
13243 vector extensions (@pxref{Vector Extensions}) and a collection of
13244 MIPS-specific built-in functions. Both kinds of support are
13245 enabled by the @option{-mdsp} command-line option.
13247 Revision 2 of the ASE was introduced in the second half of 2006.
13248 This revision adds extra instructions to the original ASE, but is
13249 otherwise backwards-compatible with it. You can select revision 2
13250 using the command-line option @option{-mdspr2}; this option implies
13253 The SCOUNT and POS bits of the DSP control register are global. The
13254 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13255 POS bits. During optimization, the compiler does not delete these
13256 instructions and it does not delete calls to functions containing
13257 these instructions.
13259 At present, GCC only provides support for operations on 32-bit
13260 vectors. The vector type associated with 8-bit integer data is
13261 usually called @code{v4i8}, the vector type associated with Q7
13262 is usually called @code{v4q7}, the vector type associated with 16-bit
13263 integer data is usually called @code{v2i16}, and the vector type
13264 associated with Q15 is usually called @code{v2q15}. They can be
13265 defined in C as follows:
13268 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13269 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13270 typedef short v2i16 __attribute__ ((vector_size(4)));
13271 typedef short v2q15 __attribute__ ((vector_size(4)));
13274 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13275 initialized in the same way as aggregates. For example:
13278 v4i8 a = @{1, 2, 3, 4@};
13280 b = (v4i8) @{5, 6, 7, 8@};
13282 v2q15 c = @{0x0fcb, 0x3a75@};
13284 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13287 @emph{Note:} The CPU's endianness determines the order in which values
13288 are packed. On little-endian targets, the first value is the least
13289 significant and the last value is the most significant. The opposite
13290 order applies to big-endian targets. For example, the code above
13291 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13292 and @code{4} on big-endian targets.
13294 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13295 representation. As shown in this example, the integer representation
13296 of a Q7 value can be obtained by multiplying the fractional value by
13297 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
13298 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
13301 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13302 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
13303 and @code{c} and @code{d} are @code{v2q15} values.
13305 @multitable @columnfractions .50 .50
13306 @item C code @tab MIPS instruction
13307 @item @code{a + b} @tab @code{addu.qb}
13308 @item @code{c + d} @tab @code{addq.ph}
13309 @item @code{a - b} @tab @code{subu.qb}
13310 @item @code{c - d} @tab @code{subq.ph}
13313 The table below lists the @code{v2i16} operation for which
13314 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
13315 @code{v2i16} values.
13317 @multitable @columnfractions .50 .50
13318 @item C code @tab MIPS instruction
13319 @item @code{e * f} @tab @code{mul.ph}
13322 It is easier to describe the DSP built-in functions if we first define
13323 the following types:
13328 typedef unsigned int ui32;
13329 typedef long long a64;
13332 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13333 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13334 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
13335 @code{long long}, but we use @code{a64} to indicate values that are
13336 placed in one of the four DSP accumulators (@code{$ac0},
13337 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13339 Also, some built-in functions prefer or require immediate numbers as
13340 parameters, because the corresponding DSP instructions accept both immediate
13341 numbers and register operands, or accept immediate numbers only. The
13342 immediate parameters are listed as follows.
13350 imm0_255: 0 to 255.
13351 imm_n32_31: -32 to 31.
13352 imm_n512_511: -512 to 511.
13355 The following built-in functions map directly to a particular MIPS DSP
13356 instruction. Please refer to the architecture specification
13357 for details on what each instruction does.
13360 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13361 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13362 q31 __builtin_mips_addq_s_w (q31, q31)
13363 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13364 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13365 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13366 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13367 q31 __builtin_mips_subq_s_w (q31, q31)
13368 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13369 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13370 i32 __builtin_mips_addsc (i32, i32)
13371 i32 __builtin_mips_addwc (i32, i32)
13372 i32 __builtin_mips_modsub (i32, i32)
13373 i32 __builtin_mips_raddu_w_qb (v4i8)
13374 v2q15 __builtin_mips_absq_s_ph (v2q15)
13375 q31 __builtin_mips_absq_s_w (q31)
13376 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13377 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13378 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13379 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13380 q31 __builtin_mips_preceq_w_phl (v2q15)
13381 q31 __builtin_mips_preceq_w_phr (v2q15)
13382 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13383 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13384 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13385 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13386 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13387 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13388 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13389 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13390 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13391 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13392 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13393 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13394 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13395 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13396 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13397 q31 __builtin_mips_shll_s_w (q31, i32)
13398 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13399 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13400 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13401 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13402 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13403 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13404 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13405 q31 __builtin_mips_shra_r_w (q31, i32)
13406 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13407 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13408 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13409 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13410 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13411 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13412 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13413 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13414 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13415 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13416 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13417 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13418 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13419 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13420 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13421 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13422 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13423 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13424 i32 __builtin_mips_bitrev (i32)
13425 i32 __builtin_mips_insv (i32, i32)
13426 v4i8 __builtin_mips_repl_qb (imm0_255)
13427 v4i8 __builtin_mips_repl_qb (i32)
13428 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13429 v2q15 __builtin_mips_repl_ph (i32)
13430 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13431 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13432 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13433 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13434 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13435 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13436 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13437 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13438 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13439 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13440 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13441 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13442 i32 __builtin_mips_extr_w (a64, imm0_31)
13443 i32 __builtin_mips_extr_w (a64, i32)
13444 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13445 i32 __builtin_mips_extr_s_h (a64, i32)
13446 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13447 i32 __builtin_mips_extr_rs_w (a64, i32)
13448 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13449 i32 __builtin_mips_extr_r_w (a64, i32)
13450 i32 __builtin_mips_extp (a64, imm0_31)
13451 i32 __builtin_mips_extp (a64, i32)
13452 i32 __builtin_mips_extpdp (a64, imm0_31)
13453 i32 __builtin_mips_extpdp (a64, i32)
13454 a64 __builtin_mips_shilo (a64, imm_n32_31)
13455 a64 __builtin_mips_shilo (a64, i32)
13456 a64 __builtin_mips_mthlip (a64, i32)
13457 void __builtin_mips_wrdsp (i32, imm0_63)
13458 i32 __builtin_mips_rddsp (imm0_63)
13459 i32 __builtin_mips_lbux (void *, i32)
13460 i32 __builtin_mips_lhx (void *, i32)
13461 i32 __builtin_mips_lwx (void *, i32)
13462 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13463 i32 __builtin_mips_bposge32 (void)
13464 a64 __builtin_mips_madd (a64, i32, i32);
13465 a64 __builtin_mips_maddu (a64, ui32, ui32);
13466 a64 __builtin_mips_msub (a64, i32, i32);
13467 a64 __builtin_mips_msubu (a64, ui32, ui32);
13468 a64 __builtin_mips_mult (i32, i32);
13469 a64 __builtin_mips_multu (ui32, ui32);
13472 The following built-in functions map directly to a particular MIPS DSP REV 2
13473 instruction. Please refer to the architecture specification
13474 for details on what each instruction does.
13477 v4q7 __builtin_mips_absq_s_qb (v4q7);
13478 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13479 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13480 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13481 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13482 i32 __builtin_mips_append (i32, i32, imm0_31);
13483 i32 __builtin_mips_balign (i32, i32, imm0_3);
13484 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13485 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13486 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13487 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13488 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13489 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13490 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13491 q31 __builtin_mips_mulq_rs_w (q31, q31);
13492 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13493 q31 __builtin_mips_mulq_s_w (q31, q31);
13494 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13495 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13496 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13497 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13498 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13499 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13500 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13501 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13502 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13503 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13504 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13505 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13506 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13507 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13508 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13509 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13510 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13511 q31 __builtin_mips_addqh_w (q31, q31);
13512 q31 __builtin_mips_addqh_r_w (q31, q31);
13513 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13514 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13515 q31 __builtin_mips_subqh_w (q31, q31);
13516 q31 __builtin_mips_subqh_r_w (q31, q31);
13517 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13518 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13519 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13520 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13521 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13522 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13526 @node MIPS Paired-Single Support
13527 @subsection MIPS Paired-Single Support
13529 The MIPS64 architecture includes a number of instructions that
13530 operate on pairs of single-precision floating-point values.
13531 Each pair is packed into a 64-bit floating-point register,
13532 with one element being designated the ``upper half'' and
13533 the other being designated the ``lower half''.
13535 GCC supports paired-single operations using both the generic
13536 vector extensions (@pxref{Vector Extensions}) and a collection of
13537 MIPS-specific built-in functions. Both kinds of support are
13538 enabled by the @option{-mpaired-single} command-line option.
13540 The vector type associated with paired-single values is usually
13541 called @code{v2sf}. It can be defined in C as follows:
13544 typedef float v2sf __attribute__ ((vector_size (8)));
13547 @code{v2sf} values are initialized in the same way as aggregates.
13551 v2sf a = @{1.5, 9.1@};
13554 b = (v2sf) @{e, f@};
13557 @emph{Note:} The CPU's endianness determines which value is stored in
13558 the upper half of a register and which value is stored in the lower half.
13559 On little-endian targets, the first value is the lower one and the second
13560 value is the upper one. The opposite order applies to big-endian targets.
13561 For example, the code above sets the lower half of @code{a} to
13562 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13564 @node MIPS Loongson Built-in Functions
13565 @subsection MIPS Loongson Built-in Functions
13567 GCC provides intrinsics to access the SIMD instructions provided by the
13568 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
13569 available after inclusion of the @code{loongson.h} header file,
13570 operate on the following 64-bit vector types:
13573 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13574 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13575 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13576 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13577 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13578 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13581 The intrinsics provided are listed below; each is named after the
13582 machine instruction to which it corresponds, with suffixes added as
13583 appropriate to distinguish intrinsics that expand to the same machine
13584 instruction yet have different argument types. Refer to the architecture
13585 documentation for a description of the functionality of each
13589 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13590 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13591 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13592 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13593 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13594 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13595 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13596 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13597 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13598 uint64_t paddd_u (uint64_t s, uint64_t t);
13599 int64_t paddd_s (int64_t s, int64_t t);
13600 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13601 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13602 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13603 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13604 uint64_t pandn_ud (uint64_t s, uint64_t t);
13605 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13606 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13607 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13608 int64_t pandn_sd (int64_t s, int64_t t);
13609 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13610 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13611 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13612 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13613 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13614 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13615 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13616 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13617 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13618 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13619 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13620 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13621 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13622 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13623 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13624 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13625 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13626 uint16x4_t pextrh_u (uint16x4_t s, int field);
13627 int16x4_t pextrh_s (int16x4_t s, int field);
13628 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13629 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13630 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13631 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13632 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13633 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13634 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13635 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13636 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13637 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13638 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13639 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13640 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13641 uint8x8_t pmovmskb_u (uint8x8_t s);
13642 int8x8_t pmovmskb_s (int8x8_t s);
13643 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13644 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13645 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13646 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13647 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13648 uint16x4_t biadd (uint8x8_t s);
13649 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13650 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13651 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13652 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13653 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13654 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13655 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13656 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13657 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13658 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13659 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13660 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13661 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13662 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13663 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13664 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13665 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13666 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13667 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13668 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13669 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13670 uint64_t psubd_u (uint64_t s, uint64_t t);
13671 int64_t psubd_s (int64_t s, int64_t t);
13672 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13673 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13674 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13675 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13676 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13677 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13678 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13679 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13680 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13681 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13682 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13683 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13684 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13685 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13686 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13687 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13691 * Paired-Single Arithmetic::
13692 * Paired-Single Built-in Functions::
13693 * MIPS-3D Built-in Functions::
13696 @node Paired-Single Arithmetic
13697 @subsubsection Paired-Single Arithmetic
13699 The table below lists the @code{v2sf} operations for which hardware
13700 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13701 values and @code{x} is an integral value.
13703 @multitable @columnfractions .50 .50
13704 @item C code @tab MIPS instruction
13705 @item @code{a + b} @tab @code{add.ps}
13706 @item @code{a - b} @tab @code{sub.ps}
13707 @item @code{-a} @tab @code{neg.ps}
13708 @item @code{a * b} @tab @code{mul.ps}
13709 @item @code{a * b + c} @tab @code{madd.ps}
13710 @item @code{a * b - c} @tab @code{msub.ps}
13711 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13712 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13713 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13716 Note that the multiply-accumulate instructions can be disabled
13717 using the command-line option @code{-mno-fused-madd}.
13719 @node Paired-Single Built-in Functions
13720 @subsubsection Paired-Single Built-in Functions
13722 The following paired-single functions map directly to a particular
13723 MIPS instruction. Please refer to the architecture specification
13724 for details on what each instruction does.
13727 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13728 Pair lower lower (@code{pll.ps}).
13730 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13731 Pair upper lower (@code{pul.ps}).
13733 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13734 Pair lower upper (@code{plu.ps}).
13736 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13737 Pair upper upper (@code{puu.ps}).
13739 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13740 Convert pair to paired single (@code{cvt.ps.s}).
13742 @item float __builtin_mips_cvt_s_pl (v2sf)
13743 Convert pair lower to single (@code{cvt.s.pl}).
13745 @item float __builtin_mips_cvt_s_pu (v2sf)
13746 Convert pair upper to single (@code{cvt.s.pu}).
13748 @item v2sf __builtin_mips_abs_ps (v2sf)
13749 Absolute value (@code{abs.ps}).
13751 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13752 Align variable (@code{alnv.ps}).
13754 @emph{Note:} The value of the third parameter must be 0 or 4
13755 modulo 8, otherwise the result is unpredictable. Please read the
13756 instruction description for details.
13759 The following multi-instruction functions are also available.
13760 In each case, @var{cond} can be any of the 16 floating-point conditions:
13761 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13762 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13763 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13766 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13767 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13768 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13769 @code{movt.ps}/@code{movf.ps}).
13771 The @code{movt} functions return the value @var{x} computed by:
13774 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13775 mov.ps @var{x},@var{c}
13776 movt.ps @var{x},@var{d},@var{cc}
13779 The @code{movf} functions are similar but use @code{movf.ps} instead
13782 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13783 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13784 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13785 @code{bc1t}/@code{bc1f}).
13787 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13788 and return either the upper or lower half of the result. For example:
13792 if (__builtin_mips_upper_c_eq_ps (a, b))
13793 upper_halves_are_equal ();
13795 upper_halves_are_unequal ();
13797 if (__builtin_mips_lower_c_eq_ps (a, b))
13798 lower_halves_are_equal ();
13800 lower_halves_are_unequal ();
13804 @node MIPS-3D Built-in Functions
13805 @subsubsection MIPS-3D Built-in Functions
13807 The MIPS-3D Application-Specific Extension (ASE) includes additional
13808 paired-single instructions that are designed to improve the performance
13809 of 3D graphics operations. Support for these instructions is controlled
13810 by the @option{-mips3d} command-line option.
13812 The functions listed below map directly to a particular MIPS-3D
13813 instruction. Please refer to the architecture specification for
13814 more details on what each instruction does.
13817 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13818 Reduction add (@code{addr.ps}).
13820 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13821 Reduction multiply (@code{mulr.ps}).
13823 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13824 Convert paired single to paired word (@code{cvt.pw.ps}).
13826 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13827 Convert paired word to paired single (@code{cvt.ps.pw}).
13829 @item float __builtin_mips_recip1_s (float)
13830 @itemx double __builtin_mips_recip1_d (double)
13831 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13832 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13834 @item float __builtin_mips_recip2_s (float, float)
13835 @itemx double __builtin_mips_recip2_d (double, double)
13836 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13837 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13839 @item float __builtin_mips_rsqrt1_s (float)
13840 @itemx double __builtin_mips_rsqrt1_d (double)
13841 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13842 Reduced-precision reciprocal square root (sequence step 1)
13843 (@code{rsqrt1.@var{fmt}}).
13845 @item float __builtin_mips_rsqrt2_s (float, float)
13846 @itemx double __builtin_mips_rsqrt2_d (double, double)
13847 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13848 Reduced-precision reciprocal square root (sequence step 2)
13849 (@code{rsqrt2.@var{fmt}}).
13852 The following multi-instruction functions are also available.
13853 In each case, @var{cond} can be any of the 16 floating-point conditions:
13854 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13855 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13856 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13859 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13860 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13861 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13862 @code{bc1t}/@code{bc1f}).
13864 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13865 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13870 if (__builtin_mips_cabs_eq_s (a, b))
13876 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13877 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13878 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13879 @code{bc1t}/@code{bc1f}).
13881 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13882 and return either the upper or lower half of the result. For example:
13886 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13887 upper_halves_are_equal ();
13889 upper_halves_are_unequal ();
13891 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13892 lower_halves_are_equal ();
13894 lower_halves_are_unequal ();
13897 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13898 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13899 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13900 @code{movt.ps}/@code{movf.ps}).
13902 The @code{movt} functions return the value @var{x} computed by:
13905 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13906 mov.ps @var{x},@var{c}
13907 movt.ps @var{x},@var{d},@var{cc}
13910 The @code{movf} functions are similar but use @code{movf.ps} instead
13913 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13914 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13915 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13916 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13917 Comparison of two paired-single values
13918 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13919 @code{bc1any2t}/@code{bc1any2f}).
13921 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13922 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13923 result is true and the @code{all} forms return true if both results are true.
13928 if (__builtin_mips_any_c_eq_ps (a, b))
13933 if (__builtin_mips_all_c_eq_ps (a, b))
13939 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13940 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13941 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13942 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13943 Comparison of four paired-single values
13944 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13945 @code{bc1any4t}/@code{bc1any4f}).
13947 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13948 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13949 The @code{any} forms return true if any of the four results are true
13950 and the @code{all} forms return true if all four results are true.
13955 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13960 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13967 @node MIPS SIMD Architecture (MSA) Support
13968 @subsection MIPS SIMD Architecture (MSA) Support
13971 * MIPS SIMD Architecture Built-in Functions::
13974 GCC provides intrinsics to access the SIMD instructions provided by the
13975 MSA MIPS SIMD Architecture. The interface is made available by including
13976 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
13977 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
13980 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
13981 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
13982 data elements. The following vectors typedefs are included in @code{msa.h}:
13984 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
13985 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
13986 @item @code{v8i16}, a vector of eight signed 16-bit integers;
13987 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
13988 @item @code{v4i32}, a vector of four signed 32-bit integers;
13989 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
13990 @item @code{v2i64}, a vector of two signed 64-bit integers;
13991 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
13992 @item @code{v4f32}, a vector of four 32-bit floats;
13993 @item @code{v2f64}, a vector of two 64-bit doubles.
13996 Instructions and corresponding built-ins may have additional restrictions and/or
13997 input/output values manipulated:
13999 @item @code{imm0_1}, an integer literal in range 0 to 1;
14000 @item @code{imm0_3}, an integer literal in range 0 to 3;
14001 @item @code{imm0_7}, an integer literal in range 0 to 7;
14002 @item @code{imm0_15}, an integer literal in range 0 to 15;
14003 @item @code{imm0_31}, an integer literal in range 0 to 31;
14004 @item @code{imm0_63}, an integer literal in range 0 to 63;
14005 @item @code{imm0_255}, an integer literal in range 0 to 255;
14006 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
14007 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
14008 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
14009 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
14010 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
14011 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
14012 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
14013 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
14014 @item @code{imm1_4}, an integer literal in range 1 to 4;
14015 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
14021 #if __LONG_MAX__ == __LONG_LONG_MAX__
14024 typedef long long i64;
14027 typedef unsigned int u32;
14028 #if __LONG_MAX__ == __LONG_LONG_MAX__
14029 typedef unsigned long u64;
14031 typedef unsigned long long u64;
14034 typedef double f64;
14039 @node MIPS SIMD Architecture Built-in Functions
14040 @subsubsection MIPS SIMD Architecture Built-in Functions
14042 The intrinsics provided are listed below; each is named after the
14043 machine instruction.
14046 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
14047 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
14048 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
14049 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
14051 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
14052 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
14053 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
14054 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
14056 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
14057 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
14058 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
14059 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
14061 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
14062 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
14063 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
14064 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
14066 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
14067 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
14068 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
14069 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
14071 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
14072 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
14073 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
14074 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
14076 v16u8 __builtin_msa_and_v (v16u8, v16u8);
14078 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
14080 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
14081 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
14082 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
14083 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
14085 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
14086 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
14087 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
14088 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
14090 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
14091 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
14092 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
14093 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
14095 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
14096 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
14097 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
14098 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
14100 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
14101 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
14102 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
14103 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
14105 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
14106 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
14107 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
14108 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
14110 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
14111 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
14112 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
14113 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
14115 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
14116 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
14117 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
14118 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
14120 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
14121 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
14122 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
14123 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
14125 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
14126 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
14127 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
14128 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
14130 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
14131 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
14132 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
14133 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
14135 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
14136 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
14137 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
14138 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
14140 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
14142 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
14144 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
14146 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
14148 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
14149 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
14150 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
14151 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
14153 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
14154 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
14155 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
14156 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
14158 i32 __builtin_msa_bnz_b (v16u8);
14159 i32 __builtin_msa_bnz_h (v8u16);
14160 i32 __builtin_msa_bnz_w (v4u32);
14161 i32 __builtin_msa_bnz_d (v2u64);
14163 i32 __builtin_msa_bnz_v (v16u8);
14165 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
14167 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
14169 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
14170 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
14171 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
14172 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
14174 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
14175 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
14176 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
14177 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
14179 i32 __builtin_msa_bz_b (v16u8);
14180 i32 __builtin_msa_bz_h (v8u16);
14181 i32 __builtin_msa_bz_w (v4u32);
14182 i32 __builtin_msa_bz_d (v2u64);
14184 i32 __builtin_msa_bz_v (v16u8);
14186 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
14187 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
14188 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
14189 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
14191 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
14192 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
14193 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
14194 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
14196 i32 __builtin_msa_cfcmsa (imm0_31);
14198 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
14199 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
14200 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
14201 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
14203 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
14204 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
14205 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
14206 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
14208 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
14209 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
14210 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
14211 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
14213 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
14214 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
14215 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
14216 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
14218 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
14219 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
14220 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
14221 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
14223 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
14224 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
14225 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
14226 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
14228 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
14229 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
14230 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14231 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14233 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14234 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14235 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14236 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14238 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14239 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14240 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14241 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14243 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14244 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14245 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14246 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14248 void __builtin_msa_ctcmsa (imm0_31, i32);
14250 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14251 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14252 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14253 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14255 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14256 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14257 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14258 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14260 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14261 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14262 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14264 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14265 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14266 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14268 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14269 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14270 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14272 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14273 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14274 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14276 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14277 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14278 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14280 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14281 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14282 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14284 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
14285 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
14287 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
14288 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
14290 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
14291 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
14293 v4i32 __builtin_msa_fclass_w (v4f32);
14294 v2i64 __builtin_msa_fclass_d (v2f64);
14296 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
14297 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
14299 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
14300 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
14302 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
14303 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
14305 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
14306 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
14308 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
14309 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
14311 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
14312 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
14314 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
14315 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
14317 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
14318 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
14320 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
14321 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
14323 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
14324 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
14326 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
14327 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
14329 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
14330 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
14332 v4f32 __builtin_msa_fexupl_w (v8i16);
14333 v2f64 __builtin_msa_fexupl_d (v4f32);
14335 v4f32 __builtin_msa_fexupr_w (v8i16);
14336 v2f64 __builtin_msa_fexupr_d (v4f32);
14338 v4f32 __builtin_msa_ffint_s_w (v4i32);
14339 v2f64 __builtin_msa_ffint_s_d (v2i64);
14341 v4f32 __builtin_msa_ffint_u_w (v4u32);
14342 v2f64 __builtin_msa_ffint_u_d (v2u64);
14344 v4f32 __builtin_msa_ffql_w (v8i16);
14345 v2f64 __builtin_msa_ffql_d (v4i32);
14347 v4f32 __builtin_msa_ffqr_w (v8i16);
14348 v2f64 __builtin_msa_ffqr_d (v4i32);
14350 v16i8 __builtin_msa_fill_b (i32);
14351 v8i16 __builtin_msa_fill_h (i32);
14352 v4i32 __builtin_msa_fill_w (i32);
14353 v2i64 __builtin_msa_fill_d (i64);
14355 v4f32 __builtin_msa_flog2_w (v4f32);
14356 v2f64 __builtin_msa_flog2_d (v2f64);
14358 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
14359 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
14361 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
14362 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
14364 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
14365 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
14367 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
14368 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
14370 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
14371 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
14373 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
14374 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
14376 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
14377 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
14379 v4f32 __builtin_msa_frint_w (v4f32);
14380 v2f64 __builtin_msa_frint_d (v2f64);
14382 v4f32 __builtin_msa_frcp_w (v4f32);
14383 v2f64 __builtin_msa_frcp_d (v2f64);
14385 v4f32 __builtin_msa_frsqrt_w (v4f32);
14386 v2f64 __builtin_msa_frsqrt_d (v2f64);
14388 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
14389 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
14391 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
14392 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
14394 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
14395 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
14397 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
14398 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
14400 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
14401 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
14403 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
14404 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
14406 v4f32 __builtin_msa_fsqrt_w (v4f32);
14407 v2f64 __builtin_msa_fsqrt_d (v2f64);
14409 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
14410 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
14412 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
14413 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
14415 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
14416 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
14418 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
14419 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
14421 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
14422 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
14424 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
14425 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
14427 v4i32 __builtin_msa_ftint_s_w (v4f32);
14428 v2i64 __builtin_msa_ftint_s_d (v2f64);
14430 v4u32 __builtin_msa_ftint_u_w (v4f32);
14431 v2u64 __builtin_msa_ftint_u_d (v2f64);
14433 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
14434 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
14436 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
14437 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
14439 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
14440 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
14442 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
14443 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
14444 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
14446 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
14447 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
14448 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
14450 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
14451 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
14452 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
14454 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
14455 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
14456 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
14458 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
14459 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
14460 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
14461 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
14463 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
14464 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
14465 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
14466 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
14468 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
14469 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
14470 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
14471 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
14473 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
14474 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
14475 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
14476 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
14478 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
14479 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
14480 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
14481 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
14483 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
14484 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
14485 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
14486 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
14488 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
14489 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
14490 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
14491 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
14493 v16i8 __builtin_msa_ldi_b (imm_n512_511);
14494 v8i16 __builtin_msa_ldi_h (imm_n512_511);
14495 v4i32 __builtin_msa_ldi_w (imm_n512_511);
14496 v2i64 __builtin_msa_ldi_d (imm_n512_511);
14498 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
14499 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
14501 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
14502 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
14504 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
14505 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
14506 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
14507 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
14509 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
14510 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
14511 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
14512 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
14514 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
14515 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
14516 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
14517 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
14519 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
14520 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
14521 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
14522 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
14524 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
14525 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
14526 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
14527 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
14529 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
14530 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
14531 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
14532 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
14534 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
14535 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
14536 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
14537 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
14539 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
14540 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
14541 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
14542 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
14544 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
14545 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
14546 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
14547 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
14549 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
14550 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
14551 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
14552 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
14554 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
14555 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
14556 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
14557 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
14559 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
14560 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
14561 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
14562 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
14564 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
14565 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
14566 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
14567 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
14569 v16i8 __builtin_msa_move_v (v16i8);
14571 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
14572 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
14574 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
14575 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
14577 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
14578 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
14579 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
14580 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
14582 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
14583 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
14585 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
14586 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
14588 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
14589 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
14590 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
14591 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
14593 v16i8 __builtin_msa_nloc_b (v16i8);
14594 v8i16 __builtin_msa_nloc_h (v8i16);
14595 v4i32 __builtin_msa_nloc_w (v4i32);
14596 v2i64 __builtin_msa_nloc_d (v2i64);
14598 v16i8 __builtin_msa_nlzc_b (v16i8);
14599 v8i16 __builtin_msa_nlzc_h (v8i16);
14600 v4i32 __builtin_msa_nlzc_w (v4i32);
14601 v2i64 __builtin_msa_nlzc_d (v2i64);
14603 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
14605 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
14607 v16u8 __builtin_msa_or_v (v16u8, v16u8);
14609 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
14611 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
14612 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
14613 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
14614 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
14616 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
14617 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
14618 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
14619 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
14621 v16i8 __builtin_msa_pcnt_b (v16i8);
14622 v8i16 __builtin_msa_pcnt_h (v8i16);
14623 v4i32 __builtin_msa_pcnt_w (v4i32);
14624 v2i64 __builtin_msa_pcnt_d (v2i64);
14626 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
14627 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
14628 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
14629 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
14631 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
14632 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
14633 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
14634 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
14636 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
14637 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
14638 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
14640 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
14641 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
14642 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
14643 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
14645 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
14646 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
14647 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
14648 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
14650 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
14651 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
14652 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
14653 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
14655 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
14656 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
14657 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
14658 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
14660 v16i8 __builtin_msa_splat_b (v16i8, i32);
14661 v8i16 __builtin_msa_splat_h (v8i16, i32);
14662 v4i32 __builtin_msa_splat_w (v4i32, i32);
14663 v2i64 __builtin_msa_splat_d (v2i64, i32);
14665 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
14666 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
14667 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
14668 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
14670 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
14671 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
14672 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
14673 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
14675 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
14676 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
14677 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
14678 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
14680 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
14681 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
14682 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
14683 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
14685 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
14686 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
14687 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
14688 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
14690 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
14691 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
14692 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
14693 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
14695 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
14696 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
14697 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
14698 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
14700 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
14701 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
14702 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
14703 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
14705 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
14706 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
14707 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
14708 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
14710 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
14711 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
14712 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
14713 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
14715 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
14716 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
14717 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
14718 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
14720 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
14721 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
14722 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
14723 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
14725 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
14726 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
14727 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
14728 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
14730 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
14731 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
14732 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
14733 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
14735 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
14736 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
14737 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
14738 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
14740 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
14741 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
14742 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
14743 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
14745 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
14746 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
14747 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
14748 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
14750 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
14752 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
14755 @node Other MIPS Built-in Functions
14756 @subsection Other MIPS Built-in Functions
14758 GCC provides other MIPS-specific built-in functions:
14761 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
14762 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
14763 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
14764 when this function is available.
14766 @item unsigned int __builtin_mips_get_fcsr (void)
14767 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
14768 Get and set the contents of the floating-point control and status register
14769 (FPU control register 31). These functions are only available in hard-float
14770 code but can be called in both MIPS16 and non-MIPS16 contexts.
14772 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
14773 register except the condition codes, which GCC assumes are preserved.
14776 @node MSP430 Built-in Functions
14777 @subsection MSP430 Built-in Functions
14779 GCC provides a couple of special builtin functions to aid in the
14780 writing of interrupt handlers in C.
14783 @item __bic_SR_register_on_exit (int @var{mask})
14784 This clears the indicated bits in the saved copy of the status register
14785 currently residing on the stack. This only works inside interrupt
14786 handlers and the changes to the status register will only take affect
14787 once the handler returns.
14789 @item __bis_SR_register_on_exit (int @var{mask})
14790 This sets the indicated bits in the saved copy of the status register
14791 currently residing on the stack. This only works inside interrupt
14792 handlers and the changes to the status register will only take affect
14793 once the handler returns.
14795 @item __delay_cycles (long long @var{cycles})
14796 This inserts an instruction sequence that takes exactly @var{cycles}
14797 cycles (between 0 and about 17E9) to complete. The inserted sequence
14798 may use jumps, loops, or no-ops, and does not interfere with any other
14799 instructions. Note that @var{cycles} must be a compile-time constant
14800 integer - that is, you must pass a number, not a variable that may be
14801 optimized to a constant later. The number of cycles delayed by this
14805 @node NDS32 Built-in Functions
14806 @subsection NDS32 Built-in Functions
14808 These built-in functions are available for the NDS32 target:
14810 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
14811 Insert an ISYNC instruction into the instruction stream where
14812 @var{addr} is an instruction address for serialization.
14815 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
14816 Insert an ISB instruction into the instruction stream.
14819 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
14820 Return the content of a system register which is mapped by @var{sr}.
14823 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
14824 Return the content of a user space register which is mapped by @var{usr}.
14827 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
14828 Move the @var{value} to a system register which is mapped by @var{sr}.
14831 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
14832 Move the @var{value} to a user space register which is mapped by @var{usr}.
14835 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
14836 Enable global interrupt.
14839 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
14840 Disable global interrupt.
14843 @node picoChip Built-in Functions
14844 @subsection picoChip Built-in Functions
14846 GCC provides an interface to selected machine instructions from the
14847 picoChip instruction set.
14850 @item int __builtin_sbc (int @var{value})
14851 Sign bit count. Return the number of consecutive bits in @var{value}
14852 that have the same value as the sign bit. The result is the number of
14853 leading sign bits minus one, giving the number of redundant sign bits in
14856 @item int __builtin_byteswap (int @var{value})
14857 Byte swap. Return the result of swapping the upper and lower bytes of
14860 @item int __builtin_brev (int @var{value})
14861 Bit reversal. Return the result of reversing the bits in
14862 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
14865 @item int __builtin_adds (int @var{x}, int @var{y})
14866 Saturating addition. Return the result of adding @var{x} and @var{y},
14867 storing the value 32767 if the result overflows.
14869 @item int __builtin_subs (int @var{x}, int @var{y})
14870 Saturating subtraction. Return the result of subtracting @var{y} from
14871 @var{x}, storing the value @minus{}32768 if the result overflows.
14873 @item void __builtin_halt (void)
14874 Halt. The processor stops execution. This built-in is useful for
14875 implementing assertions.
14879 @node PowerPC Built-in Functions
14880 @subsection PowerPC Built-in Functions
14882 The following built-in functions are always available and can be used to
14883 check the PowerPC target platform type:
14885 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
14886 This function is a @code{nop} on the PowerPC platform and is included solely
14887 to maintain API compatibility with the x86 builtins.
14890 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
14891 This function returns a value of @code{1} if the run-time CPU is of type
14892 @var{cpuname} and returns @code{0} otherwise. The following CPU names can be
14897 IBM POWER9 Server CPU.
14899 IBM POWER8 Server CPU.
14901 IBM POWER7 Server CPU.
14903 IBM POWER6 Server CPU (RAW mode).
14905 IBM POWER6 Server CPU (Architected mode).
14907 IBM POWER5+ Server CPU.
14909 IBM POWER5 Server CPU.
14911 IBM 970 Server CPU (ie, Apple G5).
14913 IBM POWER4 Server CPU.
14915 IBM A2 64-bit Embedded CPU
14917 IBM PowerPC 476FP 32-bit Embedded CPU.
14919 IBM PowerPC 464 32-bit Embedded CPU.
14921 PowerPC 440 32-bit Embedded CPU.
14923 PowerPC 405 32-bit Embedded CPU.
14925 IBM PowerPC Cell Broadband Engine Architecture CPU.
14928 Here is an example:
14930 if (__builtin_cpu_is ("power8"))
14932 do_power8 (); // POWER8 specific implementation.
14936 do_generic (); // Generic implementation.
14941 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
14942 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
14943 feature @var{feature} and returns @code{0} otherwise. The following features can be
14948 4xx CPU has a Multiply Accumulator.
14950 CPU has a SIMD/Vector Unit.
14952 CPU supports ISA 2.05 (eg, POWER6)
14954 CPU supports ISA 2.06 (eg, POWER7)
14956 CPU supports ISA 2.07 (eg, POWER8)
14958 CPU supports ISA 3.0 (eg, POWER9)
14960 CPU supports the set of compatible performance monitoring events.
14962 CPU supports the Embedded ISA category.
14964 CPU has a CELL broadband engine.
14966 CPU has a decimal floating point unit.
14968 CPU supports the data stream control register.
14970 CPU supports event base branching.
14972 CPU has a SPE double precision floating point unit.
14974 CPU has a SPE single precision floating point unit.
14976 CPU has a floating point unit.
14978 CPU has hardware transaction memory instructions.
14980 Kernel aborts hardware transactions when a syscall is made.
14982 CPU supports icache snooping capabilities.
14984 CPU supports 128-bit IEEE binary floating point instructions.
14986 CPU supports the integer select instruction.
14988 CPU has a memory management unit.
14990 CPU does not have a timebase (eg, 601 and 403gx).
14992 CPU supports the PA Semi 6T CORE ISA.
14994 CPU supports ISA 2.00 (eg, POWER4)
14996 CPU supports ISA 2.02 (eg, POWER5)
14998 CPU supports ISA 2.03 (eg, POWER5+)
15000 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
15002 CPU supports 32-bit mode execution.
15004 CPU supports the old POWER ISA (eg, 601)
15006 CPU supports 64-bit mode execution.
15008 CPU supports a little-endian mode that uses address swizzling.
15010 CPU support simultaneous multi-threading.
15012 CPU has a signal processing extension unit.
15014 CPU supports the target address register.
15016 CPU supports true little-endian mode.
15018 CPU has unified I/D cache.
15020 CPU supports the vector cryptography instructions.
15022 CPU supports the vector-scalar extension.
15025 Here is an example:
15027 if (__builtin_cpu_supports ("fpu"))
15029 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
15033 dst = __fadd (src1, src2); // Software FP addition function.
15038 These built-in functions are available for the PowerPC family of
15041 float __builtin_recipdivf (float, float);
15042 float __builtin_rsqrtf (float);
15043 double __builtin_recipdiv (double, double);
15044 double __builtin_rsqrt (double);
15045 uint64_t __builtin_ppc_get_timebase ();
15046 unsigned long __builtin_ppc_mftb ();
15047 double __builtin_unpack_longdouble (long double, int);
15048 long double __builtin_pack_longdouble (double, double);
15051 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
15052 @code{__builtin_rsqrtf} functions generate multiple instructions to
15053 implement the reciprocal sqrt functionality using reciprocal sqrt
15054 estimate instructions.
15056 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
15057 functions generate multiple instructions to implement division using
15058 the reciprocal estimate instructions.
15060 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
15061 functions generate instructions to read the Time Base Register. The
15062 @code{__builtin_ppc_get_timebase} function may generate multiple
15063 instructions and always returns the 64 bits of the Time Base Register.
15064 The @code{__builtin_ppc_mftb} function always generates one instruction and
15065 returns the Time Base Register value as an unsigned long, throwing away
15066 the most significant word on 32-bit environments.
15068 Additional built-in functions are available for the 64-bit PowerPC
15069 family of processors, for efficient use of 128-bit floating point
15070 (@code{__float128}) values.
15072 The following floating-point built-in functions are available with
15073 @code{-mfloat128} and Altivec support. All of them implement the
15074 function that is part of the name.
15077 __float128 __builtin_fabsq (__float128)
15078 __float128 __builtin_copysignq (__float128, __float128)
15081 The following built-in functions are available with @code{-mfloat128}
15082 and Altivec support.
15085 @item __float128 __builtin_infq (void)
15086 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
15087 @findex __builtin_infq
15089 @item __float128 __builtin_huge_valq (void)
15090 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
15091 @findex __builtin_huge_valq
15093 @item __float128 __builtin_nanq (void)
15094 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
15095 @findex __builtin_nanq
15097 @item __float128 __builtin_nansq (void)
15098 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
15099 @findex __builtin_nansq
15102 The following built-in functions are available for the PowerPC family
15103 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
15104 or @option{-mpopcntd}):
15106 long __builtin_bpermd (long, long);
15107 int __builtin_divwe (int, int);
15108 int __builtin_divweo (int, int);
15109 unsigned int __builtin_divweu (unsigned int, unsigned int);
15110 unsigned int __builtin_divweuo (unsigned int, unsigned int);
15111 long __builtin_divde (long, long);
15112 long __builtin_divdeo (long, long);
15113 unsigned long __builtin_divdeu (unsigned long, unsigned long);
15114 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
15115 unsigned int cdtbcd (unsigned int);
15116 unsigned int cbcdtd (unsigned int);
15117 unsigned int addg6s (unsigned int, unsigned int);
15120 The @code{__builtin_divde}, @code{__builtin_divdeo},
15121 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
15122 64-bit environment support ISA 2.06 or later.
15124 The following built-in functions are available for the PowerPC family
15125 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
15127 long long __builtin_darn (void);
15128 long long __builtin_darn_raw (void);
15129 int __builtin_darn_32 (void);
15131 unsigned int scalar_extract_exp (double source);
15132 unsigned long long int scalar_extract_sig (double source);
15135 scalar_insert_exp (unsigned long long int significand, unsigned long long int exponent);
15137 scalar_insert_exp (double significand, unsigned long long int exponent);
15139 int scalar_cmp_exp_gt (double arg1, double arg2);
15140 int scalar_cmp_exp_lt (double arg1, double arg2);
15141 int scalar_cmp_exp_eq (double arg1, double arg2);
15142 int scalar_cmp_exp_unordered (double arg1, double arg2);
15144 bool scalar_test_data_class (float source, const int condition);
15145 bool scalar_test_data_class (double source, const int condition);
15147 bool scalar_test_neg (float source);
15148 bool scalar_test_neg (double source);
15150 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
15151 int __builtin_byte_in_range (unsigned char u, unsigned int range);
15152 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
15154 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
15155 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
15156 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
15157 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
15159 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
15160 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
15161 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
15162 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
15164 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
15165 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
15166 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
15167 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
15169 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
15170 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
15171 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
15172 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
15175 The @code{__builtin_darn} and @code{__builtin_darn_raw}
15176 functions require a
15177 64-bit environment supporting ISA 3.0 or later.
15178 The @code{__builtin_darn} function provides a 64-bit conditioned
15179 random number. The @code{__builtin_darn_raw} function provides a
15180 64-bit raw random number. The @code{__builtin_darn_32} function
15181 provides a 32-bit random number.
15183 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
15184 functions require a 64-bit environment supporting ISA 3.0 or later.
15185 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
15186 functions return the significand and the biased exponent value
15187 respectively of their @code{source} arguments.
15188 Within the result returned by @code{scalar_extract_sig},
15189 the @code{0x10000000000000} bit is set if the
15190 function's @code{source} argument is in normalized form.
15191 Otherwise, this bit is set to 0.
15192 Note that the sign of the significand is not represented in the result
15193 returned from the @code{scalar_extract_sig} function. Use the
15194 @code{scalar_test_neg} function to test the sign of its @code{double}
15197 The @code{scalar_insert_exp}
15198 function requires a 64-bit environment supporting ISA 3.0 or later.
15199 The @code{scalar_insert_exp} built-in function returns a double-precision
15200 floating point value that is constructed by assembling the values of its
15201 @code{significand} and @code{exponent} arguments. The sign of the
15202 result is copied from the most significant bit of the
15203 @code{significand} argument. The significand and exponent components
15204 of the result are composed of the least significant 11 bits of the
15205 @code{exponent} argument and the least significant 52 bits of the
15206 @code{significand} argument.
15208 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
15209 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
15210 functions return a non-zero value if @code{arg1} is greater than, less
15211 than, equal to, or not comparable to @code{arg2} respectively. The
15212 arguments are not comparable if one or the other equals NaN (not a
15215 The @code{scalar_test_data_class} built-in function returns 1
15216 if any of the condition tests enabled by the value of the
15217 @code{condition} variable are true, and 0 otherwise. The
15218 @code{condition} argument must be a compile-time constant integer with
15219 value not exceeding 127. The
15220 @code{condition} argument is encoded as a bitmask with each bit
15221 enabling the testing of a different condition, as characterized by the
15225 0x20 Test for +Infinity
15226 0x10 Test for -Infinity
15227 0x08 Test for +Zero
15228 0x04 Test for -Zero
15229 0x02 Test for +Denormal
15230 0x01 Test for -Denormal
15233 The @code{scalar_test_neg} built-in function returns 1 if its
15234 @code{source} argument holds a negative value, 0 otherwise.
15236 The @code{__builtin_byte_in_set} function requires a
15237 64-bit environment supporting ISA 3.0 or later. This function returns
15238 a non-zero value if and only if its @code{u} argument exactly equals one of
15239 the eight bytes contained within its 64-bit @code{set} argument.
15241 The @code{__builtin_byte_in_range} and
15242 @code{__builtin_byte_in_either_range} require an environment
15243 supporting ISA 3.0 or later. For these two functions, the
15244 @code{range} argument is encoded as 4 bytes, organized as
15245 @code{hi_1:lo_1:hi_2:lo_2}.
15246 The @code{__builtin_byte_in_range} function returns a
15247 non-zero value if and only if its @code{u} argument is within the
15248 range bounded between @code{lo_2} and @code{hi_2} inclusive.
15249 The @code{__builtin_byte_in_either_range} function returns non-zero if
15250 and only if its @code{u} argument is within either the range bounded
15251 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
15252 between @code{lo_2} and @code{hi_2} inclusive.
15254 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
15255 if and only if the number of signficant digits of its @code{value} argument
15256 is less than its @code{comparison} argument. The
15257 @code{__builtin_dfp_dtstsfi_lt_dd} and
15258 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
15259 require that the type of the @code{value} argument be
15260 @code{__Decimal64} and @code{__Decimal128} respectively.
15262 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
15263 if and only if the number of signficant digits of its @code{value} argument
15264 is greater than its @code{comparison} argument. The
15265 @code{__builtin_dfp_dtstsfi_gt_dd} and
15266 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
15267 require that the type of the @code{value} argument be
15268 @code{__Decimal64} and @code{__Decimal128} respectively.
15270 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
15271 if and only if the number of signficant digits of its @code{value} argument
15272 equals its @code{comparison} argument. The
15273 @code{__builtin_dfp_dtstsfi_eq_dd} and
15274 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
15275 require that the type of the @code{value} argument be
15276 @code{__Decimal64} and @code{__Decimal128} respectively.
15278 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
15279 if and only if its @code{value} argument has an undefined number of
15280 significant digits, such as when @code{value} is an encoding of @code{NaN}.
15281 The @code{__builtin_dfp_dtstsfi_ov_dd} and
15282 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
15283 require that the type of the @code{value} argument be
15284 @code{__Decimal64} and @code{__Decimal128} respectively.
15286 The following built-in functions are also available for the PowerPC family
15287 of processors, starting with ISA 3.0 or later
15288 (@option{-mcpu=power9}). These string functions are described
15289 separately in order to group the descriptions closer to the function
15292 int vec_all_nez (vector signed char, vector signed char);
15293 int vec_all_nez (vector unsigned char, vector unsigned char);
15294 int vec_all_nez (vector signed short, vector signed short);
15295 int vec_all_nez (vector unsigned short, vector unsigned short);
15296 int vec_all_nez (vector signed int, vector signed int);
15297 int vec_all_nez (vector unsigned int, vector unsigned int);
15299 int vec_any_eqz (vector signed char, vector signed char);
15300 int vec_any_eqz (vector unsigned char, vector unsigned char);
15301 int vec_any_eqz (vector signed short, vector signed short);
15302 int vec_any_eqz (vector unsigned short, vector unsigned short);
15303 int vec_any_eqz (vector signed int, vector signed int);
15304 int vec_any_eqz (vector unsigned int, vector unsigned int);
15306 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
15307 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
15308 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
15309 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
15310 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
15311 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
15313 signed int vec_cntlz_lsbb (vector signed char);
15314 signed int vec_cntlz_lsbb (vector unsigned char);
15316 signed int vec_cnttz_lsbb (vector signed char);
15317 signed int vec_cnttz_lsbb (vector unsigned char);
15319 vector signed char vec_xl_len (signed char *addr, size_t len);
15320 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
15321 vector signed int vec_xl_len (signed int *addr, size_t len);
15322 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
15323 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
15324 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
15325 vector signed long long vec_xl_len (signed long long *addr, size_t len);
15326 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
15327 vector signed short vec_xl_len (signed short *addr, size_t len);
15328 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
15329 vector double vec_xl_len (double *addr, size_t len);
15330 vector float vec_xl_len (float *addr, size_t len);
15332 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
15333 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
15334 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
15335 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
15336 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
15337 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
15338 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
15339 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
15340 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
15341 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
15342 void vec_xst_len (vector double data, double *addr, size_t len);
15343 void vec_xst_len (vector float data, float *addr, size_t len);
15345 signed char vec_xlx (unsigned int index, vector signed char data);
15346 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
15347 signed short vec_xlx (unsigned int index, vector signed short data);
15348 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
15349 signed int vec_xlx (unsigned int index, vector signed int data);
15350 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
15351 float vec_xlx (unsigned int index, vector float data);
15353 signed char vec_xrx (unsigned int index, vector signed char data);
15354 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
15355 signed short vec_xrx (unsigned int index, vector signed short data);
15356 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
15357 signed int vec_xrx (unsigned int index, vector signed int data);
15358 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
15359 float vec_xrx (unsigned int index, vector float data);
15362 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
15363 perform pairwise comparisons between the elements at the same
15364 positions within their two vector arguments.
15365 The @code{vec_all_nez} function returns a
15366 non-zero value if and only if all pairwise comparisons are not
15367 equal and no element of either vector argument contains a zero.
15368 The @code{vec_any_eqz} function returns a
15369 non-zero value if and only if at least one pairwise comparison is equal
15370 or if at least one element of either vector argument contains a zero.
15371 The @code{vec_cmpnez} function returns a vector of the same type as
15372 its two arguments, within which each element consists of all ones to
15373 denote that either the corresponding elements of the incoming arguments are
15374 not equal or that at least one of the corresponding elements contains
15375 zero. Otherwise, the element of the returned vector contains all zeros.
15377 The @code{vec_cntlz_lsbb} function returns the count of the number of
15378 consecutive leading byte elements (starting from position 0 within the
15379 supplied vector argument) for which the least-significant bit
15380 equals zero. The @code{vec_cnttz_lsbb} function returns the count of
15381 the number of consecutive trailing byte elements (starting from
15382 position 15 and counting backwards within the supplied vector
15383 argument) for which the least-significant bit equals zero.
15385 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
15386 64-bit environment supporting ISA 3.0 or later. The @code{vec_xl_len}
15387 function loads a variable length vector from memory. The
15388 @code{vec_xst_len} function stores a variable length vector to memory.
15389 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
15390 @code{addr} argument represents the memory address to or from which
15391 data will be transferred, and the
15392 @code{len} argument represents the number of bytes to be
15393 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
15394 If this expression's value is not a multiple of the vector element's
15395 size, the behavior of this function is undefined.
15396 In the case that the underlying computer is configured to run in
15397 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
15398 the corresponding vector. In little-endian mode, the data transfer
15399 moves bytes @code{(16 - len)} to @code{15} of the corresponding
15400 vector. For the load function, any bytes of the result vector that
15401 are not loaded from memory are set to zero.
15402 The value of the @code{addr} argument need not be aligned on a
15403 multiple of the vector's element size.
15405 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
15406 element selected by the @code{index} argument from the vector
15407 represented by the @code{data} argument. The @code{index} argument
15408 always specifies a byte offset, regardless of the size of the vector
15409 element. With @code{vec_xlx}, @code{index} is the offset of the first
15410 byte of the element to be extracted. With @code{vec_xrx}, @code{index}
15411 represents the last byte of the element to be extracted, measured
15412 from the right end of the vector. In other words, the last byte of
15413 the element to be extracted is found at position @code{(15 - index)}.
15414 There is no requirement that @code{index} be a multiple of the vector
15415 element size. However, if the size of the vector element added to
15416 @code{index} is greater than 15, the content of the returned value is
15419 The following built-in functions are available for the PowerPC family
15420 of processors when hardware decimal floating point
15421 (@option{-mhard-dfp}) is available:
15423 _Decimal64 __builtin_dxex (_Decimal64);
15424 _Decimal128 __builtin_dxexq (_Decimal128);
15425 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15426 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15427 _Decimal64 __builtin_denbcd (int, _Decimal64);
15428 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15429 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
15430 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
15431 _Decimal64 __builtin_dscli (_Decimal64, int);
15432 _Decimal128 __builtin_dscliq (_Decimal128, int);
15433 _Decimal64 __builtin_dscri (_Decimal64, int);
15434 _Decimal128 __builtin_dscriq (_Decimal128, int);
15435 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
15436 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
15439 The following built-in functions are available for the PowerPC family
15440 of processors when the Vector Scalar (vsx) instruction set is
15443 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
15444 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
15445 unsigned long long);
15448 @node PowerPC AltiVec/VSX Built-in Functions
15449 @subsection PowerPC AltiVec Built-in Functions
15451 GCC provides an interface for the PowerPC family of processors to access
15452 the AltiVec operations described in Motorola's AltiVec Programming
15453 Interface Manual. The interface is made available by including
15454 @code{<altivec.h>} and using @option{-maltivec} and
15455 @option{-mabi=altivec}. The interface supports the following vector
15459 vector unsigned char
15463 vector unsigned short
15464 vector signed short
15468 vector unsigned int
15474 If @option{-mvsx} is used the following additional vector types are
15478 vector unsigned long
15483 The long types are only implemented for 64-bit code generation, and
15484 the long type is only used in the floating point/integer conversion
15487 GCC's implementation of the high-level language interface available from
15488 C and C++ code differs from Motorola's documentation in several ways.
15493 A vector constant is a list of constant expressions within curly braces.
15496 A vector initializer requires no cast if the vector constant is of the
15497 same type as the variable it is initializing.
15500 If @code{signed} or @code{unsigned} is omitted, the signedness of the
15501 vector type is the default signedness of the base type. The default
15502 varies depending on the operating system, so a portable program should
15503 always specify the signedness.
15506 Compiling with @option{-maltivec} adds keywords @code{__vector},
15507 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
15508 @code{bool}. When compiling ISO C, the context-sensitive substitution
15509 of the keywords @code{vector}, @code{pixel} and @code{bool} is
15510 disabled. To use them, you must include @code{<altivec.h>} instead.
15513 GCC allows using a @code{typedef} name as the type specifier for a
15517 For C, overloaded functions are implemented with macros so the following
15521 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
15525 Since @code{vec_add} is a macro, the vector constant in the example
15526 is treated as four separate arguments. Wrap the entire argument in
15527 parentheses for this to work.
15530 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
15531 Internally, GCC uses built-in functions to achieve the functionality in
15532 the aforementioned header file, but they are not supported and are
15533 subject to change without notice.
15535 The following interfaces are supported for the generic and specific
15536 AltiVec operations and the AltiVec predicates. In cases where there
15537 is a direct mapping between generic and specific operations, only the
15538 generic names are shown here, although the specific operations can also
15541 Arguments that are documented as @code{const int} require literal
15542 integral values within the range required for that operation.
15545 vector signed char vec_abs (vector signed char);
15546 vector signed short vec_abs (vector signed short);
15547 vector signed int vec_abs (vector signed int);
15548 vector float vec_abs (vector float);
15550 vector signed char vec_abss (vector signed char);
15551 vector signed short vec_abss (vector signed short);
15552 vector signed int vec_abss (vector signed int);
15554 vector signed char vec_add (vector bool char, vector signed char);
15555 vector signed char vec_add (vector signed char, vector bool char);
15556 vector signed char vec_add (vector signed char, vector signed char);
15557 vector unsigned char vec_add (vector bool char, vector unsigned char);
15558 vector unsigned char vec_add (vector unsigned char, vector bool char);
15559 vector unsigned char vec_add (vector unsigned char,
15560 vector unsigned char);
15561 vector signed short vec_add (vector bool short, vector signed short);
15562 vector signed short vec_add (vector signed short, vector bool short);
15563 vector signed short vec_add (vector signed short, vector signed short);
15564 vector unsigned short vec_add (vector bool short,
15565 vector unsigned short);
15566 vector unsigned short vec_add (vector unsigned short,
15567 vector bool short);
15568 vector unsigned short vec_add (vector unsigned short,
15569 vector unsigned short);
15570 vector signed int vec_add (vector bool int, vector signed int);
15571 vector signed int vec_add (vector signed int, vector bool int);
15572 vector signed int vec_add (vector signed int, vector signed int);
15573 vector unsigned int vec_add (vector bool int, vector unsigned int);
15574 vector unsigned int vec_add (vector unsigned int, vector bool int);
15575 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
15576 vector float vec_add (vector float, vector float);
15578 vector float vec_vaddfp (vector float, vector float);
15580 vector signed int vec_vadduwm (vector bool int, vector signed int);
15581 vector signed int vec_vadduwm (vector signed int, vector bool int);
15582 vector signed int vec_vadduwm (vector signed int, vector signed int);
15583 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
15584 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
15585 vector unsigned int vec_vadduwm (vector unsigned int,
15586 vector unsigned int);
15588 vector signed short vec_vadduhm (vector bool short,
15589 vector signed short);
15590 vector signed short vec_vadduhm (vector signed short,
15591 vector bool short);
15592 vector signed short vec_vadduhm (vector signed short,
15593 vector signed short);
15594 vector unsigned short vec_vadduhm (vector bool short,
15595 vector unsigned short);
15596 vector unsigned short vec_vadduhm (vector unsigned short,
15597 vector bool short);
15598 vector unsigned short vec_vadduhm (vector unsigned short,
15599 vector unsigned short);
15601 vector signed char vec_vaddubm (vector bool char, vector signed char);
15602 vector signed char vec_vaddubm (vector signed char, vector bool char);
15603 vector signed char vec_vaddubm (vector signed char, vector signed char);
15604 vector unsigned char vec_vaddubm (vector bool char,
15605 vector unsigned char);
15606 vector unsigned char vec_vaddubm (vector unsigned char,
15608 vector unsigned char vec_vaddubm (vector unsigned char,
15609 vector unsigned char);
15611 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
15613 vector unsigned char vec_adds (vector bool char, vector unsigned char);
15614 vector unsigned char vec_adds (vector unsigned char, vector bool char);
15615 vector unsigned char vec_adds (vector unsigned char,
15616 vector unsigned char);
15617 vector signed char vec_adds (vector bool char, vector signed char);
15618 vector signed char vec_adds (vector signed char, vector bool char);
15619 vector signed char vec_adds (vector signed char, vector signed char);
15620 vector unsigned short vec_adds (vector bool short,
15621 vector unsigned short);
15622 vector unsigned short vec_adds (vector unsigned short,
15623 vector bool short);
15624 vector unsigned short vec_adds (vector unsigned short,
15625 vector unsigned short);
15626 vector signed short vec_adds (vector bool short, vector signed short);
15627 vector signed short vec_adds (vector signed short, vector bool short);
15628 vector signed short vec_adds (vector signed short, vector signed short);
15629 vector unsigned int vec_adds (vector bool int, vector unsigned int);
15630 vector unsigned int vec_adds (vector unsigned int, vector bool int);
15631 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
15632 vector signed int vec_adds (vector bool int, vector signed int);
15633 vector signed int vec_adds (vector signed int, vector bool int);
15634 vector signed int vec_adds (vector signed int, vector signed int);
15636 vector signed int vec_vaddsws (vector bool int, vector signed int);
15637 vector signed int vec_vaddsws (vector signed int, vector bool int);
15638 vector signed int vec_vaddsws (vector signed int, vector signed int);
15640 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
15641 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
15642 vector unsigned int vec_vadduws (vector unsigned int,
15643 vector unsigned int);
15645 vector signed short vec_vaddshs (vector bool short,
15646 vector signed short);
15647 vector signed short vec_vaddshs (vector signed short,
15648 vector bool short);
15649 vector signed short vec_vaddshs (vector signed short,
15650 vector signed short);
15652 vector unsigned short vec_vadduhs (vector bool short,
15653 vector unsigned short);
15654 vector unsigned short vec_vadduhs (vector unsigned short,
15655 vector bool short);
15656 vector unsigned short vec_vadduhs (vector unsigned short,
15657 vector unsigned short);
15659 vector signed char vec_vaddsbs (vector bool char, vector signed char);
15660 vector signed char vec_vaddsbs (vector signed char, vector bool char);
15661 vector signed char vec_vaddsbs (vector signed char, vector signed char);
15663 vector unsigned char vec_vaddubs (vector bool char,
15664 vector unsigned char);
15665 vector unsigned char vec_vaddubs (vector unsigned char,
15667 vector unsigned char vec_vaddubs (vector unsigned char,
15668 vector unsigned char);
15670 vector float vec_and (vector float, vector float);
15671 vector float vec_and (vector float, vector bool int);
15672 vector float vec_and (vector bool int, vector float);
15673 vector bool int vec_and (vector bool int, vector bool int);
15674 vector signed int vec_and (vector bool int, vector signed int);
15675 vector signed int vec_and (vector signed int, vector bool int);
15676 vector signed int vec_and (vector signed int, vector signed int);
15677 vector unsigned int vec_and (vector bool int, vector unsigned int);
15678 vector unsigned int vec_and (vector unsigned int, vector bool int);
15679 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
15680 vector bool short vec_and (vector bool short, vector bool short);
15681 vector signed short vec_and (vector bool short, vector signed short);
15682 vector signed short vec_and (vector signed short, vector bool short);
15683 vector signed short vec_and (vector signed short, vector signed short);
15684 vector unsigned short vec_and (vector bool short,
15685 vector unsigned short);
15686 vector unsigned short vec_and (vector unsigned short,
15687 vector bool short);
15688 vector unsigned short vec_and (vector unsigned short,
15689 vector unsigned short);
15690 vector signed char vec_and (vector bool char, vector signed char);
15691 vector bool char vec_and (vector bool char, vector bool char);
15692 vector signed char vec_and (vector signed char, vector bool char);
15693 vector signed char vec_and (vector signed char, vector signed char);
15694 vector unsigned char vec_and (vector bool char, vector unsigned char);
15695 vector unsigned char vec_and (vector unsigned char, vector bool char);
15696 vector unsigned char vec_and (vector unsigned char,
15697 vector unsigned char);
15699 vector float vec_andc (vector float, vector float);
15700 vector float vec_andc (vector float, vector bool int);
15701 vector float vec_andc (vector bool int, vector float);
15702 vector bool int vec_andc (vector bool int, vector bool int);
15703 vector signed int vec_andc (vector bool int, vector signed int);
15704 vector signed int vec_andc (vector signed int, vector bool int);
15705 vector signed int vec_andc (vector signed int, vector signed int);
15706 vector unsigned int vec_andc (vector bool int, vector unsigned int);
15707 vector unsigned int vec_andc (vector unsigned int, vector bool int);
15708 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
15709 vector bool short vec_andc (vector bool short, vector bool short);
15710 vector signed short vec_andc (vector bool short, vector signed short);
15711 vector signed short vec_andc (vector signed short, vector bool short);
15712 vector signed short vec_andc (vector signed short, vector signed short);
15713 vector unsigned short vec_andc (vector bool short,
15714 vector unsigned short);
15715 vector unsigned short vec_andc (vector unsigned short,
15716 vector bool short);
15717 vector unsigned short vec_andc (vector unsigned short,
15718 vector unsigned short);
15719 vector signed char vec_andc (vector bool char, vector signed char);
15720 vector bool char vec_andc (vector bool char, vector bool char);
15721 vector signed char vec_andc (vector signed char, vector bool char);
15722 vector signed char vec_andc (vector signed char, vector signed char);
15723 vector unsigned char vec_andc (vector bool char, vector unsigned char);
15724 vector unsigned char vec_andc (vector unsigned char, vector bool char);
15725 vector unsigned char vec_andc (vector unsigned char,
15726 vector unsigned char);
15728 vector unsigned char vec_avg (vector unsigned char,
15729 vector unsigned char);
15730 vector signed char vec_avg (vector signed char, vector signed char);
15731 vector unsigned short vec_avg (vector unsigned short,
15732 vector unsigned short);
15733 vector signed short vec_avg (vector signed short, vector signed short);
15734 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
15735 vector signed int vec_avg (vector signed int, vector signed int);
15737 vector signed int vec_vavgsw (vector signed int, vector signed int);
15739 vector unsigned int vec_vavguw (vector unsigned int,
15740 vector unsigned int);
15742 vector signed short vec_vavgsh (vector signed short,
15743 vector signed short);
15745 vector unsigned short vec_vavguh (vector unsigned short,
15746 vector unsigned short);
15748 vector signed char vec_vavgsb (vector signed char, vector signed char);
15750 vector unsigned char vec_vavgub (vector unsigned char,
15751 vector unsigned char);
15753 vector float vec_copysign (vector float);
15755 vector float vec_ceil (vector float);
15757 vector signed int vec_cmpb (vector float, vector float);
15759 vector bool char vec_cmpeq (vector bool char, vector bool char);
15760 vector bool short vec_cmpeq (vector bool short, vector bool short);
15761 vector bool int vec_cmpeq (vector bool int, vector bool int);
15762 vector bool char vec_cmpeq (vector signed char, vector signed char);
15763 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
15764 vector bool short vec_cmpeq (vector signed short, vector signed short);
15765 vector bool short vec_cmpeq (vector unsigned short,
15766 vector unsigned short);
15767 vector bool int vec_cmpeq (vector signed int, vector signed int);
15768 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
15769 vector bool int vec_cmpeq (vector float, vector float);
15771 vector bool int vec_vcmpeqfp (vector float, vector float);
15773 vector bool int vec_vcmpequw (vector signed int, vector signed int);
15774 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
15776 vector bool short vec_vcmpequh (vector signed short,
15777 vector signed short);
15778 vector bool short vec_vcmpequh (vector unsigned short,
15779 vector unsigned short);
15781 vector bool char vec_vcmpequb (vector signed char, vector signed char);
15782 vector bool char vec_vcmpequb (vector unsigned char,
15783 vector unsigned char);
15785 vector bool int vec_cmpge (vector float, vector float);
15787 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
15788 vector bool char vec_cmpgt (vector signed char, vector signed char);
15789 vector bool short vec_cmpgt (vector unsigned short,
15790 vector unsigned short);
15791 vector bool short vec_cmpgt (vector signed short, vector signed short);
15792 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
15793 vector bool int vec_cmpgt (vector signed int, vector signed int);
15794 vector bool int vec_cmpgt (vector float, vector float);
15796 vector bool int vec_vcmpgtfp (vector float, vector float);
15798 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
15800 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
15802 vector bool short vec_vcmpgtsh (vector signed short,
15803 vector signed short);
15805 vector bool short vec_vcmpgtuh (vector unsigned short,
15806 vector unsigned short);
15808 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
15810 vector bool char vec_vcmpgtub (vector unsigned char,
15811 vector unsigned char);
15813 vector bool int vec_cmple (vector float, vector float);
15815 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
15816 vector bool char vec_cmplt (vector signed char, vector signed char);
15817 vector bool short vec_cmplt (vector unsigned short,
15818 vector unsigned short);
15819 vector bool short vec_cmplt (vector signed short, vector signed short);
15820 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
15821 vector bool int vec_cmplt (vector signed int, vector signed int);
15822 vector bool int vec_cmplt (vector float, vector float);
15824 vector float vec_cpsgn (vector float, vector float);
15826 vector float vec_ctf (vector unsigned int, const int);
15827 vector float vec_ctf (vector signed int, const int);
15828 vector double vec_ctf (vector unsigned long, const int);
15829 vector double vec_ctf (vector signed long, const int);
15831 vector float vec_vcfsx (vector signed int, const int);
15833 vector float vec_vcfux (vector unsigned int, const int);
15835 vector signed int vec_cts (vector float, const int);
15836 vector signed long vec_cts (vector double, const int);
15838 vector unsigned int vec_ctu (vector float, const int);
15839 vector unsigned long vec_ctu (vector double, const int);
15841 void vec_dss (const int);
15843 void vec_dssall (void);
15845 void vec_dst (const vector unsigned char *, int, const int);
15846 void vec_dst (const vector signed char *, int, const int);
15847 void vec_dst (const vector bool char *, int, const int);
15848 void vec_dst (const vector unsigned short *, int, const int);
15849 void vec_dst (const vector signed short *, int, const int);
15850 void vec_dst (const vector bool short *, int, const int);
15851 void vec_dst (const vector pixel *, int, const int);
15852 void vec_dst (const vector unsigned int *, int, const int);
15853 void vec_dst (const vector signed int *, int, const int);
15854 void vec_dst (const vector bool int *, int, const int);
15855 void vec_dst (const vector float *, int, const int);
15856 void vec_dst (const unsigned char *, int, const int);
15857 void vec_dst (const signed char *, int, const int);
15858 void vec_dst (const unsigned short *, int, const int);
15859 void vec_dst (const short *, int, const int);
15860 void vec_dst (const unsigned int *, int, const int);
15861 void vec_dst (const int *, int, const int);
15862 void vec_dst (const unsigned long *, int, const int);
15863 void vec_dst (const long *, int, const int);
15864 void vec_dst (const float *, int, const int);
15866 void vec_dstst (const vector unsigned char *, int, const int);
15867 void vec_dstst (const vector signed char *, int, const int);
15868 void vec_dstst (const vector bool char *, int, const int);
15869 void vec_dstst (const vector unsigned short *, int, const int);
15870 void vec_dstst (const vector signed short *, int, const int);
15871 void vec_dstst (const vector bool short *, int, const int);
15872 void vec_dstst (const vector pixel *, int, const int);
15873 void vec_dstst (const vector unsigned int *, int, const int);
15874 void vec_dstst (const vector signed int *, int, const int);
15875 void vec_dstst (const vector bool int *, int, const int);
15876 void vec_dstst (const vector float *, int, const int);
15877 void vec_dstst (const unsigned char *, int, const int);
15878 void vec_dstst (const signed char *, int, const int);
15879 void vec_dstst (const unsigned short *, int, const int);
15880 void vec_dstst (const short *, int, const int);
15881 void vec_dstst (const unsigned int *, int, const int);
15882 void vec_dstst (const int *, int, const int);
15883 void vec_dstst (const unsigned long *, int, const int);
15884 void vec_dstst (const long *, int, const int);
15885 void vec_dstst (const float *, int, const int);
15887 void vec_dststt (const vector unsigned char *, int, const int);
15888 void vec_dststt (const vector signed char *, int, const int);
15889 void vec_dststt (const vector bool char *, int, const int);
15890 void vec_dststt (const vector unsigned short *, int, const int);
15891 void vec_dststt (const vector signed short *, int, const int);
15892 void vec_dststt (const vector bool short *, int, const int);
15893 void vec_dststt (const vector pixel *, int, const int);
15894 void vec_dststt (const vector unsigned int *, int, const int);
15895 void vec_dststt (const vector signed int *, int, const int);
15896 void vec_dststt (const vector bool int *, int, const int);
15897 void vec_dststt (const vector float *, int, const int);
15898 void vec_dststt (const unsigned char *, int, const int);
15899 void vec_dststt (const signed char *, int, const int);
15900 void vec_dststt (const unsigned short *, int, const int);
15901 void vec_dststt (const short *, int, const int);
15902 void vec_dststt (const unsigned int *, int, const int);
15903 void vec_dststt (const int *, int, const int);
15904 void vec_dststt (const unsigned long *, int, const int);
15905 void vec_dststt (const long *, int, const int);
15906 void vec_dststt (const float *, int, const int);
15908 void vec_dstt (const vector unsigned char *, int, const int);
15909 void vec_dstt (const vector signed char *, int, const int);
15910 void vec_dstt (const vector bool char *, int, const int);
15911 void vec_dstt (const vector unsigned short *, int, const int);
15912 void vec_dstt (const vector signed short *, int, const int);
15913 void vec_dstt (const vector bool short *, int, const int);
15914 void vec_dstt (const vector pixel *, int, const int);
15915 void vec_dstt (const vector unsigned int *, int, const int);
15916 void vec_dstt (const vector signed int *, int, const int);
15917 void vec_dstt (const vector bool int *, int, const int);
15918 void vec_dstt (const vector float *, int, const int);
15919 void vec_dstt (const unsigned char *, int, const int);
15920 void vec_dstt (const signed char *, int, const int);
15921 void vec_dstt (const unsigned short *, int, const int);
15922 void vec_dstt (const short *, int, const int);
15923 void vec_dstt (const unsigned int *, int, const int);
15924 void vec_dstt (const int *, int, const int);
15925 void vec_dstt (const unsigned long *, int, const int);
15926 void vec_dstt (const long *, int, const int);
15927 void vec_dstt (const float *, int, const int);
15929 vector float vec_expte (vector float);
15931 vector float vec_floor (vector float);
15933 vector float vec_ld (int, const vector float *);
15934 vector float vec_ld (int, const float *);
15935 vector bool int vec_ld (int, const vector bool int *);
15936 vector signed int vec_ld (int, const vector signed int *);
15937 vector signed int vec_ld (int, const int *);
15938 vector signed int vec_ld (int, const long *);
15939 vector unsigned int vec_ld (int, const vector unsigned int *);
15940 vector unsigned int vec_ld (int, const unsigned int *);
15941 vector unsigned int vec_ld (int, const unsigned long *);
15942 vector bool short vec_ld (int, const vector bool short *);
15943 vector pixel vec_ld (int, const vector pixel *);
15944 vector signed short vec_ld (int, const vector signed short *);
15945 vector signed short vec_ld (int, const short *);
15946 vector unsigned short vec_ld (int, const vector unsigned short *);
15947 vector unsigned short vec_ld (int, const unsigned short *);
15948 vector bool char vec_ld (int, const vector bool char *);
15949 vector signed char vec_ld (int, const vector signed char *);
15950 vector signed char vec_ld (int, const signed char *);
15951 vector unsigned char vec_ld (int, const vector unsigned char *);
15952 vector unsigned char vec_ld (int, const unsigned char *);
15954 vector signed char vec_lde (int, const signed char *);
15955 vector unsigned char vec_lde (int, const unsigned char *);
15956 vector signed short vec_lde (int, const short *);
15957 vector unsigned short vec_lde (int, const unsigned short *);
15958 vector float vec_lde (int, const float *);
15959 vector signed int vec_lde (int, const int *);
15960 vector unsigned int vec_lde (int, const unsigned int *);
15961 vector signed int vec_lde (int, const long *);
15962 vector unsigned int vec_lde (int, const unsigned long *);
15964 vector float vec_lvewx (int, float *);
15965 vector signed int vec_lvewx (int, int *);
15966 vector unsigned int vec_lvewx (int, unsigned int *);
15967 vector signed int vec_lvewx (int, long *);
15968 vector unsigned int vec_lvewx (int, unsigned long *);
15970 vector signed short vec_lvehx (int, short *);
15971 vector unsigned short vec_lvehx (int, unsigned short *);
15973 vector signed char vec_lvebx (int, char *);
15974 vector unsigned char vec_lvebx (int, unsigned char *);
15976 vector float vec_ldl (int, const vector float *);
15977 vector float vec_ldl (int, const float *);
15978 vector bool int vec_ldl (int, const vector bool int *);
15979 vector signed int vec_ldl (int, const vector signed int *);
15980 vector signed int vec_ldl (int, const int *);
15981 vector signed int vec_ldl (int, const long *);
15982 vector unsigned int vec_ldl (int, const vector unsigned int *);
15983 vector unsigned int vec_ldl (int, const unsigned int *);
15984 vector unsigned int vec_ldl (int, const unsigned long *);
15985 vector bool short vec_ldl (int, const vector bool short *);
15986 vector pixel vec_ldl (int, const vector pixel *);
15987 vector signed short vec_ldl (int, const vector signed short *);
15988 vector signed short vec_ldl (int, const short *);
15989 vector unsigned short vec_ldl (int, const vector unsigned short *);
15990 vector unsigned short vec_ldl (int, const unsigned short *);
15991 vector bool char vec_ldl (int, const vector bool char *);
15992 vector signed char vec_ldl (int, const vector signed char *);
15993 vector signed char vec_ldl (int, const signed char *);
15994 vector unsigned char vec_ldl (int, const vector unsigned char *);
15995 vector unsigned char vec_ldl (int, const unsigned char *);
15997 vector float vec_loge (vector float);
15999 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
16000 vector unsigned char vec_lvsl (int, const volatile signed char *);
16001 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
16002 vector unsigned char vec_lvsl (int, const volatile short *);
16003 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
16004 vector unsigned char vec_lvsl (int, const volatile int *);
16005 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
16006 vector unsigned char vec_lvsl (int, const volatile long *);
16007 vector unsigned char vec_lvsl (int, const volatile float *);
16009 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
16010 vector unsigned char vec_lvsr (int, const volatile signed char *);
16011 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
16012 vector unsigned char vec_lvsr (int, const volatile short *);
16013 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
16014 vector unsigned char vec_lvsr (int, const volatile int *);
16015 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
16016 vector unsigned char vec_lvsr (int, const volatile long *);
16017 vector unsigned char vec_lvsr (int, const volatile float *);
16019 vector float vec_madd (vector float, vector float, vector float);
16021 vector signed short vec_madds (vector signed short,
16022 vector signed short,
16023 vector signed short);
16025 vector unsigned char vec_max (vector bool char, vector unsigned char);
16026 vector unsigned char vec_max (vector unsigned char, vector bool char);
16027 vector unsigned char vec_max (vector unsigned char,
16028 vector unsigned char);
16029 vector signed char vec_max (vector bool char, vector signed char);
16030 vector signed char vec_max (vector signed char, vector bool char);
16031 vector signed char vec_max (vector signed char, vector signed char);
16032 vector unsigned short vec_max (vector bool short,
16033 vector unsigned short);
16034 vector unsigned short vec_max (vector unsigned short,
16035 vector bool short);
16036 vector unsigned short vec_max (vector unsigned short,
16037 vector unsigned short);
16038 vector signed short vec_max (vector bool short, vector signed short);
16039 vector signed short vec_max (vector signed short, vector bool short);
16040 vector signed short vec_max (vector signed short, vector signed short);
16041 vector unsigned int vec_max (vector bool int, vector unsigned int);
16042 vector unsigned int vec_max (vector unsigned int, vector bool int);
16043 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
16044 vector signed int vec_max (vector bool int, vector signed int);
16045 vector signed int vec_max (vector signed int, vector bool int);
16046 vector signed int vec_max (vector signed int, vector signed int);
16047 vector float vec_max (vector float, vector float);
16049 vector float vec_vmaxfp (vector float, vector float);
16051 vector signed int vec_vmaxsw (vector bool int, vector signed int);
16052 vector signed int vec_vmaxsw (vector signed int, vector bool int);
16053 vector signed int vec_vmaxsw (vector signed int, vector signed int);
16055 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
16056 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
16057 vector unsigned int vec_vmaxuw (vector unsigned int,
16058 vector unsigned int);
16060 vector signed short vec_vmaxsh (vector bool short, vector signed short);
16061 vector signed short vec_vmaxsh (vector signed short, vector bool short);
16062 vector signed short vec_vmaxsh (vector signed short,
16063 vector signed short);
16065 vector unsigned short vec_vmaxuh (vector bool short,
16066 vector unsigned short);
16067 vector unsigned short vec_vmaxuh (vector unsigned short,
16068 vector bool short);
16069 vector unsigned short vec_vmaxuh (vector unsigned short,
16070 vector unsigned short);
16072 vector signed char vec_vmaxsb (vector bool char, vector signed char);
16073 vector signed char vec_vmaxsb (vector signed char, vector bool char);
16074 vector signed char vec_vmaxsb (vector signed char, vector signed char);
16076 vector unsigned char vec_vmaxub (vector bool char,
16077 vector unsigned char);
16078 vector unsigned char vec_vmaxub (vector unsigned char,
16080 vector unsigned char vec_vmaxub (vector unsigned char,
16081 vector unsigned char);
16083 vector bool char vec_mergeh (vector bool char, vector bool char);
16084 vector signed char vec_mergeh (vector signed char, vector signed char);
16085 vector unsigned char vec_mergeh (vector unsigned char,
16086 vector unsigned char);
16087 vector bool short vec_mergeh (vector bool short, vector bool short);
16088 vector pixel vec_mergeh (vector pixel, vector pixel);
16089 vector signed short vec_mergeh (vector signed short,
16090 vector signed short);
16091 vector unsigned short vec_mergeh (vector unsigned short,
16092 vector unsigned short);
16093 vector float vec_mergeh (vector float, vector float);
16094 vector bool int vec_mergeh (vector bool int, vector bool int);
16095 vector signed int vec_mergeh (vector signed int, vector signed int);
16096 vector unsigned int vec_mergeh (vector unsigned int,
16097 vector unsigned int);
16099 vector float vec_vmrghw (vector float, vector float);
16100 vector bool int vec_vmrghw (vector bool int, vector bool int);
16101 vector signed int vec_vmrghw (vector signed int, vector signed int);
16102 vector unsigned int vec_vmrghw (vector unsigned int,
16103 vector unsigned int);
16105 vector bool short vec_vmrghh (vector bool short, vector bool short);
16106 vector signed short vec_vmrghh (vector signed short,
16107 vector signed short);
16108 vector unsigned short vec_vmrghh (vector unsigned short,
16109 vector unsigned short);
16110 vector pixel vec_vmrghh (vector pixel, vector pixel);
16112 vector bool char vec_vmrghb (vector bool char, vector bool char);
16113 vector signed char vec_vmrghb (vector signed char, vector signed char);
16114 vector unsigned char vec_vmrghb (vector unsigned char,
16115 vector unsigned char);
16117 vector bool char vec_mergel (vector bool char, vector bool char);
16118 vector signed char vec_mergel (vector signed char, vector signed char);
16119 vector unsigned char vec_mergel (vector unsigned char,
16120 vector unsigned char);
16121 vector bool short vec_mergel (vector bool short, vector bool short);
16122 vector pixel vec_mergel (vector pixel, vector pixel);
16123 vector signed short vec_mergel (vector signed short,
16124 vector signed short);
16125 vector unsigned short vec_mergel (vector unsigned short,
16126 vector unsigned short);
16127 vector float vec_mergel (vector float, vector float);
16128 vector bool int vec_mergel (vector bool int, vector bool int);
16129 vector signed int vec_mergel (vector signed int, vector signed int);
16130 vector unsigned int vec_mergel (vector unsigned int,
16131 vector unsigned int);
16133 vector float vec_vmrglw (vector float, vector float);
16134 vector signed int vec_vmrglw (vector signed int, vector signed int);
16135 vector unsigned int vec_vmrglw (vector unsigned int,
16136 vector unsigned int);
16137 vector bool int vec_vmrglw (vector bool int, vector bool int);
16139 vector bool short vec_vmrglh (vector bool short, vector bool short);
16140 vector signed short vec_vmrglh (vector signed short,
16141 vector signed short);
16142 vector unsigned short vec_vmrglh (vector unsigned short,
16143 vector unsigned short);
16144 vector pixel vec_vmrglh (vector pixel, vector pixel);
16146 vector bool char vec_vmrglb (vector bool char, vector bool char);
16147 vector signed char vec_vmrglb (vector signed char, vector signed char);
16148 vector unsigned char vec_vmrglb (vector unsigned char,
16149 vector unsigned char);
16151 vector unsigned short vec_mfvscr (void);
16153 vector unsigned char vec_min (vector bool char, vector unsigned char);
16154 vector unsigned char vec_min (vector unsigned char, vector bool char);
16155 vector unsigned char vec_min (vector unsigned char,
16156 vector unsigned char);
16157 vector signed char vec_min (vector bool char, vector signed char);
16158 vector signed char vec_min (vector signed char, vector bool char);
16159 vector signed char vec_min (vector signed char, vector signed char);
16160 vector unsigned short vec_min (vector bool short,
16161 vector unsigned short);
16162 vector unsigned short vec_min (vector unsigned short,
16163 vector bool short);
16164 vector unsigned short vec_min (vector unsigned short,
16165 vector unsigned short);
16166 vector signed short vec_min (vector bool short, vector signed short);
16167 vector signed short vec_min (vector signed short, vector bool short);
16168 vector signed short vec_min (vector signed short, vector signed short);
16169 vector unsigned int vec_min (vector bool int, vector unsigned int);
16170 vector unsigned int vec_min (vector unsigned int, vector bool int);
16171 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
16172 vector signed int vec_min (vector bool int, vector signed int);
16173 vector signed int vec_min (vector signed int, vector bool int);
16174 vector signed int vec_min (vector signed int, vector signed int);
16175 vector float vec_min (vector float, vector float);
16177 vector float vec_vminfp (vector float, vector float);
16179 vector signed int vec_vminsw (vector bool int, vector signed int);
16180 vector signed int vec_vminsw (vector signed int, vector bool int);
16181 vector signed int vec_vminsw (vector signed int, vector signed int);
16183 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
16184 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
16185 vector unsigned int vec_vminuw (vector unsigned int,
16186 vector unsigned int);
16188 vector signed short vec_vminsh (vector bool short, vector signed short);
16189 vector signed short vec_vminsh (vector signed short, vector bool short);
16190 vector signed short vec_vminsh (vector signed short,
16191 vector signed short);
16193 vector unsigned short vec_vminuh (vector bool short,
16194 vector unsigned short);
16195 vector unsigned short vec_vminuh (vector unsigned short,
16196 vector bool short);
16197 vector unsigned short vec_vminuh (vector unsigned short,
16198 vector unsigned short);
16200 vector signed char vec_vminsb (vector bool char, vector signed char);
16201 vector signed char vec_vminsb (vector signed char, vector bool char);
16202 vector signed char vec_vminsb (vector signed char, vector signed char);
16204 vector unsigned char vec_vminub (vector bool char,
16205 vector unsigned char);
16206 vector unsigned char vec_vminub (vector unsigned char,
16208 vector unsigned char vec_vminub (vector unsigned char,
16209 vector unsigned char);
16211 vector signed short vec_mladd (vector signed short,
16212 vector signed short,
16213 vector signed short);
16214 vector signed short vec_mladd (vector signed short,
16215 vector unsigned short,
16216 vector unsigned short);
16217 vector signed short vec_mladd (vector unsigned short,
16218 vector signed short,
16219 vector signed short);
16220 vector unsigned short vec_mladd (vector unsigned short,
16221 vector unsigned short,
16222 vector unsigned short);
16224 vector signed short vec_mradds (vector signed short,
16225 vector signed short,
16226 vector signed short);
16228 vector unsigned int vec_msum (vector unsigned char,
16229 vector unsigned char,
16230 vector unsigned int);
16231 vector signed int vec_msum (vector signed char,
16232 vector unsigned char,
16233 vector signed int);
16234 vector unsigned int vec_msum (vector unsigned short,
16235 vector unsigned short,
16236 vector unsigned int);
16237 vector signed int vec_msum (vector signed short,
16238 vector signed short,
16239 vector signed int);
16241 vector signed int vec_vmsumshm (vector signed short,
16242 vector signed short,
16243 vector signed int);
16245 vector unsigned int vec_vmsumuhm (vector unsigned short,
16246 vector unsigned short,
16247 vector unsigned int);
16249 vector signed int vec_vmsummbm (vector signed char,
16250 vector unsigned char,
16251 vector signed int);
16253 vector unsigned int vec_vmsumubm (vector unsigned char,
16254 vector unsigned char,
16255 vector unsigned int);
16257 vector unsigned int vec_msums (vector unsigned short,
16258 vector unsigned short,
16259 vector unsigned int);
16260 vector signed int vec_msums (vector signed short,
16261 vector signed short,
16262 vector signed int);
16264 vector signed int vec_vmsumshs (vector signed short,
16265 vector signed short,
16266 vector signed int);
16268 vector unsigned int vec_vmsumuhs (vector unsigned short,
16269 vector unsigned short,
16270 vector unsigned int);
16272 void vec_mtvscr (vector signed int);
16273 void vec_mtvscr (vector unsigned int);
16274 void vec_mtvscr (vector bool int);
16275 void vec_mtvscr (vector signed short);
16276 void vec_mtvscr (vector unsigned short);
16277 void vec_mtvscr (vector bool short);
16278 void vec_mtvscr (vector pixel);
16279 void vec_mtvscr (vector signed char);
16280 void vec_mtvscr (vector unsigned char);
16281 void vec_mtvscr (vector bool char);
16283 vector unsigned short vec_mule (vector unsigned char,
16284 vector unsigned char);
16285 vector signed short vec_mule (vector signed char,
16286 vector signed char);
16287 vector unsigned int vec_mule (vector unsigned short,
16288 vector unsigned short);
16289 vector signed int vec_mule (vector signed short, vector signed short);
16291 vector signed int vec_vmulesh (vector signed short,
16292 vector signed short);
16294 vector unsigned int vec_vmuleuh (vector unsigned short,
16295 vector unsigned short);
16297 vector signed short vec_vmulesb (vector signed char,
16298 vector signed char);
16300 vector unsigned short vec_vmuleub (vector unsigned char,
16301 vector unsigned char);
16303 vector unsigned short vec_mulo (vector unsigned char,
16304 vector unsigned char);
16305 vector signed short vec_mulo (vector signed char, vector signed char);
16306 vector unsigned int vec_mulo (vector unsigned short,
16307 vector unsigned short);
16308 vector signed int vec_mulo (vector signed short, vector signed short);
16310 vector signed int vec_vmulosh (vector signed short,
16311 vector signed short);
16313 vector unsigned int vec_vmulouh (vector unsigned short,
16314 vector unsigned short);
16316 vector signed short vec_vmulosb (vector signed char,
16317 vector signed char);
16319 vector unsigned short vec_vmuloub (vector unsigned char,
16320 vector unsigned char);
16322 vector float vec_nmsub (vector float, vector float, vector float);
16324 vector signed char vec_nabs (vector signed char);
16325 vector signed short vec_nabs (vector signed short);
16326 vector signed int vec_nabs (vector signed int);
16327 vector float vec_nabs (vector float);
16328 vector double vec_nabs (vector double);
16330 vector float vec_nor (vector float, vector float);
16331 vector signed int vec_nor (vector signed int, vector signed int);
16332 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
16333 vector bool int vec_nor (vector bool int, vector bool int);
16334 vector signed short vec_nor (vector signed short, vector signed short);
16335 vector unsigned short vec_nor (vector unsigned short,
16336 vector unsigned short);
16337 vector bool short vec_nor (vector bool short, vector bool short);
16338 vector signed char vec_nor (vector signed char, vector signed char);
16339 vector unsigned char vec_nor (vector unsigned char,
16340 vector unsigned char);
16341 vector bool char vec_nor (vector bool char, vector bool char);
16343 vector float vec_or (vector float, vector float);
16344 vector float vec_or (vector float, vector bool int);
16345 vector float vec_or (vector bool int, vector float);
16346 vector bool int vec_or (vector bool int, vector bool int);
16347 vector signed int vec_or (vector bool int, vector signed int);
16348 vector signed int vec_or (vector signed int, vector bool int);
16349 vector signed int vec_or (vector signed int, vector signed int);
16350 vector unsigned int vec_or (vector bool int, vector unsigned int);
16351 vector unsigned int vec_or (vector unsigned int, vector bool int);
16352 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
16353 vector bool short vec_or (vector bool short, vector bool short);
16354 vector signed short vec_or (vector bool short, vector signed short);
16355 vector signed short vec_or (vector signed short, vector bool short);
16356 vector signed short vec_or (vector signed short, vector signed short);
16357 vector unsigned short vec_or (vector bool short, vector unsigned short);
16358 vector unsigned short vec_or (vector unsigned short, vector bool short);
16359 vector unsigned short vec_or (vector unsigned short,
16360 vector unsigned short);
16361 vector signed char vec_or (vector bool char, vector signed char);
16362 vector bool char vec_or (vector bool char, vector bool char);
16363 vector signed char vec_or (vector signed char, vector bool char);
16364 vector signed char vec_or (vector signed char, vector signed char);
16365 vector unsigned char vec_or (vector bool char, vector unsigned char);
16366 vector unsigned char vec_or (vector unsigned char, vector bool char);
16367 vector unsigned char vec_or (vector unsigned char,
16368 vector unsigned char);
16370 vector signed char vec_pack (vector signed short, vector signed short);
16371 vector unsigned char vec_pack (vector unsigned short,
16372 vector unsigned short);
16373 vector bool char vec_pack (vector bool short, vector bool short);
16374 vector signed short vec_pack (vector signed int, vector signed int);
16375 vector unsigned short vec_pack (vector unsigned int,
16376 vector unsigned int);
16377 vector bool short vec_pack (vector bool int, vector bool int);
16379 vector bool short vec_vpkuwum (vector bool int, vector bool int);
16380 vector signed short vec_vpkuwum (vector signed int, vector signed int);
16381 vector unsigned short vec_vpkuwum (vector unsigned int,
16382 vector unsigned int);
16384 vector bool char vec_vpkuhum (vector bool short, vector bool short);
16385 vector signed char vec_vpkuhum (vector signed short,
16386 vector signed short);
16387 vector unsigned char vec_vpkuhum (vector unsigned short,
16388 vector unsigned short);
16390 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
16392 vector unsigned char vec_packs (vector unsigned short,
16393 vector unsigned short);
16394 vector signed char vec_packs (vector signed short, vector signed short);
16395 vector unsigned short vec_packs (vector unsigned int,
16396 vector unsigned int);
16397 vector signed short vec_packs (vector signed int, vector signed int);
16399 vector signed short vec_vpkswss (vector signed int, vector signed int);
16401 vector unsigned short vec_vpkuwus (vector unsigned int,
16402 vector unsigned int);
16404 vector signed char vec_vpkshss (vector signed short,
16405 vector signed short);
16407 vector unsigned char vec_vpkuhus (vector unsigned short,
16408 vector unsigned short);
16410 vector unsigned char vec_packsu (vector unsigned short,
16411 vector unsigned short);
16412 vector unsigned char vec_packsu (vector signed short,
16413 vector signed short);
16414 vector unsigned short vec_packsu (vector unsigned int,
16415 vector unsigned int);
16416 vector unsigned short vec_packsu (vector signed int, vector signed int);
16418 vector unsigned short vec_vpkswus (vector signed int,
16419 vector signed int);
16421 vector unsigned char vec_vpkshus (vector signed short,
16422 vector signed short);
16424 vector float vec_perm (vector float,
16426 vector unsigned char);
16427 vector signed int vec_perm (vector signed int,
16429 vector unsigned char);
16430 vector unsigned int vec_perm (vector unsigned int,
16431 vector unsigned int,
16432 vector unsigned char);
16433 vector bool int vec_perm (vector bool int,
16435 vector unsigned char);
16436 vector signed short vec_perm (vector signed short,
16437 vector signed short,
16438 vector unsigned char);
16439 vector unsigned short vec_perm (vector unsigned short,
16440 vector unsigned short,
16441 vector unsigned char);
16442 vector bool short vec_perm (vector bool short,
16444 vector unsigned char);
16445 vector pixel vec_perm (vector pixel,
16447 vector unsigned char);
16448 vector signed char vec_perm (vector signed char,
16449 vector signed char,
16450 vector unsigned char);
16451 vector unsigned char vec_perm (vector unsigned char,
16452 vector unsigned char,
16453 vector unsigned char);
16454 vector bool char vec_perm (vector bool char,
16456 vector unsigned char);
16458 vector float vec_re (vector float);
16460 vector signed char vec_rl (vector signed char,
16461 vector unsigned char);
16462 vector unsigned char vec_rl (vector unsigned char,
16463 vector unsigned char);
16464 vector signed short vec_rl (vector signed short, vector unsigned short);
16465 vector unsigned short vec_rl (vector unsigned short,
16466 vector unsigned short);
16467 vector signed int vec_rl (vector signed int, vector unsigned int);
16468 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
16470 vector signed int vec_vrlw (vector signed int, vector unsigned int);
16471 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
16473 vector signed short vec_vrlh (vector signed short,
16474 vector unsigned short);
16475 vector unsigned short vec_vrlh (vector unsigned short,
16476 vector unsigned short);
16478 vector signed char vec_vrlb (vector signed char, vector unsigned char);
16479 vector unsigned char vec_vrlb (vector unsigned char,
16480 vector unsigned char);
16482 vector float vec_round (vector float);
16484 vector float vec_recip (vector float, vector float);
16486 vector float vec_rsqrt (vector float);
16488 vector float vec_rsqrte (vector float);
16490 vector float vec_sel (vector float, vector float, vector bool int);
16491 vector float vec_sel (vector float, vector float, vector unsigned int);
16492 vector signed int vec_sel (vector signed int,
16495 vector signed int vec_sel (vector signed int,
16497 vector unsigned int);
16498 vector unsigned int vec_sel (vector unsigned int,
16499 vector unsigned int,
16501 vector unsigned int vec_sel (vector unsigned int,
16502 vector unsigned int,
16503 vector unsigned int);
16504 vector bool int vec_sel (vector bool int,
16507 vector bool int vec_sel (vector bool int,
16509 vector unsigned int);
16510 vector signed short vec_sel (vector signed short,
16511 vector signed short,
16512 vector bool short);
16513 vector signed short vec_sel (vector signed short,
16514 vector signed short,
16515 vector unsigned short);
16516 vector unsigned short vec_sel (vector unsigned short,
16517 vector unsigned short,
16518 vector bool short);
16519 vector unsigned short vec_sel (vector unsigned short,
16520 vector unsigned short,
16521 vector unsigned short);
16522 vector bool short vec_sel (vector bool short,
16524 vector bool short);
16525 vector bool short vec_sel (vector bool short,
16527 vector unsigned short);
16528 vector signed char vec_sel (vector signed char,
16529 vector signed char,
16531 vector signed char vec_sel (vector signed char,
16532 vector signed char,
16533 vector unsigned char);
16534 vector unsigned char vec_sel (vector unsigned char,
16535 vector unsigned char,
16537 vector unsigned char vec_sel (vector unsigned char,
16538 vector unsigned char,
16539 vector unsigned char);
16540 vector bool char vec_sel (vector bool char,
16543 vector bool char vec_sel (vector bool char,
16545 vector unsigned char);
16547 vector signed char vec_sl (vector signed char,
16548 vector unsigned char);
16549 vector unsigned char vec_sl (vector unsigned char,
16550 vector unsigned char);
16551 vector signed short vec_sl (vector signed short, vector unsigned short);
16552 vector unsigned short vec_sl (vector unsigned short,
16553 vector unsigned short);
16554 vector signed int vec_sl (vector signed int, vector unsigned int);
16555 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
16557 vector signed int vec_vslw (vector signed int, vector unsigned int);
16558 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
16560 vector signed short vec_vslh (vector signed short,
16561 vector unsigned short);
16562 vector unsigned short vec_vslh (vector unsigned short,
16563 vector unsigned short);
16565 vector signed char vec_vslb (vector signed char, vector unsigned char);
16566 vector unsigned char vec_vslb (vector unsigned char,
16567 vector unsigned char);
16569 vector float vec_sld (vector float, vector float, const int);
16570 vector double vec_sld (vector double, vector double, const int);
16572 vector signed int vec_sld (vector signed int,
16575 vector unsigned int vec_sld (vector unsigned int,
16576 vector unsigned int,
16578 vector bool int vec_sld (vector bool int,
16581 vector signed short vec_sld (vector signed short,
16582 vector signed short,
16584 vector unsigned short vec_sld (vector unsigned short,
16585 vector unsigned short,
16587 vector bool short vec_sld (vector bool short,
16590 vector pixel vec_sld (vector pixel,
16593 vector signed char vec_sld (vector signed char,
16594 vector signed char,
16596 vector unsigned char vec_sld (vector unsigned char,
16597 vector unsigned char,
16599 vector bool char vec_sld (vector bool char,
16603 vector signed int vec_sll (vector signed int,
16604 vector unsigned int);
16605 vector signed int vec_sll (vector signed int,
16606 vector unsigned short);
16607 vector signed int vec_sll (vector signed int,
16608 vector unsigned char);
16609 vector unsigned int vec_sll (vector unsigned int,
16610 vector unsigned int);
16611 vector unsigned int vec_sll (vector unsigned int,
16612 vector unsigned short);
16613 vector unsigned int vec_sll (vector unsigned int,
16614 vector unsigned char);
16615 vector bool int vec_sll (vector bool int,
16616 vector unsigned int);
16617 vector bool int vec_sll (vector bool int,
16618 vector unsigned short);
16619 vector bool int vec_sll (vector bool int,
16620 vector unsigned char);
16621 vector signed short vec_sll (vector signed short,
16622 vector unsigned int);
16623 vector signed short vec_sll (vector signed short,
16624 vector unsigned short);
16625 vector signed short vec_sll (vector signed short,
16626 vector unsigned char);
16627 vector unsigned short vec_sll (vector unsigned short,
16628 vector unsigned int);
16629 vector unsigned short vec_sll (vector unsigned short,
16630 vector unsigned short);
16631 vector unsigned short vec_sll (vector unsigned short,
16632 vector unsigned char);
16633 vector bool short vec_sll (vector bool short, vector unsigned int);
16634 vector bool short vec_sll (vector bool short, vector unsigned short);
16635 vector bool short vec_sll (vector bool short, vector unsigned char);
16636 vector pixel vec_sll (vector pixel, vector unsigned int);
16637 vector pixel vec_sll (vector pixel, vector unsigned short);
16638 vector pixel vec_sll (vector pixel, vector unsigned char);
16639 vector signed char vec_sll (vector signed char, vector unsigned int);
16640 vector signed char vec_sll (vector signed char, vector unsigned short);
16641 vector signed char vec_sll (vector signed char, vector unsigned char);
16642 vector unsigned char vec_sll (vector unsigned char,
16643 vector unsigned int);
16644 vector unsigned char vec_sll (vector unsigned char,
16645 vector unsigned short);
16646 vector unsigned char vec_sll (vector unsigned char,
16647 vector unsigned char);
16648 vector bool char vec_sll (vector bool char, vector unsigned int);
16649 vector bool char vec_sll (vector bool char, vector unsigned short);
16650 vector bool char vec_sll (vector bool char, vector unsigned char);
16652 vector float vec_slo (vector float, vector signed char);
16653 vector float vec_slo (vector float, vector unsigned char);
16654 vector signed int vec_slo (vector signed int, vector signed char);
16655 vector signed int vec_slo (vector signed int, vector unsigned char);
16656 vector unsigned int vec_slo (vector unsigned int, vector signed char);
16657 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
16658 vector signed short vec_slo (vector signed short, vector signed char);
16659 vector signed short vec_slo (vector signed short, vector unsigned char);
16660 vector unsigned short vec_slo (vector unsigned short,
16661 vector signed char);
16662 vector unsigned short vec_slo (vector unsigned short,
16663 vector unsigned char);
16664 vector pixel vec_slo (vector pixel, vector signed char);
16665 vector pixel vec_slo (vector pixel, vector unsigned char);
16666 vector signed char vec_slo (vector signed char, vector signed char);
16667 vector signed char vec_slo (vector signed char, vector unsigned char);
16668 vector unsigned char vec_slo (vector unsigned char, vector signed char);
16669 vector unsigned char vec_slo (vector unsigned char,
16670 vector unsigned char);
16672 vector signed char vec_splat (vector signed char, const int);
16673 vector unsigned char vec_splat (vector unsigned char, const int);
16674 vector bool char vec_splat (vector bool char, const int);
16675 vector signed short vec_splat (vector signed short, const int);
16676 vector unsigned short vec_splat (vector unsigned short, const int);
16677 vector bool short vec_splat (vector bool short, const int);
16678 vector pixel vec_splat (vector pixel, const int);
16679 vector float vec_splat (vector float, const int);
16680 vector signed int vec_splat (vector signed int, const int);
16681 vector unsigned int vec_splat (vector unsigned int, const int);
16682 vector bool int vec_splat (vector bool int, const int);
16683 vector signed long vec_splat (vector signed long, const int);
16684 vector unsigned long vec_splat (vector unsigned long, const int);
16686 vector signed char vec_splats (signed char);
16687 vector unsigned char vec_splats (unsigned char);
16688 vector signed short vec_splats (signed short);
16689 vector unsigned short vec_splats (unsigned short);
16690 vector signed int vec_splats (signed int);
16691 vector unsigned int vec_splats (unsigned int);
16692 vector float vec_splats (float);
16694 vector float vec_vspltw (vector float, const int);
16695 vector signed int vec_vspltw (vector signed int, const int);
16696 vector unsigned int vec_vspltw (vector unsigned int, const int);
16697 vector bool int vec_vspltw (vector bool int, const int);
16699 vector bool short vec_vsplth (vector bool short, const int);
16700 vector signed short vec_vsplth (vector signed short, const int);
16701 vector unsigned short vec_vsplth (vector unsigned short, const int);
16702 vector pixel vec_vsplth (vector pixel, const int);
16704 vector signed char vec_vspltb (vector signed char, const int);
16705 vector unsigned char vec_vspltb (vector unsigned char, const int);
16706 vector bool char vec_vspltb (vector bool char, const int);
16708 vector signed char vec_splat_s8 (const int);
16710 vector signed short vec_splat_s16 (const int);
16712 vector signed int vec_splat_s32 (const int);
16714 vector unsigned char vec_splat_u8 (const int);
16716 vector unsigned short vec_splat_u16 (const int);
16718 vector unsigned int vec_splat_u32 (const int);
16720 vector signed char vec_sr (vector signed char, vector unsigned char);
16721 vector unsigned char vec_sr (vector unsigned char,
16722 vector unsigned char);
16723 vector signed short vec_sr (vector signed short,
16724 vector unsigned short);
16725 vector unsigned short vec_sr (vector unsigned short,
16726 vector unsigned short);
16727 vector signed int vec_sr (vector signed int, vector unsigned int);
16728 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
16730 vector signed int vec_vsrw (vector signed int, vector unsigned int);
16731 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
16733 vector signed short vec_vsrh (vector signed short,
16734 vector unsigned short);
16735 vector unsigned short vec_vsrh (vector unsigned short,
16736 vector unsigned short);
16738 vector signed char vec_vsrb (vector signed char, vector unsigned char);
16739 vector unsigned char vec_vsrb (vector unsigned char,
16740 vector unsigned char);
16742 vector signed char vec_sra (vector signed char, vector unsigned char);
16743 vector unsigned char vec_sra (vector unsigned char,
16744 vector unsigned char);
16745 vector signed short vec_sra (vector signed short,
16746 vector unsigned short);
16747 vector unsigned short vec_sra (vector unsigned short,
16748 vector unsigned short);
16749 vector signed int vec_sra (vector signed int, vector unsigned int);
16750 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
16752 vector signed int vec_vsraw (vector signed int, vector unsigned int);
16753 vector unsigned int vec_vsraw (vector unsigned int,
16754 vector unsigned int);
16756 vector signed short vec_vsrah (vector signed short,
16757 vector unsigned short);
16758 vector unsigned short vec_vsrah (vector unsigned short,
16759 vector unsigned short);
16761 vector signed char vec_vsrab (vector signed char, vector unsigned char);
16762 vector unsigned char vec_vsrab (vector unsigned char,
16763 vector unsigned char);
16765 vector signed int vec_srl (vector signed int, vector unsigned int);
16766 vector signed int vec_srl (vector signed int, vector unsigned short);
16767 vector signed int vec_srl (vector signed int, vector unsigned char);
16768 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
16769 vector unsigned int vec_srl (vector unsigned int,
16770 vector unsigned short);
16771 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
16772 vector bool int vec_srl (vector bool int, vector unsigned int);
16773 vector bool int vec_srl (vector bool int, vector unsigned short);
16774 vector bool int vec_srl (vector bool int, vector unsigned char);
16775 vector signed short vec_srl (vector signed short, vector unsigned int);
16776 vector signed short vec_srl (vector signed short,
16777 vector unsigned short);
16778 vector signed short vec_srl (vector signed short, vector unsigned char);
16779 vector unsigned short vec_srl (vector unsigned short,
16780 vector unsigned int);
16781 vector unsigned short vec_srl (vector unsigned short,
16782 vector unsigned short);
16783 vector unsigned short vec_srl (vector unsigned short,
16784 vector unsigned char);
16785 vector bool short vec_srl (vector bool short, vector unsigned int);
16786 vector bool short vec_srl (vector bool short, vector unsigned short);
16787 vector bool short vec_srl (vector bool short, vector unsigned char);
16788 vector pixel vec_srl (vector pixel, vector unsigned int);
16789 vector pixel vec_srl (vector pixel, vector unsigned short);
16790 vector pixel vec_srl (vector pixel, vector unsigned char);
16791 vector signed char vec_srl (vector signed char, vector unsigned int);
16792 vector signed char vec_srl (vector signed char, vector unsigned short);
16793 vector signed char vec_srl (vector signed char, vector unsigned char);
16794 vector unsigned char vec_srl (vector unsigned char,
16795 vector unsigned int);
16796 vector unsigned char vec_srl (vector unsigned char,
16797 vector unsigned short);
16798 vector unsigned char vec_srl (vector unsigned char,
16799 vector unsigned char);
16800 vector bool char vec_srl (vector bool char, vector unsigned int);
16801 vector bool char vec_srl (vector bool char, vector unsigned short);
16802 vector bool char vec_srl (vector bool char, vector unsigned char);
16804 vector float vec_sro (vector float, vector signed char);
16805 vector float vec_sro (vector float, vector unsigned char);
16806 vector signed int vec_sro (vector signed int, vector signed char);
16807 vector signed int vec_sro (vector signed int, vector unsigned char);
16808 vector unsigned int vec_sro (vector unsigned int, vector signed char);
16809 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
16810 vector signed short vec_sro (vector signed short, vector signed char);
16811 vector signed short vec_sro (vector signed short, vector unsigned char);
16812 vector unsigned short vec_sro (vector unsigned short,
16813 vector signed char);
16814 vector unsigned short vec_sro (vector unsigned short,
16815 vector unsigned char);
16816 vector pixel vec_sro (vector pixel, vector signed char);
16817 vector pixel vec_sro (vector pixel, vector unsigned char);
16818 vector signed char vec_sro (vector signed char, vector signed char);
16819 vector signed char vec_sro (vector signed char, vector unsigned char);
16820 vector unsigned char vec_sro (vector unsigned char, vector signed char);
16821 vector unsigned char vec_sro (vector unsigned char,
16822 vector unsigned char);
16824 void vec_st (vector float, int, vector float *);
16825 void vec_st (vector float, int, float *);
16826 void vec_st (vector signed int, int, vector signed int *);
16827 void vec_st (vector signed int, int, int *);
16828 void vec_st (vector unsigned int, int, vector unsigned int *);
16829 void vec_st (vector unsigned int, int, unsigned int *);
16830 void vec_st (vector bool int, int, vector bool int *);
16831 void vec_st (vector bool int, int, unsigned int *);
16832 void vec_st (vector bool int, int, int *);
16833 void vec_st (vector signed short, int, vector signed short *);
16834 void vec_st (vector signed short, int, short *);
16835 void vec_st (vector unsigned short, int, vector unsigned short *);
16836 void vec_st (vector unsigned short, int, unsigned short *);
16837 void vec_st (vector bool short, int, vector bool short *);
16838 void vec_st (vector bool short, int, unsigned short *);
16839 void vec_st (vector pixel, int, vector pixel *);
16840 void vec_st (vector pixel, int, unsigned short *);
16841 void vec_st (vector pixel, int, short *);
16842 void vec_st (vector bool short, int, short *);
16843 void vec_st (vector signed char, int, vector signed char *);
16844 void vec_st (vector signed char, int, signed char *);
16845 void vec_st (vector unsigned char, int, vector unsigned char *);
16846 void vec_st (vector unsigned char, int, unsigned char *);
16847 void vec_st (vector bool char, int, vector bool char *);
16848 void vec_st (vector bool char, int, unsigned char *);
16849 void vec_st (vector bool char, int, signed char *);
16851 void vec_ste (vector signed char, int, signed char *);
16852 void vec_ste (vector unsigned char, int, unsigned char *);
16853 void vec_ste (vector bool char, int, signed char *);
16854 void vec_ste (vector bool char, int, unsigned char *);
16855 void vec_ste (vector signed short, int, short *);
16856 void vec_ste (vector unsigned short, int, unsigned short *);
16857 void vec_ste (vector bool short, int, short *);
16858 void vec_ste (vector bool short, int, unsigned short *);
16859 void vec_ste (vector pixel, int, short *);
16860 void vec_ste (vector pixel, int, unsigned short *);
16861 void vec_ste (vector float, int, float *);
16862 void vec_ste (vector signed int, int, int *);
16863 void vec_ste (vector unsigned int, int, unsigned int *);
16864 void vec_ste (vector bool int, int, int *);
16865 void vec_ste (vector bool int, int, unsigned int *);
16867 void vec_stvewx (vector float, int, float *);
16868 void vec_stvewx (vector signed int, int, int *);
16869 void vec_stvewx (vector unsigned int, int, unsigned int *);
16870 void vec_stvewx (vector bool int, int, int *);
16871 void vec_stvewx (vector bool int, int, unsigned int *);
16873 void vec_stvehx (vector signed short, int, short *);
16874 void vec_stvehx (vector unsigned short, int, unsigned short *);
16875 void vec_stvehx (vector bool short, int, short *);
16876 void vec_stvehx (vector bool short, int, unsigned short *);
16877 void vec_stvehx (vector pixel, int, short *);
16878 void vec_stvehx (vector pixel, int, unsigned short *);
16880 void vec_stvebx (vector signed char, int, signed char *);
16881 void vec_stvebx (vector unsigned char, int, unsigned char *);
16882 void vec_stvebx (vector bool char, int, signed char *);
16883 void vec_stvebx (vector bool char, int, unsigned char *);
16885 void vec_stl (vector float, int, vector float *);
16886 void vec_stl (vector float, int, float *);
16887 void vec_stl (vector signed int, int, vector signed int *);
16888 void vec_stl (vector signed int, int, int *);
16889 void vec_stl (vector unsigned int, int, vector unsigned int *);
16890 void vec_stl (vector unsigned int, int, unsigned int *);
16891 void vec_stl (vector bool int, int, vector bool int *);
16892 void vec_stl (vector bool int, int, unsigned int *);
16893 void vec_stl (vector bool int, int, int *);
16894 void vec_stl (vector signed short, int, vector signed short *);
16895 void vec_stl (vector signed short, int, short *);
16896 void vec_stl (vector unsigned short, int, vector unsigned short *);
16897 void vec_stl (vector unsigned short, int, unsigned short *);
16898 void vec_stl (vector bool short, int, vector bool short *);
16899 void vec_stl (vector bool short, int, unsigned short *);
16900 void vec_stl (vector bool short, int, short *);
16901 void vec_stl (vector pixel, int, vector pixel *);
16902 void vec_stl (vector pixel, int, unsigned short *);
16903 void vec_stl (vector pixel, int, short *);
16904 void vec_stl (vector signed char, int, vector signed char *);
16905 void vec_stl (vector signed char, int, signed char *);
16906 void vec_stl (vector unsigned char, int, vector unsigned char *);
16907 void vec_stl (vector unsigned char, int, unsigned char *);
16908 void vec_stl (vector bool char, int, vector bool char *);
16909 void vec_stl (vector bool char, int, unsigned char *);
16910 void vec_stl (vector bool char, int, signed char *);
16912 vector signed char vec_sub (vector bool char, vector signed char);
16913 vector signed char vec_sub (vector signed char, vector bool char);
16914 vector signed char vec_sub (vector signed char, vector signed char);
16915 vector unsigned char vec_sub (vector bool char, vector unsigned char);
16916 vector unsigned char vec_sub (vector unsigned char, vector bool char);
16917 vector unsigned char vec_sub (vector unsigned char,
16918 vector unsigned char);
16919 vector signed short vec_sub (vector bool short, vector signed short);
16920 vector signed short vec_sub (vector signed short, vector bool short);
16921 vector signed short vec_sub (vector signed short, vector signed short);
16922 vector unsigned short vec_sub (vector bool short,
16923 vector unsigned short);
16924 vector unsigned short vec_sub (vector unsigned short,
16925 vector bool short);
16926 vector unsigned short vec_sub (vector unsigned short,
16927 vector unsigned short);
16928 vector signed int vec_sub (vector bool int, vector signed int);
16929 vector signed int vec_sub (vector signed int, vector bool int);
16930 vector signed int vec_sub (vector signed int, vector signed int);
16931 vector unsigned int vec_sub (vector bool int, vector unsigned int);
16932 vector unsigned int vec_sub (vector unsigned int, vector bool int);
16933 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
16934 vector float vec_sub (vector float, vector float);
16936 vector float vec_vsubfp (vector float, vector float);
16938 vector signed int vec_vsubuwm (vector bool int, vector signed int);
16939 vector signed int vec_vsubuwm (vector signed int, vector bool int);
16940 vector signed int vec_vsubuwm (vector signed int, vector signed int);
16941 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
16942 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
16943 vector unsigned int vec_vsubuwm (vector unsigned int,
16944 vector unsigned int);
16946 vector signed short vec_vsubuhm (vector bool short,
16947 vector signed short);
16948 vector signed short vec_vsubuhm (vector signed short,
16949 vector bool short);
16950 vector signed short vec_vsubuhm (vector signed short,
16951 vector signed short);
16952 vector unsigned short vec_vsubuhm (vector bool short,
16953 vector unsigned short);
16954 vector unsigned short vec_vsubuhm (vector unsigned short,
16955 vector bool short);
16956 vector unsigned short vec_vsubuhm (vector unsigned short,
16957 vector unsigned short);
16959 vector signed char vec_vsububm (vector bool char, vector signed char);
16960 vector signed char vec_vsububm (vector signed char, vector bool char);
16961 vector signed char vec_vsububm (vector signed char, vector signed char);
16962 vector unsigned char vec_vsububm (vector bool char,
16963 vector unsigned char);
16964 vector unsigned char vec_vsububm (vector unsigned char,
16966 vector unsigned char vec_vsububm (vector unsigned char,
16967 vector unsigned char);
16969 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
16971 vector unsigned char vec_subs (vector bool char, vector unsigned char);
16972 vector unsigned char vec_subs (vector unsigned char, vector bool char);
16973 vector unsigned char vec_subs (vector unsigned char,
16974 vector unsigned char);
16975 vector signed char vec_subs (vector bool char, vector signed char);
16976 vector signed char vec_subs (vector signed char, vector bool char);
16977 vector signed char vec_subs (vector signed char, vector signed char);
16978 vector unsigned short vec_subs (vector bool short,
16979 vector unsigned short);
16980 vector unsigned short vec_subs (vector unsigned short,
16981 vector bool short);
16982 vector unsigned short vec_subs (vector unsigned short,
16983 vector unsigned short);
16984 vector signed short vec_subs (vector bool short, vector signed short);
16985 vector signed short vec_subs (vector signed short, vector bool short);
16986 vector signed short vec_subs (vector signed short, vector signed short);
16987 vector unsigned int vec_subs (vector bool int, vector unsigned int);
16988 vector unsigned int vec_subs (vector unsigned int, vector bool int);
16989 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
16990 vector signed int vec_subs (vector bool int, vector signed int);
16991 vector signed int vec_subs (vector signed int, vector bool int);
16992 vector signed int vec_subs (vector signed int, vector signed int);
16994 vector signed int vec_vsubsws (vector bool int, vector signed int);
16995 vector signed int vec_vsubsws (vector signed int, vector bool int);
16996 vector signed int vec_vsubsws (vector signed int, vector signed int);
16998 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
16999 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
17000 vector unsigned int vec_vsubuws (vector unsigned int,
17001 vector unsigned int);
17003 vector signed short vec_vsubshs (vector bool short,
17004 vector signed short);
17005 vector signed short vec_vsubshs (vector signed short,
17006 vector bool short);
17007 vector signed short vec_vsubshs (vector signed short,
17008 vector signed short);
17010 vector unsigned short vec_vsubuhs (vector bool short,
17011 vector unsigned short);
17012 vector unsigned short vec_vsubuhs (vector unsigned short,
17013 vector bool short);
17014 vector unsigned short vec_vsubuhs (vector unsigned short,
17015 vector unsigned short);
17017 vector signed char vec_vsubsbs (vector bool char, vector signed char);
17018 vector signed char vec_vsubsbs (vector signed char, vector bool char);
17019 vector signed char vec_vsubsbs (vector signed char, vector signed char);
17021 vector unsigned char vec_vsububs (vector bool char,
17022 vector unsigned char);
17023 vector unsigned char vec_vsububs (vector unsigned char,
17025 vector unsigned char vec_vsububs (vector unsigned char,
17026 vector unsigned char);
17028 vector unsigned int vec_sum4s (vector unsigned char,
17029 vector unsigned int);
17030 vector signed int vec_sum4s (vector signed char, vector signed int);
17031 vector signed int vec_sum4s (vector signed short, vector signed int);
17033 vector signed int vec_vsum4shs (vector signed short, vector signed int);
17035 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
17037 vector unsigned int vec_vsum4ubs (vector unsigned char,
17038 vector unsigned int);
17040 vector signed int vec_sum2s (vector signed int, vector signed int);
17042 vector signed int vec_sums (vector signed int, vector signed int);
17044 vector float vec_trunc (vector float);
17046 vector signed short vec_unpackh (vector signed char);
17047 vector bool short vec_unpackh (vector bool char);
17048 vector signed int vec_unpackh (vector signed short);
17049 vector bool int vec_unpackh (vector bool short);
17050 vector unsigned int vec_unpackh (vector pixel);
17052 vector bool int vec_vupkhsh (vector bool short);
17053 vector signed int vec_vupkhsh (vector signed short);
17055 vector unsigned int vec_vupkhpx (vector pixel);
17057 vector bool short vec_vupkhsb (vector bool char);
17058 vector signed short vec_vupkhsb (vector signed char);
17060 vector signed short vec_unpackl (vector signed char);
17061 vector bool short vec_unpackl (vector bool char);
17062 vector unsigned int vec_unpackl (vector pixel);
17063 vector signed int vec_unpackl (vector signed short);
17064 vector bool int vec_unpackl (vector bool short);
17066 vector unsigned int vec_vupklpx (vector pixel);
17068 vector bool int vec_vupklsh (vector bool short);
17069 vector signed int vec_vupklsh (vector signed short);
17071 vector bool short vec_vupklsb (vector bool char);
17072 vector signed short vec_vupklsb (vector signed char);
17074 vector float vec_xor (vector float, vector float);
17075 vector float vec_xor (vector float, vector bool int);
17076 vector float vec_xor (vector bool int, vector float);
17077 vector bool int vec_xor (vector bool int, vector bool int);
17078 vector signed int vec_xor (vector bool int, vector signed int);
17079 vector signed int vec_xor (vector signed int, vector bool int);
17080 vector signed int vec_xor (vector signed int, vector signed int);
17081 vector unsigned int vec_xor (vector bool int, vector unsigned int);
17082 vector unsigned int vec_xor (vector unsigned int, vector bool int);
17083 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
17084 vector bool short vec_xor (vector bool short, vector bool short);
17085 vector signed short vec_xor (vector bool short, vector signed short);
17086 vector signed short vec_xor (vector signed short, vector bool short);
17087 vector signed short vec_xor (vector signed short, vector signed short);
17088 vector unsigned short vec_xor (vector bool short,
17089 vector unsigned short);
17090 vector unsigned short vec_xor (vector unsigned short,
17091 vector bool short);
17092 vector unsigned short vec_xor (vector unsigned short,
17093 vector unsigned short);
17094 vector signed char vec_xor (vector bool char, vector signed char);
17095 vector bool char vec_xor (vector bool char, vector bool char);
17096 vector signed char vec_xor (vector signed char, vector bool char);
17097 vector signed char vec_xor (vector signed char, vector signed char);
17098 vector unsigned char vec_xor (vector bool char, vector unsigned char);
17099 vector unsigned char vec_xor (vector unsigned char, vector bool char);
17100 vector unsigned char vec_xor (vector unsigned char,
17101 vector unsigned char);
17103 int vec_all_eq (vector signed char, vector bool char);
17104 int vec_all_eq (vector signed char, vector signed char);
17105 int vec_all_eq (vector unsigned char, vector bool char);
17106 int vec_all_eq (vector unsigned char, vector unsigned char);
17107 int vec_all_eq (vector bool char, vector bool char);
17108 int vec_all_eq (vector bool char, vector unsigned char);
17109 int vec_all_eq (vector bool char, vector signed char);
17110 int vec_all_eq (vector signed short, vector bool short);
17111 int vec_all_eq (vector signed short, vector signed short);
17112 int vec_all_eq (vector unsigned short, vector bool short);
17113 int vec_all_eq (vector unsigned short, vector unsigned short);
17114 int vec_all_eq (vector bool short, vector bool short);
17115 int vec_all_eq (vector bool short, vector unsigned short);
17116 int vec_all_eq (vector bool short, vector signed short);
17117 int vec_all_eq (vector pixel, vector pixel);
17118 int vec_all_eq (vector signed int, vector bool int);
17119 int vec_all_eq (vector signed int, vector signed int);
17120 int vec_all_eq (vector unsigned int, vector bool int);
17121 int vec_all_eq (vector unsigned int, vector unsigned int);
17122 int vec_all_eq (vector bool int, vector bool int);
17123 int vec_all_eq (vector bool int, vector unsigned int);
17124 int vec_all_eq (vector bool int, vector signed int);
17125 int vec_all_eq (vector float, vector float);
17127 int vec_all_ge (vector bool char, vector unsigned char);
17128 int vec_all_ge (vector unsigned char, vector bool char);
17129 int vec_all_ge (vector unsigned char, vector unsigned char);
17130 int vec_all_ge (vector bool char, vector signed char);
17131 int vec_all_ge (vector signed char, vector bool char);
17132 int vec_all_ge (vector signed char, vector signed char);
17133 int vec_all_ge (vector bool short, vector unsigned short);
17134 int vec_all_ge (vector unsigned short, vector bool short);
17135 int vec_all_ge (vector unsigned short, vector unsigned short);
17136 int vec_all_ge (vector signed short, vector signed short);
17137 int vec_all_ge (vector bool short, vector signed short);
17138 int vec_all_ge (vector signed short, vector bool short);
17139 int vec_all_ge (vector bool int, vector unsigned int);
17140 int vec_all_ge (vector unsigned int, vector bool int);
17141 int vec_all_ge (vector unsigned int, vector unsigned int);
17142 int vec_all_ge (vector bool int, vector signed int);
17143 int vec_all_ge (vector signed int, vector bool int);
17144 int vec_all_ge (vector signed int, vector signed int);
17145 int vec_all_ge (vector float, vector float);
17147 int vec_all_gt (vector bool char, vector unsigned char);
17148 int vec_all_gt (vector unsigned char, vector bool char);
17149 int vec_all_gt (vector unsigned char, vector unsigned char);
17150 int vec_all_gt (vector bool char, vector signed char);
17151 int vec_all_gt (vector signed char, vector bool char);
17152 int vec_all_gt (vector signed char, vector signed char);
17153 int vec_all_gt (vector bool short, vector unsigned short);
17154 int vec_all_gt (vector unsigned short, vector bool short);
17155 int vec_all_gt (vector unsigned short, vector unsigned short);
17156 int vec_all_gt (vector bool short, vector signed short);
17157 int vec_all_gt (vector signed short, vector bool short);
17158 int vec_all_gt (vector signed short, vector signed short);
17159 int vec_all_gt (vector bool int, vector unsigned int);
17160 int vec_all_gt (vector unsigned int, vector bool int);
17161 int vec_all_gt (vector unsigned int, vector unsigned int);
17162 int vec_all_gt (vector bool int, vector signed int);
17163 int vec_all_gt (vector signed int, vector bool int);
17164 int vec_all_gt (vector signed int, vector signed int);
17165 int vec_all_gt (vector float, vector float);
17167 int vec_all_in (vector float, vector float);
17169 int vec_all_le (vector bool char, vector unsigned char);
17170 int vec_all_le (vector unsigned char, vector bool char);
17171 int vec_all_le (vector unsigned char, vector unsigned char);
17172 int vec_all_le (vector bool char, vector signed char);
17173 int vec_all_le (vector signed char, vector bool char);
17174 int vec_all_le (vector signed char, vector signed char);
17175 int vec_all_le (vector bool short, vector unsigned short);
17176 int vec_all_le (vector unsigned short, vector bool short);
17177 int vec_all_le (vector unsigned short, vector unsigned short);
17178 int vec_all_le (vector bool short, vector signed short);
17179 int vec_all_le (vector signed short, vector bool short);
17180 int vec_all_le (vector signed short, vector signed short);
17181 int vec_all_le (vector bool int, vector unsigned int);
17182 int vec_all_le (vector unsigned int, vector bool int);
17183 int vec_all_le (vector unsigned int, vector unsigned int);
17184 int vec_all_le (vector bool int, vector signed int);
17185 int vec_all_le (vector signed int, vector bool int);
17186 int vec_all_le (vector signed int, vector signed int);
17187 int vec_all_le (vector float, vector float);
17189 int vec_all_lt (vector bool char, vector unsigned char);
17190 int vec_all_lt (vector unsigned char, vector bool char);
17191 int vec_all_lt (vector unsigned char, vector unsigned char);
17192 int vec_all_lt (vector bool char, vector signed char);
17193 int vec_all_lt (vector signed char, vector bool char);
17194 int vec_all_lt (vector signed char, vector signed char);
17195 int vec_all_lt (vector bool short, vector unsigned short);
17196 int vec_all_lt (vector unsigned short, vector bool short);
17197 int vec_all_lt (vector unsigned short, vector unsigned short);
17198 int vec_all_lt (vector bool short, vector signed short);
17199 int vec_all_lt (vector signed short, vector bool short);
17200 int vec_all_lt (vector signed short, vector signed short);
17201 int vec_all_lt (vector bool int, vector unsigned int);
17202 int vec_all_lt (vector unsigned int, vector bool int);
17203 int vec_all_lt (vector unsigned int, vector unsigned int);
17204 int vec_all_lt (vector bool int, vector signed int);
17205 int vec_all_lt (vector signed int, vector bool int);
17206 int vec_all_lt (vector signed int, vector signed int);
17207 int vec_all_lt (vector float, vector float);
17209 int vec_all_nan (vector float);
17211 int vec_all_ne (vector signed char, vector bool char);
17212 int vec_all_ne (vector signed char, vector signed char);
17213 int vec_all_ne (vector unsigned char, vector bool char);
17214 int vec_all_ne (vector unsigned char, vector unsigned char);
17215 int vec_all_ne (vector bool char, vector bool char);
17216 int vec_all_ne (vector bool char, vector unsigned char);
17217 int vec_all_ne (vector bool char, vector signed char);
17218 int vec_all_ne (vector signed short, vector bool short);
17219 int vec_all_ne (vector signed short, vector signed short);
17220 int vec_all_ne (vector unsigned short, vector bool short);
17221 int vec_all_ne (vector unsigned short, vector unsigned short);
17222 int vec_all_ne (vector bool short, vector bool short);
17223 int vec_all_ne (vector bool short, vector unsigned short);
17224 int vec_all_ne (vector bool short, vector signed short);
17225 int vec_all_ne (vector pixel, vector pixel);
17226 int vec_all_ne (vector signed int, vector bool int);
17227 int vec_all_ne (vector signed int, vector signed int);
17228 int vec_all_ne (vector unsigned int, vector bool int);
17229 int vec_all_ne (vector unsigned int, vector unsigned int);
17230 int vec_all_ne (vector bool int, vector bool int);
17231 int vec_all_ne (vector bool int, vector unsigned int);
17232 int vec_all_ne (vector bool int, vector signed int);
17233 int vec_all_ne (vector float, vector float);
17235 int vec_all_nge (vector float, vector float);
17237 int vec_all_ngt (vector float, vector float);
17239 int vec_all_nle (vector float, vector float);
17241 int vec_all_nlt (vector float, vector float);
17243 int vec_all_numeric (vector float);
17245 int vec_any_eq (vector signed char, vector bool char);
17246 int vec_any_eq (vector signed char, vector signed char);
17247 int vec_any_eq (vector unsigned char, vector bool char);
17248 int vec_any_eq (vector unsigned char, vector unsigned char);
17249 int vec_any_eq (vector bool char, vector bool char);
17250 int vec_any_eq (vector bool char, vector unsigned char);
17251 int vec_any_eq (vector bool char, vector signed char);
17252 int vec_any_eq (vector signed short, vector bool short);
17253 int vec_any_eq (vector signed short, vector signed short);
17254 int vec_any_eq (vector unsigned short, vector bool short);
17255 int vec_any_eq (vector unsigned short, vector unsigned short);
17256 int vec_any_eq (vector bool short, vector bool short);
17257 int vec_any_eq (vector bool short, vector unsigned short);
17258 int vec_any_eq (vector bool short, vector signed short);
17259 int vec_any_eq (vector pixel, vector pixel);
17260 int vec_any_eq (vector signed int, vector bool int);
17261 int vec_any_eq (vector signed int, vector signed int);
17262 int vec_any_eq (vector unsigned int, vector bool int);
17263 int vec_any_eq (vector unsigned int, vector unsigned int);
17264 int vec_any_eq (vector bool int, vector bool int);
17265 int vec_any_eq (vector bool int, vector unsigned int);
17266 int vec_any_eq (vector bool int, vector signed int);
17267 int vec_any_eq (vector float, vector float);
17269 int vec_any_ge (vector signed char, vector bool char);
17270 int vec_any_ge (vector unsigned char, vector bool char);
17271 int vec_any_ge (vector unsigned char, vector unsigned char);
17272 int vec_any_ge (vector signed char, vector signed char);
17273 int vec_any_ge (vector bool char, vector unsigned char);
17274 int vec_any_ge (vector bool char, vector signed char);
17275 int vec_any_ge (vector unsigned short, vector bool short);
17276 int vec_any_ge (vector unsigned short, vector unsigned short);
17277 int vec_any_ge (vector signed short, vector signed short);
17278 int vec_any_ge (vector signed short, vector bool short);
17279 int vec_any_ge (vector bool short, vector unsigned short);
17280 int vec_any_ge (vector bool short, vector signed short);
17281 int vec_any_ge (vector signed int, vector bool int);
17282 int vec_any_ge (vector unsigned int, vector bool int);
17283 int vec_any_ge (vector unsigned int, vector unsigned int);
17284 int vec_any_ge (vector signed int, vector signed int);
17285 int vec_any_ge (vector bool int, vector unsigned int);
17286 int vec_any_ge (vector bool int, vector signed int);
17287 int vec_any_ge (vector float, vector float);
17289 int vec_any_gt (vector bool char, vector unsigned char);
17290 int vec_any_gt (vector unsigned char, vector bool char);
17291 int vec_any_gt (vector unsigned char, vector unsigned char);
17292 int vec_any_gt (vector bool char, vector signed char);
17293 int vec_any_gt (vector signed char, vector bool char);
17294 int vec_any_gt (vector signed char, vector signed char);
17295 int vec_any_gt (vector bool short, vector unsigned short);
17296 int vec_any_gt (vector unsigned short, vector bool short);
17297 int vec_any_gt (vector unsigned short, vector unsigned short);
17298 int vec_any_gt (vector bool short, vector signed short);
17299 int vec_any_gt (vector signed short, vector bool short);
17300 int vec_any_gt (vector signed short, vector signed short);
17301 int vec_any_gt (vector bool int, vector unsigned int);
17302 int vec_any_gt (vector unsigned int, vector bool int);
17303 int vec_any_gt (vector unsigned int, vector unsigned int);
17304 int vec_any_gt (vector bool int, vector signed int);
17305 int vec_any_gt (vector signed int, vector bool int);
17306 int vec_any_gt (vector signed int, vector signed int);
17307 int vec_any_gt (vector float, vector float);
17309 int vec_any_le (vector bool char, vector unsigned char);
17310 int vec_any_le (vector unsigned char, vector bool char);
17311 int vec_any_le (vector unsigned char, vector unsigned char);
17312 int vec_any_le (vector bool char, vector signed char);
17313 int vec_any_le (vector signed char, vector bool char);
17314 int vec_any_le (vector signed char, vector signed char);
17315 int vec_any_le (vector bool short, vector unsigned short);
17316 int vec_any_le (vector unsigned short, vector bool short);
17317 int vec_any_le (vector unsigned short, vector unsigned short);
17318 int vec_any_le (vector bool short, vector signed short);
17319 int vec_any_le (vector signed short, vector bool short);
17320 int vec_any_le (vector signed short, vector signed short);
17321 int vec_any_le (vector bool int, vector unsigned int);
17322 int vec_any_le (vector unsigned int, vector bool int);
17323 int vec_any_le (vector unsigned int, vector unsigned int);
17324 int vec_any_le (vector bool int, vector signed int);
17325 int vec_any_le (vector signed int, vector bool int);
17326 int vec_any_le (vector signed int, vector signed int);
17327 int vec_any_le (vector float, vector float);
17329 int vec_any_lt (vector bool char, vector unsigned char);
17330 int vec_any_lt (vector unsigned char, vector bool char);
17331 int vec_any_lt (vector unsigned char, vector unsigned char);
17332 int vec_any_lt (vector bool char, vector signed char);
17333 int vec_any_lt (vector signed char, vector bool char);
17334 int vec_any_lt (vector signed char, vector signed char);
17335 int vec_any_lt (vector bool short, vector unsigned short);
17336 int vec_any_lt (vector unsigned short, vector bool short);
17337 int vec_any_lt (vector unsigned short, vector unsigned short);
17338 int vec_any_lt (vector bool short, vector signed short);
17339 int vec_any_lt (vector signed short, vector bool short);
17340 int vec_any_lt (vector signed short, vector signed short);
17341 int vec_any_lt (vector bool int, vector unsigned int);
17342 int vec_any_lt (vector unsigned int, vector bool int);
17343 int vec_any_lt (vector unsigned int, vector unsigned int);
17344 int vec_any_lt (vector bool int, vector signed int);
17345 int vec_any_lt (vector signed int, vector bool int);
17346 int vec_any_lt (vector signed int, vector signed int);
17347 int vec_any_lt (vector float, vector float);
17349 int vec_any_nan (vector float);
17351 int vec_any_ne (vector signed char, vector bool char);
17352 int vec_any_ne (vector signed char, vector signed char);
17353 int vec_any_ne (vector unsigned char, vector bool char);
17354 int vec_any_ne (vector unsigned char, vector unsigned char);
17355 int vec_any_ne (vector bool char, vector bool char);
17356 int vec_any_ne (vector bool char, vector unsigned char);
17357 int vec_any_ne (vector bool char, vector signed char);
17358 int vec_any_ne (vector signed short, vector bool short);
17359 int vec_any_ne (vector signed short, vector signed short);
17360 int vec_any_ne (vector unsigned short, vector bool short);
17361 int vec_any_ne (vector unsigned short, vector unsigned short);
17362 int vec_any_ne (vector bool short, vector bool short);
17363 int vec_any_ne (vector bool short, vector unsigned short);
17364 int vec_any_ne (vector bool short, vector signed short);
17365 int vec_any_ne (vector pixel, vector pixel);
17366 int vec_any_ne (vector signed int, vector bool int);
17367 int vec_any_ne (vector signed int, vector signed int);
17368 int vec_any_ne (vector unsigned int, vector bool int);
17369 int vec_any_ne (vector unsigned int, vector unsigned int);
17370 int vec_any_ne (vector bool int, vector bool int);
17371 int vec_any_ne (vector bool int, vector unsigned int);
17372 int vec_any_ne (vector bool int, vector signed int);
17373 int vec_any_ne (vector float, vector float);
17375 int vec_any_nge (vector float, vector float);
17377 int vec_any_ngt (vector float, vector float);
17379 int vec_any_nle (vector float, vector float);
17381 int vec_any_nlt (vector float, vector float);
17383 int vec_any_numeric (vector float);
17385 int vec_any_out (vector float, vector float);
17388 If the vector/scalar (VSX) instruction set is available, the following
17389 additional functions are available:
17392 vector double vec_abs (vector double);
17393 vector double vec_add (vector double, vector double);
17394 vector double vec_and (vector double, vector double);
17395 vector double vec_and (vector double, vector bool long);
17396 vector double vec_and (vector bool long, vector double);
17397 vector long vec_and (vector long, vector long);
17398 vector long vec_and (vector long, vector bool long);
17399 vector long vec_and (vector bool long, vector long);
17400 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
17401 vector unsigned long vec_and (vector unsigned long, vector bool long);
17402 vector unsigned long vec_and (vector bool long, vector unsigned long);
17403 vector double vec_andc (vector double, vector double);
17404 vector double vec_andc (vector double, vector bool long);
17405 vector double vec_andc (vector bool long, vector double);
17406 vector long vec_andc (vector long, vector long);
17407 vector long vec_andc (vector long, vector bool long);
17408 vector long vec_andc (vector bool long, vector long);
17409 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
17410 vector unsigned long vec_andc (vector unsigned long, vector bool long);
17411 vector unsigned long vec_andc (vector bool long, vector unsigned long);
17412 vector double vec_ceil (vector double);
17413 vector bool long vec_cmpeq (vector double, vector double);
17414 vector bool long vec_cmpge (vector double, vector double);
17415 vector bool long vec_cmpgt (vector double, vector double);
17416 vector bool long vec_cmple (vector double, vector double);
17417 vector bool long vec_cmplt (vector double, vector double);
17418 vector double vec_cpsgn (vector double, vector double);
17419 vector float vec_div (vector float, vector float);
17420 vector double vec_div (vector double, vector double);
17421 vector long vec_div (vector long, vector long);
17422 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
17423 vector double vec_floor (vector double);
17424 vector double vec_ld (int, const vector double *);
17425 vector double vec_ld (int, const double *);
17426 vector double vec_ldl (int, const vector double *);
17427 vector double vec_ldl (int, const double *);
17428 vector unsigned char vec_lvsl (int, const volatile double *);
17429 vector unsigned char vec_lvsr (int, const volatile double *);
17430 vector double vec_madd (vector double, vector double, vector double);
17431 vector double vec_max (vector double, vector double);
17432 vector signed long vec_mergeh (vector signed long, vector signed long);
17433 vector signed long vec_mergeh (vector signed long, vector bool long);
17434 vector signed long vec_mergeh (vector bool long, vector signed long);
17435 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
17436 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
17437 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
17438 vector signed long vec_mergel (vector signed long, vector signed long);
17439 vector signed long vec_mergel (vector signed long, vector bool long);
17440 vector signed long vec_mergel (vector bool long, vector signed long);
17441 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
17442 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
17443 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
17444 vector double vec_min (vector double, vector double);
17445 vector float vec_msub (vector float, vector float, vector float);
17446 vector double vec_msub (vector double, vector double, vector double);
17447 vector float vec_mul (vector float, vector float);
17448 vector double vec_mul (vector double, vector double);
17449 vector long vec_mul (vector long, vector long);
17450 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
17451 vector float vec_nearbyint (vector float);
17452 vector double vec_nearbyint (vector double);
17453 vector float vec_nmadd (vector float, vector float, vector float);
17454 vector double vec_nmadd (vector double, vector double, vector double);
17455 vector double vec_nmsub (vector double, vector double, vector double);
17456 vector double vec_nor (vector double, vector double);
17457 vector long vec_nor (vector long, vector long);
17458 vector long vec_nor (vector long, vector bool long);
17459 vector long vec_nor (vector bool long, vector long);
17460 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
17461 vector unsigned long vec_nor (vector unsigned long, vector bool long);
17462 vector unsigned long vec_nor (vector bool long, vector unsigned long);
17463 vector double vec_or (vector double, vector double);
17464 vector double vec_or (vector double, vector bool long);
17465 vector double vec_or (vector bool long, vector double);
17466 vector long vec_or (vector long, vector long);
17467 vector long vec_or (vector long, vector bool long);
17468 vector long vec_or (vector bool long, vector long);
17469 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
17470 vector unsigned long vec_or (vector unsigned long, vector bool long);
17471 vector unsigned long vec_or (vector bool long, vector unsigned long);
17472 vector double vec_perm (vector double, vector double, vector unsigned char);
17473 vector long vec_perm (vector long, vector long, vector unsigned char);
17474 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
17475 vector unsigned char);
17476 vector double vec_rint (vector double);
17477 vector double vec_recip (vector double, vector double);
17478 vector double vec_rsqrt (vector double);
17479 vector double vec_rsqrte (vector double);
17480 vector double vec_sel (vector double, vector double, vector bool long);
17481 vector double vec_sel (vector double, vector double, vector unsigned long);
17482 vector long vec_sel (vector long, vector long, vector long);
17483 vector long vec_sel (vector long, vector long, vector unsigned long);
17484 vector long vec_sel (vector long, vector long, vector bool long);
17485 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17487 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17488 vector unsigned long);
17489 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17491 vector double vec_splats (double);
17492 vector signed long vec_splats (signed long);
17493 vector unsigned long vec_splats (unsigned long);
17494 vector float vec_sqrt (vector float);
17495 vector double vec_sqrt (vector double);
17496 void vec_st (vector double, int, vector double *);
17497 void vec_st (vector double, int, double *);
17498 vector double vec_sub (vector double, vector double);
17499 vector double vec_trunc (vector double);
17500 vector double vec_xl (int, vector double *);
17501 vector double vec_xl (int, double *);
17502 vector long long vec_xl (int, vector long long *);
17503 vector long long vec_xl (int, long long *);
17504 vector unsigned long long vec_xl (int, vector unsigned long long *);
17505 vector unsigned long long vec_xl (int, unsigned long long *);
17506 vector float vec_xl (int, vector float *);
17507 vector float vec_xl (int, float *);
17508 vector int vec_xl (int, vector int *);
17509 vector int vec_xl (int, int *);
17510 vector unsigned int vec_xl (int, vector unsigned int *);
17511 vector unsigned int vec_xl (int, unsigned int *);
17512 vector double vec_xor (vector double, vector double);
17513 vector double vec_xor (vector double, vector bool long);
17514 vector double vec_xor (vector bool long, vector double);
17515 vector long vec_xor (vector long, vector long);
17516 vector long vec_xor (vector long, vector bool long);
17517 vector long vec_xor (vector bool long, vector long);
17518 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
17519 vector unsigned long vec_xor (vector unsigned long, vector bool long);
17520 vector unsigned long vec_xor (vector bool long, vector unsigned long);
17521 void vec_xst (vector double, int, vector double *);
17522 void vec_xst (vector double, int, double *);
17523 void vec_xst (vector long long, int, vector long long *);
17524 void vec_xst (vector long long, int, long long *);
17525 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
17526 void vec_xst (vector unsigned long long, int, unsigned long long *);
17527 void vec_xst (vector float, int, vector float *);
17528 void vec_xst (vector float, int, float *);
17529 void vec_xst (vector int, int, vector int *);
17530 void vec_xst (vector int, int, int *);
17531 void vec_xst (vector unsigned int, int, vector unsigned int *);
17532 void vec_xst (vector unsigned int, int, unsigned int *);
17533 int vec_all_eq (vector double, vector double);
17534 int vec_all_ge (vector double, vector double);
17535 int vec_all_gt (vector double, vector double);
17536 int vec_all_le (vector double, vector double);
17537 int vec_all_lt (vector double, vector double);
17538 int vec_all_nan (vector double);
17539 int vec_all_ne (vector double, vector double);
17540 int vec_all_nge (vector double, vector double);
17541 int vec_all_ngt (vector double, vector double);
17542 int vec_all_nle (vector double, vector double);
17543 int vec_all_nlt (vector double, vector double);
17544 int vec_all_numeric (vector double);
17545 int vec_any_eq (vector double, vector double);
17546 int vec_any_ge (vector double, vector double);
17547 int vec_any_gt (vector double, vector double);
17548 int vec_any_le (vector double, vector double);
17549 int vec_any_lt (vector double, vector double);
17550 int vec_any_nan (vector double);
17551 int vec_any_ne (vector double, vector double);
17552 int vec_any_nge (vector double, vector double);
17553 int vec_any_ngt (vector double, vector double);
17554 int vec_any_nle (vector double, vector double);
17555 int vec_any_nlt (vector double, vector double);
17556 int vec_any_numeric (vector double);
17558 vector double vec_vsx_ld (int, const vector double *);
17559 vector double vec_vsx_ld (int, const double *);
17560 vector float vec_vsx_ld (int, const vector float *);
17561 vector float vec_vsx_ld (int, const float *);
17562 vector bool int vec_vsx_ld (int, const vector bool int *);
17563 vector signed int vec_vsx_ld (int, const vector signed int *);
17564 vector signed int vec_vsx_ld (int, const int *);
17565 vector signed int vec_vsx_ld (int, const long *);
17566 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
17567 vector unsigned int vec_vsx_ld (int, const unsigned int *);
17568 vector unsigned int vec_vsx_ld (int, const unsigned long *);
17569 vector bool short vec_vsx_ld (int, const vector bool short *);
17570 vector pixel vec_vsx_ld (int, const vector pixel *);
17571 vector signed short vec_vsx_ld (int, const vector signed short *);
17572 vector signed short vec_vsx_ld (int, const short *);
17573 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
17574 vector unsigned short vec_vsx_ld (int, const unsigned short *);
17575 vector bool char vec_vsx_ld (int, const vector bool char *);
17576 vector signed char vec_vsx_ld (int, const vector signed char *);
17577 vector signed char vec_vsx_ld (int, const signed char *);
17578 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
17579 vector unsigned char vec_vsx_ld (int, const unsigned char *);
17581 void vec_vsx_st (vector double, int, vector double *);
17582 void vec_vsx_st (vector double, int, double *);
17583 void vec_vsx_st (vector float, int, vector float *);
17584 void vec_vsx_st (vector float, int, float *);
17585 void vec_vsx_st (vector signed int, int, vector signed int *);
17586 void vec_vsx_st (vector signed int, int, int *);
17587 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
17588 void vec_vsx_st (vector unsigned int, int, unsigned int *);
17589 void vec_vsx_st (vector bool int, int, vector bool int *);
17590 void vec_vsx_st (vector bool int, int, unsigned int *);
17591 void vec_vsx_st (vector bool int, int, int *);
17592 void vec_vsx_st (vector signed short, int, vector signed short *);
17593 void vec_vsx_st (vector signed short, int, short *);
17594 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
17595 void vec_vsx_st (vector unsigned short, int, unsigned short *);
17596 void vec_vsx_st (vector bool short, int, vector bool short *);
17597 void vec_vsx_st (vector bool short, int, unsigned short *);
17598 void vec_vsx_st (vector pixel, int, vector pixel *);
17599 void vec_vsx_st (vector pixel, int, unsigned short *);
17600 void vec_vsx_st (vector pixel, int, short *);
17601 void vec_vsx_st (vector bool short, int, short *);
17602 void vec_vsx_st (vector signed char, int, vector signed char *);
17603 void vec_vsx_st (vector signed char, int, signed char *);
17604 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
17605 void vec_vsx_st (vector unsigned char, int, unsigned char *);
17606 void vec_vsx_st (vector bool char, int, vector bool char *);
17607 void vec_vsx_st (vector bool char, int, unsigned char *);
17608 void vec_vsx_st (vector bool char, int, signed char *);
17610 vector double vec_xxpermdi (vector double, vector double, int);
17611 vector float vec_xxpermdi (vector float, vector float, int);
17612 vector long long vec_xxpermdi (vector long long, vector long long, int);
17613 vector unsigned long long vec_xxpermdi (vector unsigned long long,
17614 vector unsigned long long, int);
17615 vector int vec_xxpermdi (vector int, vector int, int);
17616 vector unsigned int vec_xxpermdi (vector unsigned int,
17617 vector unsigned int, int);
17618 vector short vec_xxpermdi (vector short, vector short, int);
17619 vector unsigned short vec_xxpermdi (vector unsigned short,
17620 vector unsigned short, int);
17621 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
17622 vector unsigned char vec_xxpermdi (vector unsigned char,
17623 vector unsigned char, int);
17625 vector double vec_xxsldi (vector double, vector double, int);
17626 vector float vec_xxsldi (vector float, vector float, int);
17627 vector long long vec_xxsldi (vector long long, vector long long, int);
17628 vector unsigned long long vec_xxsldi (vector unsigned long long,
17629 vector unsigned long long, int);
17630 vector int vec_xxsldi (vector int, vector int, int);
17631 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
17632 vector short vec_xxsldi (vector short, vector short, int);
17633 vector unsigned short vec_xxsldi (vector unsigned short,
17634 vector unsigned short, int);
17635 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
17636 vector unsigned char vec_xxsldi (vector unsigned char,
17637 vector unsigned char, int);
17640 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
17641 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
17642 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
17643 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
17644 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
17646 If the ISA 2.07 additions to the vector/scalar (power8-vector)
17647 instruction set are available, the following additional functions are
17648 available for both 32-bit and 64-bit targets. For 64-bit targets, you
17649 can use @var{vector long} instead of @var{vector long long},
17650 @var{vector bool long} instead of @var{vector bool long long}, and
17651 @var{vector unsigned long} instead of @var{vector unsigned long long}.
17654 vector long long vec_abs (vector long long);
17656 vector long long vec_add (vector long long, vector long long);
17657 vector unsigned long long vec_add (vector unsigned long long,
17658 vector unsigned long long);
17660 int vec_all_eq (vector long long, vector long long);
17661 int vec_all_eq (vector unsigned long long, vector unsigned long long);
17662 int vec_all_ge (vector long long, vector long long);
17663 int vec_all_ge (vector unsigned long long, vector unsigned long long);
17664 int vec_all_gt (vector long long, vector long long);
17665 int vec_all_gt (vector unsigned long long, vector unsigned long long);
17666 int vec_all_le (vector long long, vector long long);
17667 int vec_all_le (vector unsigned long long, vector unsigned long long);
17668 int vec_all_lt (vector long long, vector long long);
17669 int vec_all_lt (vector unsigned long long, vector unsigned long long);
17670 int vec_all_ne (vector long long, vector long long);
17671 int vec_all_ne (vector unsigned long long, vector unsigned long long);
17673 int vec_any_eq (vector long long, vector long long);
17674 int vec_any_eq (vector unsigned long long, vector unsigned long long);
17675 int vec_any_ge (vector long long, vector long long);
17676 int vec_any_ge (vector unsigned long long, vector unsigned long long);
17677 int vec_any_gt (vector long long, vector long long);
17678 int vec_any_gt (vector unsigned long long, vector unsigned long long);
17679 int vec_any_le (vector long long, vector long long);
17680 int vec_any_le (vector unsigned long long, vector unsigned long long);
17681 int vec_any_lt (vector long long, vector long long);
17682 int vec_any_lt (vector unsigned long long, vector unsigned long long);
17683 int vec_any_ne (vector long long, vector long long);
17684 int vec_any_ne (vector unsigned long long, vector unsigned long long);
17686 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
17688 vector long long vec_eqv (vector long long, vector long long);
17689 vector long long vec_eqv (vector bool long long, vector long long);
17690 vector long long vec_eqv (vector long long, vector bool long long);
17691 vector unsigned long long vec_eqv (vector unsigned long long,
17692 vector unsigned long long);
17693 vector unsigned long long vec_eqv (vector bool long long,
17694 vector unsigned long long);
17695 vector unsigned long long vec_eqv (vector unsigned long long,
17696 vector bool long long);
17697 vector int vec_eqv (vector int, vector int);
17698 vector int vec_eqv (vector bool int, vector int);
17699 vector int vec_eqv (vector int, vector bool int);
17700 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
17701 vector unsigned int vec_eqv (vector bool unsigned int,
17702 vector unsigned int);
17703 vector unsigned int vec_eqv (vector unsigned int,
17704 vector bool unsigned int);
17705 vector short vec_eqv (vector short, vector short);
17706 vector short vec_eqv (vector bool short, vector short);
17707 vector short vec_eqv (vector short, vector bool short);
17708 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
17709 vector unsigned short vec_eqv (vector bool unsigned short,
17710 vector unsigned short);
17711 vector unsigned short vec_eqv (vector unsigned short,
17712 vector bool unsigned short);
17713 vector signed char vec_eqv (vector signed char, vector signed char);
17714 vector signed char vec_eqv (vector bool signed char, vector signed char);
17715 vector signed char vec_eqv (vector signed char, vector bool signed char);
17716 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
17717 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
17718 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
17720 vector long long vec_max (vector long long, vector long long);
17721 vector unsigned long long vec_max (vector unsigned long long,
17722 vector unsigned long long);
17724 vector signed int vec_mergee (vector signed int, vector signed int);
17725 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
17726 vector bool int vec_mergee (vector bool int, vector bool int);
17728 vector signed int vec_mergeo (vector signed int, vector signed int);
17729 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
17730 vector bool int vec_mergeo (vector bool int, vector bool int);
17732 vector long long vec_min (vector long long, vector long long);
17733 vector unsigned long long vec_min (vector unsigned long long,
17734 vector unsigned long long);
17736 vector signed long long vec_nabs (vector signed long long);
17738 vector long long vec_nand (vector long long, vector long long);
17739 vector long long vec_nand (vector bool long long, vector long long);
17740 vector long long vec_nand (vector long long, vector bool long long);
17741 vector unsigned long long vec_nand (vector unsigned long long,
17742 vector unsigned long long);
17743 vector unsigned long long vec_nand (vector bool long long,
17744 vector unsigned long long);
17745 vector unsigned long long vec_nand (vector unsigned long long,
17746 vector bool long long);
17747 vector int vec_nand (vector int, vector int);
17748 vector int vec_nand (vector bool int, vector int);
17749 vector int vec_nand (vector int, vector bool int);
17750 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
17751 vector unsigned int vec_nand (vector bool unsigned int,
17752 vector unsigned int);
17753 vector unsigned int vec_nand (vector unsigned int,
17754 vector bool unsigned int);
17755 vector short vec_nand (vector short, vector short);
17756 vector short vec_nand (vector bool short, vector short);
17757 vector short vec_nand (vector short, vector bool short);
17758 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
17759 vector unsigned short vec_nand (vector bool unsigned short,
17760 vector unsigned short);
17761 vector unsigned short vec_nand (vector unsigned short,
17762 vector bool unsigned short);
17763 vector signed char vec_nand (vector signed char, vector signed char);
17764 vector signed char vec_nand (vector bool signed char, vector signed char);
17765 vector signed char vec_nand (vector signed char, vector bool signed char);
17766 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
17767 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
17768 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
17770 vector long long vec_orc (vector long long, vector long long);
17771 vector long long vec_orc (vector bool long long, vector long long);
17772 vector long long vec_orc (vector long long, vector bool long long);
17773 vector unsigned long long vec_orc (vector unsigned long long,
17774 vector unsigned long long);
17775 vector unsigned long long vec_orc (vector bool long long,
17776 vector unsigned long long);
17777 vector unsigned long long vec_orc (vector unsigned long long,
17778 vector bool long long);
17779 vector int vec_orc (vector int, vector int);
17780 vector int vec_orc (vector bool int, vector int);
17781 vector int vec_orc (vector int, vector bool int);
17782 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
17783 vector unsigned int vec_orc (vector bool unsigned int,
17784 vector unsigned int);
17785 vector unsigned int vec_orc (vector unsigned int,
17786 vector bool unsigned int);
17787 vector short vec_orc (vector short, vector short);
17788 vector short vec_orc (vector bool short, vector short);
17789 vector short vec_orc (vector short, vector bool short);
17790 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
17791 vector unsigned short vec_orc (vector bool unsigned short,
17792 vector unsigned short);
17793 vector unsigned short vec_orc (vector unsigned short,
17794 vector bool unsigned short);
17795 vector signed char vec_orc (vector signed char, vector signed char);
17796 vector signed char vec_orc (vector bool signed char, vector signed char);
17797 vector signed char vec_orc (vector signed char, vector bool signed char);
17798 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
17799 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
17800 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
17802 vector int vec_pack (vector long long, vector long long);
17803 vector unsigned int vec_pack (vector unsigned long long,
17804 vector unsigned long long);
17805 vector bool int vec_pack (vector bool long long, vector bool long long);
17806 vector float vec_pack (vector double, vector double);
17808 vector int vec_packs (vector long long, vector long long);
17809 vector unsigned int vec_packs (vector unsigned long long,
17810 vector unsigned long long);
17812 vector unsigned int vec_packsu (vector long long, vector long long);
17813 vector unsigned int vec_packsu (vector unsigned long long,
17814 vector unsigned long long);
17816 vector long long vec_rl (vector long long,
17817 vector unsigned long long);
17818 vector long long vec_rl (vector unsigned long long,
17819 vector unsigned long long);
17821 vector long long vec_sl (vector long long, vector unsigned long long);
17822 vector long long vec_sl (vector unsigned long long,
17823 vector unsigned long long);
17825 vector long long vec_sr (vector long long, vector unsigned long long);
17826 vector unsigned long long char vec_sr (vector unsigned long long,
17827 vector unsigned long long);
17829 vector long long vec_sra (vector long long, vector unsigned long long);
17830 vector unsigned long long vec_sra (vector unsigned long long,
17831 vector unsigned long long);
17833 vector long long vec_sub (vector long long, vector long long);
17834 vector unsigned long long vec_sub (vector unsigned long long,
17835 vector unsigned long long);
17837 vector long long vec_unpackh (vector int);
17838 vector unsigned long long vec_unpackh (vector unsigned int);
17840 vector long long vec_unpackl (vector int);
17841 vector unsigned long long vec_unpackl (vector unsigned int);
17843 vector long long vec_vaddudm (vector long long, vector long long);
17844 vector long long vec_vaddudm (vector bool long long, vector long long);
17845 vector long long vec_vaddudm (vector long long, vector bool long long);
17846 vector unsigned long long vec_vaddudm (vector unsigned long long,
17847 vector unsigned long long);
17848 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
17849 vector unsigned long long);
17850 vector unsigned long long vec_vaddudm (vector unsigned long long,
17851 vector bool unsigned long long);
17853 vector long long vec_vbpermq (vector signed char, vector signed char);
17854 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
17856 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
17857 vector unsigned long long vec_bperm (vector unsigned __int128,
17858 vector unsigned char);
17860 vector long long vec_cntlz (vector long long);
17861 vector unsigned long long vec_cntlz (vector unsigned long long);
17862 vector int vec_cntlz (vector int);
17863 vector unsigned int vec_cntlz (vector int);
17864 vector short vec_cntlz (vector short);
17865 vector unsigned short vec_cntlz (vector unsigned short);
17866 vector signed char vec_cntlz (vector signed char);
17867 vector unsigned char vec_cntlz (vector unsigned char);
17869 vector long long vec_vclz (vector long long);
17870 vector unsigned long long vec_vclz (vector unsigned long long);
17871 vector int vec_vclz (vector int);
17872 vector unsigned int vec_vclz (vector int);
17873 vector short vec_vclz (vector short);
17874 vector unsigned short vec_vclz (vector unsigned short);
17875 vector signed char vec_vclz (vector signed char);
17876 vector unsigned char vec_vclz (vector unsigned char);
17878 vector signed char vec_vclzb (vector signed char);
17879 vector unsigned char vec_vclzb (vector unsigned char);
17881 vector long long vec_vclzd (vector long long);
17882 vector unsigned long long vec_vclzd (vector unsigned long long);
17884 vector short vec_vclzh (vector short);
17885 vector unsigned short vec_vclzh (vector unsigned short);
17887 vector int vec_vclzw (vector int);
17888 vector unsigned int vec_vclzw (vector int);
17890 vector signed char vec_vgbbd (vector signed char);
17891 vector unsigned char vec_vgbbd (vector unsigned char);
17893 vector long long vec_vmaxsd (vector long long, vector long long);
17895 vector unsigned long long vec_vmaxud (vector unsigned long long,
17896 unsigned vector long long);
17898 vector long long vec_vminsd (vector long long, vector long long);
17900 vector unsigned long long vec_vminud (vector long long,
17903 vector int vec_vpksdss (vector long long, vector long long);
17904 vector unsigned int vec_vpksdss (vector long long, vector long long);
17906 vector unsigned int vec_vpkudus (vector unsigned long long,
17907 vector unsigned long long);
17909 vector int vec_vpkudum (vector long long, vector long long);
17910 vector unsigned int vec_vpkudum (vector unsigned long long,
17911 vector unsigned long long);
17912 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
17914 vector long long vec_vpopcnt (vector long long);
17915 vector unsigned long long vec_vpopcnt (vector unsigned long long);
17916 vector int vec_vpopcnt (vector int);
17917 vector unsigned int vec_vpopcnt (vector int);
17918 vector short vec_vpopcnt (vector short);
17919 vector unsigned short vec_vpopcnt (vector unsigned short);
17920 vector signed char vec_vpopcnt (vector signed char);
17921 vector unsigned char vec_vpopcnt (vector unsigned char);
17923 vector signed char vec_vpopcntb (vector signed char);
17924 vector unsigned char vec_vpopcntb (vector unsigned char);
17926 vector long long vec_vpopcntd (vector long long);
17927 vector unsigned long long vec_vpopcntd (vector unsigned long long);
17929 vector short vec_vpopcnth (vector short);
17930 vector unsigned short vec_vpopcnth (vector unsigned short);
17932 vector int vec_vpopcntw (vector int);
17933 vector unsigned int vec_vpopcntw (vector int);
17935 vector long long vec_vrld (vector long long, vector unsigned long long);
17936 vector unsigned long long vec_vrld (vector unsigned long long,
17937 vector unsigned long long);
17939 vector long long vec_vsld (vector long long, vector unsigned long long);
17940 vector long long vec_vsld (vector unsigned long long,
17941 vector unsigned long long);
17943 vector long long vec_vsrad (vector long long, vector unsigned long long);
17944 vector unsigned long long vec_vsrad (vector unsigned long long,
17945 vector unsigned long long);
17947 vector long long vec_vsrd (vector long long, vector unsigned long long);
17948 vector unsigned long long char vec_vsrd (vector unsigned long long,
17949 vector unsigned long long);
17951 vector long long vec_vsubudm (vector long long, vector long long);
17952 vector long long vec_vsubudm (vector bool long long, vector long long);
17953 vector long long vec_vsubudm (vector long long, vector bool long long);
17954 vector unsigned long long vec_vsubudm (vector unsigned long long,
17955 vector unsigned long long);
17956 vector unsigned long long vec_vsubudm (vector bool long long,
17957 vector unsigned long long);
17958 vector unsigned long long vec_vsubudm (vector unsigned long long,
17959 vector bool long long);
17961 vector long long vec_vupkhsw (vector int);
17962 vector unsigned long long vec_vupkhsw (vector unsigned int);
17964 vector long long vec_vupklsw (vector int);
17965 vector unsigned long long vec_vupklsw (vector int);
17968 If the ISA 2.07 additions to the vector/scalar (power8-vector)
17969 instruction set are available, the following additional functions are
17970 available for 64-bit targets. New vector types
17971 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
17972 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
17975 The normal vector extract, and set operations work on
17976 @var{vector __int128_t} and @var{vector __uint128_t} types,
17977 but the index value must be 0.
17980 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
17981 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
17983 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
17984 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
17986 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
17987 vector __int128_t);
17988 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
17989 vector __uint128_t);
17991 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
17992 vector __int128_t);
17993 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
17994 vector __uint128_t);
17996 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
17997 vector __int128_t);
17998 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
17999 vector __uint128_t);
18001 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
18002 vector __int128_t);
18003 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
18004 vector __uint128_t);
18006 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
18007 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
18009 __int128_t vec_vsubuqm (__int128_t, __int128_t);
18010 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
18012 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
18013 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
18014 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
18015 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
18016 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
18017 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
18018 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
18019 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
18020 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
18021 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
18024 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18028 vector unsigned long long vec_bperm (vector unsigned long long,
18029 vector unsigned char);
18031 vector bool char vec_cmpne (vector bool char, vector bool char);
18032 vector bool short vec_cmpne (vector bool short, vector bool short);
18033 vector bool int vec_cmpne (vector bool int, vector bool int);
18034 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
18036 vector long long vec_vctz (vector long long);
18037 vector unsigned long long vec_vctz (vector unsigned long long);
18038 vector int vec_vctz (vector int);
18039 vector unsigned int vec_vctz (vector int);
18040 vector short vec_vctz (vector short);
18041 vector unsigned short vec_vctz (vector unsigned short);
18042 vector signed char vec_vctz (vector signed char);
18043 vector unsigned char vec_vctz (vector unsigned char);
18045 vector signed char vec_vctzb (vector signed char);
18046 vector unsigned char vec_vctzb (vector unsigned char);
18048 vector long long vec_vctzd (vector long long);
18049 vector unsigned long long vec_vctzd (vector unsigned long long);
18051 vector short vec_vctzh (vector short);
18052 vector unsigned short vec_vctzh (vector unsigned short);
18054 vector int vec_vctzw (vector int);
18055 vector unsigned int vec_vctzw (vector int);
18057 long long vec_vextract4b (const vector signed char, const int);
18058 long long vec_vextract4b (const vector unsigned char, const int);
18060 vector signed char vec_insert4b (vector int, vector signed char, const int);
18061 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
18063 vector signed char vec_insert4b (long long, vector signed char, const int);
18064 vector unsigned char vec_insert4b (long long, vector unsigned char, const int);
18066 vector int vec_vprtyb (vector int);
18067 vector unsigned int vec_vprtyb (vector unsigned int);
18068 vector long long vec_vprtyb (vector long long);
18069 vector unsigned long long vec_vprtyb (vector unsigned long long);
18071 vector int vec_vprtybw (vector int);
18072 vector unsigned int vec_vprtybw (vector unsigned int);
18074 vector long long vec_vprtybd (vector long long);
18075 vector unsigned long long vec_vprtybd (vector unsigned long long);
18078 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
18082 vector long vec_vprtyb (vector long);
18083 vector unsigned long vec_vprtyb (vector unsigned long);
18084 vector __int128_t vec_vprtyb (vector __int128_t);
18085 vector __uint128_t vec_vprtyb (vector __uint128_t);
18087 vector long vec_vprtybd (vector long);
18088 vector unsigned long vec_vprtybd (vector unsigned long);
18090 vector __int128_t vec_vprtybq (vector __int128_t);
18091 vector __uint128_t vec_vprtybd (vector __uint128_t);
18094 The following built-in vector functions are available for the PowerPC family
18095 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18097 __vector unsigned char
18098 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
18099 __vector unsigned char
18100 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
18103 The @code{vec_slv} and @code{vec_srv} functions operate on
18104 all of the bytes of their @code{src} and @code{shift_distance}
18105 arguments in parallel. The behavior of the @code{vec_slv} is as if
18106 there existed a temporary array of 17 unsigned characters
18107 @code{slv_array} within which elements 0 through 15 are the same as
18108 the entries in the @code{src} array and element 16 equals 0. The
18109 result returned from the @code{vec_slv} function is a
18110 @code{__vector} of 16 unsigned characters within which element
18111 @code{i} is computed using the C expression
18112 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
18113 shift_distance[i]))},
18114 with this resulting value coerced to the @code{unsigned char} type.
18115 The behavior of the @code{vec_srv} is as if
18116 there existed a temporary array of 17 unsigned characters
18117 @code{srv_array} within which element 0 equals zero and
18118 elements 1 through 16 equal the elements 0 through 15 of
18119 the @code{src} array. The
18120 result returned from the @code{vec_srv} function is a
18121 @code{__vector} of 16 unsigned characters within which element
18122 @code{i} is computed using the C expression
18123 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
18124 (0x07 & shift_distance[i]))},
18125 with this resulting value coerced to the @code{unsigned char} type.
18127 The following built-in functions are available for the PowerPC family
18128 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18130 __vector unsigned char
18131 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
18132 __vector unsigned short
18133 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
18134 __vector unsigned int
18135 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
18137 __vector unsigned char
18138 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
18139 __vector unsigned short
18140 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
18141 __vector unsigned int
18142 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
18145 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
18146 @code{vec_absdw} built-in functions each computes the absolute
18147 differences of the pairs of vector elements supplied in its two vector
18148 arguments, placing the absolute differences into the corresponding
18149 elements of the vector result.
18151 The following built-in functions are available for the PowerPC family
18152 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18154 __vector unsigned int
18155 vec_extract_exp (__vector float source);
18156 __vector unsigned long long int
18157 vec_extract_exp (__vector double source);
18159 __vector unsigned int
18160 vec_extract_sig (__vector float source);
18161 __vector unsigned long long int
18162 vec_extract_sig (__vector double source);
18165 vec_insert_exp (__vector unsigned int significands,
18166 __vector unsigned int exponents);
18168 vec_insert_exp (__vector unsigned float significands,
18169 __vector unsigned int exponents);
18171 vec_insert_exp (__vector unsigned long long int significands,
18172 __vector unsigned long long int exponents);
18174 vec_insert_exp (__vector unsigned double significands,
18175 __vector unsigned long long int exponents);
18177 __vector bool int vec_test_data_class (__vector float source,
18178 const int condition);
18179 __vector bool long long int vec_test_data_class (__vector double source,
18180 const int condition);
18183 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
18184 functions return vectors representing the significands and biased
18185 exponent values of their @code{source} arguments respectively.
18186 Within the result vector returned by @code{vec_extract_sig}, the
18187 @code{0x800000} bit of each vector element returned when the
18188 function's @code{source} argument is of type @code{float} is set to 1
18189 if the corresponding floating point value is in normalized form.
18190 Otherwise, this bit is set to 0. When the @code{source} argument is
18191 of type @code{double}, the @code{0x10000000000000} bit within each of
18192 the result vector's elements is set according to the same rules.
18193 Note that the sign of the significand is not represented in the result
18194 returned from the @code{vec_extract_sig} function. To extract the
18196 @code{vec_cpsgn} function, which returns a new vector within which all
18197 of the sign bits of its second argument vector are overwritten with the
18198 sign bits copied from the coresponding elements of its first argument
18199 vector, and all other (non-sign) bits of the second argument vector
18200 are copied unchanged into the result vector.
18202 The @code{vec_insert_exp} built-in functions return a vector of
18203 single- or double-precision floating
18204 point values constructed by assembling the values of their
18205 @code{significands} and @code{exponents} arguments into the
18206 corresponding elements of the returned vector.
18208 element of the result is copied from the most significant bit of the
18209 corresponding entry within the @code{significands} argument.
18210 Note that the relevant
18211 bits of the @code{significands} argument are the same, for both integer
18212 and floating point types.
18214 significand and exponent components of each element of the result are
18215 composed of the least significant bits of the corresponding
18216 @code{significands} element and the least significant bits of the
18217 corresponding @code{exponents} element.
18219 The @code{vec_test_data_class} built-in function returns a vector
18220 representing the results of testing the @code{source} vector for the
18221 condition selected by the @code{condition} argument. The
18222 @code{condition} argument must be a compile-time constant integer with
18223 value not exceeding 127. The
18224 @code{condition} argument is encoded as a bitmask with each bit
18225 enabling the testing of a different condition, as characterized by the
18229 0x20 Test for +Infinity
18230 0x10 Test for -Infinity
18231 0x08 Test for +Zero
18232 0x04 Test for -Zero
18233 0x02 Test for +Denormal
18234 0x01 Test for -Denormal
18237 If any of the enabled test conditions is true, the corresponding entry
18238 in the result vector is -1. Otherwise (all of the enabled test
18239 conditions are false), the corresponding entry of the result vector is 0.
18241 The following built-in functions are available for the PowerPC family
18242 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18244 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
18245 vector unsigned int);
18246 vector unsigned long long vec_rlmi (vector unsigned long long,
18247 vector unsigned long long,
18248 vector unsigned long long);
18249 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
18250 vector unsigned int);
18251 vector unsigned long long vec_rlnm (vector unsigned long long,
18252 vector unsigned long long,
18253 vector unsigned long long);
18254 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
18255 vector unsigned long long vec_vrlnm (vector unsigned long long,
18256 vector unsigned long long);
18259 The result of @code{vec_rlmi} is obtained by rotating each element of
18260 the first argument vector left and inserting it under mask into the
18261 second argument vector. The third argument vector contains the mask
18262 beginning in bits 11:15, the mask end in bits 19:23, and the shift
18263 count in bits 27:31, of each element.
18265 The result of @code{vec_rlnm} is obtained by rotating each element of
18266 the first argument vector left and ANDing it with a mask specified by
18267 the second and third argument vectors. The second argument vector
18268 contains the shift count for each element in the low-order byte. The
18269 third argument vector contains the mask end for each element in the
18270 low-order byte, with the mask begin in the next higher byte.
18272 The result of @code{vec_vrlnm} is obtained by rotating each element
18273 of the first argument vector left and ANDing it with a mask. The
18274 second argument vector contains the mask beginning in bits 11:15,
18275 the mask end in bits 19:23, and the shift count in bits 27:31,
18278 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18281 vector signed char vec_revb (vector signed char);
18282 vector unsigned char vec_revb (vector unsigned char);
18283 vector short vec_revb (vector short);
18284 vector unsigned short vec_revb (vector unsigned short);
18285 vector int vec_revb (vector int);
18286 vector unsigned int vec_revb (vector unsigned int);
18287 vector float vec_revb (vector float);
18288 vector long long vec_revb (vector long long);
18289 vector unsigned long long vec_revb (vector unsigned long long);
18290 vector double vec_revb (vector double);
18293 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
18296 vector long vec_revb (vector long);
18297 vector unsigned long vec_revb (vector unsigned long);
18298 vector __int128_t vec_revb (vector __int128_t);
18299 vector __uint128_t vec_revb (vector __uint128_t);
18302 The @code{vec_revb} built-in function reverses the bytes on an element
18303 by element basis. A vector of @code{vector unsigned char} or
18304 @code{vector signed char} reverses the bytes in the whole word.
18306 If the cryptographic instructions are enabled (@option{-mcrypto} or
18307 @option{-mcpu=power8}), the following builtins are enabled.
18310 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
18312 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
18313 vector unsigned long long);
18315 vector unsigned long long __builtin_crypto_vcipherlast
18316 (vector unsigned long long,
18317 vector unsigned long long);
18319 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
18320 vector unsigned long long);
18322 vector unsigned long long __builtin_crypto_vncipherlast
18323 (vector unsigned long long,
18324 vector unsigned long long);
18326 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
18327 vector unsigned char,
18328 vector unsigned char);
18330 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
18331 vector unsigned short,
18332 vector unsigned short);
18334 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
18335 vector unsigned int,
18336 vector unsigned int);
18338 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
18339 vector unsigned long long,
18340 vector unsigned long long);
18342 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
18343 vector unsigned char);
18345 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
18346 vector unsigned short);
18348 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
18349 vector unsigned int);
18351 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
18352 vector unsigned long long);
18354 vector unsigned long long __builtin_crypto_vshasigmad
18355 (vector unsigned long long, int, int);
18357 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
18361 The second argument to @var{__builtin_crypto_vshasigmad} and
18362 @var{__builtin_crypto_vshasigmaw} must be a constant
18363 integer that is 0 or 1. The third argument to these built-in functions
18364 must be a constant integer in the range of 0 to 15.
18366 If the ISA 3.0 instruction set additions
18367 are enabled (@option{-mcpu=power9}), the following additional
18368 functions are available for both 32-bit and 64-bit targets.
18370 vector short vec_xl (int, vector short *);
18371 vector short vec_xl (int, short *);
18372 vector unsigned short vec_xl (int, vector unsigned short *);
18373 vector unsigned short vec_xl (int, unsigned short *);
18374 vector char vec_xl (int, vector char *);
18375 vector char vec_xl (int, char *);
18376 vector unsigned char vec_xl (int, vector unsigned char *);
18377 vector unsigned char vec_xl (int, unsigned char *);
18379 void vec_xst (vector short, int, vector short *);
18380 void vec_xst (vector short, int, short *);
18381 void vec_xst (vector unsigned short, int, vector unsigned short *);
18382 void vec_xst (vector unsigned short, int, unsigned short *);
18383 void vec_xst (vector char, int, vector char *);
18384 void vec_xst (vector char, int, char *);
18385 void vec_xst (vector unsigned char, int, vector unsigned char *);
18386 void vec_xst (vector unsigned char, int, unsigned char *);
18388 @node PowerPC Hardware Transactional Memory Built-in Functions
18389 @subsection PowerPC Hardware Transactional Memory Built-in Functions
18390 GCC provides two interfaces for accessing the Hardware Transactional
18391 Memory (HTM) instructions available on some of the PowerPC family
18392 of processors (eg, POWER8). The two interfaces come in a low level
18393 interface, consisting of built-in functions specific to PowerPC and a
18394 higher level interface consisting of inline functions that are common
18395 between PowerPC and S/390.
18397 @subsubsection PowerPC HTM Low Level Built-in Functions
18399 The following low level built-in functions are available with
18400 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
18401 They all generate the machine instruction that is part of the name.
18403 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
18404 the full 4-bit condition register value set by their associated hardware
18405 instruction. The header file @code{htmintrin.h} defines some macros that can
18406 be used to decipher the return value. The @code{__builtin_tbegin} builtin
18407 returns a simple true or false value depending on whether a transaction was
18408 successfully started or not. The arguments of the builtins match exactly the
18409 type and order of the associated hardware instruction's operands, except for
18410 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
18411 Refer to the ISA manual for a description of each instruction's operands.
18414 unsigned int __builtin_tbegin (unsigned int)
18415 unsigned int __builtin_tend (unsigned int)
18417 unsigned int __builtin_tabort (unsigned int)
18418 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
18419 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
18420 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
18421 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
18423 unsigned int __builtin_tcheck (void)
18424 unsigned int __builtin_treclaim (unsigned int)
18425 unsigned int __builtin_trechkpt (void)
18426 unsigned int __builtin_tsr (unsigned int)
18429 In addition to the above HTM built-ins, we have added built-ins for
18430 some common extended mnemonics of the HTM instructions:
18433 unsigned int __builtin_tendall (void)
18434 unsigned int __builtin_tresume (void)
18435 unsigned int __builtin_tsuspend (void)
18438 Note that the semantics of the above HTM builtins are required to mimic
18439 the locking semantics used for critical sections. Builtins that are used
18440 to create a new transaction or restart a suspended transaction must have
18441 lock acquisition like semantics while those builtins that end or suspend a
18442 transaction must have lock release like semantics. Specifically, this must
18443 mimic lock semantics as specified by C++11, for example: Lock acquisition is
18444 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
18445 that returns 0, and lock release is as-if an execution of
18446 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
18447 implicit implementation-defined lock used for all transactions. The HTM
18448 instructions associated with with the builtins inherently provide the
18449 correct acquisition and release hardware barriers required. However,
18450 the compiler must also be prohibited from moving loads and stores across
18451 the builtins in a way that would violate their semantics. This has been
18452 accomplished by adding memory barriers to the associated HTM instructions
18453 (which is a conservative approach to provide acquire and release semantics).
18454 Earlier versions of the compiler did not treat the HTM instructions as
18455 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
18456 be used to determine whether the current compiler treats HTM instructions
18457 as memory barriers or not. This allows the user to explicitly add memory
18458 barriers to their code when using an older version of the compiler.
18460 The following set of built-in functions are available to gain access
18461 to the HTM specific special purpose registers.
18464 unsigned long __builtin_get_texasr (void)
18465 unsigned long __builtin_get_texasru (void)
18466 unsigned long __builtin_get_tfhar (void)
18467 unsigned long __builtin_get_tfiar (void)
18469 void __builtin_set_texasr (unsigned long);
18470 void __builtin_set_texasru (unsigned long);
18471 void __builtin_set_tfhar (unsigned long);
18472 void __builtin_set_tfiar (unsigned long);
18475 Example usage of these low level built-in functions may look like:
18478 #include <htmintrin.h>
18480 int num_retries = 10;
18484 if (__builtin_tbegin (0))
18486 /* Transaction State Initiated. */
18487 if (is_locked (lock))
18488 __builtin_tabort (0);
18489 ... transaction code...
18490 __builtin_tend (0);
18495 /* Transaction State Failed. Use locks if the transaction
18496 failure is "persistent" or we've tried too many times. */
18497 if (num_retries-- <= 0
18498 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
18500 acquire_lock (lock);
18501 ... non transactional fallback path...
18502 release_lock (lock);
18509 One final built-in function has been added that returns the value of
18510 the 2-bit Transaction State field of the Machine Status Register (MSR)
18511 as stored in @code{CR0}.
18514 unsigned long __builtin_ttest (void)
18517 This built-in can be used to determine the current transaction state
18518 using the following code example:
18521 #include <htmintrin.h>
18523 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
18525 if (tx_state == _HTM_TRANSACTIONAL)
18527 /* Code to use in transactional state. */
18529 else if (tx_state == _HTM_NONTRANSACTIONAL)
18531 /* Code to use in non-transactional state. */
18533 else if (tx_state == _HTM_SUSPENDED)
18535 /* Code to use in transaction suspended state. */
18539 @subsubsection PowerPC HTM High Level Inline Functions
18541 The following high level HTM interface is made available by including
18542 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
18543 where CPU is `power8' or later. This interface is common between PowerPC
18544 and S/390, allowing users to write one HTM source implementation that
18545 can be compiled and executed on either system.
18548 long __TM_simple_begin (void)
18549 long __TM_begin (void* const TM_buff)
18550 long __TM_end (void)
18551 void __TM_abort (void)
18552 void __TM_named_abort (unsigned char const code)
18553 void __TM_resume (void)
18554 void __TM_suspend (void)
18556 long __TM_is_user_abort (void* const TM_buff)
18557 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
18558 long __TM_is_illegal (void* const TM_buff)
18559 long __TM_is_footprint_exceeded (void* const TM_buff)
18560 long __TM_nesting_depth (void* const TM_buff)
18561 long __TM_is_nested_too_deep(void* const TM_buff)
18562 long __TM_is_conflict(void* const TM_buff)
18563 long __TM_is_failure_persistent(void* const TM_buff)
18564 long __TM_failure_address(void* const TM_buff)
18565 long long __TM_failure_code(void* const TM_buff)
18568 Using these common set of HTM inline functions, we can create
18569 a more portable version of the HTM example in the previous
18570 section that will work on either PowerPC or S/390:
18573 #include <htmxlintrin.h>
18575 int num_retries = 10;
18576 TM_buff_type TM_buff;
18580 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
18582 /* Transaction State Initiated. */
18583 if (is_locked (lock))
18585 ... transaction code...
18591 /* Transaction State Failed. Use locks if the transaction
18592 failure is "persistent" or we've tried too many times. */
18593 if (num_retries-- <= 0
18594 || __TM_is_failure_persistent (TM_buff))
18596 acquire_lock (lock);
18597 ... non transactional fallback path...
18598 release_lock (lock);
18605 @node RX Built-in Functions
18606 @subsection RX Built-in Functions
18607 GCC supports some of the RX instructions which cannot be expressed in
18608 the C programming language via the use of built-in functions. The
18609 following functions are supported:
18611 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
18612 Generates the @code{brk} machine instruction.
18615 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
18616 Generates the @code{clrpsw} machine instruction to clear the specified
18617 bit in the processor status word.
18620 @deftypefn {Built-in Function} void __builtin_rx_int (int)
18621 Generates the @code{int} machine instruction to generate an interrupt
18622 with the specified value.
18625 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
18626 Generates the @code{machi} machine instruction to add the result of
18627 multiplying the top 16 bits of the two arguments into the
18631 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
18632 Generates the @code{maclo} machine instruction to add the result of
18633 multiplying the bottom 16 bits of the two arguments into the
18637 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
18638 Generates the @code{mulhi} machine instruction to place the result of
18639 multiplying the top 16 bits of the two arguments into the
18643 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
18644 Generates the @code{mullo} machine instruction to place the result of
18645 multiplying the bottom 16 bits of the two arguments into the
18649 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
18650 Generates the @code{mvfachi} machine instruction to read the top
18651 32 bits of the accumulator.
18654 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
18655 Generates the @code{mvfacmi} machine instruction to read the middle
18656 32 bits of the accumulator.
18659 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
18660 Generates the @code{mvfc} machine instruction which reads the control
18661 register specified in its argument and returns its value.
18664 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
18665 Generates the @code{mvtachi} machine instruction to set the top
18666 32 bits of the accumulator.
18669 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
18670 Generates the @code{mvtaclo} machine instruction to set the bottom
18671 32 bits of the accumulator.
18674 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
18675 Generates the @code{mvtc} machine instruction which sets control
18676 register number @code{reg} to @code{val}.
18679 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
18680 Generates the @code{mvtipl} machine instruction set the interrupt
18684 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
18685 Generates the @code{racw} machine instruction to round the accumulator
18686 according to the specified mode.
18689 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
18690 Generates the @code{revw} machine instruction which swaps the bytes in
18691 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
18692 and also bits 16--23 occupy bits 24--31 and vice versa.
18695 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
18696 Generates the @code{rmpa} machine instruction which initiates a
18697 repeated multiply and accumulate sequence.
18700 @deftypefn {Built-in Function} void __builtin_rx_round (float)
18701 Generates the @code{round} machine instruction which returns the
18702 floating-point argument rounded according to the current rounding mode
18703 set in the floating-point status word register.
18706 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
18707 Generates the @code{sat} machine instruction which returns the
18708 saturated value of the argument.
18711 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
18712 Generates the @code{setpsw} machine instruction to set the specified
18713 bit in the processor status word.
18716 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
18717 Generates the @code{wait} machine instruction.
18720 @node S/390 System z Built-in Functions
18721 @subsection S/390 System z Built-in Functions
18722 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
18723 Generates the @code{tbegin} machine instruction starting a
18724 non-constrained hardware transaction. If the parameter is non-NULL the
18725 memory area is used to store the transaction diagnostic buffer and
18726 will be passed as first operand to @code{tbegin}. This buffer can be
18727 defined using the @code{struct __htm_tdb} C struct defined in
18728 @code{htmintrin.h} and must reside on a double-word boundary. The
18729 second tbegin operand is set to @code{0xff0c}. This enables
18730 save/restore of all GPRs and disables aborts for FPR and AR
18731 manipulations inside the transaction body. The condition code set by
18732 the tbegin instruction is returned as integer value. The tbegin
18733 instruction by definition overwrites the content of all FPRs. The
18734 compiler will generate code which saves and restores the FPRs. For
18735 soft-float code it is recommended to used the @code{*_nofloat}
18736 variant. In order to prevent a TDB from being written it is required
18737 to pass a constant zero value as parameter. Passing a zero value
18738 through a variable is not sufficient. Although modifications of
18739 access registers inside the transaction will not trigger an
18740 transaction abort it is not supported to actually modify them. Access
18741 registers do not get saved when entering a transaction. They will have
18742 undefined state when reaching the abort code.
18745 Macros for the possible return codes of tbegin are defined in the
18746 @code{htmintrin.h} header file:
18749 @item _HTM_TBEGIN_STARTED
18750 @code{tbegin} has been executed as part of normal processing. The
18751 transaction body is supposed to be executed.
18752 @item _HTM_TBEGIN_INDETERMINATE
18753 The transaction was aborted due to an indeterminate condition which
18754 might be persistent.
18755 @item _HTM_TBEGIN_TRANSIENT
18756 The transaction aborted due to a transient failure. The transaction
18757 should be re-executed in that case.
18758 @item _HTM_TBEGIN_PERSISTENT
18759 The transaction aborted due to a persistent failure. Re-execution
18760 under same circumstances will not be productive.
18763 @defmac _HTM_FIRST_USER_ABORT_CODE
18764 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
18765 specifies the first abort code which can be used for
18766 @code{__builtin_tabort}. Values below this threshold are reserved for
18770 @deftp {Data type} {struct __htm_tdb}
18771 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
18772 the structure of the transaction diagnostic block as specified in the
18773 Principles of Operation manual chapter 5-91.
18776 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
18777 Same as @code{__builtin_tbegin} but without FPR saves and restores.
18778 Using this variant in code making use of FPRs will leave the FPRs in
18779 undefined state when entering the transaction abort handler code.
18782 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
18783 In addition to @code{__builtin_tbegin} a loop for transient failures
18784 is generated. If tbegin returns a condition code of 2 the transaction
18785 will be retried as often as specified in the second argument. The
18786 perform processor assist instruction is used to tell the CPU about the
18787 number of fails so far.
18790 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
18791 Same as @code{__builtin_tbegin_retry} but without FPR saves and
18792 restores. Using this variant in code making use of FPRs will leave
18793 the FPRs in undefined state when entering the transaction abort
18797 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
18798 Generates the @code{tbeginc} machine instruction starting a constrained
18799 hardware transaction. The second operand is set to @code{0xff08}.
18802 @deftypefn {Built-in Function} int __builtin_tend (void)
18803 Generates the @code{tend} machine instruction finishing a transaction
18804 and making the changes visible to other threads. The condition code
18805 generated by tend is returned as integer value.
18808 @deftypefn {Built-in Function} void __builtin_tabort (int)
18809 Generates the @code{tabort} machine instruction with the specified
18810 abort code. Abort codes from 0 through 255 are reserved and will
18811 result in an error message.
18814 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
18815 Generates the @code{ppa rX,rY,1} machine instruction. Where the
18816 integer parameter is loaded into rX and a value of zero is loaded into
18817 rY. The integer parameter specifies the number of times the
18818 transaction repeatedly aborted.
18821 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
18822 Generates the @code{etnd} machine instruction. The current nesting
18823 depth is returned as integer value. For a nesting depth of 0 the code
18824 is not executed as part of an transaction.
18827 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
18829 Generates the @code{ntstg} machine instruction. The second argument
18830 is written to the first arguments location. The store operation will
18831 not be rolled-back in case of an transaction abort.
18834 @node SH Built-in Functions
18835 @subsection SH Built-in Functions
18836 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
18837 families of processors:
18839 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
18840 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
18841 used by system code that manages threads and execution contexts. The compiler
18842 normally does not generate code that modifies the contents of @samp{GBR} and
18843 thus the value is preserved across function calls. Changing the @samp{GBR}
18844 value in user code must be done with caution, since the compiler might use
18845 @samp{GBR} in order to access thread local variables.
18849 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
18850 Returns the value that is currently set in the @samp{GBR} register.
18851 Memory loads and stores that use the thread pointer as a base address are
18852 turned into @samp{GBR} based displacement loads and stores, if possible.
18860 int get_tcb_value (void)
18862 // Generate @samp{mov.l @@(8,gbr),r0} instruction
18863 return ((my_tcb*)__builtin_thread_pointer ())->c;
18869 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
18870 Returns the value that is currently set in the @samp{FPSCR} register.
18873 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
18874 Sets the @samp{FPSCR} register to the specified value @var{val}, while
18875 preserving the current values of the FR, SZ and PR bits.
18878 @node SPARC VIS Built-in Functions
18879 @subsection SPARC VIS Built-in Functions
18881 GCC supports SIMD operations on the SPARC using both the generic vector
18882 extensions (@pxref{Vector Extensions}) as well as built-in functions for
18883 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
18884 switch, the VIS extension is exposed as the following built-in functions:
18887 typedef int v1si __attribute__ ((vector_size (4)));
18888 typedef int v2si __attribute__ ((vector_size (8)));
18889 typedef short v4hi __attribute__ ((vector_size (8)));
18890 typedef short v2hi __attribute__ ((vector_size (4)));
18891 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
18892 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
18894 void __builtin_vis_write_gsr (int64_t);
18895 int64_t __builtin_vis_read_gsr (void);
18897 void * __builtin_vis_alignaddr (void *, long);
18898 void * __builtin_vis_alignaddrl (void *, long);
18899 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
18900 v2si __builtin_vis_faligndatav2si (v2si, v2si);
18901 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
18902 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
18904 v4hi __builtin_vis_fexpand (v4qi);
18906 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
18907 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
18908 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
18909 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
18910 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
18911 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
18912 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
18914 v4qi __builtin_vis_fpack16 (v4hi);
18915 v8qi __builtin_vis_fpack32 (v2si, v8qi);
18916 v2hi __builtin_vis_fpackfix (v2si);
18917 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
18919 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
18921 long __builtin_vis_edge8 (void *, void *);
18922 long __builtin_vis_edge8l (void *, void *);
18923 long __builtin_vis_edge16 (void *, void *);
18924 long __builtin_vis_edge16l (void *, void *);
18925 long __builtin_vis_edge32 (void *, void *);
18926 long __builtin_vis_edge32l (void *, void *);
18928 long __builtin_vis_fcmple16 (v4hi, v4hi);
18929 long __builtin_vis_fcmple32 (v2si, v2si);
18930 long __builtin_vis_fcmpne16 (v4hi, v4hi);
18931 long __builtin_vis_fcmpne32 (v2si, v2si);
18932 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
18933 long __builtin_vis_fcmpgt32 (v2si, v2si);
18934 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
18935 long __builtin_vis_fcmpeq32 (v2si, v2si);
18937 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
18938 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
18939 v2si __builtin_vis_fpadd32 (v2si, v2si);
18940 v1si __builtin_vis_fpadd32s (v1si, v1si);
18941 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
18942 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
18943 v2si __builtin_vis_fpsub32 (v2si, v2si);
18944 v1si __builtin_vis_fpsub32s (v1si, v1si);
18946 long __builtin_vis_array8 (long, long);
18947 long __builtin_vis_array16 (long, long);
18948 long __builtin_vis_array32 (long, long);
18951 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
18952 functions also become available:
18955 long __builtin_vis_bmask (long, long);
18956 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
18957 v2si __builtin_vis_bshufflev2si (v2si, v2si);
18958 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
18959 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
18961 long __builtin_vis_edge8n (void *, void *);
18962 long __builtin_vis_edge8ln (void *, void *);
18963 long __builtin_vis_edge16n (void *, void *);
18964 long __builtin_vis_edge16ln (void *, void *);
18965 long __builtin_vis_edge32n (void *, void *);
18966 long __builtin_vis_edge32ln (void *, void *);
18969 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
18970 functions also become available:
18973 void __builtin_vis_cmask8 (long);
18974 void __builtin_vis_cmask16 (long);
18975 void __builtin_vis_cmask32 (long);
18977 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
18979 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
18980 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
18981 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
18982 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
18983 v2si __builtin_vis_fsll16 (v2si, v2si);
18984 v2si __builtin_vis_fslas16 (v2si, v2si);
18985 v2si __builtin_vis_fsrl16 (v2si, v2si);
18986 v2si __builtin_vis_fsra16 (v2si, v2si);
18988 long __builtin_vis_pdistn (v8qi, v8qi);
18990 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
18992 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
18993 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
18995 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
18996 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
18997 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
18998 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
18999 v2si __builtin_vis_fpadds32 (v2si, v2si);
19000 v1si __builtin_vis_fpadds32s (v1si, v1si);
19001 v2si __builtin_vis_fpsubs32 (v2si, v2si);
19002 v1si __builtin_vis_fpsubs32s (v1si, v1si);
19004 long __builtin_vis_fucmple8 (v8qi, v8qi);
19005 long __builtin_vis_fucmpne8 (v8qi, v8qi);
19006 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
19007 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
19009 float __builtin_vis_fhadds (float, float);
19010 double __builtin_vis_fhaddd (double, double);
19011 float __builtin_vis_fhsubs (float, float);
19012 double __builtin_vis_fhsubd (double, double);
19013 float __builtin_vis_fnhadds (float, float);
19014 double __builtin_vis_fnhaddd (double, double);
19016 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
19017 int64_t __builtin_vis_xmulx (int64_t, int64_t);
19018 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
19021 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
19022 functions also become available:
19025 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
19026 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
19027 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
19028 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
19030 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
19031 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
19032 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
19033 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
19035 long __builtin_vis_fpcmple8 (v8qi, v8qi);
19036 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
19037 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
19038 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
19039 long __builtin_vis_fpcmpule32 (v2si, v2si);
19040 long __builtin_vis_fpcmpugt32 (v2si, v2si);
19042 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
19043 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
19044 v2si __builtin_vis_fpmax32 (v2si, v2si);
19046 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
19047 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
19048 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
19051 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
19052 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
19053 v2si __builtin_vis_fpmin32 (v2si, v2si);
19055 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
19056 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
19057 v2si __builtin_vis_fpminu32 (v2si, v2si);
19060 @node SPU Built-in Functions
19061 @subsection SPU Built-in Functions
19063 GCC provides extensions for the SPU processor as described in the
19064 Sony/Toshiba/IBM SPU Language Extensions Specification. GCC's
19065 implementation differs in several ways.
19070 The optional extension of specifying vector constants in parentheses is
19074 A vector initializer requires no cast if the vector constant is of the
19075 same type as the variable it is initializing.
19078 If @code{signed} or @code{unsigned} is omitted, the signedness of the
19079 vector type is the default signedness of the base type. The default
19080 varies depending on the operating system, so a portable program should
19081 always specify the signedness.
19084 By default, the keyword @code{__vector} is added. The macro
19085 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
19089 GCC allows using a @code{typedef} name as the type specifier for a
19093 For C, overloaded functions are implemented with macros so the following
19097 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
19101 Since @code{spu_add} is a macro, the vector constant in the example
19102 is treated as four separate arguments. Wrap the entire argument in
19103 parentheses for this to work.
19106 The extended version of @code{__builtin_expect} is not supported.
19110 @emph{Note:} Only the interface described in the aforementioned
19111 specification is supported. Internally, GCC uses built-in functions to
19112 implement the required functionality, but these are not supported and
19113 are subject to change without notice.
19115 @node TI C6X Built-in Functions
19116 @subsection TI C6X Built-in Functions
19118 GCC provides intrinsics to access certain instructions of the TI C6X
19119 processors. These intrinsics, listed below, are available after
19120 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
19121 to C6X instructions.
19125 int _sadd (int, int)
19126 int _ssub (int, int)
19127 int _sadd2 (int, int)
19128 int _ssub2 (int, int)
19129 long long _mpy2 (int, int)
19130 long long _smpy2 (int, int)
19131 int _add4 (int, int)
19132 int _sub4 (int, int)
19133 int _saddu4 (int, int)
19135 int _smpy (int, int)
19136 int _smpyh (int, int)
19137 int _smpyhl (int, int)
19138 int _smpylh (int, int)
19140 int _sshl (int, int)
19141 int _subc (int, int)
19143 int _avg2 (int, int)
19144 int _avgu4 (int, int)
19146 int _clrr (int, int)
19147 int _extr (int, int)
19148 int _extru (int, int)
19154 @node TILE-Gx Built-in Functions
19155 @subsection TILE-Gx Built-in Functions
19157 GCC provides intrinsics to access every instruction of the TILE-Gx
19158 processor. The intrinsics are of the form:
19162 unsigned long long __insn_@var{op} (...)
19166 Where @var{op} is the name of the instruction. Refer to the ISA manual
19167 for the complete list of instructions.
19169 GCC also provides intrinsics to directly access the network registers.
19170 The intrinsics are:
19174 unsigned long long __tile_idn0_receive (void)
19175 unsigned long long __tile_idn1_receive (void)
19176 unsigned long long __tile_udn0_receive (void)
19177 unsigned long long __tile_udn1_receive (void)
19178 unsigned long long __tile_udn2_receive (void)
19179 unsigned long long __tile_udn3_receive (void)
19180 void __tile_idn_send (unsigned long long)
19181 void __tile_udn_send (unsigned long long)
19185 The intrinsic @code{void __tile_network_barrier (void)} is used to
19186 guarantee that no network operations before it are reordered with
19189 @node TILEPro Built-in Functions
19190 @subsection TILEPro Built-in Functions
19192 GCC provides intrinsics to access every instruction of the TILEPro
19193 processor. The intrinsics are of the form:
19197 unsigned __insn_@var{op} (...)
19202 where @var{op} is the name of the instruction. Refer to the ISA manual
19203 for the complete list of instructions.
19205 GCC also provides intrinsics to directly access the network registers.
19206 The intrinsics are:
19210 unsigned __tile_idn0_receive (void)
19211 unsigned __tile_idn1_receive (void)
19212 unsigned __tile_sn_receive (void)
19213 unsigned __tile_udn0_receive (void)
19214 unsigned __tile_udn1_receive (void)
19215 unsigned __tile_udn2_receive (void)
19216 unsigned __tile_udn3_receive (void)
19217 void __tile_idn_send (unsigned)
19218 void __tile_sn_send (unsigned)
19219 void __tile_udn_send (unsigned)
19223 The intrinsic @code{void __tile_network_barrier (void)} is used to
19224 guarantee that no network operations before it are reordered with
19227 @node x86 Built-in Functions
19228 @subsection x86 Built-in Functions
19230 These built-in functions are available for the x86-32 and x86-64 family
19231 of computers, depending on the command-line switches used.
19233 If you specify command-line switches such as @option{-msse},
19234 the compiler could use the extended instruction sets even if the built-ins
19235 are not used explicitly in the program. For this reason, applications
19236 that perform run-time CPU detection must compile separate files for each
19237 supported architecture, using the appropriate flags. In particular,
19238 the file containing the CPU detection code should be compiled without
19241 The following machine modes are available for use with MMX built-in functions
19242 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
19243 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
19244 vector of eight 8-bit integers. Some of the built-in functions operate on
19245 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
19247 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
19248 of two 32-bit floating-point values.
19250 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
19251 floating-point values. Some instructions use a vector of four 32-bit
19252 integers, these use @code{V4SI}. Finally, some instructions operate on an
19253 entire vector register, interpreting it as a 128-bit integer, these use mode
19256 The x86-32 and x86-64 family of processors use additional built-in
19257 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
19258 floating point and @code{TC} 128-bit complex floating-point values.
19260 The following floating-point built-in functions are always available. All
19261 of them implement the function that is part of the name.
19264 __float128 __builtin_fabsq (__float128)
19265 __float128 __builtin_copysignq (__float128, __float128)
19268 The following built-in functions are always available.
19271 @item __float128 __builtin_infq (void)
19272 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
19273 @findex __builtin_infq
19275 @item __float128 __builtin_huge_valq (void)
19276 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
19277 @findex __builtin_huge_valq
19279 @item __float128 __builtin_nanq (void)
19280 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
19281 @findex __builtin_nanq
19283 @item __float128 __builtin_nansq (void)
19284 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
19285 @findex __builtin_nansq
19288 The following built-in function is always available.
19291 @item void __builtin_ia32_pause (void)
19292 Generates the @code{pause} machine instruction with a compiler memory
19296 The following built-in functions are always available and can be used to
19297 check the target platform type.
19299 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
19300 This function runs the CPU detection code to check the type of CPU and the
19301 features supported. This built-in function needs to be invoked along with the built-in functions
19302 to check CPU type and features, @code{__builtin_cpu_is} and
19303 @code{__builtin_cpu_supports}, only when used in a function that is
19304 executed before any constructors are called. The CPU detection code is
19305 automatically executed in a very high priority constructor.
19307 For example, this function has to be used in @code{ifunc} resolvers that
19308 check for CPU type using the built-in functions @code{__builtin_cpu_is}
19309 and @code{__builtin_cpu_supports}, or in constructors on targets that
19310 don't support constructor priority.
19313 static void (*resolve_memcpy (void)) (void)
19315 // ifunc resolvers fire before constructors, explicitly call the init
19317 __builtin_cpu_init ();
19318 if (__builtin_cpu_supports ("ssse3"))
19319 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
19321 return default_memcpy;
19324 void *memcpy (void *, const void *, size_t)
19325 __attribute__ ((ifunc ("resolve_memcpy")));
19330 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
19331 This function returns a positive integer if the run-time CPU
19332 is of type @var{cpuname}
19333 and returns @code{0} otherwise. The following CPU names can be detected:
19349 Intel Core i7 Nehalem CPU.
19352 Intel Core i7 Westmere CPU.
19355 Intel Core i7 Sandy Bridge CPU.
19361 AMD Family 10h CPU.
19364 AMD Family 10h Barcelona CPU.
19367 AMD Family 10h Shanghai CPU.
19370 AMD Family 10h Istanbul CPU.
19373 AMD Family 14h CPU.
19376 AMD Family 15h CPU.
19379 AMD Family 15h Bulldozer version 1.
19382 AMD Family 15h Bulldozer version 2.
19385 AMD Family 15h Bulldozer version 3.
19388 AMD Family 15h Bulldozer version 4.
19391 AMD Family 16h CPU.
19394 AMD Family 17h CPU.
19397 Here is an example:
19399 if (__builtin_cpu_is ("corei7"))
19401 do_corei7 (); // Core i7 specific implementation.
19405 do_generic (); // Generic implementation.
19410 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
19411 This function returns a positive integer if the run-time CPU
19412 supports @var{feature}
19413 and returns @code{0} otherwise. The following features can be detected:
19421 POPCNT instruction.
19429 SSSE3 instructions.
19431 SSE4.1 instructions.
19433 SSE4.2 instructions.
19439 AVX512F instructions.
19442 Here is an example:
19444 if (__builtin_cpu_supports ("popcnt"))
19446 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
19450 count = generic_countbits (n); //generic implementation.
19456 The following built-in functions are made available by @option{-mmmx}.
19457 All of them generate the machine instruction that is part of the name.
19460 v8qi __builtin_ia32_paddb (v8qi, v8qi)
19461 v4hi __builtin_ia32_paddw (v4hi, v4hi)
19462 v2si __builtin_ia32_paddd (v2si, v2si)
19463 v8qi __builtin_ia32_psubb (v8qi, v8qi)
19464 v4hi __builtin_ia32_psubw (v4hi, v4hi)
19465 v2si __builtin_ia32_psubd (v2si, v2si)
19466 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
19467 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
19468 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
19469 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
19470 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
19471 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
19472 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
19473 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
19474 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
19475 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
19476 di __builtin_ia32_pand (di, di)
19477 di __builtin_ia32_pandn (di,di)
19478 di __builtin_ia32_por (di, di)
19479 di __builtin_ia32_pxor (di, di)
19480 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
19481 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
19482 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
19483 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
19484 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
19485 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
19486 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
19487 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
19488 v2si __builtin_ia32_punpckhdq (v2si, v2si)
19489 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
19490 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
19491 v2si __builtin_ia32_punpckldq (v2si, v2si)
19492 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
19493 v4hi __builtin_ia32_packssdw (v2si, v2si)
19494 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
19496 v4hi __builtin_ia32_psllw (v4hi, v4hi)
19497 v2si __builtin_ia32_pslld (v2si, v2si)
19498 v1di __builtin_ia32_psllq (v1di, v1di)
19499 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
19500 v2si __builtin_ia32_psrld (v2si, v2si)
19501 v1di __builtin_ia32_psrlq (v1di, v1di)
19502 v4hi __builtin_ia32_psraw (v4hi, v4hi)
19503 v2si __builtin_ia32_psrad (v2si, v2si)
19504 v4hi __builtin_ia32_psllwi (v4hi, int)
19505 v2si __builtin_ia32_pslldi (v2si, int)
19506 v1di __builtin_ia32_psllqi (v1di, int)
19507 v4hi __builtin_ia32_psrlwi (v4hi, int)
19508 v2si __builtin_ia32_psrldi (v2si, int)
19509 v1di __builtin_ia32_psrlqi (v1di, int)
19510 v4hi __builtin_ia32_psrawi (v4hi, int)
19511 v2si __builtin_ia32_psradi (v2si, int)
19515 The following built-in functions are made available either with
19516 @option{-msse}, or with a combination of @option{-m3dnow} and
19517 @option{-march=athlon}. All of them generate the machine
19518 instruction that is part of the name.
19521 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
19522 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
19523 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
19524 v1di __builtin_ia32_psadbw (v8qi, v8qi)
19525 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
19526 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
19527 v8qi __builtin_ia32_pminub (v8qi, v8qi)
19528 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
19529 int __builtin_ia32_pmovmskb (v8qi)
19530 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
19531 void __builtin_ia32_movntq (di *, di)
19532 void __builtin_ia32_sfence (void)
19535 The following built-in functions are available when @option{-msse} is used.
19536 All of them generate the machine instruction that is part of the name.
19539 int __builtin_ia32_comieq (v4sf, v4sf)
19540 int __builtin_ia32_comineq (v4sf, v4sf)
19541 int __builtin_ia32_comilt (v4sf, v4sf)
19542 int __builtin_ia32_comile (v4sf, v4sf)
19543 int __builtin_ia32_comigt (v4sf, v4sf)
19544 int __builtin_ia32_comige (v4sf, v4sf)
19545 int __builtin_ia32_ucomieq (v4sf, v4sf)
19546 int __builtin_ia32_ucomineq (v4sf, v4sf)
19547 int __builtin_ia32_ucomilt (v4sf, v4sf)
19548 int __builtin_ia32_ucomile (v4sf, v4sf)
19549 int __builtin_ia32_ucomigt (v4sf, v4sf)
19550 int __builtin_ia32_ucomige (v4sf, v4sf)
19551 v4sf __builtin_ia32_addps (v4sf, v4sf)
19552 v4sf __builtin_ia32_subps (v4sf, v4sf)
19553 v4sf __builtin_ia32_mulps (v4sf, v4sf)
19554 v4sf __builtin_ia32_divps (v4sf, v4sf)
19555 v4sf __builtin_ia32_addss (v4sf, v4sf)
19556 v4sf __builtin_ia32_subss (v4sf, v4sf)
19557 v4sf __builtin_ia32_mulss (v4sf, v4sf)
19558 v4sf __builtin_ia32_divss (v4sf, v4sf)
19559 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
19560 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
19561 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
19562 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
19563 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
19564 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
19565 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
19566 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
19567 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
19568 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
19569 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
19570 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
19571 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
19572 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
19573 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
19574 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
19575 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
19576 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
19577 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
19578 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
19579 v4sf __builtin_ia32_maxps (v4sf, v4sf)
19580 v4sf __builtin_ia32_maxss (v4sf, v4sf)
19581 v4sf __builtin_ia32_minps (v4sf, v4sf)
19582 v4sf __builtin_ia32_minss (v4sf, v4sf)
19583 v4sf __builtin_ia32_andps (v4sf, v4sf)
19584 v4sf __builtin_ia32_andnps (v4sf, v4sf)
19585 v4sf __builtin_ia32_orps (v4sf, v4sf)
19586 v4sf __builtin_ia32_xorps (v4sf, v4sf)
19587 v4sf __builtin_ia32_movss (v4sf, v4sf)
19588 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
19589 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
19590 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
19591 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
19592 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
19593 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
19594 v2si __builtin_ia32_cvtps2pi (v4sf)
19595 int __builtin_ia32_cvtss2si (v4sf)
19596 v2si __builtin_ia32_cvttps2pi (v4sf)
19597 int __builtin_ia32_cvttss2si (v4sf)
19598 v4sf __builtin_ia32_rcpps (v4sf)
19599 v4sf __builtin_ia32_rsqrtps (v4sf)
19600 v4sf __builtin_ia32_sqrtps (v4sf)
19601 v4sf __builtin_ia32_rcpss (v4sf)
19602 v4sf __builtin_ia32_rsqrtss (v4sf)
19603 v4sf __builtin_ia32_sqrtss (v4sf)
19604 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
19605 void __builtin_ia32_movntps (float *, v4sf)
19606 int __builtin_ia32_movmskps (v4sf)
19609 The following built-in functions are available when @option{-msse} is used.
19612 @item v4sf __builtin_ia32_loadups (float *)
19613 Generates the @code{movups} machine instruction as a load from memory.
19614 @item void __builtin_ia32_storeups (float *, v4sf)
19615 Generates the @code{movups} machine instruction as a store to memory.
19616 @item v4sf __builtin_ia32_loadss (float *)
19617 Generates the @code{movss} machine instruction as a load from memory.
19618 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
19619 Generates the @code{movhps} machine instruction as a load from memory.
19620 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
19621 Generates the @code{movlps} machine instruction as a load from memory
19622 @item void __builtin_ia32_storehps (v2sf *, v4sf)
19623 Generates the @code{movhps} machine instruction as a store to memory.
19624 @item void __builtin_ia32_storelps (v2sf *, v4sf)
19625 Generates the @code{movlps} machine instruction as a store to memory.
19628 The following built-in functions are available when @option{-msse2} is used.
19629 All of them generate the machine instruction that is part of the name.
19632 int __builtin_ia32_comisdeq (v2df, v2df)
19633 int __builtin_ia32_comisdlt (v2df, v2df)
19634 int __builtin_ia32_comisdle (v2df, v2df)
19635 int __builtin_ia32_comisdgt (v2df, v2df)
19636 int __builtin_ia32_comisdge (v2df, v2df)
19637 int __builtin_ia32_comisdneq (v2df, v2df)
19638 int __builtin_ia32_ucomisdeq (v2df, v2df)
19639 int __builtin_ia32_ucomisdlt (v2df, v2df)
19640 int __builtin_ia32_ucomisdle (v2df, v2df)
19641 int __builtin_ia32_ucomisdgt (v2df, v2df)
19642 int __builtin_ia32_ucomisdge (v2df, v2df)
19643 int __builtin_ia32_ucomisdneq (v2df, v2df)
19644 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
19645 v2df __builtin_ia32_cmpltpd (v2df, v2df)
19646 v2df __builtin_ia32_cmplepd (v2df, v2df)
19647 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
19648 v2df __builtin_ia32_cmpgepd (v2df, v2df)
19649 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
19650 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
19651 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
19652 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
19653 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
19654 v2df __builtin_ia32_cmpngepd (v2df, v2df)
19655 v2df __builtin_ia32_cmpordpd (v2df, v2df)
19656 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
19657 v2df __builtin_ia32_cmpltsd (v2df, v2df)
19658 v2df __builtin_ia32_cmplesd (v2df, v2df)
19659 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
19660 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
19661 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
19662 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
19663 v2df __builtin_ia32_cmpordsd (v2df, v2df)
19664 v2di __builtin_ia32_paddq (v2di, v2di)
19665 v2di __builtin_ia32_psubq (v2di, v2di)
19666 v2df __builtin_ia32_addpd (v2df, v2df)
19667 v2df __builtin_ia32_subpd (v2df, v2df)
19668 v2df __builtin_ia32_mulpd (v2df, v2df)
19669 v2df __builtin_ia32_divpd (v2df, v2df)
19670 v2df __builtin_ia32_addsd (v2df, v2df)
19671 v2df __builtin_ia32_subsd (v2df, v2df)
19672 v2df __builtin_ia32_mulsd (v2df, v2df)
19673 v2df __builtin_ia32_divsd (v2df, v2df)
19674 v2df __builtin_ia32_minpd (v2df, v2df)
19675 v2df __builtin_ia32_maxpd (v2df, v2df)
19676 v2df __builtin_ia32_minsd (v2df, v2df)
19677 v2df __builtin_ia32_maxsd (v2df, v2df)
19678 v2df __builtin_ia32_andpd (v2df, v2df)
19679 v2df __builtin_ia32_andnpd (v2df, v2df)
19680 v2df __builtin_ia32_orpd (v2df, v2df)
19681 v2df __builtin_ia32_xorpd (v2df, v2df)
19682 v2df __builtin_ia32_movsd (v2df, v2df)
19683 v2df __builtin_ia32_unpckhpd (v2df, v2df)
19684 v2df __builtin_ia32_unpcklpd (v2df, v2df)
19685 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
19686 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
19687 v4si __builtin_ia32_paddd128 (v4si, v4si)
19688 v2di __builtin_ia32_paddq128 (v2di, v2di)
19689 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
19690 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
19691 v4si __builtin_ia32_psubd128 (v4si, v4si)
19692 v2di __builtin_ia32_psubq128 (v2di, v2di)
19693 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
19694 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
19695 v2di __builtin_ia32_pand128 (v2di, v2di)
19696 v2di __builtin_ia32_pandn128 (v2di, v2di)
19697 v2di __builtin_ia32_por128 (v2di, v2di)
19698 v2di __builtin_ia32_pxor128 (v2di, v2di)
19699 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
19700 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
19701 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
19702 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
19703 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
19704 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
19705 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
19706 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
19707 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
19708 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
19709 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
19710 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
19711 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
19712 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
19713 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
19714 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
19715 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
19716 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
19717 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
19718 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
19719 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
19720 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
19721 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
19722 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
19723 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
19724 v2df __builtin_ia32_loadupd (double *)
19725 void __builtin_ia32_storeupd (double *, v2df)
19726 v2df __builtin_ia32_loadhpd (v2df, double const *)
19727 v2df __builtin_ia32_loadlpd (v2df, double const *)
19728 int __builtin_ia32_movmskpd (v2df)
19729 int __builtin_ia32_pmovmskb128 (v16qi)
19730 void __builtin_ia32_movnti (int *, int)
19731 void __builtin_ia32_movnti64 (long long int *, long long int)
19732 void __builtin_ia32_movntpd (double *, v2df)
19733 void __builtin_ia32_movntdq (v2df *, v2df)
19734 v4si __builtin_ia32_pshufd (v4si, int)
19735 v8hi __builtin_ia32_pshuflw (v8hi, int)
19736 v8hi __builtin_ia32_pshufhw (v8hi, int)
19737 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
19738 v2df __builtin_ia32_sqrtpd (v2df)
19739 v2df __builtin_ia32_sqrtsd (v2df)
19740 v2df __builtin_ia32_shufpd (v2df, v2df, int)
19741 v2df __builtin_ia32_cvtdq2pd (v4si)
19742 v4sf __builtin_ia32_cvtdq2ps (v4si)
19743 v4si __builtin_ia32_cvtpd2dq (v2df)
19744 v2si __builtin_ia32_cvtpd2pi (v2df)
19745 v4sf __builtin_ia32_cvtpd2ps (v2df)
19746 v4si __builtin_ia32_cvttpd2dq (v2df)
19747 v2si __builtin_ia32_cvttpd2pi (v2df)
19748 v2df __builtin_ia32_cvtpi2pd (v2si)
19749 int __builtin_ia32_cvtsd2si (v2df)
19750 int __builtin_ia32_cvttsd2si (v2df)
19751 long long __builtin_ia32_cvtsd2si64 (v2df)
19752 long long __builtin_ia32_cvttsd2si64 (v2df)
19753 v4si __builtin_ia32_cvtps2dq (v4sf)
19754 v2df __builtin_ia32_cvtps2pd (v4sf)
19755 v4si __builtin_ia32_cvttps2dq (v4sf)
19756 v2df __builtin_ia32_cvtsi2sd (v2df, int)
19757 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
19758 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
19759 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
19760 void __builtin_ia32_clflush (const void *)
19761 void __builtin_ia32_lfence (void)
19762 void __builtin_ia32_mfence (void)
19763 v16qi __builtin_ia32_loaddqu (const char *)
19764 void __builtin_ia32_storedqu (char *, v16qi)
19765 v1di __builtin_ia32_pmuludq (v2si, v2si)
19766 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
19767 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
19768 v4si __builtin_ia32_pslld128 (v4si, v4si)
19769 v2di __builtin_ia32_psllq128 (v2di, v2di)
19770 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
19771 v4si __builtin_ia32_psrld128 (v4si, v4si)
19772 v2di __builtin_ia32_psrlq128 (v2di, v2di)
19773 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
19774 v4si __builtin_ia32_psrad128 (v4si, v4si)
19775 v2di __builtin_ia32_pslldqi128 (v2di, int)
19776 v8hi __builtin_ia32_psllwi128 (v8hi, int)
19777 v4si __builtin_ia32_pslldi128 (v4si, int)
19778 v2di __builtin_ia32_psllqi128 (v2di, int)
19779 v2di __builtin_ia32_psrldqi128 (v2di, int)
19780 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
19781 v4si __builtin_ia32_psrldi128 (v4si, int)
19782 v2di __builtin_ia32_psrlqi128 (v2di, int)
19783 v8hi __builtin_ia32_psrawi128 (v8hi, int)
19784 v4si __builtin_ia32_psradi128 (v4si, int)
19785 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
19786 v2di __builtin_ia32_movq128 (v2di)
19789 The following built-in functions are available when @option{-msse3} is used.
19790 All of them generate the machine instruction that is part of the name.
19793 v2df __builtin_ia32_addsubpd (v2df, v2df)
19794 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
19795 v2df __builtin_ia32_haddpd (v2df, v2df)
19796 v4sf __builtin_ia32_haddps (v4sf, v4sf)
19797 v2df __builtin_ia32_hsubpd (v2df, v2df)
19798 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
19799 v16qi __builtin_ia32_lddqu (char const *)
19800 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
19801 v4sf __builtin_ia32_movshdup (v4sf)
19802 v4sf __builtin_ia32_movsldup (v4sf)
19803 void __builtin_ia32_mwait (unsigned int, unsigned int)
19806 The following built-in functions are available when @option{-mssse3} is used.
19807 All of them generate the machine instruction that is part of the name.
19810 v2si __builtin_ia32_phaddd (v2si, v2si)
19811 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
19812 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
19813 v2si __builtin_ia32_phsubd (v2si, v2si)
19814 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
19815 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
19816 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
19817 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
19818 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
19819 v8qi __builtin_ia32_psignb (v8qi, v8qi)
19820 v2si __builtin_ia32_psignd (v2si, v2si)
19821 v4hi __builtin_ia32_psignw (v4hi, v4hi)
19822 v1di __builtin_ia32_palignr (v1di, v1di, int)
19823 v8qi __builtin_ia32_pabsb (v8qi)
19824 v2si __builtin_ia32_pabsd (v2si)
19825 v4hi __builtin_ia32_pabsw (v4hi)
19828 The following built-in functions are available when @option{-mssse3} is used.
19829 All of them generate the machine instruction that is part of the name.
19832 v4si __builtin_ia32_phaddd128 (v4si, v4si)
19833 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
19834 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
19835 v4si __builtin_ia32_phsubd128 (v4si, v4si)
19836 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
19837 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
19838 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
19839 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
19840 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
19841 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
19842 v4si __builtin_ia32_psignd128 (v4si, v4si)
19843 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
19844 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
19845 v16qi __builtin_ia32_pabsb128 (v16qi)
19846 v4si __builtin_ia32_pabsd128 (v4si)
19847 v8hi __builtin_ia32_pabsw128 (v8hi)
19850 The following built-in functions are available when @option{-msse4.1} is
19851 used. All of them generate the machine instruction that is part of the
19855 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
19856 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
19857 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
19858 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
19859 v2df __builtin_ia32_dppd (v2df, v2df, const int)
19860 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
19861 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
19862 v2di __builtin_ia32_movntdqa (v2di *);
19863 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
19864 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
19865 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
19866 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
19867 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
19868 v8hi __builtin_ia32_phminposuw128 (v8hi)
19869 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
19870 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
19871 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
19872 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
19873 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
19874 v4si __builtin_ia32_pminsd128 (v4si, v4si)
19875 v4si __builtin_ia32_pminud128 (v4si, v4si)
19876 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
19877 v4si __builtin_ia32_pmovsxbd128 (v16qi)
19878 v2di __builtin_ia32_pmovsxbq128 (v16qi)
19879 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
19880 v2di __builtin_ia32_pmovsxdq128 (v4si)
19881 v4si __builtin_ia32_pmovsxwd128 (v8hi)
19882 v2di __builtin_ia32_pmovsxwq128 (v8hi)
19883 v4si __builtin_ia32_pmovzxbd128 (v16qi)
19884 v2di __builtin_ia32_pmovzxbq128 (v16qi)
19885 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
19886 v2di __builtin_ia32_pmovzxdq128 (v4si)
19887 v4si __builtin_ia32_pmovzxwd128 (v8hi)
19888 v2di __builtin_ia32_pmovzxwq128 (v8hi)
19889 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
19890 v4si __builtin_ia32_pmulld128 (v4si, v4si)
19891 int __builtin_ia32_ptestc128 (v2di, v2di)
19892 int __builtin_ia32_ptestnzc128 (v2di, v2di)
19893 int __builtin_ia32_ptestz128 (v2di, v2di)
19894 v2df __builtin_ia32_roundpd (v2df, const int)
19895 v4sf __builtin_ia32_roundps (v4sf, const int)
19896 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
19897 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
19900 The following built-in functions are available when @option{-msse4.1} is
19904 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
19905 Generates the @code{insertps} machine instruction.
19906 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
19907 Generates the @code{pextrb} machine instruction.
19908 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
19909 Generates the @code{pinsrb} machine instruction.
19910 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
19911 Generates the @code{pinsrd} machine instruction.
19912 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
19913 Generates the @code{pinsrq} machine instruction in 64bit mode.
19916 The following built-in functions are changed to generate new SSE4.1
19917 instructions when @option{-msse4.1} is used.
19920 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
19921 Generates the @code{extractps} machine instruction.
19922 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
19923 Generates the @code{pextrd} machine instruction.
19924 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
19925 Generates the @code{pextrq} machine instruction in 64bit mode.
19928 The following built-in functions are available when @option{-msse4.2} is
19929 used. All of them generate the machine instruction that is part of the
19933 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
19934 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
19935 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
19936 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
19937 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
19938 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
19939 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
19940 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
19941 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
19942 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
19943 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
19944 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
19945 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
19946 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
19947 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
19950 The following built-in functions are available when @option{-msse4.2} is
19954 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
19955 Generates the @code{crc32b} machine instruction.
19956 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
19957 Generates the @code{crc32w} machine instruction.
19958 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
19959 Generates the @code{crc32l} machine instruction.
19960 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
19961 Generates the @code{crc32q} machine instruction.
19964 The following built-in functions are changed to generate new SSE4.2
19965 instructions when @option{-msse4.2} is used.
19968 @item int __builtin_popcount (unsigned int)
19969 Generates the @code{popcntl} machine instruction.
19970 @item int __builtin_popcountl (unsigned long)
19971 Generates the @code{popcntl} or @code{popcntq} machine instruction,
19972 depending on the size of @code{unsigned long}.
19973 @item int __builtin_popcountll (unsigned long long)
19974 Generates the @code{popcntq} machine instruction.
19977 The following built-in functions are available when @option{-mavx} is
19978 used. All of them generate the machine instruction that is part of the
19982 v4df __builtin_ia32_addpd256 (v4df,v4df)
19983 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
19984 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
19985 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
19986 v4df __builtin_ia32_andnpd256 (v4df,v4df)
19987 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
19988 v4df __builtin_ia32_andpd256 (v4df,v4df)
19989 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
19990 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
19991 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
19992 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
19993 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
19994 v2df __builtin_ia32_cmppd (v2df,v2df,int)
19995 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
19996 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
19997 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
19998 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
19999 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
20000 v4df __builtin_ia32_cvtdq2pd256 (v4si)
20001 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
20002 v4si __builtin_ia32_cvtpd2dq256 (v4df)
20003 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
20004 v8si __builtin_ia32_cvtps2dq256 (v8sf)
20005 v4df __builtin_ia32_cvtps2pd256 (v4sf)
20006 v4si __builtin_ia32_cvttpd2dq256 (v4df)
20007 v8si __builtin_ia32_cvttps2dq256 (v8sf)
20008 v4df __builtin_ia32_divpd256 (v4df,v4df)
20009 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
20010 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
20011 v4df __builtin_ia32_haddpd256 (v4df,v4df)
20012 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
20013 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
20014 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
20015 v32qi __builtin_ia32_lddqu256 (pcchar)
20016 v32qi __builtin_ia32_loaddqu256 (pcchar)
20017 v4df __builtin_ia32_loadupd256 (pcdouble)
20018 v8sf __builtin_ia32_loadups256 (pcfloat)
20019 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
20020 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
20021 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
20022 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
20023 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
20024 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
20025 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
20026 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
20027 v4df __builtin_ia32_maxpd256 (v4df,v4df)
20028 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
20029 v4df __builtin_ia32_minpd256 (v4df,v4df)
20030 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
20031 v4df __builtin_ia32_movddup256 (v4df)
20032 int __builtin_ia32_movmskpd256 (v4df)
20033 int __builtin_ia32_movmskps256 (v8sf)
20034 v8sf __builtin_ia32_movshdup256 (v8sf)
20035 v8sf __builtin_ia32_movsldup256 (v8sf)
20036 v4df __builtin_ia32_mulpd256 (v4df,v4df)
20037 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
20038 v4df __builtin_ia32_orpd256 (v4df,v4df)
20039 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
20040 v2df __builtin_ia32_pd_pd256 (v4df)
20041 v4df __builtin_ia32_pd256_pd (v2df)
20042 v4sf __builtin_ia32_ps_ps256 (v8sf)
20043 v8sf __builtin_ia32_ps256_ps (v4sf)
20044 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
20045 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
20046 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
20047 v8sf __builtin_ia32_rcpps256 (v8sf)
20048 v4df __builtin_ia32_roundpd256 (v4df,int)
20049 v8sf __builtin_ia32_roundps256 (v8sf,int)
20050 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
20051 v8sf __builtin_ia32_rsqrtps256 (v8sf)
20052 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
20053 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
20054 v4si __builtin_ia32_si_si256 (v8si)
20055 v8si __builtin_ia32_si256_si (v4si)
20056 v4df __builtin_ia32_sqrtpd256 (v4df)
20057 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
20058 v8sf __builtin_ia32_sqrtps256 (v8sf)
20059 void __builtin_ia32_storedqu256 (pchar,v32qi)
20060 void __builtin_ia32_storeupd256 (pdouble,v4df)
20061 void __builtin_ia32_storeups256 (pfloat,v8sf)
20062 v4df __builtin_ia32_subpd256 (v4df,v4df)
20063 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
20064 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
20065 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
20066 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
20067 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
20068 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
20069 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
20070 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
20071 v4sf __builtin_ia32_vbroadcastss (pcfloat)
20072 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
20073 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
20074 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
20075 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
20076 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
20077 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
20078 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
20079 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
20080 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
20081 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
20082 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
20083 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
20084 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
20085 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
20086 v2df __builtin_ia32_vpermilpd (v2df,int)
20087 v4df __builtin_ia32_vpermilpd256 (v4df,int)
20088 v4sf __builtin_ia32_vpermilps (v4sf,int)
20089 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
20090 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
20091 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
20092 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
20093 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
20094 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
20095 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
20096 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
20097 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
20098 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
20099 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
20100 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
20101 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
20102 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
20103 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
20104 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
20105 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
20106 void __builtin_ia32_vzeroall (void)
20107 void __builtin_ia32_vzeroupper (void)
20108 v4df __builtin_ia32_xorpd256 (v4df,v4df)
20109 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
20112 The following built-in functions are available when @option{-mavx2} is
20113 used. All of them generate the machine instruction that is part of the
20117 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
20118 v32qi __builtin_ia32_pabsb256 (v32qi)
20119 v16hi __builtin_ia32_pabsw256 (v16hi)
20120 v8si __builtin_ia32_pabsd256 (v8si)
20121 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
20122 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
20123 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
20124 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
20125 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
20126 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
20127 v8si __builtin_ia32_paddd256 (v8si,v8si)
20128 v4di __builtin_ia32_paddq256 (v4di,v4di)
20129 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
20130 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
20131 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
20132 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
20133 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
20134 v4di __builtin_ia32_andsi256 (v4di,v4di)
20135 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
20136 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
20137 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
20138 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
20139 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
20140 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
20141 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
20142 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
20143 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
20144 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
20145 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
20146 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
20147 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
20148 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
20149 v8si __builtin_ia32_phaddd256 (v8si,v8si)
20150 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
20151 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
20152 v8si __builtin_ia32_phsubd256 (v8si,v8si)
20153 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
20154 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
20155 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
20156 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
20157 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
20158 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
20159 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
20160 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
20161 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
20162 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
20163 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
20164 v8si __builtin_ia32_pminsd256 (v8si,v8si)
20165 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
20166 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
20167 v8si __builtin_ia32_pminud256 (v8si,v8si)
20168 int __builtin_ia32_pmovmskb256 (v32qi)
20169 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
20170 v8si __builtin_ia32_pmovsxbd256 (v16qi)
20171 v4di __builtin_ia32_pmovsxbq256 (v16qi)
20172 v8si __builtin_ia32_pmovsxwd256 (v8hi)
20173 v4di __builtin_ia32_pmovsxwq256 (v8hi)
20174 v4di __builtin_ia32_pmovsxdq256 (v4si)
20175 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
20176 v8si __builtin_ia32_pmovzxbd256 (v16qi)
20177 v4di __builtin_ia32_pmovzxbq256 (v16qi)
20178 v8si __builtin_ia32_pmovzxwd256 (v8hi)
20179 v4di __builtin_ia32_pmovzxwq256 (v8hi)
20180 v4di __builtin_ia32_pmovzxdq256 (v4si)
20181 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
20182 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
20183 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
20184 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
20185 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
20186 v8si __builtin_ia32_pmulld256 (v8si,v8si)
20187 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
20188 v4di __builtin_ia32_por256 (v4di,v4di)
20189 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
20190 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
20191 v8si __builtin_ia32_pshufd256 (v8si,int)
20192 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
20193 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
20194 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
20195 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
20196 v8si __builtin_ia32_psignd256 (v8si,v8si)
20197 v4di __builtin_ia32_pslldqi256 (v4di,int)
20198 v16hi __builtin_ia32_psllwi256 (16hi,int)
20199 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
20200 v8si __builtin_ia32_pslldi256 (v8si,int)
20201 v8si __builtin_ia32_pslld256(v8si,v4si)
20202 v4di __builtin_ia32_psllqi256 (v4di,int)
20203 v4di __builtin_ia32_psllq256(v4di,v2di)
20204 v16hi __builtin_ia32_psrawi256 (v16hi,int)
20205 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
20206 v8si __builtin_ia32_psradi256 (v8si,int)
20207 v8si __builtin_ia32_psrad256 (v8si,v4si)
20208 v4di __builtin_ia32_psrldqi256 (v4di, int)
20209 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
20210 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
20211 v8si __builtin_ia32_psrldi256 (v8si,int)
20212 v8si __builtin_ia32_psrld256 (v8si,v4si)
20213 v4di __builtin_ia32_psrlqi256 (v4di,int)
20214 v4di __builtin_ia32_psrlq256(v4di,v2di)
20215 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
20216 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
20217 v8si __builtin_ia32_psubd256 (v8si,v8si)
20218 v4di __builtin_ia32_psubq256 (v4di,v4di)
20219 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
20220 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
20221 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
20222 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
20223 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
20224 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
20225 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
20226 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
20227 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
20228 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
20229 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
20230 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
20231 v4di __builtin_ia32_pxor256 (v4di,v4di)
20232 v4di __builtin_ia32_movntdqa256 (pv4di)
20233 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
20234 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
20235 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
20236 v4di __builtin_ia32_vbroadcastsi256 (v2di)
20237 v4si __builtin_ia32_pblendd128 (v4si,v4si)
20238 v8si __builtin_ia32_pblendd256 (v8si,v8si)
20239 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
20240 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
20241 v8si __builtin_ia32_pbroadcastd256 (v4si)
20242 v4di __builtin_ia32_pbroadcastq256 (v2di)
20243 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
20244 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
20245 v4si __builtin_ia32_pbroadcastd128 (v4si)
20246 v2di __builtin_ia32_pbroadcastq128 (v2di)
20247 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
20248 v4df __builtin_ia32_permdf256 (v4df,int)
20249 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
20250 v4di __builtin_ia32_permdi256 (v4di,int)
20251 v4di __builtin_ia32_permti256 (v4di,v4di,int)
20252 v4di __builtin_ia32_extract128i256 (v4di,int)
20253 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
20254 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
20255 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
20256 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
20257 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
20258 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
20259 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
20260 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
20261 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
20262 v8si __builtin_ia32_psllv8si (v8si,v8si)
20263 v4si __builtin_ia32_psllv4si (v4si,v4si)
20264 v4di __builtin_ia32_psllv4di (v4di,v4di)
20265 v2di __builtin_ia32_psllv2di (v2di,v2di)
20266 v8si __builtin_ia32_psrav8si (v8si,v8si)
20267 v4si __builtin_ia32_psrav4si (v4si,v4si)
20268 v8si __builtin_ia32_psrlv8si (v8si,v8si)
20269 v4si __builtin_ia32_psrlv4si (v4si,v4si)
20270 v4di __builtin_ia32_psrlv4di (v4di,v4di)
20271 v2di __builtin_ia32_psrlv2di (v2di,v2di)
20272 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
20273 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
20274 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
20275 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
20276 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
20277 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
20278 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
20279 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
20280 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
20281 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
20282 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
20283 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
20284 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
20285 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
20286 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
20287 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
20290 The following built-in functions are available when @option{-maes} is
20291 used. All of them generate the machine instruction that is part of the
20295 v2di __builtin_ia32_aesenc128 (v2di, v2di)
20296 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
20297 v2di __builtin_ia32_aesdec128 (v2di, v2di)
20298 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
20299 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
20300 v2di __builtin_ia32_aesimc128 (v2di)
20303 The following built-in function is available when @option{-mpclmul} is
20307 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
20308 Generates the @code{pclmulqdq} machine instruction.
20311 The following built-in function is available when @option{-mfsgsbase} is
20312 used. All of them generate the machine instruction that is part of the
20316 unsigned int __builtin_ia32_rdfsbase32 (void)
20317 unsigned long long __builtin_ia32_rdfsbase64 (void)
20318 unsigned int __builtin_ia32_rdgsbase32 (void)
20319 unsigned long long __builtin_ia32_rdgsbase64 (void)
20320 void _writefsbase_u32 (unsigned int)
20321 void _writefsbase_u64 (unsigned long long)
20322 void _writegsbase_u32 (unsigned int)
20323 void _writegsbase_u64 (unsigned long long)
20326 The following built-in function is available when @option{-mrdrnd} is
20327 used. All of them generate the machine instruction that is part of the
20331 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
20332 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
20333 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
20336 The following built-in functions are available when @option{-msse4a} is used.
20337 All of them generate the machine instruction that is part of the name.
20340 void __builtin_ia32_movntsd (double *, v2df)
20341 void __builtin_ia32_movntss (float *, v4sf)
20342 v2di __builtin_ia32_extrq (v2di, v16qi)
20343 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
20344 v2di __builtin_ia32_insertq (v2di, v2di)
20345 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
20348 The following built-in functions are available when @option{-mxop} is used.
20350 v2df __builtin_ia32_vfrczpd (v2df)
20351 v4sf __builtin_ia32_vfrczps (v4sf)
20352 v2df __builtin_ia32_vfrczsd (v2df)
20353 v4sf __builtin_ia32_vfrczss (v4sf)
20354 v4df __builtin_ia32_vfrczpd256 (v4df)
20355 v8sf __builtin_ia32_vfrczps256 (v8sf)
20356 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
20357 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
20358 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
20359 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
20360 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
20361 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
20362 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
20363 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
20364 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
20365 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
20366 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
20367 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
20368 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
20369 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
20370 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
20371 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
20372 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
20373 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
20374 v4si __builtin_ia32_vpcomequd (v4si, v4si)
20375 v2di __builtin_ia32_vpcomequq (v2di, v2di)
20376 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
20377 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
20378 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
20379 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
20380 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
20381 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
20382 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
20383 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
20384 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
20385 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
20386 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
20387 v4si __builtin_ia32_vpcomged (v4si, v4si)
20388 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
20389 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
20390 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
20391 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
20392 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
20393 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
20394 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
20395 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
20396 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
20397 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
20398 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
20399 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
20400 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
20401 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
20402 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
20403 v4si __builtin_ia32_vpcomled (v4si, v4si)
20404 v2di __builtin_ia32_vpcomleq (v2di, v2di)
20405 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
20406 v4si __builtin_ia32_vpcomleud (v4si, v4si)
20407 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
20408 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
20409 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
20410 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
20411 v4si __builtin_ia32_vpcomltd (v4si, v4si)
20412 v2di __builtin_ia32_vpcomltq (v2di, v2di)
20413 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
20414 v4si __builtin_ia32_vpcomltud (v4si, v4si)
20415 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
20416 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
20417 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
20418 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
20419 v4si __builtin_ia32_vpcomned (v4si, v4si)
20420 v2di __builtin_ia32_vpcomneq (v2di, v2di)
20421 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
20422 v4si __builtin_ia32_vpcomneud (v4si, v4si)
20423 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
20424 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
20425 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
20426 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
20427 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
20428 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
20429 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
20430 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
20431 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
20432 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
20433 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
20434 v4si __builtin_ia32_vphaddbd (v16qi)
20435 v2di __builtin_ia32_vphaddbq (v16qi)
20436 v8hi __builtin_ia32_vphaddbw (v16qi)
20437 v2di __builtin_ia32_vphadddq (v4si)
20438 v4si __builtin_ia32_vphaddubd (v16qi)
20439 v2di __builtin_ia32_vphaddubq (v16qi)
20440 v8hi __builtin_ia32_vphaddubw (v16qi)
20441 v2di __builtin_ia32_vphaddudq (v4si)
20442 v4si __builtin_ia32_vphadduwd (v8hi)
20443 v2di __builtin_ia32_vphadduwq (v8hi)
20444 v4si __builtin_ia32_vphaddwd (v8hi)
20445 v2di __builtin_ia32_vphaddwq (v8hi)
20446 v8hi __builtin_ia32_vphsubbw (v16qi)
20447 v2di __builtin_ia32_vphsubdq (v4si)
20448 v4si __builtin_ia32_vphsubwd (v8hi)
20449 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
20450 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
20451 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
20452 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
20453 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
20454 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
20455 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
20456 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
20457 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
20458 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
20459 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
20460 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
20461 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
20462 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
20463 v4si __builtin_ia32_vprotd (v4si, v4si)
20464 v2di __builtin_ia32_vprotq (v2di, v2di)
20465 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
20466 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
20467 v4si __builtin_ia32_vpshad (v4si, v4si)
20468 v2di __builtin_ia32_vpshaq (v2di, v2di)
20469 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
20470 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
20471 v4si __builtin_ia32_vpshld (v4si, v4si)
20472 v2di __builtin_ia32_vpshlq (v2di, v2di)
20473 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
20476 The following built-in functions are available when @option{-mfma4} is used.
20477 All of them generate the machine instruction that is part of the name.
20480 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
20481 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
20482 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
20483 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
20484 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
20485 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
20486 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
20487 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
20488 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
20489 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
20490 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
20491 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
20492 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
20493 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
20494 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
20495 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
20496 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
20497 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
20498 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
20499 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
20500 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
20501 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
20502 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
20503 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
20504 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
20505 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
20506 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
20507 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
20508 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
20509 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
20510 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
20511 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
20515 The following built-in functions are available when @option{-mlwp} is used.
20518 void __builtin_ia32_llwpcb16 (void *);
20519 void __builtin_ia32_llwpcb32 (void *);
20520 void __builtin_ia32_llwpcb64 (void *);
20521 void * __builtin_ia32_llwpcb16 (void);
20522 void * __builtin_ia32_llwpcb32 (void);
20523 void * __builtin_ia32_llwpcb64 (void);
20524 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
20525 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
20526 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
20527 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
20528 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
20529 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
20532 The following built-in functions are available when @option{-mbmi} is used.
20533 All of them generate the machine instruction that is part of the name.
20535 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
20536 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
20539 The following built-in functions are available when @option{-mbmi2} is used.
20540 All of them generate the machine instruction that is part of the name.
20542 unsigned int _bzhi_u32 (unsigned int, unsigned int)
20543 unsigned int _pdep_u32 (unsigned int, unsigned int)
20544 unsigned int _pext_u32 (unsigned int, unsigned int)
20545 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
20546 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
20547 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
20550 The following built-in functions are available when @option{-mlzcnt} is used.
20551 All of them generate the machine instruction that is part of the name.
20553 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
20554 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
20555 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
20558 The following built-in functions are available when @option{-mfxsr} is used.
20559 All of them generate the machine instruction that is part of the name.
20561 void __builtin_ia32_fxsave (void *)
20562 void __builtin_ia32_fxrstor (void *)
20563 void __builtin_ia32_fxsave64 (void *)
20564 void __builtin_ia32_fxrstor64 (void *)
20567 The following built-in functions are available when @option{-mxsave} is used.
20568 All of them generate the machine instruction that is part of the name.
20570 void __builtin_ia32_xsave (void *, long long)
20571 void __builtin_ia32_xrstor (void *, long long)
20572 void __builtin_ia32_xsave64 (void *, long long)
20573 void __builtin_ia32_xrstor64 (void *, long long)
20576 The following built-in functions are available when @option{-mxsaveopt} is used.
20577 All of them generate the machine instruction that is part of the name.
20579 void __builtin_ia32_xsaveopt (void *, long long)
20580 void __builtin_ia32_xsaveopt64 (void *, long long)
20583 The following built-in functions are available when @option{-mtbm} is used.
20584 Both of them generate the immediate form of the bextr machine instruction.
20586 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
20587 const unsigned int);
20588 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
20589 const unsigned long long);
20593 The following built-in functions are available when @option{-m3dnow} is used.
20594 All of them generate the machine instruction that is part of the name.
20597 void __builtin_ia32_femms (void)
20598 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
20599 v2si __builtin_ia32_pf2id (v2sf)
20600 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
20601 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
20602 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
20603 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
20604 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
20605 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
20606 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
20607 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
20608 v2sf __builtin_ia32_pfrcp (v2sf)
20609 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
20610 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
20611 v2sf __builtin_ia32_pfrsqrt (v2sf)
20612 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
20613 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
20614 v2sf __builtin_ia32_pi2fd (v2si)
20615 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
20618 The following built-in functions are available when both @option{-m3dnow}
20619 and @option{-march=athlon} are used. All of them generate the machine
20620 instruction that is part of the name.
20623 v2si __builtin_ia32_pf2iw (v2sf)
20624 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
20625 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
20626 v2sf __builtin_ia32_pi2fw (v2si)
20627 v2sf __builtin_ia32_pswapdsf (v2sf)
20628 v2si __builtin_ia32_pswapdsi (v2si)
20631 The following built-in functions are available when @option{-mrtm} is used
20632 They are used for restricted transactional memory. These are the internal
20633 low level functions. Normally the functions in
20634 @ref{x86 transactional memory intrinsics} should be used instead.
20637 int __builtin_ia32_xbegin ()
20638 void __builtin_ia32_xend ()
20639 void __builtin_ia32_xabort (status)
20640 int __builtin_ia32_xtest ()
20643 The following built-in functions are available when @option{-mmwaitx} is used.
20644 All of them generate the machine instruction that is part of the name.
20646 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
20647 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
20650 The following built-in functions are available when @option{-mclzero} is used.
20651 All of them generate the machine instruction that is part of the name.
20653 void __builtin_i32_clzero (void *)
20656 The following built-in functions are available when @option{-mpku} is used.
20657 They generate reads and writes to PKRU.
20659 void __builtin_ia32_wrpkru (unsigned int)
20660 unsigned int __builtin_ia32_rdpkru ()
20663 @node x86 transactional memory intrinsics
20664 @subsection x86 Transactional Memory Intrinsics
20666 These hardware transactional memory intrinsics for x86 allow you to use
20667 memory transactions with RTM (Restricted Transactional Memory).
20668 This support is enabled with the @option{-mrtm} option.
20669 For using HLE (Hardware Lock Elision) see
20670 @ref{x86 specific memory model extensions for transactional memory} instead.
20672 A memory transaction commits all changes to memory in an atomic way,
20673 as visible to other threads. If the transaction fails it is rolled back
20674 and all side effects discarded.
20676 Generally there is no guarantee that a memory transaction ever succeeds
20677 and suitable fallback code always needs to be supplied.
20679 @deftypefn {RTM Function} {unsigned} _xbegin ()
20680 Start a RTM (Restricted Transactional Memory) transaction.
20681 Returns @code{_XBEGIN_STARTED} when the transaction
20682 started successfully (note this is not 0, so the constant has to be
20683 explicitly tested).
20685 If the transaction aborts, all side-effects
20686 are undone and an abort code encoded as a bit mask is returned.
20687 The following macros are defined:
20690 @item _XABORT_EXPLICIT
20691 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
20692 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
20693 @item _XABORT_RETRY
20694 Transaction retry is possible.
20695 @item _XABORT_CONFLICT
20696 Transaction abort due to a memory conflict with another thread.
20697 @item _XABORT_CAPACITY
20698 Transaction abort due to the transaction using too much memory.
20699 @item _XABORT_DEBUG
20700 Transaction abort due to a debug trap.
20701 @item _XABORT_NESTED
20702 Transaction abort in an inner nested transaction.
20705 There is no guarantee
20706 any transaction ever succeeds, so there always needs to be a valid
20710 @deftypefn {RTM Function} {void} _xend ()
20711 Commit the current transaction. When no transaction is active this faults.
20712 All memory side-effects of the transaction become visible
20713 to other threads in an atomic manner.
20716 @deftypefn {RTM Function} {int} _xtest ()
20717 Return a nonzero value if a transaction is currently active, otherwise 0.
20720 @deftypefn {RTM Function} {void} _xabort (status)
20721 Abort the current transaction. When no transaction is active this is a no-op.
20722 The @var{status} is an 8-bit constant; its value is encoded in the return
20723 value from @code{_xbegin}.
20726 Here is an example showing handling for @code{_XABORT_RETRY}
20727 and a fallback path for other failures:
20730 #include <immintrin.h>
20732 int n_tries, max_tries;
20733 unsigned status = _XABORT_EXPLICIT;
20736 for (n_tries = 0; n_tries < max_tries; n_tries++)
20738 status = _xbegin ();
20739 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
20742 if (status == _XBEGIN_STARTED)
20744 ... transaction code...
20749 ... non-transactional fallback path...
20754 Note that, in most cases, the transactional and non-transactional code
20755 must synchronize together to ensure consistency.
20757 @node Target Format Checks
20758 @section Format Checks Specific to Particular Target Machines
20760 For some target machines, GCC supports additional options to the
20762 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
20765 * Solaris Format Checks::
20766 * Darwin Format Checks::
20769 @node Solaris Format Checks
20770 @subsection Solaris Format Checks
20772 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
20773 check. @code{cmn_err} accepts a subset of the standard @code{printf}
20774 conversions, and the two-argument @code{%b} conversion for displaying
20775 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
20777 @node Darwin Format Checks
20778 @subsection Darwin Format Checks
20780 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
20781 attribute context. Declarations made with such attribution are parsed for correct syntax
20782 and format argument types. However, parsing of the format string itself is currently undefined
20783 and is not carried out by this version of the compiler.
20785 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
20786 also be used as format arguments. Note that the relevant headers are only likely to be
20787 available on Darwin (OSX) installations. On such installations, the XCode and system
20788 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
20789 associated functions.
20792 @section Pragmas Accepted by GCC
20794 @cindex @code{#pragma}
20796 GCC supports several types of pragmas, primarily in order to compile
20797 code originally written for other compilers. Note that in general
20798 we do not recommend the use of pragmas; @xref{Function Attributes},
20799 for further explanation.
20802 * AArch64 Pragmas::
20806 * RS/6000 and PowerPC Pragmas::
20809 * Solaris Pragmas::
20810 * Symbol-Renaming Pragmas::
20811 * Structure-Layout Pragmas::
20813 * Diagnostic Pragmas::
20814 * Visibility Pragmas::
20815 * Push/Pop Macro Pragmas::
20816 * Function Specific Option Pragmas::
20817 * Loop-Specific Pragmas::
20820 @node AArch64 Pragmas
20821 @subsection AArch64 Pragmas
20823 The pragmas defined by the AArch64 target correspond to the AArch64
20824 target function attributes. They can be specified as below:
20826 #pragma GCC target("string")
20829 where @code{@var{string}} can be any string accepted as an AArch64 target
20830 attribute. @xref{AArch64 Function Attributes}, for more details
20831 on the permissible values of @code{string}.
20834 @subsection ARM Pragmas
20836 The ARM target defines pragmas for controlling the default addition of
20837 @code{long_call} and @code{short_call} attributes to functions.
20838 @xref{Function Attributes}, for information about the effects of these
20843 @cindex pragma, long_calls
20844 Set all subsequent functions to have the @code{long_call} attribute.
20846 @item no_long_calls
20847 @cindex pragma, no_long_calls
20848 Set all subsequent functions to have the @code{short_call} attribute.
20850 @item long_calls_off
20851 @cindex pragma, long_calls_off
20852 Do not affect the @code{long_call} or @code{short_call} attributes of
20853 subsequent functions.
20857 @subsection M32C Pragmas
20860 @item GCC memregs @var{number}
20861 @cindex pragma, memregs
20862 Overrides the command-line option @code{-memregs=} for the current
20863 file. Use with care! This pragma must be before any function in the
20864 file, and mixing different memregs values in different objects may
20865 make them incompatible. This pragma is useful when a
20866 performance-critical function uses a memreg for temporary values,
20867 as it may allow you to reduce the number of memregs used.
20869 @item ADDRESS @var{name} @var{address}
20870 @cindex pragma, address
20871 For any declared symbols matching @var{name}, this does three things
20872 to that symbol: it forces the symbol to be located at the given
20873 address (a number), it forces the symbol to be volatile, and it
20874 changes the symbol's scope to be static. This pragma exists for
20875 compatibility with other compilers, but note that the common
20876 @code{1234H} numeric syntax is not supported (use @code{0x1234}
20880 #pragma ADDRESS port3 0x103
20887 @subsection MeP Pragmas
20891 @item custom io_volatile (on|off)
20892 @cindex pragma, custom io_volatile
20893 Overrides the command-line option @code{-mio-volatile} for the current
20894 file. Note that for compatibility with future GCC releases, this
20895 option should only be used once before any @code{io} variables in each
20898 @item GCC coprocessor available @var{registers}
20899 @cindex pragma, coprocessor available
20900 Specifies which coprocessor registers are available to the register
20901 allocator. @var{registers} may be a single register, register range
20902 separated by ellipses, or comma-separated list of those. Example:
20905 #pragma GCC coprocessor available $c0...$c10, $c28
20908 @item GCC coprocessor call_saved @var{registers}
20909 @cindex pragma, coprocessor call_saved
20910 Specifies which coprocessor registers are to be saved and restored by
20911 any function using them. @var{registers} may be a single register,
20912 register range separated by ellipses, or comma-separated list of
20916 #pragma GCC coprocessor call_saved $c4...$c6, $c31
20919 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
20920 @cindex pragma, coprocessor subclass
20921 Creates and defines a register class. These register classes can be
20922 used by inline @code{asm} constructs. @var{registers} may be a single
20923 register, register range separated by ellipses, or comma-separated
20924 list of those. Example:
20927 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
20929 asm ("cpfoo %0" : "=B" (x));
20932 @item GCC disinterrupt @var{name} , @var{name} @dots{}
20933 @cindex pragma, disinterrupt
20934 For the named functions, the compiler adds code to disable interrupts
20935 for the duration of those functions. If any functions so named
20936 are not encountered in the source, a warning is emitted that the pragma is
20937 not used. Examples:
20940 #pragma disinterrupt foo
20941 #pragma disinterrupt bar, grill
20942 int foo () @{ @dots{} @}
20945 @item GCC call @var{name} , @var{name} @dots{}
20946 @cindex pragma, call
20947 For the named functions, the compiler always uses a register-indirect
20948 call model when calling the named functions. Examples:
20957 @node RS/6000 and PowerPC Pragmas
20958 @subsection RS/6000 and PowerPC Pragmas
20960 The RS/6000 and PowerPC targets define one pragma for controlling
20961 whether or not the @code{longcall} attribute is added to function
20962 declarations by default. This pragma overrides the @option{-mlongcall}
20963 option, but not the @code{longcall} and @code{shortcall} attributes.
20964 @xref{RS/6000 and PowerPC Options}, for more information about when long
20965 calls are and are not necessary.
20969 @cindex pragma, longcall
20970 Apply the @code{longcall} attribute to all subsequent function
20974 Do not apply the @code{longcall} attribute to subsequent function
20978 @c Describe h8300 pragmas here.
20979 @c Describe sh pragmas here.
20980 @c Describe v850 pragmas here.
20982 @node S/390 Pragmas
20983 @subsection S/390 Pragmas
20985 The pragmas defined by the S/390 target correspond to the S/390
20986 target function attributes and some the additional options:
20993 Note that options of the pragma, unlike options of the target
20994 attribute, do change the value of preprocessor macros like
20995 @code{__VEC__}. They can be specified as below:
20998 #pragma GCC target("string[,string]...")
20999 #pragma GCC target("string"[,"string"]...)
21002 @node Darwin Pragmas
21003 @subsection Darwin Pragmas
21005 The following pragmas are available for all architectures running the
21006 Darwin operating system. These are useful for compatibility with other
21010 @item mark @var{tokens}@dots{}
21011 @cindex pragma, mark
21012 This pragma is accepted, but has no effect.
21014 @item options align=@var{alignment}
21015 @cindex pragma, options align
21016 This pragma sets the alignment of fields in structures. The values of
21017 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
21018 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
21019 properly; to restore the previous setting, use @code{reset} for the
21022 @item segment @var{tokens}@dots{}
21023 @cindex pragma, segment
21024 This pragma is accepted, but has no effect.
21026 @item unused (@var{var} [, @var{var}]@dots{})
21027 @cindex pragma, unused
21028 This pragma declares variables to be possibly unused. GCC does not
21029 produce warnings for the listed variables. The effect is similar to
21030 that of the @code{unused} attribute, except that this pragma may appear
21031 anywhere within the variables' scopes.
21034 @node Solaris Pragmas
21035 @subsection Solaris Pragmas
21037 The Solaris target supports @code{#pragma redefine_extname}
21038 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
21039 @code{#pragma} directives for compatibility with the system compiler.
21042 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
21043 @cindex pragma, align
21045 Increase the minimum alignment of each @var{variable} to @var{alignment}.
21046 This is the same as GCC's @code{aligned} attribute @pxref{Variable
21047 Attributes}). Macro expansion occurs on the arguments to this pragma
21048 when compiling C and Objective-C@. It does not currently occur when
21049 compiling C++, but this is a bug which may be fixed in a future
21052 @item fini (@var{function} [, @var{function}]...)
21053 @cindex pragma, fini
21055 This pragma causes each listed @var{function} to be called after
21056 main, or during shared module unloading, by adding a call to the
21057 @code{.fini} section.
21059 @item init (@var{function} [, @var{function}]...)
21060 @cindex pragma, init
21062 This pragma causes each listed @var{function} to be called during
21063 initialization (before @code{main}) or during shared module loading, by
21064 adding a call to the @code{.init} section.
21068 @node Symbol-Renaming Pragmas
21069 @subsection Symbol-Renaming Pragmas
21071 GCC supports a @code{#pragma} directive that changes the name used in
21072 assembly for a given declaration. While this pragma is supported on all
21073 platforms, it is intended primarily to provide compatibility with the
21074 Solaris system headers. This effect can also be achieved using the asm
21075 labels extension (@pxref{Asm Labels}).
21078 @item redefine_extname @var{oldname} @var{newname}
21079 @cindex pragma, redefine_extname
21081 This pragma gives the C function @var{oldname} the assembly symbol
21082 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
21083 is defined if this pragma is available (currently on all platforms).
21086 This pragma and the asm labels extension interact in a complicated
21087 manner. Here are some corner cases you may want to be aware of:
21090 @item This pragma silently applies only to declarations with external
21091 linkage. Asm labels do not have this restriction.
21093 @item In C++, this pragma silently applies only to declarations with
21094 ``C'' linkage. Again, asm labels do not have this restriction.
21096 @item If either of the ways of changing the assembly name of a
21097 declaration are applied to a declaration whose assembly name has
21098 already been determined (either by a previous use of one of these
21099 features, or because the compiler needed the assembly name in order to
21100 generate code), and the new name is different, a warning issues and
21101 the name does not change.
21103 @item The @var{oldname} used by @code{#pragma redefine_extname} is
21104 always the C-language name.
21107 @node Structure-Layout Pragmas
21108 @subsection Structure-Layout Pragmas
21110 For compatibility with Microsoft Windows compilers, GCC supports a
21111 set of @code{#pragma} directives that change the maximum alignment of
21112 members of structures (other than zero-width bit-fields), unions, and
21113 classes subsequently defined. The @var{n} value below always is required
21114 to be a small power of two and specifies the new alignment in bytes.
21117 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
21118 @item @code{#pragma pack()} sets the alignment to the one that was in
21119 effect when compilation started (see also command-line option
21120 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
21121 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
21122 setting on an internal stack and then optionally sets the new alignment.
21123 @item @code{#pragma pack(pop)} restores the alignment setting to the one
21124 saved at the top of the internal stack (and removes that stack entry).
21125 Note that @code{#pragma pack([@var{n}])} does not influence this internal
21126 stack; thus it is possible to have @code{#pragma pack(push)} followed by
21127 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
21128 @code{#pragma pack(pop)}.
21131 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
21132 directive which lays out structures and unions subsequently defined as the
21133 documented @code{__attribute__ ((ms_struct))}.
21136 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
21137 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
21138 @item @code{#pragma ms_struct reset} goes back to the default layout.
21141 Most targets also support the @code{#pragma scalar_storage_order} directive
21142 which lays out structures and unions subsequently defined as the documented
21143 @code{__attribute__ ((scalar_storage_order))}.
21146 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
21147 of the scalar fields to big-endian.
21148 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
21149 of the scalar fields to little-endian.
21150 @item @code{#pragma scalar_storage_order default} goes back to the endianness
21151 that was in effect when compilation started (see also command-line option
21152 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
21156 @subsection Weak Pragmas
21158 For compatibility with SVR4, GCC supports a set of @code{#pragma}
21159 directives for declaring symbols to be weak, and defining weak
21163 @item #pragma weak @var{symbol}
21164 @cindex pragma, weak
21165 This pragma declares @var{symbol} to be weak, as if the declaration
21166 had the attribute of the same name. The pragma may appear before
21167 or after the declaration of @var{symbol}. It is not an error for
21168 @var{symbol} to never be defined at all.
21170 @item #pragma weak @var{symbol1} = @var{symbol2}
21171 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
21172 It is an error if @var{symbol2} is not defined in the current
21176 @node Diagnostic Pragmas
21177 @subsection Diagnostic Pragmas
21179 GCC allows the user to selectively enable or disable certain types of
21180 diagnostics, and change the kind of the diagnostic. For example, a
21181 project's policy might require that all sources compile with
21182 @option{-Werror} but certain files might have exceptions allowing
21183 specific types of warnings. Or, a project might selectively enable
21184 diagnostics and treat them as errors depending on which preprocessor
21185 macros are defined.
21188 @item #pragma GCC diagnostic @var{kind} @var{option}
21189 @cindex pragma, diagnostic
21191 Modifies the disposition of a diagnostic. Note that not all
21192 diagnostics are modifiable; at the moment only warnings (normally
21193 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
21194 Use @option{-fdiagnostics-show-option} to determine which diagnostics
21195 are controllable and which option controls them.
21197 @var{kind} is @samp{error} to treat this diagnostic as an error,
21198 @samp{warning} to treat it like a warning (even if @option{-Werror} is
21199 in effect), or @samp{ignored} if the diagnostic is to be ignored.
21200 @var{option} is a double quoted string that matches the command-line
21204 #pragma GCC diagnostic warning "-Wformat"
21205 #pragma GCC diagnostic error "-Wformat"
21206 #pragma GCC diagnostic ignored "-Wformat"
21209 Note that these pragmas override any command-line options. GCC keeps
21210 track of the location of each pragma, and issues diagnostics according
21211 to the state as of that point in the source file. Thus, pragmas occurring
21212 after a line do not affect diagnostics caused by that line.
21214 @item #pragma GCC diagnostic push
21215 @itemx #pragma GCC diagnostic pop
21217 Causes GCC to remember the state of the diagnostics as of each
21218 @code{push}, and restore to that point at each @code{pop}. If a
21219 @code{pop} has no matching @code{push}, the command-line options are
21223 #pragma GCC diagnostic error "-Wuninitialized"
21224 foo(a); /* error is given for this one */
21225 #pragma GCC diagnostic push
21226 #pragma GCC diagnostic ignored "-Wuninitialized"
21227 foo(b); /* no diagnostic for this one */
21228 #pragma GCC diagnostic pop
21229 foo(c); /* error is given for this one */
21230 #pragma GCC diagnostic pop
21231 foo(d); /* depends on command-line options */
21236 GCC also offers a simple mechanism for printing messages during
21240 @item #pragma message @var{string}
21241 @cindex pragma, diagnostic
21243 Prints @var{string} as a compiler message on compilation. The message
21244 is informational only, and is neither a compilation warning nor an error.
21247 #pragma message "Compiling " __FILE__ "..."
21250 @var{string} may be parenthesized, and is printed with location
21251 information. For example,
21254 #define DO_PRAGMA(x) _Pragma (#x)
21255 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
21257 TODO(Remember to fix this)
21261 prints @samp{/tmp/file.c:4: note: #pragma message:
21262 TODO - Remember to fix this}.
21266 @node Visibility Pragmas
21267 @subsection Visibility Pragmas
21270 @item #pragma GCC visibility push(@var{visibility})
21271 @itemx #pragma GCC visibility pop
21272 @cindex pragma, visibility
21274 This pragma allows the user to set the visibility for multiple
21275 declarations without having to give each a visibility attribute
21276 (@pxref{Function Attributes}).
21278 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
21279 declarations. Class members and template specializations are not
21280 affected; if you want to override the visibility for a particular
21281 member or instantiation, you must use an attribute.
21286 @node Push/Pop Macro Pragmas
21287 @subsection Push/Pop Macro Pragmas
21289 For compatibility with Microsoft Windows compilers, GCC supports
21290 @samp{#pragma push_macro(@var{"macro_name"})}
21291 and @samp{#pragma pop_macro(@var{"macro_name"})}.
21294 @item #pragma push_macro(@var{"macro_name"})
21295 @cindex pragma, push_macro
21296 This pragma saves the value of the macro named as @var{macro_name} to
21297 the top of the stack for this macro.
21299 @item #pragma pop_macro(@var{"macro_name"})
21300 @cindex pragma, pop_macro
21301 This pragma sets the value of the macro named as @var{macro_name} to
21302 the value on top of the stack for this macro. If the stack for
21303 @var{macro_name} is empty, the value of the macro remains unchanged.
21310 #pragma push_macro("X")
21313 #pragma pop_macro("X")
21318 In this example, the definition of X as 1 is saved by @code{#pragma
21319 push_macro} and restored by @code{#pragma pop_macro}.
21321 @node Function Specific Option Pragmas
21322 @subsection Function Specific Option Pragmas
21325 @item #pragma GCC target (@var{"string"}...)
21326 @cindex pragma GCC target
21328 This pragma allows you to set target specific options for functions
21329 defined later in the source file. One or more strings can be
21330 specified. Each function that is defined after this point is as
21331 if @code{attribute((target("STRING")))} was specified for that
21332 function. The parenthesis around the options is optional.
21333 @xref{Function Attributes}, for more information about the
21334 @code{target} attribute and the attribute syntax.
21336 The @code{#pragma GCC target} pragma is presently implemented for
21337 x86, PowerPC, and Nios II targets only.
21341 @item #pragma GCC optimize (@var{"string"}...)
21342 @cindex pragma GCC optimize
21344 This pragma allows you to set global optimization options for functions
21345 defined later in the source file. One or more strings can be
21346 specified. Each function that is defined after this point is as
21347 if @code{attribute((optimize("STRING")))} was specified for that
21348 function. The parenthesis around the options is optional.
21349 @xref{Function Attributes}, for more information about the
21350 @code{optimize} attribute and the attribute syntax.
21354 @item #pragma GCC push_options
21355 @itemx #pragma GCC pop_options
21356 @cindex pragma GCC push_options
21357 @cindex pragma GCC pop_options
21359 These pragmas maintain a stack of the current target and optimization
21360 options. It is intended for include files where you temporarily want
21361 to switch to using a different @samp{#pragma GCC target} or
21362 @samp{#pragma GCC optimize} and then to pop back to the previous
21367 @item #pragma GCC reset_options
21368 @cindex pragma GCC reset_options
21370 This pragma clears the current @code{#pragma GCC target} and
21371 @code{#pragma GCC optimize} to use the default switches as specified
21372 on the command line.
21375 @node Loop-Specific Pragmas
21376 @subsection Loop-Specific Pragmas
21379 @item #pragma GCC ivdep
21380 @cindex pragma GCC ivdep
21383 With this pragma, the programmer asserts that there are no loop-carried
21384 dependencies which would prevent consecutive iterations of
21385 the following loop from executing concurrently with SIMD
21386 (single instruction multiple data) instructions.
21388 For example, the compiler can only unconditionally vectorize the following
21389 loop with the pragma:
21392 void foo (int n, int *a, int *b, int *c)
21396 for (i = 0; i < n; ++i)
21397 a[i] = b[i] + c[i];
21402 In this example, using the @code{restrict} qualifier had the same
21403 effect. In the following example, that would not be possible. Assume
21404 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
21405 that it can unconditionally vectorize the following loop:
21408 void ignore_vec_dep (int *a, int k, int c, int m)
21411 for (int i = 0; i < m; i++)
21412 a[i] = a[i + k] * c;
21417 @node Unnamed Fields
21418 @section Unnamed Structure and Union Fields
21419 @cindex @code{struct}
21420 @cindex @code{union}
21422 As permitted by ISO C11 and for compatibility with other compilers,
21423 GCC allows you to define
21424 a structure or union that contains, as fields, structures and unions
21425 without names. For example:
21439 In this example, you are able to access members of the unnamed
21440 union with code like @samp{foo.b}. Note that only unnamed structs and
21441 unions are allowed, you may not have, for example, an unnamed
21444 You must never create such structures that cause ambiguous field definitions.
21445 For example, in this structure:
21457 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
21458 The compiler gives errors for such constructs.
21460 @opindex fms-extensions
21461 Unless @option{-fms-extensions} is used, the unnamed field must be a
21462 structure or union definition without a tag (for example, @samp{struct
21463 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
21464 also be a definition with a tag such as @samp{struct foo @{ int a;
21465 @};}, a reference to a previously defined structure or union such as
21466 @samp{struct foo;}, or a reference to a @code{typedef} name for a
21467 previously defined structure or union type.
21469 @opindex fplan9-extensions
21470 The option @option{-fplan9-extensions} enables
21471 @option{-fms-extensions} as well as two other extensions. First, a
21472 pointer to a structure is automatically converted to a pointer to an
21473 anonymous field for assignments and function calls. For example:
21476 struct s1 @{ int a; @};
21477 struct s2 @{ struct s1; @};
21478 extern void f1 (struct s1 *);
21479 void f2 (struct s2 *p) @{ f1 (p); @}
21483 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
21484 converted into a pointer to the anonymous field.
21486 Second, when the type of an anonymous field is a @code{typedef} for a
21487 @code{struct} or @code{union}, code may refer to the field using the
21488 name of the @code{typedef}.
21491 typedef struct @{ int a; @} s1;
21492 struct s2 @{ s1; @};
21493 s1 f1 (struct s2 *p) @{ return p->s1; @}
21496 These usages are only permitted when they are not ambiguous.
21499 @section Thread-Local Storage
21500 @cindex Thread-Local Storage
21501 @cindex @acronym{TLS}
21502 @cindex @code{__thread}
21504 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
21505 are allocated such that there is one instance of the variable per extant
21506 thread. The runtime model GCC uses to implement this originates
21507 in the IA-64 processor-specific ABI, but has since been migrated
21508 to other processors as well. It requires significant support from
21509 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
21510 system libraries (@file{libc.so} and @file{libpthread.so}), so it
21511 is not available everywhere.
21513 At the user level, the extension is visible with a new storage
21514 class keyword: @code{__thread}. For example:
21518 extern __thread struct state s;
21519 static __thread char *p;
21522 The @code{__thread} specifier may be used alone, with the @code{extern}
21523 or @code{static} specifiers, but with no other storage class specifier.
21524 When used with @code{extern} or @code{static}, @code{__thread} must appear
21525 immediately after the other storage class specifier.
21527 The @code{__thread} specifier may be applied to any global, file-scoped
21528 static, function-scoped static, or static data member of a class. It may
21529 not be applied to block-scoped automatic or non-static data member.
21531 When the address-of operator is applied to a thread-local variable, it is
21532 evaluated at run time and returns the address of the current thread's
21533 instance of that variable. An address so obtained may be used by any
21534 thread. When a thread terminates, any pointers to thread-local variables
21535 in that thread become invalid.
21537 No static initialization may refer to the address of a thread-local variable.
21539 In C++, if an initializer is present for a thread-local variable, it must
21540 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
21543 See @uref{https://www.akkadia.org/drepper/tls.pdf,
21544 ELF Handling For Thread-Local Storage} for a detailed explanation of
21545 the four thread-local storage addressing models, and how the runtime
21546 is expected to function.
21549 * C99 Thread-Local Edits::
21550 * C++98 Thread-Local Edits::
21553 @node C99 Thread-Local Edits
21554 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
21556 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
21557 that document the exact semantics of the language extension.
21561 @cite{5.1.2 Execution environments}
21563 Add new text after paragraph 1
21566 Within either execution environment, a @dfn{thread} is a flow of
21567 control within a program. It is implementation defined whether
21568 or not there may be more than one thread associated with a program.
21569 It is implementation defined how threads beyond the first are
21570 created, the name and type of the function called at thread
21571 startup, and how threads may be terminated. However, objects
21572 with thread storage duration shall be initialized before thread
21577 @cite{6.2.4 Storage durations of objects}
21579 Add new text before paragraph 3
21582 An object whose identifier is declared with the storage-class
21583 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
21584 Its lifetime is the entire execution of the thread, and its
21585 stored value is initialized only once, prior to thread startup.
21589 @cite{6.4.1 Keywords}
21591 Add @code{__thread}.
21594 @cite{6.7.1 Storage-class specifiers}
21596 Add @code{__thread} to the list of storage class specifiers in
21599 Change paragraph 2 to
21602 With the exception of @code{__thread}, at most one storage-class
21603 specifier may be given [@dots{}]. The @code{__thread} specifier may
21604 be used alone, or immediately following @code{extern} or
21608 Add new text after paragraph 6
21611 The declaration of an identifier for a variable that has
21612 block scope that specifies @code{__thread} shall also
21613 specify either @code{extern} or @code{static}.
21615 The @code{__thread} specifier shall be used only with
21620 @node C++98 Thread-Local Edits
21621 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
21623 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
21624 that document the exact semantics of the language extension.
21628 @b{[intro.execution]}
21630 New text after paragraph 4
21633 A @dfn{thread} is a flow of control within the abstract machine.
21634 It is implementation defined whether or not there may be more than
21638 New text after paragraph 7
21641 It is unspecified whether additional action must be taken to
21642 ensure when and whether side effects are visible to other threads.
21648 Add @code{__thread}.
21651 @b{[basic.start.main]}
21653 Add after paragraph 5
21656 The thread that begins execution at the @code{main} function is called
21657 the @dfn{main thread}. It is implementation defined how functions
21658 beginning threads other than the main thread are designated or typed.
21659 A function so designated, as well as the @code{main} function, is called
21660 a @dfn{thread startup function}. It is implementation defined what
21661 happens if a thread startup function returns. It is implementation
21662 defined what happens to other threads when any thread calls @code{exit}.
21666 @b{[basic.start.init]}
21668 Add after paragraph 4
21671 The storage for an object of thread storage duration shall be
21672 statically initialized before the first statement of the thread startup
21673 function. An object of thread storage duration shall not require
21674 dynamic initialization.
21678 @b{[basic.start.term]}
21680 Add after paragraph 3
21683 The type of an object with thread storage duration shall not have a
21684 non-trivial destructor, nor shall it be an array type whose elements
21685 (directly or indirectly) have non-trivial destructors.
21691 Add ``thread storage duration'' to the list in paragraph 1.
21696 Thread, static, and automatic storage durations are associated with
21697 objects introduced by declarations [@dots{}].
21700 Add @code{__thread} to the list of specifiers in paragraph 3.
21703 @b{[basic.stc.thread]}
21705 New section before @b{[basic.stc.static]}
21708 The keyword @code{__thread} applied to a non-local object gives the
21709 object thread storage duration.
21711 A local variable or class data member declared both @code{static}
21712 and @code{__thread} gives the variable or member thread storage
21717 @b{[basic.stc.static]}
21722 All objects that have neither thread storage duration, dynamic
21723 storage duration nor are local [@dots{}].
21729 Add @code{__thread} to the list in paragraph 1.
21734 With the exception of @code{__thread}, at most one
21735 @var{storage-class-specifier} shall appear in a given
21736 @var{decl-specifier-seq}. The @code{__thread} specifier may
21737 be used alone, or immediately following the @code{extern} or
21738 @code{static} specifiers. [@dots{}]
21741 Add after paragraph 5
21744 The @code{__thread} specifier can be applied only to the names of objects
21745 and to anonymous unions.
21751 Add after paragraph 6
21754 Non-@code{static} members shall not be @code{__thread}.
21758 @node Binary constants
21759 @section Binary Constants using the @samp{0b} Prefix
21760 @cindex Binary constants using the @samp{0b} prefix
21762 Integer constants can be written as binary constants, consisting of a
21763 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
21764 @samp{0B}. This is particularly useful in environments that operate a
21765 lot on the bit level (like microcontrollers).
21767 The following statements are identical:
21776 The type of these constants follows the same rules as for octal or
21777 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
21780 @node C++ Extensions
21781 @chapter Extensions to the C++ Language
21782 @cindex extensions, C++ language
21783 @cindex C++ language extensions
21785 The GNU compiler provides these extensions to the C++ language (and you
21786 can also use most of the C language extensions in your C++ programs). If you
21787 want to write code that checks whether these features are available, you can
21788 test for the GNU compiler the same way as for C programs: check for a
21789 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
21790 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
21791 Predefined Macros,cpp,The GNU C Preprocessor}).
21794 * C++ Volatiles:: What constitutes an access to a volatile object.
21795 * Restricted Pointers:: C99 restricted pointers and references.
21796 * Vague Linkage:: Where G++ puts inlines, vtables and such.
21797 * C++ Interface:: You can use a single C++ header file for both
21798 declarations and definitions.
21799 * Template Instantiation:: Methods for ensuring that exactly one copy of
21800 each needed template instantiation is emitted.
21801 * Bound member functions:: You can extract a function pointer to the
21802 method denoted by a @samp{->*} or @samp{.*} expression.
21803 * C++ Attributes:: Variable, function, and type attributes for C++ only.
21804 * Function Multiversioning:: Declaring multiple function versions.
21805 * Type Traits:: Compiler support for type traits.
21806 * C++ Concepts:: Improved support for generic programming.
21807 * Deprecated Features:: Things will disappear from G++.
21808 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
21811 @node C++ Volatiles
21812 @section When is a Volatile C++ Object Accessed?
21813 @cindex accessing volatiles
21814 @cindex volatile read
21815 @cindex volatile write
21816 @cindex volatile access
21818 The C++ standard differs from the C standard in its treatment of
21819 volatile objects. It fails to specify what constitutes a volatile
21820 access, except to say that C++ should behave in a similar manner to C
21821 with respect to volatiles, where possible. However, the different
21822 lvalueness of expressions between C and C++ complicate the behavior.
21823 G++ behaves the same as GCC for volatile access, @xref{C
21824 Extensions,,Volatiles}, for a description of GCC's behavior.
21826 The C and C++ language specifications differ when an object is
21827 accessed in a void context:
21830 volatile int *src = @var{somevalue};
21834 The C++ standard specifies that such expressions do not undergo lvalue
21835 to rvalue conversion, and that the type of the dereferenced object may
21836 be incomplete. The C++ standard does not specify explicitly that it
21837 is lvalue to rvalue conversion that is responsible for causing an
21838 access. There is reason to believe that it is, because otherwise
21839 certain simple expressions become undefined. However, because it
21840 would surprise most programmers, G++ treats dereferencing a pointer to
21841 volatile object of complete type as GCC would do for an equivalent
21842 type in C@. When the object has incomplete type, G++ issues a
21843 warning; if you wish to force an error, you must force a conversion to
21844 rvalue with, for instance, a static cast.
21846 When using a reference to volatile, G++ does not treat equivalent
21847 expressions as accesses to volatiles, but instead issues a warning that
21848 no volatile is accessed. The rationale for this is that otherwise it
21849 becomes difficult to determine where volatile access occur, and not
21850 possible to ignore the return value from functions returning volatile
21851 references. Again, if you wish to force a read, cast the reference to
21854 G++ implements the same behavior as GCC does when assigning to a
21855 volatile object---there is no reread of the assigned-to object, the
21856 assigned rvalue is reused. Note that in C++ assignment expressions
21857 are lvalues, and if used as an lvalue, the volatile object is
21858 referred to. For instance, @var{vref} refers to @var{vobj}, as
21859 expected, in the following example:
21863 volatile int &vref = vobj = @var{something};
21866 @node Restricted Pointers
21867 @section Restricting Pointer Aliasing
21868 @cindex restricted pointers
21869 @cindex restricted references
21870 @cindex restricted this pointer
21872 As with the C front end, G++ understands the C99 feature of restricted pointers,
21873 specified with the @code{__restrict__}, or @code{__restrict} type
21874 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
21875 language flag, @code{restrict} is not a keyword in C++.
21877 In addition to allowing restricted pointers, you can specify restricted
21878 references, which indicate that the reference is not aliased in the local
21882 void fn (int *__restrict__ rptr, int &__restrict__ rref)
21889 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
21890 @var{rref} refers to a (different) unaliased integer.
21892 You may also specify whether a member function's @var{this} pointer is
21893 unaliased by using @code{__restrict__} as a member function qualifier.
21896 void T::fn () __restrict__
21903 Within the body of @code{T::fn}, @var{this} has the effective
21904 definition @code{T *__restrict__ const this}. Notice that the
21905 interpretation of a @code{__restrict__} member function qualifier is
21906 different to that of @code{const} or @code{volatile} qualifier, in that it
21907 is applied to the pointer rather than the object. This is consistent with
21908 other compilers that implement restricted pointers.
21910 As with all outermost parameter qualifiers, @code{__restrict__} is
21911 ignored in function definition matching. This means you only need to
21912 specify @code{__restrict__} in a function definition, rather than
21913 in a function prototype as well.
21915 @node Vague Linkage
21916 @section Vague Linkage
21917 @cindex vague linkage
21919 There are several constructs in C++ that require space in the object
21920 file but are not clearly tied to a single translation unit. We say that
21921 these constructs have ``vague linkage''. Typically such constructs are
21922 emitted wherever they are needed, though sometimes we can be more
21926 @item Inline Functions
21927 Inline functions are typically defined in a header file which can be
21928 included in many different compilations. Hopefully they can usually be
21929 inlined, but sometimes an out-of-line copy is necessary, if the address
21930 of the function is taken or if inlining fails. In general, we emit an
21931 out-of-line copy in all translation units where one is needed. As an
21932 exception, we only emit inline virtual functions with the vtable, since
21933 it always requires a copy.
21935 Local static variables and string constants used in an inline function
21936 are also considered to have vague linkage, since they must be shared
21937 between all inlined and out-of-line instances of the function.
21941 C++ virtual functions are implemented in most compilers using a lookup
21942 table, known as a vtable. The vtable contains pointers to the virtual
21943 functions provided by a class, and each object of the class contains a
21944 pointer to its vtable (or vtables, in some multiple-inheritance
21945 situations). If the class declares any non-inline, non-pure virtual
21946 functions, the first one is chosen as the ``key method'' for the class,
21947 and the vtable is only emitted in the translation unit where the key
21950 @emph{Note:} If the chosen key method is later defined as inline, the
21951 vtable is still emitted in every translation unit that defines it.
21952 Make sure that any inline virtuals are declared inline in the class
21953 body, even if they are not defined there.
21955 @item @code{type_info} objects
21956 @cindex @code{type_info}
21958 C++ requires information about types to be written out in order to
21959 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
21960 For polymorphic classes (classes with virtual functions), the @samp{type_info}
21961 object is written out along with the vtable so that @samp{dynamic_cast}
21962 can determine the dynamic type of a class object at run time. For all
21963 other types, we write out the @samp{type_info} object when it is used: when
21964 applying @samp{typeid} to an expression, throwing an object, or
21965 referring to a type in a catch clause or exception specification.
21967 @item Template Instantiations
21968 Most everything in this section also applies to template instantiations,
21969 but there are other options as well.
21970 @xref{Template Instantiation,,Where's the Template?}.
21974 When used with GNU ld version 2.8 or later on an ELF system such as
21975 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
21976 these constructs will be discarded at link time. This is known as
21979 On targets that don't support COMDAT, but do support weak symbols, GCC
21980 uses them. This way one copy overrides all the others, but
21981 the unused copies still take up space in the executable.
21983 For targets that do not support either COMDAT or weak symbols,
21984 most entities with vague linkage are emitted as local symbols to
21985 avoid duplicate definition errors from the linker. This does not happen
21986 for local statics in inlines, however, as having multiple copies
21987 almost certainly breaks things.
21989 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
21990 another way to control placement of these constructs.
21992 @node C++ Interface
21993 @section C++ Interface and Implementation Pragmas
21995 @cindex interface and implementation headers, C++
21996 @cindex C++ interface and implementation headers
21997 @cindex pragmas, interface and implementation
21999 @code{#pragma interface} and @code{#pragma implementation} provide the
22000 user with a way of explicitly directing the compiler to emit entities
22001 with vague linkage (and debugging information) in a particular
22004 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
22005 by COMDAT support and the ``key method'' heuristic
22006 mentioned in @ref{Vague Linkage}. Using them can actually cause your
22007 program to grow due to unnecessary out-of-line copies of inline
22011 @item #pragma interface
22012 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
22013 @kindex #pragma interface
22014 Use this directive in @emph{header files} that define object classes, to save
22015 space in most of the object files that use those classes. Normally,
22016 local copies of certain information (backup copies of inline member
22017 functions, debugging information, and the internal tables that implement
22018 virtual functions) must be kept in each object file that includes class
22019 definitions. You can use this pragma to avoid such duplication. When a
22020 header file containing @samp{#pragma interface} is included in a
22021 compilation, this auxiliary information is not generated (unless
22022 the main input source file itself uses @samp{#pragma implementation}).
22023 Instead, the object files contain references to be resolved at link
22026 The second form of this directive is useful for the case where you have
22027 multiple headers with the same name in different directories. If you
22028 use this form, you must specify the same string to @samp{#pragma
22031 @item #pragma implementation
22032 @itemx #pragma implementation "@var{objects}.h"
22033 @kindex #pragma implementation
22034 Use this pragma in a @emph{main input file}, when you want full output from
22035 included header files to be generated (and made globally visible). The
22036 included header file, in turn, should use @samp{#pragma interface}.
22037 Backup copies of inline member functions, debugging information, and the
22038 internal tables used to implement virtual functions are all generated in
22039 implementation files.
22041 @cindex implied @code{#pragma implementation}
22042 @cindex @code{#pragma implementation}, implied
22043 @cindex naming convention, implementation headers
22044 If you use @samp{#pragma implementation} with no argument, it applies to
22045 an include file with the same basename@footnote{A file's @dfn{basename}
22046 is the name stripped of all leading path information and of trailing
22047 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
22048 file. For example, in @file{allclass.cc}, giving just
22049 @samp{#pragma implementation}
22050 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
22052 Use the string argument if you want a single implementation file to
22053 include code from multiple header files. (You must also use
22054 @samp{#include} to include the header file; @samp{#pragma
22055 implementation} only specifies how to use the file---it doesn't actually
22058 There is no way to split up the contents of a single header file into
22059 multiple implementation files.
22062 @cindex inlining and C++ pragmas
22063 @cindex C++ pragmas, effect on inlining
22064 @cindex pragmas in C++, effect on inlining
22065 @samp{#pragma implementation} and @samp{#pragma interface} also have an
22066 effect on function inlining.
22068 If you define a class in a header file marked with @samp{#pragma
22069 interface}, the effect on an inline function defined in that class is
22070 similar to an explicit @code{extern} declaration---the compiler emits
22071 no code at all to define an independent version of the function. Its
22072 definition is used only for inlining with its callers.
22074 @opindex fno-implement-inlines
22075 Conversely, when you include the same header file in a main source file
22076 that declares it as @samp{#pragma implementation}, the compiler emits
22077 code for the function itself; this defines a version of the function
22078 that can be found via pointers (or by callers compiled without
22079 inlining). If all calls to the function can be inlined, you can avoid
22080 emitting the function by compiling with @option{-fno-implement-inlines}.
22081 If any calls are not inlined, you will get linker errors.
22083 @node Template Instantiation
22084 @section Where's the Template?
22085 @cindex template instantiation
22087 C++ templates were the first language feature to require more
22088 intelligence from the environment than was traditionally found on a UNIX
22089 system. Somehow the compiler and linker have to make sure that each
22090 template instance occurs exactly once in the executable if it is needed,
22091 and not at all otherwise. There are two basic approaches to this
22092 problem, which are referred to as the Borland model and the Cfront model.
22095 @item Borland model
22096 Borland C++ solved the template instantiation problem by adding the code
22097 equivalent of common blocks to their linker; the compiler emits template
22098 instances in each translation unit that uses them, and the linker
22099 collapses them together. The advantage of this model is that the linker
22100 only has to consider the object files themselves; there is no external
22101 complexity to worry about. The disadvantage is that compilation time
22102 is increased because the template code is being compiled repeatedly.
22103 Code written for this model tends to include definitions of all
22104 templates in the header file, since they must be seen to be
22108 The AT&T C++ translator, Cfront, solved the template instantiation
22109 problem by creating the notion of a template repository, an
22110 automatically maintained place where template instances are stored. A
22111 more modern version of the repository works as follows: As individual
22112 object files are built, the compiler places any template definitions and
22113 instantiations encountered in the repository. At link time, the link
22114 wrapper adds in the objects in the repository and compiles any needed
22115 instances that were not previously emitted. The advantages of this
22116 model are more optimal compilation speed and the ability to use the
22117 system linker; to implement the Borland model a compiler vendor also
22118 needs to replace the linker. The disadvantages are vastly increased
22119 complexity, and thus potential for error; for some code this can be
22120 just as transparent, but in practice it can been very difficult to build
22121 multiple programs in one directory and one program in multiple
22122 directories. Code written for this model tends to separate definitions
22123 of non-inline member templates into a separate file, which should be
22124 compiled separately.
22127 G++ implements the Borland model on targets where the linker supports it,
22128 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
22129 Otherwise G++ implements neither automatic model.
22131 You have the following options for dealing with template instantiations:
22135 Do nothing. Code written for the Borland model works fine, but
22136 each translation unit contains instances of each of the templates it
22137 uses. The duplicate instances will be discarded by the linker, but in
22138 a large program, this can lead to an unacceptable amount of code
22139 duplication in object files or shared libraries.
22141 Duplicate instances of a template can be avoided by defining an explicit
22142 instantiation in one object file, and preventing the compiler from doing
22143 implicit instantiations in any other object files by using an explicit
22144 instantiation declaration, using the @code{extern template} syntax:
22147 extern template int max (int, int);
22150 This syntax is defined in the C++ 2011 standard, but has been supported by
22151 G++ and other compilers since well before 2011.
22153 Explicit instantiations can be used for the largest or most frequently
22154 duplicated instances, without having to know exactly which other instances
22155 are used in the rest of the program. You can scatter the explicit
22156 instantiations throughout your program, perhaps putting them in the
22157 translation units where the instances are used or the translation units
22158 that define the templates themselves; you can put all of the explicit
22159 instantiations you need into one big file; or you can create small files
22166 template class Foo<int>;
22167 template ostream& operator <<
22168 (ostream&, const Foo<int>&);
22172 for each of the instances you need, and create a template instantiation
22173 library from those.
22175 This is the simplest option, but also offers flexibility and
22176 fine-grained control when necessary. It is also the most portable
22177 alternative and programs using this approach will work with most modern
22182 Compile your template-using code with @option{-frepo}. The compiler
22183 generates files with the extension @samp{.rpo} listing all of the
22184 template instantiations used in the corresponding object files that
22185 could be instantiated there; the link wrapper, @samp{collect2},
22186 then updates the @samp{.rpo} files to tell the compiler where to place
22187 those instantiations and rebuild any affected object files. The
22188 link-time overhead is negligible after the first pass, as the compiler
22189 continues to place the instantiations in the same files.
22191 This can be a suitable option for application code written for the Borland
22192 model, as it usually just works. Code written for the Cfront model
22193 needs to be modified so that the template definitions are available at
22194 one or more points of instantiation; usually this is as simple as adding
22195 @code{#include <tmethods.cc>} to the end of each template header.
22197 For library code, if you want the library to provide all of the template
22198 instantiations it needs, just try to link all of its object files
22199 together; the link will fail, but cause the instantiations to be
22200 generated as a side effect. Be warned, however, that this may cause
22201 conflicts if multiple libraries try to provide the same instantiations.
22202 For greater control, use explicit instantiation as described in the next
22206 @opindex fno-implicit-templates
22207 Compile your code with @option{-fno-implicit-templates} to disable the
22208 implicit generation of template instances, and explicitly instantiate
22209 all the ones you use. This approach requires more knowledge of exactly
22210 which instances you need than do the others, but it's less
22211 mysterious and allows greater control if you want to ensure that only
22212 the intended instances are used.
22214 If you are using Cfront-model code, you can probably get away with not
22215 using @option{-fno-implicit-templates} when compiling files that don't
22216 @samp{#include} the member template definitions.
22218 If you use one big file to do the instantiations, you may want to
22219 compile it without @option{-fno-implicit-templates} so you get all of the
22220 instances required by your explicit instantiations (but not by any
22221 other files) without having to specify them as well.
22223 In addition to forward declaration of explicit instantiations
22224 (with @code{extern}), G++ has extended the template instantiation
22225 syntax to support instantiation of the compiler support data for a
22226 template class (i.e.@: the vtable) without instantiating any of its
22227 members (with @code{inline}), and instantiation of only the static data
22228 members of a template class, without the support data or member
22229 functions (with @code{static}):
22232 inline template class Foo<int>;
22233 static template class Foo<int>;
22237 @node Bound member functions
22238 @section Extracting the Function Pointer from a Bound Pointer to Member Function
22240 @cindex pointer to member function
22241 @cindex bound pointer to member function
22243 In C++, pointer to member functions (PMFs) are implemented using a wide
22244 pointer of sorts to handle all the possible call mechanisms; the PMF
22245 needs to store information about how to adjust the @samp{this} pointer,
22246 and if the function pointed to is virtual, where to find the vtable, and
22247 where in the vtable to look for the member function. If you are using
22248 PMFs in an inner loop, you should really reconsider that decision. If
22249 that is not an option, you can extract the pointer to the function that
22250 would be called for a given object/PMF pair and call it directly inside
22251 the inner loop, to save a bit of time.
22253 Note that you still pay the penalty for the call through a
22254 function pointer; on most modern architectures, such a call defeats the
22255 branch prediction features of the CPU@. This is also true of normal
22256 virtual function calls.
22258 The syntax for this extension is
22262 extern int (A::*fp)();
22263 typedef int (*fptr)(A *);
22265 fptr p = (fptr)(a.*fp);
22268 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
22269 no object is needed to obtain the address of the function. They can be
22270 converted to function pointers directly:
22273 fptr p1 = (fptr)(&A::foo);
22276 @opindex Wno-pmf-conversions
22277 You must specify @option{-Wno-pmf-conversions} to use this extension.
22279 @node C++ Attributes
22280 @section C++-Specific Variable, Function, and Type Attributes
22282 Some attributes only make sense for C++ programs.
22285 @item abi_tag ("@var{tag}", ...)
22286 @cindex @code{abi_tag} function attribute
22287 @cindex @code{abi_tag} variable attribute
22288 @cindex @code{abi_tag} type attribute
22289 The @code{abi_tag} attribute can be applied to a function, variable, or class
22290 declaration. It modifies the mangled name of the entity to
22291 incorporate the tag name, in order to distinguish the function or
22292 class from an earlier version with a different ABI; perhaps the class
22293 has changed size, or the function has a different return type that is
22294 not encoded in the mangled name.
22296 The attribute can also be applied to an inline namespace, but does not
22297 affect the mangled name of the namespace; in this case it is only used
22298 for @option{-Wabi-tag} warnings and automatic tagging of functions and
22299 variables. Tagging inline namespaces is generally preferable to
22300 tagging individual declarations, but the latter is sometimes
22301 necessary, such as when only certain members of a class need to be
22304 The argument can be a list of strings of arbitrary length. The
22305 strings are sorted on output, so the order of the list is
22308 A redeclaration of an entity must not add new ABI tags,
22309 since doing so would change the mangled name.
22311 The ABI tags apply to a name, so all instantiations and
22312 specializations of a template have the same tags. The attribute will
22313 be ignored if applied to an explicit specialization or instantiation.
22315 The @option{-Wabi-tag} flag enables a warning about a class which does
22316 not have all the ABI tags used by its subobjects and virtual functions; for users with code
22317 that needs to coexist with an earlier ABI, using this option can help
22318 to find all affected types that need to be tagged.
22320 When a type involving an ABI tag is used as the type of a variable or
22321 return type of a function where that tag is not already present in the
22322 signature of the function, the tag is automatically applied to the
22323 variable or function. @option{-Wabi-tag} also warns about this
22324 situation; this warning can be avoided by explicitly tagging the
22325 variable or function or moving it into a tagged inline namespace.
22327 @item init_priority (@var{priority})
22328 @cindex @code{init_priority} variable attribute
22330 In Standard C++, objects defined at namespace scope are guaranteed to be
22331 initialized in an order in strict accordance with that of their definitions
22332 @emph{in a given translation unit}. No guarantee is made for initializations
22333 across translation units. However, GNU C++ allows users to control the
22334 order of initialization of objects defined at namespace scope with the
22335 @code{init_priority} attribute by specifying a relative @var{priority},
22336 a constant integral expression currently bounded between 101 and 65535
22337 inclusive. Lower numbers indicate a higher priority.
22339 In the following example, @code{A} would normally be created before
22340 @code{B}, but the @code{init_priority} attribute reverses that order:
22343 Some_Class A __attribute__ ((init_priority (2000)));
22344 Some_Class B __attribute__ ((init_priority (543)));
22348 Note that the particular values of @var{priority} do not matter; only their
22352 @cindex @code{warn_unused} type attribute
22354 For C++ types with non-trivial constructors and/or destructors it is
22355 impossible for the compiler to determine whether a variable of this
22356 type is truly unused if it is not referenced. This type attribute
22357 informs the compiler that variables of this type should be warned
22358 about if they appear to be unused, just like variables of fundamental
22361 This attribute is appropriate for types which just represent a value,
22362 such as @code{std::string}; it is not appropriate for types which
22363 control a resource, such as @code{std::lock_guard}.
22365 This attribute is also accepted in C, but it is unnecessary because C
22366 does not have constructors or destructors.
22370 @node Function Multiversioning
22371 @section Function Multiversioning
22372 @cindex function versions
22374 With the GNU C++ front end, for x86 targets, you may specify multiple
22375 versions of a function, where each function is specialized for a
22376 specific target feature. At runtime, the appropriate version of the
22377 function is automatically executed depending on the characteristics of
22378 the execution platform. Here is an example.
22381 __attribute__ ((target ("default")))
22384 // The default version of foo.
22388 __attribute__ ((target ("sse4.2")))
22391 // foo version for SSE4.2
22395 __attribute__ ((target ("arch=atom")))
22398 // foo version for the Intel ATOM processor
22402 __attribute__ ((target ("arch=amdfam10")))
22405 // foo version for the AMD Family 0x10 processors.
22412 assert ((*p) () == foo ());
22417 In the above example, four versions of function foo are created. The
22418 first version of foo with the target attribute "default" is the default
22419 version. This version gets executed when no other target specific
22420 version qualifies for execution on a particular platform. A new version
22421 of foo is created by using the same function signature but with a
22422 different target string. Function foo is called or a pointer to it is
22423 taken just like a regular function. GCC takes care of doing the
22424 dispatching to call the right version at runtime. Refer to the
22425 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
22426 Function Multiversioning} for more details.
22429 @section Type Traits
22431 The C++ front end implements syntactic extensions that allow
22432 compile-time determination of
22433 various characteristics of a type (or of a
22437 @item __has_nothrow_assign (type)
22438 If @code{type} is const qualified or is a reference type then the trait is
22439 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
22440 is true, else if @code{type} is a cv class or union type with copy assignment
22441 operators that are known not to throw an exception then the trait is true,
22442 else it is false. Requires: @code{type} shall be a complete type,
22443 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22445 @item __has_nothrow_copy (type)
22446 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
22447 @code{type} is a cv class or union type with copy constructors that
22448 are known not to throw an exception then the trait is true, else it is false.
22449 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
22450 @code{void}, or an array of unknown bound.
22452 @item __has_nothrow_constructor (type)
22453 If @code{__has_trivial_constructor (type)} is true then the trait is
22454 true, else if @code{type} is a cv class or union type (or array
22455 thereof) with a default constructor that is known not to throw an
22456 exception then the trait is true, else it is false. Requires:
22457 @code{type} shall be a complete type, (possibly cv-qualified)
22458 @code{void}, or an array of unknown bound.
22460 @item __has_trivial_assign (type)
22461 If @code{type} is const qualified or is a reference type then the trait is
22462 false. Otherwise if @code{__is_pod (type)} is true then the trait is
22463 true, else if @code{type} is a cv class or union type with a trivial
22464 copy assignment ([class.copy]) then the trait is true, else it is
22465 false. Requires: @code{type} shall be a complete type, (possibly
22466 cv-qualified) @code{void}, or an array of unknown bound.
22468 @item __has_trivial_copy (type)
22469 If @code{__is_pod (type)} is true or @code{type} is a reference type
22470 then the trait is true, else if @code{type} is a cv class or union type
22471 with a trivial copy constructor ([class.copy]) then the trait
22472 is true, else it is false. Requires: @code{type} shall be a complete
22473 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22475 @item __has_trivial_constructor (type)
22476 If @code{__is_pod (type)} is true then the trait is true, else if
22477 @code{type} is a cv class or union type (or array thereof) with a
22478 trivial default constructor ([class.ctor]) then the trait is true,
22479 else it is false. Requires: @code{type} shall be a complete
22480 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22482 @item __has_trivial_destructor (type)
22483 If @code{__is_pod (type)} is true or @code{type} is a reference type then
22484 the trait is true, else if @code{type} is a cv class or union type (or
22485 array thereof) with a trivial destructor ([class.dtor]) then the trait
22486 is true, else it is false. Requires: @code{type} shall be a complete
22487 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22489 @item __has_virtual_destructor (type)
22490 If @code{type} is a class type with a virtual destructor
22491 ([class.dtor]) then the trait is true, else it is false. Requires:
22492 @code{type} shall be a complete type, (possibly cv-qualified)
22493 @code{void}, or an array of unknown bound.
22495 @item __is_abstract (type)
22496 If @code{type} is an abstract class ([class.abstract]) then the trait
22497 is true, else it is false. Requires: @code{type} shall be a complete
22498 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22500 @item __is_base_of (base_type, derived_type)
22501 If @code{base_type} is a base class of @code{derived_type}
22502 ([class.derived]) then the trait is true, otherwise it is false.
22503 Top-level cv qualifications of @code{base_type} and
22504 @code{derived_type} are ignored. For the purposes of this trait, a
22505 class type is considered is own base. Requires: if @code{__is_class
22506 (base_type)} and @code{__is_class (derived_type)} are true and
22507 @code{base_type} and @code{derived_type} are not the same type
22508 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
22509 type. A diagnostic is produced if this requirement is not met.
22511 @item __is_class (type)
22512 If @code{type} is a cv class type, and not a union type
22513 ([basic.compound]) the trait is true, else it is false.
22515 @item __is_empty (type)
22516 If @code{__is_class (type)} is false then the trait is false.
22517 Otherwise @code{type} is considered empty if and only if: @code{type}
22518 has no non-static data members, or all non-static data members, if
22519 any, are bit-fields of length 0, and @code{type} has no virtual
22520 members, and @code{type} has no virtual base classes, and @code{type}
22521 has no base classes @code{base_type} for which
22522 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
22523 be a complete type, (possibly cv-qualified) @code{void}, or an array
22526 @item __is_enum (type)
22527 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
22528 true, else it is false.
22530 @item __is_literal_type (type)
22531 If @code{type} is a literal type ([basic.types]) the trait is
22532 true, else it is false. Requires: @code{type} shall be a complete type,
22533 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22535 @item __is_pod (type)
22536 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
22537 else it is false. Requires: @code{type} shall be a complete type,
22538 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22540 @item __is_polymorphic (type)
22541 If @code{type} is a polymorphic class ([class.virtual]) then the trait
22542 is true, else it is false. Requires: @code{type} shall be a complete
22543 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22545 @item __is_standard_layout (type)
22546 If @code{type} is a standard-layout type ([basic.types]) the trait is
22547 true, else it is false. Requires: @code{type} shall be a complete
22548 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22550 @item __is_trivial (type)
22551 If @code{type} is a trivial type ([basic.types]) the trait is
22552 true, else it is false. Requires: @code{type} shall be a complete
22553 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22555 @item __is_union (type)
22556 If @code{type} is a cv union type ([basic.compound]) the trait is
22557 true, else it is false.
22559 @item __underlying_type (type)
22560 The underlying type of @code{type}. Requires: @code{type} shall be
22561 an enumeration type ([dcl.enum]).
22567 @section C++ Concepts
22569 C++ concepts provide much-improved support for generic programming. In
22570 particular, they allow the specification of constraints on template arguments.
22571 The constraints are used to extend the usual overloading and partial
22572 specialization capabilities of the language, allowing generic data structures
22573 and algorithms to be ``refined'' based on their properties rather than their
22576 The following keywords are reserved for concepts.
22580 States an expression as an assumption, and if possible, verifies that the
22581 assumption is valid. For example, @code{assume(n > 0)}.
22584 Introduces an axiom definition. Axioms introduce requirements on values.
22587 Introduces a universally quantified object in an axiom. For example,
22588 @code{forall (int n) n + 0 == n}).
22591 Introduces a concept definition. Concepts are sets of syntactic and semantic
22592 requirements on types and their values.
22595 Introduces constraints on template arguments or requirements for a member
22596 function of a class template.
22600 The front end also exposes a number of internal mechanism that can be used
22601 to simplify the writing of type traits. Note that some of these traits are
22602 likely to be removed in the future.
22605 @item __is_same (type1, type2)
22606 A binary type trait: true whenever the type arguments are the same.
22611 @node Deprecated Features
22612 @section Deprecated Features
22614 In the past, the GNU C++ compiler was extended to experiment with new
22615 features, at a time when the C++ language was still evolving. Now that
22616 the C++ standard is complete, some of those features are superseded by
22617 superior alternatives. Using the old features might cause a warning in
22618 some cases that the feature will be dropped in the future. In other
22619 cases, the feature might be gone already.
22621 While the list below is not exhaustive, it documents some of the options
22622 that are now deprecated:
22625 @item -fexternal-templates
22626 @itemx -falt-external-templates
22627 These are two of the many ways for G++ to implement template
22628 instantiation. @xref{Template Instantiation}. The C++ standard clearly
22629 defines how template definitions have to be organized across
22630 implementation units. G++ has an implicit instantiation mechanism that
22631 should work just fine for standard-conforming code.
22633 @item -fstrict-prototype
22634 @itemx -fno-strict-prototype
22635 Previously it was possible to use an empty prototype parameter list to
22636 indicate an unspecified number of parameters (like C), rather than no
22637 parameters, as C++ demands. This feature has been removed, except where
22638 it is required for backwards compatibility. @xref{Backwards Compatibility}.
22641 G++ allows a virtual function returning @samp{void *} to be overridden
22642 by one returning a different pointer type. This extension to the
22643 covariant return type rules is now deprecated and will be removed from a
22646 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
22647 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
22648 and are now removed from G++. Code using these operators should be
22649 modified to use @code{std::min} and @code{std::max} instead.
22651 The named return value extension has been deprecated, and is now
22654 The use of initializer lists with new expressions has been deprecated,
22655 and is now removed from G++.
22657 Floating and complex non-type template parameters have been deprecated,
22658 and are now removed from G++.
22660 The implicit typename extension has been deprecated and is now
22663 The use of default arguments in function pointers, function typedefs
22664 and other places where they are not permitted by the standard is
22665 deprecated and will be removed from a future version of G++.
22667 G++ allows floating-point literals to appear in integral constant expressions,
22668 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
22669 This extension is deprecated and will be removed from a future version.
22671 G++ allows static data members of const floating-point type to be declared
22672 with an initializer in a class definition. The standard only allows
22673 initializers for static members of const integral types and const
22674 enumeration types so this extension has been deprecated and will be removed
22675 from a future version.
22677 @node Backwards Compatibility
22678 @section Backwards Compatibility
22679 @cindex Backwards Compatibility
22680 @cindex ARM [Annotated C++ Reference Manual]
22682 Now that there is a definitive ISO standard C++, G++ has a specification
22683 to adhere to. The C++ language evolved over time, and features that
22684 used to be acceptable in previous drafts of the standard, such as the ARM
22685 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
22686 compilation of C++ written to such drafts, G++ contains some backwards
22687 compatibilities. @emph{All such backwards compatibility features are
22688 liable to disappear in future versions of G++.} They should be considered
22689 deprecated. @xref{Deprecated Features}.
22693 If a variable is declared at for scope, it used to remain in scope until
22694 the end of the scope that contained the for statement (rather than just
22695 within the for scope). G++ retains this, but issues a warning, if such a
22696 variable is accessed outside the for scope.
22698 @item Implicit C language
22699 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
22700 scope to set the language. On such systems, all header files are
22701 implicitly scoped inside a C language scope. Also, an empty prototype
22702 @code{()} is treated as an unspecified number of arguments, rather
22703 than no arguments, as C++ demands.
22706 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
22707 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr