]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/extend.texi
extend.texi (Other Builtins): Add __builtin_is_constant_evaluated.
[thirdparty/gcc.git] / gcc / doc / extend.texi
1 c Copyright (C) 1988-2019 Free Software Foundation, Inc.
2
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
5
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
10
11 @opindex pedantic
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@.
17
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++.
21
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++.
24
25 @menu
26 * Statement Exprs:: Putting statements and declarations inside expressions.
27 * Local Labels:: Labels local to a block.
28 * Labels as Values:: Getting pointers to labels, and computed gotos.
29 * Nested Functions:: Nested function in GNU C.
30 * Nonlocal Gotos:: Nonlocal gotos.
31 * Constructing Calls:: Dispatching a call to another function.
32 * Typeof:: @code{typeof}: referring to the type of an expression.
33 * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
34 * __int128:: 128-bit integers---@code{__int128}.
35 * Long Long:: Double-word integers---@code{long long int}.
36 * Complex:: Data types for complex numbers.
37 * Floating Types:: Additional Floating Types.
38 * Half-Precision:: Half-Precision Floating Point.
39 * Decimal Float:: Decimal Floating Types.
40 * Hex Floats:: Hexadecimal floating-point constants.
41 * Fixed-Point:: Fixed-Point Types.
42 * Named Address Spaces::Named address spaces.
43 * Zero Length:: Zero-length arrays.
44 * Empty Structures:: Structures with no members.
45 * Variable Length:: Arrays whose length is computed at run time.
46 * Variadic Macros:: Macros with a variable number of arguments.
47 * Escaped Newlines:: Slightly looser rules for escaped newlines.
48 * Subscripting:: Any array can be subscripted, even if not an lvalue.
49 * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
50 * Pointers to Arrays:: Pointers to arrays with qualifiers work as expected.
51 * Initializers:: Non-constant initializers.
52 * Compound Literals:: Compound literals give structures, unions
53 or arrays as values.
54 * Designated Inits:: Labeling elements of initializers.
55 * Case Ranges:: `case 1 ... 9' and such.
56 * Cast to Union:: Casting to union type from any member of the union.
57 * Mixed Declarations:: Mixing declarations and code.
58 * Function Attributes:: Declaring that functions have no side effects,
59 or that they can never return.
60 * Variable Attributes:: Specifying attributes of variables.
61 * Type Attributes:: Specifying attributes of types.
62 * Label Attributes:: Specifying attributes on labels.
63 * Enumerator Attributes:: Specifying attributes on enumerators.
64 * Statement Attributes:: Specifying attributes on statements.
65 * Attribute Syntax:: Formal syntax for attributes.
66 * Function Prototypes:: Prototype declarations and old-style definitions.
67 * C++ Comments:: C++ comments are recognized.
68 * Dollar Signs:: Dollar sign is allowed in identifiers.
69 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
70 * Alignment:: Determining the alignment of a function, type or variable.
71 * Inline:: Defining inline functions (as fast as macros).
72 * Volatiles:: What constitutes an access to a volatile object.
73 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
74 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
75 * Incomplete Enums:: @code{enum foo;}, with details to follow.
76 * Function Names:: Printable strings which are the name of the current
77 function.
78 * Return Address:: Getting the return or frame address of a function.
79 * Vector Extensions:: Using vector instructions through built-in functions.
80 * Offsetof:: Special syntax for implementing @code{offsetof}.
81 * __sync Builtins:: Legacy built-in functions for atomic memory access.
82 * __atomic Builtins:: Atomic built-in functions with memory model.
83 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
84 arithmetic overflow checking.
85 * x86 specific memory model extensions for transactional memory:: x86 memory models.
86 * Object Size Checking:: Built-in functions for limited buffer overflow
87 checking.
88 * Other Builtins:: Other built-in functions.
89 * Target Builtins:: Built-in functions specific to particular targets.
90 * Target Format Checks:: Format checks specific to particular targets.
91 * Pragmas:: Pragmas accepted by GCC.
92 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
93 * Thread-Local:: Per-thread variables.
94 * Binary constants:: Binary constants using the @samp{0b} prefix.
95 @end menu
96
97 @node Statement Exprs
98 @section Statements and Declarations in Expressions
99 @cindex statements inside expressions
100 @cindex declarations inside expressions
101 @cindex expressions containing statements
102 @cindex macros, statements in expressions
103
104 @c the above section title wrapped and causes an underfull hbox.. i
105 @c changed it from "within" to "in". --mew 4feb93
106 A compound statement enclosed in parentheses may appear as an expression
107 in GNU C@. This allows you to use loops, switches, and local variables
108 within an expression.
109
110 Recall that a compound statement is a sequence of statements surrounded
111 by braces; in this construct, parentheses go around the braces. For
112 example:
113
114 @smallexample
115 (@{ int y = foo (); int z;
116 if (y > 0) z = y;
117 else z = - y;
118 z; @})
119 @end smallexample
120
121 @noindent
122 is a valid (though slightly more complex than necessary) expression
123 for the absolute value of @code{foo ()}.
124
125 The last thing in the compound statement should be an expression
126 followed by a semicolon; the value of this subexpression serves as the
127 value of the entire construct. (If you use some other kind of statement
128 last within the braces, the construct has type @code{void}, and thus
129 effectively no value.)
130
131 This feature is especially useful in making macro definitions ``safe'' (so
132 that they evaluate each operand exactly once). For example, the
133 ``maximum'' function is commonly defined as a macro in standard C as
134 follows:
135
136 @smallexample
137 #define max(a,b) ((a) > (b) ? (a) : (b))
138 @end smallexample
139
140 @noindent
141 @cindex side effects, macro argument
142 But this definition computes either @var{a} or @var{b} twice, with bad
143 results if the operand has side effects. In GNU C, if you know the
144 type of the operands (here taken as @code{int}), you can define
145 the macro safely as follows:
146
147 @smallexample
148 #define maxint(a,b) \
149 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
150 @end smallexample
151
152 Embedded statements are not allowed in constant expressions, such as
153 the value of an enumeration constant, the width of a bit-field, or
154 the initial value of a static variable.
155
156 If you don't know the type of the operand, you can still do this, but you
157 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
158
159 In G++, the result value of a statement expression undergoes array and
160 function pointer decay, and is returned by value to the enclosing
161 expression. For instance, if @code{A} is a class, then
162
163 @smallexample
164 A a;
165
166 (@{a;@}).Foo ()
167 @end smallexample
168
169 @noindent
170 constructs a temporary @code{A} object to hold the result of the
171 statement expression, and that is used to invoke @code{Foo}.
172 Therefore the @code{this} pointer observed by @code{Foo} is not the
173 address of @code{a}.
174
175 In a statement expression, any temporaries created within a statement
176 are destroyed at that statement's end. This makes statement
177 expressions inside macros slightly different from function calls. In
178 the latter case temporaries introduced during argument evaluation are
179 destroyed at the end of the statement that includes the function
180 call. In the statement expression case they are destroyed during
181 the statement expression. For instance,
182
183 @smallexample
184 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
185 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
186
187 void foo ()
188 @{
189 macro (X ());
190 function (X ());
191 @}
192 @end smallexample
193
194 @noindent
195 has different places where temporaries are destroyed. For the
196 @code{macro} case, the temporary @code{X} is destroyed just after
197 the initialization of @code{b}. In the @code{function} case that
198 temporary is destroyed when the function returns.
199
200 These considerations mean that it is probably a bad idea to use
201 statement expressions of this form in header files that are designed to
202 work with C++. (Note that some versions of the GNU C Library contained
203 header files using statement expressions that lead to precisely this
204 bug.)
205
206 Jumping into a statement expression with @code{goto} or using a
207 @code{switch} statement outside the statement expression with a
208 @code{case} or @code{default} label inside the statement expression is
209 not permitted. Jumping into a statement expression with a computed
210 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
211 Jumping out of a statement expression is permitted, but if the
212 statement expression is part of a larger expression then it is
213 unspecified which other subexpressions of that expression have been
214 evaluated except where the language definition requires certain
215 subexpressions to be evaluated before or after the statement
216 expression. A @code{break} or @code{continue} statement inside of
217 a statement expression used in @code{while}, @code{do} or @code{for}
218 loop or @code{switch} statement condition
219 or @code{for} statement init or increment expressions jumps to an
220 outer loop or @code{switch} statement if any (otherwise it is an error),
221 rather than to the loop or @code{switch} statement in whose condition
222 or init or increment expression it appears.
223 In any case, as with a function call, the evaluation of a
224 statement expression is not interleaved with the evaluation of other
225 parts of the containing expression. For example,
226
227 @smallexample
228 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
229 @end smallexample
230
231 @noindent
232 calls @code{foo} and @code{bar1} and does not call @code{baz} but
233 may or may not call @code{bar2}. If @code{bar2} is called, it is
234 called after @code{foo} and before @code{bar1}.
235
236 @node Local Labels
237 @section Locally Declared Labels
238 @cindex local labels
239 @cindex macros, local labels
240
241 GCC allows you to declare @dfn{local labels} in any nested block
242 scope. A local label is just like an ordinary label, but you can
243 only reference it (with a @code{goto} statement, or by taking its
244 address) within the block in which it is declared.
245
246 A local label declaration looks like this:
247
248 @smallexample
249 __label__ @var{label};
250 @end smallexample
251
252 @noindent
253 or
254
255 @smallexample
256 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
257 @end smallexample
258
259 Local label declarations must come at the beginning of the block,
260 before any ordinary declarations or statements.
261
262 The label declaration defines the label @emph{name}, but does not define
263 the label itself. You must do this in the usual way, with
264 @code{@var{label}:}, within the statements of the statement expression.
265
266 The local label feature is useful for complex macros. If a macro
267 contains nested loops, a @code{goto} can be useful for breaking out of
268 them. However, an ordinary label whose scope is the whole function
269 cannot be used: if the macro can be expanded several times in one
270 function, the label is multiply defined in that function. A
271 local label avoids this problem. For example:
272
273 @smallexample
274 #define SEARCH(value, array, target) \
275 do @{ \
276 __label__ found; \
277 typeof (target) _SEARCH_target = (target); \
278 typeof (*(array)) *_SEARCH_array = (array); \
279 int i, j; \
280 int value; \
281 for (i = 0; i < max; i++) \
282 for (j = 0; j < max; j++) \
283 if (_SEARCH_array[i][j] == _SEARCH_target) \
284 @{ (value) = i; goto found; @} \
285 (value) = -1; \
286 found:; \
287 @} while (0)
288 @end smallexample
289
290 This could also be written using a statement expression:
291
292 @smallexample
293 #define SEARCH(array, target) \
294 (@{ \
295 __label__ found; \
296 typeof (target) _SEARCH_target = (target); \
297 typeof (*(array)) *_SEARCH_array = (array); \
298 int i, j; \
299 int value; \
300 for (i = 0; i < max; i++) \
301 for (j = 0; j < max; j++) \
302 if (_SEARCH_array[i][j] == _SEARCH_target) \
303 @{ value = i; goto found; @} \
304 value = -1; \
305 found: \
306 value; \
307 @})
308 @end smallexample
309
310 Local label declarations also make the labels they declare visible to
311 nested functions, if there are any. @xref{Nested Functions}, for details.
312
313 @node Labels as Values
314 @section Labels as Values
315 @cindex labels as values
316 @cindex computed gotos
317 @cindex goto with computed label
318 @cindex address of a label
319
320 You can get the address of a label defined in the current function
321 (or a containing function) with the unary operator @samp{&&}. The
322 value has type @code{void *}. This value is a constant and can be used
323 wherever a constant of that type is valid. For example:
324
325 @smallexample
326 void *ptr;
327 /* @r{@dots{}} */
328 ptr = &&foo;
329 @end smallexample
330
331 To use these values, you need to be able to jump to one. This is done
332 with the computed goto statement@footnote{The analogous feature in
333 Fortran is called an assigned goto, but that name seems inappropriate in
334 C, where one can do more than simply store label addresses in label
335 variables.}, @code{goto *@var{exp};}. For example,
336
337 @smallexample
338 goto *ptr;
339 @end smallexample
340
341 @noindent
342 Any expression of type @code{void *} is allowed.
343
344 One way of using these constants is in initializing a static array that
345 serves as a jump table:
346
347 @smallexample
348 static void *array[] = @{ &&foo, &&bar, &&hack @};
349 @end smallexample
350
351 @noindent
352 Then you can select a label with indexing, like this:
353
354 @smallexample
355 goto *array[i];
356 @end smallexample
357
358 @noindent
359 Note that this does not check whether the subscript is in bounds---array
360 indexing in C never does that.
361
362 Such an array of label values serves a purpose much like that of the
363 @code{switch} statement. The @code{switch} statement is cleaner, so
364 use that rather than an array unless the problem does not fit a
365 @code{switch} statement very well.
366
367 Another use of label values is in an interpreter for threaded code.
368 The labels within the interpreter function can be stored in the
369 threaded code for super-fast dispatching.
370
371 You may not use this mechanism to jump to code in a different function.
372 If you do that, totally unpredictable things happen. The best way to
373 avoid this is to store the label address only in automatic variables and
374 never pass it as an argument.
375
376 An alternate way to write the above example is
377
378 @smallexample
379 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
380 &&hack - &&foo @};
381 goto *(&&foo + array[i]);
382 @end smallexample
383
384 @noindent
385 This is more friendly to code living in shared libraries, as it reduces
386 the number of dynamic relocations that are needed, and by consequence,
387 allows the data to be read-only.
388 This alternative with label differences is not supported for the AVR target,
389 please use the first approach for AVR programs.
390
391 The @code{&&foo} expressions for the same label might have different
392 values if the containing function is inlined or cloned. If a program
393 relies on them being always the same,
394 @code{__attribute__((__noinline__,__noclone__))} should be used to
395 prevent inlining and cloning. If @code{&&foo} is used in a static
396 variable initializer, inlining and cloning is forbidden.
397
398 @node Nested Functions
399 @section Nested Functions
400 @cindex nested functions
401 @cindex downward funargs
402 @cindex thunks
403
404 A @dfn{nested function} is a function defined inside another function.
405 Nested functions are supported as an extension in GNU C, but are not
406 supported by GNU C++.
407
408 The nested function's name is local to the block where it is defined.
409 For example, here we define a nested function named @code{square}, and
410 call it twice:
411
412 @smallexample
413 @group
414 foo (double a, double b)
415 @{
416 double square (double z) @{ return z * z; @}
417
418 return square (a) + square (b);
419 @}
420 @end group
421 @end smallexample
422
423 The nested function can access all the variables of the containing
424 function that are visible at the point of its definition. This is
425 called @dfn{lexical scoping}. For example, here we show a nested
426 function which uses an inherited variable named @code{offset}:
427
428 @smallexample
429 @group
430 bar (int *array, int offset, int size)
431 @{
432 int access (int *array, int index)
433 @{ return array[index + offset]; @}
434 int i;
435 /* @r{@dots{}} */
436 for (i = 0; i < size; i++)
437 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
438 @}
439 @end group
440 @end smallexample
441
442 Nested function definitions are permitted within functions in the places
443 where variable definitions are allowed; that is, in any block, mixed
444 with the other declarations and statements in the block.
445
446 It is possible to call the nested function from outside the scope of its
447 name by storing its address or passing the address to another function:
448
449 @smallexample
450 hack (int *array, int size)
451 @{
452 void store (int index, int value)
453 @{ array[index] = value; @}
454
455 intermediate (store, size);
456 @}
457 @end smallexample
458
459 Here, the function @code{intermediate} receives the address of
460 @code{store} as an argument. If @code{intermediate} calls @code{store},
461 the arguments given to @code{store} are used to store into @code{array}.
462 But this technique works only so long as the containing function
463 (@code{hack}, in this example) does not exit.
464
465 If you try to call the nested function through its address after the
466 containing function exits, all hell breaks loose. If you try
467 to call it after a containing scope level exits, and if it refers
468 to some of the variables that are no longer in scope, you may be lucky,
469 but it's not wise to take the risk. If, however, the nested function
470 does not refer to anything that has gone out of scope, you should be
471 safe.
472
473 GCC implements taking the address of a nested function using a technique
474 called @dfn{trampolines}. This technique was described in
475 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
476 C++ Conference Proceedings, October 17-21, 1988).
477
478 A nested function can jump to a label inherited from a containing
479 function, provided the label is explicitly declared in the containing
480 function (@pxref{Local Labels}). Such a jump returns instantly to the
481 containing function, exiting the nested function that did the
482 @code{goto} and any intermediate functions as well. Here is an example:
483
484 @smallexample
485 @group
486 bar (int *array, int offset, int size)
487 @{
488 __label__ failure;
489 int access (int *array, int index)
490 @{
491 if (index > size)
492 goto failure;
493 return array[index + offset];
494 @}
495 int i;
496 /* @r{@dots{}} */
497 for (i = 0; i < size; i++)
498 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
499 /* @r{@dots{}} */
500 return 0;
501
502 /* @r{Control comes here from @code{access}
503 if it detects an error.} */
504 failure:
505 return -1;
506 @}
507 @end group
508 @end smallexample
509
510 A nested function always has no linkage. Declaring one with
511 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
512 before its definition, use @code{auto} (which is otherwise meaningless
513 for function declarations).
514
515 @smallexample
516 bar (int *array, int offset, int size)
517 @{
518 __label__ failure;
519 auto int access (int *, int);
520 /* @r{@dots{}} */
521 int access (int *array, int index)
522 @{
523 if (index > size)
524 goto failure;
525 return array[index + offset];
526 @}
527 /* @r{@dots{}} */
528 @}
529 @end smallexample
530
531 @node Nonlocal Gotos
532 @section Nonlocal Gotos
533 @cindex nonlocal gotos
534
535 GCC provides the built-in functions @code{__builtin_setjmp} and
536 @code{__builtin_longjmp} which are similar to, but not interchangeable
537 with, the C library functions @code{setjmp} and @code{longjmp}.
538 The built-in versions are used internally by GCC's libraries
539 to implement exception handling on some targets. You should use the
540 standard C library functions declared in @code{<setjmp.h>} in user code
541 instead of the builtins.
542
543 The built-in versions of these functions use GCC's normal
544 mechanisms to save and restore registers using the stack on function
545 entry and exit. The jump buffer argument @var{buf} holds only the
546 information needed to restore the stack frame, rather than the entire
547 set of saved register values.
548
549 An important caveat is that GCC arranges to save and restore only
550 those registers known to the specific architecture variant being
551 compiled for. This can make @code{__builtin_setjmp} and
552 @code{__builtin_longjmp} more efficient than their library
553 counterparts in some cases, but it can also cause incorrect and
554 mysterious behavior when mixing with code that uses the full register
555 set.
556
557 You should declare the jump buffer argument @var{buf} to the
558 built-in functions as:
559
560 @smallexample
561 #include <stdint.h>
562 intptr_t @var{buf}[5];
563 @end smallexample
564
565 @deftypefn {Built-in Function} {int} __builtin_setjmp (intptr_t *@var{buf})
566 This function saves the current stack context in @var{buf}.
567 @code{__builtin_setjmp} returns 0 when returning directly,
568 and 1 when returning from @code{__builtin_longjmp} using the same
569 @var{buf}.
570 @end deftypefn
571
572 @deftypefn {Built-in Function} {void} __builtin_longjmp (intptr_t *@var{buf}, int @var{val})
573 This function restores the stack context in @var{buf},
574 saved by a previous call to @code{__builtin_setjmp}. After
575 @code{__builtin_longjmp} is finished, the program resumes execution as
576 if the matching @code{__builtin_setjmp} returns the value @var{val},
577 which must be 1.
578
579 Because @code{__builtin_longjmp} depends on the function return
580 mechanism to restore the stack context, it cannot be called
581 from the same function calling @code{__builtin_setjmp} to
582 initialize @var{buf}. It can only be called from a function called
583 (directly or indirectly) from the function calling @code{__builtin_setjmp}.
584 @end deftypefn
585
586 @node Constructing Calls
587 @section Constructing Function Calls
588 @cindex constructing calls
589 @cindex forwarding calls
590
591 Using the built-in functions described below, you can record
592 the arguments a function received, and call another function
593 with the same arguments, without knowing the number or types
594 of the arguments.
595
596 You can also record the return value of that function call,
597 and later return that value, without knowing what data type
598 the function tried to return (as long as your caller expects
599 that data type).
600
601 However, these built-in functions may interact badly with some
602 sophisticated features or other extensions of the language. It
603 is, therefore, not recommended to use them outside very simple
604 functions acting as mere forwarders for their arguments.
605
606 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
607 This built-in function returns a pointer to data
608 describing how to perform a call with the same arguments as are passed
609 to the current function.
610
611 The function saves the arg pointer register, structure value address,
612 and all registers that might be used to pass arguments to a function
613 into a block of memory allocated on the stack. Then it returns the
614 address of that block.
615 @end deftypefn
616
617 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
618 This built-in function invokes @var{function}
619 with a copy of the parameters described by @var{arguments}
620 and @var{size}.
621
622 The value of @var{arguments} should be the value returned by
623 @code{__builtin_apply_args}. The argument @var{size} specifies the size
624 of the stack argument data, in bytes.
625
626 This function returns a pointer to data describing
627 how to return whatever value is returned by @var{function}. The data
628 is saved in a block of memory allocated on the stack.
629
630 It is not always simple to compute the proper value for @var{size}. The
631 value is used by @code{__builtin_apply} to compute the amount of data
632 that should be pushed on the stack and copied from the incoming argument
633 area.
634 @end deftypefn
635
636 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
637 This built-in function returns the value described by @var{result} from
638 the containing function. You should specify, for @var{result}, a value
639 returned by @code{__builtin_apply}.
640 @end deftypefn
641
642 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
643 This built-in function represents all anonymous arguments of an inline
644 function. It can be used only in inline functions that are always
645 inlined, never compiled as a separate function, such as those using
646 @code{__attribute__ ((__always_inline__))} or
647 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
648 It must be only passed as last argument to some other function
649 with variable arguments. This is useful for writing small wrapper
650 inlines for variable argument functions, when using preprocessor
651 macros is undesirable. For example:
652 @smallexample
653 extern int myprintf (FILE *f, const char *format, ...);
654 extern inline __attribute__ ((__gnu_inline__)) int
655 myprintf (FILE *f, const char *format, ...)
656 @{
657 int r = fprintf (f, "myprintf: ");
658 if (r < 0)
659 return r;
660 int s = fprintf (f, format, __builtin_va_arg_pack ());
661 if (s < 0)
662 return s;
663 return r + s;
664 @}
665 @end smallexample
666 @end deftypefn
667
668 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
669 This built-in function returns the number of anonymous arguments of
670 an inline function. It can be used only in inline functions that
671 are always inlined, never compiled as a separate function, such
672 as those using @code{__attribute__ ((__always_inline__))} or
673 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
674 For example following does link- or run-time checking of open
675 arguments for optimized code:
676 @smallexample
677 #ifdef __OPTIMIZE__
678 extern inline __attribute__((__gnu_inline__)) int
679 myopen (const char *path, int oflag, ...)
680 @{
681 if (__builtin_va_arg_pack_len () > 1)
682 warn_open_too_many_arguments ();
683
684 if (__builtin_constant_p (oflag))
685 @{
686 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
687 @{
688 warn_open_missing_mode ();
689 return __open_2 (path, oflag);
690 @}
691 return open (path, oflag, __builtin_va_arg_pack ());
692 @}
693
694 if (__builtin_va_arg_pack_len () < 1)
695 return __open_2 (path, oflag);
696
697 return open (path, oflag, __builtin_va_arg_pack ());
698 @}
699 #endif
700 @end smallexample
701 @end deftypefn
702
703 @node Typeof
704 @section Referring to a Type with @code{typeof}
705 @findex typeof
706 @findex sizeof
707 @cindex macros, types of arguments
708
709 Another way to refer to the type of an expression is with @code{typeof}.
710 The syntax of using of this keyword looks like @code{sizeof}, but the
711 construct acts semantically like a type name defined with @code{typedef}.
712
713 There are two ways of writing the argument to @code{typeof}: with an
714 expression or with a type. Here is an example with an expression:
715
716 @smallexample
717 typeof (x[0](1))
718 @end smallexample
719
720 @noindent
721 This assumes that @code{x} is an array of pointers to functions;
722 the type described is that of the values of the functions.
723
724 Here is an example with a typename as the argument:
725
726 @smallexample
727 typeof (int *)
728 @end smallexample
729
730 @noindent
731 Here the type described is that of pointers to @code{int}.
732
733 If you are writing a header file that must work when included in ISO C
734 programs, write @code{__typeof__} instead of @code{typeof}.
735 @xref{Alternate Keywords}.
736
737 A @code{typeof} construct can be used anywhere a typedef name can be
738 used. For example, you can use it in a declaration, in a cast, or inside
739 of @code{sizeof} or @code{typeof}.
740
741 The operand of @code{typeof} is evaluated for its side effects if and
742 only if it is an expression of variably modified type or the name of
743 such a type.
744
745 @code{typeof} is often useful in conjunction with
746 statement expressions (@pxref{Statement Exprs}).
747 Here is how the two together can
748 be used to define a safe ``maximum'' macro which operates on any
749 arithmetic type and evaluates each of its arguments exactly once:
750
751 @smallexample
752 #define max(a,b) \
753 (@{ typeof (a) _a = (a); \
754 typeof (b) _b = (b); \
755 _a > _b ? _a : _b; @})
756 @end smallexample
757
758 @cindex underscores in variables in macros
759 @cindex @samp{_} in variables in macros
760 @cindex local variables in macros
761 @cindex variables, local, in macros
762 @cindex macros, local variables in
763
764 The reason for using names that start with underscores for the local
765 variables is to avoid conflicts with variable names that occur within the
766 expressions that are substituted for @code{a} and @code{b}. Eventually we
767 hope to design a new form of declaration syntax that allows you to declare
768 variables whose scopes start only after their initializers; this will be a
769 more reliable way to prevent such conflicts.
770
771 @noindent
772 Some more examples of the use of @code{typeof}:
773
774 @itemize @bullet
775 @item
776 This declares @code{y} with the type of what @code{x} points to.
777
778 @smallexample
779 typeof (*x) y;
780 @end smallexample
781
782 @item
783 This declares @code{y} as an array of such values.
784
785 @smallexample
786 typeof (*x) y[4];
787 @end smallexample
788
789 @item
790 This declares @code{y} as an array of pointers to characters:
791
792 @smallexample
793 typeof (typeof (char *)[4]) y;
794 @end smallexample
795
796 @noindent
797 It is equivalent to the following traditional C declaration:
798
799 @smallexample
800 char *y[4];
801 @end smallexample
802
803 To see the meaning of the declaration using @code{typeof}, and why it
804 might be a useful way to write, rewrite it with these macros:
805
806 @smallexample
807 #define pointer(T) typeof(T *)
808 #define array(T, N) typeof(T [N])
809 @end smallexample
810
811 @noindent
812 Now the declaration can be rewritten this way:
813
814 @smallexample
815 array (pointer (char), 4) y;
816 @end smallexample
817
818 @noindent
819 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
820 pointers to @code{char}.
821 @end itemize
822
823 In GNU C, but not GNU C++, you may also declare the type of a variable
824 as @code{__auto_type}. In that case, the declaration must declare
825 only one variable, whose declarator must just be an identifier, the
826 declaration must be initialized, and the type of the variable is
827 determined by the initializer; the name of the variable is not in
828 scope until after the initializer. (In C++, you should use C++11
829 @code{auto} for this purpose.) Using @code{__auto_type}, the
830 ``maximum'' macro above could be written as:
831
832 @smallexample
833 #define max(a,b) \
834 (@{ __auto_type _a = (a); \
835 __auto_type _b = (b); \
836 _a > _b ? _a : _b; @})
837 @end smallexample
838
839 Using @code{__auto_type} instead of @code{typeof} has two advantages:
840
841 @itemize @bullet
842 @item Each argument to the macro appears only once in the expansion of
843 the macro. This prevents the size of the macro expansion growing
844 exponentially when calls to such macros are nested inside arguments of
845 such macros.
846
847 @item If the argument to the macro has variably modified type, it is
848 evaluated only once when using @code{__auto_type}, but twice if
849 @code{typeof} is used.
850 @end itemize
851
852 @node Conditionals
853 @section Conditionals with Omitted Operands
854 @cindex conditional expressions, extensions
855 @cindex omitted middle-operands
856 @cindex middle-operands, omitted
857 @cindex extensions, @code{?:}
858 @cindex @code{?:} extensions
859
860 The middle operand in a conditional expression may be omitted. Then
861 if the first operand is nonzero, its value is the value of the conditional
862 expression.
863
864 Therefore, the expression
865
866 @smallexample
867 x ? : y
868 @end smallexample
869
870 @noindent
871 has the value of @code{x} if that is nonzero; otherwise, the value of
872 @code{y}.
873
874 This example is perfectly equivalent to
875
876 @smallexample
877 x ? x : y
878 @end smallexample
879
880 @cindex side effect in @code{?:}
881 @cindex @code{?:} side effect
882 @noindent
883 In this simple case, the ability to omit the middle operand is not
884 especially useful. When it becomes useful is when the first operand does,
885 or may (if it is a macro argument), contain a side effect. Then repeating
886 the operand in the middle would perform the side effect twice. Omitting
887 the middle operand uses the value already computed without the undesirable
888 effects of recomputing it.
889
890 @node __int128
891 @section 128-bit Integers
892 @cindex @code{__int128} data types
893
894 As an extension the integer scalar type @code{__int128} is supported for
895 targets which have an integer mode wide enough to hold 128 bits.
896 Simply write @code{__int128} for a signed 128-bit integer, or
897 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
898 support in GCC for expressing an integer constant of type @code{__int128}
899 for targets with @code{long long} integer less than 128 bits wide.
900
901 @node Long Long
902 @section Double-Word Integers
903 @cindex @code{long long} data types
904 @cindex double-word arithmetic
905 @cindex multiprecision arithmetic
906 @cindex @code{LL} integer suffix
907 @cindex @code{ULL} integer suffix
908
909 ISO C99 and ISO C++11 support data types for integers that are at least
910 64 bits wide, and as an extension GCC supports them in C90 and C++98 modes.
911 Simply write @code{long long int} for a signed integer, or
912 @code{unsigned long long int} for an unsigned integer. To make an
913 integer constant of type @code{long long int}, add the suffix @samp{LL}
914 to the integer. To make an integer constant of type @code{unsigned long
915 long int}, add the suffix @samp{ULL} to the integer.
916
917 You can use these types in arithmetic like any other integer types.
918 Addition, subtraction, and bitwise boolean operations on these types
919 are open-coded on all types of machines. Multiplication is open-coded
920 if the machine supports a fullword-to-doubleword widening multiply
921 instruction. Division and shifts are open-coded only on machines that
922 provide special support. The operations that are not open-coded use
923 special library routines that come with GCC@.
924
925 There may be pitfalls when you use @code{long long} types for function
926 arguments without function prototypes. If a function
927 expects type @code{int} for its argument, and you pass a value of type
928 @code{long long int}, confusion results because the caller and the
929 subroutine disagree about the number of bytes for the argument.
930 Likewise, if the function expects @code{long long int} and you pass
931 @code{int}. The best way to avoid such problems is to use prototypes.
932
933 @node Complex
934 @section Complex Numbers
935 @cindex complex numbers
936 @cindex @code{_Complex} keyword
937 @cindex @code{__complex__} keyword
938
939 ISO C99 supports complex floating data types, and as an extension GCC
940 supports them in C90 mode and in C++. GCC also supports complex integer data
941 types which are not part of ISO C99. You can declare complex types
942 using the keyword @code{_Complex}. As an extension, the older GNU
943 keyword @code{__complex__} is also supported.
944
945 For example, @samp{_Complex double x;} declares @code{x} as a
946 variable whose real part and imaginary part are both of type
947 @code{double}. @samp{_Complex short int y;} declares @code{y} to
948 have real and imaginary parts of type @code{short int}; this is not
949 likely to be useful, but it shows that the set of complex types is
950 complete.
951
952 To write a constant with a complex data type, use the suffix @samp{i} or
953 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
954 has type @code{_Complex float} and @code{3i} has type
955 @code{_Complex int}. Such a constant always has a pure imaginary
956 value, but you can form any complex value you like by adding one to a
957 real constant. This is a GNU extension; if you have an ISO C99
958 conforming C library (such as the GNU C Library), and want to construct complex
959 constants of floating type, you should include @code{<complex.h>} and
960 use the macros @code{I} or @code{_Complex_I} instead.
961
962 The ISO C++14 library also defines the @samp{i} suffix, so C++14 code
963 that includes the @samp{<complex>} header cannot use @samp{i} for the
964 GNU extension. The @samp{j} suffix still has the GNU meaning.
965
966 @cindex @code{__real__} keyword
967 @cindex @code{__imag__} keyword
968 To extract the real part of a complex-valued expression @var{exp}, write
969 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
970 extract the imaginary part. This is a GNU extension; for values of
971 floating type, you should use the ISO C99 functions @code{crealf},
972 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
973 @code{cimagl}, declared in @code{<complex.h>} and also provided as
974 built-in functions by GCC@.
975
976 @cindex complex conjugation
977 The operator @samp{~} performs complex conjugation when used on a value
978 with a complex type. This is a GNU extension; for values of
979 floating type, you should use the ISO C99 functions @code{conjf},
980 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
981 provided as built-in functions by GCC@.
982
983 GCC can allocate complex automatic variables in a noncontiguous
984 fashion; it's even possible for the real part to be in a register while
985 the imaginary part is on the stack (or vice versa). Only the DWARF
986 debug info format can represent this, so use of DWARF is recommended.
987 If you are using the stabs debug info format, GCC describes a noncontiguous
988 complex variable as if it were two separate variables of noncomplex type.
989 If the variable's actual name is @code{foo}, the two fictitious
990 variables are named @code{foo$real} and @code{foo$imag}. You can
991 examine and set these two fictitious variables with your debugger.
992
993 @node Floating Types
994 @section Additional Floating Types
995 @cindex additional floating types
996 @cindex @code{_Float@var{n}} data types
997 @cindex @code{_Float@var{n}x} data types
998 @cindex @code{__float80} data type
999 @cindex @code{__float128} data type
1000 @cindex @code{__ibm128} data type
1001 @cindex @code{w} floating point suffix
1002 @cindex @code{q} floating point suffix
1003 @cindex @code{W} floating point suffix
1004 @cindex @code{Q} floating point suffix
1005
1006 ISO/IEC TS 18661-3:2015 defines C support for additional floating
1007 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
1008 these type names; the set of types supported depends on the target
1009 architecture. These types are not supported when compiling C++.
1010 Constants with these types use suffixes @code{f@var{n}} or
1011 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}. These type
1012 names can be used together with @code{_Complex} to declare complex
1013 types.
1014
1015 As an extension, GNU C and GNU C++ support additional floating
1016 types, which are not supported by all targets.
1017 @itemize @bullet
1018 @item @code{__float128} is available on i386, x86_64, IA-64, and
1019 hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable
1020 the vector scalar (VSX) instruction set. @code{__float128} supports
1021 the 128-bit floating type. On i386, x86_64, PowerPC, and IA-64
1022 other than HP-UX, @code{__float128} is an alias for @code{_Float128}.
1023 On hppa and IA-64 HP-UX, @code{__float128} is an alias for @code{long
1024 double}.
1025
1026 @item @code{__float80} is available on the i386, x86_64, and IA-64
1027 targets, and supports the 80-bit (@code{XFmode}) floating type. It is
1028 an alias for the type name @code{_Float64x} on these targets.
1029
1030 @item @code{__ibm128} is available on PowerPC targets, and provides
1031 access to the IBM extended double format which is the current format
1032 used for @code{long double}. When @code{long double} transitions to
1033 @code{__float128} on PowerPC in the future, @code{__ibm128} will remain
1034 for use in conversions between the two types.
1035 @end itemize
1036
1037 Support for these additional types includes the arithmetic operators:
1038 add, subtract, multiply, divide; unary arithmetic operators;
1039 relational operators; equality operators; and conversions to and from
1040 integer and other floating types. Use a suffix @samp{w} or @samp{W}
1041 in a literal constant of type @code{__float80} or type
1042 @code{__ibm128}. Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
1043
1044 In order to use @code{_Float128}, @code{__float128}, and @code{__ibm128}
1045 on PowerPC Linux systems, you must use the @option{-mfloat128} option. It is
1046 expected in future versions of GCC that @code{_Float128} and @code{__float128}
1047 will be enabled automatically.
1048
1049 The @code{_Float128} type is supported on all systems where
1050 @code{__float128} is supported or where @code{long double} has the
1051 IEEE binary128 format. The @code{_Float64x} type is supported on all
1052 systems where @code{__float128} is supported. The @code{_Float32}
1053 type is supported on all systems supporting IEEE binary32; the
1054 @code{_Float64} and @code{_Float32x} types are supported on all systems
1055 supporting IEEE binary64. The @code{_Float16} type is supported on AArch64
1056 systems by default, and on ARM systems when the IEEE format for 16-bit
1057 floating-point types is selected with @option{-mfp16-format=ieee}.
1058 GCC does not currently support @code{_Float128x} on any systems.
1059
1060 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
1061 types using the corresponding internal complex type, @code{XCmode} for
1062 @code{__float80} type and @code{TCmode} for @code{__float128} type:
1063
1064 @smallexample
1065 typedef _Complex float __attribute__((mode(TC))) _Complex128;
1066 typedef _Complex float __attribute__((mode(XC))) _Complex80;
1067 @end smallexample
1068
1069 On the PowerPC Linux VSX targets, you can declare complex types using
1070 the corresponding internal complex type, @code{KCmode} for
1071 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
1072
1073 @smallexample
1074 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
1075 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
1076 @end smallexample
1077
1078 @node Half-Precision
1079 @section Half-Precision Floating Point
1080 @cindex half-precision floating point
1081 @cindex @code{__fp16} data type
1082
1083 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1084 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1085 On ARM systems, you must enable this type explicitly with the
1086 @option{-mfp16-format} command-line option in order to use it.
1087
1088 ARM targets support two incompatible representations for half-precision
1089 floating-point values. You must choose one of the representations and
1090 use it consistently in your program.
1091
1092 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1093 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1094 There are 11 bits of significand precision, approximately 3
1095 decimal digits.
1096
1097 Specifying @option{-mfp16-format=alternative} selects the ARM
1098 alternative format. This representation is similar to the IEEE
1099 format, but does not support infinities or NaNs. Instead, the range
1100 of exponents is extended, so that this format can represent normalized
1101 values in the range of @math{2^{-14}} to 131008.
1102
1103 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1104 not require use of the @option{-mfp16-format} command-line option.
1105
1106 The @code{__fp16} type may only be used as an argument to intrinsics defined
1107 in @code{<arm_fp16.h>}, or as a storage format. For purposes of
1108 arithmetic and other operations, @code{__fp16} values in C or C++
1109 expressions are automatically promoted to @code{float}.
1110
1111 The ARM target provides hardware support for conversions between
1112 @code{__fp16} and @code{float} values
1113 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8-A provides
1114 hardware support for conversions between @code{__fp16} and @code{double}
1115 values. GCC generates code using these hardware instructions if you
1116 compile with options to select an FPU that provides them;
1117 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1118 in addition to the @option{-mfp16-format} option to select
1119 a half-precision format.
1120
1121 Language-level support for the @code{__fp16} data type is
1122 independent of whether GCC generates code using hardware floating-point
1123 instructions. In cases where hardware support is not specified, GCC
1124 implements conversions between @code{__fp16} and other types as library
1125 calls.
1126
1127 It is recommended that portable code use the @code{_Float16} type defined
1128 by ISO/IEC TS 18661-3:2015. @xref{Floating Types}.
1129
1130 @node Decimal Float
1131 @section Decimal Floating Types
1132 @cindex decimal floating types
1133 @cindex @code{_Decimal32} data type
1134 @cindex @code{_Decimal64} data type
1135 @cindex @code{_Decimal128} data type
1136 @cindex @code{df} integer suffix
1137 @cindex @code{dd} integer suffix
1138 @cindex @code{dl} integer suffix
1139 @cindex @code{DF} integer suffix
1140 @cindex @code{DD} integer suffix
1141 @cindex @code{DL} integer suffix
1142
1143 As an extension, GNU C supports decimal floating types as
1144 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1145 floating types in GCC will evolve as the draft technical report changes.
1146 Calling conventions for any target might also change. Not all targets
1147 support decimal floating types.
1148
1149 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1150 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1151 @code{float}, @code{double}, and @code{long double} whose radix is not
1152 specified by the C standard but is usually two.
1153
1154 Support for decimal floating types includes the arithmetic operators
1155 add, subtract, multiply, divide; unary arithmetic operators;
1156 relational operators; equality operators; and conversions to and from
1157 integer and other floating types. Use a suffix @samp{df} or
1158 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1159 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1160 @code{_Decimal128}.
1161
1162 GCC support of decimal float as specified by the draft technical report
1163 is incomplete:
1164
1165 @itemize @bullet
1166 @item
1167 When the value of a decimal floating type cannot be represented in the
1168 integer type to which it is being converted, the result is undefined
1169 rather than the result value specified by the draft technical report.
1170
1171 @item
1172 GCC does not provide the C library functionality associated with
1173 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1174 @file{wchar.h}, which must come from a separate C library implementation.
1175 Because of this the GNU C compiler does not define macro
1176 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1177 the technical report.
1178 @end itemize
1179
1180 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1181 are supported by the DWARF debug information format.
1182
1183 @node Hex Floats
1184 @section Hex Floats
1185 @cindex hex floats
1186
1187 ISO C99 and ISO C++17 support floating-point numbers written not only in
1188 the usual decimal notation, such as @code{1.55e1}, but also numbers such as
1189 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1190 supports this in C90 mode (except in some cases when strictly
1191 conforming) and in C++98, C++11 and C++14 modes. In that format the
1192 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1193 mandatory. The exponent is a decimal number that indicates the power of
1194 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1195 @tex
1196 $1 {15\over16}$,
1197 @end tex
1198 @ifnottex
1199 1 15/16,
1200 @end ifnottex
1201 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1202 is the same as @code{1.55e1}.
1203
1204 Unlike for floating-point numbers in the decimal notation the exponent
1205 is always required in the hexadecimal notation. Otherwise the compiler
1206 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1207 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1208 extension for floating-point constants of type @code{float}.
1209
1210 @node Fixed-Point
1211 @section Fixed-Point Types
1212 @cindex fixed-point types
1213 @cindex @code{_Fract} data type
1214 @cindex @code{_Accum} data type
1215 @cindex @code{_Sat} data type
1216 @cindex @code{hr} fixed-suffix
1217 @cindex @code{r} fixed-suffix
1218 @cindex @code{lr} fixed-suffix
1219 @cindex @code{llr} fixed-suffix
1220 @cindex @code{uhr} fixed-suffix
1221 @cindex @code{ur} fixed-suffix
1222 @cindex @code{ulr} fixed-suffix
1223 @cindex @code{ullr} fixed-suffix
1224 @cindex @code{hk} fixed-suffix
1225 @cindex @code{k} fixed-suffix
1226 @cindex @code{lk} fixed-suffix
1227 @cindex @code{llk} fixed-suffix
1228 @cindex @code{uhk} fixed-suffix
1229 @cindex @code{uk} fixed-suffix
1230 @cindex @code{ulk} fixed-suffix
1231 @cindex @code{ullk} fixed-suffix
1232 @cindex @code{HR} fixed-suffix
1233 @cindex @code{R} fixed-suffix
1234 @cindex @code{LR} fixed-suffix
1235 @cindex @code{LLR} fixed-suffix
1236 @cindex @code{UHR} fixed-suffix
1237 @cindex @code{UR} fixed-suffix
1238 @cindex @code{ULR} fixed-suffix
1239 @cindex @code{ULLR} fixed-suffix
1240 @cindex @code{HK} fixed-suffix
1241 @cindex @code{K} fixed-suffix
1242 @cindex @code{LK} fixed-suffix
1243 @cindex @code{LLK} fixed-suffix
1244 @cindex @code{UHK} fixed-suffix
1245 @cindex @code{UK} fixed-suffix
1246 @cindex @code{ULK} fixed-suffix
1247 @cindex @code{ULLK} fixed-suffix
1248
1249 As an extension, GNU C supports fixed-point types as
1250 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1251 types in GCC will evolve as the draft technical report changes.
1252 Calling conventions for any target might also change. Not all targets
1253 support fixed-point types.
1254
1255 The fixed-point types are
1256 @code{short _Fract},
1257 @code{_Fract},
1258 @code{long _Fract},
1259 @code{long long _Fract},
1260 @code{unsigned short _Fract},
1261 @code{unsigned _Fract},
1262 @code{unsigned long _Fract},
1263 @code{unsigned long long _Fract},
1264 @code{_Sat short _Fract},
1265 @code{_Sat _Fract},
1266 @code{_Sat long _Fract},
1267 @code{_Sat long long _Fract},
1268 @code{_Sat unsigned short _Fract},
1269 @code{_Sat unsigned _Fract},
1270 @code{_Sat unsigned long _Fract},
1271 @code{_Sat unsigned long long _Fract},
1272 @code{short _Accum},
1273 @code{_Accum},
1274 @code{long _Accum},
1275 @code{long long _Accum},
1276 @code{unsigned short _Accum},
1277 @code{unsigned _Accum},
1278 @code{unsigned long _Accum},
1279 @code{unsigned long long _Accum},
1280 @code{_Sat short _Accum},
1281 @code{_Sat _Accum},
1282 @code{_Sat long _Accum},
1283 @code{_Sat long long _Accum},
1284 @code{_Sat unsigned short _Accum},
1285 @code{_Sat unsigned _Accum},
1286 @code{_Sat unsigned long _Accum},
1287 @code{_Sat unsigned long long _Accum}.
1288
1289 Fixed-point data values contain fractional and optional integral parts.
1290 The format of fixed-point data varies and depends on the target machine.
1291
1292 Support for fixed-point types includes:
1293 @itemize @bullet
1294 @item
1295 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1296 @item
1297 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1298 @item
1299 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1300 @item
1301 binary shift operators (@code{<<}, @code{>>})
1302 @item
1303 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1304 @item
1305 equality operators (@code{==}, @code{!=})
1306 @item
1307 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1308 @code{<<=}, @code{>>=})
1309 @item
1310 conversions to and from integer, floating-point, or fixed-point types
1311 @end itemize
1312
1313 Use a suffix in a fixed-point literal constant:
1314 @itemize
1315 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1316 @code{_Sat short _Fract}
1317 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1318 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1319 @code{_Sat long _Fract}
1320 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1321 @code{_Sat long long _Fract}
1322 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1323 @code{_Sat unsigned short _Fract}
1324 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1325 @code{_Sat unsigned _Fract}
1326 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1327 @code{_Sat unsigned long _Fract}
1328 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1329 and @code{_Sat unsigned long long _Fract}
1330 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1331 @code{_Sat short _Accum}
1332 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1333 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1334 @code{_Sat long _Accum}
1335 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1336 @code{_Sat long long _Accum}
1337 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1338 @code{_Sat unsigned short _Accum}
1339 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1340 @code{_Sat unsigned _Accum}
1341 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1342 @code{_Sat unsigned long _Accum}
1343 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1344 and @code{_Sat unsigned long long _Accum}
1345 @end itemize
1346
1347 GCC support of fixed-point types as specified by the draft technical report
1348 is incomplete:
1349
1350 @itemize @bullet
1351 @item
1352 Pragmas to control overflow and rounding behaviors are not implemented.
1353 @end itemize
1354
1355 Fixed-point types are supported by the DWARF debug information format.
1356
1357 @node Named Address Spaces
1358 @section Named Address Spaces
1359 @cindex Named Address Spaces
1360
1361 As an extension, GNU C supports named address spaces as
1362 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1363 address spaces in GCC will evolve as the draft technical report
1364 changes. Calling conventions for any target might also change. At
1365 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1366 address spaces other than the generic address space.
1367
1368 Address space identifiers may be used exactly like any other C type
1369 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1370 document for more details.
1371
1372 @anchor{AVR Named Address Spaces}
1373 @subsection AVR Named Address Spaces
1374
1375 On the AVR target, there are several address spaces that can be used
1376 in order to put read-only data into the flash memory and access that
1377 data by means of the special instructions @code{LPM} or @code{ELPM}
1378 needed to read from flash.
1379
1380 Devices belonging to @code{avrtiny} and @code{avrxmega3} can access
1381 flash memory by means of @code{LD*} instructions because the flash
1382 memory is mapped into the RAM address space. There is @emph{no need}
1383 for language extensions like @code{__flash} or attribute
1384 @ref{AVR Variable Attributes,,@code{progmem}}.
1385 The default linker description files for these devices cater for that
1386 feature and @code{.rodata} stays in flash: The compiler just generates
1387 @code{LD*} instructions, and the linker script adds core specific
1388 offsets to all @code{.rodata} symbols: @code{0x4000} in the case of
1389 @code{avrtiny} and @code{0x8000} in the case of @code{avrxmega3}.
1390 See @ref{AVR Options} for a list of respective devices.
1391
1392 For devices not in @code{avrtiny} or @code{avrxmega3},
1393 any data including read-only data is located in RAM (the generic
1394 address space) because flash memory is not visible in the RAM address
1395 space. In order to locate read-only data in flash memory @emph{and}
1396 to generate the right instructions to access this data without
1397 using (inline) assembler code, special address spaces are needed.
1398
1399 @table @code
1400 @item __flash
1401 @cindex @code{__flash} AVR Named Address Spaces
1402 The @code{__flash} qualifier locates data in the
1403 @code{.progmem.data} section. Data is read using the @code{LPM}
1404 instruction. Pointers to this address space are 16 bits wide.
1405
1406 @item __flash1
1407 @itemx __flash2
1408 @itemx __flash3
1409 @itemx __flash4
1410 @itemx __flash5
1411 @cindex @code{__flash1} AVR Named Address Spaces
1412 @cindex @code{__flash2} AVR Named Address Spaces
1413 @cindex @code{__flash3} AVR Named Address Spaces
1414 @cindex @code{__flash4} AVR Named Address Spaces
1415 @cindex @code{__flash5} AVR Named Address Spaces
1416 These are 16-bit address spaces locating data in section
1417 @code{.progmem@var{N}.data} where @var{N} refers to
1418 address space @code{__flash@var{N}}.
1419 The compiler sets the @code{RAMPZ} segment register appropriately
1420 before reading data by means of the @code{ELPM} instruction.
1421
1422 @item __memx
1423 @cindex @code{__memx} AVR Named Address Spaces
1424 This is a 24-bit address space that linearizes flash and RAM:
1425 If the high bit of the address is set, data is read from
1426 RAM using the lower two bytes as RAM address.
1427 If the high bit of the address is clear, data is read from flash
1428 with @code{RAMPZ} set according to the high byte of the address.
1429 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1430
1431 Objects in this address space are located in @code{.progmemx.data}.
1432 @end table
1433
1434 @b{Example}
1435
1436 @smallexample
1437 char my_read (const __flash char ** p)
1438 @{
1439 /* p is a pointer to RAM that points to a pointer to flash.
1440 The first indirection of p reads that flash pointer
1441 from RAM and the second indirection reads a char from this
1442 flash address. */
1443
1444 return **p;
1445 @}
1446
1447 /* Locate array[] in flash memory */
1448 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1449
1450 int i = 1;
1451
1452 int main (void)
1453 @{
1454 /* Return 17 by reading from flash memory */
1455 return array[array[i]];
1456 @}
1457 @end smallexample
1458
1459 @noindent
1460 For each named address space supported by avr-gcc there is an equally
1461 named but uppercase built-in macro defined.
1462 The purpose is to facilitate testing if respective address space
1463 support is available or not:
1464
1465 @smallexample
1466 #ifdef __FLASH
1467 const __flash int var = 1;
1468
1469 int read_var (void)
1470 @{
1471 return var;
1472 @}
1473 #else
1474 #include <avr/pgmspace.h> /* From AVR-LibC */
1475
1476 const int var PROGMEM = 1;
1477
1478 int read_var (void)
1479 @{
1480 return (int) pgm_read_word (&var);
1481 @}
1482 #endif /* __FLASH */
1483 @end smallexample
1484
1485 @noindent
1486 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1487 locates data in flash but
1488 accesses to these data read from generic address space, i.e.@:
1489 from RAM,
1490 so that you need special accessors like @code{pgm_read_byte}
1491 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1492 together with attribute @code{progmem}.
1493
1494 @noindent
1495 @b{Limitations and caveats}
1496
1497 @itemize
1498 @item
1499 Reading across the 64@tie{}KiB section boundary of
1500 the @code{__flash} or @code{__flash@var{N}} address spaces
1501 shows undefined behavior. The only address space that
1502 supports reading across the 64@tie{}KiB flash segment boundaries is
1503 @code{__memx}.
1504
1505 @item
1506 If you use one of the @code{__flash@var{N}} address spaces
1507 you must arrange your linker script to locate the
1508 @code{.progmem@var{N}.data} sections according to your needs.
1509
1510 @item
1511 Any data or pointers to the non-generic address spaces must
1512 be qualified as @code{const}, i.e.@: as read-only data.
1513 This still applies if the data in one of these address
1514 spaces like software version number or calibration lookup table are intended to
1515 be changed after load time by, say, a boot loader. In this case
1516 the right qualification is @code{const} @code{volatile} so that the compiler
1517 must not optimize away known values or insert them
1518 as immediates into operands of instructions.
1519
1520 @item
1521 The following code initializes a variable @code{pfoo}
1522 located in static storage with a 24-bit address:
1523 @smallexample
1524 extern const __memx char foo;
1525 const __memx void *pfoo = &foo;
1526 @end smallexample
1527
1528 @item
1529 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1530 Just use vanilla C / C++ code without overhead as outlined above.
1531 Attribute @code{progmem} is supported but works differently,
1532 see @ref{AVR Variable Attributes}.
1533
1534 @end itemize
1535
1536 @subsection M32C Named Address Spaces
1537 @cindex @code{__far} M32C Named Address Spaces
1538
1539 On the M32C target, with the R8C and M16C CPU variants, variables
1540 qualified with @code{__far} are accessed using 32-bit addresses in
1541 order to access memory beyond the first 64@tie{}Ki bytes. If
1542 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1543 effect.
1544
1545 @subsection RL78 Named Address Spaces
1546 @cindex @code{__far} RL78 Named Address Spaces
1547
1548 On the RL78 target, variables qualified with @code{__far} are accessed
1549 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1550 addresses. Non-far variables are assumed to appear in the topmost
1551 64@tie{}KiB of the address space.
1552
1553 @subsection SPU Named Address Spaces
1554 @cindex @code{__ea} SPU Named Address Spaces
1555
1556 On the SPU target variables may be declared as
1557 belonging to another address space by qualifying the type with the
1558 @code{__ea} address space identifier:
1559
1560 @smallexample
1561 extern int __ea i;
1562 @end smallexample
1563
1564 @noindent
1565 The compiler generates special code to access the variable @code{i}.
1566 It may use runtime library
1567 support, or generate special machine instructions to access that address
1568 space.
1569
1570 @subsection x86 Named Address Spaces
1571 @cindex x86 named address spaces
1572
1573 On the x86 target, variables may be declared as being relative
1574 to the @code{%fs} or @code{%gs} segments.
1575
1576 @table @code
1577 @item __seg_fs
1578 @itemx __seg_gs
1579 @cindex @code{__seg_fs} x86 named address space
1580 @cindex @code{__seg_gs} x86 named address space
1581 The object is accessed with the respective segment override prefix.
1582
1583 The respective segment base must be set via some method specific to
1584 the operating system. Rather than require an expensive system call
1585 to retrieve the segment base, these address spaces are not considered
1586 to be subspaces of the generic (flat) address space. This means that
1587 explicit casts are required to convert pointers between these address
1588 spaces and the generic address space. In practice the application
1589 should cast to @code{uintptr_t} and apply the segment base offset
1590 that it installed previously.
1591
1592 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1593 defined when these address spaces are supported.
1594 @end table
1595
1596 @node Zero Length
1597 @section Arrays of Length Zero
1598 @cindex arrays of length zero
1599 @cindex zero-length arrays
1600 @cindex length-zero arrays
1601 @cindex flexible array members
1602
1603 Declaring zero-length arrays is allowed in GNU C as an extension.
1604 A zero-length array can be useful as the last element of a structure
1605 that is really a header for a variable-length object:
1606
1607 @smallexample
1608 struct line @{
1609 int length;
1610 char contents[0];
1611 @};
1612
1613 struct line *thisline = (struct line *)
1614 malloc (sizeof (struct line) + this_length);
1615 thisline->length = this_length;
1616 @end smallexample
1617
1618 Although the size of a zero-length array is zero, an array member of
1619 this kind may increase the size of the enclosing type as a result of tail
1620 padding. The offset of a zero-length array member from the beginning
1621 of the enclosing structure is the same as the offset of an array with
1622 one or more elements of the same type. The alignment of a zero-length
1623 array is the same as the alignment of its elements.
1624
1625 Declaring zero-length arrays in other contexts, including as interior
1626 members of structure objects or as non-member objects, is discouraged.
1627 Accessing elements of zero-length arrays declared in such contexts is
1628 undefined and may be diagnosed.
1629
1630 In the absence of the zero-length array extension, in ISO C90
1631 the @code{contents} array in the example above would typically be declared
1632 to have a single element. Unlike a zero-length array which only contributes
1633 to the size of the enclosing structure for the purposes of alignment,
1634 a one-element array always occupies at least as much space as a single
1635 object of the type. Although using one-element arrays this way is
1636 discouraged, GCC handles accesses to trailing one-element array members
1637 analogously to zero-length arrays.
1638
1639 The preferred mechanism to declare variable-length types like
1640 @code{struct line} above is the ISO C99 @dfn{flexible array member},
1641 with slightly different syntax and semantics:
1642
1643 @itemize @bullet
1644 @item
1645 Flexible array members are written as @code{contents[]} without
1646 the @code{0}.
1647
1648 @item
1649 Flexible array members have incomplete type, and so the @code{sizeof}
1650 operator may not be applied. As a quirk of the original implementation
1651 of zero-length arrays, @code{sizeof} evaluates to zero.
1652
1653 @item
1654 Flexible array members may only appear as the last member of a
1655 @code{struct} that is otherwise non-empty.
1656
1657 @item
1658 A structure containing a flexible array member, or a union containing
1659 such a structure (possibly recursively), may not be a member of a
1660 structure or an element of an array. (However, these uses are
1661 permitted by GCC as extensions.)
1662 @end itemize
1663
1664 Non-empty initialization of zero-length
1665 arrays is treated like any case where there are more initializer
1666 elements than the array holds, in that a suitable warning about ``excess
1667 elements in array'' is given, and the excess elements (all of them, in
1668 this case) are ignored.
1669
1670 GCC allows static initialization of flexible array members.
1671 This is equivalent to defining a new structure containing the original
1672 structure followed by an array of sufficient size to contain the data.
1673 E.g.@: in the following, @code{f1} is constructed as if it were declared
1674 like @code{f2}.
1675
1676 @smallexample
1677 struct f1 @{
1678 int x; int y[];
1679 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1680
1681 struct f2 @{
1682 struct f1 f1; int data[3];
1683 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1684 @end smallexample
1685
1686 @noindent
1687 The convenience of this extension is that @code{f1} has the desired
1688 type, eliminating the need to consistently refer to @code{f2.f1}.
1689
1690 This has symmetry with normal static arrays, in that an array of
1691 unknown size is also written with @code{[]}.
1692
1693 Of course, this extension only makes sense if the extra data comes at
1694 the end of a top-level object, as otherwise we would be overwriting
1695 data at subsequent offsets. To avoid undue complication and confusion
1696 with initialization of deeply nested arrays, we simply disallow any
1697 non-empty initialization except when the structure is the top-level
1698 object. For example:
1699
1700 @smallexample
1701 struct foo @{ int x; int y[]; @};
1702 struct bar @{ struct foo z; @};
1703
1704 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1705 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1706 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1707 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1708 @end smallexample
1709
1710 @node Empty Structures
1711 @section Structures with No Members
1712 @cindex empty structures
1713 @cindex zero-size structures
1714
1715 GCC permits a C structure to have no members:
1716
1717 @smallexample
1718 struct empty @{
1719 @};
1720 @end smallexample
1721
1722 The structure has size zero. In C++, empty structures are part
1723 of the language. G++ treats empty structures as if they had a single
1724 member of type @code{char}.
1725
1726 @node Variable Length
1727 @section Arrays of Variable Length
1728 @cindex variable-length arrays
1729 @cindex arrays of variable length
1730 @cindex VLAs
1731
1732 Variable-length automatic arrays are allowed in ISO C99, and as an
1733 extension GCC accepts them in C90 mode and in C++. These arrays are
1734 declared like any other automatic arrays, but with a length that is not
1735 a constant expression. The storage is allocated at the point of
1736 declaration and deallocated when the block scope containing the declaration
1737 exits. For
1738 example:
1739
1740 @smallexample
1741 FILE *
1742 concat_fopen (char *s1, char *s2, char *mode)
1743 @{
1744 char str[strlen (s1) + strlen (s2) + 1];
1745 strcpy (str, s1);
1746 strcat (str, s2);
1747 return fopen (str, mode);
1748 @}
1749 @end smallexample
1750
1751 @cindex scope of a variable length array
1752 @cindex variable-length array scope
1753 @cindex deallocating variable length arrays
1754 Jumping or breaking out of the scope of the array name deallocates the
1755 storage. Jumping into the scope is not allowed; you get an error
1756 message for it.
1757
1758 @cindex variable-length array in a structure
1759 As an extension, GCC accepts variable-length arrays as a member of
1760 a structure or a union. For example:
1761
1762 @smallexample
1763 void
1764 foo (int n)
1765 @{
1766 struct S @{ int x[n]; @};
1767 @}
1768 @end smallexample
1769
1770 @cindex @code{alloca} vs variable-length arrays
1771 You can use the function @code{alloca} to get an effect much like
1772 variable-length arrays. The function @code{alloca} is available in
1773 many other C implementations (but not in all). On the other hand,
1774 variable-length arrays are more elegant.
1775
1776 There are other differences between these two methods. Space allocated
1777 with @code{alloca} exists until the containing @emph{function} returns.
1778 The space for a variable-length array is deallocated as soon as the array
1779 name's scope ends, unless you also use @code{alloca} in this scope.
1780
1781 You can also use variable-length arrays as arguments to functions:
1782
1783 @smallexample
1784 struct entry
1785 tester (int len, char data[len][len])
1786 @{
1787 /* @r{@dots{}} */
1788 @}
1789 @end smallexample
1790
1791 The length of an array is computed once when the storage is allocated
1792 and is remembered for the scope of the array in case you access it with
1793 @code{sizeof}.
1794
1795 If you want to pass the array first and the length afterward, you can
1796 use a forward declaration in the parameter list---another GNU extension.
1797
1798 @smallexample
1799 struct entry
1800 tester (int len; char data[len][len], int len)
1801 @{
1802 /* @r{@dots{}} */
1803 @}
1804 @end smallexample
1805
1806 @cindex parameter forward declaration
1807 The @samp{int len} before the semicolon is a @dfn{parameter forward
1808 declaration}, and it serves the purpose of making the name @code{len}
1809 known when the declaration of @code{data} is parsed.
1810
1811 You can write any number of such parameter forward declarations in the
1812 parameter list. They can be separated by commas or semicolons, but the
1813 last one must end with a semicolon, which is followed by the ``real''
1814 parameter declarations. Each forward declaration must match a ``real''
1815 declaration in parameter name and data type. ISO C99 does not support
1816 parameter forward declarations.
1817
1818 @node Variadic Macros
1819 @section Macros with a Variable Number of Arguments.
1820 @cindex variable number of arguments
1821 @cindex macro with variable arguments
1822 @cindex rest argument (in macro)
1823 @cindex variadic macros
1824
1825 In the ISO C standard of 1999, a macro can be declared to accept a
1826 variable number of arguments much as a function can. The syntax for
1827 defining the macro is similar to that of a function. Here is an
1828 example:
1829
1830 @smallexample
1831 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1832 @end smallexample
1833
1834 @noindent
1835 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1836 such a macro, it represents the zero or more tokens until the closing
1837 parenthesis that ends the invocation, including any commas. This set of
1838 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1839 wherever it appears. See the CPP manual for more information.
1840
1841 GCC has long supported variadic macros, and used a different syntax that
1842 allowed you to give a name to the variable arguments just like any other
1843 argument. Here is an example:
1844
1845 @smallexample
1846 #define debug(format, args...) fprintf (stderr, format, args)
1847 @end smallexample
1848
1849 @noindent
1850 This is in all ways equivalent to the ISO C example above, but arguably
1851 more readable and descriptive.
1852
1853 GNU CPP has two further variadic macro extensions, and permits them to
1854 be used with either of the above forms of macro definition.
1855
1856 In standard C, you are not allowed to leave the variable argument out
1857 entirely; but you are allowed to pass an empty argument. For example,
1858 this invocation is invalid in ISO C, because there is no comma after
1859 the string:
1860
1861 @smallexample
1862 debug ("A message")
1863 @end smallexample
1864
1865 GNU CPP permits you to completely omit the variable arguments in this
1866 way. In the above examples, the compiler would complain, though since
1867 the expansion of the macro still has the extra comma after the format
1868 string.
1869
1870 To help solve this problem, CPP behaves specially for variable arguments
1871 used with the token paste operator, @samp{##}. If instead you write
1872
1873 @smallexample
1874 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1875 @end smallexample
1876
1877 @noindent
1878 and if the variable arguments are omitted or empty, the @samp{##}
1879 operator causes the preprocessor to remove the comma before it. If you
1880 do provide some variable arguments in your macro invocation, GNU CPP
1881 does not complain about the paste operation and instead places the
1882 variable arguments after the comma. Just like any other pasted macro
1883 argument, these arguments are not macro expanded.
1884
1885 @node Escaped Newlines
1886 @section Slightly Looser Rules for Escaped Newlines
1887 @cindex escaped newlines
1888 @cindex newlines (escaped)
1889
1890 The preprocessor treatment of escaped newlines is more relaxed
1891 than that specified by the C90 standard, which requires the newline
1892 to immediately follow a backslash.
1893 GCC's implementation allows whitespace in the form
1894 of spaces, horizontal and vertical tabs, and form feeds between the
1895 backslash and the subsequent newline. The preprocessor issues a
1896 warning, but treats it as a valid escaped newline and combines the two
1897 lines to form a single logical line. This works within comments and
1898 tokens, as well as between tokens. Comments are @emph{not} treated as
1899 whitespace for the purposes of this relaxation, since they have not
1900 yet been replaced with spaces.
1901
1902 @node Subscripting
1903 @section Non-Lvalue Arrays May Have Subscripts
1904 @cindex subscripting
1905 @cindex arrays, non-lvalue
1906
1907 @cindex subscripting and function values
1908 In ISO C99, arrays that are not lvalues still decay to pointers, and
1909 may be subscripted, although they may not be modified or used after
1910 the next sequence point and the unary @samp{&} operator may not be
1911 applied to them. As an extension, GNU C allows such arrays to be
1912 subscripted in C90 mode, though otherwise they do not decay to
1913 pointers outside C99 mode. For example,
1914 this is valid in GNU C though not valid in C90:
1915
1916 @smallexample
1917 @group
1918 struct foo @{int a[4];@};
1919
1920 struct foo f();
1921
1922 bar (int index)
1923 @{
1924 return f().a[index];
1925 @}
1926 @end group
1927 @end smallexample
1928
1929 @node Pointer Arith
1930 @section Arithmetic on @code{void}- and Function-Pointers
1931 @cindex void pointers, arithmetic
1932 @cindex void, size of pointer to
1933 @cindex function pointers, arithmetic
1934 @cindex function, size of pointer to
1935
1936 In GNU C, addition and subtraction operations are supported on pointers to
1937 @code{void} and on pointers to functions. This is done by treating the
1938 size of a @code{void} or of a function as 1.
1939
1940 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1941 and on function types, and returns 1.
1942
1943 @opindex Wpointer-arith
1944 The option @option{-Wpointer-arith} requests a warning if these extensions
1945 are used.
1946
1947 @node Pointers to Arrays
1948 @section Pointers to Arrays with Qualifiers Work as Expected
1949 @cindex pointers to arrays
1950 @cindex const qualifier
1951
1952 In GNU C, pointers to arrays with qualifiers work similar to pointers
1953 to other qualified types. For example, a value of type @code{int (*)[5]}
1954 can be used to initialize a variable of type @code{const int (*)[5]}.
1955 These types are incompatible in ISO C because the @code{const} qualifier
1956 is formally attached to the element type of the array and not the
1957 array itself.
1958
1959 @smallexample
1960 extern void
1961 transpose (int N, int M, double out[M][N], const double in[N][M]);
1962 double x[3][2];
1963 double y[2][3];
1964 @r{@dots{}}
1965 transpose(3, 2, y, x);
1966 @end smallexample
1967
1968 @node Initializers
1969 @section Non-Constant Initializers
1970 @cindex initializers, non-constant
1971 @cindex non-constant initializers
1972
1973 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1974 automatic variable are not required to be constant expressions in GNU C@.
1975 Here is an example of an initializer with run-time varying elements:
1976
1977 @smallexample
1978 foo (float f, float g)
1979 @{
1980 float beat_freqs[2] = @{ f-g, f+g @};
1981 /* @r{@dots{}} */
1982 @}
1983 @end smallexample
1984
1985 @node Compound Literals
1986 @section Compound Literals
1987 @cindex constructor expressions
1988 @cindex initializations in expressions
1989 @cindex structures, constructor expression
1990 @cindex expressions, constructor
1991 @cindex compound literals
1992 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1993
1994 A compound literal looks like a cast of a brace-enclosed aggregate
1995 initializer list. Its value is an object of the type specified in
1996 the cast, containing the elements specified in the initializer.
1997 Unlike the result of a cast, a compound literal is an lvalue. ISO
1998 C99 and later support compound literals. As an extension, GCC
1999 supports compound literals also in C90 mode and in C++, although
2000 as explained below, the C++ semantics are somewhat different.
2001
2002 Usually, the specified type of a compound literal is a structure. Assume
2003 that @code{struct foo} and @code{structure} are declared as shown:
2004
2005 @smallexample
2006 struct foo @{int a; char b[2];@} structure;
2007 @end smallexample
2008
2009 @noindent
2010 Here is an example of constructing a @code{struct foo} with a compound literal:
2011
2012 @smallexample
2013 structure = ((struct foo) @{x + y, 'a', 0@});
2014 @end smallexample
2015
2016 @noindent
2017 This is equivalent to writing the following:
2018
2019 @smallexample
2020 @{
2021 struct foo temp = @{x + y, 'a', 0@};
2022 structure = temp;
2023 @}
2024 @end smallexample
2025
2026 You can also construct an array, though this is dangerous in C++, as
2027 explained below. If all the elements of the compound literal are
2028 (made up of) simple constant expressions suitable for use in
2029 initializers of objects of static storage duration, then the compound
2030 literal can be coerced to a pointer to its first element and used in
2031 such an initializer, as shown here:
2032
2033 @smallexample
2034 char **foo = (char *[]) @{ "x", "y", "z" @};
2035 @end smallexample
2036
2037 Compound literals for scalar types and union types are also allowed. In
2038 the following example the variable @code{i} is initialized to the value
2039 @code{2}, the result of incrementing the unnamed object created by
2040 the compound literal.
2041
2042 @smallexample
2043 int i = ++(int) @{ 1 @};
2044 @end smallexample
2045
2046 As a GNU extension, GCC allows initialization of objects with static storage
2047 duration by compound literals (which is not possible in ISO C99 because
2048 the initializer is not a constant).
2049 It is handled as if the object were initialized only with the brace-enclosed
2050 list if the types of the compound literal and the object match.
2051 The elements of the compound literal must be constant.
2052 If the object being initialized has array type of unknown size, the size is
2053 determined by the size of the compound literal.
2054
2055 @smallexample
2056 static struct foo x = (struct foo) @{1, 'a', 'b'@};
2057 static int y[] = (int []) @{1, 2, 3@};
2058 static int z[] = (int [3]) @{1@};
2059 @end smallexample
2060
2061 @noindent
2062 The above lines are equivalent to the following:
2063 @smallexample
2064 static struct foo x = @{1, 'a', 'b'@};
2065 static int y[] = @{1, 2, 3@};
2066 static int z[] = @{1, 0, 0@};
2067 @end smallexample
2068
2069 In C, a compound literal designates an unnamed object with static or
2070 automatic storage duration. In C++, a compound literal designates a
2071 temporary object that only lives until the end of its full-expression.
2072 As a result, well-defined C code that takes the address of a subobject
2073 of a compound literal can be undefined in C++, so G++ rejects
2074 the conversion of a temporary array to a pointer. For instance, if
2075 the array compound literal example above appeared inside a function,
2076 any subsequent use of @code{foo} in C++ would have undefined behavior
2077 because the lifetime of the array ends after the declaration of @code{foo}.
2078
2079 As an optimization, G++ sometimes gives array compound literals longer
2080 lifetimes: when the array either appears outside a function or has
2081 a @code{const}-qualified type. If @code{foo} and its initializer had
2082 elements of type @code{char *const} rather than @code{char *}, or if
2083 @code{foo} were a global variable, the array would have static storage
2084 duration. But it is probably safest just to avoid the use of array
2085 compound literals in C++ code.
2086
2087 @node Designated Inits
2088 @section Designated Initializers
2089 @cindex initializers with labeled elements
2090 @cindex labeled elements in initializers
2091 @cindex case labels in initializers
2092 @cindex designated initializers
2093
2094 Standard C90 requires the elements of an initializer to appear in a fixed
2095 order, the same as the order of the elements in the array or structure
2096 being initialized.
2097
2098 In ISO C99 you can give the elements in any order, specifying the array
2099 indices or structure field names they apply to, and GNU C allows this as
2100 an extension in C90 mode as well. This extension is not
2101 implemented in GNU C++.
2102
2103 To specify an array index, write
2104 @samp{[@var{index}] =} before the element value. For example,
2105
2106 @smallexample
2107 int a[6] = @{ [4] = 29, [2] = 15 @};
2108 @end smallexample
2109
2110 @noindent
2111 is equivalent to
2112
2113 @smallexample
2114 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2115 @end smallexample
2116
2117 @noindent
2118 The index values must be constant expressions, even if the array being
2119 initialized is automatic.
2120
2121 An alternative syntax for this that has been obsolete since GCC 2.5 but
2122 GCC still accepts is to write @samp{[@var{index}]} before the element
2123 value, with no @samp{=}.
2124
2125 To initialize a range of elements to the same value, write
2126 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
2127 extension. For example,
2128
2129 @smallexample
2130 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2131 @end smallexample
2132
2133 @noindent
2134 If the value in it has side effects, the side effects happen only once,
2135 not for each initialized field by the range initializer.
2136
2137 @noindent
2138 Note that the length of the array is the highest value specified
2139 plus one.
2140
2141 In a structure initializer, specify the name of a field to initialize
2142 with @samp{.@var{fieldname} =} before the element value. For example,
2143 given the following structure,
2144
2145 @smallexample
2146 struct point @{ int x, y; @};
2147 @end smallexample
2148
2149 @noindent
2150 the following initialization
2151
2152 @smallexample
2153 struct point p = @{ .y = yvalue, .x = xvalue @};
2154 @end smallexample
2155
2156 @noindent
2157 is equivalent to
2158
2159 @smallexample
2160 struct point p = @{ xvalue, yvalue @};
2161 @end smallexample
2162
2163 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2164 @samp{@var{fieldname}:}, as shown here:
2165
2166 @smallexample
2167 struct point p = @{ y: yvalue, x: xvalue @};
2168 @end smallexample
2169
2170 Omitted fields are implicitly initialized the same as for objects
2171 that have static storage duration.
2172
2173 @cindex designators
2174 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2175 @dfn{designator}. You can also use a designator (or the obsolete colon
2176 syntax) when initializing a union, to specify which element of the union
2177 should be used. For example,
2178
2179 @smallexample
2180 union foo @{ int i; double d; @};
2181
2182 union foo f = @{ .d = 4 @};
2183 @end smallexample
2184
2185 @noindent
2186 converts 4 to a @code{double} to store it in the union using
2187 the second element. By contrast, casting 4 to type @code{union foo}
2188 stores it into the union as the integer @code{i}, since it is
2189 an integer. @xref{Cast to Union}.
2190
2191 You can combine this technique of naming elements with ordinary C
2192 initialization of successive elements. Each initializer element that
2193 does not have a designator applies to the next consecutive element of the
2194 array or structure. For example,
2195
2196 @smallexample
2197 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2198 @end smallexample
2199
2200 @noindent
2201 is equivalent to
2202
2203 @smallexample
2204 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2205 @end smallexample
2206
2207 Labeling the elements of an array initializer is especially useful
2208 when the indices are characters or belong to an @code{enum} type.
2209 For example:
2210
2211 @smallexample
2212 int whitespace[256]
2213 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2214 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2215 @end smallexample
2216
2217 @cindex designator lists
2218 You can also write a series of @samp{.@var{fieldname}} and
2219 @samp{[@var{index}]} designators before an @samp{=} to specify a
2220 nested subobject to initialize; the list is taken relative to the
2221 subobject corresponding to the closest surrounding brace pair. For
2222 example, with the @samp{struct point} declaration above:
2223
2224 @smallexample
2225 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2226 @end smallexample
2227
2228 If the same field is initialized multiple times, or overlapping
2229 fields of a union are initialized, the value from the last
2230 initialization is used. When a field of a union is itself a structure,
2231 the entire structure from the last field initialized is used. If any previous
2232 initializer has side effect, it is unspecified whether the side effect
2233 happens or not. Currently, GCC discards the side-effecting
2234 initializer expressions and issues a warning.
2235
2236 @node Case Ranges
2237 @section Case Ranges
2238 @cindex case ranges
2239 @cindex ranges in case statements
2240
2241 You can specify a range of consecutive values in a single @code{case} label,
2242 like this:
2243
2244 @smallexample
2245 case @var{low} ... @var{high}:
2246 @end smallexample
2247
2248 @noindent
2249 This has the same effect as the proper number of individual @code{case}
2250 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2251
2252 This feature is especially useful for ranges of ASCII character codes:
2253
2254 @smallexample
2255 case 'A' ... 'Z':
2256 @end smallexample
2257
2258 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2259 it may be parsed wrong when you use it with integer values. For example,
2260 write this:
2261
2262 @smallexample
2263 case 1 ... 5:
2264 @end smallexample
2265
2266 @noindent
2267 rather than this:
2268
2269 @smallexample
2270 case 1...5:
2271 @end smallexample
2272
2273 @node Cast to Union
2274 @section Cast to a Union Type
2275 @cindex cast to a union
2276 @cindex union, casting to a
2277
2278 A cast to a union type is a C extension not available in C++. It looks
2279 just like ordinary casts with the constraint that the type specified is
2280 a union type. You can specify the type either with the @code{union}
2281 keyword or with a @code{typedef} name that refers to a union. The result
2282 of a cast to a union is a temporary rvalue of the union type with a member
2283 whose type matches that of the operand initialized to the value of
2284 the operand. The effect of a cast to a union is similar to a compound
2285 literal except that it yields an rvalue like standard casts do.
2286 @xref{Compound Literals}.
2287
2288 Expressions that may be cast to the union type are those whose type matches
2289 at least one of the members of the union. Thus, given the following union
2290 and variables:
2291
2292 @smallexample
2293 union foo @{ int i; double d; @};
2294 int x;
2295 double y;
2296 union foo z;
2297 @end smallexample
2298
2299 @noindent
2300 both @code{x} and @code{y} can be cast to type @code{union foo} and
2301 the following assignments
2302 @smallexample
2303 z = (union foo) x;
2304 z = (union foo) y;
2305 @end smallexample
2306 are shorthand equivalents of these
2307 @smallexample
2308 z = (union foo) @{ .i = x @};
2309 z = (union foo) @{ .d = y @};
2310 @end smallexample
2311
2312 However, @code{(union foo) FLT_MAX;} is not a valid cast because the union
2313 has no member of type @code{float}.
2314
2315 Using the cast as the right-hand side of an assignment to a variable of
2316 union type is equivalent to storing in a member of the union with
2317 the same type
2318
2319 @smallexample
2320 union foo u;
2321 /* @r{@dots{}} */
2322 u = (union foo) x @equiv{} u.i = x
2323 u = (union foo) y @equiv{} u.d = y
2324 @end smallexample
2325
2326 You can also use the union cast as a function argument:
2327
2328 @smallexample
2329 void hack (union foo);
2330 /* @r{@dots{}} */
2331 hack ((union foo) x);
2332 @end smallexample
2333
2334 @node Mixed Declarations
2335 @section Mixed Declarations and Code
2336 @cindex mixed declarations and code
2337 @cindex declarations, mixed with code
2338 @cindex code, mixed with declarations
2339
2340 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2341 within compound statements. As an extension, GNU C also allows this in
2342 C90 mode. For example, you could do:
2343
2344 @smallexample
2345 int i;
2346 /* @r{@dots{}} */
2347 i++;
2348 int j = i + 2;
2349 @end smallexample
2350
2351 Each identifier is visible from where it is declared until the end of
2352 the enclosing block.
2353
2354 @node Function Attributes
2355 @section Declaring Attributes of Functions
2356 @cindex function attributes
2357 @cindex declaring attributes of functions
2358 @cindex @code{volatile} applied to function
2359 @cindex @code{const} applied to function
2360
2361 In GNU C and C++, you can use function attributes to specify certain
2362 function properties that may help the compiler optimize calls or
2363 check code more carefully for correctness. For example, you
2364 can use attributes to specify that a function never returns
2365 (@code{noreturn}), returns a value depending only on the values of
2366 its arguments (@code{const}), or has @code{printf}-style arguments
2367 (@code{format}).
2368
2369 You can also use attributes to control memory placement, code
2370 generation options or call/return conventions within the function
2371 being annotated. Many of these attributes are target-specific. For
2372 example, many targets support attributes for defining interrupt
2373 handler functions, which typically must follow special register usage
2374 and return conventions. Such attributes are described in the subsection
2375 for each target. However, a considerable number of attributes are
2376 supported by most, if not all targets. Those are described in
2377 the @ref{Common Function Attributes} section.
2378
2379 Function attributes are introduced by the @code{__attribute__} keyword
2380 in the declaration of a function, followed by an attribute specification
2381 enclosed in double parentheses. You can specify multiple attributes in
2382 a declaration by separating them by commas within the double parentheses
2383 or by immediately following one attribute specification with another.
2384 @xref{Attribute Syntax}, for the exact rules on attribute syntax and
2385 placement. Compatible attribute specifications on distinct declarations
2386 of the same function are merged. An attribute specification that is not
2387 compatible with attributes already applied to a declaration of the same
2388 function is ignored with a warning.
2389
2390 Some function attributes take one or more arguments that refer to
2391 the function's parameters by their positions within the function parameter
2392 list. Such attribute arguments are referred to as @dfn{positional arguments}.
2393 Unless specified otherwise, positional arguments that specify properties
2394 of parameters with pointer types can also specify the same properties of
2395 the implicit C++ @code{this} argument in non-static member functions, and
2396 of parameters of reference to a pointer type. For ordinary functions,
2397 position one refers to the first parameter on the list. In C++ non-static
2398 member functions, position one refers to the implicit @code{this} pointer.
2399 The same restrictions and effects apply to function attributes used with
2400 ordinary functions or C++ member functions.
2401
2402 GCC also supports attributes on
2403 variable declarations (@pxref{Variable Attributes}),
2404 labels (@pxref{Label Attributes}),
2405 enumerators (@pxref{Enumerator Attributes}),
2406 statements (@pxref{Statement Attributes}),
2407 and types (@pxref{Type Attributes}).
2408
2409 There is some overlap between the purposes of attributes and pragmas
2410 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2411 found convenient to use @code{__attribute__} to achieve a natural
2412 attachment of attributes to their corresponding declarations, whereas
2413 @code{#pragma} is of use for compatibility with other compilers
2414 or constructs that do not naturally form part of the grammar.
2415
2416 In addition to the attributes documented here,
2417 GCC plugins may provide their own attributes.
2418
2419 @menu
2420 * Common Function Attributes::
2421 * AArch64 Function Attributes::
2422 * AMD GCN Function Attributes::
2423 * ARC Function Attributes::
2424 * ARM Function Attributes::
2425 * AVR Function Attributes::
2426 * Blackfin Function Attributes::
2427 * CR16 Function Attributes::
2428 * C-SKY Function Attributes::
2429 * Epiphany Function Attributes::
2430 * H8/300 Function Attributes::
2431 * IA-64 Function Attributes::
2432 * M32C Function Attributes::
2433 * M32R/D Function Attributes::
2434 * m68k Function Attributes::
2435 * MCORE Function Attributes::
2436 * MeP Function Attributes::
2437 * MicroBlaze Function Attributes::
2438 * Microsoft Windows Function Attributes::
2439 * MIPS Function Attributes::
2440 * MSP430 Function Attributes::
2441 * NDS32 Function Attributes::
2442 * Nios II Function Attributes::
2443 * Nvidia PTX Function Attributes::
2444 * PowerPC Function Attributes::
2445 * RISC-V Function Attributes::
2446 * RL78 Function Attributes::
2447 * RX Function Attributes::
2448 * S/390 Function Attributes::
2449 * SH Function Attributes::
2450 * SPU Function Attributes::
2451 * Symbian OS Function Attributes::
2452 * V850 Function Attributes::
2453 * Visium Function Attributes::
2454 * x86 Function Attributes::
2455 * Xstormy16 Function Attributes::
2456 @end menu
2457
2458 @node Common Function Attributes
2459 @subsection Common Function Attributes
2460
2461 The following attributes are supported on most targets.
2462
2463 @table @code
2464 @c Keep this table alphabetized by attribute name. Treat _ as space.
2465
2466 @item alias ("@var{target}")
2467 @cindex @code{alias} function attribute
2468 The @code{alias} attribute causes the declaration to be emitted as an
2469 alias for another symbol, which must be specified. For instance,
2470
2471 @smallexample
2472 void __f () @{ /* @r{Do something.} */; @}
2473 void f () __attribute__ ((weak, alias ("__f")));
2474 @end smallexample
2475
2476 @noindent
2477 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2478 mangled name for the target must be used. It is an error if @samp{__f}
2479 is not defined in the same translation unit.
2480
2481 This attribute requires assembler and object file support,
2482 and may not be available on all targets.
2483
2484 @item aligned
2485 @itemx aligned (@var{alignment})
2486 @cindex @code{aligned} function attribute
2487 The @code{aligned} attribute specifies a minimum alignment for
2488 the first instruction of the function, measured in bytes. When specified,
2489 @var{alignment} must be an integer constant power of 2. Specifying no
2490 @var{alignment} argument implies the ideal alignment for the target.
2491 The @code{__alignof__} operator can be used to determine what that is
2492 (@pxref{Alignment}). The attribute has no effect when a definition for
2493 the function is not provided in the same translation unit.
2494
2495 The attribute cannot be used to decrease the alignment of a function
2496 previously declared with a more restrictive alignment; only to increase
2497 it. Attempts to do otherwise are diagnosed. Some targets specify
2498 a minimum default alignment for functions that is greater than 1. On
2499 such targets, specifying a less restrictive alignment is silently ignored.
2500 Using the attribute overrides the effect of the @option{-falign-functions}
2501 (@pxref{Optimize Options}) option for this function.
2502
2503 Note that the effectiveness of @code{aligned} attributes may be
2504 limited by inherent limitations in the system linker
2505 and/or object file format. On some systems, the
2506 linker is only able to arrange for functions to be aligned up to a
2507 certain maximum alignment. (For some linkers, the maximum supported
2508 alignment may be very very small.) See your linker documentation for
2509 further information.
2510
2511 The @code{aligned} attribute can also be used for variables and fields
2512 (@pxref{Variable Attributes}.)
2513
2514 @item alloc_align (@var{position})
2515 @cindex @code{alloc_align} function attribute
2516 The @code{alloc_align} attribute may be applied to a function that
2517 returns a pointer and takes at least one argument of an integer or
2518 enumerated type.
2519 It indicates that the returned pointer is aligned on a boundary given
2520 by the function argument at @var{position}. Meaningful alignments are
2521 powers of 2 greater than one. GCC uses this information to improve
2522 pointer alignment analysis.
2523
2524 The function parameter denoting the allocated alignment is specified by
2525 one constant integer argument whose number is the argument of the attribute.
2526 Argument numbering starts at one.
2527
2528 For instance,
2529
2530 @smallexample
2531 void* my_memalign (size_t, size_t) __attribute__ ((alloc_align (1)));
2532 @end smallexample
2533
2534 @noindent
2535 declares that @code{my_memalign} returns memory with minimum alignment
2536 given by parameter 1.
2537
2538 @item alloc_size (@var{position})
2539 @itemx alloc_size (@var{position-1}, @var{position-2})
2540 @cindex @code{alloc_size} function attribute
2541 The @code{alloc_size} attribute may be applied to a function that
2542 returns a pointer and takes at least one argument of an integer or
2543 enumerated type.
2544 It indicates that the returned pointer points to memory whose size is
2545 given by the function argument at @var{position-1}, or by the product
2546 of the arguments at @var{position-1} and @var{position-2}. Meaningful
2547 sizes are positive values less than @code{PTRDIFF_MAX}. GCC uses this
2548 information to improve the results of @code{__builtin_object_size}.
2549
2550 The function parameter(s) denoting the allocated size are specified by
2551 one or two integer arguments supplied to the attribute. The allocated size
2552 is either the value of the single function argument specified or the product
2553 of the two function arguments specified. Argument numbering starts at
2554 one for ordinary functions, and at two for C++ non-static member functions.
2555
2556 For instance,
2557
2558 @smallexample
2559 void* my_calloc (size_t, size_t) __attribute__ ((alloc_size (1, 2)));
2560 void* my_realloc (void*, size_t) __attribute__ ((alloc_size (2)));
2561 @end smallexample
2562
2563 @noindent
2564 declares that @code{my_calloc} returns memory of the size given by
2565 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2566 of the size given by parameter 2.
2567
2568 @item always_inline
2569 @cindex @code{always_inline} function attribute
2570 Generally, functions are not inlined unless optimization is specified.
2571 For functions declared inline, this attribute inlines the function
2572 independent of any restrictions that otherwise apply to inlining.
2573 Failure to inline such a function is diagnosed as an error.
2574 Note that if such a function is called indirectly the compiler may
2575 or may not inline it depending on optimization level and a failure
2576 to inline an indirect call may or may not be diagnosed.
2577
2578 @item artificial
2579 @cindex @code{artificial} function attribute
2580 This attribute is useful for small inline wrappers that if possible
2581 should appear during debugging as a unit. Depending on the debug
2582 info format it either means marking the function as artificial
2583 or using the caller location for all instructions within the inlined
2584 body.
2585
2586 @item assume_aligned (@var{alignment})
2587 @itemx assume_aligned (@var{alignment}, @var{offset})
2588 @cindex @code{assume_aligned} function attribute
2589 The @code{assume_aligned} attribute may be applied to a function that
2590 returns a pointer. It indicates that the returned pointer is aligned
2591 on a boundary given by @var{alignment}. If the attribute has two
2592 arguments, the second argument is misalignment @var{offset}. Meaningful
2593 values of @var{alignment} are powers of 2 greater than one. Meaningful
2594 values of @var{offset} are greater than zero and less than @var{alignment}.
2595
2596 For instance
2597
2598 @smallexample
2599 void* my_alloc1 (size_t) __attribute__((assume_aligned (16)));
2600 void* my_alloc2 (size_t) __attribute__((assume_aligned (32, 8)));
2601 @end smallexample
2602
2603 @noindent
2604 declares that @code{my_alloc1} returns 16-byte aligned pointers and
2605 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2606 to 8.
2607
2608 @item cold
2609 @cindex @code{cold} function attribute
2610 The @code{cold} attribute on functions is used to inform the compiler that
2611 the function is unlikely to be executed. The function is optimized for
2612 size rather than speed and on many targets it is placed into a special
2613 subsection of the text section so all cold functions appear close together,
2614 improving code locality of non-cold parts of program. The paths leading
2615 to calls of cold functions within code are marked as unlikely by the branch
2616 prediction mechanism. It is thus useful to mark functions used to handle
2617 unlikely conditions, such as @code{perror}, as cold to improve optimization
2618 of hot functions that do call marked functions in rare occasions.
2619
2620 When profile feedback is available, via @option{-fprofile-use}, cold functions
2621 are automatically detected and this attribute is ignored.
2622
2623 @item const
2624 @cindex @code{const} function attribute
2625 @cindex functions that have no side effects
2626 Calls to functions whose return value is not affected by changes to
2627 the observable state of the program and that have no observable effects
2628 on such state other than to return a value may lend themselves to
2629 optimizations such as common subexpression elimination. Declaring such
2630 functions with the @code{const} attribute allows GCC to avoid emitting
2631 some calls in repeated invocations of the function with the same argument
2632 values.
2633
2634 For example,
2635
2636 @smallexample
2637 int square (int) __attribute__ ((const));
2638 @end smallexample
2639
2640 @noindent
2641 tells GCC that subsequent calls to function @code{square} with the same
2642 argument value can be replaced by the result of the first call regardless
2643 of the statements in between.
2644
2645 The @code{const} attribute prohibits a function from reading objects
2646 that affect its return value between successive invocations. However,
2647 functions declared with the attribute can safely read objects that do
2648 not change their return value, such as non-volatile constants.
2649
2650 The @code{const} attribute imposes greater restrictions on a function's
2651 definition than the similar @code{pure} attribute. Declaring the same
2652 function with both the @code{const} and the @code{pure} attribute is
2653 diagnosed. Because a const function cannot have any observable side
2654 effects it does not make sense for it to return @code{void}. Declaring
2655 such a function is diagnosed.
2656
2657 @cindex pointer arguments
2658 Note that a function that has pointer arguments and examines the data
2659 pointed to must @emph{not} be declared @code{const} if the pointed-to
2660 data might change between successive invocations of the function. In
2661 general, since a function cannot distinguish data that might change
2662 from data that cannot, const functions should never take pointer or,
2663 in C++, reference arguments. Likewise, a function that calls a non-const
2664 function usually must not be const itself.
2665
2666 @item constructor
2667 @itemx destructor
2668 @itemx constructor (@var{priority})
2669 @itemx destructor (@var{priority})
2670 @cindex @code{constructor} function attribute
2671 @cindex @code{destructor} function attribute
2672 The @code{constructor} attribute causes the function to be called
2673 automatically before execution enters @code{main ()}. Similarly, the
2674 @code{destructor} attribute causes the function to be called
2675 automatically after @code{main ()} completes or @code{exit ()} is
2676 called. Functions with these attributes are useful for
2677 initializing data that is used implicitly during the execution of
2678 the program.
2679
2680 On some targets the attributes also accept an integer argument to
2681 specify a priority to control the order in which constructor and
2682 destructor functions are run. A constructor
2683 with a smaller priority number runs before a constructor with a larger
2684 priority number; the opposite relationship holds for destructors. So,
2685 if you have a constructor that allocates a resource and a destructor
2686 that deallocates the same resource, both functions typically have the
2687 same priority. The priorities for constructor and destructor
2688 functions are the same as those specified for namespace-scope C++
2689 objects (@pxref{C++ Attributes}). However, at present, the order in which
2690 constructors for C++ objects with static storage duration and functions
2691 decorated with attribute @code{constructor} are invoked is unspecified.
2692 In mixed declarations, attribute @code{init_priority} can be used to
2693 impose a specific ordering.
2694
2695 Using the argument forms of the @code{constructor} and @code{destructor}
2696 attributes on targets where the feature is not supported is rejected with
2697 an error.
2698
2699 @item copy
2700 @itemx copy (@var{function})
2701 @cindex @code{copy} function attribute
2702 The @code{copy} attribute applies the set of attributes with which
2703 @var{function} has been declared to the declaration of the function
2704 to which the attribute is applied. The attribute is designed for
2705 libraries that define aliases or function resolvers that are expected
2706 to specify the same set of attributes as their targets. The @code{copy}
2707 attribute can be used with functions, variables, or types. However,
2708 the kind of symbol to which the attribute is applied (either function
2709 or variable) must match the kind of symbol to which the argument refers.
2710 The @code{copy} attribute copies only syntactic and semantic attributes
2711 but not attributes that affect a symbol's linkage or visibility such as
2712 @code{alias}, @code{visibility}, or @code{weak}. The @code{deprecated}
2713 attribute is also not copied. @xref{Common Type Attributes}.
2714 @xref{Common Variable Attributes}.
2715
2716 For example, the @var{StrongAlias} macro below makes use of the @code{alias}
2717 and @code{copy} attributes to define an alias named @var{alloc} for function
2718 @var{allocate} declared with attributes @var{alloc_size}, @var{malloc}, and
2719 @var{nothrow}. Thanks to the @code{__typeof__} operator the alias has
2720 the same type as the target function. As a result of the @code{copy}
2721 attribute the alias also shares the same attributes as the target.
2722
2723 @smallexample
2724 #define StrongAlias(TagetFunc, AliasDecl) \
2725 extern __typeof__ (TargetFunc) AliasDecl \
2726 __attribute__ ((alias (#TargetFunc), copy (TargetFunc)));
2727
2728 extern __attribute__ ((alloc_size (1), malloc, nothrow))
2729 void* allocate (size_t);
2730 StrongAlias (allocate, alloc);
2731 @end smallexample
2732
2733 @item deprecated
2734 @itemx deprecated (@var{msg})
2735 @cindex @code{deprecated} function attribute
2736 The @code{deprecated} attribute results in a warning if the function
2737 is used anywhere in the source file. This is useful when identifying
2738 functions that are expected to be removed in a future version of a
2739 program. The warning also includes the location of the declaration
2740 of the deprecated function, to enable users to easily find further
2741 information about why the function is deprecated, or what they should
2742 do instead. Note that the warnings only occurs for uses:
2743
2744 @smallexample
2745 int old_fn () __attribute__ ((deprecated));
2746 int old_fn ();
2747 int (*fn_ptr)() = old_fn;
2748 @end smallexample
2749
2750 @noindent
2751 results in a warning on line 3 but not line 2. The optional @var{msg}
2752 argument, which must be a string, is printed in the warning if
2753 present.
2754
2755 The @code{deprecated} attribute can also be used for variables and
2756 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2757
2758 The message attached to the attribute is affected by the setting of
2759 the @option{-fmessage-length} option.
2760
2761 @item error ("@var{message}")
2762 @itemx warning ("@var{message}")
2763 @cindex @code{error} function attribute
2764 @cindex @code{warning} function attribute
2765 If the @code{error} or @code{warning} attribute
2766 is used on a function declaration and a call to such a function
2767 is not eliminated through dead code elimination or other optimizations,
2768 an error or warning (respectively) that includes @var{message} is diagnosed.
2769 This is useful
2770 for compile-time checking, especially together with @code{__builtin_constant_p}
2771 and inline functions where checking the inline function arguments is not
2772 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2773
2774 While it is possible to leave the function undefined and thus invoke
2775 a link failure (to define the function with
2776 a message in @code{.gnu.warning*} section),
2777 when using these attributes the problem is diagnosed
2778 earlier and with exact location of the call even in presence of inline
2779 functions or when not emitting debugging information.
2780
2781 @item externally_visible
2782 @cindex @code{externally_visible} function attribute
2783 This attribute, attached to a global variable or function, nullifies
2784 the effect of the @option{-fwhole-program} command-line option, so the
2785 object remains visible outside the current compilation unit.
2786
2787 If @option{-fwhole-program} is used together with @option{-flto} and
2788 @command{gold} is used as the linker plugin,
2789 @code{externally_visible} attributes are automatically added to functions
2790 (not variable yet due to a current @command{gold} issue)
2791 that are accessed outside of LTO objects according to resolution file
2792 produced by @command{gold}.
2793 For other linkers that cannot generate resolution file,
2794 explicit @code{externally_visible} attributes are still necessary.
2795
2796 @item flatten
2797 @cindex @code{flatten} function attribute
2798 Generally, inlining into a function is limited. For a function marked with
2799 this attribute, every call inside this function is inlined, if possible.
2800 Functions declared with attribute @code{noinline} and similar are not
2801 inlined. Whether the function itself is considered for inlining depends
2802 on its size and the current inlining parameters.
2803
2804 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2805 @cindex @code{format} function attribute
2806 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2807 @opindex Wformat
2808 The @code{format} attribute specifies that a function takes @code{printf},
2809 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2810 should be type-checked against a format string. For example, the
2811 declaration:
2812
2813 @smallexample
2814 extern int
2815 my_printf (void *my_object, const char *my_format, ...)
2816 __attribute__ ((format (printf, 2, 3)));
2817 @end smallexample
2818
2819 @noindent
2820 causes the compiler to check the arguments in calls to @code{my_printf}
2821 for consistency with the @code{printf} style format string argument
2822 @code{my_format}.
2823
2824 The parameter @var{archetype} determines how the format string is
2825 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2826 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2827 @code{strfmon}. (You can also use @code{__printf__},
2828 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2829 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2830 @code{ms_strftime} are also present.
2831 @var{archetype} values such as @code{printf} refer to the formats accepted
2832 by the system's C runtime library,
2833 while values prefixed with @samp{gnu_} always refer
2834 to the formats accepted by the GNU C Library. On Microsoft Windows
2835 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2836 @file{msvcrt.dll} library.
2837 The parameter @var{string-index}
2838 specifies which argument is the format string argument (starting
2839 from 1), while @var{first-to-check} is the number of the first
2840 argument to check against the format string. For functions
2841 where the arguments are not available to be checked (such as
2842 @code{vprintf}), specify the third parameter as zero. In this case the
2843 compiler only checks the format string for consistency. For
2844 @code{strftime} formats, the third parameter is required to be zero.
2845 Since non-static C++ methods have an implicit @code{this} argument, the
2846 arguments of such methods should be counted from two, not one, when
2847 giving values for @var{string-index} and @var{first-to-check}.
2848
2849 In the example above, the format string (@code{my_format}) is the second
2850 argument of the function @code{my_print}, and the arguments to check
2851 start with the third argument, so the correct parameters for the format
2852 attribute are 2 and 3.
2853
2854 @opindex ffreestanding
2855 @opindex fno-builtin
2856 The @code{format} attribute allows you to identify your own functions
2857 that take format strings as arguments, so that GCC can check the
2858 calls to these functions for errors. The compiler always (unless
2859 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2860 for the standard library functions @code{printf}, @code{fprintf},
2861 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2862 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2863 warnings are requested (using @option{-Wformat}), so there is no need to
2864 modify the header file @file{stdio.h}. In C99 mode, the functions
2865 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2866 @code{vsscanf} are also checked. Except in strictly conforming C
2867 standard modes, the X/Open function @code{strfmon} is also checked as
2868 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2869 @xref{C Dialect Options,,Options Controlling C Dialect}.
2870
2871 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2872 recognized in the same context. Declarations including these format attributes
2873 are parsed for correct syntax, however the result of checking of such format
2874 strings is not yet defined, and is not carried out by this version of the
2875 compiler.
2876
2877 The target may also provide additional types of format checks.
2878 @xref{Target Format Checks,,Format Checks Specific to Particular
2879 Target Machines}.
2880
2881 @item format_arg (@var{string-index})
2882 @cindex @code{format_arg} function attribute
2883 @opindex Wformat-nonliteral
2884 The @code{format_arg} attribute specifies that a function takes one or
2885 more format strings for a @code{printf}, @code{scanf}, @code{strftime} or
2886 @code{strfmon} style function and modifies it (for example, to translate
2887 it into another language), so the result can be passed to a
2888 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2889 function (with the remaining arguments to the format function the same
2890 as they would have been for the unmodified string). Multiple
2891 @code{format_arg} attributes may be applied to the same function, each
2892 designating a distinct parameter as a format string. For example, the
2893 declaration:
2894
2895 @smallexample
2896 extern char *
2897 my_dgettext (char *my_domain, const char *my_format)
2898 __attribute__ ((format_arg (2)));
2899 @end smallexample
2900
2901 @noindent
2902 causes the compiler to check the arguments in calls to a @code{printf},
2903 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2904 format string argument is a call to the @code{my_dgettext} function, for
2905 consistency with the format string argument @code{my_format}. If the
2906 @code{format_arg} attribute had not been specified, all the compiler
2907 could tell in such calls to format functions would be that the format
2908 string argument is not constant; this would generate a warning when
2909 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2910 without the attribute.
2911
2912 In calls to a function declared with more than one @code{format_arg}
2913 attribute, each with a distinct argument value, the corresponding
2914 actual function arguments are checked against all format strings
2915 designated by the attributes. This capability is designed to support
2916 the GNU @code{ngettext} family of functions.
2917
2918 The parameter @var{string-index} specifies which argument is the format
2919 string argument (starting from one). Since non-static C++ methods have
2920 an implicit @code{this} argument, the arguments of such methods should
2921 be counted from two.
2922
2923 The @code{format_arg} attribute allows you to identify your own
2924 functions that modify format strings, so that GCC can check the
2925 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2926 type function whose operands are a call to one of your own function.
2927 The compiler always treats @code{gettext}, @code{dgettext}, and
2928 @code{dcgettext} in this manner except when strict ISO C support is
2929 requested by @option{-ansi} or an appropriate @option{-std} option, or
2930 @option{-ffreestanding} or @option{-fno-builtin}
2931 is used. @xref{C Dialect Options,,Options
2932 Controlling C Dialect}.
2933
2934 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2935 @code{NSString} reference for compatibility with the @code{format} attribute
2936 above.
2937
2938 The target may also allow additional types in @code{format-arg} attributes.
2939 @xref{Target Format Checks,,Format Checks Specific to Particular
2940 Target Machines}.
2941
2942 @item gnu_inline
2943 @cindex @code{gnu_inline} function attribute
2944 This attribute should be used with a function that is also declared
2945 with the @code{inline} keyword. It directs GCC to treat the function
2946 as if it were defined in gnu90 mode even when compiling in C99 or
2947 gnu99 mode.
2948
2949 If the function is declared @code{extern}, then this definition of the
2950 function is used only for inlining. In no case is the function
2951 compiled as a standalone function, not even if you take its address
2952 explicitly. Such an address becomes an external reference, as if you
2953 had only declared the function, and had not defined it. This has
2954 almost the effect of a macro. The way to use this is to put a
2955 function definition in a header file with this attribute, and put
2956 another copy of the function, without @code{extern}, in a library
2957 file. The definition in the header file causes most calls to the
2958 function to be inlined. If any uses of the function remain, they
2959 refer to the single copy in the library. Note that the two
2960 definitions of the functions need not be precisely the same, although
2961 if they do not have the same effect your program may behave oddly.
2962
2963 In C, if the function is neither @code{extern} nor @code{static}, then
2964 the function is compiled as a standalone function, as well as being
2965 inlined where possible.
2966
2967 This is how GCC traditionally handled functions declared
2968 @code{inline}. Since ISO C99 specifies a different semantics for
2969 @code{inline}, this function attribute is provided as a transition
2970 measure and as a useful feature in its own right. This attribute is
2971 available in GCC 4.1.3 and later. It is available if either of the
2972 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2973 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2974 Function is As Fast As a Macro}.
2975
2976 In C++, this attribute does not depend on @code{extern} in any way,
2977 but it still requires the @code{inline} keyword to enable its special
2978 behavior.
2979
2980 @item hot
2981 @cindex @code{hot} function attribute
2982 The @code{hot} attribute on a function is used to inform the compiler that
2983 the function is a hot spot of the compiled program. The function is
2984 optimized more aggressively and on many targets it is placed into a special
2985 subsection of the text section so all hot functions appear close together,
2986 improving locality.
2987
2988 When profile feedback is available, via @option{-fprofile-use}, hot functions
2989 are automatically detected and this attribute is ignored.
2990
2991 @item ifunc ("@var{resolver}")
2992 @cindex @code{ifunc} function attribute
2993 @cindex indirect functions
2994 @cindex functions that are dynamically resolved
2995 The @code{ifunc} attribute is used to mark a function as an indirect
2996 function using the STT_GNU_IFUNC symbol type extension to the ELF
2997 standard. This allows the resolution of the symbol value to be
2998 determined dynamically at load time, and an optimized version of the
2999 routine to be selected for the particular processor or other system
3000 characteristics determined then. To use this attribute, first define
3001 the implementation functions available, and a resolver function that
3002 returns a pointer to the selected implementation function. The
3003 implementation functions' declarations must match the API of the
3004 function being implemented. The resolver should be declared to
3005 be a function taking no arguments and returning a pointer to
3006 a function of the same type as the implementation. For example:
3007
3008 @smallexample
3009 void *my_memcpy (void *dst, const void *src, size_t len)
3010 @{
3011 @dots{}
3012 return dst;
3013 @}
3014
3015 static void * (*resolve_memcpy (void))(void *, const void *, size_t)
3016 @{
3017 return my_memcpy; // we will just always select this routine
3018 @}
3019 @end smallexample
3020
3021 @noindent
3022 The exported header file declaring the function the user calls would
3023 contain:
3024
3025 @smallexample
3026 extern void *memcpy (void *, const void *, size_t);
3027 @end smallexample
3028
3029 @noindent
3030 allowing the user to call @code{memcpy} as a regular function, unaware of
3031 the actual implementation. Finally, the indirect function needs to be
3032 defined in the same translation unit as the resolver function:
3033
3034 @smallexample
3035 void *memcpy (void *, const void *, size_t)
3036 __attribute__ ((ifunc ("resolve_memcpy")));
3037 @end smallexample
3038
3039 In C++, the @code{ifunc} attribute takes a string that is the mangled name
3040 of the resolver function. A C++ resolver for a non-static member function
3041 of class @code{C} should be declared to return a pointer to a non-member
3042 function taking pointer to @code{C} as the first argument, followed by
3043 the same arguments as of the implementation function. G++ checks
3044 the signatures of the two functions and issues
3045 a @option{-Wattribute-alias} warning for mismatches. To suppress a warning
3046 for the necessary cast from a pointer to the implementation member function
3047 to the type of the corresponding non-member function use
3048 the @option{-Wno-pmf-conversions} option. For example:
3049
3050 @smallexample
3051 class S
3052 @{
3053 private:
3054 int debug_impl (int);
3055 int optimized_impl (int);
3056
3057 typedef int Func (S*, int);
3058
3059 static Func* resolver ();
3060 public:
3061
3062 int interface (int);
3063 @};
3064
3065 int S::debug_impl (int) @{ /* @r{@dots{}} */ @}
3066 int S::optimized_impl (int) @{ /* @r{@dots{}} */ @}
3067
3068 S::Func* S::resolver ()
3069 @{
3070 int (S::*pimpl) (int)
3071 = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl;
3072
3073 // Cast triggers -Wno-pmf-conversions.
3074 return reinterpret_cast<Func*>(pimpl);
3075 @}
3076
3077 int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv")));
3078 @end smallexample
3079
3080 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
3081 and GNU C Library version 2.11.1 are required to use this feature.
3082
3083 @item interrupt
3084 @itemx interrupt_handler
3085 Many GCC back ends support attributes to indicate that a function is
3086 an interrupt handler, which tells the compiler to generate function
3087 entry and exit sequences that differ from those from regular
3088 functions. The exact syntax and behavior are target-specific;
3089 refer to the following subsections for details.
3090
3091 @item leaf
3092 @cindex @code{leaf} function attribute
3093 Calls to external functions with this attribute must return to the
3094 current compilation unit only by return or by exception handling. In
3095 particular, a leaf function is not allowed to invoke callback functions
3096 passed to it from the current compilation unit, directly call functions
3097 exported by the unit, or @code{longjmp} into the unit. Leaf functions
3098 might still call functions from other compilation units and thus they
3099 are not necessarily leaf in the sense that they contain no function
3100 calls at all.
3101
3102 The attribute is intended for library functions to improve dataflow
3103 analysis. The compiler takes the hint that any data not escaping the
3104 current compilation unit cannot be used or modified by the leaf
3105 function. For example, the @code{sin} function is a leaf function, but
3106 @code{qsort} is not.
3107
3108 Note that leaf functions might indirectly run a signal handler defined
3109 in the current compilation unit that uses static variables. Similarly,
3110 when lazy symbol resolution is in effect, leaf functions might invoke
3111 indirect functions whose resolver function or implementation function is
3112 defined in the current compilation unit and uses static variables. There
3113 is no standard-compliant way to write such a signal handler, resolver
3114 function, or implementation function, and the best that you can do is to
3115 remove the @code{leaf} attribute or mark all such static variables
3116 @code{volatile}. Lastly, for ELF-based systems that support symbol
3117 interposition, care should be taken that functions defined in the
3118 current compilation unit do not unexpectedly interpose other symbols
3119 based on the defined standards mode and defined feature test macros;
3120 otherwise an inadvertent callback would be added.
3121
3122 The attribute has no effect on functions defined within the current
3123 compilation unit. This is to allow easy merging of multiple compilation
3124 units into one, for example, by using the link-time optimization. For
3125 this reason the attribute is not allowed on types to annotate indirect
3126 calls.
3127
3128 @item malloc
3129 @cindex @code{malloc} function attribute
3130 @cindex functions that behave like malloc
3131 This tells the compiler that a function is @code{malloc}-like, i.e.,
3132 that the pointer @var{P} returned by the function cannot alias any
3133 other pointer valid when the function returns, and moreover no
3134 pointers to valid objects occur in any storage addressed by @var{P}.
3135
3136 Using this attribute can improve optimization. Compiler predicts
3137 that a function with the attribute returns non-null in most cases.
3138 Functions like
3139 @code{malloc} and @code{calloc} have this property because they return
3140 a pointer to uninitialized or zeroed-out storage. However, functions
3141 like @code{realloc} do not have this property, as they can return a
3142 pointer to storage containing pointers.
3143
3144 @item no_icf
3145 @cindex @code{no_icf} function attribute
3146 This function attribute prevents a functions from being merged with another
3147 semantically equivalent function.
3148
3149 @item no_instrument_function
3150 @cindex @code{no_instrument_function} function attribute
3151 @opindex finstrument-functions
3152 @opindex p
3153 @opindex pg
3154 If any of @option{-finstrument-functions}, @option{-p}, or @option{-pg} are
3155 given, profiling function calls are
3156 generated at entry and exit of most user-compiled functions.
3157 Functions with this attribute are not so instrumented.
3158
3159 @item no_profile_instrument_function
3160 @cindex @code{no_profile_instrument_function} function attribute
3161 The @code{no_profile_instrument_function} attribute on functions is used
3162 to inform the compiler that it should not process any profile feedback based
3163 optimization code instrumentation.
3164
3165 @item no_reorder
3166 @cindex @code{no_reorder} function attribute
3167 Do not reorder functions or variables marked @code{no_reorder}
3168 against each other or top level assembler statements the executable.
3169 The actual order in the program will depend on the linker command
3170 line. Static variables marked like this are also not removed.
3171 This has a similar effect
3172 as the @option{-fno-toplevel-reorder} option, but only applies to the
3173 marked symbols.
3174
3175 @item no_sanitize ("@var{sanitize_option}")
3176 @cindex @code{no_sanitize} function attribute
3177 The @code{no_sanitize} attribute on functions is used
3178 to inform the compiler that it should not do sanitization of all options
3179 mentioned in @var{sanitize_option}. A list of values acceptable by
3180 @option{-fsanitize} option can be provided.
3181
3182 @smallexample
3183 void __attribute__ ((no_sanitize ("alignment", "object-size")))
3184 f () @{ /* @r{Do something.} */; @}
3185 void __attribute__ ((no_sanitize ("alignment,object-size")))
3186 g () @{ /* @r{Do something.} */; @}
3187 @end smallexample
3188
3189 @item no_sanitize_address
3190 @itemx no_address_safety_analysis
3191 @cindex @code{no_sanitize_address} function attribute
3192 The @code{no_sanitize_address} attribute on functions is used
3193 to inform the compiler that it should not instrument memory accesses
3194 in the function when compiling with the @option{-fsanitize=address} option.
3195 The @code{no_address_safety_analysis} is a deprecated alias of the
3196 @code{no_sanitize_address} attribute, new code should use
3197 @code{no_sanitize_address}.
3198
3199 @item no_sanitize_thread
3200 @cindex @code{no_sanitize_thread} function attribute
3201 The @code{no_sanitize_thread} attribute on functions is used
3202 to inform the compiler that it should not instrument memory accesses
3203 in the function when compiling with the @option{-fsanitize=thread} option.
3204
3205 @item no_sanitize_undefined
3206 @cindex @code{no_sanitize_undefined} function attribute
3207 The @code{no_sanitize_undefined} attribute on functions is used
3208 to inform the compiler that it should not check for undefined behavior
3209 in the function when compiling with the @option{-fsanitize=undefined} option.
3210
3211 @item no_split_stack
3212 @cindex @code{no_split_stack} function attribute
3213 @opindex fsplit-stack
3214 If @option{-fsplit-stack} is given, functions have a small
3215 prologue which decides whether to split the stack. Functions with the
3216 @code{no_split_stack} attribute do not have that prologue, and thus
3217 may run with only a small amount of stack space available.
3218
3219 @item no_stack_limit
3220 @cindex @code{no_stack_limit} function attribute
3221 This attribute locally overrides the @option{-fstack-limit-register}
3222 and @option{-fstack-limit-symbol} command-line options; it has the effect
3223 of disabling stack limit checking in the function it applies to.
3224
3225 @item noclone
3226 @cindex @code{noclone} function attribute
3227 This function attribute prevents a function from being considered for
3228 cloning---a mechanism that produces specialized copies of functions
3229 and which is (currently) performed by interprocedural constant
3230 propagation.
3231
3232 @item noinline
3233 @cindex @code{noinline} function attribute
3234 This function attribute prevents a function from being considered for
3235 inlining.
3236 @c Don't enumerate the optimizations by name here; we try to be
3237 @c future-compatible with this mechanism.
3238 If the function does not have side effects, there are optimizations
3239 other than inlining that cause function calls to be optimized away,
3240 although the function call is live. To keep such calls from being
3241 optimized away, put
3242 @smallexample
3243 asm ("");
3244 @end smallexample
3245
3246 @noindent
3247 (@pxref{Extended Asm}) in the called function, to serve as a special
3248 side effect.
3249
3250 @item noipa
3251 @cindex @code{noipa} function attribute
3252 Disable interprocedural optimizations between the function with this
3253 attribute and its callers, as if the body of the function is not available
3254 when optimizing callers and the callers are unavailable when optimizing
3255 the body. This attribute implies @code{noinline}, @code{noclone} and
3256 @code{no_icf} attributes. However, this attribute is not equivalent
3257 to a combination of other attributes, because its purpose is to suppress
3258 existing and future optimizations employing interprocedural analysis,
3259 including those that do not have an attribute suitable for disabling
3260 them individually. This attribute is supported mainly for the purpose
3261 of testing the compiler.
3262
3263 @item nonnull
3264 @itemx nonnull (@var{arg-index}, @dots{})
3265 @cindex @code{nonnull} function attribute
3266 @cindex functions with non-null pointer arguments
3267 The @code{nonnull} attribute may be applied to a function that takes at
3268 least one argument of a pointer type. It indicates that the referenced
3269 arguments must be non-null pointers. For instance, the declaration:
3270
3271 @smallexample
3272 extern void *
3273 my_memcpy (void *dest, const void *src, size_t len)
3274 __attribute__((nonnull (1, 2)));
3275 @end smallexample
3276
3277 @noindent
3278 causes the compiler to check that, in calls to @code{my_memcpy},
3279 arguments @var{dest} and @var{src} are non-null. If the compiler
3280 determines that a null pointer is passed in an argument slot marked
3281 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3282 is issued. @xref{Warning Options}. Unless disabled by
3283 the @option{-fno-delete-null-pointer-checks} option the compiler may
3284 also perform optimizations based on the knowledge that certain function
3285 arguments cannot be null. In addition,
3286 the @option{-fisolate-erroneous-paths-attribute} option can be specified
3287 to have GCC transform calls with null arguments to non-null functions
3288 into traps. @xref{Optimize Options}.
3289
3290 If no @var{arg-index} is given to the @code{nonnull} attribute,
3291 all pointer arguments are marked as non-null. To illustrate, the
3292 following declaration is equivalent to the previous example:
3293
3294 @smallexample
3295 extern void *
3296 my_memcpy (void *dest, const void *src, size_t len)
3297 __attribute__((nonnull));
3298 @end smallexample
3299
3300 @item noplt
3301 @cindex @code{noplt} function attribute
3302 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3303 Calls to functions marked with this attribute in position-independent code
3304 do not use the PLT.
3305
3306 @smallexample
3307 @group
3308 /* Externally defined function foo. */
3309 int foo () __attribute__ ((noplt));
3310
3311 int
3312 main (/* @r{@dots{}} */)
3313 @{
3314 /* @r{@dots{}} */
3315 foo ();
3316 /* @r{@dots{}} */
3317 @}
3318 @end group
3319 @end smallexample
3320
3321 The @code{noplt} attribute on function @code{foo}
3322 tells the compiler to assume that
3323 the function @code{foo} is externally defined and that the call to
3324 @code{foo} must avoid the PLT
3325 in position-independent code.
3326
3327 In position-dependent code, a few targets also convert calls to
3328 functions that are marked to not use the PLT to use the GOT instead.
3329
3330 @item noreturn
3331 @cindex @code{noreturn} function attribute
3332 @cindex functions that never return
3333 A few standard library functions, such as @code{abort} and @code{exit},
3334 cannot return. GCC knows this automatically. Some programs define
3335 their own functions that never return. You can declare them
3336 @code{noreturn} to tell the compiler this fact. For example,
3337
3338 @smallexample
3339 @group
3340 void fatal () __attribute__ ((noreturn));
3341
3342 void
3343 fatal (/* @r{@dots{}} */)
3344 @{
3345 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3346 exit (1);
3347 @}
3348 @end group
3349 @end smallexample
3350
3351 The @code{noreturn} keyword tells the compiler to assume that
3352 @code{fatal} cannot return. It can then optimize without regard to what
3353 would happen if @code{fatal} ever did return. This makes slightly
3354 better code. More importantly, it helps avoid spurious warnings of
3355 uninitialized variables.
3356
3357 The @code{noreturn} keyword does not affect the exceptional path when that
3358 applies: a @code{noreturn}-marked function may still return to the caller
3359 by throwing an exception or calling @code{longjmp}.
3360
3361 In order to preserve backtraces, GCC will never turn calls to
3362 @code{noreturn} functions into tail calls.
3363
3364 Do not assume that registers saved by the calling function are
3365 restored before calling the @code{noreturn} function.
3366
3367 It does not make sense for a @code{noreturn} function to have a return
3368 type other than @code{void}.
3369
3370 @item nothrow
3371 @cindex @code{nothrow} function attribute
3372 The @code{nothrow} attribute is used to inform the compiler that a
3373 function cannot throw an exception. For example, most functions in
3374 the standard C library can be guaranteed not to throw an exception
3375 with the notable exceptions of @code{qsort} and @code{bsearch} that
3376 take function pointer arguments.
3377
3378 @item optimize (@var{level}, @dots{})
3379 @item optimize (@var{string}, @dots{})
3380 @cindex @code{optimize} function attribute
3381 The @code{optimize} attribute is used to specify that a function is to
3382 be compiled with different optimization options than specified on the
3383 command line. Valid arguments are constant non-negative integers and
3384 strings. Each numeric argument specifies an optimization @var{level}.
3385 Each @var{string} argument consists of one or more comma-separated
3386 substrings. Each substring that begins with the letter @code{O} refers
3387 to an optimization option such as @option{-O0} or @option{-Os}. Other
3388 substrings are taken as suffixes to the @code{-f} prefix jointly
3389 forming the name of an optimization option. @xref{Optimize Options}.
3390
3391 @samp{#pragma GCC optimize} can be used to set optimization options
3392 for more than one function. @xref{Function Specific Option Pragmas},
3393 for details about the pragma.
3394
3395 Providing multiple strings as arguments separated by commas to specify
3396 multiple options is equivalent to separating the option suffixes with
3397 a comma (@samp{,}) within a single string. Spaces are not permitted
3398 within the strings.
3399
3400 Not every optimization option that starts with the @var{-f} prefix
3401 specified by the attribute necessarily has an effect on the function.
3402 The @code{optimize} attribute should be used for debugging purposes only.
3403 It is not suitable in production code.
3404
3405 @item patchable_function_entry
3406 @cindex @code{patchable_function_entry} function attribute
3407 @cindex extra NOP instructions at the function entry point
3408 In case the target's text segment can be made writable at run time by
3409 any means, padding the function entry with a number of NOPs can be
3410 used to provide a universal tool for instrumentation.
3411
3412 The @code{patchable_function_entry} function attribute can be used to
3413 change the number of NOPs to any desired value. The two-value syntax
3414 is the same as for the command-line switch
3415 @option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with
3416 the function entry point before the @var{M}th NOP instruction.
3417 @var{M} defaults to 0 if omitted e.g.@: function entry point is before
3418 the first NOP.
3419
3420 If patchable function entries are enabled globally using the command-line
3421 option @option{-fpatchable-function-entry=N,M}, then you must disable
3422 instrumentation on all functions that are part of the instrumentation
3423 framework with the attribute @code{patchable_function_entry (0)}
3424 to prevent recursion.
3425
3426 @item pure
3427 @cindex @code{pure} function attribute
3428 @cindex functions that have no side effects
3429
3430 Calls to functions that have no observable effects on the state of
3431 the program other than to return a value may lend themselves to optimizations
3432 such as common subexpression elimination. Declaring such functions with
3433 the @code{pure} attribute allows GCC to avoid emitting some calls in repeated
3434 invocations of the function with the same argument values.
3435
3436 The @code{pure} attribute prohibits a function from modifying the state
3437 of the program that is observable by means other than inspecting
3438 the function's return value. However, functions declared with the @code{pure}
3439 attribute can safely read any non-volatile objects, and modify the value of
3440 objects in a way that does not affect their return value or the observable
3441 state of the program.
3442
3443 For example,
3444
3445 @smallexample
3446 int hash (char *) __attribute__ ((pure));
3447 @end smallexample
3448
3449 @noindent
3450 tells GCC that subsequent calls to the function @code{hash} with the same
3451 string can be replaced by the result of the first call provided the state
3452 of the program observable by @code{hash}, including the contents of the array
3453 itself, does not change in between. Even though @code{hash} takes a non-const
3454 pointer argument it must not modify the array it points to, or any other object
3455 whose value the rest of the program may depend on. However, the caller may
3456 safely change the contents of the array between successive calls to
3457 the function (doing so disables the optimization). The restriction also
3458 applies to member objects referenced by the @code{this} pointer in C++
3459 non-static member functions.
3460
3461 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3462 Interesting non-pure functions are functions with infinite loops or those
3463 depending on volatile memory or other system resource, that may change between
3464 consecutive calls (such as the standard C @code{feof} function in
3465 a multithreading environment).
3466
3467 The @code{pure} attribute imposes similar but looser restrictions on
3468 a function's definition than the @code{const} attribute: @code{pure}
3469 allows the function to read any non-volatile memory, even if it changes
3470 in between successive invocations of the function. Declaring the same
3471 function with both the @code{pure} and the @code{const} attribute is
3472 diagnosed. Because a pure function cannot have any observable side
3473 effects it does not make sense for such a function to return @code{void}.
3474 Declaring such a function is diagnosed.
3475
3476 @item returns_nonnull
3477 @cindex @code{returns_nonnull} function attribute
3478 The @code{returns_nonnull} attribute specifies that the function
3479 return value should be a non-null pointer. For instance, the declaration:
3480
3481 @smallexample
3482 extern void *
3483 mymalloc (size_t len) __attribute__((returns_nonnull));
3484 @end smallexample
3485
3486 @noindent
3487 lets the compiler optimize callers based on the knowledge
3488 that the return value will never be null.
3489
3490 @item returns_twice
3491 @cindex @code{returns_twice} function attribute
3492 @cindex functions that return more than once
3493 The @code{returns_twice} attribute tells the compiler that a function may
3494 return more than one time. The compiler ensures that all registers
3495 are dead before calling such a function and emits a warning about
3496 the variables that may be clobbered after the second return from the
3497 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3498 The @code{longjmp}-like counterpart of such function, if any, might need
3499 to be marked with the @code{noreturn} attribute.
3500
3501 @item section ("@var{section-name}")
3502 @cindex @code{section} function attribute
3503 @cindex functions in arbitrary sections
3504 Normally, the compiler places the code it generates in the @code{text} section.
3505 Sometimes, however, you need additional sections, or you need certain
3506 particular functions to appear in special sections. The @code{section}
3507 attribute specifies that a function lives in a particular section.
3508 For example, the declaration:
3509
3510 @smallexample
3511 extern void foobar (void) __attribute__ ((section ("bar")));
3512 @end smallexample
3513
3514 @noindent
3515 puts the function @code{foobar} in the @code{bar} section.
3516
3517 Some file formats do not support arbitrary sections so the @code{section}
3518 attribute is not available on all platforms.
3519 If you need to map the entire contents of a module to a particular
3520 section, consider using the facilities of the linker instead.
3521
3522 @item sentinel
3523 @itemx sentinel (@var{position})
3524 @cindex @code{sentinel} function attribute
3525 This function attribute indicates that an argument in a call to the function
3526 is expected to be an explicit @code{NULL}. The attribute is only valid on
3527 variadic functions. By default, the sentinel is expected to be the last
3528 argument of the function call. If the optional @var{position} argument
3529 is specified to the attribute, the sentinel must be located at
3530 @var{position} counting backwards from the end of the argument list.
3531
3532 @smallexample
3533 __attribute__ ((sentinel))
3534 is equivalent to
3535 __attribute__ ((sentinel(0)))
3536 @end smallexample
3537
3538 The attribute is automatically set with a position of 0 for the built-in
3539 functions @code{execl} and @code{execlp}. The built-in function
3540 @code{execle} has the attribute set with a position of 1.
3541
3542 A valid @code{NULL} in this context is defined as zero with any object
3543 pointer type. If your system defines the @code{NULL} macro with
3544 an integer type then you need to add an explicit cast. During
3545 installation GCC replaces the system @code{<stddef.h>} header with
3546 a copy that redefines NULL appropriately.
3547
3548 The warnings for missing or incorrect sentinels are enabled with
3549 @option{-Wformat}.
3550
3551 @item simd
3552 @itemx simd("@var{mask}")
3553 @cindex @code{simd} function attribute
3554 This attribute enables creation of one or more function versions that
3555 can process multiple arguments using SIMD instructions from a
3556 single invocation. Specifying this attribute allows compiler to
3557 assume that such versions are available at link time (provided
3558 in the same or another translation unit). Generated versions are
3559 target-dependent and described in the corresponding Vector ABI document. For
3560 x86_64 target this document can be found
3561 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3562
3563 The optional argument @var{mask} may have the value
3564 @code{notinbranch} or @code{inbranch},
3565 and instructs the compiler to generate non-masked or masked
3566 clones correspondingly. By default, all clones are generated.
3567
3568 If the attribute is specified and @code{#pragma omp declare simd} is
3569 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3570 switch is specified, then the attribute is ignored.
3571
3572 @item stack_protect
3573 @cindex @code{stack_protect} function attribute
3574 This attribute adds stack protection code to the function if
3575 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3576 or @option{-fstack-protector-explicit} are set.
3577
3578 @item target (@var{string}, @dots{})
3579 @cindex @code{target} function attribute
3580 Multiple target back ends implement the @code{target} attribute
3581 to specify that a function is to
3582 be compiled with different target options than specified on the
3583 command line. One or more strings can be provided as arguments.
3584 Each string consists of one or more comma-separated suffixes to
3585 the @code{-m} prefix jointly forming the name of a machine-dependent
3586 option. @xref{Submodel Options,,Machine-Dependent Options}.
3587
3588 The @code{target} attribute can be used for instance to have a function
3589 compiled with a different ISA (instruction set architecture) than the
3590 default. @samp{#pragma GCC target} can be used to specify target-specific
3591 options for more than one function. @xref{Function Specific Option Pragmas},
3592 for details about the pragma.
3593
3594 For instance, on an x86, you could declare one function with the
3595 @code{target("sse4.1,arch=core2")} attribute and another with
3596 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3597 compiling the first function with @option{-msse4.1} and
3598 @option{-march=core2} options, and the second function with
3599 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3600 to make sure that a function is only invoked on a machine that
3601 supports the particular ISA it is compiled for (for example by using
3602 @code{cpuid} on x86 to determine what feature bits and architecture
3603 family are used).
3604
3605 @smallexample
3606 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3607 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3608 @end smallexample
3609
3610 Providing multiple strings as arguments separated by commas to specify
3611 multiple options is equivalent to separating the option suffixes with
3612 a comma (@samp{,}) within a single string. Spaces are not permitted
3613 within the strings.
3614
3615 The options supported are specific to each target; refer to @ref{x86
3616 Function Attributes}, @ref{PowerPC Function Attributes},
3617 @ref{ARM Function Attributes}, @ref{AArch64 Function Attributes},
3618 @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
3619 for details.
3620
3621 @item target_clones (@var{options})
3622 @cindex @code{target_clones} function attribute
3623 The @code{target_clones} attribute is used to specify that a function
3624 be cloned into multiple versions compiled with different target options
3625 than specified on the command line. The supported options and restrictions
3626 are the same as for @code{target} attribute.
3627
3628 For instance, on an x86, you could compile a function with
3629 @code{target_clones("sse4.1,avx")}. GCC creates two function clones,
3630 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3631
3632 On a PowerPC, you can compile a function with
3633 @code{target_clones("cpu=power9,default")}. GCC will create two
3634 function clones, one compiled with @option{-mcpu=power9} and another
3635 with the default options. GCC must be configured to use GLIBC 2.23 or
3636 newer in order to use the @code{target_clones} attribute.
3637
3638 It also creates a resolver function (see
3639 the @code{ifunc} attribute above) that dynamically selects a clone
3640 suitable for current architecture. The resolver is created only if there
3641 is a usage of a function with @code{target_clones} attribute.
3642
3643 @item unused
3644 @cindex @code{unused} function attribute
3645 This attribute, attached to a function, means that the function is meant
3646 to be possibly unused. GCC does not produce a warning for this
3647 function.
3648
3649 @item used
3650 @cindex @code{used} function attribute
3651 This attribute, attached to a function, means that code must be emitted
3652 for the function even if it appears that the function is not referenced.
3653 This is useful, for example, when the function is referenced only in
3654 inline assembly.
3655
3656 When applied to a member function of a C++ class template, the
3657 attribute also means that the function is instantiated if the
3658 class itself is instantiated.
3659
3660 @item visibility ("@var{visibility_type}")
3661 @cindex @code{visibility} function attribute
3662 This attribute affects the linkage of the declaration to which it is attached.
3663 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3664 (@pxref{Common Type Attributes}) as well as functions.
3665
3666 There are four supported @var{visibility_type} values: default,
3667 hidden, protected or internal visibility.
3668
3669 @smallexample
3670 void __attribute__ ((visibility ("protected")))
3671 f () @{ /* @r{Do something.} */; @}
3672 int i __attribute__ ((visibility ("hidden")));
3673 @end smallexample
3674
3675 The possible values of @var{visibility_type} correspond to the
3676 visibility settings in the ELF gABI.
3677
3678 @table @code
3679 @c keep this list of visibilities in alphabetical order.
3680
3681 @item default
3682 Default visibility is the normal case for the object file format.
3683 This value is available for the visibility attribute to override other
3684 options that may change the assumed visibility of entities.
3685
3686 On ELF, default visibility means that the declaration is visible to other
3687 modules and, in shared libraries, means that the declared entity may be
3688 overridden.
3689
3690 On Darwin, default visibility means that the declaration is visible to
3691 other modules.
3692
3693 Default visibility corresponds to ``external linkage'' in the language.
3694
3695 @item hidden
3696 Hidden visibility indicates that the entity declared has a new
3697 form of linkage, which we call ``hidden linkage''. Two
3698 declarations of an object with hidden linkage refer to the same object
3699 if they are in the same shared object.
3700
3701 @item internal
3702 Internal visibility is like hidden visibility, but with additional
3703 processor specific semantics. Unless otherwise specified by the
3704 psABI, GCC defines internal visibility to mean that a function is
3705 @emph{never} called from another module. Compare this with hidden
3706 functions which, while they cannot be referenced directly by other
3707 modules, can be referenced indirectly via function pointers. By
3708 indicating that a function cannot be called from outside the module,
3709 GCC may for instance omit the load of a PIC register since it is known
3710 that the calling function loaded the correct value.
3711
3712 @item protected
3713 Protected visibility is like default visibility except that it
3714 indicates that references within the defining module bind to the
3715 definition in that module. That is, the declared entity cannot be
3716 overridden by another module.
3717
3718 @end table
3719
3720 All visibilities are supported on many, but not all, ELF targets
3721 (supported when the assembler supports the @samp{.visibility}
3722 pseudo-op). Default visibility is supported everywhere. Hidden
3723 visibility is supported on Darwin targets.
3724
3725 The visibility attribute should be applied only to declarations that
3726 would otherwise have external linkage. The attribute should be applied
3727 consistently, so that the same entity should not be declared with
3728 different settings of the attribute.
3729
3730 In C++, the visibility attribute applies to types as well as functions
3731 and objects, because in C++ types have linkage. A class must not have
3732 greater visibility than its non-static data member types and bases,
3733 and class members default to the visibility of their class. Also, a
3734 declaration without explicit visibility is limited to the visibility
3735 of its type.
3736
3737 In C++, you can mark member functions and static member variables of a
3738 class with the visibility attribute. This is useful if you know a
3739 particular method or static member variable should only be used from
3740 one shared object; then you can mark it hidden while the rest of the
3741 class has default visibility. Care must be taken to avoid breaking
3742 the One Definition Rule; for example, it is usually not useful to mark
3743 an inline method as hidden without marking the whole class as hidden.
3744
3745 A C++ namespace declaration can also have the visibility attribute.
3746
3747 @smallexample
3748 namespace nspace1 __attribute__ ((visibility ("protected")))
3749 @{ /* @r{Do something.} */; @}
3750 @end smallexample
3751
3752 This attribute applies only to the particular namespace body, not to
3753 other definitions of the same namespace; it is equivalent to using
3754 @samp{#pragma GCC visibility} before and after the namespace
3755 definition (@pxref{Visibility Pragmas}).
3756
3757 In C++, if a template argument has limited visibility, this
3758 restriction is implicitly propagated to the template instantiation.
3759 Otherwise, template instantiations and specializations default to the
3760 visibility of their template.
3761
3762 If both the template and enclosing class have explicit visibility, the
3763 visibility from the template is used.
3764
3765 @item warn_unused_result
3766 @cindex @code{warn_unused_result} function attribute
3767 The @code{warn_unused_result} attribute causes a warning to be emitted
3768 if a caller of the function with this attribute does not use its
3769 return value. This is useful for functions where not checking
3770 the result is either a security problem or always a bug, such as
3771 @code{realloc}.
3772
3773 @smallexample
3774 int fn () __attribute__ ((warn_unused_result));
3775 int foo ()
3776 @{
3777 if (fn () < 0) return -1;
3778 fn ();
3779 return 0;
3780 @}
3781 @end smallexample
3782
3783 @noindent
3784 results in warning on line 5.
3785
3786 @item weak
3787 @cindex @code{weak} function attribute
3788 The @code{weak} attribute causes the declaration to be emitted as a weak
3789 symbol rather than a global. This is primarily useful in defining
3790 library functions that can be overridden in user code, though it can
3791 also be used with non-function declarations. Weak symbols are supported
3792 for ELF targets, and also for a.out targets when using the GNU assembler
3793 and linker.
3794
3795 @item weakref
3796 @itemx weakref ("@var{target}")
3797 @cindex @code{weakref} function attribute
3798 The @code{weakref} attribute marks a declaration as a weak reference.
3799 Without arguments, it should be accompanied by an @code{alias} attribute
3800 naming the target symbol. Optionally, the @var{target} may be given as
3801 an argument to @code{weakref} itself. In either case, @code{weakref}
3802 implicitly marks the declaration as @code{weak}. Without a
3803 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3804 @code{weakref} is equivalent to @code{weak}.
3805
3806 @smallexample
3807 static int x() __attribute__ ((weakref ("y")));
3808 /* is equivalent to... */
3809 static int x() __attribute__ ((weak, weakref, alias ("y")));
3810 /* and to... */
3811 static int x() __attribute__ ((weakref));
3812 static int x() __attribute__ ((alias ("y")));
3813 @end smallexample
3814
3815 A weak reference is an alias that does not by itself require a
3816 definition to be given for the target symbol. If the target symbol is
3817 only referenced through weak references, then it becomes a @code{weak}
3818 undefined symbol. If it is directly referenced, however, then such
3819 strong references prevail, and a definition is required for the
3820 symbol, not necessarily in the same translation unit.
3821
3822 The effect is equivalent to moving all references to the alias to a
3823 separate translation unit, renaming the alias to the aliased symbol,
3824 declaring it as weak, compiling the two separate translation units and
3825 performing a link with relocatable output (ie: @code{ld -r}) on them.
3826
3827 At present, a declaration to which @code{weakref} is attached can
3828 only be @code{static}.
3829
3830
3831 @end table
3832
3833 @c This is the end of the target-independent attribute table
3834
3835 @node AArch64 Function Attributes
3836 @subsection AArch64 Function Attributes
3837
3838 The following target-specific function attributes are available for the
3839 AArch64 target. For the most part, these options mirror the behavior of
3840 similar command-line options (@pxref{AArch64 Options}), but on a
3841 per-function basis.
3842
3843 @table @code
3844 @item general-regs-only
3845 @cindex @code{general-regs-only} function attribute, AArch64
3846 Indicates that no floating-point or Advanced SIMD registers should be
3847 used when generating code for this function. If the function explicitly
3848 uses floating-point code, then the compiler gives an error. This is
3849 the same behavior as that of the command-line option
3850 @option{-mgeneral-regs-only}.
3851
3852 @item fix-cortex-a53-835769
3853 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3854 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3855 applied to this function. To explicitly disable the workaround for this
3856 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3857 This corresponds to the behavior of the command line options
3858 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3859
3860 @item cmodel=
3861 @cindex @code{cmodel=} function attribute, AArch64
3862 Indicates that code should be generated for a particular code model for
3863 this function. The behavior and permissible arguments are the same as
3864 for the command line option @option{-mcmodel=}.
3865
3866 @item strict-align
3867 @itemx no-strict-align
3868 @cindex @code{strict-align} function attribute, AArch64
3869 @code{strict-align} indicates that the compiler should not assume that unaligned
3870 memory references are handled by the system. To allow the compiler to assume
3871 that aligned memory references are handled by the system, the inverse attribute
3872 @code{no-strict-align} can be specified. The behavior is same as for the
3873 command-line option @option{-mstrict-align} and @option{-mno-strict-align}.
3874
3875 @item omit-leaf-frame-pointer
3876 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3877 Indicates that the frame pointer should be omitted for a leaf function call.
3878 To keep the frame pointer, the inverse attribute
3879 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3880 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3881 and @option{-mno-omit-leaf-frame-pointer}.
3882
3883 @item tls-dialect=
3884 @cindex @code{tls-dialect=} function attribute, AArch64
3885 Specifies the TLS dialect to use for this function. The behavior and
3886 permissible arguments are the same as for the command-line option
3887 @option{-mtls-dialect=}.
3888
3889 @item arch=
3890 @cindex @code{arch=} function attribute, AArch64
3891 Specifies the architecture version and architectural extensions to use
3892 for this function. The behavior and permissible arguments are the same as
3893 for the @option{-march=} command-line option.
3894
3895 @item tune=
3896 @cindex @code{tune=} function attribute, AArch64
3897 Specifies the core for which to tune the performance of this function.
3898 The behavior and permissible arguments are the same as for the @option{-mtune=}
3899 command-line option.
3900
3901 @item cpu=
3902 @cindex @code{cpu=} function attribute, AArch64
3903 Specifies the core for which to tune the performance of this function and also
3904 whose architectural features to use. The behavior and valid arguments are the
3905 same as for the @option{-mcpu=} command-line option.
3906
3907 @item sign-return-address
3908 @cindex @code{sign-return-address} function attribute, AArch64
3909 Select the function scope on which return address signing will be applied. The
3910 behavior and permissible arguments are the same as for the command-line option
3911 @option{-msign-return-address=}. The default value is @code{none}.
3912
3913 @end table
3914
3915 The above target attributes can be specified as follows:
3916
3917 @smallexample
3918 __attribute__((target("@var{attr-string}")))
3919 int
3920 f (int a)
3921 @{
3922 return a + 5;
3923 @}
3924 @end smallexample
3925
3926 where @code{@var{attr-string}} is one of the attribute strings specified above.
3927
3928 Additionally, the architectural extension string may be specified on its
3929 own. This can be used to turn on and off particular architectural extensions
3930 without having to specify a particular architecture version or core. Example:
3931
3932 @smallexample
3933 __attribute__((target("+crc+nocrypto")))
3934 int
3935 foo (int a)
3936 @{
3937 return a + 5;
3938 @}
3939 @end smallexample
3940
3941 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3942 extension and disables the @code{crypto} extension for the function @code{foo}
3943 without modifying an existing @option{-march=} or @option{-mcpu} option.
3944
3945 Multiple target function attributes can be specified by separating them with
3946 a comma. For example:
3947 @smallexample
3948 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3949 int
3950 foo (int a)
3951 @{
3952 return a + 5;
3953 @}
3954 @end smallexample
3955
3956 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3957 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3958
3959 @subsubsection Inlining rules
3960 Specifying target attributes on individual functions or performing link-time
3961 optimization across translation units compiled with different target options
3962 can affect function inlining rules:
3963
3964 In particular, a caller function can inline a callee function only if the
3965 architectural features available to the callee are a subset of the features
3966 available to the caller.
3967 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3968 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3969 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3970 because the all the architectural features that function @code{bar} requires
3971 are available to function @code{foo}. Conversely, function @code{bar} cannot
3972 inline function @code{foo}.
3973
3974 Additionally inlining a function compiled with @option{-mstrict-align} into a
3975 function compiled without @code{-mstrict-align} is not allowed.
3976 However, inlining a function compiled without @option{-mstrict-align} into a
3977 function compiled with @option{-mstrict-align} is allowed.
3978
3979 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3980 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3981 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3982 architectural feature rules specified above.
3983
3984 @node AMD GCN Function Attributes
3985 @subsection AMD GCN Function Attributes
3986
3987 These function attributes are supported by the AMD GCN back end:
3988
3989 @table @code
3990 @item amdgpu_hsa_kernel
3991 @cindex @code{amdgpu_hsa_kernel} function attribute, AMD GCN
3992 This attribute indicates that the corresponding function should be compiled as
3993 a kernel function, that is an entry point that can be invoked from the host
3994 via the HSA runtime library. By default functions are only callable only from
3995 other GCN functions.
3996
3997 This attribute is implicitly applied to any function named @code{main}, using
3998 default parameters.
3999
4000 Kernel functions may return an integer value, which will be written to a
4001 conventional place within the HSA "kernargs" region.
4002
4003 The attribute parameters configure what values are passed into the kernel
4004 function by the GPU drivers, via the initial register state. Some values are
4005 used by the compiler, and therefore forced on. Enabling other options may
4006 break assumptions in the compiler and/or run-time libraries.
4007
4008 @table @code
4009 @item private_segment_buffer
4010 Set @code{enable_sgpr_private_segment_buffer} flag. Always on (required to
4011 locate the stack).
4012
4013 @item dispatch_ptr
4014 Set @code{enable_sgpr_dispatch_ptr} flag. Always on (required to locate the
4015 launch dimensions).
4016
4017 @item queue_ptr
4018 Set @code{enable_sgpr_queue_ptr} flag. Always on (required to convert address
4019 spaces).
4020
4021 @item kernarg_segment_ptr
4022 Set @code{enable_sgpr_kernarg_segment_ptr} flag. Always on (required to
4023 locate the kernel arguments, "kernargs").
4024
4025 @item dispatch_id
4026 Set @code{enable_sgpr_dispatch_id} flag.
4027
4028 @item flat_scratch_init
4029 Set @code{enable_sgpr_flat_scratch_init} flag.
4030
4031 @item private_segment_size
4032 Set @code{enable_sgpr_private_segment_size} flag.
4033
4034 @item grid_workgroup_count_X
4035 Set @code{enable_sgpr_grid_workgroup_count_x} flag. Always on (required to
4036 use OpenACC/OpenMP).
4037
4038 @item grid_workgroup_count_Y
4039 Set @code{enable_sgpr_grid_workgroup_count_y} flag.
4040
4041 @item grid_workgroup_count_Z
4042 Set @code{enable_sgpr_grid_workgroup_count_z} flag.
4043
4044 @item workgroup_id_X
4045 Set @code{enable_sgpr_workgroup_id_x} flag.
4046
4047 @item workgroup_id_Y
4048 Set @code{enable_sgpr_workgroup_id_y} flag.
4049
4050 @item workgroup_id_Z
4051 Set @code{enable_sgpr_workgroup_id_z} flag.
4052
4053 @item workgroup_info
4054 Set @code{enable_sgpr_workgroup_info} flag.
4055
4056 @item private_segment_wave_offset
4057 Set @code{enable_sgpr_private_segment_wave_byte_offset} flag. Always on
4058 (required to locate the stack).
4059
4060 @item work_item_id_X
4061 Set @code{enable_vgpr_workitem_id} parameter. Always on (can't be disabled).
4062
4063 @item work_item_id_Y
4064 Set @code{enable_vgpr_workitem_id} parameter. Always on (required to enable
4065 vectorization.)
4066
4067 @item work_item_id_Z
4068 Set @code{enable_vgpr_workitem_id} parameter. Always on (required to use
4069 OpenACC/OpenMP).
4070
4071 @end table
4072 @end table
4073
4074 @node ARC Function Attributes
4075 @subsection ARC Function Attributes
4076
4077 These function attributes are supported by the ARC back end:
4078
4079 @table @code
4080 @item interrupt
4081 @cindex @code{interrupt} function attribute, ARC
4082 Use this attribute to indicate
4083 that the specified function is an interrupt handler. The compiler generates
4084 function entry and exit sequences suitable for use in an interrupt handler
4085 when this attribute is present.
4086
4087 On the ARC, you must specify the kind of interrupt to be handled
4088 in a parameter to the interrupt attribute like this:
4089
4090 @smallexample
4091 void f () __attribute__ ((interrupt ("ilink1")));
4092 @end smallexample
4093
4094 Permissible values for this parameter are: @w{@code{ilink1}} and
4095 @w{@code{ilink2}}.
4096
4097 @item long_call
4098 @itemx medium_call
4099 @itemx short_call
4100 @cindex @code{long_call} function attribute, ARC
4101 @cindex @code{medium_call} function attribute, ARC
4102 @cindex @code{short_call} function attribute, ARC
4103 @cindex indirect calls, ARC
4104 These attributes specify how a particular function is called.
4105 These attributes override the
4106 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
4107 command-line switches and @code{#pragma long_calls} settings.
4108
4109 For ARC, a function marked with the @code{long_call} attribute is
4110 always called using register-indirect jump-and-link instructions,
4111 thereby enabling the called function to be placed anywhere within the
4112 32-bit address space. A function marked with the @code{medium_call}
4113 attribute will always be close enough to be called with an unconditional
4114 branch-and-link instruction, which has a 25-bit offset from
4115 the call site. A function marked with the @code{short_call}
4116 attribute will always be close enough to be called with a conditional
4117 branch-and-link instruction, which has a 21-bit offset from
4118 the call site.
4119
4120 @item jli_always
4121 @cindex @code{jli_always} function attribute, ARC
4122 Forces a particular function to be called using @code{jli}
4123 instruction. The @code{jli} instruction makes use of a table stored
4124 into @code{.jlitab} section, which holds the location of the functions
4125 which are addressed using this instruction.
4126
4127 @item jli_fixed
4128 @cindex @code{jli_fixed} function attribute, ARC
4129 Identical like the above one, but the location of the function in the
4130 @code{jli} table is known and given as an attribute parameter.
4131
4132 @item secure_call
4133 @cindex @code{secure_call} function attribute, ARC
4134 This attribute allows one to mark secure-code functions that are
4135 callable from normal mode. The location of the secure call function
4136 into the @code{sjli} table needs to be passed as argument.
4137
4138 @end table
4139
4140 @node ARM Function Attributes
4141 @subsection ARM Function Attributes
4142
4143 These function attributes are supported for ARM targets:
4144
4145 @table @code
4146 @item interrupt
4147 @cindex @code{interrupt} function attribute, ARM
4148 Use this attribute to indicate
4149 that the specified function is an interrupt handler. The compiler generates
4150 function entry and exit sequences suitable for use in an interrupt handler
4151 when this attribute is present.
4152
4153 You can specify the kind of interrupt to be handled by
4154 adding an optional parameter to the interrupt attribute like this:
4155
4156 @smallexample
4157 void f () __attribute__ ((interrupt ("IRQ")));
4158 @end smallexample
4159
4160 @noindent
4161 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
4162 @code{SWI}, @code{ABORT} and @code{UNDEF}.
4163
4164 On ARMv7-M the interrupt type is ignored, and the attribute means the function
4165 may be called with a word-aligned stack pointer.
4166
4167 @item isr
4168 @cindex @code{isr} function attribute, ARM
4169 Use this attribute on ARM to write Interrupt Service Routines. This is an
4170 alias to the @code{interrupt} attribute above.
4171
4172 @item long_call
4173 @itemx short_call
4174 @cindex @code{long_call} function attribute, ARM
4175 @cindex @code{short_call} function attribute, ARM
4176 @cindex indirect calls, ARM
4177 These attributes specify how a particular function is called.
4178 These attributes override the
4179 @option{-mlong-calls} (@pxref{ARM Options})
4180 command-line switch and @code{#pragma long_calls} settings. For ARM, the
4181 @code{long_call} attribute indicates that the function might be far
4182 away from the call site and require a different (more expensive)
4183 calling sequence. The @code{short_call} attribute always places
4184 the offset to the function from the call site into the @samp{BL}
4185 instruction directly.
4186
4187 @item naked
4188 @cindex @code{naked} function attribute, ARM
4189 This attribute allows the compiler to construct the
4190 requisite function declaration, while allowing the body of the
4191 function to be assembly code. The specified function will not have
4192 prologue/epilogue sequences generated by the compiler. Only basic
4193 @code{asm} statements can safely be included in naked functions
4194 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4195 basic @code{asm} and C code may appear to work, they cannot be
4196 depended upon to work reliably and are not supported.
4197
4198 @item pcs
4199 @cindex @code{pcs} function attribute, ARM
4200
4201 The @code{pcs} attribute can be used to control the calling convention
4202 used for a function on ARM. The attribute takes an argument that specifies
4203 the calling convention to use.
4204
4205 When compiling using the AAPCS ABI (or a variant of it) then valid
4206 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
4207 order to use a variant other than @code{"aapcs"} then the compiler must
4208 be permitted to use the appropriate co-processor registers (i.e., the
4209 VFP registers must be available in order to use @code{"aapcs-vfp"}).
4210 For example,
4211
4212 @smallexample
4213 /* Argument passed in r0, and result returned in r0+r1. */
4214 double f2d (float) __attribute__((pcs("aapcs")));
4215 @end smallexample
4216
4217 Variadic functions always use the @code{"aapcs"} calling convention and
4218 the compiler rejects attempts to specify an alternative.
4219
4220 @item target (@var{options})
4221 @cindex @code{target} function attribute
4222 As discussed in @ref{Common Function Attributes}, this attribute
4223 allows specification of target-specific compilation options.
4224
4225 On ARM, the following options are allowed:
4226
4227 @table @samp
4228 @item thumb
4229 @cindex @code{target("thumb")} function attribute, ARM
4230 Force code generation in the Thumb (T16/T32) ISA, depending on the
4231 architecture level.
4232
4233 @item arm
4234 @cindex @code{target("arm")} function attribute, ARM
4235 Force code generation in the ARM (A32) ISA.
4236
4237 Functions from different modes can be inlined in the caller's mode.
4238
4239 @item fpu=
4240 @cindex @code{target("fpu=")} function attribute, ARM
4241 Specifies the fpu for which to tune the performance of this function.
4242 The behavior and permissible arguments are the same as for the @option{-mfpu=}
4243 command-line option.
4244
4245 @item arch=
4246 @cindex @code{arch=} function attribute, ARM
4247 Specifies the architecture version and architectural extensions to use
4248 for this function. The behavior and permissible arguments are the same as
4249 for the @option{-march=} command-line option.
4250
4251 The above target attributes can be specified as follows:
4252
4253 @smallexample
4254 __attribute__((target("arch=armv8-a+crc")))
4255 int
4256 f (int a)
4257 @{
4258 return a + 5;
4259 @}
4260 @end smallexample
4261
4262 Additionally, the architectural extension string may be specified on its
4263 own. This can be used to turn on and off particular architectural extensions
4264 without having to specify a particular architecture version or core. Example:
4265
4266 @smallexample
4267 __attribute__((target("+crc+nocrypto")))
4268 int
4269 foo (int a)
4270 @{
4271 return a + 5;
4272 @}
4273 @end smallexample
4274
4275 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
4276 extension and disables the @code{crypto} extension for the function @code{foo}
4277 without modifying an existing @option{-march=} or @option{-mcpu} option.
4278
4279 @end table
4280
4281 @end table
4282
4283 @node AVR Function Attributes
4284 @subsection AVR Function Attributes
4285
4286 These function attributes are supported by the AVR back end:
4287
4288 @table @code
4289 @item interrupt
4290 @cindex @code{interrupt} function attribute, AVR
4291 Use this attribute to indicate
4292 that the specified function is an interrupt handler. The compiler generates
4293 function entry and exit sequences suitable for use in an interrupt handler
4294 when this attribute is present.
4295
4296 On the AVR, the hardware globally disables interrupts when an
4297 interrupt is executed. The first instruction of an interrupt handler
4298 declared with this attribute is a @code{SEI} instruction to
4299 re-enable interrupts. See also the @code{signal} function attribute
4300 that does not insert a @code{SEI} instruction. If both @code{signal} and
4301 @code{interrupt} are specified for the same function, @code{signal}
4302 is silently ignored.
4303
4304 @item naked
4305 @cindex @code{naked} function attribute, AVR
4306 This attribute allows the compiler to construct the
4307 requisite function declaration, while allowing the body of the
4308 function to be assembly code. The specified function will not have
4309 prologue/epilogue sequences generated by the compiler. Only basic
4310 @code{asm} statements can safely be included in naked functions
4311 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4312 basic @code{asm} and C code may appear to work, they cannot be
4313 depended upon to work reliably and are not supported.
4314
4315 @item no_gccisr
4316 @cindex @code{no_gccisr} function attribute, AVR
4317 Do not use @code{__gcc_isr} pseudo instructions in a function with
4318 the @code{interrupt} or @code{signal} attribute aka. interrupt
4319 service routine (ISR).
4320 Use this attribute if the preamble of the ISR prologue should always read
4321 @example
4322 push __zero_reg__
4323 push __tmp_reg__
4324 in __tmp_reg__, __SREG__
4325 push __tmp_reg__
4326 clr __zero_reg__
4327 @end example
4328 and accordingly for the postamble of the epilogue --- no matter whether
4329 the mentioned registers are actually used in the ISR or not.
4330 Situations where you might want to use this attribute include:
4331 @itemize @bullet
4332 @item
4333 Code that (effectively) clobbers bits of @code{SREG} other than the
4334 @code{I}-flag by writing to the memory location of @code{SREG}.
4335 @item
4336 Code that uses inline assembler to jump to a different function which
4337 expects (parts of) the prologue code as outlined above to be present.
4338 @end itemize
4339 To disable @code{__gcc_isr} generation for the whole compilation unit,
4340 there is option @option{-mno-gas-isr-prologues}, @pxref{AVR Options}.
4341
4342 @item OS_main
4343 @itemx OS_task
4344 @cindex @code{OS_main} function attribute, AVR
4345 @cindex @code{OS_task} function attribute, AVR
4346 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
4347 do not save/restore any call-saved register in their prologue/epilogue.
4348
4349 The @code{OS_main} attribute can be used when there @emph{is
4350 guarantee} that interrupts are disabled at the time when the function
4351 is entered. This saves resources when the stack pointer has to be
4352 changed to set up a frame for local variables.
4353
4354 The @code{OS_task} attribute can be used when there is @emph{no
4355 guarantee} that interrupts are disabled at that time when the function
4356 is entered like for, e@.g@. task functions in a multi-threading operating
4357 system. In that case, changing the stack pointer register is
4358 guarded by save/clear/restore of the global interrupt enable flag.
4359
4360 The differences to the @code{naked} function attribute are:
4361 @itemize @bullet
4362 @item @code{naked} functions do not have a return instruction whereas
4363 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
4364 @code{RETI} return instruction.
4365 @item @code{naked} functions do not set up a frame for local variables
4366 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
4367 as needed.
4368 @end itemize
4369
4370 @item signal
4371 @cindex @code{signal} function attribute, AVR
4372 Use this attribute on the AVR to indicate that the specified
4373 function is an interrupt handler. The compiler generates function
4374 entry and exit sequences suitable for use in an interrupt handler when this
4375 attribute is present.
4376
4377 See also the @code{interrupt} function attribute.
4378
4379 The AVR hardware globally disables interrupts when an interrupt is executed.
4380 Interrupt handler functions defined with the @code{signal} attribute
4381 do not re-enable interrupts. It is save to enable interrupts in a
4382 @code{signal} handler. This ``save'' only applies to the code
4383 generated by the compiler and not to the IRQ layout of the
4384 application which is responsibility of the application.
4385
4386 If both @code{signal} and @code{interrupt} are specified for the same
4387 function, @code{signal} is silently ignored.
4388 @end table
4389
4390 @node Blackfin Function Attributes
4391 @subsection Blackfin Function Attributes
4392
4393 These function attributes are supported by the Blackfin back end:
4394
4395 @table @code
4396
4397 @item exception_handler
4398 @cindex @code{exception_handler} function attribute
4399 @cindex exception handler functions, Blackfin
4400 Use this attribute on the Blackfin to indicate that the specified function
4401 is an exception handler. The compiler generates function entry and
4402 exit sequences suitable for use in an exception handler when this
4403 attribute is present.
4404
4405 @item interrupt_handler
4406 @cindex @code{interrupt_handler} function attribute, Blackfin
4407 Use this attribute to
4408 indicate that the specified function is an interrupt handler. The compiler
4409 generates function entry and exit sequences suitable for use in an
4410 interrupt handler when this attribute is present.
4411
4412 @item kspisusp
4413 @cindex @code{kspisusp} function attribute, Blackfin
4414 @cindex User stack pointer in interrupts on the Blackfin
4415 When used together with @code{interrupt_handler}, @code{exception_handler}
4416 or @code{nmi_handler}, code is generated to load the stack pointer
4417 from the USP register in the function prologue.
4418
4419 @item l1_text
4420 @cindex @code{l1_text} function attribute, Blackfin
4421 This attribute specifies a function to be placed into L1 Instruction
4422 SRAM@. The function is put into a specific section named @code{.l1.text}.
4423 With @option{-mfdpic}, function calls with a such function as the callee
4424 or caller uses inlined PLT.
4425
4426 @item l2
4427 @cindex @code{l2} function attribute, Blackfin
4428 This attribute specifies a function to be placed into L2
4429 SRAM. The function is put into a specific section named
4430 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
4431 an inlined PLT.
4432
4433 @item longcall
4434 @itemx shortcall
4435 @cindex indirect calls, Blackfin
4436 @cindex @code{longcall} function attribute, Blackfin
4437 @cindex @code{shortcall} function attribute, Blackfin
4438 The @code{longcall} attribute
4439 indicates that the function might be far away from the call site and
4440 require a different (more expensive) calling sequence. The
4441 @code{shortcall} attribute indicates that the function is always close
4442 enough for the shorter calling sequence to be used. These attributes
4443 override the @option{-mlongcall} switch.
4444
4445 @item nesting
4446 @cindex @code{nesting} function attribute, Blackfin
4447 @cindex Allow nesting in an interrupt handler on the Blackfin processor
4448 Use this attribute together with @code{interrupt_handler},
4449 @code{exception_handler} or @code{nmi_handler} to indicate that the function
4450 entry code should enable nested interrupts or exceptions.
4451
4452 @item nmi_handler
4453 @cindex @code{nmi_handler} function attribute, Blackfin
4454 @cindex NMI handler functions on the Blackfin processor
4455 Use this attribute on the Blackfin to indicate that the specified function
4456 is an NMI handler. The compiler generates function entry and
4457 exit sequences suitable for use in an NMI handler when this
4458 attribute is present.
4459
4460 @item saveall
4461 @cindex @code{saveall} function attribute, Blackfin
4462 @cindex save all registers on the Blackfin
4463 Use this attribute to indicate that
4464 all registers except the stack pointer should be saved in the prologue
4465 regardless of whether they are used or not.
4466 @end table
4467
4468 @node CR16 Function Attributes
4469 @subsection CR16 Function Attributes
4470
4471 These function attributes are supported by the CR16 back end:
4472
4473 @table @code
4474 @item interrupt
4475 @cindex @code{interrupt} function attribute, CR16
4476 Use this attribute to indicate
4477 that the specified function is an interrupt handler. The compiler generates
4478 function entry and exit sequences suitable for use in an interrupt handler
4479 when this attribute is present.
4480 @end table
4481
4482 @node C-SKY Function Attributes
4483 @subsection C-SKY Function Attributes
4484
4485 These function attributes are supported by the C-SKY back end:
4486
4487 @table @code
4488 @item interrupt
4489 @itemx isr
4490 @cindex @code{interrupt} function attribute, C-SKY
4491 @cindex @code{isr} function attribute, C-SKY
4492 Use these attributes to indicate that the specified function
4493 is an interrupt handler.
4494 The compiler generates function entry and exit sequences suitable for
4495 use in an interrupt handler when either of these attributes are present.
4496
4497 Use of these options requires the @option{-mistack} command-line option
4498 to enable support for the necessary interrupt stack instructions. They
4499 are ignored with a warning otherwise. @xref{C-SKY Options}.
4500
4501 @item naked
4502 @cindex @code{naked} function attribute, C-SKY
4503 This attribute allows the compiler to construct the
4504 requisite function declaration, while allowing the body of the
4505 function to be assembly code. The specified function will not have
4506 prologue/epilogue sequences generated by the compiler. Only basic
4507 @code{asm} statements can safely be included in naked functions
4508 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4509 basic @code{asm} and C code may appear to work, they cannot be
4510 depended upon to work reliably and are not supported.
4511 @end table
4512
4513
4514 @node Epiphany Function Attributes
4515 @subsection Epiphany Function Attributes
4516
4517 These function attributes are supported by the Epiphany back end:
4518
4519 @table @code
4520 @item disinterrupt
4521 @cindex @code{disinterrupt} function attribute, Epiphany
4522 This attribute causes the compiler to emit
4523 instructions to disable interrupts for the duration of the given
4524 function.
4525
4526 @item forwarder_section
4527 @cindex @code{forwarder_section} function attribute, Epiphany
4528 This attribute modifies the behavior of an interrupt handler.
4529 The interrupt handler may be in external memory which cannot be
4530 reached by a branch instruction, so generate a local memory trampoline
4531 to transfer control. The single parameter identifies the section where
4532 the trampoline is placed.
4533
4534 @item interrupt
4535 @cindex @code{interrupt} function attribute, Epiphany
4536 Use this attribute to indicate
4537 that the specified function is an interrupt handler. The compiler generates
4538 function entry and exit sequences suitable for use in an interrupt handler
4539 when this attribute is present. It may also generate
4540 a special section with code to initialize the interrupt vector table.
4541
4542 On Epiphany targets one or more optional parameters can be added like this:
4543
4544 @smallexample
4545 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
4546 @end smallexample
4547
4548 Permissible values for these parameters are: @w{@code{reset}},
4549 @w{@code{software_exception}}, @w{@code{page_miss}},
4550 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
4551 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
4552 Multiple parameters indicate that multiple entries in the interrupt
4553 vector table should be initialized for this function, i.e.@: for each
4554 parameter @w{@var{name}}, a jump to the function is emitted in
4555 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
4556 entirely, in which case no interrupt vector table entry is provided.
4557
4558 Note that interrupts are enabled inside the function
4559 unless the @code{disinterrupt} attribute is also specified.
4560
4561 The following examples are all valid uses of these attributes on
4562 Epiphany targets:
4563 @smallexample
4564 void __attribute__ ((interrupt)) universal_handler ();
4565 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
4566 void __attribute__ ((interrupt ("dma0, dma1")))
4567 universal_dma_handler ();
4568 void __attribute__ ((interrupt ("timer0"), disinterrupt))
4569 fast_timer_handler ();
4570 void __attribute__ ((interrupt ("dma0, dma1"),
4571 forwarder_section ("tramp")))
4572 external_dma_handler ();
4573 @end smallexample
4574
4575 @item long_call
4576 @itemx short_call
4577 @cindex @code{long_call} function attribute, Epiphany
4578 @cindex @code{short_call} function attribute, Epiphany
4579 @cindex indirect calls, Epiphany
4580 These attributes specify how a particular function is called.
4581 These attributes override the
4582 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4583 command-line switch and @code{#pragma long_calls} settings.
4584 @end table
4585
4586
4587 @node H8/300 Function Attributes
4588 @subsection H8/300 Function Attributes
4589
4590 These function attributes are available for H8/300 targets:
4591
4592 @table @code
4593 @item function_vector
4594 @cindex @code{function_vector} function attribute, H8/300
4595 Use this attribute on the H8/300, H8/300H, and H8S to indicate
4596 that the specified function should be called through the function vector.
4597 Calling a function through the function vector reduces code size; however,
4598 the function vector has a limited size (maximum 128 entries on the H8/300
4599 and 64 entries on the H8/300H and H8S)
4600 and shares space with the interrupt vector.
4601
4602 @item interrupt_handler
4603 @cindex @code{interrupt_handler} function attribute, H8/300
4604 Use this attribute on the H8/300, H8/300H, and H8S to
4605 indicate that the specified function is an interrupt handler. The compiler
4606 generates function entry and exit sequences suitable for use in an
4607 interrupt handler when this attribute is present.
4608
4609 @item saveall
4610 @cindex @code{saveall} function attribute, H8/300
4611 @cindex save all registers on the H8/300, H8/300H, and H8S
4612 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4613 all registers except the stack pointer should be saved in the prologue
4614 regardless of whether they are used or not.
4615 @end table
4616
4617 @node IA-64 Function Attributes
4618 @subsection IA-64 Function Attributes
4619
4620 These function attributes are supported on IA-64 targets:
4621
4622 @table @code
4623 @item syscall_linkage
4624 @cindex @code{syscall_linkage} function attribute, IA-64
4625 This attribute is used to modify the IA-64 calling convention by marking
4626 all input registers as live at all function exits. This makes it possible
4627 to restart a system call after an interrupt without having to save/restore
4628 the input registers. This also prevents kernel data from leaking into
4629 application code.
4630
4631 @item version_id
4632 @cindex @code{version_id} function attribute, IA-64
4633 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4634 symbol to contain a version string, thus allowing for function level
4635 versioning. HP-UX system header files may use function level versioning
4636 for some system calls.
4637
4638 @smallexample
4639 extern int foo () __attribute__((version_id ("20040821")));
4640 @end smallexample
4641
4642 @noindent
4643 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4644 @end table
4645
4646 @node M32C Function Attributes
4647 @subsection M32C Function Attributes
4648
4649 These function attributes are supported by the M32C back end:
4650
4651 @table @code
4652 @item bank_switch
4653 @cindex @code{bank_switch} function attribute, M32C
4654 When added to an interrupt handler with the M32C port, causes the
4655 prologue and epilogue to use bank switching to preserve the registers
4656 rather than saving them on the stack.
4657
4658 @item fast_interrupt
4659 @cindex @code{fast_interrupt} function attribute, M32C
4660 Use this attribute on the M32C port to indicate that the specified
4661 function is a fast interrupt handler. This is just like the
4662 @code{interrupt} attribute, except that @code{freit} is used to return
4663 instead of @code{reit}.
4664
4665 @item function_vector
4666 @cindex @code{function_vector} function attribute, M16C/M32C
4667 On M16C/M32C targets, the @code{function_vector} attribute declares a
4668 special page subroutine call function. Use of this attribute reduces
4669 the code size by 2 bytes for each call generated to the
4670 subroutine. The argument to the attribute is the vector number entry
4671 from the special page vector table which contains the 16 low-order
4672 bits of the subroutine's entry address. Each vector table has special
4673 page number (18 to 255) that is used in @code{jsrs} instructions.
4674 Jump addresses of the routines are generated by adding 0x0F0000 (in
4675 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4676 2-byte addresses set in the vector table. Therefore you need to ensure
4677 that all the special page vector routines should get mapped within the
4678 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4679 (for M32C).
4680
4681 In the following example 2 bytes are saved for each call to
4682 function @code{foo}.
4683
4684 @smallexample
4685 void foo (void) __attribute__((function_vector(0x18)));
4686 void foo (void)
4687 @{
4688 @}
4689
4690 void bar (void)
4691 @{
4692 foo();
4693 @}
4694 @end smallexample
4695
4696 If functions are defined in one file and are called in another file,
4697 then be sure to write this declaration in both files.
4698
4699 This attribute is ignored for R8C target.
4700
4701 @item interrupt
4702 @cindex @code{interrupt} function attribute, M32C
4703 Use this attribute to indicate
4704 that the specified function is an interrupt handler. The compiler generates
4705 function entry and exit sequences suitable for use in an interrupt handler
4706 when this attribute is present.
4707 @end table
4708
4709 @node M32R/D Function Attributes
4710 @subsection M32R/D Function Attributes
4711
4712 These function attributes are supported by the M32R/D back end:
4713
4714 @table @code
4715 @item interrupt
4716 @cindex @code{interrupt} function attribute, M32R/D
4717 Use this attribute to indicate
4718 that the specified function is an interrupt handler. The compiler generates
4719 function entry and exit sequences suitable for use in an interrupt handler
4720 when this attribute is present.
4721
4722 @item model (@var{model-name})
4723 @cindex @code{model} function attribute, M32R/D
4724 @cindex function addressability on the M32R/D
4725
4726 On the M32R/D, use this attribute to set the addressability of an
4727 object, and of the code generated for a function. The identifier
4728 @var{model-name} is one of @code{small}, @code{medium}, or
4729 @code{large}, representing each of the code models.
4730
4731 Small model objects live in the lower 16MB of memory (so that their
4732 addresses can be loaded with the @code{ld24} instruction), and are
4733 callable with the @code{bl} instruction.
4734
4735 Medium model objects may live anywhere in the 32-bit address space (the
4736 compiler generates @code{seth/add3} instructions to load their addresses),
4737 and are callable with the @code{bl} instruction.
4738
4739 Large model objects may live anywhere in the 32-bit address space (the
4740 compiler generates @code{seth/add3} instructions to load their addresses),
4741 and may not be reachable with the @code{bl} instruction (the compiler
4742 generates the much slower @code{seth/add3/jl} instruction sequence).
4743 @end table
4744
4745 @node m68k Function Attributes
4746 @subsection m68k Function Attributes
4747
4748 These function attributes are supported by the m68k back end:
4749
4750 @table @code
4751 @item interrupt
4752 @itemx interrupt_handler
4753 @cindex @code{interrupt} function attribute, m68k
4754 @cindex @code{interrupt_handler} function attribute, m68k
4755 Use this attribute to
4756 indicate that the specified function is an interrupt handler. The compiler
4757 generates function entry and exit sequences suitable for use in an
4758 interrupt handler when this attribute is present. Either name may be used.
4759
4760 @item interrupt_thread
4761 @cindex @code{interrupt_thread} function attribute, fido
4762 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4763 that the specified function is an interrupt handler that is designed
4764 to run as a thread. The compiler omits generate prologue/epilogue
4765 sequences and replaces the return instruction with a @code{sleep}
4766 instruction. This attribute is available only on fido.
4767 @end table
4768
4769 @node MCORE Function Attributes
4770 @subsection MCORE Function Attributes
4771
4772 These function attributes are supported by the MCORE back end:
4773
4774 @table @code
4775 @item naked
4776 @cindex @code{naked} function attribute, MCORE
4777 This attribute allows the compiler to construct the
4778 requisite function declaration, while allowing the body of the
4779 function to be assembly code. The specified function will not have
4780 prologue/epilogue sequences generated by the compiler. Only basic
4781 @code{asm} statements can safely be included in naked functions
4782 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4783 basic @code{asm} and C code may appear to work, they cannot be
4784 depended upon to work reliably and are not supported.
4785 @end table
4786
4787 @node MeP Function Attributes
4788 @subsection MeP Function Attributes
4789
4790 These function attributes are supported by the MeP back end:
4791
4792 @table @code
4793 @item disinterrupt
4794 @cindex @code{disinterrupt} function attribute, MeP
4795 On MeP targets, this attribute causes the compiler to emit
4796 instructions to disable interrupts for the duration of the given
4797 function.
4798
4799 @item interrupt
4800 @cindex @code{interrupt} function attribute, MeP
4801 Use this attribute to indicate
4802 that the specified function is an interrupt handler. The compiler generates
4803 function entry and exit sequences suitable for use in an interrupt handler
4804 when this attribute is present.
4805
4806 @item near
4807 @cindex @code{near} function attribute, MeP
4808 This attribute causes the compiler to assume the called
4809 function is close enough to use the normal calling convention,
4810 overriding the @option{-mtf} command-line option.
4811
4812 @item far
4813 @cindex @code{far} function attribute, MeP
4814 On MeP targets this causes the compiler to use a calling convention
4815 that assumes the called function is too far away for the built-in
4816 addressing modes.
4817
4818 @item vliw
4819 @cindex @code{vliw} function attribute, MeP
4820 The @code{vliw} attribute tells the compiler to emit
4821 instructions in VLIW mode instead of core mode. Note that this
4822 attribute is not allowed unless a VLIW coprocessor has been configured
4823 and enabled through command-line options.
4824 @end table
4825
4826 @node MicroBlaze Function Attributes
4827 @subsection MicroBlaze Function Attributes
4828
4829 These function attributes are supported on MicroBlaze targets:
4830
4831 @table @code
4832 @item save_volatiles
4833 @cindex @code{save_volatiles} function attribute, MicroBlaze
4834 Use this attribute to indicate that the function is
4835 an interrupt handler. All volatile registers (in addition to non-volatile
4836 registers) are saved in the function prologue. If the function is a leaf
4837 function, only volatiles used by the function are saved. A normal function
4838 return is generated instead of a return from interrupt.
4839
4840 @item break_handler
4841 @cindex @code{break_handler} function attribute, MicroBlaze
4842 @cindex break handler functions
4843 Use this attribute to indicate that
4844 the specified function is a break handler. The compiler generates function
4845 entry and exit sequences suitable for use in an break handler when this
4846 attribute is present. The return from @code{break_handler} is done through
4847 the @code{rtbd} instead of @code{rtsd}.
4848
4849 @smallexample
4850 void f () __attribute__ ((break_handler));
4851 @end smallexample
4852
4853 @item interrupt_handler
4854 @itemx fast_interrupt
4855 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4856 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4857 These attributes indicate that the specified function is an interrupt
4858 handler. Use the @code{fast_interrupt} attribute to indicate handlers
4859 used in low-latency interrupt mode, and @code{interrupt_handler} for
4860 interrupts that do not use low-latency handlers. In both cases, GCC
4861 emits appropriate prologue code and generates a return from the handler
4862 using @code{rtid} instead of @code{rtsd}.
4863 @end table
4864
4865 @node Microsoft Windows Function Attributes
4866 @subsection Microsoft Windows Function Attributes
4867
4868 The following attributes are available on Microsoft Windows and Symbian OS
4869 targets.
4870
4871 @table @code
4872 @item dllexport
4873 @cindex @code{dllexport} function attribute
4874 @cindex @code{__declspec(dllexport)}
4875 On Microsoft Windows targets and Symbian OS targets the
4876 @code{dllexport} attribute causes the compiler to provide a global
4877 pointer to a pointer in a DLL, so that it can be referenced with the
4878 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4879 name is formed by combining @code{_imp__} and the function or variable
4880 name.
4881
4882 You can use @code{__declspec(dllexport)} as a synonym for
4883 @code{__attribute__ ((dllexport))} for compatibility with other
4884 compilers.
4885
4886 On systems that support the @code{visibility} attribute, this
4887 attribute also implies ``default'' visibility. It is an error to
4888 explicitly specify any other visibility.
4889
4890 GCC's default behavior is to emit all inline functions with the
4891 @code{dllexport} attribute. Since this can cause object file-size bloat,
4892 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4893 ignore the attribute for inlined functions unless the
4894 @option{-fkeep-inline-functions} flag is used instead.
4895
4896 The attribute is ignored for undefined symbols.
4897
4898 When applied to C++ classes, the attribute marks defined non-inlined
4899 member functions and static data members as exports. Static consts
4900 initialized in-class are not marked unless they are also defined
4901 out-of-class.
4902
4903 For Microsoft Windows targets there are alternative methods for
4904 including the symbol in the DLL's export table such as using a
4905 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4906 the @option{--export-all} linker flag.
4907
4908 @item dllimport
4909 @cindex @code{dllimport} function attribute
4910 @cindex @code{__declspec(dllimport)}
4911 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4912 attribute causes the compiler to reference a function or variable via
4913 a global pointer to a pointer that is set up by the DLL exporting the
4914 symbol. The attribute implies @code{extern}. On Microsoft Windows
4915 targets, the pointer name is formed by combining @code{_imp__} and the
4916 function or variable name.
4917
4918 You can use @code{__declspec(dllimport)} as a synonym for
4919 @code{__attribute__ ((dllimport))} for compatibility with other
4920 compilers.
4921
4922 On systems that support the @code{visibility} attribute, this
4923 attribute also implies ``default'' visibility. It is an error to
4924 explicitly specify any other visibility.
4925
4926 Currently, the attribute is ignored for inlined functions. If the
4927 attribute is applied to a symbol @emph{definition}, an error is reported.
4928 If a symbol previously declared @code{dllimport} is later defined, the
4929 attribute is ignored in subsequent references, and a warning is emitted.
4930 The attribute is also overridden by a subsequent declaration as
4931 @code{dllexport}.
4932
4933 When applied to C++ classes, the attribute marks non-inlined
4934 member functions and static data members as imports. However, the
4935 attribute is ignored for virtual methods to allow creation of vtables
4936 using thunks.
4937
4938 On the SH Symbian OS target the @code{dllimport} attribute also has
4939 another affect---it can cause the vtable and run-time type information
4940 for a class to be exported. This happens when the class has a
4941 dllimported constructor or a non-inline, non-pure virtual function
4942 and, for either of those two conditions, the class also has an inline
4943 constructor or destructor and has a key function that is defined in
4944 the current translation unit.
4945
4946 For Microsoft Windows targets the use of the @code{dllimport}
4947 attribute on functions is not necessary, but provides a small
4948 performance benefit by eliminating a thunk in the DLL@. The use of the
4949 @code{dllimport} attribute on imported variables can be avoided by passing the
4950 @option{--enable-auto-import} switch to the GNU linker. As with
4951 functions, using the attribute for a variable eliminates a thunk in
4952 the DLL@.
4953
4954 One drawback to using this attribute is that a pointer to a
4955 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4956 address. However, a pointer to a @emph{function} with the
4957 @code{dllimport} attribute can be used as a constant initializer; in
4958 this case, the address of a stub function in the import lib is
4959 referenced. On Microsoft Windows targets, the attribute can be disabled
4960 for functions by setting the @option{-mnop-fun-dllimport} flag.
4961 @end table
4962
4963 @node MIPS Function Attributes
4964 @subsection MIPS Function Attributes
4965
4966 These function attributes are supported by the MIPS back end:
4967
4968 @table @code
4969 @item interrupt
4970 @cindex @code{interrupt} function attribute, MIPS
4971 Use this attribute to indicate that the specified function is an interrupt
4972 handler. The compiler generates function entry and exit sequences suitable
4973 for use in an interrupt handler when this attribute is present.
4974 An optional argument is supported for the interrupt attribute which allows
4975 the interrupt mode to be described. By default GCC assumes the external
4976 interrupt controller (EIC) mode is in use, this can be explicitly set using
4977 @code{eic}. When interrupts are non-masked then the requested Interrupt
4978 Priority Level (IPL) is copied to the current IPL which has the effect of only
4979 enabling higher priority interrupts. To use vectored interrupt mode use
4980 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4981 the behavior of the non-masked interrupt support and GCC will arrange to mask
4982 all interrupts from sw0 up to and including the specified interrupt vector.
4983
4984 You can use the following attributes to modify the behavior
4985 of an interrupt handler:
4986 @table @code
4987 @item use_shadow_register_set
4988 @cindex @code{use_shadow_register_set} function attribute, MIPS
4989 Assume that the handler uses a shadow register set, instead of
4990 the main general-purpose registers. An optional argument @code{intstack} is
4991 supported to indicate that the shadow register set contains a valid stack
4992 pointer.
4993
4994 @item keep_interrupts_masked
4995 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4996 Keep interrupts masked for the whole function. Without this attribute,
4997 GCC tries to reenable interrupts for as much of the function as it can.
4998
4999 @item use_debug_exception_return
5000 @cindex @code{use_debug_exception_return} function attribute, MIPS
5001 Return using the @code{deret} instruction. Interrupt handlers that don't
5002 have this attribute return using @code{eret} instead.
5003 @end table
5004
5005 You can use any combination of these attributes, as shown below:
5006 @smallexample
5007 void __attribute__ ((interrupt)) v0 ();
5008 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
5009 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
5010 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
5011 void __attribute__ ((interrupt, use_shadow_register_set,
5012 keep_interrupts_masked)) v4 ();
5013 void __attribute__ ((interrupt, use_shadow_register_set,
5014 use_debug_exception_return)) v5 ();
5015 void __attribute__ ((interrupt, keep_interrupts_masked,
5016 use_debug_exception_return)) v6 ();
5017 void __attribute__ ((interrupt, use_shadow_register_set,
5018 keep_interrupts_masked,
5019 use_debug_exception_return)) v7 ();
5020 void __attribute__ ((interrupt("eic"))) v8 ();
5021 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
5022 @end smallexample
5023
5024 @item long_call
5025 @itemx short_call
5026 @itemx near
5027 @itemx far
5028 @cindex indirect calls, MIPS
5029 @cindex @code{long_call} function attribute, MIPS
5030 @cindex @code{short_call} function attribute, MIPS
5031 @cindex @code{near} function attribute, MIPS
5032 @cindex @code{far} function attribute, MIPS
5033 These attributes specify how a particular function is called on MIPS@.
5034 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
5035 command-line switch. The @code{long_call} and @code{far} attributes are
5036 synonyms, and cause the compiler to always call
5037 the function by first loading its address into a register, and then using
5038 the contents of that register. The @code{short_call} and @code{near}
5039 attributes are synonyms, and have the opposite
5040 effect; they specify that non-PIC calls should be made using the more
5041 efficient @code{jal} instruction.
5042
5043 @item mips16
5044 @itemx nomips16
5045 @cindex @code{mips16} function attribute, MIPS
5046 @cindex @code{nomips16} function attribute, MIPS
5047
5048 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
5049 function attributes to locally select or turn off MIPS16 code generation.
5050 A function with the @code{mips16} attribute is emitted as MIPS16 code,
5051 while MIPS16 code generation is disabled for functions with the
5052 @code{nomips16} attribute. These attributes override the
5053 @option{-mips16} and @option{-mno-mips16} options on the command line
5054 (@pxref{MIPS Options}).
5055
5056 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
5057 preprocessor symbol @code{__mips16} reflects the setting on the command line,
5058 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
5059 may interact badly with some GCC extensions such as @code{__builtin_apply}
5060 (@pxref{Constructing Calls}).
5061
5062 @item micromips, MIPS
5063 @itemx nomicromips, MIPS
5064 @cindex @code{micromips} function attribute
5065 @cindex @code{nomicromips} function attribute
5066
5067 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
5068 function attributes to locally select or turn off microMIPS code generation.
5069 A function with the @code{micromips} attribute is emitted as microMIPS code,
5070 while microMIPS code generation is disabled for functions with the
5071 @code{nomicromips} attribute. These attributes override the
5072 @option{-mmicromips} and @option{-mno-micromips} options on the command line
5073 (@pxref{MIPS Options}).
5074
5075 When compiling files containing mixed microMIPS and non-microMIPS code, the
5076 preprocessor symbol @code{__mips_micromips} reflects the setting on the
5077 command line,
5078 not that within individual functions. Mixed microMIPS and non-microMIPS code
5079 may interact badly with some GCC extensions such as @code{__builtin_apply}
5080 (@pxref{Constructing Calls}).
5081
5082 @item nocompression
5083 @cindex @code{nocompression} function attribute, MIPS
5084 On MIPS targets, you can use the @code{nocompression} function attribute
5085 to locally turn off MIPS16 and microMIPS code generation. This attribute
5086 overrides the @option{-mips16} and @option{-mmicromips} options on the
5087 command line (@pxref{MIPS Options}).
5088 @end table
5089
5090 @node MSP430 Function Attributes
5091 @subsection MSP430 Function Attributes
5092
5093 These function attributes are supported by the MSP430 back end:
5094
5095 @table @code
5096 @item critical
5097 @cindex @code{critical} function attribute, MSP430
5098 Critical functions disable interrupts upon entry and restore the
5099 previous interrupt state upon exit. Critical functions cannot also
5100 have the @code{naked}, @code{reentrant} or @code{interrupt} attributes.
5101
5102 The MSP430 hardware ensures that interrupts are disabled on entry to
5103 @code{interrupt} functions, and restores the previous interrupt state
5104 on exit. The @code{critical} attribute is therefore redundant on
5105 @code{interrupt} functions.
5106
5107 @item interrupt
5108 @cindex @code{interrupt} function attribute, MSP430
5109 Use this attribute to indicate
5110 that the specified function is an interrupt handler. The compiler generates
5111 function entry and exit sequences suitable for use in an interrupt handler
5112 when this attribute is present.
5113
5114 You can provide an argument to the interrupt
5115 attribute which specifies a name or number. If the argument is a
5116 number it indicates the slot in the interrupt vector table (0 - 31) to
5117 which this handler should be assigned. If the argument is a name it
5118 is treated as a symbolic name for the vector slot. These names should
5119 match up with appropriate entries in the linker script. By default
5120 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
5121 @code{reset} for vector 31 are recognized.
5122
5123 @item naked
5124 @cindex @code{naked} function attribute, MSP430
5125 This attribute allows the compiler to construct the
5126 requisite function declaration, while allowing the body of the
5127 function to be assembly code. The specified function will not have
5128 prologue/epilogue sequences generated by the compiler. Only basic
5129 @code{asm} statements can safely be included in naked functions
5130 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5131 basic @code{asm} and C code may appear to work, they cannot be
5132 depended upon to work reliably and are not supported.
5133
5134 @item reentrant
5135 @cindex @code{reentrant} function attribute, MSP430
5136 Reentrant functions disable interrupts upon entry and enable them
5137 upon exit. Reentrant functions cannot also have the @code{naked}
5138 or @code{critical} attributes. They can have the @code{interrupt}
5139 attribute.
5140
5141 @item wakeup
5142 @cindex @code{wakeup} function attribute, MSP430
5143 This attribute only applies to interrupt functions. It is silently
5144 ignored if applied to a non-interrupt function. A wakeup interrupt
5145 function will rouse the processor from any low-power state that it
5146 might be in when the function exits.
5147
5148 @item lower
5149 @itemx upper
5150 @itemx either
5151 @cindex @code{lower} function attribute, MSP430
5152 @cindex @code{upper} function attribute, MSP430
5153 @cindex @code{either} function attribute, MSP430
5154 On the MSP430 target these attributes can be used to specify whether
5155 the function or variable should be placed into low memory, high
5156 memory, or the placement should be left to the linker to decide. The
5157 attributes are only significant if compiling for the MSP430X
5158 architecture.
5159
5160 The attributes work in conjunction with a linker script that has been
5161 augmented to specify where to place sections with a @code{.lower} and
5162 a @code{.upper} prefix. So, for example, as well as placing the
5163 @code{.data} section, the script also specifies the placement of a
5164 @code{.lower.data} and a @code{.upper.data} section. The intention
5165 is that @code{lower} sections are placed into a small but easier to
5166 access memory region and the upper sections are placed into a larger, but
5167 slower to access, region.
5168
5169 The @code{either} attribute is special. It tells the linker to place
5170 the object into the corresponding @code{lower} section if there is
5171 room for it. If there is insufficient room then the object is placed
5172 into the corresponding @code{upper} section instead. Note that the
5173 placement algorithm is not very sophisticated. It does not attempt to
5174 find an optimal packing of the @code{lower} sections. It just makes
5175 one pass over the objects and does the best that it can. Using the
5176 @option{-ffunction-sections} and @option{-fdata-sections} command-line
5177 options can help the packing, however, since they produce smaller,
5178 easier to pack regions.
5179 @end table
5180
5181 @node NDS32 Function Attributes
5182 @subsection NDS32 Function Attributes
5183
5184 These function attributes are supported by the NDS32 back end:
5185
5186 @table @code
5187 @item exception
5188 @cindex @code{exception} function attribute
5189 @cindex exception handler functions, NDS32
5190 Use this attribute on the NDS32 target to indicate that the specified function
5191 is an exception handler. The compiler will generate corresponding sections
5192 for use in an exception handler.
5193
5194 @item interrupt
5195 @cindex @code{interrupt} function attribute, NDS32
5196 On NDS32 target, this attribute indicates that the specified function
5197 is an interrupt handler. The compiler generates corresponding sections
5198 for use in an interrupt handler. You can use the following attributes
5199 to modify the behavior:
5200 @table @code
5201 @item nested
5202 @cindex @code{nested} function attribute, NDS32
5203 This interrupt service routine is interruptible.
5204 @item not_nested
5205 @cindex @code{not_nested} function attribute, NDS32
5206 This interrupt service routine is not interruptible.
5207 @item nested_ready
5208 @cindex @code{nested_ready} function attribute, NDS32
5209 This interrupt service routine is interruptible after @code{PSW.GIE}
5210 (global interrupt enable) is set. This allows interrupt service routine to
5211 finish some short critical code before enabling interrupts.
5212 @item save_all
5213 @cindex @code{save_all} function attribute, NDS32
5214 The system will help save all registers into stack before entering
5215 interrupt handler.
5216 @item partial_save
5217 @cindex @code{partial_save} function attribute, NDS32
5218 The system will help save caller registers into stack before entering
5219 interrupt handler.
5220 @end table
5221
5222 @item naked
5223 @cindex @code{naked} function attribute, NDS32
5224 This attribute allows the compiler to construct the
5225 requisite function declaration, while allowing the body of the
5226 function to be assembly code. The specified function will not have
5227 prologue/epilogue sequences generated by the compiler. Only basic
5228 @code{asm} statements can safely be included in naked functions
5229 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5230 basic @code{asm} and C code may appear to work, they cannot be
5231 depended upon to work reliably and are not supported.
5232
5233 @item reset
5234 @cindex @code{reset} function attribute, NDS32
5235 @cindex reset handler functions
5236 Use this attribute on the NDS32 target to indicate that the specified function
5237 is a reset handler. The compiler will generate corresponding sections
5238 for use in a reset handler. You can use the following attributes
5239 to provide extra exception handling:
5240 @table @code
5241 @item nmi
5242 @cindex @code{nmi} function attribute, NDS32
5243 Provide a user-defined function to handle NMI exception.
5244 @item warm
5245 @cindex @code{warm} function attribute, NDS32
5246 Provide a user-defined function to handle warm reset exception.
5247 @end table
5248 @end table
5249
5250 @node Nios II Function Attributes
5251 @subsection Nios II Function Attributes
5252
5253 These function attributes are supported by the Nios II back end:
5254
5255 @table @code
5256 @item target (@var{options})
5257 @cindex @code{target} function attribute
5258 As discussed in @ref{Common Function Attributes}, this attribute
5259 allows specification of target-specific compilation options.
5260
5261 When compiling for Nios II, the following options are allowed:
5262
5263 @table @samp
5264 @item custom-@var{insn}=@var{N}
5265 @itemx no-custom-@var{insn}
5266 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
5267 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
5268 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
5269 custom instruction with encoding @var{N} when generating code that uses
5270 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
5271 the custom instruction @var{insn}.
5272 These target attributes correspond to the
5273 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
5274 command-line options, and support the same set of @var{insn} keywords.
5275 @xref{Nios II Options}, for more information.
5276
5277 @item custom-fpu-cfg=@var{name}
5278 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
5279 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
5280 command-line option, to select a predefined set of custom instructions
5281 named @var{name}.
5282 @xref{Nios II Options}, for more information.
5283 @end table
5284 @end table
5285
5286 @node Nvidia PTX Function Attributes
5287 @subsection Nvidia PTX Function Attributes
5288
5289 These function attributes are supported by the Nvidia PTX back end:
5290
5291 @table @code
5292 @item kernel
5293 @cindex @code{kernel} attribute, Nvidia PTX
5294 This attribute indicates that the corresponding function should be compiled
5295 as a kernel function, which can be invoked from the host via the CUDA RT
5296 library.
5297 By default functions are only callable only from other PTX functions.
5298
5299 Kernel functions must have @code{void} return type.
5300 @end table
5301
5302 @node PowerPC Function Attributes
5303 @subsection PowerPC Function Attributes
5304
5305 These function attributes are supported by the PowerPC back end:
5306
5307 @table @code
5308 @item longcall
5309 @itemx shortcall
5310 @cindex indirect calls, PowerPC
5311 @cindex @code{longcall} function attribute, PowerPC
5312 @cindex @code{shortcall} function attribute, PowerPC
5313 The @code{longcall} attribute
5314 indicates that the function might be far away from the call site and
5315 require a different (more expensive) calling sequence. The
5316 @code{shortcall} attribute indicates that the function is always close
5317 enough for the shorter calling sequence to be used. These attributes
5318 override both the @option{-mlongcall} switch and
5319 the @code{#pragma longcall} setting.
5320
5321 @xref{RS/6000 and PowerPC Options}, for more information on whether long
5322 calls are necessary.
5323
5324 @item target (@var{options})
5325 @cindex @code{target} function attribute
5326 As discussed in @ref{Common Function Attributes}, this attribute
5327 allows specification of target-specific compilation options.
5328
5329 On the PowerPC, the following options are allowed:
5330
5331 @table @samp
5332 @item altivec
5333 @itemx no-altivec
5334 @cindex @code{target("altivec")} function attribute, PowerPC
5335 Generate code that uses (does not use) AltiVec instructions. In
5336 32-bit code, you cannot enable AltiVec instructions unless
5337 @option{-mabi=altivec} is used on the command line.
5338
5339 @item cmpb
5340 @itemx no-cmpb
5341 @cindex @code{target("cmpb")} function attribute, PowerPC
5342 Generate code that uses (does not use) the compare bytes instruction
5343 implemented on the POWER6 processor and other processors that support
5344 the PowerPC V2.05 architecture.
5345
5346 @item dlmzb
5347 @itemx no-dlmzb
5348 @cindex @code{target("dlmzb")} function attribute, PowerPC
5349 Generate code that uses (does not use) the string-search @samp{dlmzb}
5350 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
5351 generated by default when targeting those processors.
5352
5353 @item fprnd
5354 @itemx no-fprnd
5355 @cindex @code{target("fprnd")} function attribute, PowerPC
5356 Generate code that uses (does not use) the FP round to integer
5357 instructions implemented on the POWER5+ processor and other processors
5358 that support the PowerPC V2.03 architecture.
5359
5360 @item hard-dfp
5361 @itemx no-hard-dfp
5362 @cindex @code{target("hard-dfp")} function attribute, PowerPC
5363 Generate code that uses (does not use) the decimal floating-point
5364 instructions implemented on some POWER processors.
5365
5366 @item isel
5367 @itemx no-isel
5368 @cindex @code{target("isel")} function attribute, PowerPC
5369 Generate code that uses (does not use) ISEL instruction.
5370
5371 @item mfcrf
5372 @itemx no-mfcrf
5373 @cindex @code{target("mfcrf")} function attribute, PowerPC
5374 Generate code that uses (does not use) the move from condition
5375 register field instruction implemented on the POWER4 processor and
5376 other processors that support the PowerPC V2.01 architecture.
5377
5378 @item mfpgpr
5379 @itemx no-mfpgpr
5380 @cindex @code{target("mfpgpr")} function attribute, PowerPC
5381 Generate code that uses (does not use) the FP move to/from general
5382 purpose register instructions implemented on the POWER6X processor and
5383 other processors that support the extended PowerPC V2.05 architecture.
5384
5385 @item mulhw
5386 @itemx no-mulhw
5387 @cindex @code{target("mulhw")} function attribute, PowerPC
5388 Generate code that uses (does not use) the half-word multiply and
5389 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
5390 These instructions are generated by default when targeting those
5391 processors.
5392
5393 @item multiple
5394 @itemx no-multiple
5395 @cindex @code{target("multiple")} function attribute, PowerPC
5396 Generate code that uses (does not use) the load multiple word
5397 instructions and the store multiple word instructions.
5398
5399 @item update
5400 @itemx no-update
5401 @cindex @code{target("update")} function attribute, PowerPC
5402 Generate code that uses (does not use) the load or store instructions
5403 that update the base register to the address of the calculated memory
5404 location.
5405
5406 @item popcntb
5407 @itemx no-popcntb
5408 @cindex @code{target("popcntb")} function attribute, PowerPC
5409 Generate code that uses (does not use) the popcount and double-precision
5410 FP reciprocal estimate instruction implemented on the POWER5
5411 processor and other processors that support the PowerPC V2.02
5412 architecture.
5413
5414 @item popcntd
5415 @itemx no-popcntd
5416 @cindex @code{target("popcntd")} function attribute, PowerPC
5417 Generate code that uses (does not use) the popcount instruction
5418 implemented on the POWER7 processor and other processors that support
5419 the PowerPC V2.06 architecture.
5420
5421 @item powerpc-gfxopt
5422 @itemx no-powerpc-gfxopt
5423 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
5424 Generate code that uses (does not use) the optional PowerPC
5425 architecture instructions in the Graphics group, including
5426 floating-point select.
5427
5428 @item powerpc-gpopt
5429 @itemx no-powerpc-gpopt
5430 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
5431 Generate code that uses (does not use) the optional PowerPC
5432 architecture instructions in the General Purpose group, including
5433 floating-point square root.
5434
5435 @item recip-precision
5436 @itemx no-recip-precision
5437 @cindex @code{target("recip-precision")} function attribute, PowerPC
5438 Assume (do not assume) that the reciprocal estimate instructions
5439 provide higher-precision estimates than is mandated by the PowerPC
5440 ABI.
5441
5442 @item string
5443 @itemx no-string
5444 @cindex @code{target("string")} function attribute, PowerPC
5445 Generate code that uses (does not use) the load string instructions
5446 and the store string word instructions to save multiple registers and
5447 do small block moves.
5448
5449 @item vsx
5450 @itemx no-vsx
5451 @cindex @code{target("vsx")} function attribute, PowerPC
5452 Generate code that uses (does not use) vector/scalar (VSX)
5453 instructions, and also enable the use of built-in functions that allow
5454 more direct access to the VSX instruction set. In 32-bit code, you
5455 cannot enable VSX or AltiVec instructions unless
5456 @option{-mabi=altivec} is used on the command line.
5457
5458 @item friz
5459 @itemx no-friz
5460 @cindex @code{target("friz")} function attribute, PowerPC
5461 Generate (do not generate) the @code{friz} instruction when the
5462 @option{-funsafe-math-optimizations} option is used to optimize
5463 rounding a floating-point value to 64-bit integer and back to floating
5464 point. The @code{friz} instruction does not return the same value if
5465 the floating-point number is too large to fit in an integer.
5466
5467 @item avoid-indexed-addresses
5468 @itemx no-avoid-indexed-addresses
5469 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
5470 Generate code that tries to avoid (not avoid) the use of indexed load
5471 or store instructions.
5472
5473 @item paired
5474 @itemx no-paired
5475 @cindex @code{target("paired")} function attribute, PowerPC
5476 Generate code that uses (does not use) the generation of PAIRED simd
5477 instructions.
5478
5479 @item longcall
5480 @itemx no-longcall
5481 @cindex @code{target("longcall")} function attribute, PowerPC
5482 Generate code that assumes (does not assume) that all calls are far
5483 away so that a longer more expensive calling sequence is required.
5484
5485 @item cpu=@var{CPU}
5486 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
5487 Specify the architecture to generate code for when compiling the
5488 function. If you select the @code{target("cpu=power7")} attribute when
5489 generating 32-bit code, VSX and AltiVec instructions are not generated
5490 unless you use the @option{-mabi=altivec} option on the command line.
5491
5492 @item tune=@var{TUNE}
5493 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
5494 Specify the architecture to tune for when compiling the function. If
5495 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
5496 you do specify the @code{target("cpu=@var{CPU}")} attribute,
5497 compilation tunes for the @var{CPU} architecture, and not the
5498 default tuning specified on the command line.
5499 @end table
5500
5501 On the PowerPC, the inliner does not inline a
5502 function that has different target options than the caller, unless the
5503 callee has a subset of the target options of the caller.
5504 @end table
5505
5506 @node RISC-V Function Attributes
5507 @subsection RISC-V Function Attributes
5508
5509 These function attributes are supported by the RISC-V back end:
5510
5511 @table @code
5512 @item naked
5513 @cindex @code{naked} function attribute, RISC-V
5514 This attribute allows the compiler to construct the
5515 requisite function declaration, while allowing the body of the
5516 function to be assembly code. The specified function will not have
5517 prologue/epilogue sequences generated by the compiler. Only basic
5518 @code{asm} statements can safely be included in naked functions
5519 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5520 basic @code{asm} and C code may appear to work, they cannot be
5521 depended upon to work reliably and are not supported.
5522
5523 @item interrupt
5524 @cindex @code{interrupt} function attribute, RISC-V
5525 Use this attribute to indicate that the specified function is an interrupt
5526 handler. The compiler generates function entry and exit sequences suitable
5527 for use in an interrupt handler when this attribute is present.
5528
5529 You can specify the kind of interrupt to be handled by adding an optional
5530 parameter to the interrupt attribute like this:
5531
5532 @smallexample
5533 void f (void) __attribute__ ((interrupt ("user")));
5534 @end smallexample
5535
5536 Permissible values for this parameter are @code{user}, @code{supervisor},
5537 and @code{machine}. If there is no parameter, then it defaults to
5538 @code{machine}.
5539 @end table
5540
5541 @node RL78 Function Attributes
5542 @subsection RL78 Function Attributes
5543
5544 These function attributes are supported by the RL78 back end:
5545
5546 @table @code
5547 @item interrupt
5548 @itemx brk_interrupt
5549 @cindex @code{interrupt} function attribute, RL78
5550 @cindex @code{brk_interrupt} function attribute, RL78
5551 These attributes indicate
5552 that the specified function is an interrupt handler. The compiler generates
5553 function entry and exit sequences suitable for use in an interrupt handler
5554 when this attribute is present.
5555
5556 Use @code{brk_interrupt} instead of @code{interrupt} for
5557 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
5558 that must end with @code{RETB} instead of @code{RETI}).
5559
5560 @item naked
5561 @cindex @code{naked} function attribute, RL78
5562 This attribute allows the compiler to construct the
5563 requisite function declaration, while allowing the body of the
5564 function to be assembly code. The specified function will not have
5565 prologue/epilogue sequences generated by the compiler. Only basic
5566 @code{asm} statements can safely be included in naked functions
5567 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5568 basic @code{asm} and C code may appear to work, they cannot be
5569 depended upon to work reliably and are not supported.
5570 @end table
5571
5572 @node RX Function Attributes
5573 @subsection RX Function Attributes
5574
5575 These function attributes are supported by the RX back end:
5576
5577 @table @code
5578 @item fast_interrupt
5579 @cindex @code{fast_interrupt} function attribute, RX
5580 Use this attribute on the RX port to indicate that the specified
5581 function is a fast interrupt handler. This is just like the
5582 @code{interrupt} attribute, except that @code{freit} is used to return
5583 instead of @code{reit}.
5584
5585 @item interrupt
5586 @cindex @code{interrupt} function attribute, RX
5587 Use this attribute to indicate
5588 that the specified function is an interrupt handler. The compiler generates
5589 function entry and exit sequences suitable for use in an interrupt handler
5590 when this attribute is present.
5591
5592 On RX and RL78 targets, you may specify one or more vector numbers as arguments
5593 to the attribute, as well as naming an alternate table name.
5594 Parameters are handled sequentially, so one handler can be assigned to
5595 multiple entries in multiple tables. One may also pass the magic
5596 string @code{"$default"} which causes the function to be used for any
5597 unfilled slots in the current table.
5598
5599 This example shows a simple assignment of a function to one vector in
5600 the default table (note that preprocessor macros may be used for
5601 chip-specific symbolic vector names):
5602 @smallexample
5603 void __attribute__ ((interrupt (5))) txd1_handler ();
5604 @end smallexample
5605
5606 This example assigns a function to two slots in the default table
5607 (using preprocessor macros defined elsewhere) and makes it the default
5608 for the @code{dct} table:
5609 @smallexample
5610 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
5611 txd1_handler ();
5612 @end smallexample
5613
5614 @item naked
5615 @cindex @code{naked} function attribute, RX
5616 This attribute allows the compiler to construct the
5617 requisite function declaration, while allowing the body of the
5618 function to be assembly code. The specified function will not have
5619 prologue/epilogue sequences generated by the compiler. Only basic
5620 @code{asm} statements can safely be included in naked functions
5621 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5622 basic @code{asm} and C code may appear to work, they cannot be
5623 depended upon to work reliably and are not supported.
5624
5625 @item vector
5626 @cindex @code{vector} function attribute, RX
5627 This RX attribute is similar to the @code{interrupt} attribute, including its
5628 parameters, but does not make the function an interrupt-handler type
5629 function (i.e.@: it retains the normal C function calling ABI). See the
5630 @code{interrupt} attribute for a description of its arguments.
5631 @end table
5632
5633 @node S/390 Function Attributes
5634 @subsection S/390 Function Attributes
5635
5636 These function attributes are supported on the S/390:
5637
5638 @table @code
5639 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5640 @cindex @code{hotpatch} function attribute, S/390
5641
5642 On S/390 System z targets, you can use this function attribute to
5643 make GCC generate a ``hot-patching'' function prologue. If the
5644 @option{-mhotpatch=} command-line option is used at the same time,
5645 the @code{hotpatch} attribute takes precedence. The first of the
5646 two arguments specifies the number of halfwords to be added before
5647 the function label. A second argument can be used to specify the
5648 number of halfwords to be added after the function label. For
5649 both arguments the maximum allowed value is 1000000.
5650
5651 If both arguments are zero, hotpatching is disabled.
5652
5653 @item target (@var{options})
5654 @cindex @code{target} function attribute
5655 As discussed in @ref{Common Function Attributes}, this attribute
5656 allows specification of target-specific compilation options.
5657
5658 On S/390, the following options are supported:
5659
5660 @table @samp
5661 @item arch=
5662 @item tune=
5663 @item stack-guard=
5664 @item stack-size=
5665 @item branch-cost=
5666 @item warn-framesize=
5667 @item backchain
5668 @itemx no-backchain
5669 @item hard-dfp
5670 @itemx no-hard-dfp
5671 @item hard-float
5672 @itemx soft-float
5673 @item htm
5674 @itemx no-htm
5675 @item vx
5676 @itemx no-vx
5677 @item packed-stack
5678 @itemx no-packed-stack
5679 @item small-exec
5680 @itemx no-small-exec
5681 @item mvcle
5682 @itemx no-mvcle
5683 @item warn-dynamicstack
5684 @itemx no-warn-dynamicstack
5685 @end table
5686
5687 The options work exactly like the S/390 specific command line
5688 options (without the prefix @option{-m}) except that they do not
5689 change any feature macros. For example,
5690
5691 @smallexample
5692 @code{target("no-vx")}
5693 @end smallexample
5694
5695 does not undefine the @code{__VEC__} macro.
5696 @end table
5697
5698 @node SH Function Attributes
5699 @subsection SH Function Attributes
5700
5701 These function attributes are supported on the SH family of processors:
5702
5703 @table @code
5704 @item function_vector
5705 @cindex @code{function_vector} function attribute, SH
5706 @cindex calling functions through the function vector on SH2A
5707 On SH2A targets, this attribute declares a function to be called using the
5708 TBR relative addressing mode. The argument to this attribute is the entry
5709 number of the same function in a vector table containing all the TBR
5710 relative addressable functions. For correct operation the TBR must be setup
5711 accordingly to point to the start of the vector table before any functions with
5712 this attribute are invoked. Usually a good place to do the initialization is
5713 the startup routine. The TBR relative vector table can have at max 256 function
5714 entries. The jumps to these functions are generated using a SH2A specific,
5715 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
5716 from GNU binutils version 2.7 or later for this attribute to work correctly.
5717
5718 In an application, for a function being called once, this attribute
5719 saves at least 8 bytes of code; and if other successive calls are being
5720 made to the same function, it saves 2 bytes of code per each of these
5721 calls.
5722
5723 @item interrupt_handler
5724 @cindex @code{interrupt_handler} function attribute, SH
5725 Use this attribute to
5726 indicate that the specified function is an interrupt handler. The compiler
5727 generates function entry and exit sequences suitable for use in an
5728 interrupt handler when this attribute is present.
5729
5730 @item nosave_low_regs
5731 @cindex @code{nosave_low_regs} function attribute, SH
5732 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5733 function should not save and restore registers R0..R7. This can be used on SH3*
5734 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5735 interrupt handlers.
5736
5737 @item renesas
5738 @cindex @code{renesas} function attribute, SH
5739 On SH targets this attribute specifies that the function or struct follows the
5740 Renesas ABI.
5741
5742 @item resbank
5743 @cindex @code{resbank} function attribute, SH
5744 On the SH2A target, this attribute enables the high-speed register
5745 saving and restoration using a register bank for @code{interrupt_handler}
5746 routines. Saving to the bank is performed automatically after the CPU
5747 accepts an interrupt that uses a register bank.
5748
5749 The nineteen 32-bit registers comprising general register R0 to R14,
5750 control register GBR, and system registers MACH, MACL, and PR and the
5751 vector table address offset are saved into a register bank. Register
5752 banks are stacked in first-in last-out (FILO) sequence. Restoration
5753 from the bank is executed by issuing a RESBANK instruction.
5754
5755 @item sp_switch
5756 @cindex @code{sp_switch} function attribute, SH
5757 Use this attribute on the SH to indicate an @code{interrupt_handler}
5758 function should switch to an alternate stack. It expects a string
5759 argument that names a global variable holding the address of the
5760 alternate stack.
5761
5762 @smallexample
5763 void *alt_stack;
5764 void f () __attribute__ ((interrupt_handler,
5765 sp_switch ("alt_stack")));
5766 @end smallexample
5767
5768 @item trap_exit
5769 @cindex @code{trap_exit} function attribute, SH
5770 Use this attribute on the SH for an @code{interrupt_handler} to return using
5771 @code{trapa} instead of @code{rte}. This attribute expects an integer
5772 argument specifying the trap number to be used.
5773
5774 @item trapa_handler
5775 @cindex @code{trapa_handler} function attribute, SH
5776 On SH targets this function attribute is similar to @code{interrupt_handler}
5777 but it does not save and restore all registers.
5778 @end table
5779
5780 @node SPU Function Attributes
5781 @subsection SPU Function Attributes
5782
5783 These function attributes are supported by the SPU back end:
5784
5785 @table @code
5786 @item naked
5787 @cindex @code{naked} function attribute, SPU
5788 This attribute allows the compiler to construct the
5789 requisite function declaration, while allowing the body of the
5790 function to be assembly code. The specified function will not have
5791 prologue/epilogue sequences generated by the compiler. Only basic
5792 @code{asm} statements can safely be included in naked functions
5793 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5794 basic @code{asm} and C code may appear to work, they cannot be
5795 depended upon to work reliably and are not supported.
5796 @end table
5797
5798 @node Symbian OS Function Attributes
5799 @subsection Symbian OS Function Attributes
5800
5801 @xref{Microsoft Windows Function Attributes}, for discussion of the
5802 @code{dllexport} and @code{dllimport} attributes.
5803
5804 @node V850 Function Attributes
5805 @subsection V850 Function Attributes
5806
5807 The V850 back end supports these function attributes:
5808
5809 @table @code
5810 @item interrupt
5811 @itemx interrupt_handler
5812 @cindex @code{interrupt} function attribute, V850
5813 @cindex @code{interrupt_handler} function attribute, V850
5814 Use these attributes to indicate
5815 that the specified function is an interrupt handler. The compiler generates
5816 function entry and exit sequences suitable for use in an interrupt handler
5817 when either attribute is present.
5818 @end table
5819
5820 @node Visium Function Attributes
5821 @subsection Visium Function Attributes
5822
5823 These function attributes are supported by the Visium back end:
5824
5825 @table @code
5826 @item interrupt
5827 @cindex @code{interrupt} function attribute, Visium
5828 Use this attribute to indicate
5829 that the specified function is an interrupt handler. The compiler generates
5830 function entry and exit sequences suitable for use in an interrupt handler
5831 when this attribute is present.
5832 @end table
5833
5834 @node x86 Function Attributes
5835 @subsection x86 Function Attributes
5836
5837 These function attributes are supported by the x86 back end:
5838
5839 @table @code
5840 @item cdecl
5841 @cindex @code{cdecl} function attribute, x86-32
5842 @cindex functions that pop the argument stack on x86-32
5843 @opindex mrtd
5844 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5845 assume that the calling function pops off the stack space used to
5846 pass arguments. This is
5847 useful to override the effects of the @option{-mrtd} switch.
5848
5849 @item fastcall
5850 @cindex @code{fastcall} function attribute, x86-32
5851 @cindex functions that pop the argument stack on x86-32
5852 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5853 pass the first argument (if of integral type) in the register ECX and
5854 the second argument (if of integral type) in the register EDX@. Subsequent
5855 and other typed arguments are passed on the stack. The called function
5856 pops the arguments off the stack. If the number of arguments is variable all
5857 arguments are pushed on the stack.
5858
5859 @item thiscall
5860 @cindex @code{thiscall} function attribute, x86-32
5861 @cindex functions that pop the argument stack on x86-32
5862 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5863 pass the first argument (if of integral type) in the register ECX.
5864 Subsequent and other typed arguments are passed on the stack. The called
5865 function pops the arguments off the stack.
5866 If the number of arguments is variable all arguments are pushed on the
5867 stack.
5868 The @code{thiscall} attribute is intended for C++ non-static member functions.
5869 As a GCC extension, this calling convention can be used for C functions
5870 and for static member methods.
5871
5872 @item ms_abi
5873 @itemx sysv_abi
5874 @cindex @code{ms_abi} function attribute, x86
5875 @cindex @code{sysv_abi} function attribute, x86
5876
5877 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5878 to indicate which calling convention should be used for a function. The
5879 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5880 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5881 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5882 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5883
5884 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5885 requires the @option{-maccumulate-outgoing-args} option.
5886
5887 @item callee_pop_aggregate_return (@var{number})
5888 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5889
5890 On x86-32 targets, you can use this attribute to control how
5891 aggregates are returned in memory. If the caller is responsible for
5892 popping the hidden pointer together with the rest of the arguments, specify
5893 @var{number} equal to zero. If callee is responsible for popping the
5894 hidden pointer, specify @var{number} equal to one.
5895
5896 The default x86-32 ABI assumes that the callee pops the
5897 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5898 the compiler assumes that the
5899 caller pops the stack for hidden pointer.
5900
5901 @item ms_hook_prologue
5902 @cindex @code{ms_hook_prologue} function attribute, x86
5903
5904 On 32-bit and 64-bit x86 targets, you can use
5905 this function attribute to make GCC generate the ``hot-patching'' function
5906 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5907 and newer.
5908
5909 @item naked
5910 @cindex @code{naked} function attribute, x86
5911 This attribute allows the compiler to construct the
5912 requisite function declaration, while allowing the body of the
5913 function to be assembly code. The specified function will not have
5914 prologue/epilogue sequences generated by the compiler. Only basic
5915 @code{asm} statements can safely be included in naked functions
5916 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5917 basic @code{asm} and C code may appear to work, they cannot be
5918 depended upon to work reliably and are not supported.
5919
5920 @item regparm (@var{number})
5921 @cindex @code{regparm} function attribute, x86
5922 @cindex functions that are passed arguments in registers on x86-32
5923 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5924 pass arguments number one to @var{number} if they are of integral type
5925 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5926 take a variable number of arguments continue to be passed all of their
5927 arguments on the stack.
5928
5929 Beware that on some ELF systems this attribute is unsuitable for
5930 global functions in shared libraries with lazy binding (which is the
5931 default). Lazy binding sends the first call via resolving code in
5932 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5933 per the standard calling conventions. Solaris 8 is affected by this.
5934 Systems with the GNU C Library version 2.1 or higher
5935 and FreeBSD are believed to be
5936 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5937 disabled with the linker or the loader if desired, to avoid the
5938 problem.)
5939
5940 @item sseregparm
5941 @cindex @code{sseregparm} function attribute, x86
5942 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5943 causes the compiler to pass up to 3 floating-point arguments in
5944 SSE registers instead of on the stack. Functions that take a
5945 variable number of arguments continue to pass all of their
5946 floating-point arguments on the stack.
5947
5948 @item force_align_arg_pointer
5949 @cindex @code{force_align_arg_pointer} function attribute, x86
5950 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5951 applied to individual function definitions, generating an alternate
5952 prologue and epilogue that realigns the run-time stack if necessary.
5953 This supports mixing legacy codes that run with a 4-byte aligned stack
5954 with modern codes that keep a 16-byte stack for SSE compatibility.
5955
5956 @item stdcall
5957 @cindex @code{stdcall} function attribute, x86-32
5958 @cindex functions that pop the argument stack on x86-32
5959 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5960 assume that the called function pops off the stack space used to
5961 pass arguments, unless it takes a variable number of arguments.
5962
5963 @item no_caller_saved_registers
5964 @cindex @code{no_caller_saved_registers} function attribute, x86
5965 Use this attribute to indicate that the specified function has no
5966 caller-saved registers. That is, all registers are callee-saved. For
5967 example, this attribute can be used for a function called from an
5968 interrupt handler. The compiler generates proper function entry and
5969 exit sequences to save and restore any modified registers, except for
5970 the EFLAGS register. Since GCC doesn't preserve SSE, MMX nor x87
5971 states, the GCC option @option{-mgeneral-regs-only} should be used to
5972 compile functions with @code{no_caller_saved_registers} attribute.
5973
5974 @item interrupt
5975 @cindex @code{interrupt} function attribute, x86
5976 Use this attribute to indicate that the specified function is an
5977 interrupt handler or an exception handler (depending on parameters passed
5978 to the function, explained further). The compiler generates function
5979 entry and exit sequences suitable for use in an interrupt handler when
5980 this attribute is present. The @code{IRET} instruction, instead of the
5981 @code{RET} instruction, is used to return from interrupt handlers. All
5982 registers, except for the EFLAGS register which is restored by the
5983 @code{IRET} instruction, are preserved by the compiler. Since GCC
5984 doesn't preserve SSE, MMX nor x87 states, the GCC option
5985 @option{-mgeneral-regs-only} should be used to compile interrupt and
5986 exception handlers.
5987
5988 Any interruptible-without-stack-switch code must be compiled with
5989 @option{-mno-red-zone} since interrupt handlers can and will, because
5990 of the hardware design, touch the red zone.
5991
5992 An interrupt handler must be declared with a mandatory pointer
5993 argument:
5994
5995 @smallexample
5996 struct interrupt_frame;
5997
5998 __attribute__ ((interrupt))
5999 void
6000 f (struct interrupt_frame *frame)
6001 @{
6002 @}
6003 @end smallexample
6004
6005 @noindent
6006 and you must define @code{struct interrupt_frame} as described in the
6007 processor's manual.
6008
6009 Exception handlers differ from interrupt handlers because the system
6010 pushes an error code on the stack. An exception handler declaration is
6011 similar to that for an interrupt handler, but with a different mandatory
6012 function signature. The compiler arranges to pop the error code off the
6013 stack before the @code{IRET} instruction.
6014
6015 @smallexample
6016 #ifdef __x86_64__
6017 typedef unsigned long long int uword_t;
6018 #else
6019 typedef unsigned int uword_t;
6020 #endif
6021
6022 struct interrupt_frame;
6023
6024 __attribute__ ((interrupt))
6025 void
6026 f (struct interrupt_frame *frame, uword_t error_code)
6027 @{
6028 ...
6029 @}
6030 @end smallexample
6031
6032 Exception handlers should only be used for exceptions that push an error
6033 code; you should use an interrupt handler in other cases. The system
6034 will crash if the wrong kind of handler is used.
6035
6036 @item target (@var{options})
6037 @cindex @code{target} function attribute
6038 As discussed in @ref{Common Function Attributes}, this attribute
6039 allows specification of target-specific compilation options.
6040
6041 On the x86, the following options are allowed:
6042 @table @samp
6043 @item 3dnow
6044 @itemx no-3dnow
6045 @cindex @code{target("3dnow")} function attribute, x86
6046 Enable/disable the generation of the 3DNow!@: instructions.
6047
6048 @item 3dnowa
6049 @itemx no-3dnowa
6050 @cindex @code{target("3dnowa")} function attribute, x86
6051 Enable/disable the generation of the enhanced 3DNow!@: instructions.
6052
6053 @item abm
6054 @itemx no-abm
6055 @cindex @code{target("abm")} function attribute, x86
6056 Enable/disable the generation of the advanced bit instructions.
6057
6058 @item adx
6059 @itemx no-adx
6060 @cindex @code{target("adx")} function attribute, x86
6061 Enable/disable the generation of the ADX instructions.
6062
6063 @item aes
6064 @itemx no-aes
6065 @cindex @code{target("aes")} function attribute, x86
6066 Enable/disable the generation of the AES instructions.
6067
6068 @item avx
6069 @itemx no-avx
6070 @cindex @code{target("avx")} function attribute, x86
6071 Enable/disable the generation of the AVX instructions.
6072
6073 @item avx2
6074 @itemx no-avx2
6075 @cindex @code{target("avx2")} function attribute, x86
6076 Enable/disable the generation of the AVX2 instructions.
6077
6078 @item avx5124fmaps
6079 @itemx no-avx5124fmaps
6080 @cindex @code{target("avx5124fmaps")} function attribute, x86
6081 Enable/disable the generation of the AVX5124FMAPS instructions.
6082
6083 @item avx5124vnniw
6084 @itemx no-avx5124vnniw
6085 @cindex @code{target("avx5124vnniw")} function attribute, x86
6086 Enable/disable the generation of the AVX5124VNNIW instructions.
6087
6088 @item avx512bitalg
6089 @itemx no-avx512bitalg
6090 @cindex @code{target("avx512bitalg")} function attribute, x86
6091 Enable/disable the generation of the AVX512BITALG instructions.
6092
6093 @item avx512bw
6094 @itemx no-avx512bw
6095 @cindex @code{target("avx512bw")} function attribute, x86
6096 Enable/disable the generation of the AVX512BW instructions.
6097
6098 @item avx512cd
6099 @itemx no-avx512cd
6100 @cindex @code{target("avx512cd")} function attribute, x86
6101 Enable/disable the generation of the AVX512CD instructions.
6102
6103 @item avx512dq
6104 @itemx no-avx512dq
6105 @cindex @code{target("avx512dq")} function attribute, x86
6106 Enable/disable the generation of the AVX512DQ instructions.
6107
6108 @item avx512er
6109 @itemx no-avx512er
6110 @cindex @code{target("avx512er")} function attribute, x86
6111 Enable/disable the generation of the AVX512ER instructions.
6112
6113 @item avx512f
6114 @itemx no-avx512f
6115 @cindex @code{target("avx512f")} function attribute, x86
6116 Enable/disable the generation of the AVX512F instructions.
6117
6118 @item avx512ifma
6119 @itemx no-avx512ifma
6120 @cindex @code{target("avx512ifma")} function attribute, x86
6121 Enable/disable the generation of the AVX512IFMA instructions.
6122
6123 @item avx512pf
6124 @itemx no-avx512pf
6125 @cindex @code{target("avx512pf")} function attribute, x86
6126 Enable/disable the generation of the AVX512PF instructions.
6127
6128 @item avx512vbmi
6129 @itemx no-avx512vbmi
6130 @cindex @code{target("avx512vbmi")} function attribute, x86
6131 Enable/disable the generation of the AVX512VBMI instructions.
6132
6133 @item avx512vbmi2
6134 @itemx no-avx512vbmi2
6135 @cindex @code{target("avx512vbmi2")} function attribute, x86
6136 Enable/disable the generation of the AVX512VBMI2 instructions.
6137
6138 @item avx512vl
6139 @itemx no-avx512vl
6140 @cindex @code{target("avx512vl")} function attribute, x86
6141 Enable/disable the generation of the AVX512VL instructions.
6142
6143 @item avx512vnni
6144 @itemx no-avx512vnni
6145 @cindex @code{target("avx512vnni")} function attribute, x86
6146 Enable/disable the generation of the AVX512VNNI instructions.
6147
6148 @item avx512vpopcntdq
6149 @itemx no-avx512vpopcntdq
6150 @cindex @code{target("avx512vpopcntdq")} function attribute, x86
6151 Enable/disable the generation of the AVX512VPOPCNTDQ instructions.
6152
6153 @item bmi
6154 @itemx no-bmi
6155 @cindex @code{target("bmi")} function attribute, x86
6156 Enable/disable the generation of the BMI instructions.
6157
6158 @item bmi2
6159 @itemx no-bmi2
6160 @cindex @code{target("bmi2")} function attribute, x86
6161 Enable/disable the generation of the BMI2 instructions.
6162
6163 @item cldemote
6164 @itemx no-cldemote
6165 @cindex @code{target("cldemote")} function attribute, x86
6166 Enable/disable the generation of the CLDEMOTE instructions.
6167
6168 @item clflushopt
6169 @itemx no-clflushopt
6170 @cindex @code{target("clflushopt")} function attribute, x86
6171 Enable/disable the generation of the CLFLUSHOPT instructions.
6172
6173 @item clwb
6174 @itemx no-clwb
6175 @cindex @code{target("clwb")} function attribute, x86
6176 Enable/disable the generation of the CLWB instructions.
6177
6178 @item clzero
6179 @itemx no-clzero
6180 @cindex @code{target("clzero")} function attribute, x86
6181 Enable/disable the generation of the CLZERO instructions.
6182
6183 @item crc32
6184 @itemx no-crc32
6185 @cindex @code{target("crc32")} function attribute, x86
6186 Enable/disable the generation of the CRC32 instructions.
6187
6188 @item cx16
6189 @itemx no-cx16
6190 @cindex @code{target("cx16")} function attribute, x86
6191 Enable/disable the generation of the CMPXCHG16B instructions.
6192
6193 @item default
6194 @cindex @code{target("default")} function attribute, x86
6195 @xref{Function Multiversioning}, where it is used to specify the
6196 default function version.
6197
6198 @item f16c
6199 @itemx no-f16c
6200 @cindex @code{target("f16c")} function attribute, x86
6201 Enable/disable the generation of the F16C instructions.
6202
6203 @item fma
6204 @itemx no-fma
6205 @cindex @code{target("fma")} function attribute, x86
6206 Enable/disable the generation of the FMA instructions.
6207
6208 @item fma4
6209 @itemx no-fma4
6210 @cindex @code{target("fma4")} function attribute, x86
6211 Enable/disable the generation of the FMA4 instructions.
6212
6213 @item fsgsbase
6214 @itemx no-fsgsbase
6215 @cindex @code{target("fsgsbase")} function attribute, x86
6216 Enable/disable the generation of the FSGSBASE instructions.
6217
6218 @item fxsr
6219 @itemx no-fxsr
6220 @cindex @code{target("fxsr")} function attribute, x86
6221 Enable/disable the generation of the FXSR instructions.
6222
6223 @item gfni
6224 @itemx no-gfni
6225 @cindex @code{target("gfni")} function attribute, x86
6226 Enable/disable the generation of the GFNI instructions.
6227
6228 @item hle
6229 @itemx no-hle
6230 @cindex @code{target("hle")} function attribute, x86
6231 Enable/disable the generation of the HLE instruction prefixes.
6232
6233 @item lwp
6234 @itemx no-lwp
6235 @cindex @code{target("lwp")} function attribute, x86
6236 Enable/disable the generation of the LWP instructions.
6237
6238 @item lzcnt
6239 @itemx no-lzcnt
6240 @cindex @code{target("lzcnt")} function attribute, x86
6241 Enable/disable the generation of the LZCNT instructions.
6242
6243 @item mmx
6244 @itemx no-mmx
6245 @cindex @code{target("mmx")} function attribute, x86
6246 Enable/disable the generation of the MMX instructions.
6247
6248 @item movbe
6249 @itemx no-movbe
6250 @cindex @code{target("movbe")} function attribute, x86
6251 Enable/disable the generation of the MOVBE instructions.
6252
6253 @item movdir64b
6254 @itemx no-movdir64b
6255 @cindex @code{target("movdir64b")} function attribute, x86
6256 Enable/disable the generation of the MOVDIR64B instructions.
6257
6258 @item movdiri
6259 @itemx no-movdiri
6260 @cindex @code{target("movdiri")} function attribute, x86
6261 Enable/disable the generation of the MOVDIRI instructions.
6262
6263 @item mwaitx
6264 @itemx no-mwaitx
6265 @cindex @code{target("mwaitx")} function attribute, x86
6266 Enable/disable the generation of the MWAITX instructions.
6267
6268 @item pclmul
6269 @itemx no-pclmul
6270 @cindex @code{target("pclmul")} function attribute, x86
6271 Enable/disable the generation of the PCLMUL instructions.
6272
6273 @item pconfig
6274 @itemx no-pconfig
6275 @cindex @code{target("pconfig")} function attribute, x86
6276 Enable/disable the generation of the PCONFIG instructions.
6277
6278 @item pku
6279 @itemx no-pku
6280 @cindex @code{target("pku")} function attribute, x86
6281 Enable/disable the generation of the PKU instructions.
6282
6283 @item popcnt
6284 @itemx no-popcnt
6285 @cindex @code{target("popcnt")} function attribute, x86
6286 Enable/disable the generation of the POPCNT instruction.
6287
6288 @item prefetchwt1
6289 @itemx no-prefetchwt1
6290 @cindex @code{target("prefetchwt1")} function attribute, x86
6291 Enable/disable the generation of the PREFETCHWT1 instructions.
6292
6293 @item prfchw
6294 @itemx no-prfchw
6295 @cindex @code{target("prfchw")} function attribute, x86
6296 Enable/disable the generation of the PREFETCHW instruction.
6297
6298 @item ptwrite
6299 @itemx no-ptwrite
6300 @cindex @code{target("ptwrite")} function attribute, x86
6301 Enable/disable the generation of the PTWRITE instructions.
6302
6303 @item rdpid
6304 @itemx no-rdpid
6305 @cindex @code{target("rdpid")} function attribute, x86
6306 Enable/disable the generation of the RDPID instructions.
6307
6308 @item rdrnd
6309 @itemx no-rdrnd
6310 @cindex @code{target("rdrnd")} function attribute, x86
6311 Enable/disable the generation of the RDRND instructions.
6312
6313 @item rdseed
6314 @itemx no-rdseed
6315 @cindex @code{target("rdseed")} function attribute, x86
6316 Enable/disable the generation of the RDSEED instructions.
6317
6318 @item rtm
6319 @itemx no-rtm
6320 @cindex @code{target("rtm")} function attribute, x86
6321 Enable/disable the generation of the RTM instructions.
6322
6323 @item sahf
6324 @itemx no-sahf
6325 @cindex @code{target("sahf")} function attribute, x86
6326 Enable/disable the generation of the SAHF instructions.
6327
6328 @item sgx
6329 @itemx no-sgx
6330 @cindex @code{target("sgx")} function attribute, x86
6331 Enable/disable the generation of the SGX instructions.
6332
6333 @item sha
6334 @itemx no-sha
6335 @cindex @code{target("sha")} function attribute, x86
6336 Enable/disable the generation of the SHA instructions.
6337
6338 @item shstk
6339 @itemx no-shstk
6340 @cindex @code{target("shstk")} function attribute, x86
6341 Enable/disable the shadow stack built-in functions from CET.
6342
6343 @item sse
6344 @itemx no-sse
6345 @cindex @code{target("sse")} function attribute, x86
6346 Enable/disable the generation of the SSE instructions.
6347
6348 @item sse2
6349 @itemx no-sse2
6350 @cindex @code{target("sse2")} function attribute, x86
6351 Enable/disable the generation of the SSE2 instructions.
6352
6353 @item sse3
6354 @itemx no-sse3
6355 @cindex @code{target("sse3")} function attribute, x86
6356 Enable/disable the generation of the SSE3 instructions.
6357
6358 @item sse4
6359 @itemx no-sse4
6360 @cindex @code{target("sse4")} function attribute, x86
6361 Enable/disable the generation of the SSE4 instructions (both SSE4.1
6362 and SSE4.2).
6363
6364 @item sse4.1
6365 @itemx no-sse4.1
6366 @cindex @code{target("sse4.1")} function attribute, x86
6367 Enable/disable the generation of the sse4.1 instructions.
6368
6369 @item sse4.2
6370 @itemx no-sse4.2
6371 @cindex @code{target("sse4.2")} function attribute, x86
6372 Enable/disable the generation of the sse4.2 instructions.
6373
6374 @item sse4a
6375 @itemx no-sse4a
6376 @cindex @code{target("sse4a")} function attribute, x86
6377 Enable/disable the generation of the SSE4A instructions.
6378
6379 @item ssse3
6380 @itemx no-ssse3
6381 @cindex @code{target("ssse3")} function attribute, x86
6382 Enable/disable the generation of the SSSE3 instructions.
6383
6384 @item tbm
6385 @itemx no-tbm
6386 @cindex @code{target("tbm")} function attribute, x86
6387 Enable/disable the generation of the TBM instructions.
6388
6389 @item vaes
6390 @itemx no-vaes
6391 @cindex @code{target("vaes")} function attribute, x86
6392 Enable/disable the generation of the VAES instructions.
6393
6394 @item vpclmulqdq
6395 @itemx no-vpclmulqdq
6396 @cindex @code{target("vpclmulqdq")} function attribute, x86
6397 Enable/disable the generation of the VPCLMULQDQ instructions.
6398
6399 @item waitpkg
6400 @itemx no-waitpkg
6401 @cindex @code{target("waitpkg")} function attribute, x86
6402 Enable/disable the generation of the WAITPKG instructions.
6403
6404 @item wbnoinvd
6405 @itemx no-wbnoinvd
6406 @cindex @code{target("wbnoinvd")} function attribute, x86
6407 Enable/disable the generation of the WBNOINVD instructions.
6408
6409 @item xop
6410 @itemx no-xop
6411 @cindex @code{target("xop")} function attribute, x86
6412 Enable/disable the generation of the XOP instructions.
6413
6414 @item xsave
6415 @itemx no-xsave
6416 @cindex @code{target("xsave")} function attribute, x86
6417 Enable/disable the generation of the XSAVE instructions.
6418
6419 @item xsavec
6420 @itemx no-xsavec
6421 @cindex @code{target("xsavec")} function attribute, x86
6422 Enable/disable the generation of the XSAVEC instructions.
6423
6424 @item xsaveopt
6425 @itemx no-xsaveopt
6426 @cindex @code{target("xsaveopt")} function attribute, x86
6427 Enable/disable the generation of the XSAVEOPT instructions.
6428
6429 @item xsaves
6430 @itemx no-xsaves
6431 @cindex @code{target("xsaves")} function attribute, x86
6432 Enable/disable the generation of the XSAVES instructions.
6433
6434 @item cld
6435 @itemx no-cld
6436 @cindex @code{target("cld")} function attribute, x86
6437 Enable/disable the generation of the CLD before string moves.
6438
6439 @item fancy-math-387
6440 @itemx no-fancy-math-387
6441 @cindex @code{target("fancy-math-387")} function attribute, x86
6442 Enable/disable the generation of the @code{sin}, @code{cos}, and
6443 @code{sqrt} instructions on the 387 floating-point unit.
6444
6445 @item ieee-fp
6446 @itemx no-ieee-fp
6447 @cindex @code{target("ieee-fp")} function attribute, x86
6448 Enable/disable the generation of floating point that depends on IEEE arithmetic.
6449
6450 @item inline-all-stringops
6451 @itemx no-inline-all-stringops
6452 @cindex @code{target("inline-all-stringops")} function attribute, x86
6453 Enable/disable inlining of string operations.
6454
6455 @item inline-stringops-dynamically
6456 @itemx no-inline-stringops-dynamically
6457 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
6458 Enable/disable the generation of the inline code to do small string
6459 operations and calling the library routines for large operations.
6460
6461 @item align-stringops
6462 @itemx no-align-stringops
6463 @cindex @code{target("align-stringops")} function attribute, x86
6464 Do/do not align destination of inlined string operations.
6465
6466 @item recip
6467 @itemx no-recip
6468 @cindex @code{target("recip")} function attribute, x86
6469 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
6470 instructions followed an additional Newton-Raphson step instead of
6471 doing a floating-point division.
6472
6473 @item arch=@var{ARCH}
6474 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
6475 Specify the architecture to generate code for in compiling the function.
6476
6477 @item tune=@var{TUNE}
6478 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
6479 Specify the architecture to tune for in compiling the function.
6480
6481 @item fpmath=@var{FPMATH}
6482 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
6483 Specify which floating-point unit to use. You must specify the
6484 @code{target("fpmath=sse,387")} option as
6485 @code{target("fpmath=sse+387")} because the comma would separate
6486 different options.
6487
6488 @item indirect_branch("@var{choice}")
6489 @cindex @code{indirect_branch} function attribute, x86
6490 On x86 targets, the @code{indirect_branch} attribute causes the compiler
6491 to convert indirect call and jump with @var{choice}. @samp{keep}
6492 keeps indirect call and jump unmodified. @samp{thunk} converts indirect
6493 call and jump to call and return thunk. @samp{thunk-inline} converts
6494 indirect call and jump to inlined call and return thunk.
6495 @samp{thunk-extern} converts indirect call and jump to external call
6496 and return thunk provided in a separate object file.
6497
6498 @item function_return("@var{choice}")
6499 @cindex @code{function_return} function attribute, x86
6500 On x86 targets, the @code{function_return} attribute causes the compiler
6501 to convert function return with @var{choice}. @samp{keep} keeps function
6502 return unmodified. @samp{thunk} converts function return to call and
6503 return thunk. @samp{thunk-inline} converts function return to inlined
6504 call and return thunk. @samp{thunk-extern} converts function return to
6505 external call and return thunk provided in a separate object file.
6506
6507 @item nocf_check
6508 @cindex @code{nocf_check} function attribute
6509 The @code{nocf_check} attribute on a function is used to inform the
6510 compiler that the function's prologue should not be instrumented when
6511 compiled with the @option{-fcf-protection=branch} option. The
6512 compiler assumes that the function's address is a valid target for a
6513 control-flow transfer.
6514
6515 The @code{nocf_check} attribute on a type of pointer to function is
6516 used to inform the compiler that a call through the pointer should
6517 not be instrumented when compiled with the
6518 @option{-fcf-protection=branch} option. The compiler assumes
6519 that the function's address from the pointer is a valid target for
6520 a control-flow transfer. A direct function call through a function
6521 name is assumed to be a safe call thus direct calls are not
6522 instrumented by the compiler.
6523
6524 The @code{nocf_check} attribute is applied to an object's type.
6525 In case of assignment of a function address or a function pointer to
6526 another pointer, the attribute is not carried over from the right-hand
6527 object's type; the type of left-hand object stays unchanged. The
6528 compiler checks for @code{nocf_check} attribute mismatch and reports
6529 a warning in case of mismatch.
6530
6531 @smallexample
6532 @{
6533 int foo (void) __attribute__(nocf_check);
6534 void (*foo1)(void) __attribute__(nocf_check);
6535 void (*foo2)(void);
6536
6537 /* foo's address is assumed to be valid. */
6538 int
6539 foo (void)
6540
6541 /* This call site is not checked for control-flow
6542 validity. */
6543 (*foo1)();
6544
6545 /* A warning is issued about attribute mismatch. */
6546 foo1 = foo2;
6547
6548 /* This call site is still not checked. */
6549 (*foo1)();
6550
6551 /* This call site is checked. */
6552 (*foo2)();
6553
6554 /* A warning is issued about attribute mismatch. */
6555 foo2 = foo1;
6556
6557 /* This call site is still checked. */
6558 (*foo2)();
6559
6560 return 0;
6561 @}
6562 @end smallexample
6563
6564 @item cf_check
6565 @cindex @code{cf_check} function attribute, x86
6566
6567 The @code{cf_check} attribute on a function is used to inform the
6568 compiler that ENDBR instruction should be placed at the function
6569 entry when @option{-fcf-protection=branch} is enabled.
6570
6571 @item indirect_return
6572 @cindex @code{indirect_return} function attribute, x86
6573
6574 The @code{indirect_return} attribute can be applied to a function,
6575 as well as variable or type of function pointer to inform the
6576 compiler that the function may return via indirect branch.
6577
6578 @item fentry_name("@var{name}")
6579 @cindex @code{fentry_name} function attribute, x86
6580 On x86 targets, the @code{fentry_name} attribute sets the function to
6581 call on function entry when function instrumentation is enabled
6582 with @option{-pg -mfentry}. When @var{name} is nop then a 5 byte
6583 nop sequence is generated.
6584
6585 @item fentry_section("@var{name}")
6586 @cindex @code{fentry_section} function attribute, x86
6587 On x86 targets, the @code{fentry_section} attribute sets the name
6588 of the section to record function entry instrumentation calls in when
6589 enabled with @option{-pg -mrecord-mcount}
6590
6591 @end table
6592
6593 On the x86, the inliner does not inline a
6594 function that has different target options than the caller, unless the
6595 callee has a subset of the target options of the caller. For example
6596 a function declared with @code{target("sse3")} can inline a function
6597 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
6598 @end table
6599
6600 @node Xstormy16 Function Attributes
6601 @subsection Xstormy16 Function Attributes
6602
6603 These function attributes are supported by the Xstormy16 back end:
6604
6605 @table @code
6606 @item interrupt
6607 @cindex @code{interrupt} function attribute, Xstormy16
6608 Use this attribute to indicate
6609 that the specified function is an interrupt handler. The compiler generates
6610 function entry and exit sequences suitable for use in an interrupt handler
6611 when this attribute is present.
6612 @end table
6613
6614 @node Variable Attributes
6615 @section Specifying Attributes of Variables
6616 @cindex attribute of variables
6617 @cindex variable attributes
6618
6619 The keyword @code{__attribute__} allows you to specify special properties
6620 of variables, function parameters, or structure, union, and, in C++, class
6621 members. This @code{__attribute__} keyword is followed by an attribute
6622 specification enclosed in double parentheses. Some attributes are currently
6623 defined generically for variables. Other attributes are defined for
6624 variables on particular target systems. Other attributes are available
6625 for functions (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
6626 enumerators (@pxref{Enumerator Attributes}), statements
6627 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
6628 Other front ends might define more attributes
6629 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
6630
6631 @xref{Attribute Syntax}, for details of the exact syntax for using
6632 attributes.
6633
6634 @menu
6635 * Common Variable Attributes::
6636 * ARC Variable Attributes::
6637 * AVR Variable Attributes::
6638 * Blackfin Variable Attributes::
6639 * H8/300 Variable Attributes::
6640 * IA-64 Variable Attributes::
6641 * M32R/D Variable Attributes::
6642 * MeP Variable Attributes::
6643 * Microsoft Windows Variable Attributes::
6644 * MSP430 Variable Attributes::
6645 * Nvidia PTX Variable Attributes::
6646 * PowerPC Variable Attributes::
6647 * RL78 Variable Attributes::
6648 * SPU Variable Attributes::
6649 * V850 Variable Attributes::
6650 * x86 Variable Attributes::
6651 * Xstormy16 Variable Attributes::
6652 @end menu
6653
6654 @node Common Variable Attributes
6655 @subsection Common Variable Attributes
6656
6657 The following attributes are supported on most targets.
6658
6659 @table @code
6660 @cindex @code{aligned} variable attribute
6661 @item aligned
6662 @itemx aligned (@var{alignment})
6663 The @code{aligned} attribute specifies a minimum alignment for the variable
6664 or structure field, measured in bytes. When specified, @var{alignment} must
6665 be an integer constant power of 2. Specifying no @var{alignment} argument
6666 implies the maximum alignment for the target, which is often, but by no
6667 means always, 8 or 16 bytes.
6668
6669 For example, the declaration:
6670
6671 @smallexample
6672 int x __attribute__ ((aligned (16))) = 0;
6673 @end smallexample
6674
6675 @noindent
6676 causes the compiler to allocate the global variable @code{x} on a
6677 16-byte boundary. On a 68040, this could be used in conjunction with
6678 an @code{asm} expression to access the @code{move16} instruction which
6679 requires 16-byte aligned operands.
6680
6681 You can also specify the alignment of structure fields. For example, to
6682 create a double-word aligned @code{int} pair, you could write:
6683
6684 @smallexample
6685 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
6686 @end smallexample
6687
6688 @noindent
6689 This is an alternative to creating a union with a @code{double} member,
6690 which forces the union to be double-word aligned.
6691
6692 As in the preceding examples, you can explicitly specify the alignment
6693 (in bytes) that you wish the compiler to use for a given variable or
6694 structure field. Alternatively, you can leave out the alignment factor
6695 and just ask the compiler to align a variable or field to the
6696 default alignment for the target architecture you are compiling for.
6697 The default alignment is sufficient for all scalar types, but may not be
6698 enough for all vector types on a target that supports vector operations.
6699 The default alignment is fixed for a particular target ABI.
6700
6701 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
6702 which is the largest alignment ever used for any data type on the
6703 target machine you are compiling for. For example, you could write:
6704
6705 @smallexample
6706 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
6707 @end smallexample
6708
6709 The compiler automatically sets the alignment for the declared
6710 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
6711 often make copy operations more efficient, because the compiler can
6712 use whatever instructions copy the biggest chunks of memory when
6713 performing copies to or from the variables or fields that you have
6714 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
6715 may change depending on command-line options.
6716
6717 When used on a struct, or struct member, the @code{aligned} attribute can
6718 only increase the alignment; in order to decrease it, the @code{packed}
6719 attribute must be specified as well. When used as part of a typedef, the
6720 @code{aligned} attribute can both increase and decrease alignment, and
6721 specifying the @code{packed} attribute generates a warning.
6722
6723 Note that the effectiveness of @code{aligned} attributes for static
6724 variables may be limited by inherent limitations in the system linker
6725 and/or object file format. On some systems, the linker is
6726 only able to arrange for variables to be aligned up to a certain maximum
6727 alignment. (For some linkers, the maximum supported alignment may
6728 be very very small.) If your linker is only able to align variables
6729 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6730 in an @code{__attribute__} still only provides you with 8-byte
6731 alignment. See your linker documentation for further information.
6732
6733 Stack variables are not affected by linker restrictions; GCC can properly
6734 align them on any target.
6735
6736 The @code{aligned} attribute can also be used for functions
6737 (@pxref{Common Function Attributes}.)
6738
6739 @cindex @code{warn_if_not_aligned} variable attribute
6740 @item warn_if_not_aligned (@var{alignment})
6741 This attribute specifies a threshold for the structure field, measured
6742 in bytes. If the structure field is aligned below the threshold, a
6743 warning will be issued. For example, the declaration:
6744
6745 @smallexample
6746 struct foo
6747 @{
6748 int i1;
6749 int i2;
6750 unsigned long long x __attribute__ ((warn_if_not_aligned (16)));
6751 @};
6752 @end smallexample
6753
6754 @noindent
6755 causes the compiler to issue an warning on @code{struct foo}, like
6756 @samp{warning: alignment 8 of 'struct foo' is less than 16}.
6757 The compiler also issues a warning, like @samp{warning: 'x' offset
6758 8 in 'struct foo' isn't aligned to 16}, when the structure field has
6759 the misaligned offset:
6760
6761 @smallexample
6762 struct __attribute__ ((aligned (16))) foo
6763 @{
6764 int i1;
6765 int i2;
6766 unsigned long long x __attribute__ ((warn_if_not_aligned (16)));
6767 @};
6768 @end smallexample
6769
6770 This warning can be disabled by @option{-Wno-if-not-aligned}.
6771 The @code{warn_if_not_aligned} attribute can also be used for types
6772 (@pxref{Common Type Attributes}.)
6773
6774 @item alloc_size (@var{position})
6775 @itemx alloc_size (@var{position-1}, @var{position-2})
6776 @cindex @code{alloc_size} variable attribute
6777 The @code{alloc_size} variable attribute may be applied to the declaration
6778 of a pointer to a function that returns a pointer and takes at least one
6779 argument of an integer type. It indicates that the returned pointer points
6780 to an object whose size is given by the function argument at @var{position-1},
6781 or by the product of the arguments at @var{position-1} and @var{position-2}.
6782 Meaningful sizes are positive values less than @code{PTRDIFF_MAX}. Other
6783 sizes are disagnosed when detected. GCC uses this information to improve
6784 the results of @code{__builtin_object_size}.
6785
6786 For instance, the following declarations
6787
6788 @smallexample
6789 typedef __attribute__ ((alloc_size (1, 2))) void*
6790 (*calloc_ptr) (size_t, size_t);
6791 typedef __attribute__ ((alloc_size (1))) void*
6792 (*malloc_ptr) (size_t);
6793 @end smallexample
6794
6795 @noindent
6796 specify that @code{calloc_ptr} is a pointer of a function that, like
6797 the standard C function @code{calloc}, returns an object whose size
6798 is given by the product of arguments 1 and 2, and similarly, that
6799 @code{malloc_ptr}, like the standard C function @code{malloc},
6800 returns an object whose size is given by argument 1 to the function.
6801
6802 @item cleanup (@var{cleanup_function})
6803 @cindex @code{cleanup} variable attribute
6804 The @code{cleanup} attribute runs a function when the variable goes
6805 out of scope. This attribute can only be applied to auto function
6806 scope variables; it may not be applied to parameters or variables
6807 with static storage duration. The function must take one parameter,
6808 a pointer to a type compatible with the variable. The return value
6809 of the function (if any) is ignored.
6810
6811 If @option{-fexceptions} is enabled, then @var{cleanup_function}
6812 is run during the stack unwinding that happens during the
6813 processing of the exception. Note that the @code{cleanup} attribute
6814 does not allow the exception to be caught, only to perform an action.
6815 It is undefined what happens if @var{cleanup_function} does not
6816 return normally.
6817
6818 @item common
6819 @itemx nocommon
6820 @cindex @code{common} variable attribute
6821 @cindex @code{nocommon} variable attribute
6822 @opindex fcommon
6823 @opindex fno-common
6824 The @code{common} attribute requests GCC to place a variable in
6825 ``common'' storage. The @code{nocommon} attribute requests the
6826 opposite---to allocate space for it directly.
6827
6828 These attributes override the default chosen by the
6829 @option{-fno-common} and @option{-fcommon} flags respectively.
6830
6831 @item copy
6832 @itemx copy (@var{variable})
6833 @cindex @code{copy} variable attribute
6834 The @code{copy} attribute applies the set of attributes with which
6835 @var{variable} has been declared to the declaration of the variable
6836 to which the attribute is applied. The attribute is designed for
6837 libraries that define aliases that are expected to specify the same
6838 set of attributes as the aliased symbols. The @code{copy} attribute
6839 can be used with variables, functions or types. However, the kind
6840 of symbol to which the attribute is applied (either varible or
6841 function) must match the kind of symbol to which the argument refers.
6842 The @code{copy} attribute copies only syntactic and semantic attributes
6843 but not attributes that affect a symbol's linkage or visibility such as
6844 @code{alias}, @code{visibility}, or @code{weak}. The @code{deprecated}
6845 attribute is also not copied. @xref{Common Function Attributes}.
6846 @xref{Common Type Attributes}.
6847
6848 @item deprecated
6849 @itemx deprecated (@var{msg})
6850 @cindex @code{deprecated} variable attribute
6851 The @code{deprecated} attribute results in a warning if the variable
6852 is used anywhere in the source file. This is useful when identifying
6853 variables that are expected to be removed in a future version of a
6854 program. The warning also includes the location of the declaration
6855 of the deprecated variable, to enable users to easily find further
6856 information about why the variable is deprecated, or what they should
6857 do instead. Note that the warning only occurs for uses:
6858
6859 @smallexample
6860 extern int old_var __attribute__ ((deprecated));
6861 extern int old_var;
6862 int new_fn () @{ return old_var; @}
6863 @end smallexample
6864
6865 @noindent
6866 results in a warning on line 3 but not line 2. The optional @var{msg}
6867 argument, which must be a string, is printed in the warning if
6868 present.
6869
6870 The @code{deprecated} attribute can also be used for functions and
6871 types (@pxref{Common Function Attributes},
6872 @pxref{Common Type Attributes}).
6873
6874 The message attached to the attribute is affected by the setting of
6875 the @option{-fmessage-length} option.
6876
6877 @item mode (@var{mode})
6878 @cindex @code{mode} variable attribute
6879 This attribute specifies the data type for the declaration---whichever
6880 type corresponds to the mode @var{mode}. This in effect lets you
6881 request an integer or floating-point type according to its width.
6882
6883 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
6884 for a list of the possible keywords for @var{mode}.
6885 You may also specify a mode of @code{byte} or @code{__byte__} to
6886 indicate the mode corresponding to a one-byte integer, @code{word} or
6887 @code{__word__} for the mode of a one-word integer, and @code{pointer}
6888 or @code{__pointer__} for the mode used to represent pointers.
6889
6890 @item nonstring
6891 @cindex @code{nonstring} variable attribute
6892 The @code{nonstring} variable attribute specifies that an object or member
6893 declaration with type array of @code{char}, @code{signed char}, or
6894 @code{unsigned char}, or pointer to such a type is intended to store
6895 character arrays that do not necessarily contain a terminating @code{NUL}.
6896 This is useful in detecting uses of such arrays or pointers with functions
6897 that expect @code{NUL}-terminated strings, and to avoid warnings when such
6898 an array or pointer is used as an argument to a bounded string manipulation
6899 function such as @code{strncpy}. For example, without the attribute, GCC
6900 will issue a warning for the @code{strncpy} call below because it may
6901 truncate the copy without appending the terminating @code{NUL} character.
6902 Using the attribute makes it possible to suppress the warning. However,
6903 when the array is declared with the attribute the call to @code{strlen} is
6904 diagnosed because when the array doesn't contain a @code{NUL}-terminated
6905 string the call is undefined. To copy, compare, of search non-string
6906 character arrays use the @code{memcpy}, @code{memcmp}, @code{memchr},
6907 and other functions that operate on arrays of bytes. In addition,
6908 calling @code{strnlen} and @code{strndup} with such arrays is safe
6909 provided a suitable bound is specified, and not diagnosed.
6910
6911 @smallexample
6912 struct Data
6913 @{
6914 char name [32] __attribute__ ((nonstring));
6915 @};
6916
6917 int f (struct Data *pd, const char *s)
6918 @{
6919 strncpy (pd->name, s, sizeof pd->name);
6920 @dots{}
6921 return strlen (pd->name); // unsafe, gets a warning
6922 @}
6923 @end smallexample
6924
6925 @item packed
6926 @cindex @code{packed} variable attribute
6927 The @code{packed} attribute specifies that a structure member should have
6928 the smallest possible alignment---one bit for a bit-field and one byte
6929 otherwise, unless a larger value is specified with the @code{aligned}
6930 attribute. The attribute does not apply to non-member objects.
6931
6932 For example in the structure below, the member array @code{x} is packed
6933 so that it immediately follows @code{a} with no intervening padding:
6934
6935 @smallexample
6936 struct foo
6937 @{
6938 char a;
6939 int x[2] __attribute__ ((packed));
6940 @};
6941 @end smallexample
6942
6943 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
6944 @code{packed} attribute on bit-fields of type @code{char}. This has
6945 been fixed in GCC 4.4 but the change can lead to differences in the
6946 structure layout. See the documentation of
6947 @option{-Wpacked-bitfield-compat} for more information.
6948
6949 @item section ("@var{section-name}")
6950 @cindex @code{section} variable attribute
6951 Normally, the compiler places the objects it generates in sections like
6952 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
6953 or you need certain particular variables to appear in special sections,
6954 for example to map to special hardware. The @code{section}
6955 attribute specifies that a variable (or function) lives in a particular
6956 section. For example, this small program uses several specific section names:
6957
6958 @smallexample
6959 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
6960 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
6961 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
6962 int init_data __attribute__ ((section ("INITDATA")));
6963
6964 main()
6965 @{
6966 /* @r{Initialize stack pointer} */
6967 init_sp (stack + sizeof (stack));
6968
6969 /* @r{Initialize initialized data} */
6970 memcpy (&init_data, &data, &edata - &data);
6971
6972 /* @r{Turn on the serial ports} */
6973 init_duart (&a);
6974 init_duart (&b);
6975 @}
6976 @end smallexample
6977
6978 @noindent
6979 Use the @code{section} attribute with
6980 @emph{global} variables and not @emph{local} variables,
6981 as shown in the example.
6982
6983 You may use the @code{section} attribute with initialized or
6984 uninitialized global variables but the linker requires
6985 each object be defined once, with the exception that uninitialized
6986 variables tentatively go in the @code{common} (or @code{bss}) section
6987 and can be multiply ``defined''. Using the @code{section} attribute
6988 changes what section the variable goes into and may cause the
6989 linker to issue an error if an uninitialized variable has multiple
6990 definitions. You can force a variable to be initialized with the
6991 @option{-fno-common} flag or the @code{nocommon} attribute.
6992
6993 Some file formats do not support arbitrary sections so the @code{section}
6994 attribute is not available on all platforms.
6995 If you need to map the entire contents of a module to a particular
6996 section, consider using the facilities of the linker instead.
6997
6998 @item tls_model ("@var{tls_model}")
6999 @cindex @code{tls_model} variable attribute
7000 The @code{tls_model} attribute sets thread-local storage model
7001 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
7002 overriding @option{-ftls-model=} command-line switch on a per-variable
7003 basis.
7004 The @var{tls_model} argument should be one of @code{global-dynamic},
7005 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
7006
7007 Not all targets support this attribute.
7008
7009 @item unused
7010 @cindex @code{unused} variable attribute
7011 This attribute, attached to a variable, means that the variable is meant
7012 to be possibly unused. GCC does not produce a warning for this
7013 variable.
7014
7015 @item used
7016 @cindex @code{used} variable attribute
7017 This attribute, attached to a variable with static storage, means that
7018 the variable must be emitted even if it appears that the variable is not
7019 referenced.
7020
7021 When applied to a static data member of a C++ class template, the
7022 attribute also means that the member is instantiated if the
7023 class itself is instantiated.
7024
7025 @item vector_size (@var{bytes})
7026 @cindex @code{vector_size} variable attribute
7027 This attribute specifies the vector size for the variable, measured in
7028 bytes. For example, the declaration:
7029
7030 @smallexample
7031 int foo __attribute__ ((vector_size (16)));
7032 @end smallexample
7033
7034 @noindent
7035 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
7036 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
7037 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
7038
7039 This attribute is only applicable to integral and float scalars,
7040 although arrays, pointers, and function return values are allowed in
7041 conjunction with this construct.
7042
7043 Aggregates with this attribute are invalid, even if they are of the same
7044 size as a corresponding scalar. For example, the declaration:
7045
7046 @smallexample
7047 struct S @{ int a; @};
7048 struct S __attribute__ ((vector_size (16))) foo;
7049 @end smallexample
7050
7051 @noindent
7052 is invalid even if the size of the structure is the same as the size of
7053 the @code{int}.
7054
7055 @item visibility ("@var{visibility_type}")
7056 @cindex @code{visibility} variable attribute
7057 This attribute affects the linkage of the declaration to which it is attached.
7058 The @code{visibility} attribute is described in
7059 @ref{Common Function Attributes}.
7060
7061 @item weak
7062 @cindex @code{weak} variable attribute
7063 The @code{weak} attribute is described in
7064 @ref{Common Function Attributes}.
7065
7066 @end table
7067
7068 @node ARC Variable Attributes
7069 @subsection ARC Variable Attributes
7070
7071 @table @code
7072 @item aux
7073 @cindex @code{aux} variable attribute, ARC
7074 The @code{aux} attribute is used to directly access the ARC's
7075 auxiliary register space from C. The auxilirary register number is
7076 given via attribute argument.
7077
7078 @end table
7079
7080 @node AVR Variable Attributes
7081 @subsection AVR Variable Attributes
7082
7083 @table @code
7084 @item progmem
7085 @cindex @code{progmem} variable attribute, AVR
7086 The @code{progmem} attribute is used on the AVR to place read-only
7087 data in the non-volatile program memory (flash). The @code{progmem}
7088 attribute accomplishes this by putting respective variables into a
7089 section whose name starts with @code{.progmem}.
7090
7091 This attribute works similar to the @code{section} attribute
7092 but adds additional checking.
7093
7094 @table @asis
7095 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
7096 @code{progmem} affects the location
7097 of the data but not how this data is accessed.
7098 In order to read data located with the @code{progmem} attribute
7099 (inline) assembler must be used.
7100 @smallexample
7101 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
7102 #include <avr/pgmspace.h>
7103
7104 /* Locate var in flash memory */
7105 const int var[2] PROGMEM = @{ 1, 2 @};
7106
7107 int read_var (int i)
7108 @{
7109 /* Access var[] by accessor macro from avr/pgmspace.h */
7110 return (int) pgm_read_word (& var[i]);
7111 @}
7112 @end smallexample
7113
7114 AVR is a Harvard architecture processor and data and read-only data
7115 normally resides in the data memory (RAM).
7116
7117 See also the @ref{AVR Named Address Spaces} section for
7118 an alternate way to locate and access data in flash memory.
7119
7120 @item @bullet{}@tie{} AVR cores with flash memory visible in the RAM address range:
7121 On such devices, there is no need for attribute @code{progmem} or
7122 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
7123 Just use standard C / C++. The compiler will generate @code{LD*}
7124 instructions. As flash memory is visible in the RAM address range,
7125 and the default linker script does @emph{not} locate @code{.rodata} in
7126 RAM, no special features are needed in order not to waste RAM for
7127 read-only data or to read from flash. You might even get slightly better
7128 performance by
7129 avoiding @code{progmem} and @code{__flash}. This applies to devices from
7130 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
7131 an overview.
7132
7133 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
7134 The compiler adds @code{0x4000}
7135 to the addresses of objects and declarations in @code{progmem} and locates
7136 the objects in flash memory, namely in section @code{.progmem.data}.
7137 The offset is needed because the flash memory is visible in the RAM
7138 address space starting at address @code{0x4000}.
7139
7140 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
7141 no special functions or macros are needed.
7142
7143 @smallexample
7144 /* var is located in flash memory */
7145 extern const int var[2] __attribute__((progmem));
7146
7147 int read_var (int i)
7148 @{
7149 return var[i];
7150 @}
7151 @end smallexample
7152
7153 Please notice that on these devices, there is no need for @code{progmem}
7154 at all.
7155
7156 @end table
7157
7158 @item io
7159 @itemx io (@var{addr})
7160 @cindex @code{io} variable attribute, AVR
7161 Variables with the @code{io} attribute are used to address
7162 memory-mapped peripherals in the io address range.
7163 If an address is specified, the variable
7164 is assigned that address, and the value is interpreted as an
7165 address in the data address space.
7166 Example:
7167
7168 @smallexample
7169 volatile int porta __attribute__((io (0x22)));
7170 @end smallexample
7171
7172 The address specified in the address in the data address range.
7173
7174 Otherwise, the variable it is not assigned an address, but the
7175 compiler will still use in/out instructions where applicable,
7176 assuming some other module assigns an address in the io address range.
7177 Example:
7178
7179 @smallexample
7180 extern volatile int porta __attribute__((io));
7181 @end smallexample
7182
7183 @item io_low
7184 @itemx io_low (@var{addr})
7185 @cindex @code{io_low} variable attribute, AVR
7186 This is like the @code{io} attribute, but additionally it informs the
7187 compiler that the object lies in the lower half of the I/O area,
7188 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
7189 instructions.
7190
7191 @item address
7192 @itemx address (@var{addr})
7193 @cindex @code{address} variable attribute, AVR
7194 Variables with the @code{address} attribute are used to address
7195 memory-mapped peripherals that may lie outside the io address range.
7196
7197 @smallexample
7198 volatile int porta __attribute__((address (0x600)));
7199 @end smallexample
7200
7201 @item absdata
7202 @cindex @code{absdata} variable attribute, AVR
7203 Variables in static storage and with the @code{absdata} attribute can
7204 be accessed by the @code{LDS} and @code{STS} instructions which take
7205 absolute addresses.
7206
7207 @itemize @bullet
7208 @item
7209 This attribute is only supported for the reduced AVR Tiny core
7210 like ATtiny40.
7211
7212 @item
7213 You must make sure that respective data is located in the
7214 address range @code{0x40}@dots{}@code{0xbf} accessible by
7215 @code{LDS} and @code{STS}. One way to achieve this as an
7216 appropriate linker description file.
7217
7218 @item
7219 If the location does not fit the address range of @code{LDS}
7220 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
7221 warning like
7222 @quotation
7223 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
7224 @end quotation
7225
7226 @end itemize
7227
7228 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
7229
7230 @end table
7231
7232 @node Blackfin Variable Attributes
7233 @subsection Blackfin Variable Attributes
7234
7235 Three attributes are currently defined for the Blackfin.
7236
7237 @table @code
7238 @item l1_data
7239 @itemx l1_data_A
7240 @itemx l1_data_B
7241 @cindex @code{l1_data} variable attribute, Blackfin
7242 @cindex @code{l1_data_A} variable attribute, Blackfin
7243 @cindex @code{l1_data_B} variable attribute, Blackfin
7244 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
7245 Variables with @code{l1_data} attribute are put into the specific section
7246 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
7247 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
7248 attribute are put into the specific section named @code{.l1.data.B}.
7249
7250 @item l2
7251 @cindex @code{l2} variable attribute, Blackfin
7252 Use this attribute on the Blackfin to place the variable into L2 SRAM.
7253 Variables with @code{l2} attribute are put into the specific section
7254 named @code{.l2.data}.
7255 @end table
7256
7257 @node H8/300 Variable Attributes
7258 @subsection H8/300 Variable Attributes
7259
7260 These variable attributes are available for H8/300 targets:
7261
7262 @table @code
7263 @item eightbit_data
7264 @cindex @code{eightbit_data} variable attribute, H8/300
7265 @cindex eight-bit data on the H8/300, H8/300H, and H8S
7266 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
7267 variable should be placed into the eight-bit data section.
7268 The compiler generates more efficient code for certain operations
7269 on data in the eight-bit data area. Note the eight-bit data area is limited to
7270 256 bytes of data.
7271
7272 You must use GAS and GLD from GNU binutils version 2.7 or later for
7273 this attribute to work correctly.
7274
7275 @item tiny_data
7276 @cindex @code{tiny_data} variable attribute, H8/300
7277 @cindex tiny data section on the H8/300H and H8S
7278 Use this attribute on the H8/300H and H8S to indicate that the specified
7279 variable should be placed into the tiny data section.
7280 The compiler generates more efficient code for loads and stores
7281 on data in the tiny data section. Note the tiny data area is limited to
7282 slightly under 32KB of data.
7283
7284 @end table
7285
7286 @node IA-64 Variable Attributes
7287 @subsection IA-64 Variable Attributes
7288
7289 The IA-64 back end supports the following variable attribute:
7290
7291 @table @code
7292 @item model (@var{model-name})
7293 @cindex @code{model} variable attribute, IA-64
7294
7295 On IA-64, use this attribute to set the addressability of an object.
7296 At present, the only supported identifier for @var{model-name} is
7297 @code{small}, indicating addressability via ``small'' (22-bit)
7298 addresses (so that their addresses can be loaded with the @code{addl}
7299 instruction). Caveat: such addressing is by definition not position
7300 independent and hence this attribute must not be used for objects
7301 defined by shared libraries.
7302
7303 @end table
7304
7305 @node M32R/D Variable Attributes
7306 @subsection M32R/D Variable Attributes
7307
7308 One attribute is currently defined for the M32R/D@.
7309
7310 @table @code
7311 @item model (@var{model-name})
7312 @cindex @code{model-name} variable attribute, M32R/D
7313 @cindex variable addressability on the M32R/D
7314 Use this attribute on the M32R/D to set the addressability of an object.
7315 The identifier @var{model-name} is one of @code{small}, @code{medium},
7316 or @code{large}, representing each of the code models.
7317
7318 Small model objects live in the lower 16MB of memory (so that their
7319 addresses can be loaded with the @code{ld24} instruction).
7320
7321 Medium and large model objects may live anywhere in the 32-bit address space
7322 (the compiler generates @code{seth/add3} instructions to load their
7323 addresses).
7324 @end table
7325
7326 @node MeP Variable Attributes
7327 @subsection MeP Variable Attributes
7328
7329 The MeP target has a number of addressing modes and busses. The
7330 @code{near} space spans the standard memory space's first 16 megabytes
7331 (24 bits). The @code{far} space spans the entire 32-bit memory space.
7332 The @code{based} space is a 128-byte region in the memory space that
7333 is addressed relative to the @code{$tp} register. The @code{tiny}
7334 space is a 65536-byte region relative to the @code{$gp} register. In
7335 addition to these memory regions, the MeP target has a separate 16-bit
7336 control bus which is specified with @code{cb} attributes.
7337
7338 @table @code
7339
7340 @item based
7341 @cindex @code{based} variable attribute, MeP
7342 Any variable with the @code{based} attribute is assigned to the
7343 @code{.based} section, and is accessed with relative to the
7344 @code{$tp} register.
7345
7346 @item tiny
7347 @cindex @code{tiny} variable attribute, MeP
7348 Likewise, the @code{tiny} attribute assigned variables to the
7349 @code{.tiny} section, relative to the @code{$gp} register.
7350
7351 @item near
7352 @cindex @code{near} variable attribute, MeP
7353 Variables with the @code{near} attribute are assumed to have addresses
7354 that fit in a 24-bit addressing mode. This is the default for large
7355 variables (@code{-mtiny=4} is the default) but this attribute can
7356 override @code{-mtiny=} for small variables, or override @code{-ml}.
7357
7358 @item far
7359 @cindex @code{far} variable attribute, MeP
7360 Variables with the @code{far} attribute are addressed using a full
7361 32-bit address. Since this covers the entire memory space, this
7362 allows modules to make no assumptions about where variables might be
7363 stored.
7364
7365 @item io
7366 @cindex @code{io} variable attribute, MeP
7367 @itemx io (@var{addr})
7368 Variables with the @code{io} attribute are used to address
7369 memory-mapped peripherals. If an address is specified, the variable
7370 is assigned that address, else it is not assigned an address (it is
7371 assumed some other module assigns an address). Example:
7372
7373 @smallexample
7374 int timer_count __attribute__((io(0x123)));
7375 @end smallexample
7376
7377 @item cb
7378 @itemx cb (@var{addr})
7379 @cindex @code{cb} variable attribute, MeP
7380 Variables with the @code{cb} attribute are used to access the control
7381 bus, using special instructions. @code{addr} indicates the control bus
7382 address. Example:
7383
7384 @smallexample
7385 int cpu_clock __attribute__((cb(0x123)));
7386 @end smallexample
7387
7388 @end table
7389
7390 @node Microsoft Windows Variable Attributes
7391 @subsection Microsoft Windows Variable Attributes
7392
7393 You can use these attributes on Microsoft Windows targets.
7394 @ref{x86 Variable Attributes} for additional Windows compatibility
7395 attributes available on all x86 targets.
7396
7397 @table @code
7398 @item dllimport
7399 @itemx dllexport
7400 @cindex @code{dllimport} variable attribute
7401 @cindex @code{dllexport} variable attribute
7402 The @code{dllimport} and @code{dllexport} attributes are described in
7403 @ref{Microsoft Windows Function Attributes}.
7404
7405 @item selectany
7406 @cindex @code{selectany} variable attribute
7407 The @code{selectany} attribute causes an initialized global variable to
7408 have link-once semantics. When multiple definitions of the variable are
7409 encountered by the linker, the first is selected and the remainder are
7410 discarded. Following usage by the Microsoft compiler, the linker is told
7411 @emph{not} to warn about size or content differences of the multiple
7412 definitions.
7413
7414 Although the primary usage of this attribute is for POD types, the
7415 attribute can also be applied to global C++ objects that are initialized
7416 by a constructor. In this case, the static initialization and destruction
7417 code for the object is emitted in each translation defining the object,
7418 but the calls to the constructor and destructor are protected by a
7419 link-once guard variable.
7420
7421 The @code{selectany} attribute is only available on Microsoft Windows
7422 targets. You can use @code{__declspec (selectany)} as a synonym for
7423 @code{__attribute__ ((selectany))} for compatibility with other
7424 compilers.
7425
7426 @item shared
7427 @cindex @code{shared} variable attribute
7428 On Microsoft Windows, in addition to putting variable definitions in a named
7429 section, the section can also be shared among all running copies of an
7430 executable or DLL@. For example, this small program defines shared data
7431 by putting it in a named section @code{shared} and marking the section
7432 shareable:
7433
7434 @smallexample
7435 int foo __attribute__((section ("shared"), shared)) = 0;
7436
7437 int
7438 main()
7439 @{
7440 /* @r{Read and write foo. All running
7441 copies see the same value.} */
7442 return 0;
7443 @}
7444 @end smallexample
7445
7446 @noindent
7447 You may only use the @code{shared} attribute along with @code{section}
7448 attribute with a fully-initialized global definition because of the way
7449 linkers work. See @code{section} attribute for more information.
7450
7451 The @code{shared} attribute is only available on Microsoft Windows@.
7452
7453 @end table
7454
7455 @node MSP430 Variable Attributes
7456 @subsection MSP430 Variable Attributes
7457
7458 @table @code
7459 @item noinit
7460 @cindex @code{noinit} variable attribute, MSP430
7461 Any data with the @code{noinit} attribute will not be initialised by
7462 the C runtime startup code, or the program loader. Not initialising
7463 data in this way can reduce program startup times.
7464
7465 @item persistent
7466 @cindex @code{persistent} variable attribute, MSP430
7467 Any variable with the @code{persistent} attribute will not be
7468 initialised by the C runtime startup code. Instead its value will be
7469 set once, when the application is loaded, and then never initialised
7470 again, even if the processor is reset or the program restarts.
7471 Persistent data is intended to be placed into FLASH RAM, where its
7472 value will be retained across resets. The linker script being used to
7473 create the application should ensure that persistent data is correctly
7474 placed.
7475
7476 @item lower
7477 @itemx upper
7478 @itemx either
7479 @cindex @code{lower} variable attribute, MSP430
7480 @cindex @code{upper} variable attribute, MSP430
7481 @cindex @code{either} variable attribute, MSP430
7482 These attributes are the same as the MSP430 function attributes of the
7483 same name (@pxref{MSP430 Function Attributes}).
7484 These attributes can be applied to both functions and variables.
7485 @end table
7486
7487 @node Nvidia PTX Variable Attributes
7488 @subsection Nvidia PTX Variable Attributes
7489
7490 These variable attributes are supported by the Nvidia PTX back end:
7491
7492 @table @code
7493 @item shared
7494 @cindex @code{shared} attribute, Nvidia PTX
7495 Use this attribute to place a variable in the @code{.shared} memory space.
7496 This memory space is private to each cooperative thread array; only threads
7497 within one thread block refer to the same instance of the variable.
7498 The runtime does not initialize variables in this memory space.
7499 @end table
7500
7501 @node PowerPC Variable Attributes
7502 @subsection PowerPC Variable Attributes
7503
7504 Three attributes currently are defined for PowerPC configurations:
7505 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7506
7507 @cindex @code{ms_struct} variable attribute, PowerPC
7508 @cindex @code{gcc_struct} variable attribute, PowerPC
7509 For full documentation of the struct attributes please see the
7510 documentation in @ref{x86 Variable Attributes}.
7511
7512 @cindex @code{altivec} variable attribute, PowerPC
7513 For documentation of @code{altivec} attribute please see the
7514 documentation in @ref{PowerPC Type Attributes}.
7515
7516 @node RL78 Variable Attributes
7517 @subsection RL78 Variable Attributes
7518
7519 @cindex @code{saddr} variable attribute, RL78
7520 The RL78 back end supports the @code{saddr} variable attribute. This
7521 specifies placement of the corresponding variable in the SADDR area,
7522 which can be accessed more efficiently than the default memory region.
7523
7524 @node SPU Variable Attributes
7525 @subsection SPU Variable Attributes
7526
7527 @cindex @code{spu_vector} variable attribute, SPU
7528 The SPU supports the @code{spu_vector} attribute for variables. For
7529 documentation of this attribute please see the documentation in
7530 @ref{SPU Type Attributes}.
7531
7532 @node V850 Variable Attributes
7533 @subsection V850 Variable Attributes
7534
7535 These variable attributes are supported by the V850 back end:
7536
7537 @table @code
7538
7539 @item sda
7540 @cindex @code{sda} variable attribute, V850
7541 Use this attribute to explicitly place a variable in the small data area,
7542 which can hold up to 64 kilobytes.
7543
7544 @item tda
7545 @cindex @code{tda} variable attribute, V850
7546 Use this attribute to explicitly place a variable in the tiny data area,
7547 which can hold up to 256 bytes in total.
7548
7549 @item zda
7550 @cindex @code{zda} variable attribute, V850
7551 Use this attribute to explicitly place a variable in the first 32 kilobytes
7552 of memory.
7553 @end table
7554
7555 @node x86 Variable Attributes
7556 @subsection x86 Variable Attributes
7557
7558 Two attributes are currently defined for x86 configurations:
7559 @code{ms_struct} and @code{gcc_struct}.
7560
7561 @table @code
7562 @item ms_struct
7563 @itemx gcc_struct
7564 @cindex @code{ms_struct} variable attribute, x86
7565 @cindex @code{gcc_struct} variable attribute, x86
7566
7567 If @code{packed} is used on a structure, or if bit-fields are used,
7568 it may be that the Microsoft ABI lays out the structure differently
7569 than the way GCC normally does. Particularly when moving packed
7570 data between functions compiled with GCC and the native Microsoft compiler
7571 (either via function call or as data in a file), it may be necessary to access
7572 either format.
7573
7574 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7575 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7576 command-line options, respectively;
7577 see @ref{x86 Options}, for details of how structure layout is affected.
7578 @xref{x86 Type Attributes}, for information about the corresponding
7579 attributes on types.
7580
7581 @end table
7582
7583 @node Xstormy16 Variable Attributes
7584 @subsection Xstormy16 Variable Attributes
7585
7586 One attribute is currently defined for xstormy16 configurations:
7587 @code{below100}.
7588
7589 @table @code
7590 @item below100
7591 @cindex @code{below100} variable attribute, Xstormy16
7592
7593 If a variable has the @code{below100} attribute (@code{BELOW100} is
7594 allowed also), GCC places the variable in the first 0x100 bytes of
7595 memory and use special opcodes to access it. Such variables are
7596 placed in either the @code{.bss_below100} section or the
7597 @code{.data_below100} section.
7598
7599 @end table
7600
7601 @node Type Attributes
7602 @section Specifying Attributes of Types
7603 @cindex attribute of types
7604 @cindex type attributes
7605
7606 The keyword @code{__attribute__} allows you to specify various special
7607 properties of types. Some type attributes apply only to structure and
7608 union types, and in C++, also class types, while others can apply to
7609 any type defined via a @code{typedef} declaration. Unless otherwise
7610 specified, the same restrictions and effects apply to attributes regardless
7611 of whether a type is a trivial structure or a C++ class with user-defined
7612 constructors, destructors, or a copy assignment.
7613
7614 Other attributes are defined for functions (@pxref{Function Attributes}),
7615 labels (@pxref{Label Attributes}), enumerators (@pxref{Enumerator
7616 Attributes}), statements (@pxref{Statement Attributes}), and for variables
7617 (@pxref{Variable Attributes}).
7618
7619 The @code{__attribute__} keyword is followed by an attribute specification
7620 enclosed in double parentheses.
7621
7622 You may specify type attributes in an enum, struct or union type
7623 declaration or definition by placing them immediately after the
7624 @code{struct}, @code{union} or @code{enum} keyword. You can also place
7625 them just past the closing curly brace of the definition, but this is less
7626 preferred because logically the type should be fully defined at
7627 the closing brace.
7628
7629 You can also include type attributes in a @code{typedef} declaration.
7630 @xref{Attribute Syntax}, for details of the exact syntax for using
7631 attributes.
7632
7633 @menu
7634 * Common Type Attributes::
7635 * ARC Type Attributes::
7636 * ARM Type Attributes::
7637 * MeP Type Attributes::
7638 * PowerPC Type Attributes::
7639 * SPU Type Attributes::
7640 * x86 Type Attributes::
7641 @end menu
7642
7643 @node Common Type Attributes
7644 @subsection Common Type Attributes
7645
7646 The following type attributes are supported on most targets.
7647
7648 @table @code
7649 @cindex @code{aligned} type attribute
7650 @item aligned
7651 @itemx aligned (@var{alignment})
7652 The @code{aligned} attribute specifies a minimum alignment (in bytes) for
7653 variables of the specified type. When specified, @var{alignment} must be
7654 a power of 2. Specifying no @var{alignment} argument implies the maximum
7655 alignment for the target, which is often, but by no means always, 8 or 16
7656 bytes. For example, the declarations:
7657
7658 @smallexample
7659 struct __attribute__ ((aligned (8))) S @{ short f[3]; @};
7660 typedef int more_aligned_int __attribute__ ((aligned (8)));
7661 @end smallexample
7662
7663 @noindent
7664 force the compiler to ensure (as far as it can) that each variable whose
7665 type is @code{struct S} or @code{more_aligned_int} is allocated and
7666 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
7667 variables of type @code{struct S} aligned to 8-byte boundaries allows
7668 the compiler to use the @code{ldd} and @code{std} (doubleword load and
7669 store) instructions when copying one variable of type @code{struct S} to
7670 another, thus improving run-time efficiency.
7671
7672 Note that the alignment of any given @code{struct} or @code{union} type
7673 is required by the ISO C standard to be at least a perfect multiple of
7674 the lowest common multiple of the alignments of all of the members of
7675 the @code{struct} or @code{union} in question. This means that you @emph{can}
7676 effectively adjust the alignment of a @code{struct} or @code{union}
7677 type by attaching an @code{aligned} attribute to any one of the members
7678 of such a type, but the notation illustrated in the example above is a
7679 more obvious, intuitive, and readable way to request the compiler to
7680 adjust the alignment of an entire @code{struct} or @code{union} type.
7681
7682 As in the preceding example, you can explicitly specify the alignment
7683 (in bytes) that you wish the compiler to use for a given @code{struct}
7684 or @code{union} type. Alternatively, you can leave out the alignment factor
7685 and just ask the compiler to align a type to the maximum
7686 useful alignment for the target machine you are compiling for. For
7687 example, you could write:
7688
7689 @smallexample
7690 struct __attribute__ ((aligned)) S @{ short f[3]; @};
7691 @end smallexample
7692
7693 Whenever you leave out the alignment factor in an @code{aligned}
7694 attribute specification, the compiler automatically sets the alignment
7695 for the type to the largest alignment that is ever used for any data
7696 type on the target machine you are compiling for. Doing this can often
7697 make copy operations more efficient, because the compiler can use
7698 whatever instructions copy the biggest chunks of memory when performing
7699 copies to or from the variables that have types that you have aligned
7700 this way.
7701
7702 In the example above, if the size of each @code{short} is 2 bytes, then
7703 the size of the entire @code{struct S} type is 6 bytes. The smallest
7704 power of two that is greater than or equal to that is 8, so the
7705 compiler sets the alignment for the entire @code{struct S} type to 8
7706 bytes.
7707
7708 Note that although you can ask the compiler to select a time-efficient
7709 alignment for a given type and then declare only individual stand-alone
7710 objects of that type, the compiler's ability to select a time-efficient
7711 alignment is primarily useful only when you plan to create arrays of
7712 variables having the relevant (efficiently aligned) type. If you
7713 declare or use arrays of variables of an efficiently-aligned type, then
7714 it is likely that your program also does pointer arithmetic (or
7715 subscripting, which amounts to the same thing) on pointers to the
7716 relevant type, and the code that the compiler generates for these
7717 pointer arithmetic operations is often more efficient for
7718 efficiently-aligned types than for other types.
7719
7720 Note that the effectiveness of @code{aligned} attributes may be limited
7721 by inherent limitations in your linker. On many systems, the linker is
7722 only able to arrange for variables to be aligned up to a certain maximum
7723 alignment. (For some linkers, the maximum supported alignment may
7724 be very very small.) If your linker is only able to align variables
7725 up to a maximum of 8-byte alignment, then specifying @code{aligned (16)}
7726 in an @code{__attribute__} still only provides you with 8-byte
7727 alignment. See your linker documentation for further information.
7728
7729 When used on a struct, or struct member, the @code{aligned} attribute can
7730 only increase the alignment; in order to decrease it, the @code{packed}
7731 attribute must be specified as well. When used as part of a typedef, the
7732 @code{aligned} attribute can both increase and decrease alignment, and
7733 specifying the @code{packed} attribute generates a warning.
7734
7735 @cindex @code{warn_if_not_aligned} type attribute
7736 @item warn_if_not_aligned (@var{alignment})
7737 This attribute specifies a threshold for the structure field, measured
7738 in bytes. If the structure field is aligned below the threshold, a
7739 warning will be issued. For example, the declaration:
7740
7741 @smallexample
7742 typedef unsigned long long __u64
7743 __attribute__((aligned (4), warn_if_not_aligned (8)));
7744
7745 struct foo
7746 @{
7747 int i1;
7748 int i2;
7749 __u64 x;
7750 @};
7751 @end smallexample
7752
7753 @noindent
7754 causes the compiler to issue an warning on @code{struct foo}, like
7755 @samp{warning: alignment 4 of 'struct foo' is less than 8}.
7756 It is used to define @code{struct foo} in such a way that
7757 @code{struct foo} has the same layout and the structure field @code{x}
7758 has the same alignment when @code{__u64} is aligned at either 4 or
7759 8 bytes. Align @code{struct foo} to 8 bytes:
7760
7761 @smallexample
7762 struct __attribute__ ((aligned (8))) foo
7763 @{
7764 int i1;
7765 int i2;
7766 __u64 x;
7767 @};
7768 @end smallexample
7769
7770 @noindent
7771 silences the warning. The compiler also issues a warning, like
7772 @samp{warning: 'x' offset 12 in 'struct foo' isn't aligned to 8},
7773 when the structure field has the misaligned offset:
7774
7775 @smallexample
7776 struct __attribute__ ((aligned (8))) foo
7777 @{
7778 int i1;
7779 int i2;
7780 int i3;
7781 __u64 x;
7782 @};
7783 @end smallexample
7784
7785 This warning can be disabled by @option{-Wno-if-not-aligned}.
7786
7787 @item alloc_size (@var{position})
7788 @itemx alloc_size (@var{position-1}, @var{position-2})
7789 @cindex @code{alloc_size} type attribute
7790 The @code{alloc_size} type attribute may be applied to the definition
7791 of a type of a function that returns a pointer and takes at least one
7792 argument of an integer type. It indicates that the returned pointer
7793 points to an object whose size is given by the function argument at
7794 @var{position-1}, or by the product of the arguments at @var{position-1}
7795 and @var{position-2}. Meaningful sizes are positive values less than
7796 @code{PTRDIFF_MAX}. Other sizes are disagnosed when detected. GCC uses
7797 this information to improve the results of @code{__builtin_object_size}.
7798
7799 For instance, the following declarations
7800
7801 @smallexample
7802 typedef __attribute__ ((alloc_size (1, 2))) void*
7803 calloc_type (size_t, size_t);
7804 typedef __attribute__ ((alloc_size (1))) void*
7805 malloc_type (size_t);
7806 @end smallexample
7807
7808 @noindent
7809 specify that @code{calloc_type} is a type of a function that, like
7810 the standard C function @code{calloc}, returns an object whose size
7811 is given by the product of arguments 1 and 2, and that
7812 @code{malloc_type}, like the standard C function @code{malloc},
7813 returns an object whose size is given by argument 1 to the function.
7814
7815 @item copy
7816 @itemx copy (@var{expression})
7817 @cindex @code{copy} type attribute
7818 The @code{copy} attribute applies the set of attributes with which
7819 the type of the @var{expression} has been declared to the declaration
7820 of the type to which the attribute is applied. The attribute is
7821 designed for libraries that define aliases that are expected to
7822 specify the same set of attributes as the aliased symbols.
7823 The @code{copy} attribute can be used with types, variables, or
7824 functions. However, the kind of symbol to which the attribute is
7825 applied (either varible or function) must match the kind of symbol
7826 to which the argument refers.
7827 The @code{copy} attribute copies only syntactic and semantic attributes
7828 but not attributes that affect a symbol's linkage or visibility such as
7829 @code{alias}, @code{visibility}, or @code{weak}. The @code{deprecated}
7830 attribute is also not copied. @xref{Common Function Attributes}.
7831 @xref{Common Variable Attributes}.
7832
7833 For example, suppose @code{struct A} below is defined in some third
7834 party library header to have the alignment requirement @code{N} and
7835 to force a warning whenever a variable of the type is not so aligned
7836 due to attribute @code{packed}. Specifying the @code{copy} attribute
7837 on the definition on the unrelated @code{struct B} has the effect of
7838 copying all relevant attributes from the type referenced by the pointer
7839 expression to @code{struct B}.
7840
7841 @smallexample
7842 struct __attribute__ ((aligned (N), warn_if_not_aligned (N)))
7843 A @{ /* @r{@dots{}} */ @};
7844 struct __attribute__ ((copy ( (struct A *)0)) B @{ /* @r{@dots{}} */ @};
7845 @end smallexample
7846
7847 @item deprecated
7848 @itemx deprecated (@var{msg})
7849 @cindex @code{deprecated} type attribute
7850 The @code{deprecated} attribute results in a warning if the type
7851 is used anywhere in the source file. This is useful when identifying
7852 types that are expected to be removed in a future version of a program.
7853 If possible, the warning also includes the location of the declaration
7854 of the deprecated type, to enable users to easily find further
7855 information about why the type is deprecated, or what they should do
7856 instead. Note that the warnings only occur for uses and then only
7857 if the type is being applied to an identifier that itself is not being
7858 declared as deprecated.
7859
7860 @smallexample
7861 typedef int T1 __attribute__ ((deprecated));
7862 T1 x;
7863 typedef T1 T2;
7864 T2 y;
7865 typedef T1 T3 __attribute__ ((deprecated));
7866 T3 z __attribute__ ((deprecated));
7867 @end smallexample
7868
7869 @noindent
7870 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
7871 warning is issued for line 4 because T2 is not explicitly
7872 deprecated. Line 5 has no warning because T3 is explicitly
7873 deprecated. Similarly for line 6. The optional @var{msg}
7874 argument, which must be a string, is printed in the warning if
7875 present. Control characters in the string will be replaced with
7876 escape sequences, and if the @option{-fmessage-length} option is set
7877 to 0 (its default value) then any newline characters will be ignored.
7878
7879 The @code{deprecated} attribute can also be used for functions and
7880 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
7881
7882 The message attached to the attribute is affected by the setting of
7883 the @option{-fmessage-length} option.
7884
7885 @item designated_init
7886 @cindex @code{designated_init} type attribute
7887 This attribute may only be applied to structure types. It indicates
7888 that any initialization of an object of this type must use designated
7889 initializers rather than positional initializers. The intent of this
7890 attribute is to allow the programmer to indicate that a structure's
7891 layout may change, and that therefore relying on positional
7892 initialization will result in future breakage.
7893
7894 GCC emits warnings based on this attribute by default; use
7895 @option{-Wno-designated-init} to suppress them.
7896
7897 @item may_alias
7898 @cindex @code{may_alias} type attribute
7899 Accesses through pointers to types with this attribute are not subject
7900 to type-based alias analysis, but are instead assumed to be able to alias
7901 any other type of objects.
7902 In the context of section 6.5 paragraph 7 of the C99 standard,
7903 an lvalue expression
7904 dereferencing such a pointer is treated like having a character type.
7905 See @option{-fstrict-aliasing} for more information on aliasing issues.
7906 This extension exists to support some vector APIs, in which pointers to
7907 one vector type are permitted to alias pointers to a different vector type.
7908
7909 Note that an object of a type with this attribute does not have any
7910 special semantics.
7911
7912 Example of use:
7913
7914 @smallexample
7915 typedef short __attribute__ ((__may_alias__)) short_a;
7916
7917 int
7918 main (void)
7919 @{
7920 int a = 0x12345678;
7921 short_a *b = (short_a *) &a;
7922
7923 b[1] = 0;
7924
7925 if (a == 0x12345678)
7926 abort();
7927
7928 exit(0);
7929 @}
7930 @end smallexample
7931
7932 @noindent
7933 If you replaced @code{short_a} with @code{short} in the variable
7934 declaration, the above program would abort when compiled with
7935 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
7936 above.
7937
7938 @item mode (@var{mode})
7939 @cindex @code{mode} type attribute
7940 This attribute specifies the data type for the declaration---whichever
7941 type corresponds to the mode @var{mode}. This in effect lets you
7942 request an integer or floating-point type according to its width.
7943
7944 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
7945 for a list of the possible keywords for @var{mode}.
7946 You may also specify a mode of @code{byte} or @code{__byte__} to
7947 indicate the mode corresponding to a one-byte integer, @code{word} or
7948 @code{__word__} for the mode of a one-word integer, and @code{pointer}
7949 or @code{__pointer__} for the mode used to represent pointers.
7950
7951 @item packed
7952 @cindex @code{packed} type attribute
7953 This attribute, attached to a @code{struct}, @code{union}, or C++ @code{class}
7954 type definition, specifies that each of its members (other than zero-width
7955 bit-fields) is placed to minimize the memory required. This is equivalent
7956 to specifying the @code{packed} attribute on each of the members.
7957
7958 @opindex fshort-enums
7959 When attached to an @code{enum} definition, the @code{packed} attribute
7960 indicates that the smallest integral type should be used.
7961 Specifying the @option{-fshort-enums} flag on the command line
7962 is equivalent to specifying the @code{packed}
7963 attribute on all @code{enum} definitions.
7964
7965 In the following example @code{struct my_packed_struct}'s members are
7966 packed closely together, but the internal layout of its @code{s} member
7967 is not packed---to do that, @code{struct my_unpacked_struct} needs to
7968 be packed too.
7969
7970 @smallexample
7971 struct my_unpacked_struct
7972 @{
7973 char c;
7974 int i;
7975 @};
7976
7977 struct __attribute__ ((__packed__)) my_packed_struct
7978 @{
7979 char c;
7980 int i;
7981 struct my_unpacked_struct s;
7982 @};
7983 @end smallexample
7984
7985 You may only specify the @code{packed} attribute on the definition
7986 of an @code{enum}, @code{struct}, @code{union}, or @code{class},
7987 not on a @code{typedef} that does not also define the enumerated type,
7988 structure, union, or class.
7989
7990 @item scalar_storage_order ("@var{endianness}")
7991 @cindex @code{scalar_storage_order} type attribute
7992 When attached to a @code{union} or a @code{struct}, this attribute sets
7993 the storage order, aka endianness, of the scalar fields of the type, as
7994 well as the array fields whose component is scalar. The supported
7995 endiannesses are @code{big-endian} and @code{little-endian}. The attribute
7996 has no effects on fields which are themselves a @code{union}, a @code{struct}
7997 or an array whose component is a @code{union} or a @code{struct}, and it is
7998 possible for these fields to have a different scalar storage order than the
7999 enclosing type.
8000
8001 This attribute is supported only for targets that use a uniform default
8002 scalar storage order (fortunately, most of them), i.e.@: targets that store
8003 the scalars either all in big-endian or all in little-endian.
8004
8005 Additional restrictions are enforced for types with the reverse scalar
8006 storage order with regard to the scalar storage order of the target:
8007
8008 @itemize
8009 @item Taking the address of a scalar field of a @code{union} or a
8010 @code{struct} with reverse scalar storage order is not permitted and yields
8011 an error.
8012 @item Taking the address of an array field, whose component is scalar, of
8013 a @code{union} or a @code{struct} with reverse scalar storage order is
8014 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
8015 is specified.
8016 @item Taking the address of a @code{union} or a @code{struct} with reverse
8017 scalar storage order is permitted.
8018 @end itemize
8019
8020 These restrictions exist because the storage order attribute is lost when
8021 the address of a scalar or the address of an array with scalar component is
8022 taken, so storing indirectly through this address generally does not work.
8023 The second case is nevertheless allowed to be able to perform a block copy
8024 from or to the array.
8025
8026 Moreover, the use of type punning or aliasing to toggle the storage order
8027 is not supported; that is to say, a given scalar object cannot be accessed
8028 through distinct types that assign a different storage order to it.
8029
8030 @item transparent_union
8031 @cindex @code{transparent_union} type attribute
8032
8033 This attribute, attached to a @code{union} type definition, indicates
8034 that any function parameter having that union type causes calls to that
8035 function to be treated in a special way.
8036
8037 First, the argument corresponding to a transparent union type can be of
8038 any type in the union; no cast is required. Also, if the union contains
8039 a pointer type, the corresponding argument can be a null pointer
8040 constant or a void pointer expression; and if the union contains a void
8041 pointer type, the corresponding argument can be any pointer expression.
8042 If the union member type is a pointer, qualifiers like @code{const} on
8043 the referenced type must be respected, just as with normal pointer
8044 conversions.
8045
8046 Second, the argument is passed to the function using the calling
8047 conventions of the first member of the transparent union, not the calling
8048 conventions of the union itself. All members of the union must have the
8049 same machine representation; this is necessary for this argument passing
8050 to work properly.
8051
8052 Transparent unions are designed for library functions that have multiple
8053 interfaces for compatibility reasons. For example, suppose the
8054 @code{wait} function must accept either a value of type @code{int *} to
8055 comply with POSIX, or a value of type @code{union wait *} to comply with
8056 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
8057 @code{wait} would accept both kinds of arguments, but it would also
8058 accept any other pointer type and this would make argument type checking
8059 less useful. Instead, @code{<sys/wait.h>} might define the interface
8060 as follows:
8061
8062 @smallexample
8063 typedef union __attribute__ ((__transparent_union__))
8064 @{
8065 int *__ip;
8066 union wait *__up;
8067 @} wait_status_ptr_t;
8068
8069 pid_t wait (wait_status_ptr_t);
8070 @end smallexample
8071
8072 @noindent
8073 This interface allows either @code{int *} or @code{union wait *}
8074 arguments to be passed, using the @code{int *} calling convention.
8075 The program can call @code{wait} with arguments of either type:
8076
8077 @smallexample
8078 int w1 () @{ int w; return wait (&w); @}
8079 int w2 () @{ union wait w; return wait (&w); @}
8080 @end smallexample
8081
8082 @noindent
8083 With this interface, @code{wait}'s implementation might look like this:
8084
8085 @smallexample
8086 pid_t wait (wait_status_ptr_t p)
8087 @{
8088 return waitpid (-1, p.__ip, 0);
8089 @}
8090 @end smallexample
8091
8092 @item unused
8093 @cindex @code{unused} type attribute
8094 When attached to a type (including a @code{union} or a @code{struct}),
8095 this attribute means that variables of that type are meant to appear
8096 possibly unused. GCC does not produce a warning for any variables of
8097 that type, even if the variable appears to do nothing. This is often
8098 the case with lock or thread classes, which are usually defined and then
8099 not referenced, but contain constructors and destructors that have
8100 nontrivial bookkeeping functions.
8101
8102 @item visibility
8103 @cindex @code{visibility} type attribute
8104 In C++, attribute visibility (@pxref{Function Attributes}) can also be
8105 applied to class, struct, union and enum types. Unlike other type
8106 attributes, the attribute must appear between the initial keyword and
8107 the name of the type; it cannot appear after the body of the type.
8108
8109 Note that the type visibility is applied to vague linkage entities
8110 associated with the class (vtable, typeinfo node, etc.). In
8111 particular, if a class is thrown as an exception in one shared object
8112 and caught in another, the class must have default visibility.
8113 Otherwise the two shared objects are unable to use the same
8114 typeinfo node and exception handling will break.
8115
8116 @end table
8117
8118 To specify multiple attributes, separate them by commas within the
8119 double parentheses: for example, @samp{__attribute__ ((aligned (16),
8120 packed))}.
8121
8122 @node ARC Type Attributes
8123 @subsection ARC Type Attributes
8124
8125 @cindex @code{uncached} type attribute, ARC
8126 Declaring objects with @code{uncached} allows you to exclude
8127 data-cache participation in load and store operations on those objects
8128 without involving the additional semantic implications of
8129 @code{volatile}. The @code{.di} instruction suffix is used for all
8130 loads and stores of data declared @code{uncached}.
8131
8132 @node ARM Type Attributes
8133 @subsection ARM Type Attributes
8134
8135 @cindex @code{notshared} type attribute, ARM
8136 On those ARM targets that support @code{dllimport} (such as Symbian
8137 OS), you can use the @code{notshared} attribute to indicate that the
8138 virtual table and other similar data for a class should not be
8139 exported from a DLL@. For example:
8140
8141 @smallexample
8142 class __declspec(notshared) C @{
8143 public:
8144 __declspec(dllimport) C();
8145 virtual void f();
8146 @}
8147
8148 __declspec(dllexport)
8149 C::C() @{@}
8150 @end smallexample
8151
8152 @noindent
8153 In this code, @code{C::C} is exported from the current DLL, but the
8154 virtual table for @code{C} is not exported. (You can use
8155 @code{__attribute__} instead of @code{__declspec} if you prefer, but
8156 most Symbian OS code uses @code{__declspec}.)
8157
8158 @node MeP Type Attributes
8159 @subsection MeP Type Attributes
8160
8161 @cindex @code{based} type attribute, MeP
8162 @cindex @code{tiny} type attribute, MeP
8163 @cindex @code{near} type attribute, MeP
8164 @cindex @code{far} type attribute, MeP
8165 Many of the MeP variable attributes may be applied to types as well.
8166 Specifically, the @code{based}, @code{tiny}, @code{near}, and
8167 @code{far} attributes may be applied to either. The @code{io} and
8168 @code{cb} attributes may not be applied to types.
8169
8170 @node PowerPC Type Attributes
8171 @subsection PowerPC Type Attributes
8172
8173 Three attributes currently are defined for PowerPC configurations:
8174 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
8175
8176 @cindex @code{ms_struct} type attribute, PowerPC
8177 @cindex @code{gcc_struct} type attribute, PowerPC
8178 For full documentation of the @code{ms_struct} and @code{gcc_struct}
8179 attributes please see the documentation in @ref{x86 Type Attributes}.
8180
8181 @cindex @code{altivec} type attribute, PowerPC
8182 The @code{altivec} attribute allows one to declare AltiVec vector data
8183 types supported by the AltiVec Programming Interface Manual. The
8184 attribute requires an argument to specify one of three vector types:
8185 @code{vector__}, @code{pixel__} (always followed by unsigned short),
8186 and @code{bool__} (always followed by unsigned).
8187
8188 @smallexample
8189 __attribute__((altivec(vector__)))
8190 __attribute__((altivec(pixel__))) unsigned short
8191 __attribute__((altivec(bool__))) unsigned
8192 @end smallexample
8193
8194 These attributes mainly are intended to support the @code{__vector},
8195 @code{__pixel}, and @code{__bool} AltiVec keywords.
8196
8197 @node SPU Type Attributes
8198 @subsection SPU Type Attributes
8199
8200 @cindex @code{spu_vector} type attribute, SPU
8201 The SPU supports the @code{spu_vector} attribute for types. This attribute
8202 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
8203 Language Extensions Specification. It is intended to support the
8204 @code{__vector} keyword.
8205
8206 @node x86 Type Attributes
8207 @subsection x86 Type Attributes
8208
8209 Two attributes are currently defined for x86 configurations:
8210 @code{ms_struct} and @code{gcc_struct}.
8211
8212 @table @code
8213
8214 @item ms_struct
8215 @itemx gcc_struct
8216 @cindex @code{ms_struct} type attribute, x86
8217 @cindex @code{gcc_struct} type attribute, x86
8218
8219 If @code{packed} is used on a structure, or if bit-fields are used
8220 it may be that the Microsoft ABI packs them differently
8221 than GCC normally packs them. Particularly when moving packed
8222 data between functions compiled with GCC and the native Microsoft compiler
8223 (either via function call or as data in a file), it may be necessary to access
8224 either format.
8225
8226 The @code{ms_struct} and @code{gcc_struct} attributes correspond
8227 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
8228 command-line options, respectively;
8229 see @ref{x86 Options}, for details of how structure layout is affected.
8230 @xref{x86 Variable Attributes}, for information about the corresponding
8231 attributes on variables.
8232
8233 @end table
8234
8235 @node Label Attributes
8236 @section Label Attributes
8237 @cindex Label Attributes
8238
8239 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
8240 details of the exact syntax for using attributes. Other attributes are
8241 available for functions (@pxref{Function Attributes}), variables
8242 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
8243 statements (@pxref{Statement Attributes}), and for types
8244 (@pxref{Type Attributes}).
8245
8246 This example uses the @code{cold} label attribute to indicate the
8247 @code{ErrorHandling} branch is unlikely to be taken and that the
8248 @code{ErrorHandling} label is unused:
8249
8250 @smallexample
8251
8252 asm goto ("some asm" : : : : NoError);
8253
8254 /* This branch (the fall-through from the asm) is less commonly used */
8255 ErrorHandling:
8256 __attribute__((cold, unused)); /* Semi-colon is required here */
8257 printf("error\n");
8258 return 0;
8259
8260 NoError:
8261 printf("no error\n");
8262 return 1;
8263 @end smallexample
8264
8265 @table @code
8266 @item unused
8267 @cindex @code{unused} label attribute
8268 This feature is intended for program-generated code that may contain
8269 unused labels, but which is compiled with @option{-Wall}. It is
8270 not normally appropriate to use in it human-written code, though it
8271 could be useful in cases where the code that jumps to the label is
8272 contained within an @code{#ifdef} conditional.
8273
8274 @item hot
8275 @cindex @code{hot} label attribute
8276 The @code{hot} attribute on a label is used to inform the compiler that
8277 the path following the label is more likely than paths that are not so
8278 annotated. This attribute is used in cases where @code{__builtin_expect}
8279 cannot be used, for instance with computed goto or @code{asm goto}.
8280
8281 @item cold
8282 @cindex @code{cold} label attribute
8283 The @code{cold} attribute on labels is used to inform the compiler that
8284 the path following the label is unlikely to be executed. This attribute
8285 is used in cases where @code{__builtin_expect} cannot be used, for instance
8286 with computed goto or @code{asm goto}.
8287
8288 @end table
8289
8290 @node Enumerator Attributes
8291 @section Enumerator Attributes
8292 @cindex Enumerator Attributes
8293
8294 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
8295 details of the exact syntax for using attributes. Other attributes are
8296 available for functions (@pxref{Function Attributes}), variables
8297 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
8298 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
8299
8300 This example uses the @code{deprecated} enumerator attribute to indicate the
8301 @code{oldval} enumerator is deprecated:
8302
8303 @smallexample
8304 enum E @{
8305 oldval __attribute__((deprecated)),
8306 newval
8307 @};
8308
8309 int
8310 fn (void)
8311 @{
8312 return oldval;
8313 @}
8314 @end smallexample
8315
8316 @table @code
8317 @item deprecated
8318 @cindex @code{deprecated} enumerator attribute
8319 The @code{deprecated} attribute results in a warning if the enumerator
8320 is used anywhere in the source file. This is useful when identifying
8321 enumerators that are expected to be removed in a future version of a
8322 program. The warning also includes the location of the declaration
8323 of the deprecated enumerator, to enable users to easily find further
8324 information about why the enumerator is deprecated, or what they should
8325 do instead. Note that the warnings only occurs for uses.
8326
8327 @end table
8328
8329 @node Statement Attributes
8330 @section Statement Attributes
8331 @cindex Statement Attributes
8332
8333 GCC allows attributes to be set on null statements. @xref{Attribute Syntax},
8334 for details of the exact syntax for using attributes. Other attributes are
8335 available for functions (@pxref{Function Attributes}), variables
8336 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
8337 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
8338
8339 This example uses the @code{fallthrough} statement attribute to indicate that
8340 the @option{-Wimplicit-fallthrough} warning should not be emitted:
8341
8342 @smallexample
8343 switch (cond)
8344 @{
8345 case 1:
8346 bar (1);
8347 __attribute__((fallthrough));
8348 case 2:
8349 @dots{}
8350 @}
8351 @end smallexample
8352
8353 @table @code
8354 @item fallthrough
8355 @cindex @code{fallthrough} statement attribute
8356 The @code{fallthrough} attribute with a null statement serves as a
8357 fallthrough statement. It hints to the compiler that a statement
8358 that falls through to another case label, or user-defined label
8359 in a switch statement is intentional and thus the
8360 @option{-Wimplicit-fallthrough} warning must not trigger. The
8361 fallthrough attribute may appear at most once in each attribute
8362 list, and may not be mixed with other attributes. It can only
8363 be used in a switch statement (the compiler will issue an error
8364 otherwise), after a preceding statement and before a logically
8365 succeeding case label, or user-defined label.
8366
8367 @end table
8368
8369 @node Attribute Syntax
8370 @section Attribute Syntax
8371 @cindex attribute syntax
8372
8373 This section describes the syntax with which @code{__attribute__} may be
8374 used, and the constructs to which attribute specifiers bind, for the C
8375 language. Some details may vary for C++ and Objective-C@. Because of
8376 infelicities in the grammar for attributes, some forms described here
8377 may not be successfully parsed in all cases.
8378
8379 There are some problems with the semantics of attributes in C++. For
8380 example, there are no manglings for attributes, although they may affect
8381 code generation, so problems may arise when attributed types are used in
8382 conjunction with templates or overloading. Similarly, @code{typeid}
8383 does not distinguish between types with different attributes. Support
8384 for attributes in C++ may be restricted in future to attributes on
8385 declarations only, but not on nested declarators.
8386
8387 @xref{Function Attributes}, for details of the semantics of attributes
8388 applying to functions. @xref{Variable Attributes}, for details of the
8389 semantics of attributes applying to variables. @xref{Type Attributes},
8390 for details of the semantics of attributes applying to structure, union
8391 and enumerated types.
8392 @xref{Label Attributes}, for details of the semantics of attributes
8393 applying to labels.
8394 @xref{Enumerator Attributes}, for details of the semantics of attributes
8395 applying to enumerators.
8396 @xref{Statement Attributes}, for details of the semantics of attributes
8397 applying to statements.
8398
8399 An @dfn{attribute specifier} is of the form
8400 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
8401 is a possibly empty comma-separated sequence of @dfn{attributes}, where
8402 each attribute is one of the following:
8403
8404 @itemize @bullet
8405 @item
8406 Empty. Empty attributes are ignored.
8407
8408 @item
8409 An attribute name
8410 (which may be an identifier such as @code{unused}, or a reserved
8411 word such as @code{const}).
8412
8413 @item
8414 An attribute name followed by a parenthesized list of
8415 parameters for the attribute.
8416 These parameters take one of the following forms:
8417
8418 @itemize @bullet
8419 @item
8420 An identifier. For example, @code{mode} attributes use this form.
8421
8422 @item
8423 An identifier followed by a comma and a non-empty comma-separated list
8424 of expressions. For example, @code{format} attributes use this form.
8425
8426 @item
8427 A possibly empty comma-separated list of expressions. For example,
8428 @code{format_arg} attributes use this form with the list being a single
8429 integer constant expression, and @code{alias} attributes use this form
8430 with the list being a single string constant.
8431 @end itemize
8432 @end itemize
8433
8434 An @dfn{attribute specifier list} is a sequence of one or more attribute
8435 specifiers, not separated by any other tokens.
8436
8437 You may optionally specify attribute names with @samp{__}
8438 preceding and following the name.
8439 This allows you to use them in header files without
8440 being concerned about a possible macro of the same name. For example,
8441 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
8442
8443
8444 @subsubheading Label Attributes
8445
8446 In GNU C, an attribute specifier list may appear after the colon following a
8447 label, other than a @code{case} or @code{default} label. GNU C++ only permits
8448 attributes on labels if the attribute specifier is immediately
8449 followed by a semicolon (i.e., the label applies to an empty
8450 statement). If the semicolon is missing, C++ label attributes are
8451 ambiguous, as it is permissible for a declaration, which could begin
8452 with an attribute list, to be labelled in C++. Declarations cannot be
8453 labelled in C90 or C99, so the ambiguity does not arise there.
8454
8455 @subsubheading Enumerator Attributes
8456
8457 In GNU C, an attribute specifier list may appear as part of an enumerator.
8458 The attribute goes after the enumeration constant, before @code{=}, if
8459 present. The optional attribute in the enumerator appertains to the
8460 enumeration constant. It is not possible to place the attribute after
8461 the constant expression, if present.
8462
8463 @subsubheading Statement Attributes
8464 In GNU C, an attribute specifier list may appear as part of a null
8465 statement. The attribute goes before the semicolon.
8466
8467 @subsubheading Type Attributes
8468
8469 An attribute specifier list may appear as part of a @code{struct},
8470 @code{union} or @code{enum} specifier. It may go either immediately
8471 after the @code{struct}, @code{union} or @code{enum} keyword, or after
8472 the closing brace. The former syntax is preferred.
8473 Where attribute specifiers follow the closing brace, they are considered
8474 to relate to the structure, union or enumerated type defined, not to any
8475 enclosing declaration the type specifier appears in, and the type
8476 defined is not complete until after the attribute specifiers.
8477 @c Otherwise, there would be the following problems: a shift/reduce
8478 @c conflict between attributes binding the struct/union/enum and
8479 @c binding to the list of specifiers/qualifiers; and "aligned"
8480 @c attributes could use sizeof for the structure, but the size could be
8481 @c changed later by "packed" attributes.
8482
8483
8484 @subsubheading All other attributes
8485
8486 Otherwise, an attribute specifier appears as part of a declaration,
8487 counting declarations of unnamed parameters and type names, and relates
8488 to that declaration (which may be nested in another declaration, for
8489 example in the case of a parameter declaration), or to a particular declarator
8490 within a declaration. Where an
8491 attribute specifier is applied to a parameter declared as a function or
8492 an array, it should apply to the function or array rather than the
8493 pointer to which the parameter is implicitly converted, but this is not
8494 yet correctly implemented.
8495
8496 Any list of specifiers and qualifiers at the start of a declaration may
8497 contain attribute specifiers, whether or not such a list may in that
8498 context contain storage class specifiers. (Some attributes, however,
8499 are essentially in the nature of storage class specifiers, and only make
8500 sense where storage class specifiers may be used; for example,
8501 @code{section}.) There is one necessary limitation to this syntax: the
8502 first old-style parameter declaration in a function definition cannot
8503 begin with an attribute specifier, because such an attribute applies to
8504 the function instead by syntax described below (which, however, is not
8505 yet implemented in this case). In some other cases, attribute
8506 specifiers are permitted by this grammar but not yet supported by the
8507 compiler. All attribute specifiers in this place relate to the
8508 declaration as a whole. In the obsolescent usage where a type of
8509 @code{int} is implied by the absence of type specifiers, such a list of
8510 specifiers and qualifiers may be an attribute specifier list with no
8511 other specifiers or qualifiers.
8512
8513 At present, the first parameter in a function prototype must have some
8514 type specifier that is not an attribute specifier; this resolves an
8515 ambiguity in the interpretation of @code{void f(int
8516 (__attribute__((foo)) x))}, but is subject to change. At present, if
8517 the parentheses of a function declarator contain only attributes then
8518 those attributes are ignored, rather than yielding an error or warning
8519 or implying a single parameter of type int, but this is subject to
8520 change.
8521
8522 An attribute specifier list may appear immediately before a declarator
8523 (other than the first) in a comma-separated list of declarators in a
8524 declaration of more than one identifier using a single list of
8525 specifiers and qualifiers. Such attribute specifiers apply
8526 only to the identifier before whose declarator they appear. For
8527 example, in
8528
8529 @smallexample
8530 __attribute__((noreturn)) void d0 (void),
8531 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
8532 d2 (void);
8533 @end smallexample
8534
8535 @noindent
8536 the @code{noreturn} attribute applies to all the functions
8537 declared; the @code{format} attribute only applies to @code{d1}.
8538
8539 An attribute specifier list may appear immediately before the comma,
8540 @code{=} or semicolon terminating the declaration of an identifier other
8541 than a function definition. Such attribute specifiers apply
8542 to the declared object or function. Where an
8543 assembler name for an object or function is specified (@pxref{Asm
8544 Labels}), the attribute must follow the @code{asm}
8545 specification.
8546
8547 An attribute specifier list may, in future, be permitted to appear after
8548 the declarator in a function definition (before any old-style parameter
8549 declarations or the function body).
8550
8551 Attribute specifiers may be mixed with type qualifiers appearing inside
8552 the @code{[]} of a parameter array declarator, in the C99 construct by
8553 which such qualifiers are applied to the pointer to which the array is
8554 implicitly converted. Such attribute specifiers apply to the pointer,
8555 not to the array, but at present this is not implemented and they are
8556 ignored.
8557
8558 An attribute specifier list may appear at the start of a nested
8559 declarator. At present, there are some limitations in this usage: the
8560 attributes correctly apply to the declarator, but for most individual
8561 attributes the semantics this implies are not implemented.
8562 When attribute specifiers follow the @code{*} of a pointer
8563 declarator, they may be mixed with any type qualifiers present.
8564 The following describes the formal semantics of this syntax. It makes the
8565 most sense if you are familiar with the formal specification of
8566 declarators in the ISO C standard.
8567
8568 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
8569 D1}, where @code{T} contains declaration specifiers that specify a type
8570 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
8571 contains an identifier @var{ident}. The type specified for @var{ident}
8572 for derived declarators whose type does not include an attribute
8573 specifier is as in the ISO C standard.
8574
8575 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
8576 and the declaration @code{T D} specifies the type
8577 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
8578 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
8579 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
8580
8581 If @code{D1} has the form @code{*
8582 @var{type-qualifier-and-attribute-specifier-list} D}, and the
8583 declaration @code{T D} specifies the type
8584 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
8585 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
8586 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
8587 @var{ident}.
8588
8589 For example,
8590
8591 @smallexample
8592 void (__attribute__((noreturn)) ****f) (void);
8593 @end smallexample
8594
8595 @noindent
8596 specifies the type ``pointer to pointer to pointer to pointer to
8597 non-returning function returning @code{void}''. As another example,
8598
8599 @smallexample
8600 char *__attribute__((aligned(8))) *f;
8601 @end smallexample
8602
8603 @noindent
8604 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
8605 Note again that this does not work with most attributes; for example,
8606 the usage of @samp{aligned} and @samp{noreturn} attributes given above
8607 is not yet supported.
8608
8609 For compatibility with existing code written for compiler versions that
8610 did not implement attributes on nested declarators, some laxity is
8611 allowed in the placing of attributes. If an attribute that only applies
8612 to types is applied to a declaration, it is treated as applying to
8613 the type of that declaration. If an attribute that only applies to
8614 declarations is applied to the type of a declaration, it is treated
8615 as applying to that declaration; and, for compatibility with code
8616 placing the attributes immediately before the identifier declared, such
8617 an attribute applied to a function return type is treated as
8618 applying to the function type, and such an attribute applied to an array
8619 element type is treated as applying to the array type. If an
8620 attribute that only applies to function types is applied to a
8621 pointer-to-function type, it is treated as applying to the pointer
8622 target type; if such an attribute is applied to a function return type
8623 that is not a pointer-to-function type, it is treated as applying
8624 to the function type.
8625
8626 @node Function Prototypes
8627 @section Prototypes and Old-Style Function Definitions
8628 @cindex function prototype declarations
8629 @cindex old-style function definitions
8630 @cindex promotion of formal parameters
8631
8632 GNU C extends ISO C to allow a function prototype to override a later
8633 old-style non-prototype definition. Consider the following example:
8634
8635 @smallexample
8636 /* @r{Use prototypes unless the compiler is old-fashioned.} */
8637 #ifdef __STDC__
8638 #define P(x) x
8639 #else
8640 #define P(x) ()
8641 #endif
8642
8643 /* @r{Prototype function declaration.} */
8644 int isroot P((uid_t));
8645
8646 /* @r{Old-style function definition.} */
8647 int
8648 isroot (x) /* @r{??? lossage here ???} */
8649 uid_t x;
8650 @{
8651 return x == 0;
8652 @}
8653 @end smallexample
8654
8655 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
8656 not allow this example, because subword arguments in old-style
8657 non-prototype definitions are promoted. Therefore in this example the
8658 function definition's argument is really an @code{int}, which does not
8659 match the prototype argument type of @code{short}.
8660
8661 This restriction of ISO C makes it hard to write code that is portable
8662 to traditional C compilers, because the programmer does not know
8663 whether the @code{uid_t} type is @code{short}, @code{int}, or
8664 @code{long}. Therefore, in cases like these GNU C allows a prototype
8665 to override a later old-style definition. More precisely, in GNU C, a
8666 function prototype argument type overrides the argument type specified
8667 by a later old-style definition if the former type is the same as the
8668 latter type before promotion. Thus in GNU C the above example is
8669 equivalent to the following:
8670
8671 @smallexample
8672 int isroot (uid_t);
8673
8674 int
8675 isroot (uid_t x)
8676 @{
8677 return x == 0;
8678 @}
8679 @end smallexample
8680
8681 @noindent
8682 GNU C++ does not support old-style function definitions, so this
8683 extension is irrelevant.
8684
8685 @node C++ Comments
8686 @section C++ Style Comments
8687 @cindex @code{//}
8688 @cindex C++ comments
8689 @cindex comments, C++ style
8690
8691 In GNU C, you may use C++ style comments, which start with @samp{//} and
8692 continue until the end of the line. Many other C implementations allow
8693 such comments, and they are included in the 1999 C standard. However,
8694 C++ style comments are not recognized if you specify an @option{-std}
8695 option specifying a version of ISO C before C99, or @option{-ansi}
8696 (equivalent to @option{-std=c90}).
8697
8698 @node Dollar Signs
8699 @section Dollar Signs in Identifier Names
8700 @cindex $
8701 @cindex dollar signs in identifier names
8702 @cindex identifier names, dollar signs in
8703
8704 In GNU C, you may normally use dollar signs in identifier names.
8705 This is because many traditional C implementations allow such identifiers.
8706 However, dollar signs in identifiers are not supported on a few target
8707 machines, typically because the target assembler does not allow them.
8708
8709 @node Character Escapes
8710 @section The Character @key{ESC} in Constants
8711
8712 You can use the sequence @samp{\e} in a string or character constant to
8713 stand for the ASCII character @key{ESC}.
8714
8715 @node Alignment
8716 @section Determining the Alignment of Functions, Types or Variables
8717 @cindex alignment
8718 @cindex type alignment
8719 @cindex variable alignment
8720
8721 The keyword @code{__alignof__} determines the alignment requirement of
8722 a function, object, or a type, or the minimum alignment usually required
8723 by a type. Its syntax is just like @code{sizeof} and C11 @code{_Alignof}.
8724
8725 For example, if the target machine requires a @code{double} value to be
8726 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
8727 This is true on many RISC machines. On more traditional machine
8728 designs, @code{__alignof__ (double)} is 4 or even 2.
8729
8730 Some machines never actually require alignment; they allow references to any
8731 data type even at an odd address. For these machines, @code{__alignof__}
8732 reports the smallest alignment that GCC gives the data type, usually as
8733 mandated by the target ABI.
8734
8735 If the operand of @code{__alignof__} is an lvalue rather than a type,
8736 its value is the required alignment for its type, taking into account
8737 any minimum alignment specified by attribute @code{aligned}
8738 (@pxref{Common Variable Attributes}). For example, after this
8739 declaration:
8740
8741 @smallexample
8742 struct foo @{ int x; char y; @} foo1;
8743 @end smallexample
8744
8745 @noindent
8746 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
8747 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
8748 It is an error to ask for the alignment of an incomplete type other
8749 than @code{void}.
8750
8751 If the operand of the @code{__alignof__} expression is a function,
8752 the expression evaluates to the alignment of the function which may
8753 be specified by attribute @code{aligned} (@pxref{Common Function Attributes}).
8754
8755 @node Inline
8756 @section An Inline Function is As Fast As a Macro
8757 @cindex inline functions
8758 @cindex integrating function code
8759 @cindex open coding
8760 @cindex macros, inline alternative
8761
8762 By declaring a function inline, you can direct GCC to make
8763 calls to that function faster. One way GCC can achieve this is to
8764 integrate that function's code into the code for its callers. This
8765 makes execution faster by eliminating the function-call overhead; in
8766 addition, if any of the actual argument values are constant, their
8767 known values may permit simplifications at compile time so that not
8768 all of the inline function's code needs to be included. The effect on
8769 code size is less predictable; object code may be larger or smaller
8770 with function inlining, depending on the particular case. You can
8771 also direct GCC to try to integrate all ``simple enough'' functions
8772 into their callers with the option @option{-finline-functions}.
8773
8774 GCC implements three different semantics of declaring a function
8775 inline. One is available with @option{-std=gnu89} or
8776 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
8777 on all inline declarations, another when
8778 @option{-std=c99},
8779 @option{-std=gnu99} or an option for a later C version is used
8780 (without @option{-fgnu89-inline}), and the third
8781 is used when compiling C++.
8782
8783 To declare a function inline, use the @code{inline} keyword in its
8784 declaration, like this:
8785
8786 @smallexample
8787 static inline int
8788 inc (int *a)
8789 @{
8790 return (*a)++;
8791 @}
8792 @end smallexample
8793
8794 If you are writing a header file to be included in ISO C90 programs, write
8795 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
8796
8797 The three types of inlining behave similarly in two important cases:
8798 when the @code{inline} keyword is used on a @code{static} function,
8799 like the example above, and when a function is first declared without
8800 using the @code{inline} keyword and then is defined with
8801 @code{inline}, like this:
8802
8803 @smallexample
8804 extern int inc (int *a);
8805 inline int
8806 inc (int *a)
8807 @{
8808 return (*a)++;
8809 @}
8810 @end smallexample
8811
8812 In both of these common cases, the program behaves the same as if you
8813 had not used the @code{inline} keyword, except for its speed.
8814
8815 @cindex inline functions, omission of
8816 @opindex fkeep-inline-functions
8817 When a function is both inline and @code{static}, if all calls to the
8818 function are integrated into the caller, and the function's address is
8819 never used, then the function's own assembler code is never referenced.
8820 In this case, GCC does not actually output assembler code for the
8821 function, unless you specify the option @option{-fkeep-inline-functions}.
8822 If there is a nonintegrated call, then the function is compiled to
8823 assembler code as usual. The function must also be compiled as usual if
8824 the program refers to its address, because that cannot be inlined.
8825
8826 @opindex Winline
8827 Note that certain usages in a function definition can make it unsuitable
8828 for inline substitution. Among these usages are: variadic functions,
8829 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
8830 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
8831 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
8832 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
8833 function marked @code{inline} could not be substituted, and gives the
8834 reason for the failure.
8835
8836 @cindex automatic @code{inline} for C++ member fns
8837 @cindex @code{inline} automatic for C++ member fns
8838 @cindex member fns, automatically @code{inline}
8839 @cindex C++ member fns, automatically @code{inline}
8840 @opindex fno-default-inline
8841 As required by ISO C++, GCC considers member functions defined within
8842 the body of a class to be marked inline even if they are
8843 not explicitly declared with the @code{inline} keyword. You can
8844 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
8845 Options,,Options Controlling C++ Dialect}.
8846
8847 GCC does not inline any functions when not optimizing unless you specify
8848 the @samp{always_inline} attribute for the function, like this:
8849
8850 @smallexample
8851 /* @r{Prototype.} */
8852 inline void foo (const char) __attribute__((always_inline));
8853 @end smallexample
8854
8855 The remainder of this section is specific to GNU C90 inlining.
8856
8857 @cindex non-static inline function
8858 When an inline function is not @code{static}, then the compiler must assume
8859 that there may be calls from other source files; since a global symbol can
8860 be defined only once in any program, the function must not be defined in
8861 the other source files, so the calls therein cannot be integrated.
8862 Therefore, a non-@code{static} inline function is always compiled on its
8863 own in the usual fashion.
8864
8865 If you specify both @code{inline} and @code{extern} in the function
8866 definition, then the definition is used only for inlining. In no case
8867 is the function compiled on its own, not even if you refer to its
8868 address explicitly. Such an address becomes an external reference, as
8869 if you had only declared the function, and had not defined it.
8870
8871 This combination of @code{inline} and @code{extern} has almost the
8872 effect of a macro. The way to use it is to put a function definition in
8873 a header file with these keywords, and put another copy of the
8874 definition (lacking @code{inline} and @code{extern}) in a library file.
8875 The definition in the header file causes most calls to the function
8876 to be inlined. If any uses of the function remain, they refer to
8877 the single copy in the library.
8878
8879 @node Volatiles
8880 @section When is a Volatile Object Accessed?
8881 @cindex accessing volatiles
8882 @cindex volatile read
8883 @cindex volatile write
8884 @cindex volatile access
8885
8886 C has the concept of volatile objects. These are normally accessed by
8887 pointers and used for accessing hardware or inter-thread
8888 communication. The standard encourages compilers to refrain from
8889 optimizations concerning accesses to volatile objects, but leaves it
8890 implementation defined as to what constitutes a volatile access. The
8891 minimum requirement is that at a sequence point all previous accesses
8892 to volatile objects have stabilized and no subsequent accesses have
8893 occurred. Thus an implementation is free to reorder and combine
8894 volatile accesses that occur between sequence points, but cannot do
8895 so for accesses across a sequence point. The use of volatile does
8896 not allow you to violate the restriction on updating objects multiple
8897 times between two sequence points.
8898
8899 Accesses to non-volatile objects are not ordered with respect to
8900 volatile accesses. You cannot use a volatile object as a memory
8901 barrier to order a sequence of writes to non-volatile memory. For
8902 instance:
8903
8904 @smallexample
8905 int *ptr = @var{something};
8906 volatile int vobj;
8907 *ptr = @var{something};
8908 vobj = 1;
8909 @end smallexample
8910
8911 @noindent
8912 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
8913 that the write to @var{*ptr} occurs by the time the update
8914 of @var{vobj} happens. If you need this guarantee, you must use
8915 a stronger memory barrier such as:
8916
8917 @smallexample
8918 int *ptr = @var{something};
8919 volatile int vobj;
8920 *ptr = @var{something};
8921 asm volatile ("" : : : "memory");
8922 vobj = 1;
8923 @end smallexample
8924
8925 A scalar volatile object is read when it is accessed in a void context:
8926
8927 @smallexample
8928 volatile int *src = @var{somevalue};
8929 *src;
8930 @end smallexample
8931
8932 Such expressions are rvalues, and GCC implements this as a
8933 read of the volatile object being pointed to.
8934
8935 Assignments are also expressions and have an rvalue. However when
8936 assigning to a scalar volatile, the volatile object is not reread,
8937 regardless of whether the assignment expression's rvalue is used or
8938 not. If the assignment's rvalue is used, the value is that assigned
8939 to the volatile object. For instance, there is no read of @var{vobj}
8940 in all the following cases:
8941
8942 @smallexample
8943 int obj;
8944 volatile int vobj;
8945 vobj = @var{something};
8946 obj = vobj = @var{something};
8947 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
8948 obj = (@var{something}, vobj = @var{anotherthing});
8949 @end smallexample
8950
8951 If you need to read the volatile object after an assignment has
8952 occurred, you must use a separate expression with an intervening
8953 sequence point.
8954
8955 As bit-fields are not individually addressable, volatile bit-fields may
8956 be implicitly read when written to, or when adjacent bit-fields are
8957 accessed. Bit-field operations may be optimized such that adjacent
8958 bit-fields are only partially accessed, if they straddle a storage unit
8959 boundary. For these reasons it is unwise to use volatile bit-fields to
8960 access hardware.
8961
8962 @node Using Assembly Language with C
8963 @section How to Use Inline Assembly Language in C Code
8964 @cindex @code{asm} keyword
8965 @cindex assembly language in C
8966 @cindex inline assembly language
8967 @cindex mixing assembly language and C
8968
8969 The @code{asm} keyword allows you to embed assembler instructions
8970 within C code. GCC provides two forms of inline @code{asm}
8971 statements. A @dfn{basic @code{asm}} statement is one with no
8972 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
8973 statement (@pxref{Extended Asm}) includes one or more operands.
8974 The extended form is preferred for mixing C and assembly language
8975 within a function, but to include assembly language at
8976 top level you must use basic @code{asm}.
8977
8978 You can also use the @code{asm} keyword to override the assembler name
8979 for a C symbol, or to place a C variable in a specific register.
8980
8981 @menu
8982 * Basic Asm:: Inline assembler without operands.
8983 * Extended Asm:: Inline assembler with operands.
8984 * Constraints:: Constraints for @code{asm} operands
8985 * Asm Labels:: Specifying the assembler name to use for a C symbol.
8986 * Explicit Register Variables:: Defining variables residing in specified
8987 registers.
8988 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
8989 @end menu
8990
8991 @node Basic Asm
8992 @subsection Basic Asm --- Assembler Instructions Without Operands
8993 @cindex basic @code{asm}
8994 @cindex assembly language in C, basic
8995
8996 A basic @code{asm} statement has the following syntax:
8997
8998 @example
8999 asm @var{asm-qualifiers} ( @var{AssemblerInstructions} )
9000 @end example
9001
9002 The @code{asm} keyword is a GNU extension.
9003 When writing code that can be compiled with @option{-ansi} and the
9004 various @option{-std} options, use @code{__asm__} instead of
9005 @code{asm} (@pxref{Alternate Keywords}).
9006
9007 @subsubheading Qualifiers
9008 @table @code
9009 @item volatile
9010 The optional @code{volatile} qualifier has no effect.
9011 All basic @code{asm} blocks are implicitly volatile.
9012
9013 @item inline
9014 If you use the @code{inline} qualifier, then for inlining purposes the size
9015 of the @code{asm} statement is taken as the smallest size possible (@pxref{Size
9016 of an asm}).
9017 @end table
9018
9019 @subsubheading Parameters
9020 @table @var
9021
9022 @item AssemblerInstructions
9023 This is a literal string that specifies the assembler code. The string can
9024 contain any instructions recognized by the assembler, including directives.
9025 GCC does not parse the assembler instructions themselves and
9026 does not know what they mean or even whether they are valid assembler input.
9027
9028 You may place multiple assembler instructions together in a single @code{asm}
9029 string, separated by the characters normally used in assembly code for the
9030 system. A combination that works in most places is a newline to break the
9031 line, plus a tab character (written as @samp{\n\t}).
9032 Some assemblers allow semicolons as a line separator. However,
9033 note that some assembler dialects use semicolons to start a comment.
9034 @end table
9035
9036 @subsubheading Remarks
9037 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
9038 smaller, safer, and more efficient code, and in most cases it is a
9039 better solution than basic @code{asm}. However, there are two
9040 situations where only basic @code{asm} can be used:
9041
9042 @itemize @bullet
9043 @item
9044 Extended @code{asm} statements have to be inside a C
9045 function, so to write inline assembly language at file scope (``top-level''),
9046 outside of C functions, you must use basic @code{asm}.
9047 You can use this technique to emit assembler directives,
9048 define assembly language macros that can be invoked elsewhere in the file,
9049 or write entire functions in assembly language.
9050
9051 @item
9052 Functions declared
9053 with the @code{naked} attribute also require basic @code{asm}
9054 (@pxref{Function Attributes}).
9055 @end itemize
9056
9057 Safely accessing C data and calling functions from basic @code{asm} is more
9058 complex than it may appear. To access C data, it is better to use extended
9059 @code{asm}.
9060
9061 Do not expect a sequence of @code{asm} statements to remain perfectly
9062 consecutive after compilation. If certain instructions need to remain
9063 consecutive in the output, put them in a single multi-instruction @code{asm}
9064 statement. Note that GCC's optimizers can move @code{asm} statements
9065 relative to other code, including across jumps.
9066
9067 @code{asm} statements may not perform jumps into other @code{asm} statements.
9068 GCC does not know about these jumps, and therefore cannot take
9069 account of them when deciding how to optimize. Jumps from @code{asm} to C
9070 labels are only supported in extended @code{asm}.
9071
9072 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
9073 assembly code when optimizing. This can lead to unexpected duplicate
9074 symbol errors during compilation if your assembly code defines symbols or
9075 labels.
9076
9077 @strong{Warning:} The C standards do not specify semantics for @code{asm},
9078 making it a potential source of incompatibilities between compilers. These
9079 incompatibilities may not produce compiler warnings/errors.
9080
9081 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
9082 means there is no way to communicate to the compiler what is happening
9083 inside them. GCC has no visibility of symbols in the @code{asm} and may
9084 discard them as unreferenced. It also does not know about side effects of
9085 the assembler code, such as modifications to memory or registers. Unlike
9086 some compilers, GCC assumes that no changes to general purpose registers
9087 occur. This assumption may change in a future release.
9088
9089 To avoid complications from future changes to the semantics and the
9090 compatibility issues between compilers, consider replacing basic @code{asm}
9091 with extended @code{asm}. See
9092 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
9093 from basic asm to extended asm} for information about how to perform this
9094 conversion.
9095
9096 The compiler copies the assembler instructions in a basic @code{asm}
9097 verbatim to the assembly language output file, without
9098 processing dialects or any of the @samp{%} operators that are available with
9099 extended @code{asm}. This results in minor differences between basic
9100 @code{asm} strings and extended @code{asm} templates. For example, to refer to
9101 registers you might use @samp{%eax} in basic @code{asm} and
9102 @samp{%%eax} in extended @code{asm}.
9103
9104 On targets such as x86 that support multiple assembler dialects,
9105 all basic @code{asm} blocks use the assembler dialect specified by the
9106 @option{-masm} command-line option (@pxref{x86 Options}).
9107 Basic @code{asm} provides no
9108 mechanism to provide different assembler strings for different dialects.
9109
9110 For basic @code{asm} with non-empty assembler string GCC assumes
9111 the assembler block does not change any general purpose registers,
9112 but it may read or write any globally accessible variable.
9113
9114 Here is an example of basic @code{asm} for i386:
9115
9116 @example
9117 /* Note that this code will not compile with -masm=intel */
9118 #define DebugBreak() asm("int $3")
9119 @end example
9120
9121 @node Extended Asm
9122 @subsection Extended Asm - Assembler Instructions with C Expression Operands
9123 @cindex extended @code{asm}
9124 @cindex assembly language in C, extended
9125
9126 With extended @code{asm} you can read and write C variables from
9127 assembler and perform jumps from assembler code to C labels.
9128 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
9129 the operand parameters after the assembler template:
9130
9131 @example
9132 asm @var{asm-qualifiers} ( @var{AssemblerTemplate}
9133 : @var{OutputOperands}
9134 @r{[} : @var{InputOperands}
9135 @r{[} : @var{Clobbers} @r{]} @r{]})
9136
9137 asm @var{asm-qualifiers} ( @var{AssemblerTemplate}
9138 :
9139 : @var{InputOperands}
9140 : @var{Clobbers}
9141 : @var{GotoLabels})
9142 @end example
9143 where in the last form, @var{asm-qualifiers} contains @code{goto} (and in the
9144 first form, not).
9145
9146 The @code{asm} keyword is a GNU extension.
9147 When writing code that can be compiled with @option{-ansi} and the
9148 various @option{-std} options, use @code{__asm__} instead of
9149 @code{asm} (@pxref{Alternate Keywords}).
9150
9151 @subsubheading Qualifiers
9152 @table @code
9153
9154 @item volatile
9155 The typical use of extended @code{asm} statements is to manipulate input
9156 values to produce output values. However, your @code{asm} statements may
9157 also produce side effects. If so, you may need to use the @code{volatile}
9158 qualifier to disable certain optimizations. @xref{Volatile}.
9159
9160 @item inline
9161 If you use the @code{inline} qualifier, then for inlining purposes the size
9162 of the @code{asm} statement is taken as the smallest size possible
9163 (@pxref{Size of an asm}).
9164
9165 @item goto
9166 This qualifier informs the compiler that the @code{asm} statement may
9167 perform a jump to one of the labels listed in the @var{GotoLabels}.
9168 @xref{GotoLabels}.
9169 @end table
9170
9171 @subsubheading Parameters
9172 @table @var
9173 @item AssemblerTemplate
9174 This is a literal string that is the template for the assembler code. It is a
9175 combination of fixed text and tokens that refer to the input, output,
9176 and goto parameters. @xref{AssemblerTemplate}.
9177
9178 @item OutputOperands
9179 A comma-separated list of the C variables modified by the instructions in the
9180 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
9181
9182 @item InputOperands
9183 A comma-separated list of C expressions read by the instructions in the
9184 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
9185
9186 @item Clobbers
9187 A comma-separated list of registers or other values changed by the
9188 @var{AssemblerTemplate}, beyond those listed as outputs.
9189 An empty list is permitted. @xref{Clobbers and Scratch Registers}.
9190
9191 @item GotoLabels
9192 When you are using the @code{goto} form of @code{asm}, this section contains
9193 the list of all C labels to which the code in the
9194 @var{AssemblerTemplate} may jump.
9195 @xref{GotoLabels}.
9196
9197 @code{asm} statements may not perform jumps into other @code{asm} statements,
9198 only to the listed @var{GotoLabels}.
9199 GCC's optimizers do not know about other jumps; therefore they cannot take
9200 account of them when deciding how to optimize.
9201 @end table
9202
9203 The total number of input + output + goto operands is limited to 30.
9204
9205 @subsubheading Remarks
9206 The @code{asm} statement allows you to include assembly instructions directly
9207 within C code. This may help you to maximize performance in time-sensitive
9208 code or to access assembly instructions that are not readily available to C
9209 programs.
9210
9211 Note that extended @code{asm} statements must be inside a function. Only
9212 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
9213 Functions declared with the @code{naked} attribute also require basic
9214 @code{asm} (@pxref{Function Attributes}).
9215
9216 While the uses of @code{asm} are many and varied, it may help to think of an
9217 @code{asm} statement as a series of low-level instructions that convert input
9218 parameters to output parameters. So a simple (if not particularly useful)
9219 example for i386 using @code{asm} might look like this:
9220
9221 @example
9222 int src = 1;
9223 int dst;
9224
9225 asm ("mov %1, %0\n\t"
9226 "add $1, %0"
9227 : "=r" (dst)
9228 : "r" (src));
9229
9230 printf("%d\n", dst);
9231 @end example
9232
9233 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
9234
9235 @anchor{Volatile}
9236 @subsubsection Volatile
9237 @cindex volatile @code{asm}
9238 @cindex @code{asm} volatile
9239
9240 GCC's optimizers sometimes discard @code{asm} statements if they determine
9241 there is no need for the output variables. Also, the optimizers may move
9242 code out of loops if they believe that the code will always return the same
9243 result (i.e.@: none of its input values change between calls). Using the
9244 @code{volatile} qualifier disables these optimizations. @code{asm} statements
9245 that have no output operands, including @code{asm goto} statements,
9246 are implicitly volatile.
9247
9248 This i386 code demonstrates a case that does not use (or require) the
9249 @code{volatile} qualifier. If it is performing assertion checking, this code
9250 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
9251 unreferenced by any code. As a result, the optimizers can discard the
9252 @code{asm} statement, which in turn removes the need for the entire
9253 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
9254 isn't needed you allow the optimizers to produce the most efficient code
9255 possible.
9256
9257 @example
9258 void DoCheck(uint32_t dwSomeValue)
9259 @{
9260 uint32_t dwRes;
9261
9262 // Assumes dwSomeValue is not zero.
9263 asm ("bsfl %1,%0"
9264 : "=r" (dwRes)
9265 : "r" (dwSomeValue)
9266 : "cc");
9267
9268 assert(dwRes > 3);
9269 @}
9270 @end example
9271
9272 The next example shows a case where the optimizers can recognize that the input
9273 (@code{dwSomeValue}) never changes during the execution of the function and can
9274 therefore move the @code{asm} outside the loop to produce more efficient code.
9275 Again, using the @code{volatile} qualifier disables this type of optimization.
9276
9277 @example
9278 void do_print(uint32_t dwSomeValue)
9279 @{
9280 uint32_t dwRes;
9281
9282 for (uint32_t x=0; x < 5; x++)
9283 @{
9284 // Assumes dwSomeValue is not zero.
9285 asm ("bsfl %1,%0"
9286 : "=r" (dwRes)
9287 : "r" (dwSomeValue)
9288 : "cc");
9289
9290 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
9291 @}
9292 @}
9293 @end example
9294
9295 The following example demonstrates a case where you need to use the
9296 @code{volatile} qualifier.
9297 It uses the x86 @code{rdtsc} instruction, which reads
9298 the computer's time-stamp counter. Without the @code{volatile} qualifier,
9299 the optimizers might assume that the @code{asm} block will always return the
9300 same value and therefore optimize away the second call.
9301
9302 @example
9303 uint64_t msr;
9304
9305 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
9306 "shl $32, %%rdx\n\t" // Shift the upper bits left.
9307 "or %%rdx, %0" // 'Or' in the lower bits.
9308 : "=a" (msr)
9309 :
9310 : "rdx");
9311
9312 printf("msr: %llx\n", msr);
9313
9314 // Do other work...
9315
9316 // Reprint the timestamp
9317 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
9318 "shl $32, %%rdx\n\t" // Shift the upper bits left.
9319 "or %%rdx, %0" // 'Or' in the lower bits.
9320 : "=a" (msr)
9321 :
9322 : "rdx");
9323
9324 printf("msr: %llx\n", msr);
9325 @end example
9326
9327 GCC's optimizers do not treat this code like the non-volatile code in the
9328 earlier examples. They do not move it out of loops or omit it on the
9329 assumption that the result from a previous call is still valid.
9330
9331 Note that the compiler can move even @code{volatile asm} instructions relative
9332 to other code, including across jump instructions. For example, on many
9333 targets there is a system register that controls the rounding mode of
9334 floating-point operations. Setting it with a @code{volatile asm} statement,
9335 as in the following PowerPC example, does not work reliably.
9336
9337 @example
9338 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
9339 sum = x + y;
9340 @end example
9341
9342 The compiler may move the addition back before the @code{volatile asm}
9343 statement. To make it work as expected, add an artificial dependency to
9344 the @code{asm} by referencing a variable in the subsequent code, for
9345 example:
9346
9347 @example
9348 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
9349 sum = x + y;
9350 @end example
9351
9352 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
9353 assembly code when optimizing. This can lead to unexpected duplicate symbol
9354 errors during compilation if your @code{asm} code defines symbols or labels.
9355 Using @samp{%=}
9356 (@pxref{AssemblerTemplate}) may help resolve this problem.
9357
9358 @anchor{AssemblerTemplate}
9359 @subsubsection Assembler Template
9360 @cindex @code{asm} assembler template
9361
9362 An assembler template is a literal string containing assembler instructions.
9363 The compiler replaces tokens in the template that refer
9364 to inputs, outputs, and goto labels,
9365 and then outputs the resulting string to the assembler. The
9366 string can contain any instructions recognized by the assembler, including
9367 directives. GCC does not parse the assembler instructions
9368 themselves and does not know what they mean or even whether they are valid
9369 assembler input. However, it does count the statements
9370 (@pxref{Size of an asm}).
9371
9372 You may place multiple assembler instructions together in a single @code{asm}
9373 string, separated by the characters normally used in assembly code for the
9374 system. A combination that works in most places is a newline to break the
9375 line, plus a tab character to move to the instruction field (written as
9376 @samp{\n\t}).
9377 Some assemblers allow semicolons as a line separator. However, note
9378 that some assembler dialects use semicolons to start a comment.
9379
9380 Do not expect a sequence of @code{asm} statements to remain perfectly
9381 consecutive after compilation, even when you are using the @code{volatile}
9382 qualifier. If certain instructions need to remain consecutive in the output,
9383 put them in a single multi-instruction @code{asm} statement.
9384
9385 Accessing data from C programs without using input/output operands (such as
9386 by using global symbols directly from the assembler template) may not work as
9387 expected. Similarly, calling functions directly from an assembler template
9388 requires a detailed understanding of the target assembler and ABI.
9389
9390 Since GCC does not parse the assembler template,
9391 it has no visibility of any
9392 symbols it references. This may result in GCC discarding those symbols as
9393 unreferenced unless they are also listed as input, output, or goto operands.
9394
9395 @subsubheading Special format strings
9396
9397 In addition to the tokens described by the input, output, and goto operands,
9398 these tokens have special meanings in the assembler template:
9399
9400 @table @samp
9401 @item %%
9402 Outputs a single @samp{%} into the assembler code.
9403
9404 @item %=
9405 Outputs a number that is unique to each instance of the @code{asm}
9406 statement in the entire compilation. This option is useful when creating local
9407 labels and referring to them multiple times in a single template that
9408 generates multiple assembler instructions.
9409
9410 @item %@{
9411 @itemx %|
9412 @itemx %@}
9413 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
9414 into the assembler code. When unescaped, these characters have special
9415 meaning to indicate multiple assembler dialects, as described below.
9416 @end table
9417
9418 @subsubheading Multiple assembler dialects in @code{asm} templates
9419
9420 On targets such as x86, GCC supports multiple assembler dialects.
9421 The @option{-masm} option controls which dialect GCC uses as its
9422 default for inline assembler. The target-specific documentation for the
9423 @option{-masm} option contains the list of supported dialects, as well as the
9424 default dialect if the option is not specified. This information may be
9425 important to understand, since assembler code that works correctly when
9426 compiled using one dialect will likely fail if compiled using another.
9427 @xref{x86 Options}.
9428
9429 If your code needs to support multiple assembler dialects (for example, if
9430 you are writing public headers that need to support a variety of compilation
9431 options), use constructs of this form:
9432
9433 @example
9434 @{ dialect0 | dialect1 | dialect2... @}
9435 @end example
9436
9437 This construct outputs @code{dialect0}
9438 when using dialect #0 to compile the code,
9439 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
9440 braces than the number of dialects the compiler supports, the construct
9441 outputs nothing.
9442
9443 For example, if an x86 compiler supports two dialects
9444 (@samp{att}, @samp{intel}), an
9445 assembler template such as this:
9446
9447 @example
9448 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
9449 @end example
9450
9451 @noindent
9452 is equivalent to one of
9453
9454 @example
9455 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
9456 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
9457 @end example
9458
9459 Using that same compiler, this code:
9460
9461 @example
9462 "xchg@{l@}\t@{%%@}ebx, %1"
9463 @end example
9464
9465 @noindent
9466 corresponds to either
9467
9468 @example
9469 "xchgl\t%%ebx, %1" @r{/* att dialect */}
9470 "xchg\tebx, %1" @r{/* intel dialect */}
9471 @end example
9472
9473 There is no support for nesting dialect alternatives.
9474
9475 @anchor{OutputOperands}
9476 @subsubsection Output Operands
9477 @cindex @code{asm} output operands
9478
9479 An @code{asm} statement has zero or more output operands indicating the names
9480 of C variables modified by the assembler code.
9481
9482 In this i386 example, @code{old} (referred to in the template string as
9483 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
9484 (@code{%2}) is an input:
9485
9486 @example
9487 bool old;
9488
9489 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
9490 "sbb %0,%0" // Use the CF to calculate old.
9491 : "=r" (old), "+rm" (*Base)
9492 : "Ir" (Offset)
9493 : "cc");
9494
9495 return old;
9496 @end example
9497
9498 Operands are separated by commas. Each operand has this format:
9499
9500 @example
9501 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
9502 @end example
9503
9504 @table @var
9505 @item asmSymbolicName
9506 Specifies a symbolic name for the operand.
9507 Reference the name in the assembler template
9508 by enclosing it in square brackets
9509 (i.e.@: @samp{%[Value]}). The scope of the name is the @code{asm} statement
9510 that contains the definition. Any valid C variable name is acceptable,
9511 including names already defined in the surrounding code. No two operands
9512 within the same @code{asm} statement can use the same symbolic name.
9513
9514 When not using an @var{asmSymbolicName}, use the (zero-based) position
9515 of the operand
9516 in the list of operands in the assembler template. For example if there are
9517 three output operands, use @samp{%0} in the template to refer to the first,
9518 @samp{%1} for the second, and @samp{%2} for the third.
9519
9520 @item constraint
9521 A string constant specifying constraints on the placement of the operand;
9522 @xref{Constraints}, for details.
9523
9524 Output constraints must begin with either @samp{=} (a variable overwriting an
9525 existing value) or @samp{+} (when reading and writing). When using
9526 @samp{=}, do not assume the location contains the existing value
9527 on entry to the @code{asm}, except
9528 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
9529
9530 After the prefix, there must be one or more additional constraints
9531 (@pxref{Constraints}) that describe where the value resides. Common
9532 constraints include @samp{r} for register and @samp{m} for memory.
9533 When you list more than one possible location (for example, @code{"=rm"}),
9534 the compiler chooses the most efficient one based on the current context.
9535 If you list as many alternates as the @code{asm} statement allows, you permit
9536 the optimizers to produce the best possible code.
9537 If you must use a specific register, but your Machine Constraints do not
9538 provide sufficient control to select the specific register you want,
9539 local register variables may provide a solution (@pxref{Local Register
9540 Variables}).
9541
9542 @item cvariablename
9543 Specifies a C lvalue expression to hold the output, typically a variable name.
9544 The enclosing parentheses are a required part of the syntax.
9545
9546 @end table
9547
9548 When the compiler selects the registers to use to
9549 represent the output operands, it does not use any of the clobbered registers
9550 (@pxref{Clobbers and Scratch Registers}).
9551
9552 Output operand expressions must be lvalues. The compiler cannot check whether
9553 the operands have data types that are reasonable for the instruction being
9554 executed. For output expressions that are not directly addressable (for
9555 example a bit-field), the constraint must allow a register. In that case, GCC
9556 uses the register as the output of the @code{asm}, and then stores that
9557 register into the output.
9558
9559 Operands using the @samp{+} constraint modifier count as two operands
9560 (that is, both as input and output) towards the total maximum of 30 operands
9561 per @code{asm} statement.
9562
9563 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
9564 operands that must not overlap an input. Otherwise,
9565 GCC may allocate the output operand in the same register as an unrelated
9566 input operand, on the assumption that the assembler code consumes its
9567 inputs before producing outputs. This assumption may be false if the assembler
9568 code actually consists of more than one instruction.
9569
9570 The same problem can occur if one output parameter (@var{a}) allows a register
9571 constraint and another output parameter (@var{b}) allows a memory constraint.
9572 The code generated by GCC to access the memory address in @var{b} can contain
9573 registers which @emph{might} be shared by @var{a}, and GCC considers those
9574 registers to be inputs to the asm. As above, GCC assumes that such input
9575 registers are consumed before any outputs are written. This assumption may
9576 result in incorrect behavior if the @code{asm} statement writes to @var{a}
9577 before using
9578 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
9579 ensures that modifying @var{a} does not affect the address referenced by
9580 @var{b}. Otherwise, the location of @var{b}
9581 is undefined if @var{a} is modified before using @var{b}.
9582
9583 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
9584 instead of simply @samp{%2}). Typically these qualifiers are hardware
9585 dependent. The list of supported modifiers for x86 is found at
9586 @ref{x86Operandmodifiers,x86 Operand modifiers}.
9587
9588 If the C code that follows the @code{asm} makes no use of any of the output
9589 operands, use @code{volatile} for the @code{asm} statement to prevent the
9590 optimizers from discarding the @code{asm} statement as unneeded
9591 (see @ref{Volatile}).
9592
9593 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
9594 references the first output operand as @code{%0} (were there a second, it
9595 would be @code{%1}, etc). The number of the first input operand is one greater
9596 than that of the last output operand. In this i386 example, that makes
9597 @code{Mask} referenced as @code{%1}:
9598
9599 @example
9600 uint32_t Mask = 1234;
9601 uint32_t Index;
9602
9603 asm ("bsfl %1, %0"
9604 : "=r" (Index)
9605 : "r" (Mask)
9606 : "cc");
9607 @end example
9608
9609 That code overwrites the variable @code{Index} (@samp{=}),
9610 placing the value in a register (@samp{r}).
9611 Using the generic @samp{r} constraint instead of a constraint for a specific
9612 register allows the compiler to pick the register to use, which can result
9613 in more efficient code. This may not be possible if an assembler instruction
9614 requires a specific register.
9615
9616 The following i386 example uses the @var{asmSymbolicName} syntax.
9617 It produces the
9618 same result as the code above, but some may consider it more readable or more
9619 maintainable since reordering index numbers is not necessary when adding or
9620 removing operands. The names @code{aIndex} and @code{aMask}
9621 are only used in this example to emphasize which
9622 names get used where.
9623 It is acceptable to reuse the names @code{Index} and @code{Mask}.
9624
9625 @example
9626 uint32_t Mask = 1234;
9627 uint32_t Index;
9628
9629 asm ("bsfl %[aMask], %[aIndex]"
9630 : [aIndex] "=r" (Index)
9631 : [aMask] "r" (Mask)
9632 : "cc");
9633 @end example
9634
9635 Here are some more examples of output operands.
9636
9637 @example
9638 uint32_t c = 1;
9639 uint32_t d;
9640 uint32_t *e = &c;
9641
9642 asm ("mov %[e], %[d]"
9643 : [d] "=rm" (d)
9644 : [e] "rm" (*e));
9645 @end example
9646
9647 Here, @code{d} may either be in a register or in memory. Since the compiler
9648 might already have the current value of the @code{uint32_t} location
9649 pointed to by @code{e}
9650 in a register, you can enable it to choose the best location
9651 for @code{d} by specifying both constraints.
9652
9653 @anchor{FlagOutputOperands}
9654 @subsubsection Flag Output Operands
9655 @cindex @code{asm} flag output operands
9656
9657 Some targets have a special register that holds the ``flags'' for the
9658 result of an operation or comparison. Normally, the contents of that
9659 register are either unmodifed by the asm, or the @code{asm} statement is
9660 considered to clobber the contents.
9661
9662 On some targets, a special form of output operand exists by which
9663 conditions in the flags register may be outputs of the asm. The set of
9664 conditions supported are target specific, but the general rule is that
9665 the output variable must be a scalar integer, and the value is boolean.
9666 When supported, the target defines the preprocessor symbol
9667 @code{__GCC_ASM_FLAG_OUTPUTS__}.
9668
9669 Because of the special nature of the flag output operands, the constraint
9670 may not include alternatives.
9671
9672 Most often, the target has only one flags register, and thus is an implied
9673 operand of many instructions. In this case, the operand should not be
9674 referenced within the assembler template via @code{%0} etc, as there's
9675 no corresponding text in the assembly language.
9676
9677 @table @asis
9678 @item x86 family
9679 The flag output constraints for the x86 family are of the form
9680 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
9681 conditions defined in the ISA manual for @code{j@var{cc}} or
9682 @code{set@var{cc}}.
9683
9684 @table @code
9685 @item a
9686 ``above'' or unsigned greater than
9687 @item ae
9688 ``above or equal'' or unsigned greater than or equal
9689 @item b
9690 ``below'' or unsigned less than
9691 @item be
9692 ``below or equal'' or unsigned less than or equal
9693 @item c
9694 carry flag set
9695 @item e
9696 @itemx z
9697 ``equal'' or zero flag set
9698 @item g
9699 signed greater than
9700 @item ge
9701 signed greater than or equal
9702 @item l
9703 signed less than
9704 @item le
9705 signed less than or equal
9706 @item o
9707 overflow flag set
9708 @item p
9709 parity flag set
9710 @item s
9711 sign flag set
9712 @item na
9713 @itemx nae
9714 @itemx nb
9715 @itemx nbe
9716 @itemx nc
9717 @itemx ne
9718 @itemx ng
9719 @itemx nge
9720 @itemx nl
9721 @itemx nle
9722 @itemx no
9723 @itemx np
9724 @itemx ns
9725 @itemx nz
9726 ``not'' @var{flag}, or inverted versions of those above
9727 @end table
9728
9729 @end table
9730
9731 @anchor{InputOperands}
9732 @subsubsection Input Operands
9733 @cindex @code{asm} input operands
9734 @cindex @code{asm} expressions
9735
9736 Input operands make values from C variables and expressions available to the
9737 assembly code.
9738
9739 Operands are separated by commas. Each operand has this format:
9740
9741 @example
9742 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
9743 @end example
9744
9745 @table @var
9746 @item asmSymbolicName
9747 Specifies a symbolic name for the operand.
9748 Reference the name in the assembler template
9749 by enclosing it in square brackets
9750 (i.e.@: @samp{%[Value]}). The scope of the name is the @code{asm} statement
9751 that contains the definition. Any valid C variable name is acceptable,
9752 including names already defined in the surrounding code. No two operands
9753 within the same @code{asm} statement can use the same symbolic name.
9754
9755 When not using an @var{asmSymbolicName}, use the (zero-based) position
9756 of the operand
9757 in the list of operands in the assembler template. For example if there are
9758 two output operands and three inputs,
9759 use @samp{%2} in the template to refer to the first input operand,
9760 @samp{%3} for the second, and @samp{%4} for the third.
9761
9762 @item constraint
9763 A string constant specifying constraints on the placement of the operand;
9764 @xref{Constraints}, for details.
9765
9766 Input constraint strings may not begin with either @samp{=} or @samp{+}.
9767 When you list more than one possible location (for example, @samp{"irm"}),
9768 the compiler chooses the most efficient one based on the current context.
9769 If you must use a specific register, but your Machine Constraints do not
9770 provide sufficient control to select the specific register you want,
9771 local register variables may provide a solution (@pxref{Local Register
9772 Variables}).
9773
9774 Input constraints can also be digits (for example, @code{"0"}). This indicates
9775 that the specified input must be in the same place as the output constraint
9776 at the (zero-based) index in the output constraint list.
9777 When using @var{asmSymbolicName} syntax for the output operands,
9778 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
9779
9780 @item cexpression
9781 This is the C variable or expression being passed to the @code{asm} statement
9782 as input. The enclosing parentheses are a required part of the syntax.
9783
9784 @end table
9785
9786 When the compiler selects the registers to use to represent the input
9787 operands, it does not use any of the clobbered registers
9788 (@pxref{Clobbers and Scratch Registers}).
9789
9790 If there are no output operands but there are input operands, place two
9791 consecutive colons where the output operands would go:
9792
9793 @example
9794 __asm__ ("some instructions"
9795 : /* No outputs. */
9796 : "r" (Offset / 8));
9797 @end example
9798
9799 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
9800 (except for inputs tied to outputs). The compiler assumes that on exit from
9801 the @code{asm} statement these operands contain the same values as they
9802 had before executing the statement.
9803 It is @emph{not} possible to use clobbers
9804 to inform the compiler that the values in these inputs are changing. One
9805 common work-around is to tie the changing input variable to an output variable
9806 that never gets used. Note, however, that if the code that follows the
9807 @code{asm} statement makes no use of any of the output operands, the GCC
9808 optimizers may discard the @code{asm} statement as unneeded
9809 (see @ref{Volatile}).
9810
9811 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
9812 instead of simply @samp{%2}). Typically these qualifiers are hardware
9813 dependent. The list of supported modifiers for x86 is found at
9814 @ref{x86Operandmodifiers,x86 Operand modifiers}.
9815
9816 In this example using the fictitious @code{combine} instruction, the
9817 constraint @code{"0"} for input operand 1 says that it must occupy the same
9818 location as output operand 0. Only input operands may use numbers in
9819 constraints, and they must each refer to an output operand. Only a number (or
9820 the symbolic assembler name) in the constraint can guarantee that one operand
9821 is in the same place as another. The mere fact that @code{foo} is the value of
9822 both operands is not enough to guarantee that they are in the same place in
9823 the generated assembler code.
9824
9825 @example
9826 asm ("combine %2, %0"
9827 : "=r" (foo)
9828 : "0" (foo), "g" (bar));
9829 @end example
9830
9831 Here is an example using symbolic names.
9832
9833 @example
9834 asm ("cmoveq %1, %2, %[result]"
9835 : [result] "=r"(result)
9836 : "r" (test), "r" (new), "[result]" (old));
9837 @end example
9838
9839 @anchor{Clobbers and Scratch Registers}
9840 @subsubsection Clobbers and Scratch Registers
9841 @cindex @code{asm} clobbers
9842 @cindex @code{asm} scratch registers
9843
9844 While the compiler is aware of changes to entries listed in the output
9845 operands, the inline @code{asm} code may modify more than just the outputs. For
9846 example, calculations may require additional registers, or the processor may
9847 overwrite a register as a side effect of a particular assembler instruction.
9848 In order to inform the compiler of these changes, list them in the clobber
9849 list. Clobber list items are either register names or the special clobbers
9850 (listed below). Each clobber list item is a string constant
9851 enclosed in double quotes and separated by commas.
9852
9853 Clobber descriptions may not in any way overlap with an input or output
9854 operand. For example, you may not have an operand describing a register class
9855 with one member when listing that register in the clobber list. Variables
9856 declared to live in specific registers (@pxref{Explicit Register
9857 Variables}) and used
9858 as @code{asm} input or output operands must have no part mentioned in the
9859 clobber description. In particular, there is no way to specify that input
9860 operands get modified without also specifying them as output operands.
9861
9862 When the compiler selects which registers to use to represent input and output
9863 operands, it does not use any of the clobbered registers. As a result,
9864 clobbered registers are available for any use in the assembler code.
9865
9866 Another restriction is that the clobber list should not contain the
9867 stack pointer register. This is because the compiler requires the
9868 value of the stack pointer to be the same after an @code{asm}
9869 statement as it was on entry to the statement. However, previous
9870 versions of GCC did not enforce this rule and allowed the stack
9871 pointer to appear in the list, with unclear semantics. This behavior
9872 is deprecated and listing the stack pointer may become an error in
9873 future versions of GCC@.
9874
9875 Here is a realistic example for the VAX showing the use of clobbered
9876 registers:
9877
9878 @example
9879 asm volatile ("movc3 %0, %1, %2"
9880 : /* No outputs. */
9881 : "g" (from), "g" (to), "g" (count)
9882 : "r0", "r1", "r2", "r3", "r4", "r5", "memory");
9883 @end example
9884
9885 Also, there are two special clobber arguments:
9886
9887 @table @code
9888 @item "cc"
9889 The @code{"cc"} clobber indicates that the assembler code modifies the flags
9890 register. On some machines, GCC represents the condition codes as a specific
9891 hardware register; @code{"cc"} serves to name this register.
9892 On other machines, condition code handling is different,
9893 and specifying @code{"cc"} has no effect. But
9894 it is valid no matter what the target.
9895
9896 @item "memory"
9897 The @code{"memory"} clobber tells the compiler that the assembly code
9898 performs memory
9899 reads or writes to items other than those listed in the input and output
9900 operands (for example, accessing the memory pointed to by one of the input
9901 parameters). To ensure memory contains correct values, GCC may need to flush
9902 specific register values to memory before executing the @code{asm}. Further,
9903 the compiler does not assume that any values read from memory before an
9904 @code{asm} remain unchanged after that @code{asm}; it reloads them as
9905 needed.
9906 Using the @code{"memory"} clobber effectively forms a read/write
9907 memory barrier for the compiler.
9908
9909 Note that this clobber does not prevent the @emph{processor} from doing
9910 speculative reads past the @code{asm} statement. To prevent that, you need
9911 processor-specific fence instructions.
9912
9913 @end table
9914
9915 Flushing registers to memory has performance implications and may be
9916 an issue for time-sensitive code. You can provide better information
9917 to GCC to avoid this, as shown in the following examples. At a
9918 minimum, aliasing rules allow GCC to know what memory @emph{doesn't}
9919 need to be flushed.
9920
9921 Here is a fictitious sum of squares instruction, that takes two
9922 pointers to floating point values in memory and produces a floating
9923 point register output.
9924 Notice that @code{x}, and @code{y} both appear twice in the @code{asm}
9925 parameters, once to specify memory accessed, and once to specify a
9926 base register used by the @code{asm}. You won't normally be wasting a
9927 register by doing this as GCC can use the same register for both
9928 purposes. However, it would be foolish to use both @code{%1} and
9929 @code{%3} for @code{x} in this @code{asm} and expect them to be the
9930 same. In fact, @code{%3} may well not be a register. It might be a
9931 symbolic memory reference to the object pointed to by @code{x}.
9932
9933 @smallexample
9934 asm ("sumsq %0, %1, %2"
9935 : "+f" (result)
9936 : "r" (x), "r" (y), "m" (*x), "m" (*y));
9937 @end smallexample
9938
9939 Here is a fictitious @code{*z++ = *x++ * *y++} instruction.
9940 Notice that the @code{x}, @code{y} and @code{z} pointer registers
9941 must be specified as input/output because the @code{asm} modifies
9942 them.
9943
9944 @smallexample
9945 asm ("vecmul %0, %1, %2"
9946 : "+r" (z), "+r" (x), "+r" (y), "=m" (*z)
9947 : "m" (*x), "m" (*y));
9948 @end smallexample
9949
9950 An x86 example where the string memory argument is of unknown length.
9951
9952 @smallexample
9953 asm("repne scasb"
9954 : "=c" (count), "+D" (p)
9955 : "m" (*(const char (*)[]) p), "0" (-1), "a" (0));
9956 @end smallexample
9957
9958 If you know the above will only be reading a ten byte array then you
9959 could instead use a memory input like:
9960 @code{"m" (*(const char (*)[10]) p)}.
9961
9962 Here is an example of a PowerPC vector scale implemented in assembly,
9963 complete with vector and condition code clobbers, and some initialized
9964 offset registers that are unchanged by the @code{asm}.
9965
9966 @smallexample
9967 void
9968 dscal (size_t n, double *x, double alpha)
9969 @{
9970 asm ("/* lots of asm here */"
9971 : "+m" (*(double (*)[n]) x), "+&r" (n), "+b" (x)
9972 : "d" (alpha), "b" (32), "b" (48), "b" (64),
9973 "b" (80), "b" (96), "b" (112)
9974 : "cr0",
9975 "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
9976 "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47");
9977 @}
9978 @end smallexample
9979
9980 Rather than allocating fixed registers via clobbers to provide scratch
9981 registers for an @code{asm} statement, an alternative is to define a
9982 variable and make it an early-clobber output as with @code{a2} and
9983 @code{a3} in the example below. This gives the compiler register
9984 allocator more freedom. You can also define a variable and make it an
9985 output tied to an input as with @code{a0} and @code{a1}, tied
9986 respectively to @code{ap} and @code{lda}. Of course, with tied
9987 outputs your @code{asm} can't use the input value after modifying the
9988 output register since they are one and the same register. What's
9989 more, if you omit the early-clobber on the output, it is possible that
9990 GCC might allocate the same register to another of the inputs if GCC
9991 could prove they had the same value on entry to the @code{asm}. This
9992 is why @code{a1} has an early-clobber. Its tied input, @code{lda}
9993 might conceivably be known to have the value 16 and without an
9994 early-clobber share the same register as @code{%11}. On the other
9995 hand, @code{ap} can't be the same as any of the other inputs, so an
9996 early-clobber on @code{a0} is not needed. It is also not desirable in
9997 this case. An early-clobber on @code{a0} would cause GCC to allocate
9998 a separate register for the @code{"m" (*(const double (*)[]) ap)}
9999 input. Note that tying an input to an output is the way to set up an
10000 initialized temporary register modified by an @code{asm} statement.
10001 An input not tied to an output is assumed by GCC to be unchanged, for
10002 example @code{"b" (16)} below sets up @code{%11} to 16, and GCC might
10003 use that register in following code if the value 16 happened to be
10004 needed. You can even use a normal @code{asm} output for a scratch if
10005 all inputs that might share the same register are consumed before the
10006 scratch is used. The VSX registers clobbered by the @code{asm}
10007 statement could have used this technique except for GCC's limit on the
10008 number of @code{asm} parameters.
10009
10010 @smallexample
10011 static void
10012 dgemv_kernel_4x4 (long n, const double *ap, long lda,
10013 const double *x, double *y, double alpha)
10014 @{
10015 double *a0;
10016 double *a1;
10017 double *a2;
10018 double *a3;
10019
10020 __asm__
10021 (
10022 /* lots of asm here */
10023 "#n=%1 ap=%8=%12 lda=%13 x=%7=%10 y=%0=%2 alpha=%9 o16=%11\n"
10024 "#a0=%3 a1=%4 a2=%5 a3=%6"
10025 :
10026 "+m" (*(double (*)[n]) y),
10027 "+&r" (n), // 1
10028 "+b" (y), // 2
10029 "=b" (a0), // 3
10030 "=&b" (a1), // 4
10031 "=&b" (a2), // 5
10032 "=&b" (a3) // 6
10033 :
10034 "m" (*(const double (*)[n]) x),
10035 "m" (*(const double (*)[]) ap),
10036 "d" (alpha), // 9
10037 "r" (x), // 10
10038 "b" (16), // 11
10039 "3" (ap), // 12
10040 "4" (lda) // 13
10041 :
10042 "cr0",
10043 "vs32","vs33","vs34","vs35","vs36","vs37",
10044 "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47"
10045 );
10046 @}
10047 @end smallexample
10048
10049 @anchor{GotoLabels}
10050 @subsubsection Goto Labels
10051 @cindex @code{asm} goto labels
10052
10053 @code{asm goto} allows assembly code to jump to one or more C labels. The
10054 @var{GotoLabels} section in an @code{asm goto} statement contains
10055 a comma-separated
10056 list of all C labels to which the assembler code may jump. GCC assumes that
10057 @code{asm} execution falls through to the next statement (if this is not the
10058 case, consider using the @code{__builtin_unreachable} intrinsic after the
10059 @code{asm} statement). Optimization of @code{asm goto} may be improved by
10060 using the @code{hot} and @code{cold} label attributes (@pxref{Label
10061 Attributes}).
10062
10063 An @code{asm goto} statement cannot have outputs.
10064 This is due to an internal restriction of
10065 the compiler: control transfer instructions cannot have outputs.
10066 If the assembler code does modify anything, use the @code{"memory"} clobber
10067 to force the
10068 optimizers to flush all register values to memory and reload them if
10069 necessary after the @code{asm} statement.
10070
10071 Also note that an @code{asm goto} statement is always implicitly
10072 considered volatile.
10073
10074 To reference a label in the assembler template,
10075 prefix it with @samp{%l} (lowercase @samp{L}) followed
10076 by its (zero-based) position in @var{GotoLabels} plus the number of input
10077 operands. For example, if the @code{asm} has three inputs and references two
10078 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
10079
10080 Alternately, you can reference labels using the actual C label name enclosed
10081 in brackets. For example, to reference a label named @code{carry}, you can
10082 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
10083 section when using this approach.
10084
10085 Here is an example of @code{asm goto} for i386:
10086
10087 @example
10088 asm goto (
10089 "btl %1, %0\n\t"
10090 "jc %l2"
10091 : /* No outputs. */
10092 : "r" (p1), "r" (p2)
10093 : "cc"
10094 : carry);
10095
10096 return 0;
10097
10098 carry:
10099 return 1;
10100 @end example
10101
10102 The following example shows an @code{asm goto} that uses a memory clobber.
10103
10104 @example
10105 int frob(int x)
10106 @{
10107 int y;
10108 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
10109 : /* No outputs. */
10110 : "r"(x), "r"(&y)
10111 : "r5", "memory"
10112 : error);
10113 return y;
10114 error:
10115 return -1;
10116 @}
10117 @end example
10118
10119 @anchor{x86Operandmodifiers}
10120 @subsubsection x86 Operand Modifiers
10121
10122 References to input, output, and goto operands in the assembler template
10123 of extended @code{asm} statements can use
10124 modifiers to affect the way the operands are formatted in
10125 the code output to the assembler. For example, the
10126 following code uses the @samp{h} and @samp{b} modifiers for x86:
10127
10128 @example
10129 uint16_t num;
10130 asm volatile ("xchg %h0, %b0" : "+a" (num) );
10131 @end example
10132
10133 @noindent
10134 These modifiers generate this assembler code:
10135
10136 @example
10137 xchg %ah, %al
10138 @end example
10139
10140 The rest of this discussion uses the following code for illustrative purposes.
10141
10142 @example
10143 int main()
10144 @{
10145 int iInt = 1;
10146
10147 top:
10148
10149 asm volatile goto ("some assembler instructions here"
10150 : /* No outputs. */
10151 : "q" (iInt), "X" (sizeof(unsigned char) + 1), "i" (42)
10152 : /* No clobbers. */
10153 : top);
10154 @}
10155 @end example
10156
10157 With no modifiers, this is what the output from the operands would be
10158 for the @samp{att} and @samp{intel} dialects of assembler:
10159
10160 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
10161 @headitem Operand @tab @samp{att} @tab @samp{intel}
10162 @item @code{%0}
10163 @tab @code{%eax}
10164 @tab @code{eax}
10165 @item @code{%1}
10166 @tab @code{$2}
10167 @tab @code{2}
10168 @item @code{%3}
10169 @tab @code{$.L3}
10170 @tab @code{OFFSET FLAT:.L3}
10171 @end multitable
10172
10173 The table below shows the list of supported modifiers and their effects.
10174
10175 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
10176 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
10177 @item @code{a}
10178 @tab Print an absolute memory reference.
10179 @tab @code{%A0}
10180 @tab @code{*%rax}
10181 @tab @code{rax}
10182 @item @code{b}
10183 @tab Print the QImode name of the register.
10184 @tab @code{%b0}
10185 @tab @code{%al}
10186 @tab @code{al}
10187 @item @code{c}
10188 @tab Require a constant operand and print the constant expression with no punctuation.
10189 @tab @code{%c1}
10190 @tab @code{2}
10191 @tab @code{2}
10192 @item @code{E}
10193 @tab Print the address in Double Integer (DImode) mode (8 bytes) when the target is 64-bit.
10194 Otherwise mode is unspecified (VOIDmode).
10195 @tab @code{%E1}
10196 @tab @code{%(rax)}
10197 @tab @code{[rax]}
10198 @item @code{h}
10199 @tab Print the QImode name for a ``high'' register.
10200 @tab @code{%h0}
10201 @tab @code{%ah}
10202 @tab @code{ah}
10203 @item @code{H}
10204 @tab Add 8 bytes to an offsettable memory reference. Useful when accessing the
10205 high 8 bytes of SSE values. For a memref in (%rax), it generates
10206 @tab @code{%H0}
10207 @tab @code{8(%rax)}
10208 @tab @code{8[rax]}
10209 @item @code{k}
10210 @tab Print the SImode name of the register.
10211 @tab @code{%k0}
10212 @tab @code{%eax}
10213 @tab @code{eax}
10214 @item @code{l}
10215 @tab Print the label name with no punctuation.
10216 @tab @code{%l3}
10217 @tab @code{.L3}
10218 @tab @code{.L3}
10219 @item @code{p}
10220 @tab Print raw symbol name (without syntax-specific prefixes).
10221 @tab @code{%p2}
10222 @tab @code{42}
10223 @tab @code{42}
10224 @item @code{P}
10225 @tab If used for a function, print the PLT suffix and generate PIC code.
10226 For example, emit @code{foo@@PLT} instead of 'foo' for the function
10227 foo(). If used for a constant, drop all syntax-specific prefixes and
10228 issue the bare constant. See @code{p} above.
10229 @item @code{q}
10230 @tab Print the DImode name of the register.
10231 @tab @code{%q0}
10232 @tab @code{%rax}
10233 @tab @code{rax}
10234 @item @code{w}
10235 @tab Print the HImode name of the register.
10236 @tab @code{%w0}
10237 @tab @code{%ax}
10238 @tab @code{ax}
10239 @item @code{z}
10240 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
10241 @tab @code{%z0}
10242 @tab @code{l}
10243 @tab
10244 @end multitable
10245
10246 @code{V} is a special modifier which prints the name of the full integer
10247 register without @code{%}.
10248
10249 @anchor{x86floatingpointasmoperands}
10250 @subsubsection x86 Floating-Point @code{asm} Operands
10251
10252 On x86 targets, there are several rules on the usage of stack-like registers
10253 in the operands of an @code{asm}. These rules apply only to the operands
10254 that are stack-like registers:
10255
10256 @enumerate
10257 @item
10258 Given a set of input registers that die in an @code{asm}, it is
10259 necessary to know which are implicitly popped by the @code{asm}, and
10260 which must be explicitly popped by GCC@.
10261
10262 An input register that is implicitly popped by the @code{asm} must be
10263 explicitly clobbered, unless it is constrained to match an
10264 output operand.
10265
10266 @item
10267 For any input register that is implicitly popped by an @code{asm}, it is
10268 necessary to know how to adjust the stack to compensate for the pop.
10269 If any non-popped input is closer to the top of the reg-stack than
10270 the implicitly popped register, it would not be possible to know what the
10271 stack looked like---it's not clear how the rest of the stack ``slides
10272 up''.
10273
10274 All implicitly popped input registers must be closer to the top of
10275 the reg-stack than any input that is not implicitly popped.
10276
10277 It is possible that if an input dies in an @code{asm}, the compiler might
10278 use the input register for an output reload. Consider this example:
10279
10280 @smallexample
10281 asm ("foo" : "=t" (a) : "f" (b));
10282 @end smallexample
10283
10284 @noindent
10285 This code says that input @code{b} is not popped by the @code{asm}, and that
10286 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
10287 deeper after the @code{asm} than it was before. But, it is possible that
10288 reload may think that it can use the same register for both the input and
10289 the output.
10290
10291 To prevent this from happening,
10292 if any input operand uses the @samp{f} constraint, all output register
10293 constraints must use the @samp{&} early-clobber modifier.
10294
10295 The example above is correctly written as:
10296
10297 @smallexample
10298 asm ("foo" : "=&t" (a) : "f" (b));
10299 @end smallexample
10300
10301 @item
10302 Some operands need to be in particular places on the stack. All
10303 output operands fall in this category---GCC has no other way to
10304 know which registers the outputs appear in unless you indicate
10305 this in the constraints.
10306
10307 Output operands must specifically indicate which register an output
10308 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
10309 constraints must select a class with a single register.
10310
10311 @item
10312 Output operands may not be ``inserted'' between existing stack registers.
10313 Since no 387 opcode uses a read/write operand, all output operands
10314 are dead before the @code{asm}, and are pushed by the @code{asm}.
10315 It makes no sense to push anywhere but the top of the reg-stack.
10316
10317 Output operands must start at the top of the reg-stack: output
10318 operands may not ``skip'' a register.
10319
10320 @item
10321 Some @code{asm} statements may need extra stack space for internal
10322 calculations. This can be guaranteed by clobbering stack registers
10323 unrelated to the inputs and outputs.
10324
10325 @end enumerate
10326
10327 This @code{asm}
10328 takes one input, which is internally popped, and produces two outputs.
10329
10330 @smallexample
10331 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
10332 @end smallexample
10333
10334 @noindent
10335 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
10336 and replaces them with one output. The @code{st(1)} clobber is necessary
10337 for the compiler to know that @code{fyl2xp1} pops both inputs.
10338
10339 @smallexample
10340 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
10341 @end smallexample
10342
10343 @lowersections
10344 @include md.texi
10345 @raisesections
10346
10347 @node Asm Labels
10348 @subsection Controlling Names Used in Assembler Code
10349 @cindex assembler names for identifiers
10350 @cindex names used in assembler code
10351 @cindex identifiers, names in assembler code
10352
10353 You can specify the name to be used in the assembler code for a C
10354 function or variable by writing the @code{asm} (or @code{__asm__})
10355 keyword after the declarator.
10356 It is up to you to make sure that the assembler names you choose do not
10357 conflict with any other assembler symbols, or reference registers.
10358
10359 @subsubheading Assembler names for data:
10360
10361 This sample shows how to specify the assembler name for data:
10362
10363 @smallexample
10364 int foo asm ("myfoo") = 2;
10365 @end smallexample
10366
10367 @noindent
10368 This specifies that the name to be used for the variable @code{foo} in
10369 the assembler code should be @samp{myfoo} rather than the usual
10370 @samp{_foo}.
10371
10372 On systems where an underscore is normally prepended to the name of a C
10373 variable, this feature allows you to define names for the
10374 linker that do not start with an underscore.
10375
10376 GCC does not support using this feature with a non-static local variable
10377 since such variables do not have assembler names. If you are
10378 trying to put the variable in a particular register, see
10379 @ref{Explicit Register Variables}.
10380
10381 @subsubheading Assembler names for functions:
10382
10383 To specify the assembler name for functions, write a declaration for the
10384 function before its definition and put @code{asm} there, like this:
10385
10386 @smallexample
10387 int func (int x, int y) asm ("MYFUNC");
10388
10389 int func (int x, int y)
10390 @{
10391 /* @r{@dots{}} */
10392 @end smallexample
10393
10394 @noindent
10395 This specifies that the name to be used for the function @code{func} in
10396 the assembler code should be @code{MYFUNC}.
10397
10398 @node Explicit Register Variables
10399 @subsection Variables in Specified Registers
10400 @anchor{Explicit Reg Vars}
10401 @cindex explicit register variables
10402 @cindex variables in specified registers
10403 @cindex specified registers
10404
10405 GNU C allows you to associate specific hardware registers with C
10406 variables. In almost all cases, allowing the compiler to assign
10407 registers produces the best code. However under certain unusual
10408 circumstances, more precise control over the variable storage is
10409 required.
10410
10411 Both global and local variables can be associated with a register. The
10412 consequences of performing this association are very different between
10413 the two, as explained in the sections below.
10414
10415 @menu
10416 * Global Register Variables:: Variables declared at global scope.
10417 * Local Register Variables:: Variables declared within a function.
10418 @end menu
10419
10420 @node Global Register Variables
10421 @subsubsection Defining Global Register Variables
10422 @anchor{Global Reg Vars}
10423 @cindex global register variables
10424 @cindex registers, global variables in
10425 @cindex registers, global allocation
10426
10427 You can define a global register variable and associate it with a specified
10428 register like this:
10429
10430 @smallexample
10431 register int *foo asm ("r12");
10432 @end smallexample
10433
10434 @noindent
10435 Here @code{r12} is the name of the register that should be used. Note that
10436 this is the same syntax used for defining local register variables, but for
10437 a global variable the declaration appears outside a function. The
10438 @code{register} keyword is required, and cannot be combined with
10439 @code{static}. The register name must be a valid register name for the
10440 target platform.
10441
10442 Do not use type qualifiers such as @code{const} and @code{volatile}, as
10443 the outcome may be contrary to expectations. In particular, using the
10444 @code{volatile} qualifier does not fully prevent the compiler from
10445 optimizing accesses to the register.
10446
10447 Registers are a scarce resource on most systems and allowing the
10448 compiler to manage their usage usually results in the best code. However,
10449 under special circumstances it can make sense to reserve some globally.
10450 For example this may be useful in programs such as programming language
10451 interpreters that have a couple of global variables that are accessed
10452 very often.
10453
10454 After defining a global register variable, for the current compilation
10455 unit:
10456
10457 @itemize @bullet
10458 @item If the register is a call-saved register, call ABI is affected:
10459 the register will not be restored in function epilogue sequences after
10460 the variable has been assigned. Therefore, functions cannot safely
10461 return to callers that assume standard ABI.
10462 @item Conversely, if the register is a call-clobbered register, making
10463 calls to functions that use standard ABI may lose contents of the variable.
10464 Such calls may be created by the compiler even if none are evident in
10465 the original program, for example when libgcc functions are used to
10466 make up for unavailable instructions.
10467 @item Accesses to the variable may be optimized as usual and the register
10468 remains available for allocation and use in any computations, provided that
10469 observable values of the variable are not affected.
10470 @item If the variable is referenced in inline assembly, the type of access
10471 must be provided to the compiler via constraints (@pxref{Constraints}).
10472 Accesses from basic asms are not supported.
10473 @end itemize
10474
10475 Note that these points @emph{only} apply to code that is compiled with the
10476 definition. The behavior of code that is merely linked in (for example
10477 code from libraries) is not affected.
10478
10479 If you want to recompile source files that do not actually use your global
10480 register variable so they do not use the specified register for any other
10481 purpose, you need not actually add the global register declaration to
10482 their source code. It suffices to specify the compiler option
10483 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
10484 register.
10485
10486 @subsubheading Declaring the variable
10487
10488 Global register variables cannot have initial values, because an
10489 executable file has no means to supply initial contents for a register.
10490
10491 When selecting a register, choose one that is normally saved and
10492 restored by function calls on your machine. This ensures that code
10493 which is unaware of this reservation (such as library routines) will
10494 restore it before returning.
10495
10496 On machines with register windows, be sure to choose a global
10497 register that is not affected magically by the function call mechanism.
10498
10499 @subsubheading Using the variable
10500
10501 @cindex @code{qsort}, and global register variables
10502 When calling routines that are not aware of the reservation, be
10503 cautious if those routines call back into code which uses them. As an
10504 example, if you call the system library version of @code{qsort}, it may
10505 clobber your registers during execution, but (if you have selected
10506 appropriate registers) it will restore them before returning. However
10507 it will @emph{not} restore them before calling @code{qsort}'s comparison
10508 function. As a result, global values will not reliably be available to
10509 the comparison function unless the @code{qsort} function itself is rebuilt.
10510
10511 Similarly, it is not safe to access the global register variables from signal
10512 handlers or from more than one thread of control. Unless you recompile
10513 them specially for the task at hand, the system library routines may
10514 temporarily use the register for other things. Furthermore, since the register
10515 is not reserved exclusively for the variable, accessing it from handlers of
10516 asynchronous signals may observe unrelated temporary values residing in the
10517 register.
10518
10519 @cindex register variable after @code{longjmp}
10520 @cindex global register after @code{longjmp}
10521 @cindex value after @code{longjmp}
10522 @findex longjmp
10523 @findex setjmp
10524 On most machines, @code{longjmp} restores to each global register
10525 variable the value it had at the time of the @code{setjmp}. On some
10526 machines, however, @code{longjmp} does not change the value of global
10527 register variables. To be portable, the function that called @code{setjmp}
10528 should make other arrangements to save the values of the global register
10529 variables, and to restore them in a @code{longjmp}. This way, the same
10530 thing happens regardless of what @code{longjmp} does.
10531
10532 @node Local Register Variables
10533 @subsubsection Specifying Registers for Local Variables
10534 @anchor{Local Reg Vars}
10535 @cindex local variables, specifying registers
10536 @cindex specifying registers for local variables
10537 @cindex registers for local variables
10538
10539 You can define a local register variable and associate it with a specified
10540 register like this:
10541
10542 @smallexample
10543 register int *foo asm ("r12");
10544 @end smallexample
10545
10546 @noindent
10547 Here @code{r12} is the name of the register that should be used. Note
10548 that this is the same syntax used for defining global register variables,
10549 but for a local variable the declaration appears within a function. The
10550 @code{register} keyword is required, and cannot be combined with
10551 @code{static}. The register name must be a valid register name for the
10552 target platform.
10553
10554 Do not use type qualifiers such as @code{const} and @code{volatile}, as
10555 the outcome may be contrary to expectations. In particular, when the
10556 @code{const} qualifier is used, the compiler may substitute the
10557 variable with its initializer in @code{asm} statements, which may cause
10558 the corresponding operand to appear in a different register.
10559
10560 As with global register variables, it is recommended that you choose
10561 a register that is normally saved and restored by function calls on your
10562 machine, so that calls to library routines will not clobber it.
10563
10564 The only supported use for this feature is to specify registers
10565 for input and output operands when calling Extended @code{asm}
10566 (@pxref{Extended Asm}). This may be necessary if the constraints for a
10567 particular machine don't provide sufficient control to select the desired
10568 register. To force an operand into a register, create a local variable
10569 and specify the register name after the variable's declaration. Then use
10570 the local variable for the @code{asm} operand and specify any constraint
10571 letter that matches the register:
10572
10573 @smallexample
10574 register int *p1 asm ("r0") = @dots{};
10575 register int *p2 asm ("r1") = @dots{};
10576 register int *result asm ("r0");
10577 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
10578 @end smallexample
10579
10580 @emph{Warning:} In the above example, be aware that a register (for example
10581 @code{r0}) can be call-clobbered by subsequent code, including function
10582 calls and library calls for arithmetic operators on other variables (for
10583 example the initialization of @code{p2}). In this case, use temporary
10584 variables for expressions between the register assignments:
10585
10586 @smallexample
10587 int t1 = @dots{};
10588 register int *p1 asm ("r0") = @dots{};
10589 register int *p2 asm ("r1") = t1;
10590 register int *result asm ("r0");
10591 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
10592 @end smallexample
10593
10594 Defining a register variable does not reserve the register. Other than
10595 when invoking the Extended @code{asm}, the contents of the specified
10596 register are not guaranteed. For this reason, the following uses
10597 are explicitly @emph{not} supported. If they appear to work, it is only
10598 happenstance, and may stop working as intended due to (seemingly)
10599 unrelated changes in surrounding code, or even minor changes in the
10600 optimization of a future version of gcc:
10601
10602 @itemize @bullet
10603 @item Passing parameters to or from Basic @code{asm}
10604 @item Passing parameters to or from Extended @code{asm} without using input
10605 or output operands.
10606 @item Passing parameters to or from routines written in assembler (or
10607 other languages) using non-standard calling conventions.
10608 @end itemize
10609
10610 Some developers use Local Register Variables in an attempt to improve
10611 gcc's allocation of registers, especially in large functions. In this
10612 case the register name is essentially a hint to the register allocator.
10613 While in some instances this can generate better code, improvements are
10614 subject to the whims of the allocator/optimizers. Since there are no
10615 guarantees that your improvements won't be lost, this usage of Local
10616 Register Variables is discouraged.
10617
10618 On the MIPS platform, there is related use for local register variables
10619 with slightly different characteristics (@pxref{MIPS Coprocessors,,
10620 Defining coprocessor specifics for MIPS targets, gccint,
10621 GNU Compiler Collection (GCC) Internals}).
10622
10623 @node Size of an asm
10624 @subsection Size of an @code{asm}
10625
10626 Some targets require that GCC track the size of each instruction used
10627 in order to generate correct code. Because the final length of the
10628 code produced by an @code{asm} statement is only known by the
10629 assembler, GCC must make an estimate as to how big it will be. It
10630 does this by counting the number of instructions in the pattern of the
10631 @code{asm} and multiplying that by the length of the longest
10632 instruction supported by that processor. (When working out the number
10633 of instructions, it assumes that any occurrence of a newline or of
10634 whatever statement separator character is supported by the assembler ---
10635 typically @samp{;} --- indicates the end of an instruction.)
10636
10637 Normally, GCC's estimate is adequate to ensure that correct
10638 code is generated, but it is possible to confuse the compiler if you use
10639 pseudo instructions or assembler macros that expand into multiple real
10640 instructions, or if you use assembler directives that expand to more
10641 space in the object file than is needed for a single instruction.
10642 If this happens then the assembler may produce a diagnostic saying that
10643 a label is unreachable.
10644
10645 @cindex @code{asm inline}
10646 This size is also used for inlining decisions. If you use @code{asm inline}
10647 instead of just @code{asm}, then for inlining purposes the size of the asm
10648 is taken as the minimum size, ignoring how many instructions GCC thinks it is.
10649
10650 @node Alternate Keywords
10651 @section Alternate Keywords
10652 @cindex alternate keywords
10653 @cindex keywords, alternate
10654
10655 @option{-ansi} and the various @option{-std} options disable certain
10656 keywords. This causes trouble when you want to use GNU C extensions, or
10657 a general-purpose header file that should be usable by all programs,
10658 including ISO C programs. The keywords @code{asm}, @code{typeof} and
10659 @code{inline} are not available in programs compiled with
10660 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
10661 program compiled with @option{-std=c99} or @option{-std=c11}). The
10662 ISO C99 keyword
10663 @code{restrict} is only available when @option{-std=gnu99} (which will
10664 eventually be the default) or @option{-std=c99} (or the equivalent
10665 @option{-std=iso9899:1999}), or an option for a later standard
10666 version, is used.
10667
10668 The way to solve these problems is to put @samp{__} at the beginning and
10669 end of each problematical keyword. For example, use @code{__asm__}
10670 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
10671
10672 Other C compilers won't accept these alternative keywords; if you want to
10673 compile with another compiler, you can define the alternate keywords as
10674 macros to replace them with the customary keywords. It looks like this:
10675
10676 @smallexample
10677 #ifndef __GNUC__
10678 #define __asm__ asm
10679 #endif
10680 @end smallexample
10681
10682 @findex __extension__
10683 @opindex pedantic
10684 @option{-pedantic} and other options cause warnings for many GNU C extensions.
10685 You can
10686 prevent such warnings within one expression by writing
10687 @code{__extension__} before the expression. @code{__extension__} has no
10688 effect aside from this.
10689
10690 @node Incomplete Enums
10691 @section Incomplete @code{enum} Types
10692
10693 You can define an @code{enum} tag without specifying its possible values.
10694 This results in an incomplete type, much like what you get if you write
10695 @code{struct foo} without describing the elements. A later declaration
10696 that does specify the possible values completes the type.
10697
10698 You cannot allocate variables or storage using the type while it is
10699 incomplete. However, you can work with pointers to that type.
10700
10701 This extension may not be very useful, but it makes the handling of
10702 @code{enum} more consistent with the way @code{struct} and @code{union}
10703 are handled.
10704
10705 This extension is not supported by GNU C++.
10706
10707 @node Function Names
10708 @section Function Names as Strings
10709 @cindex @code{__func__} identifier
10710 @cindex @code{__FUNCTION__} identifier
10711 @cindex @code{__PRETTY_FUNCTION__} identifier
10712
10713 GCC provides three magic constants that hold the name of the current
10714 function as a string. In C++11 and later modes, all three are treated
10715 as constant expressions and can be used in @code{constexpr} constexts.
10716 The first of these constants is @code{__func__}, which is part of
10717 the C99 standard:
10718
10719 The identifier @code{__func__} is implicitly declared by the translator
10720 as if, immediately following the opening brace of each function
10721 definition, the declaration
10722
10723 @smallexample
10724 static const char __func__[] = "function-name";
10725 @end smallexample
10726
10727 @noindent
10728 appeared, where function-name is the name of the lexically-enclosing
10729 function. This name is the unadorned name of the function. As an
10730 extension, at file (or, in C++, namespace scope), @code{__func__}
10731 evaluates to the empty string.
10732
10733 @code{__FUNCTION__} is another name for @code{__func__}, provided for
10734 backward compatibility with old versions of GCC.
10735
10736 In C, @code{__PRETTY_FUNCTION__} is yet another name for
10737 @code{__func__}, except that at file (or, in C++, namespace scope),
10738 it evaluates to the string @code{"top level"}. In addition, in C++,
10739 @code{__PRETTY_FUNCTION__} contains the signature of the function as
10740 well as its bare name. For example, this program:
10741
10742 @smallexample
10743 extern "C" int printf (const char *, ...);
10744
10745 class a @{
10746 public:
10747 void sub (int i)
10748 @{
10749 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
10750 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
10751 @}
10752 @};
10753
10754 int
10755 main (void)
10756 @{
10757 a ax;
10758 ax.sub (0);
10759 return 0;
10760 @}
10761 @end smallexample
10762
10763 @noindent
10764 gives this output:
10765
10766 @smallexample
10767 __FUNCTION__ = sub
10768 __PRETTY_FUNCTION__ = void a::sub(int)
10769 @end smallexample
10770
10771 These identifiers are variables, not preprocessor macros, and may not
10772 be used to initialize @code{char} arrays or be concatenated with string
10773 literals.
10774
10775 @node Return Address
10776 @section Getting the Return or Frame Address of a Function
10777
10778 These functions may be used to get information about the callers of a
10779 function.
10780
10781 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
10782 This function returns the return address of the current function, or of
10783 one of its callers. The @var{level} argument is number of frames to
10784 scan up the call stack. A value of @code{0} yields the return address
10785 of the current function, a value of @code{1} yields the return address
10786 of the caller of the current function, and so forth. When inlining
10787 the expected behavior is that the function returns the address of
10788 the function that is returned to. To work around this behavior use
10789 the @code{noinline} function attribute.
10790
10791 The @var{level} argument must be a constant integer.
10792
10793 On some machines it may be impossible to determine the return address of
10794 any function other than the current one; in such cases, or when the top
10795 of the stack has been reached, this function returns @code{0} or a
10796 random value. In addition, @code{__builtin_frame_address} may be used
10797 to determine if the top of the stack has been reached.
10798
10799 Additional post-processing of the returned value may be needed, see
10800 @code{__builtin_extract_return_addr}.
10801
10802 Calling this function with a nonzero argument can have unpredictable
10803 effects, including crashing the calling program. As a result, calls
10804 that are considered unsafe are diagnosed when the @option{-Wframe-address}
10805 option is in effect. Such calls should only be made in debugging
10806 situations.
10807 @end deftypefn
10808
10809 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
10810 The address as returned by @code{__builtin_return_address} may have to be fed
10811 through this function to get the actual encoded address. For example, on the
10812 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
10813 platforms an offset has to be added for the true next instruction to be
10814 executed.
10815
10816 If no fixup is needed, this function simply passes through @var{addr}.
10817 @end deftypefn
10818
10819 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
10820 This function does the reverse of @code{__builtin_extract_return_addr}.
10821 @end deftypefn
10822
10823 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
10824 This function is similar to @code{__builtin_return_address}, but it
10825 returns the address of the function frame rather than the return address
10826 of the function. Calling @code{__builtin_frame_address} with a value of
10827 @code{0} yields the frame address of the current function, a value of
10828 @code{1} yields the frame address of the caller of the current function,
10829 and so forth.
10830
10831 The frame is the area on the stack that holds local variables and saved
10832 registers. The frame address is normally the address of the first word
10833 pushed on to the stack by the function. However, the exact definition
10834 depends upon the processor and the calling convention. If the processor
10835 has a dedicated frame pointer register, and the function has a frame,
10836 then @code{__builtin_frame_address} returns the value of the frame
10837 pointer register.
10838
10839 On some machines it may be impossible to determine the frame address of
10840 any function other than the current one; in such cases, or when the top
10841 of the stack has been reached, this function returns @code{0} if
10842 the first frame pointer is properly initialized by the startup code.
10843
10844 Calling this function with a nonzero argument can have unpredictable
10845 effects, including crashing the calling program. As a result, calls
10846 that are considered unsafe are diagnosed when the @option{-Wframe-address}
10847 option is in effect. Such calls should only be made in debugging
10848 situations.
10849 @end deftypefn
10850
10851 @node Vector Extensions
10852 @section Using Vector Instructions through Built-in Functions
10853
10854 On some targets, the instruction set contains SIMD vector instructions which
10855 operate on multiple values contained in one large register at the same time.
10856 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
10857 this way.
10858
10859 The first step in using these extensions is to provide the necessary data
10860 types. This should be done using an appropriate @code{typedef}:
10861
10862 @smallexample
10863 typedef int v4si __attribute__ ((vector_size (16)));
10864 @end smallexample
10865
10866 @noindent
10867 The @code{int} type specifies the base type, while the attribute specifies
10868 the vector size for the variable, measured in bytes. For example, the
10869 declaration above causes the compiler to set the mode for the @code{v4si}
10870 type to be 16 bytes wide and divided into @code{int} sized units. For
10871 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
10872 corresponding mode of @code{foo} is @acronym{V4SI}.
10873
10874 The @code{vector_size} attribute is only applicable to integral and
10875 float scalars, although arrays, pointers, and function return values
10876 are allowed in conjunction with this construct. Only sizes that are
10877 a power of two are currently allowed.
10878
10879 All the basic integer types can be used as base types, both as signed
10880 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
10881 @code{long long}. In addition, @code{float} and @code{double} can be
10882 used to build floating-point vector types.
10883
10884 Specifying a combination that is not valid for the current architecture
10885 causes GCC to synthesize the instructions using a narrower mode.
10886 For example, if you specify a variable of type @code{V4SI} and your
10887 architecture does not allow for this specific SIMD type, GCC
10888 produces code that uses 4 @code{SIs}.
10889
10890 The types defined in this manner can be used with a subset of normal C
10891 operations. Currently, GCC allows using the following operators
10892 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
10893
10894 The operations behave like C++ @code{valarrays}. Addition is defined as
10895 the addition of the corresponding elements of the operands. For
10896 example, in the code below, each of the 4 elements in @var{a} is
10897 added to the corresponding 4 elements in @var{b} and the resulting
10898 vector is stored in @var{c}.
10899
10900 @smallexample
10901 typedef int v4si __attribute__ ((vector_size (16)));
10902
10903 v4si a, b, c;
10904
10905 c = a + b;
10906 @end smallexample
10907
10908 Subtraction, multiplication, division, and the logical operations
10909 operate in a similar manner. Likewise, the result of using the unary
10910 minus or complement operators on a vector type is a vector whose
10911 elements are the negative or complemented values of the corresponding
10912 elements in the operand.
10913
10914 It is possible to use shifting operators @code{<<}, @code{>>} on
10915 integer-type vectors. The operation is defined as following: @code{@{a0,
10916 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
10917 @dots{}, an >> bn@}}@. Vector operands must have the same number of
10918 elements.
10919
10920 For convenience, it is allowed to use a binary vector operation
10921 where one operand is a scalar. In that case the compiler transforms
10922 the scalar operand into a vector where each element is the scalar from
10923 the operation. The transformation happens only if the scalar could be
10924 safely converted to the vector-element type.
10925 Consider the following code.
10926
10927 @smallexample
10928 typedef int v4si __attribute__ ((vector_size (16)));
10929
10930 v4si a, b, c;
10931 long l;
10932
10933 a = b + 1; /* a = b + @{1,1,1,1@}; */
10934 a = 2 * b; /* a = @{2,2,2,2@} * b; */
10935
10936 a = l + a; /* Error, cannot convert long to int. */
10937 @end smallexample
10938
10939 Vectors can be subscripted as if the vector were an array with
10940 the same number of elements and base type. Out of bound accesses
10941 invoke undefined behavior at run time. Warnings for out of bound
10942 accesses for vector subscription can be enabled with
10943 @option{-Warray-bounds}.
10944
10945 Vector comparison is supported with standard comparison
10946 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
10947 vector expressions of integer-type or real-type. Comparison between
10948 integer-type vectors and real-type vectors are not supported. The
10949 result of the comparison is a vector of the same width and number of
10950 elements as the comparison operands with a signed integral element
10951 type.
10952
10953 Vectors are compared element-wise producing 0 when comparison is false
10954 and -1 (constant of the appropriate type where all bits are set)
10955 otherwise. Consider the following example.
10956
10957 @smallexample
10958 typedef int v4si __attribute__ ((vector_size (16)));
10959
10960 v4si a = @{1,2,3,4@};
10961 v4si b = @{3,2,1,4@};
10962 v4si c;
10963
10964 c = a > b; /* The result would be @{0, 0,-1, 0@} */
10965 c = a == b; /* The result would be @{0,-1, 0,-1@} */
10966 @end smallexample
10967
10968 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
10969 @code{b} and @code{c} are vectors of the same type and @code{a} is an
10970 integer vector with the same number of elements of the same size as @code{b}
10971 and @code{c}, computes all three arguments and creates a vector
10972 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
10973 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
10974 As in the case of binary operations, this syntax is also accepted when
10975 one of @code{b} or @code{c} is a scalar that is then transformed into a
10976 vector. If both @code{b} and @code{c} are scalars and the type of
10977 @code{true?b:c} has the same size as the element type of @code{a}, then
10978 @code{b} and @code{c} are converted to a vector type whose elements have
10979 this type and with the same number of elements as @code{a}.
10980
10981 In C++, the logic operators @code{!, &&, ||} are available for vectors.
10982 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
10983 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
10984 For mixed operations between a scalar @code{s} and a vector @code{v},
10985 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
10986 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
10987
10988 @findex __builtin_shuffle
10989 Vector shuffling is available using functions
10990 @code{__builtin_shuffle (vec, mask)} and
10991 @code{__builtin_shuffle (vec0, vec1, mask)}.
10992 Both functions construct a permutation of elements from one or two
10993 vectors and return a vector of the same type as the input vector(s).
10994 The @var{mask} is an integral vector with the same width (@var{W})
10995 and element count (@var{N}) as the output vector.
10996
10997 The elements of the input vectors are numbered in memory ordering of
10998 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
10999 elements of @var{mask} are considered modulo @var{N} in the single-operand
11000 case and modulo @math{2*@var{N}} in the two-operand case.
11001
11002 Consider the following example,
11003
11004 @smallexample
11005 typedef int v4si __attribute__ ((vector_size (16)));
11006
11007 v4si a = @{1,2,3,4@};
11008 v4si b = @{5,6,7,8@};
11009 v4si mask1 = @{0,1,1,3@};
11010 v4si mask2 = @{0,4,2,5@};
11011 v4si res;
11012
11013 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
11014 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
11015 @end smallexample
11016
11017 Note that @code{__builtin_shuffle} is intentionally semantically
11018 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
11019
11020 You can declare variables and use them in function calls and returns, as
11021 well as in assignments and some casts. You can specify a vector type as
11022 a return type for a function. Vector types can also be used as function
11023 arguments. It is possible to cast from one vector type to another,
11024 provided they are of the same size (in fact, you can also cast vectors
11025 to and from other datatypes of the same size).
11026
11027 You cannot operate between vectors of different lengths or different
11028 signedness without a cast.
11029
11030 @findex __builtin_convertvector
11031 Vector conversion is available using the
11032 @code{__builtin_convertvector (vec, vectype)}
11033 function. @var{vec} must be an expression with integral or floating
11034 vector type and @var{vectype} an integral or floating vector type with the
11035 same number of elements. The result has @var{vectype} type and value of
11036 a C cast of every element of @var{vec} to the element type of @var{vectype}.
11037
11038 Consider the following example,
11039 @smallexample
11040 typedef int v4si __attribute__ ((vector_size (16)));
11041 typedef float v4sf __attribute__ ((vector_size (16)));
11042 typedef double v4df __attribute__ ((vector_size (32)));
11043 typedef unsigned long long v4di __attribute__ ((vector_size (32)));
11044
11045 v4si a = @{1,-2,3,-4@};
11046 v4sf b = @{1.5f,-2.5f,3.f,7.f@};
11047 v4di c = @{1ULL,5ULL,0ULL,10ULL@};
11048 v4sf d = __builtin_convertvector (a, v4sf); /* d is @{1.f,-2.f,3.f,-4.f@} */
11049 /* Equivalent of:
11050 v4sf d = @{ (float)a[0], (float)a[1], (float)a[2], (float)a[3] @}; */
11051 v4df e = __builtin_convertvector (a, v4df); /* e is @{1.,-2.,3.,-4.@} */
11052 v4df f = __builtin_convertvector (b, v4df); /* f is @{1.5,-2.5,3.,7.@} */
11053 v4si g = __builtin_convertvector (f, v4si); /* g is @{1,-2,3,7@} */
11054 v4si h = __builtin_convertvector (c, v4si); /* h is @{1,5,0,10@} */
11055 @end smallexample
11056
11057 @cindex vector types, using with x86 intrinsics
11058 Sometimes it is desirable to write code using a mix of generic vector
11059 operations (for clarity) and machine-specific vector intrinsics (to
11060 access vector instructions that are not exposed via generic built-ins).
11061 On x86, intrinsic functions for integer vectors typically use the same
11062 vector type @code{__m128i} irrespective of how they interpret the vector,
11063 making it necessary to cast their arguments and return values from/to
11064 other vector types. In C, you can make use of a @code{union} type:
11065 @c In C++ such type punning via a union is not allowed by the language
11066 @smallexample
11067 #include <immintrin.h>
11068
11069 typedef unsigned char u8x16 __attribute__ ((vector_size (16)));
11070 typedef unsigned int u32x4 __attribute__ ((vector_size (16)));
11071
11072 typedef union @{
11073 __m128i mm;
11074 u8x16 u8;
11075 u32x4 u32;
11076 @} v128;
11077 @end smallexample
11078
11079 @noindent
11080 for variables that can be used with both built-in operators and x86
11081 intrinsics:
11082
11083 @smallexample
11084 v128 x, y = @{ 0 @};
11085 memcpy (&x, ptr, sizeof x);
11086 y.u8 += 0x80;
11087 x.mm = _mm_adds_epu8 (x.mm, y.mm);
11088 x.u32 &= 0xffffff;
11089
11090 /* Instead of a variable, a compound literal may be used to pass the
11091 return value of an intrinsic call to a function expecting the union: */
11092 v128 foo (v128);
11093 x = foo ((v128) @{_mm_adds_epu8 (x.mm, y.mm)@});
11094 @c This could be done implicitly with __attribute__((transparent_union)),
11095 @c but GCC does not accept it for unions of vector types (PR 88955).
11096 @end smallexample
11097
11098 @node Offsetof
11099 @section Support for @code{offsetof}
11100 @findex __builtin_offsetof
11101
11102 GCC implements for both C and C++ a syntactic extension to implement
11103 the @code{offsetof} macro.
11104
11105 @smallexample
11106 primary:
11107 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
11108
11109 offsetof_member_designator:
11110 @code{identifier}
11111 | offsetof_member_designator "." @code{identifier}
11112 | offsetof_member_designator "[" @code{expr} "]"
11113 @end smallexample
11114
11115 This extension is sufficient such that
11116
11117 @smallexample
11118 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
11119 @end smallexample
11120
11121 @noindent
11122 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
11123 may be dependent. In either case, @var{member} may consist of a single
11124 identifier, or a sequence of member accesses and array references.
11125
11126 @node __sync Builtins
11127 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
11128
11129 The following built-in functions
11130 are intended to be compatible with those described
11131 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
11132 section 7.4. As such, they depart from normal GCC practice by not using
11133 the @samp{__builtin_} prefix and also by being overloaded so that they
11134 work on multiple types.
11135
11136 The definition given in the Intel documentation allows only for the use of
11137 the types @code{int}, @code{long}, @code{long long} or their unsigned
11138 counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
11139 size other than the C type @code{_Bool} or the C++ type @code{bool}.
11140 Operations on pointer arguments are performed as if the operands were
11141 of the @code{uintptr_t} type. That is, they are not scaled by the size
11142 of the type to which the pointer points.
11143
11144 These functions are implemented in terms of the @samp{__atomic}
11145 builtins (@pxref{__atomic Builtins}). They should not be used for new
11146 code which should use the @samp{__atomic} builtins instead.
11147
11148 Not all operations are supported by all target processors. If a particular
11149 operation cannot be implemented on the target processor, a warning is
11150 generated and a call to an external function is generated. The external
11151 function carries the same name as the built-in version,
11152 with an additional suffix
11153 @samp{_@var{n}} where @var{n} is the size of the data type.
11154
11155 @c ??? Should we have a mechanism to suppress this warning? This is almost
11156 @c useful for implementing the operation under the control of an external
11157 @c mutex.
11158
11159 In most cases, these built-in functions are considered a @dfn{full barrier}.
11160 That is,
11161 no memory operand is moved across the operation, either forward or
11162 backward. Further, instructions are issued as necessary to prevent the
11163 processor from speculating loads across the operation and from queuing stores
11164 after the operation.
11165
11166 All of the routines are described in the Intel documentation to take
11167 ``an optional list of variables protected by the memory barrier''. It's
11168 not clear what is meant by that; it could mean that @emph{only} the
11169 listed variables are protected, or it could mean a list of additional
11170 variables to be protected. The list is ignored by GCC which treats it as
11171 empty. GCC interprets an empty list as meaning that all globally
11172 accessible variables should be protected.
11173
11174 @table @code
11175 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
11176 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
11177 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
11178 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
11179 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
11180 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
11181 @findex __sync_fetch_and_add
11182 @findex __sync_fetch_and_sub
11183 @findex __sync_fetch_and_or
11184 @findex __sync_fetch_and_and
11185 @findex __sync_fetch_and_xor
11186 @findex __sync_fetch_and_nand
11187 These built-in functions perform the operation suggested by the name, and
11188 returns the value that had previously been in memory. That is, operations
11189 on integer operands have the following semantics. Operations on pointer
11190 arguments are performed as if the operands were of the @code{uintptr_t}
11191 type. That is, they are not scaled by the size of the type to which
11192 the pointer points.
11193
11194 @smallexample
11195 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
11196 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
11197 @end smallexample
11198
11199 The object pointed to by the first argument must be of integer or pointer
11200 type. It must not be a boolean type.
11201
11202 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
11203 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
11204
11205 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
11206 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
11207 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
11208 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
11209 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
11210 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
11211 @findex __sync_add_and_fetch
11212 @findex __sync_sub_and_fetch
11213 @findex __sync_or_and_fetch
11214 @findex __sync_and_and_fetch
11215 @findex __sync_xor_and_fetch
11216 @findex __sync_nand_and_fetch
11217 These built-in functions perform the operation suggested by the name, and
11218 return the new value. That is, operations on integer operands have
11219 the following semantics. Operations on pointer operands are performed as
11220 if the operand's type were @code{uintptr_t}.
11221
11222 @smallexample
11223 @{ *ptr @var{op}= value; return *ptr; @}
11224 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
11225 @end smallexample
11226
11227 The same constraints on arguments apply as for the corresponding
11228 @code{__sync_op_and_fetch} built-in functions.
11229
11230 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
11231 as @code{*ptr = ~(*ptr & value)} instead of
11232 @code{*ptr = ~*ptr & value}.
11233
11234 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
11235 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
11236 @findex __sync_bool_compare_and_swap
11237 @findex __sync_val_compare_and_swap
11238 These built-in functions perform an atomic compare and swap.
11239 That is, if the current
11240 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
11241 @code{*@var{ptr}}.
11242
11243 The ``bool'' version returns @code{true} if the comparison is successful and
11244 @var{newval} is written. The ``val'' version returns the contents
11245 of @code{*@var{ptr}} before the operation.
11246
11247 @item __sync_synchronize (...)
11248 @findex __sync_synchronize
11249 This built-in function issues a full memory barrier.
11250
11251 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
11252 @findex __sync_lock_test_and_set
11253 This built-in function, as described by Intel, is not a traditional test-and-set
11254 operation, but rather an atomic exchange operation. It writes @var{value}
11255 into @code{*@var{ptr}}, and returns the previous contents of
11256 @code{*@var{ptr}}.
11257
11258 Many targets have only minimal support for such locks, and do not support
11259 a full exchange operation. In this case, a target may support reduced
11260 functionality here by which the @emph{only} valid value to store is the
11261 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
11262 is implementation defined.
11263
11264 This built-in function is not a full barrier,
11265 but rather an @dfn{acquire barrier}.
11266 This means that references after the operation cannot move to (or be
11267 speculated to) before the operation, but previous memory stores may not
11268 be globally visible yet, and previous memory loads may not yet be
11269 satisfied.
11270
11271 @item void __sync_lock_release (@var{type} *ptr, ...)
11272 @findex __sync_lock_release
11273 This built-in function releases the lock acquired by
11274 @code{__sync_lock_test_and_set}.
11275 Normally this means writing the constant 0 to @code{*@var{ptr}}.
11276
11277 This built-in function is not a full barrier,
11278 but rather a @dfn{release barrier}.
11279 This means that all previous memory stores are globally visible, and all
11280 previous memory loads have been satisfied, but following memory reads
11281 are not prevented from being speculated to before the barrier.
11282 @end table
11283
11284 @node __atomic Builtins
11285 @section Built-in Functions for Memory Model Aware Atomic Operations
11286
11287 The following built-in functions approximately match the requirements
11288 for the C++11 memory model. They are all
11289 identified by being prefixed with @samp{__atomic} and most are
11290 overloaded so that they work with multiple types.
11291
11292 These functions are intended to replace the legacy @samp{__sync}
11293 builtins. The main difference is that the memory order that is requested
11294 is a parameter to the functions. New code should always use the
11295 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
11296
11297 Note that the @samp{__atomic} builtins assume that programs will
11298 conform to the C++11 memory model. In particular, they assume
11299 that programs are free of data races. See the C++11 standard for
11300 detailed requirements.
11301
11302 The @samp{__atomic} builtins can be used with any integral scalar or
11303 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
11304 types are also allowed if @samp{__int128} (@pxref{__int128}) is
11305 supported by the architecture.
11306
11307 The four non-arithmetic functions (load, store, exchange, and
11308 compare_exchange) all have a generic version as well. This generic
11309 version works on any data type. It uses the lock-free built-in function
11310 if the specific data type size makes that possible; otherwise, an
11311 external call is left to be resolved at run time. This external call is
11312 the same format with the addition of a @samp{size_t} parameter inserted
11313 as the first parameter indicating the size of the object being pointed to.
11314 All objects must be the same size.
11315
11316 There are 6 different memory orders that can be specified. These map
11317 to the C++11 memory orders with the same names, see the C++11 standard
11318 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
11319 on atomic synchronization} for detailed definitions. Individual
11320 targets may also support additional memory orders for use on specific
11321 architectures. Refer to the target documentation for details of
11322 these.
11323
11324 An atomic operation can both constrain code motion and
11325 be mapped to hardware instructions for synchronization between threads
11326 (e.g., a fence). To which extent this happens is controlled by the
11327 memory orders, which are listed here in approximately ascending order of
11328 strength. The description of each memory order is only meant to roughly
11329 illustrate the effects and is not a specification; see the C++11
11330 memory model for precise semantics.
11331
11332 @table @code
11333 @item __ATOMIC_RELAXED
11334 Implies no inter-thread ordering constraints.
11335 @item __ATOMIC_CONSUME
11336 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
11337 memory order because of a deficiency in C++11's semantics for
11338 @code{memory_order_consume}.
11339 @item __ATOMIC_ACQUIRE
11340 Creates an inter-thread happens-before constraint from the release (or
11341 stronger) semantic store to this acquire load. Can prevent hoisting
11342 of code to before the operation.
11343 @item __ATOMIC_RELEASE
11344 Creates an inter-thread happens-before constraint to acquire (or stronger)
11345 semantic loads that read from this release store. Can prevent sinking
11346 of code to after the operation.
11347 @item __ATOMIC_ACQ_REL
11348 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
11349 @code{__ATOMIC_RELEASE}.
11350 @item __ATOMIC_SEQ_CST
11351 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
11352 @end table
11353
11354 Note that in the C++11 memory model, @emph{fences} (e.g.,
11355 @samp{__atomic_thread_fence}) take effect in combination with other
11356 atomic operations on specific memory locations (e.g., atomic loads);
11357 operations on specific memory locations do not necessarily affect other
11358 operations in the same way.
11359
11360 Target architectures are encouraged to provide their own patterns for
11361 each of the atomic built-in functions. If no target is provided, the original
11362 non-memory model set of @samp{__sync} atomic built-in functions are
11363 used, along with any required synchronization fences surrounding it in
11364 order to achieve the proper behavior. Execution in this case is subject
11365 to the same restrictions as those built-in functions.
11366
11367 If there is no pattern or mechanism to provide a lock-free instruction
11368 sequence, a call is made to an external routine with the same parameters
11369 to be resolved at run time.
11370
11371 When implementing patterns for these built-in functions, the memory order
11372 parameter can be ignored as long as the pattern implements the most
11373 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
11374 orders execute correctly with this memory order but they may not execute as
11375 efficiently as they could with a more appropriate implementation of the
11376 relaxed requirements.
11377
11378 Note that the C++11 standard allows for the memory order parameter to be
11379 determined at run time rather than at compile time. These built-in
11380 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
11381 than invoke a runtime library call or inline a switch statement. This is
11382 standard compliant, safe, and the simplest approach for now.
11383
11384 The memory order parameter is a signed int, but only the lower 16 bits are
11385 reserved for the memory order. The remainder of the signed int is reserved
11386 for target use and should be 0. Use of the predefined atomic values
11387 ensures proper usage.
11388
11389 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
11390 This built-in function implements an atomic load operation. It returns the
11391 contents of @code{*@var{ptr}}.
11392
11393 The valid memory order variants are
11394 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
11395 and @code{__ATOMIC_CONSUME}.
11396
11397 @end deftypefn
11398
11399 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
11400 This is the generic version of an atomic load. It returns the
11401 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
11402
11403 @end deftypefn
11404
11405 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
11406 This built-in function implements an atomic store operation. It writes
11407 @code{@var{val}} into @code{*@var{ptr}}.
11408
11409 The valid memory order variants are
11410 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
11411
11412 @end deftypefn
11413
11414 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
11415 This is the generic version of an atomic store. It stores the value
11416 of @code{*@var{val}} into @code{*@var{ptr}}.
11417
11418 @end deftypefn
11419
11420 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
11421 This built-in function implements an atomic exchange operation. It writes
11422 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
11423 @code{*@var{ptr}}.
11424
11425 The valid memory order variants are
11426 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
11427 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
11428
11429 @end deftypefn
11430
11431 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
11432 This is the generic version of an atomic exchange. It stores the
11433 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
11434 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
11435
11436 @end deftypefn
11437
11438 @deftypefn {Built-in Function} bool __atomic_compare_exchange_n (@var{type} *ptr, @var{type} *expected, @var{type} desired, bool weak, int success_memorder, int failure_memorder)
11439 This built-in function implements an atomic compare and exchange operation.
11440 This compares the contents of @code{*@var{ptr}} with the contents of
11441 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
11442 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
11443 equal, the operation is a @emph{read} and the current contents of
11444 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is @code{true}
11445 for weak compare_exchange, which may fail spuriously, and @code{false} for
11446 the strong variation, which never fails spuriously. Many targets
11447 only offer the strong variation and ignore the parameter. When in doubt, use
11448 the strong variation.
11449
11450 If @var{desired} is written into @code{*@var{ptr}} then @code{true} is returned
11451 and memory is affected according to the
11452 memory order specified by @var{success_memorder}. There are no
11453 restrictions on what memory order can be used here.
11454
11455 Otherwise, @code{false} is returned and memory is affected according
11456 to @var{failure_memorder}. This memory order cannot be
11457 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
11458 stronger order than that specified by @var{success_memorder}.
11459
11460 @end deftypefn
11461
11462 @deftypefn {Built-in Function} bool __atomic_compare_exchange (@var{type} *ptr, @var{type} *expected, @var{type} *desired, bool weak, int success_memorder, int failure_memorder)
11463 This built-in function implements the generic version of
11464 @code{__atomic_compare_exchange}. The function is virtually identical to
11465 @code{__atomic_compare_exchange_n}, except the desired value is also a
11466 pointer.
11467
11468 @end deftypefn
11469
11470 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
11471 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
11472 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
11473 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
11474 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
11475 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
11476 These built-in functions perform the operation suggested by the name, and
11477 return the result of the operation. Operations on pointer arguments are
11478 performed as if the operands were of the @code{uintptr_t} type. That is,
11479 they are not scaled by the size of the type to which the pointer points.
11480
11481 @smallexample
11482 @{ *ptr @var{op}= val; return *ptr; @}
11483 @{ *ptr = ~(*ptr & val); return *ptr; @} // nand
11484 @end smallexample
11485
11486 The object pointed to by the first argument must be of integer or pointer
11487 type. It must not be a boolean type. All memory orders are valid.
11488
11489 @end deftypefn
11490
11491 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
11492 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
11493 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
11494 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
11495 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
11496 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
11497 These built-in functions perform the operation suggested by the name, and
11498 return the value that had previously been in @code{*@var{ptr}}. Operations
11499 on pointer arguments are performed as if the operands were of
11500 the @code{uintptr_t} type. That is, they are not scaled by the size of
11501 the type to which the pointer points.
11502
11503 @smallexample
11504 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
11505 @{ tmp = *ptr; *ptr = ~(*ptr & val); return tmp; @} // nand
11506 @end smallexample
11507
11508 The same constraints on arguments apply as for the corresponding
11509 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
11510
11511 @end deftypefn
11512
11513 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
11514
11515 This built-in function performs an atomic test-and-set operation on
11516 the byte at @code{*@var{ptr}}. The byte is set to some implementation
11517 defined nonzero ``set'' value and the return value is @code{true} if and only
11518 if the previous contents were ``set''.
11519 It should be only used for operands of type @code{bool} or @code{char}. For
11520 other types only part of the value may be set.
11521
11522 All memory orders are valid.
11523
11524 @end deftypefn
11525
11526 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
11527
11528 This built-in function performs an atomic clear operation on
11529 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
11530 It should be only used for operands of type @code{bool} or @code{char} and
11531 in conjunction with @code{__atomic_test_and_set}.
11532 For other types it may only clear partially. If the type is not @code{bool}
11533 prefer using @code{__atomic_store}.
11534
11535 The valid memory order variants are
11536 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
11537 @code{__ATOMIC_RELEASE}.
11538
11539 @end deftypefn
11540
11541 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
11542
11543 This built-in function acts as a synchronization fence between threads
11544 based on the specified memory order.
11545
11546 All memory orders are valid.
11547
11548 @end deftypefn
11549
11550 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
11551
11552 This built-in function acts as a synchronization fence between a thread
11553 and signal handlers based in the same thread.
11554
11555 All memory orders are valid.
11556
11557 @end deftypefn
11558
11559 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
11560
11561 This built-in function returns @code{true} if objects of @var{size} bytes always
11562 generate lock-free atomic instructions for the target architecture.
11563 @var{size} must resolve to a compile-time constant and the result also
11564 resolves to a compile-time constant.
11565
11566 @var{ptr} is an optional pointer to the object that may be used to determine
11567 alignment. A value of 0 indicates typical alignment should be used. The
11568 compiler may also ignore this parameter.
11569
11570 @smallexample
11571 if (__atomic_always_lock_free (sizeof (long long), 0))
11572 @end smallexample
11573
11574 @end deftypefn
11575
11576 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
11577
11578 This built-in function returns @code{true} if objects of @var{size} bytes always
11579 generate lock-free atomic instructions for the target architecture. If
11580 the built-in function is not known to be lock-free, a call is made to a
11581 runtime routine named @code{__atomic_is_lock_free}.
11582
11583 @var{ptr} is an optional pointer to the object that may be used to determine
11584 alignment. A value of 0 indicates typical alignment should be used. The
11585 compiler may also ignore this parameter.
11586 @end deftypefn
11587
11588 @node Integer Overflow Builtins
11589 @section Built-in Functions to Perform Arithmetic with Overflow Checking
11590
11591 The following built-in functions allow performing simple arithmetic operations
11592 together with checking whether the operations overflowed.
11593
11594 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
11595 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
11596 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
11597 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
11598 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
11599 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
11600 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
11601
11602 These built-in functions promote the first two operands into infinite precision signed
11603 type and perform addition on those promoted operands. The result is then
11604 cast to the type the third pointer argument points to and stored there.
11605 If the stored result is equal to the infinite precision result, the built-in
11606 functions return @code{false}, otherwise they return @code{true}. As the addition is
11607 performed in infinite signed precision, these built-in functions have fully defined
11608 behavior for all argument values.
11609
11610 The first built-in function allows arbitrary integral types for operands and
11611 the result type must be pointer to some integral type other than enumerated or
11612 boolean type, the rest of the built-in functions have explicit integer types.
11613
11614 The compiler will attempt to use hardware instructions to implement
11615 these built-in functions where possible, like conditional jump on overflow
11616 after addition, conditional jump on carry etc.
11617
11618 @end deftypefn
11619
11620 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
11621 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
11622 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
11623 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
11624 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
11625 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
11626 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
11627
11628 These built-in functions are similar to the add overflow checking built-in
11629 functions above, except they perform subtraction, subtract the second argument
11630 from the first one, instead of addition.
11631
11632 @end deftypefn
11633
11634 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
11635 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
11636 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
11637 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
11638 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
11639 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
11640 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
11641
11642 These built-in functions are similar to the add overflow checking built-in
11643 functions above, except they perform multiplication, instead of addition.
11644
11645 @end deftypefn
11646
11647 The following built-in functions allow checking if simple arithmetic operation
11648 would overflow.
11649
11650 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
11651 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
11652 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
11653
11654 These built-in functions are similar to @code{__builtin_add_overflow},
11655 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
11656 they don't store the result of the arithmetic operation anywhere and the
11657 last argument is not a pointer, but some expression with integral type other
11658 than enumerated or boolean type.
11659
11660 The built-in functions promote the first two operands into infinite precision signed type
11661 and perform addition on those promoted operands. The result is then
11662 cast to the type of the third argument. If the cast result is equal to the infinite
11663 precision result, the built-in functions return @code{false}, otherwise they return @code{true}.
11664 The value of the third argument is ignored, just the side effects in the third argument
11665 are evaluated, and no integral argument promotions are performed on the last argument.
11666 If the third argument is a bit-field, the type used for the result cast has the
11667 precision and signedness of the given bit-field, rather than precision and signedness
11668 of the underlying type.
11669
11670 For example, the following macro can be used to portably check, at
11671 compile-time, whether or not adding two constant integers will overflow,
11672 and perform the addition only when it is known to be safe and not to trigger
11673 a @option{-Woverflow} warning.
11674
11675 @smallexample
11676 #define INT_ADD_OVERFLOW_P(a, b) \
11677 __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
11678
11679 enum @{
11680 A = INT_MAX, B = 3,
11681 C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
11682 D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
11683 @};
11684 @end smallexample
11685
11686 The compiler will attempt to use hardware instructions to implement
11687 these built-in functions where possible, like conditional jump on overflow
11688 after addition, conditional jump on carry etc.
11689
11690 @end deftypefn
11691
11692 @node x86 specific memory model extensions for transactional memory
11693 @section x86-Specific Memory Model Extensions for Transactional Memory
11694
11695 The x86 architecture supports additional memory ordering flags
11696 to mark critical sections for hardware lock elision.
11697 These must be specified in addition to an existing memory order to
11698 atomic intrinsics.
11699
11700 @table @code
11701 @item __ATOMIC_HLE_ACQUIRE
11702 Start lock elision on a lock variable.
11703 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
11704 @item __ATOMIC_HLE_RELEASE
11705 End lock elision on a lock variable.
11706 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
11707 @end table
11708
11709 When a lock acquire fails, it is required for good performance to abort
11710 the transaction quickly. This can be done with a @code{_mm_pause}.
11711
11712 @smallexample
11713 #include <immintrin.h> // For _mm_pause
11714
11715 int lockvar;
11716
11717 /* Acquire lock with lock elision */
11718 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
11719 _mm_pause(); /* Abort failed transaction */
11720 ...
11721 /* Free lock with lock elision */
11722 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
11723 @end smallexample
11724
11725 @node Object Size Checking
11726 @section Object Size Checking Built-in Functions
11727 @findex __builtin_object_size
11728 @findex __builtin___memcpy_chk
11729 @findex __builtin___mempcpy_chk
11730 @findex __builtin___memmove_chk
11731 @findex __builtin___memset_chk
11732 @findex __builtin___strcpy_chk
11733 @findex __builtin___stpcpy_chk
11734 @findex __builtin___strncpy_chk
11735 @findex __builtin___strcat_chk
11736 @findex __builtin___strncat_chk
11737 @findex __builtin___sprintf_chk
11738 @findex __builtin___snprintf_chk
11739 @findex __builtin___vsprintf_chk
11740 @findex __builtin___vsnprintf_chk
11741 @findex __builtin___printf_chk
11742 @findex __builtin___vprintf_chk
11743 @findex __builtin___fprintf_chk
11744 @findex __builtin___vfprintf_chk
11745
11746 GCC implements a limited buffer overflow protection mechanism that can
11747 prevent some buffer overflow attacks by determining the sizes of objects
11748 into which data is about to be written and preventing the writes when
11749 the size isn't sufficient. The built-in functions described below yield
11750 the best results when used together and when optimization is enabled.
11751 For example, to detect object sizes across function boundaries or to
11752 follow pointer assignments through non-trivial control flow they rely
11753 on various optimization passes enabled with @option{-O2}. However, to
11754 a limited extent, they can be used without optimization as well.
11755
11756 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
11757 is a built-in construct that returns a constant number of bytes from
11758 @var{ptr} to the end of the object @var{ptr} pointer points to
11759 (if known at compile time). To determine the sizes of dynamically allocated
11760 objects the function relies on the allocation functions called to obtain
11761 the storage to be declared with the @code{alloc_size} attribute (@xref{Common
11762 Function Attributes}). @code{__builtin_object_size} never evaluates
11763 its arguments for side effects. If there are any side effects in them, it
11764 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
11765 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
11766 point to and all of them are known at compile time, the returned number
11767 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
11768 0 and minimum if nonzero. If it is not possible to determine which objects
11769 @var{ptr} points to at compile time, @code{__builtin_object_size} should
11770 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
11771 for @var{type} 2 or 3.
11772
11773 @var{type} is an integer constant from 0 to 3. If the least significant
11774 bit is clear, objects are whole variables, if it is set, a closest
11775 surrounding subobject is considered the object a pointer points to.
11776 The second bit determines if maximum or minimum of remaining bytes
11777 is computed.
11778
11779 @smallexample
11780 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
11781 char *p = &var.buf1[1], *q = &var.b;
11782
11783 /* Here the object p points to is var. */
11784 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
11785 /* The subobject p points to is var.buf1. */
11786 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
11787 /* The object q points to is var. */
11788 assert (__builtin_object_size (q, 0)
11789 == (char *) (&var + 1) - (char *) &var.b);
11790 /* The subobject q points to is var.b. */
11791 assert (__builtin_object_size (q, 1) == sizeof (var.b));
11792 @end smallexample
11793 @end deftypefn
11794
11795 There are built-in functions added for many common string operation
11796 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
11797 built-in is provided. This built-in has an additional last argument,
11798 which is the number of bytes remaining in the object the @var{dest}
11799 argument points to or @code{(size_t) -1} if the size is not known.
11800
11801 The built-in functions are optimized into the normal string functions
11802 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
11803 it is known at compile time that the destination object will not
11804 be overflowed. If the compiler can determine at compile time that the
11805 object will always be overflowed, it issues a warning.
11806
11807 The intended use can be e.g.@:
11808
11809 @smallexample
11810 #undef memcpy
11811 #define bos0(dest) __builtin_object_size (dest, 0)
11812 #define memcpy(dest, src, n) \
11813 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
11814
11815 char *volatile p;
11816 char buf[10];
11817 /* It is unknown what object p points to, so this is optimized
11818 into plain memcpy - no checking is possible. */
11819 memcpy (p, "abcde", n);
11820 /* Destination is known and length too. It is known at compile
11821 time there will be no overflow. */
11822 memcpy (&buf[5], "abcde", 5);
11823 /* Destination is known, but the length is not known at compile time.
11824 This will result in __memcpy_chk call that can check for overflow
11825 at run time. */
11826 memcpy (&buf[5], "abcde", n);
11827 /* Destination is known and it is known at compile time there will
11828 be overflow. There will be a warning and __memcpy_chk call that
11829 will abort the program at run time. */
11830 memcpy (&buf[6], "abcde", 5);
11831 @end smallexample
11832
11833 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
11834 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
11835 @code{strcat} and @code{strncat}.
11836
11837 There are also checking built-in functions for formatted output functions.
11838 @smallexample
11839 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
11840 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
11841 const char *fmt, ...);
11842 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
11843 va_list ap);
11844 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
11845 const char *fmt, va_list ap);
11846 @end smallexample
11847
11848 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
11849 etc.@: functions and can contain implementation specific flags on what
11850 additional security measures the checking function might take, such as
11851 handling @code{%n} differently.
11852
11853 The @var{os} argument is the object size @var{s} points to, like in the
11854 other built-in functions. There is a small difference in the behavior
11855 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
11856 optimized into the non-checking functions only if @var{flag} is 0, otherwise
11857 the checking function is called with @var{os} argument set to
11858 @code{(size_t) -1}.
11859
11860 In addition to this, there are checking built-in functions
11861 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
11862 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
11863 These have just one additional argument, @var{flag}, right before
11864 format string @var{fmt}. If the compiler is able to optimize them to
11865 @code{fputc} etc.@: functions, it does, otherwise the checking function
11866 is called and the @var{flag} argument passed to it.
11867
11868 @node Other Builtins
11869 @section Other Built-in Functions Provided by GCC
11870 @cindex built-in functions
11871 @findex __builtin_alloca
11872 @findex __builtin_alloca_with_align
11873 @findex __builtin_alloca_with_align_and_max
11874 @findex __builtin_call_with_static_chain
11875 @findex __builtin_extend_pointer
11876 @findex __builtin_fpclassify
11877 @findex __builtin_has_attribute
11878 @findex __builtin_isfinite
11879 @findex __builtin_isnormal
11880 @findex __builtin_isgreater
11881 @findex __builtin_isgreaterequal
11882 @findex __builtin_isinf_sign
11883 @findex __builtin_isless
11884 @findex __builtin_islessequal
11885 @findex __builtin_islessgreater
11886 @findex __builtin_isunordered
11887 @findex __builtin_object_size
11888 @findex __builtin_powi
11889 @findex __builtin_powif
11890 @findex __builtin_powil
11891 @findex __builtin_speculation_safe_value
11892 @findex _Exit
11893 @findex _exit
11894 @findex abort
11895 @findex abs
11896 @findex acos
11897 @findex acosf
11898 @findex acosh
11899 @findex acoshf
11900 @findex acoshl
11901 @findex acosl
11902 @findex alloca
11903 @findex asin
11904 @findex asinf
11905 @findex asinh
11906 @findex asinhf
11907 @findex asinhl
11908 @findex asinl
11909 @findex atan
11910 @findex atan2
11911 @findex atan2f
11912 @findex atan2l
11913 @findex atanf
11914 @findex atanh
11915 @findex atanhf
11916 @findex atanhl
11917 @findex atanl
11918 @findex bcmp
11919 @findex bzero
11920 @findex cabs
11921 @findex cabsf
11922 @findex cabsl
11923 @findex cacos
11924 @findex cacosf
11925 @findex cacosh
11926 @findex cacoshf
11927 @findex cacoshl
11928 @findex cacosl
11929 @findex calloc
11930 @findex carg
11931 @findex cargf
11932 @findex cargl
11933 @findex casin
11934 @findex casinf
11935 @findex casinh
11936 @findex casinhf
11937 @findex casinhl
11938 @findex casinl
11939 @findex catan
11940 @findex catanf
11941 @findex catanh
11942 @findex catanhf
11943 @findex catanhl
11944 @findex catanl
11945 @findex cbrt
11946 @findex cbrtf
11947 @findex cbrtl
11948 @findex ccos
11949 @findex ccosf
11950 @findex ccosh
11951 @findex ccoshf
11952 @findex ccoshl
11953 @findex ccosl
11954 @findex ceil
11955 @findex ceilf
11956 @findex ceill
11957 @findex cexp
11958 @findex cexpf
11959 @findex cexpl
11960 @findex cimag
11961 @findex cimagf
11962 @findex cimagl
11963 @findex clog
11964 @findex clogf
11965 @findex clogl
11966 @findex clog10
11967 @findex clog10f
11968 @findex clog10l
11969 @findex conj
11970 @findex conjf
11971 @findex conjl
11972 @findex copysign
11973 @findex copysignf
11974 @findex copysignl
11975 @findex cos
11976 @findex cosf
11977 @findex cosh
11978 @findex coshf
11979 @findex coshl
11980 @findex cosl
11981 @findex cpow
11982 @findex cpowf
11983 @findex cpowl
11984 @findex cproj
11985 @findex cprojf
11986 @findex cprojl
11987 @findex creal
11988 @findex crealf
11989 @findex creall
11990 @findex csin
11991 @findex csinf
11992 @findex csinh
11993 @findex csinhf
11994 @findex csinhl
11995 @findex csinl
11996 @findex csqrt
11997 @findex csqrtf
11998 @findex csqrtl
11999 @findex ctan
12000 @findex ctanf
12001 @findex ctanh
12002 @findex ctanhf
12003 @findex ctanhl
12004 @findex ctanl
12005 @findex dcgettext
12006 @findex dgettext
12007 @findex drem
12008 @findex dremf
12009 @findex dreml
12010 @findex erf
12011 @findex erfc
12012 @findex erfcf
12013 @findex erfcl
12014 @findex erff
12015 @findex erfl
12016 @findex exit
12017 @findex exp
12018 @findex exp10
12019 @findex exp10f
12020 @findex exp10l
12021 @findex exp2
12022 @findex exp2f
12023 @findex exp2l
12024 @findex expf
12025 @findex expl
12026 @findex expm1
12027 @findex expm1f
12028 @findex expm1l
12029 @findex fabs
12030 @findex fabsf
12031 @findex fabsl
12032 @findex fdim
12033 @findex fdimf
12034 @findex fdiml
12035 @findex ffs
12036 @findex floor
12037 @findex floorf
12038 @findex floorl
12039 @findex fma
12040 @findex fmaf
12041 @findex fmal
12042 @findex fmax
12043 @findex fmaxf
12044 @findex fmaxl
12045 @findex fmin
12046 @findex fminf
12047 @findex fminl
12048 @findex fmod
12049 @findex fmodf
12050 @findex fmodl
12051 @findex fprintf
12052 @findex fprintf_unlocked
12053 @findex fputs
12054 @findex fputs_unlocked
12055 @findex frexp
12056 @findex frexpf
12057 @findex frexpl
12058 @findex fscanf
12059 @findex gamma
12060 @findex gammaf
12061 @findex gammal
12062 @findex gamma_r
12063 @findex gammaf_r
12064 @findex gammal_r
12065 @findex gettext
12066 @findex hypot
12067 @findex hypotf
12068 @findex hypotl
12069 @findex ilogb
12070 @findex ilogbf
12071 @findex ilogbl
12072 @findex imaxabs
12073 @findex index
12074 @findex isalnum
12075 @findex isalpha
12076 @findex isascii
12077 @findex isblank
12078 @findex iscntrl
12079 @findex isdigit
12080 @findex isgraph
12081 @findex islower
12082 @findex isprint
12083 @findex ispunct
12084 @findex isspace
12085 @findex isupper
12086 @findex iswalnum
12087 @findex iswalpha
12088 @findex iswblank
12089 @findex iswcntrl
12090 @findex iswdigit
12091 @findex iswgraph
12092 @findex iswlower
12093 @findex iswprint
12094 @findex iswpunct
12095 @findex iswspace
12096 @findex iswupper
12097 @findex iswxdigit
12098 @findex isxdigit
12099 @findex j0
12100 @findex j0f
12101 @findex j0l
12102 @findex j1
12103 @findex j1f
12104 @findex j1l
12105 @findex jn
12106 @findex jnf
12107 @findex jnl
12108 @findex labs
12109 @findex ldexp
12110 @findex ldexpf
12111 @findex ldexpl
12112 @findex lgamma
12113 @findex lgammaf
12114 @findex lgammal
12115 @findex lgamma_r
12116 @findex lgammaf_r
12117 @findex lgammal_r
12118 @findex llabs
12119 @findex llrint
12120 @findex llrintf
12121 @findex llrintl
12122 @findex llround
12123 @findex llroundf
12124 @findex llroundl
12125 @findex log
12126 @findex log10
12127 @findex log10f
12128 @findex log10l
12129 @findex log1p
12130 @findex log1pf
12131 @findex log1pl
12132 @findex log2
12133 @findex log2f
12134 @findex log2l
12135 @findex logb
12136 @findex logbf
12137 @findex logbl
12138 @findex logf
12139 @findex logl
12140 @findex lrint
12141 @findex lrintf
12142 @findex lrintl
12143 @findex lround
12144 @findex lroundf
12145 @findex lroundl
12146 @findex malloc
12147 @findex memchr
12148 @findex memcmp
12149 @findex memcpy
12150 @findex mempcpy
12151 @findex memset
12152 @findex modf
12153 @findex modff
12154 @findex modfl
12155 @findex nearbyint
12156 @findex nearbyintf
12157 @findex nearbyintl
12158 @findex nextafter
12159 @findex nextafterf
12160 @findex nextafterl
12161 @findex nexttoward
12162 @findex nexttowardf
12163 @findex nexttowardl
12164 @findex pow
12165 @findex pow10
12166 @findex pow10f
12167 @findex pow10l
12168 @findex powf
12169 @findex powl
12170 @findex printf
12171 @findex printf_unlocked
12172 @findex putchar
12173 @findex puts
12174 @findex remainder
12175 @findex remainderf
12176 @findex remainderl
12177 @findex remquo
12178 @findex remquof
12179 @findex remquol
12180 @findex rindex
12181 @findex rint
12182 @findex rintf
12183 @findex rintl
12184 @findex round
12185 @findex roundf
12186 @findex roundl
12187 @findex scalb
12188 @findex scalbf
12189 @findex scalbl
12190 @findex scalbln
12191 @findex scalblnf
12192 @findex scalblnf
12193 @findex scalbn
12194 @findex scalbnf
12195 @findex scanfnl
12196 @findex signbit
12197 @findex signbitf
12198 @findex signbitl
12199 @findex signbitd32
12200 @findex signbitd64
12201 @findex signbitd128
12202 @findex significand
12203 @findex significandf
12204 @findex significandl
12205 @findex sin
12206 @findex sincos
12207 @findex sincosf
12208 @findex sincosl
12209 @findex sinf
12210 @findex sinh
12211 @findex sinhf
12212 @findex sinhl
12213 @findex sinl
12214 @findex snprintf
12215 @findex sprintf
12216 @findex sqrt
12217 @findex sqrtf
12218 @findex sqrtl
12219 @findex sscanf
12220 @findex stpcpy
12221 @findex stpncpy
12222 @findex strcasecmp
12223 @findex strcat
12224 @findex strchr
12225 @findex strcmp
12226 @findex strcpy
12227 @findex strcspn
12228 @findex strdup
12229 @findex strfmon
12230 @findex strftime
12231 @findex strlen
12232 @findex strncasecmp
12233 @findex strncat
12234 @findex strncmp
12235 @findex strncpy
12236 @findex strndup
12237 @findex strnlen
12238 @findex strpbrk
12239 @findex strrchr
12240 @findex strspn
12241 @findex strstr
12242 @findex tan
12243 @findex tanf
12244 @findex tanh
12245 @findex tanhf
12246 @findex tanhl
12247 @findex tanl
12248 @findex tgamma
12249 @findex tgammaf
12250 @findex tgammal
12251 @findex toascii
12252 @findex tolower
12253 @findex toupper
12254 @findex towlower
12255 @findex towupper
12256 @findex trunc
12257 @findex truncf
12258 @findex truncl
12259 @findex vfprintf
12260 @findex vfscanf
12261 @findex vprintf
12262 @findex vscanf
12263 @findex vsnprintf
12264 @findex vsprintf
12265 @findex vsscanf
12266 @findex y0
12267 @findex y0f
12268 @findex y0l
12269 @findex y1
12270 @findex y1f
12271 @findex y1l
12272 @findex yn
12273 @findex ynf
12274 @findex ynl
12275
12276 GCC provides a large number of built-in functions other than the ones
12277 mentioned above. Some of these are for internal use in the processing
12278 of exceptions or variable-length argument lists and are not
12279 documented here because they may change from time to time; we do not
12280 recommend general use of these functions.
12281
12282 The remaining functions are provided for optimization purposes.
12283
12284 With the exception of built-ins that have library equivalents such as
12285 the standard C library functions discussed below, or that expand to
12286 library calls, GCC built-in functions are always expanded inline and
12287 thus do not have corresponding entry points and their address cannot
12288 be obtained. Attempting to use them in an expression other than
12289 a function call results in a compile-time error.
12290
12291 @opindex fno-builtin
12292 GCC includes built-in versions of many of the functions in the standard
12293 C library. These functions come in two forms: one whose names start with
12294 the @code{__builtin_} prefix, and the other without. Both forms have the
12295 same type (including prototype), the same address (when their address is
12296 taken), and the same meaning as the C library functions even if you specify
12297 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
12298 functions are only optimized in certain cases; if they are not optimized in
12299 a particular case, a call to the library function is emitted.
12300
12301 @opindex ansi
12302 @opindex std
12303 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
12304 @option{-std=c99} or @option{-std=c11}), the functions
12305 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
12306 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
12307 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
12308 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
12309 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
12310 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
12311 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
12312 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
12313 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
12314 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
12315 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
12316 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
12317 @code{signbitd64}, @code{signbitd128}, @code{significandf},
12318 @code{significandl}, @code{significand}, @code{sincosf},
12319 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
12320 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
12321 @code{strndup}, @code{strnlen}, @code{toascii}, @code{y0f}, @code{y0l},
12322 @code{y0}, @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
12323 @code{yn}
12324 may be handled as built-in functions.
12325 All these functions have corresponding versions
12326 prefixed with @code{__builtin_}, which may be used even in strict C90
12327 mode.
12328
12329 The ISO C99 functions
12330 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
12331 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
12332 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
12333 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
12334 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
12335 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
12336 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
12337 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
12338 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
12339 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
12340 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
12341 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
12342 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
12343 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
12344 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
12345 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
12346 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
12347 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
12348 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
12349 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
12350 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
12351 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
12352 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
12353 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
12354 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
12355 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
12356 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
12357 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
12358 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
12359 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
12360 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
12361 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
12362 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
12363 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
12364 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
12365 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
12366 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
12367 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
12368 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
12369 are handled as built-in functions
12370 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
12371
12372 There are also built-in versions of the ISO C99 functions
12373 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
12374 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
12375 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
12376 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
12377 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
12378 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
12379 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
12380 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
12381 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
12382 that are recognized in any mode since ISO C90 reserves these names for
12383 the purpose to which ISO C99 puts them. All these functions have
12384 corresponding versions prefixed with @code{__builtin_}.
12385
12386 There are also built-in functions @code{__builtin_fabsf@var{n}},
12387 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
12388 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
12389 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
12390 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
12391 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
12392
12393 There are also GNU extension functions @code{clog10}, @code{clog10f} and
12394 @code{clog10l} which names are reserved by ISO C99 for future use.
12395 All these functions have versions prefixed with @code{__builtin_}.
12396
12397 The ISO C94 functions
12398 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
12399 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
12400 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
12401 @code{towupper}
12402 are handled as built-in functions
12403 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
12404
12405 The ISO C90 functions
12406 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
12407 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
12408 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
12409 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
12410 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
12411 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
12412 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
12413 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
12414 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
12415 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
12416 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
12417 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
12418 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
12419 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
12420 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
12421 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
12422 are all recognized as built-in functions unless
12423 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
12424 is specified for an individual function). All of these functions have
12425 corresponding versions prefixed with @code{__builtin_}.
12426
12427 GCC provides built-in versions of the ISO C99 floating-point comparison
12428 macros that avoid raising exceptions for unordered operands. They have
12429 the same names as the standard macros ( @code{isgreater},
12430 @code{isgreaterequal}, @code{isless}, @code{islessequal},
12431 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
12432 prefixed. We intend for a library implementor to be able to simply
12433 @code{#define} each standard macro to its built-in equivalent.
12434 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
12435 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
12436 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
12437 built-in functions appear both with and without the @code{__builtin_} prefix.
12438
12439 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
12440 The @code{__builtin_alloca} function must be called at block scope.
12441 The function allocates an object @var{size} bytes large on the stack
12442 of the calling function. The object is aligned on the default stack
12443 alignment boundary for the target determined by the
12444 @code{__BIGGEST_ALIGNMENT__} macro. The @code{__builtin_alloca}
12445 function returns a pointer to the first byte of the allocated object.
12446 The lifetime of the allocated object ends just before the calling
12447 function returns to its caller. This is so even when
12448 @code{__builtin_alloca} is called within a nested block.
12449
12450 For example, the following function allocates eight objects of @code{n}
12451 bytes each on the stack, storing a pointer to each in consecutive elements
12452 of the array @code{a}. It then passes the array to function @code{g}
12453 which can safely use the storage pointed to by each of the array elements.
12454
12455 @smallexample
12456 void f (unsigned n)
12457 @{
12458 void *a [8];
12459 for (int i = 0; i != 8; ++i)
12460 a [i] = __builtin_alloca (n);
12461
12462 g (a, n); // @r{safe}
12463 @}
12464 @end smallexample
12465
12466 Since the @code{__builtin_alloca} function doesn't validate its argument
12467 it is the responsibility of its caller to make sure the argument doesn't
12468 cause it to exceed the stack size limit.
12469 The @code{__builtin_alloca} function is provided to make it possible to
12470 allocate on the stack arrays of bytes with an upper bound that may be
12471 computed at run time. Since C99 Variable Length Arrays offer
12472 similar functionality under a portable, more convenient, and safer
12473 interface they are recommended instead, in both C99 and C++ programs
12474 where GCC provides them as an extension.
12475 @xref{Variable Length}, for details.
12476
12477 @end deftypefn
12478
12479 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
12480 The @code{__builtin_alloca_with_align} function must be called at block
12481 scope. The function allocates an object @var{size} bytes large on
12482 the stack of the calling function. The allocated object is aligned on
12483 the boundary specified by the argument @var{alignment} whose unit is given
12484 in bits (not bytes). The @var{size} argument must be positive and not
12485 exceed the stack size limit. The @var{alignment} argument must be a constant
12486 integer expression that evaluates to a power of 2 greater than or equal to
12487 @code{CHAR_BIT} and less than some unspecified maximum. Invocations
12488 with other values are rejected with an error indicating the valid bounds.
12489 The function returns a pointer to the first byte of the allocated object.
12490 The lifetime of the allocated object ends at the end of the block in which
12491 the function was called. The allocated storage is released no later than
12492 just before the calling function returns to its caller, but may be released
12493 at the end of the block in which the function was called.
12494
12495 For example, in the following function the call to @code{g} is unsafe
12496 because when @code{overalign} is non-zero, the space allocated by
12497 @code{__builtin_alloca_with_align} may have been released at the end
12498 of the @code{if} statement in which it was called.
12499
12500 @smallexample
12501 void f (unsigned n, bool overalign)
12502 @{
12503 void *p;
12504 if (overalign)
12505 p = __builtin_alloca_with_align (n, 64 /* bits */);
12506 else
12507 p = __builtin_alloc (n);
12508
12509 g (p, n); // @r{unsafe}
12510 @}
12511 @end smallexample
12512
12513 Since the @code{__builtin_alloca_with_align} function doesn't validate its
12514 @var{size} argument it is the responsibility of its caller to make sure
12515 the argument doesn't cause it to exceed the stack size limit.
12516 The @code{__builtin_alloca_with_align} function is provided to make
12517 it possible to allocate on the stack overaligned arrays of bytes with
12518 an upper bound that may be computed at run time. Since C99
12519 Variable Length Arrays offer the same functionality under
12520 a portable, more convenient, and safer interface they are recommended
12521 instead, in both C99 and C++ programs where GCC provides them as
12522 an extension. @xref{Variable Length}, for details.
12523
12524 @end deftypefn
12525
12526 @deftypefn {Built-in Function} void *__builtin_alloca_with_align_and_max (size_t size, size_t alignment, size_t max_size)
12527 Similar to @code{__builtin_alloca_with_align} but takes an extra argument
12528 specifying an upper bound for @var{size} in case its value cannot be computed
12529 at compile time, for use by @option{-fstack-usage}, @option{-Wstack-usage}
12530 and @option{-Walloca-larger-than}. @var{max_size} must be a constant integer
12531 expression, it has no effect on code generation and no attempt is made to
12532 check its compatibility with @var{size}.
12533
12534 @end deftypefn
12535
12536 @deftypefn {Built-in Function} bool __builtin_has_attribute (@var{type-or-expression}, @var{attribute})
12537 The @code{__builtin_has_attribute} function evaluates to an integer constant
12538 expression equal to @code{true} if the symbol or type referenced by
12539 the @var{type-or-expression} argument has been declared with
12540 the @var{attribute} referenced by the second argument. Neither argument
12541 is evaluated. The @var{type-or-expression} argument is subject to the same
12542 restrictions as the argument to @code{typeof} (@pxref{Typeof}). The
12543 @var{attribute} argument is an attribute name optionally followed by
12544 a comma-separated list of arguments enclosed in parentheses. Both forms
12545 of attribute names---with and without double leading and trailing
12546 underscores---are recognized. @xref{Attribute Syntax} for details.
12547 When no attribute arguments are specified for an attribute that expects
12548 one or more arguments the function returns @code{true} if
12549 @var{type-or-expression} has been declared with the attribute regardless
12550 of the attribute argument values. Arguments provided for an attribute
12551 that expects some are validated and matched up to the provided number.
12552 The function returns @code{true} if all provided arguments match. For
12553 example, the first call to the function below evaluates to @code{true}
12554 because @code{x} is declared with the @code{aligned} attribute but
12555 the second call evaluates to @code{false} because @code{x} is declared
12556 @code{aligned (8)} and not @code{aligned (4)}.
12557
12558 @smallexample
12559 __attribute__ ((aligned (8))) int x;
12560 _Static_assert (__builtin_has_attribute (x, aligned), "aligned");
12561 _Static_assert (!__builtin_has_attribute (x, aligned (4)), "aligned (4)");
12562 @end smallexample
12563
12564 Due to a limitation the @code{__builtin_has_attribute} function returns
12565 @code{false} for the @code{mode} attribute even if the type or variable
12566 referenced by the @var{type-or-expression} argument was declared with one.
12567 The function is also not supported with labels, and in C with enumerators.
12568
12569 Note that unlike the @code{__has_attribute} preprocessor operator which
12570 is suitable for use in @code{#if} preprocessing directives
12571 @code{__builtin_has_attribute} is an intrinsic function that is not
12572 recognized in such contexts.
12573
12574 @end deftypefn
12575
12576 @deftypefn {Built-in Function} @var{type} __builtin_speculation_safe_value (@var{type} val, @var{type} failval)
12577
12578 This built-in function can be used to help mitigate against unsafe
12579 speculative execution. @var{type} may be any integral type or any
12580 pointer type.
12581
12582 @enumerate
12583 @item
12584 If the CPU is not speculatively executing the code, then @var{val}
12585 is returned.
12586 @item
12587 If the CPU is executing speculatively then either:
12588 @itemize
12589 @item
12590 The function may cause execution to pause until it is known that the
12591 code is no-longer being executed speculatively (in which case
12592 @var{val} can be returned, as above); or
12593 @item
12594 The function may use target-dependent speculation tracking state to cause
12595 @var{failval} to be returned when it is known that speculative
12596 execution has incorrectly predicted a conditional branch operation.
12597 @end itemize
12598 @end enumerate
12599
12600 The second argument, @var{failval}, is optional and defaults to zero
12601 if omitted.
12602
12603 GCC defines the preprocessor macro
12604 @code{__HAVE_BUILTIN_SPECULATION_SAFE_VALUE} for targets that have been
12605 updated to support this builtin.
12606
12607 The built-in function can be used where a variable appears to be used in a
12608 safe way, but the CPU, due to speculative execution may temporarily ignore
12609 the bounds checks. Consider, for example, the following function:
12610
12611 @smallexample
12612 int array[500];
12613 int f (unsigned untrusted_index)
12614 @{
12615 if (untrusted_index < 500)
12616 return array[untrusted_index];
12617 return 0;
12618 @}
12619 @end smallexample
12620
12621 If the function is called repeatedly with @code{untrusted_index} less
12622 than the limit of 500, then a branch predictor will learn that the
12623 block of code that returns a value stored in @code{array} will be
12624 executed. If the function is subsequently called with an
12625 out-of-range value it will still try to execute that block of code
12626 first until the CPU determines that the prediction was incorrect
12627 (the CPU will unwind any incorrect operations at that point).
12628 However, depending on how the result of the function is used, it might be
12629 possible to leave traces in the cache that can reveal what was stored
12630 at the out-of-bounds location. The built-in function can be used to
12631 provide some protection against leaking data in this way by changing
12632 the code to:
12633
12634 @smallexample
12635 int array[500];
12636 int f (unsigned untrusted_index)
12637 @{
12638 if (untrusted_index < 500)
12639 return array[__builtin_speculation_safe_value (untrusted_index)];
12640 return 0;
12641 @}
12642 @end smallexample
12643
12644 The built-in function will either cause execution to stall until the
12645 conditional branch has been fully resolved, or it may permit
12646 speculative execution to continue, but using 0 instead of
12647 @code{untrusted_value} if that exceeds the limit.
12648
12649 If accessing any memory location is potentially unsafe when speculative
12650 execution is incorrect, then the code can be rewritten as
12651
12652 @smallexample
12653 int array[500];
12654 int f (unsigned untrusted_index)
12655 @{
12656 if (untrusted_index < 500)
12657 return *__builtin_speculation_safe_value (&array[untrusted_index], NULL);
12658 return 0;
12659 @}
12660 @end smallexample
12661
12662 which will cause a @code{NULL} pointer to be used for the unsafe case.
12663
12664 @end deftypefn
12665
12666 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
12667
12668 You can use the built-in function @code{__builtin_types_compatible_p} to
12669 determine whether two types are the same.
12670
12671 This built-in function returns 1 if the unqualified versions of the
12672 types @var{type1} and @var{type2} (which are types, not expressions) are
12673 compatible, 0 otherwise. The result of this built-in function can be
12674 used in integer constant expressions.
12675
12676 This built-in function ignores top level qualifiers (e.g., @code{const},
12677 @code{volatile}). For example, @code{int} is equivalent to @code{const
12678 int}.
12679
12680 The type @code{int[]} and @code{int[5]} are compatible. On the other
12681 hand, @code{int} and @code{char *} are not compatible, even if the size
12682 of their types, on the particular architecture are the same. Also, the
12683 amount of pointer indirection is taken into account when determining
12684 similarity. Consequently, @code{short *} is not similar to
12685 @code{short **}. Furthermore, two types that are typedefed are
12686 considered compatible if their underlying types are compatible.
12687
12688 An @code{enum} type is not considered to be compatible with another
12689 @code{enum} type even if both are compatible with the same integer
12690 type; this is what the C standard specifies.
12691 For example, @code{enum @{foo, bar@}} is not similar to
12692 @code{enum @{hot, dog@}}.
12693
12694 You typically use this function in code whose execution varies
12695 depending on the arguments' types. For example:
12696
12697 @smallexample
12698 #define foo(x) \
12699 (@{ \
12700 typeof (x) tmp = (x); \
12701 if (__builtin_types_compatible_p (typeof (x), long double)) \
12702 tmp = foo_long_double (tmp); \
12703 else if (__builtin_types_compatible_p (typeof (x), double)) \
12704 tmp = foo_double (tmp); \
12705 else if (__builtin_types_compatible_p (typeof (x), float)) \
12706 tmp = foo_float (tmp); \
12707 else \
12708 abort (); \
12709 tmp; \
12710 @})
12711 @end smallexample
12712
12713 @emph{Note:} This construct is only available for C@.
12714
12715 @end deftypefn
12716
12717 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
12718
12719 The @var{call_exp} expression must be a function call, and the
12720 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
12721 is passed to the function call in the target's static chain location.
12722 The result of builtin is the result of the function call.
12723
12724 @emph{Note:} This builtin is only available for C@.
12725 This builtin can be used to call Go closures from C.
12726
12727 @end deftypefn
12728
12729 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
12730
12731 You can use the built-in function @code{__builtin_choose_expr} to
12732 evaluate code depending on the value of a constant expression. This
12733 built-in function returns @var{exp1} if @var{const_exp}, which is an
12734 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
12735
12736 This built-in function is analogous to the @samp{? :} operator in C,
12737 except that the expression returned has its type unaltered by promotion
12738 rules. Also, the built-in function does not evaluate the expression
12739 that is not chosen. For example, if @var{const_exp} evaluates to @code{true},
12740 @var{exp2} is not evaluated even if it has side effects.
12741
12742 This built-in function can return an lvalue if the chosen argument is an
12743 lvalue.
12744
12745 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
12746 type. Similarly, if @var{exp2} is returned, its return type is the same
12747 as @var{exp2}.
12748
12749 Example:
12750
12751 @smallexample
12752 #define foo(x) \
12753 __builtin_choose_expr ( \
12754 __builtin_types_compatible_p (typeof (x), double), \
12755 foo_double (x), \
12756 __builtin_choose_expr ( \
12757 __builtin_types_compatible_p (typeof (x), float), \
12758 foo_float (x), \
12759 /* @r{The void expression results in a compile-time error} \
12760 @r{when assigning the result to something.} */ \
12761 (void)0))
12762 @end smallexample
12763
12764 @emph{Note:} This construct is only available for C@. Furthermore, the
12765 unused expression (@var{exp1} or @var{exp2} depending on the value of
12766 @var{const_exp}) may still generate syntax errors. This may change in
12767 future revisions.
12768
12769 @end deftypefn
12770
12771 @deftypefn {Built-in Function} @var{type} __builtin_tgmath (@var{functions}, @var{arguments})
12772
12773 The built-in function @code{__builtin_tgmath}, available only for C
12774 and Objective-C, calls a function determined according to the rules of
12775 @code{<tgmath.h>} macros. It is intended to be used in
12776 implementations of that header, so that expansions of macros from that
12777 header only expand each of their arguments once, to avoid problems
12778 when calls to such macros are nested inside the arguments of other
12779 calls to such macros; in addition, it results in better diagnostics
12780 for invalid calls to @code{<tgmath.h>} macros than implementations
12781 using other GNU C language features. For example, the @code{pow}
12782 type-generic macro might be defined as:
12783
12784 @smallexample
12785 #define pow(a, b) __builtin_tgmath (powf, pow, powl, \
12786 cpowf, cpow, cpowl, a, b)
12787 @end smallexample
12788
12789 The arguments to @code{__builtin_tgmath} are at least two pointers to
12790 functions, followed by the arguments to the type-generic macro (which
12791 will be passed as arguments to the selected function). All the
12792 pointers to functions must be pointers to prototyped functions, none
12793 of which may have variable arguments, and all of which must have the
12794 same number of parameters; the number of parameters of the first
12795 function determines how many arguments to @code{__builtin_tgmath} are
12796 interpreted as function pointers, and how many as the arguments to the
12797 called function.
12798
12799 The types of the specified functions must all be different, but
12800 related to each other in the same way as a set of functions that may
12801 be selected between by a macro in @code{<tgmath.h>}. This means that
12802 the functions are parameterized by a floating-point type @var{t},
12803 different for each such function. The function return types may all
12804 be the same type, or they may be @var{t} for each function, or they
12805 may be the real type corresponding to @var{t} for each function (if
12806 some of the types @var{t} are complex). Likewise, for each parameter
12807 position, the type of the parameter in that position may always be the
12808 same type, or may be @var{t} for each function (this case must apply
12809 for at least one parameter position), or may be the real type
12810 corresponding to @var{t} for each function.
12811
12812 The standard rules for @code{<tgmath.h>} macros are used to find a
12813 common type @var{u} from the types of the arguments for parameters
12814 whose types vary between the functions; complex integer types (a GNU
12815 extension) are treated like @code{_Complex double} for this purpose
12816 (or @code{_Complex _Float64} if all the function return types are the
12817 same @code{_Float@var{n}} or @code{_Float@var{n}x} type).
12818 If the function return types vary, or are all the same integer type,
12819 the function called is the one for which @var{t} is @var{u}, and it is
12820 an error if there is no such function. If the function return types
12821 are all the same floating-point type, the type-generic macro is taken
12822 to be one of those from TS 18661 that rounds the result to a narrower
12823 type; if there is a function for which @var{t} is @var{u}, it is
12824 called, and otherwise the first function, if any, for which @var{t}
12825 has at least the range and precision of @var{u} is called, and it is
12826 an error if there is no such function.
12827
12828 @end deftypefn
12829
12830 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
12831
12832 The built-in function @code{__builtin_complex} is provided for use in
12833 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
12834 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
12835 real binary floating-point type, and the result has the corresponding
12836 complex type with real and imaginary parts @var{real} and @var{imag}.
12837 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
12838 infinities, NaNs and negative zeros are involved.
12839
12840 @end deftypefn
12841
12842 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
12843 You can use the built-in function @code{__builtin_constant_p} to
12844 determine if a value is known to be constant at compile time and hence
12845 that GCC can perform constant-folding on expressions involving that
12846 value. The argument of the function is the value to test. The function
12847 returns the integer 1 if the argument is known to be a compile-time
12848 constant and 0 if it is not known to be a compile-time constant. A
12849 return of 0 does not indicate that the value is @emph{not} a constant,
12850 but merely that GCC cannot prove it is a constant with the specified
12851 value of the @option{-O} option.
12852
12853 You typically use this function in an embedded application where
12854 memory is a critical resource. If you have some complex calculation,
12855 you may want it to be folded if it involves constants, but need to call
12856 a function if it does not. For example:
12857
12858 @smallexample
12859 #define Scale_Value(X) \
12860 (__builtin_constant_p (X) \
12861 ? ((X) * SCALE + OFFSET) : Scale (X))
12862 @end smallexample
12863
12864 You may use this built-in function in either a macro or an inline
12865 function. However, if you use it in an inlined function and pass an
12866 argument of the function as the argument to the built-in, GCC
12867 never returns 1 when you call the inline function with a string constant
12868 or compound literal (@pxref{Compound Literals}) and does not return 1
12869 when you pass a constant numeric value to the inline function unless you
12870 specify the @option{-O} option.
12871
12872 You may also use @code{__builtin_constant_p} in initializers for static
12873 data. For instance, you can write
12874
12875 @smallexample
12876 static const int table[] = @{
12877 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
12878 /* @r{@dots{}} */
12879 @};
12880 @end smallexample
12881
12882 @noindent
12883 This is an acceptable initializer even if @var{EXPRESSION} is not a
12884 constant expression, including the case where
12885 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
12886 folded to a constant but @var{EXPRESSION} contains operands that are
12887 not otherwise permitted in a static initializer (for example,
12888 @code{0 && foo ()}). GCC must be more conservative about evaluating the
12889 built-in in this case, because it has no opportunity to perform
12890 optimization.
12891 @end deftypefn
12892
12893 @deftypefn {Built-in Function} bool __builtin_is_constant_evaluated (void)
12894 The @code{__builtin_is_constant_evaluated} function is available only
12895 in C++. The built-in is intended to be used by implementations of
12896 the @code{std::is_constant_evaluated} C++ function. Programs should make
12897 use of the latter function rather than invoking the built-in directly.
12898
12899 The main use case of the built-in is to determine whether a @code{constexpr}
12900 function is being called in a @code{constexpr} context. A call to
12901 the function evaluates to a core constant expression with the value
12902 @code{true} if and only if it occurs within the evaluation of an expression
12903 or conversion that is manifestly constant-evaluated as defined in the C++
12904 standard. Manifestly constant-evaluated contexts include constant-expressions,
12905 the conditions of @code{constexpr if} statements, constraint-expressions, and
12906 initializers of variables usable in constant expressions. For more details
12907 refer to the latest revision of the C++ standard.
12908 @end deftypefn
12909
12910 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
12911 @opindex fprofile-arcs
12912 You may use @code{__builtin_expect} to provide the compiler with
12913 branch prediction information. In general, you should prefer to
12914 use actual profile feedback for this (@option{-fprofile-arcs}), as
12915 programmers are notoriously bad at predicting how their programs
12916 actually perform. However, there are applications in which this
12917 data is hard to collect.
12918
12919 The return value is the value of @var{exp}, which should be an integral
12920 expression. The semantics of the built-in are that it is expected that
12921 @var{exp} == @var{c}. For example:
12922
12923 @smallexample
12924 if (__builtin_expect (x, 0))
12925 foo ();
12926 @end smallexample
12927
12928 @noindent
12929 indicates that we do not expect to call @code{foo}, since
12930 we expect @code{x} to be zero. Since you are limited to integral
12931 expressions for @var{exp}, you should use constructions such as
12932
12933 @smallexample
12934 if (__builtin_expect (ptr != NULL, 1))
12935 foo (*ptr);
12936 @end smallexample
12937
12938 @noindent
12939 when testing pointer or floating-point values.
12940
12941 For the purposes of branch prediction optimizations, the probability that
12942 a @code{__builtin_expect} expression is @code{true} is controlled by GCC's
12943 @code{builtin-expect-probability} parameter, which defaults to 90%.
12944 You can also use @code{__builtin_expect_with_probability} to explicitly
12945 assign a probability value to individual expressions.
12946 @end deftypefn
12947
12948 @deftypefn {Built-in Function} long __builtin_expect_with_probability
12949 (long @var{exp}, long @var{c}, double @var{probability})
12950
12951 This function has the same semantics as @code{__builtin_expect},
12952 but the caller provides the expected probability that @var{exp} == @var{c}.
12953 The last argument, @var{probability}, is a floating-point value in the
12954 range 0.0 to 1.0, inclusive. The @var{probability} argument must be
12955 constant floating-point expression.
12956 @end deftypefn
12957
12958 @deftypefn {Built-in Function} void __builtin_trap (void)
12959 This function causes the program to exit abnormally. GCC implements
12960 this function by using a target-dependent mechanism (such as
12961 intentionally executing an illegal instruction) or by calling
12962 @code{abort}. The mechanism used may vary from release to release so
12963 you should not rely on any particular implementation.
12964 @end deftypefn
12965
12966 @deftypefn {Built-in Function} void __builtin_unreachable (void)
12967 If control flow reaches the point of the @code{__builtin_unreachable},
12968 the program is undefined. It is useful in situations where the
12969 compiler cannot deduce the unreachability of the code.
12970
12971 One such case is immediately following an @code{asm} statement that
12972 either never terminates, or one that transfers control elsewhere
12973 and never returns. In this example, without the
12974 @code{__builtin_unreachable}, GCC issues a warning that control
12975 reaches the end of a non-void function. It also generates code
12976 to return after the @code{asm}.
12977
12978 @smallexample
12979 int f (int c, int v)
12980 @{
12981 if (c)
12982 @{
12983 return v;
12984 @}
12985 else
12986 @{
12987 asm("jmp error_handler");
12988 __builtin_unreachable ();
12989 @}
12990 @}
12991 @end smallexample
12992
12993 @noindent
12994 Because the @code{asm} statement unconditionally transfers control out
12995 of the function, control never reaches the end of the function
12996 body. The @code{__builtin_unreachable} is in fact unreachable and
12997 communicates this fact to the compiler.
12998
12999 Another use for @code{__builtin_unreachable} is following a call a
13000 function that never returns but that is not declared
13001 @code{__attribute__((noreturn))}, as in this example:
13002
13003 @smallexample
13004 void function_that_never_returns (void);
13005
13006 int g (int c)
13007 @{
13008 if (c)
13009 @{
13010 return 1;
13011 @}
13012 else
13013 @{
13014 function_that_never_returns ();
13015 __builtin_unreachable ();
13016 @}
13017 @}
13018 @end smallexample
13019
13020 @end deftypefn
13021
13022 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
13023 This function returns its first argument, and allows the compiler
13024 to assume that the returned pointer is at least @var{align} bytes
13025 aligned. This built-in can have either two or three arguments,
13026 if it has three, the third argument should have integer type, and
13027 if it is nonzero means misalignment offset. For example:
13028
13029 @smallexample
13030 void *x = __builtin_assume_aligned (arg, 16);
13031 @end smallexample
13032
13033 @noindent
13034 means that the compiler can assume @code{x}, set to @code{arg}, is at least
13035 16-byte aligned, while:
13036
13037 @smallexample
13038 void *x = __builtin_assume_aligned (arg, 32, 8);
13039 @end smallexample
13040
13041 @noindent
13042 means that the compiler can assume for @code{x}, set to @code{arg}, that
13043 @code{(char *) x - 8} is 32-byte aligned.
13044 @end deftypefn
13045
13046 @deftypefn {Built-in Function} int __builtin_LINE ()
13047 This function is the equivalent of the preprocessor @code{__LINE__}
13048 macro and returns a constant integer expression that evaluates to
13049 the line number of the invocation of the built-in. When used as a C++
13050 default argument for a function @var{F}, it returns the line number
13051 of the call to @var{F}.
13052 @end deftypefn
13053
13054 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
13055 This function is the equivalent of the @code{__FUNCTION__} symbol
13056 and returns an address constant pointing to the name of the function
13057 from which the built-in was invoked, or the empty string if
13058 the invocation is not at function scope. When used as a C++ default
13059 argument for a function @var{F}, it returns the name of @var{F}'s
13060 caller or the empty string if the call was not made at function
13061 scope.
13062 @end deftypefn
13063
13064 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
13065 This function is the equivalent of the preprocessor @code{__FILE__}
13066 macro and returns an address constant pointing to the file name
13067 containing the invocation of the built-in, or the empty string if
13068 the invocation is not at function scope. When used as a C++ default
13069 argument for a function @var{F}, it returns the file name of the call
13070 to @var{F} or the empty string if the call was not made at function
13071 scope.
13072
13073 For example, in the following, each call to function @code{foo} will
13074 print a line similar to @code{"file.c:123: foo: message"} with the name
13075 of the file and the line number of the @code{printf} call, the name of
13076 the function @code{foo}, followed by the word @code{message}.
13077
13078 @smallexample
13079 const char*
13080 function (const char *func = __builtin_FUNCTION ())
13081 @{
13082 return func;
13083 @}
13084
13085 void foo (void)
13086 @{
13087 printf ("%s:%i: %s: message\n", file (), line (), function ());
13088 @}
13089 @end smallexample
13090
13091 @end deftypefn
13092
13093 @deftypefn {Built-in Function} void __builtin___clear_cache (void *@var{begin}, void *@var{end})
13094 This function is used to flush the processor's instruction cache for
13095 the region of memory between @var{begin} inclusive and @var{end}
13096 exclusive. Some targets require that the instruction cache be
13097 flushed, after modifying memory containing code, in order to obtain
13098 deterministic behavior.
13099
13100 If the target does not require instruction cache flushes,
13101 @code{__builtin___clear_cache} has no effect. Otherwise either
13102 instructions are emitted in-line to clear the instruction cache or a
13103 call to the @code{__clear_cache} function in libgcc is made.
13104 @end deftypefn
13105
13106 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
13107 This function is used to minimize cache-miss latency by moving data into
13108 a cache before it is accessed.
13109 You can insert calls to @code{__builtin_prefetch} into code for which
13110 you know addresses of data in memory that is likely to be accessed soon.
13111 If the target supports them, data prefetch instructions are generated.
13112 If the prefetch is done early enough before the access then the data will
13113 be in the cache by the time it is accessed.
13114
13115 The value of @var{addr} is the address of the memory to prefetch.
13116 There are two optional arguments, @var{rw} and @var{locality}.
13117 The value of @var{rw} is a compile-time constant one or zero; one
13118 means that the prefetch is preparing for a write to the memory address
13119 and zero, the default, means that the prefetch is preparing for a read.
13120 The value @var{locality} must be a compile-time constant integer between
13121 zero and three. A value of zero means that the data has no temporal
13122 locality, so it need not be left in the cache after the access. A value
13123 of three means that the data has a high degree of temporal locality and
13124 should be left in all levels of cache possible. Values of one and two
13125 mean, respectively, a low or moderate degree of temporal locality. The
13126 default is three.
13127
13128 @smallexample
13129 for (i = 0; i < n; i++)
13130 @{
13131 a[i] = a[i] + b[i];
13132 __builtin_prefetch (&a[i+j], 1, 1);
13133 __builtin_prefetch (&b[i+j], 0, 1);
13134 /* @r{@dots{}} */
13135 @}
13136 @end smallexample
13137
13138 Data prefetch does not generate faults if @var{addr} is invalid, but
13139 the address expression itself must be valid. For example, a prefetch
13140 of @code{p->next} does not fault if @code{p->next} is not a valid
13141 address, but evaluation faults if @code{p} is not a valid address.
13142
13143 If the target does not support data prefetch, the address expression
13144 is evaluated if it includes side effects but no other code is generated
13145 and GCC does not issue a warning.
13146 @end deftypefn
13147
13148 @deftypefn {Built-in Function}{size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
13149 Returns the size of an object pointed to by @var{ptr}. @xref{Object Size Checking} for a detailed description of the function.
13150 @end deftypefn
13151
13152 @deftypefn {Built-in Function} double __builtin_huge_val (void)
13153 Returns a positive infinity, if supported by the floating-point format,
13154 else @code{DBL_MAX}. This function is suitable for implementing the
13155 ISO C macro @code{HUGE_VAL}.
13156 @end deftypefn
13157
13158 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
13159 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
13160 @end deftypefn
13161
13162 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
13163 Similar to @code{__builtin_huge_val}, except the return
13164 type is @code{long double}.
13165 @end deftypefn
13166
13167 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
13168 Similar to @code{__builtin_huge_val}, except the return type is
13169 @code{_Float@var{n}}.
13170 @end deftypefn
13171
13172 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
13173 Similar to @code{__builtin_huge_val}, except the return type is
13174 @code{_Float@var{n}x}.
13175 @end deftypefn
13176
13177 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
13178 This built-in implements the C99 fpclassify functionality. The first
13179 five int arguments should be the target library's notion of the
13180 possible FP classes and are used for return values. They must be
13181 constant values and they must appear in this order: @code{FP_NAN},
13182 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
13183 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
13184 to classify. GCC treats the last argument as type-generic, which
13185 means it does not do default promotion from float to double.
13186 @end deftypefn
13187
13188 @deftypefn {Built-in Function} double __builtin_inf (void)
13189 Similar to @code{__builtin_huge_val}, except a warning is generated
13190 if the target floating-point format does not support infinities.
13191 @end deftypefn
13192
13193 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
13194 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
13195 @end deftypefn
13196
13197 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
13198 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
13199 @end deftypefn
13200
13201 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
13202 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
13203 @end deftypefn
13204
13205 @deftypefn {Built-in Function} float __builtin_inff (void)
13206 Similar to @code{__builtin_inf}, except the return type is @code{float}.
13207 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
13208 @end deftypefn
13209
13210 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
13211 Similar to @code{__builtin_inf}, except the return
13212 type is @code{long double}.
13213 @end deftypefn
13214
13215 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
13216 Similar to @code{__builtin_inf}, except the return
13217 type is @code{_Float@var{n}}.
13218 @end deftypefn
13219
13220 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
13221 Similar to @code{__builtin_inf}, except the return
13222 type is @code{_Float@var{n}x}.
13223 @end deftypefn
13224
13225 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
13226 Similar to @code{isinf}, except the return value is -1 for
13227 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
13228 Note while the parameter list is an
13229 ellipsis, this function only accepts exactly one floating-point
13230 argument. GCC treats this parameter as type-generic, which means it
13231 does not do default promotion from float to double.
13232 @end deftypefn
13233
13234 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
13235 This is an implementation of the ISO C99 function @code{nan}.
13236
13237 Since ISO C99 defines this function in terms of @code{strtod}, which we
13238 do not implement, a description of the parsing is in order. The string
13239 is parsed as by @code{strtol}; that is, the base is recognized by
13240 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
13241 in the significand such that the least significant bit of the number
13242 is at the least significant bit of the significand. The number is
13243 truncated to fit the significand field provided. The significand is
13244 forced to be a quiet NaN@.
13245
13246 This function, if given a string literal all of which would have been
13247 consumed by @code{strtol}, is evaluated early enough that it is considered a
13248 compile-time constant.
13249 @end deftypefn
13250
13251 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
13252 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
13253 @end deftypefn
13254
13255 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
13256 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
13257 @end deftypefn
13258
13259 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
13260 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
13261 @end deftypefn
13262
13263 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
13264 Similar to @code{__builtin_nan}, except the return type is @code{float}.
13265 @end deftypefn
13266
13267 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
13268 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
13269 @end deftypefn
13270
13271 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
13272 Similar to @code{__builtin_nan}, except the return type is
13273 @code{_Float@var{n}}.
13274 @end deftypefn
13275
13276 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
13277 Similar to @code{__builtin_nan}, except the return type is
13278 @code{_Float@var{n}x}.
13279 @end deftypefn
13280
13281 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
13282 Similar to @code{__builtin_nan}, except the significand is forced
13283 to be a signaling NaN@. The @code{nans} function is proposed by
13284 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
13285 @end deftypefn
13286
13287 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
13288 Similar to @code{__builtin_nans}, except the return type is @code{float}.
13289 @end deftypefn
13290
13291 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
13292 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
13293 @end deftypefn
13294
13295 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
13296 Similar to @code{__builtin_nans}, except the return type is
13297 @code{_Float@var{n}}.
13298 @end deftypefn
13299
13300 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
13301 Similar to @code{__builtin_nans}, except the return type is
13302 @code{_Float@var{n}x}.
13303 @end deftypefn
13304
13305 @deftypefn {Built-in Function} int __builtin_ffs (int x)
13306 Returns one plus the index of the least significant 1-bit of @var{x}, or
13307 if @var{x} is zero, returns zero.
13308 @end deftypefn
13309
13310 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
13311 Returns the number of leading 0-bits in @var{x}, starting at the most
13312 significant bit position. If @var{x} is 0, the result is undefined.
13313 @end deftypefn
13314
13315 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
13316 Returns the number of trailing 0-bits in @var{x}, starting at the least
13317 significant bit position. If @var{x} is 0, the result is undefined.
13318 @end deftypefn
13319
13320 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
13321 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
13322 number of bits following the most significant bit that are identical
13323 to it. There are no special cases for 0 or other values.
13324 @end deftypefn
13325
13326 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
13327 Returns the number of 1-bits in @var{x}.
13328 @end deftypefn
13329
13330 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
13331 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
13332 modulo 2.
13333 @end deftypefn
13334
13335 @deftypefn {Built-in Function} int __builtin_ffsl (long)
13336 Similar to @code{__builtin_ffs}, except the argument type is
13337 @code{long}.
13338 @end deftypefn
13339
13340 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
13341 Similar to @code{__builtin_clz}, except the argument type is
13342 @code{unsigned long}.
13343 @end deftypefn
13344
13345 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
13346 Similar to @code{__builtin_ctz}, except the argument type is
13347 @code{unsigned long}.
13348 @end deftypefn
13349
13350 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
13351 Similar to @code{__builtin_clrsb}, except the argument type is
13352 @code{long}.
13353 @end deftypefn
13354
13355 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
13356 Similar to @code{__builtin_popcount}, except the argument type is
13357 @code{unsigned long}.
13358 @end deftypefn
13359
13360 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
13361 Similar to @code{__builtin_parity}, except the argument type is
13362 @code{unsigned long}.
13363 @end deftypefn
13364
13365 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
13366 Similar to @code{__builtin_ffs}, except the argument type is
13367 @code{long long}.
13368 @end deftypefn
13369
13370 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
13371 Similar to @code{__builtin_clz}, except the argument type is
13372 @code{unsigned long long}.
13373 @end deftypefn
13374
13375 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
13376 Similar to @code{__builtin_ctz}, except the argument type is
13377 @code{unsigned long long}.
13378 @end deftypefn
13379
13380 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
13381 Similar to @code{__builtin_clrsb}, except the argument type is
13382 @code{long long}.
13383 @end deftypefn
13384
13385 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
13386 Similar to @code{__builtin_popcount}, except the argument type is
13387 @code{unsigned long long}.
13388 @end deftypefn
13389
13390 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
13391 Similar to @code{__builtin_parity}, except the argument type is
13392 @code{unsigned long long}.
13393 @end deftypefn
13394
13395 @deftypefn {Built-in Function} double __builtin_powi (double, int)
13396 Returns the first argument raised to the power of the second. Unlike the
13397 @code{pow} function no guarantees about precision and rounding are made.
13398 @end deftypefn
13399
13400 @deftypefn {Built-in Function} float __builtin_powif (float, int)
13401 Similar to @code{__builtin_powi}, except the argument and return types
13402 are @code{float}.
13403 @end deftypefn
13404
13405 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
13406 Similar to @code{__builtin_powi}, except the argument and return types
13407 are @code{long double}.
13408 @end deftypefn
13409
13410 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
13411 Returns @var{x} with the order of the bytes reversed; for example,
13412 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
13413 exactly 8 bits.
13414 @end deftypefn
13415
13416 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
13417 Similar to @code{__builtin_bswap16}, except the argument and return types
13418 are 32 bit.
13419 @end deftypefn
13420
13421 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
13422 Similar to @code{__builtin_bswap32}, except the argument and return types
13423 are 64 bit.
13424 @end deftypefn
13425
13426 @deftypefn {Built-in Function} Pmode __builtin_extend_pointer (void * x)
13427 On targets where the user visible pointer size is smaller than the size
13428 of an actual hardware address this function returns the extended user
13429 pointer. Targets where this is true included ILP32 mode on x86_64 or
13430 Aarch64. This function is mainly useful when writing inline assembly
13431 code.
13432 @end deftypefn
13433
13434 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_id (int x)
13435 Returns the openacc gang, worker or vector id depending on whether @var{x} is
13436 0, 1 or 2.
13437 @end deftypefn
13438
13439 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_size (int x)
13440 Returns the openacc gang, worker or vector size depending on whether @var{x} is
13441 0, 1 or 2.
13442 @end deftypefn
13443
13444 @node Target Builtins
13445 @section Built-in Functions Specific to Particular Target Machines
13446
13447 On some target machines, GCC supports many built-in functions specific
13448 to those machines. Generally these generate calls to specific machine
13449 instructions, but allow the compiler to schedule those calls.
13450
13451 @menu
13452 * AArch64 Built-in Functions::
13453 * Alpha Built-in Functions::
13454 * Altera Nios II Built-in Functions::
13455 * ARC Built-in Functions::
13456 * ARC SIMD Built-in Functions::
13457 * ARM iWMMXt Built-in Functions::
13458 * ARM C Language Extensions (ACLE)::
13459 * ARM Floating Point Status and Control Intrinsics::
13460 * ARM ARMv8-M Security Extensions::
13461 * AVR Built-in Functions::
13462 * Blackfin Built-in Functions::
13463 * FR-V Built-in Functions::
13464 * MIPS DSP Built-in Functions::
13465 * MIPS Paired-Single Support::
13466 * MIPS Loongson Built-in Functions::
13467 * MIPS SIMD Architecture (MSA) Support::
13468 * Other MIPS Built-in Functions::
13469 * MSP430 Built-in Functions::
13470 * NDS32 Built-in Functions::
13471 * picoChip Built-in Functions::
13472 * Basic PowerPC Built-in Functions::
13473 * PowerPC AltiVec/VSX Built-in Functions::
13474 * PowerPC Hardware Transactional Memory Built-in Functions::
13475 * PowerPC Atomic Memory Operation Functions::
13476 * RX Built-in Functions::
13477 * S/390 System z Built-in Functions::
13478 * SH Built-in Functions::
13479 * SPARC VIS Built-in Functions::
13480 * SPU Built-in Functions::
13481 * TI C6X Built-in Functions::
13482 * TILE-Gx Built-in Functions::
13483 * TILEPro Built-in Functions::
13484 * x86 Built-in Functions::
13485 * x86 transactional memory intrinsics::
13486 * x86 control-flow protection intrinsics::
13487 @end menu
13488
13489 @node AArch64 Built-in Functions
13490 @subsection AArch64 Built-in Functions
13491
13492 These built-in functions are available for the AArch64 family of
13493 processors.
13494 @smallexample
13495 unsigned int __builtin_aarch64_get_fpcr ()
13496 void __builtin_aarch64_set_fpcr (unsigned int)
13497 unsigned int __builtin_aarch64_get_fpsr ()
13498 void __builtin_aarch64_set_fpsr (unsigned int)
13499 @end smallexample
13500
13501 @node Alpha Built-in Functions
13502 @subsection Alpha Built-in Functions
13503
13504 These built-in functions are available for the Alpha family of
13505 processors, depending on the command-line switches used.
13506
13507 The following built-in functions are always available. They
13508 all generate the machine instruction that is part of the name.
13509
13510 @smallexample
13511 long __builtin_alpha_implver (void)
13512 long __builtin_alpha_rpcc (void)
13513 long __builtin_alpha_amask (long)
13514 long __builtin_alpha_cmpbge (long, long)
13515 long __builtin_alpha_extbl (long, long)
13516 long __builtin_alpha_extwl (long, long)
13517 long __builtin_alpha_extll (long, long)
13518 long __builtin_alpha_extql (long, long)
13519 long __builtin_alpha_extwh (long, long)
13520 long __builtin_alpha_extlh (long, long)
13521 long __builtin_alpha_extqh (long, long)
13522 long __builtin_alpha_insbl (long, long)
13523 long __builtin_alpha_inswl (long, long)
13524 long __builtin_alpha_insll (long, long)
13525 long __builtin_alpha_insql (long, long)
13526 long __builtin_alpha_inswh (long, long)
13527 long __builtin_alpha_inslh (long, long)
13528 long __builtin_alpha_insqh (long, long)
13529 long __builtin_alpha_mskbl (long, long)
13530 long __builtin_alpha_mskwl (long, long)
13531 long __builtin_alpha_mskll (long, long)
13532 long __builtin_alpha_mskql (long, long)
13533 long __builtin_alpha_mskwh (long, long)
13534 long __builtin_alpha_msklh (long, long)
13535 long __builtin_alpha_mskqh (long, long)
13536 long __builtin_alpha_umulh (long, long)
13537 long __builtin_alpha_zap (long, long)
13538 long __builtin_alpha_zapnot (long, long)
13539 @end smallexample
13540
13541 The following built-in functions are always with @option{-mmax}
13542 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
13543 later. They all generate the machine instruction that is part
13544 of the name.
13545
13546 @smallexample
13547 long __builtin_alpha_pklb (long)
13548 long __builtin_alpha_pkwb (long)
13549 long __builtin_alpha_unpkbl (long)
13550 long __builtin_alpha_unpkbw (long)
13551 long __builtin_alpha_minub8 (long, long)
13552 long __builtin_alpha_minsb8 (long, long)
13553 long __builtin_alpha_minuw4 (long, long)
13554 long __builtin_alpha_minsw4 (long, long)
13555 long __builtin_alpha_maxub8 (long, long)
13556 long __builtin_alpha_maxsb8 (long, long)
13557 long __builtin_alpha_maxuw4 (long, long)
13558 long __builtin_alpha_maxsw4 (long, long)
13559 long __builtin_alpha_perr (long, long)
13560 @end smallexample
13561
13562 The following built-in functions are always with @option{-mcix}
13563 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
13564 later. They all generate the machine instruction that is part
13565 of the name.
13566
13567 @smallexample
13568 long __builtin_alpha_cttz (long)
13569 long __builtin_alpha_ctlz (long)
13570 long __builtin_alpha_ctpop (long)
13571 @end smallexample
13572
13573 The following built-in functions are available on systems that use the OSF/1
13574 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
13575 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
13576 @code{rdval} and @code{wrval}.
13577
13578 @smallexample
13579 void *__builtin_thread_pointer (void)
13580 void __builtin_set_thread_pointer (void *)
13581 @end smallexample
13582
13583 @node Altera Nios II Built-in Functions
13584 @subsection Altera Nios II Built-in Functions
13585
13586 These built-in functions are available for the Altera Nios II
13587 family of processors.
13588
13589 The following built-in functions are always available. They
13590 all generate the machine instruction that is part of the name.
13591
13592 @example
13593 int __builtin_ldbio (volatile const void *)
13594 int __builtin_ldbuio (volatile const void *)
13595 int __builtin_ldhio (volatile const void *)
13596 int __builtin_ldhuio (volatile const void *)
13597 int __builtin_ldwio (volatile const void *)
13598 void __builtin_stbio (volatile void *, int)
13599 void __builtin_sthio (volatile void *, int)
13600 void __builtin_stwio (volatile void *, int)
13601 void __builtin_sync (void)
13602 int __builtin_rdctl (int)
13603 int __builtin_rdprs (int, int)
13604 void __builtin_wrctl (int, int)
13605 void __builtin_flushd (volatile void *)
13606 void __builtin_flushda (volatile void *)
13607 int __builtin_wrpie (int);
13608 void __builtin_eni (int);
13609 int __builtin_ldex (volatile const void *)
13610 int __builtin_stex (volatile void *, int)
13611 int __builtin_ldsex (volatile const void *)
13612 int __builtin_stsex (volatile void *, int)
13613 @end example
13614
13615 The following built-in functions are always available. They
13616 all generate a Nios II Custom Instruction. The name of the
13617 function represents the types that the function takes and
13618 returns. The letter before the @code{n} is the return type
13619 or void if absent. The @code{n} represents the first parameter
13620 to all the custom instructions, the custom instruction number.
13621 The two letters after the @code{n} represent the up to two
13622 parameters to the function.
13623
13624 The letters represent the following data types:
13625 @table @code
13626 @item <no letter>
13627 @code{void} for return type and no parameter for parameter types.
13628
13629 @item i
13630 @code{int} for return type and parameter type
13631
13632 @item f
13633 @code{float} for return type and parameter type
13634
13635 @item p
13636 @code{void *} for return type and parameter type
13637
13638 @end table
13639
13640 And the function names are:
13641 @example
13642 void __builtin_custom_n (void)
13643 void __builtin_custom_ni (int)
13644 void __builtin_custom_nf (float)
13645 void __builtin_custom_np (void *)
13646 void __builtin_custom_nii (int, int)
13647 void __builtin_custom_nif (int, float)
13648 void __builtin_custom_nip (int, void *)
13649 void __builtin_custom_nfi (float, int)
13650 void __builtin_custom_nff (float, float)
13651 void __builtin_custom_nfp (float, void *)
13652 void __builtin_custom_npi (void *, int)
13653 void __builtin_custom_npf (void *, float)
13654 void __builtin_custom_npp (void *, void *)
13655 int __builtin_custom_in (void)
13656 int __builtin_custom_ini (int)
13657 int __builtin_custom_inf (float)
13658 int __builtin_custom_inp (void *)
13659 int __builtin_custom_inii (int, int)
13660 int __builtin_custom_inif (int, float)
13661 int __builtin_custom_inip (int, void *)
13662 int __builtin_custom_infi (float, int)
13663 int __builtin_custom_inff (float, float)
13664 int __builtin_custom_infp (float, void *)
13665 int __builtin_custom_inpi (void *, int)
13666 int __builtin_custom_inpf (void *, float)
13667 int __builtin_custom_inpp (void *, void *)
13668 float __builtin_custom_fn (void)
13669 float __builtin_custom_fni (int)
13670 float __builtin_custom_fnf (float)
13671 float __builtin_custom_fnp (void *)
13672 float __builtin_custom_fnii (int, int)
13673 float __builtin_custom_fnif (int, float)
13674 float __builtin_custom_fnip (int, void *)
13675 float __builtin_custom_fnfi (float, int)
13676 float __builtin_custom_fnff (float, float)
13677 float __builtin_custom_fnfp (float, void *)
13678 float __builtin_custom_fnpi (void *, int)
13679 float __builtin_custom_fnpf (void *, float)
13680 float __builtin_custom_fnpp (void *, void *)
13681 void * __builtin_custom_pn (void)
13682 void * __builtin_custom_pni (int)
13683 void * __builtin_custom_pnf (float)
13684 void * __builtin_custom_pnp (void *)
13685 void * __builtin_custom_pnii (int, int)
13686 void * __builtin_custom_pnif (int, float)
13687 void * __builtin_custom_pnip (int, void *)
13688 void * __builtin_custom_pnfi (float, int)
13689 void * __builtin_custom_pnff (float, float)
13690 void * __builtin_custom_pnfp (float, void *)
13691 void * __builtin_custom_pnpi (void *, int)
13692 void * __builtin_custom_pnpf (void *, float)
13693 void * __builtin_custom_pnpp (void *, void *)
13694 @end example
13695
13696 @node ARC Built-in Functions
13697 @subsection ARC Built-in Functions
13698
13699 The following built-in functions are provided for ARC targets. The
13700 built-ins generate the corresponding assembly instructions. In the
13701 examples given below, the generated code often requires an operand or
13702 result to be in a register. Where necessary further code will be
13703 generated to ensure this is true, but for brevity this is not
13704 described in each case.
13705
13706 @emph{Note:} Using a built-in to generate an instruction not supported
13707 by a target may cause problems. At present the compiler is not
13708 guaranteed to detect such misuse, and as a result an internal compiler
13709 error may be generated.
13710
13711 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
13712 Return 1 if @var{val} is known to have the byte alignment given
13713 by @var{alignval}, otherwise return 0.
13714 Note that this is different from
13715 @smallexample
13716 __alignof__(*(char *)@var{val}) >= alignval
13717 @end smallexample
13718 because __alignof__ sees only the type of the dereference, whereas
13719 __builtin_arc_align uses alignment information from the pointer
13720 as well as from the pointed-to type.
13721 The information available will depend on optimization level.
13722 @end deftypefn
13723
13724 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
13725 Generates
13726 @example
13727 brk
13728 @end example
13729 @end deftypefn
13730
13731 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
13732 The operand is the number of a register to be read. Generates:
13733 @example
13734 mov @var{dest}, r@var{regno}
13735 @end example
13736 where the value in @var{dest} will be the result returned from the
13737 built-in.
13738 @end deftypefn
13739
13740 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
13741 The first operand is the number of a register to be written, the
13742 second operand is a compile time constant to write into that
13743 register. Generates:
13744 @example
13745 mov r@var{regno}, @var{val}
13746 @end example
13747 @end deftypefn
13748
13749 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
13750 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
13751 Generates:
13752 @example
13753 divaw @var{dest}, @var{a}, @var{b}
13754 @end example
13755 where the value in @var{dest} will be the result returned from the
13756 built-in.
13757 @end deftypefn
13758
13759 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
13760 Generates
13761 @example
13762 flag @var{a}
13763 @end example
13764 @end deftypefn
13765
13766 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
13767 The operand, @var{auxv}, is the address of an auxiliary register and
13768 must be a compile time constant. Generates:
13769 @example
13770 lr @var{dest}, [@var{auxr}]
13771 @end example
13772 Where the value in @var{dest} will be the result returned from the
13773 built-in.
13774 @end deftypefn
13775
13776 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
13777 Only available with @option{-mmul64}. Generates:
13778 @example
13779 mul64 @var{a}, @var{b}
13780 @end example
13781 @end deftypefn
13782
13783 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
13784 Only available with @option{-mmul64}. Generates:
13785 @example
13786 mulu64 @var{a}, @var{b}
13787 @end example
13788 @end deftypefn
13789
13790 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
13791 Generates:
13792 @example
13793 nop
13794 @end example
13795 @end deftypefn
13796
13797 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
13798 Only valid if the @samp{norm} instruction is available through the
13799 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
13800 Generates:
13801 @example
13802 norm @var{dest}, @var{src}
13803 @end example
13804 Where the value in @var{dest} will be the result returned from the
13805 built-in.
13806 @end deftypefn
13807
13808 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
13809 Only valid if the @samp{normw} instruction is available through the
13810 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
13811 Generates:
13812 @example
13813 normw @var{dest}, @var{src}
13814 @end example
13815 Where the value in @var{dest} will be the result returned from the
13816 built-in.
13817 @end deftypefn
13818
13819 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
13820 Generates:
13821 @example
13822 rtie
13823 @end example
13824 @end deftypefn
13825
13826 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
13827 Generates:
13828 @example
13829 sleep @var{a}
13830 @end example
13831 @end deftypefn
13832
13833 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
13834 The first argument, @var{auxv}, is the address of an auxiliary
13835 register, the second argument, @var{val}, is a compile time constant
13836 to be written to the register. Generates:
13837 @example
13838 sr @var{auxr}, [@var{val}]
13839 @end example
13840 @end deftypefn
13841
13842 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
13843 Only valid with @option{-mswap}. Generates:
13844 @example
13845 swap @var{dest}, @var{src}
13846 @end example
13847 Where the value in @var{dest} will be the result returned from the
13848 built-in.
13849 @end deftypefn
13850
13851 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
13852 Generates:
13853 @example
13854 swi
13855 @end example
13856 @end deftypefn
13857
13858 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
13859 Only available with @option{-mcpu=ARC700}. Generates:
13860 @example
13861 sync
13862 @end example
13863 @end deftypefn
13864
13865 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
13866 Only available with @option{-mcpu=ARC700}. Generates:
13867 @example
13868 trap_s @var{c}
13869 @end example
13870 @end deftypefn
13871
13872 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
13873 Only available with @option{-mcpu=ARC700}. Generates:
13874 @example
13875 unimp_s
13876 @end example
13877 @end deftypefn
13878
13879 The instructions generated by the following builtins are not
13880 considered as candidates for scheduling. They are not moved around by
13881 the compiler during scheduling, and thus can be expected to appear
13882 where they are put in the C code:
13883 @example
13884 __builtin_arc_brk()
13885 __builtin_arc_core_read()
13886 __builtin_arc_core_write()
13887 __builtin_arc_flag()
13888 __builtin_arc_lr()
13889 __builtin_arc_sleep()
13890 __builtin_arc_sr()
13891 __builtin_arc_swi()
13892 @end example
13893
13894 @node ARC SIMD Built-in Functions
13895 @subsection ARC SIMD Built-in Functions
13896
13897 SIMD builtins provided by the compiler can be used to generate the
13898 vector instructions. This section describes the available builtins
13899 and their usage in programs. With the @option{-msimd} option, the
13900 compiler provides 128-bit vector types, which can be specified using
13901 the @code{vector_size} attribute. The header file @file{arc-simd.h}
13902 can be included to use the following predefined types:
13903 @example
13904 typedef int __v4si __attribute__((vector_size(16)));
13905 typedef short __v8hi __attribute__((vector_size(16)));
13906 @end example
13907
13908 These types can be used to define 128-bit variables. The built-in
13909 functions listed in the following section can be used on these
13910 variables to generate the vector operations.
13911
13912 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
13913 @file{arc-simd.h} also provides equivalent macros called
13914 @code{_@var{someinsn}} that can be used for programming ease and
13915 improved readability. The following macros for DMA control are also
13916 provided:
13917 @example
13918 #define _setup_dma_in_channel_reg _vdiwr
13919 #define _setup_dma_out_channel_reg _vdowr
13920 @end example
13921
13922 The following is a complete list of all the SIMD built-ins provided
13923 for ARC, grouped by calling signature.
13924
13925 The following take two @code{__v8hi} arguments and return a
13926 @code{__v8hi} result:
13927 @example
13928 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
13929 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
13930 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
13931 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
13932 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
13933 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
13934 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
13935 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
13936 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
13937 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
13938 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
13939 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
13940 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
13941 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
13942 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
13943 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
13944 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
13945 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
13946 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
13947 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
13948 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
13949 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
13950 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
13951 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
13952 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
13953 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
13954 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
13955 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
13956 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
13957 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
13958 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
13959 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
13960 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
13961 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
13962 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
13963 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
13964 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
13965 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
13966 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
13967 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
13968 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
13969 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
13970 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
13971 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
13972 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
13973 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
13974 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
13975 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
13976 @end example
13977
13978 The following take one @code{__v8hi} and one @code{int} argument and return a
13979 @code{__v8hi} result:
13980
13981 @example
13982 __v8hi __builtin_arc_vbaddw (__v8hi, int)
13983 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
13984 __v8hi __builtin_arc_vbminw (__v8hi, int)
13985 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
13986 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
13987 __v8hi __builtin_arc_vbmulw (__v8hi, int)
13988 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
13989 __v8hi __builtin_arc_vbsubw (__v8hi, int)
13990 @end example
13991
13992 The following take one @code{__v8hi} argument and one @code{int} argument which
13993 must be a 3-bit compile time constant indicating a register number
13994 I0-I7. They return a @code{__v8hi} result.
13995 @example
13996 __v8hi __builtin_arc_vasrw (__v8hi, const int)
13997 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
13998 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
13999 @end example
14000
14001 The following take one @code{__v8hi} argument and one @code{int}
14002 argument which must be a 6-bit compile time constant. They return a
14003 @code{__v8hi} result.
14004 @example
14005 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
14006 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
14007 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
14008 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
14009 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
14010 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
14011 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
14012 @end example
14013
14014 The following take one @code{__v8hi} argument and one @code{int} argument which
14015 must be a 8-bit compile time constant. They return a @code{__v8hi}
14016 result.
14017 @example
14018 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
14019 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
14020 __v8hi __builtin_arc_vmvw (__v8hi, const int)
14021 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
14022 @end example
14023
14024 The following take two @code{int} arguments, the second of which which
14025 must be a 8-bit compile time constant. They return a @code{__v8hi}
14026 result:
14027 @example
14028 __v8hi __builtin_arc_vmovaw (int, const int)
14029 __v8hi __builtin_arc_vmovw (int, const int)
14030 __v8hi __builtin_arc_vmovzw (int, const int)
14031 @end example
14032
14033 The following take a single @code{__v8hi} argument and return a
14034 @code{__v8hi} result:
14035 @example
14036 __v8hi __builtin_arc_vabsaw (__v8hi)
14037 __v8hi __builtin_arc_vabsw (__v8hi)
14038 __v8hi __builtin_arc_vaddsuw (__v8hi)
14039 __v8hi __builtin_arc_vexch1 (__v8hi)
14040 __v8hi __builtin_arc_vexch2 (__v8hi)
14041 __v8hi __builtin_arc_vexch4 (__v8hi)
14042 __v8hi __builtin_arc_vsignw (__v8hi)
14043 __v8hi __builtin_arc_vupbaw (__v8hi)
14044 __v8hi __builtin_arc_vupbw (__v8hi)
14045 __v8hi __builtin_arc_vupsbaw (__v8hi)
14046 __v8hi __builtin_arc_vupsbw (__v8hi)
14047 @end example
14048
14049 The following take two @code{int} arguments and return no result:
14050 @example
14051 void __builtin_arc_vdirun (int, int)
14052 void __builtin_arc_vdorun (int, int)
14053 @end example
14054
14055 The following take two @code{int} arguments and return no result. The
14056 first argument must a 3-bit compile time constant indicating one of
14057 the DR0-DR7 DMA setup channels:
14058 @example
14059 void __builtin_arc_vdiwr (const int, int)
14060 void __builtin_arc_vdowr (const int, int)
14061 @end example
14062
14063 The following take an @code{int} argument and return no result:
14064 @example
14065 void __builtin_arc_vendrec (int)
14066 void __builtin_arc_vrec (int)
14067 void __builtin_arc_vrecrun (int)
14068 void __builtin_arc_vrun (int)
14069 @end example
14070
14071 The following take a @code{__v8hi} argument and two @code{int}
14072 arguments and return a @code{__v8hi} result. The second argument must
14073 be a 3-bit compile time constants, indicating one the registers I0-I7,
14074 and the third argument must be an 8-bit compile time constant.
14075
14076 @emph{Note:} Although the equivalent hardware instructions do not take
14077 an SIMD register as an operand, these builtins overwrite the relevant
14078 bits of the @code{__v8hi} register provided as the first argument with
14079 the value loaded from the @code{[Ib, u8]} location in the SDM.
14080
14081 @example
14082 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
14083 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
14084 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
14085 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
14086 @end example
14087
14088 The following take two @code{int} arguments and return a @code{__v8hi}
14089 result. The first argument must be a 3-bit compile time constants,
14090 indicating one the registers I0-I7, and the second argument must be an
14091 8-bit compile time constant.
14092
14093 @example
14094 __v8hi __builtin_arc_vld128 (const int, const int)
14095 __v8hi __builtin_arc_vld64w (const int, const int)
14096 @end example
14097
14098 The following take a @code{__v8hi} argument and two @code{int}
14099 arguments and return no result. The second argument must be a 3-bit
14100 compile time constants, indicating one the registers I0-I7, and the
14101 third argument must be an 8-bit compile time constant.
14102
14103 @example
14104 void __builtin_arc_vst128 (__v8hi, const int, const int)
14105 void __builtin_arc_vst64 (__v8hi, const int, const int)
14106 @end example
14107
14108 The following take a @code{__v8hi} argument and three @code{int}
14109 arguments and return no result. The second argument must be a 3-bit
14110 compile-time constant, identifying the 16-bit sub-register to be
14111 stored, the third argument must be a 3-bit compile time constants,
14112 indicating one the registers I0-I7, and the fourth argument must be an
14113 8-bit compile time constant.
14114
14115 @example
14116 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
14117 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
14118 @end example
14119
14120 @node ARM iWMMXt Built-in Functions
14121 @subsection ARM iWMMXt Built-in Functions
14122
14123 These built-in functions are available for the ARM family of
14124 processors when the @option{-mcpu=iwmmxt} switch is used:
14125
14126 @smallexample
14127 typedef int v2si __attribute__ ((vector_size (8)));
14128 typedef short v4hi __attribute__ ((vector_size (8)));
14129 typedef char v8qi __attribute__ ((vector_size (8)));
14130
14131 int __builtin_arm_getwcgr0 (void)
14132 void __builtin_arm_setwcgr0 (int)
14133 int __builtin_arm_getwcgr1 (void)
14134 void __builtin_arm_setwcgr1 (int)
14135 int __builtin_arm_getwcgr2 (void)
14136 void __builtin_arm_setwcgr2 (int)
14137 int __builtin_arm_getwcgr3 (void)
14138 void __builtin_arm_setwcgr3 (int)
14139 int __builtin_arm_textrmsb (v8qi, int)
14140 int __builtin_arm_textrmsh (v4hi, int)
14141 int __builtin_arm_textrmsw (v2si, int)
14142 int __builtin_arm_textrmub (v8qi, int)
14143 int __builtin_arm_textrmuh (v4hi, int)
14144 int __builtin_arm_textrmuw (v2si, int)
14145 v8qi __builtin_arm_tinsrb (v8qi, int, int)
14146 v4hi __builtin_arm_tinsrh (v4hi, int, int)
14147 v2si __builtin_arm_tinsrw (v2si, int, int)
14148 long long __builtin_arm_tmia (long long, int, int)
14149 long long __builtin_arm_tmiabb (long long, int, int)
14150 long long __builtin_arm_tmiabt (long long, int, int)
14151 long long __builtin_arm_tmiaph (long long, int, int)
14152 long long __builtin_arm_tmiatb (long long, int, int)
14153 long long __builtin_arm_tmiatt (long long, int, int)
14154 int __builtin_arm_tmovmskb (v8qi)
14155 int __builtin_arm_tmovmskh (v4hi)
14156 int __builtin_arm_tmovmskw (v2si)
14157 long long __builtin_arm_waccb (v8qi)
14158 long long __builtin_arm_wacch (v4hi)
14159 long long __builtin_arm_waccw (v2si)
14160 v8qi __builtin_arm_waddb (v8qi, v8qi)
14161 v8qi __builtin_arm_waddbss (v8qi, v8qi)
14162 v8qi __builtin_arm_waddbus (v8qi, v8qi)
14163 v4hi __builtin_arm_waddh (v4hi, v4hi)
14164 v4hi __builtin_arm_waddhss (v4hi, v4hi)
14165 v4hi __builtin_arm_waddhus (v4hi, v4hi)
14166 v2si __builtin_arm_waddw (v2si, v2si)
14167 v2si __builtin_arm_waddwss (v2si, v2si)
14168 v2si __builtin_arm_waddwus (v2si, v2si)
14169 v8qi __builtin_arm_walign (v8qi, v8qi, int)
14170 long long __builtin_arm_wand(long long, long long)
14171 long long __builtin_arm_wandn (long long, long long)
14172 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
14173 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
14174 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
14175 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
14176 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
14177 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
14178 v2si __builtin_arm_wcmpeqw (v2si, v2si)
14179 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
14180 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
14181 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
14182 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
14183 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
14184 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
14185 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
14186 long long __builtin_arm_wmacsz (v4hi, v4hi)
14187 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
14188 long long __builtin_arm_wmacuz (v4hi, v4hi)
14189 v4hi __builtin_arm_wmadds (v4hi, v4hi)
14190 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
14191 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
14192 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
14193 v2si __builtin_arm_wmaxsw (v2si, v2si)
14194 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
14195 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
14196 v2si __builtin_arm_wmaxuw (v2si, v2si)
14197 v8qi __builtin_arm_wminsb (v8qi, v8qi)
14198 v4hi __builtin_arm_wminsh (v4hi, v4hi)
14199 v2si __builtin_arm_wminsw (v2si, v2si)
14200 v8qi __builtin_arm_wminub (v8qi, v8qi)
14201 v4hi __builtin_arm_wminuh (v4hi, v4hi)
14202 v2si __builtin_arm_wminuw (v2si, v2si)
14203 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
14204 v4hi __builtin_arm_wmulul (v4hi, v4hi)
14205 v4hi __builtin_arm_wmulum (v4hi, v4hi)
14206 long long __builtin_arm_wor (long long, long long)
14207 v2si __builtin_arm_wpackdss (long long, long long)
14208 v2si __builtin_arm_wpackdus (long long, long long)
14209 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
14210 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
14211 v4hi __builtin_arm_wpackwss (v2si, v2si)
14212 v4hi __builtin_arm_wpackwus (v2si, v2si)
14213 long long __builtin_arm_wrord (long long, long long)
14214 long long __builtin_arm_wrordi (long long, int)
14215 v4hi __builtin_arm_wrorh (v4hi, long long)
14216 v4hi __builtin_arm_wrorhi (v4hi, int)
14217 v2si __builtin_arm_wrorw (v2si, long long)
14218 v2si __builtin_arm_wrorwi (v2si, int)
14219 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
14220 v2si __builtin_arm_wsadbz (v8qi, v8qi)
14221 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
14222 v2si __builtin_arm_wsadhz (v4hi, v4hi)
14223 v4hi __builtin_arm_wshufh (v4hi, int)
14224 long long __builtin_arm_wslld (long long, long long)
14225 long long __builtin_arm_wslldi (long long, int)
14226 v4hi __builtin_arm_wsllh (v4hi, long long)
14227 v4hi __builtin_arm_wsllhi (v4hi, int)
14228 v2si __builtin_arm_wsllw (v2si, long long)
14229 v2si __builtin_arm_wsllwi (v2si, int)
14230 long long __builtin_arm_wsrad (long long, long long)
14231 long long __builtin_arm_wsradi (long long, int)
14232 v4hi __builtin_arm_wsrah (v4hi, long long)
14233 v4hi __builtin_arm_wsrahi (v4hi, int)
14234 v2si __builtin_arm_wsraw (v2si, long long)
14235 v2si __builtin_arm_wsrawi (v2si, int)
14236 long long __builtin_arm_wsrld (long long, long long)
14237 long long __builtin_arm_wsrldi (long long, int)
14238 v4hi __builtin_arm_wsrlh (v4hi, long long)
14239 v4hi __builtin_arm_wsrlhi (v4hi, int)
14240 v2si __builtin_arm_wsrlw (v2si, long long)
14241 v2si __builtin_arm_wsrlwi (v2si, int)
14242 v8qi __builtin_arm_wsubb (v8qi, v8qi)
14243 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
14244 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
14245 v4hi __builtin_arm_wsubh (v4hi, v4hi)
14246 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
14247 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
14248 v2si __builtin_arm_wsubw (v2si, v2si)
14249 v2si __builtin_arm_wsubwss (v2si, v2si)
14250 v2si __builtin_arm_wsubwus (v2si, v2si)
14251 v4hi __builtin_arm_wunpckehsb (v8qi)
14252 v2si __builtin_arm_wunpckehsh (v4hi)
14253 long long __builtin_arm_wunpckehsw (v2si)
14254 v4hi __builtin_arm_wunpckehub (v8qi)
14255 v2si __builtin_arm_wunpckehuh (v4hi)
14256 long long __builtin_arm_wunpckehuw (v2si)
14257 v4hi __builtin_arm_wunpckelsb (v8qi)
14258 v2si __builtin_arm_wunpckelsh (v4hi)
14259 long long __builtin_arm_wunpckelsw (v2si)
14260 v4hi __builtin_arm_wunpckelub (v8qi)
14261 v2si __builtin_arm_wunpckeluh (v4hi)
14262 long long __builtin_arm_wunpckeluw (v2si)
14263 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
14264 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
14265 v2si __builtin_arm_wunpckihw (v2si, v2si)
14266 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
14267 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
14268 v2si __builtin_arm_wunpckilw (v2si, v2si)
14269 long long __builtin_arm_wxor (long long, long long)
14270 long long __builtin_arm_wzero ()
14271 @end smallexample
14272
14273
14274 @node ARM C Language Extensions (ACLE)
14275 @subsection ARM C Language Extensions (ACLE)
14276
14277 GCC implements extensions for C as described in the ARM C Language
14278 Extensions (ACLE) specification, which can be found at
14279 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
14280
14281 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
14282 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
14283 intrinsics can be found at
14284 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
14285 The built-in intrinsics for the Advanced SIMD extension are available when
14286 NEON is enabled.
14287
14288 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
14289 back ends support CRC32 intrinsics and the ARM back end supports the
14290 Coprocessor intrinsics, all from @file{arm_acle.h}. The ARM back end's 16-bit
14291 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
14292 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
14293 intrinsics yet.
14294
14295 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
14296 availability of extensions.
14297
14298 @node ARM Floating Point Status and Control Intrinsics
14299 @subsection ARM Floating Point Status and Control Intrinsics
14300
14301 These built-in functions are available for the ARM family of
14302 processors with floating-point unit.
14303
14304 @smallexample
14305 unsigned int __builtin_arm_get_fpscr ()
14306 void __builtin_arm_set_fpscr (unsigned int)
14307 @end smallexample
14308
14309 @node ARM ARMv8-M Security Extensions
14310 @subsection ARM ARMv8-M Security Extensions
14311
14312 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
14313 Security Extensions: Requirements on Development Tools Engineering
14314 Specification, which can be found at
14315 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
14316
14317 As part of the Security Extensions GCC implements two new function attributes:
14318 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
14319
14320 As part of the Security Extensions GCC implements the intrinsics below. FPTR
14321 is used here to mean any function pointer type.
14322
14323 @smallexample
14324 cmse_address_info_t cmse_TT (void *)
14325 cmse_address_info_t cmse_TT_fptr (FPTR)
14326 cmse_address_info_t cmse_TTT (void *)
14327 cmse_address_info_t cmse_TTT_fptr (FPTR)
14328 cmse_address_info_t cmse_TTA (void *)
14329 cmse_address_info_t cmse_TTA_fptr (FPTR)
14330 cmse_address_info_t cmse_TTAT (void *)
14331 cmse_address_info_t cmse_TTAT_fptr (FPTR)
14332 void * cmse_check_address_range (void *, size_t, int)
14333 typeof(p) cmse_nsfptr_create (FPTR p)
14334 intptr_t cmse_is_nsfptr (FPTR)
14335 int cmse_nonsecure_caller (void)
14336 @end smallexample
14337
14338 @node AVR Built-in Functions
14339 @subsection AVR Built-in Functions
14340
14341 For each built-in function for AVR, there is an equally named,
14342 uppercase built-in macro defined. That way users can easily query if
14343 or if not a specific built-in is implemented or not. For example, if
14344 @code{__builtin_avr_nop} is available the macro
14345 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
14346
14347 @table @code
14348
14349 @item void __builtin_avr_nop (void)
14350 @itemx void __builtin_avr_sei (void)
14351 @itemx void __builtin_avr_cli (void)
14352 @itemx void __builtin_avr_sleep (void)
14353 @itemx void __builtin_avr_wdr (void)
14354 @itemx unsigned char __builtin_avr_swap (unsigned char)
14355 @itemx unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
14356 @itemx int __builtin_avr_fmuls (char, char)
14357 @itemx int __builtin_avr_fmulsu (char, unsigned char)
14358 These built-in functions map to the respective machine
14359 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
14360 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
14361 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
14362 as library call if no hardware multiplier is available.
14363
14364 @item void __builtin_avr_delay_cycles (unsigned long ticks)
14365 Delay execution for @var{ticks} cycles. Note that this
14366 built-in does not take into account the effect of interrupts that
14367 might increase delay time. @var{ticks} must be a compile-time
14368 integer constant; delays with a variable number of cycles are not supported.
14369
14370 @item char __builtin_avr_flash_segment (const __memx void*)
14371 This built-in takes a byte address to the 24-bit
14372 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
14373 the number of the flash segment (the 64 KiB chunk) where the address
14374 points to. Counting starts at @code{0}.
14375 If the address does not point to flash memory, return @code{-1}.
14376
14377 @item uint8_t __builtin_avr_insert_bits (uint32_t map, uint8_t bits, uint8_t val)
14378 Insert bits from @var{bits} into @var{val} and return the resulting
14379 value. The nibbles of @var{map} determine how the insertion is
14380 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
14381 @enumerate
14382 @item If @var{X} is @code{0xf},
14383 then the @var{n}-th bit of @var{val} is returned unaltered.
14384
14385 @item If X is in the range 0@dots{}7,
14386 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
14387
14388 @item If X is in the range 8@dots{}@code{0xe},
14389 then the @var{n}-th result bit is undefined.
14390 @end enumerate
14391
14392 @noindent
14393 One typical use case for this built-in is adjusting input and
14394 output values to non-contiguous port layouts. Some examples:
14395
14396 @smallexample
14397 // same as val, bits is unused
14398 __builtin_avr_insert_bits (0xffffffff, bits, val)
14399 @end smallexample
14400
14401 @smallexample
14402 // same as bits, val is unused
14403 __builtin_avr_insert_bits (0x76543210, bits, val)
14404 @end smallexample
14405
14406 @smallexample
14407 // same as rotating bits by 4
14408 __builtin_avr_insert_bits (0x32107654, bits, 0)
14409 @end smallexample
14410
14411 @smallexample
14412 // high nibble of result is the high nibble of val
14413 // low nibble of result is the low nibble of bits
14414 __builtin_avr_insert_bits (0xffff3210, bits, val)
14415 @end smallexample
14416
14417 @smallexample
14418 // reverse the bit order of bits
14419 __builtin_avr_insert_bits (0x01234567, bits, 0)
14420 @end smallexample
14421
14422 @item void __builtin_avr_nops (unsigned count)
14423 Insert @var{count} @code{NOP} instructions.
14424 The number of instructions must be a compile-time integer constant.
14425
14426 @end table
14427
14428 @noindent
14429 There are many more AVR-specific built-in functions that are used to
14430 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
14431 section 7.18a.6. You don't need to use these built-ins directly.
14432 Instead, use the declarations as supplied by the @code{stdfix.h} header
14433 with GNU-C99:
14434
14435 @smallexample
14436 #include <stdfix.h>
14437
14438 // Re-interpret the bit representation of unsigned 16-bit
14439 // integer @var{uval} as Q-format 0.16 value.
14440 unsigned fract get_bits (uint_ur_t uval)
14441 @{
14442 return urbits (uval);
14443 @}
14444 @end smallexample
14445
14446 @node Blackfin Built-in Functions
14447 @subsection Blackfin Built-in Functions
14448
14449 Currently, there are two Blackfin-specific built-in functions. These are
14450 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
14451 using inline assembly; by using these built-in functions the compiler can
14452 automatically add workarounds for hardware errata involving these
14453 instructions. These functions are named as follows:
14454
14455 @smallexample
14456 void __builtin_bfin_csync (void)
14457 void __builtin_bfin_ssync (void)
14458 @end smallexample
14459
14460 @node FR-V Built-in Functions
14461 @subsection FR-V Built-in Functions
14462
14463 GCC provides many FR-V-specific built-in functions. In general,
14464 these functions are intended to be compatible with those described
14465 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
14466 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
14467 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
14468 pointer rather than by value.
14469
14470 Most of the functions are named after specific FR-V instructions.
14471 Such functions are said to be ``directly mapped'' and are summarized
14472 here in tabular form.
14473
14474 @menu
14475 * Argument Types::
14476 * Directly-mapped Integer Functions::
14477 * Directly-mapped Media Functions::
14478 * Raw read/write Functions::
14479 * Other Built-in Functions::
14480 @end menu
14481
14482 @node Argument Types
14483 @subsubsection Argument Types
14484
14485 The arguments to the built-in functions can be divided into three groups:
14486 register numbers, compile-time constants and run-time values. In order
14487 to make this classification clear at a glance, the arguments and return
14488 values are given the following pseudo types:
14489
14490 @multitable @columnfractions .20 .30 .15 .35
14491 @item Pseudo type @tab Real C type @tab Constant? @tab Description
14492 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
14493 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
14494 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
14495 @item @code{uw2} @tab @code{unsigned long long} @tab No
14496 @tab an unsigned doubleword
14497 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
14498 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
14499 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
14500 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
14501 @end multitable
14502
14503 These pseudo types are not defined by GCC, they are simply a notational
14504 convenience used in this manual.
14505
14506 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
14507 and @code{sw2} are evaluated at run time. They correspond to
14508 register operands in the underlying FR-V instructions.
14509
14510 @code{const} arguments represent immediate operands in the underlying
14511 FR-V instructions. They must be compile-time constants.
14512
14513 @code{acc} arguments are evaluated at compile time and specify the number
14514 of an accumulator register. For example, an @code{acc} argument of 2
14515 selects the ACC2 register.
14516
14517 @code{iacc} arguments are similar to @code{acc} arguments but specify the
14518 number of an IACC register. See @pxref{Other Built-in Functions}
14519 for more details.
14520
14521 @node Directly-mapped Integer Functions
14522 @subsubsection Directly-Mapped Integer Functions
14523
14524 The functions listed below map directly to FR-V I-type instructions.
14525
14526 @multitable @columnfractions .45 .32 .23
14527 @item Function prototype @tab Example usage @tab Assembly output
14528 @item @code{sw1 __ADDSS (sw1, sw1)}
14529 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
14530 @tab @code{ADDSS @var{a},@var{b},@var{c}}
14531 @item @code{sw1 __SCAN (sw1, sw1)}
14532 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
14533 @tab @code{SCAN @var{a},@var{b},@var{c}}
14534 @item @code{sw1 __SCUTSS (sw1)}
14535 @tab @code{@var{b} = __SCUTSS (@var{a})}
14536 @tab @code{SCUTSS @var{a},@var{b}}
14537 @item @code{sw1 __SLASS (sw1, sw1)}
14538 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
14539 @tab @code{SLASS @var{a},@var{b},@var{c}}
14540 @item @code{void __SMASS (sw1, sw1)}
14541 @tab @code{__SMASS (@var{a}, @var{b})}
14542 @tab @code{SMASS @var{a},@var{b}}
14543 @item @code{void __SMSSS (sw1, sw1)}
14544 @tab @code{__SMSSS (@var{a}, @var{b})}
14545 @tab @code{SMSSS @var{a},@var{b}}
14546 @item @code{void __SMU (sw1, sw1)}
14547 @tab @code{__SMU (@var{a}, @var{b})}
14548 @tab @code{SMU @var{a},@var{b}}
14549 @item @code{sw2 __SMUL (sw1, sw1)}
14550 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
14551 @tab @code{SMUL @var{a},@var{b},@var{c}}
14552 @item @code{sw1 __SUBSS (sw1, sw1)}
14553 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
14554 @tab @code{SUBSS @var{a},@var{b},@var{c}}
14555 @item @code{uw2 __UMUL (uw1, uw1)}
14556 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
14557 @tab @code{UMUL @var{a},@var{b},@var{c}}
14558 @end multitable
14559
14560 @node Directly-mapped Media Functions
14561 @subsubsection Directly-Mapped Media Functions
14562
14563 The functions listed below map directly to FR-V M-type instructions.
14564
14565 @multitable @columnfractions .45 .32 .23
14566 @item Function prototype @tab Example usage @tab Assembly output
14567 @item @code{uw1 __MABSHS (sw1)}
14568 @tab @code{@var{b} = __MABSHS (@var{a})}
14569 @tab @code{MABSHS @var{a},@var{b}}
14570 @item @code{void __MADDACCS (acc, acc)}
14571 @tab @code{__MADDACCS (@var{b}, @var{a})}
14572 @tab @code{MADDACCS @var{a},@var{b}}
14573 @item @code{sw1 __MADDHSS (sw1, sw1)}
14574 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
14575 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
14576 @item @code{uw1 __MADDHUS (uw1, uw1)}
14577 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
14578 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
14579 @item @code{uw1 __MAND (uw1, uw1)}
14580 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
14581 @tab @code{MAND @var{a},@var{b},@var{c}}
14582 @item @code{void __MASACCS (acc, acc)}
14583 @tab @code{__MASACCS (@var{b}, @var{a})}
14584 @tab @code{MASACCS @var{a},@var{b}}
14585 @item @code{uw1 __MAVEH (uw1, uw1)}
14586 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
14587 @tab @code{MAVEH @var{a},@var{b},@var{c}}
14588 @item @code{uw2 __MBTOH (uw1)}
14589 @tab @code{@var{b} = __MBTOH (@var{a})}
14590 @tab @code{MBTOH @var{a},@var{b}}
14591 @item @code{void __MBTOHE (uw1 *, uw1)}
14592 @tab @code{__MBTOHE (&@var{b}, @var{a})}
14593 @tab @code{MBTOHE @var{a},@var{b}}
14594 @item @code{void __MCLRACC (acc)}
14595 @tab @code{__MCLRACC (@var{a})}
14596 @tab @code{MCLRACC @var{a}}
14597 @item @code{void __MCLRACCA (void)}
14598 @tab @code{__MCLRACCA ()}
14599 @tab @code{MCLRACCA}
14600 @item @code{uw1 __Mcop1 (uw1, uw1)}
14601 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
14602 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
14603 @item @code{uw1 __Mcop2 (uw1, uw1)}
14604 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
14605 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
14606 @item @code{uw1 __MCPLHI (uw2, const)}
14607 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
14608 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
14609 @item @code{uw1 __MCPLI (uw2, const)}
14610 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
14611 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
14612 @item @code{void __MCPXIS (acc, sw1, sw1)}
14613 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
14614 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
14615 @item @code{void __MCPXIU (acc, uw1, uw1)}
14616 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
14617 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
14618 @item @code{void __MCPXRS (acc, sw1, sw1)}
14619 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
14620 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
14621 @item @code{void __MCPXRU (acc, uw1, uw1)}
14622 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
14623 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
14624 @item @code{uw1 __MCUT (acc, uw1)}
14625 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
14626 @tab @code{MCUT @var{a},@var{b},@var{c}}
14627 @item @code{uw1 __MCUTSS (acc, sw1)}
14628 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
14629 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
14630 @item @code{void __MDADDACCS (acc, acc)}
14631 @tab @code{__MDADDACCS (@var{b}, @var{a})}
14632 @tab @code{MDADDACCS @var{a},@var{b}}
14633 @item @code{void __MDASACCS (acc, acc)}
14634 @tab @code{__MDASACCS (@var{b}, @var{a})}
14635 @tab @code{MDASACCS @var{a},@var{b}}
14636 @item @code{uw2 __MDCUTSSI (acc, const)}
14637 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
14638 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
14639 @item @code{uw2 __MDPACKH (uw2, uw2)}
14640 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
14641 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
14642 @item @code{uw2 __MDROTLI (uw2, const)}
14643 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
14644 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
14645 @item @code{void __MDSUBACCS (acc, acc)}
14646 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
14647 @tab @code{MDSUBACCS @var{a},@var{b}}
14648 @item @code{void __MDUNPACKH (uw1 *, uw2)}
14649 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
14650 @tab @code{MDUNPACKH @var{a},@var{b}}
14651 @item @code{uw2 __MEXPDHD (uw1, const)}
14652 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
14653 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
14654 @item @code{uw1 __MEXPDHW (uw1, const)}
14655 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
14656 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
14657 @item @code{uw1 __MHDSETH (uw1, const)}
14658 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
14659 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
14660 @item @code{sw1 __MHDSETS (const)}
14661 @tab @code{@var{b} = __MHDSETS (@var{a})}
14662 @tab @code{MHDSETS #@var{a},@var{b}}
14663 @item @code{uw1 __MHSETHIH (uw1, const)}
14664 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
14665 @tab @code{MHSETHIH #@var{a},@var{b}}
14666 @item @code{sw1 __MHSETHIS (sw1, const)}
14667 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
14668 @tab @code{MHSETHIS #@var{a},@var{b}}
14669 @item @code{uw1 __MHSETLOH (uw1, const)}
14670 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
14671 @tab @code{MHSETLOH #@var{a},@var{b}}
14672 @item @code{sw1 __MHSETLOS (sw1, const)}
14673 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
14674 @tab @code{MHSETLOS #@var{a},@var{b}}
14675 @item @code{uw1 __MHTOB (uw2)}
14676 @tab @code{@var{b} = __MHTOB (@var{a})}
14677 @tab @code{MHTOB @var{a},@var{b}}
14678 @item @code{void __MMACHS (acc, sw1, sw1)}
14679 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
14680 @tab @code{MMACHS @var{a},@var{b},@var{c}}
14681 @item @code{void __MMACHU (acc, uw1, uw1)}
14682 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
14683 @tab @code{MMACHU @var{a},@var{b},@var{c}}
14684 @item @code{void __MMRDHS (acc, sw1, sw1)}
14685 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
14686 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
14687 @item @code{void __MMRDHU (acc, uw1, uw1)}
14688 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
14689 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
14690 @item @code{void __MMULHS (acc, sw1, sw1)}
14691 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
14692 @tab @code{MMULHS @var{a},@var{b},@var{c}}
14693 @item @code{void __MMULHU (acc, uw1, uw1)}
14694 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
14695 @tab @code{MMULHU @var{a},@var{b},@var{c}}
14696 @item @code{void __MMULXHS (acc, sw1, sw1)}
14697 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
14698 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
14699 @item @code{void __MMULXHU (acc, uw1, uw1)}
14700 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
14701 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
14702 @item @code{uw1 __MNOT (uw1)}
14703 @tab @code{@var{b} = __MNOT (@var{a})}
14704 @tab @code{MNOT @var{a},@var{b}}
14705 @item @code{uw1 __MOR (uw1, uw1)}
14706 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
14707 @tab @code{MOR @var{a},@var{b},@var{c}}
14708 @item @code{uw1 __MPACKH (uh, uh)}
14709 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
14710 @tab @code{MPACKH @var{a},@var{b},@var{c}}
14711 @item @code{sw2 __MQADDHSS (sw2, sw2)}
14712 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
14713 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
14714 @item @code{uw2 __MQADDHUS (uw2, uw2)}
14715 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
14716 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
14717 @item @code{void __MQCPXIS (acc, sw2, sw2)}
14718 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
14719 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
14720 @item @code{void __MQCPXIU (acc, uw2, uw2)}
14721 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
14722 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
14723 @item @code{void __MQCPXRS (acc, sw2, sw2)}
14724 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
14725 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
14726 @item @code{void __MQCPXRU (acc, uw2, uw2)}
14727 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
14728 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
14729 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
14730 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
14731 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
14732 @item @code{sw2 __MQLMTHS (sw2, sw2)}
14733 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
14734 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
14735 @item @code{void __MQMACHS (acc, sw2, sw2)}
14736 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
14737 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
14738 @item @code{void __MQMACHU (acc, uw2, uw2)}
14739 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
14740 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
14741 @item @code{void __MQMACXHS (acc, sw2, sw2)}
14742 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
14743 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
14744 @item @code{void __MQMULHS (acc, sw2, sw2)}
14745 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
14746 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
14747 @item @code{void __MQMULHU (acc, uw2, uw2)}
14748 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
14749 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
14750 @item @code{void __MQMULXHS (acc, sw2, sw2)}
14751 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
14752 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
14753 @item @code{void __MQMULXHU (acc, uw2, uw2)}
14754 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
14755 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
14756 @item @code{sw2 __MQSATHS (sw2, sw2)}
14757 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
14758 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
14759 @item @code{uw2 __MQSLLHI (uw2, int)}
14760 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
14761 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
14762 @item @code{sw2 __MQSRAHI (sw2, int)}
14763 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
14764 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
14765 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
14766 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
14767 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
14768 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
14769 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
14770 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
14771 @item @code{void __MQXMACHS (acc, sw2, sw2)}
14772 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
14773 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
14774 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
14775 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
14776 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
14777 @item @code{uw1 __MRDACC (acc)}
14778 @tab @code{@var{b} = __MRDACC (@var{a})}
14779 @tab @code{MRDACC @var{a},@var{b}}
14780 @item @code{uw1 __MRDACCG (acc)}
14781 @tab @code{@var{b} = __MRDACCG (@var{a})}
14782 @tab @code{MRDACCG @var{a},@var{b}}
14783 @item @code{uw1 __MROTLI (uw1, const)}
14784 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
14785 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
14786 @item @code{uw1 __MROTRI (uw1, const)}
14787 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
14788 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
14789 @item @code{sw1 __MSATHS (sw1, sw1)}
14790 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
14791 @tab @code{MSATHS @var{a},@var{b},@var{c}}
14792 @item @code{uw1 __MSATHU (uw1, uw1)}
14793 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
14794 @tab @code{MSATHU @var{a},@var{b},@var{c}}
14795 @item @code{uw1 __MSLLHI (uw1, const)}
14796 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
14797 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
14798 @item @code{sw1 __MSRAHI (sw1, const)}
14799 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
14800 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
14801 @item @code{uw1 __MSRLHI (uw1, const)}
14802 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
14803 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
14804 @item @code{void __MSUBACCS (acc, acc)}
14805 @tab @code{__MSUBACCS (@var{b}, @var{a})}
14806 @tab @code{MSUBACCS @var{a},@var{b}}
14807 @item @code{sw1 __MSUBHSS (sw1, sw1)}
14808 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
14809 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
14810 @item @code{uw1 __MSUBHUS (uw1, uw1)}
14811 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
14812 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
14813 @item @code{void __MTRAP (void)}
14814 @tab @code{__MTRAP ()}
14815 @tab @code{MTRAP}
14816 @item @code{uw2 __MUNPACKH (uw1)}
14817 @tab @code{@var{b} = __MUNPACKH (@var{a})}
14818 @tab @code{MUNPACKH @var{a},@var{b}}
14819 @item @code{uw1 __MWCUT (uw2, uw1)}
14820 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
14821 @tab @code{MWCUT @var{a},@var{b},@var{c}}
14822 @item @code{void __MWTACC (acc, uw1)}
14823 @tab @code{__MWTACC (@var{b}, @var{a})}
14824 @tab @code{MWTACC @var{a},@var{b}}
14825 @item @code{void __MWTACCG (acc, uw1)}
14826 @tab @code{__MWTACCG (@var{b}, @var{a})}
14827 @tab @code{MWTACCG @var{a},@var{b}}
14828 @item @code{uw1 __MXOR (uw1, uw1)}
14829 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
14830 @tab @code{MXOR @var{a},@var{b},@var{c}}
14831 @end multitable
14832
14833 @node Raw read/write Functions
14834 @subsubsection Raw Read/Write Functions
14835
14836 This sections describes built-in functions related to read and write
14837 instructions to access memory. These functions generate
14838 @code{membar} instructions to flush the I/O load and stores where
14839 appropriate, as described in Fujitsu's manual described above.
14840
14841 @table @code
14842
14843 @item unsigned char __builtin_read8 (void *@var{data})
14844 @item unsigned short __builtin_read16 (void *@var{data})
14845 @item unsigned long __builtin_read32 (void *@var{data})
14846 @item unsigned long long __builtin_read64 (void *@var{data})
14847
14848 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
14849 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
14850 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
14851 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
14852 @end table
14853
14854 @node Other Built-in Functions
14855 @subsubsection Other Built-in Functions
14856
14857 This section describes built-in functions that are not named after
14858 a specific FR-V instruction.
14859
14860 @table @code
14861 @item sw2 __IACCreadll (iacc @var{reg})
14862 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
14863 for future expansion and must be 0.
14864
14865 @item sw1 __IACCreadl (iacc @var{reg})
14866 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
14867 Other values of @var{reg} are rejected as invalid.
14868
14869 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
14870 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
14871 is reserved for future expansion and must be 0.
14872
14873 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
14874 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
14875 is 1. Other values of @var{reg} are rejected as invalid.
14876
14877 @item void __data_prefetch0 (const void *@var{x})
14878 Use the @code{dcpl} instruction to load the contents of address @var{x}
14879 into the data cache.
14880
14881 @item void __data_prefetch (const void *@var{x})
14882 Use the @code{nldub} instruction to load the contents of address @var{x}
14883 into the data cache. The instruction is issued in slot I1@.
14884 @end table
14885
14886 @node MIPS DSP Built-in Functions
14887 @subsection MIPS DSP Built-in Functions
14888
14889 The MIPS DSP Application-Specific Extension (ASE) includes new
14890 instructions that are designed to improve the performance of DSP and
14891 media applications. It provides instructions that operate on packed
14892 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
14893
14894 GCC supports MIPS DSP operations using both the generic
14895 vector extensions (@pxref{Vector Extensions}) and a collection of
14896 MIPS-specific built-in functions. Both kinds of support are
14897 enabled by the @option{-mdsp} command-line option.
14898
14899 Revision 2 of the ASE was introduced in the second half of 2006.
14900 This revision adds extra instructions to the original ASE, but is
14901 otherwise backwards-compatible with it. You can select revision 2
14902 using the command-line option @option{-mdspr2}; this option implies
14903 @option{-mdsp}.
14904
14905 The SCOUNT and POS bits of the DSP control register are global. The
14906 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
14907 POS bits. During optimization, the compiler does not delete these
14908 instructions and it does not delete calls to functions containing
14909 these instructions.
14910
14911 At present, GCC only provides support for operations on 32-bit
14912 vectors. The vector type associated with 8-bit integer data is
14913 usually called @code{v4i8}, the vector type associated with Q7
14914 is usually called @code{v4q7}, the vector type associated with 16-bit
14915 integer data is usually called @code{v2i16}, and the vector type
14916 associated with Q15 is usually called @code{v2q15}. They can be
14917 defined in C as follows:
14918
14919 @smallexample
14920 typedef signed char v4i8 __attribute__ ((vector_size(4)));
14921 typedef signed char v4q7 __attribute__ ((vector_size(4)));
14922 typedef short v2i16 __attribute__ ((vector_size(4)));
14923 typedef short v2q15 __attribute__ ((vector_size(4)));
14924 @end smallexample
14925
14926 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
14927 initialized in the same way as aggregates. For example:
14928
14929 @smallexample
14930 v4i8 a = @{1, 2, 3, 4@};
14931 v4i8 b;
14932 b = (v4i8) @{5, 6, 7, 8@};
14933
14934 v2q15 c = @{0x0fcb, 0x3a75@};
14935 v2q15 d;
14936 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
14937 @end smallexample
14938
14939 @emph{Note:} The CPU's endianness determines the order in which values
14940 are packed. On little-endian targets, the first value is the least
14941 significant and the last value is the most significant. The opposite
14942 order applies to big-endian targets. For example, the code above
14943 sets the lowest byte of @code{a} to @code{1} on little-endian targets
14944 and @code{4} on big-endian targets.
14945
14946 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
14947 representation. As shown in this example, the integer representation
14948 of a Q7 value can be obtained by multiplying the fractional value by
14949 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
14950 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
14951 @code{0x1.0p31}.
14952
14953 The table below lists the @code{v4i8} and @code{v2q15} operations for which
14954 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
14955 and @code{c} and @code{d} are @code{v2q15} values.
14956
14957 @multitable @columnfractions .50 .50
14958 @item C code @tab MIPS instruction
14959 @item @code{a + b} @tab @code{addu.qb}
14960 @item @code{c + d} @tab @code{addq.ph}
14961 @item @code{a - b} @tab @code{subu.qb}
14962 @item @code{c - d} @tab @code{subq.ph}
14963 @end multitable
14964
14965 The table below lists the @code{v2i16} operation for which
14966 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
14967 @code{v2i16} values.
14968
14969 @multitable @columnfractions .50 .50
14970 @item C code @tab MIPS instruction
14971 @item @code{e * f} @tab @code{mul.ph}
14972 @end multitable
14973
14974 It is easier to describe the DSP built-in functions if we first define
14975 the following types:
14976
14977 @smallexample
14978 typedef int q31;
14979 typedef int i32;
14980 typedef unsigned int ui32;
14981 typedef long long a64;
14982 @end smallexample
14983
14984 @code{q31} and @code{i32} are actually the same as @code{int}, but we
14985 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
14986 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
14987 @code{long long}, but we use @code{a64} to indicate values that are
14988 placed in one of the four DSP accumulators (@code{$ac0},
14989 @code{$ac1}, @code{$ac2} or @code{$ac3}).
14990
14991 Also, some built-in functions prefer or require immediate numbers as
14992 parameters, because the corresponding DSP instructions accept both immediate
14993 numbers and register operands, or accept immediate numbers only. The
14994 immediate parameters are listed as follows.
14995
14996 @smallexample
14997 imm0_3: 0 to 3.
14998 imm0_7: 0 to 7.
14999 imm0_15: 0 to 15.
15000 imm0_31: 0 to 31.
15001 imm0_63: 0 to 63.
15002 imm0_255: 0 to 255.
15003 imm_n32_31: -32 to 31.
15004 imm_n512_511: -512 to 511.
15005 @end smallexample
15006
15007 The following built-in functions map directly to a particular MIPS DSP
15008 instruction. Please refer to the architecture specification
15009 for details on what each instruction does.
15010
15011 @smallexample
15012 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
15013 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
15014 q31 __builtin_mips_addq_s_w (q31, q31)
15015 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
15016 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
15017 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
15018 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
15019 q31 __builtin_mips_subq_s_w (q31, q31)
15020 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
15021 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
15022 i32 __builtin_mips_addsc (i32, i32)
15023 i32 __builtin_mips_addwc (i32, i32)
15024 i32 __builtin_mips_modsub (i32, i32)
15025 i32 __builtin_mips_raddu_w_qb (v4i8)
15026 v2q15 __builtin_mips_absq_s_ph (v2q15)
15027 q31 __builtin_mips_absq_s_w (q31)
15028 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
15029 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
15030 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
15031 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
15032 q31 __builtin_mips_preceq_w_phl (v2q15)
15033 q31 __builtin_mips_preceq_w_phr (v2q15)
15034 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
15035 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
15036 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
15037 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
15038 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
15039 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
15040 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
15041 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
15042 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
15043 v4i8 __builtin_mips_shll_qb (v4i8, i32)
15044 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
15045 v2q15 __builtin_mips_shll_ph (v2q15, i32)
15046 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
15047 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
15048 q31 __builtin_mips_shll_s_w (q31, imm0_31)
15049 q31 __builtin_mips_shll_s_w (q31, i32)
15050 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
15051 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
15052 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
15053 v2q15 __builtin_mips_shra_ph (v2q15, i32)
15054 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
15055 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
15056 q31 __builtin_mips_shra_r_w (q31, imm0_31)
15057 q31 __builtin_mips_shra_r_w (q31, i32)
15058 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
15059 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
15060 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
15061 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
15062 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
15063 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
15064 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
15065 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
15066 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
15067 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
15068 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
15069 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
15070 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
15071 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
15072 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
15073 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
15074 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
15075 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
15076 i32 __builtin_mips_bitrev (i32)
15077 i32 __builtin_mips_insv (i32, i32)
15078 v4i8 __builtin_mips_repl_qb (imm0_255)
15079 v4i8 __builtin_mips_repl_qb (i32)
15080 v2q15 __builtin_mips_repl_ph (imm_n512_511)
15081 v2q15 __builtin_mips_repl_ph (i32)
15082 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
15083 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
15084 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
15085 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
15086 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
15087 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
15088 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
15089 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
15090 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
15091 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
15092 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
15093 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
15094 i32 __builtin_mips_extr_w (a64, imm0_31)
15095 i32 __builtin_mips_extr_w (a64, i32)
15096 i32 __builtin_mips_extr_r_w (a64, imm0_31)
15097 i32 __builtin_mips_extr_s_h (a64, i32)
15098 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
15099 i32 __builtin_mips_extr_rs_w (a64, i32)
15100 i32 __builtin_mips_extr_s_h (a64, imm0_31)
15101 i32 __builtin_mips_extr_r_w (a64, i32)
15102 i32 __builtin_mips_extp (a64, imm0_31)
15103 i32 __builtin_mips_extp (a64, i32)
15104 i32 __builtin_mips_extpdp (a64, imm0_31)
15105 i32 __builtin_mips_extpdp (a64, i32)
15106 a64 __builtin_mips_shilo (a64, imm_n32_31)
15107 a64 __builtin_mips_shilo (a64, i32)
15108 a64 __builtin_mips_mthlip (a64, i32)
15109 void __builtin_mips_wrdsp (i32, imm0_63)
15110 i32 __builtin_mips_rddsp (imm0_63)
15111 i32 __builtin_mips_lbux (void *, i32)
15112 i32 __builtin_mips_lhx (void *, i32)
15113 i32 __builtin_mips_lwx (void *, i32)
15114 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
15115 i32 __builtin_mips_bposge32 (void)
15116 a64 __builtin_mips_madd (a64, i32, i32);
15117 a64 __builtin_mips_maddu (a64, ui32, ui32);
15118 a64 __builtin_mips_msub (a64, i32, i32);
15119 a64 __builtin_mips_msubu (a64, ui32, ui32);
15120 a64 __builtin_mips_mult (i32, i32);
15121 a64 __builtin_mips_multu (ui32, ui32);
15122 @end smallexample
15123
15124 The following built-in functions map directly to a particular MIPS DSP REV 2
15125 instruction. Please refer to the architecture specification
15126 for details on what each instruction does.
15127
15128 @smallexample
15129 v4q7 __builtin_mips_absq_s_qb (v4q7);
15130 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
15131 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
15132 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
15133 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
15134 i32 __builtin_mips_append (i32, i32, imm0_31);
15135 i32 __builtin_mips_balign (i32, i32, imm0_3);
15136 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
15137 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
15138 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
15139 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
15140 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
15141 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
15142 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
15143 q31 __builtin_mips_mulq_rs_w (q31, q31);
15144 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
15145 q31 __builtin_mips_mulq_s_w (q31, q31);
15146 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
15147 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
15148 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
15149 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
15150 i32 __builtin_mips_prepend (i32, i32, imm0_31);
15151 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
15152 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
15153 v4i8 __builtin_mips_shra_qb (v4i8, i32);
15154 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
15155 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
15156 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
15157 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
15158 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
15159 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
15160 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
15161 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
15162 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
15163 q31 __builtin_mips_addqh_w (q31, q31);
15164 q31 __builtin_mips_addqh_r_w (q31, q31);
15165 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
15166 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
15167 q31 __builtin_mips_subqh_w (q31, q31);
15168 q31 __builtin_mips_subqh_r_w (q31, q31);
15169 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
15170 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
15171 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
15172 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
15173 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
15174 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
15175 @end smallexample
15176
15177
15178 @node MIPS Paired-Single Support
15179 @subsection MIPS Paired-Single Support
15180
15181 The MIPS64 architecture includes a number of instructions that
15182 operate on pairs of single-precision floating-point values.
15183 Each pair is packed into a 64-bit floating-point register,
15184 with one element being designated the ``upper half'' and
15185 the other being designated the ``lower half''.
15186
15187 GCC supports paired-single operations using both the generic
15188 vector extensions (@pxref{Vector Extensions}) and a collection of
15189 MIPS-specific built-in functions. Both kinds of support are
15190 enabled by the @option{-mpaired-single} command-line option.
15191
15192 The vector type associated with paired-single values is usually
15193 called @code{v2sf}. It can be defined in C as follows:
15194
15195 @smallexample
15196 typedef float v2sf __attribute__ ((vector_size (8)));
15197 @end smallexample
15198
15199 @code{v2sf} values are initialized in the same way as aggregates.
15200 For example:
15201
15202 @smallexample
15203 v2sf a = @{1.5, 9.1@};
15204 v2sf b;
15205 float e, f;
15206 b = (v2sf) @{e, f@};
15207 @end smallexample
15208
15209 @emph{Note:} The CPU's endianness determines which value is stored in
15210 the upper half of a register and which value is stored in the lower half.
15211 On little-endian targets, the first value is the lower one and the second
15212 value is the upper one. The opposite order applies to big-endian targets.
15213 For example, the code above sets the lower half of @code{a} to
15214 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
15215
15216 @node MIPS Loongson Built-in Functions
15217 @subsection MIPS Loongson Built-in Functions
15218
15219 GCC provides intrinsics to access the SIMD instructions provided by the
15220 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
15221 available after inclusion of the @code{loongson.h} header file,
15222 operate on the following 64-bit vector types:
15223
15224 @itemize
15225 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
15226 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
15227 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
15228 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
15229 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
15230 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
15231 @end itemize
15232
15233 The intrinsics provided are listed below; each is named after the
15234 machine instruction to which it corresponds, with suffixes added as
15235 appropriate to distinguish intrinsics that expand to the same machine
15236 instruction yet have different argument types. Refer to the architecture
15237 documentation for a description of the functionality of each
15238 instruction.
15239
15240 @smallexample
15241 int16x4_t packsswh (int32x2_t s, int32x2_t t);
15242 int8x8_t packsshb (int16x4_t s, int16x4_t t);
15243 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
15244 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
15245 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
15246 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
15247 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
15248 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
15249 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
15250 uint64_t paddd_u (uint64_t s, uint64_t t);
15251 int64_t paddd_s (int64_t s, int64_t t);
15252 int16x4_t paddsh (int16x4_t s, int16x4_t t);
15253 int8x8_t paddsb (int8x8_t s, int8x8_t t);
15254 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
15255 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
15256 uint64_t pandn_ud (uint64_t s, uint64_t t);
15257 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
15258 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
15259 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
15260 int64_t pandn_sd (int64_t s, int64_t t);
15261 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
15262 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
15263 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
15264 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
15265 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
15266 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
15267 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
15268 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
15269 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
15270 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
15271 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
15272 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
15273 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
15274 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
15275 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
15276 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
15277 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
15278 uint16x4_t pextrh_u (uint16x4_t s, int field);
15279 int16x4_t pextrh_s (int16x4_t s, int field);
15280 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
15281 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
15282 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
15283 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
15284 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
15285 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
15286 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
15287 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
15288 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
15289 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
15290 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
15291 int16x4_t pminsh (int16x4_t s, int16x4_t t);
15292 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
15293 uint8x8_t pmovmskb_u (uint8x8_t s);
15294 int8x8_t pmovmskb_s (int8x8_t s);
15295 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
15296 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
15297 int16x4_t pmullh (int16x4_t s, int16x4_t t);
15298 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
15299 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
15300 uint16x4_t biadd (uint8x8_t s);
15301 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
15302 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
15303 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
15304 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
15305 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
15306 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
15307 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
15308 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
15309 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
15310 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
15311 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
15312 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
15313 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
15314 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
15315 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
15316 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
15317 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
15318 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
15319 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
15320 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
15321 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
15322 uint64_t psubd_u (uint64_t s, uint64_t t);
15323 int64_t psubd_s (int64_t s, int64_t t);
15324 int16x4_t psubsh (int16x4_t s, int16x4_t t);
15325 int8x8_t psubsb (int8x8_t s, int8x8_t t);
15326 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
15327 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
15328 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
15329 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
15330 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
15331 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
15332 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
15333 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
15334 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
15335 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
15336 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
15337 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
15338 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
15339 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
15340 @end smallexample
15341
15342 @menu
15343 * Paired-Single Arithmetic::
15344 * Paired-Single Built-in Functions::
15345 * MIPS-3D Built-in Functions::
15346 @end menu
15347
15348 @node Paired-Single Arithmetic
15349 @subsubsection Paired-Single Arithmetic
15350
15351 The table below lists the @code{v2sf} operations for which hardware
15352 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
15353 values and @code{x} is an integral value.
15354
15355 @multitable @columnfractions .50 .50
15356 @item C code @tab MIPS instruction
15357 @item @code{a + b} @tab @code{add.ps}
15358 @item @code{a - b} @tab @code{sub.ps}
15359 @item @code{-a} @tab @code{neg.ps}
15360 @item @code{a * b} @tab @code{mul.ps}
15361 @item @code{a * b + c} @tab @code{madd.ps}
15362 @item @code{a * b - c} @tab @code{msub.ps}
15363 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
15364 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
15365 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
15366 @end multitable
15367
15368 Note that the multiply-accumulate instructions can be disabled
15369 using the command-line option @code{-mno-fused-madd}.
15370
15371 @node Paired-Single Built-in Functions
15372 @subsubsection Paired-Single Built-in Functions
15373
15374 The following paired-single functions map directly to a particular
15375 MIPS instruction. Please refer to the architecture specification
15376 for details on what each instruction does.
15377
15378 @table @code
15379 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
15380 Pair lower lower (@code{pll.ps}).
15381
15382 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
15383 Pair upper lower (@code{pul.ps}).
15384
15385 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
15386 Pair lower upper (@code{plu.ps}).
15387
15388 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
15389 Pair upper upper (@code{puu.ps}).
15390
15391 @item v2sf __builtin_mips_cvt_ps_s (float, float)
15392 Convert pair to paired single (@code{cvt.ps.s}).
15393
15394 @item float __builtin_mips_cvt_s_pl (v2sf)
15395 Convert pair lower to single (@code{cvt.s.pl}).
15396
15397 @item float __builtin_mips_cvt_s_pu (v2sf)
15398 Convert pair upper to single (@code{cvt.s.pu}).
15399
15400 @item v2sf __builtin_mips_abs_ps (v2sf)
15401 Absolute value (@code{abs.ps}).
15402
15403 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
15404 Align variable (@code{alnv.ps}).
15405
15406 @emph{Note:} The value of the third parameter must be 0 or 4
15407 modulo 8, otherwise the result is unpredictable. Please read the
15408 instruction description for details.
15409 @end table
15410
15411 The following multi-instruction functions are also available.
15412 In each case, @var{cond} can be any of the 16 floating-point conditions:
15413 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
15414 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
15415 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
15416
15417 @table @code
15418 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15419 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15420 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
15421 @code{movt.ps}/@code{movf.ps}).
15422
15423 The @code{movt} functions return the value @var{x} computed by:
15424
15425 @smallexample
15426 c.@var{cond}.ps @var{cc},@var{a},@var{b}
15427 mov.ps @var{x},@var{c}
15428 movt.ps @var{x},@var{d},@var{cc}
15429 @end smallexample
15430
15431 The @code{movf} functions are similar but use @code{movf.ps} instead
15432 of @code{movt.ps}.
15433
15434 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15435 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15436 Comparison of two paired-single values (@code{c.@var{cond}.ps},
15437 @code{bc1t}/@code{bc1f}).
15438
15439 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
15440 and return either the upper or lower half of the result. For example:
15441
15442 @smallexample
15443 v2sf a, b;
15444 if (__builtin_mips_upper_c_eq_ps (a, b))
15445 upper_halves_are_equal ();
15446 else
15447 upper_halves_are_unequal ();
15448
15449 if (__builtin_mips_lower_c_eq_ps (a, b))
15450 lower_halves_are_equal ();
15451 else
15452 lower_halves_are_unequal ();
15453 @end smallexample
15454 @end table
15455
15456 @node MIPS-3D Built-in Functions
15457 @subsubsection MIPS-3D Built-in Functions
15458
15459 The MIPS-3D Application-Specific Extension (ASE) includes additional
15460 paired-single instructions that are designed to improve the performance
15461 of 3D graphics operations. Support for these instructions is controlled
15462 by the @option{-mips3d} command-line option.
15463
15464 The functions listed below map directly to a particular MIPS-3D
15465 instruction. Please refer to the architecture specification for
15466 more details on what each instruction does.
15467
15468 @table @code
15469 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
15470 Reduction add (@code{addr.ps}).
15471
15472 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
15473 Reduction multiply (@code{mulr.ps}).
15474
15475 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
15476 Convert paired single to paired word (@code{cvt.pw.ps}).
15477
15478 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
15479 Convert paired word to paired single (@code{cvt.ps.pw}).
15480
15481 @item float __builtin_mips_recip1_s (float)
15482 @itemx double __builtin_mips_recip1_d (double)
15483 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
15484 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
15485
15486 @item float __builtin_mips_recip2_s (float, float)
15487 @itemx double __builtin_mips_recip2_d (double, double)
15488 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
15489 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
15490
15491 @item float __builtin_mips_rsqrt1_s (float)
15492 @itemx double __builtin_mips_rsqrt1_d (double)
15493 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
15494 Reduced-precision reciprocal square root (sequence step 1)
15495 (@code{rsqrt1.@var{fmt}}).
15496
15497 @item float __builtin_mips_rsqrt2_s (float, float)
15498 @itemx double __builtin_mips_rsqrt2_d (double, double)
15499 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
15500 Reduced-precision reciprocal square root (sequence step 2)
15501 (@code{rsqrt2.@var{fmt}}).
15502 @end table
15503
15504 The following multi-instruction functions are also available.
15505 In each case, @var{cond} can be any of the 16 floating-point conditions:
15506 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
15507 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
15508 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
15509
15510 @table @code
15511 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
15512 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
15513 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
15514 @code{bc1t}/@code{bc1f}).
15515
15516 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
15517 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
15518 For example:
15519
15520 @smallexample
15521 float a, b;
15522 if (__builtin_mips_cabs_eq_s (a, b))
15523 true ();
15524 else
15525 false ();
15526 @end smallexample
15527
15528 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15529 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15530 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
15531 @code{bc1t}/@code{bc1f}).
15532
15533 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
15534 and return either the upper or lower half of the result. For example:
15535
15536 @smallexample
15537 v2sf a, b;
15538 if (__builtin_mips_upper_cabs_eq_ps (a, b))
15539 upper_halves_are_equal ();
15540 else
15541 upper_halves_are_unequal ();
15542
15543 if (__builtin_mips_lower_cabs_eq_ps (a, b))
15544 lower_halves_are_equal ();
15545 else
15546 lower_halves_are_unequal ();
15547 @end smallexample
15548
15549 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15550 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15551 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
15552 @code{movt.ps}/@code{movf.ps}).
15553
15554 The @code{movt} functions return the value @var{x} computed by:
15555
15556 @smallexample
15557 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
15558 mov.ps @var{x},@var{c}
15559 movt.ps @var{x},@var{d},@var{cc}
15560 @end smallexample
15561
15562 The @code{movf} functions are similar but use @code{movf.ps} instead
15563 of @code{movt.ps}.
15564
15565 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15566 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15567 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15568 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15569 Comparison of two paired-single values
15570 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
15571 @code{bc1any2t}/@code{bc1any2f}).
15572
15573 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
15574 or @code{cabs.@var{cond}.ps}. The @code{any} forms return @code{true} if either
15575 result is @code{true} and the @code{all} forms return @code{true} if both results are @code{true}.
15576 For example:
15577
15578 @smallexample
15579 v2sf a, b;
15580 if (__builtin_mips_any_c_eq_ps (a, b))
15581 one_is_true ();
15582 else
15583 both_are_false ();
15584
15585 if (__builtin_mips_all_c_eq_ps (a, b))
15586 both_are_true ();
15587 else
15588 one_is_false ();
15589 @end smallexample
15590
15591 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15592 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15593 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15594 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15595 Comparison of four paired-single values
15596 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
15597 @code{bc1any4t}/@code{bc1any4f}).
15598
15599 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
15600 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
15601 The @code{any} forms return @code{true} if any of the four results are @code{true}
15602 and the @code{all} forms return @code{true} if all four results are @code{true}.
15603 For example:
15604
15605 @smallexample
15606 v2sf a, b, c, d;
15607 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
15608 some_are_true ();
15609 else
15610 all_are_false ();
15611
15612 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
15613 all_are_true ();
15614 else
15615 some_are_false ();
15616 @end smallexample
15617 @end table
15618
15619 @node MIPS SIMD Architecture (MSA) Support
15620 @subsection MIPS SIMD Architecture (MSA) Support
15621
15622 @menu
15623 * MIPS SIMD Architecture Built-in Functions::
15624 @end menu
15625
15626 GCC provides intrinsics to access the SIMD instructions provided by the
15627 MSA MIPS SIMD Architecture. The interface is made available by including
15628 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
15629 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
15630 @code{__msa_*}.
15631
15632 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
15633 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
15634 data elements. The following vectors typedefs are included in @code{msa.h}:
15635 @itemize
15636 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
15637 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
15638 @item @code{v8i16}, a vector of eight signed 16-bit integers;
15639 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
15640 @item @code{v4i32}, a vector of four signed 32-bit integers;
15641 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
15642 @item @code{v2i64}, a vector of two signed 64-bit integers;
15643 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
15644 @item @code{v4f32}, a vector of four 32-bit floats;
15645 @item @code{v2f64}, a vector of two 64-bit doubles.
15646 @end itemize
15647
15648 Instructions and corresponding built-ins may have additional restrictions and/or
15649 input/output values manipulated:
15650 @itemize
15651 @item @code{imm0_1}, an integer literal in range 0 to 1;
15652 @item @code{imm0_3}, an integer literal in range 0 to 3;
15653 @item @code{imm0_7}, an integer literal in range 0 to 7;
15654 @item @code{imm0_15}, an integer literal in range 0 to 15;
15655 @item @code{imm0_31}, an integer literal in range 0 to 31;
15656 @item @code{imm0_63}, an integer literal in range 0 to 63;
15657 @item @code{imm0_255}, an integer literal in range 0 to 255;
15658 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
15659 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
15660 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
15661 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
15662 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
15663 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
15664 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
15665 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
15666 @item @code{imm1_4}, an integer literal in range 1 to 4;
15667 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
15668 @end itemize
15669
15670 @smallexample
15671 @{
15672 typedef int i32;
15673 #if __LONG_MAX__ == __LONG_LONG_MAX__
15674 typedef long i64;
15675 #else
15676 typedef long long i64;
15677 #endif
15678
15679 typedef unsigned int u32;
15680 #if __LONG_MAX__ == __LONG_LONG_MAX__
15681 typedef unsigned long u64;
15682 #else
15683 typedef unsigned long long u64;
15684 #endif
15685
15686 typedef double f64;
15687 typedef float f32;
15688 @}
15689 @end smallexample
15690
15691 @node MIPS SIMD Architecture Built-in Functions
15692 @subsubsection MIPS SIMD Architecture Built-in Functions
15693
15694 The intrinsics provided are listed below; each is named after the
15695 machine instruction.
15696
15697 @smallexample
15698 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
15699 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
15700 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
15701 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
15702
15703 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
15704 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
15705 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
15706 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
15707
15708 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
15709 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
15710 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
15711 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
15712
15713 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
15714 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
15715 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
15716 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
15717
15718 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
15719 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
15720 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
15721 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
15722
15723 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
15724 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
15725 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
15726 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
15727
15728 v16u8 __builtin_msa_and_v (v16u8, v16u8);
15729
15730 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
15731
15732 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
15733 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
15734 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
15735 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
15736
15737 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
15738 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
15739 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
15740 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
15741
15742 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
15743 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
15744 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
15745 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
15746
15747 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
15748 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
15749 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
15750 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
15751
15752 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
15753 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
15754 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
15755 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
15756
15757 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
15758 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
15759 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
15760 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
15761
15762 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
15763 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
15764 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
15765 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
15766
15767 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
15768 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
15769 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
15770 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
15771
15772 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
15773 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
15774 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
15775 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
15776
15777 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
15778 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
15779 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
15780 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
15781
15782 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
15783 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
15784 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
15785 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
15786
15787 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
15788 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
15789 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
15790 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
15791
15792 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
15793
15794 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
15795
15796 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
15797
15798 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
15799
15800 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
15801 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
15802 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
15803 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
15804
15805 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
15806 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
15807 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
15808 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
15809
15810 i32 __builtin_msa_bnz_b (v16u8);
15811 i32 __builtin_msa_bnz_h (v8u16);
15812 i32 __builtin_msa_bnz_w (v4u32);
15813 i32 __builtin_msa_bnz_d (v2u64);
15814
15815 i32 __builtin_msa_bnz_v (v16u8);
15816
15817 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
15818
15819 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
15820
15821 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
15822 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
15823 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
15824 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
15825
15826 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
15827 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
15828 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
15829 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
15830
15831 i32 __builtin_msa_bz_b (v16u8);
15832 i32 __builtin_msa_bz_h (v8u16);
15833 i32 __builtin_msa_bz_w (v4u32);
15834 i32 __builtin_msa_bz_d (v2u64);
15835
15836 i32 __builtin_msa_bz_v (v16u8);
15837
15838 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
15839 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
15840 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
15841 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
15842
15843 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
15844 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
15845 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
15846 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
15847
15848 i32 __builtin_msa_cfcmsa (imm0_31);
15849
15850 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
15851 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
15852 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
15853 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
15854
15855 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
15856 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
15857 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
15858 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
15859
15860 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
15861 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
15862 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
15863 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
15864
15865 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
15866 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
15867 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
15868 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
15869
15870 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
15871 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
15872 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
15873 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
15874
15875 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
15876 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
15877 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
15878 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
15879
15880 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
15881 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
15882 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
15883 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
15884
15885 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
15886 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
15887 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
15888 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
15889
15890 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
15891 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
15892 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
15893 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
15894
15895 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
15896 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
15897 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
15898 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
15899
15900 void __builtin_msa_ctcmsa (imm0_31, i32);
15901
15902 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
15903 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
15904 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
15905 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
15906
15907 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
15908 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
15909 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
15910 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
15911
15912 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
15913 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
15914 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
15915
15916 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
15917 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
15918 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
15919
15920 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
15921 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
15922 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
15923
15924 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
15925 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
15926 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
15927
15928 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
15929 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
15930 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
15931
15932 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
15933 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
15934 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
15935
15936 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
15937 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
15938
15939 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
15940 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
15941
15942 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
15943 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
15944
15945 v4i32 __builtin_msa_fclass_w (v4f32);
15946 v2i64 __builtin_msa_fclass_d (v2f64);
15947
15948 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
15949 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
15950
15951 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
15952 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
15953
15954 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
15955 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
15956
15957 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
15958 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
15959
15960 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
15961 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
15962
15963 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
15964 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
15965
15966 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
15967 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
15968
15969 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
15970 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
15971
15972 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
15973 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
15974
15975 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
15976 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
15977
15978 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
15979 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
15980
15981 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
15982 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
15983
15984 v4f32 __builtin_msa_fexupl_w (v8i16);
15985 v2f64 __builtin_msa_fexupl_d (v4f32);
15986
15987 v4f32 __builtin_msa_fexupr_w (v8i16);
15988 v2f64 __builtin_msa_fexupr_d (v4f32);
15989
15990 v4f32 __builtin_msa_ffint_s_w (v4i32);
15991 v2f64 __builtin_msa_ffint_s_d (v2i64);
15992
15993 v4f32 __builtin_msa_ffint_u_w (v4u32);
15994 v2f64 __builtin_msa_ffint_u_d (v2u64);
15995
15996 v4f32 __builtin_msa_ffql_w (v8i16);
15997 v2f64 __builtin_msa_ffql_d (v4i32);
15998
15999 v4f32 __builtin_msa_ffqr_w (v8i16);
16000 v2f64 __builtin_msa_ffqr_d (v4i32);
16001
16002 v16i8 __builtin_msa_fill_b (i32);
16003 v8i16 __builtin_msa_fill_h (i32);
16004 v4i32 __builtin_msa_fill_w (i32);
16005 v2i64 __builtin_msa_fill_d (i64);
16006
16007 v4f32 __builtin_msa_flog2_w (v4f32);
16008 v2f64 __builtin_msa_flog2_d (v2f64);
16009
16010 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
16011 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
16012
16013 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
16014 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
16015
16016 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
16017 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
16018
16019 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
16020 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
16021
16022 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
16023 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
16024
16025 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
16026 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
16027
16028 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
16029 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
16030
16031 v4f32 __builtin_msa_frint_w (v4f32);
16032 v2f64 __builtin_msa_frint_d (v2f64);
16033
16034 v4f32 __builtin_msa_frcp_w (v4f32);
16035 v2f64 __builtin_msa_frcp_d (v2f64);
16036
16037 v4f32 __builtin_msa_frsqrt_w (v4f32);
16038 v2f64 __builtin_msa_frsqrt_d (v2f64);
16039
16040 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
16041 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
16042
16043 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
16044 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
16045
16046 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
16047 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
16048
16049 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
16050 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
16051
16052 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
16053 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
16054
16055 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
16056 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
16057
16058 v4f32 __builtin_msa_fsqrt_w (v4f32);
16059 v2f64 __builtin_msa_fsqrt_d (v2f64);
16060
16061 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
16062 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
16063
16064 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
16065 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
16066
16067 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
16068 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
16069
16070 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
16071 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
16072
16073 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
16074 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
16075
16076 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
16077 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
16078
16079 v4i32 __builtin_msa_ftint_s_w (v4f32);
16080 v2i64 __builtin_msa_ftint_s_d (v2f64);
16081
16082 v4u32 __builtin_msa_ftint_u_w (v4f32);
16083 v2u64 __builtin_msa_ftint_u_d (v2f64);
16084
16085 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
16086 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
16087
16088 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
16089 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
16090
16091 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
16092 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
16093
16094 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
16095 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
16096 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
16097
16098 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
16099 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
16100 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
16101
16102 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
16103 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
16104 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
16105
16106 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
16107 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
16108 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
16109
16110 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
16111 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
16112 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
16113 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
16114
16115 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
16116 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
16117 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
16118 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
16119
16120 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
16121 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
16122 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
16123 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
16124
16125 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
16126 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
16127 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
16128 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
16129
16130 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
16131 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
16132 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
16133 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
16134
16135 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
16136 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
16137 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
16138 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
16139
16140 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
16141 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
16142 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
16143 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
16144
16145 v16i8 __builtin_msa_ldi_b (imm_n512_511);
16146 v8i16 __builtin_msa_ldi_h (imm_n512_511);
16147 v4i32 __builtin_msa_ldi_w (imm_n512_511);
16148 v2i64 __builtin_msa_ldi_d (imm_n512_511);
16149
16150 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
16151 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
16152
16153 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
16154 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
16155
16156 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
16157 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
16158 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
16159 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
16160
16161 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
16162 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
16163 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
16164 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
16165
16166 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
16167 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
16168 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
16169 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
16170
16171 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
16172 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
16173 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
16174 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
16175
16176 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
16177 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
16178 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
16179 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
16180
16181 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
16182 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
16183 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
16184 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
16185
16186 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
16187 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
16188 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
16189 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
16190
16191 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
16192 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
16193 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
16194 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
16195
16196 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
16197 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
16198 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
16199 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
16200
16201 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
16202 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
16203 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
16204 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
16205
16206 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
16207 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
16208 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
16209 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
16210
16211 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
16212 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
16213 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
16214 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
16215
16216 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
16217 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
16218 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
16219 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
16220
16221 v16i8 __builtin_msa_move_v (v16i8);
16222
16223 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
16224 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
16225
16226 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
16227 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
16228
16229 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
16230 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
16231 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
16232 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
16233
16234 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
16235 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
16236
16237 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
16238 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
16239
16240 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
16241 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
16242 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
16243 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
16244
16245 v16i8 __builtin_msa_nloc_b (v16i8);
16246 v8i16 __builtin_msa_nloc_h (v8i16);
16247 v4i32 __builtin_msa_nloc_w (v4i32);
16248 v2i64 __builtin_msa_nloc_d (v2i64);
16249
16250 v16i8 __builtin_msa_nlzc_b (v16i8);
16251 v8i16 __builtin_msa_nlzc_h (v8i16);
16252 v4i32 __builtin_msa_nlzc_w (v4i32);
16253 v2i64 __builtin_msa_nlzc_d (v2i64);
16254
16255 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
16256
16257 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
16258
16259 v16u8 __builtin_msa_or_v (v16u8, v16u8);
16260
16261 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
16262
16263 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
16264 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
16265 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
16266 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
16267
16268 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
16269 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
16270 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
16271 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
16272
16273 v16i8 __builtin_msa_pcnt_b (v16i8);
16274 v8i16 __builtin_msa_pcnt_h (v8i16);
16275 v4i32 __builtin_msa_pcnt_w (v4i32);
16276 v2i64 __builtin_msa_pcnt_d (v2i64);
16277
16278 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
16279 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
16280 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
16281 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
16282
16283 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
16284 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
16285 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
16286 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
16287
16288 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
16289 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
16290 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
16291
16292 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
16293 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
16294 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
16295 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
16296
16297 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
16298 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
16299 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
16300 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
16301
16302 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
16303 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
16304 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
16305 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
16306
16307 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
16308 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
16309 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
16310 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
16311
16312 v16i8 __builtin_msa_splat_b (v16i8, i32);
16313 v8i16 __builtin_msa_splat_h (v8i16, i32);
16314 v4i32 __builtin_msa_splat_w (v4i32, i32);
16315 v2i64 __builtin_msa_splat_d (v2i64, i32);
16316
16317 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
16318 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
16319 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
16320 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
16321
16322 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
16323 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
16324 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
16325 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
16326
16327 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
16328 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
16329 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
16330 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
16331
16332 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
16333 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
16334 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
16335 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
16336
16337 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
16338 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
16339 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
16340 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
16341
16342 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
16343 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
16344 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
16345 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
16346
16347 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
16348 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
16349 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
16350 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
16351
16352 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
16353 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
16354 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
16355 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
16356
16357 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
16358 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
16359 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
16360 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
16361
16362 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
16363 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
16364 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
16365 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
16366
16367 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
16368 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
16369 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
16370 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
16371
16372 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
16373 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
16374 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
16375 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
16376
16377 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
16378 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
16379 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
16380 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
16381
16382 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
16383 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
16384 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
16385 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
16386
16387 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
16388 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
16389 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
16390 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
16391
16392 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
16393 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
16394 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
16395 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
16396
16397 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
16398 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
16399 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
16400 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
16401
16402 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
16403
16404 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
16405 @end smallexample
16406
16407 @node Other MIPS Built-in Functions
16408 @subsection Other MIPS Built-in Functions
16409
16410 GCC provides other MIPS-specific built-in functions:
16411
16412 @table @code
16413 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
16414 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
16415 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
16416 when this function is available.
16417
16418 @item unsigned int __builtin_mips_get_fcsr (void)
16419 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
16420 Get and set the contents of the floating-point control and status register
16421 (FPU control register 31). These functions are only available in hard-float
16422 code but can be called in both MIPS16 and non-MIPS16 contexts.
16423
16424 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
16425 register except the condition codes, which GCC assumes are preserved.
16426 @end table
16427
16428 @node MSP430 Built-in Functions
16429 @subsection MSP430 Built-in Functions
16430
16431 GCC provides a couple of special builtin functions to aid in the
16432 writing of interrupt handlers in C.
16433
16434 @table @code
16435 @item __bic_SR_register_on_exit (int @var{mask})
16436 This clears the indicated bits in the saved copy of the status register
16437 currently residing on the stack. This only works inside interrupt
16438 handlers and the changes to the status register will only take affect
16439 once the handler returns.
16440
16441 @item __bis_SR_register_on_exit (int @var{mask})
16442 This sets the indicated bits in the saved copy of the status register
16443 currently residing on the stack. This only works inside interrupt
16444 handlers and the changes to the status register will only take affect
16445 once the handler returns.
16446
16447 @item __delay_cycles (long long @var{cycles})
16448 This inserts an instruction sequence that takes exactly @var{cycles}
16449 cycles (between 0 and about 17E9) to complete. The inserted sequence
16450 may use jumps, loops, or no-ops, and does not interfere with any other
16451 instructions. Note that @var{cycles} must be a compile-time constant
16452 integer - that is, you must pass a number, not a variable that may be
16453 optimized to a constant later. The number of cycles delayed by this
16454 builtin is exact.
16455 @end table
16456
16457 @node NDS32 Built-in Functions
16458 @subsection NDS32 Built-in Functions
16459
16460 These built-in functions are available for the NDS32 target:
16461
16462 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
16463 Insert an ISYNC instruction into the instruction stream where
16464 @var{addr} is an instruction address for serialization.
16465 @end deftypefn
16466
16467 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
16468 Insert an ISB instruction into the instruction stream.
16469 @end deftypefn
16470
16471 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
16472 Return the content of a system register which is mapped by @var{sr}.
16473 @end deftypefn
16474
16475 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
16476 Return the content of a user space register which is mapped by @var{usr}.
16477 @end deftypefn
16478
16479 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
16480 Move the @var{value} to a system register which is mapped by @var{sr}.
16481 @end deftypefn
16482
16483 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
16484 Move the @var{value} to a user space register which is mapped by @var{usr}.
16485 @end deftypefn
16486
16487 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
16488 Enable global interrupt.
16489 @end deftypefn
16490
16491 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
16492 Disable global interrupt.
16493 @end deftypefn
16494
16495 @node picoChip Built-in Functions
16496 @subsection picoChip Built-in Functions
16497
16498 GCC provides an interface to selected machine instructions from the
16499 picoChip instruction set.
16500
16501 @table @code
16502 @item int __builtin_sbc (int @var{value})
16503 Sign bit count. Return the number of consecutive bits in @var{value}
16504 that have the same value as the sign bit. The result is the number of
16505 leading sign bits minus one, giving the number of redundant sign bits in
16506 @var{value}.
16507
16508 @item int __builtin_byteswap (int @var{value})
16509 Byte swap. Return the result of swapping the upper and lower bytes of
16510 @var{value}.
16511
16512 @item int __builtin_brev (int @var{value})
16513 Bit reversal. Return the result of reversing the bits in
16514 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
16515 and so on.
16516
16517 @item int __builtin_adds (int @var{x}, int @var{y})
16518 Saturating addition. Return the result of adding @var{x} and @var{y},
16519 storing the value 32767 if the result overflows.
16520
16521 @item int __builtin_subs (int @var{x}, int @var{y})
16522 Saturating subtraction. Return the result of subtracting @var{y} from
16523 @var{x}, storing the value @minus{}32768 if the result overflows.
16524
16525 @item void __builtin_halt (void)
16526 Halt. The processor stops execution. This built-in is useful for
16527 implementing assertions.
16528
16529 @end table
16530
16531 @node Basic PowerPC Built-in Functions
16532 @subsection Basic PowerPC Built-in Functions
16533
16534 @menu
16535 * Basic PowerPC Built-in Functions Available on all Configurations::
16536 * Basic PowerPC Built-in Functions Available on ISA 2.05::
16537 * Basic PowerPC Built-in Functions Available on ISA 2.06::
16538 * Basic PowerPC Built-in Functions Available on ISA 2.07::
16539 * Basic PowerPC Built-in Functions Available on ISA 3.0::
16540 @end menu
16541
16542 This section describes PowerPC built-in functions that do not require
16543 the inclusion of any special header files to declare prototypes or
16544 provide macro definitions. The sections that follow describe
16545 additional PowerPC built-in functions.
16546
16547 @node Basic PowerPC Built-in Functions Available on all Configurations
16548 @subsubsection Basic PowerPC Built-in Functions Available on all Configurations
16549
16550 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
16551 This function is a @code{nop} on the PowerPC platform and is included solely
16552 to maintain API compatibility with the x86 builtins.
16553 @end deftypefn
16554
16555 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
16556 This function returns a value of @code{1} if the run-time CPU is of type
16557 @var{cpuname} and returns @code{0} otherwise
16558
16559 The @code{__builtin_cpu_is} function requires GLIBC 2.23 or newer
16560 which exports the hardware capability bits. GCC defines the macro
16561 @code{__BUILTIN_CPU_SUPPORTS__} if the @code{__builtin_cpu_supports}
16562 built-in function is fully supported.
16563
16564 If GCC was configured to use a GLIBC before 2.23, the built-in
16565 function @code{__builtin_cpu_is} always returns a 0 and the compiler
16566 issues a warning.
16567
16568 The following CPU names can be detected:
16569
16570 @table @samp
16571 @item power9
16572 IBM POWER9 Server CPU.
16573 @item power8
16574 IBM POWER8 Server CPU.
16575 @item power7
16576 IBM POWER7 Server CPU.
16577 @item power6x
16578 IBM POWER6 Server CPU (RAW mode).
16579 @item power6
16580 IBM POWER6 Server CPU (Architected mode).
16581 @item power5+
16582 IBM POWER5+ Server CPU.
16583 @item power5
16584 IBM POWER5 Server CPU.
16585 @item ppc970
16586 IBM 970 Server CPU (ie, Apple G5).
16587 @item power4
16588 IBM POWER4 Server CPU.
16589 @item ppca2
16590 IBM A2 64-bit Embedded CPU
16591 @item ppc476
16592 IBM PowerPC 476FP 32-bit Embedded CPU.
16593 @item ppc464
16594 IBM PowerPC 464 32-bit Embedded CPU.
16595 @item ppc440
16596 PowerPC 440 32-bit Embedded CPU.
16597 @item ppc405
16598 PowerPC 405 32-bit Embedded CPU.
16599 @item ppc-cell-be
16600 IBM PowerPC Cell Broadband Engine Architecture CPU.
16601 @end table
16602
16603 Here is an example:
16604 @smallexample
16605 #ifdef __BUILTIN_CPU_SUPPORTS__
16606 if (__builtin_cpu_is ("power8"))
16607 @{
16608 do_power8 (); // POWER8 specific implementation.
16609 @}
16610 else
16611 #endif
16612 @{
16613 do_generic (); // Generic implementation.
16614 @}
16615 @end smallexample
16616 @end deftypefn
16617
16618 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
16619 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
16620 feature @var{feature} and returns @code{0} otherwise.
16621
16622 The @code{__builtin_cpu_supports} function requires GLIBC 2.23 or
16623 newer which exports the hardware capability bits. GCC defines the
16624 macro @code{__BUILTIN_CPU_SUPPORTS__} if the
16625 @code{__builtin_cpu_supports} built-in function is fully supported.
16626
16627 If GCC was configured to use a GLIBC before 2.23, the built-in
16628 function @code{__builtin_cpu_suports} always returns a 0 and the
16629 compiler issues a warning.
16630
16631 The following features can be
16632 detected:
16633
16634 @table @samp
16635 @item 4xxmac
16636 4xx CPU has a Multiply Accumulator.
16637 @item altivec
16638 CPU has a SIMD/Vector Unit.
16639 @item arch_2_05
16640 CPU supports ISA 2.05 (eg, POWER6)
16641 @item arch_2_06
16642 CPU supports ISA 2.06 (eg, POWER7)
16643 @item arch_2_07
16644 CPU supports ISA 2.07 (eg, POWER8)
16645 @item arch_3_00
16646 CPU supports ISA 3.0 (eg, POWER9)
16647 @item archpmu
16648 CPU supports the set of compatible performance monitoring events.
16649 @item booke
16650 CPU supports the Embedded ISA category.
16651 @item cellbe
16652 CPU has a CELL broadband engine.
16653 @item darn
16654 CPU supports the @code{darn} (deliver a random number) instruction.
16655 @item dfp
16656 CPU has a decimal floating point unit.
16657 @item dscr
16658 CPU supports the data stream control register.
16659 @item ebb
16660 CPU supports event base branching.
16661 @item efpdouble
16662 CPU has a SPE double precision floating point unit.
16663 @item efpsingle
16664 CPU has a SPE single precision floating point unit.
16665 @item fpu
16666 CPU has a floating point unit.
16667 @item htm
16668 CPU has hardware transaction memory instructions.
16669 @item htm-nosc
16670 Kernel aborts hardware transactions when a syscall is made.
16671 @item htm-no-suspend
16672 CPU supports hardware transaction memory but does not support the
16673 @code{tsuspend.} instruction.
16674 @item ic_snoop
16675 CPU supports icache snooping capabilities.
16676 @item ieee128
16677 CPU supports 128-bit IEEE binary floating point instructions.
16678 @item isel
16679 CPU supports the integer select instruction.
16680 @item mmu
16681 CPU has a memory management unit.
16682 @item notb
16683 CPU does not have a timebase (eg, 601 and 403gx).
16684 @item pa6t
16685 CPU supports the PA Semi 6T CORE ISA.
16686 @item power4
16687 CPU supports ISA 2.00 (eg, POWER4)
16688 @item power5
16689 CPU supports ISA 2.02 (eg, POWER5)
16690 @item power5+
16691 CPU supports ISA 2.03 (eg, POWER5+)
16692 @item power6x
16693 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
16694 @item ppc32
16695 CPU supports 32-bit mode execution.
16696 @item ppc601
16697 CPU supports the old POWER ISA (eg, 601)
16698 @item ppc64
16699 CPU supports 64-bit mode execution.
16700 @item ppcle
16701 CPU supports a little-endian mode that uses address swizzling.
16702 @item scv
16703 Kernel supports system call vectored.
16704 @item smt
16705 CPU support simultaneous multi-threading.
16706 @item spe
16707 CPU has a signal processing extension unit.
16708 @item tar
16709 CPU supports the target address register.
16710 @item true_le
16711 CPU supports true little-endian mode.
16712 @item ucache
16713 CPU has unified I/D cache.
16714 @item vcrypto
16715 CPU supports the vector cryptography instructions.
16716 @item vsx
16717 CPU supports the vector-scalar extension.
16718 @end table
16719
16720 Here is an example:
16721 @smallexample
16722 #ifdef __BUILTIN_CPU_SUPPORTS__
16723 if (__builtin_cpu_supports ("fpu"))
16724 @{
16725 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
16726 @}
16727 else
16728 #endif
16729 @{
16730 dst = __fadd (src1, src2); // Software FP addition function.
16731 @}
16732 @end smallexample
16733 @end deftypefn
16734
16735 The following built-in functions are also available on all PowerPC
16736 processors:
16737 @smallexample
16738 uint64_t __builtin_ppc_get_timebase ();
16739 unsigned long __builtin_ppc_mftb ();
16740 double __builtin_unpack_ibm128 (__ibm128, int);
16741 __ibm128 __builtin_pack_ibm128 (double, double);
16742 double __builtin_mffs (void);
16743 void __builtin_mtfsb0 (const int);
16744 void __builtin_mtfsb1 (const int);
16745 void __builtin_set_fpscr_rn (int);
16746 @end smallexample
16747
16748 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
16749 functions generate instructions to read the Time Base Register. The
16750 @code{__builtin_ppc_get_timebase} function may generate multiple
16751 instructions and always returns the 64 bits of the Time Base Register.
16752 The @code{__builtin_ppc_mftb} function always generates one instruction and
16753 returns the Time Base Register value as an unsigned long, throwing away
16754 the most significant word on 32-bit environments. The @code{__builtin_mffs}
16755 return the value of the FPSCR register. Note, ISA 3.0 supports the
16756 @code{__builtin_mffsl()} which permits software to read the control and
16757 non-sticky status bits in the FSPCR without the higher latency associated with
16758 accessing the sticky status bits. The
16759 @code{__builtin_mtfsb0} and @code{__builtin_mtfsb1} take the bit to change
16760 as an argument. The valid bit range is between 0 and 31. The builtins map to
16761 the @code{mtfsb0} and @code{mtfsb1} instructions which take the argument and
16762 add 32. Hence these instructions only modify the FPSCR[32:63] bits by
16763 changing the specified bit to a zero or one respectively. The
16764 @code{__builtin_set_fpscr_rn} builtin allows changing both of the floating
16765 point rounding mode bits. The argument is a 2-bit value. The argument can
16766 either be a @code{const int} or stored in a variable. The builtin uses
16767 the ISA 3.0
16768 instruction @code{mffscrn} if available, otherwise it reads the FPSCR, masks
16769 the current rounding mode bits out and OR's in the new value.
16770
16771 @node Basic PowerPC Built-in Functions Available on ISA 2.05
16772 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.05
16773
16774 The basic built-in functions described in this section are
16775 available on the PowerPC family of processors starting with ISA 2.05
16776 or later. Unless specific options are explicitly disabled on the
16777 command line, specifying option @option{-mcpu=power6} has the effect of
16778 enabling the @option{-mpowerpc64}, @option{-mpowerpc-gpopt},
16779 @option{-mpowerpc-gfxopt}, @option{-mmfcrf}, @option{-mpopcntb},
16780 @option{-mfprnd}, @option{-mcmpb}, @option{-mhard-dfp}, and
16781 @option{-mrecip-precision} options. Specify the
16782 @option{-maltivec} and @option{-mfpgpr} options explicitly in
16783 combination with the above options if they are desired.
16784
16785 The following functions require option @option{-mcmpb}.
16786 @smallexample
16787 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
16788 unsigned int __builtin_cmpb (unsigned int, unsigned int);
16789 @end smallexample
16790
16791 The @code{__builtin_cmpb} function
16792 performs a byte-wise compare on the contents of its two arguments,
16793 returning the result of the byte-wise comparison as the returned
16794 value. For each byte comparison, the corresponding byte of the return
16795 value holds 0xff if the input bytes are equal and 0 if the input bytes
16796 are not equal. If either of the arguments to this built-in function
16797 is wider than 32 bits, the function call expands into the form that
16798 expects @code{unsigned long long int} arguments
16799 which is only available on 64-bit targets.
16800
16801 The following built-in functions are available
16802 when hardware decimal floating point
16803 (@option{-mhard-dfp}) is available:
16804 @smallexample
16805 void __builtin_set_fpscr_drn(int);
16806 _Decimal64 __builtin_ddedpd (int, _Decimal64);
16807 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
16808 _Decimal64 __builtin_denbcd (int, _Decimal64);
16809 _Decimal128 __builtin_denbcdq (int, _Decimal128);
16810 _Decimal64 __builtin_diex (long long, _Decimal64);
16811 _Decimal128 _builtin_diexq (long long, _Decimal128);
16812 _Decimal64 __builtin_dscli (_Decimal64, int);
16813 _Decimal128 __builtin_dscliq (_Decimal128, int);
16814 _Decimal64 __builtin_dscri (_Decimal64, int);
16815 _Decimal128 __builtin_dscriq (_Decimal128, int);
16816 long long __builtin_dxex (_Decimal64);
16817 long long __builtin_dxexq (_Decimal128);
16818 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
16819 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
16820
16821 The @code{__builtin_set_fpscr_drn} builtin allows changing the three decimal
16822 floating point rounding mode bits. The argument is a 3-bit value. The
16823 argument can either be a @code{const int} or the value can be stored in
16824 a variable.
16825 The builtin uses the ISA 3.0 instruction @code{mffscdrn} if available.
16826 Otherwise the builtin reads the FPSCR, masks the current decimal rounding
16827 mode bits out and OR's in the new value.
16828
16829 @end smallexample
16830
16831 The following functions require @option{-mhard-float},
16832 @option{-mpowerpc-gfxopt}, and @option{-mpopcntb} options.
16833
16834 @smallexample
16835 double __builtin_recipdiv (double, double);
16836 float __builtin_recipdivf (float, float);
16837 double __builtin_rsqrt (double);
16838 float __builtin_rsqrtf (float);
16839 @end smallexample
16840
16841 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
16842 @code{__builtin_rsqrtf} functions generate multiple instructions to
16843 implement the reciprocal sqrt functionality using reciprocal sqrt
16844 estimate instructions.
16845
16846 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
16847 functions generate multiple instructions to implement division using
16848 the reciprocal estimate instructions.
16849
16850 The following functions require @option{-mhard-float} and
16851 @option{-mmultiple} options.
16852
16853 The @code{__builtin_unpack_longdouble} function takes a
16854 @code{long double} argument and a compile time constant of 0 or 1. If
16855 the constant is 0, the first @code{double} within the
16856 @code{long double} is returned, otherwise the second @code{double}
16857 is returned. The @code{__builtin_unpack_longdouble} function is only
16858 available if @code{long double} uses the IBM extended double
16859 representation.
16860
16861 The @code{__builtin_pack_longdouble} function takes two @code{double}
16862 arguments and returns a @code{long double} value that combines the two
16863 arguments. The @code{__builtin_pack_longdouble} function is only
16864 available if @code{long double} uses the IBM extended double
16865 representation.
16866
16867 The @code{__builtin_unpack_ibm128} function takes a @code{__ibm128}
16868 argument and a compile time constant of 0 or 1. If the constant is 0,
16869 the first @code{double} within the @code{__ibm128} is returned,
16870 otherwise the second @code{double} is returned.
16871
16872 The @code{__builtin_pack_ibm128} function takes two @code{double}
16873 arguments and returns a @code{__ibm128} value that combines the two
16874 arguments.
16875
16876 Additional built-in functions are available for the 64-bit PowerPC
16877 family of processors, for efficient use of 128-bit floating point
16878 (@code{__float128}) values.
16879
16880 @node Basic PowerPC Built-in Functions Available on ISA 2.06
16881 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.06
16882
16883 The basic built-in functions described in this section are
16884 available on the PowerPC family of processors starting with ISA 2.05
16885 or later. Unless specific options are explicitly disabled on the
16886 command line, specifying option @option{-mcpu=power7} has the effect of
16887 enabling all the same options as for @option{-mcpu=power6} in
16888 addition to the @option{-maltivec}, @option{-mpopcntd}, and
16889 @option{-mvsx} options.
16890
16891 The following basic built-in functions require @option{-mpopcntd}:
16892 @smallexample
16893 unsigned int __builtin_addg6s (unsigned int, unsigned int);
16894 long long __builtin_bpermd (long long, long long);
16895 unsigned int __builtin_cbcdtd (unsigned int);
16896 unsigned int __builtin_cdtbcd (unsigned int);
16897 long long __builtin_divde (long long, long long);
16898 unsigned long long __builtin_divdeu (unsigned long long, unsigned long long);
16899 int __builtin_divwe (int, int);
16900 unsigned int __builtin_divweu (unsigned int, unsigned int);
16901 vector __int128 __builtin_pack_vector_int128 (long long, long long);
16902 void __builtin_rs6000_speculation_barrier (void);
16903 long long __builtin_unpack_vector_int128 (vector __int128, signed char);
16904 @end smallexample
16905
16906 Of these, the @code{__builtin_divde} and @code{__builtin_divdeu} functions
16907 require a 64-bit environment.
16908
16909 The following basic built-in functions, which are also supported on
16910 x86 targets, require @option{-mfloat128}.
16911 @smallexample
16912 __float128 __builtin_fabsq (__float128);
16913 __float128 __builtin_copysignq (__float128, __float128);
16914 __float128 __builtin_infq (void);
16915 __float128 __builtin_huge_valq (void);
16916 __float128 __builtin_nanq (void);
16917 __float128 __builtin_nansq (void);
16918
16919 __float128 __builtin_sqrtf128 (__float128);
16920 __float128 __builtin_fmaf128 (__float128, __float128, __float128);
16921 @end smallexample
16922
16923 @node Basic PowerPC Built-in Functions Available on ISA 2.07
16924 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.07
16925
16926 The basic built-in functions described in this section are
16927 available on the PowerPC family of processors starting with ISA 2.07
16928 or later. Unless specific options are explicitly disabled on the
16929 command line, specifying option @option{-mcpu=power8} has the effect of
16930 enabling all the same options as for @option{-mcpu=power7} in
16931 addition to the @option{-mpower8-fusion}, @option{-mpower8-vector},
16932 @option{-mcrypto}, @option{-mhtm}, @option{-mquad-memory}, and
16933 @option{-mquad-memory-atomic} options.
16934
16935 This section intentionally empty.
16936
16937 @node Basic PowerPC Built-in Functions Available on ISA 3.0
16938 @subsubsection Basic PowerPC Built-in Functions Available on ISA 3.0
16939
16940 The basic built-in functions described in this section are
16941 available on the PowerPC family of processors starting with ISA 3.0
16942 or later. Unless specific options are explicitly disabled on the
16943 command line, specifying option @option{-mcpu=power9} has the effect of
16944 enabling all the same options as for @option{-mcpu=power8} in
16945 addition to the @option{-misel} option.
16946
16947 The following built-in functions are available on Linux 64-bit systems
16948 that use the ISA 3.0 instruction set (@option{-mcpu=power9}):
16949
16950 @table @code
16951 @item __float128 __builtin_addf128_round_to_odd (__float128, __float128)
16952 Perform a 128-bit IEEE floating point add using round to odd as the
16953 rounding mode.
16954 @findex __builtin_addf128_round_to_odd
16955
16956 @item __float128 __builtin_subf128_round_to_odd (__float128, __float128)
16957 Perform a 128-bit IEEE floating point subtract using round to odd as
16958 the rounding mode.
16959 @findex __builtin_subf128_round_to_odd
16960
16961 @item __float128 __builtin_mulf128_round_to_odd (__float128, __float128)
16962 Perform a 128-bit IEEE floating point multiply using round to odd as
16963 the rounding mode.
16964 @findex __builtin_mulf128_round_to_odd
16965
16966 @item __float128 __builtin_divf128_round_to_odd (__float128, __float128)
16967 Perform a 128-bit IEEE floating point divide using round to odd as
16968 the rounding mode.
16969 @findex __builtin_divf128_round_to_odd
16970
16971 @item __float128 __builtin_sqrtf128_round_to_odd (__float128)
16972 Perform a 128-bit IEEE floating point square root using round to odd
16973 as the rounding mode.
16974 @findex __builtin_sqrtf128_round_to_odd
16975
16976 @item __float128 __builtin_fmaf128_round_to_odd (__float128, __float128, __float128)
16977 Perform a 128-bit IEEE floating point fused multiply and add operation
16978 using round to odd as the rounding mode.
16979 @findex __builtin_fmaf128_round_to_odd
16980
16981 @item double __builtin_truncf128_round_to_odd (__float128)
16982 Convert a 128-bit IEEE floating point value to @code{double} using
16983 round to odd as the rounding mode.
16984 @findex __builtin_truncf128_round_to_odd
16985 @end table
16986
16987 The following additional built-in functions are also available for the
16988 PowerPC family of processors, starting with ISA 3.0 or later:
16989 @smallexample
16990 long long __builtin_darn (void);
16991 long long __builtin_darn_raw (void);
16992 int __builtin_darn_32 (void);
16993 @end smallexample
16994
16995 The @code{__builtin_darn} and @code{__builtin_darn_raw}
16996 functions require a
16997 64-bit environment supporting ISA 3.0 or later.
16998 The @code{__builtin_darn} function provides a 64-bit conditioned
16999 random number. The @code{__builtin_darn_raw} function provides a
17000 64-bit raw random number. The @code{__builtin_darn_32} function
17001 provides a 32-bit conditioned random number.
17002
17003 The following additional built-in functions are also available for the
17004 PowerPC family of processors, starting with ISA 3.0 or later:
17005
17006 @smallexample
17007 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
17008 int __builtin_byte_in_range (unsigned char u, unsigned int range);
17009 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
17010
17011 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
17012 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
17013 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
17014 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
17015
17016 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
17017 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
17018 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
17019 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
17020
17021 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
17022 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
17023 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
17024 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
17025
17026 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
17027 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
17028 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
17029 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
17030
17031 double __builtin_mffsl(void);
17032
17033 @end smallexample
17034 The @code{__builtin_byte_in_set} function requires a
17035 64-bit environment supporting ISA 3.0 or later. This function returns
17036 a non-zero value if and only if its @code{u} argument exactly equals one of
17037 the eight bytes contained within its 64-bit @code{set} argument.
17038
17039 The @code{__builtin_byte_in_range} and
17040 @code{__builtin_byte_in_either_range} require an environment
17041 supporting ISA 3.0 or later. For these two functions, the
17042 @code{range} argument is encoded as 4 bytes, organized as
17043 @code{hi_1:lo_1:hi_2:lo_2}.
17044 The @code{__builtin_byte_in_range} function returns a
17045 non-zero value if and only if its @code{u} argument is within the
17046 range bounded between @code{lo_2} and @code{hi_2} inclusive.
17047 The @code{__builtin_byte_in_either_range} function returns non-zero if
17048 and only if its @code{u} argument is within either the range bounded
17049 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
17050 between @code{lo_2} and @code{hi_2} inclusive.
17051
17052 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
17053 if and only if the number of signficant digits of its @code{value} argument
17054 is less than its @code{comparison} argument. The
17055 @code{__builtin_dfp_dtstsfi_lt_dd} and
17056 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
17057 require that the type of the @code{value} argument be
17058 @code{__Decimal64} and @code{__Decimal128} respectively.
17059
17060 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
17061 if and only if the number of signficant digits of its @code{value} argument
17062 is greater than its @code{comparison} argument. The
17063 @code{__builtin_dfp_dtstsfi_gt_dd} and
17064 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
17065 require that the type of the @code{value} argument be
17066 @code{__Decimal64} and @code{__Decimal128} respectively.
17067
17068 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
17069 if and only if the number of signficant digits of its @code{value} argument
17070 equals its @code{comparison} argument. The
17071 @code{__builtin_dfp_dtstsfi_eq_dd} and
17072 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
17073 require that the type of the @code{value} argument be
17074 @code{__Decimal64} and @code{__Decimal128} respectively.
17075
17076 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
17077 if and only if its @code{value} argument has an undefined number of
17078 significant digits, such as when @code{value} is an encoding of @code{NaN}.
17079 The @code{__builtin_dfp_dtstsfi_ov_dd} and
17080 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
17081 require that the type of the @code{value} argument be
17082 @code{__Decimal64} and @code{__Decimal128} respectively.
17083
17084 The @code{__builtin_mffsl} uses the ISA 3.0 @code{mffsl} instruction to read
17085 the FPSCR. The instruction is a lower latency version of the @code{mffs}
17086 instruction. If the @code{mffsl} instruction is not available, then the
17087 builtin uses the older @code{mffs} instruction to read the FPSCR.
17088
17089
17090 @node PowerPC AltiVec/VSX Built-in Functions
17091 @subsection PowerPC AltiVec/VSX Built-in Functions
17092
17093 GCC provides an interface for the PowerPC family of processors to access
17094 the AltiVec operations described in Motorola's AltiVec Programming
17095 Interface Manual. The interface is made available by including
17096 @code{<altivec.h>} and using @option{-maltivec} and
17097 @option{-mabi=altivec}. The interface supports the following vector
17098 types.
17099
17100 @smallexample
17101 vector unsigned char
17102 vector signed char
17103 vector bool char
17104
17105 vector unsigned short
17106 vector signed short
17107 vector bool short
17108 vector pixel
17109
17110 vector unsigned int
17111 vector signed int
17112 vector bool int
17113 vector float
17114 @end smallexample
17115
17116 GCC's implementation of the high-level language interface available from
17117 C and C++ code differs from Motorola's documentation in several ways.
17118
17119 @itemize @bullet
17120
17121 @item
17122 A vector constant is a list of constant expressions within curly braces.
17123
17124 @item
17125 A vector initializer requires no cast if the vector constant is of the
17126 same type as the variable it is initializing.
17127
17128 @item
17129 If @code{signed} or @code{unsigned} is omitted, the signedness of the
17130 vector type is the default signedness of the base type. The default
17131 varies depending on the operating system, so a portable program should
17132 always specify the signedness.
17133
17134 @item
17135 Compiling with @option{-maltivec} adds keywords @code{__vector},
17136 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
17137 @code{bool}. When compiling ISO C, the context-sensitive substitution
17138 of the keywords @code{vector}, @code{pixel} and @code{bool} is
17139 disabled. To use them, you must include @code{<altivec.h>} instead.
17140
17141 @item
17142 GCC allows using a @code{typedef} name as the type specifier for a
17143 vector type, but only under the following circumstances:
17144
17145 @itemize @bullet
17146
17147 @item
17148 When using @code{__vector} instead of @code{vector}; for example,
17149
17150 @smallexample
17151 typedef signed short int16;
17152 __vector int16 data;
17153 @end smallexample
17154
17155 @item
17156 When using @code{vector} in keyword-and-predefine mode; for example,
17157
17158 @smallexample
17159 typedef signed short int16;
17160 vector int16 data;
17161 @end smallexample
17162
17163 Note that keyword-and-predefine mode is enabled by disabling GNU
17164 extensions (e.g., by using @code{-std=c11}) and including
17165 @code{<altivec.h>}.
17166 @end itemize
17167
17168 @item
17169 For C, overloaded functions are implemented with macros so the following
17170 does not work:
17171
17172 @smallexample
17173 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
17174 @end smallexample
17175
17176 @noindent
17177 Since @code{vec_add} is a macro, the vector constant in the example
17178 is treated as four separate arguments. Wrap the entire argument in
17179 parentheses for this to work.
17180 @end itemize
17181
17182 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
17183 Internally, GCC uses built-in functions to achieve the functionality in
17184 the aforementioned header file, but they are not supported and are
17185 subject to change without notice.
17186
17187 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
17188 which may be found at
17189 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
17190 Appendix A of this document lists the vector API interfaces that must be
17191 provided by compliant compilers. Programmers should preferentially use
17192 the interfaces described therein. However, historically GCC has provided
17193 additional interfaces for access to vector instructions. These are
17194 briefly described below.
17195
17196 @menu
17197 * PowerPC AltiVec Built-in Functions on ISA 2.05::
17198 * PowerPC AltiVec Built-in Functions Available on ISA 2.06::
17199 * PowerPC AltiVec Built-in Functions Available on ISA 2.07::
17200 * PowerPC AltiVec Built-in Functions Available on ISA 3.0::
17201 @end menu
17202
17203 @node PowerPC AltiVec Built-in Functions on ISA 2.05
17204 @subsubsection PowerPC AltiVec Built-in Functions on ISA 2.05
17205
17206 The following interfaces are supported for the generic and specific
17207 AltiVec operations and the AltiVec predicates. In cases where there
17208 is a direct mapping between generic and specific operations, only the
17209 generic names are shown here, although the specific operations can also
17210 be used.
17211
17212 Arguments that are documented as @code{const int} require literal
17213 integral values within the range required for that operation.
17214
17215 @smallexample
17216 vector signed char vec_abs (vector signed char);
17217 vector signed short vec_abs (vector signed short);
17218 vector signed int vec_abs (vector signed int);
17219 vector float vec_abs (vector float);
17220
17221 vector signed char vec_abss (vector signed char);
17222 vector signed short vec_abss (vector signed short);
17223 vector signed int vec_abss (vector signed int);
17224
17225 vector signed char vec_add (vector bool char, vector signed char);
17226 vector signed char vec_add (vector signed char, vector bool char);
17227 vector signed char vec_add (vector signed char, vector signed char);
17228 vector unsigned char vec_add (vector bool char, vector unsigned char);
17229 vector unsigned char vec_add (vector unsigned char, vector bool char);
17230 vector unsigned char vec_add (vector unsigned char, vector unsigned char);
17231 vector signed short vec_add (vector bool short, vector signed short);
17232 vector signed short vec_add (vector signed short, vector bool short);
17233 vector signed short vec_add (vector signed short, vector signed short);
17234 vector unsigned short vec_add (vector bool short, vector unsigned short);
17235 vector unsigned short vec_add (vector unsigned short, vector bool short);
17236 vector unsigned short vec_add (vector unsigned short, vector unsigned short);
17237 vector signed int vec_add (vector bool int, vector signed int);
17238 vector signed int vec_add (vector signed int, vector bool int);
17239 vector signed int vec_add (vector signed int, vector signed int);
17240 vector unsigned int vec_add (vector bool int, vector unsigned int);
17241 vector unsigned int vec_add (vector unsigned int, vector bool int);
17242 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
17243 vector float vec_add (vector float, vector float);
17244
17245 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
17246
17247 vector unsigned char vec_adds (vector bool char, vector unsigned char);
17248 vector unsigned char vec_adds (vector unsigned char, vector bool char);
17249 vector unsigned char vec_adds (vector unsigned char, vector unsigned char);
17250 vector signed char vec_adds (vector bool char, vector signed char);
17251 vector signed char vec_adds (vector signed char, vector bool char);
17252 vector signed char vec_adds (vector signed char, vector signed char);
17253 vector unsigned short vec_adds (vector bool short, vector unsigned short);
17254 vector unsigned short vec_adds (vector unsigned short, vector bool short);
17255 vector unsigned short vec_adds (vector unsigned short, vector unsigned short);
17256 vector signed short vec_adds (vector bool short, vector signed short);
17257 vector signed short vec_adds (vector signed short, vector bool short);
17258 vector signed short vec_adds (vector signed short, vector signed short);
17259 vector unsigned int vec_adds (vector bool int, vector unsigned int);
17260 vector unsigned int vec_adds (vector unsigned int, vector bool int);
17261 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
17262 vector signed int vec_adds (vector bool int, vector signed int);
17263 vector signed int vec_adds (vector signed int, vector bool int);
17264 vector signed int vec_adds (vector signed int, vector signed int);
17265
17266 int vec_all_eq (vector signed char, vector bool char);
17267 int vec_all_eq (vector signed char, vector signed char);
17268 int vec_all_eq (vector unsigned char, vector bool char);
17269 int vec_all_eq (vector unsigned char, vector unsigned char);
17270 int vec_all_eq (vector bool char, vector bool char);
17271 int vec_all_eq (vector bool char, vector unsigned char);
17272 int vec_all_eq (vector bool char, vector signed char);
17273 int vec_all_eq (vector signed short, vector bool short);
17274 int vec_all_eq (vector signed short, vector signed short);
17275 int vec_all_eq (vector unsigned short, vector bool short);
17276 int vec_all_eq (vector unsigned short, vector unsigned short);
17277 int vec_all_eq (vector bool short, vector bool short);
17278 int vec_all_eq (vector bool short, vector unsigned short);
17279 int vec_all_eq (vector bool short, vector signed short);
17280 int vec_all_eq (vector pixel, vector pixel);
17281 int vec_all_eq (vector signed int, vector bool int);
17282 int vec_all_eq (vector signed int, vector signed int);
17283 int vec_all_eq (vector unsigned int, vector bool int);
17284 int vec_all_eq (vector unsigned int, vector unsigned int);
17285 int vec_all_eq (vector bool int, vector bool int);
17286 int vec_all_eq (vector bool int, vector unsigned int);
17287 int vec_all_eq (vector bool int, vector signed int);
17288 int vec_all_eq (vector float, vector float);
17289
17290 int vec_all_ge (vector bool char, vector unsigned char);
17291 int vec_all_ge (vector unsigned char, vector bool char);
17292 int vec_all_ge (vector unsigned char, vector unsigned char);
17293 int vec_all_ge (vector bool char, vector signed char);
17294 int vec_all_ge (vector signed char, vector bool char);
17295 int vec_all_ge (vector signed char, vector signed char);
17296 int vec_all_ge (vector bool short, vector unsigned short);
17297 int vec_all_ge (vector unsigned short, vector bool short);
17298 int vec_all_ge (vector unsigned short, vector unsigned short);
17299 int vec_all_ge (vector signed short, vector signed short);
17300 int vec_all_ge (vector bool short, vector signed short);
17301 int vec_all_ge (vector signed short, vector bool short);
17302 int vec_all_ge (vector bool int, vector unsigned int);
17303 int vec_all_ge (vector unsigned int, vector bool int);
17304 int vec_all_ge (vector unsigned int, vector unsigned int);
17305 int vec_all_ge (vector bool int, vector signed int);
17306 int vec_all_ge (vector signed int, vector bool int);
17307 int vec_all_ge (vector signed int, vector signed int);
17308 int vec_all_ge (vector float, vector float);
17309
17310 int vec_all_gt (vector bool char, vector unsigned char);
17311 int vec_all_gt (vector unsigned char, vector bool char);
17312 int vec_all_gt (vector unsigned char, vector unsigned char);
17313 int vec_all_gt (vector bool char, vector signed char);
17314 int vec_all_gt (vector signed char, vector bool char);
17315 int vec_all_gt (vector signed char, vector signed char);
17316 int vec_all_gt (vector bool short, vector unsigned short);
17317 int vec_all_gt (vector unsigned short, vector bool short);
17318 int vec_all_gt (vector unsigned short, vector unsigned short);
17319 int vec_all_gt (vector bool short, vector signed short);
17320 int vec_all_gt (vector signed short, vector bool short);
17321 int vec_all_gt (vector signed short, vector signed short);
17322 int vec_all_gt (vector bool int, vector unsigned int);
17323 int vec_all_gt (vector unsigned int, vector bool int);
17324 int vec_all_gt (vector unsigned int, vector unsigned int);
17325 int vec_all_gt (vector bool int, vector signed int);
17326 int vec_all_gt (vector signed int, vector bool int);
17327 int vec_all_gt (vector signed int, vector signed int);
17328 int vec_all_gt (vector float, vector float);
17329
17330 int vec_all_in (vector float, vector float);
17331
17332 int vec_all_le (vector bool char, vector unsigned char);
17333 int vec_all_le (vector unsigned char, vector bool char);
17334 int vec_all_le (vector unsigned char, vector unsigned char);
17335 int vec_all_le (vector bool char, vector signed char);
17336 int vec_all_le (vector signed char, vector bool char);
17337 int vec_all_le (vector signed char, vector signed char);
17338 int vec_all_le (vector bool short, vector unsigned short);
17339 int vec_all_le (vector unsigned short, vector bool short);
17340 int vec_all_le (vector unsigned short, vector unsigned short);
17341 int vec_all_le (vector bool short, vector signed short);
17342 int vec_all_le (vector signed short, vector bool short);
17343 int vec_all_le (vector signed short, vector signed short);
17344 int vec_all_le (vector bool int, vector unsigned int);
17345 int vec_all_le (vector unsigned int, vector bool int);
17346 int vec_all_le (vector unsigned int, vector unsigned int);
17347 int vec_all_le (vector bool int, vector signed int);
17348 int vec_all_le (vector signed int, vector bool int);
17349 int vec_all_le (vector signed int, vector signed int);
17350 int vec_all_le (vector float, vector float);
17351
17352 int vec_all_lt (vector bool char, vector unsigned char);
17353 int vec_all_lt (vector unsigned char, vector bool char);
17354 int vec_all_lt (vector unsigned char, vector unsigned char);
17355 int vec_all_lt (vector bool char, vector signed char);
17356 int vec_all_lt (vector signed char, vector bool char);
17357 int vec_all_lt (vector signed char, vector signed char);
17358 int vec_all_lt (vector bool short, vector unsigned short);
17359 int vec_all_lt (vector unsigned short, vector bool short);
17360 int vec_all_lt (vector unsigned short, vector unsigned short);
17361 int vec_all_lt (vector bool short, vector signed short);
17362 int vec_all_lt (vector signed short, vector bool short);
17363 int vec_all_lt (vector signed short, vector signed short);
17364 int vec_all_lt (vector bool int, vector unsigned int);
17365 int vec_all_lt (vector unsigned int, vector bool int);
17366 int vec_all_lt (vector unsigned int, vector unsigned int);
17367 int vec_all_lt (vector bool int, vector signed int);
17368 int vec_all_lt (vector signed int, vector bool int);
17369 int vec_all_lt (vector signed int, vector signed int);
17370 int vec_all_lt (vector float, vector float);
17371
17372 int vec_all_nan (vector float);
17373
17374 int vec_all_ne (vector signed char, vector bool char);
17375 int vec_all_ne (vector signed char, vector signed char);
17376 int vec_all_ne (vector unsigned char, vector bool char);
17377 int vec_all_ne (vector unsigned char, vector unsigned char);
17378 int vec_all_ne (vector bool char, vector bool char);
17379 int vec_all_ne (vector bool char, vector unsigned char);
17380 int vec_all_ne (vector bool char, vector signed char);
17381 int vec_all_ne (vector signed short, vector bool short);
17382 int vec_all_ne (vector signed short, vector signed short);
17383 int vec_all_ne (vector unsigned short, vector bool short);
17384 int vec_all_ne (vector unsigned short, vector unsigned short);
17385 int vec_all_ne (vector bool short, vector bool short);
17386 int vec_all_ne (vector bool short, vector unsigned short);
17387 int vec_all_ne (vector bool short, vector signed short);
17388 int vec_all_ne (vector pixel, vector pixel);
17389 int vec_all_ne (vector signed int, vector bool int);
17390 int vec_all_ne (vector signed int, vector signed int);
17391 int vec_all_ne (vector unsigned int, vector bool int);
17392 int vec_all_ne (vector unsigned int, vector unsigned int);
17393 int vec_all_ne (vector bool int, vector bool int);
17394 int vec_all_ne (vector bool int, vector unsigned int);
17395 int vec_all_ne (vector bool int, vector signed int);
17396 int vec_all_ne (vector float, vector float);
17397
17398 int vec_all_nge (vector float, vector float);
17399
17400 int vec_all_ngt (vector float, vector float);
17401
17402 int vec_all_nle (vector float, vector float);
17403
17404 int vec_all_nlt (vector float, vector float);
17405
17406 int vec_all_numeric (vector float);
17407
17408 vector float vec_and (vector float, vector float);
17409 vector float vec_and (vector float, vector bool int);
17410 vector float vec_and (vector bool int, vector float);
17411 vector bool int vec_and (vector bool int, vector bool int);
17412 vector signed int vec_and (vector bool int, vector signed int);
17413 vector signed int vec_and (vector signed int, vector bool int);
17414 vector signed int vec_and (vector signed int, vector signed int);
17415 vector unsigned int vec_and (vector bool int, vector unsigned int);
17416 vector unsigned int vec_and (vector unsigned int, vector bool int);
17417 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
17418 vector bool short vec_and (vector bool short, vector bool short);
17419 vector signed short vec_and (vector bool short, vector signed short);
17420 vector signed short vec_and (vector signed short, vector bool short);
17421 vector signed short vec_and (vector signed short, vector signed short);
17422 vector unsigned short vec_and (vector bool short, vector unsigned short);
17423 vector unsigned short vec_and (vector unsigned short, vector bool short);
17424 vector unsigned short vec_and (vector unsigned short, vector unsigned short);
17425 vector signed char vec_and (vector bool char, vector signed char);
17426 vector bool char vec_and (vector bool char, vector bool char);
17427 vector signed char vec_and (vector signed char, vector bool char);
17428 vector signed char vec_and (vector signed char, vector signed char);
17429 vector unsigned char vec_and (vector bool char, vector unsigned char);
17430 vector unsigned char vec_and (vector unsigned char, vector bool char);
17431 vector unsigned char vec_and (vector unsigned char, vector unsigned char);
17432
17433 vector float vec_andc (vector float, vector float);
17434 vector float vec_andc (vector float, vector bool int);
17435 vector float vec_andc (vector bool int, vector float);
17436 vector bool int vec_andc (vector bool int, vector bool int);
17437 vector signed int vec_andc (vector bool int, vector signed int);
17438 vector signed int vec_andc (vector signed int, vector bool int);
17439 vector signed int vec_andc (vector signed int, vector signed int);
17440 vector unsigned int vec_andc (vector bool int, vector unsigned int);
17441 vector unsigned int vec_andc (vector unsigned int, vector bool int);
17442 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
17443 vector bool short vec_andc (vector bool short, vector bool short);
17444 vector signed short vec_andc (vector bool short, vector signed short);
17445 vector signed short vec_andc (vector signed short, vector bool short);
17446 vector signed short vec_andc (vector signed short, vector signed short);
17447 vector unsigned short vec_andc (vector bool short, vector unsigned short);
17448 vector unsigned short vec_andc (vector unsigned short, vector bool short);
17449 vector unsigned short vec_andc (vector unsigned short, vector unsigned short);
17450 vector signed char vec_andc (vector bool char, vector signed char);
17451 vector bool char vec_andc (vector bool char, vector bool char);
17452 vector signed char vec_andc (vector signed char, vector bool char);
17453 vector signed char vec_andc (vector signed char, vector signed char);
17454 vector unsigned char vec_andc (vector bool char, vector unsigned char);
17455 vector unsigned char vec_andc (vector unsigned char, vector bool char);
17456 vector unsigned char vec_andc (vector unsigned char, vector unsigned char);
17457
17458 int vec_any_eq (vector signed char, vector bool char);
17459 int vec_any_eq (vector signed char, vector signed char);
17460 int vec_any_eq (vector unsigned char, vector bool char);
17461 int vec_any_eq (vector unsigned char, vector unsigned char);
17462 int vec_any_eq (vector bool char, vector bool char);
17463 int vec_any_eq (vector bool char, vector unsigned char);
17464 int vec_any_eq (vector bool char, vector signed char);
17465 int vec_any_eq (vector signed short, vector bool short);
17466 int vec_any_eq (vector signed short, vector signed short);
17467 int vec_any_eq (vector unsigned short, vector bool short);
17468 int vec_any_eq (vector unsigned short, vector unsigned short);
17469 int vec_any_eq (vector bool short, vector bool short);
17470 int vec_any_eq (vector bool short, vector unsigned short);
17471 int vec_any_eq (vector bool short, vector signed short);
17472 int vec_any_eq (vector pixel, vector pixel);
17473 int vec_any_eq (vector signed int, vector bool int);
17474 int vec_any_eq (vector signed int, vector signed int);
17475 int vec_any_eq (vector unsigned int, vector bool int);
17476 int vec_any_eq (vector unsigned int, vector unsigned int);
17477 int vec_any_eq (vector bool int, vector bool int);
17478 int vec_any_eq (vector bool int, vector unsigned int);
17479 int vec_any_eq (vector bool int, vector signed int);
17480 int vec_any_eq (vector float, vector float);
17481
17482 int vec_any_ge (vector signed char, vector bool char);
17483 int vec_any_ge (vector unsigned char, vector bool char);
17484 int vec_any_ge (vector unsigned char, vector unsigned char);
17485 int vec_any_ge (vector signed char, vector signed char);
17486 int vec_any_ge (vector bool char, vector unsigned char);
17487 int vec_any_ge (vector bool char, vector signed char);
17488 int vec_any_ge (vector unsigned short, vector bool short);
17489 int vec_any_ge (vector unsigned short, vector unsigned short);
17490 int vec_any_ge (vector signed short, vector signed short);
17491 int vec_any_ge (vector signed short, vector bool short);
17492 int vec_any_ge (vector bool short, vector unsigned short);
17493 int vec_any_ge (vector bool short, vector signed short);
17494 int vec_any_ge (vector signed int, vector bool int);
17495 int vec_any_ge (vector unsigned int, vector bool int);
17496 int vec_any_ge (vector unsigned int, vector unsigned int);
17497 int vec_any_ge (vector signed int, vector signed int);
17498 int vec_any_ge (vector bool int, vector unsigned int);
17499 int vec_any_ge (vector bool int, vector signed int);
17500 int vec_any_ge (vector float, vector float);
17501
17502 int vec_any_gt (vector bool char, vector unsigned char);
17503 int vec_any_gt (vector unsigned char, vector bool char);
17504 int vec_any_gt (vector unsigned char, vector unsigned char);
17505 int vec_any_gt (vector bool char, vector signed char);
17506 int vec_any_gt (vector signed char, vector bool char);
17507 int vec_any_gt (vector signed char, vector signed char);
17508 int vec_any_gt (vector bool short, vector unsigned short);
17509 int vec_any_gt (vector unsigned short, vector bool short);
17510 int vec_any_gt (vector unsigned short, vector unsigned short);
17511 int vec_any_gt (vector bool short, vector signed short);
17512 int vec_any_gt (vector signed short, vector bool short);
17513 int vec_any_gt (vector signed short, vector signed short);
17514 int vec_any_gt (vector bool int, vector unsigned int);
17515 int vec_any_gt (vector unsigned int, vector bool int);
17516 int vec_any_gt (vector unsigned int, vector unsigned int);
17517 int vec_any_gt (vector bool int, vector signed int);
17518 int vec_any_gt (vector signed int, vector bool int);
17519 int vec_any_gt (vector signed int, vector signed int);
17520 int vec_any_gt (vector float, vector float);
17521
17522 int vec_any_le (vector bool char, vector unsigned char);
17523 int vec_any_le (vector unsigned char, vector bool char);
17524 int vec_any_le (vector unsigned char, vector unsigned char);
17525 int vec_any_le (vector bool char, vector signed char);
17526 int vec_any_le (vector signed char, vector bool char);
17527 int vec_any_le (vector signed char, vector signed char);
17528 int vec_any_le (vector bool short, vector unsigned short);
17529 int vec_any_le (vector unsigned short, vector bool short);
17530 int vec_any_le (vector unsigned short, vector unsigned short);
17531 int vec_any_le (vector bool short, vector signed short);
17532 int vec_any_le (vector signed short, vector bool short);
17533 int vec_any_le (vector signed short, vector signed short);
17534 int vec_any_le (vector bool int, vector unsigned int);
17535 int vec_any_le (vector unsigned int, vector bool int);
17536 int vec_any_le (vector unsigned int, vector unsigned int);
17537 int vec_any_le (vector bool int, vector signed int);
17538 int vec_any_le (vector signed int, vector bool int);
17539 int vec_any_le (vector signed int, vector signed int);
17540 int vec_any_le (vector float, vector float);
17541
17542 int vec_any_lt (vector bool char, vector unsigned char);
17543 int vec_any_lt (vector unsigned char, vector bool char);
17544 int vec_any_lt (vector unsigned char, vector unsigned char);
17545 int vec_any_lt (vector bool char, vector signed char);
17546 int vec_any_lt (vector signed char, vector bool char);
17547 int vec_any_lt (vector signed char, vector signed char);
17548 int vec_any_lt (vector bool short, vector unsigned short);
17549 int vec_any_lt (vector unsigned short, vector bool short);
17550 int vec_any_lt (vector unsigned short, vector unsigned short);
17551 int vec_any_lt (vector bool short, vector signed short);
17552 int vec_any_lt (vector signed short, vector bool short);
17553 int vec_any_lt (vector signed short, vector signed short);
17554 int vec_any_lt (vector bool int, vector unsigned int);
17555 int vec_any_lt (vector unsigned int, vector bool int);
17556 int vec_any_lt (vector unsigned int, vector unsigned int);
17557 int vec_any_lt (vector bool int, vector signed int);
17558 int vec_any_lt (vector signed int, vector bool int);
17559 int vec_any_lt (vector signed int, vector signed int);
17560 int vec_any_lt (vector float, vector float);
17561
17562 int vec_any_nan (vector float);
17563
17564 int vec_any_ne (vector signed char, vector bool char);
17565 int vec_any_ne (vector signed char, vector signed char);
17566 int vec_any_ne (vector unsigned char, vector bool char);
17567 int vec_any_ne (vector unsigned char, vector unsigned char);
17568 int vec_any_ne (vector bool char, vector bool char);
17569 int vec_any_ne (vector bool char, vector unsigned char);
17570 int vec_any_ne (vector bool char, vector signed char);
17571 int vec_any_ne (vector signed short, vector bool short);
17572 int vec_any_ne (vector signed short, vector signed short);
17573 int vec_any_ne (vector unsigned short, vector bool short);
17574 int vec_any_ne (vector unsigned short, vector unsigned short);
17575 int vec_any_ne (vector bool short, vector bool short);
17576 int vec_any_ne (vector bool short, vector unsigned short);
17577 int vec_any_ne (vector bool short, vector signed short);
17578 int vec_any_ne (vector pixel, vector pixel);
17579 int vec_any_ne (vector signed int, vector bool int);
17580 int vec_any_ne (vector signed int, vector signed int);
17581 int vec_any_ne (vector unsigned int, vector bool int);
17582 int vec_any_ne (vector unsigned int, vector unsigned int);
17583 int vec_any_ne (vector bool int, vector bool int);
17584 int vec_any_ne (vector bool int, vector unsigned int);
17585 int vec_any_ne (vector bool int, vector signed int);
17586 int vec_any_ne (vector float, vector float);
17587
17588 int vec_any_nge (vector float, vector float);
17589
17590 int vec_any_ngt (vector float, vector float);
17591
17592 int vec_any_nle (vector float, vector float);
17593
17594 int vec_any_nlt (vector float, vector float);
17595
17596 int vec_any_numeric (vector float);
17597
17598 int vec_any_out (vector float, vector float);
17599
17600 vector unsigned char vec_avg (vector unsigned char, vector unsigned char);
17601 vector signed char vec_avg (vector signed char, vector signed char);
17602 vector unsigned short vec_avg (vector unsigned short, vector unsigned short);
17603 vector signed short vec_avg (vector signed short, vector signed short);
17604 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
17605 vector signed int vec_avg (vector signed int, vector signed int);
17606
17607 vector float vec_ceil (vector float);
17608
17609 vector signed int vec_cmpb (vector float, vector float);
17610
17611 vector bool char vec_cmpeq (vector bool char, vector bool char);
17612 vector bool short vec_cmpeq (vector bool short, vector bool short);
17613 vector bool int vec_cmpeq (vector bool int, vector bool int);
17614 vector bool char vec_cmpeq (vector signed char, vector signed char);
17615 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
17616 vector bool short vec_cmpeq (vector signed short, vector signed short);
17617 vector bool short vec_cmpeq (vector unsigned short, vector unsigned short);
17618 vector bool int vec_cmpeq (vector signed int, vector signed int);
17619 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
17620 vector bool int vec_cmpeq (vector float, vector float);
17621
17622 vector bool int vec_cmpge (vector float, vector float);
17623
17624 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
17625 vector bool char vec_cmpgt (vector signed char, vector signed char);
17626 vector bool short vec_cmpgt (vector unsigned short, vector unsigned short);
17627 vector bool short vec_cmpgt (vector signed short, vector signed short);
17628 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
17629 vector bool int vec_cmpgt (vector signed int, vector signed int);
17630 vector bool int vec_cmpgt (vector float, vector float);
17631
17632 vector bool int vec_cmple (vector float, vector float);
17633
17634 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
17635 vector bool char vec_cmplt (vector signed char, vector signed char);
17636 vector bool short vec_cmplt (vector unsigned short, vector unsigned short);
17637 vector bool short vec_cmplt (vector signed short, vector signed short);
17638 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
17639 vector bool int vec_cmplt (vector signed int, vector signed int);
17640 vector bool int vec_cmplt (vector float, vector float);
17641
17642 vector float vec_cpsgn (vector float, vector float);
17643
17644 vector float vec_ctf (vector unsigned int, const int);
17645 vector float vec_ctf (vector signed int, const int);
17646
17647 vector signed int vec_cts (vector float, const int);
17648
17649 vector unsigned int vec_ctu (vector float, const int);
17650
17651 void vec_dss (const int);
17652
17653 void vec_dssall (void);
17654
17655 void vec_dst (const vector unsigned char *, int, const int);
17656 void vec_dst (const vector signed char *, int, const int);
17657 void vec_dst (const vector bool char *, int, const int);
17658 void vec_dst (const vector unsigned short *, int, const int);
17659 void vec_dst (const vector signed short *, int, const int);
17660 void vec_dst (const vector bool short *, int, const int);
17661 void vec_dst (const vector pixel *, int, const int);
17662 void vec_dst (const vector unsigned int *, int, const int);
17663 void vec_dst (const vector signed int *, int, const int);
17664 void vec_dst (const vector bool int *, int, const int);
17665 void vec_dst (const vector float *, int, const int);
17666 void vec_dst (const unsigned char *, int, const int);
17667 void vec_dst (const signed char *, int, const int);
17668 void vec_dst (const unsigned short *, int, const int);
17669 void vec_dst (const short *, int, const int);
17670 void vec_dst (const unsigned int *, int, const int);
17671 void vec_dst (const int *, int, const int);
17672 void vec_dst (const float *, int, const int);
17673
17674 void vec_dstst (const vector unsigned char *, int, const int);
17675 void vec_dstst (const vector signed char *, int, const int);
17676 void vec_dstst (const vector bool char *, int, const int);
17677 void vec_dstst (const vector unsigned short *, int, const int);
17678 void vec_dstst (const vector signed short *, int, const int);
17679 void vec_dstst (const vector bool short *, int, const int);
17680 void vec_dstst (const vector pixel *, int, const int);
17681 void vec_dstst (const vector unsigned int *, int, const int);
17682 void vec_dstst (const vector signed int *, int, const int);
17683 void vec_dstst (const vector bool int *, int, const int);
17684 void vec_dstst (const vector float *, int, const int);
17685 void vec_dstst (const unsigned char *, int, const int);
17686 void vec_dstst (const signed char *, int, const int);
17687 void vec_dstst (const unsigned short *, int, const int);
17688 void vec_dstst (const short *, int, const int);
17689 void vec_dstst (const unsigned int *, int, const int);
17690 void vec_dstst (const int *, int, const int);
17691 void vec_dstst (const unsigned long *, int, const int);
17692 void vec_dstst (const long *, int, const int);
17693 void vec_dstst (const float *, int, const int);
17694
17695 void vec_dststt (const vector unsigned char *, int, const int);
17696 void vec_dststt (const vector signed char *, int, const int);
17697 void vec_dststt (const vector bool char *, int, const int);
17698 void vec_dststt (const vector unsigned short *, int, const int);
17699 void vec_dststt (const vector signed short *, int, const int);
17700 void vec_dststt (const vector bool short *, int, const int);
17701 void vec_dststt (const vector pixel *, int, const int);
17702 void vec_dststt (const vector unsigned int *, int, const int);
17703 void vec_dststt (const vector signed int *, int, const int);
17704 void vec_dststt (const vector bool int *, int, const int);
17705 void vec_dststt (const vector float *, int, const int);
17706 void vec_dststt (const unsigned char *, int, const int);
17707 void vec_dststt (const signed char *, int, const int);
17708 void vec_dststt (const unsigned short *, int, const int);
17709 void vec_dststt (const short *, int, const int);
17710 void vec_dststt (const unsigned int *, int, const int);
17711 void vec_dststt (const int *, int, const int);
17712 void vec_dststt (const float *, int, const int);
17713
17714 void vec_dstt (const vector unsigned char *, int, const int);
17715 void vec_dstt (const vector signed char *, int, const int);
17716 void vec_dstt (const vector bool char *, int, const int);
17717 void vec_dstt (const vector unsigned short *, int, const int);
17718 void vec_dstt (const vector signed short *, int, const int);
17719 void vec_dstt (const vector bool short *, int, const int);
17720 void vec_dstt (const vector pixel *, int, const int);
17721 void vec_dstt (const vector unsigned int *, int, const int);
17722 void vec_dstt (const vector signed int *, int, const int);
17723 void vec_dstt (const vector bool int *, int, const int);
17724 void vec_dstt (const vector float *, int, const int);
17725 void vec_dstt (const unsigned char *, int, const int);
17726 void vec_dstt (const signed char *, int, const int);
17727 void vec_dstt (const unsigned short *, int, const int);
17728 void vec_dstt (const short *, int, const int);
17729 void vec_dstt (const unsigned int *, int, const int);
17730 void vec_dstt (const int *, int, const int);
17731 void vec_dstt (const float *, int, const int);
17732
17733 vector float vec_expte (vector float);
17734
17735 vector float vec_floor (vector float);
17736
17737 vector float vec_ld (int, const vector float *);
17738 vector float vec_ld (int, const float *);
17739 vector bool int vec_ld (int, const vector bool int *);
17740 vector signed int vec_ld (int, const vector signed int *);
17741 vector signed int vec_ld (int, const int *);
17742 vector unsigned int vec_ld (int, const vector unsigned int *);
17743 vector unsigned int vec_ld (int, const unsigned int *);
17744 vector bool short vec_ld (int, const vector bool short *);
17745 vector pixel vec_ld (int, const vector pixel *);
17746 vector signed short vec_ld (int, const vector signed short *);
17747 vector signed short vec_ld (int, const short *);
17748 vector unsigned short vec_ld (int, const vector unsigned short *);
17749 vector unsigned short vec_ld (int, const unsigned short *);
17750 vector bool char vec_ld (int, const vector bool char *);
17751 vector signed char vec_ld (int, const vector signed char *);
17752 vector signed char vec_ld (int, const signed char *);
17753 vector unsigned char vec_ld (int, const vector unsigned char *);
17754 vector unsigned char vec_ld (int, const unsigned char *);
17755
17756 vector signed char vec_lde (int, const signed char *);
17757 vector unsigned char vec_lde (int, const unsigned char *);
17758 vector signed short vec_lde (int, const short *);
17759 vector unsigned short vec_lde (int, const unsigned short *);
17760 vector float vec_lde (int, const float *);
17761 vector signed int vec_lde (int, const int *);
17762 vector unsigned int vec_lde (int, const unsigned int *);
17763
17764 vector float vec_ldl (int, const vector float *);
17765 vector float vec_ldl (int, const float *);
17766 vector bool int vec_ldl (int, const vector bool int *);
17767 vector signed int vec_ldl (int, const vector signed int *);
17768 vector signed int vec_ldl (int, const int *);
17769 vector unsigned int vec_ldl (int, const vector unsigned int *);
17770 vector unsigned int vec_ldl (int, const unsigned int *);
17771 vector bool short vec_ldl (int, const vector bool short *);
17772 vector pixel vec_ldl (int, const vector pixel *);
17773 vector signed short vec_ldl (int, const vector signed short *);
17774 vector signed short vec_ldl (int, const short *);
17775 vector unsigned short vec_ldl (int, const vector unsigned short *);
17776 vector unsigned short vec_ldl (int, const unsigned short *);
17777 vector bool char vec_ldl (int, const vector bool char *);
17778 vector signed char vec_ldl (int, const vector signed char *);
17779 vector signed char vec_ldl (int, const signed char *);
17780 vector unsigned char vec_ldl (int, const vector unsigned char *);
17781 vector unsigned char vec_ldl (int, const unsigned char *);
17782
17783 vector float vec_loge (vector float);
17784
17785 vector signed char vec_lvebx (int, char *);
17786 vector unsigned char vec_lvebx (int, unsigned char *);
17787
17788 vector signed short vec_lvehx (int, short *);
17789 vector unsigned short vec_lvehx (int, unsigned short *);
17790
17791 vector float vec_lvewx (int, float *);
17792 vector signed int vec_lvewx (int, int *);
17793 vector unsigned int vec_lvewx (int, unsigned int *);
17794
17795 vector unsigned char vec_lvsl (int, const unsigned char *);
17796 vector unsigned char vec_lvsl (int, const signed char *);
17797 vector unsigned char vec_lvsl (int, const unsigned short *);
17798 vector unsigned char vec_lvsl (int, const short *);
17799 vector unsigned char vec_lvsl (int, const unsigned int *);
17800 vector unsigned char vec_lvsl (int, const int *);
17801 vector unsigned char vec_lvsl (int, const float *);
17802
17803 vector unsigned char vec_lvsr (int, const unsigned char *);
17804 vector unsigned char vec_lvsr (int, const signed char *);
17805 vector unsigned char vec_lvsr (int, const unsigned short *);
17806 vector unsigned char vec_lvsr (int, const short *);
17807 vector unsigned char vec_lvsr (int, const unsigned int *);
17808 vector unsigned char vec_lvsr (int, const int *);
17809 vector unsigned char vec_lvsr (int, const float *);
17810
17811 vector float vec_madd (vector float, vector float, vector float);
17812
17813 vector signed short vec_madds (vector signed short, vector signed short,
17814 vector signed short);
17815
17816 vector unsigned char vec_max (vector bool char, vector unsigned char);
17817 vector unsigned char vec_max (vector unsigned char, vector bool char);
17818 vector unsigned char vec_max (vector unsigned char, vector unsigned char);
17819 vector signed char vec_max (vector bool char, vector signed char);
17820 vector signed char vec_max (vector signed char, vector bool char);
17821 vector signed char vec_max (vector signed char, vector signed char);
17822 vector unsigned short vec_max (vector bool short, vector unsigned short);
17823 vector unsigned short vec_max (vector unsigned short, vector bool short);
17824 vector unsigned short vec_max (vector unsigned short, vector unsigned short);
17825 vector signed short vec_max (vector bool short, vector signed short);
17826 vector signed short vec_max (vector signed short, vector bool short);
17827 vector signed short vec_max (vector signed short, vector signed short);
17828 vector unsigned int vec_max (vector bool int, vector unsigned int);
17829 vector unsigned int vec_max (vector unsigned int, vector bool int);
17830 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
17831 vector signed int vec_max (vector bool int, vector signed int);
17832 vector signed int vec_max (vector signed int, vector bool int);
17833 vector signed int vec_max (vector signed int, vector signed int);
17834 vector float vec_max (vector float, vector float);
17835
17836 vector bool char vec_mergeh (vector bool char, vector bool char);
17837 vector signed char vec_mergeh (vector signed char, vector signed char);
17838 vector unsigned char vec_mergeh (vector unsigned char, vector unsigned char);
17839 vector bool short vec_mergeh (vector bool short, vector bool short);
17840 vector pixel vec_mergeh (vector pixel, vector pixel);
17841 vector signed short vec_mergeh (vector signed short, vector signed short);
17842 vector unsigned short vec_mergeh (vector unsigned short, vector unsigned short);
17843 vector float vec_mergeh (vector float, vector float);
17844 vector bool int vec_mergeh (vector bool int, vector bool int);
17845 vector signed int vec_mergeh (vector signed int, vector signed int);
17846 vector unsigned int vec_mergeh (vector unsigned int, vector unsigned int);
17847
17848 vector bool char vec_mergel (vector bool char, vector bool char);
17849 vector signed char vec_mergel (vector signed char, vector signed char);
17850 vector unsigned char vec_mergel (vector unsigned char, vector unsigned char);
17851 vector bool short vec_mergel (vector bool short, vector bool short);
17852 vector pixel vec_mergel (vector pixel, vector pixel);
17853 vector signed short vec_mergel (vector signed short, vector signed short);
17854 vector unsigned short vec_mergel (vector unsigned short, vector unsigned short);
17855 vector float vec_mergel (vector float, vector float);
17856 vector bool int vec_mergel (vector bool int, vector bool int);
17857 vector signed int vec_mergel (vector signed int, vector signed int);
17858 vector unsigned int vec_mergel (vector unsigned int, vector unsigned int);
17859
17860 vector unsigned short vec_mfvscr (void);
17861
17862 vector unsigned char vec_min (vector bool char, vector unsigned char);
17863 vector unsigned char vec_min (vector unsigned char, vector bool char);
17864 vector unsigned char vec_min (vector unsigned char, vector unsigned char);
17865 vector signed char vec_min (vector bool char, vector signed char);
17866 vector signed char vec_min (vector signed char, vector bool char);
17867 vector signed char vec_min (vector signed char, vector signed char);
17868 vector unsigned short vec_min (vector bool short, vector unsigned short);
17869 vector unsigned short vec_min (vector unsigned short, vector bool short);
17870 vector unsigned short vec_min (vector unsigned short, vector unsigned short);
17871 vector signed short vec_min (vector bool short, vector signed short);
17872 vector signed short vec_min (vector signed short, vector bool short);
17873 vector signed short vec_min (vector signed short, vector signed short);
17874 vector unsigned int vec_min (vector bool int, vector unsigned int);
17875 vector unsigned int vec_min (vector unsigned int, vector bool int);
17876 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
17877 vector signed int vec_min (vector bool int, vector signed int);
17878 vector signed int vec_min (vector signed int, vector bool int);
17879 vector signed int vec_min (vector signed int, vector signed int);
17880 vector float vec_min (vector float, vector float);
17881
17882 vector signed short vec_mladd (vector signed short, vector signed short,
17883 vector signed short);
17884 vector signed short vec_mladd (vector signed short, vector unsigned short,
17885 vector unsigned short);
17886 vector signed short vec_mladd (vector unsigned short, vector signed short,
17887 vector signed short);
17888 vector unsigned short vec_mladd (vector unsigned short, vector unsigned short,
17889 vector unsigned short);
17890
17891 vector signed short vec_mradds (vector signed short, vector signed short,
17892 vector signed short);
17893
17894 vector unsigned int vec_msum (vector unsigned char, vector unsigned char,
17895 vector unsigned int);
17896 vector signed int vec_msum (vector signed char, vector unsigned char,
17897 vector signed int);
17898 vector unsigned int vec_msum (vector unsigned short, vector unsigned short,
17899 vector unsigned int);
17900 vector signed int vec_msum (vector signed short, vector signed short,
17901 vector signed int);
17902
17903 vector unsigned int vec_msums (vector unsigned short, vector unsigned short,
17904 vector unsigned int);
17905 vector signed int vec_msums (vector signed short, vector signed short,
17906 vector signed int);
17907
17908 void vec_mtvscr (vector signed int);
17909 void vec_mtvscr (vector unsigned int);
17910 void vec_mtvscr (vector bool int);
17911 void vec_mtvscr (vector signed short);
17912 void vec_mtvscr (vector unsigned short);
17913 void vec_mtvscr (vector bool short);
17914 void vec_mtvscr (vector pixel);
17915 void vec_mtvscr (vector signed char);
17916 void vec_mtvscr (vector unsigned char);
17917 void vec_mtvscr (vector bool char);
17918
17919 vector float vec_mul (vector float, vector float);
17920
17921 vector unsigned short vec_mule (vector unsigned char, vector unsigned char);
17922 vector signed short vec_mule (vector signed char, vector signed char);
17923 vector unsigned int vec_mule (vector unsigned short, vector unsigned short);
17924 vector signed int vec_mule (vector signed short, vector signed short);
17925
17926 vector unsigned short vec_mulo (vector unsigned char, vector unsigned char);
17927 vector signed short vec_mulo (vector signed char, vector signed char);
17928 vector unsigned int vec_mulo (vector unsigned short, vector unsigned short);
17929 vector signed int vec_mulo (vector signed short, vector signed short);
17930
17931 vector signed char vec_nabs (vector signed char);
17932 vector signed short vec_nabs (vector signed short);
17933 vector signed int vec_nabs (vector signed int);
17934 vector float vec_nabs (vector float);
17935
17936 vector float vec_nmsub (vector float, vector float, vector float);
17937
17938 vector float vec_nor (vector float, vector float);
17939 vector signed int vec_nor (vector signed int, vector signed int);
17940 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
17941 vector bool int vec_nor (vector bool int, vector bool int);
17942 vector signed short vec_nor (vector signed short, vector signed short);
17943 vector unsigned short vec_nor (vector unsigned short, vector unsigned short);
17944 vector bool short vec_nor (vector bool short, vector bool short);
17945 vector signed char vec_nor (vector signed char, vector signed char);
17946 vector unsigned char vec_nor (vector unsigned char, vector unsigned char);
17947 vector bool char vec_nor (vector bool char, vector bool char);
17948
17949 vector float vec_or (vector float, vector float);
17950 vector float vec_or (vector float, vector bool int);
17951 vector float vec_or (vector bool int, vector float);
17952 vector bool int vec_or (vector bool int, vector bool int);
17953 vector signed int vec_or (vector bool int, vector signed int);
17954 vector signed int vec_or (vector signed int, vector bool int);
17955 vector signed int vec_or (vector signed int, vector signed int);
17956 vector unsigned int vec_or (vector bool int, vector unsigned int);
17957 vector unsigned int vec_or (vector unsigned int, vector bool int);
17958 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
17959 vector bool short vec_or (vector bool short, vector bool short);
17960 vector signed short vec_or (vector bool short, vector signed short);
17961 vector signed short vec_or (vector signed short, vector bool short);
17962 vector signed short vec_or (vector signed short, vector signed short);
17963 vector unsigned short vec_or (vector bool short, vector unsigned short);
17964 vector unsigned short vec_or (vector unsigned short, vector bool short);
17965 vector unsigned short vec_or (vector unsigned short, vector unsigned short);
17966 vector signed char vec_or (vector bool char, vector signed char);
17967 vector bool char vec_or (vector bool char, vector bool char);
17968 vector signed char vec_or (vector signed char, vector bool char);
17969 vector signed char vec_or (vector signed char, vector signed char);
17970 vector unsigned char vec_or (vector bool char, vector unsigned char);
17971 vector unsigned char vec_or (vector unsigned char, vector bool char);
17972 vector unsigned char vec_or (vector unsigned char, vector unsigned char);
17973
17974 vector signed char vec_pack (vector signed short, vector signed short);
17975 vector unsigned char vec_pack (vector unsigned short, vector unsigned short);
17976 vector bool char vec_pack (vector bool short, vector bool short);
17977 vector signed short vec_pack (vector signed int, vector signed int);
17978 vector unsigned short vec_pack (vector unsigned int, vector unsigned int);
17979 vector bool short vec_pack (vector bool int, vector bool int);
17980
17981 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
17982
17983 vector unsigned char vec_packs (vector unsigned short, vector unsigned short);
17984 vector signed char vec_packs (vector signed short, vector signed short);
17985 vector unsigned short vec_packs (vector unsigned int, vector unsigned int);
17986 vector signed short vec_packs (vector signed int, vector signed int);
17987
17988 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short);
17989 vector unsigned char vec_packsu (vector signed short, vector signed short);
17990 vector unsigned short vec_packsu (vector unsigned int, vector unsigned int);
17991 vector unsigned short vec_packsu (vector signed int, vector signed int);
17992
17993 vector float vec_perm (vector float, vector float, vector unsigned char);
17994 vector signed int vec_perm (vector signed int, vector signed int, vector unsigned char);
17995 vector unsigned int vec_perm (vector unsigned int, vector unsigned int,
17996 vector unsigned char);
17997 vector bool int vec_perm (vector bool int, vector bool int, vector unsigned char);
17998 vector signed short vec_perm (vector signed short, vector signed short,
17999 vector unsigned char);
18000 vector unsigned short vec_perm (vector unsigned short, vector unsigned short,
18001 vector unsigned char);
18002 vector bool short vec_perm (vector bool short, vector bool short, vector unsigned char);
18003 vector pixel vec_perm (vector pixel, vector pixel, vector unsigned char);
18004 vector signed char vec_perm (vector signed char, vector signed char,
18005 vector unsigned char);
18006 vector unsigned char vec_perm (vector unsigned char, vector unsigned char,
18007 vector unsigned char);
18008 vector bool char vec_perm (vector bool char, vector bool char, vector unsigned char);
18009
18010 vector float vec_re (vector float);
18011
18012 vector bool char vec_reve (vector bool char);
18013 vector signed char vec_reve (vector signed char);
18014 vector unsigned char vec_reve (vector unsigned char);
18015 vector bool int vec_reve (vector bool int);
18016 vector signed int vec_reve (vector signed int);
18017 vector unsigned int vec_reve (vector unsigned int);
18018 vector bool short vec_reve (vector bool short);
18019 vector signed short vec_reve (vector signed short);
18020 vector unsigned short vec_reve (vector unsigned short);
18021
18022 vector signed char vec_rl (vector signed char, vector unsigned char);
18023 vector unsigned char vec_rl (vector unsigned char, vector unsigned char);
18024 vector signed short vec_rl (vector signed short, vector unsigned short);
18025 vector unsigned short vec_rl (vector unsigned short, vector unsigned short);
18026 vector signed int vec_rl (vector signed int, vector unsigned int);
18027 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
18028
18029 vector float vec_round (vector float);
18030
18031 vector float vec_rsqrt (vector float);
18032
18033 vector float vec_rsqrte (vector float);
18034
18035 vector float vec_sel (vector float, vector float, vector bool int);
18036 vector float vec_sel (vector float, vector float, vector unsigned int);
18037 vector signed int vec_sel (vector signed int, vector signed int, vector bool int);
18038 vector signed int vec_sel (vector signed int, vector signed int, vector unsigned int);
18039 vector unsigned int vec_sel (vector unsigned int, vector unsigned int, vector bool int);
18040 vector unsigned int vec_sel (vector unsigned int, vector unsigned int,
18041 vector unsigned int);
18042 vector bool int vec_sel (vector bool int, vector bool int, vector bool int);
18043 vector bool int vec_sel (vector bool int, vector bool int, vector unsigned int);
18044 vector signed short vec_sel (vector signed short, vector signed short,
18045 vector bool short);
18046 vector signed short vec_sel (vector signed short, vector signed short,
18047 vector unsigned short);
18048 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
18049 vector bool short);
18050 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
18051 vector unsigned short);
18052 vector bool short vec_sel (vector bool short, vector bool short, vector bool short);
18053 vector bool short vec_sel (vector bool short, vector bool short, vector unsigned short);
18054 vector signed char vec_sel (vector signed char, vector signed char, vector bool char);
18055 vector signed char vec_sel (vector signed char, vector signed char,
18056 vector unsigned char);
18057 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
18058 vector bool char);
18059 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
18060 vector unsigned char);
18061 vector bool char vec_sel (vector bool char, vector bool char, vector bool char);
18062 vector bool char vec_sel (vector bool char, vector bool char, vector unsigned char);
18063
18064 vector signed char vec_sl (vector signed char, vector unsigned char);
18065 vector unsigned char vec_sl (vector unsigned char, vector unsigned char);
18066 vector signed short vec_sl (vector signed short, vector unsigned short);
18067 vector unsigned short vec_sl (vector unsigned short, vector unsigned short);
18068 vector signed int vec_sl (vector signed int, vector unsigned int);
18069 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
18070
18071 vector float vec_sld (vector float, vector float, const int);
18072 vector signed int vec_sld (vector signed int, vector signed int, const int);
18073 vector unsigned int vec_sld (vector unsigned int, vector unsigned int, const int);
18074 vector bool int vec_sld (vector bool int, vector bool int, const int);
18075 vector signed short vec_sld (vector signed short, vector signed short, const int);
18076 vector unsigned short vec_sld (vector unsigned short, vector unsigned short, const int);
18077 vector bool short vec_sld (vector bool short, vector bool short, const int);
18078 vector pixel vec_sld (vector pixel, vector pixel, const int);
18079 vector signed char vec_sld (vector signed char, vector signed char, const int);
18080 vector unsigned char vec_sld (vector unsigned char, vector unsigned char, const int);
18081 vector bool char vec_sld (vector bool char, vector bool char, const int);
18082
18083 vector signed int vec_sll (vector signed int, vector unsigned int);
18084 vector signed int vec_sll (vector signed int, vector unsigned short);
18085 vector signed int vec_sll (vector signed int, vector unsigned char);
18086 vector unsigned int vec_sll (vector unsigned int, vector unsigned int);
18087 vector unsigned int vec_sll (vector unsigned int, vector unsigned short);
18088 vector unsigned int vec_sll (vector unsigned int, vector unsigned char);
18089 vector bool int vec_sll (vector bool int, vector unsigned int);
18090 vector bool int vec_sll (vector bool int, vector unsigned short);
18091 vector bool int vec_sll (vector bool int, vector unsigned char);
18092 vector signed short vec_sll (vector signed short, vector unsigned int);
18093 vector signed short vec_sll (vector signed short, vector unsigned short);
18094 vector signed short vec_sll (vector signed short, vector unsigned char);
18095 vector unsigned short vec_sll (vector unsigned short, vector unsigned int);
18096 vector unsigned short vec_sll (vector unsigned short, vector unsigned short);
18097 vector unsigned short vec_sll (vector unsigned short, vector unsigned char);
18098 vector bool short vec_sll (vector bool short, vector unsigned int);
18099 vector bool short vec_sll (vector bool short, vector unsigned short);
18100 vector bool short vec_sll (vector bool short, vector unsigned char);
18101 vector pixel vec_sll (vector pixel, vector unsigned int);
18102 vector pixel vec_sll (vector pixel, vector unsigned short);
18103 vector pixel vec_sll (vector pixel, vector unsigned char);
18104 vector signed char vec_sll (vector signed char, vector unsigned int);
18105 vector signed char vec_sll (vector signed char, vector unsigned short);
18106 vector signed char vec_sll (vector signed char, vector unsigned char);
18107 vector unsigned char vec_sll (vector unsigned char, vector unsigned int);
18108 vector unsigned char vec_sll (vector unsigned char, vector unsigned short);
18109 vector unsigned char vec_sll (vector unsigned char, vector unsigned char);
18110 vector bool char vec_sll (vector bool char, vector unsigned int);
18111 vector bool char vec_sll (vector bool char, vector unsigned short);
18112 vector bool char vec_sll (vector bool char, vector unsigned char);
18113
18114 vector float vec_slo (vector float, vector signed char);
18115 vector float vec_slo (vector float, vector unsigned char);
18116 vector signed int vec_slo (vector signed int, vector signed char);
18117 vector signed int vec_slo (vector signed int, vector unsigned char);
18118 vector unsigned int vec_slo (vector unsigned int, vector signed char);
18119 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
18120 vector signed short vec_slo (vector signed short, vector signed char);
18121 vector signed short vec_slo (vector signed short, vector unsigned char);
18122 vector unsigned short vec_slo (vector unsigned short, vector signed char);
18123 vector unsigned short vec_slo (vector unsigned short, vector unsigned char);
18124 vector pixel vec_slo (vector pixel, vector signed char);
18125 vector pixel vec_slo (vector pixel, vector unsigned char);
18126 vector signed char vec_slo (vector signed char, vector signed char);
18127 vector signed char vec_slo (vector signed char, vector unsigned char);
18128 vector unsigned char vec_slo (vector unsigned char, vector signed char);
18129 vector unsigned char vec_slo (vector unsigned char, vector unsigned char);
18130
18131 vector signed char vec_splat (vector signed char, const int);
18132 vector unsigned char vec_splat (vector unsigned char, const int);
18133 vector bool char vec_splat (vector bool char, const int);
18134 vector signed short vec_splat (vector signed short, const int);
18135 vector unsigned short vec_splat (vector unsigned short, const int);
18136 vector bool short vec_splat (vector bool short, const int);
18137 vector pixel vec_splat (vector pixel, const int);
18138 vector float vec_splat (vector float, const int);
18139 vector signed int vec_splat (vector signed int, const int);
18140 vector unsigned int vec_splat (vector unsigned int, const int);
18141 vector bool int vec_splat (vector bool int, const int);
18142
18143 vector signed short vec_splat_s16 (const int);
18144
18145 vector signed int vec_splat_s32 (const int);
18146
18147 vector signed char vec_splat_s8 (const int);
18148
18149 vector unsigned short vec_splat_u16 (const int);
18150
18151 vector unsigned int vec_splat_u32 (const int);
18152
18153 vector unsigned char vec_splat_u8 (const int);
18154
18155 vector signed char vec_splats (signed char);
18156 vector unsigned char vec_splats (unsigned char);
18157 vector signed short vec_splats (signed short);
18158 vector unsigned short vec_splats (unsigned short);
18159 vector signed int vec_splats (signed int);
18160 vector unsigned int vec_splats (unsigned int);
18161 vector float vec_splats (float);
18162
18163 vector signed char vec_sr (vector signed char, vector unsigned char);
18164 vector unsigned char vec_sr (vector unsigned char, vector unsigned char);
18165 vector signed short vec_sr (vector signed short, vector unsigned short);
18166 vector unsigned short vec_sr (vector unsigned short, vector unsigned short);
18167 vector signed int vec_sr (vector signed int, vector unsigned int);
18168 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
18169
18170 vector signed char vec_sra (vector signed char, vector unsigned char);
18171 vector unsigned char vec_sra (vector unsigned char, vector unsigned char);
18172 vector signed short vec_sra (vector signed short, vector unsigned short);
18173 vector unsigned short vec_sra (vector unsigned short, vector unsigned short);
18174 vector signed int vec_sra (vector signed int, vector unsigned int);
18175 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
18176
18177 vector signed int vec_srl (vector signed int, vector unsigned int);
18178 vector signed int vec_srl (vector signed int, vector unsigned short);
18179 vector signed int vec_srl (vector signed int, vector unsigned char);
18180 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
18181 vector unsigned int vec_srl (vector unsigned int, vector unsigned short);
18182 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
18183 vector bool int vec_srl (vector bool int, vector unsigned int);
18184 vector bool int vec_srl (vector bool int, vector unsigned short);
18185 vector bool int vec_srl (vector bool int, vector unsigned char);
18186 vector signed short vec_srl (vector signed short, vector unsigned int);
18187 vector signed short vec_srl (vector signed short, vector unsigned short);
18188 vector signed short vec_srl (vector signed short, vector unsigned char);
18189 vector unsigned short vec_srl (vector unsigned short, vector unsigned int);
18190 vector unsigned short vec_srl (vector unsigned short, vector unsigned short);
18191 vector unsigned short vec_srl (vector unsigned short, vector unsigned char);
18192 vector bool short vec_srl (vector bool short, vector unsigned int);
18193 vector bool short vec_srl (vector bool short, vector unsigned short);
18194 vector bool short vec_srl (vector bool short, vector unsigned char);
18195 vector pixel vec_srl (vector pixel, vector unsigned int);
18196 vector pixel vec_srl (vector pixel, vector unsigned short);
18197 vector pixel vec_srl (vector pixel, vector unsigned char);
18198 vector signed char vec_srl (vector signed char, vector unsigned int);
18199 vector signed char vec_srl (vector signed char, vector unsigned short);
18200 vector signed char vec_srl (vector signed char, vector unsigned char);
18201 vector unsigned char vec_srl (vector unsigned char, vector unsigned int);
18202 vector unsigned char vec_srl (vector unsigned char, vector unsigned short);
18203 vector unsigned char vec_srl (vector unsigned char, vector unsigned char);
18204 vector bool char vec_srl (vector bool char, vector unsigned int);
18205 vector bool char vec_srl (vector bool char, vector unsigned short);
18206 vector bool char vec_srl (vector bool char, vector unsigned char);
18207
18208 vector float vec_sro (vector float, vector signed char);
18209 vector float vec_sro (vector float, vector unsigned char);
18210 vector signed int vec_sro (vector signed int, vector signed char);
18211 vector signed int vec_sro (vector signed int, vector unsigned char);
18212 vector unsigned int vec_sro (vector unsigned int, vector signed char);
18213 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
18214 vector signed short vec_sro (vector signed short, vector signed char);
18215 vector signed short vec_sro (vector signed short, vector unsigned char);
18216 vector unsigned short vec_sro (vector unsigned short, vector signed char);
18217 vector unsigned short vec_sro (vector unsigned short, vector unsigned char);
18218 vector pixel vec_sro (vector pixel, vector signed char);
18219 vector pixel vec_sro (vector pixel, vector unsigned char);
18220 vector signed char vec_sro (vector signed char, vector signed char);
18221 vector signed char vec_sro (vector signed char, vector unsigned char);
18222 vector unsigned char vec_sro (vector unsigned char, vector signed char);
18223 vector unsigned char vec_sro (vector unsigned char, vector unsigned char);
18224
18225 void vec_st (vector float, int, vector float *);
18226 void vec_st (vector float, int, float *);
18227 void vec_st (vector signed int, int, vector signed int *);
18228 void vec_st (vector signed int, int, int *);
18229 void vec_st (vector unsigned int, int, vector unsigned int *);
18230 void vec_st (vector unsigned int, int, unsigned int *);
18231 void vec_st (vector bool int, int, vector bool int *);
18232 void vec_st (vector bool int, int, unsigned int *);
18233 void vec_st (vector bool int, int, int *);
18234 void vec_st (vector signed short, int, vector signed short *);
18235 void vec_st (vector signed short, int, short *);
18236 void vec_st (vector unsigned short, int, vector unsigned short *);
18237 void vec_st (vector unsigned short, int, unsigned short *);
18238 void vec_st (vector bool short, int, vector bool short *);
18239 void vec_st (vector bool short, int, unsigned short *);
18240 void vec_st (vector pixel, int, vector pixel *);
18241 void vec_st (vector bool short, int, short *);
18242 void vec_st (vector signed char, int, vector signed char *);
18243 void vec_st (vector signed char, int, signed char *);
18244 void vec_st (vector unsigned char, int, vector unsigned char *);
18245 void vec_st (vector unsigned char, int, unsigned char *);
18246 void vec_st (vector bool char, int, vector bool char *);
18247 void vec_st (vector bool char, int, unsigned char *);
18248 void vec_st (vector bool char, int, signed char *);
18249
18250 void vec_ste (vector signed char, int, signed char *);
18251 void vec_ste (vector unsigned char, int, unsigned char *);
18252 void vec_ste (vector bool char, int, signed char *);
18253 void vec_ste (vector bool char, int, unsigned char *);
18254 void vec_ste (vector signed short, int, short *);
18255 void vec_ste (vector unsigned short, int, unsigned short *);
18256 void vec_ste (vector bool short, int, short *);
18257 void vec_ste (vector bool short, int, unsigned short *);
18258 void vec_ste (vector pixel, int, short *);
18259 void vec_ste (vector pixel, int, unsigned short *);
18260 void vec_ste (vector float, int, float *);
18261 void vec_ste (vector signed int, int, int *);
18262 void vec_ste (vector unsigned int, int, unsigned int *);
18263 void vec_ste (vector bool int, int, int *);
18264 void vec_ste (vector bool int, int, unsigned int *);
18265
18266 void vec_stl (vector float, int, vector float *);
18267 void vec_stl (vector float, int, float *);
18268 void vec_stl (vector signed int, int, vector signed int *);
18269 void vec_stl (vector signed int, int, int *);
18270 void vec_stl (vector unsigned int, int, vector unsigned int *);
18271 void vec_stl (vector unsigned int, int, unsigned int *);
18272 void vec_stl (vector bool int, int, vector bool int *);
18273 void vec_stl (vector bool int, int, unsigned int *);
18274 void vec_stl (vector bool int, int, int *);
18275 void vec_stl (vector signed short, int, vector signed short *);
18276 void vec_stl (vector signed short, int, short *);
18277 void vec_stl (vector unsigned short, int, vector unsigned short *);
18278 void vec_stl (vector unsigned short, int, unsigned short *);
18279 void vec_stl (vector bool short, int, vector bool short *);
18280 void vec_stl (vector bool short, int, unsigned short *);
18281 void vec_stl (vector bool short, int, short *);
18282 void vec_stl (vector pixel, int, vector pixel *);
18283 void vec_stl (vector signed char, int, vector signed char *);
18284 void vec_stl (vector signed char, int, signed char *);
18285 void vec_stl (vector unsigned char, int, vector unsigned char *);
18286 void vec_stl (vector unsigned char, int, unsigned char *);
18287 void vec_stl (vector bool char, int, vector bool char *);
18288 void vec_stl (vector bool char, int, unsigned char *);
18289 void vec_stl (vector bool char, int, signed char *);
18290
18291 void vec_stvebx (vector signed char, int, signed char *);
18292 void vec_stvebx (vector unsigned char, int, unsigned char *);
18293 void vec_stvebx (vector bool char, int, signed char *);
18294 void vec_stvebx (vector bool char, int, unsigned char *);
18295
18296 void vec_stvehx (vector signed short, int, short *);
18297 void vec_stvehx (vector unsigned short, int, unsigned short *);
18298 void vec_stvehx (vector bool short, int, short *);
18299 void vec_stvehx (vector bool short, int, unsigned short *);
18300
18301 void vec_stvewx (vector float, int, float *);
18302 void vec_stvewx (vector signed int, int, int *);
18303 void vec_stvewx (vector unsigned int, int, unsigned int *);
18304 void vec_stvewx (vector bool int, int, int *);
18305 void vec_stvewx (vector bool int, int, unsigned int *);
18306
18307 vector signed char vec_sub (vector bool char, vector signed char);
18308 vector signed char vec_sub (vector signed char, vector bool char);
18309 vector signed char vec_sub (vector signed char, vector signed char);
18310 vector unsigned char vec_sub (vector bool char, vector unsigned char);
18311 vector unsigned char vec_sub (vector unsigned char, vector bool char);
18312 vector unsigned char vec_sub (vector unsigned char, vector unsigned char);
18313 vector signed short vec_sub (vector bool short, vector signed short);
18314 vector signed short vec_sub (vector signed short, vector bool short);
18315 vector signed short vec_sub (vector signed short, vector signed short);
18316 vector unsigned short vec_sub (vector bool short, vector unsigned short);
18317 vector unsigned short vec_sub (vector unsigned short, vector bool short);
18318 vector unsigned short vec_sub (vector unsigned short, vector unsigned short);
18319 vector signed int vec_sub (vector bool int, vector signed int);
18320 vector signed int vec_sub (vector signed int, vector bool int);
18321 vector signed int vec_sub (vector signed int, vector signed int);
18322 vector unsigned int vec_sub (vector bool int, vector unsigned int);
18323 vector unsigned int vec_sub (vector unsigned int, vector bool int);
18324 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
18325 vector float vec_sub (vector float, vector float);
18326
18327 vector signed int vec_subc (vector signed int, vector signed int);
18328 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
18329
18330 vector signed int vec_sube (vector signed int, vector signed int,
18331 vector signed int);
18332 vector unsigned int vec_sube (vector unsigned int, vector unsigned int,
18333 vector unsigned int);
18334
18335 vector signed int vec_subec (vector signed int, vector signed int,
18336 vector signed int);
18337 vector unsigned int vec_subec (vector unsigned int, vector unsigned int,
18338 vector unsigned int);
18339
18340 vector unsigned char vec_subs (vector bool char, vector unsigned char);
18341 vector unsigned char vec_subs (vector unsigned char, vector bool char);
18342 vector unsigned char vec_subs (vector unsigned char, vector unsigned char);
18343 vector signed char vec_subs (vector bool char, vector signed char);
18344 vector signed char vec_subs (vector signed char, vector bool char);
18345 vector signed char vec_subs (vector signed char, vector signed char);
18346 vector unsigned short vec_subs (vector bool short, vector unsigned short);
18347 vector unsigned short vec_subs (vector unsigned short, vector bool short);
18348 vector unsigned short vec_subs (vector unsigned short, vector unsigned short);
18349 vector signed short vec_subs (vector bool short, vector signed short);
18350 vector signed short vec_subs (vector signed short, vector bool short);
18351 vector signed short vec_subs (vector signed short, vector signed short);
18352 vector unsigned int vec_subs (vector bool int, vector unsigned int);
18353 vector unsigned int vec_subs (vector unsigned int, vector bool int);
18354 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
18355 vector signed int vec_subs (vector bool int, vector signed int);
18356 vector signed int vec_subs (vector signed int, vector bool int);
18357 vector signed int vec_subs (vector signed int, vector signed int);
18358
18359 vector signed int vec_sum2s (vector signed int, vector signed int);
18360
18361 vector unsigned int vec_sum4s (vector unsigned char, vector unsigned int);
18362 vector signed int vec_sum4s (vector signed char, vector signed int);
18363 vector signed int vec_sum4s (vector signed short, vector signed int);
18364
18365 vector signed int vec_sums (vector signed int, vector signed int);
18366
18367 vector float vec_trunc (vector float);
18368
18369 vector signed short vec_unpackh (vector signed char);
18370 vector bool short vec_unpackh (vector bool char);
18371 vector signed int vec_unpackh (vector signed short);
18372 vector bool int vec_unpackh (vector bool short);
18373 vector unsigned int vec_unpackh (vector pixel);
18374
18375 vector signed short vec_unpackl (vector signed char);
18376 vector bool short vec_unpackl (vector bool char);
18377 vector unsigned int vec_unpackl (vector pixel);
18378 vector signed int vec_unpackl (vector signed short);
18379 vector bool int vec_unpackl (vector bool short);
18380
18381 vector float vec_vaddfp (vector float, vector float);
18382
18383 vector signed char vec_vaddsbs (vector bool char, vector signed char);
18384 vector signed char vec_vaddsbs (vector signed char, vector bool char);
18385 vector signed char vec_vaddsbs (vector signed char, vector signed char);
18386
18387 vector signed short vec_vaddshs (vector bool short, vector signed short);
18388 vector signed short vec_vaddshs (vector signed short, vector bool short);
18389 vector signed short vec_vaddshs (vector signed short, vector signed short);
18390
18391 vector signed int vec_vaddsws (vector bool int, vector signed int);
18392 vector signed int vec_vaddsws (vector signed int, vector bool int);
18393 vector signed int vec_vaddsws (vector signed int, vector signed int);
18394
18395 vector signed char vec_vaddubm (vector bool char, vector signed char);
18396 vector signed char vec_vaddubm (vector signed char, vector bool char);
18397 vector signed char vec_vaddubm (vector signed char, vector signed char);
18398 vector unsigned char vec_vaddubm (vector bool char, vector unsigned char);
18399 vector unsigned char vec_vaddubm (vector unsigned char, vector bool char);
18400 vector unsigned char vec_vaddubm (vector unsigned char, vector unsigned char);
18401
18402 vector unsigned char vec_vaddubs (vector bool char, vector unsigned char);
18403 vector unsigned char vec_vaddubs (vector unsigned char, vector bool char);
18404 vector unsigned char vec_vaddubs (vector unsigned char, vector unsigned char);
18405
18406 vector signed short vec_vadduhm (vector bool short, vector signed short);
18407 vector signed short vec_vadduhm (vector signed short, vector bool short);
18408 vector signed short vec_vadduhm (vector signed short, vector signed short);
18409 vector unsigned short vec_vadduhm (vector bool short, vector unsigned short);
18410 vector unsigned short vec_vadduhm (vector unsigned short, vector bool short);
18411 vector unsigned short vec_vadduhm (vector unsigned short, vector unsigned short);
18412
18413 vector unsigned short vec_vadduhs (vector bool short, vector unsigned short);
18414 vector unsigned short vec_vadduhs (vector unsigned short, vector bool short);
18415 vector unsigned short vec_vadduhs (vector unsigned short, vector unsigned short);
18416
18417 vector signed int vec_vadduwm (vector bool int, vector signed int);
18418 vector signed int vec_vadduwm (vector signed int, vector bool int);
18419 vector signed int vec_vadduwm (vector signed int, vector signed int);
18420 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
18421 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
18422 vector unsigned int vec_vadduwm (vector unsigned int, vector unsigned int);
18423
18424 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
18425 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
18426 vector unsigned int vec_vadduws (vector unsigned int, vector unsigned int);
18427
18428 vector signed char vec_vavgsb (vector signed char, vector signed char);
18429
18430 vector signed short vec_vavgsh (vector signed short, vector signed short);
18431
18432 vector signed int vec_vavgsw (vector signed int, vector signed int);
18433
18434 vector unsigned char vec_vavgub (vector unsigned char, vector unsigned char);
18435
18436 vector unsigned short vec_vavguh (vector unsigned short, vector unsigned short);
18437
18438 vector unsigned int vec_vavguw (vector unsigned int, vector unsigned int);
18439
18440 vector float vec_vcfsx (vector signed int, const int);
18441
18442 vector float vec_vcfux (vector unsigned int, const int);
18443
18444 vector bool int vec_vcmpeqfp (vector float, vector float);
18445
18446 vector bool char vec_vcmpequb (vector signed char, vector signed char);
18447 vector bool char vec_vcmpequb (vector unsigned char, vector unsigned char);
18448
18449 vector bool short vec_vcmpequh (vector signed short, vector signed short);
18450 vector bool short vec_vcmpequh (vector unsigned short, vector unsigned short);
18451
18452 vector bool int vec_vcmpequw (vector signed int, vector signed int);
18453 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
18454
18455 vector bool int vec_vcmpgtfp (vector float, vector float);
18456
18457 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
18458
18459 vector bool short vec_vcmpgtsh (vector signed short, vector signed short);
18460
18461 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
18462
18463 vector bool char vec_vcmpgtub (vector unsigned char, vector unsigned char);
18464
18465 vector bool short vec_vcmpgtuh (vector unsigned short, vector unsigned short);
18466
18467 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
18468
18469 vector float vec_vmaxfp (vector float, vector float);
18470
18471 vector signed char vec_vmaxsb (vector bool char, vector signed char);
18472 vector signed char vec_vmaxsb (vector signed char, vector bool char);
18473 vector signed char vec_vmaxsb (vector signed char, vector signed char);
18474
18475 vector signed short vec_vmaxsh (vector bool short, vector signed short);
18476 vector signed short vec_vmaxsh (vector signed short, vector bool short);
18477 vector signed short vec_vmaxsh (vector signed short, vector signed short);
18478
18479 vector signed int vec_vmaxsw (vector bool int, vector signed int);
18480 vector signed int vec_vmaxsw (vector signed int, vector bool int);
18481 vector signed int vec_vmaxsw (vector signed int, vector signed int);
18482
18483 vector unsigned char vec_vmaxub (vector bool char, vector unsigned char);
18484 vector unsigned char vec_vmaxub (vector unsigned char, vector bool char);
18485 vector unsigned char vec_vmaxub (vector unsigned char, vector unsigned char);
18486
18487 vector unsigned short vec_vmaxuh (vector bool short, vector unsigned short);
18488 vector unsigned short vec_vmaxuh (vector unsigned short, vector bool short);
18489 vector unsigned short vec_vmaxuh (vector unsigned short, vector unsigned short);
18490
18491 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
18492 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
18493 vector unsigned int vec_vmaxuw (vector unsigned int, vector unsigned int);
18494
18495 vector float vec_vminfp (vector float, vector float);
18496
18497 vector signed char vec_vminsb (vector bool char, vector signed char);
18498 vector signed char vec_vminsb (vector signed char, vector bool char);
18499 vector signed char vec_vminsb (vector signed char, vector signed char);
18500
18501 vector signed short vec_vminsh (vector bool short, vector signed short);
18502 vector signed short vec_vminsh (vector signed short, vector bool short);
18503 vector signed short vec_vminsh (vector signed short, vector signed short);
18504
18505 vector signed int vec_vminsw (vector bool int, vector signed int);
18506 vector signed int vec_vminsw (vector signed int, vector bool int);
18507 vector signed int vec_vminsw (vector signed int, vector signed int);
18508
18509 vector unsigned char vec_vminub (vector bool char, vector unsigned char);
18510 vector unsigned char vec_vminub (vector unsigned char, vector bool char);
18511 vector unsigned char vec_vminub (vector unsigned char, vector unsigned char);
18512
18513 vector unsigned short vec_vminuh (vector bool short, vector unsigned short);
18514 vector unsigned short vec_vminuh (vector unsigned short, vector bool short);
18515 vector unsigned short vec_vminuh (vector unsigned short, vector unsigned short);
18516
18517 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
18518 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
18519 vector unsigned int vec_vminuw (vector unsigned int, vector unsigned int);
18520
18521 vector bool char vec_vmrghb (vector bool char, vector bool char);
18522 vector signed char vec_vmrghb (vector signed char, vector signed char);
18523 vector unsigned char vec_vmrghb (vector unsigned char, vector unsigned char);
18524
18525 vector bool short vec_vmrghh (vector bool short, vector bool short);
18526 vector signed short vec_vmrghh (vector signed short, vector signed short);
18527 vector unsigned short vec_vmrghh (vector unsigned short, vector unsigned short);
18528 vector pixel vec_vmrghh (vector pixel, vector pixel);
18529
18530 vector float vec_vmrghw (vector float, vector float);
18531 vector bool int vec_vmrghw (vector bool int, vector bool int);
18532 vector signed int vec_vmrghw (vector signed int, vector signed int);
18533 vector unsigned int vec_vmrghw (vector unsigned int, vector unsigned int);
18534
18535 vector bool char vec_vmrglb (vector bool char, vector bool char);
18536 vector signed char vec_vmrglb (vector signed char, vector signed char);
18537 vector unsigned char vec_vmrglb (vector unsigned char, vector unsigned char);
18538
18539 vector bool short vec_vmrglh (vector bool short, vector bool short);
18540 vector signed short vec_vmrglh (vector signed short, vector signed short);
18541 vector unsigned short vec_vmrglh (vector unsigned short, vector unsigned short);
18542 vector pixel vec_vmrglh (vector pixel, vector pixel);
18543
18544 vector float vec_vmrglw (vector float, vector float);
18545 vector signed int vec_vmrglw (vector signed int, vector signed int);
18546 vector unsigned int vec_vmrglw (vector unsigned int, vector unsigned int);
18547 vector bool int vec_vmrglw (vector bool int, vector bool int);
18548
18549 vector signed int vec_vmsummbm (vector signed char, vector unsigned char,
18550 vector signed int);
18551
18552 vector signed int vec_vmsumshm (vector signed short, vector signed short,
18553 vector signed int);
18554
18555 vector signed int vec_vmsumshs (vector signed short, vector signed short,
18556 vector signed int);
18557
18558 vector unsigned int vec_vmsumubm (vector unsigned char, vector unsigned char,
18559 vector unsigned int);
18560
18561 vector unsigned int vec_vmsumuhm (vector unsigned short, vector unsigned short,
18562 vector unsigned int);
18563
18564 vector unsigned int vec_vmsumuhs (vector unsigned short, vector unsigned short,
18565 vector unsigned int);
18566
18567 vector signed short vec_vmulesb (vector signed char, vector signed char);
18568
18569 vector signed int vec_vmulesh (vector signed short, vector signed short);
18570
18571 vector unsigned short vec_vmuleub (vector unsigned char, vector unsigned char);
18572
18573 vector unsigned int vec_vmuleuh (vector unsigned short, vector unsigned short);
18574
18575 vector signed short vec_vmulosb (vector signed char, vector signed char);
18576
18577 vector signed int vec_vmulosh (vector signed short, vector signed short);
18578
18579 vector unsigned short vec_vmuloub (vector unsigned char, vector unsigned char);
18580
18581 vector unsigned int vec_vmulouh (vector unsigned short, vector unsigned short);
18582
18583 vector signed char vec_vpkshss (vector signed short, vector signed short);
18584
18585 vector unsigned char vec_vpkshus (vector signed short, vector signed short);
18586
18587 vector signed short vec_vpkswss (vector signed int, vector signed int);
18588
18589 vector unsigned short vec_vpkswus (vector signed int, vector signed int);
18590
18591 vector bool char vec_vpkuhum (vector bool short, vector bool short);
18592 vector signed char vec_vpkuhum (vector signed short, vector signed short);
18593 vector unsigned char vec_vpkuhum (vector unsigned short, vector unsigned short);
18594
18595 vector unsigned char vec_vpkuhus (vector unsigned short, vector unsigned short);
18596
18597 vector bool short vec_vpkuwum (vector bool int, vector bool int);
18598 vector signed short vec_vpkuwum (vector signed int, vector signed int);
18599 vector unsigned short vec_vpkuwum (vector unsigned int, vector unsigned int);
18600
18601 vector unsigned short vec_vpkuwus (vector unsigned int, vector unsigned int);
18602
18603 vector signed char vec_vrlb (vector signed char, vector unsigned char);
18604 vector unsigned char vec_vrlb (vector unsigned char, vector unsigned char);
18605
18606 vector signed short vec_vrlh (vector signed short, vector unsigned short);
18607 vector unsigned short vec_vrlh (vector unsigned short, vector unsigned short);
18608
18609 vector signed int vec_vrlw (vector signed int, vector unsigned int);
18610 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
18611
18612 vector signed char vec_vslb (vector signed char, vector unsigned char);
18613 vector unsigned char vec_vslb (vector unsigned char, vector unsigned char);
18614
18615 vector signed short vec_vslh (vector signed short, vector unsigned short);
18616 vector unsigned short vec_vslh (vector unsigned short, vector unsigned short);
18617
18618 vector signed int vec_vslw (vector signed int, vector unsigned int);
18619 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
18620
18621 vector signed char vec_vspltb (vector signed char, const int);
18622 vector unsigned char vec_vspltb (vector unsigned char, const int);
18623 vector bool char vec_vspltb (vector bool char, const int);
18624
18625 vector bool short vec_vsplth (vector bool short, const int);
18626 vector signed short vec_vsplth (vector signed short, const int);
18627 vector unsigned short vec_vsplth (vector unsigned short, const int);
18628 vector pixel vec_vsplth (vector pixel, const int);
18629
18630 vector float vec_vspltw (vector float, const int);
18631 vector signed int vec_vspltw (vector signed int, const int);
18632 vector unsigned int vec_vspltw (vector unsigned int, const int);
18633 vector bool int vec_vspltw (vector bool int, const int);
18634
18635 vector signed char vec_vsrab (vector signed char, vector unsigned char);
18636 vector unsigned char vec_vsrab (vector unsigned char, vector unsigned char);
18637
18638 vector signed short vec_vsrah (vector signed short, vector unsigned short);
18639 vector unsigned short vec_vsrah (vector unsigned short, vector unsigned short);
18640
18641 vector signed int vec_vsraw (vector signed int, vector unsigned int);
18642 vector unsigned int vec_vsraw (vector unsigned int, vector unsigned int);
18643
18644 vector signed char vec_vsrb (vector signed char, vector unsigned char);
18645 vector unsigned char vec_vsrb (vector unsigned char, vector unsigned char);
18646
18647 vector signed short vec_vsrh (vector signed short, vector unsigned short);
18648 vector unsigned short vec_vsrh (vector unsigned short, vector unsigned short);
18649
18650 vector signed int vec_vsrw (vector signed int, vector unsigned int);
18651 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
18652
18653 vector float vec_vsubfp (vector float, vector float);
18654
18655 vector signed char vec_vsubsbs (vector bool char, vector signed char);
18656 vector signed char vec_vsubsbs (vector signed char, vector bool char);
18657 vector signed char vec_vsubsbs (vector signed char, vector signed char);
18658
18659 vector signed short vec_vsubshs (vector bool short, vector signed short);
18660 vector signed short vec_vsubshs (vector signed short, vector bool short);
18661 vector signed short vec_vsubshs (vector signed short, vector signed short);
18662
18663 vector signed int vec_vsubsws (vector bool int, vector signed int);
18664 vector signed int vec_vsubsws (vector signed int, vector bool int);
18665 vector signed int vec_vsubsws (vector signed int, vector signed int);
18666
18667 vector signed char vec_vsububm (vector bool char, vector signed char);
18668 vector signed char vec_vsububm (vector signed char, vector bool char);
18669 vector signed char vec_vsububm (vector signed char, vector signed char);
18670 vector unsigned char vec_vsububm (vector bool char, vector unsigned char);
18671 vector unsigned char vec_vsububm (vector unsigned char, vector bool char);
18672 vector unsigned char vec_vsububm (vector unsigned char, vector unsigned char);
18673
18674 vector unsigned char vec_vsububs (vector bool char, vector unsigned char);
18675 vector unsigned char vec_vsububs (vector unsigned char, vector bool char);
18676 vector unsigned char vec_vsububs (vector unsigned char, vector unsigned char);
18677
18678 vector signed short vec_vsubuhm (vector bool short, vector signed short);
18679 vector signed short vec_vsubuhm (vector signed short, vector bool short);
18680 vector signed short vec_vsubuhm (vector signed short, vector signed short);
18681 vector unsigned short vec_vsubuhm (vector bool short, vector unsigned short);
18682 vector unsigned short vec_vsubuhm (vector unsigned short, vector bool short);
18683 vector unsigned short vec_vsubuhm (vector unsigned short, vector unsigned short);
18684
18685 vector unsigned short vec_vsubuhs (vector bool short, vector unsigned short);
18686 vector unsigned short vec_vsubuhs (vector unsigned short, vector bool short);
18687 vector unsigned short vec_vsubuhs (vector unsigned short, vector unsigned short);
18688
18689 vector signed int vec_vsubuwm (vector bool int, vector signed int);
18690 vector signed int vec_vsubuwm (vector signed int, vector bool int);
18691 vector signed int vec_vsubuwm (vector signed int, vector signed int);
18692 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
18693 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
18694 vector unsigned int vec_vsubuwm (vector unsigned int, vector unsigned int);
18695
18696 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
18697 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
18698 vector unsigned int vec_vsubuws (vector unsigned int, vector unsigned int);
18699
18700 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
18701
18702 vector signed int vec_vsum4shs (vector signed short, vector signed int);
18703
18704 vector unsigned int vec_vsum4ubs (vector unsigned char, vector unsigned int);
18705
18706 vector unsigned int vec_vupkhpx (vector pixel);
18707
18708 vector bool short vec_vupkhsb (vector bool char);
18709 vector signed short vec_vupkhsb (vector signed char);
18710
18711 vector bool int vec_vupkhsh (vector bool short);
18712 vector signed int vec_vupkhsh (vector signed short);
18713
18714 vector unsigned int vec_vupklpx (vector pixel);
18715
18716 vector bool short vec_vupklsb (vector bool char);
18717 vector signed short vec_vupklsb (vector signed char);
18718
18719 vector bool int vec_vupklsh (vector bool short);
18720 vector signed int vec_vupklsh (vector signed short);
18721
18722 vector float vec_xor (vector float, vector float);
18723 vector float vec_xor (vector float, vector bool int);
18724 vector float vec_xor (vector bool int, vector float);
18725 vector bool int vec_xor (vector bool int, vector bool int);
18726 vector signed int vec_xor (vector bool int, vector signed int);
18727 vector signed int vec_xor (vector signed int, vector bool int);
18728 vector signed int vec_xor (vector signed int, vector signed int);
18729 vector unsigned int vec_xor (vector bool int, vector unsigned int);
18730 vector unsigned int vec_xor (vector unsigned int, vector bool int);
18731 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
18732 vector bool short vec_xor (vector bool short, vector bool short);
18733 vector signed short vec_xor (vector bool short, vector signed short);
18734 vector signed short vec_xor (vector signed short, vector bool short);
18735 vector signed short vec_xor (vector signed short, vector signed short);
18736 vector unsigned short vec_xor (vector bool short, vector unsigned short);
18737 vector unsigned short vec_xor (vector unsigned short, vector bool short);
18738 vector unsigned short vec_xor (vector unsigned short, vector unsigned short);
18739 vector signed char vec_xor (vector bool char, vector signed char);
18740 vector bool char vec_xor (vector bool char, vector bool char);
18741 vector signed char vec_xor (vector signed char, vector bool char);
18742 vector signed char vec_xor (vector signed char, vector signed char);
18743 vector unsigned char vec_xor (vector bool char, vector unsigned char);
18744 vector unsigned char vec_xor (vector unsigned char, vector bool char);
18745 vector unsigned char vec_xor (vector unsigned char, vector unsigned char);
18746 @end smallexample
18747
18748 @node PowerPC AltiVec Built-in Functions Available on ISA 2.06
18749 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.06
18750
18751 The AltiVec built-in functions described in this section are
18752 available on the PowerPC family of processors starting with ISA 2.06
18753 or later. These are normally enabled by adding @option{-mvsx} to the
18754 command line.
18755
18756 When @option{-mvsx} is used, the following additional vector types are
18757 implemented.
18758
18759 @smallexample
18760 vector unsigned __int128
18761 vector signed __int128
18762 vector unsigned long long int
18763 vector signed long long int
18764 vector double
18765 @end smallexample
18766
18767 The long long types are only implemented for 64-bit code generation.
18768
18769 @smallexample
18770
18771 vector bool long long vec_and (vector bool long long int, vector bool long long);
18772
18773 vector double vec_ctf (vector unsigned long, const int);
18774 vector double vec_ctf (vector signed long, const int);
18775
18776 vector signed long vec_cts (vector double, const int);
18777
18778 vector unsigned long vec_ctu (vector double, const int);
18779
18780 void vec_dst (const unsigned long *, int, const int);
18781 void vec_dst (const long *, int, const int);
18782
18783 void vec_dststt (const unsigned long *, int, const int);
18784 void vec_dststt (const long *, int, const int);
18785
18786 void vec_dstt (const unsigned long *, int, const int);
18787 void vec_dstt (const long *, int, const int);
18788
18789 vector unsigned char vec_lvsl (int, const unsigned long *);
18790 vector unsigned char vec_lvsl (int, const long *);
18791
18792 vector unsigned char vec_lvsr (int, const unsigned long *);
18793 vector unsigned char vec_lvsr (int, const long *);
18794
18795 vector double vec_mul (vector double, vector double);
18796 vector long vec_mul (vector long, vector long);
18797 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
18798
18799 vector unsigned long long vec_mule (vector unsigned int, vector unsigned int);
18800 vector signed long long vec_mule (vector signed int, vector signed int);
18801
18802 vector unsigned long long vec_mulo (vector unsigned int, vector unsigned int);
18803 vector signed long long vec_mulo (vector signed int, vector signed int);
18804
18805 vector double vec_nabs (vector double);
18806
18807 vector bool long long vec_reve (vector bool long long);
18808 vector signed long long vec_reve (vector signed long long);
18809 vector unsigned long long vec_reve (vector unsigned long long);
18810 vector double vec_sld (vector double, vector double, const int);
18811
18812 vector bool long long int vec_sld (vector bool long long int,
18813 vector bool long long int, const int);
18814 vector long long int vec_sld (vector long long int, vector long long int, const int);
18815 vector unsigned long long int vec_sld (vector unsigned long long int,
18816 vector unsigned long long int, const int);
18817
18818 vector long long int vec_sll (vector long long int, vector unsigned char);
18819 vector unsigned long long int vec_sll (vector unsigned long long int,
18820 vector unsigned char);
18821
18822 vector signed long long vec_slo (vector signed long long, vector signed char);
18823 vector signed long long vec_slo (vector signed long long, vector unsigned char);
18824 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
18825 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
18826
18827 vector signed long vec_splat (vector signed long, const int);
18828 vector unsigned long vec_splat (vector unsigned long, const int);
18829
18830 vector long long int vec_srl (vector long long int, vector unsigned char);
18831 vector unsigned long long int vec_srl (vector unsigned long long int,
18832 vector unsigned char);
18833
18834 vector long long int vec_sro (vector long long int, vector char);
18835 vector long long int vec_sro (vector long long int, vector unsigned char);
18836 vector unsigned long long int vec_sro (vector unsigned long long int, vector char);
18837 vector unsigned long long int vec_sro (vector unsigned long long int,
18838 vector unsigned char);
18839
18840 vector signed __int128 vec_subc (vector signed __int128, vector signed __int128);
18841 vector unsigned __int128 vec_subc (vector unsigned __int128, vector unsigned __int128);
18842
18843 vector signed __int128 vec_sube (vector signed __int128, vector signed __int128,
18844 vector signed __int128);
18845 vector unsigned __int128 vec_sube (vector unsigned __int128, vector unsigned __int128,
18846 vector unsigned __int128);
18847
18848 vector signed __int128 vec_subec (vector signed __int128, vector signed __int128,
18849 vector signed __int128);
18850 vector unsigned __int128 vec_subec (vector unsigned __int128, vector unsigned __int128,
18851 vector unsigned __int128);
18852
18853 vector double vec_unpackh (vector float);
18854
18855 vector double vec_unpackl (vector float);
18856
18857 vector double vec_doublee (vector float);
18858 vector double vec_doublee (vector signed int);
18859 vector double vec_doublee (vector unsigned int);
18860
18861 vector double vec_doubleo (vector float);
18862 vector double vec_doubleo (vector signed int);
18863 vector double vec_doubleo (vector unsigned int);
18864
18865 vector double vec_doubleh (vector float);
18866 vector double vec_doubleh (vector signed int);
18867 vector double vec_doubleh (vector unsigned int);
18868
18869 vector double vec_doublel (vector float);
18870 vector double vec_doublel (vector signed int);
18871 vector double vec_doublel (vector unsigned int);
18872
18873 vector float vec_float (vector signed int);
18874 vector float vec_float (vector unsigned int);
18875
18876 vector float vec_float2 (vector signed long long, vector signed long long);
18877 vector float vec_float2 (vector unsigned long long, vector signed long long);
18878
18879 vector float vec_floate (vector double);
18880 vector float vec_floate (vector signed long long);
18881 vector float vec_floate (vector unsigned long long);
18882
18883 vector float vec_floato (vector double);
18884 vector float vec_floato (vector signed long long);
18885 vector float vec_floato (vector unsigned long long);
18886
18887 vector signed long long vec_signed (vector double);
18888 vector signed int vec_signed (vector float);
18889
18890 vector signed int vec_signede (vector double);
18891
18892 vector signed int vec_signedo (vector double);
18893
18894 vector signed char vec_sldw (vector signed char, vector signed char, const int);
18895 vector unsigned char vec_sldw (vector unsigned char, vector unsigned char, const int);
18896 vector signed short vec_sldw (vector signed short, vector signed short, const int);
18897 vector unsigned short vec_sldw (vector unsigned short,
18898 vector unsigned short, const int);
18899 vector signed int vec_sldw (vector signed int, vector signed int, const int);
18900 vector unsigned int vec_sldw (vector unsigned int, vector unsigned int, const int);
18901 vector signed long long vec_sldw (vector signed long long,
18902 vector signed long long, const int);
18903 vector unsigned long long vec_sldw (vector unsigned long long,
18904 vector unsigned long long, const int);
18905
18906 vector signed long long vec_unsigned (vector double);
18907 vector signed int vec_unsigned (vector float);
18908
18909 vector signed int vec_unsignede (vector double);
18910
18911 vector signed int vec_unsignedo (vector double);
18912
18913 vector double vec_abs (vector double);
18914 vector double vec_add (vector double, vector double);
18915 vector double vec_and (vector double, vector double);
18916 vector double vec_and (vector double, vector bool long);
18917 vector double vec_and (vector bool long, vector double);
18918 vector long vec_and (vector long, vector long);
18919 vector long vec_and (vector long, vector bool long);
18920 vector long vec_and (vector bool long, vector long);
18921 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
18922 vector unsigned long vec_and (vector unsigned long, vector bool long);
18923 vector unsigned long vec_and (vector bool long, vector unsigned long);
18924 vector double vec_andc (vector double, vector double);
18925 vector double vec_andc (vector double, vector bool long);
18926 vector double vec_andc (vector bool long, vector double);
18927 vector long vec_andc (vector long, vector long);
18928 vector long vec_andc (vector long, vector bool long);
18929 vector long vec_andc (vector bool long, vector long);
18930 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
18931 vector unsigned long vec_andc (vector unsigned long, vector bool long);
18932 vector unsigned long vec_andc (vector bool long, vector unsigned long);
18933 vector double vec_ceil (vector double);
18934 vector bool long vec_cmpeq (vector double, vector double);
18935 vector bool long vec_cmpge (vector double, vector double);
18936 vector bool long vec_cmpgt (vector double, vector double);
18937 vector bool long vec_cmple (vector double, vector double);
18938 vector bool long vec_cmplt (vector double, vector double);
18939 vector double vec_cpsgn (vector double, vector double);
18940 vector float vec_div (vector float, vector float);
18941 vector double vec_div (vector double, vector double);
18942 vector long vec_div (vector long, vector long);
18943 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
18944 vector double vec_floor (vector double);
18945 vector signed long long vec_ld (int, const vector signed long long *);
18946 vector signed long long vec_ld (int, const signed long long *);
18947 vector unsigned long long vec_ld (int, const vector unsigned long long *);
18948 vector unsigned long long vec_ld (int, const unsigned long long *);
18949 vector __int128 vec_ld (int, const vector __int128 *);
18950 vector unsigned __int128 vec_ld (int, const vector unsigned __int128 *);
18951 vector __int128 vec_ld (int, const __int128 *);
18952 vector unsigned __int128 vec_ld (int, const unsigned __int128 *);
18953 vector double vec_ld (int, const vector double *);
18954 vector double vec_ld (int, const double *);
18955 vector double vec_ldl (int, const vector double *);
18956 vector double vec_ldl (int, const double *);
18957 vector unsigned char vec_lvsl (int, const double *);
18958 vector unsigned char vec_lvsr (int, const double *);
18959 vector double vec_madd (vector double, vector double, vector double);
18960 vector double vec_max (vector double, vector double);
18961 vector signed long vec_mergeh (vector signed long, vector signed long);
18962 vector signed long vec_mergeh (vector signed long, vector bool long);
18963 vector signed long vec_mergeh (vector bool long, vector signed long);
18964 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
18965 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
18966 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
18967 vector signed long vec_mergel (vector signed long, vector signed long);
18968 vector signed long vec_mergel (vector signed long, vector bool long);
18969 vector signed long vec_mergel (vector bool long, vector signed long);
18970 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
18971 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
18972 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
18973 vector double vec_min (vector double, vector double);
18974 vector float vec_msub (vector float, vector float, vector float);
18975 vector double vec_msub (vector double, vector double, vector double);
18976 vector float vec_nearbyint (vector float);
18977 vector double vec_nearbyint (vector double);
18978 vector float vec_nmadd (vector float, vector float, vector float);
18979 vector double vec_nmadd (vector double, vector double, vector double);
18980 vector double vec_nmsub (vector double, vector double, vector double);
18981 vector double vec_nor (vector double, vector double);
18982 vector long vec_nor (vector long, vector long);
18983 vector long vec_nor (vector long, vector bool long);
18984 vector long vec_nor (vector bool long, vector long);
18985 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
18986 vector unsigned long vec_nor (vector unsigned long, vector bool long);
18987 vector unsigned long vec_nor (vector bool long, vector unsigned long);
18988 vector double vec_or (vector double, vector double);
18989 vector double vec_or (vector double, vector bool long);
18990 vector double vec_or (vector bool long, vector double);
18991 vector long vec_or (vector long, vector long);
18992 vector long vec_or (vector long, vector bool long);
18993 vector long vec_or (vector bool long, vector long);
18994 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
18995 vector unsigned long vec_or (vector unsigned long, vector bool long);
18996 vector unsigned long vec_or (vector bool long, vector unsigned long);
18997 vector double vec_perm (vector double, vector double, vector unsigned char);
18998 vector long vec_perm (vector long, vector long, vector unsigned char);
18999 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
19000 vector unsigned char);
19001 vector bool char vec_permxor (vector bool char, vector bool char,
19002 vector bool char);
19003 vector unsigned char vec_permxor (vector signed char, vector signed char,
19004 vector signed char);
19005 vector unsigned char vec_permxor (vector unsigned char, vector unsigned char,
19006 vector unsigned char);
19007 vector double vec_rint (vector double);
19008 vector double vec_recip (vector double, vector double);
19009 vector double vec_rsqrt (vector double);
19010 vector double vec_rsqrte (vector double);
19011 vector double vec_sel (vector double, vector double, vector bool long);
19012 vector double vec_sel (vector double, vector double, vector unsigned long);
19013 vector long vec_sel (vector long, vector long, vector long);
19014 vector long vec_sel (vector long, vector long, vector unsigned long);
19015 vector long vec_sel (vector long, vector long, vector bool long);
19016 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
19017 vector long);
19018 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
19019 vector unsigned long);
19020 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
19021 vector bool long);
19022 vector double vec_splats (double);
19023 vector signed long vec_splats (signed long);
19024 vector unsigned long vec_splats (unsigned long);
19025 vector float vec_sqrt (vector float);
19026 vector double vec_sqrt (vector double);
19027 void vec_st (vector signed long long, int, vector signed long long *);
19028 void vec_st (vector signed long long, int, signed long long *);
19029 void vec_st (vector unsigned long long, int, vector unsigned long long *);
19030 void vec_st (vector unsigned long long, int, unsigned long long *);
19031 void vec_st (vector bool long long, int, vector bool long long *);
19032 void vec_st (vector bool long long, int, signed long long *);
19033 void vec_st (vector bool long long, int, unsigned long long *);
19034 void vec_st (vector double, int, vector double *);
19035 void vec_st (vector double, int, double *);
19036 vector double vec_sub (vector double, vector double);
19037 vector double vec_trunc (vector double);
19038 vector double vec_xl (int, vector double *);
19039 vector double vec_xl (int, double *);
19040 vector long long vec_xl (int, vector long long *);
19041 vector long long vec_xl (int, long long *);
19042 vector unsigned long long vec_xl (int, vector unsigned long long *);
19043 vector unsigned long long vec_xl (int, unsigned long long *);
19044 vector float vec_xl (int, vector float *);
19045 vector float vec_xl (int, float *);
19046 vector int vec_xl (int, vector int *);
19047 vector int vec_xl (int, int *);
19048 vector unsigned int vec_xl (int, vector unsigned int *);
19049 vector unsigned int vec_xl (int, unsigned int *);
19050 vector double vec_xor (vector double, vector double);
19051 vector double vec_xor (vector double, vector bool long);
19052 vector double vec_xor (vector bool long, vector double);
19053 vector long vec_xor (vector long, vector long);
19054 vector long vec_xor (vector long, vector bool long);
19055 vector long vec_xor (vector bool long, vector long);
19056 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
19057 vector unsigned long vec_xor (vector unsigned long, vector bool long);
19058 vector unsigned long vec_xor (vector bool long, vector unsigned long);
19059 void vec_xst (vector double, int, vector double *);
19060 void vec_xst (vector double, int, double *);
19061 void vec_xst (vector long long, int, vector long long *);
19062 void vec_xst (vector long long, int, long long *);
19063 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
19064 void vec_xst (vector unsigned long long, int, unsigned long long *);
19065 void vec_xst (vector float, int, vector float *);
19066 void vec_xst (vector float, int, float *);
19067 void vec_xst (vector int, int, vector int *);
19068 void vec_xst (vector int, int, int *);
19069 void vec_xst (vector unsigned int, int, vector unsigned int *);
19070 void vec_xst (vector unsigned int, int, unsigned int *);
19071 int vec_all_eq (vector double, vector double);
19072 int vec_all_ge (vector double, vector double);
19073 int vec_all_gt (vector double, vector double);
19074 int vec_all_le (vector double, vector double);
19075 int vec_all_lt (vector double, vector double);
19076 int vec_all_nan (vector double);
19077 int vec_all_ne (vector double, vector double);
19078 int vec_all_nge (vector double, vector double);
19079 int vec_all_ngt (vector double, vector double);
19080 int vec_all_nle (vector double, vector double);
19081 int vec_all_nlt (vector double, vector double);
19082 int vec_all_numeric (vector double);
19083 int vec_any_eq (vector double, vector double);
19084 int vec_any_ge (vector double, vector double);
19085 int vec_any_gt (vector double, vector double);
19086 int vec_any_le (vector double, vector double);
19087 int vec_any_lt (vector double, vector double);
19088 int vec_any_nan (vector double);
19089 int vec_any_ne (vector double, vector double);
19090 int vec_any_nge (vector double, vector double);
19091 int vec_any_ngt (vector double, vector double);
19092 int vec_any_nle (vector double, vector double);
19093 int vec_any_nlt (vector double, vector double);
19094 int vec_any_numeric (vector double);
19095
19096 vector double vec_vsx_ld (int, const vector double *);
19097 vector double vec_vsx_ld (int, const double *);
19098 vector float vec_vsx_ld (int, const vector float *);
19099 vector float vec_vsx_ld (int, const float *);
19100 vector bool int vec_vsx_ld (int, const vector bool int *);
19101 vector signed int vec_vsx_ld (int, const vector signed int *);
19102 vector signed int vec_vsx_ld (int, const int *);
19103 vector signed int vec_vsx_ld (int, const long *);
19104 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
19105 vector unsigned int vec_vsx_ld (int, const unsigned int *);
19106 vector unsigned int vec_vsx_ld (int, const unsigned long *);
19107 vector bool short vec_vsx_ld (int, const vector bool short *);
19108 vector pixel vec_vsx_ld (int, const vector pixel *);
19109 vector signed short vec_vsx_ld (int, const vector signed short *);
19110 vector signed short vec_vsx_ld (int, const short *);
19111 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
19112 vector unsigned short vec_vsx_ld (int, const unsigned short *);
19113 vector bool char vec_vsx_ld (int, const vector bool char *);
19114 vector signed char vec_vsx_ld (int, const vector signed char *);
19115 vector signed char vec_vsx_ld (int, const signed char *);
19116 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
19117 vector unsigned char vec_vsx_ld (int, const unsigned char *);
19118
19119 void vec_vsx_st (vector double, int, vector double *);
19120 void vec_vsx_st (vector double, int, double *);
19121 void vec_vsx_st (vector float, int, vector float *);
19122 void vec_vsx_st (vector float, int, float *);
19123 void vec_vsx_st (vector signed int, int, vector signed int *);
19124 void vec_vsx_st (vector signed int, int, int *);
19125 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
19126 void vec_vsx_st (vector unsigned int, int, unsigned int *);
19127 void vec_vsx_st (vector bool int, int, vector bool int *);
19128 void vec_vsx_st (vector bool int, int, unsigned int *);
19129 void vec_vsx_st (vector bool int, int, int *);
19130 void vec_vsx_st (vector signed short, int, vector signed short *);
19131 void vec_vsx_st (vector signed short, int, short *);
19132 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
19133 void vec_vsx_st (vector unsigned short, int, unsigned short *);
19134 void vec_vsx_st (vector bool short, int, vector bool short *);
19135 void vec_vsx_st (vector bool short, int, unsigned short *);
19136 void vec_vsx_st (vector pixel, int, vector pixel *);
19137 void vec_vsx_st (vector pixel, int, unsigned short *);
19138 void vec_vsx_st (vector pixel, int, short *);
19139 void vec_vsx_st (vector bool short, int, short *);
19140 void vec_vsx_st (vector signed char, int, vector signed char *);
19141 void vec_vsx_st (vector signed char, int, signed char *);
19142 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
19143 void vec_vsx_st (vector unsigned char, int, unsigned char *);
19144 void vec_vsx_st (vector bool char, int, vector bool char *);
19145 void vec_vsx_st (vector bool char, int, unsigned char *);
19146 void vec_vsx_st (vector bool char, int, signed char *);
19147
19148 vector double vec_xxpermdi (vector double, vector double, const int);
19149 vector float vec_xxpermdi (vector float, vector float, const int);
19150 vector long long vec_xxpermdi (vector long long, vector long long, const int);
19151 vector unsigned long long vec_xxpermdi (vector unsigned long long,
19152 vector unsigned long long, const int);
19153 vector int vec_xxpermdi (vector int, vector int, const int);
19154 vector unsigned int vec_xxpermdi (vector unsigned int,
19155 vector unsigned int, const int);
19156 vector short vec_xxpermdi (vector short, vector short, const int);
19157 vector unsigned short vec_xxpermdi (vector unsigned short,
19158 vector unsigned short, const int);
19159 vector signed char vec_xxpermdi (vector signed char, vector signed char,
19160 const int);
19161 vector unsigned char vec_xxpermdi (vector unsigned char,
19162 vector unsigned char, const int);
19163
19164 vector double vec_xxsldi (vector double, vector double, int);
19165 vector float vec_xxsldi (vector float, vector float, int);
19166 vector long long vec_xxsldi (vector long long, vector long long, int);
19167 vector unsigned long long vec_xxsldi (vector unsigned long long,
19168 vector unsigned long long, int);
19169 vector int vec_xxsldi (vector int, vector int, int);
19170 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
19171 vector short vec_xxsldi (vector short, vector short, int);
19172 vector unsigned short vec_xxsldi (vector unsigned short,
19173 vector unsigned short, int);
19174 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
19175 vector unsigned char vec_xxsldi (vector unsigned char,
19176 vector unsigned char, int);
19177 @end smallexample
19178
19179 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
19180 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
19181 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
19182 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
19183 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
19184
19185 @node PowerPC AltiVec Built-in Functions Available on ISA 2.07
19186 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.07
19187
19188 If the ISA 2.07 additions to the vector/scalar (power8-vector)
19189 instruction set are available, the following additional functions are
19190 available for both 32-bit and 64-bit targets. For 64-bit targets, you
19191 can use @var{vector long} instead of @var{vector long long},
19192 @var{vector bool long} instead of @var{vector bool long long}, and
19193 @var{vector unsigned long} instead of @var{vector unsigned long long}.
19194
19195 @smallexample
19196 vector signed char vec_neg (vector signed char);
19197 vector signed short vec_neg (vector signed short);
19198 vector signed int vec_neg (vector signed int);
19199 vector signed long long vec_neg (vector signed long long);
19200 vector float char vec_neg (vector float);
19201 vector double vec_neg (vector double);
19202
19203 vector signed int vec_signed2 (vector double, vector double);
19204
19205 vector signed int vec_unsigned2 (vector double, vector double);
19206
19207 vector long long vec_abs (vector long long);
19208
19209 vector long long vec_add (vector long long, vector long long);
19210 vector unsigned long long vec_add (vector unsigned long long,
19211 vector unsigned long long);
19212
19213 int vec_all_eq (vector long long, vector long long);
19214 int vec_all_eq (vector unsigned long long, vector unsigned long long);
19215 int vec_all_ge (vector long long, vector long long);
19216 int vec_all_ge (vector unsigned long long, vector unsigned long long);
19217 int vec_all_gt (vector long long, vector long long);
19218 int vec_all_gt (vector unsigned long long, vector unsigned long long);
19219 int vec_all_le (vector long long, vector long long);
19220 int vec_all_le (vector unsigned long long, vector unsigned long long);
19221 int vec_all_lt (vector long long, vector long long);
19222 int vec_all_lt (vector unsigned long long, vector unsigned long long);
19223 int vec_all_ne (vector long long, vector long long);
19224 int vec_all_ne (vector unsigned long long, vector unsigned long long);
19225
19226 int vec_any_eq (vector long long, vector long long);
19227 int vec_any_eq (vector unsigned long long, vector unsigned long long);
19228 int vec_any_ge (vector long long, vector long long);
19229 int vec_any_ge (vector unsigned long long, vector unsigned long long);
19230 int vec_any_gt (vector long long, vector long long);
19231 int vec_any_gt (vector unsigned long long, vector unsigned long long);
19232 int vec_any_le (vector long long, vector long long);
19233 int vec_any_le (vector unsigned long long, vector unsigned long long);
19234 int vec_any_lt (vector long long, vector long long);
19235 int vec_any_lt (vector unsigned long long, vector unsigned long long);
19236 int vec_any_ne (vector long long, vector long long);
19237 int vec_any_ne (vector unsigned long long, vector unsigned long long);
19238
19239 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
19240
19241 vector long long vec_eqv (vector long long, vector long long);
19242 vector long long vec_eqv (vector bool long long, vector long long);
19243 vector long long vec_eqv (vector long long, vector bool long long);
19244 vector unsigned long long vec_eqv (vector unsigned long long, vector unsigned long long);
19245 vector unsigned long long vec_eqv (vector bool long long, vector unsigned long long);
19246 vector unsigned long long vec_eqv (vector unsigned long long,
19247 vector bool long long);
19248 vector int vec_eqv (vector int, vector int);
19249 vector int vec_eqv (vector bool int, vector int);
19250 vector int vec_eqv (vector int, vector bool int);
19251 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
19252 vector unsigned int vec_eqv (vector bool unsigned int, vector unsigned int);
19253 vector unsigned int vec_eqv (vector unsigned int, vector bool unsigned int);
19254 vector short vec_eqv (vector short, vector short);
19255 vector short vec_eqv (vector bool short, vector short);
19256 vector short vec_eqv (vector short, vector bool short);
19257 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
19258 vector unsigned short vec_eqv (vector bool unsigned short, vector unsigned short);
19259 vector unsigned short vec_eqv (vector unsigned short, vector bool unsigned short);
19260 vector signed char vec_eqv (vector signed char, vector signed char);
19261 vector signed char vec_eqv (vector bool signed char, vector signed char);
19262 vector signed char vec_eqv (vector signed char, vector bool signed char);
19263 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
19264 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
19265 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
19266
19267 vector long long vec_max (vector long long, vector long long);
19268 vector unsigned long long vec_max (vector unsigned long long,
19269 vector unsigned long long);
19270
19271 vector signed int vec_mergee (vector signed int, vector signed int);
19272 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
19273 vector bool int vec_mergee (vector bool int, vector bool int);
19274
19275 vector signed int vec_mergeo (vector signed int, vector signed int);
19276 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
19277 vector bool int vec_mergeo (vector bool int, vector bool int);
19278
19279 vector long long vec_min (vector long long, vector long long);
19280 vector unsigned long long vec_min (vector unsigned long long,
19281 vector unsigned long long);
19282
19283 vector signed long long vec_nabs (vector signed long long);
19284
19285 vector long long vec_nand (vector long long, vector long long);
19286 vector long long vec_nand (vector bool long long, vector long long);
19287 vector long long vec_nand (vector long long, vector bool long long);
19288 vector unsigned long long vec_nand (vector unsigned long long,
19289 vector unsigned long long);
19290 vector unsigned long long vec_nand (vector bool long long, vector unsigned long long);
19291 vector unsigned long long vec_nand (vector unsigned long long, vector bool long long);
19292 vector int vec_nand (vector int, vector int);
19293 vector int vec_nand (vector bool int, vector int);
19294 vector int vec_nand (vector int, vector bool int);
19295 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
19296 vector unsigned int vec_nand (vector bool unsigned int, vector unsigned int);
19297 vector unsigned int vec_nand (vector unsigned int, vector bool unsigned int);
19298 vector short vec_nand (vector short, vector short);
19299 vector short vec_nand (vector bool short, vector short);
19300 vector short vec_nand (vector short, vector bool short);
19301 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
19302 vector unsigned short vec_nand (vector bool unsigned short, vector unsigned short);
19303 vector unsigned short vec_nand (vector unsigned short, vector bool unsigned short);
19304 vector signed char vec_nand (vector signed char, vector signed char);
19305 vector signed char vec_nand (vector bool signed char, vector signed char);
19306 vector signed char vec_nand (vector signed char, vector bool signed char);
19307 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
19308 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
19309 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
19310
19311 vector long long vec_orc (vector long long, vector long long);
19312 vector long long vec_orc (vector bool long long, vector long long);
19313 vector long long vec_orc (vector long long, vector bool long long);
19314 vector unsigned long long vec_orc (vector unsigned long long,
19315 vector unsigned long long);
19316 vector unsigned long long vec_orc (vector bool long long, vector unsigned long long);
19317 vector unsigned long long vec_orc (vector unsigned long long, vector bool long long);
19318 vector int vec_orc (vector int, vector int);
19319 vector int vec_orc (vector bool int, vector int);
19320 vector int vec_orc (vector int, vector bool int);
19321 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
19322 vector unsigned int vec_orc (vector bool unsigned int, vector unsigned int);
19323 vector unsigned int vec_orc (vector unsigned int, vector bool unsigned int);
19324 vector short vec_orc (vector short, vector short);
19325 vector short vec_orc (vector bool short, vector short);
19326 vector short vec_orc (vector short, vector bool short);
19327 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
19328 vector unsigned short vec_orc (vector bool unsigned short, vector unsigned short);
19329 vector unsigned short vec_orc (vector unsigned short, vector bool unsigned short);
19330 vector signed char vec_orc (vector signed char, vector signed char);
19331 vector signed char vec_orc (vector bool signed char, vector signed char);
19332 vector signed char vec_orc (vector signed char, vector bool signed char);
19333 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
19334 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
19335 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
19336
19337 vector int vec_pack (vector long long, vector long long);
19338 vector unsigned int vec_pack (vector unsigned long long, vector unsigned long long);
19339 vector bool int vec_pack (vector bool long long, vector bool long long);
19340 vector float vec_pack (vector double, vector double);
19341
19342 vector int vec_packs (vector long long, vector long long);
19343 vector unsigned int vec_packs (vector unsigned long long, vector unsigned long long);
19344
19345 vector unsigned char vec_packsu (vector signed short, vector signed short)
19346 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short)
19347 vector unsigned short int vec_packsu (vector signed int, vector signed int);
19348 vector unsigned short int vec_packsu (vector unsigned int, vector unsigned int);
19349 vector unsigned int vec_packsu (vector long long, vector long long);
19350 vector unsigned int vec_packsu (vector unsigned long long, vector unsigned long long);
19351 vector unsigned int vec_packsu (vector signed long long, vector signed long long);
19352
19353 vector unsigned char vec_popcnt (vector signed char);
19354 vector unsigned char vec_popcnt (vector unsigned char);
19355 vector unsigned short vec_popcnt (vector signed short);
19356 vector unsigned short vec_popcnt (vector unsigned short);
19357 vector unsigned int vec_popcnt (vector signed int);
19358 vector unsigned int vec_popcnt (vector unsigned int);
19359 vector unsigned long long vec_popcnt (vector signed long long);
19360 vector unsigned long long vec_popcnt (vector unsigned long long);
19361
19362 vector long long vec_rl (vector long long, vector unsigned long long);
19363 vector long long vec_rl (vector unsigned long long, vector unsigned long long);
19364
19365 vector long long vec_sl (vector long long, vector unsigned long long);
19366 vector long long vec_sl (vector unsigned long long, vector unsigned long long);
19367
19368 vector long long vec_sr (vector long long, vector unsigned long long);
19369 vector unsigned long long char vec_sr (vector unsigned long long,
19370 vector unsigned long long);
19371
19372 vector long long vec_sra (vector long long, vector unsigned long long);
19373 vector unsigned long long vec_sra (vector unsigned long long,
19374 vector unsigned long long);
19375
19376 vector long long vec_sub (vector long long, vector long long);
19377 vector unsigned long long vec_sub (vector unsigned long long,
19378 vector unsigned long long);
19379
19380 vector long long vec_unpackh (vector int);
19381 vector unsigned long long vec_unpackh (vector unsigned int);
19382
19383 vector long long vec_unpackl (vector int);
19384 vector unsigned long long vec_unpackl (vector unsigned int);
19385
19386 vector long long vec_vaddudm (vector long long, vector long long);
19387 vector long long vec_vaddudm (vector bool long long, vector long long);
19388 vector long long vec_vaddudm (vector long long, vector bool long long);
19389 vector unsigned long long vec_vaddudm (vector unsigned long long,
19390 vector unsigned long long);
19391 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
19392 vector unsigned long long);
19393 vector unsigned long long vec_vaddudm (vector unsigned long long,
19394 vector bool unsigned long long);
19395
19396 vector long long vec_vbpermq (vector signed char, vector signed char);
19397 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
19398
19399 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
19400 vector unsigned char vec_bperm (vector unsigned long long, vector unsigned char);
19401 vector unsigned long long vec_bperm (vector unsigned __int128, vector unsigned char);
19402
19403 vector long long vec_cntlz (vector long long);
19404 vector unsigned long long vec_cntlz (vector unsigned long long);
19405 vector int vec_cntlz (vector int);
19406 vector unsigned int vec_cntlz (vector int);
19407 vector short vec_cntlz (vector short);
19408 vector unsigned short vec_cntlz (vector unsigned short);
19409 vector signed char vec_cntlz (vector signed char);
19410 vector unsigned char vec_cntlz (vector unsigned char);
19411
19412 vector long long vec_vclz (vector long long);
19413 vector unsigned long long vec_vclz (vector unsigned long long);
19414 vector int vec_vclz (vector int);
19415 vector unsigned int vec_vclz (vector int);
19416 vector short vec_vclz (vector short);
19417 vector unsigned short vec_vclz (vector unsigned short);
19418 vector signed char vec_vclz (vector signed char);
19419 vector unsigned char vec_vclz (vector unsigned char);
19420
19421 vector signed char vec_vclzb (vector signed char);
19422 vector unsigned char vec_vclzb (vector unsigned char);
19423
19424 vector long long vec_vclzd (vector long long);
19425 vector unsigned long long vec_vclzd (vector unsigned long long);
19426
19427 vector short vec_vclzh (vector short);
19428 vector unsigned short vec_vclzh (vector unsigned short);
19429
19430 vector int vec_vclzw (vector int);
19431 vector unsigned int vec_vclzw (vector int);
19432
19433 vector signed char vec_vgbbd (vector signed char);
19434 vector unsigned char vec_vgbbd (vector unsigned char);
19435
19436 vector long long vec_vmaxsd (vector long long, vector long long);
19437
19438 vector unsigned long long vec_vmaxud (vector unsigned long long,
19439 unsigned vector long long);
19440
19441 vector long long vec_vminsd (vector long long, vector long long);
19442
19443 vector unsigned long long vec_vminud (vector long long, vector long long);
19444
19445 vector int vec_vpksdss (vector long long, vector long long);
19446 vector unsigned int vec_vpksdss (vector long long, vector long long);
19447
19448 vector unsigned int vec_vpkudus (vector unsigned long long,
19449 vector unsigned long long);
19450
19451 vector int vec_vpkudum (vector long long, vector long long);
19452 vector unsigned int vec_vpkudum (vector unsigned long long,
19453 vector unsigned long long);
19454 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
19455
19456 vector long long vec_vpopcnt (vector long long);
19457 vector unsigned long long vec_vpopcnt (vector unsigned long long);
19458 vector int vec_vpopcnt (vector int);
19459 vector unsigned int vec_vpopcnt (vector int);
19460 vector short vec_vpopcnt (vector short);
19461 vector unsigned short vec_vpopcnt (vector unsigned short);
19462 vector signed char vec_vpopcnt (vector signed char);
19463 vector unsigned char vec_vpopcnt (vector unsigned char);
19464
19465 vector signed char vec_vpopcntb (vector signed char);
19466 vector unsigned char vec_vpopcntb (vector unsigned char);
19467
19468 vector long long vec_vpopcntd (vector long long);
19469 vector unsigned long long vec_vpopcntd (vector unsigned long long);
19470
19471 vector short vec_vpopcnth (vector short);
19472 vector unsigned short vec_vpopcnth (vector unsigned short);
19473
19474 vector int vec_vpopcntw (vector int);
19475 vector unsigned int vec_vpopcntw (vector int);
19476
19477 vector long long vec_vrld (vector long long, vector unsigned long long);
19478 vector unsigned long long vec_vrld (vector unsigned long long,
19479 vector unsigned long long);
19480
19481 vector long long vec_vsld (vector long long, vector unsigned long long);
19482 vector long long vec_vsld (vector unsigned long long,
19483 vector unsigned long long);
19484
19485 vector long long vec_vsrad (vector long long, vector unsigned long long);
19486 vector unsigned long long vec_vsrad (vector unsigned long long,
19487 vector unsigned long long);
19488
19489 vector long long vec_vsrd (vector long long, vector unsigned long long);
19490 vector unsigned long long char vec_vsrd (vector unsigned long long,
19491 vector unsigned long long);
19492
19493 vector long long vec_vsubudm (vector long long, vector long long);
19494 vector long long vec_vsubudm (vector bool long long, vector long long);
19495 vector long long vec_vsubudm (vector long long, vector bool long long);
19496 vector unsigned long long vec_vsubudm (vector unsigned long long,
19497 vector unsigned long long);
19498 vector unsigned long long vec_vsubudm (vector bool long long,
19499 vector unsigned long long);
19500 vector unsigned long long vec_vsubudm (vector unsigned long long,
19501 vector bool long long);
19502
19503 vector long long vec_vupkhsw (vector int);
19504 vector unsigned long long vec_vupkhsw (vector unsigned int);
19505
19506 vector long long vec_vupklsw (vector int);
19507 vector unsigned long long vec_vupklsw (vector int);
19508 @end smallexample
19509
19510 If the ISA 2.07 additions to the vector/scalar (power8-vector)
19511 instruction set are available, the following additional functions are
19512 available for 64-bit targets. New vector types
19513 (@var{vector __int128} and @var{vector __uint128}) are available
19514 to hold the @var{__int128} and @var{__uint128} types to use these
19515 builtins.
19516
19517 The normal vector extract, and set operations work on
19518 @var{vector __int128} and @var{vector __uint128} types,
19519 but the index value must be 0.
19520
19521 @smallexample
19522 vector __int128 vec_vaddcuq (vector __int128, vector __int128);
19523 vector __uint128 vec_vaddcuq (vector __uint128, vector __uint128);
19524
19525 vector __int128 vec_vadduqm (vector __int128, vector __int128);
19526 vector __uint128 vec_vadduqm (vector __uint128, vector __uint128);
19527
19528 vector __int128 vec_vaddecuq (vector __int128, vector __int128,
19529 vector __int128);
19530 vector __uint128 vec_vaddecuq (vector __uint128, vector __uint128,
19531 vector __uint128);
19532
19533 vector __int128 vec_vaddeuqm (vector __int128, vector __int128,
19534 vector __int128);
19535 vector __uint128 vec_vaddeuqm (vector __uint128, vector __uint128,
19536 vector __uint128);
19537
19538 vector __int128 vec_vsubecuq (vector __int128, vector __int128,
19539 vector __int128);
19540 vector __uint128 vec_vsubecuq (vector __uint128, vector __uint128,
19541 vector __uint128);
19542
19543 vector __int128 vec_vsubeuqm (vector __int128, vector __int128,
19544 vector __int128);
19545 vector __uint128 vec_vsubeuqm (vector __uint128, vector __uint128,
19546 vector __uint128);
19547
19548 vector __int128 vec_vsubcuq (vector __int128, vector __int128);
19549 vector __uint128 vec_vsubcuq (vector __uint128, vector __uint128);
19550
19551 __int128 vec_vsubuqm (__int128, __int128);
19552 __uint128 vec_vsubuqm (__uint128, __uint128);
19553
19554 vector __int128 __builtin_bcdadd (vector __int128, vector __int128, const int);
19555 int __builtin_bcdadd_lt (vector __int128, vector __int128, const int);
19556 int __builtin_bcdadd_eq (vector __int128, vector __int128, const int);
19557 int __builtin_bcdadd_gt (vector __int128, vector __int128, const int);
19558 int __builtin_bcdadd_ov (vector __int128, vector __int128, const int);
19559 vector __int128 __builtin_bcdsub (vector __int128, vector __int128, const int);
19560 int __builtin_bcdsub_lt (vector __int128, vector __int128, const int);
19561 int __builtin_bcdsub_eq (vector __int128, vector __int128, const int);
19562 int __builtin_bcdsub_gt (vector __int128, vector __int128, const int);
19563 int __builtin_bcdsub_ov (vector __int128, vector __int128, const int);
19564 @end smallexample
19565
19566 @node PowerPC AltiVec Built-in Functions Available on ISA 3.0
19567 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 3.0
19568
19569 The following additional built-in functions are also available for the
19570 PowerPC family of processors, starting with ISA 3.0
19571 (@option{-mcpu=power9}) or later:
19572 @smallexample
19573 unsigned int scalar_extract_exp (double source);
19574 unsigned long long int scalar_extract_exp (__ieee128 source);
19575
19576 unsigned long long int scalar_extract_sig (double source);
19577 unsigned __int128 scalar_extract_sig (__ieee128 source);
19578
19579 double scalar_insert_exp (unsigned long long int significand,
19580 unsigned long long int exponent);
19581 double scalar_insert_exp (double significand, unsigned long long int exponent);
19582
19583 ieee_128 scalar_insert_exp (unsigned __int128 significand,
19584 unsigned long long int exponent);
19585 ieee_128 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent);
19586
19587 int scalar_cmp_exp_gt (double arg1, double arg2);
19588 int scalar_cmp_exp_lt (double arg1, double arg2);
19589 int scalar_cmp_exp_eq (double arg1, double arg2);
19590 int scalar_cmp_exp_unordered (double arg1, double arg2);
19591
19592 bool scalar_test_data_class (float source, const int condition);
19593 bool scalar_test_data_class (double source, const int condition);
19594 bool scalar_test_data_class (__ieee128 source, const int condition);
19595
19596 bool scalar_test_neg (float source);
19597 bool scalar_test_neg (double source);
19598 bool scalar_test_neg (__ieee128 source);
19599 @end smallexample
19600
19601 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
19602 functions require a 64-bit environment supporting ISA 3.0 or later.
19603 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
19604 functions return the significand and the biased exponent value
19605 respectively of their @code{source} arguments.
19606 When supplied with a 64-bit @code{source} argument, the
19607 result returned by @code{scalar_extract_sig} has
19608 the @code{0x0010000000000000} bit set if the
19609 function's @code{source} argument is in normalized form.
19610 Otherwise, this bit is set to 0.
19611 When supplied with a 128-bit @code{source} argument, the
19612 @code{0x00010000000000000000000000000000} bit of the result is
19613 treated similarly.
19614 Note that the sign of the significand is not represented in the result
19615 returned from the @code{scalar_extract_sig} function. Use the
19616 @code{scalar_test_neg} function to test the sign of its @code{double}
19617 argument.
19618
19619 The @code{scalar_insert_exp}
19620 functions require a 64-bit environment supporting ISA 3.0 or later.
19621 When supplied with a 64-bit first argument, the
19622 @code{scalar_insert_exp} built-in function returns a double-precision
19623 floating point value that is constructed by assembling the values of its
19624 @code{significand} and @code{exponent} arguments. The sign of the
19625 result is copied from the most significant bit of the
19626 @code{significand} argument. The significand and exponent components
19627 of the result are composed of the least significant 11 bits of the
19628 @code{exponent} argument and the least significant 52 bits of the
19629 @code{significand} argument respectively.
19630
19631 When supplied with a 128-bit first argument, the
19632 @code{scalar_insert_exp} built-in function returns a quad-precision
19633 ieee floating point value. The sign bit of the result is copied from
19634 the most significant bit of the @code{significand} argument.
19635 The significand and exponent components of the result are composed of
19636 the least significant 15 bits of the @code{exponent} argument and the
19637 least significant 112 bits of the @code{significand} argument respectively.
19638
19639 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
19640 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
19641 functions return a non-zero value if @code{arg1} is greater than, less
19642 than, equal to, or not comparable to @code{arg2} respectively. The
19643 arguments are not comparable if one or the other equals NaN (not a
19644 number).
19645
19646 The @code{scalar_test_data_class} built-in function returns 1
19647 if any of the condition tests enabled by the value of the
19648 @code{condition} variable are true, and 0 otherwise. The
19649 @code{condition} argument must be a compile-time constant integer with
19650 value not exceeding 127. The
19651 @code{condition} argument is encoded as a bitmask with each bit
19652 enabling the testing of a different condition, as characterized by the
19653 following:
19654 @smallexample
19655 0x40 Test for NaN
19656 0x20 Test for +Infinity
19657 0x10 Test for -Infinity
19658 0x08 Test for +Zero
19659 0x04 Test for -Zero
19660 0x02 Test for +Denormal
19661 0x01 Test for -Denormal
19662 @end smallexample
19663
19664 The @code{scalar_test_neg} built-in function returns 1 if its
19665 @code{source} argument holds a negative value, 0 otherwise.
19666
19667 The following built-in functions are also available for the PowerPC family
19668 of processors, starting with ISA 3.0 or later
19669 (@option{-mcpu=power9}). These string functions are described
19670 separately in order to group the descriptions closer to the function
19671 prototypes:
19672 @smallexample
19673 int vec_all_nez (vector signed char, vector signed char);
19674 int vec_all_nez (vector unsigned char, vector unsigned char);
19675 int vec_all_nez (vector signed short, vector signed short);
19676 int vec_all_nez (vector unsigned short, vector unsigned short);
19677 int vec_all_nez (vector signed int, vector signed int);
19678 int vec_all_nez (vector unsigned int, vector unsigned int);
19679
19680 int vec_any_eqz (vector signed char, vector signed char);
19681 int vec_any_eqz (vector unsigned char, vector unsigned char);
19682 int vec_any_eqz (vector signed short, vector signed short);
19683 int vec_any_eqz (vector unsigned short, vector unsigned short);
19684 int vec_any_eqz (vector signed int, vector signed int);
19685 int vec_any_eqz (vector unsigned int, vector unsigned int);
19686
19687 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
19688 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
19689 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
19690 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
19691 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
19692 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
19693
19694 vector signed char vec_cnttz (vector signed char);
19695 vector unsigned char vec_cnttz (vector unsigned char);
19696 vector signed short vec_cnttz (vector signed short);
19697 vector unsigned short vec_cnttz (vector unsigned short);
19698 vector signed int vec_cnttz (vector signed int);
19699 vector unsigned int vec_cnttz (vector unsigned int);
19700 vector signed long long vec_cnttz (vector signed long long);
19701 vector unsigned long long vec_cnttz (vector unsigned long long);
19702
19703 signed int vec_cntlz_lsbb (vector signed char);
19704 signed int vec_cntlz_lsbb (vector unsigned char);
19705
19706 signed int vec_cnttz_lsbb (vector signed char);
19707 signed int vec_cnttz_lsbb (vector unsigned char);
19708
19709 unsigned int vec_first_match_index (vector signed char, vector signed char);
19710 unsigned int vec_first_match_index (vector unsigned char, vector unsigned char);
19711 unsigned int vec_first_match_index (vector signed int, vector signed int);
19712 unsigned int vec_first_match_index (vector unsigned int, vector unsigned int);
19713 unsigned int vec_first_match_index (vector signed short, vector signed short);
19714 unsigned int vec_first_match_index (vector unsigned short, vector unsigned short);
19715 unsigned int vec_first_match_or_eos_index (vector signed char, vector signed char);
19716 unsigned int vec_first_match_or_eos_index (vector unsigned char, vector unsigned char);
19717 unsigned int vec_first_match_or_eos_index (vector signed int, vector signed int);
19718 unsigned int vec_first_match_or_eos_index (vector unsigned int, vector unsigned int);
19719 unsigned int vec_first_match_or_eos_index (vector signed short, vector signed short);
19720 unsigned int vec_first_match_or_eos_index (vector unsigned short,
19721 vector unsigned short);
19722 unsigned int vec_first_mismatch_index (vector signed char, vector signed char);
19723 unsigned int vec_first_mismatch_index (vector unsigned char, vector unsigned char);
19724 unsigned int vec_first_mismatch_index (vector signed int, vector signed int);
19725 unsigned int vec_first_mismatch_index (vector unsigned int, vector unsigned int);
19726 unsigned int vec_first_mismatch_index (vector signed short, vector signed short);
19727 unsigned int vec_first_mismatch_index (vector unsigned short, vector unsigned short);
19728 unsigned int vec_first_mismatch_or_eos_index (vector signed char, vector signed char);
19729 unsigned int vec_first_mismatch_or_eos_index (vector unsigned char,
19730 vector unsigned char);
19731 unsigned int vec_first_mismatch_or_eos_index (vector signed int, vector signed int);
19732 unsigned int vec_first_mismatch_or_eos_index (vector unsigned int, vector unsigned int);
19733 unsigned int vec_first_mismatch_or_eos_index (vector signed short, vector signed short);
19734 unsigned int vec_first_mismatch_or_eos_index (vector unsigned short,
19735 vector unsigned short);
19736
19737 vector unsigned short vec_pack_to_short_fp32 (vector float, vector float);
19738
19739 vector signed char vec_xl_be (signed long long, signed char *);
19740 vector unsigned char vec_xl_be (signed long long, unsigned char *);
19741 vector signed int vec_xl_be (signed long long, signed int *);
19742 vector unsigned int vec_xl_be (signed long long, unsigned int *);
19743 vector signed __int128 vec_xl_be (signed long long, signed __int128 *);
19744 vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *);
19745 vector signed long long vec_xl_be (signed long long, signed long long *);
19746 vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
19747 vector signed short vec_xl_be (signed long long, signed short *);
19748 vector unsigned short vec_xl_be (signed long long, unsigned short *);
19749 vector double vec_xl_be (signed long long, double *);
19750 vector float vec_xl_be (signed long long, float *);
19751
19752 vector signed char vec_xl_len (signed char *addr, size_t len);
19753 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
19754 vector signed int vec_xl_len (signed int *addr, size_t len);
19755 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
19756 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
19757 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
19758 vector signed long long vec_xl_len (signed long long *addr, size_t len);
19759 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
19760 vector signed short vec_xl_len (signed short *addr, size_t len);
19761 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
19762 vector double vec_xl_len (double *addr, size_t len);
19763 vector float vec_xl_len (float *addr, size_t len);
19764
19765 vector unsigned char vec_xl_len_r (unsigned char *addr, size_t len);
19766
19767 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
19768 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
19769 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
19770 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
19771 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
19772 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
19773 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
19774 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
19775 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
19776 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
19777 void vec_xst_len (vector double data, double *addr, size_t len);
19778 void vec_xst_len (vector float data, float *addr, size_t len);
19779
19780 void vec_xst_len_r (vector unsigned char data, unsigned char *addr, size_t len);
19781
19782 signed char vec_xlx (unsigned int index, vector signed char data);
19783 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
19784 signed short vec_xlx (unsigned int index, vector signed short data);
19785 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
19786 signed int vec_xlx (unsigned int index, vector signed int data);
19787 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
19788 float vec_xlx (unsigned int index, vector float data);
19789
19790 signed char vec_xrx (unsigned int index, vector signed char data);
19791 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
19792 signed short vec_xrx (unsigned int index, vector signed short data);
19793 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
19794 signed int vec_xrx (unsigned int index, vector signed int data);
19795 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
19796 float vec_xrx (unsigned int index, vector float data);
19797 @end smallexample
19798
19799 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
19800 perform pairwise comparisons between the elements at the same
19801 positions within their two vector arguments.
19802 The @code{vec_all_nez} function returns a
19803 non-zero value if and only if all pairwise comparisons are not
19804 equal and no element of either vector argument contains a zero.
19805 The @code{vec_any_eqz} function returns a
19806 non-zero value if and only if at least one pairwise comparison is equal
19807 or if at least one element of either vector argument contains a zero.
19808 The @code{vec_cmpnez} function returns a vector of the same type as
19809 its two arguments, within which each element consists of all ones to
19810 denote that either the corresponding elements of the incoming arguments are
19811 not equal or that at least one of the corresponding elements contains
19812 zero. Otherwise, the element of the returned vector contains all zeros.
19813
19814 The @code{vec_cntlz_lsbb} function returns the count of the number of
19815 consecutive leading byte elements (starting from position 0 within the
19816 supplied vector argument) for which the least-significant bit
19817 equals zero. The @code{vec_cnttz_lsbb} function returns the count of
19818 the number of consecutive trailing byte elements (starting from
19819 position 15 and counting backwards within the supplied vector
19820 argument) for which the least-significant bit equals zero.
19821
19822 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
19823 64-bit environment supporting ISA 3.0 or later. The @code{vec_xl_len}
19824 function loads a variable length vector from memory. The
19825 @code{vec_xst_len} function stores a variable length vector to memory.
19826 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
19827 @code{addr} argument represents the memory address to or from which
19828 data will be transferred, and the
19829 @code{len} argument represents the number of bytes to be
19830 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
19831 If this expression's value is not a multiple of the vector element's
19832 size, the behavior of this function is undefined.
19833 In the case that the underlying computer is configured to run in
19834 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
19835 the corresponding vector. In little-endian mode, the data transfer
19836 moves bytes @code{(16 - len)} to @code{15} of the corresponding
19837 vector. For the load function, any bytes of the result vector that
19838 are not loaded from memory are set to zero.
19839 The value of the @code{addr} argument need not be aligned on a
19840 multiple of the vector's element size.
19841
19842 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
19843 element selected by the @code{index} argument from the vector
19844 represented by the @code{data} argument. The @code{index} argument
19845 always specifies a byte offset, regardless of the size of the vector
19846 element. With @code{vec_xlx}, @code{index} is the offset of the first
19847 byte of the element to be extracted. With @code{vec_xrx}, @code{index}
19848 represents the last byte of the element to be extracted, measured
19849 from the right end of the vector. In other words, the last byte of
19850 the element to be extracted is found at position @code{(15 - index)}.
19851 There is no requirement that @code{index} be a multiple of the vector
19852 element size. However, if the size of the vector element added to
19853 @code{index} is greater than 15, the content of the returned value is
19854 undefined.
19855
19856 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19857 are available:
19858
19859 @smallexample
19860 vector unsigned long long vec_bperm (vector unsigned long long, vector unsigned char);
19861
19862 vector bool char vec_cmpne (vector bool char, vector bool char);
19863 vector bool char vec_cmpne (vector signed char, vector signed char);
19864 vector bool char vec_cmpne (vector unsigned char, vector unsigned char);
19865 vector bool int vec_cmpne (vector bool int, vector bool int);
19866 vector bool int vec_cmpne (vector signed int, vector signed int);
19867 vector bool int vec_cmpne (vector unsigned int, vector unsigned int);
19868 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
19869 vector bool long long vec_cmpne (vector signed long long, vector signed long long);
19870 vector bool long long vec_cmpne (vector unsigned long long, vector unsigned long long);
19871 vector bool short vec_cmpne (vector bool short, vector bool short);
19872 vector bool short vec_cmpne (vector signed short, vector signed short);
19873 vector bool short vec_cmpne (vector unsigned short, vector unsigned short);
19874 vector bool long long vec_cmpne (vector double, vector double);
19875 vector bool int vec_cmpne (vector float, vector float);
19876
19877 vector float vec_extract_fp32_from_shorth (vector unsigned short);
19878 vector float vec_extract_fp32_from_shortl (vector unsigned short);
19879
19880 vector long long vec_vctz (vector long long);
19881 vector unsigned long long vec_vctz (vector unsigned long long);
19882 vector int vec_vctz (vector int);
19883 vector unsigned int vec_vctz (vector int);
19884 vector short vec_vctz (vector short);
19885 vector unsigned short vec_vctz (vector unsigned short);
19886 vector signed char vec_vctz (vector signed char);
19887 vector unsigned char vec_vctz (vector unsigned char);
19888
19889 vector signed char vec_vctzb (vector signed char);
19890 vector unsigned char vec_vctzb (vector unsigned char);
19891
19892 vector long long vec_vctzd (vector long long);
19893 vector unsigned long long vec_vctzd (vector unsigned long long);
19894
19895 vector short vec_vctzh (vector short);
19896 vector unsigned short vec_vctzh (vector unsigned short);
19897
19898 vector int vec_vctzw (vector int);
19899 vector unsigned int vec_vctzw (vector int);
19900
19901 vector unsigned long long vec_extract4b (vector unsigned char, const int);
19902
19903 vector unsigned char vec_insert4b (vector signed int, vector unsigned char,
19904 const int);
19905 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
19906 const int);
19907
19908 vector unsigned int vec_parity_lsbb (vector signed int);
19909 vector unsigned int vec_parity_lsbb (vector unsigned int);
19910 vector unsigned __int128 vec_parity_lsbb (vector signed __int128);
19911 vector unsigned __int128 vec_parity_lsbb (vector unsigned __int128);
19912 vector unsigned long long vec_parity_lsbb (vector signed long long);
19913 vector unsigned long long vec_parity_lsbb (vector unsigned long long);
19914
19915 vector int vec_vprtyb (vector int);
19916 vector unsigned int vec_vprtyb (vector unsigned int);
19917 vector long long vec_vprtyb (vector long long);
19918 vector unsigned long long vec_vprtyb (vector unsigned long long);
19919
19920 vector int vec_vprtybw (vector int);
19921 vector unsigned int vec_vprtybw (vector unsigned int);
19922
19923 vector long long vec_vprtybd (vector long long);
19924 vector unsigned long long vec_vprtybd (vector unsigned long long);
19925 @end smallexample
19926
19927 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19928 are available:
19929
19930 @smallexample
19931 vector long vec_vprtyb (vector long);
19932 vector unsigned long vec_vprtyb (vector unsigned long);
19933 vector __int128 vec_vprtyb (vector __int128);
19934 vector __uint128 vec_vprtyb (vector __uint128);
19935
19936 vector long vec_vprtybd (vector long);
19937 vector unsigned long vec_vprtybd (vector unsigned long);
19938
19939 vector __int128 vec_vprtybq (vector __int128);
19940 vector __uint128 vec_vprtybd (vector __uint128);
19941 @end smallexample
19942
19943 The following built-in vector functions are available for the PowerPC family
19944 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19945 @smallexample
19946 __vector unsigned char
19947 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
19948 __vector unsigned char
19949 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
19950 @end smallexample
19951
19952 The @code{vec_slv} and @code{vec_srv} functions operate on
19953 all of the bytes of their @code{src} and @code{shift_distance}
19954 arguments in parallel. The behavior of the @code{vec_slv} is as if
19955 there existed a temporary array of 17 unsigned characters
19956 @code{slv_array} within which elements 0 through 15 are the same as
19957 the entries in the @code{src} array and element 16 equals 0. The
19958 result returned from the @code{vec_slv} function is a
19959 @code{__vector} of 16 unsigned characters within which element
19960 @code{i} is computed using the C expression
19961 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
19962 shift_distance[i]))},
19963 with this resulting value coerced to the @code{unsigned char} type.
19964 The behavior of the @code{vec_srv} is as if
19965 there existed a temporary array of 17 unsigned characters
19966 @code{srv_array} within which element 0 equals zero and
19967 elements 1 through 16 equal the elements 0 through 15 of
19968 the @code{src} array. The
19969 result returned from the @code{vec_srv} function is a
19970 @code{__vector} of 16 unsigned characters within which element
19971 @code{i} is computed using the C expression
19972 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
19973 (0x07 & shift_distance[i]))},
19974 with this resulting value coerced to the @code{unsigned char} type.
19975
19976 The following built-in functions are available for the PowerPC family
19977 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19978 @smallexample
19979 __vector unsigned char
19980 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
19981 __vector unsigned short
19982 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
19983 __vector unsigned int
19984 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
19985
19986 __vector unsigned char
19987 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
19988 __vector unsigned short
19989 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
19990 __vector unsigned int
19991 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
19992 @end smallexample
19993
19994 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
19995 @code{vec_absdw} built-in functions each computes the absolute
19996 differences of the pairs of vector elements supplied in its two vector
19997 arguments, placing the absolute differences into the corresponding
19998 elements of the vector result.
19999
20000 The following built-in functions are available for the PowerPC family
20001 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
20002 @smallexample
20003 __vector unsigned int vec_extract_exp (__vector float source);
20004 __vector unsigned long long int vec_extract_exp (__vector double source);
20005
20006 __vector unsigned int vec_extract_sig (__vector float source);
20007 __vector unsigned long long int vec_extract_sig (__vector double source);
20008
20009 __vector float vec_insert_exp (__vector unsigned int significands,
20010 __vector unsigned int exponents);
20011 __vector float vec_insert_exp (__vector unsigned float significands,
20012 __vector unsigned int exponents);
20013 __vector double vec_insert_exp (__vector unsigned long long int significands,
20014 __vector unsigned long long int exponents);
20015 __vector double vec_insert_exp (__vector unsigned double significands,
20016 __vector unsigned long long int exponents);
20017
20018 __vector bool int vec_test_data_class (__vector float source, const int condition);
20019 __vector bool long long int vec_test_data_class (__vector double source,
20020 const int condition);
20021 @end smallexample
20022
20023 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
20024 functions return vectors representing the significands and biased
20025 exponent values of their @code{source} arguments respectively.
20026 Within the result vector returned by @code{vec_extract_sig}, the
20027 @code{0x800000} bit of each vector element returned when the
20028 function's @code{source} argument is of type @code{float} is set to 1
20029 if the corresponding floating point value is in normalized form.
20030 Otherwise, this bit is set to 0. When the @code{source} argument is
20031 of type @code{double}, the @code{0x10000000000000} bit within each of
20032 the result vector's elements is set according to the same rules.
20033 Note that the sign of the significand is not represented in the result
20034 returned from the @code{vec_extract_sig} function. To extract the
20035 sign bits, use the
20036 @code{vec_cpsgn} function, which returns a new vector within which all
20037 of the sign bits of its second argument vector are overwritten with the
20038 sign bits copied from the coresponding elements of its first argument
20039 vector, and all other (non-sign) bits of the second argument vector
20040 are copied unchanged into the result vector.
20041
20042 The @code{vec_insert_exp} built-in functions return a vector of
20043 single- or double-precision floating
20044 point values constructed by assembling the values of their
20045 @code{significands} and @code{exponents} arguments into the
20046 corresponding elements of the returned vector.
20047 The sign of each
20048 element of the result is copied from the most significant bit of the
20049 corresponding entry within the @code{significands} argument.
20050 Note that the relevant
20051 bits of the @code{significands} argument are the same, for both integer
20052 and floating point types.
20053 The
20054 significand and exponent components of each element of the result are
20055 composed of the least significant bits of the corresponding
20056 @code{significands} element and the least significant bits of the
20057 corresponding @code{exponents} element.
20058
20059 The @code{vec_test_data_class} built-in function returns a vector
20060 representing the results of testing the @code{source} vector for the
20061 condition selected by the @code{condition} argument. The
20062 @code{condition} argument must be a compile-time constant integer with
20063 value not exceeding 127. The
20064 @code{condition} argument is encoded as a bitmask with each bit
20065 enabling the testing of a different condition, as characterized by the
20066 following:
20067 @smallexample
20068 0x40 Test for NaN
20069 0x20 Test for +Infinity
20070 0x10 Test for -Infinity
20071 0x08 Test for +Zero
20072 0x04 Test for -Zero
20073 0x02 Test for +Denormal
20074 0x01 Test for -Denormal
20075 @end smallexample
20076
20077 If any of the enabled test conditions is true, the corresponding entry
20078 in the result vector is -1. Otherwise (all of the enabled test
20079 conditions are false), the corresponding entry of the result vector is 0.
20080
20081 The following built-in functions are available for the PowerPC family
20082 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
20083 @smallexample
20084 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
20085 vector unsigned int);
20086 vector unsigned long long vec_rlmi (vector unsigned long long,
20087 vector unsigned long long,
20088 vector unsigned long long);
20089 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
20090 vector unsigned int);
20091 vector unsigned long long vec_rlnm (vector unsigned long long,
20092 vector unsigned long long,
20093 vector unsigned long long);
20094 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
20095 vector unsigned long long vec_vrlnm (vector unsigned long long,
20096 vector unsigned long long);
20097 @end smallexample
20098
20099 The result of @code{vec_rlmi} is obtained by rotating each element of
20100 the first argument vector left and inserting it under mask into the
20101 second argument vector. The third argument vector contains the mask
20102 beginning in bits 11:15, the mask end in bits 19:23, and the shift
20103 count in bits 27:31, of each element.
20104
20105 The result of @code{vec_rlnm} is obtained by rotating each element of
20106 the first argument vector left and ANDing it with a mask specified by
20107 the second and third argument vectors. The second argument vector
20108 contains the shift count for each element in the low-order byte. The
20109 third argument vector contains the mask end for each element in the
20110 low-order byte, with the mask begin in the next higher byte.
20111
20112 The result of @code{vec_vrlnm} is obtained by rotating each element
20113 of the first argument vector left and ANDing it with a mask. The
20114 second argument vector contains the mask beginning in bits 11:15,
20115 the mask end in bits 19:23, and the shift count in bits 27:31,
20116 of each element.
20117
20118 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
20119 are available:
20120 @smallexample
20121 vector signed bool char vec_revb (vector signed char);
20122 vector signed char vec_revb (vector signed char);
20123 vector unsigned char vec_revb (vector unsigned char);
20124 vector bool short vec_revb (vector bool short);
20125 vector short vec_revb (vector short);
20126 vector unsigned short vec_revb (vector unsigned short);
20127 vector bool int vec_revb (vector bool int);
20128 vector int vec_revb (vector int);
20129 vector unsigned int vec_revb (vector unsigned int);
20130 vector float vec_revb (vector float);
20131 vector bool long long vec_revb (vector bool long long);
20132 vector long long vec_revb (vector long long);
20133 vector unsigned long long vec_revb (vector unsigned long long);
20134 vector double vec_revb (vector double);
20135 @end smallexample
20136
20137 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
20138 are available:
20139 @smallexample
20140 vector long vec_revb (vector long);
20141 vector unsigned long vec_revb (vector unsigned long);
20142 vector __int128 vec_revb (vector __int128);
20143 vector __uint128 vec_revb (vector __uint128);
20144 @end smallexample
20145
20146 The @code{vec_revb} built-in function reverses the bytes on an element
20147 by element basis. A vector of @code{vector unsigned char} or
20148 @code{vector signed char} reverses the bytes in the whole word.
20149
20150 If the cryptographic instructions are enabled (@option{-mcrypto} or
20151 @option{-mcpu=power8}), the following builtins are enabled.
20152
20153 @smallexample
20154 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
20155
20156 vector unsigned char vec_sbox_be (vector unsigned char);
20157
20158 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
20159 vector unsigned long long);
20160
20161 vector unsigned char vec_cipher_be (vector unsigned char, vector unsigned char);
20162
20163 vector unsigned long long __builtin_crypto_vcipherlast
20164 (vector unsigned long long,
20165 vector unsigned long long);
20166
20167 vector unsigned char vec_cipherlast_be (vector unsigned char,
20168 vector unsigned char);
20169
20170 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
20171 vector unsigned long long);
20172
20173 vector unsigned char vec_ncipher_be (vector unsigned char,
20174 vector unsigned char);
20175
20176 vector unsigned long long __builtin_crypto_vncipherlast (vector unsigned long long,
20177 vector unsigned long long);
20178
20179 vector unsigned char vec_ncipherlast_be (vector unsigned char,
20180 vector unsigned char);
20181
20182 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
20183 vector unsigned char,
20184 vector unsigned char);
20185
20186 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
20187 vector unsigned short,
20188 vector unsigned short);
20189
20190 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
20191 vector unsigned int,
20192 vector unsigned int);
20193
20194 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
20195 vector unsigned long long,
20196 vector unsigned long long);
20197
20198 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
20199 vector unsigned char);
20200
20201 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
20202 vector unsigned short);
20203
20204 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
20205 vector unsigned int);
20206
20207 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
20208 vector unsigned long long);
20209
20210 vector unsigned long long __builtin_crypto_vshasigmad (vector unsigned long long,
20211 int, int);
20212
20213 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int, int, int);
20214 @end smallexample
20215
20216 The second argument to @var{__builtin_crypto_vshasigmad} and
20217 @var{__builtin_crypto_vshasigmaw} must be a constant
20218 integer that is 0 or 1. The third argument to these built-in functions
20219 must be a constant integer in the range of 0 to 15.
20220
20221 If the ISA 3.0 instruction set additions
20222 are enabled (@option{-mcpu=power9}), the following additional
20223 functions are available for both 32-bit and 64-bit targets.
20224 @smallexample
20225 vector short vec_xl (int, vector short *);
20226 vector short vec_xl (int, short *);
20227 vector unsigned short vec_xl (int, vector unsigned short *);
20228 vector unsigned short vec_xl (int, unsigned short *);
20229 vector char vec_xl (int, vector char *);
20230 vector char vec_xl (int, char *);
20231 vector unsigned char vec_xl (int, vector unsigned char *);
20232 vector unsigned char vec_xl (int, unsigned char *);
20233
20234 void vec_xst (vector short, int, vector short *);
20235 void vec_xst (vector short, int, short *);
20236 void vec_xst (vector unsigned short, int, vector unsigned short *);
20237 void vec_xst (vector unsigned short, int, unsigned short *);
20238 void vec_xst (vector char, int, vector char *);
20239 void vec_xst (vector char, int, char *);
20240 void vec_xst (vector unsigned char, int, vector unsigned char *);
20241 void vec_xst (vector unsigned char, int, unsigned char *);
20242 @end smallexample
20243 @node PowerPC Hardware Transactional Memory Built-in Functions
20244 @subsection PowerPC Hardware Transactional Memory Built-in Functions
20245 GCC provides two interfaces for accessing the Hardware Transactional
20246 Memory (HTM) instructions available on some of the PowerPC family
20247 of processors (eg, POWER8). The two interfaces come in a low level
20248 interface, consisting of built-in functions specific to PowerPC and a
20249 higher level interface consisting of inline functions that are common
20250 between PowerPC and S/390.
20251
20252 @subsubsection PowerPC HTM Low Level Built-in Functions
20253
20254 The following low level built-in functions are available with
20255 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
20256 They all generate the machine instruction that is part of the name.
20257
20258 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
20259 the full 4-bit condition register value set by their associated hardware
20260 instruction. The header file @code{htmintrin.h} defines some macros that can
20261 be used to decipher the return value. The @code{__builtin_tbegin} builtin
20262 returns a simple @code{true} or @code{false} value depending on whether a transaction was
20263 successfully started or not. The arguments of the builtins match exactly the
20264 type and order of the associated hardware instruction's operands, except for
20265 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
20266 Refer to the ISA manual for a description of each instruction's operands.
20267
20268 @smallexample
20269 unsigned int __builtin_tbegin (unsigned int)
20270 unsigned int __builtin_tend (unsigned int)
20271
20272 unsigned int __builtin_tabort (unsigned int)
20273 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
20274 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
20275 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
20276 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
20277
20278 unsigned int __builtin_tcheck (void)
20279 unsigned int __builtin_treclaim (unsigned int)
20280 unsigned int __builtin_trechkpt (void)
20281 unsigned int __builtin_tsr (unsigned int)
20282 @end smallexample
20283
20284 In addition to the above HTM built-ins, we have added built-ins for
20285 some common extended mnemonics of the HTM instructions:
20286
20287 @smallexample
20288 unsigned int __builtin_tendall (void)
20289 unsigned int __builtin_tresume (void)
20290 unsigned int __builtin_tsuspend (void)
20291 @end smallexample
20292
20293 Note that the semantics of the above HTM builtins are required to mimic
20294 the locking semantics used for critical sections. Builtins that are used
20295 to create a new transaction or restart a suspended transaction must have
20296 lock acquisition like semantics while those builtins that end or suspend a
20297 transaction must have lock release like semantics. Specifically, this must
20298 mimic lock semantics as specified by C++11, for example: Lock acquisition is
20299 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
20300 that returns 0, and lock release is as-if an execution of
20301 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
20302 implicit implementation-defined lock used for all transactions. The HTM
20303 instructions associated with with the builtins inherently provide the
20304 correct acquisition and release hardware barriers required. However,
20305 the compiler must also be prohibited from moving loads and stores across
20306 the builtins in a way that would violate their semantics. This has been
20307 accomplished by adding memory barriers to the associated HTM instructions
20308 (which is a conservative approach to provide acquire and release semantics).
20309 Earlier versions of the compiler did not treat the HTM instructions as
20310 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
20311 be used to determine whether the current compiler treats HTM instructions
20312 as memory barriers or not. This allows the user to explicitly add memory
20313 barriers to their code when using an older version of the compiler.
20314
20315 The following set of built-in functions are available to gain access
20316 to the HTM specific special purpose registers.
20317
20318 @smallexample
20319 unsigned long __builtin_get_texasr (void)
20320 unsigned long __builtin_get_texasru (void)
20321 unsigned long __builtin_get_tfhar (void)
20322 unsigned long __builtin_get_tfiar (void)
20323
20324 void __builtin_set_texasr (unsigned long);
20325 void __builtin_set_texasru (unsigned long);
20326 void __builtin_set_tfhar (unsigned long);
20327 void __builtin_set_tfiar (unsigned long);
20328 @end smallexample
20329
20330 Example usage of these low level built-in functions may look like:
20331
20332 @smallexample
20333 #include <htmintrin.h>
20334
20335 int num_retries = 10;
20336
20337 while (1)
20338 @{
20339 if (__builtin_tbegin (0))
20340 @{
20341 /* Transaction State Initiated. */
20342 if (is_locked (lock))
20343 __builtin_tabort (0);
20344 ... transaction code...
20345 __builtin_tend (0);
20346 break;
20347 @}
20348 else
20349 @{
20350 /* Transaction State Failed. Use locks if the transaction
20351 failure is "persistent" or we've tried too many times. */
20352 if (num_retries-- <= 0
20353 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
20354 @{
20355 acquire_lock (lock);
20356 ... non transactional fallback path...
20357 release_lock (lock);
20358 break;
20359 @}
20360 @}
20361 @}
20362 @end smallexample
20363
20364 One final built-in function has been added that returns the value of
20365 the 2-bit Transaction State field of the Machine Status Register (MSR)
20366 as stored in @code{CR0}.
20367
20368 @smallexample
20369 unsigned long __builtin_ttest (void)
20370 @end smallexample
20371
20372 This built-in can be used to determine the current transaction state
20373 using the following code example:
20374
20375 @smallexample
20376 #include <htmintrin.h>
20377
20378 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
20379
20380 if (tx_state == _HTM_TRANSACTIONAL)
20381 @{
20382 /* Code to use in transactional state. */
20383 @}
20384 else if (tx_state == _HTM_NONTRANSACTIONAL)
20385 @{
20386 /* Code to use in non-transactional state. */
20387 @}
20388 else if (tx_state == _HTM_SUSPENDED)
20389 @{
20390 /* Code to use in transaction suspended state. */
20391 @}
20392 @end smallexample
20393
20394 @subsubsection PowerPC HTM High Level Inline Functions
20395
20396 The following high level HTM interface is made available by including
20397 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
20398 where CPU is `power8' or later. This interface is common between PowerPC
20399 and S/390, allowing users to write one HTM source implementation that
20400 can be compiled and executed on either system.
20401
20402 @smallexample
20403 long __TM_simple_begin (void)
20404 long __TM_begin (void* const TM_buff)
20405 long __TM_end (void)
20406 void __TM_abort (void)
20407 void __TM_named_abort (unsigned char const code)
20408 void __TM_resume (void)
20409 void __TM_suspend (void)
20410
20411 long __TM_is_user_abort (void* const TM_buff)
20412 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
20413 long __TM_is_illegal (void* const TM_buff)
20414 long __TM_is_footprint_exceeded (void* const TM_buff)
20415 long __TM_nesting_depth (void* const TM_buff)
20416 long __TM_is_nested_too_deep(void* const TM_buff)
20417 long __TM_is_conflict(void* const TM_buff)
20418 long __TM_is_failure_persistent(void* const TM_buff)
20419 long __TM_failure_address(void* const TM_buff)
20420 long long __TM_failure_code(void* const TM_buff)
20421 @end smallexample
20422
20423 Using these common set of HTM inline functions, we can create
20424 a more portable version of the HTM example in the previous
20425 section that will work on either PowerPC or S/390:
20426
20427 @smallexample
20428 #include <htmxlintrin.h>
20429
20430 int num_retries = 10;
20431 TM_buff_type TM_buff;
20432
20433 while (1)
20434 @{
20435 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
20436 @{
20437 /* Transaction State Initiated. */
20438 if (is_locked (lock))
20439 __TM_abort ();
20440 ... transaction code...
20441 __TM_end ();
20442 break;
20443 @}
20444 else
20445 @{
20446 /* Transaction State Failed. Use locks if the transaction
20447 failure is "persistent" or we've tried too many times. */
20448 if (num_retries-- <= 0
20449 || __TM_is_failure_persistent (TM_buff))
20450 @{
20451 acquire_lock (lock);
20452 ... non transactional fallback path...
20453 release_lock (lock);
20454 break;
20455 @}
20456 @}
20457 @}
20458 @end smallexample
20459
20460 @node PowerPC Atomic Memory Operation Functions
20461 @subsection PowerPC Atomic Memory Operation Functions
20462 ISA 3.0 of the PowerPC added new atomic memory operation (amo)
20463 instructions. GCC provides support for these instructions in 64-bit
20464 environments. All of the functions are declared in the include file
20465 @code{amo.h}.
20466
20467 The functions supported are:
20468
20469 @smallexample
20470 #include <amo.h>
20471
20472 uint32_t amo_lwat_add (uint32_t *, uint32_t);
20473 uint32_t amo_lwat_xor (uint32_t *, uint32_t);
20474 uint32_t amo_lwat_ior (uint32_t *, uint32_t);
20475 uint32_t amo_lwat_and (uint32_t *, uint32_t);
20476 uint32_t amo_lwat_umax (uint32_t *, uint32_t);
20477 uint32_t amo_lwat_umin (uint32_t *, uint32_t);
20478 uint32_t amo_lwat_swap (uint32_t *, uint32_t);
20479
20480 int32_t amo_lwat_sadd (int32_t *, int32_t);
20481 int32_t amo_lwat_smax (int32_t *, int32_t);
20482 int32_t amo_lwat_smin (int32_t *, int32_t);
20483 int32_t amo_lwat_sswap (int32_t *, int32_t);
20484
20485 uint64_t amo_ldat_add (uint64_t *, uint64_t);
20486 uint64_t amo_ldat_xor (uint64_t *, uint64_t);
20487 uint64_t amo_ldat_ior (uint64_t *, uint64_t);
20488 uint64_t amo_ldat_and (uint64_t *, uint64_t);
20489 uint64_t amo_ldat_umax (uint64_t *, uint64_t);
20490 uint64_t amo_ldat_umin (uint64_t *, uint64_t);
20491 uint64_t amo_ldat_swap (uint64_t *, uint64_t);
20492
20493 int64_t amo_ldat_sadd (int64_t *, int64_t);
20494 int64_t amo_ldat_smax (int64_t *, int64_t);
20495 int64_t amo_ldat_smin (int64_t *, int64_t);
20496 int64_t amo_ldat_sswap (int64_t *, int64_t);
20497
20498 void amo_stwat_add (uint32_t *, uint32_t);
20499 void amo_stwat_xor (uint32_t *, uint32_t);
20500 void amo_stwat_ior (uint32_t *, uint32_t);
20501 void amo_stwat_and (uint32_t *, uint32_t);
20502 void amo_stwat_umax (uint32_t *, uint32_t);
20503 void amo_stwat_umin (uint32_t *, uint32_t);
20504
20505 void amo_stwat_sadd (int32_t *, int32_t);
20506 void amo_stwat_smax (int32_t *, int32_t);
20507 void amo_stwat_smin (int32_t *, int32_t);
20508
20509 void amo_stdat_add (uint64_t *, uint64_t);
20510 void amo_stdat_xor (uint64_t *, uint64_t);
20511 void amo_stdat_ior (uint64_t *, uint64_t);
20512 void amo_stdat_and (uint64_t *, uint64_t);
20513 void amo_stdat_umax (uint64_t *, uint64_t);
20514 void amo_stdat_umin (uint64_t *, uint64_t);
20515
20516 void amo_stdat_sadd (int64_t *, int64_t);
20517 void amo_stdat_smax (int64_t *, int64_t);
20518 void amo_stdat_smin (int64_t *, int64_t);
20519 @end smallexample
20520
20521 @node RX Built-in Functions
20522 @subsection RX Built-in Functions
20523 GCC supports some of the RX instructions which cannot be expressed in
20524 the C programming language via the use of built-in functions. The
20525 following functions are supported:
20526
20527 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
20528 Generates the @code{brk} machine instruction.
20529 @end deftypefn
20530
20531 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
20532 Generates the @code{clrpsw} machine instruction to clear the specified
20533 bit in the processor status word.
20534 @end deftypefn
20535
20536 @deftypefn {Built-in Function} void __builtin_rx_int (int)
20537 Generates the @code{int} machine instruction to generate an interrupt
20538 with the specified value.
20539 @end deftypefn
20540
20541 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
20542 Generates the @code{machi} machine instruction to add the result of
20543 multiplying the top 16 bits of the two arguments into the
20544 accumulator.
20545 @end deftypefn
20546
20547 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
20548 Generates the @code{maclo} machine instruction to add the result of
20549 multiplying the bottom 16 bits of the two arguments into the
20550 accumulator.
20551 @end deftypefn
20552
20553 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
20554 Generates the @code{mulhi} machine instruction to place the result of
20555 multiplying the top 16 bits of the two arguments into the
20556 accumulator.
20557 @end deftypefn
20558
20559 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
20560 Generates the @code{mullo} machine instruction to place the result of
20561 multiplying the bottom 16 bits of the two arguments into the
20562 accumulator.
20563 @end deftypefn
20564
20565 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
20566 Generates the @code{mvfachi} machine instruction to read the top
20567 32 bits of the accumulator.
20568 @end deftypefn
20569
20570 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
20571 Generates the @code{mvfacmi} machine instruction to read the middle
20572 32 bits of the accumulator.
20573 @end deftypefn
20574
20575 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
20576 Generates the @code{mvfc} machine instruction which reads the control
20577 register specified in its argument and returns its value.
20578 @end deftypefn
20579
20580 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
20581 Generates the @code{mvtachi} machine instruction to set the top
20582 32 bits of the accumulator.
20583 @end deftypefn
20584
20585 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
20586 Generates the @code{mvtaclo} machine instruction to set the bottom
20587 32 bits of the accumulator.
20588 @end deftypefn
20589
20590 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
20591 Generates the @code{mvtc} machine instruction which sets control
20592 register number @code{reg} to @code{val}.
20593 @end deftypefn
20594
20595 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
20596 Generates the @code{mvtipl} machine instruction set the interrupt
20597 priority level.
20598 @end deftypefn
20599
20600 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
20601 Generates the @code{racw} machine instruction to round the accumulator
20602 according to the specified mode.
20603 @end deftypefn
20604
20605 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
20606 Generates the @code{revw} machine instruction which swaps the bytes in
20607 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
20608 and also bits 16--23 occupy bits 24--31 and vice versa.
20609 @end deftypefn
20610
20611 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
20612 Generates the @code{rmpa} machine instruction which initiates a
20613 repeated multiply and accumulate sequence.
20614 @end deftypefn
20615
20616 @deftypefn {Built-in Function} void __builtin_rx_round (float)
20617 Generates the @code{round} machine instruction which returns the
20618 floating-point argument rounded according to the current rounding mode
20619 set in the floating-point status word register.
20620 @end deftypefn
20621
20622 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
20623 Generates the @code{sat} machine instruction which returns the
20624 saturated value of the argument.
20625 @end deftypefn
20626
20627 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
20628 Generates the @code{setpsw} machine instruction to set the specified
20629 bit in the processor status word.
20630 @end deftypefn
20631
20632 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
20633 Generates the @code{wait} machine instruction.
20634 @end deftypefn
20635
20636 @node S/390 System z Built-in Functions
20637 @subsection S/390 System z Built-in Functions
20638 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
20639 Generates the @code{tbegin} machine instruction starting a
20640 non-constrained hardware transaction. If the parameter is non-NULL the
20641 memory area is used to store the transaction diagnostic buffer and
20642 will be passed as first operand to @code{tbegin}. This buffer can be
20643 defined using the @code{struct __htm_tdb} C struct defined in
20644 @code{htmintrin.h} and must reside on a double-word boundary. The
20645 second tbegin operand is set to @code{0xff0c}. This enables
20646 save/restore of all GPRs and disables aborts for FPR and AR
20647 manipulations inside the transaction body. The condition code set by
20648 the tbegin instruction is returned as integer value. The tbegin
20649 instruction by definition overwrites the content of all FPRs. The
20650 compiler will generate code which saves and restores the FPRs. For
20651 soft-float code it is recommended to used the @code{*_nofloat}
20652 variant. In order to prevent a TDB from being written it is required
20653 to pass a constant zero value as parameter. Passing a zero value
20654 through a variable is not sufficient. Although modifications of
20655 access registers inside the transaction will not trigger an
20656 transaction abort it is not supported to actually modify them. Access
20657 registers do not get saved when entering a transaction. They will have
20658 undefined state when reaching the abort code.
20659 @end deftypefn
20660
20661 Macros for the possible return codes of tbegin are defined in the
20662 @code{htmintrin.h} header file:
20663
20664 @table @code
20665 @item _HTM_TBEGIN_STARTED
20666 @code{tbegin} has been executed as part of normal processing. The
20667 transaction body is supposed to be executed.
20668 @item _HTM_TBEGIN_INDETERMINATE
20669 The transaction was aborted due to an indeterminate condition which
20670 might be persistent.
20671 @item _HTM_TBEGIN_TRANSIENT
20672 The transaction aborted due to a transient failure. The transaction
20673 should be re-executed in that case.
20674 @item _HTM_TBEGIN_PERSISTENT
20675 The transaction aborted due to a persistent failure. Re-execution
20676 under same circumstances will not be productive.
20677 @end table
20678
20679 @defmac _HTM_FIRST_USER_ABORT_CODE
20680 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
20681 specifies the first abort code which can be used for
20682 @code{__builtin_tabort}. Values below this threshold are reserved for
20683 machine use.
20684 @end defmac
20685
20686 @deftp {Data type} {struct __htm_tdb}
20687 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
20688 the structure of the transaction diagnostic block as specified in the
20689 Principles of Operation manual chapter 5-91.
20690 @end deftp
20691
20692 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
20693 Same as @code{__builtin_tbegin} but without FPR saves and restores.
20694 Using this variant in code making use of FPRs will leave the FPRs in
20695 undefined state when entering the transaction abort handler code.
20696 @end deftypefn
20697
20698 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
20699 In addition to @code{__builtin_tbegin} a loop for transient failures
20700 is generated. If tbegin returns a condition code of 2 the transaction
20701 will be retried as often as specified in the second argument. The
20702 perform processor assist instruction is used to tell the CPU about the
20703 number of fails so far.
20704 @end deftypefn
20705
20706 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
20707 Same as @code{__builtin_tbegin_retry} but without FPR saves and
20708 restores. Using this variant in code making use of FPRs will leave
20709 the FPRs in undefined state when entering the transaction abort
20710 handler code.
20711 @end deftypefn
20712
20713 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
20714 Generates the @code{tbeginc} machine instruction starting a constrained
20715 hardware transaction. The second operand is set to @code{0xff08}.
20716 @end deftypefn
20717
20718 @deftypefn {Built-in Function} int __builtin_tend (void)
20719 Generates the @code{tend} machine instruction finishing a transaction
20720 and making the changes visible to other threads. The condition code
20721 generated by tend is returned as integer value.
20722 @end deftypefn
20723
20724 @deftypefn {Built-in Function} void __builtin_tabort (int)
20725 Generates the @code{tabort} machine instruction with the specified
20726 abort code. Abort codes from 0 through 255 are reserved and will
20727 result in an error message.
20728 @end deftypefn
20729
20730 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
20731 Generates the @code{ppa rX,rY,1} machine instruction. Where the
20732 integer parameter is loaded into rX and a value of zero is loaded into
20733 rY. The integer parameter specifies the number of times the
20734 transaction repeatedly aborted.
20735 @end deftypefn
20736
20737 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
20738 Generates the @code{etnd} machine instruction. The current nesting
20739 depth is returned as integer value. For a nesting depth of 0 the code
20740 is not executed as part of an transaction.
20741 @end deftypefn
20742
20743 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
20744
20745 Generates the @code{ntstg} machine instruction. The second argument
20746 is written to the first arguments location. The store operation will
20747 not be rolled-back in case of an transaction abort.
20748 @end deftypefn
20749
20750 @node SH Built-in Functions
20751 @subsection SH Built-in Functions
20752 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
20753 families of processors:
20754
20755 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
20756 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
20757 used by system code that manages threads and execution contexts. The compiler
20758 normally does not generate code that modifies the contents of @samp{GBR} and
20759 thus the value is preserved across function calls. Changing the @samp{GBR}
20760 value in user code must be done with caution, since the compiler might use
20761 @samp{GBR} in order to access thread local variables.
20762
20763 @end deftypefn
20764
20765 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
20766 Returns the value that is currently set in the @samp{GBR} register.
20767 Memory loads and stores that use the thread pointer as a base address are
20768 turned into @samp{GBR} based displacement loads and stores, if possible.
20769 For example:
20770 @smallexample
20771 struct my_tcb
20772 @{
20773 int a, b, c, d, e;
20774 @};
20775
20776 int get_tcb_value (void)
20777 @{
20778 // Generate @samp{mov.l @@(8,gbr),r0} instruction
20779 return ((my_tcb*)__builtin_thread_pointer ())->c;
20780 @}
20781
20782 @end smallexample
20783 @end deftypefn
20784
20785 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
20786 Returns the value that is currently set in the @samp{FPSCR} register.
20787 @end deftypefn
20788
20789 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
20790 Sets the @samp{FPSCR} register to the specified value @var{val}, while
20791 preserving the current values of the FR, SZ and PR bits.
20792 @end deftypefn
20793
20794 @node SPARC VIS Built-in Functions
20795 @subsection SPARC VIS Built-in Functions
20796
20797 GCC supports SIMD operations on the SPARC using both the generic vector
20798 extensions (@pxref{Vector Extensions}) as well as built-in functions for
20799 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
20800 switch, the VIS extension is exposed as the following built-in functions:
20801
20802 @smallexample
20803 typedef int v1si __attribute__ ((vector_size (4)));
20804 typedef int v2si __attribute__ ((vector_size (8)));
20805 typedef short v4hi __attribute__ ((vector_size (8)));
20806 typedef short v2hi __attribute__ ((vector_size (4)));
20807 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
20808 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
20809
20810 void __builtin_vis_write_gsr (int64_t);
20811 int64_t __builtin_vis_read_gsr (void);
20812
20813 void * __builtin_vis_alignaddr (void *, long);
20814 void * __builtin_vis_alignaddrl (void *, long);
20815 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
20816 v2si __builtin_vis_faligndatav2si (v2si, v2si);
20817 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
20818 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
20819
20820 v4hi __builtin_vis_fexpand (v4qi);
20821
20822 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
20823 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
20824 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
20825 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
20826 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
20827 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
20828 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
20829
20830 v4qi __builtin_vis_fpack16 (v4hi);
20831 v8qi __builtin_vis_fpack32 (v2si, v8qi);
20832 v2hi __builtin_vis_fpackfix (v2si);
20833 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
20834
20835 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
20836
20837 long __builtin_vis_edge8 (void *, void *);
20838 long __builtin_vis_edge8l (void *, void *);
20839 long __builtin_vis_edge16 (void *, void *);
20840 long __builtin_vis_edge16l (void *, void *);
20841 long __builtin_vis_edge32 (void *, void *);
20842 long __builtin_vis_edge32l (void *, void *);
20843
20844 long __builtin_vis_fcmple16 (v4hi, v4hi);
20845 long __builtin_vis_fcmple32 (v2si, v2si);
20846 long __builtin_vis_fcmpne16 (v4hi, v4hi);
20847 long __builtin_vis_fcmpne32 (v2si, v2si);
20848 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
20849 long __builtin_vis_fcmpgt32 (v2si, v2si);
20850 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
20851 long __builtin_vis_fcmpeq32 (v2si, v2si);
20852
20853 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
20854 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
20855 v2si __builtin_vis_fpadd32 (v2si, v2si);
20856 v1si __builtin_vis_fpadd32s (v1si, v1si);
20857 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
20858 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
20859 v2si __builtin_vis_fpsub32 (v2si, v2si);
20860 v1si __builtin_vis_fpsub32s (v1si, v1si);
20861
20862 long __builtin_vis_array8 (long, long);
20863 long __builtin_vis_array16 (long, long);
20864 long __builtin_vis_array32 (long, long);
20865 @end smallexample
20866
20867 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
20868 functions also become available:
20869
20870 @smallexample
20871 long __builtin_vis_bmask (long, long);
20872 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
20873 v2si __builtin_vis_bshufflev2si (v2si, v2si);
20874 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
20875 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
20876
20877 long __builtin_vis_edge8n (void *, void *);
20878 long __builtin_vis_edge8ln (void *, void *);
20879 long __builtin_vis_edge16n (void *, void *);
20880 long __builtin_vis_edge16ln (void *, void *);
20881 long __builtin_vis_edge32n (void *, void *);
20882 long __builtin_vis_edge32ln (void *, void *);
20883 @end smallexample
20884
20885 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
20886 functions also become available:
20887
20888 @smallexample
20889 void __builtin_vis_cmask8 (long);
20890 void __builtin_vis_cmask16 (long);
20891 void __builtin_vis_cmask32 (long);
20892
20893 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
20894
20895 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
20896 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
20897 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
20898 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
20899 v2si __builtin_vis_fsll16 (v2si, v2si);
20900 v2si __builtin_vis_fslas16 (v2si, v2si);
20901 v2si __builtin_vis_fsrl16 (v2si, v2si);
20902 v2si __builtin_vis_fsra16 (v2si, v2si);
20903
20904 long __builtin_vis_pdistn (v8qi, v8qi);
20905
20906 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
20907
20908 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
20909 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
20910
20911 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
20912 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
20913 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
20914 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
20915 v2si __builtin_vis_fpadds32 (v2si, v2si);
20916 v1si __builtin_vis_fpadds32s (v1si, v1si);
20917 v2si __builtin_vis_fpsubs32 (v2si, v2si);
20918 v1si __builtin_vis_fpsubs32s (v1si, v1si);
20919
20920 long __builtin_vis_fucmple8 (v8qi, v8qi);
20921 long __builtin_vis_fucmpne8 (v8qi, v8qi);
20922 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
20923 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
20924
20925 float __builtin_vis_fhadds (float, float);
20926 double __builtin_vis_fhaddd (double, double);
20927 float __builtin_vis_fhsubs (float, float);
20928 double __builtin_vis_fhsubd (double, double);
20929 float __builtin_vis_fnhadds (float, float);
20930 double __builtin_vis_fnhaddd (double, double);
20931
20932 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
20933 int64_t __builtin_vis_xmulx (int64_t, int64_t);
20934 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
20935 @end smallexample
20936
20937 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
20938 functions also become available:
20939
20940 @smallexample
20941 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
20942 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
20943 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
20944 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
20945
20946 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
20947 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
20948 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
20949 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
20950
20951 long __builtin_vis_fpcmple8 (v8qi, v8qi);
20952 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
20953 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
20954 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
20955 long __builtin_vis_fpcmpule32 (v2si, v2si);
20956 long __builtin_vis_fpcmpugt32 (v2si, v2si);
20957
20958 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
20959 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
20960 v2si __builtin_vis_fpmax32 (v2si, v2si);
20961
20962 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
20963 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
20964 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
20965
20966
20967 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
20968 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
20969 v2si __builtin_vis_fpmin32 (v2si, v2si);
20970
20971 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
20972 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
20973 v2si __builtin_vis_fpminu32 (v2si, v2si);
20974 @end smallexample
20975
20976 When you use the @option{-mvis4b} switch, the VIS version 4.0B
20977 built-in functions also become available:
20978
20979 @smallexample
20980 v8qi __builtin_vis_dictunpack8 (double, int);
20981 v4hi __builtin_vis_dictunpack16 (double, int);
20982 v2si __builtin_vis_dictunpack32 (double, int);
20983
20984 long __builtin_vis_fpcmple8shl (v8qi, v8qi, int);
20985 long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int);
20986 long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int);
20987 long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int);
20988
20989 long __builtin_vis_fpcmple16shl (v4hi, v4hi, int);
20990 long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int);
20991 long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int);
20992 long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int);
20993
20994 long __builtin_vis_fpcmple32shl (v2si, v2si, int);
20995 long __builtin_vis_fpcmpgt32shl (v2si, v2si, int);
20996 long __builtin_vis_fpcmpeq32shl (v2si, v2si, int);
20997 long __builtin_vis_fpcmpne32shl (v2si, v2si, int);
20998
20999 long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int);
21000 long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int);
21001 long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int);
21002 long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int);
21003 long __builtin_vis_fpcmpule32shl (v2si, v2si, int);
21004 long __builtin_vis_fpcmpugt32shl (v2si, v2si, int);
21005
21006 long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int);
21007 long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int);
21008 long __builtin_vis_fpcmpde32shl (v2si, v2si, int);
21009
21010 long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int);
21011 long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int);
21012 long __builtin_vis_fpcmpur32shl (v2si, v2si, int);
21013 @end smallexample
21014
21015 @node SPU Built-in Functions
21016 @subsection SPU Built-in Functions
21017
21018 GCC provides extensions for the SPU processor as described in the
21019 Sony/Toshiba/IBM SPU Language Extensions Specification. GCC's
21020 implementation differs in several ways.
21021
21022 @itemize @bullet
21023
21024 @item
21025 The optional extension of specifying vector constants in parentheses is
21026 not supported.
21027
21028 @item
21029 A vector initializer requires no cast if the vector constant is of the
21030 same type as the variable it is initializing.
21031
21032 @item
21033 If @code{signed} or @code{unsigned} is omitted, the signedness of the
21034 vector type is the default signedness of the base type. The default
21035 varies depending on the operating system, so a portable program should
21036 always specify the signedness.
21037
21038 @item
21039 By default, the keyword @code{__vector} is added. The macro
21040 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
21041 undefined.
21042
21043 @item
21044 GCC allows using a @code{typedef} name as the type specifier for a
21045 vector type.
21046
21047 @item
21048 For C, overloaded functions are implemented with macros so the following
21049 does not work:
21050
21051 @smallexample
21052 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
21053 @end smallexample
21054
21055 @noindent
21056 Since @code{spu_add} is a macro, the vector constant in the example
21057 is treated as four separate arguments. Wrap the entire argument in
21058 parentheses for this to work.
21059
21060 @item
21061 The extended version of @code{__builtin_expect} is not supported.
21062
21063 @end itemize
21064
21065 @emph{Note:} Only the interface described in the aforementioned
21066 specification is supported. Internally, GCC uses built-in functions to
21067 implement the required functionality, but these are not supported and
21068 are subject to change without notice.
21069
21070 @node TI C6X Built-in Functions
21071 @subsection TI C6X Built-in Functions
21072
21073 GCC provides intrinsics to access certain instructions of the TI C6X
21074 processors. These intrinsics, listed below, are available after
21075 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
21076 to C6X instructions.
21077
21078 @smallexample
21079
21080 int _sadd (int, int)
21081 int _ssub (int, int)
21082 int _sadd2 (int, int)
21083 int _ssub2 (int, int)
21084 long long _mpy2 (int, int)
21085 long long _smpy2 (int, int)
21086 int _add4 (int, int)
21087 int _sub4 (int, int)
21088 int _saddu4 (int, int)
21089
21090 int _smpy (int, int)
21091 int _smpyh (int, int)
21092 int _smpyhl (int, int)
21093 int _smpylh (int, int)
21094
21095 int _sshl (int, int)
21096 int _subc (int, int)
21097
21098 int _avg2 (int, int)
21099 int _avgu4 (int, int)
21100
21101 int _clrr (int, int)
21102 int _extr (int, int)
21103 int _extru (int, int)
21104 int _abs (int)
21105 int _abs2 (int)
21106
21107 @end smallexample
21108
21109 @node TILE-Gx Built-in Functions
21110 @subsection TILE-Gx Built-in Functions
21111
21112 GCC provides intrinsics to access every instruction of the TILE-Gx
21113 processor. The intrinsics are of the form:
21114
21115 @smallexample
21116
21117 unsigned long long __insn_@var{op} (...)
21118
21119 @end smallexample
21120
21121 Where @var{op} is the name of the instruction. Refer to the ISA manual
21122 for the complete list of instructions.
21123
21124 GCC also provides intrinsics to directly access the network registers.
21125 The intrinsics are:
21126
21127 @smallexample
21128
21129 unsigned long long __tile_idn0_receive (void)
21130 unsigned long long __tile_idn1_receive (void)
21131 unsigned long long __tile_udn0_receive (void)
21132 unsigned long long __tile_udn1_receive (void)
21133 unsigned long long __tile_udn2_receive (void)
21134 unsigned long long __tile_udn3_receive (void)
21135 void __tile_idn_send (unsigned long long)
21136 void __tile_udn_send (unsigned long long)
21137
21138 @end smallexample
21139
21140 The intrinsic @code{void __tile_network_barrier (void)} is used to
21141 guarantee that no network operations before it are reordered with
21142 those after it.
21143
21144 @node TILEPro Built-in Functions
21145 @subsection TILEPro Built-in Functions
21146
21147 GCC provides intrinsics to access every instruction of the TILEPro
21148 processor. The intrinsics are of the form:
21149
21150 @smallexample
21151
21152 unsigned __insn_@var{op} (...)
21153
21154 @end smallexample
21155
21156 @noindent
21157 where @var{op} is the name of the instruction. Refer to the ISA manual
21158 for the complete list of instructions.
21159
21160 GCC also provides intrinsics to directly access the network registers.
21161 The intrinsics are:
21162
21163 @smallexample
21164
21165 unsigned __tile_idn0_receive (void)
21166 unsigned __tile_idn1_receive (void)
21167 unsigned __tile_sn_receive (void)
21168 unsigned __tile_udn0_receive (void)
21169 unsigned __tile_udn1_receive (void)
21170 unsigned __tile_udn2_receive (void)
21171 unsigned __tile_udn3_receive (void)
21172 void __tile_idn_send (unsigned)
21173 void __tile_sn_send (unsigned)
21174 void __tile_udn_send (unsigned)
21175
21176 @end smallexample
21177
21178 The intrinsic @code{void __tile_network_barrier (void)} is used to
21179 guarantee that no network operations before it are reordered with
21180 those after it.
21181
21182 @node x86 Built-in Functions
21183 @subsection x86 Built-in Functions
21184
21185 These built-in functions are available for the x86-32 and x86-64 family
21186 of computers, depending on the command-line switches used.
21187
21188 If you specify command-line switches such as @option{-msse},
21189 the compiler could use the extended instruction sets even if the built-ins
21190 are not used explicitly in the program. For this reason, applications
21191 that perform run-time CPU detection must compile separate files for each
21192 supported architecture, using the appropriate flags. In particular,
21193 the file containing the CPU detection code should be compiled without
21194 these options.
21195
21196 The following machine modes are available for use with MMX built-in functions
21197 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
21198 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
21199 vector of eight 8-bit integers. Some of the built-in functions operate on
21200 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
21201
21202 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
21203 of two 32-bit floating-point values.
21204
21205 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
21206 floating-point values. Some instructions use a vector of four 32-bit
21207 integers, these use @code{V4SI}. Finally, some instructions operate on an
21208 entire vector register, interpreting it as a 128-bit integer, these use mode
21209 @code{TI}.
21210
21211 The x86-32 and x86-64 family of processors use additional built-in
21212 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
21213 floating point and @code{TC} 128-bit complex floating-point values.
21214
21215 The following floating-point built-in functions are always available. All
21216 of them implement the function that is part of the name.
21217
21218 @smallexample
21219 __float128 __builtin_fabsq (__float128)
21220 __float128 __builtin_copysignq (__float128, __float128)
21221 @end smallexample
21222
21223 The following built-in functions are always available.
21224
21225 @table @code
21226 @item __float128 __builtin_infq (void)
21227 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
21228 @findex __builtin_infq
21229
21230 @item __float128 __builtin_huge_valq (void)
21231 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
21232 @findex __builtin_huge_valq
21233
21234 @item __float128 __builtin_nanq (void)
21235 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
21236 @findex __builtin_nanq
21237
21238 @item __float128 __builtin_nansq (void)
21239 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
21240 @findex __builtin_nansq
21241 @end table
21242
21243 The following built-in function is always available.
21244
21245 @table @code
21246 @item void __builtin_ia32_pause (void)
21247 Generates the @code{pause} machine instruction with a compiler memory
21248 barrier.
21249 @end table
21250
21251 The following built-in functions are always available and can be used to
21252 check the target platform type.
21253
21254 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
21255 This function runs the CPU detection code to check the type of CPU and the
21256 features supported. This built-in function needs to be invoked along with the built-in functions
21257 to check CPU type and features, @code{__builtin_cpu_is} and
21258 @code{__builtin_cpu_supports}, only when used in a function that is
21259 executed before any constructors are called. The CPU detection code is
21260 automatically executed in a very high priority constructor.
21261
21262 For example, this function has to be used in @code{ifunc} resolvers that
21263 check for CPU type using the built-in functions @code{__builtin_cpu_is}
21264 and @code{__builtin_cpu_supports}, or in constructors on targets that
21265 don't support constructor priority.
21266 @smallexample
21267
21268 static void (*resolve_memcpy (void)) (void)
21269 @{
21270 // ifunc resolvers fire before constructors, explicitly call the init
21271 // function.
21272 __builtin_cpu_init ();
21273 if (__builtin_cpu_supports ("ssse3"))
21274 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
21275 else
21276 return default_memcpy;
21277 @}
21278
21279 void *memcpy (void *, const void *, size_t)
21280 __attribute__ ((ifunc ("resolve_memcpy")));
21281 @end smallexample
21282
21283 @end deftypefn
21284
21285 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
21286 This function returns a positive integer if the run-time CPU
21287 is of type @var{cpuname}
21288 and returns @code{0} otherwise. The following CPU names can be detected:
21289
21290 @table @samp
21291 @item amd
21292 AMD CPU.
21293
21294 @item intel
21295 Intel CPU.
21296
21297 @item atom
21298 Intel Atom CPU.
21299
21300 @item slm
21301 Intel Silvermont CPU.
21302
21303 @item core2
21304 Intel Core 2 CPU.
21305
21306 @item corei7
21307 Intel Core i7 CPU.
21308
21309 @item nehalem
21310 Intel Core i7 Nehalem CPU.
21311
21312 @item westmere
21313 Intel Core i7 Westmere CPU.
21314
21315 @item sandybridge
21316 Intel Core i7 Sandy Bridge CPU.
21317
21318 @item ivybridge
21319 Intel Core i7 Ivy Bridge CPU.
21320
21321 @item haswell
21322 Intel Core i7 Haswell CPU.
21323
21324 @item broadwell
21325 Intel Core i7 Broadwell CPU.
21326
21327 @item skylake
21328 Intel Core i7 Skylake CPU.
21329
21330 @item skylake-avx512
21331 Intel Core i7 Skylake AVX512 CPU.
21332
21333 @item cannonlake
21334 Intel Core i7 Cannon Lake CPU.
21335
21336 @item icelake-client
21337 Intel Core i7 Ice Lake Client CPU.
21338
21339 @item icelake-server
21340 Intel Core i7 Ice Lake Server CPU.
21341
21342 @item cascadelake
21343 Intel Core i7 Cascadelake CPU.
21344
21345 @item bonnell
21346 Intel Atom Bonnell CPU.
21347
21348 @item silvermont
21349 Intel Atom Silvermont CPU.
21350
21351 @item goldmont
21352 Intel Atom Goldmont CPU.
21353
21354 @item goldmont-plus
21355 Intel Atom Goldmont Plus CPU.
21356
21357 @item tremont
21358 Intel Atom Tremont CPU.
21359
21360 @item knl
21361 Intel Knights Landing CPU.
21362
21363 @item knm
21364 Intel Knights Mill CPU.
21365
21366 @item amdfam10h
21367 AMD Family 10h CPU.
21368
21369 @item barcelona
21370 AMD Family 10h Barcelona CPU.
21371
21372 @item shanghai
21373 AMD Family 10h Shanghai CPU.
21374
21375 @item istanbul
21376 AMD Family 10h Istanbul CPU.
21377
21378 @item btver1
21379 AMD Family 14h CPU.
21380
21381 @item amdfam15h
21382 AMD Family 15h CPU.
21383
21384 @item bdver1
21385 AMD Family 15h Bulldozer version 1.
21386
21387 @item bdver2
21388 AMD Family 15h Bulldozer version 2.
21389
21390 @item bdver3
21391 AMD Family 15h Bulldozer version 3.
21392
21393 @item bdver4
21394 AMD Family 15h Bulldozer version 4.
21395
21396 @item btver2
21397 AMD Family 16h CPU.
21398
21399 @item amdfam17h
21400 AMD Family 17h CPU.
21401
21402 @item znver1
21403 AMD Family 17h Zen version 1.
21404
21405 @item znver2
21406 AMD Family 17h Zen version 2.
21407 @end table
21408
21409 Here is an example:
21410 @smallexample
21411 if (__builtin_cpu_is ("corei7"))
21412 @{
21413 do_corei7 (); // Core i7 specific implementation.
21414 @}
21415 else
21416 @{
21417 do_generic (); // Generic implementation.
21418 @}
21419 @end smallexample
21420 @end deftypefn
21421
21422 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
21423 This function returns a positive integer if the run-time CPU
21424 supports @var{feature}
21425 and returns @code{0} otherwise. The following features can be detected:
21426
21427 @table @samp
21428 @item cmov
21429 CMOV instruction.
21430 @item mmx
21431 MMX instructions.
21432 @item popcnt
21433 POPCNT instruction.
21434 @item sse
21435 SSE instructions.
21436 @item sse2
21437 SSE2 instructions.
21438 @item sse3
21439 SSE3 instructions.
21440 @item ssse3
21441 SSSE3 instructions.
21442 @item sse4.1
21443 SSE4.1 instructions.
21444 @item sse4.2
21445 SSE4.2 instructions.
21446 @item avx
21447 AVX instructions.
21448 @item avx2
21449 AVX2 instructions.
21450 @item sse4a
21451 SSE4A instructions.
21452 @item fma4
21453 FMA4 instructions.
21454 @item xop
21455 XOP instructions.
21456 @item fma
21457 FMA instructions.
21458 @item avx512f
21459 AVX512F instructions.
21460 @item bmi
21461 BMI instructions.
21462 @item bmi2
21463 BMI2 instructions.
21464 @item aes
21465 AES instructions.
21466 @item pclmul
21467 PCLMUL instructions.
21468 @item avx512vl
21469 AVX512VL instructions.
21470 @item avx512bw
21471 AVX512BW instructions.
21472 @item avx512dq
21473 AVX512DQ instructions.
21474 @item avx512cd
21475 AVX512CD instructions.
21476 @item avx512er
21477 AVX512ER instructions.
21478 @item avx512pf
21479 AVX512PF instructions.
21480 @item avx512vbmi
21481 AVX512VBMI instructions.
21482 @item avx512ifma
21483 AVX512IFMA instructions.
21484 @item avx5124vnniw
21485 AVX5124VNNIW instructions.
21486 @item avx5124fmaps
21487 AVX5124FMAPS instructions.
21488 @item avx512vpopcntdq
21489 AVX512VPOPCNTDQ instructions.
21490 @item avx512vbmi2
21491 AVX512VBMI2 instructions.
21492 @item gfni
21493 GFNI instructions.
21494 @item vpclmulqdq
21495 VPCLMULQDQ instructions.
21496 @item avx512vnni
21497 AVX512VNNI instructions.
21498 @item avx512bitalg
21499 AVX512BITALG instructions.
21500 @end table
21501
21502 Here is an example:
21503 @smallexample
21504 if (__builtin_cpu_supports ("popcnt"))
21505 @{
21506 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
21507 @}
21508 else
21509 @{
21510 count = generic_countbits (n); //generic implementation.
21511 @}
21512 @end smallexample
21513 @end deftypefn
21514
21515
21516 The following built-in functions are made available by @option{-mmmx}.
21517 All of them generate the machine instruction that is part of the name.
21518
21519 @smallexample
21520 v8qi __builtin_ia32_paddb (v8qi, v8qi)
21521 v4hi __builtin_ia32_paddw (v4hi, v4hi)
21522 v2si __builtin_ia32_paddd (v2si, v2si)
21523 v8qi __builtin_ia32_psubb (v8qi, v8qi)
21524 v4hi __builtin_ia32_psubw (v4hi, v4hi)
21525 v2si __builtin_ia32_psubd (v2si, v2si)
21526 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
21527 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
21528 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
21529 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
21530 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
21531 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
21532 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
21533 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
21534 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
21535 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
21536 di __builtin_ia32_pand (di, di)
21537 di __builtin_ia32_pandn (di,di)
21538 di __builtin_ia32_por (di, di)
21539 di __builtin_ia32_pxor (di, di)
21540 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
21541 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
21542 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
21543 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
21544 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
21545 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
21546 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
21547 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
21548 v2si __builtin_ia32_punpckhdq (v2si, v2si)
21549 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
21550 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
21551 v2si __builtin_ia32_punpckldq (v2si, v2si)
21552 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
21553 v4hi __builtin_ia32_packssdw (v2si, v2si)
21554 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
21555
21556 v4hi __builtin_ia32_psllw (v4hi, v4hi)
21557 v2si __builtin_ia32_pslld (v2si, v2si)
21558 v1di __builtin_ia32_psllq (v1di, v1di)
21559 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
21560 v2si __builtin_ia32_psrld (v2si, v2si)
21561 v1di __builtin_ia32_psrlq (v1di, v1di)
21562 v4hi __builtin_ia32_psraw (v4hi, v4hi)
21563 v2si __builtin_ia32_psrad (v2si, v2si)
21564 v4hi __builtin_ia32_psllwi (v4hi, int)
21565 v2si __builtin_ia32_pslldi (v2si, int)
21566 v1di __builtin_ia32_psllqi (v1di, int)
21567 v4hi __builtin_ia32_psrlwi (v4hi, int)
21568 v2si __builtin_ia32_psrldi (v2si, int)
21569 v1di __builtin_ia32_psrlqi (v1di, int)
21570 v4hi __builtin_ia32_psrawi (v4hi, int)
21571 v2si __builtin_ia32_psradi (v2si, int)
21572
21573 @end smallexample
21574
21575 The following built-in functions are made available either with
21576 @option{-msse}, or with @option{-m3dnowa}. All of them generate
21577 the machine instruction that is part of the name.
21578
21579 @smallexample
21580 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
21581 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
21582 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
21583 v1di __builtin_ia32_psadbw (v8qi, v8qi)
21584 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
21585 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
21586 v8qi __builtin_ia32_pminub (v8qi, v8qi)
21587 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
21588 int __builtin_ia32_pmovmskb (v8qi)
21589 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
21590 void __builtin_ia32_movntq (di *, di)
21591 void __builtin_ia32_sfence (void)
21592 @end smallexample
21593
21594 The following built-in functions are available when @option{-msse} is used.
21595 All of them generate the machine instruction that is part of the name.
21596
21597 @smallexample
21598 int __builtin_ia32_comieq (v4sf, v4sf)
21599 int __builtin_ia32_comineq (v4sf, v4sf)
21600 int __builtin_ia32_comilt (v4sf, v4sf)
21601 int __builtin_ia32_comile (v4sf, v4sf)
21602 int __builtin_ia32_comigt (v4sf, v4sf)
21603 int __builtin_ia32_comige (v4sf, v4sf)
21604 int __builtin_ia32_ucomieq (v4sf, v4sf)
21605 int __builtin_ia32_ucomineq (v4sf, v4sf)
21606 int __builtin_ia32_ucomilt (v4sf, v4sf)
21607 int __builtin_ia32_ucomile (v4sf, v4sf)
21608 int __builtin_ia32_ucomigt (v4sf, v4sf)
21609 int __builtin_ia32_ucomige (v4sf, v4sf)
21610 v4sf __builtin_ia32_addps (v4sf, v4sf)
21611 v4sf __builtin_ia32_subps (v4sf, v4sf)
21612 v4sf __builtin_ia32_mulps (v4sf, v4sf)
21613 v4sf __builtin_ia32_divps (v4sf, v4sf)
21614 v4sf __builtin_ia32_addss (v4sf, v4sf)
21615 v4sf __builtin_ia32_subss (v4sf, v4sf)
21616 v4sf __builtin_ia32_mulss (v4sf, v4sf)
21617 v4sf __builtin_ia32_divss (v4sf, v4sf)
21618 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
21619 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
21620 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
21621 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
21622 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
21623 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
21624 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
21625 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
21626 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
21627 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
21628 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
21629 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
21630 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
21631 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
21632 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
21633 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
21634 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
21635 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
21636 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
21637 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
21638 v4sf __builtin_ia32_maxps (v4sf, v4sf)
21639 v4sf __builtin_ia32_maxss (v4sf, v4sf)
21640 v4sf __builtin_ia32_minps (v4sf, v4sf)
21641 v4sf __builtin_ia32_minss (v4sf, v4sf)
21642 v4sf __builtin_ia32_andps (v4sf, v4sf)
21643 v4sf __builtin_ia32_andnps (v4sf, v4sf)
21644 v4sf __builtin_ia32_orps (v4sf, v4sf)
21645 v4sf __builtin_ia32_xorps (v4sf, v4sf)
21646 v4sf __builtin_ia32_movss (v4sf, v4sf)
21647 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
21648 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
21649 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
21650 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
21651 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
21652 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
21653 v2si __builtin_ia32_cvtps2pi (v4sf)
21654 int __builtin_ia32_cvtss2si (v4sf)
21655 v2si __builtin_ia32_cvttps2pi (v4sf)
21656 int __builtin_ia32_cvttss2si (v4sf)
21657 v4sf __builtin_ia32_rcpps (v4sf)
21658 v4sf __builtin_ia32_rsqrtps (v4sf)
21659 v4sf __builtin_ia32_sqrtps (v4sf)
21660 v4sf __builtin_ia32_rcpss (v4sf)
21661 v4sf __builtin_ia32_rsqrtss (v4sf)
21662 v4sf __builtin_ia32_sqrtss (v4sf)
21663 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
21664 void __builtin_ia32_movntps (float *, v4sf)
21665 int __builtin_ia32_movmskps (v4sf)
21666 @end smallexample
21667
21668 The following built-in functions are available when @option{-msse} is used.
21669
21670 @table @code
21671 @item v4sf __builtin_ia32_loadups (float *)
21672 Generates the @code{movups} machine instruction as a load from memory.
21673 @item void __builtin_ia32_storeups (float *, v4sf)
21674 Generates the @code{movups} machine instruction as a store to memory.
21675 @item v4sf __builtin_ia32_loadss (float *)
21676 Generates the @code{movss} machine instruction as a load from memory.
21677 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
21678 Generates the @code{movhps} machine instruction as a load from memory.
21679 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
21680 Generates the @code{movlps} machine instruction as a load from memory
21681 @item void __builtin_ia32_storehps (v2sf *, v4sf)
21682 Generates the @code{movhps} machine instruction as a store to memory.
21683 @item void __builtin_ia32_storelps (v2sf *, v4sf)
21684 Generates the @code{movlps} machine instruction as a store to memory.
21685 @end table
21686
21687 The following built-in functions are available when @option{-msse2} is used.
21688 All of them generate the machine instruction that is part of the name.
21689
21690 @smallexample
21691 int __builtin_ia32_comisdeq (v2df, v2df)
21692 int __builtin_ia32_comisdlt (v2df, v2df)
21693 int __builtin_ia32_comisdle (v2df, v2df)
21694 int __builtin_ia32_comisdgt (v2df, v2df)
21695 int __builtin_ia32_comisdge (v2df, v2df)
21696 int __builtin_ia32_comisdneq (v2df, v2df)
21697 int __builtin_ia32_ucomisdeq (v2df, v2df)
21698 int __builtin_ia32_ucomisdlt (v2df, v2df)
21699 int __builtin_ia32_ucomisdle (v2df, v2df)
21700 int __builtin_ia32_ucomisdgt (v2df, v2df)
21701 int __builtin_ia32_ucomisdge (v2df, v2df)
21702 int __builtin_ia32_ucomisdneq (v2df, v2df)
21703 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
21704 v2df __builtin_ia32_cmpltpd (v2df, v2df)
21705 v2df __builtin_ia32_cmplepd (v2df, v2df)
21706 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
21707 v2df __builtin_ia32_cmpgepd (v2df, v2df)
21708 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
21709 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
21710 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
21711 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
21712 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
21713 v2df __builtin_ia32_cmpngepd (v2df, v2df)
21714 v2df __builtin_ia32_cmpordpd (v2df, v2df)
21715 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
21716 v2df __builtin_ia32_cmpltsd (v2df, v2df)
21717 v2df __builtin_ia32_cmplesd (v2df, v2df)
21718 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
21719 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
21720 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
21721 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
21722 v2df __builtin_ia32_cmpordsd (v2df, v2df)
21723 v2di __builtin_ia32_paddq (v2di, v2di)
21724 v2di __builtin_ia32_psubq (v2di, v2di)
21725 v2df __builtin_ia32_addpd (v2df, v2df)
21726 v2df __builtin_ia32_subpd (v2df, v2df)
21727 v2df __builtin_ia32_mulpd (v2df, v2df)
21728 v2df __builtin_ia32_divpd (v2df, v2df)
21729 v2df __builtin_ia32_addsd (v2df, v2df)
21730 v2df __builtin_ia32_subsd (v2df, v2df)
21731 v2df __builtin_ia32_mulsd (v2df, v2df)
21732 v2df __builtin_ia32_divsd (v2df, v2df)
21733 v2df __builtin_ia32_minpd (v2df, v2df)
21734 v2df __builtin_ia32_maxpd (v2df, v2df)
21735 v2df __builtin_ia32_minsd (v2df, v2df)
21736 v2df __builtin_ia32_maxsd (v2df, v2df)
21737 v2df __builtin_ia32_andpd (v2df, v2df)
21738 v2df __builtin_ia32_andnpd (v2df, v2df)
21739 v2df __builtin_ia32_orpd (v2df, v2df)
21740 v2df __builtin_ia32_xorpd (v2df, v2df)
21741 v2df __builtin_ia32_movsd (v2df, v2df)
21742 v2df __builtin_ia32_unpckhpd (v2df, v2df)
21743 v2df __builtin_ia32_unpcklpd (v2df, v2df)
21744 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
21745 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
21746 v4si __builtin_ia32_paddd128 (v4si, v4si)
21747 v2di __builtin_ia32_paddq128 (v2di, v2di)
21748 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
21749 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
21750 v4si __builtin_ia32_psubd128 (v4si, v4si)
21751 v2di __builtin_ia32_psubq128 (v2di, v2di)
21752 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
21753 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
21754 v2di __builtin_ia32_pand128 (v2di, v2di)
21755 v2di __builtin_ia32_pandn128 (v2di, v2di)
21756 v2di __builtin_ia32_por128 (v2di, v2di)
21757 v2di __builtin_ia32_pxor128 (v2di, v2di)
21758 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
21759 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
21760 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
21761 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
21762 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
21763 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
21764 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
21765 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
21766 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
21767 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
21768 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
21769 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
21770 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
21771 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
21772 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
21773 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
21774 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
21775 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
21776 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
21777 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
21778 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
21779 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
21780 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
21781 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
21782 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
21783 v2df __builtin_ia32_loadupd (double *)
21784 void __builtin_ia32_storeupd (double *, v2df)
21785 v2df __builtin_ia32_loadhpd (v2df, double const *)
21786 v2df __builtin_ia32_loadlpd (v2df, double const *)
21787 int __builtin_ia32_movmskpd (v2df)
21788 int __builtin_ia32_pmovmskb128 (v16qi)
21789 void __builtin_ia32_movnti (int *, int)
21790 void __builtin_ia32_movnti64 (long long int *, long long int)
21791 void __builtin_ia32_movntpd (double *, v2df)
21792 void __builtin_ia32_movntdq (v2df *, v2df)
21793 v4si __builtin_ia32_pshufd (v4si, int)
21794 v8hi __builtin_ia32_pshuflw (v8hi, int)
21795 v8hi __builtin_ia32_pshufhw (v8hi, int)
21796 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
21797 v2df __builtin_ia32_sqrtpd (v2df)
21798 v2df __builtin_ia32_sqrtsd (v2df)
21799 v2df __builtin_ia32_shufpd (v2df, v2df, int)
21800 v2df __builtin_ia32_cvtdq2pd (v4si)
21801 v4sf __builtin_ia32_cvtdq2ps (v4si)
21802 v4si __builtin_ia32_cvtpd2dq (v2df)
21803 v2si __builtin_ia32_cvtpd2pi (v2df)
21804 v4sf __builtin_ia32_cvtpd2ps (v2df)
21805 v4si __builtin_ia32_cvttpd2dq (v2df)
21806 v2si __builtin_ia32_cvttpd2pi (v2df)
21807 v2df __builtin_ia32_cvtpi2pd (v2si)
21808 int __builtin_ia32_cvtsd2si (v2df)
21809 int __builtin_ia32_cvttsd2si (v2df)
21810 long long __builtin_ia32_cvtsd2si64 (v2df)
21811 long long __builtin_ia32_cvttsd2si64 (v2df)
21812 v4si __builtin_ia32_cvtps2dq (v4sf)
21813 v2df __builtin_ia32_cvtps2pd (v4sf)
21814 v4si __builtin_ia32_cvttps2dq (v4sf)
21815 v2df __builtin_ia32_cvtsi2sd (v2df, int)
21816 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
21817 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
21818 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
21819 void __builtin_ia32_clflush (const void *)
21820 void __builtin_ia32_lfence (void)
21821 void __builtin_ia32_mfence (void)
21822 v16qi __builtin_ia32_loaddqu (const char *)
21823 void __builtin_ia32_storedqu (char *, v16qi)
21824 v1di __builtin_ia32_pmuludq (v2si, v2si)
21825 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
21826 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
21827 v4si __builtin_ia32_pslld128 (v4si, v4si)
21828 v2di __builtin_ia32_psllq128 (v2di, v2di)
21829 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
21830 v4si __builtin_ia32_psrld128 (v4si, v4si)
21831 v2di __builtin_ia32_psrlq128 (v2di, v2di)
21832 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
21833 v4si __builtin_ia32_psrad128 (v4si, v4si)
21834 v2di __builtin_ia32_pslldqi128 (v2di, int)
21835 v8hi __builtin_ia32_psllwi128 (v8hi, int)
21836 v4si __builtin_ia32_pslldi128 (v4si, int)
21837 v2di __builtin_ia32_psllqi128 (v2di, int)
21838 v2di __builtin_ia32_psrldqi128 (v2di, int)
21839 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
21840 v4si __builtin_ia32_psrldi128 (v4si, int)
21841 v2di __builtin_ia32_psrlqi128 (v2di, int)
21842 v8hi __builtin_ia32_psrawi128 (v8hi, int)
21843 v4si __builtin_ia32_psradi128 (v4si, int)
21844 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
21845 v2di __builtin_ia32_movq128 (v2di)
21846 @end smallexample
21847
21848 The following built-in functions are available when @option{-msse3} is used.
21849 All of them generate the machine instruction that is part of the name.
21850
21851 @smallexample
21852 v2df __builtin_ia32_addsubpd (v2df, v2df)
21853 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
21854 v2df __builtin_ia32_haddpd (v2df, v2df)
21855 v4sf __builtin_ia32_haddps (v4sf, v4sf)
21856 v2df __builtin_ia32_hsubpd (v2df, v2df)
21857 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
21858 v16qi __builtin_ia32_lddqu (char const *)
21859 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
21860 v4sf __builtin_ia32_movshdup (v4sf)
21861 v4sf __builtin_ia32_movsldup (v4sf)
21862 void __builtin_ia32_mwait (unsigned int, unsigned int)
21863 @end smallexample
21864
21865 The following built-in functions are available when @option{-mssse3} is used.
21866 All of them generate the machine instruction that is part of the name.
21867
21868 @smallexample
21869 v2si __builtin_ia32_phaddd (v2si, v2si)
21870 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
21871 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
21872 v2si __builtin_ia32_phsubd (v2si, v2si)
21873 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
21874 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
21875 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
21876 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
21877 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
21878 v8qi __builtin_ia32_psignb (v8qi, v8qi)
21879 v2si __builtin_ia32_psignd (v2si, v2si)
21880 v4hi __builtin_ia32_psignw (v4hi, v4hi)
21881 v1di __builtin_ia32_palignr (v1di, v1di, int)
21882 v8qi __builtin_ia32_pabsb (v8qi)
21883 v2si __builtin_ia32_pabsd (v2si)
21884 v4hi __builtin_ia32_pabsw (v4hi)
21885 @end smallexample
21886
21887 The following built-in functions are available when @option{-mssse3} is used.
21888 All of them generate the machine instruction that is part of the name.
21889
21890 @smallexample
21891 v4si __builtin_ia32_phaddd128 (v4si, v4si)
21892 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
21893 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
21894 v4si __builtin_ia32_phsubd128 (v4si, v4si)
21895 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
21896 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
21897 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
21898 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
21899 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
21900 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
21901 v4si __builtin_ia32_psignd128 (v4si, v4si)
21902 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
21903 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
21904 v16qi __builtin_ia32_pabsb128 (v16qi)
21905 v4si __builtin_ia32_pabsd128 (v4si)
21906 v8hi __builtin_ia32_pabsw128 (v8hi)
21907 @end smallexample
21908
21909 The following built-in functions are available when @option{-msse4.1} is
21910 used. All of them generate the machine instruction that is part of the
21911 name.
21912
21913 @smallexample
21914 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
21915 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
21916 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
21917 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
21918 v2df __builtin_ia32_dppd (v2df, v2df, const int)
21919 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
21920 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
21921 v2di __builtin_ia32_movntdqa (v2di *);
21922 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
21923 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
21924 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
21925 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
21926 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
21927 v8hi __builtin_ia32_phminposuw128 (v8hi)
21928 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
21929 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
21930 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
21931 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
21932 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
21933 v4si __builtin_ia32_pminsd128 (v4si, v4si)
21934 v4si __builtin_ia32_pminud128 (v4si, v4si)
21935 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
21936 v4si __builtin_ia32_pmovsxbd128 (v16qi)
21937 v2di __builtin_ia32_pmovsxbq128 (v16qi)
21938 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
21939 v2di __builtin_ia32_pmovsxdq128 (v4si)
21940 v4si __builtin_ia32_pmovsxwd128 (v8hi)
21941 v2di __builtin_ia32_pmovsxwq128 (v8hi)
21942 v4si __builtin_ia32_pmovzxbd128 (v16qi)
21943 v2di __builtin_ia32_pmovzxbq128 (v16qi)
21944 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
21945 v2di __builtin_ia32_pmovzxdq128 (v4si)
21946 v4si __builtin_ia32_pmovzxwd128 (v8hi)
21947 v2di __builtin_ia32_pmovzxwq128 (v8hi)
21948 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
21949 v4si __builtin_ia32_pmulld128 (v4si, v4si)
21950 int __builtin_ia32_ptestc128 (v2di, v2di)
21951 int __builtin_ia32_ptestnzc128 (v2di, v2di)
21952 int __builtin_ia32_ptestz128 (v2di, v2di)
21953 v2df __builtin_ia32_roundpd (v2df, const int)
21954 v4sf __builtin_ia32_roundps (v4sf, const int)
21955 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
21956 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
21957 @end smallexample
21958
21959 The following built-in functions are available when @option{-msse4.1} is
21960 used.
21961
21962 @table @code
21963 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
21964 Generates the @code{insertps} machine instruction.
21965 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
21966 Generates the @code{pextrb} machine instruction.
21967 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
21968 Generates the @code{pinsrb} machine instruction.
21969 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
21970 Generates the @code{pinsrd} machine instruction.
21971 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
21972 Generates the @code{pinsrq} machine instruction in 64bit mode.
21973 @end table
21974
21975 The following built-in functions are changed to generate new SSE4.1
21976 instructions when @option{-msse4.1} is used.
21977
21978 @table @code
21979 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
21980 Generates the @code{extractps} machine instruction.
21981 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
21982 Generates the @code{pextrd} machine instruction.
21983 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
21984 Generates the @code{pextrq} machine instruction in 64bit mode.
21985 @end table
21986
21987 The following built-in functions are available when @option{-msse4.2} is
21988 used. All of them generate the machine instruction that is part of the
21989 name.
21990
21991 @smallexample
21992 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
21993 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
21994 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
21995 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
21996 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
21997 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
21998 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
21999 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
22000 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
22001 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
22002 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
22003 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
22004 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
22005 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
22006 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
22007 @end smallexample
22008
22009 The following built-in functions are available when @option{-msse4.2} is
22010 used.
22011
22012 @table @code
22013 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
22014 Generates the @code{crc32b} machine instruction.
22015 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
22016 Generates the @code{crc32w} machine instruction.
22017 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
22018 Generates the @code{crc32l} machine instruction.
22019 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
22020 Generates the @code{crc32q} machine instruction.
22021 @end table
22022
22023 The following built-in functions are changed to generate new SSE4.2
22024 instructions when @option{-msse4.2} is used.
22025
22026 @table @code
22027 @item int __builtin_popcount (unsigned int)
22028 Generates the @code{popcntl} machine instruction.
22029 @item int __builtin_popcountl (unsigned long)
22030 Generates the @code{popcntl} or @code{popcntq} machine instruction,
22031 depending on the size of @code{unsigned long}.
22032 @item int __builtin_popcountll (unsigned long long)
22033 Generates the @code{popcntq} machine instruction.
22034 @end table
22035
22036 The following built-in functions are available when @option{-mavx} is
22037 used. All of them generate the machine instruction that is part of the
22038 name.
22039
22040 @smallexample
22041 v4df __builtin_ia32_addpd256 (v4df,v4df)
22042 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
22043 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
22044 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
22045 v4df __builtin_ia32_andnpd256 (v4df,v4df)
22046 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
22047 v4df __builtin_ia32_andpd256 (v4df,v4df)
22048 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
22049 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
22050 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
22051 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
22052 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
22053 v2df __builtin_ia32_cmppd (v2df,v2df,int)
22054 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
22055 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
22056 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
22057 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
22058 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
22059 v4df __builtin_ia32_cvtdq2pd256 (v4si)
22060 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
22061 v4si __builtin_ia32_cvtpd2dq256 (v4df)
22062 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
22063 v8si __builtin_ia32_cvtps2dq256 (v8sf)
22064 v4df __builtin_ia32_cvtps2pd256 (v4sf)
22065 v4si __builtin_ia32_cvttpd2dq256 (v4df)
22066 v8si __builtin_ia32_cvttps2dq256 (v8sf)
22067 v4df __builtin_ia32_divpd256 (v4df,v4df)
22068 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
22069 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
22070 v4df __builtin_ia32_haddpd256 (v4df,v4df)
22071 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
22072 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
22073 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
22074 v32qi __builtin_ia32_lddqu256 (pcchar)
22075 v32qi __builtin_ia32_loaddqu256 (pcchar)
22076 v4df __builtin_ia32_loadupd256 (pcdouble)
22077 v8sf __builtin_ia32_loadups256 (pcfloat)
22078 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
22079 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
22080 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
22081 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
22082 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
22083 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
22084 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
22085 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
22086 v4df __builtin_ia32_maxpd256 (v4df,v4df)
22087 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
22088 v4df __builtin_ia32_minpd256 (v4df,v4df)
22089 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
22090 v4df __builtin_ia32_movddup256 (v4df)
22091 int __builtin_ia32_movmskpd256 (v4df)
22092 int __builtin_ia32_movmskps256 (v8sf)
22093 v8sf __builtin_ia32_movshdup256 (v8sf)
22094 v8sf __builtin_ia32_movsldup256 (v8sf)
22095 v4df __builtin_ia32_mulpd256 (v4df,v4df)
22096 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
22097 v4df __builtin_ia32_orpd256 (v4df,v4df)
22098 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
22099 v2df __builtin_ia32_pd_pd256 (v4df)
22100 v4df __builtin_ia32_pd256_pd (v2df)
22101 v4sf __builtin_ia32_ps_ps256 (v8sf)
22102 v8sf __builtin_ia32_ps256_ps (v4sf)
22103 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
22104 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
22105 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
22106 v8sf __builtin_ia32_rcpps256 (v8sf)
22107 v4df __builtin_ia32_roundpd256 (v4df,int)
22108 v8sf __builtin_ia32_roundps256 (v8sf,int)
22109 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
22110 v8sf __builtin_ia32_rsqrtps256 (v8sf)
22111 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
22112 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
22113 v4si __builtin_ia32_si_si256 (v8si)
22114 v8si __builtin_ia32_si256_si (v4si)
22115 v4df __builtin_ia32_sqrtpd256 (v4df)
22116 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
22117 v8sf __builtin_ia32_sqrtps256 (v8sf)
22118 void __builtin_ia32_storedqu256 (pchar,v32qi)
22119 void __builtin_ia32_storeupd256 (pdouble,v4df)
22120 void __builtin_ia32_storeups256 (pfloat,v8sf)
22121 v4df __builtin_ia32_subpd256 (v4df,v4df)
22122 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
22123 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
22124 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
22125 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
22126 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
22127 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
22128 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
22129 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
22130 v4sf __builtin_ia32_vbroadcastss (pcfloat)
22131 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
22132 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
22133 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
22134 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
22135 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
22136 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
22137 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
22138 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
22139 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
22140 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
22141 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
22142 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
22143 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
22144 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
22145 v2df __builtin_ia32_vpermilpd (v2df,int)
22146 v4df __builtin_ia32_vpermilpd256 (v4df,int)
22147 v4sf __builtin_ia32_vpermilps (v4sf,int)
22148 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
22149 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
22150 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
22151 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
22152 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
22153 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
22154 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
22155 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
22156 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
22157 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
22158 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
22159 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
22160 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
22161 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
22162 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
22163 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
22164 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
22165 void __builtin_ia32_vzeroall (void)
22166 void __builtin_ia32_vzeroupper (void)
22167 v4df __builtin_ia32_xorpd256 (v4df,v4df)
22168 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
22169 @end smallexample
22170
22171 The following built-in functions are available when @option{-mavx2} is
22172 used. All of them generate the machine instruction that is part of the
22173 name.
22174
22175 @smallexample
22176 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
22177 v32qi __builtin_ia32_pabsb256 (v32qi)
22178 v16hi __builtin_ia32_pabsw256 (v16hi)
22179 v8si __builtin_ia32_pabsd256 (v8si)
22180 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
22181 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
22182 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
22183 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
22184 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
22185 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
22186 v8si __builtin_ia32_paddd256 (v8si,v8si)
22187 v4di __builtin_ia32_paddq256 (v4di,v4di)
22188 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
22189 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
22190 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
22191 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
22192 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
22193 v4di __builtin_ia32_andsi256 (v4di,v4di)
22194 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
22195 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
22196 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
22197 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
22198 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
22199 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
22200 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
22201 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
22202 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
22203 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
22204 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
22205 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
22206 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
22207 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
22208 v8si __builtin_ia32_phaddd256 (v8si,v8si)
22209 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
22210 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
22211 v8si __builtin_ia32_phsubd256 (v8si,v8si)
22212 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
22213 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
22214 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
22215 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
22216 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
22217 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
22218 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
22219 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
22220 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
22221 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
22222 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
22223 v8si __builtin_ia32_pminsd256 (v8si,v8si)
22224 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
22225 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
22226 v8si __builtin_ia32_pminud256 (v8si,v8si)
22227 int __builtin_ia32_pmovmskb256 (v32qi)
22228 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
22229 v8si __builtin_ia32_pmovsxbd256 (v16qi)
22230 v4di __builtin_ia32_pmovsxbq256 (v16qi)
22231 v8si __builtin_ia32_pmovsxwd256 (v8hi)
22232 v4di __builtin_ia32_pmovsxwq256 (v8hi)
22233 v4di __builtin_ia32_pmovsxdq256 (v4si)
22234 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
22235 v8si __builtin_ia32_pmovzxbd256 (v16qi)
22236 v4di __builtin_ia32_pmovzxbq256 (v16qi)
22237 v8si __builtin_ia32_pmovzxwd256 (v8hi)
22238 v4di __builtin_ia32_pmovzxwq256 (v8hi)
22239 v4di __builtin_ia32_pmovzxdq256 (v4si)
22240 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
22241 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
22242 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
22243 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
22244 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
22245 v8si __builtin_ia32_pmulld256 (v8si,v8si)
22246 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
22247 v4di __builtin_ia32_por256 (v4di,v4di)
22248 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
22249 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
22250 v8si __builtin_ia32_pshufd256 (v8si,int)
22251 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
22252 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
22253 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
22254 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
22255 v8si __builtin_ia32_psignd256 (v8si,v8si)
22256 v4di __builtin_ia32_pslldqi256 (v4di,int)
22257 v16hi __builtin_ia32_psllwi256 (16hi,int)
22258 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
22259 v8si __builtin_ia32_pslldi256 (v8si,int)
22260 v8si __builtin_ia32_pslld256(v8si,v4si)
22261 v4di __builtin_ia32_psllqi256 (v4di,int)
22262 v4di __builtin_ia32_psllq256(v4di,v2di)
22263 v16hi __builtin_ia32_psrawi256 (v16hi,int)
22264 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
22265 v8si __builtin_ia32_psradi256 (v8si,int)
22266 v8si __builtin_ia32_psrad256 (v8si,v4si)
22267 v4di __builtin_ia32_psrldqi256 (v4di, int)
22268 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
22269 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
22270 v8si __builtin_ia32_psrldi256 (v8si,int)
22271 v8si __builtin_ia32_psrld256 (v8si,v4si)
22272 v4di __builtin_ia32_psrlqi256 (v4di,int)
22273 v4di __builtin_ia32_psrlq256(v4di,v2di)
22274 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
22275 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
22276 v8si __builtin_ia32_psubd256 (v8si,v8si)
22277 v4di __builtin_ia32_psubq256 (v4di,v4di)
22278 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
22279 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
22280 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
22281 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
22282 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
22283 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
22284 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
22285 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
22286 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
22287 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
22288 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
22289 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
22290 v4di __builtin_ia32_pxor256 (v4di,v4di)
22291 v4di __builtin_ia32_movntdqa256 (pv4di)
22292 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
22293 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
22294 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
22295 v4di __builtin_ia32_vbroadcastsi256 (v2di)
22296 v4si __builtin_ia32_pblendd128 (v4si,v4si)
22297 v8si __builtin_ia32_pblendd256 (v8si,v8si)
22298 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
22299 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
22300 v8si __builtin_ia32_pbroadcastd256 (v4si)
22301 v4di __builtin_ia32_pbroadcastq256 (v2di)
22302 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
22303 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
22304 v4si __builtin_ia32_pbroadcastd128 (v4si)
22305 v2di __builtin_ia32_pbroadcastq128 (v2di)
22306 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
22307 v4df __builtin_ia32_permdf256 (v4df,int)
22308 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
22309 v4di __builtin_ia32_permdi256 (v4di,int)
22310 v4di __builtin_ia32_permti256 (v4di,v4di,int)
22311 v4di __builtin_ia32_extract128i256 (v4di,int)
22312 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
22313 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
22314 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
22315 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
22316 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
22317 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
22318 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
22319 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
22320 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
22321 v8si __builtin_ia32_psllv8si (v8si,v8si)
22322 v4si __builtin_ia32_psllv4si (v4si,v4si)
22323 v4di __builtin_ia32_psllv4di (v4di,v4di)
22324 v2di __builtin_ia32_psllv2di (v2di,v2di)
22325 v8si __builtin_ia32_psrav8si (v8si,v8si)
22326 v4si __builtin_ia32_psrav4si (v4si,v4si)
22327 v8si __builtin_ia32_psrlv8si (v8si,v8si)
22328 v4si __builtin_ia32_psrlv4si (v4si,v4si)
22329 v4di __builtin_ia32_psrlv4di (v4di,v4di)
22330 v2di __builtin_ia32_psrlv2di (v2di,v2di)
22331 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
22332 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
22333 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
22334 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
22335 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
22336 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
22337 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
22338 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
22339 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
22340 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
22341 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
22342 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
22343 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
22344 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
22345 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
22346 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
22347 @end smallexample
22348
22349 The following built-in functions are available when @option{-maes} is
22350 used. All of them generate the machine instruction that is part of the
22351 name.
22352
22353 @smallexample
22354 v2di __builtin_ia32_aesenc128 (v2di, v2di)
22355 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
22356 v2di __builtin_ia32_aesdec128 (v2di, v2di)
22357 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
22358 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
22359 v2di __builtin_ia32_aesimc128 (v2di)
22360 @end smallexample
22361
22362 The following built-in function is available when @option{-mpclmul} is
22363 used.
22364
22365 @table @code
22366 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
22367 Generates the @code{pclmulqdq} machine instruction.
22368 @end table
22369
22370 The following built-in function is available when @option{-mfsgsbase} is
22371 used. All of them generate the machine instruction that is part of the
22372 name.
22373
22374 @smallexample
22375 unsigned int __builtin_ia32_rdfsbase32 (void)
22376 unsigned long long __builtin_ia32_rdfsbase64 (void)
22377 unsigned int __builtin_ia32_rdgsbase32 (void)
22378 unsigned long long __builtin_ia32_rdgsbase64 (void)
22379 void _writefsbase_u32 (unsigned int)
22380 void _writefsbase_u64 (unsigned long long)
22381 void _writegsbase_u32 (unsigned int)
22382 void _writegsbase_u64 (unsigned long long)
22383 @end smallexample
22384
22385 The following built-in function is available when @option{-mrdrnd} is
22386 used. All of them generate the machine instruction that is part of the
22387 name.
22388
22389 @smallexample
22390 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
22391 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
22392 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
22393 @end smallexample
22394
22395 The following built-in function is available when @option{-mptwrite} is
22396 used. All of them generate the machine instruction that is part of the
22397 name.
22398
22399 @smallexample
22400 void __builtin_ia32_ptwrite32 (unsigned)
22401 void __builtin_ia32_ptwrite64 (unsigned long long)
22402 @end smallexample
22403
22404 The following built-in functions are available when @option{-msse4a} is used.
22405 All of them generate the machine instruction that is part of the name.
22406
22407 @smallexample
22408 void __builtin_ia32_movntsd (double *, v2df)
22409 void __builtin_ia32_movntss (float *, v4sf)
22410 v2di __builtin_ia32_extrq (v2di, v16qi)
22411 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
22412 v2di __builtin_ia32_insertq (v2di, v2di)
22413 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
22414 @end smallexample
22415
22416 The following built-in functions are available when @option{-mxop} is used.
22417 @smallexample
22418 v2df __builtin_ia32_vfrczpd (v2df)
22419 v4sf __builtin_ia32_vfrczps (v4sf)
22420 v2df __builtin_ia32_vfrczsd (v2df)
22421 v4sf __builtin_ia32_vfrczss (v4sf)
22422 v4df __builtin_ia32_vfrczpd256 (v4df)
22423 v8sf __builtin_ia32_vfrczps256 (v8sf)
22424 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
22425 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
22426 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
22427 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
22428 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
22429 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
22430 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
22431 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
22432 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
22433 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
22434 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
22435 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
22436 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
22437 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
22438 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
22439 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
22440 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
22441 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
22442 v4si __builtin_ia32_vpcomequd (v4si, v4si)
22443 v2di __builtin_ia32_vpcomequq (v2di, v2di)
22444 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
22445 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
22446 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
22447 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
22448 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
22449 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
22450 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
22451 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
22452 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
22453 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
22454 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
22455 v4si __builtin_ia32_vpcomged (v4si, v4si)
22456 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
22457 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
22458 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
22459 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
22460 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
22461 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
22462 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
22463 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
22464 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
22465 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
22466 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
22467 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
22468 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
22469 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
22470 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
22471 v4si __builtin_ia32_vpcomled (v4si, v4si)
22472 v2di __builtin_ia32_vpcomleq (v2di, v2di)
22473 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
22474 v4si __builtin_ia32_vpcomleud (v4si, v4si)
22475 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
22476 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
22477 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
22478 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
22479 v4si __builtin_ia32_vpcomltd (v4si, v4si)
22480 v2di __builtin_ia32_vpcomltq (v2di, v2di)
22481 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
22482 v4si __builtin_ia32_vpcomltud (v4si, v4si)
22483 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
22484 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
22485 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
22486 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
22487 v4si __builtin_ia32_vpcomned (v4si, v4si)
22488 v2di __builtin_ia32_vpcomneq (v2di, v2di)
22489 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
22490 v4si __builtin_ia32_vpcomneud (v4si, v4si)
22491 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
22492 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
22493 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
22494 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
22495 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
22496 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
22497 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
22498 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
22499 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
22500 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
22501 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
22502 v4si __builtin_ia32_vphaddbd (v16qi)
22503 v2di __builtin_ia32_vphaddbq (v16qi)
22504 v8hi __builtin_ia32_vphaddbw (v16qi)
22505 v2di __builtin_ia32_vphadddq (v4si)
22506 v4si __builtin_ia32_vphaddubd (v16qi)
22507 v2di __builtin_ia32_vphaddubq (v16qi)
22508 v8hi __builtin_ia32_vphaddubw (v16qi)
22509 v2di __builtin_ia32_vphaddudq (v4si)
22510 v4si __builtin_ia32_vphadduwd (v8hi)
22511 v2di __builtin_ia32_vphadduwq (v8hi)
22512 v4si __builtin_ia32_vphaddwd (v8hi)
22513 v2di __builtin_ia32_vphaddwq (v8hi)
22514 v8hi __builtin_ia32_vphsubbw (v16qi)
22515 v2di __builtin_ia32_vphsubdq (v4si)
22516 v4si __builtin_ia32_vphsubwd (v8hi)
22517 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
22518 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
22519 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
22520 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
22521 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
22522 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
22523 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
22524 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
22525 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
22526 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
22527 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
22528 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
22529 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
22530 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
22531 v4si __builtin_ia32_vprotd (v4si, v4si)
22532 v2di __builtin_ia32_vprotq (v2di, v2di)
22533 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
22534 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
22535 v4si __builtin_ia32_vpshad (v4si, v4si)
22536 v2di __builtin_ia32_vpshaq (v2di, v2di)
22537 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
22538 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
22539 v4si __builtin_ia32_vpshld (v4si, v4si)
22540 v2di __builtin_ia32_vpshlq (v2di, v2di)
22541 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
22542 @end smallexample
22543
22544 The following built-in functions are available when @option{-mfma4} is used.
22545 All of them generate the machine instruction that is part of the name.
22546
22547 @smallexample
22548 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
22549 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
22550 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
22551 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
22552 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
22553 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
22554 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
22555 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
22556 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
22557 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
22558 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
22559 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
22560 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
22561 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
22562 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
22563 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
22564 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
22565 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
22566 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
22567 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
22568 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
22569 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
22570 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
22571 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
22572 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
22573 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
22574 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
22575 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
22576 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
22577 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
22578 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
22579 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
22580
22581 @end smallexample
22582
22583 The following built-in functions are available when @option{-mlwp} is used.
22584
22585 @smallexample
22586 void __builtin_ia32_llwpcb16 (void *);
22587 void __builtin_ia32_llwpcb32 (void *);
22588 void __builtin_ia32_llwpcb64 (void *);
22589 void * __builtin_ia32_llwpcb16 (void);
22590 void * __builtin_ia32_llwpcb32 (void);
22591 void * __builtin_ia32_llwpcb64 (void);
22592 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
22593 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
22594 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
22595 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
22596 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
22597 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
22598 @end smallexample
22599
22600 The following built-in functions are available when @option{-mbmi} is used.
22601 All of them generate the machine instruction that is part of the name.
22602 @smallexample
22603 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
22604 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
22605 @end smallexample
22606
22607 The following built-in functions are available when @option{-mbmi2} is used.
22608 All of them generate the machine instruction that is part of the name.
22609 @smallexample
22610 unsigned int _bzhi_u32 (unsigned int, unsigned int)
22611 unsigned int _pdep_u32 (unsigned int, unsigned int)
22612 unsigned int _pext_u32 (unsigned int, unsigned int)
22613 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
22614 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
22615 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
22616 @end smallexample
22617
22618 The following built-in functions are available when @option{-mlzcnt} is used.
22619 All of them generate the machine instruction that is part of the name.
22620 @smallexample
22621 unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
22622 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
22623 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
22624 @end smallexample
22625
22626 The following built-in functions are available when @option{-mfxsr} is used.
22627 All of them generate the machine instruction that is part of the name.
22628 @smallexample
22629 void __builtin_ia32_fxsave (void *)
22630 void __builtin_ia32_fxrstor (void *)
22631 void __builtin_ia32_fxsave64 (void *)
22632 void __builtin_ia32_fxrstor64 (void *)
22633 @end smallexample
22634
22635 The following built-in functions are available when @option{-mxsave} is used.
22636 All of them generate the machine instruction that is part of the name.
22637 @smallexample
22638 void __builtin_ia32_xsave (void *, long long)
22639 void __builtin_ia32_xrstor (void *, long long)
22640 void __builtin_ia32_xsave64 (void *, long long)
22641 void __builtin_ia32_xrstor64 (void *, long long)
22642 @end smallexample
22643
22644 The following built-in functions are available when @option{-mxsaveopt} is used.
22645 All of them generate the machine instruction that is part of the name.
22646 @smallexample
22647 void __builtin_ia32_xsaveopt (void *, long long)
22648 void __builtin_ia32_xsaveopt64 (void *, long long)
22649 @end smallexample
22650
22651 The following built-in functions are available when @option{-mtbm} is used.
22652 Both of them generate the immediate form of the bextr machine instruction.
22653 @smallexample
22654 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
22655 const unsigned int);
22656 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
22657 const unsigned long long);
22658 @end smallexample
22659
22660
22661 The following built-in functions are available when @option{-m3dnow} is used.
22662 All of them generate the machine instruction that is part of the name.
22663
22664 @smallexample
22665 void __builtin_ia32_femms (void)
22666 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
22667 v2si __builtin_ia32_pf2id (v2sf)
22668 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
22669 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
22670 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
22671 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
22672 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
22673 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
22674 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
22675 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
22676 v2sf __builtin_ia32_pfrcp (v2sf)
22677 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
22678 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
22679 v2sf __builtin_ia32_pfrsqrt (v2sf)
22680 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
22681 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
22682 v2sf __builtin_ia32_pi2fd (v2si)
22683 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
22684 @end smallexample
22685
22686 The following built-in functions are available when @option{-m3dnowa} is used.
22687 All of them generate the machine instruction that is part of the name.
22688
22689 @smallexample
22690 v2si __builtin_ia32_pf2iw (v2sf)
22691 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
22692 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
22693 v2sf __builtin_ia32_pi2fw (v2si)
22694 v2sf __builtin_ia32_pswapdsf (v2sf)
22695 v2si __builtin_ia32_pswapdsi (v2si)
22696 @end smallexample
22697
22698 The following built-in functions are available when @option{-mrtm} is used
22699 They are used for restricted transactional memory. These are the internal
22700 low level functions. Normally the functions in
22701 @ref{x86 transactional memory intrinsics} should be used instead.
22702
22703 @smallexample
22704 int __builtin_ia32_xbegin ()
22705 void __builtin_ia32_xend ()
22706 void __builtin_ia32_xabort (status)
22707 int __builtin_ia32_xtest ()
22708 @end smallexample
22709
22710 The following built-in functions are available when @option{-mmwaitx} is used.
22711 All of them generate the machine instruction that is part of the name.
22712 @smallexample
22713 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
22714 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
22715 @end smallexample
22716
22717 The following built-in functions are available when @option{-mclzero} is used.
22718 All of them generate the machine instruction that is part of the name.
22719 @smallexample
22720 void __builtin_i32_clzero (void *)
22721 @end smallexample
22722
22723 The following built-in functions are available when @option{-mpku} is used.
22724 They generate reads and writes to PKRU.
22725 @smallexample
22726 void __builtin_ia32_wrpkru (unsigned int)
22727 unsigned int __builtin_ia32_rdpkru ()
22728 @end smallexample
22729
22730 The following built-in functions are available when @option{-mcet} or
22731 @option{-mshstk} option is used. They support shadow stack
22732 machine instructions from Intel Control-flow Enforcement Technology (CET).
22733 Each built-in function generates the machine instruction that is part
22734 of the function's name. These are the internal low-level functions.
22735 Normally the functions in @ref{x86 control-flow protection intrinsics}
22736 should be used instead.
22737
22738 @smallexample
22739 unsigned int __builtin_ia32_rdsspd (void)
22740 unsigned long long __builtin_ia32_rdsspq (void)
22741 void __builtin_ia32_incsspd (unsigned int)
22742 void __builtin_ia32_incsspq (unsigned long long)
22743 void __builtin_ia32_saveprevssp(void);
22744 void __builtin_ia32_rstorssp(void *);
22745 void __builtin_ia32_wrssd(unsigned int, void *);
22746 void __builtin_ia32_wrssq(unsigned long long, void *);
22747 void __builtin_ia32_wrussd(unsigned int, void *);
22748 void __builtin_ia32_wrussq(unsigned long long, void *);
22749 void __builtin_ia32_setssbsy(void);
22750 void __builtin_ia32_clrssbsy(void *);
22751 @end smallexample
22752
22753 @node x86 transactional memory intrinsics
22754 @subsection x86 Transactional Memory Intrinsics
22755
22756 These hardware transactional memory intrinsics for x86 allow you to use
22757 memory transactions with RTM (Restricted Transactional Memory).
22758 This support is enabled with the @option{-mrtm} option.
22759 For using HLE (Hardware Lock Elision) see
22760 @ref{x86 specific memory model extensions for transactional memory} instead.
22761
22762 A memory transaction commits all changes to memory in an atomic way,
22763 as visible to other threads. If the transaction fails it is rolled back
22764 and all side effects discarded.
22765
22766 Generally there is no guarantee that a memory transaction ever succeeds
22767 and suitable fallback code always needs to be supplied.
22768
22769 @deftypefn {RTM Function} {unsigned} _xbegin ()
22770 Start a RTM (Restricted Transactional Memory) transaction.
22771 Returns @code{_XBEGIN_STARTED} when the transaction
22772 started successfully (note this is not 0, so the constant has to be
22773 explicitly tested).
22774
22775 If the transaction aborts, all side effects
22776 are undone and an abort code encoded as a bit mask is returned.
22777 The following macros are defined:
22778
22779 @table @code
22780 @item _XABORT_EXPLICIT
22781 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
22782 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
22783 @item _XABORT_RETRY
22784 Transaction retry is possible.
22785 @item _XABORT_CONFLICT
22786 Transaction abort due to a memory conflict with another thread.
22787 @item _XABORT_CAPACITY
22788 Transaction abort due to the transaction using too much memory.
22789 @item _XABORT_DEBUG
22790 Transaction abort due to a debug trap.
22791 @item _XABORT_NESTED
22792 Transaction abort in an inner nested transaction.
22793 @end table
22794
22795 There is no guarantee
22796 any transaction ever succeeds, so there always needs to be a valid
22797 fallback path.
22798 @end deftypefn
22799
22800 @deftypefn {RTM Function} {void} _xend ()
22801 Commit the current transaction. When no transaction is active this faults.
22802 All memory side effects of the transaction become visible
22803 to other threads in an atomic manner.
22804 @end deftypefn
22805
22806 @deftypefn {RTM Function} {int} _xtest ()
22807 Return a nonzero value if a transaction is currently active, otherwise 0.
22808 @end deftypefn
22809
22810 @deftypefn {RTM Function} {void} _xabort (status)
22811 Abort the current transaction. When no transaction is active this is a no-op.
22812 The @var{status} is an 8-bit constant; its value is encoded in the return
22813 value from @code{_xbegin}.
22814 @end deftypefn
22815
22816 Here is an example showing handling for @code{_XABORT_RETRY}
22817 and a fallback path for other failures:
22818
22819 @smallexample
22820 #include <immintrin.h>
22821
22822 int n_tries, max_tries;
22823 unsigned status = _XABORT_EXPLICIT;
22824 ...
22825
22826 for (n_tries = 0; n_tries < max_tries; n_tries++)
22827 @{
22828 status = _xbegin ();
22829 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
22830 break;
22831 @}
22832 if (status == _XBEGIN_STARTED)
22833 @{
22834 ... transaction code...
22835 _xend ();
22836 @}
22837 else
22838 @{
22839 ... non-transactional fallback path...
22840 @}
22841 @end smallexample
22842
22843 @noindent
22844 Note that, in most cases, the transactional and non-transactional code
22845 must synchronize together to ensure consistency.
22846
22847 @node x86 control-flow protection intrinsics
22848 @subsection x86 Control-Flow Protection Intrinsics
22849
22850 @deftypefn {CET Function} {ret_type} _get_ssp (void)
22851 Get the current value of shadow stack pointer if shadow stack support
22852 from Intel CET is enabled in the hardware or @code{0} otherwise.
22853 The @code{ret_type} is @code{unsigned long long} for 64-bit targets
22854 and @code{unsigned int} for 32-bit targets.
22855 @end deftypefn
22856
22857 @deftypefn {CET Function} void _inc_ssp (unsigned int)
22858 Increment the current shadow stack pointer by the size specified by the
22859 function argument. The argument is masked to a byte value for security
22860 reasons, so to increment by more than 255 bytes you must call the function
22861 multiple times.
22862 @end deftypefn
22863
22864 The shadow stack unwind code looks like:
22865
22866 @smallexample
22867 #include <immintrin.h>
22868
22869 /* Unwind the shadow stack for EH. */
22870 #define _Unwind_Frames_Extra(x) \
22871 do \
22872 @{ \
22873 _Unwind_Word ssp = _get_ssp (); \
22874 if (ssp != 0) \
22875 @{ \
22876 _Unwind_Word tmp = (x); \
22877 while (tmp > 255) \
22878 @{ \
22879 _inc_ssp (tmp); \
22880 tmp -= 255; \
22881 @} \
22882 _inc_ssp (tmp); \
22883 @} \
22884 @} \
22885 while (0)
22886 @end smallexample
22887
22888 @noindent
22889 This code runs unconditionally on all 64-bit processors. For 32-bit
22890 processors the code runs on those that support multi-byte NOP instructions.
22891
22892 @node Target Format Checks
22893 @section Format Checks Specific to Particular Target Machines
22894
22895 For some target machines, GCC supports additional options to the
22896 format attribute
22897 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
22898
22899 @menu
22900 * Solaris Format Checks::
22901 * Darwin Format Checks::
22902 @end menu
22903
22904 @node Solaris Format Checks
22905 @subsection Solaris Format Checks
22906
22907 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
22908 check. @code{cmn_err} accepts a subset of the standard @code{printf}
22909 conversions, and the two-argument @code{%b} conversion for displaying
22910 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
22911
22912 @node Darwin Format Checks
22913 @subsection Darwin Format Checks
22914
22915 In addition to the full set of format archetypes (attribute format style
22916 arguments such as @code{printf}, @code{scanf}, @code{strftime}, and
22917 @code{strfmon}), Darwin targets also support the @code{CFString} (or
22918 @code{__CFString__}) archetype in the @code{format} attribute.
22919 Declarations with this archetype are parsed for correct syntax
22920 and argument types. However, parsing of the format string itself and
22921 validating arguments against it in calls to such functions is currently
22922 not performed.
22923
22924 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
22925 also be used as format arguments. Note that the relevant headers are only likely to be
22926 available on Darwin (OSX) installations. On such installations, the XCode and system
22927 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
22928 associated functions.
22929
22930 @node Pragmas
22931 @section Pragmas Accepted by GCC
22932 @cindex pragmas
22933 @cindex @code{#pragma}
22934
22935 GCC supports several types of pragmas, primarily in order to compile
22936 code originally written for other compilers. Note that in general
22937 we do not recommend the use of pragmas; @xref{Function Attributes},
22938 for further explanation.
22939
22940 The GNU C preprocessor recognizes several pragmas in addition to the
22941 compiler pragmas documented here. Refer to the CPP manual for more
22942 information.
22943
22944 @menu
22945 * AArch64 Pragmas::
22946 * ARM Pragmas::
22947 * M32C Pragmas::
22948 * MeP Pragmas::
22949 * RS/6000 and PowerPC Pragmas::
22950 * S/390 Pragmas::
22951 * Darwin Pragmas::
22952 * Solaris Pragmas::
22953 * Symbol-Renaming Pragmas::
22954 * Structure-Layout Pragmas::
22955 * Weak Pragmas::
22956 * Diagnostic Pragmas::
22957 * Visibility Pragmas::
22958 * Push/Pop Macro Pragmas::
22959 * Function Specific Option Pragmas::
22960 * Loop-Specific Pragmas::
22961 @end menu
22962
22963 @node AArch64 Pragmas
22964 @subsection AArch64 Pragmas
22965
22966 The pragmas defined by the AArch64 target correspond to the AArch64
22967 target function attributes. They can be specified as below:
22968 @smallexample
22969 #pragma GCC target("string")
22970 @end smallexample
22971
22972 where @code{@var{string}} can be any string accepted as an AArch64 target
22973 attribute. @xref{AArch64 Function Attributes}, for more details
22974 on the permissible values of @code{string}.
22975
22976 @node ARM Pragmas
22977 @subsection ARM Pragmas
22978
22979 The ARM target defines pragmas for controlling the default addition of
22980 @code{long_call} and @code{short_call} attributes to functions.
22981 @xref{Function Attributes}, for information about the effects of these
22982 attributes.
22983
22984 @table @code
22985 @item long_calls
22986 @cindex pragma, long_calls
22987 Set all subsequent functions to have the @code{long_call} attribute.
22988
22989 @item no_long_calls
22990 @cindex pragma, no_long_calls
22991 Set all subsequent functions to have the @code{short_call} attribute.
22992
22993 @item long_calls_off
22994 @cindex pragma, long_calls_off
22995 Do not affect the @code{long_call} or @code{short_call} attributes of
22996 subsequent functions.
22997 @end table
22998
22999 @node M32C Pragmas
23000 @subsection M32C Pragmas
23001
23002 @table @code
23003 @item GCC memregs @var{number}
23004 @cindex pragma, memregs
23005 Overrides the command-line option @code{-memregs=} for the current
23006 file. Use with care! This pragma must be before any function in the
23007 file, and mixing different memregs values in different objects may
23008 make them incompatible. This pragma is useful when a
23009 performance-critical function uses a memreg for temporary values,
23010 as it may allow you to reduce the number of memregs used.
23011
23012 @item ADDRESS @var{name} @var{address}
23013 @cindex pragma, address
23014 For any declared symbols matching @var{name}, this does three things
23015 to that symbol: it forces the symbol to be located at the given
23016 address (a number), it forces the symbol to be volatile, and it
23017 changes the symbol's scope to be static. This pragma exists for
23018 compatibility with other compilers, but note that the common
23019 @code{1234H} numeric syntax is not supported (use @code{0x1234}
23020 instead). Example:
23021
23022 @smallexample
23023 #pragma ADDRESS port3 0x103
23024 char port3;
23025 @end smallexample
23026
23027 @end table
23028
23029 @node MeP Pragmas
23030 @subsection MeP Pragmas
23031
23032 @table @code
23033
23034 @item custom io_volatile (on|off)
23035 @cindex pragma, custom io_volatile
23036 Overrides the command-line option @code{-mio-volatile} for the current
23037 file. Note that for compatibility with future GCC releases, this
23038 option should only be used once before any @code{io} variables in each
23039 file.
23040
23041 @item GCC coprocessor available @var{registers}
23042 @cindex pragma, coprocessor available
23043 Specifies which coprocessor registers are available to the register
23044 allocator. @var{registers} may be a single register, register range
23045 separated by ellipses, or comma-separated list of those. Example:
23046
23047 @smallexample
23048 #pragma GCC coprocessor available $c0...$c10, $c28
23049 @end smallexample
23050
23051 @item GCC coprocessor call_saved @var{registers}
23052 @cindex pragma, coprocessor call_saved
23053 Specifies which coprocessor registers are to be saved and restored by
23054 any function using them. @var{registers} may be a single register,
23055 register range separated by ellipses, or comma-separated list of
23056 those. Example:
23057
23058 @smallexample
23059 #pragma GCC coprocessor call_saved $c4...$c6, $c31
23060 @end smallexample
23061
23062 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
23063 @cindex pragma, coprocessor subclass
23064 Creates and defines a register class. These register classes can be
23065 used by inline @code{asm} constructs. @var{registers} may be a single
23066 register, register range separated by ellipses, or comma-separated
23067 list of those. Example:
23068
23069 @smallexample
23070 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
23071
23072 asm ("cpfoo %0" : "=B" (x));
23073 @end smallexample
23074
23075 @item GCC disinterrupt @var{name} , @var{name} @dots{}
23076 @cindex pragma, disinterrupt
23077 For the named functions, the compiler adds code to disable interrupts
23078 for the duration of those functions. If any functions so named
23079 are not encountered in the source, a warning is emitted that the pragma is
23080 not used. Examples:
23081
23082 @smallexample
23083 #pragma disinterrupt foo
23084 #pragma disinterrupt bar, grill
23085 int foo () @{ @dots{} @}
23086 @end smallexample
23087
23088 @item GCC call @var{name} , @var{name} @dots{}
23089 @cindex pragma, call
23090 For the named functions, the compiler always uses a register-indirect
23091 call model when calling the named functions. Examples:
23092
23093 @smallexample
23094 extern int foo ();
23095 #pragma call foo
23096 @end smallexample
23097
23098 @end table
23099
23100 @node RS/6000 and PowerPC Pragmas
23101 @subsection RS/6000 and PowerPC Pragmas
23102
23103 The RS/6000 and PowerPC targets define one pragma for controlling
23104 whether or not the @code{longcall} attribute is added to function
23105 declarations by default. This pragma overrides the @option{-mlongcall}
23106 option, but not the @code{longcall} and @code{shortcall} attributes.
23107 @xref{RS/6000 and PowerPC Options}, for more information about when long
23108 calls are and are not necessary.
23109
23110 @table @code
23111 @item longcall (1)
23112 @cindex pragma, longcall
23113 Apply the @code{longcall} attribute to all subsequent function
23114 declarations.
23115
23116 @item longcall (0)
23117 Do not apply the @code{longcall} attribute to subsequent function
23118 declarations.
23119 @end table
23120
23121 @c Describe h8300 pragmas here.
23122 @c Describe sh pragmas here.
23123 @c Describe v850 pragmas here.
23124
23125 @node S/390 Pragmas
23126 @subsection S/390 Pragmas
23127
23128 The pragmas defined by the S/390 target correspond to the S/390
23129 target function attributes and some the additional options:
23130
23131 @table @samp
23132 @item zvector
23133 @itemx no-zvector
23134 @end table
23135
23136 Note that options of the pragma, unlike options of the target
23137 attribute, do change the value of preprocessor macros like
23138 @code{__VEC__}. They can be specified as below:
23139
23140 @smallexample
23141 #pragma GCC target("string[,string]...")
23142 #pragma GCC target("string"[,"string"]...)
23143 @end smallexample
23144
23145 @node Darwin Pragmas
23146 @subsection Darwin Pragmas
23147
23148 The following pragmas are available for all architectures running the
23149 Darwin operating system. These are useful for compatibility with other
23150 Mac OS compilers.
23151
23152 @table @code
23153 @item mark @var{tokens}@dots{}
23154 @cindex pragma, mark
23155 This pragma is accepted, but has no effect.
23156
23157 @item options align=@var{alignment}
23158 @cindex pragma, options align
23159 This pragma sets the alignment of fields in structures. The values of
23160 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
23161 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
23162 properly; to restore the previous setting, use @code{reset} for the
23163 @var{alignment}.
23164
23165 @item segment @var{tokens}@dots{}
23166 @cindex pragma, segment
23167 This pragma is accepted, but has no effect.
23168
23169 @item unused (@var{var} [, @var{var}]@dots{})
23170 @cindex pragma, unused
23171 This pragma declares variables to be possibly unused. GCC does not
23172 produce warnings for the listed variables. The effect is similar to
23173 that of the @code{unused} attribute, except that this pragma may appear
23174 anywhere within the variables' scopes.
23175 @end table
23176
23177 @node Solaris Pragmas
23178 @subsection Solaris Pragmas
23179
23180 The Solaris target supports @code{#pragma redefine_extname}
23181 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
23182 @code{#pragma} directives for compatibility with the system compiler.
23183
23184 @table @code
23185 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
23186 @cindex pragma, align
23187
23188 Increase the minimum alignment of each @var{variable} to @var{alignment}.
23189 This is the same as GCC's @code{aligned} attribute @pxref{Variable
23190 Attributes}). Macro expansion occurs on the arguments to this pragma
23191 when compiling C and Objective-C@. It does not currently occur when
23192 compiling C++, but this is a bug which may be fixed in a future
23193 release.
23194
23195 @item fini (@var{function} [, @var{function}]...)
23196 @cindex pragma, fini
23197
23198 This pragma causes each listed @var{function} to be called after
23199 main, or during shared module unloading, by adding a call to the
23200 @code{.fini} section.
23201
23202 @item init (@var{function} [, @var{function}]...)
23203 @cindex pragma, init
23204
23205 This pragma causes each listed @var{function} to be called during
23206 initialization (before @code{main}) or during shared module loading, by
23207 adding a call to the @code{.init} section.
23208
23209 @end table
23210
23211 @node Symbol-Renaming Pragmas
23212 @subsection Symbol-Renaming Pragmas
23213
23214 GCC supports a @code{#pragma} directive that changes the name used in
23215 assembly for a given declaration. While this pragma is supported on all
23216 platforms, it is intended primarily to provide compatibility with the
23217 Solaris system headers. This effect can also be achieved using the asm
23218 labels extension (@pxref{Asm Labels}).
23219
23220 @table @code
23221 @item redefine_extname @var{oldname} @var{newname}
23222 @cindex pragma, redefine_extname
23223
23224 This pragma gives the C function @var{oldname} the assembly symbol
23225 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
23226 is defined if this pragma is available (currently on all platforms).
23227 @end table
23228
23229 This pragma and the @code{asm} labels extension interact in a complicated
23230 manner. Here are some corner cases you may want to be aware of:
23231
23232 @enumerate
23233 @item This pragma silently applies only to declarations with external
23234 linkage. The @code{asm} label feature does not have this restriction.
23235
23236 @item In C++, this pragma silently applies only to declarations with
23237 ``C'' linkage. Again, @code{asm} labels do not have this restriction.
23238
23239 @item If either of the ways of changing the assembly name of a
23240 declaration are applied to a declaration whose assembly name has
23241 already been determined (either by a previous use of one of these
23242 features, or because the compiler needed the assembly name in order to
23243 generate code), and the new name is different, a warning issues and
23244 the name does not change.
23245
23246 @item The @var{oldname} used by @code{#pragma redefine_extname} is
23247 always the C-language name.
23248 @end enumerate
23249
23250 @node Structure-Layout Pragmas
23251 @subsection Structure-Layout Pragmas
23252
23253 For compatibility with Microsoft Windows compilers, GCC supports a
23254 set of @code{#pragma} directives that change the maximum alignment of
23255 members of structures (other than zero-width bit-fields), unions, and
23256 classes subsequently defined. The @var{n} value below always is required
23257 to be a small power of two and specifies the new alignment in bytes.
23258
23259 @enumerate
23260 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
23261 @item @code{#pragma pack()} sets the alignment to the one that was in
23262 effect when compilation started (see also command-line option
23263 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
23264 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
23265 setting on an internal stack and then optionally sets the new alignment.
23266 @item @code{#pragma pack(pop)} restores the alignment setting to the one
23267 saved at the top of the internal stack (and removes that stack entry).
23268 Note that @code{#pragma pack([@var{n}])} does not influence this internal
23269 stack; thus it is possible to have @code{#pragma pack(push)} followed by
23270 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
23271 @code{#pragma pack(pop)}.
23272 @end enumerate
23273
23274 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
23275 directive which lays out structures and unions subsequently defined as the
23276 documented @code{__attribute__ ((ms_struct))}.
23277
23278 @enumerate
23279 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
23280 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
23281 @item @code{#pragma ms_struct reset} goes back to the default layout.
23282 @end enumerate
23283
23284 Most targets also support the @code{#pragma scalar_storage_order} directive
23285 which lays out structures and unions subsequently defined as the documented
23286 @code{__attribute__ ((scalar_storage_order))}.
23287
23288 @enumerate
23289 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
23290 of the scalar fields to big-endian.
23291 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
23292 of the scalar fields to little-endian.
23293 @item @code{#pragma scalar_storage_order default} goes back to the endianness
23294 that was in effect when compilation started (see also command-line option
23295 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
23296 @end enumerate
23297
23298 @node Weak Pragmas
23299 @subsection Weak Pragmas
23300
23301 For compatibility with SVR4, GCC supports a set of @code{#pragma}
23302 directives for declaring symbols to be weak, and defining weak
23303 aliases.
23304
23305 @table @code
23306 @item #pragma weak @var{symbol}
23307 @cindex pragma, weak
23308 This pragma declares @var{symbol} to be weak, as if the declaration
23309 had the attribute of the same name. The pragma may appear before
23310 or after the declaration of @var{symbol}. It is not an error for
23311 @var{symbol} to never be defined at all.
23312
23313 @item #pragma weak @var{symbol1} = @var{symbol2}
23314 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
23315 It is an error if @var{symbol2} is not defined in the current
23316 translation unit.
23317 @end table
23318
23319 @node Diagnostic Pragmas
23320 @subsection Diagnostic Pragmas
23321
23322 GCC allows the user to selectively enable or disable certain types of
23323 diagnostics, and change the kind of the diagnostic. For example, a
23324 project's policy might require that all sources compile with
23325 @option{-Werror} but certain files might have exceptions allowing
23326 specific types of warnings. Or, a project might selectively enable
23327 diagnostics and treat them as errors depending on which preprocessor
23328 macros are defined.
23329
23330 @table @code
23331 @item #pragma GCC diagnostic @var{kind} @var{option}
23332 @cindex pragma, diagnostic
23333
23334 Modifies the disposition of a diagnostic. Note that not all
23335 diagnostics are modifiable; at the moment only warnings (normally
23336 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
23337 Use @option{-fdiagnostics-show-option} to determine which diagnostics
23338 are controllable and which option controls them.
23339
23340 @var{kind} is @samp{error} to treat this diagnostic as an error,
23341 @samp{warning} to treat it like a warning (even if @option{-Werror} is
23342 in effect), or @samp{ignored} if the diagnostic is to be ignored.
23343 @var{option} is a double quoted string that matches the command-line
23344 option.
23345
23346 @smallexample
23347 #pragma GCC diagnostic warning "-Wformat"
23348 #pragma GCC diagnostic error "-Wformat"
23349 #pragma GCC diagnostic ignored "-Wformat"
23350 @end smallexample
23351
23352 Note that these pragmas override any command-line options. GCC keeps
23353 track of the location of each pragma, and issues diagnostics according
23354 to the state as of that point in the source file. Thus, pragmas occurring
23355 after a line do not affect diagnostics caused by that line.
23356
23357 @item #pragma GCC diagnostic push
23358 @itemx #pragma GCC diagnostic pop
23359
23360 Causes GCC to remember the state of the diagnostics as of each
23361 @code{push}, and restore to that point at each @code{pop}. If a
23362 @code{pop} has no matching @code{push}, the command-line options are
23363 restored.
23364
23365 @smallexample
23366 #pragma GCC diagnostic error "-Wuninitialized"
23367 foo(a); /* error is given for this one */
23368 #pragma GCC diagnostic push
23369 #pragma GCC diagnostic ignored "-Wuninitialized"
23370 foo(b); /* no diagnostic for this one */
23371 #pragma GCC diagnostic pop
23372 foo(c); /* error is given for this one */
23373 #pragma GCC diagnostic pop
23374 foo(d); /* depends on command-line options */
23375 @end smallexample
23376
23377 @end table
23378
23379 GCC also offers a simple mechanism for printing messages during
23380 compilation.
23381
23382 @table @code
23383 @item #pragma message @var{string}
23384 @cindex pragma, diagnostic
23385
23386 Prints @var{string} as a compiler message on compilation. The message
23387 is informational only, and is neither a compilation warning nor an
23388 error. Newlines can be included in the string by using the @samp{\n}
23389 escape sequence.
23390
23391 @smallexample
23392 #pragma message "Compiling " __FILE__ "..."
23393 @end smallexample
23394
23395 @var{string} may be parenthesized, and is printed with location
23396 information. For example,
23397
23398 @smallexample
23399 #define DO_PRAGMA(x) _Pragma (#x)
23400 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
23401
23402 TODO(Remember to fix this)
23403 @end smallexample
23404
23405 @noindent
23406 prints @samp{/tmp/file.c:4: note: #pragma message:
23407 TODO - Remember to fix this}.
23408
23409 @item #pragma GCC error @var{message}
23410 @cindex pragma, diagnostic
23411 Generates an error message. This pragma @emph{is} considered to
23412 indicate an error in the compilation, and it will be treated as such.
23413
23414 Newlines can be included in the string by using the @samp{\n}
23415 escape sequence. They will be displayed as newlines even if the
23416 @option{-fmessage-length} option is set to zero.
23417
23418 The error is only generated if the pragma is present in the code after
23419 pre-processing has been completed. It does not matter however if the
23420 code containing the pragma is unreachable:
23421
23422 @smallexample
23423 #if 0
23424 #pragma GCC error "this error is not seen"
23425 #endif
23426 void foo (void)
23427 @{
23428 return;
23429 #pragma GCC error "this error is seen"
23430 @}
23431 @end smallexample
23432
23433 @item #pragma GCC warning @var{message}
23434 @cindex pragma, diagnostic
23435 This is just like @samp{pragma GCC error} except that a warning
23436 message is issued instead of an error message. Unless
23437 @option{-Werror} is in effect, in which case this pragma will generate
23438 an error as well.
23439
23440 @end table
23441
23442 @node Visibility Pragmas
23443 @subsection Visibility Pragmas
23444
23445 @table @code
23446 @item #pragma GCC visibility push(@var{visibility})
23447 @itemx #pragma GCC visibility pop
23448 @cindex pragma, visibility
23449
23450 This pragma allows the user to set the visibility for multiple
23451 declarations without having to give each a visibility attribute
23452 (@pxref{Function Attributes}).
23453
23454 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
23455 declarations. Class members and template specializations are not
23456 affected; if you want to override the visibility for a particular
23457 member or instantiation, you must use an attribute.
23458
23459 @end table
23460
23461
23462 @node Push/Pop Macro Pragmas
23463 @subsection Push/Pop Macro Pragmas
23464
23465 For compatibility with Microsoft Windows compilers, GCC supports
23466 @samp{#pragma push_macro(@var{"macro_name"})}
23467 and @samp{#pragma pop_macro(@var{"macro_name"})}.
23468
23469 @table @code
23470 @item #pragma push_macro(@var{"macro_name"})
23471 @cindex pragma, push_macro
23472 This pragma saves the value of the macro named as @var{macro_name} to
23473 the top of the stack for this macro.
23474
23475 @item #pragma pop_macro(@var{"macro_name"})
23476 @cindex pragma, pop_macro
23477 This pragma sets the value of the macro named as @var{macro_name} to
23478 the value on top of the stack for this macro. If the stack for
23479 @var{macro_name} is empty, the value of the macro remains unchanged.
23480 @end table
23481
23482 For example:
23483
23484 @smallexample
23485 #define X 1
23486 #pragma push_macro("X")
23487 #undef X
23488 #define X -1
23489 #pragma pop_macro("X")
23490 int x [X];
23491 @end smallexample
23492
23493 @noindent
23494 In this example, the definition of X as 1 is saved by @code{#pragma
23495 push_macro} and restored by @code{#pragma pop_macro}.
23496
23497 @node Function Specific Option Pragmas
23498 @subsection Function Specific Option Pragmas
23499
23500 @table @code
23501 @item #pragma GCC target (@var{string}, @dots{})
23502 @cindex pragma GCC target
23503
23504 This pragma allows you to set target-specific options for functions
23505 defined later in the source file. One or more strings can be
23506 specified. Each function that is defined after this point is treated
23507 as if it had been declared with one @code{target(}@var{string}@code{)}
23508 attribute for each @var{string} argument. The parentheses around
23509 the strings in the pragma are optional. @xref{Function Attributes},
23510 for more information about the @code{target} attribute and the attribute
23511 syntax.
23512
23513 The @code{#pragma GCC target} pragma is presently implemented for
23514 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
23515
23516 @item #pragma GCC optimize (@var{string}, @dots{})
23517 @cindex pragma GCC optimize
23518
23519 This pragma allows you to set global optimization options for functions
23520 defined later in the source file. One or more strings can be
23521 specified. Each function that is defined after this point is treated
23522 as if it had been declared with one @code{optimize(}@var{string}@code{)}
23523 attribute for each @var{string} argument. The parentheses around
23524 the strings in the pragma are optional. @xref{Function Attributes},
23525 for more information about the @code{optimize} attribute and the attribute
23526 syntax.
23527
23528 @item #pragma GCC push_options
23529 @itemx #pragma GCC pop_options
23530 @cindex pragma GCC push_options
23531 @cindex pragma GCC pop_options
23532
23533 These pragmas maintain a stack of the current target and optimization
23534 options. It is intended for include files where you temporarily want
23535 to switch to using a different @samp{#pragma GCC target} or
23536 @samp{#pragma GCC optimize} and then to pop back to the previous
23537 options.
23538
23539 @item #pragma GCC reset_options
23540 @cindex pragma GCC reset_options
23541
23542 This pragma clears the current @code{#pragma GCC target} and
23543 @code{#pragma GCC optimize} to use the default switches as specified
23544 on the command line.
23545
23546 @end table
23547
23548 @node Loop-Specific Pragmas
23549 @subsection Loop-Specific Pragmas
23550
23551 @table @code
23552 @item #pragma GCC ivdep
23553 @cindex pragma GCC ivdep
23554
23555 With this pragma, the programmer asserts that there are no loop-carried
23556 dependencies which would prevent consecutive iterations of
23557 the following loop from executing concurrently with SIMD
23558 (single instruction multiple data) instructions.
23559
23560 For example, the compiler can only unconditionally vectorize the following
23561 loop with the pragma:
23562
23563 @smallexample
23564 void foo (int n, int *a, int *b, int *c)
23565 @{
23566 int i, j;
23567 #pragma GCC ivdep
23568 for (i = 0; i < n; ++i)
23569 a[i] = b[i] + c[i];
23570 @}
23571 @end smallexample
23572
23573 @noindent
23574 In this example, using the @code{restrict} qualifier had the same
23575 effect. In the following example, that would not be possible. Assume
23576 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
23577 that it can unconditionally vectorize the following loop:
23578
23579 @smallexample
23580 void ignore_vec_dep (int *a, int k, int c, int m)
23581 @{
23582 #pragma GCC ivdep
23583 for (int i = 0; i < m; i++)
23584 a[i] = a[i + k] * c;
23585 @}
23586 @end smallexample
23587
23588 @item #pragma GCC unroll @var{n}
23589 @cindex pragma GCC unroll @var{n}
23590
23591 You can use this pragma to control how many times a loop should be unrolled.
23592 It must be placed immediately before a @code{for}, @code{while} or @code{do}
23593 loop or a @code{#pragma GCC ivdep}, and applies only to the loop that follows.
23594 @var{n} is an integer constant expression specifying the unrolling factor.
23595 The values of @math{0} and @math{1} block any unrolling of the loop.
23596
23597 @end table
23598
23599 @node Unnamed Fields
23600 @section Unnamed Structure and Union Fields
23601 @cindex @code{struct}
23602 @cindex @code{union}
23603
23604 As permitted by ISO C11 and for compatibility with other compilers,
23605 GCC allows you to define
23606 a structure or union that contains, as fields, structures and unions
23607 without names. For example:
23608
23609 @smallexample
23610 struct @{
23611 int a;
23612 union @{
23613 int b;
23614 float c;
23615 @};
23616 int d;
23617 @} foo;
23618 @end smallexample
23619
23620 @noindent
23621 In this example, you are able to access members of the unnamed
23622 union with code like @samp{foo.b}. Note that only unnamed structs and
23623 unions are allowed, you may not have, for example, an unnamed
23624 @code{int}.
23625
23626 You must never create such structures that cause ambiguous field definitions.
23627 For example, in this structure:
23628
23629 @smallexample
23630 struct @{
23631 int a;
23632 struct @{
23633 int a;
23634 @};
23635 @} foo;
23636 @end smallexample
23637
23638 @noindent
23639 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
23640 The compiler gives errors for such constructs.
23641
23642 @opindex fms-extensions
23643 Unless @option{-fms-extensions} is used, the unnamed field must be a
23644 structure or union definition without a tag (for example, @samp{struct
23645 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
23646 also be a definition with a tag such as @samp{struct foo @{ int a;
23647 @};}, a reference to a previously defined structure or union such as
23648 @samp{struct foo;}, or a reference to a @code{typedef} name for a
23649 previously defined structure or union type.
23650
23651 @opindex fplan9-extensions
23652 The option @option{-fplan9-extensions} enables
23653 @option{-fms-extensions} as well as two other extensions. First, a
23654 pointer to a structure is automatically converted to a pointer to an
23655 anonymous field for assignments and function calls. For example:
23656
23657 @smallexample
23658 struct s1 @{ int a; @};
23659 struct s2 @{ struct s1; @};
23660 extern void f1 (struct s1 *);
23661 void f2 (struct s2 *p) @{ f1 (p); @}
23662 @end smallexample
23663
23664 @noindent
23665 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
23666 converted into a pointer to the anonymous field.
23667
23668 Second, when the type of an anonymous field is a @code{typedef} for a
23669 @code{struct} or @code{union}, code may refer to the field using the
23670 name of the @code{typedef}.
23671
23672 @smallexample
23673 typedef struct @{ int a; @} s1;
23674 struct s2 @{ s1; @};
23675 s1 f1 (struct s2 *p) @{ return p->s1; @}
23676 @end smallexample
23677
23678 These usages are only permitted when they are not ambiguous.
23679
23680 @node Thread-Local
23681 @section Thread-Local Storage
23682 @cindex Thread-Local Storage
23683 @cindex @acronym{TLS}
23684 @cindex @code{__thread}
23685
23686 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
23687 are allocated such that there is one instance of the variable per extant
23688 thread. The runtime model GCC uses to implement this originates
23689 in the IA-64 processor-specific ABI, but has since been migrated
23690 to other processors as well. It requires significant support from
23691 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
23692 system libraries (@file{libc.so} and @file{libpthread.so}), so it
23693 is not available everywhere.
23694
23695 At the user level, the extension is visible with a new storage
23696 class keyword: @code{__thread}. For example:
23697
23698 @smallexample
23699 __thread int i;
23700 extern __thread struct state s;
23701 static __thread char *p;
23702 @end smallexample
23703
23704 The @code{__thread} specifier may be used alone, with the @code{extern}
23705 or @code{static} specifiers, but with no other storage class specifier.
23706 When used with @code{extern} or @code{static}, @code{__thread} must appear
23707 immediately after the other storage class specifier.
23708
23709 The @code{__thread} specifier may be applied to any global, file-scoped
23710 static, function-scoped static, or static data member of a class. It may
23711 not be applied to block-scoped automatic or non-static data member.
23712
23713 When the address-of operator is applied to a thread-local variable, it is
23714 evaluated at run time and returns the address of the current thread's
23715 instance of that variable. An address so obtained may be used by any
23716 thread. When a thread terminates, any pointers to thread-local variables
23717 in that thread become invalid.
23718
23719 No static initialization may refer to the address of a thread-local variable.
23720
23721 In C++, if an initializer is present for a thread-local variable, it must
23722 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
23723 standard.
23724
23725 See @uref{https://www.akkadia.org/drepper/tls.pdf,
23726 ELF Handling For Thread-Local Storage} for a detailed explanation of
23727 the four thread-local storage addressing models, and how the runtime
23728 is expected to function.
23729
23730 @menu
23731 * C99 Thread-Local Edits::
23732 * C++98 Thread-Local Edits::
23733 @end menu
23734
23735 @node C99 Thread-Local Edits
23736 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
23737
23738 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
23739 that document the exact semantics of the language extension.
23740
23741 @itemize @bullet
23742 @item
23743 @cite{5.1.2 Execution environments}
23744
23745 Add new text after paragraph 1
23746
23747 @quotation
23748 Within either execution environment, a @dfn{thread} is a flow of
23749 control within a program. It is implementation defined whether
23750 or not there may be more than one thread associated with a program.
23751 It is implementation defined how threads beyond the first are
23752 created, the name and type of the function called at thread
23753 startup, and how threads may be terminated. However, objects
23754 with thread storage duration shall be initialized before thread
23755 startup.
23756 @end quotation
23757
23758 @item
23759 @cite{6.2.4 Storage durations of objects}
23760
23761 Add new text before paragraph 3
23762
23763 @quotation
23764 An object whose identifier is declared with the storage-class
23765 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
23766 Its lifetime is the entire execution of the thread, and its
23767 stored value is initialized only once, prior to thread startup.
23768 @end quotation
23769
23770 @item
23771 @cite{6.4.1 Keywords}
23772
23773 Add @code{__thread}.
23774
23775 @item
23776 @cite{6.7.1 Storage-class specifiers}
23777
23778 Add @code{__thread} to the list of storage class specifiers in
23779 paragraph 1.
23780
23781 Change paragraph 2 to
23782
23783 @quotation
23784 With the exception of @code{__thread}, at most one storage-class
23785 specifier may be given [@dots{}]. The @code{__thread} specifier may
23786 be used alone, or immediately following @code{extern} or
23787 @code{static}.
23788 @end quotation
23789
23790 Add new text after paragraph 6
23791
23792 @quotation
23793 The declaration of an identifier for a variable that has
23794 block scope that specifies @code{__thread} shall also
23795 specify either @code{extern} or @code{static}.
23796
23797 The @code{__thread} specifier shall be used only with
23798 variables.
23799 @end quotation
23800 @end itemize
23801
23802 @node C++98 Thread-Local Edits
23803 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
23804
23805 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
23806 that document the exact semantics of the language extension.
23807
23808 @itemize @bullet
23809 @item
23810 @b{[intro.execution]}
23811
23812 New text after paragraph 4
23813
23814 @quotation
23815 A @dfn{thread} is a flow of control within the abstract machine.
23816 It is implementation defined whether or not there may be more than
23817 one thread.
23818 @end quotation
23819
23820 New text after paragraph 7
23821
23822 @quotation
23823 It is unspecified whether additional action must be taken to
23824 ensure when and whether side effects are visible to other threads.
23825 @end quotation
23826
23827 @item
23828 @b{[lex.key]}
23829
23830 Add @code{__thread}.
23831
23832 @item
23833 @b{[basic.start.main]}
23834
23835 Add after paragraph 5
23836
23837 @quotation
23838 The thread that begins execution at the @code{main} function is called
23839 the @dfn{main thread}. It is implementation defined how functions
23840 beginning threads other than the main thread are designated or typed.
23841 A function so designated, as well as the @code{main} function, is called
23842 a @dfn{thread startup function}. It is implementation defined what
23843 happens if a thread startup function returns. It is implementation
23844 defined what happens to other threads when any thread calls @code{exit}.
23845 @end quotation
23846
23847 @item
23848 @b{[basic.start.init]}
23849
23850 Add after paragraph 4
23851
23852 @quotation
23853 The storage for an object of thread storage duration shall be
23854 statically initialized before the first statement of the thread startup
23855 function. An object of thread storage duration shall not require
23856 dynamic initialization.
23857 @end quotation
23858
23859 @item
23860 @b{[basic.start.term]}
23861
23862 Add after paragraph 3
23863
23864 @quotation
23865 The type of an object with thread storage duration shall not have a
23866 non-trivial destructor, nor shall it be an array type whose elements
23867 (directly or indirectly) have non-trivial destructors.
23868 @end quotation
23869
23870 @item
23871 @b{[basic.stc]}
23872
23873 Add ``thread storage duration'' to the list in paragraph 1.
23874
23875 Change paragraph 2
23876
23877 @quotation
23878 Thread, static, and automatic storage durations are associated with
23879 objects introduced by declarations [@dots{}].
23880 @end quotation
23881
23882 Add @code{__thread} to the list of specifiers in paragraph 3.
23883
23884 @item
23885 @b{[basic.stc.thread]}
23886
23887 New section before @b{[basic.stc.static]}
23888
23889 @quotation
23890 The keyword @code{__thread} applied to a non-local object gives the
23891 object thread storage duration.
23892
23893 A local variable or class data member declared both @code{static}
23894 and @code{__thread} gives the variable or member thread storage
23895 duration.
23896 @end quotation
23897
23898 @item
23899 @b{[basic.stc.static]}
23900
23901 Change paragraph 1
23902
23903 @quotation
23904 All objects that have neither thread storage duration, dynamic
23905 storage duration nor are local [@dots{}].
23906 @end quotation
23907
23908 @item
23909 @b{[dcl.stc]}
23910
23911 Add @code{__thread} to the list in paragraph 1.
23912
23913 Change paragraph 1
23914
23915 @quotation
23916 With the exception of @code{__thread}, at most one
23917 @var{storage-class-specifier} shall appear in a given
23918 @var{decl-specifier-seq}. The @code{__thread} specifier may
23919 be used alone, or immediately following the @code{extern} or
23920 @code{static} specifiers. [@dots{}]
23921 @end quotation
23922
23923 Add after paragraph 5
23924
23925 @quotation
23926 The @code{__thread} specifier can be applied only to the names of objects
23927 and to anonymous unions.
23928 @end quotation
23929
23930 @item
23931 @b{[class.mem]}
23932
23933 Add after paragraph 6
23934
23935 @quotation
23936 Non-@code{static} members shall not be @code{__thread}.
23937 @end quotation
23938 @end itemize
23939
23940 @node Binary constants
23941 @section Binary Constants using the @samp{0b} Prefix
23942 @cindex Binary constants using the @samp{0b} prefix
23943
23944 Integer constants can be written as binary constants, consisting of a
23945 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
23946 @samp{0B}. This is particularly useful in environments that operate a
23947 lot on the bit level (like microcontrollers).
23948
23949 The following statements are identical:
23950
23951 @smallexample
23952 i = 42;
23953 i = 0x2a;
23954 i = 052;
23955 i = 0b101010;
23956 @end smallexample
23957
23958 The type of these constants follows the same rules as for octal or
23959 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
23960 can be applied.
23961
23962 @node C++ Extensions
23963 @chapter Extensions to the C++ Language
23964 @cindex extensions, C++ language
23965 @cindex C++ language extensions
23966
23967 The GNU compiler provides these extensions to the C++ language (and you
23968 can also use most of the C language extensions in your C++ programs). If you
23969 want to write code that checks whether these features are available, you can
23970 test for the GNU compiler the same way as for C programs: check for a
23971 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
23972 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
23973 Predefined Macros,cpp,The GNU C Preprocessor}).
23974
23975 @menu
23976 * C++ Volatiles:: What constitutes an access to a volatile object.
23977 * Restricted Pointers:: C99 restricted pointers and references.
23978 * Vague Linkage:: Where G++ puts inlines, vtables and such.
23979 * C++ Interface:: You can use a single C++ header file for both
23980 declarations and definitions.
23981 * Template Instantiation:: Methods for ensuring that exactly one copy of
23982 each needed template instantiation is emitted.
23983 * Bound member functions:: You can extract a function pointer to the
23984 method denoted by a @samp{->*} or @samp{.*} expression.
23985 * C++ Attributes:: Variable, function, and type attributes for C++ only.
23986 * Function Multiversioning:: Declaring multiple function versions.
23987 * Type Traits:: Compiler support for type traits.
23988 * C++ Concepts:: Improved support for generic programming.
23989 * Deprecated Features:: Things will disappear from G++.
23990 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
23991 @end menu
23992
23993 @node C++ Volatiles
23994 @section When is a Volatile C++ Object Accessed?
23995 @cindex accessing volatiles
23996 @cindex volatile read
23997 @cindex volatile write
23998 @cindex volatile access
23999
24000 The C++ standard differs from the C standard in its treatment of
24001 volatile objects. It fails to specify what constitutes a volatile
24002 access, except to say that C++ should behave in a similar manner to C
24003 with respect to volatiles, where possible. However, the different
24004 lvalueness of expressions between C and C++ complicate the behavior.
24005 G++ behaves the same as GCC for volatile access, @xref{C
24006 Extensions,,Volatiles}, for a description of GCC's behavior.
24007
24008 The C and C++ language specifications differ when an object is
24009 accessed in a void context:
24010
24011 @smallexample
24012 volatile int *src = @var{somevalue};
24013 *src;
24014 @end smallexample
24015
24016 The C++ standard specifies that such expressions do not undergo lvalue
24017 to rvalue conversion, and that the type of the dereferenced object may
24018 be incomplete. The C++ standard does not specify explicitly that it
24019 is lvalue to rvalue conversion that is responsible for causing an
24020 access. There is reason to believe that it is, because otherwise
24021 certain simple expressions become undefined. However, because it
24022 would surprise most programmers, G++ treats dereferencing a pointer to
24023 volatile object of complete type as GCC would do for an equivalent
24024 type in C@. When the object has incomplete type, G++ issues a
24025 warning; if you wish to force an error, you must force a conversion to
24026 rvalue with, for instance, a static cast.
24027
24028 When using a reference to volatile, G++ does not treat equivalent
24029 expressions as accesses to volatiles, but instead issues a warning that
24030 no volatile is accessed. The rationale for this is that otherwise it
24031 becomes difficult to determine where volatile access occur, and not
24032 possible to ignore the return value from functions returning volatile
24033 references. Again, if you wish to force a read, cast the reference to
24034 an rvalue.
24035
24036 G++ implements the same behavior as GCC does when assigning to a
24037 volatile object---there is no reread of the assigned-to object, the
24038 assigned rvalue is reused. Note that in C++ assignment expressions
24039 are lvalues, and if used as an lvalue, the volatile object is
24040 referred to. For instance, @var{vref} refers to @var{vobj}, as
24041 expected, in the following example:
24042
24043 @smallexample
24044 volatile int vobj;
24045 volatile int &vref = vobj = @var{something};
24046 @end smallexample
24047
24048 @node Restricted Pointers
24049 @section Restricting Pointer Aliasing
24050 @cindex restricted pointers
24051 @cindex restricted references
24052 @cindex restricted this pointer
24053
24054 As with the C front end, G++ understands the C99 feature of restricted pointers,
24055 specified with the @code{__restrict__}, or @code{__restrict} type
24056 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
24057 language flag, @code{restrict} is not a keyword in C++.
24058
24059 In addition to allowing restricted pointers, you can specify restricted
24060 references, which indicate that the reference is not aliased in the local
24061 context.
24062
24063 @smallexample
24064 void fn (int *__restrict__ rptr, int &__restrict__ rref)
24065 @{
24066 /* @r{@dots{}} */
24067 @}
24068 @end smallexample
24069
24070 @noindent
24071 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
24072 @var{rref} refers to a (different) unaliased integer.
24073
24074 You may also specify whether a member function's @var{this} pointer is
24075 unaliased by using @code{__restrict__} as a member function qualifier.
24076
24077 @smallexample
24078 void T::fn () __restrict__
24079 @{
24080 /* @r{@dots{}} */
24081 @}
24082 @end smallexample
24083
24084 @noindent
24085 Within the body of @code{T::fn}, @var{this} has the effective
24086 definition @code{T *__restrict__ const this}. Notice that the
24087 interpretation of a @code{__restrict__} member function qualifier is
24088 different to that of @code{const} or @code{volatile} qualifier, in that it
24089 is applied to the pointer rather than the object. This is consistent with
24090 other compilers that implement restricted pointers.
24091
24092 As with all outermost parameter qualifiers, @code{__restrict__} is
24093 ignored in function definition matching. This means you only need to
24094 specify @code{__restrict__} in a function definition, rather than
24095 in a function prototype as well.
24096
24097 @node Vague Linkage
24098 @section Vague Linkage
24099 @cindex vague linkage
24100
24101 There are several constructs in C++ that require space in the object
24102 file but are not clearly tied to a single translation unit. We say that
24103 these constructs have ``vague linkage''. Typically such constructs are
24104 emitted wherever they are needed, though sometimes we can be more
24105 clever.
24106
24107 @table @asis
24108 @item Inline Functions
24109 Inline functions are typically defined in a header file which can be
24110 included in many different compilations. Hopefully they can usually be
24111 inlined, but sometimes an out-of-line copy is necessary, if the address
24112 of the function is taken or if inlining fails. In general, we emit an
24113 out-of-line copy in all translation units where one is needed. As an
24114 exception, we only emit inline virtual functions with the vtable, since
24115 it always requires a copy.
24116
24117 Local static variables and string constants used in an inline function
24118 are also considered to have vague linkage, since they must be shared
24119 between all inlined and out-of-line instances of the function.
24120
24121 @item VTables
24122 @cindex vtable
24123 C++ virtual functions are implemented in most compilers using a lookup
24124 table, known as a vtable. The vtable contains pointers to the virtual
24125 functions provided by a class, and each object of the class contains a
24126 pointer to its vtable (or vtables, in some multiple-inheritance
24127 situations). If the class declares any non-inline, non-pure virtual
24128 functions, the first one is chosen as the ``key method'' for the class,
24129 and the vtable is only emitted in the translation unit where the key
24130 method is defined.
24131
24132 @emph{Note:} If the chosen key method is later defined as inline, the
24133 vtable is still emitted in every translation unit that defines it.
24134 Make sure that any inline virtuals are declared inline in the class
24135 body, even if they are not defined there.
24136
24137 @item @code{type_info} objects
24138 @cindex @code{type_info}
24139 @cindex RTTI
24140 C++ requires information about types to be written out in order to
24141 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
24142 For polymorphic classes (classes with virtual functions), the @samp{type_info}
24143 object is written out along with the vtable so that @samp{dynamic_cast}
24144 can determine the dynamic type of a class object at run time. For all
24145 other types, we write out the @samp{type_info} object when it is used: when
24146 applying @samp{typeid} to an expression, throwing an object, or
24147 referring to a type in a catch clause or exception specification.
24148
24149 @item Template Instantiations
24150 Most everything in this section also applies to template instantiations,
24151 but there are other options as well.
24152 @xref{Template Instantiation,,Where's the Template?}.
24153
24154 @end table
24155
24156 When used with GNU ld version 2.8 or later on an ELF system such as
24157 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
24158 these constructs will be discarded at link time. This is known as
24159 COMDAT support.
24160
24161 On targets that don't support COMDAT, but do support weak symbols, GCC
24162 uses them. This way one copy overrides all the others, but
24163 the unused copies still take up space in the executable.
24164
24165 For targets that do not support either COMDAT or weak symbols,
24166 most entities with vague linkage are emitted as local symbols to
24167 avoid duplicate definition errors from the linker. This does not happen
24168 for local statics in inlines, however, as having multiple copies
24169 almost certainly breaks things.
24170
24171 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
24172 another way to control placement of these constructs.
24173
24174 @node C++ Interface
24175 @section C++ Interface and Implementation Pragmas
24176
24177 @cindex interface and implementation headers, C++
24178 @cindex C++ interface and implementation headers
24179 @cindex pragmas, interface and implementation
24180
24181 @code{#pragma interface} and @code{#pragma implementation} provide the
24182 user with a way of explicitly directing the compiler to emit entities
24183 with vague linkage (and debugging information) in a particular
24184 translation unit.
24185
24186 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
24187 by COMDAT support and the ``key method'' heuristic
24188 mentioned in @ref{Vague Linkage}. Using them can actually cause your
24189 program to grow due to unnecessary out-of-line copies of inline
24190 functions.
24191
24192 @table @code
24193 @item #pragma interface
24194 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
24195 @kindex #pragma interface
24196 Use this directive in @emph{header files} that define object classes, to save
24197 space in most of the object files that use those classes. Normally,
24198 local copies of certain information (backup copies of inline member
24199 functions, debugging information, and the internal tables that implement
24200 virtual functions) must be kept in each object file that includes class
24201 definitions. You can use this pragma to avoid such duplication. When a
24202 header file containing @samp{#pragma interface} is included in a
24203 compilation, this auxiliary information is not generated (unless
24204 the main input source file itself uses @samp{#pragma implementation}).
24205 Instead, the object files contain references to be resolved at link
24206 time.
24207
24208 The second form of this directive is useful for the case where you have
24209 multiple headers with the same name in different directories. If you
24210 use this form, you must specify the same string to @samp{#pragma
24211 implementation}.
24212
24213 @item #pragma implementation
24214 @itemx #pragma implementation "@var{objects}.h"
24215 @kindex #pragma implementation
24216 Use this pragma in a @emph{main input file}, when you want full output from
24217 included header files to be generated (and made globally visible). The
24218 included header file, in turn, should use @samp{#pragma interface}.
24219 Backup copies of inline member functions, debugging information, and the
24220 internal tables used to implement virtual functions are all generated in
24221 implementation files.
24222
24223 @cindex implied @code{#pragma implementation}
24224 @cindex @code{#pragma implementation}, implied
24225 @cindex naming convention, implementation headers
24226 If you use @samp{#pragma implementation} with no argument, it applies to
24227 an include file with the same basename@footnote{A file's @dfn{basename}
24228 is the name stripped of all leading path information and of trailing
24229 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
24230 file. For example, in @file{allclass.cc}, giving just
24231 @samp{#pragma implementation}
24232 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
24233
24234 Use the string argument if you want a single implementation file to
24235 include code from multiple header files. (You must also use
24236 @samp{#include} to include the header file; @samp{#pragma
24237 implementation} only specifies how to use the file---it doesn't actually
24238 include it.)
24239
24240 There is no way to split up the contents of a single header file into
24241 multiple implementation files.
24242 @end table
24243
24244 @cindex inlining and C++ pragmas
24245 @cindex C++ pragmas, effect on inlining
24246 @cindex pragmas in C++, effect on inlining
24247 @samp{#pragma implementation} and @samp{#pragma interface} also have an
24248 effect on function inlining.
24249
24250 If you define a class in a header file marked with @samp{#pragma
24251 interface}, the effect on an inline function defined in that class is
24252 similar to an explicit @code{extern} declaration---the compiler emits
24253 no code at all to define an independent version of the function. Its
24254 definition is used only for inlining with its callers.
24255
24256 @opindex fno-implement-inlines
24257 Conversely, when you include the same header file in a main source file
24258 that declares it as @samp{#pragma implementation}, the compiler emits
24259 code for the function itself; this defines a version of the function
24260 that can be found via pointers (or by callers compiled without
24261 inlining). If all calls to the function can be inlined, you can avoid
24262 emitting the function by compiling with @option{-fno-implement-inlines}.
24263 If any calls are not inlined, you will get linker errors.
24264
24265 @node Template Instantiation
24266 @section Where's the Template?
24267 @cindex template instantiation
24268
24269 C++ templates were the first language feature to require more
24270 intelligence from the environment than was traditionally found on a UNIX
24271 system. Somehow the compiler and linker have to make sure that each
24272 template instance occurs exactly once in the executable if it is needed,
24273 and not at all otherwise. There are two basic approaches to this
24274 problem, which are referred to as the Borland model and the Cfront model.
24275
24276 @table @asis
24277 @item Borland model
24278 Borland C++ solved the template instantiation problem by adding the code
24279 equivalent of common blocks to their linker; the compiler emits template
24280 instances in each translation unit that uses them, and the linker
24281 collapses them together. The advantage of this model is that the linker
24282 only has to consider the object files themselves; there is no external
24283 complexity to worry about. The disadvantage is that compilation time
24284 is increased because the template code is being compiled repeatedly.
24285 Code written for this model tends to include definitions of all
24286 templates in the header file, since they must be seen to be
24287 instantiated.
24288
24289 @item Cfront model
24290 The AT&T C++ translator, Cfront, solved the template instantiation
24291 problem by creating the notion of a template repository, an
24292 automatically maintained place where template instances are stored. A
24293 more modern version of the repository works as follows: As individual
24294 object files are built, the compiler places any template definitions and
24295 instantiations encountered in the repository. At link time, the link
24296 wrapper adds in the objects in the repository and compiles any needed
24297 instances that were not previously emitted. The advantages of this
24298 model are more optimal compilation speed and the ability to use the
24299 system linker; to implement the Borland model a compiler vendor also
24300 needs to replace the linker. The disadvantages are vastly increased
24301 complexity, and thus potential for error; for some code this can be
24302 just as transparent, but in practice it can been very difficult to build
24303 multiple programs in one directory and one program in multiple
24304 directories. Code written for this model tends to separate definitions
24305 of non-inline member templates into a separate file, which should be
24306 compiled separately.
24307 @end table
24308
24309 G++ implements the Borland model on targets where the linker supports it,
24310 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
24311 Otherwise G++ implements neither automatic model.
24312
24313 You have the following options for dealing with template instantiations:
24314
24315 @enumerate
24316 @item
24317 Do nothing. Code written for the Borland model works fine, but
24318 each translation unit contains instances of each of the templates it
24319 uses. The duplicate instances will be discarded by the linker, but in
24320 a large program, this can lead to an unacceptable amount of code
24321 duplication in object files or shared libraries.
24322
24323 Duplicate instances of a template can be avoided by defining an explicit
24324 instantiation in one object file, and preventing the compiler from doing
24325 implicit instantiations in any other object files by using an explicit
24326 instantiation declaration, using the @code{extern template} syntax:
24327
24328 @smallexample
24329 extern template int max (int, int);
24330 @end smallexample
24331
24332 This syntax is defined in the C++ 2011 standard, but has been supported by
24333 G++ and other compilers since well before 2011.
24334
24335 Explicit instantiations can be used for the largest or most frequently
24336 duplicated instances, without having to know exactly which other instances
24337 are used in the rest of the program. You can scatter the explicit
24338 instantiations throughout your program, perhaps putting them in the
24339 translation units where the instances are used or the translation units
24340 that define the templates themselves; you can put all of the explicit
24341 instantiations you need into one big file; or you can create small files
24342 like
24343
24344 @smallexample
24345 #include "Foo.h"
24346 #include "Foo.cc"
24347
24348 template class Foo<int>;
24349 template ostream& operator <<
24350 (ostream&, const Foo<int>&);
24351 @end smallexample
24352
24353 @noindent
24354 for each of the instances you need, and create a template instantiation
24355 library from those.
24356
24357 This is the simplest option, but also offers flexibility and
24358 fine-grained control when necessary. It is also the most portable
24359 alternative and programs using this approach will work with most modern
24360 compilers.
24361
24362 @item
24363 @opindex frepo
24364 Compile your template-using code with @option{-frepo}. The compiler
24365 generates files with the extension @samp{.rpo} listing all of the
24366 template instantiations used in the corresponding object files that
24367 could be instantiated there; the link wrapper, @samp{collect2},
24368 then updates the @samp{.rpo} files to tell the compiler where to place
24369 those instantiations and rebuild any affected object files. The
24370 link-time overhead is negligible after the first pass, as the compiler
24371 continues to place the instantiations in the same files.
24372
24373 This can be a suitable option for application code written for the Borland
24374 model, as it usually just works. Code written for the Cfront model
24375 needs to be modified so that the template definitions are available at
24376 one or more points of instantiation; usually this is as simple as adding
24377 @code{#include <tmethods.cc>} to the end of each template header.
24378
24379 For library code, if you want the library to provide all of the template
24380 instantiations it needs, just try to link all of its object files
24381 together; the link will fail, but cause the instantiations to be
24382 generated as a side effect. Be warned, however, that this may cause
24383 conflicts if multiple libraries try to provide the same instantiations.
24384 For greater control, use explicit instantiation as described in the next
24385 option.
24386
24387 @item
24388 @opindex fno-implicit-templates
24389 Compile your code with @option{-fno-implicit-templates} to disable the
24390 implicit generation of template instances, and explicitly instantiate
24391 all the ones you use. This approach requires more knowledge of exactly
24392 which instances you need than do the others, but it's less
24393 mysterious and allows greater control if you want to ensure that only
24394 the intended instances are used.
24395
24396 If you are using Cfront-model code, you can probably get away with not
24397 using @option{-fno-implicit-templates} when compiling files that don't
24398 @samp{#include} the member template definitions.
24399
24400 If you use one big file to do the instantiations, you may want to
24401 compile it without @option{-fno-implicit-templates} so you get all of the
24402 instances required by your explicit instantiations (but not by any
24403 other files) without having to specify them as well.
24404
24405 In addition to forward declaration of explicit instantiations
24406 (with @code{extern}), G++ has extended the template instantiation
24407 syntax to support instantiation of the compiler support data for a
24408 template class (i.e.@: the vtable) without instantiating any of its
24409 members (with @code{inline}), and instantiation of only the static data
24410 members of a template class, without the support data or member
24411 functions (with @code{static}):
24412
24413 @smallexample
24414 inline template class Foo<int>;
24415 static template class Foo<int>;
24416 @end smallexample
24417 @end enumerate
24418
24419 @node Bound member functions
24420 @section Extracting the Function Pointer from a Bound Pointer to Member Function
24421 @cindex pmf
24422 @cindex pointer to member function
24423 @cindex bound pointer to member function
24424
24425 In C++, pointer to member functions (PMFs) are implemented using a wide
24426 pointer of sorts to handle all the possible call mechanisms; the PMF
24427 needs to store information about how to adjust the @samp{this} pointer,
24428 and if the function pointed to is virtual, where to find the vtable, and
24429 where in the vtable to look for the member function. If you are using
24430 PMFs in an inner loop, you should really reconsider that decision. If
24431 that is not an option, you can extract the pointer to the function that
24432 would be called for a given object/PMF pair and call it directly inside
24433 the inner loop, to save a bit of time.
24434
24435 Note that you still pay the penalty for the call through a
24436 function pointer; on most modern architectures, such a call defeats the
24437 branch prediction features of the CPU@. This is also true of normal
24438 virtual function calls.
24439
24440 The syntax for this extension is
24441
24442 @smallexample
24443 extern A a;
24444 extern int (A::*fp)();
24445 typedef int (*fptr)(A *);
24446
24447 fptr p = (fptr)(a.*fp);
24448 @end smallexample
24449
24450 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
24451 no object is needed to obtain the address of the function. They can be
24452 converted to function pointers directly:
24453
24454 @smallexample
24455 fptr p1 = (fptr)(&A::foo);
24456 @end smallexample
24457
24458 @opindex Wno-pmf-conversions
24459 You must specify @option{-Wno-pmf-conversions} to use this extension.
24460
24461 @node C++ Attributes
24462 @section C++-Specific Variable, Function, and Type Attributes
24463
24464 Some attributes only make sense for C++ programs.
24465
24466 @table @code
24467 @item abi_tag ("@var{tag}", ...)
24468 @cindex @code{abi_tag} function attribute
24469 @cindex @code{abi_tag} variable attribute
24470 @cindex @code{abi_tag} type attribute
24471 The @code{abi_tag} attribute can be applied to a function, variable, or class
24472 declaration. It modifies the mangled name of the entity to
24473 incorporate the tag name, in order to distinguish the function or
24474 class from an earlier version with a different ABI; perhaps the class
24475 has changed size, or the function has a different return type that is
24476 not encoded in the mangled name.
24477
24478 The attribute can also be applied to an inline namespace, but does not
24479 affect the mangled name of the namespace; in this case it is only used
24480 for @option{-Wabi-tag} warnings and automatic tagging of functions and
24481 variables. Tagging inline namespaces is generally preferable to
24482 tagging individual declarations, but the latter is sometimes
24483 necessary, such as when only certain members of a class need to be
24484 tagged.
24485
24486 The argument can be a list of strings of arbitrary length. The
24487 strings are sorted on output, so the order of the list is
24488 unimportant.
24489
24490 A redeclaration of an entity must not add new ABI tags,
24491 since doing so would change the mangled name.
24492
24493 The ABI tags apply to a name, so all instantiations and
24494 specializations of a template have the same tags. The attribute will
24495 be ignored if applied to an explicit specialization or instantiation.
24496
24497 The @option{-Wabi-tag} flag enables a warning about a class which does
24498 not have all the ABI tags used by its subobjects and virtual functions; for users with code
24499 that needs to coexist with an earlier ABI, using this option can help
24500 to find all affected types that need to be tagged.
24501
24502 When a type involving an ABI tag is used as the type of a variable or
24503 return type of a function where that tag is not already present in the
24504 signature of the function, the tag is automatically applied to the
24505 variable or function. @option{-Wabi-tag} also warns about this
24506 situation; this warning can be avoided by explicitly tagging the
24507 variable or function or moving it into a tagged inline namespace.
24508
24509 @item init_priority (@var{priority})
24510 @cindex @code{init_priority} variable attribute
24511
24512 In Standard C++, objects defined at namespace scope are guaranteed to be
24513 initialized in an order in strict accordance with that of their definitions
24514 @emph{in a given translation unit}. No guarantee is made for initializations
24515 across translation units. However, GNU C++ allows users to control the
24516 order of initialization of objects defined at namespace scope with the
24517 @code{init_priority} attribute by specifying a relative @var{priority},
24518 a constant integral expression currently bounded between 101 and 65535
24519 inclusive. Lower numbers indicate a higher priority.
24520
24521 In the following example, @code{A} would normally be created before
24522 @code{B}, but the @code{init_priority} attribute reverses that order:
24523
24524 @smallexample
24525 Some_Class A __attribute__ ((init_priority (2000)));
24526 Some_Class B __attribute__ ((init_priority (543)));
24527 @end smallexample
24528
24529 @noindent
24530 Note that the particular values of @var{priority} do not matter; only their
24531 relative ordering.
24532
24533 @item warn_unused
24534 @cindex @code{warn_unused} type attribute
24535
24536 For C++ types with non-trivial constructors and/or destructors it is
24537 impossible for the compiler to determine whether a variable of this
24538 type is truly unused if it is not referenced. This type attribute
24539 informs the compiler that variables of this type should be warned
24540 about if they appear to be unused, just like variables of fundamental
24541 types.
24542
24543 This attribute is appropriate for types which just represent a value,
24544 such as @code{std::string}; it is not appropriate for types which
24545 control a resource, such as @code{std::lock_guard}.
24546
24547 This attribute is also accepted in C, but it is unnecessary because C
24548 does not have constructors or destructors.
24549
24550 @end table
24551
24552 @node Function Multiversioning
24553 @section Function Multiversioning
24554 @cindex function versions
24555
24556 With the GNU C++ front end, for x86 targets, you may specify multiple
24557 versions of a function, where each function is specialized for a
24558 specific target feature. At runtime, the appropriate version of the
24559 function is automatically executed depending on the characteristics of
24560 the execution platform. Here is an example.
24561
24562 @smallexample
24563 __attribute__ ((target ("default")))
24564 int foo ()
24565 @{
24566 // The default version of foo.
24567 return 0;
24568 @}
24569
24570 __attribute__ ((target ("sse4.2")))
24571 int foo ()
24572 @{
24573 // foo version for SSE4.2
24574 return 1;
24575 @}
24576
24577 __attribute__ ((target ("arch=atom")))
24578 int foo ()
24579 @{
24580 // foo version for the Intel ATOM processor
24581 return 2;
24582 @}
24583
24584 __attribute__ ((target ("arch=amdfam10")))
24585 int foo ()
24586 @{
24587 // foo version for the AMD Family 0x10 processors.
24588 return 3;
24589 @}
24590
24591 int main ()
24592 @{
24593 int (*p)() = &foo;
24594 assert ((*p) () == foo ());
24595 return 0;
24596 @}
24597 @end smallexample
24598
24599 In the above example, four versions of function foo are created. The
24600 first version of foo with the target attribute "default" is the default
24601 version. This version gets executed when no other target specific
24602 version qualifies for execution on a particular platform. A new version
24603 of foo is created by using the same function signature but with a
24604 different target string. Function foo is called or a pointer to it is
24605 taken just like a regular function. GCC takes care of doing the
24606 dispatching to call the right version at runtime. Refer to the
24607 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
24608 Function Multiversioning} for more details.
24609
24610 @node Type Traits
24611 @section Type Traits
24612
24613 The C++ front end implements syntactic extensions that allow
24614 compile-time determination of
24615 various characteristics of a type (or of a
24616 pair of types).
24617
24618 @table @code
24619 @item __has_nothrow_assign (type)
24620 If @code{type} is @code{const}-qualified or is a reference type then
24621 the trait is @code{false}. Otherwise if @code{__has_trivial_assign (type)}
24622 is @code{true} then the trait is @code{true}, else if @code{type} is
24623 a cv-qualified class or union type with copy assignment operators that are
24624 known not to throw an exception then the trait is @code{true}, else it is
24625 @code{false}.
24626 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24627 @code{void}, or an array of unknown bound.
24628
24629 @item __has_nothrow_copy (type)
24630 If @code{__has_trivial_copy (type)} is @code{true} then the trait is
24631 @code{true}, else if @code{type} is a cv-qualified class or union type
24632 with copy constructors that are known not to throw an exception then
24633 the trait is @code{true}, else it is @code{false}.
24634 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24635 @code{void}, or an array of unknown bound.
24636
24637 @item __has_nothrow_constructor (type)
24638 If @code{__has_trivial_constructor (type)} is @code{true} then the trait
24639 is @code{true}, else if @code{type} is a cv class or union type (or array
24640 thereof) with a default constructor that is known not to throw an
24641 exception then the trait is @code{true}, else it is @code{false}.
24642 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24643 @code{void}, or an array of unknown bound.
24644
24645 @item __has_trivial_assign (type)
24646 If @code{type} is @code{const}- qualified or is a reference type then
24647 the trait is @code{false}. Otherwise if @code{__is_pod (type)} is
24648 @code{true} then the trait is @code{true}, else if @code{type} is
24649 a cv-qualified class or union type with a trivial copy assignment
24650 ([class.copy]) then the trait is @code{true}, else it is @code{false}.
24651 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24652 @code{void}, or an array of unknown bound.
24653
24654 @item __has_trivial_copy (type)
24655 If @code{__is_pod (type)} is @code{true} or @code{type} is a reference
24656 type then the trait is @code{true}, else if @code{type} is a cv class
24657 or union type with a trivial copy constructor ([class.copy]) then the trait
24658 is @code{true}, else it is @code{false}. Requires: @code{type} shall be
24659 a complete type, (possibly cv-qualified) @code{void}, or an array of unknown
24660 bound.
24661
24662 @item __has_trivial_constructor (type)
24663 If @code{__is_pod (type)} is @code{true} then the trait is @code{true},
24664 else if @code{type} is a cv-qualified class or union type (or array thereof)
24665 with a trivial default constructor ([class.ctor]) then the trait is @code{true},
24666 else it is @code{false}.
24667 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24668 @code{void}, or an array of unknown bound.
24669
24670 @item __has_trivial_destructor (type)
24671 If @code{__is_pod (type)} is @code{true} or @code{type} is a reference type
24672 then the trait is @code{true}, else if @code{type} is a cv class or union
24673 type (or array thereof) with a trivial destructor ([class.dtor]) then
24674 the trait is @code{true}, else it is @code{false}.
24675 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24676 @code{void}, or an array of unknown bound.
24677
24678 @item __has_virtual_destructor (type)
24679 If @code{type} is a class type with a virtual destructor
24680 ([class.dtor]) then the trait is @code{true}, else it is @code{false}.
24681 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24682 @code{void}, or an array of unknown bound.
24683
24684 @item __is_abstract (type)
24685 If @code{type} is an abstract class ([class.abstract]) then the trait
24686 is @code{true}, else it is @code{false}.
24687 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24688 @code{void}, or an array of unknown bound.
24689
24690 @item __is_base_of (base_type, derived_type)
24691 If @code{base_type} is a base class of @code{derived_type}
24692 ([class.derived]) then the trait is @code{true}, otherwise it is @code{false}.
24693 Top-level cv-qualifications of @code{base_type} and
24694 @code{derived_type} are ignored. For the purposes of this trait, a
24695 class type is considered is own base.
24696 Requires: if @code{__is_class (base_type)} and @code{__is_class (derived_type)}
24697 are @code{true} and @code{base_type} and @code{derived_type} are not the same
24698 type (disregarding cv-qualifiers), @code{derived_type} shall be a complete
24699 type. A diagnostic is produced if this requirement is not met.
24700
24701 @item __is_class (type)
24702 If @code{type} is a cv-qualified class type, and not a union type
24703 ([basic.compound]) the trait is @code{true}, else it is @code{false}.
24704
24705 @item __is_empty (type)
24706 If @code{__is_class (type)} is @code{false} then the trait is @code{false}.
24707 Otherwise @code{type} is considered empty if and only if: @code{type}
24708 has no non-static data members, or all non-static data members, if
24709 any, are bit-fields of length 0, and @code{type} has no virtual
24710 members, and @code{type} has no virtual base classes, and @code{type}
24711 has no base classes @code{base_type} for which
24712 @code{__is_empty (base_type)} is @code{false}.
24713 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24714 @code{void}, or an array of unknown bound.
24715
24716 @item __is_enum (type)
24717 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
24718 @code{true}, else it is @code{false}.
24719
24720 @item __is_literal_type (type)
24721 If @code{type} is a literal type ([basic.types]) the trait is
24722 @code{true}, else it is @code{false}.
24723 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24724 @code{void}, or an array of unknown bound.
24725
24726 @item __is_pod (type)
24727 If @code{type} is a cv POD type ([basic.types]) then the trait is @code{true},
24728 else it is @code{false}.
24729 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24730 @code{void}, or an array of unknown bound.
24731
24732 @item __is_polymorphic (type)
24733 If @code{type} is a polymorphic class ([class.virtual]) then the trait
24734 is @code{true}, else it is @code{false}.
24735 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24736 @code{void}, or an array of unknown bound.
24737
24738 @item __is_standard_layout (type)
24739 If @code{type} is a standard-layout type ([basic.types]) the trait is
24740 @code{true}, else it is @code{false}.
24741 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24742 @code{void}, or an array of unknown bound.
24743
24744 @item __is_trivial (type)
24745 If @code{type} is a trivial type ([basic.types]) the trait is
24746 @code{true}, else it is @code{false}.
24747 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24748 @code{void}, or an array of unknown bound.
24749
24750 @item __is_union (type)
24751 If @code{type} is a cv union type ([basic.compound]) the trait is
24752 @code{true}, else it is @code{false}.
24753
24754 @item __underlying_type (type)
24755 The underlying type of @code{type}.
24756 Requires: @code{type} shall be an enumeration type ([dcl.enum]).
24757
24758 @item __integer_pack (length)
24759 When used as the pattern of a pack expansion within a template
24760 definition, expands to a template argument pack containing integers
24761 from @code{0} to @code{length-1}. This is provided for efficient
24762 implementation of @code{std::make_integer_sequence}.
24763
24764 @end table
24765
24766
24767 @node C++ Concepts
24768 @section C++ Concepts
24769
24770 C++ concepts provide much-improved support for generic programming. In
24771 particular, they allow the specification of constraints on template arguments.
24772 The constraints are used to extend the usual overloading and partial
24773 specialization capabilities of the language, allowing generic data structures
24774 and algorithms to be ``refined'' based on their properties rather than their
24775 type names.
24776
24777 The following keywords are reserved for concepts.
24778
24779 @table @code
24780 @item assumes
24781 States an expression as an assumption, and if possible, verifies that the
24782 assumption is valid. For example, @code{assume(n > 0)}.
24783
24784 @item axiom
24785 Introduces an axiom definition. Axioms introduce requirements on values.
24786
24787 @item forall
24788 Introduces a universally quantified object in an axiom. For example,
24789 @code{forall (int n) n + 0 == n}).
24790
24791 @item concept
24792 Introduces a concept definition. Concepts are sets of syntactic and semantic
24793 requirements on types and their values.
24794
24795 @item requires
24796 Introduces constraints on template arguments or requirements for a member
24797 function of a class template.
24798
24799 @end table
24800
24801 The front end also exposes a number of internal mechanism that can be used
24802 to simplify the writing of type traits. Note that some of these traits are
24803 likely to be removed in the future.
24804
24805 @table @code
24806 @item __is_same (type1, type2)
24807 A binary type trait: @code{true} whenever the type arguments are the same.
24808
24809 @end table
24810
24811
24812 @node Deprecated Features
24813 @section Deprecated Features
24814
24815 In the past, the GNU C++ compiler was extended to experiment with new
24816 features, at a time when the C++ language was still evolving. Now that
24817 the C++ standard is complete, some of those features are superseded by
24818 superior alternatives. Using the old features might cause a warning in
24819 some cases that the feature will be dropped in the future. In other
24820 cases, the feature might be gone already.
24821
24822 G++ allows a virtual function returning @samp{void *} to be overridden
24823 by one returning a different pointer type. This extension to the
24824 covariant return type rules is now deprecated and will be removed from a
24825 future version.
24826
24827 The use of default arguments in function pointers, function typedefs
24828 and other places where they are not permitted by the standard is
24829 deprecated and will be removed from a future version of G++.
24830
24831 G++ allows floating-point literals to appear in integral constant expressions,
24832 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
24833 This extension is deprecated and will be removed from a future version.
24834
24835 G++ allows static data members of const floating-point type to be declared
24836 with an initializer in a class definition. The standard only allows
24837 initializers for static members of const integral types and const
24838 enumeration types so this extension has been deprecated and will be removed
24839 from a future version.
24840
24841 G++ allows attributes to follow a parenthesized direct initializer,
24842 e.g.@: @samp{ int f (0) __attribute__ ((something)); } This extension
24843 has been ignored since G++ 3.3 and is deprecated.
24844
24845 G++ allows anonymous structs and unions to have members that are not
24846 public non-static data members (i.e.@: fields). These extensions are
24847 deprecated.
24848
24849 @node Backwards Compatibility
24850 @section Backwards Compatibility
24851 @cindex Backwards Compatibility
24852 @cindex ARM [Annotated C++ Reference Manual]
24853
24854 Now that there is a definitive ISO standard C++, G++ has a specification
24855 to adhere to. The C++ language evolved over time, and features that
24856 used to be acceptable in previous drafts of the standard, such as the ARM
24857 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
24858 compilation of C++ written to such drafts, G++ contains some backwards
24859 compatibilities. @emph{All such backwards compatibility features are
24860 liable to disappear in future versions of G++.} They should be considered
24861 deprecated. @xref{Deprecated Features}.
24862
24863 @table @code
24864
24865 @item Implicit C language
24866 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
24867 scope to set the language. On such systems, all system header files are
24868 implicitly scoped inside a C language scope. Such headers must
24869 correctly prototype function argument types, there is no leeway for
24870 @code{()} to indicate an unspecified set of arguments.
24871
24872 @end table
24873
24874 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
24875 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr