1 @c Copyright (C) 1988-2015 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 * Label Attributes:: Specifying attributes on labels.
60 * Attribute Syntax:: Formal syntax for attributes.
61 * Function Prototypes:: Prototype declarations and old-style definitions.
62 * C++ Comments:: C++ comments are recognized.
63 * Dollar Signs:: Dollar sign is allowed in identifiers.
64 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
65 * Variable Attributes:: Specifying attributes of variables.
66 * Type Attributes:: Specifying attributes of types.
67 * Alignment:: Inquiring about the alignment of a type or variable.
68 * Inline:: Defining inline functions (as fast as macros).
69 * Volatiles:: What constitutes an access to a volatile object.
70 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
71 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
72 * Incomplete Enums:: @code{enum foo;}, with details to follow.
73 * Function Names:: Printable strings which are the name of the current
75 * Return Address:: Getting the return or frame address of a function.
76 * Vector Extensions:: Using vector instructions through built-in functions.
77 * Offsetof:: Special syntax for implementing @code{offsetof}.
78 * __sync Builtins:: Legacy built-in functions for atomic memory access.
79 * __atomic Builtins:: Atomic built-in functions with memory model.
80 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
81 arithmetic overflow checking.
82 * x86 specific memory model extensions for transactional memory:: x86 memory models.
83 * Object Size Checking:: Built-in functions for limited buffer overflow
85 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
86 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
87 * Other Builtins:: Other built-in functions.
88 * Target Builtins:: Built-in functions specific to particular targets.
89 * Target Format Checks:: Format checks specific to particular targets.
90 * Pragmas:: Pragmas accepted by GCC.
91 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
92 * Thread-Local:: Per-thread variables.
93 * Binary constants:: Binary constants using the @samp{0b} prefix.
97 @section Statements and Declarations in Expressions
98 @cindex statements inside expressions
99 @cindex declarations inside expressions
100 @cindex expressions containing statements
101 @cindex macros, statements in expressions
103 @c the above section title wrapped and causes an underfull hbox.. i
104 @c changed it from "within" to "in". --mew 4feb93
105 A compound statement enclosed in parentheses may appear as an expression
106 in GNU C@. This allows you to use loops, switches, and local variables
107 within an expression.
109 Recall that a compound statement is a sequence of statements surrounded
110 by braces; in this construct, parentheses go around the braces. For
114 (@{ int y = foo (); int z;
121 is a valid (though slightly more complex than necessary) expression
122 for the absolute value of @code{foo ()}.
124 The last thing in the compound statement should be an expression
125 followed by a semicolon; the value of this subexpression serves as the
126 value of the entire construct. (If you use some other kind of statement
127 last within the braces, the construct has type @code{void}, and thus
128 effectively no value.)
130 This feature is especially useful in making macro definitions ``safe'' (so
131 that they evaluate each operand exactly once). For example, the
132 ``maximum'' function is commonly defined as a macro in standard C as
136 #define max(a,b) ((a) > (b) ? (a) : (b))
140 @cindex side effects, macro argument
141 But this definition computes either @var{a} or @var{b} twice, with bad
142 results if the operand has side effects. In GNU C, if you know the
143 type of the operands (here taken as @code{int}), you can define
144 the macro safely as follows:
147 #define maxint(a,b) \
148 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
151 Embedded statements are not allowed in constant expressions, such as
152 the value of an enumeration constant, the width of a bit-field, or
153 the initial value of a static variable.
155 If you don't know the type of the operand, you can still do this, but you
156 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
158 In G++, the result value of a statement expression undergoes array and
159 function pointer decay, and is returned by value to the enclosing
160 expression. For instance, if @code{A} is a class, then
169 constructs a temporary @code{A} object to hold the result of the
170 statement expression, and that is used to invoke @code{Foo}.
171 Therefore the @code{this} pointer observed by @code{Foo} is not the
174 In a statement expression, any temporaries created within a statement
175 are destroyed at that statement's end. This makes statement
176 expressions inside macros slightly different from function calls. In
177 the latter case temporaries introduced during argument evaluation are
178 destroyed at the end of the statement that includes the function
179 call. In the statement expression case they are destroyed during
180 the statement expression. For instance,
183 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
184 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
194 has different places where temporaries are destroyed. For the
195 @code{macro} case, the temporary @code{X} is destroyed just after
196 the initialization of @code{b}. In the @code{function} case that
197 temporary is destroyed when the function returns.
199 These considerations mean that it is probably a bad idea to use
200 statement expressions of this form in header files that are designed to
201 work with C++. (Note that some versions of the GNU C Library contained
202 header files using statement expressions that lead to precisely this
205 Jumping into a statement expression with @code{goto} or using a
206 @code{switch} statement outside the statement expression with a
207 @code{case} or @code{default} label inside the statement expression is
208 not permitted. Jumping into a statement expression with a computed
209 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
210 Jumping out of a statement expression is permitted, but if the
211 statement expression is part of a larger expression then it is
212 unspecified which other subexpressions of that expression have been
213 evaluated except where the language definition requires certain
214 subexpressions to be evaluated before or after the statement
215 expression. In any case, as with a function call, the evaluation of a
216 statement expression is not interleaved with the evaluation of other
217 parts of the containing expression. For example,
220 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
224 calls @code{foo} and @code{bar1} and does not call @code{baz} but
225 may or may not call @code{bar2}. If @code{bar2} is called, it is
226 called after @code{foo} and before @code{bar1}.
229 @section Locally Declared Labels
231 @cindex macros, local labels
233 GCC allows you to declare @dfn{local labels} in any nested block
234 scope. A local label is just like an ordinary label, but you can
235 only reference it (with a @code{goto} statement, or by taking its
236 address) within the block in which it is declared.
238 A local label declaration looks like this:
241 __label__ @var{label};
248 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
251 Local label declarations must come at the beginning of the block,
252 before any ordinary declarations or statements.
254 The label declaration defines the label @emph{name}, but does not define
255 the label itself. You must do this in the usual way, with
256 @code{@var{label}:}, within the statements of the statement expression.
258 The local label feature is useful for complex macros. If a macro
259 contains nested loops, a @code{goto} can be useful for breaking out of
260 them. However, an ordinary label whose scope is the whole function
261 cannot be used: if the macro can be expanded several times in one
262 function, the label is multiply defined in that function. A
263 local label avoids this problem. For example:
266 #define SEARCH(value, array, target) \
269 typeof (target) _SEARCH_target = (target); \
270 typeof (*(array)) *_SEARCH_array = (array); \
273 for (i = 0; i < max; i++) \
274 for (j = 0; j < max; j++) \
275 if (_SEARCH_array[i][j] == _SEARCH_target) \
276 @{ (value) = i; goto found; @} \
282 This could also be written using a statement expression:
285 #define SEARCH(array, target) \
288 typeof (target) _SEARCH_target = (target); \
289 typeof (*(array)) *_SEARCH_array = (array); \
292 for (i = 0; i < max; i++) \
293 for (j = 0; j < max; j++) \
294 if (_SEARCH_array[i][j] == _SEARCH_target) \
295 @{ value = i; goto found; @} \
302 Local label declarations also make the labels they declare visible to
303 nested functions, if there are any. @xref{Nested Functions}, for details.
305 @node Labels as Values
306 @section Labels as Values
307 @cindex labels as values
308 @cindex computed gotos
309 @cindex goto with computed label
310 @cindex address of a label
312 You can get the address of a label defined in the current function
313 (or a containing function) with the unary operator @samp{&&}. The
314 value has type @code{void *}. This value is a constant and can be used
315 wherever a constant of that type is valid. For example:
323 To use these values, you need to be able to jump to one. This is done
324 with the computed goto statement@footnote{The analogous feature in
325 Fortran is called an assigned goto, but that name seems inappropriate in
326 C, where one can do more than simply store label addresses in label
327 variables.}, @code{goto *@var{exp};}. For example,
334 Any expression of type @code{void *} is allowed.
336 One way of using these constants is in initializing a static array that
337 serves as a jump table:
340 static void *array[] = @{ &&foo, &&bar, &&hack @};
344 Then you can select a label with indexing, like this:
351 Note that this does not check whether the subscript is in bounds---array
352 indexing in C never does that.
354 Such an array of label values serves a purpose much like that of the
355 @code{switch} statement. The @code{switch} statement is cleaner, so
356 use that rather than an array unless the problem does not fit a
357 @code{switch} statement very well.
359 Another use of label values is in an interpreter for threaded code.
360 The labels within the interpreter function can be stored in the
361 threaded code for super-fast dispatching.
363 You may not use this mechanism to jump to code in a different function.
364 If you do that, totally unpredictable things happen. The best way to
365 avoid this is to store the label address only in automatic variables and
366 never pass it as an argument.
368 An alternate way to write the above example is
371 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
373 goto *(&&foo + array[i]);
377 This is more friendly to code living in shared libraries, as it reduces
378 the number of dynamic relocations that are needed, and by consequence,
379 allows the data to be read-only.
380 This alternative with label differences is not supported for the AVR target,
381 please use the first approach for AVR programs.
383 The @code{&&foo} expressions for the same label might have different
384 values if the containing function is inlined or cloned. If a program
385 relies on them being always the same,
386 @code{__attribute__((__noinline__,__noclone__))} should be used to
387 prevent inlining and cloning. If @code{&&foo} is used in a static
388 variable initializer, inlining and cloning is forbidden.
390 @node Nested Functions
391 @section Nested Functions
392 @cindex nested functions
393 @cindex downward funargs
396 A @dfn{nested function} is a function defined inside another function.
397 Nested functions are supported as an extension in GNU C, but are not
398 supported by GNU C++.
400 The nested function's name is local to the block where it is defined.
401 For example, here we define a nested function named @code{square}, and
406 foo (double a, double b)
408 double square (double z) @{ return z * z; @}
410 return square (a) + square (b);
415 The nested function can access all the variables of the containing
416 function that are visible at the point of its definition. This is
417 called @dfn{lexical scoping}. For example, here we show a nested
418 function which uses an inherited variable named @code{offset}:
422 bar (int *array, int offset, int size)
424 int access (int *array, int index)
425 @{ return array[index + offset]; @}
428 for (i = 0; i < size; i++)
429 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
434 Nested function definitions are permitted within functions in the places
435 where variable definitions are allowed; that is, in any block, mixed
436 with the other declarations and statements in the block.
438 It is possible to call the nested function from outside the scope of its
439 name by storing its address or passing the address to another function:
442 hack (int *array, int size)
444 void store (int index, int value)
445 @{ array[index] = value; @}
447 intermediate (store, size);
451 Here, the function @code{intermediate} receives the address of
452 @code{store} as an argument. If @code{intermediate} calls @code{store},
453 the arguments given to @code{store} are used to store into @code{array}.
454 But this technique works only so long as the containing function
455 (@code{hack}, in this example) does not exit.
457 If you try to call the nested function through its address after the
458 containing function exits, all hell breaks loose. If you try
459 to call it after a containing scope level exits, and if it refers
460 to some of the variables that are no longer in scope, you may be lucky,
461 but it's not wise to take the risk. If, however, the nested function
462 does not refer to anything that has gone out of scope, you should be
465 GCC implements taking the address of a nested function using a technique
466 called @dfn{trampolines}. This technique was described in
467 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
468 C++ Conference Proceedings, October 17-21, 1988).
470 A nested function can jump to a label inherited from a containing
471 function, provided the label is explicitly declared in the containing
472 function (@pxref{Local Labels}). Such a jump returns instantly to the
473 containing function, exiting the nested function that did the
474 @code{goto} and any intermediate functions as well. Here is an example:
478 bar (int *array, int offset, int size)
481 int access (int *array, int index)
485 return array[index + offset];
489 for (i = 0; i < size; i++)
490 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
494 /* @r{Control comes here from @code{access}
495 if it detects an error.} */
502 A nested function always has no linkage. Declaring one with
503 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
504 before its definition, use @code{auto} (which is otherwise meaningless
505 for function declarations).
508 bar (int *array, int offset, int size)
511 auto int access (int *, int);
513 int access (int *array, int index)
517 return array[index + offset];
523 @node Constructing Calls
524 @section Constructing Function Calls
525 @cindex constructing calls
526 @cindex forwarding calls
528 Using the built-in functions described below, you can record
529 the arguments a function received, and call another function
530 with the same arguments, without knowing the number or types
533 You can also record the return value of that function call,
534 and later return that value, without knowing what data type
535 the function tried to return (as long as your caller expects
538 However, these built-in functions may interact badly with some
539 sophisticated features or other extensions of the language. It
540 is, therefore, not recommended to use them outside very simple
541 functions acting as mere forwarders for their arguments.
543 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
544 This built-in function returns a pointer to data
545 describing how to perform a call with the same arguments as are passed
546 to the current function.
548 The function saves the arg pointer register, structure value address,
549 and all registers that might be used to pass arguments to a function
550 into a block of memory allocated on the stack. Then it returns the
551 address of that block.
554 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
555 This built-in function invokes @var{function}
556 with a copy of the parameters described by @var{arguments}
559 The value of @var{arguments} should be the value returned by
560 @code{__builtin_apply_args}. The argument @var{size} specifies the size
561 of the stack argument data, in bytes.
563 This function returns a pointer to data describing
564 how to return whatever value is returned by @var{function}. The data
565 is saved in a block of memory allocated on the stack.
567 It is not always simple to compute the proper value for @var{size}. The
568 value is used by @code{__builtin_apply} to compute the amount of data
569 that should be pushed on the stack and copied from the incoming argument
573 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
574 This built-in function returns the value described by @var{result} from
575 the containing function. You should specify, for @var{result}, a value
576 returned by @code{__builtin_apply}.
579 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
580 This built-in function represents all anonymous arguments of an inline
581 function. It can be used only in inline functions that are always
582 inlined, never compiled as a separate function, such as those using
583 @code{__attribute__ ((__always_inline__))} or
584 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
585 It must be only passed as last argument to some other function
586 with variable arguments. This is useful for writing small wrapper
587 inlines for variable argument functions, when using preprocessor
588 macros is undesirable. For example:
590 extern int myprintf (FILE *f, const char *format, ...);
591 extern inline __attribute__ ((__gnu_inline__)) int
592 myprintf (FILE *f, const char *format, ...)
594 int r = fprintf (f, "myprintf: ");
597 int s = fprintf (f, format, __builtin_va_arg_pack ());
605 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
606 This built-in function returns the number of anonymous arguments of
607 an inline function. It can be used only in inline functions that
608 are always inlined, never compiled as a separate function, such
609 as those using @code{__attribute__ ((__always_inline__))} or
610 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
611 For example following does link- or run-time checking of open
612 arguments for optimized code:
615 extern inline __attribute__((__gnu_inline__)) int
616 myopen (const char *path, int oflag, ...)
618 if (__builtin_va_arg_pack_len () > 1)
619 warn_open_too_many_arguments ();
621 if (__builtin_constant_p (oflag))
623 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
625 warn_open_missing_mode ();
626 return __open_2 (path, oflag);
628 return open (path, oflag, __builtin_va_arg_pack ());
631 if (__builtin_va_arg_pack_len () < 1)
632 return __open_2 (path, oflag);
634 return open (path, oflag, __builtin_va_arg_pack ());
641 @section Referring to a Type with @code{typeof}
644 @cindex macros, types of arguments
646 Another way to refer to the type of an expression is with @code{typeof}.
647 The syntax of using of this keyword looks like @code{sizeof}, but the
648 construct acts semantically like a type name defined with @code{typedef}.
650 There are two ways of writing the argument to @code{typeof}: with an
651 expression or with a type. Here is an example with an expression:
658 This assumes that @code{x} is an array of pointers to functions;
659 the type described is that of the values of the functions.
661 Here is an example with a typename as the argument:
668 Here the type described is that of pointers to @code{int}.
670 If you are writing a header file that must work when included in ISO C
671 programs, write @code{__typeof__} instead of @code{typeof}.
672 @xref{Alternate Keywords}.
674 A @code{typeof} construct can be used anywhere a typedef name can be
675 used. For example, you can use it in a declaration, in a cast, or inside
676 of @code{sizeof} or @code{typeof}.
678 The operand of @code{typeof} is evaluated for its side effects if and
679 only if it is an expression of variably modified type or the name of
682 @code{typeof} is often useful in conjunction with
683 statement expressions (@pxref{Statement Exprs}).
684 Here is how the two together can
685 be used to define a safe ``maximum'' macro which operates on any
686 arithmetic type and evaluates each of its arguments exactly once:
690 (@{ typeof (a) _a = (a); \
691 typeof (b) _b = (b); \
692 _a > _b ? _a : _b; @})
695 @cindex underscores in variables in macros
696 @cindex @samp{_} in variables in macros
697 @cindex local variables in macros
698 @cindex variables, local, in macros
699 @cindex macros, local variables in
701 The reason for using names that start with underscores for the local
702 variables is to avoid conflicts with variable names that occur within the
703 expressions that are substituted for @code{a} and @code{b}. Eventually we
704 hope to design a new form of declaration syntax that allows you to declare
705 variables whose scopes start only after their initializers; this will be a
706 more reliable way to prevent such conflicts.
709 Some more examples of the use of @code{typeof}:
713 This declares @code{y} with the type of what @code{x} points to.
720 This declares @code{y} as an array of such values.
727 This declares @code{y} as an array of pointers to characters:
730 typeof (typeof (char *)[4]) y;
734 It is equivalent to the following traditional C declaration:
740 To see the meaning of the declaration using @code{typeof}, and why it
741 might be a useful way to write, rewrite it with these macros:
744 #define pointer(T) typeof(T *)
745 #define array(T, N) typeof(T [N])
749 Now the declaration can be rewritten this way:
752 array (pointer (char), 4) y;
756 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
757 pointers to @code{char}.
760 In GNU C, but not GNU C++, you may also declare the type of a variable
761 as @code{__auto_type}. In that case, the declaration must declare
762 only one variable, whose declarator must just be an identifier, the
763 declaration must be initialized, and the type of the variable is
764 determined by the initializer; the name of the variable is not in
765 scope until after the initializer. (In C++, you should use C++11
766 @code{auto} for this purpose.) Using @code{__auto_type}, the
767 ``maximum'' macro above could be written as:
771 (@{ __auto_type _a = (a); \
772 __auto_type _b = (b); \
773 _a > _b ? _a : _b; @})
776 Using @code{__auto_type} instead of @code{typeof} has two advantages:
779 @item Each argument to the macro appears only once in the expansion of
780 the macro. This prevents the size of the macro expansion growing
781 exponentially when calls to such macros are nested inside arguments of
784 @item If the argument to the macro has variably modified type, it is
785 evaluated only once when using @code{__auto_type}, but twice if
786 @code{typeof} is used.
789 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
790 a more limited extension that permitted one to write
793 typedef @var{T} = @var{expr};
797 with the effect of declaring @var{T} to have the type of the expression
798 @var{expr}. This extension does not work with GCC 3 (versions between
799 3.0 and 3.2 crash; 3.2.1 and later give an error). Code that
800 relies on it should be rewritten to use @code{typeof}:
803 typedef typeof(@var{expr}) @var{T};
807 This works with all versions of GCC@.
810 @section Conditionals with Omitted Operands
811 @cindex conditional expressions, extensions
812 @cindex omitted middle-operands
813 @cindex middle-operands, omitted
814 @cindex extensions, @code{?:}
815 @cindex @code{?:} extensions
817 The middle operand in a conditional expression may be omitted. Then
818 if the first operand is nonzero, its value is the value of the conditional
821 Therefore, the expression
828 has the value of @code{x} if that is nonzero; otherwise, the value of
831 This example is perfectly equivalent to
837 @cindex side effect in @code{?:}
838 @cindex @code{?:} side effect
840 In this simple case, the ability to omit the middle operand is not
841 especially useful. When it becomes useful is when the first operand does,
842 or may (if it is a macro argument), contain a side effect. Then repeating
843 the operand in the middle would perform the side effect twice. Omitting
844 the middle operand uses the value already computed without the undesirable
845 effects of recomputing it.
848 @section 128-bit integers
849 @cindex @code{__int128} data types
851 As an extension the integer scalar type @code{__int128} is supported for
852 targets which have an integer mode wide enough to hold 128 bits.
853 Simply write @code{__int128} for a signed 128-bit integer, or
854 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
855 support in GCC for expressing an integer constant of type @code{__int128}
856 for targets with @code{long long} integer less than 128 bits wide.
859 @section Double-Word Integers
860 @cindex @code{long long} data types
861 @cindex double-word arithmetic
862 @cindex multiprecision arithmetic
863 @cindex @code{LL} integer suffix
864 @cindex @code{ULL} integer suffix
866 ISO C99 supports data types for integers that are at least 64 bits wide,
867 and as an extension GCC supports them in C90 mode and in C++.
868 Simply write @code{long long int} for a signed integer, or
869 @code{unsigned long long int} for an unsigned integer. To make an
870 integer constant of type @code{long long int}, add the suffix @samp{LL}
871 to the integer. To make an integer constant of type @code{unsigned long
872 long int}, add the suffix @samp{ULL} to the integer.
874 You can use these types in arithmetic like any other integer types.
875 Addition, subtraction, and bitwise boolean operations on these types
876 are open-coded on all types of machines. Multiplication is open-coded
877 if the machine supports a fullword-to-doubleword widening multiply
878 instruction. Division and shifts are open-coded only on machines that
879 provide special support. The operations that are not open-coded use
880 special library routines that come with GCC@.
882 There may be pitfalls when you use @code{long long} types for function
883 arguments without function prototypes. If a function
884 expects type @code{int} for its argument, and you pass a value of type
885 @code{long long int}, confusion results because the caller and the
886 subroutine disagree about the number of bytes for the argument.
887 Likewise, if the function expects @code{long long int} and you pass
888 @code{int}. The best way to avoid such problems is to use prototypes.
891 @section Complex Numbers
892 @cindex complex numbers
893 @cindex @code{_Complex} keyword
894 @cindex @code{__complex__} keyword
896 ISO C99 supports complex floating data types, and as an extension GCC
897 supports them in C90 mode and in C++. GCC also supports complex integer data
898 types which are not part of ISO C99. You can declare complex types
899 using the keyword @code{_Complex}. As an extension, the older GNU
900 keyword @code{__complex__} is also supported.
902 For example, @samp{_Complex double x;} declares @code{x} as a
903 variable whose real part and imaginary part are both of type
904 @code{double}. @samp{_Complex short int y;} declares @code{y} to
905 have real and imaginary parts of type @code{short int}; this is not
906 likely to be useful, but it shows that the set of complex types is
909 To write a constant with a complex data type, use the suffix @samp{i} or
910 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
911 has type @code{_Complex float} and @code{3i} has type
912 @code{_Complex int}. Such a constant always has a pure imaginary
913 value, but you can form any complex value you like by adding one to a
914 real constant. This is a GNU extension; if you have an ISO C99
915 conforming C library (such as the GNU C Library), and want to construct complex
916 constants of floating type, you should include @code{<complex.h>} and
917 use the macros @code{I} or @code{_Complex_I} instead.
919 @cindex @code{__real__} keyword
920 @cindex @code{__imag__} keyword
921 To extract the real part of a complex-valued expression @var{exp}, write
922 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
923 extract the imaginary part. This is a GNU extension; for values of
924 floating type, you should use the ISO C99 functions @code{crealf},
925 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
926 @code{cimagl}, declared in @code{<complex.h>} and also provided as
927 built-in functions by GCC@.
929 @cindex complex conjugation
930 The operator @samp{~} performs complex conjugation when used on a value
931 with a complex type. This is a GNU extension; for values of
932 floating type, you should use the ISO C99 functions @code{conjf},
933 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
934 provided as built-in functions by GCC@.
936 GCC can allocate complex automatic variables in a noncontiguous
937 fashion; it's even possible for the real part to be in a register while
938 the imaginary part is on the stack (or vice versa). Only the DWARF 2
939 debug info format can represent this, so use of DWARF 2 is recommended.
940 If you are using the stabs debug info format, GCC describes a noncontiguous
941 complex variable as if it were two separate variables of noncomplex type.
942 If the variable's actual name is @code{foo}, the two fictitious
943 variables are named @code{foo$real} and @code{foo$imag}. You can
944 examine and set these two fictitious variables with your debugger.
947 @section Additional Floating Types
948 @cindex additional floating types
949 @cindex @code{__float80} data type
950 @cindex @code{__float128} data type
951 @cindex @code{w} floating point suffix
952 @cindex @code{q} floating point suffix
953 @cindex @code{W} floating point suffix
954 @cindex @code{Q} floating point suffix
956 As an extension, GNU C supports additional floating
957 types, @code{__float80} and @code{__float128} to support 80-bit
958 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
959 Support for additional types includes the arithmetic operators:
960 add, subtract, multiply, divide; unary arithmetic operators;
961 relational operators; equality operators; and conversions to and from
962 integer and other floating types. Use a suffix @samp{w} or @samp{W}
963 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
964 for @code{_float128}. You can declare complex types using the
965 corresponding internal complex type, @code{XCmode} for @code{__float80}
966 type and @code{TCmode} for @code{__float128} type:
969 typedef _Complex float __attribute__((mode(TC))) _Complex128;
970 typedef _Complex float __attribute__((mode(XC))) _Complex80;
973 Not all targets support additional floating-point types. @code{__float80}
974 and @code{__float128} types are supported on x86 and IA-64 targets.
975 The @code{__float128} type is supported on hppa HP-UX targets.
978 @section Half-Precision Floating Point
979 @cindex half-precision floating point
980 @cindex @code{__fp16} data type
982 On ARM targets, GCC supports half-precision (16-bit) floating point via
983 the @code{__fp16} type. You must enable this type explicitly
984 with the @option{-mfp16-format} command-line option in order to use it.
986 ARM supports two incompatible representations for half-precision
987 floating-point values. You must choose one of the representations and
988 use it consistently in your program.
990 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
991 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
992 There are 11 bits of significand precision, approximately 3
995 Specifying @option{-mfp16-format=alternative} selects the ARM
996 alternative format. This representation is similar to the IEEE
997 format, but does not support infinities or NaNs. Instead, the range
998 of exponents is extended, so that this format can represent normalized
999 values in the range of @math{2^{-14}} to 131008.
1001 The @code{__fp16} type is a storage format only. For purposes
1002 of arithmetic and other operations, @code{__fp16} values in C or C++
1003 expressions are automatically promoted to @code{float}. In addition,
1004 you cannot declare a function with a return value or parameters
1005 of type @code{__fp16}.
1007 Note that conversions from @code{double} to @code{__fp16}
1008 involve an intermediate conversion to @code{float}. Because
1009 of rounding, this can sometimes produce a different result than a
1012 ARM provides hardware support for conversions between
1013 @code{__fp16} and @code{float} values
1014 as an extension to VFP and NEON (Advanced SIMD). GCC generates
1015 code using these hardware instructions if you compile with
1016 options to select an FPU that provides them;
1017 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1018 in addition to the @option{-mfp16-format} option to select
1019 a half-precision format.
1021 Language-level support for the @code{__fp16} data type is
1022 independent of whether GCC generates code using hardware floating-point
1023 instructions. In cases where hardware support is not specified, GCC
1024 implements conversions between @code{__fp16} and @code{float} values
1028 @section Decimal Floating Types
1029 @cindex decimal floating types
1030 @cindex @code{_Decimal32} data type
1031 @cindex @code{_Decimal64} data type
1032 @cindex @code{_Decimal128} data type
1033 @cindex @code{df} integer suffix
1034 @cindex @code{dd} integer suffix
1035 @cindex @code{dl} integer suffix
1036 @cindex @code{DF} integer suffix
1037 @cindex @code{DD} integer suffix
1038 @cindex @code{DL} integer suffix
1040 As an extension, GNU C supports decimal floating types as
1041 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1042 floating types in GCC will evolve as the draft technical report changes.
1043 Calling conventions for any target might also change. Not all targets
1044 support decimal floating types.
1046 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1047 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1048 @code{float}, @code{double}, and @code{long double} whose radix is not
1049 specified by the C standard but is usually two.
1051 Support for decimal floating types includes the arithmetic operators
1052 add, subtract, multiply, divide; unary arithmetic operators;
1053 relational operators; equality operators; and conversions to and from
1054 integer and other floating types. Use a suffix @samp{df} or
1055 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1056 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1059 GCC support of decimal float as specified by the draft technical report
1064 When the value of a decimal floating type cannot be represented in the
1065 integer type to which it is being converted, the result is undefined
1066 rather than the result value specified by the draft technical report.
1069 GCC does not provide the C library functionality associated with
1070 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1071 @file{wchar.h}, which must come from a separate C library implementation.
1072 Because of this the GNU C compiler does not define macro
1073 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1074 the technical report.
1077 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1078 are supported by the DWARF 2 debug information format.
1084 ISO C99 supports floating-point numbers written not only in the usual
1085 decimal notation, such as @code{1.55e1}, but also numbers such as
1086 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1087 supports this in C90 mode (except in some cases when strictly
1088 conforming) and in C++. In that format the
1089 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1090 mandatory. The exponent is a decimal number that indicates the power of
1091 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1098 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1099 is the same as @code{1.55e1}.
1101 Unlike for floating-point numbers in the decimal notation the exponent
1102 is always required in the hexadecimal notation. Otherwise the compiler
1103 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1104 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1105 extension for floating-point constants of type @code{float}.
1108 @section Fixed-Point Types
1109 @cindex fixed-point types
1110 @cindex @code{_Fract} data type
1111 @cindex @code{_Accum} data type
1112 @cindex @code{_Sat} data type
1113 @cindex @code{hr} fixed-suffix
1114 @cindex @code{r} fixed-suffix
1115 @cindex @code{lr} fixed-suffix
1116 @cindex @code{llr} fixed-suffix
1117 @cindex @code{uhr} fixed-suffix
1118 @cindex @code{ur} fixed-suffix
1119 @cindex @code{ulr} fixed-suffix
1120 @cindex @code{ullr} fixed-suffix
1121 @cindex @code{hk} fixed-suffix
1122 @cindex @code{k} fixed-suffix
1123 @cindex @code{lk} fixed-suffix
1124 @cindex @code{llk} fixed-suffix
1125 @cindex @code{uhk} fixed-suffix
1126 @cindex @code{uk} fixed-suffix
1127 @cindex @code{ulk} fixed-suffix
1128 @cindex @code{ullk} fixed-suffix
1129 @cindex @code{HR} fixed-suffix
1130 @cindex @code{R} fixed-suffix
1131 @cindex @code{LR} fixed-suffix
1132 @cindex @code{LLR} fixed-suffix
1133 @cindex @code{UHR} fixed-suffix
1134 @cindex @code{UR} fixed-suffix
1135 @cindex @code{ULR} fixed-suffix
1136 @cindex @code{ULLR} fixed-suffix
1137 @cindex @code{HK} fixed-suffix
1138 @cindex @code{K} fixed-suffix
1139 @cindex @code{LK} fixed-suffix
1140 @cindex @code{LLK} fixed-suffix
1141 @cindex @code{UHK} fixed-suffix
1142 @cindex @code{UK} fixed-suffix
1143 @cindex @code{ULK} fixed-suffix
1144 @cindex @code{ULLK} fixed-suffix
1146 As an extension, GNU C supports fixed-point types as
1147 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1148 types in GCC will evolve as the draft technical report changes.
1149 Calling conventions for any target might also change. Not all targets
1150 support fixed-point types.
1152 The fixed-point types are
1153 @code{short _Fract},
1156 @code{long long _Fract},
1157 @code{unsigned short _Fract},
1158 @code{unsigned _Fract},
1159 @code{unsigned long _Fract},
1160 @code{unsigned long long _Fract},
1161 @code{_Sat short _Fract},
1163 @code{_Sat long _Fract},
1164 @code{_Sat long long _Fract},
1165 @code{_Sat unsigned short _Fract},
1166 @code{_Sat unsigned _Fract},
1167 @code{_Sat unsigned long _Fract},
1168 @code{_Sat unsigned long long _Fract},
1169 @code{short _Accum},
1172 @code{long long _Accum},
1173 @code{unsigned short _Accum},
1174 @code{unsigned _Accum},
1175 @code{unsigned long _Accum},
1176 @code{unsigned long long _Accum},
1177 @code{_Sat short _Accum},
1179 @code{_Sat long _Accum},
1180 @code{_Sat long long _Accum},
1181 @code{_Sat unsigned short _Accum},
1182 @code{_Sat unsigned _Accum},
1183 @code{_Sat unsigned long _Accum},
1184 @code{_Sat unsigned long long _Accum}.
1186 Fixed-point data values contain fractional and optional integral parts.
1187 The format of fixed-point data varies and depends on the target machine.
1189 Support for fixed-point types includes:
1192 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1194 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1196 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1198 binary shift operators (@code{<<}, @code{>>})
1200 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1202 equality operators (@code{==}, @code{!=})
1204 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1205 @code{<<=}, @code{>>=})
1207 conversions to and from integer, floating-point, or fixed-point types
1210 Use a suffix in a fixed-point literal constant:
1212 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1213 @code{_Sat short _Fract}
1214 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1215 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1216 @code{_Sat long _Fract}
1217 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1218 @code{_Sat long long _Fract}
1219 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1220 @code{_Sat unsigned short _Fract}
1221 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1222 @code{_Sat unsigned _Fract}
1223 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1224 @code{_Sat unsigned long _Fract}
1225 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1226 and @code{_Sat unsigned long long _Fract}
1227 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1228 @code{_Sat short _Accum}
1229 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1230 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1231 @code{_Sat long _Accum}
1232 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1233 @code{_Sat long long _Accum}
1234 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1235 @code{_Sat unsigned short _Accum}
1236 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1237 @code{_Sat unsigned _Accum}
1238 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1239 @code{_Sat unsigned long _Accum}
1240 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1241 and @code{_Sat unsigned long long _Accum}
1244 GCC support of fixed-point types as specified by the draft technical report
1249 Pragmas to control overflow and rounding behaviors are not implemented.
1252 Fixed-point types are supported by the DWARF 2 debug information format.
1254 @node Named Address Spaces
1255 @section Named Address Spaces
1256 @cindex Named Address Spaces
1258 As an extension, GNU C supports named address spaces as
1259 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1260 address spaces in GCC will evolve as the draft technical report
1261 changes. Calling conventions for any target might also change. At
1262 present, only the AVR, SPU, M32C, and RL78 targets support address
1263 spaces other than the generic address space.
1265 Address space identifiers may be used exactly like any other C type
1266 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1267 document for more details.
1269 @anchor{AVR Named Address Spaces}
1270 @subsection AVR Named Address Spaces
1272 On the AVR target, there are several address spaces that can be used
1273 in order to put read-only data into the flash memory and access that
1274 data by means of the special instructions @code{LPM} or @code{ELPM}
1275 needed to read from flash.
1277 Per default, any data including read-only data is located in RAM
1278 (the generic address space) so that non-generic address spaces are
1279 needed to locate read-only data in flash memory
1280 @emph{and} to generate the right instructions to access this data
1281 without using (inline) assembler code.
1285 @cindex @code{__flash} AVR Named Address Spaces
1286 The @code{__flash} qualifier locates data in the
1287 @code{.progmem.data} section. Data is read using the @code{LPM}
1288 instruction. Pointers to this address space are 16 bits wide.
1295 @cindex @code{__flash1} AVR Named Address Spaces
1296 @cindex @code{__flash2} AVR Named Address Spaces
1297 @cindex @code{__flash3} AVR Named Address Spaces
1298 @cindex @code{__flash4} AVR Named Address Spaces
1299 @cindex @code{__flash5} AVR Named Address Spaces
1300 These are 16-bit address spaces locating data in section
1301 @code{.progmem@var{N}.data} where @var{N} refers to
1302 address space @code{__flash@var{N}}.
1303 The compiler sets the @code{RAMPZ} segment register appropriately
1304 before reading data by means of the @code{ELPM} instruction.
1307 @cindex @code{__memx} AVR Named Address Spaces
1308 This is a 24-bit address space that linearizes flash and RAM:
1309 If the high bit of the address is set, data is read from
1310 RAM using the lower two bytes as RAM address.
1311 If the high bit of the address is clear, data is read from flash
1312 with @code{RAMPZ} set according to the high byte of the address.
1313 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1315 Objects in this address space are located in @code{.progmemx.data}.
1321 char my_read (const __flash char ** p)
1323 /* p is a pointer to RAM that points to a pointer to flash.
1324 The first indirection of p reads that flash pointer
1325 from RAM and the second indirection reads a char from this
1331 /* Locate array[] in flash memory */
1332 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1338 /* Return 17 by reading from flash memory */
1339 return array[array[i]];
1344 For each named address space supported by avr-gcc there is an equally
1345 named but uppercase built-in macro defined.
1346 The purpose is to facilitate testing if respective address space
1347 support is available or not:
1351 const __flash int var = 1;
1358 #include <avr/pgmspace.h> /* From AVR-LibC */
1360 const int var PROGMEM = 1;
1364 return (int) pgm_read_word (&var);
1366 #endif /* __FLASH */
1370 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1371 locates data in flash but
1372 accesses to these data read from generic address space, i.e.@:
1374 so that you need special accessors like @code{pgm_read_byte}
1375 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1376 together with attribute @code{progmem}.
1379 @b{Limitations and caveats}
1383 Reading across the 64@tie{}KiB section boundary of
1384 the @code{__flash} or @code{__flash@var{N}} address spaces
1385 shows undefined behavior. The only address space that
1386 supports reading across the 64@tie{}KiB flash segment boundaries is
1390 If you use one of the @code{__flash@var{N}} address spaces
1391 you must arrange your linker script to locate the
1392 @code{.progmem@var{N}.data} sections according to your needs.
1395 Any data or pointers to the non-generic address spaces must
1396 be qualified as @code{const}, i.e.@: as read-only data.
1397 This still applies if the data in one of these address
1398 spaces like software version number or calibration lookup table are intended to
1399 be changed after load time by, say, a boot loader. In this case
1400 the right qualification is @code{const} @code{volatile} so that the compiler
1401 must not optimize away known values or insert them
1402 as immediates into operands of instructions.
1405 The following code initializes a variable @code{pfoo}
1406 located in static storage with a 24-bit address:
1408 extern const __memx char foo;
1409 const __memx void *pfoo = &foo;
1413 Such code requires at least binutils 2.23, see
1414 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1418 @subsection M32C Named Address Spaces
1419 @cindex @code{__far} M32C Named Address Spaces
1421 On the M32C target, with the R8C and M16C CPU variants, variables
1422 qualified with @code{__far} are accessed using 32-bit addresses in
1423 order to access memory beyond the first 64@tie{}Ki bytes. If
1424 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1427 @subsection RL78 Named Address Spaces
1428 @cindex @code{__far} RL78 Named Address Spaces
1430 On the RL78 target, variables qualified with @code{__far} are accessed
1431 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1432 addresses. Non-far variables are assumed to appear in the topmost
1433 64@tie{}KiB of the address space.
1435 @subsection SPU Named Address Spaces
1436 @cindex @code{__ea} SPU Named Address Spaces
1438 On the SPU target variables may be declared as
1439 belonging to another address space by qualifying the type with the
1440 @code{__ea} address space identifier:
1447 The compiler generates special code to access the variable @code{i}.
1448 It may use runtime library
1449 support, or generate special machine instructions to access that address
1453 @section Arrays of Length Zero
1454 @cindex arrays of length zero
1455 @cindex zero-length arrays
1456 @cindex length-zero arrays
1457 @cindex flexible array members
1459 Zero-length arrays are allowed in GNU C@. They are very useful as the
1460 last element of a structure that is really a header for a variable-length
1469 struct line *thisline = (struct line *)
1470 malloc (sizeof (struct line) + this_length);
1471 thisline->length = this_length;
1474 In ISO C90, you would have to give @code{contents} a length of 1, which
1475 means either you waste space or complicate the argument to @code{malloc}.
1477 In ISO C99, you would use a @dfn{flexible array member}, which is
1478 slightly different in syntax and semantics:
1482 Flexible array members are written as @code{contents[]} without
1486 Flexible array members have incomplete type, and so the @code{sizeof}
1487 operator may not be applied. As a quirk of the original implementation
1488 of zero-length arrays, @code{sizeof} evaluates to zero.
1491 Flexible array members may only appear as the last member of a
1492 @code{struct} that is otherwise non-empty.
1495 A structure containing a flexible array member, or a union containing
1496 such a structure (possibly recursively), may not be a member of a
1497 structure or an element of an array. (However, these uses are
1498 permitted by GCC as extensions.)
1501 GCC versions before 3.0 allowed zero-length arrays to be statically
1502 initialized, as if they were flexible arrays. In addition to those
1503 cases that were useful, it also allowed initializations in situations
1504 that would corrupt later data. Non-empty initialization of zero-length
1505 arrays is now treated like any case where there are more initializer
1506 elements than the array holds, in that a suitable warning about ``excess
1507 elements in array'' is given, and the excess elements (all of them, in
1508 this case) are ignored.
1510 Instead GCC allows static initialization of flexible array members.
1511 This is equivalent to defining a new structure containing the original
1512 structure followed by an array of sufficient size to contain the data.
1513 E.g.@: in the following, @code{f1} is constructed as if it were declared
1519 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1522 struct f1 f1; int data[3];
1523 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1527 The convenience of this extension is that @code{f1} has the desired
1528 type, eliminating the need to consistently refer to @code{f2.f1}.
1530 This has symmetry with normal static arrays, in that an array of
1531 unknown size is also written with @code{[]}.
1533 Of course, this extension only makes sense if the extra data comes at
1534 the end of a top-level object, as otherwise we would be overwriting
1535 data at subsequent offsets. To avoid undue complication and confusion
1536 with initialization of deeply nested arrays, we simply disallow any
1537 non-empty initialization except when the structure is the top-level
1538 object. For example:
1541 struct foo @{ int x; int y[]; @};
1542 struct bar @{ struct foo z; @};
1544 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1545 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1546 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1547 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1550 @node Empty Structures
1551 @section Structures With No Members
1552 @cindex empty structures
1553 @cindex zero-size structures
1555 GCC permits a C structure to have no members:
1562 The structure has size zero. In C++, empty structures are part
1563 of the language. G++ treats empty structures as if they had a single
1564 member of type @code{char}.
1566 @node Variable Length
1567 @section Arrays of Variable Length
1568 @cindex variable-length arrays
1569 @cindex arrays of variable length
1572 Variable-length automatic arrays are allowed in ISO C99, and as an
1573 extension GCC accepts them in C90 mode and in C++. These arrays are
1574 declared like any other automatic arrays, but with a length that is not
1575 a constant expression. The storage is allocated at the point of
1576 declaration and deallocated when the block scope containing the declaration
1582 concat_fopen (char *s1, char *s2, char *mode)
1584 char str[strlen (s1) + strlen (s2) + 1];
1587 return fopen (str, mode);
1591 @cindex scope of a variable length array
1592 @cindex variable-length array scope
1593 @cindex deallocating variable length arrays
1594 Jumping or breaking out of the scope of the array name deallocates the
1595 storage. Jumping into the scope is not allowed; you get an error
1598 @cindex variable-length array in a structure
1599 As an extension, GCC accepts variable-length arrays as a member of
1600 a structure or a union. For example:
1606 struct S @{ int x[n]; @};
1610 @cindex @code{alloca} vs variable-length arrays
1611 You can use the function @code{alloca} to get an effect much like
1612 variable-length arrays. The function @code{alloca} is available in
1613 many other C implementations (but not in all). On the other hand,
1614 variable-length arrays are more elegant.
1616 There are other differences between these two methods. Space allocated
1617 with @code{alloca} exists until the containing @emph{function} returns.
1618 The space for a variable-length array is deallocated as soon as the array
1619 name's scope ends. (If you use both variable-length arrays and
1620 @code{alloca} in the same function, deallocation of a variable-length array
1621 also deallocates anything more recently allocated with @code{alloca}.)
1623 You can also use variable-length arrays as arguments to functions:
1627 tester (int len, char data[len][len])
1633 The length of an array is computed once when the storage is allocated
1634 and is remembered for the scope of the array in case you access it with
1637 If you want to pass the array first and the length afterward, you can
1638 use a forward declaration in the parameter list---another GNU extension.
1642 tester (int len; char data[len][len], int len)
1648 @cindex parameter forward declaration
1649 The @samp{int len} before the semicolon is a @dfn{parameter forward
1650 declaration}, and it serves the purpose of making the name @code{len}
1651 known when the declaration of @code{data} is parsed.
1653 You can write any number of such parameter forward declarations in the
1654 parameter list. They can be separated by commas or semicolons, but the
1655 last one must end with a semicolon, which is followed by the ``real''
1656 parameter declarations. Each forward declaration must match a ``real''
1657 declaration in parameter name and data type. ISO C99 does not support
1658 parameter forward declarations.
1660 @node Variadic Macros
1661 @section Macros with a Variable Number of Arguments.
1662 @cindex variable number of arguments
1663 @cindex macro with variable arguments
1664 @cindex rest argument (in macro)
1665 @cindex variadic macros
1667 In the ISO C standard of 1999, a macro can be declared to accept a
1668 variable number of arguments much as a function can. The syntax for
1669 defining the macro is similar to that of a function. Here is an
1673 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1677 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1678 such a macro, it represents the zero or more tokens until the closing
1679 parenthesis that ends the invocation, including any commas. This set of
1680 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1681 wherever it appears. See the CPP manual for more information.
1683 GCC has long supported variadic macros, and used a different syntax that
1684 allowed you to give a name to the variable arguments just like any other
1685 argument. Here is an example:
1688 #define debug(format, args...) fprintf (stderr, format, args)
1692 This is in all ways equivalent to the ISO C example above, but arguably
1693 more readable and descriptive.
1695 GNU CPP has two further variadic macro extensions, and permits them to
1696 be used with either of the above forms of macro definition.
1698 In standard C, you are not allowed to leave the variable argument out
1699 entirely; but you are allowed to pass an empty argument. For example,
1700 this invocation is invalid in ISO C, because there is no comma after
1707 GNU CPP permits you to completely omit the variable arguments in this
1708 way. In the above examples, the compiler would complain, though since
1709 the expansion of the macro still has the extra comma after the format
1712 To help solve this problem, CPP behaves specially for variable arguments
1713 used with the token paste operator, @samp{##}. If instead you write
1716 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1720 and if the variable arguments are omitted or empty, the @samp{##}
1721 operator causes the preprocessor to remove the comma before it. If you
1722 do provide some variable arguments in your macro invocation, GNU CPP
1723 does not complain about the paste operation and instead places the
1724 variable arguments after the comma. Just like any other pasted macro
1725 argument, these arguments are not macro expanded.
1727 @node Escaped Newlines
1728 @section Slightly Looser Rules for Escaped Newlines
1729 @cindex escaped newlines
1730 @cindex newlines (escaped)
1732 Recently, the preprocessor has relaxed its treatment of escaped
1733 newlines. Previously, the newline had to immediately follow a
1734 backslash. The current implementation allows whitespace in the form
1735 of spaces, horizontal and vertical tabs, and form feeds between the
1736 backslash and the subsequent newline. The preprocessor issues a
1737 warning, but treats it as a valid escaped newline and combines the two
1738 lines to form a single logical line. This works within comments and
1739 tokens, as well as between tokens. Comments are @emph{not} treated as
1740 whitespace for the purposes of this relaxation, since they have not
1741 yet been replaced with spaces.
1744 @section Non-Lvalue Arrays May Have Subscripts
1745 @cindex subscripting
1746 @cindex arrays, non-lvalue
1748 @cindex subscripting and function values
1749 In ISO C99, arrays that are not lvalues still decay to pointers, and
1750 may be subscripted, although they may not be modified or used after
1751 the next sequence point and the unary @samp{&} operator may not be
1752 applied to them. As an extension, GNU C allows such arrays to be
1753 subscripted in C90 mode, though otherwise they do not decay to
1754 pointers outside C99 mode. For example,
1755 this is valid in GNU C though not valid in C90:
1759 struct foo @{int a[4];@};
1765 return f().a[index];
1771 @section Arithmetic on @code{void}- and Function-Pointers
1772 @cindex void pointers, arithmetic
1773 @cindex void, size of pointer to
1774 @cindex function pointers, arithmetic
1775 @cindex function, size of pointer to
1777 In GNU C, addition and subtraction operations are supported on pointers to
1778 @code{void} and on pointers to functions. This is done by treating the
1779 size of a @code{void} or of a function as 1.
1781 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1782 and on function types, and returns 1.
1784 @opindex Wpointer-arith
1785 The option @option{-Wpointer-arith} requests a warning if these extensions
1788 @node Pointers to Arrays
1789 @section Pointers to arrays with qualifiers work as expected
1790 @cindex pointers to arrays
1791 @cindex const qualifier
1793 In GNU C, pointers to arrays with qualifiers work similar to pointers
1794 to other qualified types. For example, a value of type @code{int (*)[5]}
1795 can be used to initialize a variable of type @code{const int (*)[5]}.
1796 These types are incompatible in ISO C because the @code{const} qualifier
1797 is formally attached to the element type of the array and not the
1802 transpose (int N, int M, double out[M][N], const double in[N][M]);
1806 transpose(3, 2, y, x);
1810 @section Non-Constant Initializers
1811 @cindex initializers, non-constant
1812 @cindex non-constant initializers
1814 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1815 automatic variable are not required to be constant expressions in GNU C@.
1816 Here is an example of an initializer with run-time varying elements:
1819 foo (float f, float g)
1821 float beat_freqs[2] = @{ f-g, f+g @};
1826 @node Compound Literals
1827 @section Compound Literals
1828 @cindex constructor expressions
1829 @cindex initializations in expressions
1830 @cindex structures, constructor expression
1831 @cindex expressions, constructor
1832 @cindex compound literals
1833 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1835 ISO C99 supports compound literals. A compound literal looks like
1836 a cast containing an initializer. Its value is an object of the
1837 type specified in the cast, containing the elements specified in
1838 the initializer; it is an lvalue. As an extension, GCC supports
1839 compound literals in C90 mode and in C++, though the semantics are
1840 somewhat different in C++.
1842 Usually, the specified type is a structure. Assume that
1843 @code{struct foo} and @code{structure} are declared as shown:
1846 struct foo @{int a; char b[2];@} structure;
1850 Here is an example of constructing a @code{struct foo} with a compound literal:
1853 structure = ((struct foo) @{x + y, 'a', 0@});
1857 This is equivalent to writing the following:
1861 struct foo temp = @{x + y, 'a', 0@};
1866 You can also construct an array, though this is dangerous in C++, as
1867 explained below. If all the elements of the compound literal are
1868 (made up of) simple constant expressions, suitable for use in
1869 initializers of objects of static storage duration, then the compound
1870 literal can be coerced to a pointer to its first element and used in
1871 such an initializer, as shown here:
1874 char **foo = (char *[]) @{ "x", "y", "z" @};
1877 Compound literals for scalar types and union types are
1878 also allowed, but then the compound literal is equivalent
1881 As a GNU extension, GCC allows initialization of objects with static storage
1882 duration by compound literals (which is not possible in ISO C99, because
1883 the initializer is not a constant).
1884 It is handled as if the object is initialized only with the bracket
1885 enclosed list if the types of the compound literal and the object match.
1886 The initializer list of the compound literal must be constant.
1887 If the object being initialized has array type of unknown size, the size is
1888 determined by compound literal size.
1891 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1892 static int y[] = (int []) @{1, 2, 3@};
1893 static int z[] = (int [3]) @{1@};
1897 The above lines are equivalent to the following:
1899 static struct foo x = @{1, 'a', 'b'@};
1900 static int y[] = @{1, 2, 3@};
1901 static int z[] = @{1, 0, 0@};
1904 In C, a compound literal designates an unnamed object with static or
1905 automatic storage duration. In C++, a compound literal designates a
1906 temporary object, which only lives until the end of its
1907 full-expression. As a result, well-defined C code that takes the
1908 address of a subobject of a compound literal can be undefined in C++.
1909 For instance, if the array compound literal example above appeared
1910 inside a function, any subsequent use of @samp{foo} in C++ has
1911 undefined behavior because the lifetime of the array ends after the
1912 declaration of @samp{foo}. As a result, the C++ compiler now rejects
1913 the conversion of a temporary array to a pointer.
1915 As an optimization, the C++ compiler sometimes gives array compound
1916 literals longer lifetimes: when the array either appears outside a
1917 function or has const-qualified type. If @samp{foo} and its
1918 initializer had elements of @samp{char *const} type rather than
1919 @samp{char *}, or if @samp{foo} were a global variable, the array
1920 would have static storage duration. But it is probably safest just to
1921 avoid the use of array compound literals in code compiled as C++.
1923 @node Designated Inits
1924 @section Designated Initializers
1925 @cindex initializers with labeled elements
1926 @cindex labeled elements in initializers
1927 @cindex case labels in initializers
1928 @cindex designated initializers
1930 Standard C90 requires the elements of an initializer to appear in a fixed
1931 order, the same as the order of the elements in the array or structure
1934 In ISO C99 you can give the elements in any order, specifying the array
1935 indices or structure field names they apply to, and GNU C allows this as
1936 an extension in C90 mode as well. This extension is not
1937 implemented in GNU C++.
1939 To specify an array index, write
1940 @samp{[@var{index}] =} before the element value. For example,
1943 int a[6] = @{ [4] = 29, [2] = 15 @};
1950 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1954 The index values must be constant expressions, even if the array being
1955 initialized is automatic.
1957 An alternative syntax for this that has been obsolete since GCC 2.5 but
1958 GCC still accepts is to write @samp{[@var{index}]} before the element
1959 value, with no @samp{=}.
1961 To initialize a range of elements to the same value, write
1962 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
1963 extension. For example,
1966 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1970 If the value in it has side-effects, the side-effects happen only once,
1971 not for each initialized field by the range initializer.
1974 Note that the length of the array is the highest value specified
1977 In a structure initializer, specify the name of a field to initialize
1978 with @samp{.@var{fieldname} =} before the element value. For example,
1979 given the following structure,
1982 struct point @{ int x, y; @};
1986 the following initialization
1989 struct point p = @{ .y = yvalue, .x = xvalue @};
1996 struct point p = @{ xvalue, yvalue @};
1999 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2000 @samp{@var{fieldname}:}, as shown here:
2003 struct point p = @{ y: yvalue, x: xvalue @};
2006 Omitted field members are implicitly initialized the same as objects
2007 that have static storage duration.
2010 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2011 @dfn{designator}. You can also use a designator (or the obsolete colon
2012 syntax) when initializing a union, to specify which element of the union
2013 should be used. For example,
2016 union foo @{ int i; double d; @};
2018 union foo f = @{ .d = 4 @};
2022 converts 4 to a @code{double} to store it in the union using
2023 the second element. By contrast, casting 4 to type @code{union foo}
2024 stores it into the union as the integer @code{i}, since it is
2025 an integer. (@xref{Cast to Union}.)
2027 You can combine this technique of naming elements with ordinary C
2028 initialization of successive elements. Each initializer element that
2029 does not have a designator applies to the next consecutive element of the
2030 array or structure. For example,
2033 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2040 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2043 Labeling the elements of an array initializer is especially useful
2044 when the indices are characters or belong to an @code{enum} type.
2049 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2050 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2053 @cindex designator lists
2054 You can also write a series of @samp{.@var{fieldname}} and
2055 @samp{[@var{index}]} designators before an @samp{=} to specify a
2056 nested subobject to initialize; the list is taken relative to the
2057 subobject corresponding to the closest surrounding brace pair. For
2058 example, with the @samp{struct point} declaration above:
2061 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2065 If the same field is initialized multiple times, it has the value from
2066 the last initialization. If any such overridden initialization has
2067 side-effect, it is unspecified whether the side-effect happens or not.
2068 Currently, GCC discards them and issues a warning.
2071 @section Case Ranges
2073 @cindex ranges in case statements
2075 You can specify a range of consecutive values in a single @code{case} label,
2079 case @var{low} ... @var{high}:
2083 This has the same effect as the proper number of individual @code{case}
2084 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2086 This feature is especially useful for ranges of ASCII character codes:
2092 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2093 it may be parsed wrong when you use it with integer values. For example,
2108 @section Cast to a Union Type
2109 @cindex cast to a union
2110 @cindex union, casting to a
2112 A cast to union type is similar to other casts, except that the type
2113 specified is a union type. You can specify the type either with
2114 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2115 a constructor, not a cast, and hence does not yield an lvalue like
2116 normal casts. (@xref{Compound Literals}.)
2118 The types that may be cast to the union type are those of the members
2119 of the union. Thus, given the following union and variables:
2122 union foo @{ int i; double d; @};
2128 both @code{x} and @code{y} can be cast to type @code{union foo}.
2130 Using the cast as the right-hand side of an assignment to a variable of
2131 union type is equivalent to storing in a member of the union:
2136 u = (union foo) x @equiv{} u.i = x
2137 u = (union foo) y @equiv{} u.d = y
2140 You can also use the union cast as a function argument:
2143 void hack (union foo);
2145 hack ((union foo) x);
2148 @node Mixed Declarations
2149 @section Mixed Declarations and Code
2150 @cindex mixed declarations and code
2151 @cindex declarations, mixed with code
2152 @cindex code, mixed with declarations
2154 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2155 within compound statements. As an extension, GNU C also allows this in
2156 C90 mode. For example, you could do:
2165 Each identifier is visible from where it is declared until the end of
2166 the enclosing block.
2168 @node Function Attributes
2169 @section Declaring Attributes of Functions
2170 @cindex function attributes
2171 @cindex declaring attributes of functions
2172 @cindex functions that never return
2173 @cindex functions that return more than once
2174 @cindex functions that have no side effects
2175 @cindex functions in arbitrary sections
2176 @cindex functions that behave like malloc
2177 @cindex @code{volatile} applied to function
2178 @cindex @code{const} applied to function
2179 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2180 @cindex functions with non-null pointer arguments
2181 @cindex functions that are passed arguments in registers on x86-32
2182 @cindex functions that pop the argument stack on x86-32
2183 @cindex functions that do not pop the argument stack on x86-32
2184 @cindex functions that have different compilation options on x86-32
2185 @cindex functions that have different optimization options
2186 @cindex functions that are dynamically resolved
2188 In GNU C, you declare certain things about functions called in your program
2189 which help the compiler optimize function calls and check your code more
2192 The keyword @code{__attribute__} allows you to specify special
2193 attributes when making a declaration. This keyword is followed by an
2194 attribute specification inside double parentheses. The following
2195 attributes are currently defined for functions on all targets:
2196 @code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned},
2197 @code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone},
2199 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2200 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2201 @code{no_instrument_function}, @code{no_split_stack},
2202 @code{section}, @code{constructor},
2203 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2204 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2205 @code{warn_unused_result}, @code{nonnull},
2206 @code{returns_nonnull}, @code{gnu_inline},
2207 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2208 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2209 @code{no_sanitize_thread},
2210 @code{no_sanitize_undefined}, @code{no_reorder}, @code{bnd_legacy},
2211 @code{bnd_instrument}, @code{stack_protect},
2212 @code{error} and @code{warning}.
2213 Several other attributes are defined for functions on particular
2214 target systems. Other attributes, including @code{section} are
2215 supported for variables declarations (@pxref{Variable Attributes}),
2216 labels (@pxref{Label Attributes})
2217 and for types (@pxref{Type Attributes}).
2219 GCC plugins may provide their own attributes.
2221 You may also specify attributes with @samp{__} preceding and following
2222 each keyword. This allows you to use them in header files without
2223 being concerned about a possible macro of the same name. For example,
2224 you may use @code{__noreturn__} instead of @code{noreturn}.
2226 @xref{Attribute Syntax}, for details of the exact syntax for using
2230 @c Keep this table alphabetized by attribute name. Treat _ as space.
2232 @item alias ("@var{target}")
2233 @cindex @code{alias} attribute
2234 The @code{alias} attribute causes the declaration to be emitted as an
2235 alias for another symbol, which must be specified. For instance,
2238 void __f () @{ /* @r{Do something.} */; @}
2239 void f () __attribute__ ((weak, alias ("__f")));
2243 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2244 mangled name for the target must be used. It is an error if @samp{__f}
2245 is not defined in the same translation unit.
2247 Not all target machines support this attribute.
2249 @item aligned (@var{alignment})
2250 @cindex @code{aligned} attribute
2251 This attribute specifies a minimum alignment for the function,
2254 You cannot use this attribute to decrease the alignment of a function,
2255 only to increase it. However, when you explicitly specify a function
2256 alignment this overrides the effect of the
2257 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2260 Note that the effectiveness of @code{aligned} attributes may be
2261 limited by inherent limitations in your linker. On many systems, the
2262 linker is only able to arrange for functions to be aligned up to a
2263 certain maximum alignment. (For some linkers, the maximum supported
2264 alignment may be very very small.) See your linker documentation for
2265 further information.
2267 The @code{aligned} attribute can also be used for variables and fields
2268 (@pxref{Variable Attributes}.)
2271 @cindex @code{alloc_size} attribute
2272 The @code{alloc_size} attribute is used to tell the compiler that the
2273 function return value points to memory, where the size is given by
2274 one or two of the functions parameters. GCC uses this
2275 information to improve the correctness of @code{__builtin_object_size}.
2277 The function parameter(s) denoting the allocated size are specified by
2278 one or two integer arguments supplied to the attribute. The allocated size
2279 is either the value of the single function argument specified or the product
2280 of the two function arguments specified. Argument numbering starts at
2286 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2287 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2291 declares that @code{my_calloc} returns memory of the size given by
2292 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2293 of the size given by parameter 2.
2296 @cindex @code{alloc_align} attribute
2297 The @code{alloc_align} attribute is used to tell the compiler that the
2298 function return value points to memory, where the returned pointer minimum
2299 alignment is given by one of the functions parameters. GCC uses this
2300 information to improve pointer alignment analysis.
2302 The function parameter denoting the allocated alignment is specified by
2303 one integer argument, whose number is the argument of the attribute.
2304 Argument numbering starts at one.
2309 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2313 declares that @code{my_memalign} returns memory with minimum alignment
2314 given by parameter 1.
2316 @item assume_aligned
2317 @cindex @code{assume_aligned} attribute
2318 The @code{assume_aligned} attribute is used to tell the compiler that the
2319 function return value points to memory, where the returned pointer minimum
2320 alignment is given by the first argument.
2321 If the attribute has two arguments, the second argument is misalignment offset.
2326 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2327 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2331 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2332 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2336 @cindex @code{always_inline} function attribute
2337 Generally, functions are not inlined unless optimization is specified.
2338 For functions declared inline, this attribute inlines the function
2339 independent of any restrictions that otherwise apply to inlining.
2340 Failure to inline such a function is diagnosed as an error.
2341 Note that if such a function is called indirectly the compiler may
2342 or may not inline it depending on optimization level and a failure
2343 to inline an indirect call may or may not be diagnosed.
2346 @cindex @code{gnu_inline} function attribute
2347 This attribute should be used with a function that is also declared
2348 with the @code{inline} keyword. It directs GCC to treat the function
2349 as if it were defined in gnu90 mode even when compiling in C99 or
2352 If the function is declared @code{extern}, then this definition of the
2353 function is used only for inlining. In no case is the function
2354 compiled as a standalone function, not even if you take its address
2355 explicitly. Such an address becomes an external reference, as if you
2356 had only declared the function, and had not defined it. This has
2357 almost the effect of a macro. The way to use this is to put a
2358 function definition in a header file with this attribute, and put
2359 another copy of the function, without @code{extern}, in a library
2360 file. The definition in the header file causes most calls to the
2361 function to be inlined. If any uses of the function remain, they
2362 refer to the single copy in the library. Note that the two
2363 definitions of the functions need not be precisely the same, although
2364 if they do not have the same effect your program may behave oddly.
2366 In C, if the function is neither @code{extern} nor @code{static}, then
2367 the function is compiled as a standalone function, as well as being
2368 inlined where possible.
2370 This is how GCC traditionally handled functions declared
2371 @code{inline}. Since ISO C99 specifies a different semantics for
2372 @code{inline}, this function attribute is provided as a transition
2373 measure and as a useful feature in its own right. This attribute is
2374 available in GCC 4.1.3 and later. It is available if either of the
2375 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2376 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2377 Function is As Fast As a Macro}.
2379 In C++, this attribute does not depend on @code{extern} in any way,
2380 but it still requires the @code{inline} keyword to enable its special
2384 @cindex @code{artificial} function attribute
2385 This attribute is useful for small inline wrappers that if possible
2386 should appear during debugging as a unit. Depending on the debug
2387 info format it either means marking the function as artificial
2388 or using the caller location for all instructions within the inlined
2392 @cindex interrupt handler functions
2393 When added to an interrupt handler with the M32C port, causes the
2394 prologue and epilogue to use bank switching to preserve the registers
2395 rather than saving them on the stack.
2398 @cindex @code{flatten} function attribute
2399 Generally, inlining into a function is limited. For a function marked with
2400 this attribute, every call inside this function is inlined, if possible.
2401 Whether the function itself is considered for inlining depends on its size and
2402 the current inlining parameters.
2404 @item error ("@var{message}")
2405 @cindex @code{error} function attribute
2406 If this attribute is used on a function declaration and a call to such a function
2407 is not eliminated through dead code elimination or other optimizations, an error
2408 that includes @var{message} is diagnosed. This is useful
2409 for compile-time checking, especially together with @code{__builtin_constant_p}
2410 and inline functions where checking the inline function arguments is not
2411 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2412 While it is possible to leave the function undefined and thus invoke
2413 a link failure, when using this attribute the problem is diagnosed
2414 earlier and with exact location of the call even in presence of inline
2415 functions or when not emitting debugging information.
2417 @item warning ("@var{message}")
2418 @cindex @code{warning} function attribute
2419 If this attribute is used on a function declaration and a call to such a function
2420 is not eliminated through dead code elimination or other optimizations, a warning
2421 that includes @var{message} is diagnosed. This is useful
2422 for compile-time checking, especially together with @code{__builtin_constant_p}
2423 and inline functions. While it is possible to define the function with
2424 a message in @code{.gnu.warning*} section, when using this attribute the problem
2425 is diagnosed earlier and with exact location of the call even in presence
2426 of inline functions or when not emitting debugging information.
2429 @cindex functions that do pop the argument stack on x86-32
2431 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
2432 assume that the calling function pops off the stack space used to
2433 pass arguments. This is
2434 useful to override the effects of the @option{-mrtd} switch.
2437 @cindex @code{const} function attribute
2438 Many functions do not examine any values except their arguments, and
2439 have no effects except the return value. Basically this is just slightly
2440 more strict class than the @code{pure} attribute below, since function is not
2441 allowed to read global memory.
2443 @cindex pointer arguments
2444 Note that a function that has pointer arguments and examines the data
2445 pointed to must @emph{not} be declared @code{const}. Likewise, a
2446 function that calls a non-@code{const} function usually must not be
2447 @code{const}. It does not make sense for a @code{const} function to
2450 The attribute @code{const} is not implemented in GCC versions earlier
2451 than 2.5. An alternative way to declare that a function has no side
2452 effects, which works in the current version and in some older versions,
2456 typedef int intfn ();
2458 extern const intfn square;
2462 This approach does not work in GNU C++ from 2.6.0 on, since the language
2463 specifies that the @samp{const} must be attached to the return value.
2467 @itemx constructor (@var{priority})
2468 @itemx destructor (@var{priority})
2469 @cindex @code{constructor} function attribute
2470 @cindex @code{destructor} function attribute
2471 The @code{constructor} attribute causes the function to be called
2472 automatically before execution enters @code{main ()}. Similarly, the
2473 @code{destructor} attribute causes the function to be called
2474 automatically after @code{main ()} completes or @code{exit ()} is
2475 called. Functions with these attributes are useful for
2476 initializing data that is used implicitly during the execution of
2479 You may provide an optional integer priority to control the order in
2480 which constructor and destructor functions are run. A constructor
2481 with a smaller priority number runs before a constructor with a larger
2482 priority number; the opposite relationship holds for destructors. So,
2483 if you have a constructor that allocates a resource and a destructor
2484 that deallocates the same resource, both functions typically have the
2485 same priority. The priorities for constructor and destructor
2486 functions are the same as those specified for namespace-scope C++
2487 objects (@pxref{C++ Attributes}).
2489 These attributes are not currently implemented for Objective-C@.
2492 @itemx deprecated (@var{msg})
2493 @cindex @code{deprecated} attribute.
2494 The @code{deprecated} attribute results in a warning if the function
2495 is used anywhere in the source file. This is useful when identifying
2496 functions that are expected to be removed in a future version of a
2497 program. The warning also includes the location of the declaration
2498 of the deprecated function, to enable users to easily find further
2499 information about why the function is deprecated, or what they should
2500 do instead. Note that the warnings only occurs for uses:
2503 int old_fn () __attribute__ ((deprecated));
2505 int (*fn_ptr)() = old_fn;
2509 results in a warning on line 3 but not line 2. The optional @var{msg}
2510 argument, which must be a string, is printed in the warning if
2513 The @code{deprecated} attribute can also be used for variables and
2514 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2517 @cindex @code{disinterrupt} attribute
2518 On Epiphany and MeP targets, this attribute causes the compiler to emit
2519 instructions to disable interrupts for the duration of the given
2523 @cindex @code{__declspec(dllexport)}
2524 On Microsoft Windows targets and Symbian OS targets the
2525 @code{dllexport} attribute causes the compiler to provide a global
2526 pointer to a pointer in a DLL, so that it can be referenced with the
2527 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
2528 name is formed by combining @code{_imp__} and the function or variable
2531 You can use @code{__declspec(dllexport)} as a synonym for
2532 @code{__attribute__ ((dllexport))} for compatibility with other
2535 On systems that support the @code{visibility} attribute, this
2536 attribute also implies ``default'' visibility. It is an error to
2537 explicitly specify any other visibility.
2539 In previous versions of GCC, the @code{dllexport} attribute was ignored
2540 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2541 had been used. The default behavior now is to emit all dllexported
2542 inline functions; however, this can cause object file-size bloat, in
2543 which case the old behavior can be restored by using
2544 @option{-fno-keep-inline-dllexport}.
2546 The attribute is also ignored for undefined symbols.
2548 When applied to C++ classes, the attribute marks defined non-inlined
2549 member functions and static data members as exports. Static consts
2550 initialized in-class are not marked unless they are also defined
2553 For Microsoft Windows targets there are alternative methods for
2554 including the symbol in the DLL's export table such as using a
2555 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2556 the @option{--export-all} linker flag.
2559 @cindex @code{__declspec(dllimport)}
2560 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2561 attribute causes the compiler to reference a function or variable via
2562 a global pointer to a pointer that is set up by the DLL exporting the
2563 symbol. The attribute implies @code{extern}. On Microsoft Windows
2564 targets, the pointer name is formed by combining @code{_imp__} and the
2565 function or variable name.
2567 You can use @code{__declspec(dllimport)} as a synonym for
2568 @code{__attribute__ ((dllimport))} for compatibility with other
2571 On systems that support the @code{visibility} attribute, this
2572 attribute also implies ``default'' visibility. It is an error to
2573 explicitly specify any other visibility.
2575 Currently, the attribute is ignored for inlined functions. If the
2576 attribute is applied to a symbol @emph{definition}, an error is reported.
2577 If a symbol previously declared @code{dllimport} is later defined, the
2578 attribute is ignored in subsequent references, and a warning is emitted.
2579 The attribute is also overridden by a subsequent declaration as
2582 When applied to C++ classes, the attribute marks non-inlined
2583 member functions and static data members as imports. However, the
2584 attribute is ignored for virtual methods to allow creation of vtables
2587 On the SH Symbian OS target the @code{dllimport} attribute also has
2588 another affect---it can cause the vtable and run-time type information
2589 for a class to be exported. This happens when the class has a
2590 dllimported constructor or a non-inline, non-pure virtual function
2591 and, for either of those two conditions, the class also has an inline
2592 constructor or destructor and has a key function that is defined in
2593 the current translation unit.
2595 For Microsoft Windows targets the use of the @code{dllimport}
2596 attribute on functions is not necessary, but provides a small
2597 performance benefit by eliminating a thunk in the DLL@. The use of the
2598 @code{dllimport} attribute on imported variables was required on older
2599 versions of the GNU linker, but can now be avoided by passing the
2600 @option{--enable-auto-import} switch to the GNU linker. As with
2601 functions, using the attribute for a variable eliminates a thunk in
2604 One drawback to using this attribute is that a pointer to a
2605 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2606 address. However, a pointer to a @emph{function} with the
2607 @code{dllimport} attribute can be used as a constant initializer; in
2608 this case, the address of a stub function in the import lib is
2609 referenced. On Microsoft Windows targets, the attribute can be disabled
2610 for functions by setting the @option{-mnop-fun-dllimport} flag.
2613 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2614 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2615 variable should be placed into the eight-bit data section.
2616 The compiler generates more efficient code for certain operations
2617 on data in the eight-bit data area. Note the eight-bit data area is limited to
2620 You must use GAS and GLD from GNU binutils version 2.7 or later for
2621 this attribute to work correctly.
2624 @cindex exception handler functions
2625 Use this attribute on the NDS32 target to indicate that the specified function
2626 is an exception handler. The compiler will generate corresponding sections
2627 for use in an exception handler.
2629 @item exception_handler
2630 @cindex exception handler functions on the Blackfin processor
2631 Use this attribute on the Blackfin to indicate that the specified function
2632 is an exception handler. The compiler generates function entry and
2633 exit sequences suitable for use in an exception handler when this
2634 attribute is present.
2636 @item externally_visible
2637 @cindex @code{externally_visible} attribute.
2638 This attribute, attached to a global variable or function, nullifies
2639 the effect of the @option{-fwhole-program} command-line option, so the
2640 object remains visible outside the current compilation unit.
2642 If @option{-fwhole-program} is used together with @option{-flto} and
2643 @command{gold} is used as the linker plugin,
2644 @code{externally_visible} attributes are automatically added to functions
2645 (not variable yet due to a current @command{gold} issue)
2646 that are accessed outside of LTO objects according to resolution file
2647 produced by @command{gold}.
2648 For other linkers that cannot generate resolution file,
2649 explicit @code{externally_visible} attributes are still necessary.
2652 @cindex functions that handle memory bank switching
2653 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2654 use a calling convention that takes care of switching memory banks when
2655 entering and leaving a function. This calling convention is also the
2656 default when using the @option{-mlong-calls} option.
2658 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2659 to call and return from a function.
2661 On 68HC11 the compiler generates a sequence of instructions
2662 to invoke a board-specific routine to switch the memory bank and call the
2663 real function. The board-specific routine simulates a @code{call}.
2664 At the end of a function, it jumps to a board-specific routine
2665 instead of using @code{rts}. The board-specific return routine simulates
2668 On MeP targets this causes the compiler to use a calling convention
2669 that assumes the called function is too far away for the built-in
2672 @item fast_interrupt
2673 @cindex interrupt handler functions
2674 Use this attribute on the M32C and RX ports to indicate that the specified
2675 function is a fast interrupt handler. This is just like the
2676 @code{interrupt} attribute, except that @code{freit} is used to return
2677 instead of @code{reit}.
2680 @cindex functions that pop the argument stack on x86-32
2681 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
2682 pass the first argument (if of integral type) in the register ECX and
2683 the second argument (if of integral type) in the register EDX@. Subsequent
2684 and other typed arguments are passed on the stack. The called function
2685 pops the arguments off the stack. If the number of arguments is variable all
2686 arguments are pushed on the stack.
2689 @cindex functions that pop the argument stack on x86-32
2690 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
2691 pass the first argument (if of integral type) in the register ECX.
2692 Subsequent and other typed arguments are passed on the stack. The called
2693 function pops the arguments off the stack.
2694 If the number of arguments is variable all arguments are pushed on the
2696 The @code{thiscall} attribute is intended for C++ non-static member functions.
2697 As a GCC extension, this calling convention can be used for C functions
2698 and for static member methods.
2700 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2701 @cindex @code{format} function attribute
2703 The @code{format} attribute specifies that a function takes @code{printf},
2704 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2705 should be type-checked against a format string. For example, the
2710 my_printf (void *my_object, const char *my_format, ...)
2711 __attribute__ ((format (printf, 2, 3)));
2715 causes the compiler to check the arguments in calls to @code{my_printf}
2716 for consistency with the @code{printf} style format string argument
2719 The parameter @var{archetype} determines how the format string is
2720 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2721 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2722 @code{strfmon}. (You can also use @code{__printf__},
2723 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2724 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2725 @code{ms_strftime} are also present.
2726 @var{archetype} values such as @code{printf} refer to the formats accepted
2727 by the system's C runtime library,
2728 while values prefixed with @samp{gnu_} always refer
2729 to the formats accepted by the GNU C Library. On Microsoft Windows
2730 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2731 @file{msvcrt.dll} library.
2732 The parameter @var{string-index}
2733 specifies which argument is the format string argument (starting
2734 from 1), while @var{first-to-check} is the number of the first
2735 argument to check against the format string. For functions
2736 where the arguments are not available to be checked (such as
2737 @code{vprintf}), specify the third parameter as zero. In this case the
2738 compiler only checks the format string for consistency. For
2739 @code{strftime} formats, the third parameter is required to be zero.
2740 Since non-static C++ methods have an implicit @code{this} argument, the
2741 arguments of such methods should be counted from two, not one, when
2742 giving values for @var{string-index} and @var{first-to-check}.
2744 In the example above, the format string (@code{my_format}) is the second
2745 argument of the function @code{my_print}, and the arguments to check
2746 start with the third argument, so the correct parameters for the format
2747 attribute are 2 and 3.
2749 @opindex ffreestanding
2750 @opindex fno-builtin
2751 The @code{format} attribute allows you to identify your own functions
2752 that take format strings as arguments, so that GCC can check the
2753 calls to these functions for errors. The compiler always (unless
2754 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2755 for the standard library functions @code{printf}, @code{fprintf},
2756 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2757 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2758 warnings are requested (using @option{-Wformat}), so there is no need to
2759 modify the header file @file{stdio.h}. In C99 mode, the functions
2760 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2761 @code{vsscanf} are also checked. Except in strictly conforming C
2762 standard modes, the X/Open function @code{strfmon} is also checked as
2763 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2764 @xref{C Dialect Options,,Options Controlling C Dialect}.
2766 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2767 recognized in the same context. Declarations including these format attributes
2768 are parsed for correct syntax, however the result of checking of such format
2769 strings is not yet defined, and is not carried out by this version of the
2772 The target may also provide additional types of format checks.
2773 @xref{Target Format Checks,,Format Checks Specific to Particular
2776 @item format_arg (@var{string-index})
2777 @cindex @code{format_arg} function attribute
2778 @opindex Wformat-nonliteral
2779 The @code{format_arg} attribute specifies that a function takes a format
2780 string for a @code{printf}, @code{scanf}, @code{strftime} or
2781 @code{strfmon} style function and modifies it (for example, to translate
2782 it into another language), so the result can be passed to a
2783 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2784 function (with the remaining arguments to the format function the same
2785 as they would have been for the unmodified string). For example, the
2790 my_dgettext (char *my_domain, const char *my_format)
2791 __attribute__ ((format_arg (2)));
2795 causes the compiler to check the arguments in calls to a @code{printf},
2796 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2797 format string argument is a call to the @code{my_dgettext} function, for
2798 consistency with the format string argument @code{my_format}. If the
2799 @code{format_arg} attribute had not been specified, all the compiler
2800 could tell in such calls to format functions would be that the format
2801 string argument is not constant; this would generate a warning when
2802 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2803 without the attribute.
2805 The parameter @var{string-index} specifies which argument is the format
2806 string argument (starting from one). Since non-static C++ methods have
2807 an implicit @code{this} argument, the arguments of such methods should
2808 be counted from two.
2810 The @code{format_arg} attribute allows you to identify your own
2811 functions that modify format strings, so that GCC can check the
2812 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2813 type function whose operands are a call to one of your own function.
2814 The compiler always treats @code{gettext}, @code{dgettext}, and
2815 @code{dcgettext} in this manner except when strict ISO C support is
2816 requested by @option{-ansi} or an appropriate @option{-std} option, or
2817 @option{-ffreestanding} or @option{-fno-builtin}
2818 is used. @xref{C Dialect Options,,Options
2819 Controlling C Dialect}.
2821 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2822 @code{NSString} reference for compatibility with the @code{format} attribute
2825 The target may also allow additional types in @code{format-arg} attributes.
2826 @xref{Target Format Checks,,Format Checks Specific to Particular
2829 @item function_vector
2830 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2831 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2832 function should be called through the function vector. Calling a
2833 function through the function vector reduces code size, however;
2834 the function vector has a limited size (maximum 128 entries on the H8/300
2835 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2837 On SH2A targets, this attribute declares a function to be called using the
2838 TBR relative addressing mode. The argument to this attribute is the entry
2839 number of the same function in a vector table containing all the TBR
2840 relative addressable functions. For correct operation the TBR must be setup
2841 accordingly to point to the start of the vector table before any functions with
2842 this attribute are invoked. Usually a good place to do the initialization is
2843 the startup routine. The TBR relative vector table can have at max 256 function
2844 entries. The jumps to these functions are generated using a SH2A specific,
2845 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
2846 from GNU binutils version 2.7 or later for this attribute to work correctly.
2848 Please refer the example of M16C target, to see the use of this
2849 attribute while declaring a function,
2851 In an application, for a function being called once, this attribute
2852 saves at least 8 bytes of code; and if other successive calls are being
2853 made to the same function, it saves 2 bytes of code per each of these
2856 On M16C/M32C targets, the @code{function_vector} attribute declares a
2857 special page subroutine call function. Use of this attribute reduces
2858 the code size by 2 bytes for each call generated to the
2859 subroutine. The argument to the attribute is the vector number entry
2860 from the special page vector table which contains the 16 low-order
2861 bits of the subroutine's entry address. Each vector table has special
2862 page number (18 to 255) that is used in @code{jsrs} instructions.
2863 Jump addresses of the routines are generated by adding 0x0F0000 (in
2864 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2865 2-byte addresses set in the vector table. Therefore you need to ensure
2866 that all the special page vector routines should get mapped within the
2867 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2870 In the following example 2 bytes are saved for each call to
2871 function @code{foo}.
2874 void foo (void) __attribute__((function_vector(0x18)));
2885 If functions are defined in one file and are called in another file,
2886 then be sure to write this declaration in both files.
2888 This attribute is ignored for R8C target.
2890 @item ifunc ("@var{resolver}")
2891 @cindex @code{ifunc} attribute
2892 The @code{ifunc} attribute is used to mark a function as an indirect
2893 function using the STT_GNU_IFUNC symbol type extension to the ELF
2894 standard. This allows the resolution of the symbol value to be
2895 determined dynamically at load time, and an optimized version of the
2896 routine can be selected for the particular processor or other system
2897 characteristics determined then. To use this attribute, first define
2898 the implementation functions available, and a resolver function that
2899 returns a pointer to the selected implementation function. The
2900 implementation functions' declarations must match the API of the
2901 function being implemented, the resolver's declaration is be a
2902 function returning pointer to void function returning void:
2905 void *my_memcpy (void *dst, const void *src, size_t len)
2910 static void (*resolve_memcpy (void)) (void)
2912 return my_memcpy; // we'll just always select this routine
2917 The exported header file declaring the function the user calls would
2921 extern void *memcpy (void *, const void *, size_t);
2925 allowing the user to call this as a regular function, unaware of the
2926 implementation. Finally, the indirect function needs to be defined in
2927 the same translation unit as the resolver function:
2930 void *memcpy (void *, const void *, size_t)
2931 __attribute__ ((ifunc ("resolve_memcpy")));
2934 Indirect functions cannot be weak, and require a recent binutils (at
2935 least version 2.20.1), and GNU C library (at least version 2.11.1).
2938 @cindex interrupt handler functions
2939 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2940 m68k, MeP, MIPS, MSP430, RL78, RX, Visium and Xstormy16 ports to indicate
2941 that the specified function is an interrupt handler. The compiler generates
2942 function entry and exit sequences suitable for use in an interrupt handler
2943 when this attribute is present. With Epiphany targets it may also generate
2944 a special section with code to initialize the interrupt vector table.
2946 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2947 and SH processors can be specified via the @code{interrupt_handler} attribute.
2949 Note, on the ARC, you must specify the kind of interrupt to be handled
2950 in a parameter to the interrupt attribute like this:
2953 void f () __attribute__ ((interrupt ("ilink1")));
2956 Permissible values for this parameter are: @w{@code{ilink1}} and
2959 Note, on the AVR, the hardware globally disables interrupts when an
2960 interrupt is executed. The first instruction of an interrupt handler
2961 declared with this attribute is a @code{SEI} instruction to
2962 re-enable interrupts. See also the @code{signal} function attribute
2963 that does not insert a @code{SEI} instruction. If both @code{signal} and
2964 @code{interrupt} are specified for the same function, @code{signal}
2965 is silently ignored.
2967 Note, for the ARM, you can specify the kind of interrupt to be handled by
2968 adding an optional parameter to the interrupt attribute like this:
2971 void f () __attribute__ ((interrupt ("IRQ")));
2975 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2976 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2978 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2979 may be called with a word-aligned stack pointer.
2981 Note, for the MSP430 you can provide an argument to the interrupt
2982 attribute which specifies a name or number. If the argument is a
2983 number it indicates the slot in the interrupt vector table (0 - 31) to
2984 which this handler should be assigned. If the argument is a name it
2985 is treated as a symbolic name for the vector slot. These names should
2986 match up with appropriate entries in the linker script. By default
2987 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2988 @code{reset} for vector 31 are recognised.
2990 You can also use the following function attributes to modify how
2991 normal functions interact with interrupt functions:
2995 @cindex @code{critical} attribute
2996 Critical functions disable interrupts upon entry and restore the
2997 previous interrupt state upon exit. Critical functions cannot also
2998 have the @code{naked} or @code{reentrant} attributes. They can have
2999 the @code{interrupt} attribute.
3002 @cindex @code{reentrant} attribute
3003 Reentrant functions disable interrupts upon entry and enable them
3004 upon exit. Reentrant functions cannot also have the @code{naked}
3005 or @code{critical} attributes. They can have the @code{interrupt}
3009 @cindex @code{wakeup} attribute
3010 This attribute only applies to interrupt functions. It is silently
3011 ignored if applied to a non-interrupt function. A wakeup interrupt
3012 function will rouse the processor from any low-power state that it
3013 might be in when the function exits.
3017 On Epiphany targets one or more optional parameters can be added like this:
3020 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3023 Permissible values for these parameters are: @w{@code{reset}},
3024 @w{@code{software_exception}}, @w{@code{page_miss}},
3025 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3026 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3027 Multiple parameters indicate that multiple entries in the interrupt
3028 vector table should be initialized for this function, i.e.@: for each
3029 parameter @w{@var{name}}, a jump to the function is emitted in
3030 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
3031 entirely, in which case no interrupt vector table entry is provided.
3033 Note, on Epiphany targets, interrupts are enabled inside the function
3034 unless the @code{disinterrupt} attribute is also specified.
3036 On Epiphany targets, you can also use the following attribute to
3037 modify the behavior of an interrupt handler:
3039 @item forwarder_section
3040 @cindex @code{forwarder_section} attribute
3041 The interrupt handler may be in external memory which cannot be
3042 reached by a branch instruction, so generate a local memory trampoline
3043 to transfer control. The single parameter identifies the section where
3044 the trampoline is placed.
3047 The following examples are all valid uses of these attributes on
3050 void __attribute__ ((interrupt)) universal_handler ();
3051 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3052 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3053 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3054 fast_timer_handler ();
3055 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
3056 external_dma_handler ();
3059 On MIPS targets, you can use the following attributes to modify the behavior
3060 of an interrupt handler:
3062 @item use_shadow_register_set
3063 @cindex @code{use_shadow_register_set} attribute
3064 Assume that the handler uses a shadow register set, instead of
3065 the main general-purpose registers.
3067 @item keep_interrupts_masked
3068 @cindex @code{keep_interrupts_masked} attribute
3069 Keep interrupts masked for the whole function. Without this attribute,
3070 GCC tries to reenable interrupts for as much of the function as it can.
3072 @item use_debug_exception_return
3073 @cindex @code{use_debug_exception_return} attribute
3074 Return using the @code{deret} instruction. Interrupt handlers that don't
3075 have this attribute return using @code{eret} instead.
3078 You can use any combination of these attributes, as shown below:
3080 void __attribute__ ((interrupt)) v0 ();
3081 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
3082 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
3083 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
3084 void __attribute__ ((interrupt, use_shadow_register_set,
3085 keep_interrupts_masked)) v4 ();
3086 void __attribute__ ((interrupt, use_shadow_register_set,
3087 use_debug_exception_return)) v5 ();
3088 void __attribute__ ((interrupt, keep_interrupts_masked,
3089 use_debug_exception_return)) v6 ();
3090 void __attribute__ ((interrupt, use_shadow_register_set,
3091 keep_interrupts_masked,
3092 use_debug_exception_return)) v7 ();
3095 On NDS32 target, this attribute is to indicate that the specified function
3096 is an interrupt handler. The compiler will generate corresponding sections
3097 for use in an interrupt handler. You can use the following attributes
3098 to modify the behavior:
3101 @cindex @code{nested} attribute
3102 This interrupt service routine is interruptible.
3104 @cindex @code{not_nested} attribute
3105 This interrupt service routine is not interruptible.
3107 @cindex @code{nested_ready} attribute
3108 This interrupt service routine is interruptible after @code{PSW.GIE}
3109 (global interrupt enable) is set. This allows interrupt service routine to
3110 finish some short critical code before enabling interrupts.
3112 @cindex @code{save_all} attribute
3113 The system will help save all registers into stack before entering
3116 @cindex @code{partial_save} attribute
3117 The system will help save caller registers into stack before entering
3121 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3122 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3123 that must end with @code{RETB} instead of @code{RETI}).
3125 On RX targets, you may specify one or more vector numbers as arguments
3126 to the attribute, as well as naming an alternate table name.
3127 Parameters are handled sequentially, so one handler can be assigned to
3128 multiple entries in multiple tables. One may also pass the magic
3129 string @code{"$default"} which causes the function to be used for any
3130 unfilled slots in the current table.
3132 This example shows a simple assignment of a function to one vector in
3133 the default table (note that preprocessor macros may be used for
3134 chip-specific symbolic vector names):
3136 void __attribute__ ((interrupt (5))) txd1_handler ();
3139 This example assigns a function to two slots in the default table
3140 (using preprocessor macros defined elsewhere) and makes it the default
3141 for the @code{dct} table:
3143 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
3147 @item interrupt_handler
3148 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
3149 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3150 indicate that the specified function is an interrupt handler. The compiler
3151 generates function entry and exit sequences suitable for use in an
3152 interrupt handler when this attribute is present.
3154 @item interrupt_thread
3155 @cindex interrupt thread functions on fido
3156 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3157 that the specified function is an interrupt handler that is designed
3158 to run as a thread. The compiler omits generate prologue/epilogue
3159 sequences and replaces the return instruction with a @code{sleep}
3160 instruction. This attribute is available only on fido.
3163 @cindex interrupt service routines on ARM
3164 Use this attribute on ARM to write Interrupt Service Routines. This is an
3165 alias to the @code{interrupt} attribute above.
3168 @cindex User stack pointer in interrupts on the Blackfin
3169 When used together with @code{interrupt_handler}, @code{exception_handler}
3170 or @code{nmi_handler}, code is generated to load the stack pointer
3171 from the USP register in the function prologue.
3174 @cindex @code{l1_text} function attribute
3175 This attribute specifies a function to be placed into L1 Instruction
3176 SRAM@. The function is put into a specific section named @code{.l1.text}.
3177 With @option{-mfdpic}, function calls with a such function as the callee
3178 or caller uses inlined PLT.
3181 @cindex @code{l2} function attribute
3182 On the Blackfin, this attribute specifies a function to be placed into L2
3183 SRAM. The function is put into a specific section named
3184 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3188 @cindex @code{leaf} function attribute
3189 Calls to external functions with this attribute must return to the current
3190 compilation unit only by return or by exception handling. In particular, leaf
3191 functions are not allowed to call callback function passed to it from the current
3192 compilation unit or directly call functions exported by the unit or longjmp
3193 into the unit. Leaf function might still call functions from other compilation
3194 units and thus they are not necessarily leaf in the sense that they contain no
3195 function calls at all.
3197 The attribute is intended for library functions to improve dataflow analysis.
3198 The compiler takes the hint that any data not escaping the current compilation unit can
3199 not be used or modified by the leaf function. For example, the @code{sin} function
3200 is a leaf function, but @code{qsort} is not.
3202 Note that leaf functions might invoke signals and signal handlers might be
3203 defined in the current compilation unit and use static variables. The only
3204 compliant way to write such a signal handler is to declare such variables
3207 The attribute has no effect on functions defined within the current compilation
3208 unit. This is to allow easy merging of multiple compilation units into one,
3209 for example, by using the link-time optimization. For this reason the
3210 attribute is not allowed on types to annotate indirect calls.
3212 @item long_call/medium_call/short_call
3213 @cindex indirect calls on ARC
3214 @cindex indirect calls on ARM
3215 @cindex indirect calls on Epiphany
3216 These attributes specify how a particular function is called on
3217 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3218 These attributes override the
3219 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3220 and @option{-mmedium-calls} (@pxref{ARC Options})
3221 command-line switches and @code{#pragma long_calls} settings. For ARM, the
3222 @code{long_call} attribute indicates that the function might be far
3223 away from the call site and require a different (more expensive)
3224 calling sequence. The @code{short_call} attribute always places
3225 the offset to the function from the call site into the @samp{BL}
3226 instruction directly.
3228 For ARC, a function marked with the @code{long_call} attribute is
3229 always called using register-indirect jump-and-link instructions,
3230 thereby enabling the called function to be placed anywhere within the
3231 32-bit address space. A function marked with the @code{medium_call}
3232 attribute will always be close enough to be called with an unconditional
3233 branch-and-link instruction, which has a 25-bit offset from
3234 the call site. A function marked with the @code{short_call}
3235 attribute will always be close enough to be called with a conditional
3236 branch-and-link instruction, which has a 21-bit offset from
3239 @item longcall/shortcall
3240 @cindex functions called via pointer on the RS/6000 and PowerPC
3241 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3242 indicates that the function might be far away from the call site and
3243 require a different (more expensive) calling sequence. The
3244 @code{shortcall} attribute indicates that the function is always close
3245 enough for the shorter calling sequence to be used. These attributes
3246 override both the @option{-mlongcall} switch and, on the RS/6000 and
3247 PowerPC, the @code{#pragma longcall} setting.
3249 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3250 calls are necessary.
3252 @item long_call/near/far
3253 @cindex indirect calls on MIPS
3254 These attributes specify how a particular function is called on MIPS@.
3255 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3256 command-line switch. The @code{long_call} and @code{far} attributes are
3257 synonyms, and cause the compiler to always call
3258 the function by first loading its address into a register, and then using
3259 the contents of that register. The @code{near} attribute has the opposite
3260 effect; it specifies that non-PIC calls should be made using the more
3261 efficient @code{jal} instruction.
3264 @cindex @code{malloc} attribute
3265 This tells the compiler that a function is @code{malloc}-like, i.e.,
3266 that the pointer @var{P} returned by the function cannot alias any
3267 other pointer valid when the function returns, and moreover no
3268 pointers to valid objects occur in any storage addressed by @var{P}.
3270 Using this attribute can improve optimization. Functions like
3271 @code{malloc} and @code{calloc} have this property because they return
3272 a pointer to uninitialized or zeroed-out storage. However, functions
3273 like @code{realloc} do not have this property, as they can return a
3274 pointer to storage containing pointers.
3276 @item mips16/nomips16
3277 @cindex @code{mips16} attribute
3278 @cindex @code{nomips16} attribute
3280 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3281 function attributes to locally select or turn off MIPS16 code generation.
3282 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3283 while MIPS16 code generation is disabled for functions with the
3284 @code{nomips16} attribute. These attributes override the
3285 @option{-mips16} and @option{-mno-mips16} options on the command line
3286 (@pxref{MIPS Options}).
3288 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3289 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3290 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
3291 may interact badly with some GCC extensions such as @code{__builtin_apply}
3292 (@pxref{Constructing Calls}).
3294 @item micromips/nomicromips
3295 @cindex @code{micromips} attribute
3296 @cindex @code{nomicromips} attribute
3298 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3299 function attributes to locally select or turn off microMIPS code generation.
3300 A function with the @code{micromips} attribute is emitted as microMIPS code,
3301 while microMIPS code generation is disabled for functions with the
3302 @code{nomicromips} attribute. These attributes override the
3303 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3304 (@pxref{MIPS Options}).
3306 When compiling files containing mixed microMIPS and non-microMIPS code, the
3307 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3309 not that within individual functions. Mixed microMIPS and non-microMIPS code
3310 may interact badly with some GCC extensions such as @code{__builtin_apply}
3311 (@pxref{Constructing Calls}).
3313 @item model (@var{model-name})
3314 @cindex function addressability on the M32R/D
3315 @cindex variable addressability on the IA-64
3317 On the M32R/D, use this attribute to set the addressability of an
3318 object, and of the code generated for a function. The identifier
3319 @var{model-name} is one of @code{small}, @code{medium}, or
3320 @code{large}, representing each of the code models.
3322 Small model objects live in the lower 16MB of memory (so that their
3323 addresses can be loaded with the @code{ld24} instruction), and are
3324 callable with the @code{bl} instruction.
3326 Medium model objects may live anywhere in the 32-bit address space (the
3327 compiler generates @code{seth/add3} instructions to load their addresses),
3328 and are callable with the @code{bl} instruction.
3330 Large model objects may live anywhere in the 32-bit address space (the
3331 compiler generates @code{seth/add3} instructions to load their addresses),
3332 and may not be reachable with the @code{bl} instruction (the compiler
3333 generates the much slower @code{seth/add3/jl} instruction sequence).
3335 On IA-64, use this attribute to set the addressability of an object.
3336 At present, the only supported identifier for @var{model-name} is
3337 @code{small}, indicating addressability via ``small'' (22-bit)
3338 addresses (so that their addresses can be loaded with the @code{addl}
3339 instruction). Caveat: such addressing is by definition not position
3340 independent and hence this attribute must not be used for objects
3341 defined by shared libraries.
3343 @item ms_abi/sysv_abi
3344 @cindex @code{ms_abi} attribute
3345 @cindex @code{sysv_abi} attribute
3347 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
3348 to indicate which calling convention should be used for a function. The
3349 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3350 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3351 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
3352 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
3354 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3355 requires the @option{-maccumulate-outgoing-args} option.
3357 @item callee_pop_aggregate_return (@var{number})
3358 @cindex @code{callee_pop_aggregate_return} attribute
3360 On x86-32 targets, you can use this attribute to control how
3361 aggregates are returned in memory. If the caller is responsible for
3362 popping the hidden pointer together with the rest of the arguments, specify
3363 @var{number} equal to zero. If callee is responsible for popping the
3364 hidden pointer, specify @var{number} equal to one.
3366 The default x86-32 ABI assumes that the callee pops the
3367 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
3368 the compiler assumes that the
3369 caller pops the stack for hidden pointer.
3371 @item ms_hook_prologue
3372 @cindex @code{ms_hook_prologue} attribute
3374 On 32-bit and 64-bit x86 targets, you can use
3375 this function attribute to make GCC generate the ``hot-patching'' function
3376 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3379 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
3380 @cindex @code{hotpatch} attribute
3382 On S/390 System z targets, you can use this function attribute to
3383 make GCC generate a ``hot-patching'' function prologue. If the
3384 @option{-mhotpatch=} command-line option is used at the same time,
3385 the @code{hotpatch} attribute takes precedence. The first of the
3386 two arguments specifies the number of halfwords to be added before
3387 the function label. A second argument can be used to specify the
3388 number of halfwords to be added after the function label. For
3389 both arguments the maximum allowed value is 1000000.
3391 If both ar guments are zero, hotpatching is disabled.
3394 @cindex function without a prologue/epilogue code
3395 This attribute is available on the ARM, AVR, MCORE, MSP430, NDS32,
3396 RL78, RX and SPU ports. It allows the compiler to construct the
3397 requisite function declaration, while allowing the body of the
3398 function to be assembly code. The specified function will not have
3399 prologue/epilogue sequences generated by the compiler. Only Basic
3400 @code{asm} statements can safely be included in naked functions
3401 (@pxref{Basic Asm}). While using Extended @code{asm} or a mixture of
3402 Basic @code{asm} and ``C'' code may appear to work, they cannot be
3403 depended upon to work reliably and are not supported.
3406 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3407 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3408 use the normal calling convention based on @code{jsr} and @code{rts}.
3409 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3412 On MeP targets this attribute causes the compiler to assume the called
3413 function is close enough to use the normal calling convention,
3414 overriding the @option{-mtf} command-line option.
3417 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3418 Use this attribute together with @code{interrupt_handler},
3419 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3420 entry code should enable nested interrupts or exceptions.
3423 @cindex NMI handler functions on the Blackfin processor
3424 Use this attribute on the Blackfin to indicate that the specified function
3425 is an NMI handler. The compiler generates function entry and
3426 exit sequences suitable for use in an NMI handler when this
3427 attribute is present.
3430 @cindex @code{nocompression} attribute
3431 On MIPS targets, you can use the @code{nocompression} function attribute
3432 to locally turn off MIPS16 and microMIPS code generation. This attribute
3433 overrides the @option{-mips16} and @option{-mmicromips} options on the
3434 command line (@pxref{MIPS Options}).
3436 @item no_instrument_function
3437 @cindex @code{no_instrument_function} function attribute
3438 @opindex finstrument-functions
3439 If @option{-finstrument-functions} is given, profiling function calls are
3440 generated at entry and exit of most user-compiled functions.
3441 Functions with this attribute are not so instrumented.
3443 @item no_split_stack
3444 @cindex @code{no_split_stack} function attribute
3445 @opindex fsplit-stack
3446 If @option{-fsplit-stack} is given, functions have a small
3447 prologue which decides whether to split the stack. Functions with the
3448 @code{no_split_stack} attribute do not have that prologue, and thus
3449 may run with only a small amount of stack space available.
3452 @cindex @code{stack_protect} function attribute
3453 This function attribute make a stack protection of the function if
3454 flags @option{fstack-protector} or @option{fstack-protector-strong}
3455 or @option{fstack-protector-explicit} are set.
3458 @cindex @code{noinline} function attribute
3459 This function attribute prevents a function from being considered for
3461 @c Don't enumerate the optimizations by name here; we try to be
3462 @c future-compatible with this mechanism.
3463 If the function does not have side-effects, there are optimizations
3464 other than inlining that cause function calls to be optimized away,
3465 although the function call is live. To keep such calls from being
3472 (@pxref{Extended Asm}) in the called function, to serve as a special
3476 @cindex @code{noclone} function attribute
3477 This function attribute prevents a function from being considered for
3478 cloning---a mechanism that produces specialized copies of functions
3479 and which is (currently) performed by interprocedural constant
3483 @cindex @code{no_icf} function attribute
3484 This function attribute prevents a functions from being merged with another
3485 semantically equivalent function.
3487 @item nonnull (@var{arg-index}, @dots{})
3488 @cindex @code{nonnull} function attribute
3489 The @code{nonnull} attribute specifies that some function parameters should
3490 be non-null pointers. For instance, the declaration:
3494 my_memcpy (void *dest, const void *src, size_t len)
3495 __attribute__((nonnull (1, 2)));
3499 causes the compiler to check that, in calls to @code{my_memcpy},
3500 arguments @var{dest} and @var{src} are non-null. If the compiler
3501 determines that a null pointer is passed in an argument slot marked
3502 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3503 is issued. The compiler may also choose to make optimizations based
3504 on the knowledge that certain function arguments will never be null.
3506 If no argument index list is given to the @code{nonnull} attribute,
3507 all pointer arguments are marked as non-null. To illustrate, the
3508 following declaration is equivalent to the previous example:
3512 my_memcpy (void *dest, const void *src, size_t len)
3513 __attribute__((nonnull));
3517 @cindex @code{no_reorder} function or variable attribute
3518 Do not reorder functions or variables marked @code{no_reorder}
3519 against each other or top level assembler statements the executable.
3520 The actual order in the program will depend on the linker command
3521 line. Static variables marked like this are also not removed.
3522 This has a similar effect
3523 as the @option{-fno-toplevel-reorder} option, but only applies to the
3526 @item returns_nonnull
3527 @cindex @code{returns_nonnull} function attribute
3528 The @code{returns_nonnull} attribute specifies that the function
3529 return value should be a non-null pointer. For instance, the declaration:
3533 mymalloc (size_t len) __attribute__((returns_nonnull));
3537 lets the compiler optimize callers based on the knowledge
3538 that the return value will never be null.
3541 @cindex @code{noreturn} function attribute
3542 A few standard library functions, such as @code{abort} and @code{exit},
3543 cannot return. GCC knows this automatically. Some programs define
3544 their own functions that never return. You can declare them
3545 @code{noreturn} to tell the compiler this fact. For example,
3549 void fatal () __attribute__ ((noreturn));
3552 fatal (/* @r{@dots{}} */)
3554 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3560 The @code{noreturn} keyword tells the compiler to assume that
3561 @code{fatal} cannot return. It can then optimize without regard to what
3562 would happen if @code{fatal} ever did return. This makes slightly
3563 better code. More importantly, it helps avoid spurious warnings of
3564 uninitialized variables.
3566 The @code{noreturn} keyword does not affect the exceptional path when that
3567 applies: a @code{noreturn}-marked function may still return to the caller
3568 by throwing an exception or calling @code{longjmp}.
3570 Do not assume that registers saved by the calling function are
3571 restored before calling the @code{noreturn} function.
3573 It does not make sense for a @code{noreturn} function to have a return
3574 type other than @code{void}.
3576 The attribute @code{noreturn} is not implemented in GCC versions
3577 earlier than 2.5. An alternative way to declare that a function does
3578 not return, which works in the current version and in some older
3579 versions, is as follows:
3582 typedef void voidfn ();
3584 volatile voidfn fatal;
3588 This approach does not work in GNU C++.
3591 @cindex @code{nothrow} function attribute
3592 The @code{nothrow} attribute is used to inform the compiler that a
3593 function cannot throw an exception. For example, most functions in
3594 the standard C library can be guaranteed not to throw an exception
3595 with the notable exceptions of @code{qsort} and @code{bsearch} that
3596 take function pointer arguments. The @code{nothrow} attribute is not
3597 implemented in GCC versions earlier than 3.3.
3599 @item nosave_low_regs
3600 @cindex @code{nosave_low_regs} attribute
3601 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3602 function should not save and restore registers R0..R7. This can be used on SH3*
3603 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3607 @cindex @code{optimize} function attribute
3608 The @code{optimize} attribute is used to specify that a function is to
3609 be compiled with different optimization options than specified on the
3610 command line. Arguments can either be numbers or strings. Numbers
3611 are assumed to be an optimization level. Strings that begin with
3612 @code{O} are assumed to be an optimization option, while other options
3613 are assumed to be used with a @code{-f} prefix. You can also use the
3614 @samp{#pragma GCC optimize} pragma to set the optimization options
3615 that affect more than one function.
3616 @xref{Function Specific Option Pragmas}, for details about the
3617 @samp{#pragma GCC optimize} pragma.
3619 This can be used for instance to have frequently-executed functions
3620 compiled with more aggressive optimization options that produce faster
3621 and larger code, while other functions can be compiled with less
3624 @item OS_main/OS_task
3625 @cindex @code{OS_main} AVR function attribute
3626 @cindex @code{OS_task} AVR function attribute
3627 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3628 do not save/restore any call-saved register in their prologue/epilogue.
3630 The @code{OS_main} attribute can be used when there @emph{is
3631 guarantee} that interrupts are disabled at the time when the function
3632 is entered. This saves resources when the stack pointer has to be
3633 changed to set up a frame for local variables.
3635 The @code{OS_task} attribute can be used when there is @emph{no
3636 guarantee} that interrupts are disabled at that time when the function
3637 is entered like for, e@.g@. task functions in a multi-threading operating
3638 system. In that case, changing the stack pointer register is
3639 guarded by save/clear/restore of the global interrupt enable flag.
3641 The differences to the @code{naked} function attribute are:
3643 @item @code{naked} functions do not have a return instruction whereas
3644 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3645 @code{RETI} return instruction.
3646 @item @code{naked} functions do not set up a frame for local variables
3647 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3652 @cindex @code{pcs} function attribute
3654 The @code{pcs} attribute can be used to control the calling convention
3655 used for a function on ARM. The attribute takes an argument that specifies
3656 the calling convention to use.
3658 When compiling using the AAPCS ABI (or a variant of it) then valid
3659 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3660 order to use a variant other than @code{"aapcs"} then the compiler must
3661 be permitted to use the appropriate co-processor registers (i.e., the
3662 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3666 /* Argument passed in r0, and result returned in r0+r1. */
3667 double f2d (float) __attribute__((pcs("aapcs")));
3670 Variadic functions always use the @code{"aapcs"} calling convention and
3671 the compiler rejects attempts to specify an alternative.
3674 @cindex @code{pure} function attribute
3675 Many functions have no effects except the return value and their
3676 return value depends only on the parameters and/or global variables.
3677 Such a function can be subject
3678 to common subexpression elimination and loop optimization just as an
3679 arithmetic operator would be. These functions should be declared
3680 with the attribute @code{pure}. For example,
3683 int square (int) __attribute__ ((pure));
3687 says that the hypothetical function @code{square} is safe to call
3688 fewer times than the program says.
3690 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3691 Interesting non-pure functions are functions with infinite loops or those
3692 depending on volatile memory or other system resource, that may change between
3693 two consecutive calls (such as @code{feof} in a multithreading environment).
3695 The attribute @code{pure} is not implemented in GCC versions earlier
3699 @cindex @code{hot} function attribute
3700 The @code{hot} attribute on a function is used to inform the compiler that
3701 the function is a hot spot of the compiled program. The function is
3702 optimized more aggressively and on many targets it is placed into a special
3703 subsection of the text section so all hot functions appear close together,
3706 When profile feedback is available, via @option{-fprofile-use}, hot functions
3707 are automatically detected and this attribute is ignored.
3709 The @code{hot} attribute on functions is not implemented in GCC versions
3713 @cindex @code{cold} function attribute
3714 The @code{cold} attribute on functions is used to inform the compiler that
3715 the function is unlikely to be executed. The function is optimized for
3716 size rather than speed and on many targets it is placed into a special
3717 subsection of the text section so all cold functions appear close together,
3718 improving code locality of non-cold parts of program. The paths leading
3719 to calls of cold functions within code are marked as unlikely by the branch
3720 prediction mechanism. It is thus useful to mark functions used to handle
3721 unlikely conditions, such as @code{perror}, as cold to improve optimization
3722 of hot functions that do call marked functions in rare occasions.
3724 When profile feedback is available, via @option{-fprofile-use}, cold functions
3725 are automatically detected and this attribute is ignored.
3727 The @code{cold} attribute on functions is not implemented in GCC versions
3730 @item no_sanitize_address
3731 @itemx no_address_safety_analysis
3732 @cindex @code{no_sanitize_address} function attribute
3733 The @code{no_sanitize_address} attribute on functions is used
3734 to inform the compiler that it should not instrument memory accesses
3735 in the function when compiling with the @option{-fsanitize=address} option.
3736 The @code{no_address_safety_analysis} is a deprecated alias of the
3737 @code{no_sanitize_address} attribute, new code should use
3738 @code{no_sanitize_address}.
3740 @item no_sanitize_thread
3741 @cindex @code{no_sanitize_thread} function attribute
3742 The @code{no_sanitize_thread} attribute on functions is used
3743 to inform the compiler that it should not instrument memory accesses
3744 in the function when compiling with the @option{-fsanitize=thread} option.
3746 @item no_sanitize_undefined
3747 @cindex @code{no_sanitize_undefined} function attribute
3748 The @code{no_sanitize_undefined} attribute on functions is used
3749 to inform the compiler that it should not check for undefined behavior
3750 in the function when compiling with the @option{-fsanitize=undefined} option.
3753 @cindex @code{bnd_legacy} function attribute
3754 The @code{bnd_legacy} attribute on functions is used to inform
3755 compiler that function should not be instrumented when compiled
3756 with @option{-fcheck-pointer-bounds} option.
3758 @item bnd_instrument
3759 @cindex @code{bnd_instrument} function attribute
3760 The @code{bnd_instrument} attribute on functions is used to inform
3761 compiler that function should be instrumented when compiled
3762 with @option{-fchkp-instrument-marked-only} option.
3764 @item regparm (@var{number})
3765 @cindex @code{regparm} attribute
3766 @cindex functions that are passed arguments in registers on x86-32
3767 On x86-32 targets, the @code{regparm} attribute causes the compiler to
3768 pass arguments number one to @var{number} if they are of integral type
3769 in registers EAX, EDX, and ECX instead of on the stack. Functions that
3770 take a variable number of arguments continue to be passed all of their
3771 arguments on the stack.
3773 Beware that on some ELF systems this attribute is unsuitable for
3774 global functions in shared libraries with lazy binding (which is the
3775 default). Lazy binding sends the first call via resolving code in
3776 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3777 per the standard calling conventions. Solaris 8 is affected by this.
3778 Systems with the GNU C Library version 2.1 or higher
3779 and FreeBSD are believed to be
3780 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
3781 disabled with the linker or the loader if desired, to avoid the
3785 @cindex reset handler functions
3786 Use this attribute on the NDS32 target to indicate that the specified function
3787 is a reset handler. The compiler will generate corresponding sections
3788 for use in a reset handler. You can use the following attributes
3789 to provide extra exception handling:
3792 @cindex @code{nmi} attribute
3793 Provide a user-defined function to handle NMI exception.
3795 @cindex @code{warm} attribute
3796 Provide a user-defined function to handle warm reset exception.
3800 @cindex @code{sseregparm} attribute
3801 On x86-32 targets with SSE support, the @code{sseregparm} attribute
3802 causes the compiler to pass up to 3 floating-point arguments in
3803 SSE registers instead of on the stack. Functions that take a
3804 variable number of arguments continue to pass all of their
3805 floating-point arguments on the stack.
3807 @item force_align_arg_pointer
3808 @cindex @code{force_align_arg_pointer} attribute
3809 On x86 targets, the @code{force_align_arg_pointer} attribute may be
3810 applied to individual function definitions, generating an alternate
3811 prologue and epilogue that realigns the run-time stack if necessary.
3812 This supports mixing legacy codes that run with a 4-byte aligned stack
3813 with modern codes that keep a 16-byte stack for SSE compatibility.
3816 @cindex @code{renesas} attribute
3817 On SH targets this attribute specifies that the function or struct follows the
3821 @cindex @code{resbank} attribute
3822 On the SH2A target, this attribute enables the high-speed register
3823 saving and restoration using a register bank for @code{interrupt_handler}
3824 routines. Saving to the bank is performed automatically after the CPU
3825 accepts an interrupt that uses a register bank.
3827 The nineteen 32-bit registers comprising general register R0 to R14,
3828 control register GBR, and system registers MACH, MACL, and PR and the
3829 vector table address offset are saved into a register bank. Register
3830 banks are stacked in first-in last-out (FILO) sequence. Restoration
3831 from the bank is executed by issuing a RESBANK instruction.
3834 @cindex @code{returns_twice} attribute
3835 The @code{returns_twice} attribute tells the compiler that a function may
3836 return more than one time. The compiler ensures that all registers
3837 are dead before calling such a function and emits a warning about
3838 the variables that may be clobbered after the second return from the
3839 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3840 The @code{longjmp}-like counterpart of such function, if any, might need
3841 to be marked with the @code{noreturn} attribute.
3844 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3845 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3846 all registers except the stack pointer should be saved in the prologue
3847 regardless of whether they are used or not.
3849 @item save_volatiles
3850 @cindex save volatile registers on the MicroBlaze
3851 Use this attribute on the MicroBlaze to indicate that the function is
3852 an interrupt handler. All volatile registers (in addition to non-volatile
3853 registers) are saved in the function prologue. If the function is a leaf
3854 function, only volatiles used by the function are saved. A normal function
3855 return is generated instead of a return from interrupt.
3858 @cindex break handler functions
3859 Use this attribute on the MicroBlaze ports to indicate that
3860 the specified function is an break handler. The compiler generates function
3861 entry and exit sequences suitable for use in an break handler when this
3862 attribute is present. The return from @code{break_handler} is done through
3863 the @code{rtbd} instead of @code{rtsd}.
3866 void f () __attribute__ ((break_handler));
3869 @item section ("@var{section-name}")
3870 @cindex @code{section} function attribute
3871 Normally, the compiler places the code it generates in the @code{text} section.
3872 Sometimes, however, you need additional sections, or you need certain
3873 particular functions to appear in special sections. The @code{section}
3874 attribute specifies that a function lives in a particular section.
3875 For example, the declaration:
3878 extern void foobar (void) __attribute__ ((section ("bar")));
3882 puts the function @code{foobar} in the @code{bar} section.
3884 Some file formats do not support arbitrary sections so the @code{section}
3885 attribute is not available on all platforms.
3886 If you need to map the entire contents of a module to a particular
3887 section, consider using the facilities of the linker instead.
3890 @cindex @code{sentinel} function attribute
3891 This function attribute ensures that a parameter in a function call is
3892 an explicit @code{NULL}. The attribute is only valid on variadic
3893 functions. By default, the sentinel is located at position zero, the
3894 last parameter of the function call. If an optional integer position
3895 argument P is supplied to the attribute, the sentinel must be located at
3896 position P counting backwards from the end of the argument list.
3899 __attribute__ ((sentinel))
3901 __attribute__ ((sentinel(0)))
3904 The attribute is automatically set with a position of 0 for the built-in
3905 functions @code{execl} and @code{execlp}. The built-in function
3906 @code{execle} has the attribute set with a position of 1.
3908 A valid @code{NULL} in this context is defined as zero with any pointer
3909 type. If your system defines the @code{NULL} macro with an integer type
3910 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3911 with a copy that redefines NULL appropriately.
3913 The warnings for missing or incorrect sentinels are enabled with
3917 See @code{long_call/short_call}.
3920 See @code{longcall/shortcall}.
3923 @cindex interrupt handler functions on the AVR processors
3924 Use this attribute on the AVR to indicate that the specified
3925 function is an interrupt handler. The compiler generates function
3926 entry and exit sequences suitable for use in an interrupt handler when this
3927 attribute is present.
3929 See also the @code{interrupt} function attribute.
3931 The AVR hardware globally disables interrupts when an interrupt is executed.
3932 Interrupt handler functions defined with the @code{signal} attribute
3933 do not re-enable interrupts. It is save to enable interrupts in a
3934 @code{signal} handler. This ``save'' only applies to the code
3935 generated by the compiler and not to the IRQ layout of the
3936 application which is responsibility of the application.
3938 If both @code{signal} and @code{interrupt} are specified for the same
3939 function, @code{signal} is silently ignored.
3942 @cindex @code{sp_switch} attribute
3943 Use this attribute on the SH to indicate an @code{interrupt_handler}
3944 function should switch to an alternate stack. It expects a string
3945 argument that names a global variable holding the address of the
3950 void f () __attribute__ ((interrupt_handler,
3951 sp_switch ("alt_stack")));
3955 @cindex functions that pop the argument stack on x86-32
3956 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
3957 assume that the called function pops off the stack space used to
3958 pass arguments, unless it takes a variable number of arguments.
3960 @item syscall_linkage
3961 @cindex @code{syscall_linkage} attribute
3962 This attribute is used to modify the IA-64 calling convention by marking
3963 all input registers as live at all function exits. This makes it possible
3964 to restart a system call after an interrupt without having to save/restore
3965 the input registers. This also prevents kernel data from leaking into
3969 @cindex @code{target} function attribute
3970 The @code{target} attribute is used to specify that a function is to
3971 be compiled with different target options than specified on the
3972 command line. This can be used for instance to have functions
3973 compiled with a different ISA (instruction set architecture) than the
3974 default. You can also use the @samp{#pragma GCC target} pragma to set
3975 more than one function to be compiled with specific target options.
3976 @xref{Function Specific Option Pragmas}, for details about the
3977 @samp{#pragma GCC target} pragma.
3979 For instance on an x86, you could compile one function with
3980 @code{target("sse4.1,arch=core2")} and another with
3981 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3982 compiling the first function with @option{-msse4.1} and
3983 @option{-march=core2} options, and the second function with
3984 @option{-msse4a} and @option{-march=amdfam10} options. It is up to the
3985 user to make sure that a function is only invoked on a machine that
3986 supports the particular ISA it is compiled for (for example by using
3987 @code{cpuid} on x86 to determine what feature bits and architecture
3991 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3992 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3995 You can either use multiple
3996 strings to specify multiple options, or separate the options
3997 with a comma (@samp{,}).
3999 The @code{target} attribute is presently implemented for
4000 x86, PowerPC, and Nios II targets only.
4001 The options supported are specific to each target.
4003 On the x86, the following options are allowed:
4008 @cindex @code{target("abm")} attribute
4009 Enable/disable the generation of the advanced bit instructions.
4013 @cindex @code{target("aes")} attribute
4014 Enable/disable the generation of the AES instructions.
4017 @cindex @code{target("default")} attribute
4018 @xref{Function Multiversioning}, where it is used to specify the
4019 default function version.
4023 @cindex @code{target("mmx")} attribute
4024 Enable/disable the generation of the MMX instructions.
4028 @cindex @code{target("pclmul")} attribute
4029 Enable/disable the generation of the PCLMUL instructions.
4033 @cindex @code{target("popcnt")} attribute
4034 Enable/disable the generation of the POPCNT instruction.
4038 @cindex @code{target("sse")} attribute
4039 Enable/disable the generation of the SSE instructions.
4043 @cindex @code{target("sse2")} attribute
4044 Enable/disable the generation of the SSE2 instructions.
4048 @cindex @code{target("sse3")} attribute
4049 Enable/disable the generation of the SSE3 instructions.
4053 @cindex @code{target("sse4")} attribute
4054 Enable/disable the generation of the SSE4 instructions (both SSE4.1
4059 @cindex @code{target("sse4.1")} attribute
4060 Enable/disable the generation of the sse4.1 instructions.
4064 @cindex @code{target("sse4.2")} attribute
4065 Enable/disable the generation of the sse4.2 instructions.
4069 @cindex @code{target("sse4a")} attribute
4070 Enable/disable the generation of the SSE4A instructions.
4074 @cindex @code{target("fma4")} attribute
4075 Enable/disable the generation of the FMA4 instructions.
4079 @cindex @code{target("xop")} attribute
4080 Enable/disable the generation of the XOP instructions.
4084 @cindex @code{target("lwp")} attribute
4085 Enable/disable the generation of the LWP instructions.
4089 @cindex @code{target("ssse3")} attribute
4090 Enable/disable the generation of the SSSE3 instructions.
4094 @cindex @code{target("cld")} attribute
4095 Enable/disable the generation of the CLD before string moves.
4097 @item fancy-math-387
4098 @itemx no-fancy-math-387
4099 @cindex @code{target("fancy-math-387")} attribute
4100 Enable/disable the generation of the @code{sin}, @code{cos}, and
4101 @code{sqrt} instructions on the 387 floating-point unit.
4104 @itemx no-fused-madd
4105 @cindex @code{target("fused-madd")} attribute
4106 Enable/disable the generation of the fused multiply/add instructions.
4110 @cindex @code{target("ieee-fp")} attribute
4111 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4113 @item inline-all-stringops
4114 @itemx no-inline-all-stringops
4115 @cindex @code{target("inline-all-stringops")} attribute
4116 Enable/disable inlining of string operations.
4118 @item inline-stringops-dynamically
4119 @itemx no-inline-stringops-dynamically
4120 @cindex @code{target("inline-stringops-dynamically")} attribute
4121 Enable/disable the generation of the inline code to do small string
4122 operations and calling the library routines for large operations.
4124 @item align-stringops
4125 @itemx no-align-stringops
4126 @cindex @code{target("align-stringops")} attribute
4127 Do/do not align destination of inlined string operations.
4131 @cindex @code{target("recip")} attribute
4132 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4133 instructions followed an additional Newton-Raphson step instead of
4134 doing a floating-point division.
4136 @item arch=@var{ARCH}
4137 @cindex @code{target("arch=@var{ARCH}")} attribute
4138 Specify the architecture to generate code for in compiling the function.
4140 @item tune=@var{TUNE}
4141 @cindex @code{target("tune=@var{TUNE}")} attribute
4142 Specify the architecture to tune for in compiling the function.
4144 @item fpmath=@var{FPMATH}
4145 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
4146 Specify which floating-point unit to use. The
4147 @code{target("fpmath=sse,387")} option must be specified as
4148 @code{target("fpmath=sse+387")} because the comma would separate
4152 On the PowerPC, the following options are allowed:
4157 @cindex @code{target("altivec")} attribute
4158 Generate code that uses (does not use) AltiVec instructions. In
4159 32-bit code, you cannot enable AltiVec instructions unless
4160 @option{-mabi=altivec} is used on the command line.
4164 @cindex @code{target("cmpb")} attribute
4165 Generate code that uses (does not use) the compare bytes instruction
4166 implemented on the POWER6 processor and other processors that support
4167 the PowerPC V2.05 architecture.
4171 @cindex @code{target("dlmzb")} attribute
4172 Generate code that uses (does not use) the string-search @samp{dlmzb}
4173 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4174 generated by default when targeting those processors.
4178 @cindex @code{target("fprnd")} attribute
4179 Generate code that uses (does not use) the FP round to integer
4180 instructions implemented on the POWER5+ processor and other processors
4181 that support the PowerPC V2.03 architecture.
4185 @cindex @code{target("hard-dfp")} attribute
4186 Generate code that uses (does not use) the decimal floating-point
4187 instructions implemented on some POWER processors.
4191 @cindex @code{target("isel")} attribute
4192 Generate code that uses (does not use) ISEL instruction.
4196 @cindex @code{target("mfcrf")} attribute
4197 Generate code that uses (does not use) the move from condition
4198 register field instruction implemented on the POWER4 processor and
4199 other processors that support the PowerPC V2.01 architecture.
4203 @cindex @code{target("mfpgpr")} attribute
4204 Generate code that uses (does not use) the FP move to/from general
4205 purpose register instructions implemented on the POWER6X processor and
4206 other processors that support the extended PowerPC V2.05 architecture.
4210 @cindex @code{target("mulhw")} attribute
4211 Generate code that uses (does not use) the half-word multiply and
4212 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4213 These instructions are generated by default when targeting those
4218 @cindex @code{target("multiple")} attribute
4219 Generate code that uses (does not use) the load multiple word
4220 instructions and the store multiple word instructions.
4224 @cindex @code{target("update")} attribute
4225 Generate code that uses (does not use) the load or store instructions
4226 that update the base register to the address of the calculated memory
4231 @cindex @code{target("popcntb")} attribute
4232 Generate code that uses (does not use) the popcount and double-precision
4233 FP reciprocal estimate instruction implemented on the POWER5
4234 processor and other processors that support the PowerPC V2.02
4239 @cindex @code{target("popcntd")} attribute
4240 Generate code that uses (does not use) the popcount instruction
4241 implemented on the POWER7 processor and other processors that support
4242 the PowerPC V2.06 architecture.
4244 @item powerpc-gfxopt
4245 @itemx no-powerpc-gfxopt
4246 @cindex @code{target("powerpc-gfxopt")} attribute
4247 Generate code that uses (does not use) the optional PowerPC
4248 architecture instructions in the Graphics group, including
4249 floating-point select.
4252 @itemx no-powerpc-gpopt
4253 @cindex @code{target("powerpc-gpopt")} attribute
4254 Generate code that uses (does not use) the optional PowerPC
4255 architecture instructions in the General Purpose group, including
4256 floating-point square root.
4258 @item recip-precision
4259 @itemx no-recip-precision
4260 @cindex @code{target("recip-precision")} attribute
4261 Assume (do not assume) that the reciprocal estimate instructions
4262 provide higher-precision estimates than is mandated by the powerpc
4267 @cindex @code{target("string")} attribute
4268 Generate code that uses (does not use) the load string instructions
4269 and the store string word instructions to save multiple registers and
4270 do small block moves.
4274 @cindex @code{target("vsx")} attribute
4275 Generate code that uses (does not use) vector/scalar (VSX)
4276 instructions, and also enable the use of built-in functions that allow
4277 more direct access to the VSX instruction set. In 32-bit code, you
4278 cannot enable VSX or AltiVec instructions unless
4279 @option{-mabi=altivec} is used on the command line.
4283 @cindex @code{target("friz")} attribute
4284 Generate (do not generate) the @code{friz} instruction when the
4285 @option{-funsafe-math-optimizations} option is used to optimize
4286 rounding a floating-point value to 64-bit integer and back to floating
4287 point. The @code{friz} instruction does not return the same value if
4288 the floating-point number is too large to fit in an integer.
4290 @item avoid-indexed-addresses
4291 @itemx no-avoid-indexed-addresses
4292 @cindex @code{target("avoid-indexed-addresses")} attribute
4293 Generate code that tries to avoid (not avoid) the use of indexed load
4294 or store instructions.
4298 @cindex @code{target("paired")} attribute
4299 Generate code that uses (does not use) the generation of PAIRED simd
4304 @cindex @code{target("longcall")} attribute
4305 Generate code that assumes (does not assume) that all calls are far
4306 away so that a longer more expensive calling sequence is required.
4309 @cindex @code{target("cpu=@var{CPU}")} attribute
4310 Specify the architecture to generate code for when compiling the
4311 function. If you select the @code{target("cpu=power7")} attribute when
4312 generating 32-bit code, VSX and AltiVec instructions are not generated
4313 unless you use the @option{-mabi=altivec} option on the command line.
4315 @item tune=@var{TUNE}
4316 @cindex @code{target("tune=@var{TUNE}")} attribute
4317 Specify the architecture to tune for when compiling the function. If
4318 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4319 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4320 compilation tunes for the @var{CPU} architecture, and not the
4321 default tuning specified on the command line.
4324 When compiling for Nios II, the following options are allowed:
4327 @item custom-@var{insn}=@var{N}
4328 @itemx no-custom-@var{insn}
4329 @cindex @code{target("custom-@var{insn}=@var{N}")} attribute
4330 @cindex @code{target("no-custom-@var{insn}")} attribute
4331 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4332 custom instruction with encoding @var{N} when generating code that uses
4333 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4334 the custom instruction @var{insn}.
4335 These target attributes correspond to the
4336 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4337 command-line options, and support the same set of @var{insn} keywords.
4338 @xref{Nios II Options}, for more information.
4340 @item custom-fpu-cfg=@var{name}
4341 @cindex @code{target("custom-fpu-cfg=@var{name}")} attribute
4342 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4343 command-line option, to select a predefined set of custom instructions
4345 @xref{Nios II Options}, for more information.
4348 On the x86 and PowerPC back ends, the inliner does not inline a
4349 function that has different target options than the caller, unless the
4350 callee has a subset of the target options of the caller. For example
4351 a function declared with @code{target("sse3")} can inline a function
4352 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4355 @cindex tiny data section on the H8/300H and H8S
4356 Use this attribute on the H8/300H and H8S to indicate that the specified
4357 variable should be placed into the tiny data section.
4358 The compiler generates more efficient code for loads and stores
4359 on data in the tiny data section. Note the tiny data area is limited to
4360 slightly under 32KB of data.
4363 @cindex @code{trap_exit} attribute
4364 Use this attribute on the SH for an @code{interrupt_handler} to return using
4365 @code{trapa} instead of @code{rte}. This attribute expects an integer
4366 argument specifying the trap number to be used.
4369 @cindex @code{trapa_handler} attribute
4370 On SH targets this function attribute is similar to @code{interrupt_handler}
4371 but it does not save and restore all registers.
4374 @cindex @code{unused} attribute.
4375 This attribute, attached to a function, means that the function is meant
4376 to be possibly unused. GCC does not produce a warning for this
4380 @cindex @code{used} attribute.
4381 This attribute, attached to a function, means that code must be emitted
4382 for the function even if it appears that the function is not referenced.
4383 This is useful, for example, when the function is referenced only in
4386 When applied to a member function of a C++ class template, the
4387 attribute also means that the function is instantiated if the
4388 class itself is instantiated.
4391 @cindex @code{vector} attribute
4392 This RX attribute is similar to the @code{interrupt} attribute, including its
4393 parameters, but does not make the function an interrupt-handler type
4394 function (i.e. it retains the normal C function calling ABI). See the
4395 @code{interrupt} attribute for a description of its arguments.
4398 @cindex @code{version_id} attribute
4399 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4400 symbol to contain a version string, thus allowing for function level
4401 versioning. HP-UX system header files may use function level versioning
4402 for some system calls.
4405 extern int foo () __attribute__((version_id ("20040821")));
4409 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4411 @item visibility ("@var{visibility_type}")
4412 @cindex @code{visibility} attribute
4413 This attribute affects the linkage of the declaration to which it is attached.
4414 There are four supported @var{visibility_type} values: default,
4415 hidden, protected or internal visibility.
4418 void __attribute__ ((visibility ("protected")))
4419 f () @{ /* @r{Do something.} */; @}
4420 int i __attribute__ ((visibility ("hidden")));
4423 The possible values of @var{visibility_type} correspond to the
4424 visibility settings in the ELF gABI.
4427 @c keep this list of visibilities in alphabetical order.
4430 Default visibility is the normal case for the object file format.
4431 This value is available for the visibility attribute to override other
4432 options that may change the assumed visibility of entities.
4434 On ELF, default visibility means that the declaration is visible to other
4435 modules and, in shared libraries, means that the declared entity may be
4438 On Darwin, default visibility means that the declaration is visible to
4441 Default visibility corresponds to ``external linkage'' in the language.
4444 Hidden visibility indicates that the entity declared has a new
4445 form of linkage, which we call ``hidden linkage''. Two
4446 declarations of an object with hidden linkage refer to the same object
4447 if they are in the same shared object.
4450 Internal visibility is like hidden visibility, but with additional
4451 processor specific semantics. Unless otherwise specified by the
4452 psABI, GCC defines internal visibility to mean that a function is
4453 @emph{never} called from another module. Compare this with hidden
4454 functions which, while they cannot be referenced directly by other
4455 modules, can be referenced indirectly via function pointers. By
4456 indicating that a function cannot be called from outside the module,
4457 GCC may for instance omit the load of a PIC register since it is known
4458 that the calling function loaded the correct value.
4461 Protected visibility is like default visibility except that it
4462 indicates that references within the defining module bind to the
4463 definition in that module. That is, the declared entity cannot be
4464 overridden by another module.
4468 All visibilities are supported on many, but not all, ELF targets
4469 (supported when the assembler supports the @samp{.visibility}
4470 pseudo-op). Default visibility is supported everywhere. Hidden
4471 visibility is supported on Darwin targets.
4473 The visibility attribute should be applied only to declarations that
4474 would otherwise have external linkage. The attribute should be applied
4475 consistently, so that the same entity should not be declared with
4476 different settings of the attribute.
4478 In C++, the visibility attribute applies to types as well as functions
4479 and objects, because in C++ types have linkage. A class must not have
4480 greater visibility than its non-static data member types and bases,
4481 and class members default to the visibility of their class. Also, a
4482 declaration without explicit visibility is limited to the visibility
4485 In C++, you can mark member functions and static member variables of a
4486 class with the visibility attribute. This is useful if you know a
4487 particular method or static member variable should only be used from
4488 one shared object; then you can mark it hidden while the rest of the
4489 class has default visibility. Care must be taken to avoid breaking
4490 the One Definition Rule; for example, it is usually not useful to mark
4491 an inline method as hidden without marking the whole class as hidden.
4493 A C++ namespace declaration can also have the visibility attribute.
4496 namespace nspace1 __attribute__ ((visibility ("protected")))
4497 @{ /* @r{Do something.} */; @}
4500 This attribute applies only to the particular namespace body, not to
4501 other definitions of the same namespace; it is equivalent to using
4502 @samp{#pragma GCC visibility} before and after the namespace
4503 definition (@pxref{Visibility Pragmas}).
4505 In C++, if a template argument has limited visibility, this
4506 restriction is implicitly propagated to the template instantiation.
4507 Otherwise, template instantiations and specializations default to the
4508 visibility of their template.
4510 If both the template and enclosing class have explicit visibility, the
4511 visibility from the template is used.
4514 @cindex @code{vliw} attribute
4515 On MeP, the @code{vliw} attribute tells the compiler to emit
4516 instructions in VLIW mode instead of core mode. Note that this
4517 attribute is not allowed unless a VLIW coprocessor has been configured
4518 and enabled through command-line options.
4520 @item warn_unused_result
4521 @cindex @code{warn_unused_result} attribute
4522 The @code{warn_unused_result} attribute causes a warning to be emitted
4523 if a caller of the function with this attribute does not use its
4524 return value. This is useful for functions where not checking
4525 the result is either a security problem or always a bug, such as
4529 int fn () __attribute__ ((warn_unused_result));
4532 if (fn () < 0) return -1;
4539 results in warning on line 5.
4542 @cindex @code{weak} attribute
4543 The @code{weak} attribute causes the declaration to be emitted as a weak
4544 symbol rather than a global. This is primarily useful in defining
4545 library functions that can be overridden in user code, though it can
4546 also be used with non-function declarations. Weak symbols are supported
4547 for ELF targets, and also for a.out targets when using the GNU assembler
4551 @itemx weakref ("@var{target}")
4552 @cindex @code{weakref} attribute
4553 The @code{weakref} attribute marks a declaration as a weak reference.
4554 Without arguments, it should be accompanied by an @code{alias} attribute
4555 naming the target symbol. Optionally, the @var{target} may be given as
4556 an argument to @code{weakref} itself. In either case, @code{weakref}
4557 implicitly marks the declaration as @code{weak}. Without a
4558 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4559 @code{weakref} is equivalent to @code{weak}.
4562 static int x() __attribute__ ((weakref ("y")));
4563 /* is equivalent to... */
4564 static int x() __attribute__ ((weak, weakref, alias ("y")));
4566 static int x() __attribute__ ((weakref));
4567 static int x() __attribute__ ((alias ("y")));
4570 A weak reference is an alias that does not by itself require a
4571 definition to be given for the target symbol. If the target symbol is
4572 only referenced through weak references, then it becomes a @code{weak}
4573 undefined symbol. If it is directly referenced, however, then such
4574 strong references prevail, and a definition is required for the
4575 symbol, not necessarily in the same translation unit.
4577 The effect is equivalent to moving all references to the alias to a
4578 separate translation unit, renaming the alias to the aliased symbol,
4579 declaring it as weak, compiling the two separate translation units and
4580 performing a reloadable link on them.
4582 At present, a declaration to which @code{weakref} is attached can
4583 only be @code{static}.
4587 You can specify multiple attributes in a declaration by separating them
4588 by commas within the double parentheses or by immediately following an
4589 attribute declaration with another attribute declaration.
4591 @cindex @code{#pragma}, reason for not using
4592 @cindex pragma, reason for not using
4593 Some people object to the @code{__attribute__} feature, suggesting that
4594 ISO C's @code{#pragma} should be used instead. At the time
4595 @code{__attribute__} was designed, there were two reasons for not doing
4600 It is impossible to generate @code{#pragma} commands from a macro.
4603 There is no telling what the same @code{#pragma} might mean in another
4607 These two reasons applied to almost any application that might have been
4608 proposed for @code{#pragma}. It was basically a mistake to use
4609 @code{#pragma} for @emph{anything}.
4611 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4612 to be generated from macros. In addition, a @code{#pragma GCC}
4613 namespace is now in use for GCC-specific pragmas. However, it has been
4614 found convenient to use @code{__attribute__} to achieve a natural
4615 attachment of attributes to their corresponding declarations, whereas
4616 @code{#pragma GCC} is of use for constructs that do not naturally form
4617 part of the grammar. @xref{Pragmas,,Pragmas Accepted by GCC}.
4619 @node Label Attributes
4620 @section Label Attributes
4621 @cindex Label Attributes
4623 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
4624 details of the exact syntax for using attributes. Other attributes are
4625 available for functions (@pxref{Function Attributes}), variables
4626 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
4628 This example uses the @code{cold} label attribute to indicate the
4629 @code{ErrorHandling} branch is unlikely to be taken and that the
4630 @code{ErrorHandling} label is unused:
4634 asm goto ("some asm" : : : : NoError);
4636 /* This branch (the fallthru from the asm) is less commonly used */
4638 __attribute__((cold, unused)); /* Semi-colon is required here */
4643 printf("no error\n");
4649 @cindex @code{unused} label attribute
4650 This feature is intended for program-generated code that may contain
4651 unused labels, but which is compiled with @option{-Wall}. It is
4652 not normally appropriate to use in it human-written code, though it
4653 could be useful in cases where the code that jumps to the label is
4654 contained within an @code{#ifdef} conditional.
4657 @cindex @code{hot} label attribute
4658 The @code{hot} attribute on a label is used to inform the compiler that
4659 the path following the label is more likely than paths that are not so
4660 annotated. This attribute is used in cases where @code{__builtin_expect}
4661 cannot be used, for instance with computed goto or @code{asm goto}.
4663 The @code{hot} attribute on labels is not implemented in GCC versions
4667 @cindex @code{cold} label attribute
4668 The @code{cold} attribute on labels is used to inform the compiler that
4669 the path following the label is unlikely to be executed. This attribute
4670 is used in cases where @code{__builtin_expect} cannot be used, for instance
4671 with computed goto or @code{asm goto}.
4673 The @code{cold} attribute on labels is not implemented in GCC versions
4678 @node Attribute Syntax
4679 @section Attribute Syntax
4680 @cindex attribute syntax
4682 This section describes the syntax with which @code{__attribute__} may be
4683 used, and the constructs to which attribute specifiers bind, for the C
4684 language. Some details may vary for C++ and Objective-C@. Because of
4685 infelicities in the grammar for attributes, some forms described here
4686 may not be successfully parsed in all cases.
4688 There are some problems with the semantics of attributes in C++. For
4689 example, there are no manglings for attributes, although they may affect
4690 code generation, so problems may arise when attributed types are used in
4691 conjunction with templates or overloading. Similarly, @code{typeid}
4692 does not distinguish between types with different attributes. Support
4693 for attributes in C++ may be restricted in future to attributes on
4694 declarations only, but not on nested declarators.
4696 @xref{Function Attributes}, for details of the semantics of attributes
4697 applying to functions. @xref{Variable Attributes}, for details of the
4698 semantics of attributes applying to variables. @xref{Type Attributes},
4699 for details of the semantics of attributes applying to structure, union
4700 and enumerated types.
4701 @xref{Label Attributes}, for details of the semantics of attributes
4704 An @dfn{attribute specifier} is of the form
4705 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
4706 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4707 each attribute is one of the following:
4711 Empty. Empty attributes are ignored.
4714 A word (which may be an identifier such as @code{unused}, or a reserved
4715 word such as @code{const}).
4718 A word, followed by, in parentheses, parameters for the attribute.
4719 These parameters take one of the following forms:
4723 An identifier. For example, @code{mode} attributes use this form.
4726 An identifier followed by a comma and a non-empty comma-separated list
4727 of expressions. For example, @code{format} attributes use this form.
4730 A possibly empty comma-separated list of expressions. For example,
4731 @code{format_arg} attributes use this form with the list being a single
4732 integer constant expression, and @code{alias} attributes use this form
4733 with the list being a single string constant.
4737 An @dfn{attribute specifier list} is a sequence of one or more attribute
4738 specifiers, not separated by any other tokens.
4740 @subsubheading Label Attributes
4742 In GNU C, an attribute specifier list may appear after the colon following a
4743 label, other than a @code{case} or @code{default} label. GNU C++ only permits
4744 attributes on labels if the attribute specifier is immediately
4745 followed by a semicolon (i.e., the label applies to an empty
4746 statement). If the semicolon is missing, C++ label attributes are
4747 ambiguous, as it is permissible for a declaration, which could begin
4748 with an attribute list, to be labelled in C++. Declarations cannot be
4749 labelled in C90 or C99, so the ambiguity does not arise there.
4751 @subsubheading Type Attributes
4753 An attribute specifier list may appear as part of a @code{struct},
4754 @code{union} or @code{enum} specifier. It may go either immediately
4755 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4756 the closing brace. The former syntax is preferred.
4757 Where attribute specifiers follow the closing brace, they are considered
4758 to relate to the structure, union or enumerated type defined, not to any
4759 enclosing declaration the type specifier appears in, and the type
4760 defined is not complete until after the attribute specifiers.
4761 @c Otherwise, there would be the following problems: a shift/reduce
4762 @c conflict between attributes binding the struct/union/enum and
4763 @c binding to the list of specifiers/qualifiers; and "aligned"
4764 @c attributes could use sizeof for the structure, but the size could be
4765 @c changed later by "packed" attributes.
4768 @subsubheading All other attributes
4770 Otherwise, an attribute specifier appears as part of a declaration,
4771 counting declarations of unnamed parameters and type names, and relates
4772 to that declaration (which may be nested in another declaration, for
4773 example in the case of a parameter declaration), or to a particular declarator
4774 within a declaration. Where an
4775 attribute specifier is applied to a parameter declared as a function or
4776 an array, it should apply to the function or array rather than the
4777 pointer to which the parameter is implicitly converted, but this is not
4778 yet correctly implemented.
4780 Any list of specifiers and qualifiers at the start of a declaration may
4781 contain attribute specifiers, whether or not such a list may in that
4782 context contain storage class specifiers. (Some attributes, however,
4783 are essentially in the nature of storage class specifiers, and only make
4784 sense where storage class specifiers may be used; for example,
4785 @code{section}.) There is one necessary limitation to this syntax: the
4786 first old-style parameter declaration in a function definition cannot
4787 begin with an attribute specifier, because such an attribute applies to
4788 the function instead by syntax described below (which, however, is not
4789 yet implemented in this case). In some other cases, attribute
4790 specifiers are permitted by this grammar but not yet supported by the
4791 compiler. All attribute specifiers in this place relate to the
4792 declaration as a whole. In the obsolescent usage where a type of
4793 @code{int} is implied by the absence of type specifiers, such a list of
4794 specifiers and qualifiers may be an attribute specifier list with no
4795 other specifiers or qualifiers.
4797 At present, the first parameter in a function prototype must have some
4798 type specifier that is not an attribute specifier; this resolves an
4799 ambiguity in the interpretation of @code{void f(int
4800 (__attribute__((foo)) x))}, but is subject to change. At present, if
4801 the parentheses of a function declarator contain only attributes then
4802 those attributes are ignored, rather than yielding an error or warning
4803 or implying a single parameter of type int, but this is subject to
4806 An attribute specifier list may appear immediately before a declarator
4807 (other than the first) in a comma-separated list of declarators in a
4808 declaration of more than one identifier using a single list of
4809 specifiers and qualifiers. Such attribute specifiers apply
4810 only to the identifier before whose declarator they appear. For
4814 __attribute__((noreturn)) void d0 (void),
4815 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4820 the @code{noreturn} attribute applies to all the functions
4821 declared; the @code{format} attribute only applies to @code{d1}.
4823 An attribute specifier list may appear immediately before the comma,
4824 @code{=} or semicolon terminating the declaration of an identifier other
4825 than a function definition. Such attribute specifiers apply
4826 to the declared object or function. Where an
4827 assembler name for an object or function is specified (@pxref{Asm
4828 Labels}), the attribute must follow the @code{asm}
4831 An attribute specifier list may, in future, be permitted to appear after
4832 the declarator in a function definition (before any old-style parameter
4833 declarations or the function body).
4835 Attribute specifiers may be mixed with type qualifiers appearing inside
4836 the @code{[]} of a parameter array declarator, in the C99 construct by
4837 which such qualifiers are applied to the pointer to which the array is
4838 implicitly converted. Such attribute specifiers apply to the pointer,
4839 not to the array, but at present this is not implemented and they are
4842 An attribute specifier list may appear at the start of a nested
4843 declarator. At present, there are some limitations in this usage: the
4844 attributes correctly apply to the declarator, but for most individual
4845 attributes the semantics this implies are not implemented.
4846 When attribute specifiers follow the @code{*} of a pointer
4847 declarator, they may be mixed with any type qualifiers present.
4848 The following describes the formal semantics of this syntax. It makes the
4849 most sense if you are familiar with the formal specification of
4850 declarators in the ISO C standard.
4852 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4853 D1}, where @code{T} contains declaration specifiers that specify a type
4854 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4855 contains an identifier @var{ident}. The type specified for @var{ident}
4856 for derived declarators whose type does not include an attribute
4857 specifier is as in the ISO C standard.
4859 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4860 and the declaration @code{T D} specifies the type
4861 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4862 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4863 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4865 If @code{D1} has the form @code{*
4866 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4867 declaration @code{T D} specifies the type
4868 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4869 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4870 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4876 void (__attribute__((noreturn)) ****f) (void);
4880 specifies the type ``pointer to pointer to pointer to pointer to
4881 non-returning function returning @code{void}''. As another example,
4884 char *__attribute__((aligned(8))) *f;
4888 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4889 Note again that this does not work with most attributes; for example,
4890 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4891 is not yet supported.
4893 For compatibility with existing code written for compiler versions that
4894 did not implement attributes on nested declarators, some laxity is
4895 allowed in the placing of attributes. If an attribute that only applies
4896 to types is applied to a declaration, it is treated as applying to
4897 the type of that declaration. If an attribute that only applies to
4898 declarations is applied to the type of a declaration, it is treated
4899 as applying to that declaration; and, for compatibility with code
4900 placing the attributes immediately before the identifier declared, such
4901 an attribute applied to a function return type is treated as
4902 applying to the function type, and such an attribute applied to an array
4903 element type is treated as applying to the array type. If an
4904 attribute that only applies to function types is applied to a
4905 pointer-to-function type, it is treated as applying to the pointer
4906 target type; if such an attribute is applied to a function return type
4907 that is not a pointer-to-function type, it is treated as applying
4908 to the function type.
4910 @node Function Prototypes
4911 @section Prototypes and Old-Style Function Definitions
4912 @cindex function prototype declarations
4913 @cindex old-style function definitions
4914 @cindex promotion of formal parameters
4916 GNU C extends ISO C to allow a function prototype to override a later
4917 old-style non-prototype definition. Consider the following example:
4920 /* @r{Use prototypes unless the compiler is old-fashioned.} */
4927 /* @r{Prototype function declaration.} */
4928 int isroot P((uid_t));
4930 /* @r{Old-style function definition.} */
4932 isroot (x) /* @r{??? lossage here ???} */
4939 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
4940 not allow this example, because subword arguments in old-style
4941 non-prototype definitions are promoted. Therefore in this example the
4942 function definition's argument is really an @code{int}, which does not
4943 match the prototype argument type of @code{short}.
4945 This restriction of ISO C makes it hard to write code that is portable
4946 to traditional C compilers, because the programmer does not know
4947 whether the @code{uid_t} type is @code{short}, @code{int}, or
4948 @code{long}. Therefore, in cases like these GNU C allows a prototype
4949 to override a later old-style definition. More precisely, in GNU C, a
4950 function prototype argument type overrides the argument type specified
4951 by a later old-style definition if the former type is the same as the
4952 latter type before promotion. Thus in GNU C the above example is
4953 equivalent to the following:
4966 GNU C++ does not support old-style function definitions, so this
4967 extension is irrelevant.
4970 @section C++ Style Comments
4972 @cindex C++ comments
4973 @cindex comments, C++ style
4975 In GNU C, you may use C++ style comments, which start with @samp{//} and
4976 continue until the end of the line. Many other C implementations allow
4977 such comments, and they are included in the 1999 C standard. However,
4978 C++ style comments are not recognized if you specify an @option{-std}
4979 option specifying a version of ISO C before C99, or @option{-ansi}
4980 (equivalent to @option{-std=c90}).
4983 @section Dollar Signs in Identifier Names
4985 @cindex dollar signs in identifier names
4986 @cindex identifier names, dollar signs in
4988 In GNU C, you may normally use dollar signs in identifier names.
4989 This is because many traditional C implementations allow such identifiers.
4990 However, dollar signs in identifiers are not supported on a few target
4991 machines, typically because the target assembler does not allow them.
4993 @node Character Escapes
4994 @section The Character @key{ESC} in Constants
4996 You can use the sequence @samp{\e} in a string or character constant to
4997 stand for the ASCII character @key{ESC}.
4999 @node Variable Attributes
5000 @section Specifying Attributes of Variables
5001 @cindex attribute of variables
5002 @cindex variable attributes
5004 The keyword @code{__attribute__} allows you to specify special
5005 attributes of variables or structure fields. This keyword is followed
5006 by an attribute specification inside double parentheses. Some
5007 attributes are currently defined generically for variables.
5008 Other attributes are defined for variables on particular target
5009 systems. Other attributes are available for functions
5010 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for
5011 types (@pxref{Type Attributes}).
5012 Other front ends might define more attributes
5013 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5015 You may also specify attributes with @samp{__} preceding and following
5016 each keyword. This allows you to use them in header files without
5017 being concerned about a possible macro of the same name. For example,
5018 you may use @code{__aligned__} instead of @code{aligned}.
5020 @xref{Attribute Syntax}, for details of the exact syntax for using
5024 @cindex @code{aligned} attribute
5025 @item aligned (@var{alignment})
5026 This attribute specifies a minimum alignment for the variable or
5027 structure field, measured in bytes. For example, the declaration:
5030 int x __attribute__ ((aligned (16))) = 0;
5034 causes the compiler to allocate the global variable @code{x} on a
5035 16-byte boundary. On a 68040, this could be used in conjunction with
5036 an @code{asm} expression to access the @code{move16} instruction which
5037 requires 16-byte aligned operands.
5039 You can also specify the alignment of structure fields. For example, to
5040 create a double-word aligned @code{int} pair, you could write:
5043 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5047 This is an alternative to creating a union with a @code{double} member,
5048 which forces the union to be double-word aligned.
5050 As in the preceding examples, you can explicitly specify the alignment
5051 (in bytes) that you wish the compiler to use for a given variable or
5052 structure field. Alternatively, you can leave out the alignment factor
5053 and just ask the compiler to align a variable or field to the
5054 default alignment for the target architecture you are compiling for.
5055 The default alignment is sufficient for all scalar types, but may not be
5056 enough for all vector types on a target that supports vector operations.
5057 The default alignment is fixed for a particular target ABI.
5059 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5060 which is the largest alignment ever used for any data type on the
5061 target machine you are compiling for. For example, you could write:
5064 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5067 The compiler automatically sets the alignment for the declared
5068 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5069 often make copy operations more efficient, because the compiler can
5070 use whatever instructions copy the biggest chunks of memory when
5071 performing copies to or from the variables or fields that you have
5072 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5073 may change depending on command-line options.
5075 When used on a struct, or struct member, the @code{aligned} attribute can
5076 only increase the alignment; in order to decrease it, the @code{packed}
5077 attribute must be specified as well. When used as part of a typedef, the
5078 @code{aligned} attribute can both increase and decrease alignment, and
5079 specifying the @code{packed} attribute generates a warning.
5081 Note that the effectiveness of @code{aligned} attributes may be limited
5082 by inherent limitations in your linker. On many systems, the linker is
5083 only able to arrange for variables to be aligned up to a certain maximum
5084 alignment. (For some linkers, the maximum supported alignment may
5085 be very very small.) If your linker is only able to align variables
5086 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5087 in an @code{__attribute__} still only provides you with 8-byte
5088 alignment. See your linker documentation for further information.
5090 The @code{aligned} attribute can also be used for functions
5091 (@pxref{Function Attributes}.)
5093 @item cleanup (@var{cleanup_function})
5094 @cindex @code{cleanup} attribute
5095 The @code{cleanup} attribute runs a function when the variable goes
5096 out of scope. This attribute can only be applied to auto function
5097 scope variables; it may not be applied to parameters or variables
5098 with static storage duration. The function must take one parameter,
5099 a pointer to a type compatible with the variable. The return value
5100 of the function (if any) is ignored.
5102 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5103 is run during the stack unwinding that happens during the
5104 processing of the exception. Note that the @code{cleanup} attribute
5105 does not allow the exception to be caught, only to perform an action.
5106 It is undefined what happens if @var{cleanup_function} does not
5111 @cindex @code{common} attribute
5112 @cindex @code{nocommon} attribute
5115 The @code{common} attribute requests GCC to place a variable in
5116 ``common'' storage. The @code{nocommon} attribute requests the
5117 opposite---to allocate space for it directly.
5119 These attributes override the default chosen by the
5120 @option{-fno-common} and @option{-fcommon} flags respectively.
5123 @itemx deprecated (@var{msg})
5124 @cindex @code{deprecated} attribute
5125 The @code{deprecated} attribute results in a warning if the variable
5126 is used anywhere in the source file. This is useful when identifying
5127 variables that are expected to be removed in a future version of a
5128 program. The warning also includes the location of the declaration
5129 of the deprecated variable, to enable users to easily find further
5130 information about why the variable is deprecated, or what they should
5131 do instead. Note that the warning only occurs for uses:
5134 extern int old_var __attribute__ ((deprecated));
5136 int new_fn () @{ return old_var; @}
5140 results in a warning on line 3 but not line 2. The optional @var{msg}
5141 argument, which must be a string, is printed in the warning if
5144 The @code{deprecated} attribute can also be used for functions and
5145 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
5147 @item mode (@var{mode})
5148 @cindex @code{mode} attribute
5149 This attribute specifies the data type for the declaration---whichever
5150 type corresponds to the mode @var{mode}. This in effect lets you
5151 request an integer or floating-point type according to its width.
5153 You may also specify a mode of @code{byte} or @code{__byte__} to
5154 indicate the mode corresponding to a one-byte integer, @code{word} or
5155 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5156 or @code{__pointer__} for the mode used to represent pointers.
5159 @cindex @code{packed} attribute
5160 The @code{packed} attribute specifies that a variable or structure field
5161 should have the smallest possible alignment---one byte for a variable,
5162 and one bit for a field, unless you specify a larger value with the
5163 @code{aligned} attribute.
5165 Here is a structure in which the field @code{x} is packed, so that it
5166 immediately follows @code{a}:
5172 int x[2] __attribute__ ((packed));
5176 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5177 @code{packed} attribute on bit-fields of type @code{char}. This has
5178 been fixed in GCC 4.4 but the change can lead to differences in the
5179 structure layout. See the documentation of
5180 @option{-Wpacked-bitfield-compat} for more information.
5182 @item section ("@var{section-name}")
5183 @cindex @code{section} variable attribute
5184 Normally, the compiler places the objects it generates in sections like
5185 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5186 or you need certain particular variables to appear in special sections,
5187 for example to map to special hardware. The @code{section}
5188 attribute specifies that a variable (or function) lives in a particular
5189 section. For example, this small program uses several specific section names:
5192 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5193 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5194 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5195 int init_data __attribute__ ((section ("INITDATA")));
5199 /* @r{Initialize stack pointer} */
5200 init_sp (stack + sizeof (stack));
5202 /* @r{Initialize initialized data} */
5203 memcpy (&init_data, &data, &edata - &data);
5205 /* @r{Turn on the serial ports} */
5212 Use the @code{section} attribute with
5213 @emph{global} variables and not @emph{local} variables,
5214 as shown in the example.
5216 You may use the @code{section} attribute with initialized or
5217 uninitialized global variables but the linker requires
5218 each object be defined once, with the exception that uninitialized
5219 variables tentatively go in the @code{common} (or @code{bss}) section
5220 and can be multiply ``defined''. Using the @code{section} attribute
5221 changes what section the variable goes into and may cause the
5222 linker to issue an error if an uninitialized variable has multiple
5223 definitions. You can force a variable to be initialized with the
5224 @option{-fno-common} flag or the @code{nocommon} attribute.
5226 Some file formats do not support arbitrary sections so the @code{section}
5227 attribute is not available on all platforms.
5228 If you need to map the entire contents of a module to a particular
5229 section, consider using the facilities of the linker instead.
5232 @cindex @code{shared} variable attribute
5233 On Microsoft Windows, in addition to putting variable definitions in a named
5234 section, the section can also be shared among all running copies of an
5235 executable or DLL@. For example, this small program defines shared data
5236 by putting it in a named section @code{shared} and marking the section
5240 int foo __attribute__((section ("shared"), shared)) = 0;
5245 /* @r{Read and write foo. All running
5246 copies see the same value.} */
5252 You may only use the @code{shared} attribute along with @code{section}
5253 attribute with a fully-initialized global definition because of the way
5254 linkers work. See @code{section} attribute for more information.
5256 The @code{shared} attribute is only available on Microsoft Windows@.
5258 @item tls_model ("@var{tls_model}")
5259 @cindex @code{tls_model} attribute
5260 The @code{tls_model} attribute sets thread-local storage model
5261 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5262 overriding @option{-ftls-model=} command-line switch on a per-variable
5264 The @var{tls_model} argument should be one of @code{global-dynamic},
5265 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5267 Not all targets support this attribute.
5270 This attribute, attached to a variable, means that the variable is meant
5271 to be possibly unused. GCC does not produce a warning for this
5275 This attribute, attached to a variable with the static storage, means that
5276 the variable must be emitted even if it appears that the variable is not
5279 When applied to a static data member of a C++ class template, the
5280 attribute also means that the member is instantiated if the
5281 class itself is instantiated.
5283 @item vector_size (@var{bytes})
5284 This attribute specifies the vector size for the variable, measured in
5285 bytes. For example, the declaration:
5288 int foo __attribute__ ((vector_size (16)));
5292 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5293 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5294 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5296 This attribute is only applicable to integral and float scalars,
5297 although arrays, pointers, and function return values are allowed in
5298 conjunction with this construct.
5300 Aggregates with this attribute are invalid, even if they are of the same
5301 size as a corresponding scalar. For example, the declaration:
5304 struct S @{ int a; @};
5305 struct S __attribute__ ((vector_size (16))) foo;
5309 is invalid even if the size of the structure is the same as the size of
5313 The @code{selectany} attribute causes an initialized global variable to
5314 have link-once semantics. When multiple definitions of the variable are
5315 encountered by the linker, the first is selected and the remainder are
5316 discarded. Following usage by the Microsoft compiler, the linker is told
5317 @emph{not} to warn about size or content differences of the multiple
5320 Although the primary usage of this attribute is for POD types, the
5321 attribute can also be applied to global C++ objects that are initialized
5322 by a constructor. In this case, the static initialization and destruction
5323 code for the object is emitted in each translation defining the object,
5324 but the calls to the constructor and destructor are protected by a
5325 link-once guard variable.
5327 The @code{selectany} attribute is only available on Microsoft Windows
5328 targets. You can use @code{__declspec (selectany)} as a synonym for
5329 @code{__attribute__ ((selectany))} for compatibility with other
5333 The @code{weak} attribute is described in @ref{Function Attributes}.
5336 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5339 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5343 @anchor{AVR Variable Attributes}
5344 @subsection AVR Variable Attributes
5348 @cindex @code{progmem} AVR variable attribute
5349 The @code{progmem} attribute is used on the AVR to place read-only
5350 data in the non-volatile program memory (flash). The @code{progmem}
5351 attribute accomplishes this by putting respective variables into a
5352 section whose name starts with @code{.progmem}.
5354 This attribute works similar to the @code{section} attribute
5355 but adds additional checking. Notice that just like the
5356 @code{section} attribute, @code{progmem} affects the location
5357 of the data but not how this data is accessed.
5359 In order to read data located with the @code{progmem} attribute
5360 (inline) assembler must be used.
5362 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5363 #include <avr/pgmspace.h>
5365 /* Locate var in flash memory */
5366 const int var[2] PROGMEM = @{ 1, 2 @};
5368 int read_var (int i)
5370 /* Access var[] by accessor macro from avr/pgmspace.h */
5371 return (int) pgm_read_word (& var[i]);
5375 AVR is a Harvard architecture processor and data and read-only data
5376 normally resides in the data memory (RAM).
5378 See also the @ref{AVR Named Address Spaces} section for
5379 an alternate way to locate and access data in flash memory.
5382 @itemx io (@var{addr})
5383 Variables with the @code{io} attribute are used to address
5384 memory-mapped peripherals in the io address range.
5385 If an address is specified, the variable
5386 is assigned that address, and the value is interpreted as an
5387 address in the data address space.
5391 volatile int porta __attribute__((io (0x22)));
5394 The address specified in the address in the data address range.
5396 Otherwise, the variable it is not assigned an address, but the
5397 compiler will still use in/out instructions where applicable,
5398 assuming some other module assigns an address in the io address range.
5402 extern volatile int porta __attribute__((io));
5406 @itemx io_low (@var{addr})
5407 This is like the @code{io} attribute, but additionally it informs the
5408 compiler that the object lies in the lower half of the I/O area,
5409 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5413 @itemx address (@var{addr})
5414 Variables with the @code{address} attribute are used to address
5415 memory-mapped peripherals that may lie outside the io address range.
5418 volatile int porta __attribute__((address (0x600)));
5423 @subsection Blackfin Variable Attributes
5425 Three attributes are currently defined for the Blackfin.
5431 @cindex @code{l1_data} variable attribute
5432 @cindex @code{l1_data_A} variable attribute
5433 @cindex @code{l1_data_B} variable attribute
5434 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5435 Variables with @code{l1_data} attribute are put into the specific section
5436 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5437 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5438 attribute are put into the specific section named @code{.l1.data.B}.
5441 @cindex @code{l2} variable attribute
5442 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5443 Variables with @code{l2} attribute are put into the specific section
5444 named @code{.l2.data}.
5447 @subsection M32R/D Variable Attributes
5449 One attribute is currently defined for the M32R/D@.
5452 @item model (@var{model-name})
5453 @cindex variable addressability on the M32R/D
5454 Use this attribute on the M32R/D to set the addressability of an object.
5455 The identifier @var{model-name} is one of @code{small}, @code{medium},
5456 or @code{large}, representing each of the code models.
5458 Small model objects live in the lower 16MB of memory (so that their
5459 addresses can be loaded with the @code{ld24} instruction).
5461 Medium and large model objects may live anywhere in the 32-bit address space
5462 (the compiler generates @code{seth/add3} instructions to load their
5466 @anchor{MeP Variable Attributes}
5467 @subsection MeP Variable Attributes
5469 The MeP target has a number of addressing modes and busses. The
5470 @code{near} space spans the standard memory space's first 16 megabytes
5471 (24 bits). The @code{far} space spans the entire 32-bit memory space.
5472 The @code{based} space is a 128-byte region in the memory space that
5473 is addressed relative to the @code{$tp} register. The @code{tiny}
5474 space is a 65536-byte region relative to the @code{$gp} register. In
5475 addition to these memory regions, the MeP target has a separate 16-bit
5476 control bus which is specified with @code{cb} attributes.
5481 Any variable with the @code{based} attribute is assigned to the
5482 @code{.based} section, and is accessed with relative to the
5483 @code{$tp} register.
5486 Likewise, the @code{tiny} attribute assigned variables to the
5487 @code{.tiny} section, relative to the @code{$gp} register.
5490 Variables with the @code{near} attribute are assumed to have addresses
5491 that fit in a 24-bit addressing mode. This is the default for large
5492 variables (@code{-mtiny=4} is the default) but this attribute can
5493 override @code{-mtiny=} for small variables, or override @code{-ml}.
5496 Variables with the @code{far} attribute are addressed using a full
5497 32-bit address. Since this covers the entire memory space, this
5498 allows modules to make no assumptions about where variables might be
5502 @itemx io (@var{addr})
5503 Variables with the @code{io} attribute are used to address
5504 memory-mapped peripherals. If an address is specified, the variable
5505 is assigned that address, else it is not assigned an address (it is
5506 assumed some other module assigns an address). Example:
5509 int timer_count __attribute__((io(0x123)));
5513 @itemx cb (@var{addr})
5514 Variables with the @code{cb} attribute are used to access the control
5515 bus, using special instructions. @code{addr} indicates the control bus
5519 int cpu_clock __attribute__((cb(0x123)));
5524 @anchor{x86 Variable Attributes}
5525 @subsection x86 Variable Attributes
5527 Two attributes are currently defined for x86 configurations:
5528 @code{ms_struct} and @code{gcc_struct}.
5533 @cindex @code{ms_struct} attribute
5534 @cindex @code{gcc_struct} attribute
5536 If @code{packed} is used on a structure, or if bit-fields are used,
5537 it may be that the Microsoft ABI lays out the structure differently
5538 than the way GCC normally does. Particularly when moving packed
5539 data between functions compiled with GCC and the native Microsoft compiler
5540 (either via function call or as data in a file), it may be necessary to access
5543 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
5544 compilers to match the native Microsoft compiler.
5546 The Microsoft structure layout algorithm is fairly simple with the exception
5547 of the bit-field packing.
5548 The padding and alignment of members of structures and whether a bit-field
5549 can straddle a storage-unit boundary are determine by these rules:
5552 @item Structure members are stored sequentially in the order in which they are
5553 declared: the first member has the lowest memory address and the last member
5556 @item Every data object has an alignment requirement. The alignment requirement
5557 for all data except structures, unions, and arrays is either the size of the
5558 object or the current packing size (specified with either the
5559 @code{aligned} attribute or the @code{pack} pragma),
5560 whichever is less. For structures, unions, and arrays,
5561 the alignment requirement is the largest alignment requirement of its members.
5562 Every object is allocated an offset so that:
5565 offset % alignment_requirement == 0
5568 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5569 unit if the integral types are the same size and if the next bit-field fits
5570 into the current allocation unit without crossing the boundary imposed by the
5571 common alignment requirements of the bit-fields.
5574 MSVC interprets zero-length bit-fields in the following ways:
5577 @item If a zero-length bit-field is inserted between two bit-fields that
5578 are normally coalesced, the bit-fields are not coalesced.
5585 unsigned long bf_1 : 12;
5587 unsigned long bf_2 : 12;
5592 The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
5593 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5595 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5596 alignment of the zero-length bit-field is greater than the member that follows it,
5597 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5618 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5619 Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
5620 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5623 Taking this into account, it is important to note the following:
5626 @item If a zero-length bit-field follows a normal bit-field, the type of the
5627 zero-length bit-field may affect the alignment of the structure as whole. For
5628 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5629 normal bit-field, and is of type short.
5631 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5632 still affect the alignment of the structure:
5643 Here, @code{t4} takes up 4 bytes.
5646 @item Zero-length bit-fields following non-bit-field members are ignored:
5658 Here, @code{t5} takes up 2 bytes.
5662 @subsection PowerPC Variable Attributes
5664 Three attributes currently are defined for PowerPC configurations:
5665 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5667 For full documentation of the struct attributes please see the
5668 documentation in @ref{x86 Variable Attributes}.
5670 For documentation of @code{altivec} attribute please see the
5671 documentation in @ref{PowerPC Type Attributes}.
5673 @subsection SPU Variable Attributes
5675 The SPU supports the @code{spu_vector} attribute for variables. For
5676 documentation of this attribute please see the documentation in
5677 @ref{SPU Type Attributes}.
5679 @subsection Xstormy16 Variable Attributes
5681 One attribute is currently defined for xstormy16 configurations:
5686 @cindex @code{below100} attribute
5688 If a variable has the @code{below100} attribute (@code{BELOW100} is
5689 allowed also), GCC places the variable in the first 0x100 bytes of
5690 memory and use special opcodes to access it. Such variables are
5691 placed in either the @code{.bss_below100} section or the
5692 @code{.data_below100} section.
5696 @node Type Attributes
5697 @section Specifying Attributes of Types
5698 @cindex attribute of types
5699 @cindex type attributes
5701 The keyword @code{__attribute__} allows you to specify special
5702 attributes of @code{struct} and @code{union} types when you define
5703 such types. This keyword is followed by an attribute specification
5704 inside double parentheses. Eight attributes are currently defined for
5705 types: @code{aligned}, @code{packed}, @code{transparent_union},
5706 @code{unused}, @code{deprecated}, @code{visibility}, @code{may_alias}
5707 and @code{bnd_variable_size}. Other attributes are defined for
5708 functions (@pxref{Function Attributes}), labels (@pxref{Label
5709 Attributes}) and for variables (@pxref{Variable Attributes}).
5711 You may also specify any one of these attributes with @samp{__}
5712 preceding and following its keyword. This allows you to use these
5713 attributes in header files without being concerned about a possible
5714 macro of the same name. For example, you may use @code{__aligned__}
5715 instead of @code{aligned}.
5717 You may specify type attributes in an enum, struct or union type
5718 declaration or definition, or for other types in a @code{typedef}
5721 For an enum, struct or union type, you may specify attributes either
5722 between the enum, struct or union tag and the name of the type, or
5723 just past the closing curly brace of the @emph{definition}. The
5724 former syntax is preferred.
5726 @xref{Attribute Syntax}, for details of the exact syntax for using
5730 @cindex @code{aligned} attribute
5731 @item aligned (@var{alignment})
5732 This attribute specifies a minimum alignment (in bytes) for variables
5733 of the specified type. For example, the declarations:
5736 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5737 typedef int more_aligned_int __attribute__ ((aligned (8)));
5741 force the compiler to ensure (as far as it can) that each variable whose
5742 type is @code{struct S} or @code{more_aligned_int} is allocated and
5743 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
5744 variables of type @code{struct S} aligned to 8-byte boundaries allows
5745 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5746 store) instructions when copying one variable of type @code{struct S} to
5747 another, thus improving run-time efficiency.
5749 Note that the alignment of any given @code{struct} or @code{union} type
5750 is required by the ISO C standard to be at least a perfect multiple of
5751 the lowest common multiple of the alignments of all of the members of
5752 the @code{struct} or @code{union} in question. This means that you @emph{can}
5753 effectively adjust the alignment of a @code{struct} or @code{union}
5754 type by attaching an @code{aligned} attribute to any one of the members
5755 of such a type, but the notation illustrated in the example above is a
5756 more obvious, intuitive, and readable way to request the compiler to
5757 adjust the alignment of an entire @code{struct} or @code{union} type.
5759 As in the preceding example, you can explicitly specify the alignment
5760 (in bytes) that you wish the compiler to use for a given @code{struct}
5761 or @code{union} type. Alternatively, you can leave out the alignment factor
5762 and just ask the compiler to align a type to the maximum
5763 useful alignment for the target machine you are compiling for. For
5764 example, you could write:
5767 struct S @{ short f[3]; @} __attribute__ ((aligned));
5770 Whenever you leave out the alignment factor in an @code{aligned}
5771 attribute specification, the compiler automatically sets the alignment
5772 for the type to the largest alignment that is ever used for any data
5773 type on the target machine you are compiling for. Doing this can often
5774 make copy operations more efficient, because the compiler can use
5775 whatever instructions copy the biggest chunks of memory when performing
5776 copies to or from the variables that have types that you have aligned
5779 In the example above, if the size of each @code{short} is 2 bytes, then
5780 the size of the entire @code{struct S} type is 6 bytes. The smallest
5781 power of two that is greater than or equal to that is 8, so the
5782 compiler sets the alignment for the entire @code{struct S} type to 8
5785 Note that although you can ask the compiler to select a time-efficient
5786 alignment for a given type and then declare only individual stand-alone
5787 objects of that type, the compiler's ability to select a time-efficient
5788 alignment is primarily useful only when you plan to create arrays of
5789 variables having the relevant (efficiently aligned) type. If you
5790 declare or use arrays of variables of an efficiently-aligned type, then
5791 it is likely that your program also does pointer arithmetic (or
5792 subscripting, which amounts to the same thing) on pointers to the
5793 relevant type, and the code that the compiler generates for these
5794 pointer arithmetic operations is often more efficient for
5795 efficiently-aligned types than for other types.
5797 The @code{aligned} attribute can only increase the alignment; but you
5798 can decrease it by specifying @code{packed} as well. See below.
5800 Note that the effectiveness of @code{aligned} attributes may be limited
5801 by inherent limitations in your linker. On many systems, the linker is
5802 only able to arrange for variables to be aligned up to a certain maximum
5803 alignment. (For some linkers, the maximum supported alignment may
5804 be very very small.) If your linker is only able to align variables
5805 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5806 in an @code{__attribute__} still only provides you with 8-byte
5807 alignment. See your linker documentation for further information.
5810 This attribute, attached to @code{struct} or @code{union} type
5811 definition, specifies that each member (other than zero-width bit-fields)
5812 of the structure or union is placed to minimize the memory required. When
5813 attached to an @code{enum} definition, it indicates that the smallest
5814 integral type should be used.
5816 @opindex fshort-enums
5817 Specifying this attribute for @code{struct} and @code{union} types is
5818 equivalent to specifying the @code{packed} attribute on each of the
5819 structure or union members. Specifying the @option{-fshort-enums}
5820 flag on the line is equivalent to specifying the @code{packed}
5821 attribute on all @code{enum} definitions.
5823 In the following example @code{struct my_packed_struct}'s members are
5824 packed closely together, but the internal layout of its @code{s} member
5825 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5829 struct my_unpacked_struct
5835 struct __attribute__ ((__packed__)) my_packed_struct
5839 struct my_unpacked_struct s;
5843 You may only specify this attribute on the definition of an @code{enum},
5844 @code{struct} or @code{union}, not on a @code{typedef} that does not
5845 also define the enumerated type, structure or union.
5847 @item transparent_union
5848 @cindex @code{transparent_union} attribute
5850 This attribute, attached to a @code{union} type definition, indicates
5851 that any function parameter having that union type causes calls to that
5852 function to be treated in a special way.
5854 First, the argument corresponding to a transparent union type can be of
5855 any type in the union; no cast is required. Also, if the union contains
5856 a pointer type, the corresponding argument can be a null pointer
5857 constant or a void pointer expression; and if the union contains a void
5858 pointer type, the corresponding argument can be any pointer expression.
5859 If the union member type is a pointer, qualifiers like @code{const} on
5860 the referenced type must be respected, just as with normal pointer
5863 Second, the argument is passed to the function using the calling
5864 conventions of the first member of the transparent union, not the calling
5865 conventions of the union itself. All members of the union must have the
5866 same machine representation; this is necessary for this argument passing
5869 Transparent unions are designed for library functions that have multiple
5870 interfaces for compatibility reasons. For example, suppose the
5871 @code{wait} function must accept either a value of type @code{int *} to
5872 comply with POSIX, or a value of type @code{union wait *} to comply with
5873 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
5874 @code{wait} would accept both kinds of arguments, but it would also
5875 accept any other pointer type and this would make argument type checking
5876 less useful. Instead, @code{<sys/wait.h>} might define the interface
5880 typedef union __attribute__ ((__transparent_union__))
5884 @} wait_status_ptr_t;
5886 pid_t wait (wait_status_ptr_t);
5890 This interface allows either @code{int *} or @code{union wait *}
5891 arguments to be passed, using the @code{int *} calling convention.
5892 The program can call @code{wait} with arguments of either type:
5895 int w1 () @{ int w; return wait (&w); @}
5896 int w2 () @{ union wait w; return wait (&w); @}
5900 With this interface, @code{wait}'s implementation might look like this:
5903 pid_t wait (wait_status_ptr_t p)
5905 return waitpid (-1, p.__ip, 0);
5910 When attached to a type (including a @code{union} or a @code{struct}),
5911 this attribute means that variables of that type are meant to appear
5912 possibly unused. GCC does not produce a warning for any variables of
5913 that type, even if the variable appears to do nothing. This is often
5914 the case with lock or thread classes, which are usually defined and then
5915 not referenced, but contain constructors and destructors that have
5916 nontrivial bookkeeping functions.
5919 @itemx deprecated (@var{msg})
5920 The @code{deprecated} attribute results in a warning if the type
5921 is used anywhere in the source file. This is useful when identifying
5922 types that are expected to be removed in a future version of a program.
5923 If possible, the warning also includes the location of the declaration
5924 of the deprecated type, to enable users to easily find further
5925 information about why the type is deprecated, or what they should do
5926 instead. Note that the warnings only occur for uses and then only
5927 if the type is being applied to an identifier that itself is not being
5928 declared as deprecated.
5931 typedef int T1 __attribute__ ((deprecated));
5935 typedef T1 T3 __attribute__ ((deprecated));
5936 T3 z __attribute__ ((deprecated));
5940 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
5941 warning is issued for line 4 because T2 is not explicitly
5942 deprecated. Line 5 has no warning because T3 is explicitly
5943 deprecated. Similarly for line 6. The optional @var{msg}
5944 argument, which must be a string, is printed in the warning if
5947 The @code{deprecated} attribute can also be used for functions and
5948 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5951 Accesses through pointers to types with this attribute are not subject
5952 to type-based alias analysis, but are instead assumed to be able to alias
5953 any other type of objects.
5954 In the context of section 6.5 paragraph 7 of the C99 standard,
5955 an lvalue expression
5956 dereferencing such a pointer is treated like having a character type.
5957 See @option{-fstrict-aliasing} for more information on aliasing issues.
5958 This extension exists to support some vector APIs, in which pointers to
5959 one vector type are permitted to alias pointers to a different vector type.
5961 Note that an object of a type with this attribute does not have any
5967 typedef short __attribute__((__may_alias__)) short_a;
5973 short_a *b = (short_a *) &a;
5977 if (a == 0x12345678)
5985 If you replaced @code{short_a} with @code{short} in the variable
5986 declaration, the above program would abort when compiled with
5987 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5988 above in recent GCC versions.
5991 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5992 applied to class, struct, union and enum types. Unlike other type
5993 attributes, the attribute must appear between the initial keyword and
5994 the name of the type; it cannot appear after the body of the type.
5996 Note that the type visibility is applied to vague linkage entities
5997 associated with the class (vtable, typeinfo node, etc.). In
5998 particular, if a class is thrown as an exception in one shared object
5999 and caught in another, the class must have default visibility.
6000 Otherwise the two shared objects are unable to use the same
6001 typeinfo node and exception handling will break.
6003 @item designated_init
6004 This attribute may only be applied to structure types. It indicates
6005 that any initialization of an object of this type must use designated
6006 initializers rather than positional initializers. The intent of this
6007 attribute is to allow the programmer to indicate that a structure's
6008 layout may change, and that therefore relying on positional
6009 initialization will result in future breakage.
6011 GCC emits warnings based on this attribute by default; use
6012 @option{-Wno-designated-init} to suppress them.
6014 @item bnd_variable_size
6015 When applied to a structure field, this attribute tells Pointer
6016 Bounds Checker that the size of this field should not be computed
6017 using static type information. It may be used to mark variable
6018 sized static array fields placed at the end of a structure.
6026 S *p = (S *)malloc (sizeof(S) + 100);
6027 p->data[10] = 0; //Bounds violation
6030 By using an attribute for a field we may avoid bound violation
6031 we most probably do not want to see:
6037 char data[1] __attribute__((bnd_variable_size));
6039 S *p = (S *)malloc (sizeof(S) + 100);
6040 p->data[10] = 0; //OK
6045 To specify multiple attributes, separate them by commas within the
6046 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6049 @subsection ARM Type Attributes
6051 On those ARM targets that support @code{dllimport} (such as Symbian
6052 OS), you can use the @code{notshared} attribute to indicate that the
6053 virtual table and other similar data for a class should not be
6054 exported from a DLL@. For example:
6057 class __declspec(notshared) C @{
6059 __declspec(dllimport) C();
6063 __declspec(dllexport)
6068 In this code, @code{C::C} is exported from the current DLL, but the
6069 virtual table for @code{C} is not exported. (You can use
6070 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6071 most Symbian OS code uses @code{__declspec}.)
6073 @anchor{MeP Type Attributes}
6074 @subsection MeP Type Attributes
6076 Many of the MeP variable attributes may be applied to types as well.
6077 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6078 @code{far} attributes may be applied to either. The @code{io} and
6079 @code{cb} attributes may not be applied to types.
6081 @anchor{x86 Type Attributes}
6082 @subsection x86 Type Attributes
6084 Two attributes are currently defined for x86 configurations:
6085 @code{ms_struct} and @code{gcc_struct}.
6091 @cindex @code{ms_struct}
6092 @cindex @code{gcc_struct}
6094 If @code{packed} is used on a structure, or if bit-fields are used
6095 it may be that the Microsoft ABI packs them differently
6096 than GCC normally packs them. Particularly when moving packed
6097 data between functions compiled with GCC and the native Microsoft compiler
6098 (either via function call or as data in a file), it may be necessary to access
6101 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
6102 compilers to match the native Microsoft compiler.
6105 @anchor{PowerPC Type Attributes}
6106 @subsection PowerPC Type Attributes
6108 Three attributes currently are defined for PowerPC configurations:
6109 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6111 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6112 attributes please see the documentation in @ref{x86 Type Attributes}.
6114 The @code{altivec} attribute allows one to declare AltiVec vector data
6115 types supported by the AltiVec Programming Interface Manual. The
6116 attribute requires an argument to specify one of three vector types:
6117 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6118 and @code{bool__} (always followed by unsigned).
6121 __attribute__((altivec(vector__)))
6122 __attribute__((altivec(pixel__))) unsigned short
6123 __attribute__((altivec(bool__))) unsigned
6126 These attributes mainly are intended to support the @code{__vector},
6127 @code{__pixel}, and @code{__bool} AltiVec keywords.
6129 @anchor{SPU Type Attributes}
6130 @subsection SPU Type Attributes
6132 The SPU supports the @code{spu_vector} attribute for types. This attribute
6133 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6134 Language Extensions Specification. It is intended to support the
6135 @code{__vector} keyword.
6138 @section Inquiring on Alignment of Types or Variables
6140 @cindex type alignment
6141 @cindex variable alignment
6143 The keyword @code{__alignof__} allows you to inquire about how an object
6144 is aligned, or the minimum alignment usually required by a type. Its
6145 syntax is just like @code{sizeof}.
6147 For example, if the target machine requires a @code{double} value to be
6148 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
6149 This is true on many RISC machines. On more traditional machine
6150 designs, @code{__alignof__ (double)} is 4 or even 2.
6152 Some machines never actually require alignment; they allow reference to any
6153 data type even at an odd address. For these machines, @code{__alignof__}
6154 reports the smallest alignment that GCC gives the data type, usually as
6155 mandated by the target ABI.
6157 If the operand of @code{__alignof__} is an lvalue rather than a type,
6158 its value is the required alignment for its type, taking into account
6159 any minimum alignment specified with GCC's @code{__attribute__}
6160 extension (@pxref{Variable Attributes}). For example, after this
6164 struct foo @{ int x; char y; @} foo1;
6168 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6169 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6171 It is an error to ask for the alignment of an incomplete type.
6175 @section An Inline Function is As Fast As a Macro
6176 @cindex inline functions
6177 @cindex integrating function code
6179 @cindex macros, inline alternative
6181 By declaring a function inline, you can direct GCC to make
6182 calls to that function faster. One way GCC can achieve this is to
6183 integrate that function's code into the code for its callers. This
6184 makes execution faster by eliminating the function-call overhead; in
6185 addition, if any of the actual argument values are constant, their
6186 known values may permit simplifications at compile time so that not
6187 all of the inline function's code needs to be included. The effect on
6188 code size is less predictable; object code may be larger or smaller
6189 with function inlining, depending on the particular case. You can
6190 also direct GCC to try to integrate all ``simple enough'' functions
6191 into their callers with the option @option{-finline-functions}.
6193 GCC implements three different semantics of declaring a function
6194 inline. One is available with @option{-std=gnu89} or
6195 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6196 on all inline declarations, another when
6197 @option{-std=c99}, @option{-std=c11},
6198 @option{-std=gnu99} or @option{-std=gnu11}
6199 (without @option{-fgnu89-inline}), and the third
6200 is used when compiling C++.
6202 To declare a function inline, use the @code{inline} keyword in its
6203 declaration, like this:
6213 If you are writing a header file to be included in ISO C90 programs, write
6214 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
6216 The three types of inlining behave similarly in two important cases:
6217 when the @code{inline} keyword is used on a @code{static} function,
6218 like the example above, and when a function is first declared without
6219 using the @code{inline} keyword and then is defined with
6220 @code{inline}, like this:
6223 extern int inc (int *a);
6231 In both of these common cases, the program behaves the same as if you
6232 had not used the @code{inline} keyword, except for its speed.
6234 @cindex inline functions, omission of
6235 @opindex fkeep-inline-functions
6236 When a function is both inline and @code{static}, if all calls to the
6237 function are integrated into the caller, and the function's address is
6238 never used, then the function's own assembler code is never referenced.
6239 In this case, GCC does not actually output assembler code for the
6240 function, unless you specify the option @option{-fkeep-inline-functions}.
6241 Some calls cannot be integrated for various reasons (in particular,
6242 calls that precede the function's definition cannot be integrated, and
6243 neither can recursive calls within the definition). If there is a
6244 nonintegrated call, then the function is compiled to assembler code as
6245 usual. The function must also be compiled as usual if the program
6246 refers to its address, because that can't be inlined.
6249 Note that certain usages in a function definition can make it unsuitable
6250 for inline substitution. Among these usages are: variadic functions, use of
6251 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6252 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6253 and nested functions (@pxref{Nested Functions}). Using @option{-Winline}
6254 warns when a function marked @code{inline} could not be substituted,
6255 and gives the reason for the failure.
6257 @cindex automatic @code{inline} for C++ member fns
6258 @cindex @code{inline} automatic for C++ member fns
6259 @cindex member fns, automatically @code{inline}
6260 @cindex C++ member fns, automatically @code{inline}
6261 @opindex fno-default-inline
6262 As required by ISO C++, GCC considers member functions defined within
6263 the body of a class to be marked inline even if they are
6264 not explicitly declared with the @code{inline} keyword. You can
6265 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6266 Options,,Options Controlling C++ Dialect}.
6268 GCC does not inline any functions when not optimizing unless you specify
6269 the @samp{always_inline} attribute for the function, like this:
6272 /* @r{Prototype.} */
6273 inline void foo (const char) __attribute__((always_inline));
6276 The remainder of this section is specific to GNU C90 inlining.
6278 @cindex non-static inline function
6279 When an inline function is not @code{static}, then the compiler must assume
6280 that there may be calls from other source files; since a global symbol can
6281 be defined only once in any program, the function must not be defined in
6282 the other source files, so the calls therein cannot be integrated.
6283 Therefore, a non-@code{static} inline function is always compiled on its
6284 own in the usual fashion.
6286 If you specify both @code{inline} and @code{extern} in the function
6287 definition, then the definition is used only for inlining. In no case
6288 is the function compiled on its own, not even if you refer to its
6289 address explicitly. Such an address becomes an external reference, as
6290 if you had only declared the function, and had not defined it.
6292 This combination of @code{inline} and @code{extern} has almost the
6293 effect of a macro. The way to use it is to put a function definition in
6294 a header file with these keywords, and put another copy of the
6295 definition (lacking @code{inline} and @code{extern}) in a library file.
6296 The definition in the header file causes most calls to the function
6297 to be inlined. If any uses of the function remain, they refer to
6298 the single copy in the library.
6301 @section When is a Volatile Object Accessed?
6302 @cindex accessing volatiles
6303 @cindex volatile read
6304 @cindex volatile write
6305 @cindex volatile access
6307 C has the concept of volatile objects. These are normally accessed by
6308 pointers and used for accessing hardware or inter-thread
6309 communication. The standard encourages compilers to refrain from
6310 optimizations concerning accesses to volatile objects, but leaves it
6311 implementation defined as to what constitutes a volatile access. The
6312 minimum requirement is that at a sequence point all previous accesses
6313 to volatile objects have stabilized and no subsequent accesses have
6314 occurred. Thus an implementation is free to reorder and combine
6315 volatile accesses that occur between sequence points, but cannot do
6316 so for accesses across a sequence point. The use of volatile does
6317 not allow you to violate the restriction on updating objects multiple
6318 times between two sequence points.
6320 Accesses to non-volatile objects are not ordered with respect to
6321 volatile accesses. You cannot use a volatile object as a memory
6322 barrier to order a sequence of writes to non-volatile memory. For
6326 int *ptr = @var{something};
6328 *ptr = @var{something};
6333 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6334 that the write to @var{*ptr} occurs by the time the update
6335 of @var{vobj} happens. If you need this guarantee, you must use
6336 a stronger memory barrier such as:
6339 int *ptr = @var{something};
6341 *ptr = @var{something};
6342 asm volatile ("" : : : "memory");
6346 A scalar volatile object is read when it is accessed in a void context:
6349 volatile int *src = @var{somevalue};
6353 Such expressions are rvalues, and GCC implements this as a
6354 read of the volatile object being pointed to.
6356 Assignments are also expressions and have an rvalue. However when
6357 assigning to a scalar volatile, the volatile object is not reread,
6358 regardless of whether the assignment expression's rvalue is used or
6359 not. If the assignment's rvalue is used, the value is that assigned
6360 to the volatile object. For instance, there is no read of @var{vobj}
6361 in all the following cases:
6366 vobj = @var{something};
6367 obj = vobj = @var{something};
6368 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6369 obj = (@var{something}, vobj = @var{anotherthing});
6372 If you need to read the volatile object after an assignment has
6373 occurred, you must use a separate expression with an intervening
6376 As bit-fields are not individually addressable, volatile bit-fields may
6377 be implicitly read when written to, or when adjacent bit-fields are
6378 accessed. Bit-field operations may be optimized such that adjacent
6379 bit-fields are only partially accessed, if they straddle a storage unit
6380 boundary. For these reasons it is unwise to use volatile bit-fields to
6383 @node Using Assembly Language with C
6384 @section How to Use Inline Assembly Language in C Code
6386 GCC provides various extensions that allow you to embed assembler within
6390 * Basic Asm:: Inline assembler with no operands.
6391 * Extended Asm:: Inline assembler with operands.
6392 * Constraints:: Constraints for @code{asm} operands
6393 * Asm Labels:: Specifying the assembler name to use for a C symbol.
6394 * Explicit Reg Vars:: Defining variables residing in specified registers.
6395 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
6399 @subsection Basic Asm --- Assembler Instructions with No Operands
6400 @cindex basic @code{asm}
6402 The @code{asm} keyword allows you to embed assembler instructions within
6406 asm [ volatile ] ( AssemblerInstructions )
6409 To create headers compatible with ISO C, write @code{__asm__} instead of
6410 @code{asm} (@pxref{Alternate Keywords}).
6412 By definition, a Basic @code{asm} statement is one with no operands.
6413 @code{asm} statements that contain one or more colons (used to delineate
6414 operands) are considered to be Extended (for example, @code{asm("int $3")}
6415 is Basic, and @code{asm("int $3" : )} is Extended). @xref{Extended Asm}.
6417 @subsubheading Qualifiers
6420 This optional qualifier has no effect. All Basic @code{asm} blocks are
6421 implicitly volatile.
6423 @subsubheading Parameters
6424 @emph{AssemblerInstructions}
6426 This is a literal string that specifies the assembler code. The string can
6427 contain any instructions recognized by the assembler, including directives.
6428 GCC does not parse the assembler instructions themselves and
6429 does not know what they mean or even whether they are valid assembler input.
6430 The compiler copies it verbatim to the assembly language output file, without
6431 processing dialects or any of the "%" operators that are available with
6432 Extended @code{asm}. This results in minor differences between Basic
6433 @code{asm} strings and Extended @code{asm} templates. For example, to refer to
6434 registers you might use %%eax in Extended @code{asm} and %eax in Basic
6437 You may place multiple assembler instructions together in a single @code{asm}
6438 string, separated by the characters normally used in assembly code for the
6439 system. A combination that works in most places is a newline to break the
6440 line, plus a tab character (written as "\n\t").
6441 Some assemblers allow semicolons as a line separator. However,
6442 note that some assembler dialects use semicolons to start a comment.
6444 Do not expect a sequence of @code{asm} statements to remain perfectly
6445 consecutive after compilation. If certain instructions need to remain
6446 consecutive in the output, put them in a single multi-instruction asm
6447 statement. Note that GCC's optimizers can move @code{asm} statements
6448 relative to other code, including across jumps.
6450 @code{asm} statements may not perform jumps into other @code{asm} statements.
6451 GCC does not know about these jumps, and therefore cannot take
6452 account of them when deciding how to optimize. Jumps from @code{asm} to C
6453 labels are only supported in Extended @code{asm}.
6455 @subsubheading Remarks
6456 Using Extended @code{asm} will typically produce smaller, safer, and more
6457 efficient code, and in most cases it is a better solution. When writing
6458 inline assembly language outside of C functions, however, you must use Basic
6459 @code{asm}. Extended @code{asm} statements have to be inside a C function.
6460 Functions declared with the @code{naked} attribute also require Basic
6461 @code{asm} (@pxref{Function Attributes}).
6463 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
6464 assembly code when optimizing. This can lead to unexpected duplicate
6465 symbol errors during compilation if your assembly code defines symbols or
6468 Safely accessing C data and calling functions from Basic @code{asm} is more
6469 complex than it may appear. To access C data, it is better to use Extended
6472 Since GCC does not parse the AssemblerInstructions, it has no
6473 visibility of any symbols it references. This may result in GCC discarding
6474 those symbols as unreferenced.
6476 Unlike Extended @code{asm}, all Basic @code{asm} blocks are implicitly
6477 volatile. @xref{Volatile}. Similarly, Basic @code{asm} blocks are not treated
6478 as though they used a "memory" clobber (@pxref{Clobbers}).
6480 All Basic @code{asm} blocks use the assembler dialect specified by the
6481 @option{-masm} command-line option. Basic @code{asm} provides no
6482 mechanism to provide different assembler strings for different dialects.
6484 Here is an example of Basic @code{asm} for i386:
6487 /* Note that this code will not compile with -masm=intel */
6488 #define DebugBreak() asm("int $3")
6492 @subsection Extended Asm - Assembler Instructions with C Expression Operands
6493 @cindex @code{asm} keyword
6494 @cindex extended @code{asm}
6495 @cindex assembler instructions
6497 The @code{asm} keyword allows you to embed assembler instructions within C
6498 code. With Extended @code{asm} you can read and write C variables from
6499 assembler and perform jumps from assembler code to C labels.
6503 asm [volatile] ( AssemblerTemplate : [OutputOperands] [ : [InputOperands] [ : [Clobbers] ] ] )
6505 asm [volatile] goto ( AssemblerTemplate : : [InputOperands] : [Clobbers] : GotoLabels )
6508 asm [volatile] ( AssemblerTemplate
6513 asm [volatile] goto ( AssemblerTemplate
6521 To create headers compatible with ISO C, write @code{__asm__} instead of
6522 @code{asm} and @code{__volatile__} instead of @code{volatile}
6523 (@pxref{Alternate Keywords}). There is no alternate for @code{goto}.
6525 By definition, Extended @code{asm} is an @code{asm} statement that contains
6526 operands. To separate the classes of operands, you use colons. Basic
6527 @code{asm} statements contain no colons. (So, for example,
6528 @code{asm("int $3")} is Basic @code{asm}, and @code{asm("int $3" : )} is
6529 Extended @code{asm}. @pxref{Basic Asm}.)
6531 @subsubheading Qualifiers
6534 The typical use of Extended @code{asm} statements is to manipulate input
6535 values to produce output values. However, your @code{asm} statements may
6536 also produce side effects. If so, you may need to use the @code{volatile}
6537 qualifier to disable certain optimizations. @xref{Volatile}.
6541 This qualifier informs the compiler that the @code{asm} statement may
6542 perform a jump to one of the labels listed in the GotoLabels section.
6545 @subsubheading Parameters
6546 @emph{AssemblerTemplate}
6548 This is a literal string that contains the assembler code. It is a
6549 combination of fixed text and tokens that refer to the input, output,
6550 and goto parameters. @xref{AssemblerTemplate}.
6552 @emph{OutputOperands}
6554 A comma-separated list of the C variables modified by the instructions in the
6555 AssemblerTemplate. @xref{OutputOperands}.
6557 @emph{InputOperands}
6559 A comma-separated list of C expressions read by the instructions in the
6560 AssemblerTemplate. @xref{InputOperands}.
6564 A comma-separated list of registers or other values changed by the
6565 AssemblerTemplate, beyond those listed as outputs. @xref{Clobbers}.
6569 When you are using the @code{goto} form of @code{asm}, this section contains
6570 the list of all C labels to which the AssemblerTemplate may jump.
6573 @subsubheading Remarks
6574 The @code{asm} statement allows you to include assembly instructions directly
6575 within C code. This may help you to maximize performance in time-sensitive
6576 code or to access assembly instructions that are not readily available to C
6579 Note that Extended @code{asm} statements must be inside a function. Only
6580 Basic @code{asm} may be outside functions (@pxref{Basic Asm}).
6581 Functions declared with the @code{naked} attribute also require Basic
6582 @code{asm} (@pxref{Function Attributes}).
6584 While the uses of @code{asm} are many and varied, it may help to think of an
6585 @code{asm} statement as a series of low-level instructions that convert input
6586 parameters to output parameters. So a simple (if not particularly useful)
6587 example for i386 using @code{asm} might look like this:
6593 asm ("mov %1, %0\n\t"
6598 printf("%d\n", dst);
6601 This code will copy @var{src} to @var{dst} and add 1 to @var{dst}.
6604 @subsubsection Volatile
6605 @cindex volatile @code{asm}
6606 @cindex @code{asm} volatile
6608 GCC's optimizers sometimes discard @code{asm} statements if they determine
6609 there is no need for the output variables. Also, the optimizers may move
6610 code out of loops if they believe that the code will always return the same
6611 result (i.e. none of its input values change between calls). Using the
6612 @code{volatile} qualifier disables these optimizations. @code{asm} statements
6613 that have no output operands are implicitly volatile.
6617 This i386 code demonstrates a case that does not use (or require) the
6618 @code{volatile} qualifier. If it is performing assertion checking, this code
6619 uses @code{asm} to perform the validation. Otherwise, @var{dwRes} is
6620 unreferenced by any code. As a result, the optimizers can discard the
6621 @code{asm} statement, which in turn removes the need for the entire
6622 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
6623 isn't needed you allow the optimizers to produce the most efficient code
6627 void DoCheck(uint32_t dwSomeValue)
6631 // Assumes dwSomeValue is not zero.
6641 The next example shows a case where the optimizers can recognize that the input
6642 (@var{dwSomeValue}) never changes during the execution of the function and can
6643 therefore move the @code{asm} outside the loop to produce more efficient code.
6644 Again, using @code{volatile} disables this type of optimization.
6647 void do_print(uint32_t dwSomeValue)
6651 for (uint32_t x=0; x < 5; x++)
6653 // Assumes dwSomeValue is not zero.
6659 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
6664 The following example demonstrates a case where you need to use the
6665 @code{volatile} qualifier. It uses the x86 RDTSC instruction, which reads
6666 the computer's time-stamp counter. Without the @code{volatile} qualifier,
6667 the optimizers might assume that the @code{asm} block will always return the
6668 same value and therefore optimize away the second call.
6673 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
6674 "shl $32, %%rdx\n\t" // Shift the upper bits left.
6675 "or %%rdx, %0" // 'Or' in the lower bits.
6680 printf("msr: %llx\n", msr);
6684 // Reprint the timestamp
6685 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
6686 "shl $32, %%rdx\n\t" // Shift the upper bits left.
6687 "or %%rdx, %0" // 'Or' in the lower bits.
6692 printf("msr: %llx\n", msr);
6695 GCC's optimizers will not treat this code like the non-volatile code in the
6696 earlier examples. They do not move it out of loops or omit it on the
6697 assumption that the result from a previous call is still valid.
6699 Note that the compiler can move even volatile @code{asm} instructions relative
6700 to other code, including across jump instructions. For example, on many
6701 targets there is a system register that controls the rounding mode of
6702 floating-point operations. Setting it with a volatile @code{asm}, as in the
6703 following PowerPC example, will not work reliably.
6706 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
6710 The compiler may move the addition back before the volatile @code{asm}. To
6711 make it work as expected, add an artificial dependency to the @code{asm} by
6712 referencing a variable in the subsequent code, for example:
6715 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
6719 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
6720 assembly code when optimizing. This can lead to unexpected duplicate symbol
6721 errors during compilation if your asm code defines symbols or labels. Using %=
6722 (@pxref{AssemblerTemplate}) may help resolve this problem.
6724 @anchor{AssemblerTemplate}
6725 @subsubsection Assembler Template
6726 @cindex @code{asm} assembler template
6728 An assembler template is a literal string containing assembler instructions.
6729 The compiler will replace any references to inputs, outputs, and goto labels
6730 in the template, and then output the resulting string to the assembler. The
6731 string can contain any instructions recognized by the assembler, including
6732 directives. GCC does not parse the assembler instructions
6733 themselves and does not know what they mean or even whether they are valid
6734 assembler input. However, it does count the statements
6735 (@pxref{Size of an asm}).
6737 You may place multiple assembler instructions together in a single @code{asm}
6738 string, separated by the characters normally used in assembly code for the
6739 system. A combination that works in most places is a newline to break the
6740 line, plus a tab character to move to the instruction field (written as
6741 "\n\t"). Some assemblers allow semicolons as a line separator. However, note
6742 that some assembler dialects use semicolons to start a comment.
6744 Do not expect a sequence of @code{asm} statements to remain perfectly
6745 consecutive after compilation, even when you are using the @code{volatile}
6746 qualifier. If certain instructions need to remain consecutive in the output,
6747 put them in a single multi-instruction asm statement.
6749 Accessing data from C programs without using input/output operands (such as
6750 by using global symbols directly from the assembler template) may not work as
6751 expected. Similarly, calling functions directly from an assembler template
6752 requires a detailed understanding of the target assembler and ABI.
6754 Since GCC does not parse the AssemblerTemplate, it has no visibility of any
6755 symbols it references. This may result in GCC discarding those symbols as
6756 unreferenced unless they are also listed as input, output, or goto operands.
6758 GCC can support multiple assembler dialects (for example, GCC for x86
6759 supports "att" and "intel" dialects) for inline assembler. In builds that
6760 support this capability, the @option{-masm} option controls which dialect
6761 GCC uses as its default. The hardware-specific documentation for the
6762 @option{-masm} option contains the list of supported dialects, as well as the
6763 default dialect if the option is not specified. This information may be
6764 important to understand, since assembler code that works correctly when
6765 compiled using one dialect will likely fail if compiled using another.
6767 @subsubheading Using braces in @code{asm} templates
6769 If your code needs to support multiple assembler dialects (for example, if
6770 you are writing public headers that need to support a variety of compilation
6771 options), use constructs of this form:
6774 @{ dialect0 | dialect1 | dialect2... @}
6777 This construct outputs 'dialect0' when using dialect #0 to compile the code,
6778 'dialect1' for dialect #1, etc. If there are fewer alternatives within the
6779 braces than the number of dialects the compiler supports, the construct
6782 For example, if an x86 compiler supports two dialects (att, intel), an
6783 assembler template such as this:
6786 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
6789 would produce the output:
6792 For att: "btl %[Offset],%[Base] ; jc %l2"
6793 For intel: "bt %[Base],%[Offset]; jc %l2"
6796 Using that same compiler, this code:
6799 "xchg@{l@}\t@{%%@}ebx, %1"
6805 For att: "xchgl\t%%ebx, %1"
6806 For intel: "xchg\tebx, %1"
6809 There is no support for nesting dialect alternatives. Also, there is no
6810 ``escape'' for an open brace (@{), so do not use open braces in an Extended
6811 @code{asm} template other than as a dialect indicator.
6813 @subsubheading Other format strings
6815 In addition to the tokens described by the input, output, and goto operands,
6816 there are a few special cases:
6820 "%%" outputs a single "%" into the assembler code.
6823 "%=" outputs a number that is unique to each instance of the @code{asm}
6824 statement in the entire compilation. This option is useful when creating local
6825 labels and referring to them multiple times in a single template that
6826 generates multiple assembler instructions.
6830 @anchor{OutputOperands}
6831 @subsubsection Output Operands
6832 @cindex @code{asm} output operands
6834 An @code{asm} statement has zero or more output operands indicating the names
6835 of C variables modified by the assembler code.
6837 In this i386 example, @var{old} (referred to in the template string as
6838 @code{%0}) and @var{*Base} (as @code{%1}) are outputs and @var{Offset}
6839 (@code{%2}) is an input:
6844 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
6845 "sbb %0,%0" // Use the CF to calculate old.
6846 : "=r" (old), "+rm" (*Base)
6853 Operands use this format:
6856 [ [asmSymbolicName] ] "constraint" (cvariablename)
6859 @emph{asmSymbolicName}
6862 When not using asmSymbolicNames, use the (zero-based) position of the operand
6863 in the list of operands in the assembler template. For example if there are
6864 three output operands, use @code{%0} in the template to refer to the first,
6865 @code{%1} for the second, and @code{%2} for the third. When using an
6866 asmSymbolicName, reference it by enclosing the name in square brackets
6867 (i.e. @code{%[Value]}). The scope of the name is the @code{asm} statement
6868 that contains the definition. Any valid C variable name is acceptable,
6869 including names already defined in the surrounding code. No two operands
6870 within the same @code{asm} statement can use the same symbolic name.
6874 Output constraints must begin with either @code{"="} (a variable overwriting an
6875 existing value) or @code{"+"} (when reading and writing). When using
6876 @code{"="}, do not assume the location will contain the existing value (except
6877 when tying the variable to an input; @pxref{InputOperands,,Input Operands}).
6879 After the prefix, there must be one or more additional constraints
6880 (@pxref{Constraints}) that describe where the value resides. Common
6881 constraints include @code{"r"} for register and @code{"m"} for memory.
6882 When you list more than one possible location (for example @code{"=rm"}), the
6883 compiler chooses the most efficient one based on the current context. If you
6884 list as many alternates as the @code{asm} statement allows, you will permit
6885 the optimizers to produce the best possible code. If you must use a specific
6886 register, but your Machine Constraints do not provide sufficient
6887 control to select the specific register you want, Local Reg Vars may provide
6888 a solution (@pxref{Local Reg Vars}).
6890 @emph{cvariablename}
6892 Specifies the C variable name of the output (enclosed by parentheses). Accepts
6893 any (non-constant) variable within scope.
6897 The total number of input + output + goto operands has a limit of 30. Commas
6898 separate the operands. When the compiler selects the registers to use to
6899 represent the output operands, it will not use any of the clobbered registers
6902 Output operand expressions must be lvalues. The compiler cannot check whether
6903 the operands have data types that are reasonable for the instruction being
6904 executed. For output expressions that are not directly addressable (for
6905 example a bit-field), the constraint must allow a register. In that case, GCC
6906 uses the register as the output of the @code{asm}, and then stores that
6907 register into the output.
6909 Unless an output operand has the '@code{&}' constraint modifier
6910 (@pxref{Modifiers}), GCC may allocate it in the same register as an unrelated
6911 input operand, on the assumption that the assembler code will consume its
6912 inputs before producing outputs. This assumption may be false if the assembler
6913 code actually consists of more than one instruction. In this case, use
6914 '@code{&}' on each output operand that must not overlap an input.
6916 The same problem can occur if one output parameter (@var{a}) allows a register
6917 constraint and another output parameter (@var{b}) allows a memory constraint.
6918 The code generated by GCC to access the memory address in @var{b} can contain
6919 registers which @emph{might} be shared by @var{a}, and GCC considers those
6920 registers to be inputs to the asm. As above, GCC assumes that such input
6921 registers are consumed before any outputs are written. This assumption may
6922 result in incorrect behavior if the asm writes to @var{a} before using
6923 @var{b}. Combining the `@code{&}' constraint with the register constraint
6924 ensures that modifying @var{a} will not affect what address is referenced by
6925 @var{b}. Omitting the `@code{&}' constraint means that the location of @var{b}
6926 will be undefined if @var{a} is modified before using @var{b}.
6928 @code{asm} supports operand modifiers on operands (for example @code{%k2}
6929 instead of simply @code{%2}). Typically these qualifiers are hardware
6930 dependent. The list of supported modifiers for x86 is found at
6931 @ref{x86Operandmodifiers,x86 Operand modifiers}.
6933 If the C code that follows the @code{asm} makes no use of any of the output
6934 operands, use @code{volatile} for the @code{asm} statement to prevent the
6935 optimizers from discarding the @code{asm} statement as unneeded
6936 (see @ref{Volatile}).
6940 This code makes no use of the optional asmSymbolicName. Therefore it
6941 references the first output operand as @code{%0} (were there a second, it
6942 would be @code{%1}, etc). The number of the first input operand is one greater
6943 than that of the last output operand. In this i386 example, that makes
6944 @var{Mask} @code{%1}:
6947 uint32_t Mask = 1234;
6956 That code overwrites the variable Index ("="), placing the value in a register
6957 ("r"). The generic "r" constraint instead of a constraint for a specific
6958 register allows the compiler to pick the register to use, which can result
6959 in more efficient code. This may not be possible if an assembler instruction
6960 requires a specific register.
6962 The following i386 example uses the asmSymbolicName operand. It produces the
6963 same result as the code above, but some may consider it more readable or more
6964 maintainable since reordering index numbers is not necessary when adding or
6965 removing operands. The names aIndex and aMask are only used to emphasize which
6966 names get used where. It is acceptable to reuse the names Index and Mask.
6969 uint32_t Mask = 1234;
6972 asm ("bsfl %[aMask], %[aIndex]"
6973 : [aIndex] "=r" (Index)
6974 : [aMask] "r" (Mask)
6978 Here are some more examples of output operands.
6985 asm ("mov %[e], %[d]"
6990 Here, @var{d} may either be in a register or in memory. Since the compiler
6991 might already have the current value of the uint32_t pointed to by @var{e}
6992 in a register, you can enable it to choose the best location
6993 for @var{d} by specifying both constraints.
6995 @anchor{InputOperands}
6996 @subsubsection Input Operands
6997 @cindex @code{asm} input operands
6998 @cindex @code{asm} expressions
7000 Input operands make inputs from C variables and expressions available to the
7003 Specify input operands by using the format:
7006 [ [asmSymbolicName] ] "constraint" (cexpression)
7009 @emph{asmSymbolicName}
7011 When not using asmSymbolicNames, use the (zero-based) position of the operand
7012 in the list of operands, including outputs, in the assembler template. For
7013 example, if there are two output parameters and three inputs, @code{%2} refers
7014 to the first input, @code{%3} to the second, and @code{%4} to the third.
7015 When using an asmSymbolicName, reference it by enclosing the name in square
7016 brackets (e.g. @code{%[Value]}). The scope of the name is the @code{asm}
7017 statement that contains the definition. Any valid C variable name is
7018 acceptable, including names already defined in the surrounding code. No two
7019 operands within the same @code{asm} statement can use the same symbolic name.
7023 Input constraints must be a string containing one or more constraints
7024 (@pxref{Constraints}). When you give more than one possible constraint
7025 (for example, @code{"irm"}), the compiler will choose the most efficient
7026 method based on the current context. Input constraints may not begin with
7027 either "=" or "+". If you must use a specific register, but your Machine
7028 Constraints do not provide sufficient control to select the specific
7029 register you want, Local Reg Vars may provide a solution
7030 (@pxref{Local Reg Vars}).
7032 Input constraints can also be digits (for example, @code{"0"}). This indicates
7033 that the specified input will be in the same place as the output constraint
7034 at the (zero-based) index in the output constraint list. When using
7035 asmSymbolicNames for the output operands, you may use these names (enclosed
7036 in brackets []) instead of digits.
7040 This is the C variable or expression being passed to the @code{asm} statement
7043 When the compiler selects the registers to use to represent the input
7044 operands, it will not use any of the clobbered registers (@pxref{Clobbers}).
7046 If there are no output operands but there are input operands, place two
7047 consecutive colons where the output operands would go:
7050 __asm__ ("some instructions"
7055 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
7056 (except for inputs tied to outputs). The compiler assumes that on exit from
7057 the @code{asm} statement these operands will contain the same values as they
7058 had before executing the assembler. It is @emph{not} possible to use Clobbers
7059 to inform the compiler that the values in these inputs are changing. One
7060 common work-around is to tie the changing input variable to an output variable
7061 that never gets used. Note, however, that if the code that follows the
7062 @code{asm} statement makes no use of any of the output operands, the GCC
7063 optimizers may discard the @code{asm} statement as unneeded
7064 (see @ref{Volatile}).
7068 The total number of input + output + goto operands has a limit of 30.
7070 @code{asm} supports operand modifiers on operands (for example @code{%k2}
7071 instead of simply @code{%2}). Typically these qualifiers are hardware
7072 dependent. The list of supported modifiers for x86 is found at
7073 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7077 In this example using the fictitious @code{combine} instruction, the
7078 constraint @code{"0"} for input operand 1 says that it must occupy the same
7079 location as output operand 0. Only input operands may use numbers in
7080 constraints, and they must each refer to an output operand. Only a number (or
7081 the symbolic assembler name) in the constraint can guarantee that one operand
7082 is in the same place as another. The mere fact that @var{foo} is the value of
7083 both operands is not enough to guarantee that they are in the same place in
7084 the generated assembler code.
7087 asm ("combine %2, %0"
7089 : "0" (foo), "g" (bar));
7092 Here is an example using symbolic names.
7095 asm ("cmoveq %1, %2, %[result]"
7096 : [result] "=r"(result)
7097 : "r" (test), "r" (new), "[result]" (old));
7101 @subsubsection Clobbers
7102 @cindex @code{asm} clobbers
7104 While the compiler is aware of changes to entries listed in the output
7105 operands, the assembler code may modify more than just the outputs. For
7106 example, calculations may require additional registers, or the processor may
7107 overwrite a register as a side effect of a particular assembler instruction.
7108 In order to inform the compiler of these changes, list them in the clobber
7109 list. Clobber list items are either register names or the special clobbers
7110 (listed below). Each clobber list item is enclosed in double quotes and
7111 separated by commas.
7113 Clobber descriptions may not in any way overlap with an input or output
7114 operand. For example, you may not have an operand describing a register class
7115 with one member when listing that register in the clobber list. Variables
7116 declared to live in specific registers (@pxref{Explicit Reg Vars}), and used
7117 as @code{asm} input or output operands, must have no part mentioned in the
7118 clobber description. In particular, there is no way to specify that input
7119 operands get modified without also specifying them as output operands.
7121 When the compiler selects which registers to use to represent input and output
7122 operands, it will not use any of the clobbered registers. As a result,
7123 clobbered registers are available for any use in the assembler code.
7125 Here is a realistic example for the VAX showing the use of clobbered
7129 asm volatile ("movc3 %0, %1, %2"
7131 : "g" (from), "g" (to), "g" (count)
7132 : "r0", "r1", "r2", "r3", "r4", "r5");
7135 Also, there are two special clobber arguments:
7139 The @code{"cc"} clobber indicates that the assembler code modifies the flags
7140 register. On some machines, GCC represents the condition codes as a specific
7141 hardware register; "cc" serves to name this register. On other machines,
7142 condition code handling is different, and specifying "cc" has no effect. But
7143 it is valid no matter what the machine.
7146 The "memory" clobber tells the compiler that the assembly code performs memory
7147 reads or writes to items other than those listed in the input and output
7148 operands (for example accessing the memory pointed to by one of the input
7149 parameters). To ensure memory contains correct values, GCC may need to flush
7150 specific register values to memory before executing the @code{asm}. Further,
7151 the compiler will not assume that any values read from memory before an
7152 @code{asm} will remain unchanged after that @code{asm}; it will reload them as
7153 needed. This effectively forms a read/write memory barrier for the compiler.
7155 Note that this clobber does not prevent the @emph{processor} from doing
7156 speculative reads past the @code{asm} statement. To prevent that, you need
7157 processor-specific fence instructions.
7159 Flushing registers to memory has performance implications and may be an issue
7160 for time-sensitive code. One trick to avoid this is available if the size of
7161 the memory being accessed is known at compile time. For example, if accessing
7162 ten bytes of a string, use a memory input like:
7164 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7169 @subsubsection Goto Labels
7170 @cindex @code{asm} goto labels
7172 @code{asm goto} allows assembly code to jump to one or more C labels. The
7173 GotoLabels section in an @code{asm goto} statement contains a comma-separated
7174 list of all C labels to which the assembler code may jump. GCC assumes that
7175 @code{asm} execution falls through to the next statement (if this is not the
7176 case, consider using the @code{__builtin_unreachable} intrinsic after the
7177 @code{asm} statement). Optimization of @code{asm goto} may be improved by
7178 using the @code{hot} and @code{cold} label attributes (@pxref{Label
7179 Attributes}). The total number of input + output + goto operands has
7182 An @code{asm goto} statement can not have outputs (which means that the
7183 statement is implicitly volatile). This is due to an internal restriction of
7184 the compiler: control transfer instructions cannot have outputs. If the
7185 assembler code does modify anything, use the "memory" clobber to force the
7186 optimizers to flush all register values to memory, and reload them if
7187 necessary, after the @code{asm} statement.
7189 To reference a label, prefix it with @code{%l} (that's a lowercase L) followed
7190 by its (zero-based) position in GotoLabels plus the number of input
7191 arguments. For example, if the @code{asm} has three inputs and references two
7192 labels, refer to the first label as @code{%l3} and the second as @code{%l4}).
7194 @code{asm} statements may not perform jumps into other @code{asm} statements.
7195 GCC's optimizers do not know about these jumps; therefore they cannot take
7196 account of them when deciding how to optimize.
7198 Example code for i386 might look like:
7205 : "r" (p1), "r" (p2)
7215 The following example shows an @code{asm goto} that uses the memory clobber.
7221 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
7232 @anchor{x86Operandmodifiers}
7233 @subsubsection x86 Operand modifiers
7235 Input, output, and goto operands for extended @code{asm} statements can use
7236 modifiers to affect the code output to the assembler. For example, the
7237 following code uses the "h" and "b" modifiers for x86:
7241 asm volatile ("xchg %h0, %b0" : "+a" (num) );
7244 These modifiers generate this assembler code:
7250 The rest of this discussion uses the following code for illustrative purposes.
7259 asm volatile goto ("some assembler instructions here"
7261 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7262 : /* No clobbers. */
7267 With no modifiers, this is what the output from the operands would be for the
7268 att and intel dialects of assembler:
7270 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7271 @headitem Operand @tab masm=att @tab masm=intel
7280 @tab @code{OFFSET FLAT:.L2}
7283 The table below shows the list of supported modifiers and their effects.
7285 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7286 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7288 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7293 @tab Print the QImode name of the register.
7298 @tab Print the QImode name for a ``high'' register.
7303 @tab Print the HImode name of the register.
7308 @tab Print the SImode name of the register.
7313 @tab Print the DImode name of the register.
7318 @tab Print the label name with no punctuation.
7323 @tab Require a constant operand and print the constant expression with no punctuation.
7329 @anchor{x86floatingpointasmoperands}
7330 @subsubsection x86 floating-point asm operands
7332 On x86 targets, there are several rules on the usage of stack-like registers
7333 in the operands of an @code{asm}. These rules apply only to the operands
7334 that are stack-like registers:
7338 Given a set of input registers that die in an @code{asm}, it is
7339 necessary to know which are implicitly popped by the @code{asm}, and
7340 which must be explicitly popped by GCC@.
7342 An input register that is implicitly popped by the @code{asm} must be
7343 explicitly clobbered, unless it is constrained to match an
7347 For any input register that is implicitly popped by an @code{asm}, it is
7348 necessary to know how to adjust the stack to compensate for the pop.
7349 If any non-popped input is closer to the top of the reg-stack than
7350 the implicitly popped register, it would not be possible to know what the
7351 stack looked like---it's not clear how the rest of the stack ``slides
7354 All implicitly popped input registers must be closer to the top of
7355 the reg-stack than any input that is not implicitly popped.
7357 It is possible that if an input dies in an @code{asm}, the compiler might
7358 use the input register for an output reload. Consider this example:
7361 asm ("foo" : "=t" (a) : "f" (b));
7365 This code says that input @code{b} is not popped by the @code{asm}, and that
7366 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7367 deeper after the @code{asm} than it was before. But, it is possible that
7368 reload may think that it can use the same register for both the input and
7371 To prevent this from happening,
7372 if any input operand uses the @code{f} constraint, all output register
7373 constraints must use the @code{&} early-clobber modifier.
7375 The example above would be correctly written as:
7378 asm ("foo" : "=&t" (a) : "f" (b));
7382 Some operands need to be in particular places on the stack. All
7383 output operands fall in this category---GCC has no other way to
7384 know which registers the outputs appear in unless you indicate
7385 this in the constraints.
7387 Output operands must specifically indicate which register an output
7388 appears in after an @code{asm}. @code{=f} is not allowed: the operand
7389 constraints must select a class with a single register.
7392 Output operands may not be ``inserted'' between existing stack registers.
7393 Since no 387 opcode uses a read/write operand, all output operands
7394 are dead before the @code{asm}, and are pushed by the @code{asm}.
7395 It makes no sense to push anywhere but the top of the reg-stack.
7397 Output operands must start at the top of the reg-stack: output
7398 operands may not ``skip'' a register.
7401 Some @code{asm} statements may need extra stack space for internal
7402 calculations. This can be guaranteed by clobbering stack registers
7403 unrelated to the inputs and outputs.
7407 Here are a couple of reasonable @code{asm}s to want to write. This
7409 takes one input, which is internally popped, and produces two outputs.
7412 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
7416 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
7417 and replaces them with one output. The @code{st(1)} clobber is necessary
7418 for the compiler to know that @code{fyl2xp1} pops both inputs.
7421 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
7429 @subsection Controlling Names Used in Assembler Code
7430 @cindex assembler names for identifiers
7431 @cindex names used in assembler code
7432 @cindex identifiers, names in assembler code
7434 You can specify the name to be used in the assembler code for a C
7435 function or variable by writing the @code{asm} (or @code{__asm__})
7436 keyword after the declarator as follows:
7439 int foo asm ("myfoo") = 2;
7443 This specifies that the name to be used for the variable @code{foo} in
7444 the assembler code should be @samp{myfoo} rather than the usual
7447 On systems where an underscore is normally prepended to the name of a C
7448 function or variable, this feature allows you to define names for the
7449 linker that do not start with an underscore.
7451 It does not make sense to use this feature with a non-static local
7452 variable since such variables do not have assembler names. If you are
7453 trying to put the variable in a particular register, see @ref{Explicit
7454 Reg Vars}. GCC presently accepts such code with a warning, but will
7455 probably be changed to issue an error, rather than a warning, in the
7458 You cannot use @code{asm} in this way in a function @emph{definition}; but
7459 you can get the same effect by writing a declaration for the function
7460 before its definition and putting @code{asm} there, like this:
7463 extern func () asm ("FUNC");
7470 It is up to you to make sure that the assembler names you choose do not
7471 conflict with any other assembler symbols. Also, you must not use a
7472 register name; that would produce completely invalid assembler code. GCC
7473 does not as yet have the ability to store static variables in registers.
7474 Perhaps that will be added.
7476 @node Explicit Reg Vars
7477 @subsection Variables in Specified Registers
7478 @cindex explicit register variables
7479 @cindex variables in specified registers
7480 @cindex specified registers
7481 @cindex registers, global allocation
7483 GNU C allows you to put a few global variables into specified hardware
7484 registers. You can also specify the register in which an ordinary
7485 register variable should be allocated.
7489 Global register variables reserve registers throughout the program.
7490 This may be useful in programs such as programming language
7491 interpreters that have a couple of global variables that are accessed
7495 Local register variables in specific registers do not reserve the
7496 registers, except at the point where they are used as input or output
7497 operands in an @code{asm} statement and the @code{asm} statement itself is
7498 not deleted. The compiler's data flow analysis is capable of determining
7499 where the specified registers contain live values, and where they are
7500 available for other uses. Stores into local register variables may be deleted
7501 when they appear to be dead according to dataflow analysis. References
7502 to local register variables may be deleted or moved or simplified.
7504 These local variables are sometimes convenient for use with the extended
7505 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
7506 output of the assembler instruction directly into a particular register.
7507 (This works provided the register you specify fits the constraints
7508 specified for that operand in the @code{asm}.)
7516 @node Global Reg Vars
7517 @subsubsection Defining Global Register Variables
7518 @cindex global register variables
7519 @cindex registers, global variables in
7521 You can define a global register variable in GNU C like this:
7524 register int *foo asm ("a5");
7528 Here @code{a5} is the name of the register that should be used. Choose a
7529 register that is normally saved and restored by function calls on your
7530 machine, so that library routines will not clobber it.
7532 Naturally the register name is cpu-dependent, so you need to
7533 conditionalize your program according to cpu type. The register
7534 @code{a5} is a good choice on a 68000 for a variable of pointer
7535 type. On machines with register windows, be sure to choose a ``global''
7536 register that is not affected magically by the function call mechanism.
7538 In addition, different operating systems on the same CPU may differ in how they
7539 name the registers; then you need additional conditionals. For
7540 example, some 68000 operating systems call this register @code{%a5}.
7542 Eventually there may be a way of asking the compiler to choose a register
7543 automatically, but first we need to figure out how it should choose and
7544 how to enable you to guide the choice. No solution is evident.
7546 Defining a global register variable in a certain register reserves that
7547 register entirely for this use, at least within the current compilation.
7548 The register is not allocated for any other purpose in the functions
7549 in the current compilation, and is not saved and restored by
7550 these functions. Stores into this register are never deleted even if they
7551 appear to be dead, but references may be deleted or moved or
7554 It is not safe to access the global register variables from signal
7555 handlers, or from more than one thread of control, because the system
7556 library routines may temporarily use the register for other things (unless
7557 you recompile them specially for the task at hand).
7559 @cindex @code{qsort}, and global register variables
7560 It is not safe for one function that uses a global register variable to
7561 call another such function @code{foo} by way of a third function
7562 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
7563 different source file in which the variable isn't declared). This is
7564 because @code{lose} might save the register and put some other value there.
7565 For example, you can't expect a global register variable to be available in
7566 the comparison-function that you pass to @code{qsort}, since @code{qsort}
7567 might have put something else in that register. (If you are prepared to
7568 recompile @code{qsort} with the same global register variable, you can
7569 solve this problem.)
7571 If you want to recompile @code{qsort} or other source files that do not
7572 actually use your global register variable, so that they do not use that
7573 register for any other purpose, then it suffices to specify the compiler
7574 option @option{-ffixed-@var{reg}}. You need not actually add a global
7575 register declaration to their source code.
7577 A function that can alter the value of a global register variable cannot
7578 safely be called from a function compiled without this variable, because it
7579 could clobber the value the caller expects to find there on return.
7580 Therefore, the function that is the entry point into the part of the
7581 program that uses the global register variable must explicitly save and
7582 restore the value that belongs to its caller.
7584 @cindex register variable after @code{longjmp}
7585 @cindex global register after @code{longjmp}
7586 @cindex value after @code{longjmp}
7589 On most machines, @code{longjmp} restores to each global register
7590 variable the value it had at the time of the @code{setjmp}. On some
7591 machines, however, @code{longjmp} does not change the value of global
7592 register variables. To be portable, the function that called @code{setjmp}
7593 should make other arrangements to save the values of the global register
7594 variables, and to restore them in a @code{longjmp}. This way, the same
7595 thing happens regardless of what @code{longjmp} does.
7597 All global register variable declarations must precede all function
7598 definitions. If such a declaration could appear after function
7599 definitions, the declaration would be too late to prevent the register from
7600 being used for other purposes in the preceding functions.
7602 Global register variables may not have initial values, because an
7603 executable file has no means to supply initial contents for a register.
7605 On the SPARC, there are reports that g3 @dots{} g7 are suitable
7606 registers, but certain library functions, such as @code{getwd}, as well
7607 as the subroutines for division and remainder, modify g3 and g4. g1 and
7608 g2 are local temporaries.
7610 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
7611 Of course, it does not do to use more than a few of those.
7613 @node Local Reg Vars
7614 @subsubsection Specifying Registers for Local Variables
7615 @cindex local variables, specifying registers
7616 @cindex specifying registers for local variables
7617 @cindex registers for local variables
7619 You can define a local register variable with a specified register
7623 register int *foo asm ("a5");
7627 Here @code{a5} is the name of the register that should be used. Note
7628 that this is the same syntax used for defining global register
7629 variables, but for a local variable it appears within a function.
7631 Naturally the register name is cpu-dependent, but this is not a
7632 problem, since specific registers are most often useful with explicit
7633 assembler instructions (@pxref{Extended Asm}). Both of these things
7634 generally require that you conditionalize your program according to
7637 In addition, operating systems on one type of cpu may differ in how they
7638 name the registers; then you need additional conditionals. For
7639 example, some 68000 operating systems call this register @code{%a5}.
7641 Defining such a register variable does not reserve the register; it
7642 remains available for other uses in places where flow control determines
7643 the variable's value is not live.
7645 This option does not guarantee that GCC generates code that has
7646 this variable in the register you specify at all times. You may not
7647 code an explicit reference to this register in the @emph{assembler
7648 instruction template} part of an @code{asm} statement and assume it
7649 always refers to this variable. However, using the variable as an
7650 @code{asm} @emph{operand} guarantees that the specified register is used
7653 Stores into local register variables may be deleted when they appear to be dead
7654 according to dataflow analysis. References to local register variables may
7655 be deleted or moved or simplified.
7657 As with global register variables, it is recommended that you choose a
7658 register that is normally saved and restored by function calls on
7659 your machine, so that library routines will not clobber it.
7661 Sometimes when writing inline @code{asm} code, you need to make an operand be a
7662 specific register, but there's no matching constraint letter for that
7663 register. To force the operand into that register, create a local variable
7664 and specify the register in the variable's declaration. Then use the local
7665 variable for the asm operand and specify any constraint letter that matches
7669 register int *p1 asm ("r0") = @dots{};
7670 register int *p2 asm ("r1") = @dots{};
7671 register int *result asm ("r0");
7672 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7675 @emph{Warning:} In the above example, be aware that a register (for example r0) can be
7676 call-clobbered by subsequent code, including function calls and library calls
7677 for arithmetic operators on other variables (for example the initialization
7678 of p2). In this case, use temporary variables for expressions between the
7679 register assignments:
7683 register int *p1 asm ("r0") = @dots{};
7684 register int *p2 asm ("r1") = t1;
7685 register int *result asm ("r0");
7686 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7689 @node Size of an asm
7690 @subsection Size of an @code{asm}
7692 Some targets require that GCC track the size of each instruction used
7693 in order to generate correct code. Because the final length of the
7694 code produced by an @code{asm} statement is only known by the
7695 assembler, GCC must make an estimate as to how big it will be. It
7696 does this by counting the number of instructions in the pattern of the
7697 @code{asm} and multiplying that by the length of the longest
7698 instruction supported by that processor. (When working out the number
7699 of instructions, it assumes that any occurrence of a newline or of
7700 whatever statement separator character is supported by the assembler --
7701 typically @samp{;} --- indicates the end of an instruction.)
7703 Normally, GCC's estimate is adequate to ensure that correct
7704 code is generated, but it is possible to confuse the compiler if you use
7705 pseudo instructions or assembler macros that expand into multiple real
7706 instructions, or if you use assembler directives that expand to more
7707 space in the object file than is needed for a single instruction.
7708 If this happens then the assembler may produce a diagnostic saying that
7709 a label is unreachable.
7711 @node Alternate Keywords
7712 @section Alternate Keywords
7713 @cindex alternate keywords
7714 @cindex keywords, alternate
7716 @option{-ansi} and the various @option{-std} options disable certain
7717 keywords. This causes trouble when you want to use GNU C extensions, or
7718 a general-purpose header file that should be usable by all programs,
7719 including ISO C programs. The keywords @code{asm}, @code{typeof} and
7720 @code{inline} are not available in programs compiled with
7721 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
7722 program compiled with @option{-std=c99} or @option{-std=c11}). The
7724 @code{restrict} is only available when @option{-std=gnu99} (which will
7725 eventually be the default) or @option{-std=c99} (or the equivalent
7726 @option{-std=iso9899:1999}), or an option for a later standard
7729 The way to solve these problems is to put @samp{__} at the beginning and
7730 end of each problematical keyword. For example, use @code{__asm__}
7731 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
7733 Other C compilers won't accept these alternative keywords; if you want to
7734 compile with another compiler, you can define the alternate keywords as
7735 macros to replace them with the customary keywords. It looks like this:
7743 @findex __extension__
7745 @option{-pedantic} and other options cause warnings for many GNU C extensions.
7747 prevent such warnings within one expression by writing
7748 @code{__extension__} before the expression. @code{__extension__} has no
7749 effect aside from this.
7751 @node Incomplete Enums
7752 @section Incomplete @code{enum} Types
7754 You can define an @code{enum} tag without specifying its possible values.
7755 This results in an incomplete type, much like what you get if you write
7756 @code{struct foo} without describing the elements. A later declaration
7757 that does specify the possible values completes the type.
7759 You can't allocate variables or storage using the type while it is
7760 incomplete. However, you can work with pointers to that type.
7762 This extension may not be very useful, but it makes the handling of
7763 @code{enum} more consistent with the way @code{struct} and @code{union}
7766 This extension is not supported by GNU C++.
7768 @node Function Names
7769 @section Function Names as Strings
7770 @cindex @code{__func__} identifier
7771 @cindex @code{__FUNCTION__} identifier
7772 @cindex @code{__PRETTY_FUNCTION__} identifier
7774 GCC provides three magic variables that hold the name of the current
7775 function, as a string. The first of these is @code{__func__}, which
7776 is part of the C99 standard:
7778 The identifier @code{__func__} is implicitly declared by the translator
7779 as if, immediately following the opening brace of each function
7780 definition, the declaration
7783 static const char __func__[] = "function-name";
7787 appeared, where function-name is the name of the lexically-enclosing
7788 function. This name is the unadorned name of the function.
7790 @code{__FUNCTION__} is another name for @code{__func__}. Older
7791 versions of GCC recognize only this name. However, it is not
7792 standardized. For maximum portability, we recommend you use
7793 @code{__func__}, but provide a fallback definition with the
7797 #if __STDC_VERSION__ < 199901L
7799 # define __func__ __FUNCTION__
7801 # define __func__ "<unknown>"
7806 In C, @code{__PRETTY_FUNCTION__} is yet another name for
7807 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
7808 the type signature of the function as well as its bare name. For
7809 example, this program:
7813 extern int printf (char *, ...);
7820 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
7821 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
7839 __PRETTY_FUNCTION__ = void a::sub(int)
7842 These identifiers are not preprocessor macros. In GCC 3.3 and
7843 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
7844 were treated as string literals; they could be used to initialize
7845 @code{char} arrays, and they could be concatenated with other string
7846 literals. GCC 3.4 and later treat them as variables, like
7847 @code{__func__}. In C++, @code{__FUNCTION__} and
7848 @code{__PRETTY_FUNCTION__} have always been variables.
7850 @node Return Address
7851 @section Getting the Return or Frame Address of a Function
7853 These functions may be used to get information about the callers of a
7856 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7857 This function returns the return address of the current function, or of
7858 one of its callers. The @var{level} argument is number of frames to
7859 scan up the call stack. A value of @code{0} yields the return address
7860 of the current function, a value of @code{1} yields the return address
7861 of the caller of the current function, and so forth. When inlining
7862 the expected behavior is that the function returns the address of
7863 the function that is returned to. To work around this behavior use
7864 the @code{noinline} function attribute.
7866 The @var{level} argument must be a constant integer.
7868 On some machines it may be impossible to determine the return address of
7869 any function other than the current one; in such cases, or when the top
7870 of the stack has been reached, this function returns @code{0} or a
7871 random value. In addition, @code{__builtin_frame_address} may be used
7872 to determine if the top of the stack has been reached.
7874 Additional post-processing of the returned value may be needed, see
7875 @code{__builtin_extract_return_addr}.
7877 This function should only be used with a nonzero argument for debugging
7881 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7882 The address as returned by @code{__builtin_return_address} may have to be fed
7883 through this function to get the actual encoded address. For example, on the
7884 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7885 platforms an offset has to be added for the true next instruction to be
7888 If no fixup is needed, this function simply passes through @var{addr}.
7891 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7892 This function does the reverse of @code{__builtin_extract_return_addr}.
7895 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7896 This function is similar to @code{__builtin_return_address}, but it
7897 returns the address of the function frame rather than the return address
7898 of the function. Calling @code{__builtin_frame_address} with a value of
7899 @code{0} yields the frame address of the current function, a value of
7900 @code{1} yields the frame address of the caller of the current function,
7903 The frame is the area on the stack that holds local variables and saved
7904 registers. The frame address is normally the address of the first word
7905 pushed on to the stack by the function. However, the exact definition
7906 depends upon the processor and the calling convention. If the processor
7907 has a dedicated frame pointer register, and the function has a frame,
7908 then @code{__builtin_frame_address} returns the value of the frame
7911 On some machines it may be impossible to determine the frame address of
7912 any function other than the current one; in such cases, or when the top
7913 of the stack has been reached, this function returns @code{0} if
7914 the first frame pointer is properly initialized by the startup code.
7916 This function should only be used with a nonzero argument for debugging
7920 @node Vector Extensions
7921 @section Using Vector Instructions through Built-in Functions
7923 On some targets, the instruction set contains SIMD vector instructions which
7924 operate on multiple values contained in one large register at the same time.
7925 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
7928 The first step in using these extensions is to provide the necessary data
7929 types. This should be done using an appropriate @code{typedef}:
7932 typedef int v4si __attribute__ ((vector_size (16)));
7936 The @code{int} type specifies the base type, while the attribute specifies
7937 the vector size for the variable, measured in bytes. For example, the
7938 declaration above causes the compiler to set the mode for the @code{v4si}
7939 type to be 16 bytes wide and divided into @code{int} sized units. For
7940 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7941 corresponding mode of @code{foo} is @acronym{V4SI}.
7943 The @code{vector_size} attribute is only applicable to integral and
7944 float scalars, although arrays, pointers, and function return values
7945 are allowed in conjunction with this construct. Only sizes that are
7946 a power of two are currently allowed.
7948 All the basic integer types can be used as base types, both as signed
7949 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7950 @code{long long}. In addition, @code{float} and @code{double} can be
7951 used to build floating-point vector types.
7953 Specifying a combination that is not valid for the current architecture
7954 causes GCC to synthesize the instructions using a narrower mode.
7955 For example, if you specify a variable of type @code{V4SI} and your
7956 architecture does not allow for this specific SIMD type, GCC
7957 produces code that uses 4 @code{SIs}.
7959 The types defined in this manner can be used with a subset of normal C
7960 operations. Currently, GCC allows using the following operators
7961 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7963 The operations behave like C++ @code{valarrays}. Addition is defined as
7964 the addition of the corresponding elements of the operands. For
7965 example, in the code below, each of the 4 elements in @var{a} is
7966 added to the corresponding 4 elements in @var{b} and the resulting
7967 vector is stored in @var{c}.
7970 typedef int v4si __attribute__ ((vector_size (16)));
7977 Subtraction, multiplication, division, and the logical operations
7978 operate in a similar manner. Likewise, the result of using the unary
7979 minus or complement operators on a vector type is a vector whose
7980 elements are the negative or complemented values of the corresponding
7981 elements in the operand.
7983 It is possible to use shifting operators @code{<<}, @code{>>} on
7984 integer-type vectors. The operation is defined as following: @code{@{a0,
7985 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7986 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7989 For convenience, it is allowed to use a binary vector operation
7990 where one operand is a scalar. In that case the compiler transforms
7991 the scalar operand into a vector where each element is the scalar from
7992 the operation. The transformation happens only if the scalar could be
7993 safely converted to the vector-element type.
7994 Consider the following code.
7997 typedef int v4si __attribute__ ((vector_size (16)));
8002 a = b + 1; /* a = b + @{1,1,1,1@}; */
8003 a = 2 * b; /* a = @{2,2,2,2@} * b; */
8005 a = l + a; /* Error, cannot convert long to int. */
8008 Vectors can be subscripted as if the vector were an array with
8009 the same number of elements and base type. Out of bound accesses
8010 invoke undefined behavior at run time. Warnings for out of bound
8011 accesses for vector subscription can be enabled with
8012 @option{-Warray-bounds}.
8014 Vector comparison is supported with standard comparison
8015 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
8016 vector expressions of integer-type or real-type. Comparison between
8017 integer-type vectors and real-type vectors are not supported. The
8018 result of the comparison is a vector of the same width and number of
8019 elements as the comparison operands with a signed integral element
8022 Vectors are compared element-wise producing 0 when comparison is false
8023 and -1 (constant of the appropriate type where all bits are set)
8024 otherwise. Consider the following example.
8027 typedef int v4si __attribute__ ((vector_size (16)));
8029 v4si a = @{1,2,3,4@};
8030 v4si b = @{3,2,1,4@};
8033 c = a > b; /* The result would be @{0, 0,-1, 0@} */
8034 c = a == b; /* The result would be @{0,-1, 0,-1@} */
8037 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
8038 @code{b} and @code{c} are vectors of the same type and @code{a} is an
8039 integer vector with the same number of elements of the same size as @code{b}
8040 and @code{c}, computes all three arguments and creates a vector
8041 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
8042 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
8043 As in the case of binary operations, this syntax is also accepted when
8044 one of @code{b} or @code{c} is a scalar that is then transformed into a
8045 vector. If both @code{b} and @code{c} are scalars and the type of
8046 @code{true?b:c} has the same size as the element type of @code{a}, then
8047 @code{b} and @code{c} are converted to a vector type whose elements have
8048 this type and with the same number of elements as @code{a}.
8050 In C++, the logic operators @code{!, &&, ||} are available for vectors.
8051 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
8052 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
8053 For mixed operations between a scalar @code{s} and a vector @code{v},
8054 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
8055 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
8057 Vector shuffling is available using functions
8058 @code{__builtin_shuffle (vec, mask)} and
8059 @code{__builtin_shuffle (vec0, vec1, mask)}.
8060 Both functions construct a permutation of elements from one or two
8061 vectors and return a vector of the same type as the input vector(s).
8062 The @var{mask} is an integral vector with the same width (@var{W})
8063 and element count (@var{N}) as the output vector.
8065 The elements of the input vectors are numbered in memory ordering of
8066 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
8067 elements of @var{mask} are considered modulo @var{N} in the single-operand
8068 case and modulo @math{2*@var{N}} in the two-operand case.
8070 Consider the following example,
8073 typedef int v4si __attribute__ ((vector_size (16)));
8075 v4si a = @{1,2,3,4@};
8076 v4si b = @{5,6,7,8@};
8077 v4si mask1 = @{0,1,1,3@};
8078 v4si mask2 = @{0,4,2,5@};
8081 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
8082 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
8085 Note that @code{__builtin_shuffle} is intentionally semantically
8086 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
8088 You can declare variables and use them in function calls and returns, as
8089 well as in assignments and some casts. You can specify a vector type as
8090 a return type for a function. Vector types can also be used as function
8091 arguments. It is possible to cast from one vector type to another,
8092 provided they are of the same size (in fact, you can also cast vectors
8093 to and from other datatypes of the same size).
8095 You cannot operate between vectors of different lengths or different
8096 signedness without a cast.
8100 @findex __builtin_offsetof
8102 GCC implements for both C and C++ a syntactic extension to implement
8103 the @code{offsetof} macro.
8107 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
8109 offsetof_member_designator:
8111 | offsetof_member_designator "." @code{identifier}
8112 | offsetof_member_designator "[" @code{expr} "]"
8115 This extension is sufficient such that
8118 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
8122 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
8123 may be dependent. In either case, @var{member} may consist of a single
8124 identifier, or a sequence of member accesses and array references.
8126 @node __sync Builtins
8127 @section Legacy __sync Built-in Functions for Atomic Memory Access
8129 The following built-in functions
8130 are intended to be compatible with those described
8131 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
8132 section 7.4. As such, they depart from the normal GCC practice of using
8133 the @samp{__builtin_} prefix, and further that they are overloaded such that
8134 they work on multiple types.
8136 The definition given in the Intel documentation allows only for the use of
8137 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
8138 counterparts. GCC allows any integral scalar or pointer type that is
8139 1, 2, 4 or 8 bytes in length.
8141 Not all operations are supported by all target processors. If a particular
8142 operation cannot be implemented on the target processor, a warning is
8143 generated and a call an external function is generated. The external
8144 function carries the same name as the built-in version,
8145 with an additional suffix
8146 @samp{_@var{n}} where @var{n} is the size of the data type.
8148 @c ??? Should we have a mechanism to suppress this warning? This is almost
8149 @c useful for implementing the operation under the control of an external
8152 In most cases, these built-in functions are considered a @dfn{full barrier}.
8154 no memory operand is moved across the operation, either forward or
8155 backward. Further, instructions are issued as necessary to prevent the
8156 processor from speculating loads across the operation and from queuing stores
8157 after the operation.
8159 All of the routines are described in the Intel documentation to take
8160 ``an optional list of variables protected by the memory barrier''. It's
8161 not clear what is meant by that; it could mean that @emph{only} the
8162 following variables are protected, or it could mean that these variables
8163 should in addition be protected. At present GCC ignores this list and
8164 protects all variables that are globally accessible. If in the future
8165 we make some use of this list, an empty list will continue to mean all
8166 globally accessible variables.
8169 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8170 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8171 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8172 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8173 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8174 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8175 @findex __sync_fetch_and_add
8176 @findex __sync_fetch_and_sub
8177 @findex __sync_fetch_and_or
8178 @findex __sync_fetch_and_and
8179 @findex __sync_fetch_and_xor
8180 @findex __sync_fetch_and_nand
8181 These built-in functions perform the operation suggested by the name, and
8182 returns the value that had previously been in memory. That is,
8185 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8186 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
8189 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8190 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8192 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8193 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8194 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8195 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8196 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8197 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8198 @findex __sync_add_and_fetch
8199 @findex __sync_sub_and_fetch
8200 @findex __sync_or_and_fetch
8201 @findex __sync_and_and_fetch
8202 @findex __sync_xor_and_fetch
8203 @findex __sync_nand_and_fetch
8204 These built-in functions perform the operation suggested by the name, and
8205 return the new value. That is,
8208 @{ *ptr @var{op}= value; return *ptr; @}
8209 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
8212 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8213 as @code{*ptr = ~(*ptr & value)} instead of
8214 @code{*ptr = ~*ptr & value}.
8216 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8217 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8218 @findex __sync_bool_compare_and_swap
8219 @findex __sync_val_compare_and_swap
8220 These built-in functions perform an atomic compare and swap.
8221 That is, if the current
8222 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8225 The ``bool'' version returns true if the comparison is successful and
8226 @var{newval} is written. The ``val'' version returns the contents
8227 of @code{*@var{ptr}} before the operation.
8229 @item __sync_synchronize (...)
8230 @findex __sync_synchronize
8231 This built-in function issues a full memory barrier.
8233 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
8234 @findex __sync_lock_test_and_set
8235 This built-in function, as described by Intel, is not a traditional test-and-set
8236 operation, but rather an atomic exchange operation. It writes @var{value}
8237 into @code{*@var{ptr}}, and returns the previous contents of
8240 Many targets have only minimal support for such locks, and do not support
8241 a full exchange operation. In this case, a target may support reduced
8242 functionality here by which the @emph{only} valid value to store is the
8243 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
8244 is implementation defined.
8246 This built-in function is not a full barrier,
8247 but rather an @dfn{acquire barrier}.
8248 This means that references after the operation cannot move to (or be
8249 speculated to) before the operation, but previous memory stores may not
8250 be globally visible yet, and previous memory loads may not yet be
8253 @item void __sync_lock_release (@var{type} *ptr, ...)
8254 @findex __sync_lock_release
8255 This built-in function releases the lock acquired by
8256 @code{__sync_lock_test_and_set}.
8257 Normally this means writing the constant 0 to @code{*@var{ptr}}.
8259 This built-in function is not a full barrier,
8260 but rather a @dfn{release barrier}.
8261 This means that all previous memory stores are globally visible, and all
8262 previous memory loads have been satisfied, but following memory reads
8263 are not prevented from being speculated to before the barrier.
8266 @node __atomic Builtins
8267 @section Built-in functions for memory model aware atomic operations
8269 The following built-in functions approximately match the requirements for
8270 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
8271 functions, but all also have a memory model parameter. These are all
8272 identified by being prefixed with @samp{__atomic}, and most are overloaded
8273 such that they work with multiple types.
8275 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
8276 bytes in length. 16-byte integral types are also allowed if
8277 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
8279 Target architectures are encouraged to provide their own patterns for
8280 each of these built-in functions. If no target is provided, the original
8281 non-memory model set of @samp{__sync} atomic built-in functions are
8282 utilized, along with any required synchronization fences surrounding it in
8283 order to achieve the proper behavior. Execution in this case is subject
8284 to the same restrictions as those built-in functions.
8286 If there is no pattern or mechanism to provide a lock free instruction
8287 sequence, a call is made to an external routine with the same parameters
8288 to be resolved at run time.
8290 The four non-arithmetic functions (load, store, exchange, and
8291 compare_exchange) all have a generic version as well. This generic
8292 version works on any data type. If the data type size maps to one
8293 of the integral sizes that may have lock free support, the generic
8294 version utilizes the lock free built-in function. Otherwise an
8295 external call is left to be resolved at run time. This external call is
8296 the same format with the addition of a @samp{size_t} parameter inserted
8297 as the first parameter indicating the size of the object being pointed to.
8298 All objects must be the same size.
8300 There are 6 different memory models that can be specified. These map
8301 to the same names in the C++11 standard. Refer there or to the
8302 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
8303 atomic synchronization} for more detailed definitions. These memory
8304 models integrate both barriers to code motion as well as synchronization
8305 requirements with other threads. These are listed in approximately
8306 ascending order of strength. It is also possible to use target specific
8307 flags for memory model flags, like Hardware Lock Elision.
8310 @item __ATOMIC_RELAXED
8311 No barriers or synchronization.
8312 @item __ATOMIC_CONSUME
8313 Data dependency only for both barrier and synchronization with another
8315 @item __ATOMIC_ACQUIRE
8316 Barrier to hoisting of code and synchronizes with release (or stronger)
8317 semantic stores from another thread.
8318 @item __ATOMIC_RELEASE
8319 Barrier to sinking of code and synchronizes with acquire (or stronger)
8320 semantic loads from another thread.
8321 @item __ATOMIC_ACQ_REL
8322 Full barrier in both directions and synchronizes with acquire loads and
8323 release stores in another thread.
8324 @item __ATOMIC_SEQ_CST
8325 Full barrier in both directions and synchronizes with acquire loads and
8326 release stores in all threads.
8329 When implementing patterns for these built-in functions, the memory model
8330 parameter can be ignored as long as the pattern implements the most
8331 restrictive @code{__ATOMIC_SEQ_CST} model. Any of the other memory models
8332 execute correctly with this memory model but they may not execute as
8333 efficiently as they could with a more appropriate implementation of the
8334 relaxed requirements.
8336 Note that the C++11 standard allows for the memory model parameter to be
8337 determined at run time rather than at compile time. These built-in
8338 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8339 than invoke a runtime library call or inline a switch statement. This is
8340 standard compliant, safe, and the simplest approach for now.
8342 The memory model parameter is a signed int, but only the lower 8 bits are
8343 reserved for the memory model. The remainder of the signed int is reserved
8344 for future use and should be 0. Use of the predefined atomic values
8345 ensures proper usage.
8347 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8348 This built-in function implements an atomic load operation. It returns the
8349 contents of @code{*@var{ptr}}.
8351 The valid memory model variants are
8352 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8353 and @code{__ATOMIC_CONSUME}.
8357 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8358 This is the generic version of an atomic load. It returns the
8359 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8363 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8364 This built-in function implements an atomic store operation. It writes
8365 @code{@var{val}} into @code{*@var{ptr}}.
8367 The valid memory model variants are
8368 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8372 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8373 This is the generic version of an atomic store. It stores the value
8374 of @code{*@var{val}} into @code{*@var{ptr}}.
8378 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8379 This built-in function implements an atomic exchange operation. It writes
8380 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8383 The valid memory model variants are
8384 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8385 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8389 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8390 This is the generic version of an atomic exchange. It stores the
8391 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8392 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
8396 @deftypefn {Built-in Function} bool __atomic_compare_exchange_n (@var{type} *ptr, @var{type} *expected, @var{type} desired, bool weak, int success_memmodel, int failure_memmodel)
8397 This built-in function implements an atomic compare and exchange operation.
8398 This compares the contents of @code{*@var{ptr}} with the contents of
8399 @code{*@var{expected}} and if equal, writes @var{desired} into
8400 @code{*@var{ptr}}. If they are not equal, the current contents of
8401 @code{*@var{ptr}} is written into @code{*@var{expected}}. @var{weak} is true
8402 for weak compare_exchange, and false for the strong variation. Many targets
8403 only offer the strong variation and ignore the parameter. When in doubt, use
8404 the strong variation.
8406 True is returned if @var{desired} is written into
8407 @code{*@var{ptr}} and the execution is considered to conform to the
8408 memory model specified by @var{success_memmodel}. There are no
8409 restrictions on what memory model can be used here.
8411 False is returned otherwise, and the execution is considered to conform
8412 to @var{failure_memmodel}. This memory model cannot be
8413 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
8414 stronger model than that specified by @var{success_memmodel}.
8418 @deftypefn {Built-in Function} bool __atomic_compare_exchange (@var{type} *ptr, @var{type} *expected, @var{type} *desired, bool weak, int success_memmodel, int failure_memmodel)
8419 This built-in function implements the generic version of
8420 @code{__atomic_compare_exchange}. The function is virtually identical to
8421 @code{__atomic_compare_exchange_n}, except the desired value is also a
8426 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8427 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8428 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8429 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8430 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8431 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8432 These built-in functions perform the operation suggested by the name, and
8433 return the result of the operation. That is,
8436 @{ *ptr @var{op}= val; return *ptr; @}
8439 All memory models are valid.
8443 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
8444 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
8445 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
8446 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
8447 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
8448 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
8449 These built-in functions perform the operation suggested by the name, and
8450 return the value that had previously been in @code{*@var{ptr}}. That is,
8453 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
8456 All memory models are valid.
8460 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
8462 This built-in function performs an atomic test-and-set operation on
8463 the byte at @code{*@var{ptr}}. The byte is set to some implementation
8464 defined nonzero ``set'' value and the return value is @code{true} if and only
8465 if the previous contents were ``set''.
8466 It should be only used for operands of type @code{bool} or @code{char}. For
8467 other types only part of the value may be set.
8469 All memory models are valid.
8473 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
8475 This built-in function performs an atomic clear operation on
8476 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
8477 It should be only used for operands of type @code{bool} or @code{char} and
8478 in conjunction with @code{__atomic_test_and_set}.
8479 For other types it may only clear partially. If the type is not @code{bool}
8480 prefer using @code{__atomic_store}.
8482 The valid memory model variants are
8483 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
8484 @code{__ATOMIC_RELEASE}.
8488 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
8490 This built-in function acts as a synchronization fence between threads
8491 based on the specified memory model.
8493 All memory orders are valid.
8497 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
8499 This built-in function acts as a synchronization fence between a thread
8500 and signal handlers based in the same thread.
8502 All memory orders are valid.
8506 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
8508 This built-in function returns true if objects of @var{size} bytes always
8509 generate lock free atomic instructions for the target architecture.
8510 @var{size} must resolve to a compile-time constant and the result also
8511 resolves to a compile-time constant.
8513 @var{ptr} is an optional pointer to the object that may be used to determine
8514 alignment. A value of 0 indicates typical alignment should be used. The
8515 compiler may also ignore this parameter.
8518 if (_atomic_always_lock_free (sizeof (long long), 0))
8523 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
8525 This built-in function returns true if objects of @var{size} bytes always
8526 generate lock free atomic instructions for the target architecture. If
8527 it is not known to be lock free a call is made to a runtime routine named
8528 @code{__atomic_is_lock_free}.
8530 @var{ptr} is an optional pointer to the object that may be used to determine
8531 alignment. A value of 0 indicates typical alignment should be used. The
8532 compiler may also ignore this parameter.
8535 @node Integer Overflow Builtins
8536 @section Built-in functions to perform arithmetics and arithmetic overflow checking.
8538 The following built-in functions allow performing simple arithmetic operations
8539 together with checking whether the operations overflowed.
8541 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8542 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
8543 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
8544 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
8545 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
8546 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8547 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8549 These built-in functions promote the first two operands into infinite precision signed
8550 type and perform addition on those promoted operands. The result is then
8551 cast to the type the third pointer argument points to and stored there.
8552 If the stored result is equal to the infinite precision result, the built-in
8553 functions return false, otherwise they return true. As the addition is
8554 performed in infinite signed precision, these built-in functions have fully defined
8555 behavior for all argument values.
8557 The first built-in function allows arbitrary integral types for operands and
8558 the result type must be pointer to some integer type, the rest of the built-in
8559 functions have explicit integer types.
8561 The compiler will attempt to use hardware instructions to implement
8562 these built-in functions where possible, like conditional jump on overflow
8563 after addition, conditional jump on carry etc.
8567 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8568 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
8569 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
8570 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
8571 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
8572 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8573 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8575 These built-in functions are similar to the add overflow checking built-in
8576 functions above, except they perform subtraction, subtract the second argument
8577 from the first one, instead of addition.
8581 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8582 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
8583 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
8584 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
8585 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
8586 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8587 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8589 These built-in functions are similar to the add overflow checking built-in
8590 functions above, except they perform multiplication, instead of addition.
8594 @node x86 specific memory model extensions for transactional memory
8595 @section x86 specific memory model extensions for transactional memory
8597 The x86 architecture supports additional memory ordering flags
8598 to mark lock critical sections for hardware lock elision.
8599 These must be specified in addition to an existing memory model to
8603 @item __ATOMIC_HLE_ACQUIRE
8604 Start lock elision on a lock variable.
8605 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
8606 @item __ATOMIC_HLE_RELEASE
8607 End lock elision on a lock variable.
8608 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
8611 When a lock acquire fails it is required for good performance to abort
8612 the transaction quickly. This can be done with a @code{_mm_pause}
8615 #include <immintrin.h> // For _mm_pause
8619 /* Acquire lock with lock elision */
8620 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
8621 _mm_pause(); /* Abort failed transaction */
8623 /* Free lock with lock elision */
8624 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
8627 @node Object Size Checking
8628 @section Object Size Checking Built-in Functions
8629 @findex __builtin_object_size
8630 @findex __builtin___memcpy_chk
8631 @findex __builtin___mempcpy_chk
8632 @findex __builtin___memmove_chk
8633 @findex __builtin___memset_chk
8634 @findex __builtin___strcpy_chk
8635 @findex __builtin___stpcpy_chk
8636 @findex __builtin___strncpy_chk
8637 @findex __builtin___strcat_chk
8638 @findex __builtin___strncat_chk
8639 @findex __builtin___sprintf_chk
8640 @findex __builtin___snprintf_chk
8641 @findex __builtin___vsprintf_chk
8642 @findex __builtin___vsnprintf_chk
8643 @findex __builtin___printf_chk
8644 @findex __builtin___vprintf_chk
8645 @findex __builtin___fprintf_chk
8646 @findex __builtin___vfprintf_chk
8648 GCC implements a limited buffer overflow protection mechanism
8649 that can prevent some buffer overflow attacks.
8651 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
8652 is a built-in construct that returns a constant number of bytes from
8653 @var{ptr} to the end of the object @var{ptr} pointer points to
8654 (if known at compile time). @code{__builtin_object_size} never evaluates
8655 its arguments for side-effects. If there are any side-effects in them, it
8656 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8657 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
8658 point to and all of them are known at compile time, the returned number
8659 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
8660 0 and minimum if nonzero. If it is not possible to determine which objects
8661 @var{ptr} points to at compile time, @code{__builtin_object_size} should
8662 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8663 for @var{type} 2 or 3.
8665 @var{type} is an integer constant from 0 to 3. If the least significant
8666 bit is clear, objects are whole variables, if it is set, a closest
8667 surrounding subobject is considered the object a pointer points to.
8668 The second bit determines if maximum or minimum of remaining bytes
8672 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
8673 char *p = &var.buf1[1], *q = &var.b;
8675 /* Here the object p points to is var. */
8676 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
8677 /* The subobject p points to is var.buf1. */
8678 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
8679 /* The object q points to is var. */
8680 assert (__builtin_object_size (q, 0)
8681 == (char *) (&var + 1) - (char *) &var.b);
8682 /* The subobject q points to is var.b. */
8683 assert (__builtin_object_size (q, 1) == sizeof (var.b));
8687 There are built-in functions added for many common string operation
8688 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
8689 built-in is provided. This built-in has an additional last argument,
8690 which is the number of bytes remaining in object the @var{dest}
8691 argument points to or @code{(size_t) -1} if the size is not known.
8693 The built-in functions are optimized into the normal string functions
8694 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
8695 it is known at compile time that the destination object will not
8696 be overflown. If the compiler can determine at compile time the
8697 object will be always overflown, it issues a warning.
8699 The intended use can be e.g.@:
8703 #define bos0(dest) __builtin_object_size (dest, 0)
8704 #define memcpy(dest, src, n) \
8705 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
8709 /* It is unknown what object p points to, so this is optimized
8710 into plain memcpy - no checking is possible. */
8711 memcpy (p, "abcde", n);
8712 /* Destination is known and length too. It is known at compile
8713 time there will be no overflow. */
8714 memcpy (&buf[5], "abcde", 5);
8715 /* Destination is known, but the length is not known at compile time.
8716 This will result in __memcpy_chk call that can check for overflow
8718 memcpy (&buf[5], "abcde", n);
8719 /* Destination is known and it is known at compile time there will
8720 be overflow. There will be a warning and __memcpy_chk call that
8721 will abort the program at run time. */
8722 memcpy (&buf[6], "abcde", 5);
8725 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
8726 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
8727 @code{strcat} and @code{strncat}.
8729 There are also checking built-in functions for formatted output functions.
8731 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
8732 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8733 const char *fmt, ...);
8734 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
8736 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8737 const char *fmt, va_list ap);
8740 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
8741 etc.@: functions and can contain implementation specific flags on what
8742 additional security measures the checking function might take, such as
8743 handling @code{%n} differently.
8745 The @var{os} argument is the object size @var{s} points to, like in the
8746 other built-in functions. There is a small difference in the behavior
8747 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
8748 optimized into the non-checking functions only if @var{flag} is 0, otherwise
8749 the checking function is called with @var{os} argument set to
8752 In addition to this, there are checking built-in functions
8753 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
8754 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
8755 These have just one additional argument, @var{flag}, right before
8756 format string @var{fmt}. If the compiler is able to optimize them to
8757 @code{fputc} etc.@: functions, it does, otherwise the checking function
8758 is called and the @var{flag} argument passed to it.
8760 @node Pointer Bounds Checker builtins
8761 @section Pointer Bounds Checker Built-in Functions
8762 @findex __builtin___bnd_set_ptr_bounds
8763 @findex __builtin___bnd_narrow_ptr_bounds
8764 @findex __builtin___bnd_copy_ptr_bounds
8765 @findex __builtin___bnd_init_ptr_bounds
8766 @findex __builtin___bnd_null_ptr_bounds
8767 @findex __builtin___bnd_store_ptr_bounds
8768 @findex __builtin___bnd_chk_ptr_lbounds
8769 @findex __builtin___bnd_chk_ptr_ubounds
8770 @findex __builtin___bnd_chk_ptr_bounds
8771 @findex __builtin___bnd_get_ptr_lbound
8772 @findex __builtin___bnd_get_ptr_ubound
8774 GCC provides a set of built-in functions to control Pointer Bounds Checker
8775 instrumentation. Note that all Pointer Bounds Checker builtins are allowed
8776 to use even if you compile with Pointer Bounds Checker off. The builtins
8777 behavior may differ in such case as documented below.
8779 @deftypefn {Built-in Function} void * __builtin___bnd_set_ptr_bounds (const void * @var{q}, size_t @var{size})
8781 This built-in function returns a new pointer with the value of @var{q}, and
8782 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
8783 Bounds Checker off built-in function just returns the first argument.
8786 extern void *__wrap_malloc (size_t n)
8788 void *p = (void *)__real_malloc (n);
8789 if (!p) return __builtin___bnd_null_ptr_bounds (p);
8790 return __builtin___bnd_set_ptr_bounds (p, n);
8796 @deftypefn {Built-in Function} void * __builtin___bnd_narrow_ptr_bounds (const void * @var{p}, const void * @var{q}, size_t @var{size})
8798 This built-in function returns a new pointer with the value of @var{p}
8799 and associate it with the narrowed bounds formed by the intersection
8800 of bounds associated with @var{q} and the [@var{p}, @var{p} + @var{size} - 1].
8801 With Pointer Bounds Checker off built-in function just returns the first
8805 void init_objects (object *objs, size_t size)
8808 /* Initialize objects one-by-one passing pointers with bounds of an object,
8809 not the full array of objects. */
8810 for (i = 0; i < size; i++)
8811 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs, sizeof(object)));
8817 @deftypefn {Built-in Function} void * __builtin___bnd_copy_ptr_bounds (const void * @var{q}, const void * @var{r})
8819 This built-in function returns a new pointer with the value of @var{q},
8820 and associate it with the bounds already associated with pointer @var{r}.
8821 With Pointer Bounds Checker off built-in function just returns the first
8825 /* Here is a way to get pointer to object's field but
8826 still with the full object's bounds. */
8827 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_filed, objptr);
8832 @deftypefn {Built-in Function} void * __builtin___bnd_init_ptr_bounds (const void * @var{q})
8834 This built-in function returns a new pointer with the value of @var{q}, and
8835 associate it with INIT (allowing full memory access) bounds. With Pointer
8836 Bounds Checker off built-in function just returns the first argument.
8840 @deftypefn {Built-in Function} void * __builtin___bnd_null_ptr_bounds (const void * @var{q})
8842 This built-in function returns a new pointer with the value of @var{q}, and
8843 associate it with NULL (allowing no memory access) bounds. With Pointer
8844 Bounds Checker off built-in function just returns the first argument.
8848 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void ** @var{ptr_addr}, const void * @var{ptr_val})
8850 This built-in function stores the bounds associated with pointer @var{ptr_val}
8851 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
8852 bounds from legacy code without touching the associated pointer's memory when
8853 pointers were copied as integers. With Pointer Bounds Checker off built-in
8854 function call is ignored.
8858 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void * @var{q})
8860 This built-in function checks if the pointer @var{q} is within the lower
8861 bound of its associated bounds. With Pointer Bounds Checker off built-in
8862 function call is ignored.
8865 extern void *__wrap_memset (void *dst, int c, size_t len)
8869 __builtin___bnd_chk_ptr_lbounds (dst);
8870 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
8871 __real_memset (dst, c, len);
8879 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void * @var{q})
8881 This built-in function checks if the pointer @var{q} is within the upper
8882 bound of its associated bounds. With Pointer Bounds Checker off built-in
8883 function call is ignored.
8887 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void * @var{q}, size_t @var{size})
8889 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
8890 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
8891 off built-in function call is ignored.
8894 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
8898 __bnd_chk_ptr_bounds (dst, n);
8899 __bnd_chk_ptr_bounds (src, n);
8900 __real_memcpy (dst, src, n);
8908 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_lbound (const void * @var{q})
8910 This built-in function returns the lower bound (which is a pointer) associated
8911 with the pointer @var{q}. This is at least useful for debugging using printf.
8912 With Pointer Bounds Checker off built-in function returns 0.
8915 void *lb = __builtin___bnd_get_ptr_lbound (q);
8916 void *ub = __builtin___bnd_get_ptr_ubound (q);
8917 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
8922 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_ubound (const void * @var{q})
8924 This built-in function returns the upper bound (which is a pointer) associated
8925 with the pointer @var{q}. With Pointer Bounds Checker off built-in function
8930 @node Cilk Plus Builtins
8931 @section Cilk Plus C/C++ language extension Built-in Functions.
8933 GCC provides support for the following built-in reduction funtions if Cilk Plus
8934 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
8937 @item __sec_implicit_index
8939 @item __sec_reduce_add
8940 @item __sec_reduce_all_nonzero
8941 @item __sec_reduce_all_zero
8942 @item __sec_reduce_any_nonzero
8943 @item __sec_reduce_any_zero
8944 @item __sec_reduce_max
8945 @item __sec_reduce_min
8946 @item __sec_reduce_max_ind
8947 @item __sec_reduce_min_ind
8948 @item __sec_reduce_mul
8949 @item __sec_reduce_mutating
8952 Further details and examples about these built-in functions are described
8953 in the Cilk Plus language manual which can be found at
8954 @uref{http://www.cilkplus.org}.
8956 @node Other Builtins
8957 @section Other Built-in Functions Provided by GCC
8958 @cindex built-in functions
8959 @findex __builtin_call_with_static_chain
8960 @findex __builtin_fpclassify
8961 @findex __builtin_isfinite
8962 @findex __builtin_isnormal
8963 @findex __builtin_isgreater
8964 @findex __builtin_isgreaterequal
8965 @findex __builtin_isinf_sign
8966 @findex __builtin_isless
8967 @findex __builtin_islessequal
8968 @findex __builtin_islessgreater
8969 @findex __builtin_isunordered
8970 @findex __builtin_powi
8971 @findex __builtin_powif
8972 @findex __builtin_powil
9130 @findex fprintf_unlocked
9132 @findex fputs_unlocked
9249 @findex printf_unlocked
9281 @findex significandf
9282 @findex significandl
9353 GCC provides a large number of built-in functions other than the ones
9354 mentioned above. Some of these are for internal use in the processing
9355 of exceptions or variable-length argument lists and are not
9356 documented here because they may change from time to time; we do not
9357 recommend general use of these functions.
9359 The remaining functions are provided for optimization purposes.
9361 @opindex fno-builtin
9362 GCC includes built-in versions of many of the functions in the standard
9363 C library. The versions prefixed with @code{__builtin_} are always
9364 treated as having the same meaning as the C library function even if you
9365 specify the @option{-fno-builtin} option. (@pxref{C Dialect Options})
9366 Many of these functions are only optimized in certain cases; if they are
9367 not optimized in a particular case, a call to the library function is
9372 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
9373 @option{-std=c99} or @option{-std=c11}), the functions
9374 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
9375 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
9376 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
9377 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
9378 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
9379 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
9380 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
9381 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
9382 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
9383 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
9384 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
9385 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
9386 @code{signbitd64}, @code{signbitd128}, @code{significandf},
9387 @code{significandl}, @code{significand}, @code{sincosf},
9388 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
9389 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
9390 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
9391 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
9393 may be handled as built-in functions.
9394 All these functions have corresponding versions
9395 prefixed with @code{__builtin_}, which may be used even in strict C90
9398 The ISO C99 functions
9399 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
9400 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
9401 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
9402 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
9403 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
9404 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
9405 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
9406 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
9407 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
9408 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
9409 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
9410 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
9411 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
9412 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
9413 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
9414 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
9415 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
9416 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
9417 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
9418 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
9419 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
9420 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
9421 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
9422 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
9423 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
9424 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
9425 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
9426 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
9427 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
9428 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
9429 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
9430 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
9431 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
9432 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
9433 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
9434 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
9435 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
9436 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
9437 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
9438 are handled as built-in functions
9439 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9441 There are also built-in versions of the ISO C99 functions
9442 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
9443 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
9444 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
9445 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
9446 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
9447 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
9448 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
9449 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
9450 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
9451 that are recognized in any mode since ISO C90 reserves these names for
9452 the purpose to which ISO C99 puts them. All these functions have
9453 corresponding versions prefixed with @code{__builtin_}.
9455 The ISO C94 functions
9456 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
9457 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
9458 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
9460 are handled as built-in functions
9461 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9463 The ISO C90 functions
9464 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
9465 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
9466 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
9467 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
9468 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
9469 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
9470 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
9471 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
9472 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
9473 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
9474 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
9475 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
9476 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
9477 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
9478 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
9479 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
9480 are all recognized as built-in functions unless
9481 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
9482 is specified for an individual function). All of these functions have
9483 corresponding versions prefixed with @code{__builtin_}.
9485 GCC provides built-in versions of the ISO C99 floating-point comparison
9486 macros that avoid raising exceptions for unordered operands. They have
9487 the same names as the standard macros ( @code{isgreater},
9488 @code{isgreaterequal}, @code{isless}, @code{islessequal},
9489 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
9490 prefixed. We intend for a library implementor to be able to simply
9491 @code{#define} each standard macro to its built-in equivalent.
9492 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
9493 @code{isinf_sign} and @code{isnormal} built-ins used with
9494 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
9495 built-in functions appear both with and without the @code{__builtin_} prefix.
9497 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
9499 You can use the built-in function @code{__builtin_types_compatible_p} to
9500 determine whether two types are the same.
9502 This built-in function returns 1 if the unqualified versions of the
9503 types @var{type1} and @var{type2} (which are types, not expressions) are
9504 compatible, 0 otherwise. The result of this built-in function can be
9505 used in integer constant expressions.
9507 This built-in function ignores top level qualifiers (e.g., @code{const},
9508 @code{volatile}). For example, @code{int} is equivalent to @code{const
9511 The type @code{int[]} and @code{int[5]} are compatible. On the other
9512 hand, @code{int} and @code{char *} are not compatible, even if the size
9513 of their types, on the particular architecture are the same. Also, the
9514 amount of pointer indirection is taken into account when determining
9515 similarity. Consequently, @code{short *} is not similar to
9516 @code{short **}. Furthermore, two types that are typedefed are
9517 considered compatible if their underlying types are compatible.
9519 An @code{enum} type is not considered to be compatible with another
9520 @code{enum} type even if both are compatible with the same integer
9521 type; this is what the C standard specifies.
9522 For example, @code{enum @{foo, bar@}} is not similar to
9523 @code{enum @{hot, dog@}}.
9525 You typically use this function in code whose execution varies
9526 depending on the arguments' types. For example:
9531 typeof (x) tmp = (x); \
9532 if (__builtin_types_compatible_p (typeof (x), long double)) \
9533 tmp = foo_long_double (tmp); \
9534 else if (__builtin_types_compatible_p (typeof (x), double)) \
9535 tmp = foo_double (tmp); \
9536 else if (__builtin_types_compatible_p (typeof (x), float)) \
9537 tmp = foo_float (tmp); \
9544 @emph{Note:} This construct is only available for C@.
9548 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
9550 The @var{call_exp} expression must be a function call, and the
9551 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
9552 is passed to the function call in the target's static chain location.
9553 The result of builtin is the result of the function call.
9555 @emph{Note:} This builtin is only available for C@.
9556 This builtin can be used to call Go closures from C.
9560 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
9562 You can use the built-in function @code{__builtin_choose_expr} to
9563 evaluate code depending on the value of a constant expression. This
9564 built-in function returns @var{exp1} if @var{const_exp}, which is an
9565 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
9567 This built-in function is analogous to the @samp{? :} operator in C,
9568 except that the expression returned has its type unaltered by promotion
9569 rules. Also, the built-in function does not evaluate the expression
9570 that is not chosen. For example, if @var{const_exp} evaluates to true,
9571 @var{exp2} is not evaluated even if it has side-effects.
9573 This built-in function can return an lvalue if the chosen argument is an
9576 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
9577 type. Similarly, if @var{exp2} is returned, its return type is the same
9584 __builtin_choose_expr ( \
9585 __builtin_types_compatible_p (typeof (x), double), \
9587 __builtin_choose_expr ( \
9588 __builtin_types_compatible_p (typeof (x), float), \
9590 /* @r{The void expression results in a compile-time error} \
9591 @r{when assigning the result to something.} */ \
9595 @emph{Note:} This construct is only available for C@. Furthermore, the
9596 unused expression (@var{exp1} or @var{exp2} depending on the value of
9597 @var{const_exp}) may still generate syntax errors. This may change in
9602 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
9604 The built-in function @code{__builtin_complex} is provided for use in
9605 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
9606 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
9607 real binary floating-point type, and the result has the corresponding
9608 complex type with real and imaginary parts @var{real} and @var{imag}.
9609 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
9610 infinities, NaNs and negative zeros are involved.
9614 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
9615 You can use the built-in function @code{__builtin_constant_p} to
9616 determine if a value is known to be constant at compile time and hence
9617 that GCC can perform constant-folding on expressions involving that
9618 value. The argument of the function is the value to test. The function
9619 returns the integer 1 if the argument is known to be a compile-time
9620 constant and 0 if it is not known to be a compile-time constant. A
9621 return of 0 does not indicate that the value is @emph{not} a constant,
9622 but merely that GCC cannot prove it is a constant with the specified
9623 value of the @option{-O} option.
9625 You typically use this function in an embedded application where
9626 memory is a critical resource. If you have some complex calculation,
9627 you may want it to be folded if it involves constants, but need to call
9628 a function if it does not. For example:
9631 #define Scale_Value(X) \
9632 (__builtin_constant_p (X) \
9633 ? ((X) * SCALE + OFFSET) : Scale (X))
9636 You may use this built-in function in either a macro or an inline
9637 function. However, if you use it in an inlined function and pass an
9638 argument of the function as the argument to the built-in, GCC
9639 never returns 1 when you call the inline function with a string constant
9640 or compound literal (@pxref{Compound Literals}) and does not return 1
9641 when you pass a constant numeric value to the inline function unless you
9642 specify the @option{-O} option.
9644 You may also use @code{__builtin_constant_p} in initializers for static
9645 data. For instance, you can write
9648 static const int table[] = @{
9649 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
9655 This is an acceptable initializer even if @var{EXPRESSION} is not a
9656 constant expression, including the case where
9657 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
9658 folded to a constant but @var{EXPRESSION} contains operands that are
9659 not otherwise permitted in a static initializer (for example,
9660 @code{0 && foo ()}). GCC must be more conservative about evaluating the
9661 built-in in this case, because it has no opportunity to perform
9664 Previous versions of GCC did not accept this built-in in data
9665 initializers. The earliest version where it is completely safe is
9669 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
9670 @opindex fprofile-arcs
9671 You may use @code{__builtin_expect} to provide the compiler with
9672 branch prediction information. In general, you should prefer to
9673 use actual profile feedback for this (@option{-fprofile-arcs}), as
9674 programmers are notoriously bad at predicting how their programs
9675 actually perform. However, there are applications in which this
9676 data is hard to collect.
9678 The return value is the value of @var{exp}, which should be an integral
9679 expression. The semantics of the built-in are that it is expected that
9680 @var{exp} == @var{c}. For example:
9683 if (__builtin_expect (x, 0))
9688 indicates that we do not expect to call @code{foo}, since
9689 we expect @code{x} to be zero. Since you are limited to integral
9690 expressions for @var{exp}, you should use constructions such as
9693 if (__builtin_expect (ptr != NULL, 1))
9698 when testing pointer or floating-point values.
9701 @deftypefn {Built-in Function} void __builtin_trap (void)
9702 This function causes the program to exit abnormally. GCC implements
9703 this function by using a target-dependent mechanism (such as
9704 intentionally executing an illegal instruction) or by calling
9705 @code{abort}. The mechanism used may vary from release to release so
9706 you should not rely on any particular implementation.
9709 @deftypefn {Built-in Function} void __builtin_unreachable (void)
9710 If control flow reaches the point of the @code{__builtin_unreachable},
9711 the program is undefined. It is useful in situations where the
9712 compiler cannot deduce the unreachability of the code.
9714 One such case is immediately following an @code{asm} statement that
9715 either never terminates, or one that transfers control elsewhere
9716 and never returns. In this example, without the
9717 @code{__builtin_unreachable}, GCC issues a warning that control
9718 reaches the end of a non-void function. It also generates code
9719 to return after the @code{asm}.
9722 int f (int c, int v)
9730 asm("jmp error_handler");
9731 __builtin_unreachable ();
9737 Because the @code{asm} statement unconditionally transfers control out
9738 of the function, control never reaches the end of the function
9739 body. The @code{__builtin_unreachable} is in fact unreachable and
9740 communicates this fact to the compiler.
9742 Another use for @code{__builtin_unreachable} is following a call a
9743 function that never returns but that is not declared
9744 @code{__attribute__((noreturn))}, as in this example:
9747 void function_that_never_returns (void);
9757 function_that_never_returns ();
9758 __builtin_unreachable ();
9765 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
9766 This function returns its first argument, and allows the compiler
9767 to assume that the returned pointer is at least @var{align} bytes
9768 aligned. This built-in can have either two or three arguments,
9769 if it has three, the third argument should have integer type, and
9770 if it is nonzero means misalignment offset. For example:
9773 void *x = __builtin_assume_aligned (arg, 16);
9777 means that the compiler can assume @code{x}, set to @code{arg}, is at least
9778 16-byte aligned, while:
9781 void *x = __builtin_assume_aligned (arg, 32, 8);
9785 means that the compiler can assume for @code{x}, set to @code{arg}, that
9786 @code{(char *) x - 8} is 32-byte aligned.
9789 @deftypefn {Built-in Function} int __builtin_LINE ()
9790 This function is the equivalent to the preprocessor @code{__LINE__}
9791 macro and returns the line number of the invocation of the built-in.
9792 In a C++ default argument for a function @var{F}, it gets the line number of
9793 the call to @var{F}.
9796 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
9797 This function is the equivalent to the preprocessor @code{__FUNCTION__}
9798 macro and returns the function name the invocation of the built-in is in.
9801 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
9802 This function is the equivalent to the preprocessor @code{__FILE__}
9803 macro and returns the file name the invocation of the built-in is in.
9804 In a C++ default argument for a function @var{F}, it gets the file name of
9805 the call to @var{F}.
9808 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
9809 This function is used to flush the processor's instruction cache for
9810 the region of memory between @var{begin} inclusive and @var{end}
9811 exclusive. Some targets require that the instruction cache be
9812 flushed, after modifying memory containing code, in order to obtain
9813 deterministic behavior.
9815 If the target does not require instruction cache flushes,
9816 @code{__builtin___clear_cache} has no effect. Otherwise either
9817 instructions are emitted in-line to clear the instruction cache or a
9818 call to the @code{__clear_cache} function in libgcc is made.
9821 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
9822 This function is used to minimize cache-miss latency by moving data into
9823 a cache before it is accessed.
9824 You can insert calls to @code{__builtin_prefetch} into code for which
9825 you know addresses of data in memory that is likely to be accessed soon.
9826 If the target supports them, data prefetch instructions are generated.
9827 If the prefetch is done early enough before the access then the data will
9828 be in the cache by the time it is accessed.
9830 The value of @var{addr} is the address of the memory to prefetch.
9831 There are two optional arguments, @var{rw} and @var{locality}.
9832 The value of @var{rw} is a compile-time constant one or zero; one
9833 means that the prefetch is preparing for a write to the memory address
9834 and zero, the default, means that the prefetch is preparing for a read.
9835 The value @var{locality} must be a compile-time constant integer between
9836 zero and three. A value of zero means that the data has no temporal
9837 locality, so it need not be left in the cache after the access. A value
9838 of three means that the data has a high degree of temporal locality and
9839 should be left in all levels of cache possible. Values of one and two
9840 mean, respectively, a low or moderate degree of temporal locality. The
9844 for (i = 0; i < n; i++)
9847 __builtin_prefetch (&a[i+j], 1, 1);
9848 __builtin_prefetch (&b[i+j], 0, 1);
9853 Data prefetch does not generate faults if @var{addr} is invalid, but
9854 the address expression itself must be valid. For example, a prefetch
9855 of @code{p->next} does not fault if @code{p->next} is not a valid
9856 address, but evaluation faults if @code{p} is not a valid address.
9858 If the target does not support data prefetch, the address expression
9859 is evaluated if it includes side effects but no other code is generated
9860 and GCC does not issue a warning.
9863 @deftypefn {Built-in Function} double __builtin_huge_val (void)
9864 Returns a positive infinity, if supported by the floating-point format,
9865 else @code{DBL_MAX}. This function is suitable for implementing the
9866 ISO C macro @code{HUGE_VAL}.
9869 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
9870 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
9873 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
9874 Similar to @code{__builtin_huge_val}, except the return
9875 type is @code{long double}.
9878 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
9879 This built-in implements the C99 fpclassify functionality. The first
9880 five int arguments should be the target library's notion of the
9881 possible FP classes and are used for return values. They must be
9882 constant values and they must appear in this order: @code{FP_NAN},
9883 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
9884 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
9885 to classify. GCC treats the last argument as type-generic, which
9886 means it does not do default promotion from float to double.
9889 @deftypefn {Built-in Function} double __builtin_inf (void)
9890 Similar to @code{__builtin_huge_val}, except a warning is generated
9891 if the target floating-point format does not support infinities.
9894 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
9895 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
9898 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
9899 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
9902 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
9903 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
9906 @deftypefn {Built-in Function} float __builtin_inff (void)
9907 Similar to @code{__builtin_inf}, except the return type is @code{float}.
9908 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
9911 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
9912 Similar to @code{__builtin_inf}, except the return
9913 type is @code{long double}.
9916 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
9917 Similar to @code{isinf}, except the return value is -1 for
9918 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
9919 Note while the parameter list is an
9920 ellipsis, this function only accepts exactly one floating-point
9921 argument. GCC treats this parameter as type-generic, which means it
9922 does not do default promotion from float to double.
9925 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
9926 This is an implementation of the ISO C99 function @code{nan}.
9928 Since ISO C99 defines this function in terms of @code{strtod}, which we
9929 do not implement, a description of the parsing is in order. The string
9930 is parsed as by @code{strtol}; that is, the base is recognized by
9931 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
9932 in the significand such that the least significant bit of the number
9933 is at the least significant bit of the significand. The number is
9934 truncated to fit the significand field provided. The significand is
9935 forced to be a quiet NaN@.
9937 This function, if given a string literal all of which would have been
9938 consumed by @code{strtol}, is evaluated early enough that it is considered a
9939 compile-time constant.
9942 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
9943 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
9946 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
9947 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
9950 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
9951 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
9954 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
9955 Similar to @code{__builtin_nan}, except the return type is @code{float}.
9958 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
9959 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
9962 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
9963 Similar to @code{__builtin_nan}, except the significand is forced
9964 to be a signaling NaN@. The @code{nans} function is proposed by
9965 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
9968 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
9969 Similar to @code{__builtin_nans}, except the return type is @code{float}.
9972 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
9973 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
9976 @deftypefn {Built-in Function} int __builtin_ffs (int x)
9977 Returns one plus the index of the least significant 1-bit of @var{x}, or
9978 if @var{x} is zero, returns zero.
9981 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
9982 Returns the number of leading 0-bits in @var{x}, starting at the most
9983 significant bit position. If @var{x} is 0, the result is undefined.
9986 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
9987 Returns the number of trailing 0-bits in @var{x}, starting at the least
9988 significant bit position. If @var{x} is 0, the result is undefined.
9991 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
9992 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
9993 number of bits following the most significant bit that are identical
9994 to it. There are no special cases for 0 or other values.
9997 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
9998 Returns the number of 1-bits in @var{x}.
10001 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
10002 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
10006 @deftypefn {Built-in Function} int __builtin_ffsl (long)
10007 Similar to @code{__builtin_ffs}, except the argument type is
10011 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
10012 Similar to @code{__builtin_clz}, except the argument type is
10013 @code{unsigned long}.
10016 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
10017 Similar to @code{__builtin_ctz}, except the argument type is
10018 @code{unsigned long}.
10021 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
10022 Similar to @code{__builtin_clrsb}, except the argument type is
10026 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
10027 Similar to @code{__builtin_popcount}, except the argument type is
10028 @code{unsigned long}.
10031 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
10032 Similar to @code{__builtin_parity}, except the argument type is
10033 @code{unsigned long}.
10036 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
10037 Similar to @code{__builtin_ffs}, except the argument type is
10041 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
10042 Similar to @code{__builtin_clz}, except the argument type is
10043 @code{unsigned long long}.
10046 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
10047 Similar to @code{__builtin_ctz}, except the argument type is
10048 @code{unsigned long long}.
10051 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
10052 Similar to @code{__builtin_clrsb}, except the argument type is
10056 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
10057 Similar to @code{__builtin_popcount}, except the argument type is
10058 @code{unsigned long long}.
10061 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
10062 Similar to @code{__builtin_parity}, except the argument type is
10063 @code{unsigned long long}.
10066 @deftypefn {Built-in Function} double __builtin_powi (double, int)
10067 Returns the first argument raised to the power of the second. Unlike the
10068 @code{pow} function no guarantees about precision and rounding are made.
10071 @deftypefn {Built-in Function} float __builtin_powif (float, int)
10072 Similar to @code{__builtin_powi}, except the argument and return types
10076 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
10077 Similar to @code{__builtin_powi}, except the argument and return types
10078 are @code{long double}.
10081 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
10082 Returns @var{x} with the order of the bytes reversed; for example,
10083 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
10087 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
10088 Similar to @code{__builtin_bswap16}, except the argument and return types
10092 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
10093 Similar to @code{__builtin_bswap32}, except the argument and return types
10097 @node Target Builtins
10098 @section Built-in Functions Specific to Particular Target Machines
10100 On some target machines, GCC supports many built-in functions specific
10101 to those machines. Generally these generate calls to specific machine
10102 instructions, but allow the compiler to schedule those calls.
10105 * AArch64 Built-in Functions::
10106 * Alpha Built-in Functions::
10107 * Altera Nios II Built-in Functions::
10108 * ARC Built-in Functions::
10109 * ARC SIMD Built-in Functions::
10110 * ARM iWMMXt Built-in Functions::
10111 * ARM C Language Extensions (ACLE)::
10112 * ARM Floating Point Status and Control Intrinsics::
10113 * AVR Built-in Functions::
10114 * Blackfin Built-in Functions::
10115 * FR-V Built-in Functions::
10116 * x86 Built-in Functions::
10117 * x86 transactional memory intrinsics::
10118 * MIPS DSP Built-in Functions::
10119 * MIPS Paired-Single Support::
10120 * MIPS Loongson Built-in Functions::
10121 * Other MIPS Built-in Functions::
10122 * MSP430 Built-in Functions::
10123 * NDS32 Built-in Functions::
10124 * picoChip Built-in Functions::
10125 * PowerPC Built-in Functions::
10126 * PowerPC AltiVec/VSX Built-in Functions::
10127 * PowerPC Hardware Transactional Memory Built-in Functions::
10128 * RX Built-in Functions::
10129 * S/390 System z Built-in Functions::
10130 * SH Built-in Functions::
10131 * SPARC VIS Built-in Functions::
10132 * SPU Built-in Functions::
10133 * TI C6X Built-in Functions::
10134 * TILE-Gx Built-in Functions::
10135 * TILEPro Built-in Functions::
10138 @node AArch64 Built-in Functions
10139 @subsection AArch64 Built-in Functions
10141 These built-in functions are available for the AArch64 family of
10144 unsigned int __builtin_aarch64_get_fpcr ()
10145 void __builtin_aarch64_set_fpcr (unsigned int)
10146 unsigned int __builtin_aarch64_get_fpsr ()
10147 void __builtin_aarch64_set_fpsr (unsigned int)
10150 @node Alpha Built-in Functions
10151 @subsection Alpha Built-in Functions
10153 These built-in functions are available for the Alpha family of
10154 processors, depending on the command-line switches used.
10156 The following built-in functions are always available. They
10157 all generate the machine instruction that is part of the name.
10160 long __builtin_alpha_implver (void)
10161 long __builtin_alpha_rpcc (void)
10162 long __builtin_alpha_amask (long)
10163 long __builtin_alpha_cmpbge (long, long)
10164 long __builtin_alpha_extbl (long, long)
10165 long __builtin_alpha_extwl (long, long)
10166 long __builtin_alpha_extll (long, long)
10167 long __builtin_alpha_extql (long, long)
10168 long __builtin_alpha_extwh (long, long)
10169 long __builtin_alpha_extlh (long, long)
10170 long __builtin_alpha_extqh (long, long)
10171 long __builtin_alpha_insbl (long, long)
10172 long __builtin_alpha_inswl (long, long)
10173 long __builtin_alpha_insll (long, long)
10174 long __builtin_alpha_insql (long, long)
10175 long __builtin_alpha_inswh (long, long)
10176 long __builtin_alpha_inslh (long, long)
10177 long __builtin_alpha_insqh (long, long)
10178 long __builtin_alpha_mskbl (long, long)
10179 long __builtin_alpha_mskwl (long, long)
10180 long __builtin_alpha_mskll (long, long)
10181 long __builtin_alpha_mskql (long, long)
10182 long __builtin_alpha_mskwh (long, long)
10183 long __builtin_alpha_msklh (long, long)
10184 long __builtin_alpha_mskqh (long, long)
10185 long __builtin_alpha_umulh (long, long)
10186 long __builtin_alpha_zap (long, long)
10187 long __builtin_alpha_zapnot (long, long)
10190 The following built-in functions are always with @option{-mmax}
10191 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
10192 later. They all generate the machine instruction that is part
10196 long __builtin_alpha_pklb (long)
10197 long __builtin_alpha_pkwb (long)
10198 long __builtin_alpha_unpkbl (long)
10199 long __builtin_alpha_unpkbw (long)
10200 long __builtin_alpha_minub8 (long, long)
10201 long __builtin_alpha_minsb8 (long, long)
10202 long __builtin_alpha_minuw4 (long, long)
10203 long __builtin_alpha_minsw4 (long, long)
10204 long __builtin_alpha_maxub8 (long, long)
10205 long __builtin_alpha_maxsb8 (long, long)
10206 long __builtin_alpha_maxuw4 (long, long)
10207 long __builtin_alpha_maxsw4 (long, long)
10208 long __builtin_alpha_perr (long, long)
10211 The following built-in functions are always with @option{-mcix}
10212 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
10213 later. They all generate the machine instruction that is part
10217 long __builtin_alpha_cttz (long)
10218 long __builtin_alpha_ctlz (long)
10219 long __builtin_alpha_ctpop (long)
10222 The following built-in functions are available on systems that use the OSF/1
10223 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
10224 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
10225 @code{rdval} and @code{wrval}.
10228 void *__builtin_thread_pointer (void)
10229 void __builtin_set_thread_pointer (void *)
10232 @node Altera Nios II Built-in Functions
10233 @subsection Altera Nios II Built-in Functions
10235 These built-in functions are available for the Altera Nios II
10236 family of processors.
10238 The following built-in functions are always available. They
10239 all generate the machine instruction that is part of the name.
10242 int __builtin_ldbio (volatile const void *)
10243 int __builtin_ldbuio (volatile const void *)
10244 int __builtin_ldhio (volatile const void *)
10245 int __builtin_ldhuio (volatile const void *)
10246 int __builtin_ldwio (volatile const void *)
10247 void __builtin_stbio (volatile void *, int)
10248 void __builtin_sthio (volatile void *, int)
10249 void __builtin_stwio (volatile void *, int)
10250 void __builtin_sync (void)
10251 int __builtin_rdctl (int)
10252 void __builtin_wrctl (int, int)
10255 The following built-in functions are always available. They
10256 all generate a Nios II Custom Instruction. The name of the
10257 function represents the types that the function takes and
10258 returns. The letter before the @code{n} is the return type
10259 or void if absent. The @code{n} represents the first parameter
10260 to all the custom instructions, the custom instruction number.
10261 The two letters after the @code{n} represent the up to two
10262 parameters to the function.
10264 The letters represent the following data types:
10267 @code{void} for return type and no parameter for parameter types.
10270 @code{int} for return type and parameter type
10273 @code{float} for return type and parameter type
10276 @code{void *} for return type and parameter type
10280 And the function names are:
10282 void __builtin_custom_n (void)
10283 void __builtin_custom_ni (int)
10284 void __builtin_custom_nf (float)
10285 void __builtin_custom_np (void *)
10286 void __builtin_custom_nii (int, int)
10287 void __builtin_custom_nif (int, float)
10288 void __builtin_custom_nip (int, void *)
10289 void __builtin_custom_nfi (float, int)
10290 void __builtin_custom_nff (float, float)
10291 void __builtin_custom_nfp (float, void *)
10292 void __builtin_custom_npi (void *, int)
10293 void __builtin_custom_npf (void *, float)
10294 void __builtin_custom_npp (void *, void *)
10295 int __builtin_custom_in (void)
10296 int __builtin_custom_ini (int)
10297 int __builtin_custom_inf (float)
10298 int __builtin_custom_inp (void *)
10299 int __builtin_custom_inii (int, int)
10300 int __builtin_custom_inif (int, float)
10301 int __builtin_custom_inip (int, void *)
10302 int __builtin_custom_infi (float, int)
10303 int __builtin_custom_inff (float, float)
10304 int __builtin_custom_infp (float, void *)
10305 int __builtin_custom_inpi (void *, int)
10306 int __builtin_custom_inpf (void *, float)
10307 int __builtin_custom_inpp (void *, void *)
10308 float __builtin_custom_fn (void)
10309 float __builtin_custom_fni (int)
10310 float __builtin_custom_fnf (float)
10311 float __builtin_custom_fnp (void *)
10312 float __builtin_custom_fnii (int, int)
10313 float __builtin_custom_fnif (int, float)
10314 float __builtin_custom_fnip (int, void *)
10315 float __builtin_custom_fnfi (float, int)
10316 float __builtin_custom_fnff (float, float)
10317 float __builtin_custom_fnfp (float, void *)
10318 float __builtin_custom_fnpi (void *, int)
10319 float __builtin_custom_fnpf (void *, float)
10320 float __builtin_custom_fnpp (void *, void *)
10321 void * __builtin_custom_pn (void)
10322 void * __builtin_custom_pni (int)
10323 void * __builtin_custom_pnf (float)
10324 void * __builtin_custom_pnp (void *)
10325 void * __builtin_custom_pnii (int, int)
10326 void * __builtin_custom_pnif (int, float)
10327 void * __builtin_custom_pnip (int, void *)
10328 void * __builtin_custom_pnfi (float, int)
10329 void * __builtin_custom_pnff (float, float)
10330 void * __builtin_custom_pnfp (float, void *)
10331 void * __builtin_custom_pnpi (void *, int)
10332 void * __builtin_custom_pnpf (void *, float)
10333 void * __builtin_custom_pnpp (void *, void *)
10336 @node ARC Built-in Functions
10337 @subsection ARC Built-in Functions
10339 The following built-in functions are provided for ARC targets. The
10340 built-ins generate the corresponding assembly instructions. In the
10341 examples given below, the generated code often requires an operand or
10342 result to be in a register. Where necessary further code will be
10343 generated to ensure this is true, but for brevity this is not
10344 described in each case.
10346 @emph{Note:} Using a built-in to generate an instruction not supported
10347 by a target may cause problems. At present the compiler is not
10348 guaranteed to detect such misuse, and as a result an internal compiler
10349 error may be generated.
10351 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
10352 Return 1 if @var{val} is known to have the byte alignment given
10353 by @var{alignval}, otherwise return 0.
10354 Note that this is different from
10356 __alignof__(*(char *)@var{val}) >= alignval
10358 because __alignof__ sees only the type of the dereference, whereas
10359 __builtin_arc_align uses alignment information from the pointer
10360 as well as from the pointed-to type.
10361 The information available will depend on optimization level.
10364 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
10371 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
10372 The operand is the number of a register to be read. Generates:
10374 mov @var{dest}, r@var{regno}
10376 where the value in @var{dest} will be the result returned from the
10380 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
10381 The first operand is the number of a register to be written, the
10382 second operand is a compile time constant to write into that
10383 register. Generates:
10385 mov r@var{regno}, @var{val}
10389 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
10390 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
10393 divaw @var{dest}, @var{a}, @var{b}
10395 where the value in @var{dest} will be the result returned from the
10399 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
10406 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
10407 The operand, @var{auxv}, is the address of an auxiliary register and
10408 must be a compile time constant. Generates:
10410 lr @var{dest}, [@var{auxr}]
10412 Where the value in @var{dest} will be the result returned from the
10416 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
10417 Only available with @option{-mmul64}. Generates:
10419 mul64 @var{a}, @var{b}
10423 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
10424 Only available with @option{-mmul64}. Generates:
10426 mulu64 @var{a}, @var{b}
10430 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
10437 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
10438 Only valid if the @samp{norm} instruction is available through the
10439 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10442 norm @var{dest}, @var{src}
10444 Where the value in @var{dest} will be the result returned from the
10448 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
10449 Only valid if the @samp{normw} instruction is available through the
10450 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10453 normw @var{dest}, @var{src}
10455 Where the value in @var{dest} will be the result returned from the
10459 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
10466 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
10473 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
10474 The first argument, @var{auxv}, is the address of an auxiliary
10475 register, the second argument, @var{val}, is a compile time constant
10476 to be written to the register. Generates:
10478 sr @var{auxr}, [@var{val}]
10482 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
10483 Only valid with @option{-mswap}. Generates:
10485 swap @var{dest}, @var{src}
10487 Where the value in @var{dest} will be the result returned from the
10491 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
10498 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
10499 Only available with @option{-mcpu=ARC700}. Generates:
10505 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
10506 Only available with @option{-mcpu=ARC700}. Generates:
10512 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
10513 Only available with @option{-mcpu=ARC700}. Generates:
10519 The instructions generated by the following builtins are not
10520 considered as candidates for scheduling. They are not moved around by
10521 the compiler during scheduling, and thus can be expected to appear
10522 where they are put in the C code:
10524 __builtin_arc_brk()
10525 __builtin_arc_core_read()
10526 __builtin_arc_core_write()
10527 __builtin_arc_flag()
10529 __builtin_arc_sleep()
10531 __builtin_arc_swi()
10534 @node ARC SIMD Built-in Functions
10535 @subsection ARC SIMD Built-in Functions
10537 SIMD builtins provided by the compiler can be used to generate the
10538 vector instructions. This section describes the available builtins
10539 and their usage in programs. With the @option{-msimd} option, the
10540 compiler provides 128-bit vector types, which can be specified using
10541 the @code{vector_size} attribute. The header file @file{arc-simd.h}
10542 can be included to use the following predefined types:
10544 typedef int __v4si __attribute__((vector_size(16)));
10545 typedef short __v8hi __attribute__((vector_size(16)));
10548 These types can be used to define 128-bit variables. The built-in
10549 functions listed in the following section can be used on these
10550 variables to generate the vector operations.
10552 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
10553 @file{arc-simd.h} also provides equivalent macros called
10554 @code{_@var{someinsn}} that can be used for programming ease and
10555 improved readability. The following macros for DMA control are also
10558 #define _setup_dma_in_channel_reg _vdiwr
10559 #define _setup_dma_out_channel_reg _vdowr
10562 The following is a complete list of all the SIMD built-ins provided
10563 for ARC, grouped by calling signature.
10565 The following take two @code{__v8hi} arguments and return a
10566 @code{__v8hi} result:
10568 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
10569 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
10570 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
10571 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
10572 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
10573 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
10574 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
10575 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
10576 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
10577 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
10578 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
10579 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
10580 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
10581 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
10582 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
10583 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
10584 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
10585 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
10586 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
10587 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
10588 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
10589 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
10590 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
10591 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
10592 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
10593 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
10594 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
10595 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
10596 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
10597 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
10598 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
10599 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
10600 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
10601 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
10602 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
10603 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
10604 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
10605 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
10606 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
10607 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
10608 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
10609 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
10610 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
10611 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
10612 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
10613 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
10614 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
10615 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
10618 The following take one @code{__v8hi} and one @code{int} argument and return a
10619 @code{__v8hi} result:
10622 __v8hi __builtin_arc_vbaddw (__v8hi, int)
10623 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
10624 __v8hi __builtin_arc_vbminw (__v8hi, int)
10625 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
10626 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
10627 __v8hi __builtin_arc_vbmulw (__v8hi, int)
10628 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
10629 __v8hi __builtin_arc_vbsubw (__v8hi, int)
10632 The following take one @code{__v8hi} argument and one @code{int} argument which
10633 must be a 3-bit compile time constant indicating a register number
10634 I0-I7. They return a @code{__v8hi} result.
10636 __v8hi __builtin_arc_vasrw (__v8hi, const int)
10637 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
10638 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
10641 The following take one @code{__v8hi} argument and one @code{int}
10642 argument which must be a 6-bit compile time constant. They return a
10643 @code{__v8hi} result.
10645 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
10646 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
10647 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
10648 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
10649 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
10650 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
10651 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
10654 The following take one @code{__v8hi} argument and one @code{int} argument which
10655 must be a 8-bit compile time constant. They return a @code{__v8hi}
10658 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
10659 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
10660 __v8hi __builtin_arc_vmvw (__v8hi, const int)
10661 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
10664 The following take two @code{int} arguments, the second of which which
10665 must be a 8-bit compile time constant. They return a @code{__v8hi}
10668 __v8hi __builtin_arc_vmovaw (int, const int)
10669 __v8hi __builtin_arc_vmovw (int, const int)
10670 __v8hi __builtin_arc_vmovzw (int, const int)
10673 The following take a single @code{__v8hi} argument and return a
10674 @code{__v8hi} result:
10676 __v8hi __builtin_arc_vabsaw (__v8hi)
10677 __v8hi __builtin_arc_vabsw (__v8hi)
10678 __v8hi __builtin_arc_vaddsuw (__v8hi)
10679 __v8hi __builtin_arc_vexch1 (__v8hi)
10680 __v8hi __builtin_arc_vexch2 (__v8hi)
10681 __v8hi __builtin_arc_vexch4 (__v8hi)
10682 __v8hi __builtin_arc_vsignw (__v8hi)
10683 __v8hi __builtin_arc_vupbaw (__v8hi)
10684 __v8hi __builtin_arc_vupbw (__v8hi)
10685 __v8hi __builtin_arc_vupsbaw (__v8hi)
10686 __v8hi __builtin_arc_vupsbw (__v8hi)
10689 The followign take two @code{int} arguments and return no result:
10691 void __builtin_arc_vdirun (int, int)
10692 void __builtin_arc_vdorun (int, int)
10695 The following take two @code{int} arguments and return no result. The
10696 first argument must a 3-bit compile time constant indicating one of
10697 the DR0-DR7 DMA setup channels:
10699 void __builtin_arc_vdiwr (const int, int)
10700 void __builtin_arc_vdowr (const int, int)
10703 The following take an @code{int} argument and return no result:
10705 void __builtin_arc_vendrec (int)
10706 void __builtin_arc_vrec (int)
10707 void __builtin_arc_vrecrun (int)
10708 void __builtin_arc_vrun (int)
10711 The following take a @code{__v8hi} argument and two @code{int}
10712 arguments and return a @code{__v8hi} result. The second argument must
10713 be a 3-bit compile time constants, indicating one the registers I0-I7,
10714 and the third argument must be an 8-bit compile time constant.
10716 @emph{Note:} Although the equivalent hardware instructions do not take
10717 an SIMD register as an operand, these builtins overwrite the relevant
10718 bits of the @code{__v8hi} register provided as the first argument with
10719 the value loaded from the @code{[Ib, u8]} location in the SDM.
10722 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
10723 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
10724 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
10725 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
10728 The following take two @code{int} arguments and return a @code{__v8hi}
10729 result. The first argument must be a 3-bit compile time constants,
10730 indicating one the registers I0-I7, and the second argument must be an
10731 8-bit compile time constant.
10734 __v8hi __builtin_arc_vld128 (const int, const int)
10735 __v8hi __builtin_arc_vld64w (const int, const int)
10738 The following take a @code{__v8hi} argument and two @code{int}
10739 arguments and return no result. The second argument must be a 3-bit
10740 compile time constants, indicating one the registers I0-I7, and the
10741 third argument must be an 8-bit compile time constant.
10744 void __builtin_arc_vst128 (__v8hi, const int, const int)
10745 void __builtin_arc_vst64 (__v8hi, const int, const int)
10748 The following take a @code{__v8hi} argument and three @code{int}
10749 arguments and return no result. The second argument must be a 3-bit
10750 compile-time constant, identifying the 16-bit sub-register to be
10751 stored, the third argument must be a 3-bit compile time constants,
10752 indicating one the registers I0-I7, and the fourth argument must be an
10753 8-bit compile time constant.
10756 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
10757 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
10760 @node ARM iWMMXt Built-in Functions
10761 @subsection ARM iWMMXt Built-in Functions
10763 These built-in functions are available for the ARM family of
10764 processors when the @option{-mcpu=iwmmxt} switch is used:
10767 typedef int v2si __attribute__ ((vector_size (8)));
10768 typedef short v4hi __attribute__ ((vector_size (8)));
10769 typedef char v8qi __attribute__ ((vector_size (8)));
10771 int __builtin_arm_getwcgr0 (void)
10772 void __builtin_arm_setwcgr0 (int)
10773 int __builtin_arm_getwcgr1 (void)
10774 void __builtin_arm_setwcgr1 (int)
10775 int __builtin_arm_getwcgr2 (void)
10776 void __builtin_arm_setwcgr2 (int)
10777 int __builtin_arm_getwcgr3 (void)
10778 void __builtin_arm_setwcgr3 (int)
10779 int __builtin_arm_textrmsb (v8qi, int)
10780 int __builtin_arm_textrmsh (v4hi, int)
10781 int __builtin_arm_textrmsw (v2si, int)
10782 int __builtin_arm_textrmub (v8qi, int)
10783 int __builtin_arm_textrmuh (v4hi, int)
10784 int __builtin_arm_textrmuw (v2si, int)
10785 v8qi __builtin_arm_tinsrb (v8qi, int, int)
10786 v4hi __builtin_arm_tinsrh (v4hi, int, int)
10787 v2si __builtin_arm_tinsrw (v2si, int, int)
10788 long long __builtin_arm_tmia (long long, int, int)
10789 long long __builtin_arm_tmiabb (long long, int, int)
10790 long long __builtin_arm_tmiabt (long long, int, int)
10791 long long __builtin_arm_tmiaph (long long, int, int)
10792 long long __builtin_arm_tmiatb (long long, int, int)
10793 long long __builtin_arm_tmiatt (long long, int, int)
10794 int __builtin_arm_tmovmskb (v8qi)
10795 int __builtin_arm_tmovmskh (v4hi)
10796 int __builtin_arm_tmovmskw (v2si)
10797 long long __builtin_arm_waccb (v8qi)
10798 long long __builtin_arm_wacch (v4hi)
10799 long long __builtin_arm_waccw (v2si)
10800 v8qi __builtin_arm_waddb (v8qi, v8qi)
10801 v8qi __builtin_arm_waddbss (v8qi, v8qi)
10802 v8qi __builtin_arm_waddbus (v8qi, v8qi)
10803 v4hi __builtin_arm_waddh (v4hi, v4hi)
10804 v4hi __builtin_arm_waddhss (v4hi, v4hi)
10805 v4hi __builtin_arm_waddhus (v4hi, v4hi)
10806 v2si __builtin_arm_waddw (v2si, v2si)
10807 v2si __builtin_arm_waddwss (v2si, v2si)
10808 v2si __builtin_arm_waddwus (v2si, v2si)
10809 v8qi __builtin_arm_walign (v8qi, v8qi, int)
10810 long long __builtin_arm_wand(long long, long long)
10811 long long __builtin_arm_wandn (long long, long long)
10812 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
10813 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
10814 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
10815 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
10816 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
10817 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
10818 v2si __builtin_arm_wcmpeqw (v2si, v2si)
10819 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
10820 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
10821 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
10822 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
10823 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
10824 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
10825 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
10826 long long __builtin_arm_wmacsz (v4hi, v4hi)
10827 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
10828 long long __builtin_arm_wmacuz (v4hi, v4hi)
10829 v4hi __builtin_arm_wmadds (v4hi, v4hi)
10830 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
10831 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
10832 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
10833 v2si __builtin_arm_wmaxsw (v2si, v2si)
10834 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
10835 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
10836 v2si __builtin_arm_wmaxuw (v2si, v2si)
10837 v8qi __builtin_arm_wminsb (v8qi, v8qi)
10838 v4hi __builtin_arm_wminsh (v4hi, v4hi)
10839 v2si __builtin_arm_wminsw (v2si, v2si)
10840 v8qi __builtin_arm_wminub (v8qi, v8qi)
10841 v4hi __builtin_arm_wminuh (v4hi, v4hi)
10842 v2si __builtin_arm_wminuw (v2si, v2si)
10843 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
10844 v4hi __builtin_arm_wmulul (v4hi, v4hi)
10845 v4hi __builtin_arm_wmulum (v4hi, v4hi)
10846 long long __builtin_arm_wor (long long, long long)
10847 v2si __builtin_arm_wpackdss (long long, long long)
10848 v2si __builtin_arm_wpackdus (long long, long long)
10849 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
10850 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
10851 v4hi __builtin_arm_wpackwss (v2si, v2si)
10852 v4hi __builtin_arm_wpackwus (v2si, v2si)
10853 long long __builtin_arm_wrord (long long, long long)
10854 long long __builtin_arm_wrordi (long long, int)
10855 v4hi __builtin_arm_wrorh (v4hi, long long)
10856 v4hi __builtin_arm_wrorhi (v4hi, int)
10857 v2si __builtin_arm_wrorw (v2si, long long)
10858 v2si __builtin_arm_wrorwi (v2si, int)
10859 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
10860 v2si __builtin_arm_wsadbz (v8qi, v8qi)
10861 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
10862 v2si __builtin_arm_wsadhz (v4hi, v4hi)
10863 v4hi __builtin_arm_wshufh (v4hi, int)
10864 long long __builtin_arm_wslld (long long, long long)
10865 long long __builtin_arm_wslldi (long long, int)
10866 v4hi __builtin_arm_wsllh (v4hi, long long)
10867 v4hi __builtin_arm_wsllhi (v4hi, int)
10868 v2si __builtin_arm_wsllw (v2si, long long)
10869 v2si __builtin_arm_wsllwi (v2si, int)
10870 long long __builtin_arm_wsrad (long long, long long)
10871 long long __builtin_arm_wsradi (long long, int)
10872 v4hi __builtin_arm_wsrah (v4hi, long long)
10873 v4hi __builtin_arm_wsrahi (v4hi, int)
10874 v2si __builtin_arm_wsraw (v2si, long long)
10875 v2si __builtin_arm_wsrawi (v2si, int)
10876 long long __builtin_arm_wsrld (long long, long long)
10877 long long __builtin_arm_wsrldi (long long, int)
10878 v4hi __builtin_arm_wsrlh (v4hi, long long)
10879 v4hi __builtin_arm_wsrlhi (v4hi, int)
10880 v2si __builtin_arm_wsrlw (v2si, long long)
10881 v2si __builtin_arm_wsrlwi (v2si, int)
10882 v8qi __builtin_arm_wsubb (v8qi, v8qi)
10883 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
10884 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
10885 v4hi __builtin_arm_wsubh (v4hi, v4hi)
10886 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
10887 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
10888 v2si __builtin_arm_wsubw (v2si, v2si)
10889 v2si __builtin_arm_wsubwss (v2si, v2si)
10890 v2si __builtin_arm_wsubwus (v2si, v2si)
10891 v4hi __builtin_arm_wunpckehsb (v8qi)
10892 v2si __builtin_arm_wunpckehsh (v4hi)
10893 long long __builtin_arm_wunpckehsw (v2si)
10894 v4hi __builtin_arm_wunpckehub (v8qi)
10895 v2si __builtin_arm_wunpckehuh (v4hi)
10896 long long __builtin_arm_wunpckehuw (v2si)
10897 v4hi __builtin_arm_wunpckelsb (v8qi)
10898 v2si __builtin_arm_wunpckelsh (v4hi)
10899 long long __builtin_arm_wunpckelsw (v2si)
10900 v4hi __builtin_arm_wunpckelub (v8qi)
10901 v2si __builtin_arm_wunpckeluh (v4hi)
10902 long long __builtin_arm_wunpckeluw (v2si)
10903 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
10904 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
10905 v2si __builtin_arm_wunpckihw (v2si, v2si)
10906 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
10907 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
10908 v2si __builtin_arm_wunpckilw (v2si, v2si)
10909 long long __builtin_arm_wxor (long long, long long)
10910 long long __builtin_arm_wzero ()
10914 @node ARM C Language Extensions (ACLE)
10915 @subsection ARM C Language Extensions (ACLE)
10917 GCC implements extensions for C as described in the ARM C Language
10918 Extensions (ACLE) specification, which can be found at
10919 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
10921 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
10922 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
10923 intrinsics can be found at
10924 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
10925 The built-in intrinsics for the Advanced SIMD extension are available when
10928 Currently, ARM and AArch64 back-ends do not support ACLE 2.0 fully. Both
10929 back-ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM backend's
10930 16-bit floating-point Advanded SIMD Intrinsics currently comply to ACLE v1.1.
10931 AArch64's backend does not have support for 16-bit floating point Advanced SIMD
10934 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
10935 availability of extensions.
10937 @node ARM Floating Point Status and Control Intrinsics
10938 @subsection ARM Floating Point Status and Control Intrinsics
10940 These built-in functions are available for the ARM family of
10941 processors with floating-point unit.
10944 unsigned int __builtin_arm_get_fpscr ()
10945 void __builtin_arm_set_fpscr (unsigned int)
10948 @node AVR Built-in Functions
10949 @subsection AVR Built-in Functions
10951 For each built-in function for AVR, there is an equally named,
10952 uppercase built-in macro defined. That way users can easily query if
10953 or if not a specific built-in is implemented or not. For example, if
10954 @code{__builtin_avr_nop} is available the macro
10955 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
10957 The following built-in functions map to the respective machine
10958 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
10959 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
10960 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
10961 as library call if no hardware multiplier is available.
10964 void __builtin_avr_nop (void)
10965 void __builtin_avr_sei (void)
10966 void __builtin_avr_cli (void)
10967 void __builtin_avr_sleep (void)
10968 void __builtin_avr_wdr (void)
10969 unsigned char __builtin_avr_swap (unsigned char)
10970 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
10971 int __builtin_avr_fmuls (char, char)
10972 int __builtin_avr_fmulsu (char, unsigned char)
10975 In order to delay execution for a specific number of cycles, GCC
10978 void __builtin_avr_delay_cycles (unsigned long ticks)
10982 @code{ticks} is the number of ticks to delay execution. Note that this
10983 built-in does not take into account the effect of interrupts that
10984 might increase delay time. @code{ticks} must be a compile-time
10985 integer constant; delays with a variable number of cycles are not supported.
10988 char __builtin_avr_flash_segment (const __memx void*)
10992 This built-in takes a byte address to the 24-bit
10993 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
10994 the number of the flash segment (the 64 KiB chunk) where the address
10995 points to. Counting starts at @code{0}.
10996 If the address does not point to flash memory, return @code{-1}.
10999 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
11003 Insert bits from @var{bits} into @var{val} and return the resulting
11004 value. The nibbles of @var{map} determine how the insertion is
11005 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
11007 @item If @var{X} is @code{0xf},
11008 then the @var{n}-th bit of @var{val} is returned unaltered.
11010 @item If X is in the range 0@dots{}7,
11011 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
11013 @item If X is in the range 8@dots{}@code{0xe},
11014 then the @var{n}-th result bit is undefined.
11018 One typical use case for this built-in is adjusting input and
11019 output values to non-contiguous port layouts. Some examples:
11022 // same as val, bits is unused
11023 __builtin_avr_insert_bits (0xffffffff, bits, val)
11027 // same as bits, val is unused
11028 __builtin_avr_insert_bits (0x76543210, bits, val)
11032 // same as rotating bits by 4
11033 __builtin_avr_insert_bits (0x32107654, bits, 0)
11037 // high nibble of result is the high nibble of val
11038 // low nibble of result is the low nibble of bits
11039 __builtin_avr_insert_bits (0xffff3210, bits, val)
11043 // reverse the bit order of bits
11044 __builtin_avr_insert_bits (0x01234567, bits, 0)
11047 @node Blackfin Built-in Functions
11048 @subsection Blackfin Built-in Functions
11050 Currently, there are two Blackfin-specific built-in functions. These are
11051 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
11052 using inline assembly; by using these built-in functions the compiler can
11053 automatically add workarounds for hardware errata involving these
11054 instructions. These functions are named as follows:
11057 void __builtin_bfin_csync (void)
11058 void __builtin_bfin_ssync (void)
11061 @node FR-V Built-in Functions
11062 @subsection FR-V Built-in Functions
11064 GCC provides many FR-V-specific built-in functions. In general,
11065 these functions are intended to be compatible with those described
11066 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
11067 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
11068 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
11069 pointer rather than by value.
11071 Most of the functions are named after specific FR-V instructions.
11072 Such functions are said to be ``directly mapped'' and are summarized
11073 here in tabular form.
11077 * Directly-mapped Integer Functions::
11078 * Directly-mapped Media Functions::
11079 * Raw read/write Functions::
11080 * Other Built-in Functions::
11083 @node Argument Types
11084 @subsubsection Argument Types
11086 The arguments to the built-in functions can be divided into three groups:
11087 register numbers, compile-time constants and run-time values. In order
11088 to make this classification clear at a glance, the arguments and return
11089 values are given the following pseudo types:
11091 @multitable @columnfractions .20 .30 .15 .35
11092 @item Pseudo type @tab Real C type @tab Constant? @tab Description
11093 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
11094 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
11095 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
11096 @item @code{uw2} @tab @code{unsigned long long} @tab No
11097 @tab an unsigned doubleword
11098 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
11099 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
11100 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
11101 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
11104 These pseudo types are not defined by GCC, they are simply a notational
11105 convenience used in this manual.
11107 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
11108 and @code{sw2} are evaluated at run time. They correspond to
11109 register operands in the underlying FR-V instructions.
11111 @code{const} arguments represent immediate operands in the underlying
11112 FR-V instructions. They must be compile-time constants.
11114 @code{acc} arguments are evaluated at compile time and specify the number
11115 of an accumulator register. For example, an @code{acc} argument of 2
11116 selects the ACC2 register.
11118 @code{iacc} arguments are similar to @code{acc} arguments but specify the
11119 number of an IACC register. See @pxref{Other Built-in Functions}
11122 @node Directly-mapped Integer Functions
11123 @subsubsection Directly-mapped Integer Functions
11125 The functions listed below map directly to FR-V I-type instructions.
11127 @multitable @columnfractions .45 .32 .23
11128 @item Function prototype @tab Example usage @tab Assembly output
11129 @item @code{sw1 __ADDSS (sw1, sw1)}
11130 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
11131 @tab @code{ADDSS @var{a},@var{b},@var{c}}
11132 @item @code{sw1 __SCAN (sw1, sw1)}
11133 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
11134 @tab @code{SCAN @var{a},@var{b},@var{c}}
11135 @item @code{sw1 __SCUTSS (sw1)}
11136 @tab @code{@var{b} = __SCUTSS (@var{a})}
11137 @tab @code{SCUTSS @var{a},@var{b}}
11138 @item @code{sw1 __SLASS (sw1, sw1)}
11139 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
11140 @tab @code{SLASS @var{a},@var{b},@var{c}}
11141 @item @code{void __SMASS (sw1, sw1)}
11142 @tab @code{__SMASS (@var{a}, @var{b})}
11143 @tab @code{SMASS @var{a},@var{b}}
11144 @item @code{void __SMSSS (sw1, sw1)}
11145 @tab @code{__SMSSS (@var{a}, @var{b})}
11146 @tab @code{SMSSS @var{a},@var{b}}
11147 @item @code{void __SMU (sw1, sw1)}
11148 @tab @code{__SMU (@var{a}, @var{b})}
11149 @tab @code{SMU @var{a},@var{b}}
11150 @item @code{sw2 __SMUL (sw1, sw1)}
11151 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
11152 @tab @code{SMUL @var{a},@var{b},@var{c}}
11153 @item @code{sw1 __SUBSS (sw1, sw1)}
11154 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
11155 @tab @code{SUBSS @var{a},@var{b},@var{c}}
11156 @item @code{uw2 __UMUL (uw1, uw1)}
11157 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
11158 @tab @code{UMUL @var{a},@var{b},@var{c}}
11161 @node Directly-mapped Media Functions
11162 @subsubsection Directly-mapped Media Functions
11164 The functions listed below map directly to FR-V M-type instructions.
11166 @multitable @columnfractions .45 .32 .23
11167 @item Function prototype @tab Example usage @tab Assembly output
11168 @item @code{uw1 __MABSHS (sw1)}
11169 @tab @code{@var{b} = __MABSHS (@var{a})}
11170 @tab @code{MABSHS @var{a},@var{b}}
11171 @item @code{void __MADDACCS (acc, acc)}
11172 @tab @code{__MADDACCS (@var{b}, @var{a})}
11173 @tab @code{MADDACCS @var{a},@var{b}}
11174 @item @code{sw1 __MADDHSS (sw1, sw1)}
11175 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
11176 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
11177 @item @code{uw1 __MADDHUS (uw1, uw1)}
11178 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
11179 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
11180 @item @code{uw1 __MAND (uw1, uw1)}
11181 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
11182 @tab @code{MAND @var{a},@var{b},@var{c}}
11183 @item @code{void __MASACCS (acc, acc)}
11184 @tab @code{__MASACCS (@var{b}, @var{a})}
11185 @tab @code{MASACCS @var{a},@var{b}}
11186 @item @code{uw1 __MAVEH (uw1, uw1)}
11187 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
11188 @tab @code{MAVEH @var{a},@var{b},@var{c}}
11189 @item @code{uw2 __MBTOH (uw1)}
11190 @tab @code{@var{b} = __MBTOH (@var{a})}
11191 @tab @code{MBTOH @var{a},@var{b}}
11192 @item @code{void __MBTOHE (uw1 *, uw1)}
11193 @tab @code{__MBTOHE (&@var{b}, @var{a})}
11194 @tab @code{MBTOHE @var{a},@var{b}}
11195 @item @code{void __MCLRACC (acc)}
11196 @tab @code{__MCLRACC (@var{a})}
11197 @tab @code{MCLRACC @var{a}}
11198 @item @code{void __MCLRACCA (void)}
11199 @tab @code{__MCLRACCA ()}
11200 @tab @code{MCLRACCA}
11201 @item @code{uw1 __Mcop1 (uw1, uw1)}
11202 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
11203 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
11204 @item @code{uw1 __Mcop2 (uw1, uw1)}
11205 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
11206 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
11207 @item @code{uw1 __MCPLHI (uw2, const)}
11208 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
11209 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
11210 @item @code{uw1 __MCPLI (uw2, const)}
11211 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
11212 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
11213 @item @code{void __MCPXIS (acc, sw1, sw1)}
11214 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
11215 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
11216 @item @code{void __MCPXIU (acc, uw1, uw1)}
11217 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
11218 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
11219 @item @code{void __MCPXRS (acc, sw1, sw1)}
11220 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
11221 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
11222 @item @code{void __MCPXRU (acc, uw1, uw1)}
11223 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
11224 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
11225 @item @code{uw1 __MCUT (acc, uw1)}
11226 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
11227 @tab @code{MCUT @var{a},@var{b},@var{c}}
11228 @item @code{uw1 __MCUTSS (acc, sw1)}
11229 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
11230 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
11231 @item @code{void __MDADDACCS (acc, acc)}
11232 @tab @code{__MDADDACCS (@var{b}, @var{a})}
11233 @tab @code{MDADDACCS @var{a},@var{b}}
11234 @item @code{void __MDASACCS (acc, acc)}
11235 @tab @code{__MDASACCS (@var{b}, @var{a})}
11236 @tab @code{MDASACCS @var{a},@var{b}}
11237 @item @code{uw2 __MDCUTSSI (acc, const)}
11238 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
11239 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
11240 @item @code{uw2 __MDPACKH (uw2, uw2)}
11241 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
11242 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
11243 @item @code{uw2 __MDROTLI (uw2, const)}
11244 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
11245 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
11246 @item @code{void __MDSUBACCS (acc, acc)}
11247 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
11248 @tab @code{MDSUBACCS @var{a},@var{b}}
11249 @item @code{void __MDUNPACKH (uw1 *, uw2)}
11250 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
11251 @tab @code{MDUNPACKH @var{a},@var{b}}
11252 @item @code{uw2 __MEXPDHD (uw1, const)}
11253 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
11254 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
11255 @item @code{uw1 __MEXPDHW (uw1, const)}
11256 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
11257 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
11258 @item @code{uw1 __MHDSETH (uw1, const)}
11259 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
11260 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
11261 @item @code{sw1 __MHDSETS (const)}
11262 @tab @code{@var{b} = __MHDSETS (@var{a})}
11263 @tab @code{MHDSETS #@var{a},@var{b}}
11264 @item @code{uw1 __MHSETHIH (uw1, const)}
11265 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
11266 @tab @code{MHSETHIH #@var{a},@var{b}}
11267 @item @code{sw1 __MHSETHIS (sw1, const)}
11268 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
11269 @tab @code{MHSETHIS #@var{a},@var{b}}
11270 @item @code{uw1 __MHSETLOH (uw1, const)}
11271 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
11272 @tab @code{MHSETLOH #@var{a},@var{b}}
11273 @item @code{sw1 __MHSETLOS (sw1, const)}
11274 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
11275 @tab @code{MHSETLOS #@var{a},@var{b}}
11276 @item @code{uw1 __MHTOB (uw2)}
11277 @tab @code{@var{b} = __MHTOB (@var{a})}
11278 @tab @code{MHTOB @var{a},@var{b}}
11279 @item @code{void __MMACHS (acc, sw1, sw1)}
11280 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
11281 @tab @code{MMACHS @var{a},@var{b},@var{c}}
11282 @item @code{void __MMACHU (acc, uw1, uw1)}
11283 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
11284 @tab @code{MMACHU @var{a},@var{b},@var{c}}
11285 @item @code{void __MMRDHS (acc, sw1, sw1)}
11286 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
11287 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
11288 @item @code{void __MMRDHU (acc, uw1, uw1)}
11289 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
11290 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
11291 @item @code{void __MMULHS (acc, sw1, sw1)}
11292 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
11293 @tab @code{MMULHS @var{a},@var{b},@var{c}}
11294 @item @code{void __MMULHU (acc, uw1, uw1)}
11295 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
11296 @tab @code{MMULHU @var{a},@var{b},@var{c}}
11297 @item @code{void __MMULXHS (acc, sw1, sw1)}
11298 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
11299 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
11300 @item @code{void __MMULXHU (acc, uw1, uw1)}
11301 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
11302 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
11303 @item @code{uw1 __MNOT (uw1)}
11304 @tab @code{@var{b} = __MNOT (@var{a})}
11305 @tab @code{MNOT @var{a},@var{b}}
11306 @item @code{uw1 __MOR (uw1, uw1)}
11307 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
11308 @tab @code{MOR @var{a},@var{b},@var{c}}
11309 @item @code{uw1 __MPACKH (uh, uh)}
11310 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
11311 @tab @code{MPACKH @var{a},@var{b},@var{c}}
11312 @item @code{sw2 __MQADDHSS (sw2, sw2)}
11313 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
11314 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
11315 @item @code{uw2 __MQADDHUS (uw2, uw2)}
11316 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
11317 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
11318 @item @code{void __MQCPXIS (acc, sw2, sw2)}
11319 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
11320 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
11321 @item @code{void __MQCPXIU (acc, uw2, uw2)}
11322 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
11323 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
11324 @item @code{void __MQCPXRS (acc, sw2, sw2)}
11325 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
11326 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
11327 @item @code{void __MQCPXRU (acc, uw2, uw2)}
11328 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
11329 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
11330 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
11331 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
11332 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
11333 @item @code{sw2 __MQLMTHS (sw2, sw2)}
11334 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
11335 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
11336 @item @code{void __MQMACHS (acc, sw2, sw2)}
11337 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
11338 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
11339 @item @code{void __MQMACHU (acc, uw2, uw2)}
11340 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
11341 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
11342 @item @code{void __MQMACXHS (acc, sw2, sw2)}
11343 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
11344 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
11345 @item @code{void __MQMULHS (acc, sw2, sw2)}
11346 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
11347 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
11348 @item @code{void __MQMULHU (acc, uw2, uw2)}
11349 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
11350 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
11351 @item @code{void __MQMULXHS (acc, sw2, sw2)}
11352 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
11353 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
11354 @item @code{void __MQMULXHU (acc, uw2, uw2)}
11355 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
11356 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
11357 @item @code{sw2 __MQSATHS (sw2, sw2)}
11358 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
11359 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
11360 @item @code{uw2 __MQSLLHI (uw2, int)}
11361 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
11362 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
11363 @item @code{sw2 __MQSRAHI (sw2, int)}
11364 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
11365 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
11366 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
11367 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
11368 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
11369 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
11370 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
11371 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
11372 @item @code{void __MQXMACHS (acc, sw2, sw2)}
11373 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
11374 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
11375 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
11376 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
11377 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
11378 @item @code{uw1 __MRDACC (acc)}
11379 @tab @code{@var{b} = __MRDACC (@var{a})}
11380 @tab @code{MRDACC @var{a},@var{b}}
11381 @item @code{uw1 __MRDACCG (acc)}
11382 @tab @code{@var{b} = __MRDACCG (@var{a})}
11383 @tab @code{MRDACCG @var{a},@var{b}}
11384 @item @code{uw1 __MROTLI (uw1, const)}
11385 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
11386 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
11387 @item @code{uw1 __MROTRI (uw1, const)}
11388 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
11389 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
11390 @item @code{sw1 __MSATHS (sw1, sw1)}
11391 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
11392 @tab @code{MSATHS @var{a},@var{b},@var{c}}
11393 @item @code{uw1 __MSATHU (uw1, uw1)}
11394 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
11395 @tab @code{MSATHU @var{a},@var{b},@var{c}}
11396 @item @code{uw1 __MSLLHI (uw1, const)}
11397 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
11398 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
11399 @item @code{sw1 __MSRAHI (sw1, const)}
11400 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
11401 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
11402 @item @code{uw1 __MSRLHI (uw1, const)}
11403 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
11404 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
11405 @item @code{void __MSUBACCS (acc, acc)}
11406 @tab @code{__MSUBACCS (@var{b}, @var{a})}
11407 @tab @code{MSUBACCS @var{a},@var{b}}
11408 @item @code{sw1 __MSUBHSS (sw1, sw1)}
11409 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
11410 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
11411 @item @code{uw1 __MSUBHUS (uw1, uw1)}
11412 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
11413 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
11414 @item @code{void __MTRAP (void)}
11415 @tab @code{__MTRAP ()}
11417 @item @code{uw2 __MUNPACKH (uw1)}
11418 @tab @code{@var{b} = __MUNPACKH (@var{a})}
11419 @tab @code{MUNPACKH @var{a},@var{b}}
11420 @item @code{uw1 __MWCUT (uw2, uw1)}
11421 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
11422 @tab @code{MWCUT @var{a},@var{b},@var{c}}
11423 @item @code{void __MWTACC (acc, uw1)}
11424 @tab @code{__MWTACC (@var{b}, @var{a})}
11425 @tab @code{MWTACC @var{a},@var{b}}
11426 @item @code{void __MWTACCG (acc, uw1)}
11427 @tab @code{__MWTACCG (@var{b}, @var{a})}
11428 @tab @code{MWTACCG @var{a},@var{b}}
11429 @item @code{uw1 __MXOR (uw1, uw1)}
11430 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
11431 @tab @code{MXOR @var{a},@var{b},@var{c}}
11434 @node Raw read/write Functions
11435 @subsubsection Raw read/write Functions
11437 This sections describes built-in functions related to read and write
11438 instructions to access memory. These functions generate
11439 @code{membar} instructions to flush the I/O load and stores where
11440 appropriate, as described in Fujitsu's manual described above.
11444 @item unsigned char __builtin_read8 (void *@var{data})
11445 @item unsigned short __builtin_read16 (void *@var{data})
11446 @item unsigned long __builtin_read32 (void *@var{data})
11447 @item unsigned long long __builtin_read64 (void *@var{data})
11449 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
11450 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
11451 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
11452 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
11455 @node Other Built-in Functions
11456 @subsubsection Other Built-in Functions
11458 This section describes built-in functions that are not named after
11459 a specific FR-V instruction.
11462 @item sw2 __IACCreadll (iacc @var{reg})
11463 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
11464 for future expansion and must be 0.
11466 @item sw1 __IACCreadl (iacc @var{reg})
11467 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
11468 Other values of @var{reg} are rejected as invalid.
11470 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
11471 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
11472 is reserved for future expansion and must be 0.
11474 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
11475 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
11476 is 1. Other values of @var{reg} are rejected as invalid.
11478 @item void __data_prefetch0 (const void *@var{x})
11479 Use the @code{dcpl} instruction to load the contents of address @var{x}
11480 into the data cache.
11482 @item void __data_prefetch (const void *@var{x})
11483 Use the @code{nldub} instruction to load the contents of address @var{x}
11484 into the data cache. The instruction is issued in slot I1@.
11487 @node x86 Built-in Functions
11488 @subsection x86 Built-in Functions
11490 These built-in functions are available for the x86-32 and x86-64 family
11491 of computers, depending on the command-line switches used.
11493 If you specify command-line switches such as @option{-msse},
11494 the compiler could use the extended instruction sets even if the built-ins
11495 are not used explicitly in the program. For this reason, applications
11496 that perform run-time CPU detection must compile separate files for each
11497 supported architecture, using the appropriate flags. In particular,
11498 the file containing the CPU detection code should be compiled without
11501 The following machine modes are available for use with MMX built-in functions
11502 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
11503 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
11504 vector of eight 8-bit integers. Some of the built-in functions operate on
11505 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
11507 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
11508 of two 32-bit floating-point values.
11510 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
11511 floating-point values. Some instructions use a vector of four 32-bit
11512 integers, these use @code{V4SI}. Finally, some instructions operate on an
11513 entire vector register, interpreting it as a 128-bit integer, these use mode
11516 In 64-bit mode, the x86-64 family of processors uses additional built-in
11517 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
11518 floating point and @code{TC} 128-bit complex floating-point values.
11520 The following floating-point built-in functions are available in 64-bit
11521 mode. All of them implement the function that is part of the name.
11524 __float128 __builtin_fabsq (__float128)
11525 __float128 __builtin_copysignq (__float128, __float128)
11528 The following built-in function is always available.
11531 @item void __builtin_ia32_pause (void)
11532 Generates the @code{pause} machine instruction with a compiler memory
11536 The following floating-point built-in functions are made available in the
11540 @item __float128 __builtin_infq (void)
11541 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
11542 @findex __builtin_infq
11544 @item __float128 __builtin_huge_valq (void)
11545 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
11546 @findex __builtin_huge_valq
11549 The following built-in functions are always available and can be used to
11550 check the target platform type.
11552 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
11553 This function runs the CPU detection code to check the type of CPU and the
11554 features supported. This built-in function needs to be invoked along with the built-in functions
11555 to check CPU type and features, @code{__builtin_cpu_is} and
11556 @code{__builtin_cpu_supports}, only when used in a function that is
11557 executed before any constructors are called. The CPU detection code is
11558 automatically executed in a very high priority constructor.
11560 For example, this function has to be used in @code{ifunc} resolvers that
11561 check for CPU type using the built-in functions @code{__builtin_cpu_is}
11562 and @code{__builtin_cpu_supports}, or in constructors on targets that
11563 don't support constructor priority.
11566 static void (*resolve_memcpy (void)) (void)
11568 // ifunc resolvers fire before constructors, explicitly call the init
11570 __builtin_cpu_init ();
11571 if (__builtin_cpu_supports ("ssse3"))
11572 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
11574 return default_memcpy;
11577 void *memcpy (void *, const void *, size_t)
11578 __attribute__ ((ifunc ("resolve_memcpy")));
11583 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
11584 This function returns a positive integer if the run-time CPU
11585 is of type @var{cpuname}
11586 and returns @code{0} otherwise. The following CPU names can be detected:
11602 Intel Core i7 Nehalem CPU.
11605 Intel Core i7 Westmere CPU.
11608 Intel Core i7 Sandy Bridge CPU.
11614 AMD Family 10h CPU.
11617 AMD Family 10h Barcelona CPU.
11620 AMD Family 10h Shanghai CPU.
11623 AMD Family 10h Istanbul CPU.
11626 AMD Family 14h CPU.
11629 AMD Family 15h CPU.
11632 AMD Family 15h Bulldozer version 1.
11635 AMD Family 15h Bulldozer version 2.
11638 AMD Family 15h Bulldozer version 3.
11641 AMD Family 15h Bulldozer version 4.
11644 AMD Family 16h CPU.
11647 Here is an example:
11649 if (__builtin_cpu_is ("corei7"))
11651 do_corei7 (); // Core i7 specific implementation.
11655 do_generic (); // Generic implementation.
11660 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
11661 This function returns a positive integer if the run-time CPU
11662 supports @var{feature}
11663 and returns @code{0} otherwise. The following features can be detected:
11671 POPCNT instruction.
11679 SSSE3 instructions.
11681 SSE4.1 instructions.
11683 SSE4.2 instructions.
11689 AVX512F instructions.
11692 Here is an example:
11694 if (__builtin_cpu_supports ("popcnt"))
11696 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
11700 count = generic_countbits (n); //generic implementation.
11706 The following built-in functions are made available by @option{-mmmx}.
11707 All of them generate the machine instruction that is part of the name.
11710 v8qi __builtin_ia32_paddb (v8qi, v8qi)
11711 v4hi __builtin_ia32_paddw (v4hi, v4hi)
11712 v2si __builtin_ia32_paddd (v2si, v2si)
11713 v8qi __builtin_ia32_psubb (v8qi, v8qi)
11714 v4hi __builtin_ia32_psubw (v4hi, v4hi)
11715 v2si __builtin_ia32_psubd (v2si, v2si)
11716 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
11717 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
11718 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
11719 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
11720 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
11721 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
11722 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
11723 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
11724 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
11725 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
11726 di __builtin_ia32_pand (di, di)
11727 di __builtin_ia32_pandn (di,di)
11728 di __builtin_ia32_por (di, di)
11729 di __builtin_ia32_pxor (di, di)
11730 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
11731 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
11732 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
11733 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
11734 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
11735 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
11736 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
11737 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
11738 v2si __builtin_ia32_punpckhdq (v2si, v2si)
11739 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
11740 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
11741 v2si __builtin_ia32_punpckldq (v2si, v2si)
11742 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
11743 v4hi __builtin_ia32_packssdw (v2si, v2si)
11744 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
11746 v4hi __builtin_ia32_psllw (v4hi, v4hi)
11747 v2si __builtin_ia32_pslld (v2si, v2si)
11748 v1di __builtin_ia32_psllq (v1di, v1di)
11749 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
11750 v2si __builtin_ia32_psrld (v2si, v2si)
11751 v1di __builtin_ia32_psrlq (v1di, v1di)
11752 v4hi __builtin_ia32_psraw (v4hi, v4hi)
11753 v2si __builtin_ia32_psrad (v2si, v2si)
11754 v4hi __builtin_ia32_psllwi (v4hi, int)
11755 v2si __builtin_ia32_pslldi (v2si, int)
11756 v1di __builtin_ia32_psllqi (v1di, int)
11757 v4hi __builtin_ia32_psrlwi (v4hi, int)
11758 v2si __builtin_ia32_psrldi (v2si, int)
11759 v1di __builtin_ia32_psrlqi (v1di, int)
11760 v4hi __builtin_ia32_psrawi (v4hi, int)
11761 v2si __builtin_ia32_psradi (v2si, int)
11765 The following built-in functions are made available either with
11766 @option{-msse}, or with a combination of @option{-m3dnow} and
11767 @option{-march=athlon}. All of them generate the machine
11768 instruction that is part of the name.
11771 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
11772 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
11773 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
11774 v1di __builtin_ia32_psadbw (v8qi, v8qi)
11775 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
11776 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
11777 v8qi __builtin_ia32_pminub (v8qi, v8qi)
11778 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
11779 int __builtin_ia32_pmovmskb (v8qi)
11780 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
11781 void __builtin_ia32_movntq (di *, di)
11782 void __builtin_ia32_sfence (void)
11785 The following built-in functions are available when @option{-msse} is used.
11786 All of them generate the machine instruction that is part of the name.
11789 int __builtin_ia32_comieq (v4sf, v4sf)
11790 int __builtin_ia32_comineq (v4sf, v4sf)
11791 int __builtin_ia32_comilt (v4sf, v4sf)
11792 int __builtin_ia32_comile (v4sf, v4sf)
11793 int __builtin_ia32_comigt (v4sf, v4sf)
11794 int __builtin_ia32_comige (v4sf, v4sf)
11795 int __builtin_ia32_ucomieq (v4sf, v4sf)
11796 int __builtin_ia32_ucomineq (v4sf, v4sf)
11797 int __builtin_ia32_ucomilt (v4sf, v4sf)
11798 int __builtin_ia32_ucomile (v4sf, v4sf)
11799 int __builtin_ia32_ucomigt (v4sf, v4sf)
11800 int __builtin_ia32_ucomige (v4sf, v4sf)
11801 v4sf __builtin_ia32_addps (v4sf, v4sf)
11802 v4sf __builtin_ia32_subps (v4sf, v4sf)
11803 v4sf __builtin_ia32_mulps (v4sf, v4sf)
11804 v4sf __builtin_ia32_divps (v4sf, v4sf)
11805 v4sf __builtin_ia32_addss (v4sf, v4sf)
11806 v4sf __builtin_ia32_subss (v4sf, v4sf)
11807 v4sf __builtin_ia32_mulss (v4sf, v4sf)
11808 v4sf __builtin_ia32_divss (v4sf, v4sf)
11809 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
11810 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
11811 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
11812 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
11813 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
11814 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
11815 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
11816 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
11817 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
11818 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
11819 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
11820 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
11821 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
11822 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
11823 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
11824 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
11825 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
11826 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
11827 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
11828 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
11829 v4sf __builtin_ia32_maxps (v4sf, v4sf)
11830 v4sf __builtin_ia32_maxss (v4sf, v4sf)
11831 v4sf __builtin_ia32_minps (v4sf, v4sf)
11832 v4sf __builtin_ia32_minss (v4sf, v4sf)
11833 v4sf __builtin_ia32_andps (v4sf, v4sf)
11834 v4sf __builtin_ia32_andnps (v4sf, v4sf)
11835 v4sf __builtin_ia32_orps (v4sf, v4sf)
11836 v4sf __builtin_ia32_xorps (v4sf, v4sf)
11837 v4sf __builtin_ia32_movss (v4sf, v4sf)
11838 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
11839 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
11840 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
11841 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
11842 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
11843 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
11844 v2si __builtin_ia32_cvtps2pi (v4sf)
11845 int __builtin_ia32_cvtss2si (v4sf)
11846 v2si __builtin_ia32_cvttps2pi (v4sf)
11847 int __builtin_ia32_cvttss2si (v4sf)
11848 v4sf __builtin_ia32_rcpps (v4sf)
11849 v4sf __builtin_ia32_rsqrtps (v4sf)
11850 v4sf __builtin_ia32_sqrtps (v4sf)
11851 v4sf __builtin_ia32_rcpss (v4sf)
11852 v4sf __builtin_ia32_rsqrtss (v4sf)
11853 v4sf __builtin_ia32_sqrtss (v4sf)
11854 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
11855 void __builtin_ia32_movntps (float *, v4sf)
11856 int __builtin_ia32_movmskps (v4sf)
11859 The following built-in functions are available when @option{-msse} is used.
11862 @item v4sf __builtin_ia32_loadups (float *)
11863 Generates the @code{movups} machine instruction as a load from memory.
11864 @item void __builtin_ia32_storeups (float *, v4sf)
11865 Generates the @code{movups} machine instruction as a store to memory.
11866 @item v4sf __builtin_ia32_loadss (float *)
11867 Generates the @code{movss} machine instruction as a load from memory.
11868 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
11869 Generates the @code{movhps} machine instruction as a load from memory.
11870 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
11871 Generates the @code{movlps} machine instruction as a load from memory
11872 @item void __builtin_ia32_storehps (v2sf *, v4sf)
11873 Generates the @code{movhps} machine instruction as a store to memory.
11874 @item void __builtin_ia32_storelps (v2sf *, v4sf)
11875 Generates the @code{movlps} machine instruction as a store to memory.
11878 The following built-in functions are available when @option{-msse2} is used.
11879 All of them generate the machine instruction that is part of the name.
11882 int __builtin_ia32_comisdeq (v2df, v2df)
11883 int __builtin_ia32_comisdlt (v2df, v2df)
11884 int __builtin_ia32_comisdle (v2df, v2df)
11885 int __builtin_ia32_comisdgt (v2df, v2df)
11886 int __builtin_ia32_comisdge (v2df, v2df)
11887 int __builtin_ia32_comisdneq (v2df, v2df)
11888 int __builtin_ia32_ucomisdeq (v2df, v2df)
11889 int __builtin_ia32_ucomisdlt (v2df, v2df)
11890 int __builtin_ia32_ucomisdle (v2df, v2df)
11891 int __builtin_ia32_ucomisdgt (v2df, v2df)
11892 int __builtin_ia32_ucomisdge (v2df, v2df)
11893 int __builtin_ia32_ucomisdneq (v2df, v2df)
11894 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
11895 v2df __builtin_ia32_cmpltpd (v2df, v2df)
11896 v2df __builtin_ia32_cmplepd (v2df, v2df)
11897 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
11898 v2df __builtin_ia32_cmpgepd (v2df, v2df)
11899 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
11900 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
11901 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
11902 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
11903 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
11904 v2df __builtin_ia32_cmpngepd (v2df, v2df)
11905 v2df __builtin_ia32_cmpordpd (v2df, v2df)
11906 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
11907 v2df __builtin_ia32_cmpltsd (v2df, v2df)
11908 v2df __builtin_ia32_cmplesd (v2df, v2df)
11909 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
11910 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
11911 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
11912 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
11913 v2df __builtin_ia32_cmpordsd (v2df, v2df)
11914 v2di __builtin_ia32_paddq (v2di, v2di)
11915 v2di __builtin_ia32_psubq (v2di, v2di)
11916 v2df __builtin_ia32_addpd (v2df, v2df)
11917 v2df __builtin_ia32_subpd (v2df, v2df)
11918 v2df __builtin_ia32_mulpd (v2df, v2df)
11919 v2df __builtin_ia32_divpd (v2df, v2df)
11920 v2df __builtin_ia32_addsd (v2df, v2df)
11921 v2df __builtin_ia32_subsd (v2df, v2df)
11922 v2df __builtin_ia32_mulsd (v2df, v2df)
11923 v2df __builtin_ia32_divsd (v2df, v2df)
11924 v2df __builtin_ia32_minpd (v2df, v2df)
11925 v2df __builtin_ia32_maxpd (v2df, v2df)
11926 v2df __builtin_ia32_minsd (v2df, v2df)
11927 v2df __builtin_ia32_maxsd (v2df, v2df)
11928 v2df __builtin_ia32_andpd (v2df, v2df)
11929 v2df __builtin_ia32_andnpd (v2df, v2df)
11930 v2df __builtin_ia32_orpd (v2df, v2df)
11931 v2df __builtin_ia32_xorpd (v2df, v2df)
11932 v2df __builtin_ia32_movsd (v2df, v2df)
11933 v2df __builtin_ia32_unpckhpd (v2df, v2df)
11934 v2df __builtin_ia32_unpcklpd (v2df, v2df)
11935 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
11936 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
11937 v4si __builtin_ia32_paddd128 (v4si, v4si)
11938 v2di __builtin_ia32_paddq128 (v2di, v2di)
11939 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
11940 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
11941 v4si __builtin_ia32_psubd128 (v4si, v4si)
11942 v2di __builtin_ia32_psubq128 (v2di, v2di)
11943 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
11944 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
11945 v2di __builtin_ia32_pand128 (v2di, v2di)
11946 v2di __builtin_ia32_pandn128 (v2di, v2di)
11947 v2di __builtin_ia32_por128 (v2di, v2di)
11948 v2di __builtin_ia32_pxor128 (v2di, v2di)
11949 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
11950 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
11951 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
11952 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
11953 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
11954 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
11955 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
11956 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
11957 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
11958 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
11959 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
11960 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
11961 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
11962 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
11963 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
11964 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
11965 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
11966 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
11967 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
11968 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
11969 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
11970 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
11971 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
11972 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
11973 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
11974 v2df __builtin_ia32_loadupd (double *)
11975 void __builtin_ia32_storeupd (double *, v2df)
11976 v2df __builtin_ia32_loadhpd (v2df, double const *)
11977 v2df __builtin_ia32_loadlpd (v2df, double const *)
11978 int __builtin_ia32_movmskpd (v2df)
11979 int __builtin_ia32_pmovmskb128 (v16qi)
11980 void __builtin_ia32_movnti (int *, int)
11981 void __builtin_ia32_movnti64 (long long int *, long long int)
11982 void __builtin_ia32_movntpd (double *, v2df)
11983 void __builtin_ia32_movntdq (v2df *, v2df)
11984 v4si __builtin_ia32_pshufd (v4si, int)
11985 v8hi __builtin_ia32_pshuflw (v8hi, int)
11986 v8hi __builtin_ia32_pshufhw (v8hi, int)
11987 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
11988 v2df __builtin_ia32_sqrtpd (v2df)
11989 v2df __builtin_ia32_sqrtsd (v2df)
11990 v2df __builtin_ia32_shufpd (v2df, v2df, int)
11991 v2df __builtin_ia32_cvtdq2pd (v4si)
11992 v4sf __builtin_ia32_cvtdq2ps (v4si)
11993 v4si __builtin_ia32_cvtpd2dq (v2df)
11994 v2si __builtin_ia32_cvtpd2pi (v2df)
11995 v4sf __builtin_ia32_cvtpd2ps (v2df)
11996 v4si __builtin_ia32_cvttpd2dq (v2df)
11997 v2si __builtin_ia32_cvttpd2pi (v2df)
11998 v2df __builtin_ia32_cvtpi2pd (v2si)
11999 int __builtin_ia32_cvtsd2si (v2df)
12000 int __builtin_ia32_cvttsd2si (v2df)
12001 long long __builtin_ia32_cvtsd2si64 (v2df)
12002 long long __builtin_ia32_cvttsd2si64 (v2df)
12003 v4si __builtin_ia32_cvtps2dq (v4sf)
12004 v2df __builtin_ia32_cvtps2pd (v4sf)
12005 v4si __builtin_ia32_cvttps2dq (v4sf)
12006 v2df __builtin_ia32_cvtsi2sd (v2df, int)
12007 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
12008 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
12009 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
12010 void __builtin_ia32_clflush (const void *)
12011 void __builtin_ia32_lfence (void)
12012 void __builtin_ia32_mfence (void)
12013 v16qi __builtin_ia32_loaddqu (const char *)
12014 void __builtin_ia32_storedqu (char *, v16qi)
12015 v1di __builtin_ia32_pmuludq (v2si, v2si)
12016 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
12017 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
12018 v4si __builtin_ia32_pslld128 (v4si, v4si)
12019 v2di __builtin_ia32_psllq128 (v2di, v2di)
12020 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
12021 v4si __builtin_ia32_psrld128 (v4si, v4si)
12022 v2di __builtin_ia32_psrlq128 (v2di, v2di)
12023 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
12024 v4si __builtin_ia32_psrad128 (v4si, v4si)
12025 v2di __builtin_ia32_pslldqi128 (v2di, int)
12026 v8hi __builtin_ia32_psllwi128 (v8hi, int)
12027 v4si __builtin_ia32_pslldi128 (v4si, int)
12028 v2di __builtin_ia32_psllqi128 (v2di, int)
12029 v2di __builtin_ia32_psrldqi128 (v2di, int)
12030 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
12031 v4si __builtin_ia32_psrldi128 (v4si, int)
12032 v2di __builtin_ia32_psrlqi128 (v2di, int)
12033 v8hi __builtin_ia32_psrawi128 (v8hi, int)
12034 v4si __builtin_ia32_psradi128 (v4si, int)
12035 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
12036 v2di __builtin_ia32_movq128 (v2di)
12039 The following built-in functions are available when @option{-msse3} is used.
12040 All of them generate the machine instruction that is part of the name.
12043 v2df __builtin_ia32_addsubpd (v2df, v2df)
12044 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
12045 v2df __builtin_ia32_haddpd (v2df, v2df)
12046 v4sf __builtin_ia32_haddps (v4sf, v4sf)
12047 v2df __builtin_ia32_hsubpd (v2df, v2df)
12048 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
12049 v16qi __builtin_ia32_lddqu (char const *)
12050 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
12051 v4sf __builtin_ia32_movshdup (v4sf)
12052 v4sf __builtin_ia32_movsldup (v4sf)
12053 void __builtin_ia32_mwait (unsigned int, unsigned int)
12056 The following built-in functions are available when @option{-mssse3} is used.
12057 All of them generate the machine instruction that is part of the name.
12060 v2si __builtin_ia32_phaddd (v2si, v2si)
12061 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
12062 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
12063 v2si __builtin_ia32_phsubd (v2si, v2si)
12064 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
12065 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
12066 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
12067 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
12068 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
12069 v8qi __builtin_ia32_psignb (v8qi, v8qi)
12070 v2si __builtin_ia32_psignd (v2si, v2si)
12071 v4hi __builtin_ia32_psignw (v4hi, v4hi)
12072 v1di __builtin_ia32_palignr (v1di, v1di, int)
12073 v8qi __builtin_ia32_pabsb (v8qi)
12074 v2si __builtin_ia32_pabsd (v2si)
12075 v4hi __builtin_ia32_pabsw (v4hi)
12078 The following built-in functions are available when @option{-mssse3} is used.
12079 All of them generate the machine instruction that is part of the name.
12082 v4si __builtin_ia32_phaddd128 (v4si, v4si)
12083 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
12084 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
12085 v4si __builtin_ia32_phsubd128 (v4si, v4si)
12086 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
12087 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
12088 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
12089 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
12090 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
12091 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
12092 v4si __builtin_ia32_psignd128 (v4si, v4si)
12093 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
12094 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
12095 v16qi __builtin_ia32_pabsb128 (v16qi)
12096 v4si __builtin_ia32_pabsd128 (v4si)
12097 v8hi __builtin_ia32_pabsw128 (v8hi)
12100 The following built-in functions are available when @option{-msse4.1} is
12101 used. All of them generate the machine instruction that is part of the
12105 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
12106 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
12107 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
12108 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
12109 v2df __builtin_ia32_dppd (v2df, v2df, const int)
12110 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
12111 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
12112 v2di __builtin_ia32_movntdqa (v2di *);
12113 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
12114 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
12115 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
12116 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
12117 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
12118 v8hi __builtin_ia32_phminposuw128 (v8hi)
12119 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
12120 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
12121 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
12122 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
12123 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
12124 v4si __builtin_ia32_pminsd128 (v4si, v4si)
12125 v4si __builtin_ia32_pminud128 (v4si, v4si)
12126 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
12127 v4si __builtin_ia32_pmovsxbd128 (v16qi)
12128 v2di __builtin_ia32_pmovsxbq128 (v16qi)
12129 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
12130 v2di __builtin_ia32_pmovsxdq128 (v4si)
12131 v4si __builtin_ia32_pmovsxwd128 (v8hi)
12132 v2di __builtin_ia32_pmovsxwq128 (v8hi)
12133 v4si __builtin_ia32_pmovzxbd128 (v16qi)
12134 v2di __builtin_ia32_pmovzxbq128 (v16qi)
12135 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
12136 v2di __builtin_ia32_pmovzxdq128 (v4si)
12137 v4si __builtin_ia32_pmovzxwd128 (v8hi)
12138 v2di __builtin_ia32_pmovzxwq128 (v8hi)
12139 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
12140 v4si __builtin_ia32_pmulld128 (v4si, v4si)
12141 int __builtin_ia32_ptestc128 (v2di, v2di)
12142 int __builtin_ia32_ptestnzc128 (v2di, v2di)
12143 int __builtin_ia32_ptestz128 (v2di, v2di)
12144 v2df __builtin_ia32_roundpd (v2df, const int)
12145 v4sf __builtin_ia32_roundps (v4sf, const int)
12146 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
12147 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
12150 The following built-in functions are available when @option{-msse4.1} is
12154 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
12155 Generates the @code{insertps} machine instruction.
12156 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
12157 Generates the @code{pextrb} machine instruction.
12158 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
12159 Generates the @code{pinsrb} machine instruction.
12160 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
12161 Generates the @code{pinsrd} machine instruction.
12162 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
12163 Generates the @code{pinsrq} machine instruction in 64bit mode.
12166 The following built-in functions are changed to generate new SSE4.1
12167 instructions when @option{-msse4.1} is used.
12170 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
12171 Generates the @code{extractps} machine instruction.
12172 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
12173 Generates the @code{pextrd} machine instruction.
12174 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
12175 Generates the @code{pextrq} machine instruction in 64bit mode.
12178 The following built-in functions are available when @option{-msse4.2} is
12179 used. All of them generate the machine instruction that is part of the
12183 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
12184 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
12185 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
12186 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
12187 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
12188 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
12189 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
12190 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
12191 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
12192 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
12193 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
12194 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
12195 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
12196 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
12197 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
12200 The following built-in functions are available when @option{-msse4.2} is
12204 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
12205 Generates the @code{crc32b} machine instruction.
12206 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
12207 Generates the @code{crc32w} machine instruction.
12208 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
12209 Generates the @code{crc32l} machine instruction.
12210 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
12211 Generates the @code{crc32q} machine instruction.
12214 The following built-in functions are changed to generate new SSE4.2
12215 instructions when @option{-msse4.2} is used.
12218 @item int __builtin_popcount (unsigned int)
12219 Generates the @code{popcntl} machine instruction.
12220 @item int __builtin_popcountl (unsigned long)
12221 Generates the @code{popcntl} or @code{popcntq} machine instruction,
12222 depending on the size of @code{unsigned long}.
12223 @item int __builtin_popcountll (unsigned long long)
12224 Generates the @code{popcntq} machine instruction.
12227 The following built-in functions are available when @option{-mavx} is
12228 used. All of them generate the machine instruction that is part of the
12232 v4df __builtin_ia32_addpd256 (v4df,v4df)
12233 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
12234 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
12235 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
12236 v4df __builtin_ia32_andnpd256 (v4df,v4df)
12237 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
12238 v4df __builtin_ia32_andpd256 (v4df,v4df)
12239 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
12240 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
12241 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
12242 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
12243 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
12244 v2df __builtin_ia32_cmppd (v2df,v2df,int)
12245 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
12246 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
12247 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
12248 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
12249 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
12250 v4df __builtin_ia32_cvtdq2pd256 (v4si)
12251 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
12252 v4si __builtin_ia32_cvtpd2dq256 (v4df)
12253 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
12254 v8si __builtin_ia32_cvtps2dq256 (v8sf)
12255 v4df __builtin_ia32_cvtps2pd256 (v4sf)
12256 v4si __builtin_ia32_cvttpd2dq256 (v4df)
12257 v8si __builtin_ia32_cvttps2dq256 (v8sf)
12258 v4df __builtin_ia32_divpd256 (v4df,v4df)
12259 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
12260 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
12261 v4df __builtin_ia32_haddpd256 (v4df,v4df)
12262 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
12263 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
12264 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
12265 v32qi __builtin_ia32_lddqu256 (pcchar)
12266 v32qi __builtin_ia32_loaddqu256 (pcchar)
12267 v4df __builtin_ia32_loadupd256 (pcdouble)
12268 v8sf __builtin_ia32_loadups256 (pcfloat)
12269 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
12270 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
12271 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
12272 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
12273 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
12274 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
12275 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
12276 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
12277 v4df __builtin_ia32_maxpd256 (v4df,v4df)
12278 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
12279 v4df __builtin_ia32_minpd256 (v4df,v4df)
12280 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
12281 v4df __builtin_ia32_movddup256 (v4df)
12282 int __builtin_ia32_movmskpd256 (v4df)
12283 int __builtin_ia32_movmskps256 (v8sf)
12284 v8sf __builtin_ia32_movshdup256 (v8sf)
12285 v8sf __builtin_ia32_movsldup256 (v8sf)
12286 v4df __builtin_ia32_mulpd256 (v4df,v4df)
12287 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
12288 v4df __builtin_ia32_orpd256 (v4df,v4df)
12289 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
12290 v2df __builtin_ia32_pd_pd256 (v4df)
12291 v4df __builtin_ia32_pd256_pd (v2df)
12292 v4sf __builtin_ia32_ps_ps256 (v8sf)
12293 v8sf __builtin_ia32_ps256_ps (v4sf)
12294 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
12295 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
12296 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
12297 v8sf __builtin_ia32_rcpps256 (v8sf)
12298 v4df __builtin_ia32_roundpd256 (v4df,int)
12299 v8sf __builtin_ia32_roundps256 (v8sf,int)
12300 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
12301 v8sf __builtin_ia32_rsqrtps256 (v8sf)
12302 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
12303 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
12304 v4si __builtin_ia32_si_si256 (v8si)
12305 v8si __builtin_ia32_si256_si (v4si)
12306 v4df __builtin_ia32_sqrtpd256 (v4df)
12307 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
12308 v8sf __builtin_ia32_sqrtps256 (v8sf)
12309 void __builtin_ia32_storedqu256 (pchar,v32qi)
12310 void __builtin_ia32_storeupd256 (pdouble,v4df)
12311 void __builtin_ia32_storeups256 (pfloat,v8sf)
12312 v4df __builtin_ia32_subpd256 (v4df,v4df)
12313 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
12314 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
12315 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
12316 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
12317 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
12318 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
12319 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
12320 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
12321 v4sf __builtin_ia32_vbroadcastss (pcfloat)
12322 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
12323 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
12324 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
12325 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
12326 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
12327 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
12328 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
12329 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
12330 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
12331 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
12332 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
12333 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
12334 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
12335 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
12336 v2df __builtin_ia32_vpermilpd (v2df,int)
12337 v4df __builtin_ia32_vpermilpd256 (v4df,int)
12338 v4sf __builtin_ia32_vpermilps (v4sf,int)
12339 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
12340 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
12341 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
12342 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
12343 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
12344 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
12345 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
12346 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
12347 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
12348 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
12349 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
12350 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
12351 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
12352 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
12353 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
12354 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
12355 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
12356 void __builtin_ia32_vzeroall (void)
12357 void __builtin_ia32_vzeroupper (void)
12358 v4df __builtin_ia32_xorpd256 (v4df,v4df)
12359 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
12362 The following built-in functions are available when @option{-mavx2} is
12363 used. All of them generate the machine instruction that is part of the
12367 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
12368 v32qi __builtin_ia32_pabsb256 (v32qi)
12369 v16hi __builtin_ia32_pabsw256 (v16hi)
12370 v8si __builtin_ia32_pabsd256 (v8si)
12371 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
12372 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
12373 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
12374 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
12375 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
12376 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
12377 v8si __builtin_ia32_paddd256 (v8si,v8si)
12378 v4di __builtin_ia32_paddq256 (v4di,v4di)
12379 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
12380 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
12381 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
12382 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
12383 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
12384 v4di __builtin_ia32_andsi256 (v4di,v4di)
12385 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
12386 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
12387 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
12388 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
12389 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
12390 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
12391 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
12392 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
12393 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
12394 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
12395 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
12396 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
12397 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
12398 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
12399 v8si __builtin_ia32_phaddd256 (v8si,v8si)
12400 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
12401 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
12402 v8si __builtin_ia32_phsubd256 (v8si,v8si)
12403 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
12404 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
12405 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
12406 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
12407 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
12408 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
12409 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
12410 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
12411 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
12412 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
12413 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
12414 v8si __builtin_ia32_pminsd256 (v8si,v8si)
12415 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
12416 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
12417 v8si __builtin_ia32_pminud256 (v8si,v8si)
12418 int __builtin_ia32_pmovmskb256 (v32qi)
12419 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
12420 v8si __builtin_ia32_pmovsxbd256 (v16qi)
12421 v4di __builtin_ia32_pmovsxbq256 (v16qi)
12422 v8si __builtin_ia32_pmovsxwd256 (v8hi)
12423 v4di __builtin_ia32_pmovsxwq256 (v8hi)
12424 v4di __builtin_ia32_pmovsxdq256 (v4si)
12425 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
12426 v8si __builtin_ia32_pmovzxbd256 (v16qi)
12427 v4di __builtin_ia32_pmovzxbq256 (v16qi)
12428 v8si __builtin_ia32_pmovzxwd256 (v8hi)
12429 v4di __builtin_ia32_pmovzxwq256 (v8hi)
12430 v4di __builtin_ia32_pmovzxdq256 (v4si)
12431 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
12432 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
12433 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
12434 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
12435 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
12436 v8si __builtin_ia32_pmulld256 (v8si,v8si)
12437 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
12438 v4di __builtin_ia32_por256 (v4di,v4di)
12439 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
12440 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
12441 v8si __builtin_ia32_pshufd256 (v8si,int)
12442 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
12443 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
12444 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
12445 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
12446 v8si __builtin_ia32_psignd256 (v8si,v8si)
12447 v4di __builtin_ia32_pslldqi256 (v4di,int)
12448 v16hi __builtin_ia32_psllwi256 (16hi,int)
12449 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
12450 v8si __builtin_ia32_pslldi256 (v8si,int)
12451 v8si __builtin_ia32_pslld256(v8si,v4si)
12452 v4di __builtin_ia32_psllqi256 (v4di,int)
12453 v4di __builtin_ia32_psllq256(v4di,v2di)
12454 v16hi __builtin_ia32_psrawi256 (v16hi,int)
12455 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
12456 v8si __builtin_ia32_psradi256 (v8si,int)
12457 v8si __builtin_ia32_psrad256 (v8si,v4si)
12458 v4di __builtin_ia32_psrldqi256 (v4di, int)
12459 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
12460 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
12461 v8si __builtin_ia32_psrldi256 (v8si,int)
12462 v8si __builtin_ia32_psrld256 (v8si,v4si)
12463 v4di __builtin_ia32_psrlqi256 (v4di,int)
12464 v4di __builtin_ia32_psrlq256(v4di,v2di)
12465 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
12466 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
12467 v8si __builtin_ia32_psubd256 (v8si,v8si)
12468 v4di __builtin_ia32_psubq256 (v4di,v4di)
12469 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
12470 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
12471 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
12472 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
12473 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
12474 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
12475 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
12476 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
12477 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
12478 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
12479 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
12480 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
12481 v4di __builtin_ia32_pxor256 (v4di,v4di)
12482 v4di __builtin_ia32_movntdqa256 (pv4di)
12483 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
12484 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
12485 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
12486 v4di __builtin_ia32_vbroadcastsi256 (v2di)
12487 v4si __builtin_ia32_pblendd128 (v4si,v4si)
12488 v8si __builtin_ia32_pblendd256 (v8si,v8si)
12489 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
12490 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
12491 v8si __builtin_ia32_pbroadcastd256 (v4si)
12492 v4di __builtin_ia32_pbroadcastq256 (v2di)
12493 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
12494 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
12495 v4si __builtin_ia32_pbroadcastd128 (v4si)
12496 v2di __builtin_ia32_pbroadcastq128 (v2di)
12497 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
12498 v4df __builtin_ia32_permdf256 (v4df,int)
12499 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
12500 v4di __builtin_ia32_permdi256 (v4di,int)
12501 v4di __builtin_ia32_permti256 (v4di,v4di,int)
12502 v4di __builtin_ia32_extract128i256 (v4di,int)
12503 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
12504 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
12505 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
12506 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
12507 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
12508 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
12509 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
12510 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
12511 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
12512 v8si __builtin_ia32_psllv8si (v8si,v8si)
12513 v4si __builtin_ia32_psllv4si (v4si,v4si)
12514 v4di __builtin_ia32_psllv4di (v4di,v4di)
12515 v2di __builtin_ia32_psllv2di (v2di,v2di)
12516 v8si __builtin_ia32_psrav8si (v8si,v8si)
12517 v4si __builtin_ia32_psrav4si (v4si,v4si)
12518 v8si __builtin_ia32_psrlv8si (v8si,v8si)
12519 v4si __builtin_ia32_psrlv4si (v4si,v4si)
12520 v4di __builtin_ia32_psrlv4di (v4di,v4di)
12521 v2di __builtin_ia32_psrlv2di (v2di,v2di)
12522 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
12523 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
12524 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
12525 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
12526 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
12527 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
12528 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
12529 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
12530 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
12531 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
12532 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
12533 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
12534 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
12535 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
12536 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
12537 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
12540 The following built-in functions are available when @option{-maes} is
12541 used. All of them generate the machine instruction that is part of the
12545 v2di __builtin_ia32_aesenc128 (v2di, v2di)
12546 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
12547 v2di __builtin_ia32_aesdec128 (v2di, v2di)
12548 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
12549 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
12550 v2di __builtin_ia32_aesimc128 (v2di)
12553 The following built-in function is available when @option{-mpclmul} is
12557 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
12558 Generates the @code{pclmulqdq} machine instruction.
12561 The following built-in function is available when @option{-mfsgsbase} is
12562 used. All of them generate the machine instruction that is part of the
12566 unsigned int __builtin_ia32_rdfsbase32 (void)
12567 unsigned long long __builtin_ia32_rdfsbase64 (void)
12568 unsigned int __builtin_ia32_rdgsbase32 (void)
12569 unsigned long long __builtin_ia32_rdgsbase64 (void)
12570 void _writefsbase_u32 (unsigned int)
12571 void _writefsbase_u64 (unsigned long long)
12572 void _writegsbase_u32 (unsigned int)
12573 void _writegsbase_u64 (unsigned long long)
12576 The following built-in function is available when @option{-mrdrnd} is
12577 used. All of them generate the machine instruction that is part of the
12581 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
12582 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
12583 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
12586 The following built-in functions are available when @option{-msse4a} is used.
12587 All of them generate the machine instruction that is part of the name.
12590 void __builtin_ia32_movntsd (double *, v2df)
12591 void __builtin_ia32_movntss (float *, v4sf)
12592 v2di __builtin_ia32_extrq (v2di, v16qi)
12593 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
12594 v2di __builtin_ia32_insertq (v2di, v2di)
12595 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
12598 The following built-in functions are available when @option{-mxop} is used.
12600 v2df __builtin_ia32_vfrczpd (v2df)
12601 v4sf __builtin_ia32_vfrczps (v4sf)
12602 v2df __builtin_ia32_vfrczsd (v2df)
12603 v4sf __builtin_ia32_vfrczss (v4sf)
12604 v4df __builtin_ia32_vfrczpd256 (v4df)
12605 v8sf __builtin_ia32_vfrczps256 (v8sf)
12606 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
12607 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
12608 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
12609 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
12610 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
12611 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
12612 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
12613 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
12614 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
12615 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
12616 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
12617 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
12618 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
12619 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
12620 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12621 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
12622 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
12623 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
12624 v4si __builtin_ia32_vpcomequd (v4si, v4si)
12625 v2di __builtin_ia32_vpcomequq (v2di, v2di)
12626 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
12627 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12628 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
12629 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
12630 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
12631 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
12632 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
12633 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
12634 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
12635 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
12636 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
12637 v4si __builtin_ia32_vpcomged (v4si, v4si)
12638 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
12639 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
12640 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
12641 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
12642 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
12643 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
12644 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
12645 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
12646 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
12647 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
12648 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
12649 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
12650 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
12651 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
12652 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
12653 v4si __builtin_ia32_vpcomled (v4si, v4si)
12654 v2di __builtin_ia32_vpcomleq (v2di, v2di)
12655 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
12656 v4si __builtin_ia32_vpcomleud (v4si, v4si)
12657 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
12658 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
12659 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
12660 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
12661 v4si __builtin_ia32_vpcomltd (v4si, v4si)
12662 v2di __builtin_ia32_vpcomltq (v2di, v2di)
12663 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
12664 v4si __builtin_ia32_vpcomltud (v4si, v4si)
12665 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
12666 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
12667 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
12668 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
12669 v4si __builtin_ia32_vpcomned (v4si, v4si)
12670 v2di __builtin_ia32_vpcomneq (v2di, v2di)
12671 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
12672 v4si __builtin_ia32_vpcomneud (v4si, v4si)
12673 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
12674 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
12675 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
12676 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
12677 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
12678 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
12679 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
12680 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
12681 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
12682 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
12683 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
12684 v4si __builtin_ia32_vphaddbd (v16qi)
12685 v2di __builtin_ia32_vphaddbq (v16qi)
12686 v8hi __builtin_ia32_vphaddbw (v16qi)
12687 v2di __builtin_ia32_vphadddq (v4si)
12688 v4si __builtin_ia32_vphaddubd (v16qi)
12689 v2di __builtin_ia32_vphaddubq (v16qi)
12690 v8hi __builtin_ia32_vphaddubw (v16qi)
12691 v2di __builtin_ia32_vphaddudq (v4si)
12692 v4si __builtin_ia32_vphadduwd (v8hi)
12693 v2di __builtin_ia32_vphadduwq (v8hi)
12694 v4si __builtin_ia32_vphaddwd (v8hi)
12695 v2di __builtin_ia32_vphaddwq (v8hi)
12696 v8hi __builtin_ia32_vphsubbw (v16qi)
12697 v2di __builtin_ia32_vphsubdq (v4si)
12698 v4si __builtin_ia32_vphsubwd (v8hi)
12699 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
12700 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
12701 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
12702 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
12703 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
12704 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
12705 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
12706 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
12707 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
12708 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
12709 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
12710 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
12711 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
12712 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
12713 v4si __builtin_ia32_vprotd (v4si, v4si)
12714 v2di __builtin_ia32_vprotq (v2di, v2di)
12715 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
12716 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
12717 v4si __builtin_ia32_vpshad (v4si, v4si)
12718 v2di __builtin_ia32_vpshaq (v2di, v2di)
12719 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
12720 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
12721 v4si __builtin_ia32_vpshld (v4si, v4si)
12722 v2di __builtin_ia32_vpshlq (v2di, v2di)
12723 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
12726 The following built-in functions are available when @option{-mfma4} is used.
12727 All of them generate the machine instruction that is part of the name.
12730 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
12731 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
12732 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
12733 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
12734 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
12735 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
12736 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
12737 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
12738 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
12739 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
12740 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
12741 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
12742 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
12743 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
12744 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
12745 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
12746 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
12747 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
12748 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
12749 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
12750 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
12751 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
12752 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
12753 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
12754 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
12755 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
12756 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
12757 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
12758 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
12759 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
12760 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
12761 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
12765 The following built-in functions are available when @option{-mlwp} is used.
12768 void __builtin_ia32_llwpcb16 (void *);
12769 void __builtin_ia32_llwpcb32 (void *);
12770 void __builtin_ia32_llwpcb64 (void *);
12771 void * __builtin_ia32_llwpcb16 (void);
12772 void * __builtin_ia32_llwpcb32 (void);
12773 void * __builtin_ia32_llwpcb64 (void);
12774 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
12775 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
12776 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
12777 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
12778 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
12779 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
12782 The following built-in functions are available when @option{-mbmi} is used.
12783 All of them generate the machine instruction that is part of the name.
12785 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
12786 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
12789 The following built-in functions are available when @option{-mbmi2} is used.
12790 All of them generate the machine instruction that is part of the name.
12792 unsigned int _bzhi_u32 (unsigned int, unsigned int)
12793 unsigned int _pdep_u32 (unsigned int, unsigned int)
12794 unsigned int _pext_u32 (unsigned int, unsigned int)
12795 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
12796 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
12797 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
12800 The following built-in functions are available when @option{-mlzcnt} is used.
12801 All of them generate the machine instruction that is part of the name.
12803 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
12804 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
12805 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
12808 The following built-in functions are available when @option{-mfxsr} is used.
12809 All of them generate the machine instruction that is part of the name.
12811 void __builtin_ia32_fxsave (void *)
12812 void __builtin_ia32_fxrstor (void *)
12813 void __builtin_ia32_fxsave64 (void *)
12814 void __builtin_ia32_fxrstor64 (void *)
12817 The following built-in functions are available when @option{-mxsave} is used.
12818 All of them generate the machine instruction that is part of the name.
12820 void __builtin_ia32_xsave (void *, long long)
12821 void __builtin_ia32_xrstor (void *, long long)
12822 void __builtin_ia32_xsave64 (void *, long long)
12823 void __builtin_ia32_xrstor64 (void *, long long)
12826 The following built-in functions are available when @option{-mxsaveopt} is used.
12827 All of them generate the machine instruction that is part of the name.
12829 void __builtin_ia32_xsaveopt (void *, long long)
12830 void __builtin_ia32_xsaveopt64 (void *, long long)
12833 The following built-in functions are available when @option{-mtbm} is used.
12834 Both of them generate the immediate form of the bextr machine instruction.
12836 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
12837 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
12841 The following built-in functions are available when @option{-m3dnow} is used.
12842 All of them generate the machine instruction that is part of the name.
12845 void __builtin_ia32_femms (void)
12846 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
12847 v2si __builtin_ia32_pf2id (v2sf)
12848 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
12849 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
12850 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
12851 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
12852 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
12853 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
12854 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
12855 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
12856 v2sf __builtin_ia32_pfrcp (v2sf)
12857 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
12858 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
12859 v2sf __builtin_ia32_pfrsqrt (v2sf)
12860 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
12861 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
12862 v2sf __builtin_ia32_pi2fd (v2si)
12863 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
12866 The following built-in functions are available when both @option{-m3dnow}
12867 and @option{-march=athlon} are used. All of them generate the machine
12868 instruction that is part of the name.
12871 v2si __builtin_ia32_pf2iw (v2sf)
12872 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
12873 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
12874 v2sf __builtin_ia32_pi2fw (v2si)
12875 v2sf __builtin_ia32_pswapdsf (v2sf)
12876 v2si __builtin_ia32_pswapdsi (v2si)
12879 The following built-in functions are available when @option{-mrtm} is used
12880 They are used for restricted transactional memory. These are the internal
12881 low level functions. Normally the functions in
12882 @ref{x86 transactional memory intrinsics} should be used instead.
12885 int __builtin_ia32_xbegin ()
12886 void __builtin_ia32_xend ()
12887 void __builtin_ia32_xabort (status)
12888 int __builtin_ia32_xtest ()
12891 @node x86 transactional memory intrinsics
12892 @subsection x86 transaction memory intrinsics
12894 Hardware transactional memory intrinsics for x86. These allow to use
12895 memory transactions with RTM (Restricted Transactional Memory).
12896 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
12897 This support is enabled with the @option{-mrtm} option.
12899 A memory transaction commits all changes to memory in an atomic way,
12900 as visible to other threads. If the transaction fails it is rolled back
12901 and all side effects discarded.
12903 Generally there is no guarantee that a memory transaction ever succeeds
12904 and suitable fallback code always needs to be supplied.
12906 @deftypefn {RTM Function} {unsigned} _xbegin ()
12907 Start a RTM (Restricted Transactional Memory) transaction.
12908 Returns _XBEGIN_STARTED when the transaction
12909 started successfully (note this is not 0, so the constant has to be
12910 explicitely tested). When the transaction aborts all side effects
12911 are undone and an abort code is returned. There is no guarantee
12912 any transaction ever succeeds, so there always needs to be a valid
12913 tested fallback path.
12917 #include <immintrin.h>
12919 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
12920 ... transaction code...
12923 ... non transactional fallback path...
12927 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
12930 @item _XABORT_EXPLICIT
12931 Transaction explicitely aborted with @code{_xabort}. The parameter passed
12932 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
12933 @item _XABORT_RETRY
12934 Transaction retry is possible.
12935 @item _XABORT_CONFLICT
12936 Transaction abort due to a memory conflict with another thread
12937 @item _XABORT_CAPACITY
12938 Transaction abort due to the transaction using too much memory
12939 @item _XABORT_DEBUG
12940 Transaction abort due to a debug trap
12941 @item _XABORT_NESTED
12942 Transaction abort in a inner nested transaction
12945 @deftypefn {RTM Function} {void} _xend ()
12946 Commit the current transaction. When no transaction is active this will
12947 fault. All memory side effects of the transactions will become visible
12948 to other threads in an atomic matter.
12951 @deftypefn {RTM Function} {int} _xtest ()
12952 Return a value not zero when a transaction is currently active, otherwise 0.
12955 @deftypefn {RTM Function} {void} _xabort (status)
12956 Abort the current transaction. When no transaction is active this is a no-op.
12957 status must be a 8bit constant, that is included in the status code returned
12961 @node MIPS DSP Built-in Functions
12962 @subsection MIPS DSP Built-in Functions
12964 The MIPS DSP Application-Specific Extension (ASE) includes new
12965 instructions that are designed to improve the performance of DSP and
12966 media applications. It provides instructions that operate on packed
12967 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12969 GCC supports MIPS DSP operations using both the generic
12970 vector extensions (@pxref{Vector Extensions}) and a collection of
12971 MIPS-specific built-in functions. Both kinds of support are
12972 enabled by the @option{-mdsp} command-line option.
12974 Revision 2 of the ASE was introduced in the second half of 2006.
12975 This revision adds extra instructions to the original ASE, but is
12976 otherwise backwards-compatible with it. You can select revision 2
12977 using the command-line option @option{-mdspr2}; this option implies
12980 The SCOUNT and POS bits of the DSP control register are global. The
12981 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12982 POS bits. During optimization, the compiler does not delete these
12983 instructions and it does not delete calls to functions containing
12984 these instructions.
12986 At present, GCC only provides support for operations on 32-bit
12987 vectors. The vector type associated with 8-bit integer data is
12988 usually called @code{v4i8}, the vector type associated with Q7
12989 is usually called @code{v4q7}, the vector type associated with 16-bit
12990 integer data is usually called @code{v2i16}, and the vector type
12991 associated with Q15 is usually called @code{v2q15}. They can be
12992 defined in C as follows:
12995 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12996 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12997 typedef short v2i16 __attribute__ ((vector_size(4)));
12998 typedef short v2q15 __attribute__ ((vector_size(4)));
13001 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13002 initialized in the same way as aggregates. For example:
13005 v4i8 a = @{1, 2, 3, 4@};
13007 b = (v4i8) @{5, 6, 7, 8@};
13009 v2q15 c = @{0x0fcb, 0x3a75@};
13011 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13014 @emph{Note:} The CPU's endianness determines the order in which values
13015 are packed. On little-endian targets, the first value is the least
13016 significant and the last value is the most significant. The opposite
13017 order applies to big-endian targets. For example, the code above
13018 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13019 and @code{4} on big-endian targets.
13021 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13022 representation. As shown in this example, the integer representation
13023 of a Q7 value can be obtained by multiplying the fractional value by
13024 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
13025 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
13028 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13029 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
13030 and @code{c} and @code{d} are @code{v2q15} values.
13032 @multitable @columnfractions .50 .50
13033 @item C code @tab MIPS instruction
13034 @item @code{a + b} @tab @code{addu.qb}
13035 @item @code{c + d} @tab @code{addq.ph}
13036 @item @code{a - b} @tab @code{subu.qb}
13037 @item @code{c - d} @tab @code{subq.ph}
13040 The table below lists the @code{v2i16} operation for which
13041 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
13042 @code{v2i16} values.
13044 @multitable @columnfractions .50 .50
13045 @item C code @tab MIPS instruction
13046 @item @code{e * f} @tab @code{mul.ph}
13049 It is easier to describe the DSP built-in functions if we first define
13050 the following types:
13055 typedef unsigned int ui32;
13056 typedef long long a64;
13059 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13060 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13061 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
13062 @code{long long}, but we use @code{a64} to indicate values that are
13063 placed in one of the four DSP accumulators (@code{$ac0},
13064 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13066 Also, some built-in functions prefer or require immediate numbers as
13067 parameters, because the corresponding DSP instructions accept both immediate
13068 numbers and register operands, or accept immediate numbers only. The
13069 immediate parameters are listed as follows.
13077 imm0_255: 0 to 255.
13078 imm_n32_31: -32 to 31.
13079 imm_n512_511: -512 to 511.
13082 The following built-in functions map directly to a particular MIPS DSP
13083 instruction. Please refer to the architecture specification
13084 for details on what each instruction does.
13087 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13088 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13089 q31 __builtin_mips_addq_s_w (q31, q31)
13090 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13091 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13092 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13093 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13094 q31 __builtin_mips_subq_s_w (q31, q31)
13095 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13096 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13097 i32 __builtin_mips_addsc (i32, i32)
13098 i32 __builtin_mips_addwc (i32, i32)
13099 i32 __builtin_mips_modsub (i32, i32)
13100 i32 __builtin_mips_raddu_w_qb (v4i8)
13101 v2q15 __builtin_mips_absq_s_ph (v2q15)
13102 q31 __builtin_mips_absq_s_w (q31)
13103 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13104 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13105 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13106 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13107 q31 __builtin_mips_preceq_w_phl (v2q15)
13108 q31 __builtin_mips_preceq_w_phr (v2q15)
13109 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13110 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13111 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13112 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13113 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13114 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13115 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13116 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13117 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13118 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13119 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13120 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13121 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13122 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13123 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13124 q31 __builtin_mips_shll_s_w (q31, i32)
13125 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13126 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13127 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13128 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13129 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13130 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13131 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13132 q31 __builtin_mips_shra_r_w (q31, i32)
13133 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13134 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13135 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13136 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13137 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13138 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13139 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13140 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13141 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13142 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13143 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13144 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13145 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13146 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13147 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13148 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13149 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13150 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13151 i32 __builtin_mips_bitrev (i32)
13152 i32 __builtin_mips_insv (i32, i32)
13153 v4i8 __builtin_mips_repl_qb (imm0_255)
13154 v4i8 __builtin_mips_repl_qb (i32)
13155 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13156 v2q15 __builtin_mips_repl_ph (i32)
13157 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13158 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13159 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13160 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13161 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13162 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13163 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13164 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13165 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13166 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13167 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13168 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13169 i32 __builtin_mips_extr_w (a64, imm0_31)
13170 i32 __builtin_mips_extr_w (a64, i32)
13171 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13172 i32 __builtin_mips_extr_s_h (a64, i32)
13173 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13174 i32 __builtin_mips_extr_rs_w (a64, i32)
13175 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13176 i32 __builtin_mips_extr_r_w (a64, i32)
13177 i32 __builtin_mips_extp (a64, imm0_31)
13178 i32 __builtin_mips_extp (a64, i32)
13179 i32 __builtin_mips_extpdp (a64, imm0_31)
13180 i32 __builtin_mips_extpdp (a64, i32)
13181 a64 __builtin_mips_shilo (a64, imm_n32_31)
13182 a64 __builtin_mips_shilo (a64, i32)
13183 a64 __builtin_mips_mthlip (a64, i32)
13184 void __builtin_mips_wrdsp (i32, imm0_63)
13185 i32 __builtin_mips_rddsp (imm0_63)
13186 i32 __builtin_mips_lbux (void *, i32)
13187 i32 __builtin_mips_lhx (void *, i32)
13188 i32 __builtin_mips_lwx (void *, i32)
13189 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13190 i32 __builtin_mips_bposge32 (void)
13191 a64 __builtin_mips_madd (a64, i32, i32);
13192 a64 __builtin_mips_maddu (a64, ui32, ui32);
13193 a64 __builtin_mips_msub (a64, i32, i32);
13194 a64 __builtin_mips_msubu (a64, ui32, ui32);
13195 a64 __builtin_mips_mult (i32, i32);
13196 a64 __builtin_mips_multu (ui32, ui32);
13199 The following built-in functions map directly to a particular MIPS DSP REV 2
13200 instruction. Please refer to the architecture specification
13201 for details on what each instruction does.
13204 v4q7 __builtin_mips_absq_s_qb (v4q7);
13205 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13206 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13207 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13208 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13209 i32 __builtin_mips_append (i32, i32, imm0_31);
13210 i32 __builtin_mips_balign (i32, i32, imm0_3);
13211 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13212 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13213 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13214 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13215 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13216 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13217 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13218 q31 __builtin_mips_mulq_rs_w (q31, q31);
13219 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13220 q31 __builtin_mips_mulq_s_w (q31, q31);
13221 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13222 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13223 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13224 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13225 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13226 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13227 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13228 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13229 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13230 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13231 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13232 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13233 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13234 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13235 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13236 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13237 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13238 q31 __builtin_mips_addqh_w (q31, q31);
13239 q31 __builtin_mips_addqh_r_w (q31, q31);
13240 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13241 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13242 q31 __builtin_mips_subqh_w (q31, q31);
13243 q31 __builtin_mips_subqh_r_w (q31, q31);
13244 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13245 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13246 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13247 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13248 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13249 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13253 @node MIPS Paired-Single Support
13254 @subsection MIPS Paired-Single Support
13256 The MIPS64 architecture includes a number of instructions that
13257 operate on pairs of single-precision floating-point values.
13258 Each pair is packed into a 64-bit floating-point register,
13259 with one element being designated the ``upper half'' and
13260 the other being designated the ``lower half''.
13262 GCC supports paired-single operations using both the generic
13263 vector extensions (@pxref{Vector Extensions}) and a collection of
13264 MIPS-specific built-in functions. Both kinds of support are
13265 enabled by the @option{-mpaired-single} command-line option.
13267 The vector type associated with paired-single values is usually
13268 called @code{v2sf}. It can be defined in C as follows:
13271 typedef float v2sf __attribute__ ((vector_size (8)));
13274 @code{v2sf} values are initialized in the same way as aggregates.
13278 v2sf a = @{1.5, 9.1@};
13281 b = (v2sf) @{e, f@};
13284 @emph{Note:} The CPU's endianness determines which value is stored in
13285 the upper half of a register and which value is stored in the lower half.
13286 On little-endian targets, the first value is the lower one and the second
13287 value is the upper one. The opposite order applies to big-endian targets.
13288 For example, the code above sets the lower half of @code{a} to
13289 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13291 @node MIPS Loongson Built-in Functions
13292 @subsection MIPS Loongson Built-in Functions
13294 GCC provides intrinsics to access the SIMD instructions provided by the
13295 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
13296 available after inclusion of the @code{loongson.h} header file,
13297 operate on the following 64-bit vector types:
13300 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13301 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13302 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13303 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13304 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13305 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13308 The intrinsics provided are listed below; each is named after the
13309 machine instruction to which it corresponds, with suffixes added as
13310 appropriate to distinguish intrinsics that expand to the same machine
13311 instruction yet have different argument types. Refer to the architecture
13312 documentation for a description of the functionality of each
13316 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13317 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13318 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13319 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13320 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13321 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13322 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13323 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13324 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13325 uint64_t paddd_u (uint64_t s, uint64_t t);
13326 int64_t paddd_s (int64_t s, int64_t t);
13327 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13328 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13329 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13330 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13331 uint64_t pandn_ud (uint64_t s, uint64_t t);
13332 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13333 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13334 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13335 int64_t pandn_sd (int64_t s, int64_t t);
13336 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13337 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13338 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13339 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13340 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13341 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13342 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13343 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13344 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13345 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13346 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13347 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13348 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13349 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13350 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13351 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13352 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13353 uint16x4_t pextrh_u (uint16x4_t s, int field);
13354 int16x4_t pextrh_s (int16x4_t s, int field);
13355 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13356 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13357 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13358 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13359 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13360 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13361 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13362 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13363 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13364 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13365 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13366 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13367 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13368 uint8x8_t pmovmskb_u (uint8x8_t s);
13369 int8x8_t pmovmskb_s (int8x8_t s);
13370 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13371 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13372 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13373 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13374 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13375 uint16x4_t biadd (uint8x8_t s);
13376 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13377 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13378 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13379 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13380 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13381 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13382 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13383 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13384 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13385 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13386 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13387 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13388 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13389 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13390 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13391 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13392 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13393 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13394 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13395 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13396 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13397 uint64_t psubd_u (uint64_t s, uint64_t t);
13398 int64_t psubd_s (int64_t s, int64_t t);
13399 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13400 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13401 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13402 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13403 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13404 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13405 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13406 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13407 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13408 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13409 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13410 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13411 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13412 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13413 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13414 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13418 * Paired-Single Arithmetic::
13419 * Paired-Single Built-in Functions::
13420 * MIPS-3D Built-in Functions::
13423 @node Paired-Single Arithmetic
13424 @subsubsection Paired-Single Arithmetic
13426 The table below lists the @code{v2sf} operations for which hardware
13427 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13428 values and @code{x} is an integral value.
13430 @multitable @columnfractions .50 .50
13431 @item C code @tab MIPS instruction
13432 @item @code{a + b} @tab @code{add.ps}
13433 @item @code{a - b} @tab @code{sub.ps}
13434 @item @code{-a} @tab @code{neg.ps}
13435 @item @code{a * b} @tab @code{mul.ps}
13436 @item @code{a * b + c} @tab @code{madd.ps}
13437 @item @code{a * b - c} @tab @code{msub.ps}
13438 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13439 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13440 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13443 Note that the multiply-accumulate instructions can be disabled
13444 using the command-line option @code{-mno-fused-madd}.
13446 @node Paired-Single Built-in Functions
13447 @subsubsection Paired-Single Built-in Functions
13449 The following paired-single functions map directly to a particular
13450 MIPS instruction. Please refer to the architecture specification
13451 for details on what each instruction does.
13454 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13455 Pair lower lower (@code{pll.ps}).
13457 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13458 Pair upper lower (@code{pul.ps}).
13460 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13461 Pair lower upper (@code{plu.ps}).
13463 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13464 Pair upper upper (@code{puu.ps}).
13466 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13467 Convert pair to paired single (@code{cvt.ps.s}).
13469 @item float __builtin_mips_cvt_s_pl (v2sf)
13470 Convert pair lower to single (@code{cvt.s.pl}).
13472 @item float __builtin_mips_cvt_s_pu (v2sf)
13473 Convert pair upper to single (@code{cvt.s.pu}).
13475 @item v2sf __builtin_mips_abs_ps (v2sf)
13476 Absolute value (@code{abs.ps}).
13478 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13479 Align variable (@code{alnv.ps}).
13481 @emph{Note:} The value of the third parameter must be 0 or 4
13482 modulo 8, otherwise the result is unpredictable. Please read the
13483 instruction description for details.
13486 The following multi-instruction functions are also available.
13487 In each case, @var{cond} can be any of the 16 floating-point conditions:
13488 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13489 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13490 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13493 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13494 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13495 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13496 @code{movt.ps}/@code{movf.ps}).
13498 The @code{movt} functions return the value @var{x} computed by:
13501 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13502 mov.ps @var{x},@var{c}
13503 movt.ps @var{x},@var{d},@var{cc}
13506 The @code{movf} functions are similar but use @code{movf.ps} instead
13509 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13510 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13511 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13512 @code{bc1t}/@code{bc1f}).
13514 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13515 and return either the upper or lower half of the result. For example:
13519 if (__builtin_mips_upper_c_eq_ps (a, b))
13520 upper_halves_are_equal ();
13522 upper_halves_are_unequal ();
13524 if (__builtin_mips_lower_c_eq_ps (a, b))
13525 lower_halves_are_equal ();
13527 lower_halves_are_unequal ();
13531 @node MIPS-3D Built-in Functions
13532 @subsubsection MIPS-3D Built-in Functions
13534 The MIPS-3D Application-Specific Extension (ASE) includes additional
13535 paired-single instructions that are designed to improve the performance
13536 of 3D graphics operations. Support for these instructions is controlled
13537 by the @option{-mips3d} command-line option.
13539 The functions listed below map directly to a particular MIPS-3D
13540 instruction. Please refer to the architecture specification for
13541 more details on what each instruction does.
13544 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13545 Reduction add (@code{addr.ps}).
13547 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13548 Reduction multiply (@code{mulr.ps}).
13550 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13551 Convert paired single to paired word (@code{cvt.pw.ps}).
13553 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13554 Convert paired word to paired single (@code{cvt.ps.pw}).
13556 @item float __builtin_mips_recip1_s (float)
13557 @itemx double __builtin_mips_recip1_d (double)
13558 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13559 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13561 @item float __builtin_mips_recip2_s (float, float)
13562 @itemx double __builtin_mips_recip2_d (double, double)
13563 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13564 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13566 @item float __builtin_mips_rsqrt1_s (float)
13567 @itemx double __builtin_mips_rsqrt1_d (double)
13568 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13569 Reduced-precision reciprocal square root (sequence step 1)
13570 (@code{rsqrt1.@var{fmt}}).
13572 @item float __builtin_mips_rsqrt2_s (float, float)
13573 @itemx double __builtin_mips_rsqrt2_d (double, double)
13574 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13575 Reduced-precision reciprocal square root (sequence step 2)
13576 (@code{rsqrt2.@var{fmt}}).
13579 The following multi-instruction functions are also available.
13580 In each case, @var{cond} can be any of the 16 floating-point conditions:
13581 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13582 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13583 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13586 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13587 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13588 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13589 @code{bc1t}/@code{bc1f}).
13591 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13592 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13597 if (__builtin_mips_cabs_eq_s (a, b))
13603 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13604 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13605 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13606 @code{bc1t}/@code{bc1f}).
13608 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13609 and return either the upper or lower half of the result. For example:
13613 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13614 upper_halves_are_equal ();
13616 upper_halves_are_unequal ();
13618 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13619 lower_halves_are_equal ();
13621 lower_halves_are_unequal ();
13624 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13625 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13626 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13627 @code{movt.ps}/@code{movf.ps}).
13629 The @code{movt} functions return the value @var{x} computed by:
13632 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13633 mov.ps @var{x},@var{c}
13634 movt.ps @var{x},@var{d},@var{cc}
13637 The @code{movf} functions are similar but use @code{movf.ps} instead
13640 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13641 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13642 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13643 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13644 Comparison of two paired-single values
13645 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13646 @code{bc1any2t}/@code{bc1any2f}).
13648 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13649 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13650 result is true and the @code{all} forms return true if both results are true.
13655 if (__builtin_mips_any_c_eq_ps (a, b))
13660 if (__builtin_mips_all_c_eq_ps (a, b))
13666 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13667 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13668 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13669 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13670 Comparison of four paired-single values
13671 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13672 @code{bc1any4t}/@code{bc1any4f}).
13674 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13675 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13676 The @code{any} forms return true if any of the four results are true
13677 and the @code{all} forms return true if all four results are true.
13682 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13687 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13694 @node Other MIPS Built-in Functions
13695 @subsection Other MIPS Built-in Functions
13697 GCC provides other MIPS-specific built-in functions:
13700 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13701 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13702 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13703 when this function is available.
13705 @item unsigned int __builtin_mips_get_fcsr (void)
13706 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13707 Get and set the contents of the floating-point control and status register
13708 (FPU control register 31). These functions are only available in hard-float
13709 code but can be called in both MIPS16 and non-MIPS16 contexts.
13711 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13712 register except the condition codes, which GCC assumes are preserved.
13715 @node MSP430 Built-in Functions
13716 @subsection MSP430 Built-in Functions
13718 GCC provides a couple of special builtin functions to aid in the
13719 writing of interrupt handlers in C.
13722 @item __bic_SR_register_on_exit (int @var{mask})
13723 This clears the indicated bits in the saved copy of the status register
13724 currently residing on the stack. This only works inside interrupt
13725 handlers and the changes to the status register will only take affect
13726 once the handler returns.
13728 @item __bis_SR_register_on_exit (int @var{mask})
13729 This sets the indicated bits in the saved copy of the status register
13730 currently residing on the stack. This only works inside interrupt
13731 handlers and the changes to the status register will only take affect
13732 once the handler returns.
13734 @item __delay_cycles (long long @var{cycles})
13735 This inserts an instruction sequence that takes exactly @var{cycles}
13736 cycles (between 0 and about 17E9) to complete. The inserted sequence
13737 may use jumps, loops, or no-ops, and does not interfere with any other
13738 instructions. Note that @var{cycles} must be a compile-time constant
13739 integer - that is, you must pass a number, not a variable that may be
13740 optimized to a constant later. The number of cycles delayed by this
13744 @node NDS32 Built-in Functions
13745 @subsection NDS32 Built-in Functions
13747 These built-in functions are available for the NDS32 target:
13749 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13750 Insert an ISYNC instruction into the instruction stream where
13751 @var{addr} is an instruction address for serialization.
13754 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13755 Insert an ISB instruction into the instruction stream.
13758 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13759 Return the content of a system register which is mapped by @var{sr}.
13762 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13763 Return the content of a user space register which is mapped by @var{usr}.
13766 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13767 Move the @var{value} to a system register which is mapped by @var{sr}.
13770 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13771 Move the @var{value} to a user space register which is mapped by @var{usr}.
13774 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13775 Enable global interrupt.
13778 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13779 Disable global interrupt.
13782 @node picoChip Built-in Functions
13783 @subsection picoChip Built-in Functions
13785 GCC provides an interface to selected machine instructions from the
13786 picoChip instruction set.
13789 @item int __builtin_sbc (int @var{value})
13790 Sign bit count. Return the number of consecutive bits in @var{value}
13791 that have the same value as the sign bit. The result is the number of
13792 leading sign bits minus one, giving the number of redundant sign bits in
13795 @item int __builtin_byteswap (int @var{value})
13796 Byte swap. Return the result of swapping the upper and lower bytes of
13799 @item int __builtin_brev (int @var{value})
13800 Bit reversal. Return the result of reversing the bits in
13801 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13804 @item int __builtin_adds (int @var{x}, int @var{y})
13805 Saturating addition. Return the result of adding @var{x} and @var{y},
13806 storing the value 32767 if the result overflows.
13808 @item int __builtin_subs (int @var{x}, int @var{y})
13809 Saturating subtraction. Return the result of subtracting @var{y} from
13810 @var{x}, storing the value @minus{}32768 if the result overflows.
13812 @item void __builtin_halt (void)
13813 Halt. The processor stops execution. This built-in is useful for
13814 implementing assertions.
13818 @node PowerPC Built-in Functions
13819 @subsection PowerPC Built-in Functions
13821 These built-in functions are available for the PowerPC family of
13824 float __builtin_recipdivf (float, float);
13825 float __builtin_rsqrtf (float);
13826 double __builtin_recipdiv (double, double);
13827 double __builtin_rsqrt (double);
13828 uint64_t __builtin_ppc_get_timebase ();
13829 unsigned long __builtin_ppc_mftb ();
13830 double __builtin_unpack_longdouble (long double, int);
13831 long double __builtin_pack_longdouble (double, double);
13834 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13835 @code{__builtin_rsqrtf} functions generate multiple instructions to
13836 implement the reciprocal sqrt functionality using reciprocal sqrt
13837 estimate instructions.
13839 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13840 functions generate multiple instructions to implement division using
13841 the reciprocal estimate instructions.
13843 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13844 functions generate instructions to read the Time Base Register. The
13845 @code{__builtin_ppc_get_timebase} function may generate multiple
13846 instructions and always returns the 64 bits of the Time Base Register.
13847 The @code{__builtin_ppc_mftb} function always generates one instruction and
13848 returns the Time Base Register value as an unsigned long, throwing away
13849 the most significant word on 32-bit environments.
13851 The following built-in functions are available for the PowerPC family
13852 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13853 or @option{-mpopcntd}):
13855 long __builtin_bpermd (long, long);
13856 int __builtin_divwe (int, int);
13857 int __builtin_divweo (int, int);
13858 unsigned int __builtin_divweu (unsigned int, unsigned int);
13859 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13860 long __builtin_divde (long, long);
13861 long __builtin_divdeo (long, long);
13862 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13863 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13864 unsigned int cdtbcd (unsigned int);
13865 unsigned int cbcdtd (unsigned int);
13866 unsigned int addg6s (unsigned int, unsigned int);
13869 The @code{__builtin_divde}, @code{__builtin_divdeo},
13870 @code{__builitin_divdeu}, @code{__builtin_divdeou} functions require a
13871 64-bit environment support ISA 2.06 or later.
13873 The following built-in functions are available for the PowerPC family
13874 of processors when hardware decimal floating point
13875 (@option{-mhard-dfp}) is available:
13877 _Decimal64 __builtin_dxex (_Decimal64);
13878 _Decimal128 __builtin_dxexq (_Decimal128);
13879 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13880 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13881 _Decimal64 __builtin_denbcd (int, _Decimal64);
13882 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13883 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13884 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13885 _Decimal64 __builtin_dscli (_Decimal64, int);
13886 _Decimal128 __builitn_dscliq (_Decimal128, int);
13887 _Decimal64 __builtin_dscri (_Decimal64, int);
13888 _Decimal128 __builitn_dscriq (_Decimal128, int);
13889 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13890 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13893 The following built-in functions are available for the PowerPC family
13894 of processors when the Vector Scalar (vsx) instruction set is
13897 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13898 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13899 unsigned long long);
13902 @node PowerPC AltiVec/VSX Built-in Functions
13903 @subsection PowerPC AltiVec Built-in Functions
13905 GCC provides an interface for the PowerPC family of processors to access
13906 the AltiVec operations described in Motorola's AltiVec Programming
13907 Interface Manual. The interface is made available by including
13908 @code{<altivec.h>} and using @option{-maltivec} and
13909 @option{-mabi=altivec}. The interface supports the following vector
13913 vector unsigned char
13917 vector unsigned short
13918 vector signed short
13922 vector unsigned int
13928 If @option{-mvsx} is used the following additional vector types are
13932 vector unsigned long
13937 The long types are only implemented for 64-bit code generation, and
13938 the long type is only used in the floating point/integer conversion
13941 GCC's implementation of the high-level language interface available from
13942 C and C++ code differs from Motorola's documentation in several ways.
13947 A vector constant is a list of constant expressions within curly braces.
13950 A vector initializer requires no cast if the vector constant is of the
13951 same type as the variable it is initializing.
13954 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13955 vector type is the default signedness of the base type. The default
13956 varies depending on the operating system, so a portable program should
13957 always specify the signedness.
13960 Compiling with @option{-maltivec} adds keywords @code{__vector},
13961 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13962 @code{bool}. When compiling ISO C, the context-sensitive substitution
13963 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13964 disabled. To use them, you must include @code{<altivec.h>} instead.
13967 GCC allows using a @code{typedef} name as the type specifier for a
13971 For C, overloaded functions are implemented with macros so the following
13975 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13979 Since @code{vec_add} is a macro, the vector constant in the example
13980 is treated as four separate arguments. Wrap the entire argument in
13981 parentheses for this to work.
13984 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13985 Internally, GCC uses built-in functions to achieve the functionality in
13986 the aforementioned header file, but they are not supported and are
13987 subject to change without notice.
13989 The following interfaces are supported for the generic and specific
13990 AltiVec operations and the AltiVec predicates. In cases where there
13991 is a direct mapping between generic and specific operations, only the
13992 generic names are shown here, although the specific operations can also
13995 Arguments that are documented as @code{const int} require literal
13996 integral values within the range required for that operation.
13999 vector signed char vec_abs (vector signed char);
14000 vector signed short vec_abs (vector signed short);
14001 vector signed int vec_abs (vector signed int);
14002 vector float vec_abs (vector float);
14004 vector signed char vec_abss (vector signed char);
14005 vector signed short vec_abss (vector signed short);
14006 vector signed int vec_abss (vector signed int);
14008 vector signed char vec_add (vector bool char, vector signed char);
14009 vector signed char vec_add (vector signed char, vector bool char);
14010 vector signed char vec_add (vector signed char, vector signed char);
14011 vector unsigned char vec_add (vector bool char, vector unsigned char);
14012 vector unsigned char vec_add (vector unsigned char, vector bool char);
14013 vector unsigned char vec_add (vector unsigned char,
14014 vector unsigned char);
14015 vector signed short vec_add (vector bool short, vector signed short);
14016 vector signed short vec_add (vector signed short, vector bool short);
14017 vector signed short vec_add (vector signed short, vector signed short);
14018 vector unsigned short vec_add (vector bool short,
14019 vector unsigned short);
14020 vector unsigned short vec_add (vector unsigned short,
14021 vector bool short);
14022 vector unsigned short vec_add (vector unsigned short,
14023 vector unsigned short);
14024 vector signed int vec_add (vector bool int, vector signed int);
14025 vector signed int vec_add (vector signed int, vector bool int);
14026 vector signed int vec_add (vector signed int, vector signed int);
14027 vector unsigned int vec_add (vector bool int, vector unsigned int);
14028 vector unsigned int vec_add (vector unsigned int, vector bool int);
14029 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
14030 vector float vec_add (vector float, vector float);
14032 vector float vec_vaddfp (vector float, vector float);
14034 vector signed int vec_vadduwm (vector bool int, vector signed int);
14035 vector signed int vec_vadduwm (vector signed int, vector bool int);
14036 vector signed int vec_vadduwm (vector signed int, vector signed int);
14037 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
14038 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
14039 vector unsigned int vec_vadduwm (vector unsigned int,
14040 vector unsigned int);
14042 vector signed short vec_vadduhm (vector bool short,
14043 vector signed short);
14044 vector signed short vec_vadduhm (vector signed short,
14045 vector bool short);
14046 vector signed short vec_vadduhm (vector signed short,
14047 vector signed short);
14048 vector unsigned short vec_vadduhm (vector bool short,
14049 vector unsigned short);
14050 vector unsigned short vec_vadduhm (vector unsigned short,
14051 vector bool short);
14052 vector unsigned short vec_vadduhm (vector unsigned short,
14053 vector unsigned short);
14055 vector signed char vec_vaddubm (vector bool char, vector signed char);
14056 vector signed char vec_vaddubm (vector signed char, vector bool char);
14057 vector signed char vec_vaddubm (vector signed char, vector signed char);
14058 vector unsigned char vec_vaddubm (vector bool char,
14059 vector unsigned char);
14060 vector unsigned char vec_vaddubm (vector unsigned char,
14062 vector unsigned char vec_vaddubm (vector unsigned char,
14063 vector unsigned char);
14065 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
14067 vector unsigned char vec_adds (vector bool char, vector unsigned char);
14068 vector unsigned char vec_adds (vector unsigned char, vector bool char);
14069 vector unsigned char vec_adds (vector unsigned char,
14070 vector unsigned char);
14071 vector signed char vec_adds (vector bool char, vector signed char);
14072 vector signed char vec_adds (vector signed char, vector bool char);
14073 vector signed char vec_adds (vector signed char, vector signed char);
14074 vector unsigned short vec_adds (vector bool short,
14075 vector unsigned short);
14076 vector unsigned short vec_adds (vector unsigned short,
14077 vector bool short);
14078 vector unsigned short vec_adds (vector unsigned short,
14079 vector unsigned short);
14080 vector signed short vec_adds (vector bool short, vector signed short);
14081 vector signed short vec_adds (vector signed short, vector bool short);
14082 vector signed short vec_adds (vector signed short, vector signed short);
14083 vector unsigned int vec_adds (vector bool int, vector unsigned int);
14084 vector unsigned int vec_adds (vector unsigned int, vector bool int);
14085 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
14086 vector signed int vec_adds (vector bool int, vector signed int);
14087 vector signed int vec_adds (vector signed int, vector bool int);
14088 vector signed int vec_adds (vector signed int, vector signed int);
14090 vector signed int vec_vaddsws (vector bool int, vector signed int);
14091 vector signed int vec_vaddsws (vector signed int, vector bool int);
14092 vector signed int vec_vaddsws (vector signed int, vector signed int);
14094 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
14095 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
14096 vector unsigned int vec_vadduws (vector unsigned int,
14097 vector unsigned int);
14099 vector signed short vec_vaddshs (vector bool short,
14100 vector signed short);
14101 vector signed short vec_vaddshs (vector signed short,
14102 vector bool short);
14103 vector signed short vec_vaddshs (vector signed short,
14104 vector signed short);
14106 vector unsigned short vec_vadduhs (vector bool short,
14107 vector unsigned short);
14108 vector unsigned short vec_vadduhs (vector unsigned short,
14109 vector bool short);
14110 vector unsigned short vec_vadduhs (vector unsigned short,
14111 vector unsigned short);
14113 vector signed char vec_vaddsbs (vector bool char, vector signed char);
14114 vector signed char vec_vaddsbs (vector signed char, vector bool char);
14115 vector signed char vec_vaddsbs (vector signed char, vector signed char);
14117 vector unsigned char vec_vaddubs (vector bool char,
14118 vector unsigned char);
14119 vector unsigned char vec_vaddubs (vector unsigned char,
14121 vector unsigned char vec_vaddubs (vector unsigned char,
14122 vector unsigned char);
14124 vector float vec_and (vector float, vector float);
14125 vector float vec_and (vector float, vector bool int);
14126 vector float vec_and (vector bool int, vector float);
14127 vector bool int vec_and (vector bool int, vector bool int);
14128 vector signed int vec_and (vector bool int, vector signed int);
14129 vector signed int vec_and (vector signed int, vector bool int);
14130 vector signed int vec_and (vector signed int, vector signed int);
14131 vector unsigned int vec_and (vector bool int, vector unsigned int);
14132 vector unsigned int vec_and (vector unsigned int, vector bool int);
14133 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
14134 vector bool short vec_and (vector bool short, vector bool short);
14135 vector signed short vec_and (vector bool short, vector signed short);
14136 vector signed short vec_and (vector signed short, vector bool short);
14137 vector signed short vec_and (vector signed short, vector signed short);
14138 vector unsigned short vec_and (vector bool short,
14139 vector unsigned short);
14140 vector unsigned short vec_and (vector unsigned short,
14141 vector bool short);
14142 vector unsigned short vec_and (vector unsigned short,
14143 vector unsigned short);
14144 vector signed char vec_and (vector bool char, vector signed char);
14145 vector bool char vec_and (vector bool char, vector bool char);
14146 vector signed char vec_and (vector signed char, vector bool char);
14147 vector signed char vec_and (vector signed char, vector signed char);
14148 vector unsigned char vec_and (vector bool char, vector unsigned char);
14149 vector unsigned char vec_and (vector unsigned char, vector bool char);
14150 vector unsigned char vec_and (vector unsigned char,
14151 vector unsigned char);
14153 vector float vec_andc (vector float, vector float);
14154 vector float vec_andc (vector float, vector bool int);
14155 vector float vec_andc (vector bool int, vector float);
14156 vector bool int vec_andc (vector bool int, vector bool int);
14157 vector signed int vec_andc (vector bool int, vector signed int);
14158 vector signed int vec_andc (vector signed int, vector bool int);
14159 vector signed int vec_andc (vector signed int, vector signed int);
14160 vector unsigned int vec_andc (vector bool int, vector unsigned int);
14161 vector unsigned int vec_andc (vector unsigned int, vector bool int);
14162 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
14163 vector bool short vec_andc (vector bool short, vector bool short);
14164 vector signed short vec_andc (vector bool short, vector signed short);
14165 vector signed short vec_andc (vector signed short, vector bool short);
14166 vector signed short vec_andc (vector signed short, vector signed short);
14167 vector unsigned short vec_andc (vector bool short,
14168 vector unsigned short);
14169 vector unsigned short vec_andc (vector unsigned short,
14170 vector bool short);
14171 vector unsigned short vec_andc (vector unsigned short,
14172 vector unsigned short);
14173 vector signed char vec_andc (vector bool char, vector signed char);
14174 vector bool char vec_andc (vector bool char, vector bool char);
14175 vector signed char vec_andc (vector signed char, vector bool char);
14176 vector signed char vec_andc (vector signed char, vector signed char);
14177 vector unsigned char vec_andc (vector bool char, vector unsigned char);
14178 vector unsigned char vec_andc (vector unsigned char, vector bool char);
14179 vector unsigned char vec_andc (vector unsigned char,
14180 vector unsigned char);
14182 vector unsigned char vec_avg (vector unsigned char,
14183 vector unsigned char);
14184 vector signed char vec_avg (vector signed char, vector signed char);
14185 vector unsigned short vec_avg (vector unsigned short,
14186 vector unsigned short);
14187 vector signed short vec_avg (vector signed short, vector signed short);
14188 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
14189 vector signed int vec_avg (vector signed int, vector signed int);
14191 vector signed int vec_vavgsw (vector signed int, vector signed int);
14193 vector unsigned int vec_vavguw (vector unsigned int,
14194 vector unsigned int);
14196 vector signed short vec_vavgsh (vector signed short,
14197 vector signed short);
14199 vector unsigned short vec_vavguh (vector unsigned short,
14200 vector unsigned short);
14202 vector signed char vec_vavgsb (vector signed char, vector signed char);
14204 vector unsigned char vec_vavgub (vector unsigned char,
14205 vector unsigned char);
14207 vector float vec_copysign (vector float);
14209 vector float vec_ceil (vector float);
14211 vector signed int vec_cmpb (vector float, vector float);
14213 vector bool char vec_cmpeq (vector signed char, vector signed char);
14214 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
14215 vector bool short vec_cmpeq (vector signed short, vector signed short);
14216 vector bool short vec_cmpeq (vector unsigned short,
14217 vector unsigned short);
14218 vector bool int vec_cmpeq (vector signed int, vector signed int);
14219 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
14220 vector bool int vec_cmpeq (vector float, vector float);
14222 vector bool int vec_vcmpeqfp (vector float, vector float);
14224 vector bool int vec_vcmpequw (vector signed int, vector signed int);
14225 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
14227 vector bool short vec_vcmpequh (vector signed short,
14228 vector signed short);
14229 vector bool short vec_vcmpequh (vector unsigned short,
14230 vector unsigned short);
14232 vector bool char vec_vcmpequb (vector signed char, vector signed char);
14233 vector bool char vec_vcmpequb (vector unsigned char,
14234 vector unsigned char);
14236 vector bool int vec_cmpge (vector float, vector float);
14238 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
14239 vector bool char vec_cmpgt (vector signed char, vector signed char);
14240 vector bool short vec_cmpgt (vector unsigned short,
14241 vector unsigned short);
14242 vector bool short vec_cmpgt (vector signed short, vector signed short);
14243 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
14244 vector bool int vec_cmpgt (vector signed int, vector signed int);
14245 vector bool int vec_cmpgt (vector float, vector float);
14247 vector bool int vec_vcmpgtfp (vector float, vector float);
14249 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
14251 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
14253 vector bool short vec_vcmpgtsh (vector signed short,
14254 vector signed short);
14256 vector bool short vec_vcmpgtuh (vector unsigned short,
14257 vector unsigned short);
14259 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
14261 vector bool char vec_vcmpgtub (vector unsigned char,
14262 vector unsigned char);
14264 vector bool int vec_cmple (vector float, vector float);
14266 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
14267 vector bool char vec_cmplt (vector signed char, vector signed char);
14268 vector bool short vec_cmplt (vector unsigned short,
14269 vector unsigned short);
14270 vector bool short vec_cmplt (vector signed short, vector signed short);
14271 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
14272 vector bool int vec_cmplt (vector signed int, vector signed int);
14273 vector bool int vec_cmplt (vector float, vector float);
14275 vector float vec_cpsgn (vector float, vector float);
14277 vector float vec_ctf (vector unsigned int, const int);
14278 vector float vec_ctf (vector signed int, const int);
14279 vector double vec_ctf (vector unsigned long, const int);
14280 vector double vec_ctf (vector signed long, const int);
14282 vector float vec_vcfsx (vector signed int, const int);
14284 vector float vec_vcfux (vector unsigned int, const int);
14286 vector signed int vec_cts (vector float, const int);
14287 vector signed long vec_cts (vector double, const int);
14289 vector unsigned int vec_ctu (vector float, const int);
14290 vector unsigned long vec_ctu (vector double, const int);
14292 void vec_dss (const int);
14294 void vec_dssall (void);
14296 void vec_dst (const vector unsigned char *, int, const int);
14297 void vec_dst (const vector signed char *, int, const int);
14298 void vec_dst (const vector bool char *, int, const int);
14299 void vec_dst (const vector unsigned short *, int, const int);
14300 void vec_dst (const vector signed short *, int, const int);
14301 void vec_dst (const vector bool short *, int, const int);
14302 void vec_dst (const vector pixel *, int, const int);
14303 void vec_dst (const vector unsigned int *, int, const int);
14304 void vec_dst (const vector signed int *, int, const int);
14305 void vec_dst (const vector bool int *, int, const int);
14306 void vec_dst (const vector float *, int, const int);
14307 void vec_dst (const unsigned char *, int, const int);
14308 void vec_dst (const signed char *, int, const int);
14309 void vec_dst (const unsigned short *, int, const int);
14310 void vec_dst (const short *, int, const int);
14311 void vec_dst (const unsigned int *, int, const int);
14312 void vec_dst (const int *, int, const int);
14313 void vec_dst (const unsigned long *, int, const int);
14314 void vec_dst (const long *, int, const int);
14315 void vec_dst (const float *, int, const int);
14317 void vec_dstst (const vector unsigned char *, int, const int);
14318 void vec_dstst (const vector signed char *, int, const int);
14319 void vec_dstst (const vector bool char *, int, const int);
14320 void vec_dstst (const vector unsigned short *, int, const int);
14321 void vec_dstst (const vector signed short *, int, const int);
14322 void vec_dstst (const vector bool short *, int, const int);
14323 void vec_dstst (const vector pixel *, int, const int);
14324 void vec_dstst (const vector unsigned int *, int, const int);
14325 void vec_dstst (const vector signed int *, int, const int);
14326 void vec_dstst (const vector bool int *, int, const int);
14327 void vec_dstst (const vector float *, int, const int);
14328 void vec_dstst (const unsigned char *, int, const int);
14329 void vec_dstst (const signed char *, int, const int);
14330 void vec_dstst (const unsigned short *, int, const int);
14331 void vec_dstst (const short *, int, const int);
14332 void vec_dstst (const unsigned int *, int, const int);
14333 void vec_dstst (const int *, int, const int);
14334 void vec_dstst (const unsigned long *, int, const int);
14335 void vec_dstst (const long *, int, const int);
14336 void vec_dstst (const float *, int, const int);
14338 void vec_dststt (const vector unsigned char *, int, const int);
14339 void vec_dststt (const vector signed char *, int, const int);
14340 void vec_dststt (const vector bool char *, int, const int);
14341 void vec_dststt (const vector unsigned short *, int, const int);
14342 void vec_dststt (const vector signed short *, int, const int);
14343 void vec_dststt (const vector bool short *, int, const int);
14344 void vec_dststt (const vector pixel *, int, const int);
14345 void vec_dststt (const vector unsigned int *, int, const int);
14346 void vec_dststt (const vector signed int *, int, const int);
14347 void vec_dststt (const vector bool int *, int, const int);
14348 void vec_dststt (const vector float *, int, const int);
14349 void vec_dststt (const unsigned char *, int, const int);
14350 void vec_dststt (const signed char *, int, const int);
14351 void vec_dststt (const unsigned short *, int, const int);
14352 void vec_dststt (const short *, int, const int);
14353 void vec_dststt (const unsigned int *, int, const int);
14354 void vec_dststt (const int *, int, const int);
14355 void vec_dststt (const unsigned long *, int, const int);
14356 void vec_dststt (const long *, int, const int);
14357 void vec_dststt (const float *, int, const int);
14359 void vec_dstt (const vector unsigned char *, int, const int);
14360 void vec_dstt (const vector signed char *, int, const int);
14361 void vec_dstt (const vector bool char *, int, const int);
14362 void vec_dstt (const vector unsigned short *, int, const int);
14363 void vec_dstt (const vector signed short *, int, const int);
14364 void vec_dstt (const vector bool short *, int, const int);
14365 void vec_dstt (const vector pixel *, int, const int);
14366 void vec_dstt (const vector unsigned int *, int, const int);
14367 void vec_dstt (const vector signed int *, int, const int);
14368 void vec_dstt (const vector bool int *, int, const int);
14369 void vec_dstt (const vector float *, int, const int);
14370 void vec_dstt (const unsigned char *, int, const int);
14371 void vec_dstt (const signed char *, int, const int);
14372 void vec_dstt (const unsigned short *, int, const int);
14373 void vec_dstt (const short *, int, const int);
14374 void vec_dstt (const unsigned int *, int, const int);
14375 void vec_dstt (const int *, int, const int);
14376 void vec_dstt (const unsigned long *, int, const int);
14377 void vec_dstt (const long *, int, const int);
14378 void vec_dstt (const float *, int, const int);
14380 vector float vec_expte (vector float);
14382 vector float vec_floor (vector float);
14384 vector float vec_ld (int, const vector float *);
14385 vector float vec_ld (int, const float *);
14386 vector bool int vec_ld (int, const vector bool int *);
14387 vector signed int vec_ld (int, const vector signed int *);
14388 vector signed int vec_ld (int, const int *);
14389 vector signed int vec_ld (int, const long *);
14390 vector unsigned int vec_ld (int, const vector unsigned int *);
14391 vector unsigned int vec_ld (int, const unsigned int *);
14392 vector unsigned int vec_ld (int, const unsigned long *);
14393 vector bool short vec_ld (int, const vector bool short *);
14394 vector pixel vec_ld (int, const vector pixel *);
14395 vector signed short vec_ld (int, const vector signed short *);
14396 vector signed short vec_ld (int, const short *);
14397 vector unsigned short vec_ld (int, const vector unsigned short *);
14398 vector unsigned short vec_ld (int, const unsigned short *);
14399 vector bool char vec_ld (int, const vector bool char *);
14400 vector signed char vec_ld (int, const vector signed char *);
14401 vector signed char vec_ld (int, const signed char *);
14402 vector unsigned char vec_ld (int, const vector unsigned char *);
14403 vector unsigned char vec_ld (int, const unsigned char *);
14405 vector signed char vec_lde (int, const signed char *);
14406 vector unsigned char vec_lde (int, const unsigned char *);
14407 vector signed short vec_lde (int, const short *);
14408 vector unsigned short vec_lde (int, const unsigned short *);
14409 vector float vec_lde (int, const float *);
14410 vector signed int vec_lde (int, const int *);
14411 vector unsigned int vec_lde (int, const unsigned int *);
14412 vector signed int vec_lde (int, const long *);
14413 vector unsigned int vec_lde (int, const unsigned long *);
14415 vector float vec_lvewx (int, float *);
14416 vector signed int vec_lvewx (int, int *);
14417 vector unsigned int vec_lvewx (int, unsigned int *);
14418 vector signed int vec_lvewx (int, long *);
14419 vector unsigned int vec_lvewx (int, unsigned long *);
14421 vector signed short vec_lvehx (int, short *);
14422 vector unsigned short vec_lvehx (int, unsigned short *);
14424 vector signed char vec_lvebx (int, char *);
14425 vector unsigned char vec_lvebx (int, unsigned char *);
14427 vector float vec_ldl (int, const vector float *);
14428 vector float vec_ldl (int, const float *);
14429 vector bool int vec_ldl (int, const vector bool int *);
14430 vector signed int vec_ldl (int, const vector signed int *);
14431 vector signed int vec_ldl (int, const int *);
14432 vector signed int vec_ldl (int, const long *);
14433 vector unsigned int vec_ldl (int, const vector unsigned int *);
14434 vector unsigned int vec_ldl (int, const unsigned int *);
14435 vector unsigned int vec_ldl (int, const unsigned long *);
14436 vector bool short vec_ldl (int, const vector bool short *);
14437 vector pixel vec_ldl (int, const vector pixel *);
14438 vector signed short vec_ldl (int, const vector signed short *);
14439 vector signed short vec_ldl (int, const short *);
14440 vector unsigned short vec_ldl (int, const vector unsigned short *);
14441 vector unsigned short vec_ldl (int, const unsigned short *);
14442 vector bool char vec_ldl (int, const vector bool char *);
14443 vector signed char vec_ldl (int, const vector signed char *);
14444 vector signed char vec_ldl (int, const signed char *);
14445 vector unsigned char vec_ldl (int, const vector unsigned char *);
14446 vector unsigned char vec_ldl (int, const unsigned char *);
14448 vector float vec_loge (vector float);
14450 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14451 vector unsigned char vec_lvsl (int, const volatile signed char *);
14452 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14453 vector unsigned char vec_lvsl (int, const volatile short *);
14454 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14455 vector unsigned char vec_lvsl (int, const volatile int *);
14456 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14457 vector unsigned char vec_lvsl (int, const volatile long *);
14458 vector unsigned char vec_lvsl (int, const volatile float *);
14460 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14461 vector unsigned char vec_lvsr (int, const volatile signed char *);
14462 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14463 vector unsigned char vec_lvsr (int, const volatile short *);
14464 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14465 vector unsigned char vec_lvsr (int, const volatile int *);
14466 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14467 vector unsigned char vec_lvsr (int, const volatile long *);
14468 vector unsigned char vec_lvsr (int, const volatile float *);
14470 vector float vec_madd (vector float, vector float, vector float);
14472 vector signed short vec_madds (vector signed short,
14473 vector signed short,
14474 vector signed short);
14476 vector unsigned char vec_max (vector bool char, vector unsigned char);
14477 vector unsigned char vec_max (vector unsigned char, vector bool char);
14478 vector unsigned char vec_max (vector unsigned char,
14479 vector unsigned char);
14480 vector signed char vec_max (vector bool char, vector signed char);
14481 vector signed char vec_max (vector signed char, vector bool char);
14482 vector signed char vec_max (vector signed char, vector signed char);
14483 vector unsigned short vec_max (vector bool short,
14484 vector unsigned short);
14485 vector unsigned short vec_max (vector unsigned short,
14486 vector bool short);
14487 vector unsigned short vec_max (vector unsigned short,
14488 vector unsigned short);
14489 vector signed short vec_max (vector bool short, vector signed short);
14490 vector signed short vec_max (vector signed short, vector bool short);
14491 vector signed short vec_max (vector signed short, vector signed short);
14492 vector unsigned int vec_max (vector bool int, vector unsigned int);
14493 vector unsigned int vec_max (vector unsigned int, vector bool int);
14494 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14495 vector signed int vec_max (vector bool int, vector signed int);
14496 vector signed int vec_max (vector signed int, vector bool int);
14497 vector signed int vec_max (vector signed int, vector signed int);
14498 vector float vec_max (vector float, vector float);
14500 vector float vec_vmaxfp (vector float, vector float);
14502 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14503 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14504 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14506 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14507 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14508 vector unsigned int vec_vmaxuw (vector unsigned int,
14509 vector unsigned int);
14511 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14512 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14513 vector signed short vec_vmaxsh (vector signed short,
14514 vector signed short);
14516 vector unsigned short vec_vmaxuh (vector bool short,
14517 vector unsigned short);
14518 vector unsigned short vec_vmaxuh (vector unsigned short,
14519 vector bool short);
14520 vector unsigned short vec_vmaxuh (vector unsigned short,
14521 vector unsigned short);
14523 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14524 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14525 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14527 vector unsigned char vec_vmaxub (vector bool char,
14528 vector unsigned char);
14529 vector unsigned char vec_vmaxub (vector unsigned char,
14531 vector unsigned char vec_vmaxub (vector unsigned char,
14532 vector unsigned char);
14534 vector bool char vec_mergeh (vector bool char, vector bool char);
14535 vector signed char vec_mergeh (vector signed char, vector signed char);
14536 vector unsigned char vec_mergeh (vector unsigned char,
14537 vector unsigned char);
14538 vector bool short vec_mergeh (vector bool short, vector bool short);
14539 vector pixel vec_mergeh (vector pixel, vector pixel);
14540 vector signed short vec_mergeh (vector signed short,
14541 vector signed short);
14542 vector unsigned short vec_mergeh (vector unsigned short,
14543 vector unsigned short);
14544 vector float vec_mergeh (vector float, vector float);
14545 vector bool int vec_mergeh (vector bool int, vector bool int);
14546 vector signed int vec_mergeh (vector signed int, vector signed int);
14547 vector unsigned int vec_mergeh (vector unsigned int,
14548 vector unsigned int);
14550 vector float vec_vmrghw (vector float, vector float);
14551 vector bool int vec_vmrghw (vector bool int, vector bool int);
14552 vector signed int vec_vmrghw (vector signed int, vector signed int);
14553 vector unsigned int vec_vmrghw (vector unsigned int,
14554 vector unsigned int);
14556 vector bool short vec_vmrghh (vector bool short, vector bool short);
14557 vector signed short vec_vmrghh (vector signed short,
14558 vector signed short);
14559 vector unsigned short vec_vmrghh (vector unsigned short,
14560 vector unsigned short);
14561 vector pixel vec_vmrghh (vector pixel, vector pixel);
14563 vector bool char vec_vmrghb (vector bool char, vector bool char);
14564 vector signed char vec_vmrghb (vector signed char, vector signed char);
14565 vector unsigned char vec_vmrghb (vector unsigned char,
14566 vector unsigned char);
14568 vector bool char vec_mergel (vector bool char, vector bool char);
14569 vector signed char vec_mergel (vector signed char, vector signed char);
14570 vector unsigned char vec_mergel (vector unsigned char,
14571 vector unsigned char);
14572 vector bool short vec_mergel (vector bool short, vector bool short);
14573 vector pixel vec_mergel (vector pixel, vector pixel);
14574 vector signed short vec_mergel (vector signed short,
14575 vector signed short);
14576 vector unsigned short vec_mergel (vector unsigned short,
14577 vector unsigned short);
14578 vector float vec_mergel (vector float, vector float);
14579 vector bool int vec_mergel (vector bool int, vector bool int);
14580 vector signed int vec_mergel (vector signed int, vector signed int);
14581 vector unsigned int vec_mergel (vector unsigned int,
14582 vector unsigned int);
14584 vector float vec_vmrglw (vector float, vector float);
14585 vector signed int vec_vmrglw (vector signed int, vector signed int);
14586 vector unsigned int vec_vmrglw (vector unsigned int,
14587 vector unsigned int);
14588 vector bool int vec_vmrglw (vector bool int, vector bool int);
14590 vector bool short vec_vmrglh (vector bool short, vector bool short);
14591 vector signed short vec_vmrglh (vector signed short,
14592 vector signed short);
14593 vector unsigned short vec_vmrglh (vector unsigned short,
14594 vector unsigned short);
14595 vector pixel vec_vmrglh (vector pixel, vector pixel);
14597 vector bool char vec_vmrglb (vector bool char, vector bool char);
14598 vector signed char vec_vmrglb (vector signed char, vector signed char);
14599 vector unsigned char vec_vmrglb (vector unsigned char,
14600 vector unsigned char);
14602 vector unsigned short vec_mfvscr (void);
14604 vector unsigned char vec_min (vector bool char, vector unsigned char);
14605 vector unsigned char vec_min (vector unsigned char, vector bool char);
14606 vector unsigned char vec_min (vector unsigned char,
14607 vector unsigned char);
14608 vector signed char vec_min (vector bool char, vector signed char);
14609 vector signed char vec_min (vector signed char, vector bool char);
14610 vector signed char vec_min (vector signed char, vector signed char);
14611 vector unsigned short vec_min (vector bool short,
14612 vector unsigned short);
14613 vector unsigned short vec_min (vector unsigned short,
14614 vector bool short);
14615 vector unsigned short vec_min (vector unsigned short,
14616 vector unsigned short);
14617 vector signed short vec_min (vector bool short, vector signed short);
14618 vector signed short vec_min (vector signed short, vector bool short);
14619 vector signed short vec_min (vector signed short, vector signed short);
14620 vector unsigned int vec_min (vector bool int, vector unsigned int);
14621 vector unsigned int vec_min (vector unsigned int, vector bool int);
14622 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14623 vector signed int vec_min (vector bool int, vector signed int);
14624 vector signed int vec_min (vector signed int, vector bool int);
14625 vector signed int vec_min (vector signed int, vector signed int);
14626 vector float vec_min (vector float, vector float);
14628 vector float vec_vminfp (vector float, vector float);
14630 vector signed int vec_vminsw (vector bool int, vector signed int);
14631 vector signed int vec_vminsw (vector signed int, vector bool int);
14632 vector signed int vec_vminsw (vector signed int, vector signed int);
14634 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14635 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14636 vector unsigned int vec_vminuw (vector unsigned int,
14637 vector unsigned int);
14639 vector signed short vec_vminsh (vector bool short, vector signed short);
14640 vector signed short vec_vminsh (vector signed short, vector bool short);
14641 vector signed short vec_vminsh (vector signed short,
14642 vector signed short);
14644 vector unsigned short vec_vminuh (vector bool short,
14645 vector unsigned short);
14646 vector unsigned short vec_vminuh (vector unsigned short,
14647 vector bool short);
14648 vector unsigned short vec_vminuh (vector unsigned short,
14649 vector unsigned short);
14651 vector signed char vec_vminsb (vector bool char, vector signed char);
14652 vector signed char vec_vminsb (vector signed char, vector bool char);
14653 vector signed char vec_vminsb (vector signed char, vector signed char);
14655 vector unsigned char vec_vminub (vector bool char,
14656 vector unsigned char);
14657 vector unsigned char vec_vminub (vector unsigned char,
14659 vector unsigned char vec_vminub (vector unsigned char,
14660 vector unsigned char);
14662 vector signed short vec_mladd (vector signed short,
14663 vector signed short,
14664 vector signed short);
14665 vector signed short vec_mladd (vector signed short,
14666 vector unsigned short,
14667 vector unsigned short);
14668 vector signed short vec_mladd (vector unsigned short,
14669 vector signed short,
14670 vector signed short);
14671 vector unsigned short vec_mladd (vector unsigned short,
14672 vector unsigned short,
14673 vector unsigned short);
14675 vector signed short vec_mradds (vector signed short,
14676 vector signed short,
14677 vector signed short);
14679 vector unsigned int vec_msum (vector unsigned char,
14680 vector unsigned char,
14681 vector unsigned int);
14682 vector signed int vec_msum (vector signed char,
14683 vector unsigned char,
14684 vector signed int);
14685 vector unsigned int vec_msum (vector unsigned short,
14686 vector unsigned short,
14687 vector unsigned int);
14688 vector signed int vec_msum (vector signed short,
14689 vector signed short,
14690 vector signed int);
14692 vector signed int vec_vmsumshm (vector signed short,
14693 vector signed short,
14694 vector signed int);
14696 vector unsigned int vec_vmsumuhm (vector unsigned short,
14697 vector unsigned short,
14698 vector unsigned int);
14700 vector signed int vec_vmsummbm (vector signed char,
14701 vector unsigned char,
14702 vector signed int);
14704 vector unsigned int vec_vmsumubm (vector unsigned char,
14705 vector unsigned char,
14706 vector unsigned int);
14708 vector unsigned int vec_msums (vector unsigned short,
14709 vector unsigned short,
14710 vector unsigned int);
14711 vector signed int vec_msums (vector signed short,
14712 vector signed short,
14713 vector signed int);
14715 vector signed int vec_vmsumshs (vector signed short,
14716 vector signed short,
14717 vector signed int);
14719 vector unsigned int vec_vmsumuhs (vector unsigned short,
14720 vector unsigned short,
14721 vector unsigned int);
14723 void vec_mtvscr (vector signed int);
14724 void vec_mtvscr (vector unsigned int);
14725 void vec_mtvscr (vector bool int);
14726 void vec_mtvscr (vector signed short);
14727 void vec_mtvscr (vector unsigned short);
14728 void vec_mtvscr (vector bool short);
14729 void vec_mtvscr (vector pixel);
14730 void vec_mtvscr (vector signed char);
14731 void vec_mtvscr (vector unsigned char);
14732 void vec_mtvscr (vector bool char);
14734 vector unsigned short vec_mule (vector unsigned char,
14735 vector unsigned char);
14736 vector signed short vec_mule (vector signed char,
14737 vector signed char);
14738 vector unsigned int vec_mule (vector unsigned short,
14739 vector unsigned short);
14740 vector signed int vec_mule (vector signed short, vector signed short);
14742 vector signed int vec_vmulesh (vector signed short,
14743 vector signed short);
14745 vector unsigned int vec_vmuleuh (vector unsigned short,
14746 vector unsigned short);
14748 vector signed short vec_vmulesb (vector signed char,
14749 vector signed char);
14751 vector unsigned short vec_vmuleub (vector unsigned char,
14752 vector unsigned char);
14754 vector unsigned short vec_mulo (vector unsigned char,
14755 vector unsigned char);
14756 vector signed short vec_mulo (vector signed char, vector signed char);
14757 vector unsigned int vec_mulo (vector unsigned short,
14758 vector unsigned short);
14759 vector signed int vec_mulo (vector signed short, vector signed short);
14761 vector signed int vec_vmulosh (vector signed short,
14762 vector signed short);
14764 vector unsigned int vec_vmulouh (vector unsigned short,
14765 vector unsigned short);
14767 vector signed short vec_vmulosb (vector signed char,
14768 vector signed char);
14770 vector unsigned short vec_vmuloub (vector unsigned char,
14771 vector unsigned char);
14773 vector float vec_nmsub (vector float, vector float, vector float);
14775 vector float vec_nor (vector float, vector float);
14776 vector signed int vec_nor (vector signed int, vector signed int);
14777 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14778 vector bool int vec_nor (vector bool int, vector bool int);
14779 vector signed short vec_nor (vector signed short, vector signed short);
14780 vector unsigned short vec_nor (vector unsigned short,
14781 vector unsigned short);
14782 vector bool short vec_nor (vector bool short, vector bool short);
14783 vector signed char vec_nor (vector signed char, vector signed char);
14784 vector unsigned char vec_nor (vector unsigned char,
14785 vector unsigned char);
14786 vector bool char vec_nor (vector bool char, vector bool char);
14788 vector float vec_or (vector float, vector float);
14789 vector float vec_or (vector float, vector bool int);
14790 vector float vec_or (vector bool int, vector float);
14791 vector bool int vec_or (vector bool int, vector bool int);
14792 vector signed int vec_or (vector bool int, vector signed int);
14793 vector signed int vec_or (vector signed int, vector bool int);
14794 vector signed int vec_or (vector signed int, vector signed int);
14795 vector unsigned int vec_or (vector bool int, vector unsigned int);
14796 vector unsigned int vec_or (vector unsigned int, vector bool int);
14797 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14798 vector bool short vec_or (vector bool short, vector bool short);
14799 vector signed short vec_or (vector bool short, vector signed short);
14800 vector signed short vec_or (vector signed short, vector bool short);
14801 vector signed short vec_or (vector signed short, vector signed short);
14802 vector unsigned short vec_or (vector bool short, vector unsigned short);
14803 vector unsigned short vec_or (vector unsigned short, vector bool short);
14804 vector unsigned short vec_or (vector unsigned short,
14805 vector unsigned short);
14806 vector signed char vec_or (vector bool char, vector signed char);
14807 vector bool char vec_or (vector bool char, vector bool char);
14808 vector signed char vec_or (vector signed char, vector bool char);
14809 vector signed char vec_or (vector signed char, vector signed char);
14810 vector unsigned char vec_or (vector bool char, vector unsigned char);
14811 vector unsigned char vec_or (vector unsigned char, vector bool char);
14812 vector unsigned char vec_or (vector unsigned char,
14813 vector unsigned char);
14815 vector signed char vec_pack (vector signed short, vector signed short);
14816 vector unsigned char vec_pack (vector unsigned short,
14817 vector unsigned short);
14818 vector bool char vec_pack (vector bool short, vector bool short);
14819 vector signed short vec_pack (vector signed int, vector signed int);
14820 vector unsigned short vec_pack (vector unsigned int,
14821 vector unsigned int);
14822 vector bool short vec_pack (vector bool int, vector bool int);
14824 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14825 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14826 vector unsigned short vec_vpkuwum (vector unsigned int,
14827 vector unsigned int);
14829 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14830 vector signed char vec_vpkuhum (vector signed short,
14831 vector signed short);
14832 vector unsigned char vec_vpkuhum (vector unsigned short,
14833 vector unsigned short);
14835 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14837 vector unsigned char vec_packs (vector unsigned short,
14838 vector unsigned short);
14839 vector signed char vec_packs (vector signed short, vector signed short);
14840 vector unsigned short vec_packs (vector unsigned int,
14841 vector unsigned int);
14842 vector signed short vec_packs (vector signed int, vector signed int);
14844 vector signed short vec_vpkswss (vector signed int, vector signed int);
14846 vector unsigned short vec_vpkuwus (vector unsigned int,
14847 vector unsigned int);
14849 vector signed char vec_vpkshss (vector signed short,
14850 vector signed short);
14852 vector unsigned char vec_vpkuhus (vector unsigned short,
14853 vector unsigned short);
14855 vector unsigned char vec_packsu (vector unsigned short,
14856 vector unsigned short);
14857 vector unsigned char vec_packsu (vector signed short,
14858 vector signed short);
14859 vector unsigned short vec_packsu (vector unsigned int,
14860 vector unsigned int);
14861 vector unsigned short vec_packsu (vector signed int, vector signed int);
14863 vector unsigned short vec_vpkswus (vector signed int,
14864 vector signed int);
14866 vector unsigned char vec_vpkshus (vector signed short,
14867 vector signed short);
14869 vector float vec_perm (vector float,
14871 vector unsigned char);
14872 vector signed int vec_perm (vector signed int,
14874 vector unsigned char);
14875 vector unsigned int vec_perm (vector unsigned int,
14876 vector unsigned int,
14877 vector unsigned char);
14878 vector bool int vec_perm (vector bool int,
14880 vector unsigned char);
14881 vector signed short vec_perm (vector signed short,
14882 vector signed short,
14883 vector unsigned char);
14884 vector unsigned short vec_perm (vector unsigned short,
14885 vector unsigned short,
14886 vector unsigned char);
14887 vector bool short vec_perm (vector bool short,
14889 vector unsigned char);
14890 vector pixel vec_perm (vector pixel,
14892 vector unsigned char);
14893 vector signed char vec_perm (vector signed char,
14894 vector signed char,
14895 vector unsigned char);
14896 vector unsigned char vec_perm (vector unsigned char,
14897 vector unsigned char,
14898 vector unsigned char);
14899 vector bool char vec_perm (vector bool char,
14901 vector unsigned char);
14903 vector float vec_re (vector float);
14905 vector signed char vec_rl (vector signed char,
14906 vector unsigned char);
14907 vector unsigned char vec_rl (vector unsigned char,
14908 vector unsigned char);
14909 vector signed short vec_rl (vector signed short, vector unsigned short);
14910 vector unsigned short vec_rl (vector unsigned short,
14911 vector unsigned short);
14912 vector signed int vec_rl (vector signed int, vector unsigned int);
14913 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14915 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14916 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14918 vector signed short vec_vrlh (vector signed short,
14919 vector unsigned short);
14920 vector unsigned short vec_vrlh (vector unsigned short,
14921 vector unsigned short);
14923 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14924 vector unsigned char vec_vrlb (vector unsigned char,
14925 vector unsigned char);
14927 vector float vec_round (vector float);
14929 vector float vec_recip (vector float, vector float);
14931 vector float vec_rsqrt (vector float);
14933 vector float vec_rsqrte (vector float);
14935 vector float vec_sel (vector float, vector float, vector bool int);
14936 vector float vec_sel (vector float, vector float, vector unsigned int);
14937 vector signed int vec_sel (vector signed int,
14940 vector signed int vec_sel (vector signed int,
14942 vector unsigned int);
14943 vector unsigned int vec_sel (vector unsigned int,
14944 vector unsigned int,
14946 vector unsigned int vec_sel (vector unsigned int,
14947 vector unsigned int,
14948 vector unsigned int);
14949 vector bool int vec_sel (vector bool int,
14952 vector bool int vec_sel (vector bool int,
14954 vector unsigned int);
14955 vector signed short vec_sel (vector signed short,
14956 vector signed short,
14957 vector bool short);
14958 vector signed short vec_sel (vector signed short,
14959 vector signed short,
14960 vector unsigned short);
14961 vector unsigned short vec_sel (vector unsigned short,
14962 vector unsigned short,
14963 vector bool short);
14964 vector unsigned short vec_sel (vector unsigned short,
14965 vector unsigned short,
14966 vector unsigned short);
14967 vector bool short vec_sel (vector bool short,
14969 vector bool short);
14970 vector bool short vec_sel (vector bool short,
14972 vector unsigned short);
14973 vector signed char vec_sel (vector signed char,
14974 vector signed char,
14976 vector signed char vec_sel (vector signed char,
14977 vector signed char,
14978 vector unsigned char);
14979 vector unsigned char vec_sel (vector unsigned char,
14980 vector unsigned char,
14982 vector unsigned char vec_sel (vector unsigned char,
14983 vector unsigned char,
14984 vector unsigned char);
14985 vector bool char vec_sel (vector bool char,
14988 vector bool char vec_sel (vector bool char,
14990 vector unsigned char);
14992 vector signed char vec_sl (vector signed char,
14993 vector unsigned char);
14994 vector unsigned char vec_sl (vector unsigned char,
14995 vector unsigned char);
14996 vector signed short vec_sl (vector signed short, vector unsigned short);
14997 vector unsigned short vec_sl (vector unsigned short,
14998 vector unsigned short);
14999 vector signed int vec_sl (vector signed int, vector unsigned int);
15000 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
15002 vector signed int vec_vslw (vector signed int, vector unsigned int);
15003 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
15005 vector signed short vec_vslh (vector signed short,
15006 vector unsigned short);
15007 vector unsigned short vec_vslh (vector unsigned short,
15008 vector unsigned short);
15010 vector signed char vec_vslb (vector signed char, vector unsigned char);
15011 vector unsigned char vec_vslb (vector unsigned char,
15012 vector unsigned char);
15014 vector float vec_sld (vector float, vector float, const int);
15015 vector signed int vec_sld (vector signed int,
15018 vector unsigned int vec_sld (vector unsigned int,
15019 vector unsigned int,
15021 vector bool int vec_sld (vector bool int,
15024 vector signed short vec_sld (vector signed short,
15025 vector signed short,
15027 vector unsigned short vec_sld (vector unsigned short,
15028 vector unsigned short,
15030 vector bool short vec_sld (vector bool short,
15033 vector pixel vec_sld (vector pixel,
15036 vector signed char vec_sld (vector signed char,
15037 vector signed char,
15039 vector unsigned char vec_sld (vector unsigned char,
15040 vector unsigned char,
15042 vector bool char vec_sld (vector bool char,
15046 vector signed int vec_sll (vector signed int,
15047 vector unsigned int);
15048 vector signed int vec_sll (vector signed int,
15049 vector unsigned short);
15050 vector signed int vec_sll (vector signed int,
15051 vector unsigned char);
15052 vector unsigned int vec_sll (vector unsigned int,
15053 vector unsigned int);
15054 vector unsigned int vec_sll (vector unsigned int,
15055 vector unsigned short);
15056 vector unsigned int vec_sll (vector unsigned int,
15057 vector unsigned char);
15058 vector bool int vec_sll (vector bool int,
15059 vector unsigned int);
15060 vector bool int vec_sll (vector bool int,
15061 vector unsigned short);
15062 vector bool int vec_sll (vector bool int,
15063 vector unsigned char);
15064 vector signed short vec_sll (vector signed short,
15065 vector unsigned int);
15066 vector signed short vec_sll (vector signed short,
15067 vector unsigned short);
15068 vector signed short vec_sll (vector signed short,
15069 vector unsigned char);
15070 vector unsigned short vec_sll (vector unsigned short,
15071 vector unsigned int);
15072 vector unsigned short vec_sll (vector unsigned short,
15073 vector unsigned short);
15074 vector unsigned short vec_sll (vector unsigned short,
15075 vector unsigned char);
15076 vector bool short vec_sll (vector bool short, vector unsigned int);
15077 vector bool short vec_sll (vector bool short, vector unsigned short);
15078 vector bool short vec_sll (vector bool short, vector unsigned char);
15079 vector pixel vec_sll (vector pixel, vector unsigned int);
15080 vector pixel vec_sll (vector pixel, vector unsigned short);
15081 vector pixel vec_sll (vector pixel, vector unsigned char);
15082 vector signed char vec_sll (vector signed char, vector unsigned int);
15083 vector signed char vec_sll (vector signed char, vector unsigned short);
15084 vector signed char vec_sll (vector signed char, vector unsigned char);
15085 vector unsigned char vec_sll (vector unsigned char,
15086 vector unsigned int);
15087 vector unsigned char vec_sll (vector unsigned char,
15088 vector unsigned short);
15089 vector unsigned char vec_sll (vector unsigned char,
15090 vector unsigned char);
15091 vector bool char vec_sll (vector bool char, vector unsigned int);
15092 vector bool char vec_sll (vector bool char, vector unsigned short);
15093 vector bool char vec_sll (vector bool char, vector unsigned char);
15095 vector float vec_slo (vector float, vector signed char);
15096 vector float vec_slo (vector float, vector unsigned char);
15097 vector signed int vec_slo (vector signed int, vector signed char);
15098 vector signed int vec_slo (vector signed int, vector unsigned char);
15099 vector unsigned int vec_slo (vector unsigned int, vector signed char);
15100 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
15101 vector signed short vec_slo (vector signed short, vector signed char);
15102 vector signed short vec_slo (vector signed short, vector unsigned char);
15103 vector unsigned short vec_slo (vector unsigned short,
15104 vector signed char);
15105 vector unsigned short vec_slo (vector unsigned short,
15106 vector unsigned char);
15107 vector pixel vec_slo (vector pixel, vector signed char);
15108 vector pixel vec_slo (vector pixel, vector unsigned char);
15109 vector signed char vec_slo (vector signed char, vector signed char);
15110 vector signed char vec_slo (vector signed char, vector unsigned char);
15111 vector unsigned char vec_slo (vector unsigned char, vector signed char);
15112 vector unsigned char vec_slo (vector unsigned char,
15113 vector unsigned char);
15115 vector signed char vec_splat (vector signed char, const int);
15116 vector unsigned char vec_splat (vector unsigned char, const int);
15117 vector bool char vec_splat (vector bool char, const int);
15118 vector signed short vec_splat (vector signed short, const int);
15119 vector unsigned short vec_splat (vector unsigned short, const int);
15120 vector bool short vec_splat (vector bool short, const int);
15121 vector pixel vec_splat (vector pixel, const int);
15122 vector float vec_splat (vector float, const int);
15123 vector signed int vec_splat (vector signed int, const int);
15124 vector unsigned int vec_splat (vector unsigned int, const int);
15125 vector bool int vec_splat (vector bool int, const int);
15126 vector signed long vec_splat (vector signed long, const int);
15127 vector unsigned long vec_splat (vector unsigned long, const int);
15129 vector signed char vec_splats (signed char);
15130 vector unsigned char vec_splats (unsigned char);
15131 vector signed short vec_splats (signed short);
15132 vector unsigned short vec_splats (unsigned short);
15133 vector signed int vec_splats (signed int);
15134 vector unsigned int vec_splats (unsigned int);
15135 vector float vec_splats (float);
15137 vector float vec_vspltw (vector float, const int);
15138 vector signed int vec_vspltw (vector signed int, const int);
15139 vector unsigned int vec_vspltw (vector unsigned int, const int);
15140 vector bool int vec_vspltw (vector bool int, const int);
15142 vector bool short vec_vsplth (vector bool short, const int);
15143 vector signed short vec_vsplth (vector signed short, const int);
15144 vector unsigned short vec_vsplth (vector unsigned short, const int);
15145 vector pixel vec_vsplth (vector pixel, const int);
15147 vector signed char vec_vspltb (vector signed char, const int);
15148 vector unsigned char vec_vspltb (vector unsigned char, const int);
15149 vector bool char vec_vspltb (vector bool char, const int);
15151 vector signed char vec_splat_s8 (const int);
15153 vector signed short vec_splat_s16 (const int);
15155 vector signed int vec_splat_s32 (const int);
15157 vector unsigned char vec_splat_u8 (const int);
15159 vector unsigned short vec_splat_u16 (const int);
15161 vector unsigned int vec_splat_u32 (const int);
15163 vector signed char vec_sr (vector signed char, vector unsigned char);
15164 vector unsigned char vec_sr (vector unsigned char,
15165 vector unsigned char);
15166 vector signed short vec_sr (vector signed short,
15167 vector unsigned short);
15168 vector unsigned short vec_sr (vector unsigned short,
15169 vector unsigned short);
15170 vector signed int vec_sr (vector signed int, vector unsigned int);
15171 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
15173 vector signed int vec_vsrw (vector signed int, vector unsigned int);
15174 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
15176 vector signed short vec_vsrh (vector signed short,
15177 vector unsigned short);
15178 vector unsigned short vec_vsrh (vector unsigned short,
15179 vector unsigned short);
15181 vector signed char vec_vsrb (vector signed char, vector unsigned char);
15182 vector unsigned char vec_vsrb (vector unsigned char,
15183 vector unsigned char);
15185 vector signed char vec_sra (vector signed char, vector unsigned char);
15186 vector unsigned char vec_sra (vector unsigned char,
15187 vector unsigned char);
15188 vector signed short vec_sra (vector signed short,
15189 vector unsigned short);
15190 vector unsigned short vec_sra (vector unsigned short,
15191 vector unsigned short);
15192 vector signed int vec_sra (vector signed int, vector unsigned int);
15193 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
15195 vector signed int vec_vsraw (vector signed int, vector unsigned int);
15196 vector unsigned int vec_vsraw (vector unsigned int,
15197 vector unsigned int);
15199 vector signed short vec_vsrah (vector signed short,
15200 vector unsigned short);
15201 vector unsigned short vec_vsrah (vector unsigned short,
15202 vector unsigned short);
15204 vector signed char vec_vsrab (vector signed char, vector unsigned char);
15205 vector unsigned char vec_vsrab (vector unsigned char,
15206 vector unsigned char);
15208 vector signed int vec_srl (vector signed int, vector unsigned int);
15209 vector signed int vec_srl (vector signed int, vector unsigned short);
15210 vector signed int vec_srl (vector signed int, vector unsigned char);
15211 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
15212 vector unsigned int vec_srl (vector unsigned int,
15213 vector unsigned short);
15214 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
15215 vector bool int vec_srl (vector bool int, vector unsigned int);
15216 vector bool int vec_srl (vector bool int, vector unsigned short);
15217 vector bool int vec_srl (vector bool int, vector unsigned char);
15218 vector signed short vec_srl (vector signed short, vector unsigned int);
15219 vector signed short vec_srl (vector signed short,
15220 vector unsigned short);
15221 vector signed short vec_srl (vector signed short, vector unsigned char);
15222 vector unsigned short vec_srl (vector unsigned short,
15223 vector unsigned int);
15224 vector unsigned short vec_srl (vector unsigned short,
15225 vector unsigned short);
15226 vector unsigned short vec_srl (vector unsigned short,
15227 vector unsigned char);
15228 vector bool short vec_srl (vector bool short, vector unsigned int);
15229 vector bool short vec_srl (vector bool short, vector unsigned short);
15230 vector bool short vec_srl (vector bool short, vector unsigned char);
15231 vector pixel vec_srl (vector pixel, vector unsigned int);
15232 vector pixel vec_srl (vector pixel, vector unsigned short);
15233 vector pixel vec_srl (vector pixel, vector unsigned char);
15234 vector signed char vec_srl (vector signed char, vector unsigned int);
15235 vector signed char vec_srl (vector signed char, vector unsigned short);
15236 vector signed char vec_srl (vector signed char, vector unsigned char);
15237 vector unsigned char vec_srl (vector unsigned char,
15238 vector unsigned int);
15239 vector unsigned char vec_srl (vector unsigned char,
15240 vector unsigned short);
15241 vector unsigned char vec_srl (vector unsigned char,
15242 vector unsigned char);
15243 vector bool char vec_srl (vector bool char, vector unsigned int);
15244 vector bool char vec_srl (vector bool char, vector unsigned short);
15245 vector bool char vec_srl (vector bool char, vector unsigned char);
15247 vector float vec_sro (vector float, vector signed char);
15248 vector float vec_sro (vector float, vector unsigned char);
15249 vector signed int vec_sro (vector signed int, vector signed char);
15250 vector signed int vec_sro (vector signed int, vector unsigned char);
15251 vector unsigned int vec_sro (vector unsigned int, vector signed char);
15252 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
15253 vector signed short vec_sro (vector signed short, vector signed char);
15254 vector signed short vec_sro (vector signed short, vector unsigned char);
15255 vector unsigned short vec_sro (vector unsigned short,
15256 vector signed char);
15257 vector unsigned short vec_sro (vector unsigned short,
15258 vector unsigned char);
15259 vector pixel vec_sro (vector pixel, vector signed char);
15260 vector pixel vec_sro (vector pixel, vector unsigned char);
15261 vector signed char vec_sro (vector signed char, vector signed char);
15262 vector signed char vec_sro (vector signed char, vector unsigned char);
15263 vector unsigned char vec_sro (vector unsigned char, vector signed char);
15264 vector unsigned char vec_sro (vector unsigned char,
15265 vector unsigned char);
15267 void vec_st (vector float, int, vector float *);
15268 void vec_st (vector float, int, float *);
15269 void vec_st (vector signed int, int, vector signed int *);
15270 void vec_st (vector signed int, int, int *);
15271 void vec_st (vector unsigned int, int, vector unsigned int *);
15272 void vec_st (vector unsigned int, int, unsigned int *);
15273 void vec_st (vector bool int, int, vector bool int *);
15274 void vec_st (vector bool int, int, unsigned int *);
15275 void vec_st (vector bool int, int, int *);
15276 void vec_st (vector signed short, int, vector signed short *);
15277 void vec_st (vector signed short, int, short *);
15278 void vec_st (vector unsigned short, int, vector unsigned short *);
15279 void vec_st (vector unsigned short, int, unsigned short *);
15280 void vec_st (vector bool short, int, vector bool short *);
15281 void vec_st (vector bool short, int, unsigned short *);
15282 void vec_st (vector pixel, int, vector pixel *);
15283 void vec_st (vector pixel, int, unsigned short *);
15284 void vec_st (vector pixel, int, short *);
15285 void vec_st (vector bool short, int, short *);
15286 void vec_st (vector signed char, int, vector signed char *);
15287 void vec_st (vector signed char, int, signed char *);
15288 void vec_st (vector unsigned char, int, vector unsigned char *);
15289 void vec_st (vector unsigned char, int, unsigned char *);
15290 void vec_st (vector bool char, int, vector bool char *);
15291 void vec_st (vector bool char, int, unsigned char *);
15292 void vec_st (vector bool char, int, signed char *);
15294 void vec_ste (vector signed char, int, signed char *);
15295 void vec_ste (vector unsigned char, int, unsigned char *);
15296 void vec_ste (vector bool char, int, signed char *);
15297 void vec_ste (vector bool char, int, unsigned char *);
15298 void vec_ste (vector signed short, int, short *);
15299 void vec_ste (vector unsigned short, int, unsigned short *);
15300 void vec_ste (vector bool short, int, short *);
15301 void vec_ste (vector bool short, int, unsigned short *);
15302 void vec_ste (vector pixel, int, short *);
15303 void vec_ste (vector pixel, int, unsigned short *);
15304 void vec_ste (vector float, int, float *);
15305 void vec_ste (vector signed int, int, int *);
15306 void vec_ste (vector unsigned int, int, unsigned int *);
15307 void vec_ste (vector bool int, int, int *);
15308 void vec_ste (vector bool int, int, unsigned int *);
15310 void vec_stvewx (vector float, int, float *);
15311 void vec_stvewx (vector signed int, int, int *);
15312 void vec_stvewx (vector unsigned int, int, unsigned int *);
15313 void vec_stvewx (vector bool int, int, int *);
15314 void vec_stvewx (vector bool int, int, unsigned int *);
15316 void vec_stvehx (vector signed short, int, short *);
15317 void vec_stvehx (vector unsigned short, int, unsigned short *);
15318 void vec_stvehx (vector bool short, int, short *);
15319 void vec_stvehx (vector bool short, int, unsigned short *);
15320 void vec_stvehx (vector pixel, int, short *);
15321 void vec_stvehx (vector pixel, int, unsigned short *);
15323 void vec_stvebx (vector signed char, int, signed char *);
15324 void vec_stvebx (vector unsigned char, int, unsigned char *);
15325 void vec_stvebx (vector bool char, int, signed char *);
15326 void vec_stvebx (vector bool char, int, unsigned char *);
15328 void vec_stl (vector float, int, vector float *);
15329 void vec_stl (vector float, int, float *);
15330 void vec_stl (vector signed int, int, vector signed int *);
15331 void vec_stl (vector signed int, int, int *);
15332 void vec_stl (vector unsigned int, int, vector unsigned int *);
15333 void vec_stl (vector unsigned int, int, unsigned int *);
15334 void vec_stl (vector bool int, int, vector bool int *);
15335 void vec_stl (vector bool int, int, unsigned int *);
15336 void vec_stl (vector bool int, int, int *);
15337 void vec_stl (vector signed short, int, vector signed short *);
15338 void vec_stl (vector signed short, int, short *);
15339 void vec_stl (vector unsigned short, int, vector unsigned short *);
15340 void vec_stl (vector unsigned short, int, unsigned short *);
15341 void vec_stl (vector bool short, int, vector bool short *);
15342 void vec_stl (vector bool short, int, unsigned short *);
15343 void vec_stl (vector bool short, int, short *);
15344 void vec_stl (vector pixel, int, vector pixel *);
15345 void vec_stl (vector pixel, int, unsigned short *);
15346 void vec_stl (vector pixel, int, short *);
15347 void vec_stl (vector signed char, int, vector signed char *);
15348 void vec_stl (vector signed char, int, signed char *);
15349 void vec_stl (vector unsigned char, int, vector unsigned char *);
15350 void vec_stl (vector unsigned char, int, unsigned char *);
15351 void vec_stl (vector bool char, int, vector bool char *);
15352 void vec_stl (vector bool char, int, unsigned char *);
15353 void vec_stl (vector bool char, int, signed char *);
15355 vector signed char vec_sub (vector bool char, vector signed char);
15356 vector signed char vec_sub (vector signed char, vector bool char);
15357 vector signed char vec_sub (vector signed char, vector signed char);
15358 vector unsigned char vec_sub (vector bool char, vector unsigned char);
15359 vector unsigned char vec_sub (vector unsigned char, vector bool char);
15360 vector unsigned char vec_sub (vector unsigned char,
15361 vector unsigned char);
15362 vector signed short vec_sub (vector bool short, vector signed short);
15363 vector signed short vec_sub (vector signed short, vector bool short);
15364 vector signed short vec_sub (vector signed short, vector signed short);
15365 vector unsigned short vec_sub (vector bool short,
15366 vector unsigned short);
15367 vector unsigned short vec_sub (vector unsigned short,
15368 vector bool short);
15369 vector unsigned short vec_sub (vector unsigned short,
15370 vector unsigned short);
15371 vector signed int vec_sub (vector bool int, vector signed int);
15372 vector signed int vec_sub (vector signed int, vector bool int);
15373 vector signed int vec_sub (vector signed int, vector signed int);
15374 vector unsigned int vec_sub (vector bool int, vector unsigned int);
15375 vector unsigned int vec_sub (vector unsigned int, vector bool int);
15376 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
15377 vector float vec_sub (vector float, vector float);
15379 vector float vec_vsubfp (vector float, vector float);
15381 vector signed int vec_vsubuwm (vector bool int, vector signed int);
15382 vector signed int vec_vsubuwm (vector signed int, vector bool int);
15383 vector signed int vec_vsubuwm (vector signed int, vector signed int);
15384 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
15385 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
15386 vector unsigned int vec_vsubuwm (vector unsigned int,
15387 vector unsigned int);
15389 vector signed short vec_vsubuhm (vector bool short,
15390 vector signed short);
15391 vector signed short vec_vsubuhm (vector signed short,
15392 vector bool short);
15393 vector signed short vec_vsubuhm (vector signed short,
15394 vector signed short);
15395 vector unsigned short vec_vsubuhm (vector bool short,
15396 vector unsigned short);
15397 vector unsigned short vec_vsubuhm (vector unsigned short,
15398 vector bool short);
15399 vector unsigned short vec_vsubuhm (vector unsigned short,
15400 vector unsigned short);
15402 vector signed char vec_vsububm (vector bool char, vector signed char);
15403 vector signed char vec_vsububm (vector signed char, vector bool char);
15404 vector signed char vec_vsububm (vector signed char, vector signed char);
15405 vector unsigned char vec_vsububm (vector bool char,
15406 vector unsigned char);
15407 vector unsigned char vec_vsububm (vector unsigned char,
15409 vector unsigned char vec_vsububm (vector unsigned char,
15410 vector unsigned char);
15412 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
15414 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15415 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15416 vector unsigned char vec_subs (vector unsigned char,
15417 vector unsigned char);
15418 vector signed char vec_subs (vector bool char, vector signed char);
15419 vector signed char vec_subs (vector signed char, vector bool char);
15420 vector signed char vec_subs (vector signed char, vector signed char);
15421 vector unsigned short vec_subs (vector bool short,
15422 vector unsigned short);
15423 vector unsigned short vec_subs (vector unsigned short,
15424 vector bool short);
15425 vector unsigned short vec_subs (vector unsigned short,
15426 vector unsigned short);
15427 vector signed short vec_subs (vector bool short, vector signed short);
15428 vector signed short vec_subs (vector signed short, vector bool short);
15429 vector signed short vec_subs (vector signed short, vector signed short);
15430 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15431 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15432 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15433 vector signed int vec_subs (vector bool int, vector signed int);
15434 vector signed int vec_subs (vector signed int, vector bool int);
15435 vector signed int vec_subs (vector signed int, vector signed int);
15437 vector signed int vec_vsubsws (vector bool int, vector signed int);
15438 vector signed int vec_vsubsws (vector signed int, vector bool int);
15439 vector signed int vec_vsubsws (vector signed int, vector signed int);
15441 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15442 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15443 vector unsigned int vec_vsubuws (vector unsigned int,
15444 vector unsigned int);
15446 vector signed short vec_vsubshs (vector bool short,
15447 vector signed short);
15448 vector signed short vec_vsubshs (vector signed short,
15449 vector bool short);
15450 vector signed short vec_vsubshs (vector signed short,
15451 vector signed short);
15453 vector unsigned short vec_vsubuhs (vector bool short,
15454 vector unsigned short);
15455 vector unsigned short vec_vsubuhs (vector unsigned short,
15456 vector bool short);
15457 vector unsigned short vec_vsubuhs (vector unsigned short,
15458 vector unsigned short);
15460 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15461 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15462 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15464 vector unsigned char vec_vsububs (vector bool char,
15465 vector unsigned char);
15466 vector unsigned char vec_vsububs (vector unsigned char,
15468 vector unsigned char vec_vsububs (vector unsigned char,
15469 vector unsigned char);
15471 vector unsigned int vec_sum4s (vector unsigned char,
15472 vector unsigned int);
15473 vector signed int vec_sum4s (vector signed char, vector signed int);
15474 vector signed int vec_sum4s (vector signed short, vector signed int);
15476 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15478 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15480 vector unsigned int vec_vsum4ubs (vector unsigned char,
15481 vector unsigned int);
15483 vector signed int vec_sum2s (vector signed int, vector signed int);
15485 vector signed int vec_sums (vector signed int, vector signed int);
15487 vector float vec_trunc (vector float);
15489 vector signed short vec_unpackh (vector signed char);
15490 vector bool short vec_unpackh (vector bool char);
15491 vector signed int vec_unpackh (vector signed short);
15492 vector bool int vec_unpackh (vector bool short);
15493 vector unsigned int vec_unpackh (vector pixel);
15495 vector bool int vec_vupkhsh (vector bool short);
15496 vector signed int vec_vupkhsh (vector signed short);
15498 vector unsigned int vec_vupkhpx (vector pixel);
15500 vector bool short vec_vupkhsb (vector bool char);
15501 vector signed short vec_vupkhsb (vector signed char);
15503 vector signed short vec_unpackl (vector signed char);
15504 vector bool short vec_unpackl (vector bool char);
15505 vector unsigned int vec_unpackl (vector pixel);
15506 vector signed int vec_unpackl (vector signed short);
15507 vector bool int vec_unpackl (vector bool short);
15509 vector unsigned int vec_vupklpx (vector pixel);
15511 vector bool int vec_vupklsh (vector bool short);
15512 vector signed int vec_vupklsh (vector signed short);
15514 vector bool short vec_vupklsb (vector bool char);
15515 vector signed short vec_vupklsb (vector signed char);
15517 vector float vec_xor (vector float, vector float);
15518 vector float vec_xor (vector float, vector bool int);
15519 vector float vec_xor (vector bool int, vector float);
15520 vector bool int vec_xor (vector bool int, vector bool int);
15521 vector signed int vec_xor (vector bool int, vector signed int);
15522 vector signed int vec_xor (vector signed int, vector bool int);
15523 vector signed int vec_xor (vector signed int, vector signed int);
15524 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15525 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15526 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15527 vector bool short vec_xor (vector bool short, vector bool short);
15528 vector signed short vec_xor (vector bool short, vector signed short);
15529 vector signed short vec_xor (vector signed short, vector bool short);
15530 vector signed short vec_xor (vector signed short, vector signed short);
15531 vector unsigned short vec_xor (vector bool short,
15532 vector unsigned short);
15533 vector unsigned short vec_xor (vector unsigned short,
15534 vector bool short);
15535 vector unsigned short vec_xor (vector unsigned short,
15536 vector unsigned short);
15537 vector signed char vec_xor (vector bool char, vector signed char);
15538 vector bool char vec_xor (vector bool char, vector bool char);
15539 vector signed char vec_xor (vector signed char, vector bool char);
15540 vector signed char vec_xor (vector signed char, vector signed char);
15541 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15542 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15543 vector unsigned char vec_xor (vector unsigned char,
15544 vector unsigned char);
15546 int vec_all_eq (vector signed char, vector bool char);
15547 int vec_all_eq (vector signed char, vector signed char);
15548 int vec_all_eq (vector unsigned char, vector bool char);
15549 int vec_all_eq (vector unsigned char, vector unsigned char);
15550 int vec_all_eq (vector bool char, vector bool char);
15551 int vec_all_eq (vector bool char, vector unsigned char);
15552 int vec_all_eq (vector bool char, vector signed char);
15553 int vec_all_eq (vector signed short, vector bool short);
15554 int vec_all_eq (vector signed short, vector signed short);
15555 int vec_all_eq (vector unsigned short, vector bool short);
15556 int vec_all_eq (vector unsigned short, vector unsigned short);
15557 int vec_all_eq (vector bool short, vector bool short);
15558 int vec_all_eq (vector bool short, vector unsigned short);
15559 int vec_all_eq (vector bool short, vector signed short);
15560 int vec_all_eq (vector pixel, vector pixel);
15561 int vec_all_eq (vector signed int, vector bool int);
15562 int vec_all_eq (vector signed int, vector signed int);
15563 int vec_all_eq (vector unsigned int, vector bool int);
15564 int vec_all_eq (vector unsigned int, vector unsigned int);
15565 int vec_all_eq (vector bool int, vector bool int);
15566 int vec_all_eq (vector bool int, vector unsigned int);
15567 int vec_all_eq (vector bool int, vector signed int);
15568 int vec_all_eq (vector float, vector float);
15570 int vec_all_ge (vector bool char, vector unsigned char);
15571 int vec_all_ge (vector unsigned char, vector bool char);
15572 int vec_all_ge (vector unsigned char, vector unsigned char);
15573 int vec_all_ge (vector bool char, vector signed char);
15574 int vec_all_ge (vector signed char, vector bool char);
15575 int vec_all_ge (vector signed char, vector signed char);
15576 int vec_all_ge (vector bool short, vector unsigned short);
15577 int vec_all_ge (vector unsigned short, vector bool short);
15578 int vec_all_ge (vector unsigned short, vector unsigned short);
15579 int vec_all_ge (vector signed short, vector signed short);
15580 int vec_all_ge (vector bool short, vector signed short);
15581 int vec_all_ge (vector signed short, vector bool short);
15582 int vec_all_ge (vector bool int, vector unsigned int);
15583 int vec_all_ge (vector unsigned int, vector bool int);
15584 int vec_all_ge (vector unsigned int, vector unsigned int);
15585 int vec_all_ge (vector bool int, vector signed int);
15586 int vec_all_ge (vector signed int, vector bool int);
15587 int vec_all_ge (vector signed int, vector signed int);
15588 int vec_all_ge (vector float, vector float);
15590 int vec_all_gt (vector bool char, vector unsigned char);
15591 int vec_all_gt (vector unsigned char, vector bool char);
15592 int vec_all_gt (vector unsigned char, vector unsigned char);
15593 int vec_all_gt (vector bool char, vector signed char);
15594 int vec_all_gt (vector signed char, vector bool char);
15595 int vec_all_gt (vector signed char, vector signed char);
15596 int vec_all_gt (vector bool short, vector unsigned short);
15597 int vec_all_gt (vector unsigned short, vector bool short);
15598 int vec_all_gt (vector unsigned short, vector unsigned short);
15599 int vec_all_gt (vector bool short, vector signed short);
15600 int vec_all_gt (vector signed short, vector bool short);
15601 int vec_all_gt (vector signed short, vector signed short);
15602 int vec_all_gt (vector bool int, vector unsigned int);
15603 int vec_all_gt (vector unsigned int, vector bool int);
15604 int vec_all_gt (vector unsigned int, vector unsigned int);
15605 int vec_all_gt (vector bool int, vector signed int);
15606 int vec_all_gt (vector signed int, vector bool int);
15607 int vec_all_gt (vector signed int, vector signed int);
15608 int vec_all_gt (vector float, vector float);
15610 int vec_all_in (vector float, vector float);
15612 int vec_all_le (vector bool char, vector unsigned char);
15613 int vec_all_le (vector unsigned char, vector bool char);
15614 int vec_all_le (vector unsigned char, vector unsigned char);
15615 int vec_all_le (vector bool char, vector signed char);
15616 int vec_all_le (vector signed char, vector bool char);
15617 int vec_all_le (vector signed char, vector signed char);
15618 int vec_all_le (vector bool short, vector unsigned short);
15619 int vec_all_le (vector unsigned short, vector bool short);
15620 int vec_all_le (vector unsigned short, vector unsigned short);
15621 int vec_all_le (vector bool short, vector signed short);
15622 int vec_all_le (vector signed short, vector bool short);
15623 int vec_all_le (vector signed short, vector signed short);
15624 int vec_all_le (vector bool int, vector unsigned int);
15625 int vec_all_le (vector unsigned int, vector bool int);
15626 int vec_all_le (vector unsigned int, vector unsigned int);
15627 int vec_all_le (vector bool int, vector signed int);
15628 int vec_all_le (vector signed int, vector bool int);
15629 int vec_all_le (vector signed int, vector signed int);
15630 int vec_all_le (vector float, vector float);
15632 int vec_all_lt (vector bool char, vector unsigned char);
15633 int vec_all_lt (vector unsigned char, vector bool char);
15634 int vec_all_lt (vector unsigned char, vector unsigned char);
15635 int vec_all_lt (vector bool char, vector signed char);
15636 int vec_all_lt (vector signed char, vector bool char);
15637 int vec_all_lt (vector signed char, vector signed char);
15638 int vec_all_lt (vector bool short, vector unsigned short);
15639 int vec_all_lt (vector unsigned short, vector bool short);
15640 int vec_all_lt (vector unsigned short, vector unsigned short);
15641 int vec_all_lt (vector bool short, vector signed short);
15642 int vec_all_lt (vector signed short, vector bool short);
15643 int vec_all_lt (vector signed short, vector signed short);
15644 int vec_all_lt (vector bool int, vector unsigned int);
15645 int vec_all_lt (vector unsigned int, vector bool int);
15646 int vec_all_lt (vector unsigned int, vector unsigned int);
15647 int vec_all_lt (vector bool int, vector signed int);
15648 int vec_all_lt (vector signed int, vector bool int);
15649 int vec_all_lt (vector signed int, vector signed int);
15650 int vec_all_lt (vector float, vector float);
15652 int vec_all_nan (vector float);
15654 int vec_all_ne (vector signed char, vector bool char);
15655 int vec_all_ne (vector signed char, vector signed char);
15656 int vec_all_ne (vector unsigned char, vector bool char);
15657 int vec_all_ne (vector unsigned char, vector unsigned char);
15658 int vec_all_ne (vector bool char, vector bool char);
15659 int vec_all_ne (vector bool char, vector unsigned char);
15660 int vec_all_ne (vector bool char, vector signed char);
15661 int vec_all_ne (vector signed short, vector bool short);
15662 int vec_all_ne (vector signed short, vector signed short);
15663 int vec_all_ne (vector unsigned short, vector bool short);
15664 int vec_all_ne (vector unsigned short, vector unsigned short);
15665 int vec_all_ne (vector bool short, vector bool short);
15666 int vec_all_ne (vector bool short, vector unsigned short);
15667 int vec_all_ne (vector bool short, vector signed short);
15668 int vec_all_ne (vector pixel, vector pixel);
15669 int vec_all_ne (vector signed int, vector bool int);
15670 int vec_all_ne (vector signed int, vector signed int);
15671 int vec_all_ne (vector unsigned int, vector bool int);
15672 int vec_all_ne (vector unsigned int, vector unsigned int);
15673 int vec_all_ne (vector bool int, vector bool int);
15674 int vec_all_ne (vector bool int, vector unsigned int);
15675 int vec_all_ne (vector bool int, vector signed int);
15676 int vec_all_ne (vector float, vector float);
15678 int vec_all_nge (vector float, vector float);
15680 int vec_all_ngt (vector float, vector float);
15682 int vec_all_nle (vector float, vector float);
15684 int vec_all_nlt (vector float, vector float);
15686 int vec_all_numeric (vector float);
15688 int vec_any_eq (vector signed char, vector bool char);
15689 int vec_any_eq (vector signed char, vector signed char);
15690 int vec_any_eq (vector unsigned char, vector bool char);
15691 int vec_any_eq (vector unsigned char, vector unsigned char);
15692 int vec_any_eq (vector bool char, vector bool char);
15693 int vec_any_eq (vector bool char, vector unsigned char);
15694 int vec_any_eq (vector bool char, vector signed char);
15695 int vec_any_eq (vector signed short, vector bool short);
15696 int vec_any_eq (vector signed short, vector signed short);
15697 int vec_any_eq (vector unsigned short, vector bool short);
15698 int vec_any_eq (vector unsigned short, vector unsigned short);
15699 int vec_any_eq (vector bool short, vector bool short);
15700 int vec_any_eq (vector bool short, vector unsigned short);
15701 int vec_any_eq (vector bool short, vector signed short);
15702 int vec_any_eq (vector pixel, vector pixel);
15703 int vec_any_eq (vector signed int, vector bool int);
15704 int vec_any_eq (vector signed int, vector signed int);
15705 int vec_any_eq (vector unsigned int, vector bool int);
15706 int vec_any_eq (vector unsigned int, vector unsigned int);
15707 int vec_any_eq (vector bool int, vector bool int);
15708 int vec_any_eq (vector bool int, vector unsigned int);
15709 int vec_any_eq (vector bool int, vector signed int);
15710 int vec_any_eq (vector float, vector float);
15712 int vec_any_ge (vector signed char, vector bool char);
15713 int vec_any_ge (vector unsigned char, vector bool char);
15714 int vec_any_ge (vector unsigned char, vector unsigned char);
15715 int vec_any_ge (vector signed char, vector signed char);
15716 int vec_any_ge (vector bool char, vector unsigned char);
15717 int vec_any_ge (vector bool char, vector signed char);
15718 int vec_any_ge (vector unsigned short, vector bool short);
15719 int vec_any_ge (vector unsigned short, vector unsigned short);
15720 int vec_any_ge (vector signed short, vector signed short);
15721 int vec_any_ge (vector signed short, vector bool short);
15722 int vec_any_ge (vector bool short, vector unsigned short);
15723 int vec_any_ge (vector bool short, vector signed short);
15724 int vec_any_ge (vector signed int, vector bool int);
15725 int vec_any_ge (vector unsigned int, vector bool int);
15726 int vec_any_ge (vector unsigned int, vector unsigned int);
15727 int vec_any_ge (vector signed int, vector signed int);
15728 int vec_any_ge (vector bool int, vector unsigned int);
15729 int vec_any_ge (vector bool int, vector signed int);
15730 int vec_any_ge (vector float, vector float);
15732 int vec_any_gt (vector bool char, vector unsigned char);
15733 int vec_any_gt (vector unsigned char, vector bool char);
15734 int vec_any_gt (vector unsigned char, vector unsigned char);
15735 int vec_any_gt (vector bool char, vector signed char);
15736 int vec_any_gt (vector signed char, vector bool char);
15737 int vec_any_gt (vector signed char, vector signed char);
15738 int vec_any_gt (vector bool short, vector unsigned short);
15739 int vec_any_gt (vector unsigned short, vector bool short);
15740 int vec_any_gt (vector unsigned short, vector unsigned short);
15741 int vec_any_gt (vector bool short, vector signed short);
15742 int vec_any_gt (vector signed short, vector bool short);
15743 int vec_any_gt (vector signed short, vector signed short);
15744 int vec_any_gt (vector bool int, vector unsigned int);
15745 int vec_any_gt (vector unsigned int, vector bool int);
15746 int vec_any_gt (vector unsigned int, vector unsigned int);
15747 int vec_any_gt (vector bool int, vector signed int);
15748 int vec_any_gt (vector signed int, vector bool int);
15749 int vec_any_gt (vector signed int, vector signed int);
15750 int vec_any_gt (vector float, vector float);
15752 int vec_any_le (vector bool char, vector unsigned char);
15753 int vec_any_le (vector unsigned char, vector bool char);
15754 int vec_any_le (vector unsigned char, vector unsigned char);
15755 int vec_any_le (vector bool char, vector signed char);
15756 int vec_any_le (vector signed char, vector bool char);
15757 int vec_any_le (vector signed char, vector signed char);
15758 int vec_any_le (vector bool short, vector unsigned short);
15759 int vec_any_le (vector unsigned short, vector bool short);
15760 int vec_any_le (vector unsigned short, vector unsigned short);
15761 int vec_any_le (vector bool short, vector signed short);
15762 int vec_any_le (vector signed short, vector bool short);
15763 int vec_any_le (vector signed short, vector signed short);
15764 int vec_any_le (vector bool int, vector unsigned int);
15765 int vec_any_le (vector unsigned int, vector bool int);
15766 int vec_any_le (vector unsigned int, vector unsigned int);
15767 int vec_any_le (vector bool int, vector signed int);
15768 int vec_any_le (vector signed int, vector bool int);
15769 int vec_any_le (vector signed int, vector signed int);
15770 int vec_any_le (vector float, vector float);
15772 int vec_any_lt (vector bool char, vector unsigned char);
15773 int vec_any_lt (vector unsigned char, vector bool char);
15774 int vec_any_lt (vector unsigned char, vector unsigned char);
15775 int vec_any_lt (vector bool char, vector signed char);
15776 int vec_any_lt (vector signed char, vector bool char);
15777 int vec_any_lt (vector signed char, vector signed char);
15778 int vec_any_lt (vector bool short, vector unsigned short);
15779 int vec_any_lt (vector unsigned short, vector bool short);
15780 int vec_any_lt (vector unsigned short, vector unsigned short);
15781 int vec_any_lt (vector bool short, vector signed short);
15782 int vec_any_lt (vector signed short, vector bool short);
15783 int vec_any_lt (vector signed short, vector signed short);
15784 int vec_any_lt (vector bool int, vector unsigned int);
15785 int vec_any_lt (vector unsigned int, vector bool int);
15786 int vec_any_lt (vector unsigned int, vector unsigned int);
15787 int vec_any_lt (vector bool int, vector signed int);
15788 int vec_any_lt (vector signed int, vector bool int);
15789 int vec_any_lt (vector signed int, vector signed int);
15790 int vec_any_lt (vector float, vector float);
15792 int vec_any_nan (vector float);
15794 int vec_any_ne (vector signed char, vector bool char);
15795 int vec_any_ne (vector signed char, vector signed char);
15796 int vec_any_ne (vector unsigned char, vector bool char);
15797 int vec_any_ne (vector unsigned char, vector unsigned char);
15798 int vec_any_ne (vector bool char, vector bool char);
15799 int vec_any_ne (vector bool char, vector unsigned char);
15800 int vec_any_ne (vector bool char, vector signed char);
15801 int vec_any_ne (vector signed short, vector bool short);
15802 int vec_any_ne (vector signed short, vector signed short);
15803 int vec_any_ne (vector unsigned short, vector bool short);
15804 int vec_any_ne (vector unsigned short, vector unsigned short);
15805 int vec_any_ne (vector bool short, vector bool short);
15806 int vec_any_ne (vector bool short, vector unsigned short);
15807 int vec_any_ne (vector bool short, vector signed short);
15808 int vec_any_ne (vector pixel, vector pixel);
15809 int vec_any_ne (vector signed int, vector bool int);
15810 int vec_any_ne (vector signed int, vector signed int);
15811 int vec_any_ne (vector unsigned int, vector bool int);
15812 int vec_any_ne (vector unsigned int, vector unsigned int);
15813 int vec_any_ne (vector bool int, vector bool int);
15814 int vec_any_ne (vector bool int, vector unsigned int);
15815 int vec_any_ne (vector bool int, vector signed int);
15816 int vec_any_ne (vector float, vector float);
15818 int vec_any_nge (vector float, vector float);
15820 int vec_any_ngt (vector float, vector float);
15822 int vec_any_nle (vector float, vector float);
15824 int vec_any_nlt (vector float, vector float);
15826 int vec_any_numeric (vector float);
15828 int vec_any_out (vector float, vector float);
15831 If the vector/scalar (VSX) instruction set is available, the following
15832 additional functions are available:
15835 vector double vec_abs (vector double);
15836 vector double vec_add (vector double, vector double);
15837 vector double vec_and (vector double, vector double);
15838 vector double vec_and (vector double, vector bool long);
15839 vector double vec_and (vector bool long, vector double);
15840 vector long vec_and (vector long, vector long);
15841 vector long vec_and (vector long, vector bool long);
15842 vector long vec_and (vector bool long, vector long);
15843 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15844 vector unsigned long vec_and (vector unsigned long, vector bool long);
15845 vector unsigned long vec_and (vector bool long, vector unsigned long);
15846 vector double vec_andc (vector double, vector double);
15847 vector double vec_andc (vector double, vector bool long);
15848 vector double vec_andc (vector bool long, vector double);
15849 vector long vec_andc (vector long, vector long);
15850 vector long vec_andc (vector long, vector bool long);
15851 vector long vec_andc (vector bool long, vector long);
15852 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15853 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15854 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15855 vector double vec_ceil (vector double);
15856 vector bool long vec_cmpeq (vector double, vector double);
15857 vector bool long vec_cmpge (vector double, vector double);
15858 vector bool long vec_cmpgt (vector double, vector double);
15859 vector bool long vec_cmple (vector double, vector double);
15860 vector bool long vec_cmplt (vector double, vector double);
15861 vector double vec_cpsgn (vector double, vector double);
15862 vector float vec_div (vector float, vector float);
15863 vector double vec_div (vector double, vector double);
15864 vector long vec_div (vector long, vector long);
15865 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15866 vector double vec_floor (vector double);
15867 vector double vec_ld (int, const vector double *);
15868 vector double vec_ld (int, const double *);
15869 vector double vec_ldl (int, const vector double *);
15870 vector double vec_ldl (int, const double *);
15871 vector unsigned char vec_lvsl (int, const volatile double *);
15872 vector unsigned char vec_lvsr (int, const volatile double *);
15873 vector double vec_madd (vector double, vector double, vector double);
15874 vector double vec_max (vector double, vector double);
15875 vector signed long vec_mergeh (vector signed long, vector signed long);
15876 vector signed long vec_mergeh (vector signed long, vector bool long);
15877 vector signed long vec_mergeh (vector bool long, vector signed long);
15878 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15879 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15880 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15881 vector signed long vec_mergel (vector signed long, vector signed long);
15882 vector signed long vec_mergel (vector signed long, vector bool long);
15883 vector signed long vec_mergel (vector bool long, vector signed long);
15884 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15885 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15886 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15887 vector double vec_min (vector double, vector double);
15888 vector float vec_msub (vector float, vector float, vector float);
15889 vector double vec_msub (vector double, vector double, vector double);
15890 vector float vec_mul (vector float, vector float);
15891 vector double vec_mul (vector double, vector double);
15892 vector long vec_mul (vector long, vector long);
15893 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15894 vector float vec_nearbyint (vector float);
15895 vector double vec_nearbyint (vector double);
15896 vector float vec_nmadd (vector float, vector float, vector float);
15897 vector double vec_nmadd (vector double, vector double, vector double);
15898 vector double vec_nmsub (vector double, vector double, vector double);
15899 vector double vec_nor (vector double, vector double);
15900 vector long vec_nor (vector long, vector long);
15901 vector long vec_nor (vector long, vector bool long);
15902 vector long vec_nor (vector bool long, vector long);
15903 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15904 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15905 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15906 vector double vec_or (vector double, vector double);
15907 vector double vec_or (vector double, vector bool long);
15908 vector double vec_or (vector bool long, vector double);
15909 vector long vec_or (vector long, vector long);
15910 vector long vec_or (vector long, vector bool long);
15911 vector long vec_or (vector bool long, vector long);
15912 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15913 vector unsigned long vec_or (vector unsigned long, vector bool long);
15914 vector unsigned long vec_or (vector bool long, vector unsigned long);
15915 vector double vec_perm (vector double, vector double, vector unsigned char);
15916 vector long vec_perm (vector long, vector long, vector unsigned char);
15917 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15918 vector unsigned char);
15919 vector double vec_rint (vector double);
15920 vector double vec_recip (vector double, vector double);
15921 vector double vec_rsqrt (vector double);
15922 vector double vec_rsqrte (vector double);
15923 vector double vec_sel (vector double, vector double, vector bool long);
15924 vector double vec_sel (vector double, vector double, vector unsigned long);
15925 vector long vec_sel (vector long, vector long, vector long);
15926 vector long vec_sel (vector long, vector long, vector unsigned long);
15927 vector long vec_sel (vector long, vector long, vector bool long);
15928 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15930 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15931 vector unsigned long);
15932 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15934 vector double vec_splats (double);
15935 vector signed long vec_splats (signed long);
15936 vector unsigned long vec_splats (unsigned long);
15937 vector float vec_sqrt (vector float);
15938 vector double vec_sqrt (vector double);
15939 void vec_st (vector double, int, vector double *);
15940 void vec_st (vector double, int, double *);
15941 vector double vec_sub (vector double, vector double);
15942 vector double vec_trunc (vector double);
15943 vector double vec_xor (vector double, vector double);
15944 vector double vec_xor (vector double, vector bool long);
15945 vector double vec_xor (vector bool long, vector double);
15946 vector long vec_xor (vector long, vector long);
15947 vector long vec_xor (vector long, vector bool long);
15948 vector long vec_xor (vector bool long, vector long);
15949 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15950 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15951 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15952 int vec_all_eq (vector double, vector double);
15953 int vec_all_ge (vector double, vector double);
15954 int vec_all_gt (vector double, vector double);
15955 int vec_all_le (vector double, vector double);
15956 int vec_all_lt (vector double, vector double);
15957 int vec_all_nan (vector double);
15958 int vec_all_ne (vector double, vector double);
15959 int vec_all_nge (vector double, vector double);
15960 int vec_all_ngt (vector double, vector double);
15961 int vec_all_nle (vector double, vector double);
15962 int vec_all_nlt (vector double, vector double);
15963 int vec_all_numeric (vector double);
15964 int vec_any_eq (vector double, vector double);
15965 int vec_any_ge (vector double, vector double);
15966 int vec_any_gt (vector double, vector double);
15967 int vec_any_le (vector double, vector double);
15968 int vec_any_lt (vector double, vector double);
15969 int vec_any_nan (vector double);
15970 int vec_any_ne (vector double, vector double);
15971 int vec_any_nge (vector double, vector double);
15972 int vec_any_ngt (vector double, vector double);
15973 int vec_any_nle (vector double, vector double);
15974 int vec_any_nlt (vector double, vector double);
15975 int vec_any_numeric (vector double);
15977 vector double vec_vsx_ld (int, const vector double *);
15978 vector double vec_vsx_ld (int, const double *);
15979 vector float vec_vsx_ld (int, const vector float *);
15980 vector float vec_vsx_ld (int, const float *);
15981 vector bool int vec_vsx_ld (int, const vector bool int *);
15982 vector signed int vec_vsx_ld (int, const vector signed int *);
15983 vector signed int vec_vsx_ld (int, const int *);
15984 vector signed int vec_vsx_ld (int, const long *);
15985 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15986 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15987 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15988 vector bool short vec_vsx_ld (int, const vector bool short *);
15989 vector pixel vec_vsx_ld (int, const vector pixel *);
15990 vector signed short vec_vsx_ld (int, const vector signed short *);
15991 vector signed short vec_vsx_ld (int, const short *);
15992 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15993 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15994 vector bool char vec_vsx_ld (int, const vector bool char *);
15995 vector signed char vec_vsx_ld (int, const vector signed char *);
15996 vector signed char vec_vsx_ld (int, const signed char *);
15997 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15998 vector unsigned char vec_vsx_ld (int, const unsigned char *);
16000 void vec_vsx_st (vector double, int, vector double *);
16001 void vec_vsx_st (vector double, int, double *);
16002 void vec_vsx_st (vector float, int, vector float *);
16003 void vec_vsx_st (vector float, int, float *);
16004 void vec_vsx_st (vector signed int, int, vector signed int *);
16005 void vec_vsx_st (vector signed int, int, int *);
16006 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
16007 void vec_vsx_st (vector unsigned int, int, unsigned int *);
16008 void vec_vsx_st (vector bool int, int, vector bool int *);
16009 void vec_vsx_st (vector bool int, int, unsigned int *);
16010 void vec_vsx_st (vector bool int, int, int *);
16011 void vec_vsx_st (vector signed short, int, vector signed short *);
16012 void vec_vsx_st (vector signed short, int, short *);
16013 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
16014 void vec_vsx_st (vector unsigned short, int, unsigned short *);
16015 void vec_vsx_st (vector bool short, int, vector bool short *);
16016 void vec_vsx_st (vector bool short, int, unsigned short *);
16017 void vec_vsx_st (vector pixel, int, vector pixel *);
16018 void vec_vsx_st (vector pixel, int, unsigned short *);
16019 void vec_vsx_st (vector pixel, int, short *);
16020 void vec_vsx_st (vector bool short, int, short *);
16021 void vec_vsx_st (vector signed char, int, vector signed char *);
16022 void vec_vsx_st (vector signed char, int, signed char *);
16023 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
16024 void vec_vsx_st (vector unsigned char, int, unsigned char *);
16025 void vec_vsx_st (vector bool char, int, vector bool char *);
16026 void vec_vsx_st (vector bool char, int, unsigned char *);
16027 void vec_vsx_st (vector bool char, int, signed char *);
16029 vector double vec_xxpermdi (vector double, vector double, int);
16030 vector float vec_xxpermdi (vector float, vector float, int);
16031 vector long long vec_xxpermdi (vector long long, vector long long, int);
16032 vector unsigned long long vec_xxpermdi (vector unsigned long long,
16033 vector unsigned long long, int);
16034 vector int vec_xxpermdi (vector int, vector int, int);
16035 vector unsigned int vec_xxpermdi (vector unsigned int,
16036 vector unsigned int, int);
16037 vector short vec_xxpermdi (vector short, vector short, int);
16038 vector unsigned short vec_xxpermdi (vector unsigned short,
16039 vector unsigned short, int);
16040 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
16041 vector unsigned char vec_xxpermdi (vector unsigned char,
16042 vector unsigned char, int);
16044 vector double vec_xxsldi (vector double, vector double, int);
16045 vector float vec_xxsldi (vector float, vector float, int);
16046 vector long long vec_xxsldi (vector long long, vector long long, int);
16047 vector unsigned long long vec_xxsldi (vector unsigned long long,
16048 vector unsigned long long, int);
16049 vector int vec_xxsldi (vector int, vector int, int);
16050 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
16051 vector short vec_xxsldi (vector short, vector short, int);
16052 vector unsigned short vec_xxsldi (vector unsigned short,
16053 vector unsigned short, int);
16054 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
16055 vector unsigned char vec_xxsldi (vector unsigned char,
16056 vector unsigned char, int);
16059 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
16060 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
16061 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
16062 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
16063 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
16065 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16066 instruction set is available, the following additional functions are
16067 available for both 32-bit and 64-bit targets. For 64-bit targets, you
16068 can use @var{vector long} instead of @var{vector long long},
16069 @var{vector bool long} instead of @var{vector bool long long}, and
16070 @var{vector unsigned long} instead of @var{vector unsigned long long}.
16073 vector long long vec_abs (vector long long);
16075 vector long long vec_add (vector long long, vector long long);
16076 vector unsigned long long vec_add (vector unsigned long long,
16077 vector unsigned long long);
16079 int vec_all_eq (vector long long, vector long long);
16080 int vec_all_eq (vector unsigned long long, vector unsigned long long);
16081 int vec_all_ge (vector long long, vector long long);
16082 int vec_all_ge (vector unsigned long long, vector unsigned long long);
16083 int vec_all_gt (vector long long, vector long long);
16084 int vec_all_gt (vector unsigned long long, vector unsigned long long);
16085 int vec_all_le (vector long long, vector long long);
16086 int vec_all_le (vector unsigned long long, vector unsigned long long);
16087 int vec_all_lt (vector long long, vector long long);
16088 int vec_all_lt (vector unsigned long long, vector unsigned long long);
16089 int vec_all_ne (vector long long, vector long long);
16090 int vec_all_ne (vector unsigned long long, vector unsigned long long);
16092 int vec_any_eq (vector long long, vector long long);
16093 int vec_any_eq (vector unsigned long long, vector unsigned long long);
16094 int vec_any_ge (vector long long, vector long long);
16095 int vec_any_ge (vector unsigned long long, vector unsigned long long);
16096 int vec_any_gt (vector long long, vector long long);
16097 int vec_any_gt (vector unsigned long long, vector unsigned long long);
16098 int vec_any_le (vector long long, vector long long);
16099 int vec_any_le (vector unsigned long long, vector unsigned long long);
16100 int vec_any_lt (vector long long, vector long long);
16101 int vec_any_lt (vector unsigned long long, vector unsigned long long);
16102 int vec_any_ne (vector long long, vector long long);
16103 int vec_any_ne (vector unsigned long long, vector unsigned long long);
16105 vector long long vec_eqv (vector long long, vector long long);
16106 vector long long vec_eqv (vector bool long long, vector long long);
16107 vector long long vec_eqv (vector long long, vector bool long long);
16108 vector unsigned long long vec_eqv (vector unsigned long long,
16109 vector unsigned long long);
16110 vector unsigned long long vec_eqv (vector bool long long,
16111 vector unsigned long long);
16112 vector unsigned long long vec_eqv (vector unsigned long long,
16113 vector bool long long);
16114 vector int vec_eqv (vector int, vector int);
16115 vector int vec_eqv (vector bool int, vector int);
16116 vector int vec_eqv (vector int, vector bool int);
16117 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
16118 vector unsigned int vec_eqv (vector bool unsigned int,
16119 vector unsigned int);
16120 vector unsigned int vec_eqv (vector unsigned int,
16121 vector bool unsigned int);
16122 vector short vec_eqv (vector short, vector short);
16123 vector short vec_eqv (vector bool short, vector short);
16124 vector short vec_eqv (vector short, vector bool short);
16125 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
16126 vector unsigned short vec_eqv (vector bool unsigned short,
16127 vector unsigned short);
16128 vector unsigned short vec_eqv (vector unsigned short,
16129 vector bool unsigned short);
16130 vector signed char vec_eqv (vector signed char, vector signed char);
16131 vector signed char vec_eqv (vector bool signed char, vector signed char);
16132 vector signed char vec_eqv (vector signed char, vector bool signed char);
16133 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
16134 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
16135 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
16137 vector long long vec_max (vector long long, vector long long);
16138 vector unsigned long long vec_max (vector unsigned long long,
16139 vector unsigned long long);
16141 vector signed int vec_mergee (vector signed int, vector signed int);
16142 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
16143 vector bool int vec_mergee (vector bool int, vector bool int);
16145 vector signed int vec_mergeo (vector signed int, vector signed int);
16146 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
16147 vector bool int vec_mergeo (vector bool int, vector bool int);
16149 vector long long vec_min (vector long long, vector long long);
16150 vector unsigned long long vec_min (vector unsigned long long,
16151 vector unsigned long long);
16153 vector long long vec_nand (vector long long, vector long long);
16154 vector long long vec_nand (vector bool long long, vector long long);
16155 vector long long vec_nand (vector long long, vector bool long long);
16156 vector unsigned long long vec_nand (vector unsigned long long,
16157 vector unsigned long long);
16158 vector unsigned long long vec_nand (vector bool long long,
16159 vector unsigned long long);
16160 vector unsigned long long vec_nand (vector unsigned long long,
16161 vector bool long long);
16162 vector int vec_nand (vector int, vector int);
16163 vector int vec_nand (vector bool int, vector int);
16164 vector int vec_nand (vector int, vector bool int);
16165 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
16166 vector unsigned int vec_nand (vector bool unsigned int,
16167 vector unsigned int);
16168 vector unsigned int vec_nand (vector unsigned int,
16169 vector bool unsigned int);
16170 vector short vec_nand (vector short, vector short);
16171 vector short vec_nand (vector bool short, vector short);
16172 vector short vec_nand (vector short, vector bool short);
16173 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
16174 vector unsigned short vec_nand (vector bool unsigned short,
16175 vector unsigned short);
16176 vector unsigned short vec_nand (vector unsigned short,
16177 vector bool unsigned short);
16178 vector signed char vec_nand (vector signed char, vector signed char);
16179 vector signed char vec_nand (vector bool signed char, vector signed char);
16180 vector signed char vec_nand (vector signed char, vector bool signed char);
16181 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
16182 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
16183 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
16185 vector long long vec_orc (vector long long, vector long long);
16186 vector long long vec_orc (vector bool long long, vector long long);
16187 vector long long vec_orc (vector long long, vector bool long long);
16188 vector unsigned long long vec_orc (vector unsigned long long,
16189 vector unsigned long long);
16190 vector unsigned long long vec_orc (vector bool long long,
16191 vector unsigned long long);
16192 vector unsigned long long vec_orc (vector unsigned long long,
16193 vector bool long long);
16194 vector int vec_orc (vector int, vector int);
16195 vector int vec_orc (vector bool int, vector int);
16196 vector int vec_orc (vector int, vector bool int);
16197 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
16198 vector unsigned int vec_orc (vector bool unsigned int,
16199 vector unsigned int);
16200 vector unsigned int vec_orc (vector unsigned int,
16201 vector bool unsigned int);
16202 vector short vec_orc (vector short, vector short);
16203 vector short vec_orc (vector bool short, vector short);
16204 vector short vec_orc (vector short, vector bool short);
16205 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
16206 vector unsigned short vec_orc (vector bool unsigned short,
16207 vector unsigned short);
16208 vector unsigned short vec_orc (vector unsigned short,
16209 vector bool unsigned short);
16210 vector signed char vec_orc (vector signed char, vector signed char);
16211 vector signed char vec_orc (vector bool signed char, vector signed char);
16212 vector signed char vec_orc (vector signed char, vector bool signed char);
16213 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
16214 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
16215 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
16217 vector int vec_pack (vector long long, vector long long);
16218 vector unsigned int vec_pack (vector unsigned long long,
16219 vector unsigned long long);
16220 vector bool int vec_pack (vector bool long long, vector bool long long);
16222 vector int vec_packs (vector long long, vector long long);
16223 vector unsigned int vec_packs (vector unsigned long long,
16224 vector unsigned long long);
16226 vector unsigned int vec_packsu (vector long long, vector long long);
16227 vector unsigned int vec_packsu (vector unsigned long long,
16228 vector unsigned long long);
16230 vector long long vec_rl (vector long long,
16231 vector unsigned long long);
16232 vector long long vec_rl (vector unsigned long long,
16233 vector unsigned long long);
16235 vector long long vec_sl (vector long long, vector unsigned long long);
16236 vector long long vec_sl (vector unsigned long long,
16237 vector unsigned long long);
16239 vector long long vec_sr (vector long long, vector unsigned long long);
16240 vector unsigned long long char vec_sr (vector unsigned long long,
16241 vector unsigned long long);
16243 vector long long vec_sra (vector long long, vector unsigned long long);
16244 vector unsigned long long vec_sra (vector unsigned long long,
16245 vector unsigned long long);
16247 vector long long vec_sub (vector long long, vector long long);
16248 vector unsigned long long vec_sub (vector unsigned long long,
16249 vector unsigned long long);
16251 vector long long vec_unpackh (vector int);
16252 vector unsigned long long vec_unpackh (vector unsigned int);
16254 vector long long vec_unpackl (vector int);
16255 vector unsigned long long vec_unpackl (vector unsigned int);
16257 vector long long vec_vaddudm (vector long long, vector long long);
16258 vector long long vec_vaddudm (vector bool long long, vector long long);
16259 vector long long vec_vaddudm (vector long long, vector bool long long);
16260 vector unsigned long long vec_vaddudm (vector unsigned long long,
16261 vector unsigned long long);
16262 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
16263 vector unsigned long long);
16264 vector unsigned long long vec_vaddudm (vector unsigned long long,
16265 vector bool unsigned long long);
16267 vector long long vec_vbpermq (vector signed char, vector signed char);
16268 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
16270 vector long long vec_cntlz (vector long long);
16271 vector unsigned long long vec_cntlz (vector unsigned long long);
16272 vector int vec_cntlz (vector int);
16273 vector unsigned int vec_cntlz (vector int);
16274 vector short vec_cntlz (vector short);
16275 vector unsigned short vec_cntlz (vector unsigned short);
16276 vector signed char vec_cntlz (vector signed char);
16277 vector unsigned char vec_cntlz (vector unsigned char);
16279 vector long long vec_vclz (vector long long);
16280 vector unsigned long long vec_vclz (vector unsigned long long);
16281 vector int vec_vclz (vector int);
16282 vector unsigned int vec_vclz (vector int);
16283 vector short vec_vclz (vector short);
16284 vector unsigned short vec_vclz (vector unsigned short);
16285 vector signed char vec_vclz (vector signed char);
16286 vector unsigned char vec_vclz (vector unsigned char);
16288 vector signed char vec_vclzb (vector signed char);
16289 vector unsigned char vec_vclzb (vector unsigned char);
16291 vector long long vec_vclzd (vector long long);
16292 vector unsigned long long vec_vclzd (vector unsigned long long);
16294 vector short vec_vclzh (vector short);
16295 vector unsigned short vec_vclzh (vector unsigned short);
16297 vector int vec_vclzw (vector int);
16298 vector unsigned int vec_vclzw (vector int);
16300 vector signed char vec_vgbbd (vector signed char);
16301 vector unsigned char vec_vgbbd (vector unsigned char);
16303 vector long long vec_vmaxsd (vector long long, vector long long);
16305 vector unsigned long long vec_vmaxud (vector unsigned long long,
16306 unsigned vector long long);
16308 vector long long vec_vminsd (vector long long, vector long long);
16310 vector unsigned long long vec_vminud (vector long long,
16313 vector int vec_vpksdss (vector long long, vector long long);
16314 vector unsigned int vec_vpksdss (vector long long, vector long long);
16316 vector unsigned int vec_vpkudus (vector unsigned long long,
16317 vector unsigned long long);
16319 vector int vec_vpkudum (vector long long, vector long long);
16320 vector unsigned int vec_vpkudum (vector unsigned long long,
16321 vector unsigned long long);
16322 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
16324 vector long long vec_vpopcnt (vector long long);
16325 vector unsigned long long vec_vpopcnt (vector unsigned long long);
16326 vector int vec_vpopcnt (vector int);
16327 vector unsigned int vec_vpopcnt (vector int);
16328 vector short vec_vpopcnt (vector short);
16329 vector unsigned short vec_vpopcnt (vector unsigned short);
16330 vector signed char vec_vpopcnt (vector signed char);
16331 vector unsigned char vec_vpopcnt (vector unsigned char);
16333 vector signed char vec_vpopcntb (vector signed char);
16334 vector unsigned char vec_vpopcntb (vector unsigned char);
16336 vector long long vec_vpopcntd (vector long long);
16337 vector unsigned long long vec_vpopcntd (vector unsigned long long);
16339 vector short vec_vpopcnth (vector short);
16340 vector unsigned short vec_vpopcnth (vector unsigned short);
16342 vector int vec_vpopcntw (vector int);
16343 vector unsigned int vec_vpopcntw (vector int);
16345 vector long long vec_vrld (vector long long, vector unsigned long long);
16346 vector unsigned long long vec_vrld (vector unsigned long long,
16347 vector unsigned long long);
16349 vector long long vec_vsld (vector long long, vector unsigned long long);
16350 vector long long vec_vsld (vector unsigned long long,
16351 vector unsigned long long);
16353 vector long long vec_vsrad (vector long long, vector unsigned long long);
16354 vector unsigned long long vec_vsrad (vector unsigned long long,
16355 vector unsigned long long);
16357 vector long long vec_vsrd (vector long long, vector unsigned long long);
16358 vector unsigned long long char vec_vsrd (vector unsigned long long,
16359 vector unsigned long long);
16361 vector long long vec_vsubudm (vector long long, vector long long);
16362 vector long long vec_vsubudm (vector bool long long, vector long long);
16363 vector long long vec_vsubudm (vector long long, vector bool long long);
16364 vector unsigned long long vec_vsubudm (vector unsigned long long,
16365 vector unsigned long long);
16366 vector unsigned long long vec_vsubudm (vector bool long long,
16367 vector unsigned long long);
16368 vector unsigned long long vec_vsubudm (vector unsigned long long,
16369 vector bool long long);
16371 vector long long vec_vupkhsw (vector int);
16372 vector unsigned long long vec_vupkhsw (vector unsigned int);
16374 vector long long vec_vupklsw (vector int);
16375 vector unsigned long long vec_vupklsw (vector int);
16378 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16379 instruction set is available, the following additional functions are
16380 available for 64-bit targets. New vector types
16381 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
16382 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
16385 The normal vector extract, and set operations work on
16386 @var{vector __int128_t} and @var{vector __uint128_t} types,
16387 but the index value must be 0.
16390 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
16391 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
16393 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
16394 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
16396 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
16397 vector __int128_t);
16398 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
16399 vector __uint128_t);
16401 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
16402 vector __int128_t);
16403 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
16404 vector __uint128_t);
16406 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
16407 vector __int128_t);
16408 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
16409 vector __uint128_t);
16411 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
16412 vector __int128_t);
16413 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16414 vector __uint128_t);
16416 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16417 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16419 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16420 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16422 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16423 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16424 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16425 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16426 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16427 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16428 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16429 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16430 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16431 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16434 If the cryptographic instructions are enabled (@option{-mcrypto} or
16435 @option{-mcpu=power8}), the following builtins are enabled.
16438 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16440 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16441 vector unsigned long long);
16443 vector unsigned long long __builtin_crypto_vcipherlast
16444 (vector unsigned long long,
16445 vector unsigned long long);
16447 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16448 vector unsigned long long);
16450 vector unsigned long long __builtin_crypto_vncipherlast
16451 (vector unsigned long long,
16452 vector unsigned long long);
16454 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16455 vector unsigned char,
16456 vector unsigned char);
16458 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16459 vector unsigned short,
16460 vector unsigned short);
16462 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16463 vector unsigned int,
16464 vector unsigned int);
16466 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16467 vector unsigned long long,
16468 vector unsigned long long);
16470 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16471 vector unsigned char);
16473 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16474 vector unsigned short);
16476 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16477 vector unsigned int);
16479 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16480 vector unsigned long long);
16482 vector unsigned long long __builtin_crypto_vshasigmad
16483 (vector unsigned long long, int, int);
16485 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16489 The second argument to the @var{__builtin_crypto_vshasigmad} and
16490 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16491 integer that is 0 or 1. The third argument to these builtin functions
16492 must be a constant integer in the range of 0 to 15.
16494 @node PowerPC Hardware Transactional Memory Built-in Functions
16495 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16496 GCC provides two interfaces for accessing the Hardware Transactional
16497 Memory (HTM) instructions available on some of the PowerPC family
16498 of prcoessors (eg, POWER8). The two interfaces come in a low level
16499 interface, consisting of built-in functions specific to PowerPC and a
16500 higher level interface consisting of inline functions that are common
16501 between PowerPC and S/390.
16503 @subsubsection PowerPC HTM Low Level Built-in Functions
16505 The following low level built-in functions are available with
16506 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16507 They all generate the machine instruction that is part of the name.
16509 The HTM built-ins return true or false depending on their success and
16510 their arguments match exactly the type and order of the associated
16511 hardware instruction's operands. Refer to the ISA manual for a
16512 description of each instruction's operands.
16515 unsigned int __builtin_tbegin (unsigned int)
16516 unsigned int __builtin_tend (unsigned int)
16518 unsigned int __builtin_tabort (unsigned int)
16519 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16520 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16521 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16522 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16524 unsigned int __builtin_tcheck (unsigned int)
16525 unsigned int __builtin_treclaim (unsigned int)
16526 unsigned int __builtin_trechkpt (void)
16527 unsigned int __builtin_tsr (unsigned int)
16530 In addition to the above HTM built-ins, we have added built-ins for
16531 some common extended mnemonics of the HTM instructions:
16534 unsigned int __builtin_tendall (void)
16535 unsigned int __builtin_tresume (void)
16536 unsigned int __builtin_tsuspend (void)
16539 The following set of built-in functions are available to gain access
16540 to the HTM specific special purpose registers.
16543 unsigned long __builtin_get_texasr (void)
16544 unsigned long __builtin_get_texasru (void)
16545 unsigned long __builtin_get_tfhar (void)
16546 unsigned long __builtin_get_tfiar (void)
16548 void __builtin_set_texasr (unsigned long);
16549 void __builtin_set_texasru (unsigned long);
16550 void __builtin_set_tfhar (unsigned long);
16551 void __builtin_set_tfiar (unsigned long);
16554 Example usage of these low level built-in functions may look like:
16557 #include <htmintrin.h>
16559 int num_retries = 10;
16563 if (__builtin_tbegin (0))
16565 /* Transaction State Initiated. */
16566 if (is_locked (lock))
16567 __builtin_tabort (0);
16568 ... transaction code...
16569 __builtin_tend (0);
16574 /* Transaction State Failed. Use locks if the transaction
16575 failure is "persistent" or we've tried too many times. */
16576 if (num_retries-- <= 0
16577 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16579 acquire_lock (lock);
16580 ... non transactional fallback path...
16581 release_lock (lock);
16588 One final built-in function has been added that returns the value of
16589 the 2-bit Transaction State field of the Machine Status Register (MSR)
16590 as stored in @code{CR0}.
16593 unsigned long __builtin_ttest (void)
16596 This built-in can be used to determine the current transaction state
16597 using the following code example:
16600 #include <htmintrin.h>
16602 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16604 if (tx_state == _HTM_TRANSACTIONAL)
16606 /* Code to use in transactional state. */
16608 else if (tx_state == _HTM_NONTRANSACTIONAL)
16610 /* Code to use in non-transactional state. */
16612 else if (tx_state == _HTM_SUSPENDED)
16614 /* Code to use in transaction suspended state. */
16618 @subsubsection PowerPC HTM High Level Inline Functions
16620 The following high level HTM interface is made available by including
16621 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16622 where CPU is `power8' or later. This interface is common between PowerPC
16623 and S/390, allowing users to write one HTM source implementation that
16624 can be compiled and executed on either system.
16627 long __TM_simple_begin (void)
16628 long __TM_begin (void* const TM_buff)
16629 long __TM_end (void)
16630 void __TM_abort (void)
16631 void __TM_named_abort (unsigned char const code)
16632 void __TM_resume (void)
16633 void __TM_suspend (void)
16635 long __TM_is_user_abort (void* const TM_buff)
16636 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16637 long __TM_is_illegal (void* const TM_buff)
16638 long __TM_is_footprint_exceeded (void* const TM_buff)
16639 long __TM_nesting_depth (void* const TM_buff)
16640 long __TM_is_nested_too_deep(void* const TM_buff)
16641 long __TM_is_conflict(void* const TM_buff)
16642 long __TM_is_failure_persistent(void* const TM_buff)
16643 long __TM_failure_address(void* const TM_buff)
16644 long long __TM_failure_code(void* const TM_buff)
16647 Using these common set of HTM inline functions, we can create
16648 a more portable version of the HTM example in the previous
16649 section that will work on either PowerPC or S/390:
16652 #include <htmxlintrin.h>
16654 int num_retries = 10;
16655 TM_buff_type TM_buff;
16659 if (__TM_begin (TM_buff))
16661 /* Transaction State Initiated. */
16662 if (is_locked (lock))
16664 ... transaction code...
16670 /* Transaction State Failed. Use locks if the transaction
16671 failure is "persistent" or we've tried too many times. */
16672 if (num_retries-- <= 0
16673 || __TM_is_failure_persistent (TM_buff))
16675 acquire_lock (lock);
16676 ... non transactional fallback path...
16677 release_lock (lock);
16684 @node RX Built-in Functions
16685 @subsection RX Built-in Functions
16686 GCC supports some of the RX instructions which cannot be expressed in
16687 the C programming language via the use of built-in functions. The
16688 following functions are supported:
16690 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
16691 Generates the @code{brk} machine instruction.
16694 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
16695 Generates the @code{clrpsw} machine instruction to clear the specified
16696 bit in the processor status word.
16699 @deftypefn {Built-in Function} void __builtin_rx_int (int)
16700 Generates the @code{int} machine instruction to generate an interrupt
16701 with the specified value.
16704 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
16705 Generates the @code{machi} machine instruction to add the result of
16706 multiplying the top 16 bits of the two arguments into the
16710 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
16711 Generates the @code{maclo} machine instruction to add the result of
16712 multiplying the bottom 16 bits of the two arguments into the
16716 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
16717 Generates the @code{mulhi} machine instruction to place the result of
16718 multiplying the top 16 bits of the two arguments into the
16722 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
16723 Generates the @code{mullo} machine instruction to place the result of
16724 multiplying the bottom 16 bits of the two arguments into the
16728 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
16729 Generates the @code{mvfachi} machine instruction to read the top
16730 32 bits of the accumulator.
16733 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
16734 Generates the @code{mvfacmi} machine instruction to read the middle
16735 32 bits of the accumulator.
16738 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
16739 Generates the @code{mvfc} machine instruction which reads the control
16740 register specified in its argument and returns its value.
16743 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
16744 Generates the @code{mvtachi} machine instruction to set the top
16745 32 bits of the accumulator.
16748 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
16749 Generates the @code{mvtaclo} machine instruction to set the bottom
16750 32 bits of the accumulator.
16753 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
16754 Generates the @code{mvtc} machine instruction which sets control
16755 register number @code{reg} to @code{val}.
16758 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
16759 Generates the @code{mvtipl} machine instruction set the interrupt
16763 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
16764 Generates the @code{racw} machine instruction to round the accumulator
16765 according to the specified mode.
16768 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
16769 Generates the @code{revw} machine instruction which swaps the bytes in
16770 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16771 and also bits 16--23 occupy bits 24--31 and vice versa.
16774 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
16775 Generates the @code{rmpa} machine instruction which initiates a
16776 repeated multiply and accumulate sequence.
16779 @deftypefn {Built-in Function} void __builtin_rx_round (float)
16780 Generates the @code{round} machine instruction which returns the
16781 floating-point argument rounded according to the current rounding mode
16782 set in the floating-point status word register.
16785 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
16786 Generates the @code{sat} machine instruction which returns the
16787 saturated value of the argument.
16790 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
16791 Generates the @code{setpsw} machine instruction to set the specified
16792 bit in the processor status word.
16795 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
16796 Generates the @code{wait} machine instruction.
16799 @node S/390 System z Built-in Functions
16800 @subsection S/390 System z Built-in Functions
16801 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16802 Generates the @code{tbegin} machine instruction starting a
16803 non-constraint hardware transaction. If the parameter is non-NULL the
16804 memory area is used to store the transaction diagnostic buffer and
16805 will be passed as first operand to @code{tbegin}. This buffer can be
16806 defined using the @code{struct __htm_tdb} C struct defined in
16807 @code{htmintrin.h} and must reside on a double-word boundary. The
16808 second tbegin operand is set to @code{0xff0c}. This enables
16809 save/restore of all GPRs and disables aborts for FPR and AR
16810 manipulations inside the transaction body. The condition code set by
16811 the tbegin instruction is returned as integer value. The tbegin
16812 instruction by definition overwrites the content of all FPRs. The
16813 compiler will generate code which saves and restores the FPRs. For
16814 soft-float code it is recommended to used the @code{*_nofloat}
16815 variant. In order to prevent a TDB from being written it is required
16816 to pass an constant zero value as parameter. Passing the zero value
16817 through a variable is not sufficient. Although modifications of
16818 access registers inside the transaction will not trigger an
16819 transaction abort it is not supported to actually modify them. Access
16820 registers do not get saved when entering a transaction. They will have
16821 undefined state when reaching the abort code.
16824 Macros for the possible return codes of tbegin are defined in the
16825 @code{htmintrin.h} header file:
16828 @item _HTM_TBEGIN_STARTED
16829 @code{tbegin} has been executed as part of normal processing. The
16830 transaction body is supposed to be executed.
16831 @item _HTM_TBEGIN_INDETERMINATE
16832 The transaction was aborted due to an indeterminate condition which
16833 might be persistent.
16834 @item _HTM_TBEGIN_TRANSIENT
16835 The transaction aborted due to a transient failure. The transaction
16836 should be re-executed in that case.
16837 @item _HTM_TBEGIN_PERSISTENT
16838 The transaction aborted due to a persistent failure. Re-execution
16839 under same circumstances will not be productive.
16842 @defmac _HTM_FIRST_USER_ABORT_CODE
16843 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16844 specifies the first abort code which can be used for
16845 @code{__builtin_tabort}. Values below this threshold are reserved for
16849 @deftp {Data type} {struct __htm_tdb}
16850 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16851 the structure of the transaction diagnostic block as specified in the
16852 Principles of Operation manual chapter 5-91.
16855 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16856 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16857 Using this variant in code making use of FPRs will leave the FPRs in
16858 undefined state when entering the transaction abort handler code.
16861 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16862 In addition to @code{__builtin_tbegin} a loop for transient failures
16863 is generated. If tbegin returns a condition code of 2 the transaction
16864 will be retried as often as specified in the second argument. The
16865 perform processor assist instruction is used to tell the CPU about the
16866 number of fails so far.
16869 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16870 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16871 restores. Using this variant in code making use of FPRs will leave
16872 the FPRs in undefined state when entering the transaction abort
16876 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16877 Generates the @code{tbeginc} machine instruction starting a constraint
16878 hardware transaction. The second operand is set to @code{0xff08}.
16881 @deftypefn {Built-in Function} int __builtin_tend (void)
16882 Generates the @code{tend} machine instruction finishing a transaction
16883 and making the changes visible to other threads. The condition code
16884 generated by tend is returned as integer value.
16887 @deftypefn {Built-in Function} void __builtin_tabort (int)
16888 Generates the @code{tabort} machine instruction with the specified
16889 abort code. Abort codes from 0 through 255 are reserved and will
16890 result in an error message.
16893 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16894 Generates the @code{ppa rX,rY,1} machine instruction. Where the
16895 integer parameter is loaded into rX and a value of zero is loaded into
16896 rY. The integer parameter specifies the number of times the
16897 transaction repeatedly aborted.
16900 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16901 Generates the @code{etnd} machine instruction. The current nesting
16902 depth is returned as integer value. For a nesting depth of 0 the code
16903 is not executed as part of an transaction.
16906 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16908 Generates the @code{ntstg} machine instruction. The second argument
16909 is written to the first arguments location. The store operation will
16910 not be rolled-back in case of an transaction abort.
16913 @node SH Built-in Functions
16914 @subsection SH Built-in Functions
16915 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16916 families of processors:
16918 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16919 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
16920 used by system code that manages threads and execution contexts. The compiler
16921 normally does not generate code that modifies the contents of @samp{GBR} and
16922 thus the value is preserved across function calls. Changing the @samp{GBR}
16923 value in user code must be done with caution, since the compiler might use
16924 @samp{GBR} in order to access thread local variables.
16928 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16929 Returns the value that is currently set in the @samp{GBR} register.
16930 Memory loads and stores that use the thread pointer as a base address are
16931 turned into @samp{GBR} based displacement loads and stores, if possible.
16939 int get_tcb_value (void)
16941 // Generate @samp{mov.l @@(8,gbr),r0} instruction
16942 return ((my_tcb*)__builtin_thread_pointer ())->c;
16948 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
16949 Returns the value that is currently set in the @samp{FPSCR} register.
16952 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
16953 Sets the @samp{FPSCR} register to the specified value @var{val}, while
16954 preserving the current values of the FR, SZ and PR bits.
16957 @node SPARC VIS Built-in Functions
16958 @subsection SPARC VIS Built-in Functions
16960 GCC supports SIMD operations on the SPARC using both the generic vector
16961 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16962 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
16963 switch, the VIS extension is exposed as the following built-in functions:
16966 typedef int v1si __attribute__ ((vector_size (4)));
16967 typedef int v2si __attribute__ ((vector_size (8)));
16968 typedef short v4hi __attribute__ ((vector_size (8)));
16969 typedef short v2hi __attribute__ ((vector_size (4)));
16970 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16971 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16973 void __builtin_vis_write_gsr (int64_t);
16974 int64_t __builtin_vis_read_gsr (void);
16976 void * __builtin_vis_alignaddr (void *, long);
16977 void * __builtin_vis_alignaddrl (void *, long);
16978 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16979 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16980 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16981 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16983 v4hi __builtin_vis_fexpand (v4qi);
16985 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16986 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16987 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16988 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16989 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16990 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16991 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16993 v4qi __builtin_vis_fpack16 (v4hi);
16994 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16995 v2hi __builtin_vis_fpackfix (v2si);
16996 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16998 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
17000 long __builtin_vis_edge8 (void *, void *);
17001 long __builtin_vis_edge8l (void *, void *);
17002 long __builtin_vis_edge16 (void *, void *);
17003 long __builtin_vis_edge16l (void *, void *);
17004 long __builtin_vis_edge32 (void *, void *);
17005 long __builtin_vis_edge32l (void *, void *);
17007 long __builtin_vis_fcmple16 (v4hi, v4hi);
17008 long __builtin_vis_fcmple32 (v2si, v2si);
17009 long __builtin_vis_fcmpne16 (v4hi, v4hi);
17010 long __builtin_vis_fcmpne32 (v2si, v2si);
17011 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
17012 long __builtin_vis_fcmpgt32 (v2si, v2si);
17013 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
17014 long __builtin_vis_fcmpeq32 (v2si, v2si);
17016 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
17017 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
17018 v2si __builtin_vis_fpadd32 (v2si, v2si);
17019 v1si __builtin_vis_fpadd32s (v1si, v1si);
17020 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
17021 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
17022 v2si __builtin_vis_fpsub32 (v2si, v2si);
17023 v1si __builtin_vis_fpsub32s (v1si, v1si);
17025 long __builtin_vis_array8 (long, long);
17026 long __builtin_vis_array16 (long, long);
17027 long __builtin_vis_array32 (long, long);
17030 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
17031 functions also become available:
17034 long __builtin_vis_bmask (long, long);
17035 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
17036 v2si __builtin_vis_bshufflev2si (v2si, v2si);
17037 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
17038 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
17040 long __builtin_vis_edge8n (void *, void *);
17041 long __builtin_vis_edge8ln (void *, void *);
17042 long __builtin_vis_edge16n (void *, void *);
17043 long __builtin_vis_edge16ln (void *, void *);
17044 long __builtin_vis_edge32n (void *, void *);
17045 long __builtin_vis_edge32ln (void *, void *);
17048 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
17049 functions also become available:
17052 void __builtin_vis_cmask8 (long);
17053 void __builtin_vis_cmask16 (long);
17054 void __builtin_vis_cmask32 (long);
17056 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
17058 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
17059 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
17060 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
17061 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
17062 v2si __builtin_vis_fsll16 (v2si, v2si);
17063 v2si __builtin_vis_fslas16 (v2si, v2si);
17064 v2si __builtin_vis_fsrl16 (v2si, v2si);
17065 v2si __builtin_vis_fsra16 (v2si, v2si);
17067 long __builtin_vis_pdistn (v8qi, v8qi);
17069 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
17071 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
17072 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
17074 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
17075 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
17076 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
17077 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
17078 v2si __builtin_vis_fpadds32 (v2si, v2si);
17079 v1si __builtin_vis_fpadds32s (v1si, v1si);
17080 v2si __builtin_vis_fpsubs32 (v2si, v2si);
17081 v1si __builtin_vis_fpsubs32s (v1si, v1si);
17083 long __builtin_vis_fucmple8 (v8qi, v8qi);
17084 long __builtin_vis_fucmpne8 (v8qi, v8qi);
17085 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
17086 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
17088 float __builtin_vis_fhadds (float, float);
17089 double __builtin_vis_fhaddd (double, double);
17090 float __builtin_vis_fhsubs (float, float);
17091 double __builtin_vis_fhsubd (double, double);
17092 float __builtin_vis_fnhadds (float, float);
17093 double __builtin_vis_fnhaddd (double, double);
17095 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
17096 int64_t __builtin_vis_xmulx (int64_t, int64_t);
17097 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
17100 @node SPU Built-in Functions
17101 @subsection SPU Built-in Functions
17103 GCC provides extensions for the SPU processor as described in the
17104 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
17105 found at @uref{http://cell.scei.co.jp/} or
17106 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
17107 implementation differs in several ways.
17112 The optional extension of specifying vector constants in parentheses is
17116 A vector initializer requires no cast if the vector constant is of the
17117 same type as the variable it is initializing.
17120 If @code{signed} or @code{unsigned} is omitted, the signedness of the
17121 vector type is the default signedness of the base type. The default
17122 varies depending on the operating system, so a portable program should
17123 always specify the signedness.
17126 By default, the keyword @code{__vector} is added. The macro
17127 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
17131 GCC allows using a @code{typedef} name as the type specifier for a
17135 For C, overloaded functions are implemented with macros so the following
17139 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
17143 Since @code{spu_add} is a macro, the vector constant in the example
17144 is treated as four separate arguments. Wrap the entire argument in
17145 parentheses for this to work.
17148 The extended version of @code{__builtin_expect} is not supported.
17152 @emph{Note:} Only the interface described in the aforementioned
17153 specification is supported. Internally, GCC uses built-in functions to
17154 implement the required functionality, but these are not supported and
17155 are subject to change without notice.
17157 @node TI C6X Built-in Functions
17158 @subsection TI C6X Built-in Functions
17160 GCC provides intrinsics to access certain instructions of the TI C6X
17161 processors. These intrinsics, listed below, are available after
17162 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
17163 to C6X instructions.
17167 int _sadd (int, int)
17168 int _ssub (int, int)
17169 int _sadd2 (int, int)
17170 int _ssub2 (int, int)
17171 long long _mpy2 (int, int)
17172 long long _smpy2 (int, int)
17173 int _add4 (int, int)
17174 int _sub4 (int, int)
17175 int _saddu4 (int, int)
17177 int _smpy (int, int)
17178 int _smpyh (int, int)
17179 int _smpyhl (int, int)
17180 int _smpylh (int, int)
17182 int _sshl (int, int)
17183 int _subc (int, int)
17185 int _avg2 (int, int)
17186 int _avgu4 (int, int)
17188 int _clrr (int, int)
17189 int _extr (int, int)
17190 int _extru (int, int)
17196 @node TILE-Gx Built-in Functions
17197 @subsection TILE-Gx Built-in Functions
17199 GCC provides intrinsics to access every instruction of the TILE-Gx
17200 processor. The intrinsics are of the form:
17204 unsigned long long __insn_@var{op} (...)
17208 Where @var{op} is the name of the instruction. Refer to the ISA manual
17209 for the complete list of instructions.
17211 GCC also provides intrinsics to directly access the network registers.
17212 The intrinsics are:
17216 unsigned long long __tile_idn0_receive (void)
17217 unsigned long long __tile_idn1_receive (void)
17218 unsigned long long __tile_udn0_receive (void)
17219 unsigned long long __tile_udn1_receive (void)
17220 unsigned long long __tile_udn2_receive (void)
17221 unsigned long long __tile_udn3_receive (void)
17222 void __tile_idn_send (unsigned long long)
17223 void __tile_udn_send (unsigned long long)
17227 The intrinsic @code{void __tile_network_barrier (void)} is used to
17228 guarantee that no network operations before it are reordered with
17231 @node TILEPro Built-in Functions
17232 @subsection TILEPro Built-in Functions
17234 GCC provides intrinsics to access every instruction of the TILEPro
17235 processor. The intrinsics are of the form:
17239 unsigned __insn_@var{op} (...)
17244 where @var{op} is the name of the instruction. Refer to the ISA manual
17245 for the complete list of instructions.
17247 GCC also provides intrinsics to directly access the network registers.
17248 The intrinsics are:
17252 unsigned __tile_idn0_receive (void)
17253 unsigned __tile_idn1_receive (void)
17254 unsigned __tile_sn_receive (void)
17255 unsigned __tile_udn0_receive (void)
17256 unsigned __tile_udn1_receive (void)
17257 unsigned __tile_udn2_receive (void)
17258 unsigned __tile_udn3_receive (void)
17259 void __tile_idn_send (unsigned)
17260 void __tile_sn_send (unsigned)
17261 void __tile_udn_send (unsigned)
17265 The intrinsic @code{void __tile_network_barrier (void)} is used to
17266 guarantee that no network operations before it are reordered with
17269 @node Target Format Checks
17270 @section Format Checks Specific to Particular Target Machines
17272 For some target machines, GCC supports additional options to the
17274 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
17277 * Solaris Format Checks::
17278 * Darwin Format Checks::
17281 @node Solaris Format Checks
17282 @subsection Solaris Format Checks
17284 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
17285 check. @code{cmn_err} accepts a subset of the standard @code{printf}
17286 conversions, and the two-argument @code{%b} conversion for displaying
17287 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
17289 @node Darwin Format Checks
17290 @subsection Darwin Format Checks
17292 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
17293 attribute context. Declarations made with such attribution are parsed for correct syntax
17294 and format argument types. However, parsing of the format string itself is currently undefined
17295 and is not carried out by this version of the compiler.
17297 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
17298 also be used as format arguments. Note that the relevant headers are only likely to be
17299 available on Darwin (OSX) installations. On such installations, the XCode and system
17300 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
17301 associated functions.
17304 @section Pragmas Accepted by GCC
17306 @cindex @code{#pragma}
17308 GCC supports several types of pragmas, primarily in order to compile
17309 code originally written for other compilers. Note that in general
17310 we do not recommend the use of pragmas; @xref{Function Attributes},
17311 for further explanation.
17317 * RS/6000 and PowerPC Pragmas::
17319 * Solaris Pragmas::
17320 * Symbol-Renaming Pragmas::
17321 * Structure-Packing Pragmas::
17323 * Diagnostic Pragmas::
17324 * Visibility Pragmas::
17325 * Push/Pop Macro Pragmas::
17326 * Function Specific Option Pragmas::
17327 * Loop-Specific Pragmas::
17331 @subsection ARM Pragmas
17333 The ARM target defines pragmas for controlling the default addition of
17334 @code{long_call} and @code{short_call} attributes to functions.
17335 @xref{Function Attributes}, for information about the effects of these
17340 @cindex pragma, long_calls
17341 Set all subsequent functions to have the @code{long_call} attribute.
17343 @item no_long_calls
17344 @cindex pragma, no_long_calls
17345 Set all subsequent functions to have the @code{short_call} attribute.
17347 @item long_calls_off
17348 @cindex pragma, long_calls_off
17349 Do not affect the @code{long_call} or @code{short_call} attributes of
17350 subsequent functions.
17354 @subsection M32C Pragmas
17357 @item GCC memregs @var{number}
17358 @cindex pragma, memregs
17359 Overrides the command-line option @code{-memregs=} for the current
17360 file. Use with care! This pragma must be before any function in the
17361 file, and mixing different memregs values in different objects may
17362 make them incompatible. This pragma is useful when a
17363 performance-critical function uses a memreg for temporary values,
17364 as it may allow you to reduce the number of memregs used.
17366 @item ADDRESS @var{name} @var{address}
17367 @cindex pragma, address
17368 For any declared symbols matching @var{name}, this does three things
17369 to that symbol: it forces the symbol to be located at the given
17370 address (a number), it forces the symbol to be volatile, and it
17371 changes the symbol's scope to be static. This pragma exists for
17372 compatibility with other compilers, but note that the common
17373 @code{1234H} numeric syntax is not supported (use @code{0x1234}
17377 #pragma ADDRESS port3 0x103
17384 @subsection MeP Pragmas
17388 @item custom io_volatile (on|off)
17389 @cindex pragma, custom io_volatile
17390 Overrides the command-line option @code{-mio-volatile} for the current
17391 file. Note that for compatibility with future GCC releases, this
17392 option should only be used once before any @code{io} variables in each
17395 @item GCC coprocessor available @var{registers}
17396 @cindex pragma, coprocessor available
17397 Specifies which coprocessor registers are available to the register
17398 allocator. @var{registers} may be a single register, register range
17399 separated by ellipses, or comma-separated list of those. Example:
17402 #pragma GCC coprocessor available $c0...$c10, $c28
17405 @item GCC coprocessor call_saved @var{registers}
17406 @cindex pragma, coprocessor call_saved
17407 Specifies which coprocessor registers are to be saved and restored by
17408 any function using them. @var{registers} may be a single register,
17409 register range separated by ellipses, or comma-separated list of
17413 #pragma GCC coprocessor call_saved $c4...$c6, $c31
17416 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
17417 @cindex pragma, coprocessor subclass
17418 Creates and defines a register class. These register classes can be
17419 used by inline @code{asm} constructs. @var{registers} may be a single
17420 register, register range separated by ellipses, or comma-separated
17421 list of those. Example:
17424 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
17426 asm ("cpfoo %0" : "=B" (x));
17429 @item GCC disinterrupt @var{name} , @var{name} @dots{}
17430 @cindex pragma, disinterrupt
17431 For the named functions, the compiler adds code to disable interrupts
17432 for the duration of those functions. If any functions so named
17433 are not encountered in the source, a warning is emitted that the pragma is
17434 not used. Examples:
17437 #pragma disinterrupt foo
17438 #pragma disinterrupt bar, grill
17439 int foo () @{ @dots{} @}
17442 @item GCC call @var{name} , @var{name} @dots{}
17443 @cindex pragma, call
17444 For the named functions, the compiler always uses a register-indirect
17445 call model when calling the named functions. Examples:
17454 @node RS/6000 and PowerPC Pragmas
17455 @subsection RS/6000 and PowerPC Pragmas
17457 The RS/6000 and PowerPC targets define one pragma for controlling
17458 whether or not the @code{longcall} attribute is added to function
17459 declarations by default. This pragma overrides the @option{-mlongcall}
17460 option, but not the @code{longcall} and @code{shortcall} attributes.
17461 @xref{RS/6000 and PowerPC Options}, for more information about when long
17462 calls are and are not necessary.
17466 @cindex pragma, longcall
17467 Apply the @code{longcall} attribute to all subsequent function
17471 Do not apply the @code{longcall} attribute to subsequent function
17475 @c Describe h8300 pragmas here.
17476 @c Describe sh pragmas here.
17477 @c Describe v850 pragmas here.
17479 @node Darwin Pragmas
17480 @subsection Darwin Pragmas
17482 The following pragmas are available for all architectures running the
17483 Darwin operating system. These are useful for compatibility with other
17487 @item mark @var{tokens}@dots{}
17488 @cindex pragma, mark
17489 This pragma is accepted, but has no effect.
17491 @item options align=@var{alignment}
17492 @cindex pragma, options align
17493 This pragma sets the alignment of fields in structures. The values of
17494 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
17495 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
17496 properly; to restore the previous setting, use @code{reset} for the
17499 @item segment @var{tokens}@dots{}
17500 @cindex pragma, segment
17501 This pragma is accepted, but has no effect.
17503 @item unused (@var{var} [, @var{var}]@dots{})
17504 @cindex pragma, unused
17505 This pragma declares variables to be possibly unused. GCC does not
17506 produce warnings for the listed variables. The effect is similar to
17507 that of the @code{unused} attribute, except that this pragma may appear
17508 anywhere within the variables' scopes.
17511 @node Solaris Pragmas
17512 @subsection Solaris Pragmas
17514 The Solaris target supports @code{#pragma redefine_extname}
17515 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
17516 @code{#pragma} directives for compatibility with the system compiler.
17519 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
17520 @cindex pragma, align
17522 Increase the minimum alignment of each @var{variable} to @var{alignment}.
17523 This is the same as GCC's @code{aligned} attribute @pxref{Variable
17524 Attributes}). Macro expansion occurs on the arguments to this pragma
17525 when compiling C and Objective-C@. It does not currently occur when
17526 compiling C++, but this is a bug which may be fixed in a future
17529 @item fini (@var{function} [, @var{function}]...)
17530 @cindex pragma, fini
17532 This pragma causes each listed @var{function} to be called after
17533 main, or during shared module unloading, by adding a call to the
17534 @code{.fini} section.
17536 @item init (@var{function} [, @var{function}]...)
17537 @cindex pragma, init
17539 This pragma causes each listed @var{function} to be called during
17540 initialization (before @code{main}) or during shared module loading, by
17541 adding a call to the @code{.init} section.
17545 @node Symbol-Renaming Pragmas
17546 @subsection Symbol-Renaming Pragmas
17548 GCC supports a @code{#pragma} directive that changes the name used in
17549 assembly for a given declaration. This effect can also be achieved
17550 using the asm labels extension (@pxref{Asm Labels}).
17553 @item redefine_extname @var{oldname} @var{newname}
17554 @cindex pragma, redefine_extname
17556 This pragma gives the C function @var{oldname} the assembly symbol
17557 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
17558 is defined if this pragma is available (currently on all platforms).
17561 This pragma and the asm labels extension interact in a complicated
17562 manner. Here are some corner cases you may want to be aware of:
17565 @item This pragma silently applies only to declarations with external
17566 linkage. Asm labels do not have this restriction.
17568 @item In C++, this pragma silently applies only to declarations with
17569 ``C'' linkage. Again, asm labels do not have this restriction.
17571 @item If either of the ways of changing the assembly name of a
17572 declaration are applied to a declaration whose assembly name has
17573 already been determined (either by a previous use of one of these
17574 features, or because the compiler needed the assembly name in order to
17575 generate code), and the new name is different, a warning issues and
17576 the name does not change.
17578 @item The @var{oldname} used by @code{#pragma redefine_extname} is
17579 always the C-language name.
17582 @node Structure-Packing Pragmas
17583 @subsection Structure-Packing Pragmas
17585 For compatibility with Microsoft Windows compilers, GCC supports a
17586 set of @code{#pragma} directives that change the maximum alignment of
17587 members of structures (other than zero-width bit-fields), unions, and
17588 classes subsequently defined. The @var{n} value below always is required
17589 to be a small power of two and specifies the new alignment in bytes.
17592 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
17593 @item @code{#pragma pack()} sets the alignment to the one that was in
17594 effect when compilation started (see also command-line option
17595 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
17596 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
17597 setting on an internal stack and then optionally sets the new alignment.
17598 @item @code{#pragma pack(pop)} restores the alignment setting to the one
17599 saved at the top of the internal stack (and removes that stack entry).
17600 Note that @code{#pragma pack([@var{n}])} does not influence this internal
17601 stack; thus it is possible to have @code{#pragma pack(push)} followed by
17602 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
17603 @code{#pragma pack(pop)}.
17606 Some targets, e.g.@: x86 and PowerPC, support the @code{ms_struct}
17607 @code{#pragma} which lays out a structure as the documented
17608 @code{__attribute__ ((ms_struct))}.
17610 @item @code{#pragma ms_struct on} turns on the layout for structures
17612 @item @code{#pragma ms_struct off} turns off the layout for structures
17614 @item @code{#pragma ms_struct reset} goes back to the default layout.
17618 @subsection Weak Pragmas
17620 For compatibility with SVR4, GCC supports a set of @code{#pragma}
17621 directives for declaring symbols to be weak, and defining weak
17625 @item #pragma weak @var{symbol}
17626 @cindex pragma, weak
17627 This pragma declares @var{symbol} to be weak, as if the declaration
17628 had the attribute of the same name. The pragma may appear before
17629 or after the declaration of @var{symbol}. It is not an error for
17630 @var{symbol} to never be defined at all.
17632 @item #pragma weak @var{symbol1} = @var{symbol2}
17633 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
17634 It is an error if @var{symbol2} is not defined in the current
17638 @node Diagnostic Pragmas
17639 @subsection Diagnostic Pragmas
17641 GCC allows the user to selectively enable or disable certain types of
17642 diagnostics, and change the kind of the diagnostic. For example, a
17643 project's policy might require that all sources compile with
17644 @option{-Werror} but certain files might have exceptions allowing
17645 specific types of warnings. Or, a project might selectively enable
17646 diagnostics and treat them as errors depending on which preprocessor
17647 macros are defined.
17650 @item #pragma GCC diagnostic @var{kind} @var{option}
17651 @cindex pragma, diagnostic
17653 Modifies the disposition of a diagnostic. Note that not all
17654 diagnostics are modifiable; at the moment only warnings (normally
17655 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
17656 Use @option{-fdiagnostics-show-option} to determine which diagnostics
17657 are controllable and which option controls them.
17659 @var{kind} is @samp{error} to treat this diagnostic as an error,
17660 @samp{warning} to treat it like a warning (even if @option{-Werror} is
17661 in effect), or @samp{ignored} if the diagnostic is to be ignored.
17662 @var{option} is a double quoted string that matches the command-line
17666 #pragma GCC diagnostic warning "-Wformat"
17667 #pragma GCC diagnostic error "-Wformat"
17668 #pragma GCC diagnostic ignored "-Wformat"
17671 Note that these pragmas override any command-line options. GCC keeps
17672 track of the location of each pragma, and issues diagnostics according
17673 to the state as of that point in the source file. Thus, pragmas occurring
17674 after a line do not affect diagnostics caused by that line.
17676 @item #pragma GCC diagnostic push
17677 @itemx #pragma GCC diagnostic pop
17679 Causes GCC to remember the state of the diagnostics as of each
17680 @code{push}, and restore to that point at each @code{pop}. If a
17681 @code{pop} has no matching @code{push}, the command-line options are
17685 #pragma GCC diagnostic error "-Wuninitialized"
17686 foo(a); /* error is given for this one */
17687 #pragma GCC diagnostic push
17688 #pragma GCC diagnostic ignored "-Wuninitialized"
17689 foo(b); /* no diagnostic for this one */
17690 #pragma GCC diagnostic pop
17691 foo(c); /* error is given for this one */
17692 #pragma GCC diagnostic pop
17693 foo(d); /* depends on command-line options */
17698 GCC also offers a simple mechanism for printing messages during
17702 @item #pragma message @var{string}
17703 @cindex pragma, diagnostic
17705 Prints @var{string} as a compiler message on compilation. The message
17706 is informational only, and is neither a compilation warning nor an error.
17709 #pragma message "Compiling " __FILE__ "..."
17712 @var{string} may be parenthesized, and is printed with location
17713 information. For example,
17716 #define DO_PRAGMA(x) _Pragma (#x)
17717 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
17719 TODO(Remember to fix this)
17723 prints @samp{/tmp/file.c:4: note: #pragma message:
17724 TODO - Remember to fix this}.
17728 @node Visibility Pragmas
17729 @subsection Visibility Pragmas
17732 @item #pragma GCC visibility push(@var{visibility})
17733 @itemx #pragma GCC visibility pop
17734 @cindex pragma, visibility
17736 This pragma allows the user to set the visibility for multiple
17737 declarations without having to give each a visibility attribute
17738 (@pxref{Function Attributes}).
17740 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
17741 declarations. Class members and template specializations are not
17742 affected; if you want to override the visibility for a particular
17743 member or instantiation, you must use an attribute.
17748 @node Push/Pop Macro Pragmas
17749 @subsection Push/Pop Macro Pragmas
17751 For compatibility with Microsoft Windows compilers, GCC supports
17752 @samp{#pragma push_macro(@var{"macro_name"})}
17753 and @samp{#pragma pop_macro(@var{"macro_name"})}.
17756 @item #pragma push_macro(@var{"macro_name"})
17757 @cindex pragma, push_macro
17758 This pragma saves the value of the macro named as @var{macro_name} to
17759 the top of the stack for this macro.
17761 @item #pragma pop_macro(@var{"macro_name"})
17762 @cindex pragma, pop_macro
17763 This pragma sets the value of the macro named as @var{macro_name} to
17764 the value on top of the stack for this macro. If the stack for
17765 @var{macro_name} is empty, the value of the macro remains unchanged.
17772 #pragma push_macro("X")
17775 #pragma pop_macro("X")
17780 In this example, the definition of X as 1 is saved by @code{#pragma
17781 push_macro} and restored by @code{#pragma pop_macro}.
17783 @node Function Specific Option Pragmas
17784 @subsection Function Specific Option Pragmas
17787 @item #pragma GCC target (@var{"string"}...)
17788 @cindex pragma GCC target
17790 This pragma allows you to set target specific options for functions
17791 defined later in the source file. One or more strings can be
17792 specified. Each function that is defined after this point is as
17793 if @code{attribute((target("STRING")))} was specified for that
17794 function. The parenthesis around the options is optional.
17795 @xref{Function Attributes}, for more information about the
17796 @code{target} attribute and the attribute syntax.
17798 The @code{#pragma GCC target} pragma is presently implemented for
17799 x86, PowerPC, and Nios II targets only.
17803 @item #pragma GCC optimize (@var{"string"}...)
17804 @cindex pragma GCC optimize
17806 This pragma allows you to set global optimization options for functions
17807 defined later in the source file. One or more strings can be
17808 specified. Each function that is defined after this point is as
17809 if @code{attribute((optimize("STRING")))} was specified for that
17810 function. The parenthesis around the options is optional.
17811 @xref{Function Attributes}, for more information about the
17812 @code{optimize} attribute and the attribute syntax.
17814 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
17815 versions earlier than 4.4.
17819 @item #pragma GCC push_options
17820 @itemx #pragma GCC pop_options
17821 @cindex pragma GCC push_options
17822 @cindex pragma GCC pop_options
17824 These pragmas maintain a stack of the current target and optimization
17825 options. It is intended for include files where you temporarily want
17826 to switch to using a different @samp{#pragma GCC target} or
17827 @samp{#pragma GCC optimize} and then to pop back to the previous
17830 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
17831 pragmas are not implemented in GCC versions earlier than 4.4.
17835 @item #pragma GCC reset_options
17836 @cindex pragma GCC reset_options
17838 This pragma clears the current @code{#pragma GCC target} and
17839 @code{#pragma GCC optimize} to use the default switches as specified
17840 on the command line.
17842 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
17843 versions earlier than 4.4.
17846 @node Loop-Specific Pragmas
17847 @subsection Loop-Specific Pragmas
17850 @item #pragma GCC ivdep
17851 @cindex pragma GCC ivdep
17854 With this pragma, the programmer asserts that there are no loop-carried
17855 dependencies which would prevent that consecutive iterations of
17856 the following loop can be executed concurrently with SIMD
17857 (single instruction multiple data) instructions.
17859 For example, the compiler can only unconditionally vectorize the following
17860 loop with the pragma:
17863 void foo (int n, int *a, int *b, int *c)
17867 for (i = 0; i < n; ++i)
17868 a[i] = b[i] + c[i];
17873 In this example, using the @code{restrict} qualifier had the same
17874 effect. In the following example, that would not be possible. Assume
17875 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
17876 that it can unconditionally vectorize the following loop:
17879 void ignore_vec_dep (int *a, int k, int c, int m)
17882 for (int i = 0; i < m; i++)
17883 a[i] = a[i + k] * c;
17888 @node Unnamed Fields
17889 @section Unnamed struct/union fields within structs/unions
17890 @cindex @code{struct}
17891 @cindex @code{union}
17893 As permitted by ISO C11 and for compatibility with other compilers,
17894 GCC allows you to define
17895 a structure or union that contains, as fields, structures and unions
17896 without names. For example:
17910 In this example, you are able to access members of the unnamed
17911 union with code like @samp{foo.b}. Note that only unnamed structs and
17912 unions are allowed, you may not have, for example, an unnamed
17915 You must never create such structures that cause ambiguous field definitions.
17916 For example, in this structure:
17928 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
17929 The compiler gives errors for such constructs.
17931 @opindex fms-extensions
17932 Unless @option{-fms-extensions} is used, the unnamed field must be a
17933 structure or union definition without a tag (for example, @samp{struct
17934 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
17935 also be a definition with a tag such as @samp{struct foo @{ int a;
17936 @};}, a reference to a previously defined structure or union such as
17937 @samp{struct foo;}, or a reference to a @code{typedef} name for a
17938 previously defined structure or union type.
17940 @opindex fplan9-extensions
17941 The option @option{-fplan9-extensions} enables
17942 @option{-fms-extensions} as well as two other extensions. First, a
17943 pointer to a structure is automatically converted to a pointer to an
17944 anonymous field for assignments and function calls. For example:
17947 struct s1 @{ int a; @};
17948 struct s2 @{ struct s1; @};
17949 extern void f1 (struct s1 *);
17950 void f2 (struct s2 *p) @{ f1 (p); @}
17954 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
17955 converted into a pointer to the anonymous field.
17957 Second, when the type of an anonymous field is a @code{typedef} for a
17958 @code{struct} or @code{union}, code may refer to the field using the
17959 name of the @code{typedef}.
17962 typedef struct @{ int a; @} s1;
17963 struct s2 @{ s1; @};
17964 s1 f1 (struct s2 *p) @{ return p->s1; @}
17967 These usages are only permitted when they are not ambiguous.
17970 @section Thread-Local Storage
17971 @cindex Thread-Local Storage
17972 @cindex @acronym{TLS}
17973 @cindex @code{__thread}
17975 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
17976 are allocated such that there is one instance of the variable per extant
17977 thread. The runtime model GCC uses to implement this originates
17978 in the IA-64 processor-specific ABI, but has since been migrated
17979 to other processors as well. It requires significant support from
17980 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
17981 system libraries (@file{libc.so} and @file{libpthread.so}), so it
17982 is not available everywhere.
17984 At the user level, the extension is visible with a new storage
17985 class keyword: @code{__thread}. For example:
17989 extern __thread struct state s;
17990 static __thread char *p;
17993 The @code{__thread} specifier may be used alone, with the @code{extern}
17994 or @code{static} specifiers, but with no other storage class specifier.
17995 When used with @code{extern} or @code{static}, @code{__thread} must appear
17996 immediately after the other storage class specifier.
17998 The @code{__thread} specifier may be applied to any global, file-scoped
17999 static, function-scoped static, or static data member of a class. It may
18000 not be applied to block-scoped automatic or non-static data member.
18002 When the address-of operator is applied to a thread-local variable, it is
18003 evaluated at run time and returns the address of the current thread's
18004 instance of that variable. An address so obtained may be used by any
18005 thread. When a thread terminates, any pointers to thread-local variables
18006 in that thread become invalid.
18008 No static initialization may refer to the address of a thread-local variable.
18010 In C++, if an initializer is present for a thread-local variable, it must
18011 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
18014 See @uref{http://www.akkadia.org/drepper/tls.pdf,
18015 ELF Handling For Thread-Local Storage} for a detailed explanation of
18016 the four thread-local storage addressing models, and how the runtime
18017 is expected to function.
18020 * C99 Thread-Local Edits::
18021 * C++98 Thread-Local Edits::
18024 @node C99 Thread-Local Edits
18025 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
18027 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
18028 that document the exact semantics of the language extension.
18032 @cite{5.1.2 Execution environments}
18034 Add new text after paragraph 1
18037 Within either execution environment, a @dfn{thread} is a flow of
18038 control within a program. It is implementation defined whether
18039 or not there may be more than one thread associated with a program.
18040 It is implementation defined how threads beyond the first are
18041 created, the name and type of the function called at thread
18042 startup, and how threads may be terminated. However, objects
18043 with thread storage duration shall be initialized before thread
18048 @cite{6.2.4 Storage durations of objects}
18050 Add new text before paragraph 3
18053 An object whose identifier is declared with the storage-class
18054 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
18055 Its lifetime is the entire execution of the thread, and its
18056 stored value is initialized only once, prior to thread startup.
18060 @cite{6.4.1 Keywords}
18062 Add @code{__thread}.
18065 @cite{6.7.1 Storage-class specifiers}
18067 Add @code{__thread} to the list of storage class specifiers in
18070 Change paragraph 2 to
18073 With the exception of @code{__thread}, at most one storage-class
18074 specifier may be given [@dots{}]. The @code{__thread} specifier may
18075 be used alone, or immediately following @code{extern} or
18079 Add new text after paragraph 6
18082 The declaration of an identifier for a variable that has
18083 block scope that specifies @code{__thread} shall also
18084 specify either @code{extern} or @code{static}.
18086 The @code{__thread} specifier shall be used only with
18091 @node C++98 Thread-Local Edits
18092 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
18094 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
18095 that document the exact semantics of the language extension.
18099 @b{[intro.execution]}
18101 New text after paragraph 4
18104 A @dfn{thread} is a flow of control within the abstract machine.
18105 It is implementation defined whether or not there may be more than
18109 New text after paragraph 7
18112 It is unspecified whether additional action must be taken to
18113 ensure when and whether side effects are visible to other threads.
18119 Add @code{__thread}.
18122 @b{[basic.start.main]}
18124 Add after paragraph 5
18127 The thread that begins execution at the @code{main} function is called
18128 the @dfn{main thread}. It is implementation defined how functions
18129 beginning threads other than the main thread are designated or typed.
18130 A function so designated, as well as the @code{main} function, is called
18131 a @dfn{thread startup function}. It is implementation defined what
18132 happens if a thread startup function returns. It is implementation
18133 defined what happens to other threads when any thread calls @code{exit}.
18137 @b{[basic.start.init]}
18139 Add after paragraph 4
18142 The storage for an object of thread storage duration shall be
18143 statically initialized before the first statement of the thread startup
18144 function. An object of thread storage duration shall not require
18145 dynamic initialization.
18149 @b{[basic.start.term]}
18151 Add after paragraph 3
18154 The type of an object with thread storage duration shall not have a
18155 non-trivial destructor, nor shall it be an array type whose elements
18156 (directly or indirectly) have non-trivial destructors.
18162 Add ``thread storage duration'' to the list in paragraph 1.
18167 Thread, static, and automatic storage durations are associated with
18168 objects introduced by declarations [@dots{}].
18171 Add @code{__thread} to the list of specifiers in paragraph 3.
18174 @b{[basic.stc.thread]}
18176 New section before @b{[basic.stc.static]}
18179 The keyword @code{__thread} applied to a non-local object gives the
18180 object thread storage duration.
18182 A local variable or class data member declared both @code{static}
18183 and @code{__thread} gives the variable or member thread storage
18188 @b{[basic.stc.static]}
18193 All objects that have neither thread storage duration, dynamic
18194 storage duration nor are local [@dots{}].
18200 Add @code{__thread} to the list in paragraph 1.
18205 With the exception of @code{__thread}, at most one
18206 @var{storage-class-specifier} shall appear in a given
18207 @var{decl-specifier-seq}. The @code{__thread} specifier may
18208 be used alone, or immediately following the @code{extern} or
18209 @code{static} specifiers. [@dots{}]
18212 Add after paragraph 5
18215 The @code{__thread} specifier can be applied only to the names of objects
18216 and to anonymous unions.
18222 Add after paragraph 6
18225 Non-@code{static} members shall not be @code{__thread}.
18229 @node Binary constants
18230 @section Binary constants using the @samp{0b} prefix
18231 @cindex Binary constants using the @samp{0b} prefix
18233 Integer constants can be written as binary constants, consisting of a
18234 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
18235 @samp{0B}. This is particularly useful in environments that operate a
18236 lot on the bit level (like microcontrollers).
18238 The following statements are identical:
18247 The type of these constants follows the same rules as for octal or
18248 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
18251 @node C++ Extensions
18252 @chapter Extensions to the C++ Language
18253 @cindex extensions, C++ language
18254 @cindex C++ language extensions
18256 The GNU compiler provides these extensions to the C++ language (and you
18257 can also use most of the C language extensions in your C++ programs). If you
18258 want to write code that checks whether these features are available, you can
18259 test for the GNU compiler the same way as for C programs: check for a
18260 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
18261 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
18262 Predefined Macros,cpp,The GNU C Preprocessor}).
18265 * C++ Volatiles:: What constitutes an access to a volatile object.
18266 * Restricted Pointers:: C99 restricted pointers and references.
18267 * Vague Linkage:: Where G++ puts inlines, vtables and such.
18268 * C++ Interface:: You can use a single C++ header file for both
18269 declarations and definitions.
18270 * Template Instantiation:: Methods for ensuring that exactly one copy of
18271 each needed template instantiation is emitted.
18272 * Bound member functions:: You can extract a function pointer to the
18273 method denoted by a @samp{->*} or @samp{.*} expression.
18274 * C++ Attributes:: Variable, function, and type attributes for C++ only.
18275 * Function Multiversioning:: Declaring multiple function versions.
18276 * Namespace Association:: Strong using-directives for namespace association.
18277 * Type Traits:: Compiler support for type traits
18278 * Java Exceptions:: Tweaking exception handling to work with Java.
18279 * Deprecated Features:: Things will disappear from G++.
18280 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
18283 @node C++ Volatiles
18284 @section When is a Volatile C++ Object Accessed?
18285 @cindex accessing volatiles
18286 @cindex volatile read
18287 @cindex volatile write
18288 @cindex volatile access
18290 The C++ standard differs from the C standard in its treatment of
18291 volatile objects. It fails to specify what constitutes a volatile
18292 access, except to say that C++ should behave in a similar manner to C
18293 with respect to volatiles, where possible. However, the different
18294 lvalueness of expressions between C and C++ complicate the behavior.
18295 G++ behaves the same as GCC for volatile access, @xref{C
18296 Extensions,,Volatiles}, for a description of GCC's behavior.
18298 The C and C++ language specifications differ when an object is
18299 accessed in a void context:
18302 volatile int *src = @var{somevalue};
18306 The C++ standard specifies that such expressions do not undergo lvalue
18307 to rvalue conversion, and that the type of the dereferenced object may
18308 be incomplete. The C++ standard does not specify explicitly that it
18309 is lvalue to rvalue conversion that is responsible for causing an
18310 access. There is reason to believe that it is, because otherwise
18311 certain simple expressions become undefined. However, because it
18312 would surprise most programmers, G++ treats dereferencing a pointer to
18313 volatile object of complete type as GCC would do for an equivalent
18314 type in C@. When the object has incomplete type, G++ issues a
18315 warning; if you wish to force an error, you must force a conversion to
18316 rvalue with, for instance, a static cast.
18318 When using a reference to volatile, G++ does not treat equivalent
18319 expressions as accesses to volatiles, but instead issues a warning that
18320 no volatile is accessed. The rationale for this is that otherwise it
18321 becomes difficult to determine where volatile access occur, and not
18322 possible to ignore the return value from functions returning volatile
18323 references. Again, if you wish to force a read, cast the reference to
18326 G++ implements the same behavior as GCC does when assigning to a
18327 volatile object---there is no reread of the assigned-to object, the
18328 assigned rvalue is reused. Note that in C++ assignment expressions
18329 are lvalues, and if used as an lvalue, the volatile object is
18330 referred to. For instance, @var{vref} refers to @var{vobj}, as
18331 expected, in the following example:
18335 volatile int &vref = vobj = @var{something};
18338 @node Restricted Pointers
18339 @section Restricting Pointer Aliasing
18340 @cindex restricted pointers
18341 @cindex restricted references
18342 @cindex restricted this pointer
18344 As with the C front end, G++ understands the C99 feature of restricted pointers,
18345 specified with the @code{__restrict__}, or @code{__restrict} type
18346 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
18347 language flag, @code{restrict} is not a keyword in C++.
18349 In addition to allowing restricted pointers, you can specify restricted
18350 references, which indicate that the reference is not aliased in the local
18354 void fn (int *__restrict__ rptr, int &__restrict__ rref)
18361 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
18362 @var{rref} refers to a (different) unaliased integer.
18364 You may also specify whether a member function's @var{this} pointer is
18365 unaliased by using @code{__restrict__} as a member function qualifier.
18368 void T::fn () __restrict__
18375 Within the body of @code{T::fn}, @var{this} has the effective
18376 definition @code{T *__restrict__ const this}. Notice that the
18377 interpretation of a @code{__restrict__} member function qualifier is
18378 different to that of @code{const} or @code{volatile} qualifier, in that it
18379 is applied to the pointer rather than the object. This is consistent with
18380 other compilers that implement restricted pointers.
18382 As with all outermost parameter qualifiers, @code{__restrict__} is
18383 ignored in function definition matching. This means you only need to
18384 specify @code{__restrict__} in a function definition, rather than
18385 in a function prototype as well.
18387 @node Vague Linkage
18388 @section Vague Linkage
18389 @cindex vague linkage
18391 There are several constructs in C++ that require space in the object
18392 file but are not clearly tied to a single translation unit. We say that
18393 these constructs have ``vague linkage''. Typically such constructs are
18394 emitted wherever they are needed, though sometimes we can be more
18398 @item Inline Functions
18399 Inline functions are typically defined in a header file which can be
18400 included in many different compilations. Hopefully they can usually be
18401 inlined, but sometimes an out-of-line copy is necessary, if the address
18402 of the function is taken or if inlining fails. In general, we emit an
18403 out-of-line copy in all translation units where one is needed. As an
18404 exception, we only emit inline virtual functions with the vtable, since
18405 it always requires a copy.
18407 Local static variables and string constants used in an inline function
18408 are also considered to have vague linkage, since they must be shared
18409 between all inlined and out-of-line instances of the function.
18413 C++ virtual functions are implemented in most compilers using a lookup
18414 table, known as a vtable. The vtable contains pointers to the virtual
18415 functions provided by a class, and each object of the class contains a
18416 pointer to its vtable (or vtables, in some multiple-inheritance
18417 situations). If the class declares any non-inline, non-pure virtual
18418 functions, the first one is chosen as the ``key method'' for the class,
18419 and the vtable is only emitted in the translation unit where the key
18422 @emph{Note:} If the chosen key method is later defined as inline, the
18423 vtable is still emitted in every translation unit that defines it.
18424 Make sure that any inline virtuals are declared inline in the class
18425 body, even if they are not defined there.
18427 @item @code{type_info} objects
18428 @cindex @code{type_info}
18430 C++ requires information about types to be written out in order to
18431 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
18432 For polymorphic classes (classes with virtual functions), the @samp{type_info}
18433 object is written out along with the vtable so that @samp{dynamic_cast}
18434 can determine the dynamic type of a class object at run time. For all
18435 other types, we write out the @samp{type_info} object when it is used: when
18436 applying @samp{typeid} to an expression, throwing an object, or
18437 referring to a type in a catch clause or exception specification.
18439 @item Template Instantiations
18440 Most everything in this section also applies to template instantiations,
18441 but there are other options as well.
18442 @xref{Template Instantiation,,Where's the Template?}.
18446 When used with GNU ld version 2.8 or later on an ELF system such as
18447 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
18448 these constructs will be discarded at link time. This is known as
18451 On targets that don't support COMDAT, but do support weak symbols, GCC
18452 uses them. This way one copy overrides all the others, but
18453 the unused copies still take up space in the executable.
18455 For targets that do not support either COMDAT or weak symbols,
18456 most entities with vague linkage are emitted as local symbols to
18457 avoid duplicate definition errors from the linker. This does not happen
18458 for local statics in inlines, however, as having multiple copies
18459 almost certainly breaks things.
18461 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
18462 another way to control placement of these constructs.
18464 @node C++ Interface
18465 @section #pragma interface and implementation
18467 @cindex interface and implementation headers, C++
18468 @cindex C++ interface and implementation headers
18469 @cindex pragmas, interface and implementation
18471 @code{#pragma interface} and @code{#pragma implementation} provide the
18472 user with a way of explicitly directing the compiler to emit entities
18473 with vague linkage (and debugging information) in a particular
18476 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
18477 most cases, because of COMDAT support and the ``key method'' heuristic
18478 mentioned in @ref{Vague Linkage}. Using them can actually cause your
18479 program to grow due to unnecessary out-of-line copies of inline
18480 functions. Currently (3.4) the only benefit of these
18481 @code{#pragma}s is reduced duplication of debugging information, and
18482 that should be addressed soon on DWARF 2 targets with the use of
18486 @item #pragma interface
18487 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
18488 @kindex #pragma interface
18489 Use this directive in @emph{header files} that define object classes, to save
18490 space in most of the object files that use those classes. Normally,
18491 local copies of certain information (backup copies of inline member
18492 functions, debugging information, and the internal tables that implement
18493 virtual functions) must be kept in each object file that includes class
18494 definitions. You can use this pragma to avoid such duplication. When a
18495 header file containing @samp{#pragma interface} is included in a
18496 compilation, this auxiliary information is not generated (unless
18497 the main input source file itself uses @samp{#pragma implementation}).
18498 Instead, the object files contain references to be resolved at link
18501 The second form of this directive is useful for the case where you have
18502 multiple headers with the same name in different directories. If you
18503 use this form, you must specify the same string to @samp{#pragma
18506 @item #pragma implementation
18507 @itemx #pragma implementation "@var{objects}.h"
18508 @kindex #pragma implementation
18509 Use this pragma in a @emph{main input file}, when you want full output from
18510 included header files to be generated (and made globally visible). The
18511 included header file, in turn, should use @samp{#pragma interface}.
18512 Backup copies of inline member functions, debugging information, and the
18513 internal tables used to implement virtual functions are all generated in
18514 implementation files.
18516 @cindex implied @code{#pragma implementation}
18517 @cindex @code{#pragma implementation}, implied
18518 @cindex naming convention, implementation headers
18519 If you use @samp{#pragma implementation} with no argument, it applies to
18520 an include file with the same basename@footnote{A file's @dfn{basename}
18521 is the name stripped of all leading path information and of trailing
18522 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
18523 file. For example, in @file{allclass.cc}, giving just
18524 @samp{#pragma implementation}
18525 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
18527 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
18528 an implementation file whenever you would include it from
18529 @file{allclass.cc} even if you never specified @samp{#pragma
18530 implementation}. This was deemed to be more trouble than it was worth,
18531 however, and disabled.
18533 Use the string argument if you want a single implementation file to
18534 include code from multiple header files. (You must also use
18535 @samp{#include} to include the header file; @samp{#pragma
18536 implementation} only specifies how to use the file---it doesn't actually
18539 There is no way to split up the contents of a single header file into
18540 multiple implementation files.
18543 @cindex inlining and C++ pragmas
18544 @cindex C++ pragmas, effect on inlining
18545 @cindex pragmas in C++, effect on inlining
18546 @samp{#pragma implementation} and @samp{#pragma interface} also have an
18547 effect on function inlining.
18549 If you define a class in a header file marked with @samp{#pragma
18550 interface}, the effect on an inline function defined in that class is
18551 similar to an explicit @code{extern} declaration---the compiler emits
18552 no code at all to define an independent version of the function. Its
18553 definition is used only for inlining with its callers.
18555 @opindex fno-implement-inlines
18556 Conversely, when you include the same header file in a main source file
18557 that declares it as @samp{#pragma implementation}, the compiler emits
18558 code for the function itself; this defines a version of the function
18559 that can be found via pointers (or by callers compiled without
18560 inlining). If all calls to the function can be inlined, you can avoid
18561 emitting the function by compiling with @option{-fno-implement-inlines}.
18562 If any calls are not inlined, you will get linker errors.
18564 @node Template Instantiation
18565 @section Where's the Template?
18566 @cindex template instantiation
18568 C++ templates are the first language feature to require more
18569 intelligence from the environment than one usually finds on a UNIX
18570 system. Somehow the compiler and linker have to make sure that each
18571 template instance occurs exactly once in the executable if it is needed,
18572 and not at all otherwise. There are two basic approaches to this
18573 problem, which are referred to as the Borland model and the Cfront model.
18576 @item Borland model
18577 Borland C++ solved the template instantiation problem by adding the code
18578 equivalent of common blocks to their linker; the compiler emits template
18579 instances in each translation unit that uses them, and the linker
18580 collapses them together. The advantage of this model is that the linker
18581 only has to consider the object files themselves; there is no external
18582 complexity to worry about. This disadvantage is that compilation time
18583 is increased because the template code is being compiled repeatedly.
18584 Code written for this model tends to include definitions of all
18585 templates in the header file, since they must be seen to be
18589 The AT&T C++ translator, Cfront, solved the template instantiation
18590 problem by creating the notion of a template repository, an
18591 automatically maintained place where template instances are stored. A
18592 more modern version of the repository works as follows: As individual
18593 object files are built, the compiler places any template definitions and
18594 instantiations encountered in the repository. At link time, the link
18595 wrapper adds in the objects in the repository and compiles any needed
18596 instances that were not previously emitted. The advantages of this
18597 model are more optimal compilation speed and the ability to use the
18598 system linker; to implement the Borland model a compiler vendor also
18599 needs to replace the linker. The disadvantages are vastly increased
18600 complexity, and thus potential for error; for some code this can be
18601 just as transparent, but in practice it can been very difficult to build
18602 multiple programs in one directory and one program in multiple
18603 directories. Code written for this model tends to separate definitions
18604 of non-inline member templates into a separate file, which should be
18605 compiled separately.
18608 When used with GNU ld version 2.8 or later on an ELF system such as
18609 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
18610 Borland model. On other systems, G++ implements neither automatic
18613 You have the following options for dealing with template instantiations:
18618 Compile your template-using code with @option{-frepo}. The compiler
18619 generates files with the extension @samp{.rpo} listing all of the
18620 template instantiations used in the corresponding object files that
18621 could be instantiated there; the link wrapper, @samp{collect2},
18622 then updates the @samp{.rpo} files to tell the compiler where to place
18623 those instantiations and rebuild any affected object files. The
18624 link-time overhead is negligible after the first pass, as the compiler
18625 continues to place the instantiations in the same files.
18627 This is your best option for application code written for the Borland
18628 model, as it just works. Code written for the Cfront model
18629 needs to be modified so that the template definitions are available at
18630 one or more points of instantiation; usually this is as simple as adding
18631 @code{#include <tmethods.cc>} to the end of each template header.
18633 For library code, if you want the library to provide all of the template
18634 instantiations it needs, just try to link all of its object files
18635 together; the link will fail, but cause the instantiations to be
18636 generated as a side effect. Be warned, however, that this may cause
18637 conflicts if multiple libraries try to provide the same instantiations.
18638 For greater control, use explicit instantiation as described in the next
18642 @opindex fno-implicit-templates
18643 Compile your code with @option{-fno-implicit-templates} to disable the
18644 implicit generation of template instances, and explicitly instantiate
18645 all the ones you use. This approach requires more knowledge of exactly
18646 which instances you need than do the others, but it's less
18647 mysterious and allows greater control. You can scatter the explicit
18648 instantiations throughout your program, perhaps putting them in the
18649 translation units where the instances are used or the translation units
18650 that define the templates themselves; you can put all of the explicit
18651 instantiations you need into one big file; or you can create small files
18658 template class Foo<int>;
18659 template ostream& operator <<
18660 (ostream&, const Foo<int>&);
18664 for each of the instances you need, and create a template instantiation
18665 library from those.
18667 If you are using Cfront-model code, you can probably get away with not
18668 using @option{-fno-implicit-templates} when compiling files that don't
18669 @samp{#include} the member template definitions.
18671 If you use one big file to do the instantiations, you may want to
18672 compile it without @option{-fno-implicit-templates} so you get all of the
18673 instances required by your explicit instantiations (but not by any
18674 other files) without having to specify them as well.
18676 The ISO C++ 2011 standard allows forward declaration of explicit
18677 instantiations (with @code{extern}). G++ supports explicit instantiation
18678 declarations in C++98 mode and has extended the template instantiation
18679 syntax to support instantiation of the compiler support data for a
18680 template class (i.e.@: the vtable) without instantiating any of its
18681 members (with @code{inline}), and instantiation of only the static data
18682 members of a template class, without the support data or member
18683 functions (with @code{static}):
18686 extern template int max (int, int);
18687 inline template class Foo<int>;
18688 static template class Foo<int>;
18692 Do nothing. Pretend G++ does implement automatic instantiation
18693 management. Code written for the Borland model works fine, but
18694 each translation unit contains instances of each of the templates it
18695 uses. In a large program, this can lead to an unacceptable amount of code
18699 @node Bound member functions
18700 @section Extracting the function pointer from a bound pointer to member function
18702 @cindex pointer to member function
18703 @cindex bound pointer to member function
18705 In C++, pointer to member functions (PMFs) are implemented using a wide
18706 pointer of sorts to handle all the possible call mechanisms; the PMF
18707 needs to store information about how to adjust the @samp{this} pointer,
18708 and if the function pointed to is virtual, where to find the vtable, and
18709 where in the vtable to look for the member function. If you are using
18710 PMFs in an inner loop, you should really reconsider that decision. If
18711 that is not an option, you can extract the pointer to the function that
18712 would be called for a given object/PMF pair and call it directly inside
18713 the inner loop, to save a bit of time.
18715 Note that you still pay the penalty for the call through a
18716 function pointer; on most modern architectures, such a call defeats the
18717 branch prediction features of the CPU@. This is also true of normal
18718 virtual function calls.
18720 The syntax for this extension is
18724 extern int (A::*fp)();
18725 typedef int (*fptr)(A *);
18727 fptr p = (fptr)(a.*fp);
18730 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
18731 no object is needed to obtain the address of the function. They can be
18732 converted to function pointers directly:
18735 fptr p1 = (fptr)(&A::foo);
18738 @opindex Wno-pmf-conversions
18739 You must specify @option{-Wno-pmf-conversions} to use this extension.
18741 @node C++ Attributes
18742 @section C++-Specific Variable, Function, and Type Attributes
18744 Some attributes only make sense for C++ programs.
18747 @item abi_tag ("@var{tag}", ...)
18748 @cindex @code{abi_tag} attribute
18749 The @code{abi_tag} attribute can be applied to a function or class
18750 declaration. It modifies the mangled name of the function or class to
18751 incorporate the tag name, in order to distinguish the function or
18752 class from an earlier version with a different ABI; perhaps the class
18753 has changed size, or the function has a different return type that is
18754 not encoded in the mangled name.
18756 The argument can be a list of strings of arbitrary length. The
18757 strings are sorted on output, so the order of the list is
18760 A redeclaration of a function or class must not add new ABI tags,
18761 since doing so would change the mangled name.
18763 The ABI tags apply to a name, so all instantiations and
18764 specializations of a template have the same tags. The attribute will
18765 be ignored if applied to an explicit specialization or instantiation.
18767 The @option{-Wabi-tag} flag enables a warning about a class which does
18768 not have all the ABI tags used by its subobjects and virtual functions; for users with code
18769 that needs to coexist with an earlier ABI, using this option can help
18770 to find all affected types that need to be tagged.
18772 @item init_priority (@var{priority})
18773 @cindex @code{init_priority} attribute
18776 In Standard C++, objects defined at namespace scope are guaranteed to be
18777 initialized in an order in strict accordance with that of their definitions
18778 @emph{in a given translation unit}. No guarantee is made for initializations
18779 across translation units. However, GNU C++ allows users to control the
18780 order of initialization of objects defined at namespace scope with the
18781 @code{init_priority} attribute by specifying a relative @var{priority},
18782 a constant integral expression currently bounded between 101 and 65535
18783 inclusive. Lower numbers indicate a higher priority.
18785 In the following example, @code{A} would normally be created before
18786 @code{B}, but the @code{init_priority} attribute reverses that order:
18789 Some_Class A __attribute__ ((init_priority (2000)));
18790 Some_Class B __attribute__ ((init_priority (543)));
18794 Note that the particular values of @var{priority} do not matter; only their
18797 @item java_interface
18798 @cindex @code{java_interface} attribute
18800 This type attribute informs C++ that the class is a Java interface. It may
18801 only be applied to classes declared within an @code{extern "Java"} block.
18802 Calls to methods declared in this interface are dispatched using GCJ's
18803 interface table mechanism, instead of regular virtual table dispatch.
18806 @cindex @code{warn_unused} attribute
18808 For C++ types with non-trivial constructors and/or destructors it is
18809 impossible for the compiler to determine whether a variable of this
18810 type is truly unused if it is not referenced. This type attribute
18811 informs the compiler that variables of this type should be warned
18812 about if they appear to be unused, just like variables of fundamental
18815 This attribute is appropriate for types which just represent a value,
18816 such as @code{std::string}; it is not appropriate for types which
18817 control a resource, such as @code{std::mutex}.
18819 This attribute is also accepted in C, but it is unnecessary because C
18820 does not have constructors or destructors.
18824 See also @ref{Namespace Association}.
18826 @node Function Multiversioning
18827 @section Function Multiversioning
18828 @cindex function versions
18830 With the GNU C++ front end, for x86 targets, you may specify multiple
18831 versions of a function, where each function is specialized for a
18832 specific target feature. At runtime, the appropriate version of the
18833 function is automatically executed depending on the characteristics of
18834 the execution platform. Here is an example.
18837 __attribute__ ((target ("default")))
18840 // The default version of foo.
18844 __attribute__ ((target ("sse4.2")))
18847 // foo version for SSE4.2
18851 __attribute__ ((target ("arch=atom")))
18854 // foo version for the Intel ATOM processor
18858 __attribute__ ((target ("arch=amdfam10")))
18861 // foo version for the AMD Family 0x10 processors.
18868 assert ((*p) () == foo ());
18873 In the above example, four versions of function foo are created. The
18874 first version of foo with the target attribute "default" is the default
18875 version. This version gets executed when no other target specific
18876 version qualifies for execution on a particular platform. A new version
18877 of foo is created by using the same function signature but with a
18878 different target string. Function foo is called or a pointer to it is
18879 taken just like a regular function. GCC takes care of doing the
18880 dispatching to call the right version at runtime. Refer to the
18881 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
18882 Function Multiversioning} for more details.
18884 @node Namespace Association
18885 @section Namespace Association
18887 @strong{Caution:} The semantics of this extension are equivalent
18888 to C++ 2011 inline namespaces. Users should use inline namespaces
18889 instead as this extension will be removed in future versions of G++.
18891 A using-directive with @code{__attribute ((strong))} is stronger
18892 than a normal using-directive in two ways:
18896 Templates from the used namespace can be specialized and explicitly
18897 instantiated as though they were members of the using namespace.
18900 The using namespace is considered an associated namespace of all
18901 templates in the used namespace for purposes of argument-dependent
18905 The used namespace must be nested within the using namespace so that
18906 normal unqualified lookup works properly.
18908 This is useful for composing a namespace transparently from
18909 implementation namespaces. For example:
18914 template <class T> struct A @{ @};
18916 using namespace debug __attribute ((__strong__));
18917 template <> struct A<int> @{ @}; // @r{OK to specialize}
18919 template <class T> void f (A<T>);
18924 f (std::A<float>()); // @r{lookup finds} std::f
18930 @section Type Traits
18932 The C++ front end implements syntactic extensions that allow
18933 compile-time determination of
18934 various characteristics of a type (or of a
18938 @item __has_nothrow_assign (type)
18939 If @code{type} is const qualified or is a reference type then the trait is
18940 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
18941 is true, else if @code{type} is a cv class or union type with copy assignment
18942 operators that are known not to throw an exception then the trait is true,
18943 else it is false. Requires: @code{type} shall be a complete type,
18944 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18946 @item __has_nothrow_copy (type)
18947 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
18948 @code{type} is a cv class or union type with copy constructors that
18949 are known not to throw an exception then the trait is true, else it is false.
18950 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
18951 @code{void}, or an array of unknown bound.
18953 @item __has_nothrow_constructor (type)
18954 If @code{__has_trivial_constructor (type)} is true then the trait is
18955 true, else if @code{type} is a cv class or union type (or array
18956 thereof) with a default constructor that is known not to throw an
18957 exception then the trait is true, else it is false. Requires:
18958 @code{type} shall be a complete type, (possibly cv-qualified)
18959 @code{void}, or an array of unknown bound.
18961 @item __has_trivial_assign (type)
18962 If @code{type} is const qualified or is a reference type then the trait is
18963 false. Otherwise if @code{__is_pod (type)} is true then the trait is
18964 true, else if @code{type} is a cv class or union type with a trivial
18965 copy assignment ([class.copy]) then the trait is true, else it is
18966 false. Requires: @code{type} shall be a complete type, (possibly
18967 cv-qualified) @code{void}, or an array of unknown bound.
18969 @item __has_trivial_copy (type)
18970 If @code{__is_pod (type)} is true or @code{type} is a reference type
18971 then the trait is true, else if @code{type} is a cv class or union type
18972 with a trivial copy constructor ([class.copy]) then the trait
18973 is true, else it is false. Requires: @code{type} shall be a complete
18974 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18976 @item __has_trivial_constructor (type)
18977 If @code{__is_pod (type)} is true then the trait is true, else if
18978 @code{type} is a cv class or union type (or array thereof) with a
18979 trivial default constructor ([class.ctor]) then the trait is true,
18980 else it is false. Requires: @code{type} shall be a complete
18981 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18983 @item __has_trivial_destructor (type)
18984 If @code{__is_pod (type)} is true or @code{type} is a reference type then
18985 the trait is true, else if @code{type} is a cv class or union type (or
18986 array thereof) with a trivial destructor ([class.dtor]) then the trait
18987 is true, else it is false. Requires: @code{type} shall be a complete
18988 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18990 @item __has_virtual_destructor (type)
18991 If @code{type} is a class type with a virtual destructor
18992 ([class.dtor]) then the trait is true, else it is false. Requires:
18993 @code{type} shall be a complete type, (possibly cv-qualified)
18994 @code{void}, or an array of unknown bound.
18996 @item __is_abstract (type)
18997 If @code{type} is an abstract class ([class.abstract]) then the trait
18998 is true, else it is false. Requires: @code{type} shall be a complete
18999 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19001 @item __is_base_of (base_type, derived_type)
19002 If @code{base_type} is a base class of @code{derived_type}
19003 ([class.derived]) then the trait is true, otherwise it is false.
19004 Top-level cv qualifications of @code{base_type} and
19005 @code{derived_type} are ignored. For the purposes of this trait, a
19006 class type is considered is own base. Requires: if @code{__is_class
19007 (base_type)} and @code{__is_class (derived_type)} are true and
19008 @code{base_type} and @code{derived_type} are not the same type
19009 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
19010 type. Diagnostic is produced if this requirement is not met.
19012 @item __is_class (type)
19013 If @code{type} is a cv class type, and not a union type
19014 ([basic.compound]) the trait is true, else it is false.
19016 @item __is_empty (type)
19017 If @code{__is_class (type)} is false then the trait is false.
19018 Otherwise @code{type} is considered empty if and only if: @code{type}
19019 has no non-static data members, or all non-static data members, if
19020 any, are bit-fields of length 0, and @code{type} has no virtual
19021 members, and @code{type} has no virtual base classes, and @code{type}
19022 has no base classes @code{base_type} for which
19023 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
19024 be a complete type, (possibly cv-qualified) @code{void}, or an array
19027 @item __is_enum (type)
19028 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
19029 true, else it is false.
19031 @item __is_literal_type (type)
19032 If @code{type} is a literal type ([basic.types]) the trait is
19033 true, else it is false. Requires: @code{type} shall be a complete type,
19034 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19036 @item __is_pod (type)
19037 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
19038 else it is false. Requires: @code{type} shall be a complete type,
19039 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19041 @item __is_polymorphic (type)
19042 If @code{type} is a polymorphic class ([class.virtual]) then the trait
19043 is true, else it is false. Requires: @code{type} shall be a complete
19044 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19046 @item __is_standard_layout (type)
19047 If @code{type} is a standard-layout type ([basic.types]) the trait is
19048 true, else it is false. Requires: @code{type} shall be a complete
19049 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19051 @item __is_trivial (type)
19052 If @code{type} is a trivial type ([basic.types]) the trait is
19053 true, else it is false. Requires: @code{type} shall be a complete
19054 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19056 @item __is_union (type)
19057 If @code{type} is a cv union type ([basic.compound]) the trait is
19058 true, else it is false.
19060 @item __underlying_type (type)
19061 The underlying type of @code{type}. Requires: @code{type} shall be
19062 an enumeration type ([dcl.enum]).
19066 @node Java Exceptions
19067 @section Java Exceptions
19069 The Java language uses a slightly different exception handling model
19070 from C++. Normally, GNU C++ automatically detects when you are
19071 writing C++ code that uses Java exceptions, and handle them
19072 appropriately. However, if C++ code only needs to execute destructors
19073 when Java exceptions are thrown through it, GCC guesses incorrectly.
19074 Sample problematic code is:
19077 struct S @{ ~S(); @};
19078 extern void bar(); // @r{is written in Java, and may throw exceptions}
19087 The usual effect of an incorrect guess is a link failure, complaining of
19088 a missing routine called @samp{__gxx_personality_v0}.
19090 You can inform the compiler that Java exceptions are to be used in a
19091 translation unit, irrespective of what it might think, by writing
19092 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
19093 @samp{#pragma} must appear before any functions that throw or catch
19094 exceptions, or run destructors when exceptions are thrown through them.
19096 You cannot mix Java and C++ exceptions in the same translation unit. It
19097 is believed to be safe to throw a C++ exception from one file through
19098 another file compiled for the Java exception model, or vice versa, but
19099 there may be bugs in this area.
19101 @node Deprecated Features
19102 @section Deprecated Features
19104 In the past, the GNU C++ compiler was extended to experiment with new
19105 features, at a time when the C++ language was still evolving. Now that
19106 the C++ standard is complete, some of those features are superseded by
19107 superior alternatives. Using the old features might cause a warning in
19108 some cases that the feature will be dropped in the future. In other
19109 cases, the feature might be gone already.
19111 While the list below is not exhaustive, it documents some of the options
19112 that are now deprecated:
19115 @item -fexternal-templates
19116 @itemx -falt-external-templates
19117 These are two of the many ways for G++ to implement template
19118 instantiation. @xref{Template Instantiation}. The C++ standard clearly
19119 defines how template definitions have to be organized across
19120 implementation units. G++ has an implicit instantiation mechanism that
19121 should work just fine for standard-conforming code.
19123 @item -fstrict-prototype
19124 @itemx -fno-strict-prototype
19125 Previously it was possible to use an empty prototype parameter list to
19126 indicate an unspecified number of parameters (like C), rather than no
19127 parameters, as C++ demands. This feature has been removed, except where
19128 it is required for backwards compatibility. @xref{Backwards Compatibility}.
19131 G++ allows a virtual function returning @samp{void *} to be overridden
19132 by one returning a different pointer type. This extension to the
19133 covariant return type rules is now deprecated and will be removed from a
19136 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
19137 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
19138 and are now removed from G++. Code using these operators should be
19139 modified to use @code{std::min} and @code{std::max} instead.
19141 The named return value extension has been deprecated, and is now
19144 The use of initializer lists with new expressions has been deprecated,
19145 and is now removed from G++.
19147 Floating and complex non-type template parameters have been deprecated,
19148 and are now removed from G++.
19150 The implicit typename extension has been deprecated and is now
19153 The use of default arguments in function pointers, function typedefs
19154 and other places where they are not permitted by the standard is
19155 deprecated and will be removed from a future version of G++.
19157 G++ allows floating-point literals to appear in integral constant expressions,
19158 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
19159 This extension is deprecated and will be removed from a future version.
19161 G++ allows static data members of const floating-point type to be declared
19162 with an initializer in a class definition. The standard only allows
19163 initializers for static members of const integral types and const
19164 enumeration types so this extension has been deprecated and will be removed
19165 from a future version.
19167 @node Backwards Compatibility
19168 @section Backwards Compatibility
19169 @cindex Backwards Compatibility
19170 @cindex ARM [Annotated C++ Reference Manual]
19172 Now that there is a definitive ISO standard C++, G++ has a specification
19173 to adhere to. The C++ language evolved over time, and features that
19174 used to be acceptable in previous drafts of the standard, such as the ARM
19175 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
19176 compilation of C++ written to such drafts, G++ contains some backwards
19177 compatibilities. @emph{All such backwards compatibility features are
19178 liable to disappear in future versions of G++.} They should be considered
19179 deprecated. @xref{Deprecated Features}.
19183 If a variable is declared at for scope, it used to remain in scope until
19184 the end of the scope that contained the for statement (rather than just
19185 within the for scope). G++ retains this, but issues a warning, if such a
19186 variable is accessed outside the for scope.
19188 @item Implicit C language
19189 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
19190 scope to set the language. On such systems, all header files are
19191 implicitly scoped inside a C language scope. Also, an empty prototype
19192 @code{()} is treated as an unspecified number of arguments, rather
19193 than no arguments, as C++ demands.
19196 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
19197 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr followign