re PR target/82066 (#pragma GCC target documentation does not say it is implemented...
[gcc.git] / gcc / doc / extend.texi
1 c Copyright (C) 1988-2017 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:: As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls:: Dispatching a call to another function.
31 * Typeof:: @code{typeof}: referring to the type of an expression.
32 * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
33 * __int128:: 128-bit integers---@code{__int128}.
34 * Long Long:: Double-word integers---@code{long long int}.
35 * Complex:: Data types for complex numbers.
36 * Floating Types:: Additional Floating Types.
37 * Half-Precision:: Half-Precision Floating Point.
38 * Decimal Float:: Decimal Floating Types.
39 * Hex Floats:: Hexadecimal floating-point constants.
40 * Fixed-Point:: Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length:: Zero-length arrays.
43 * Empty Structures:: Structures with no members.
44 * Variable Length:: Arrays whose length is computed at run time.
45 * Variadic Macros:: Macros with a variable number of arguments.
46 * Escaped Newlines:: Slightly looser rules for escaped newlines.
47 * Subscripting:: Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays:: Pointers to arrays with qualifiers work as expected.
50 * Initializers:: Non-constant initializers.
51 * Compound Literals:: Compound literals give structures, unions
52 or arrays as values.
53 * Designated Inits:: Labeling elements of initializers.
54 * Case Ranges:: `case 1 ... 9' and such.
55 * Cast to Union:: Casting to union type from any member of the union.
56 * Mixed Declarations:: Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58 or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes:: Specifying attributes of types.
61 * Label Attributes:: Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Statement Attributes:: Specifying attributes on statements.
64 * Attribute Syntax:: Formal syntax for attributes.
65 * Function Prototypes:: Prototype declarations and old-style definitions.
66 * C++ Comments:: C++ comments are recognized.
67 * Dollar Signs:: Dollar sign is allowed in identifiers.
68 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
69 * Alignment:: Inquiring about the alignment of a type or variable.
70 * Inline:: Defining inline functions (as fast as macros).
71 * Volatiles:: What constitutes an access to a volatile object.
72 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
73 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums:: @code{enum foo;}, with details to follow.
75 * Function Names:: Printable strings which are the name of the current
76 function.
77 * Return Address:: Getting the return or frame address of a function.
78 * Vector Extensions:: Using vector instructions through built-in functions.
79 * Offsetof:: Special syntax for implementing @code{offsetof}.
80 * __sync Builtins:: Legacy built-in functions for atomic memory access.
81 * __atomic Builtins:: Atomic built-in functions with memory model.
82 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
83 arithmetic overflow checking.
84 * x86 specific memory model extensions for transactional memory:: x86 memory models.
85 * Object Size Checking:: Built-in functions for limited buffer overflow
86 checking.
87 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
88 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
89 * Other Builtins:: Other built-in functions.
90 * Target Builtins:: Built-in functions specific to particular targets.
91 * Target Format Checks:: Format checks specific to particular targets.
92 * Pragmas:: Pragmas accepted by GCC.
93 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
94 * Thread-Local:: Per-thread variables.
95 * Binary constants:: Binary constants using the @samp{0b} prefix.
96 @end menu
97
98 @node Statement Exprs
99 @section Statements and Declarations in Expressions
100 @cindex statements inside expressions
101 @cindex declarations inside expressions
102 @cindex expressions containing statements
103 @cindex macros, statements in expressions
104
105 @c the above section title wrapped and causes an underfull hbox.. i
106 @c changed it from "within" to "in". --mew 4feb93
107 A compound statement enclosed in parentheses may appear as an expression
108 in GNU C@. This allows you to use loops, switches, and local variables
109 within an expression.
110
111 Recall that a compound statement is a sequence of statements surrounded
112 by braces; in this construct, parentheses go around the braces. For
113 example:
114
115 @smallexample
116 (@{ int y = foo (); int z;
117 if (y > 0) z = y;
118 else z = - y;
119 z; @})
120 @end smallexample
121
122 @noindent
123 is a valid (though slightly more complex than necessary) expression
124 for the absolute value of @code{foo ()}.
125
126 The last thing in the compound statement should be an expression
127 followed by a semicolon; the value of this subexpression serves as the
128 value of the entire construct. (If you use some other kind of statement
129 last within the braces, the construct has type @code{void}, and thus
130 effectively no value.)
131
132 This feature is especially useful in making macro definitions ``safe'' (so
133 that they evaluate each operand exactly once). For example, the
134 ``maximum'' function is commonly defined as a macro in standard C as
135 follows:
136
137 @smallexample
138 #define max(a,b) ((a) > (b) ? (a) : (b))
139 @end smallexample
140
141 @noindent
142 @cindex side effects, macro argument
143 But this definition computes either @var{a} or @var{b} twice, with bad
144 results if the operand has side effects. In GNU C, if you know the
145 type of the operands (here taken as @code{int}), you can define
146 the macro safely as follows:
147
148 @smallexample
149 #define maxint(a,b) \
150 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
151 @end smallexample
152
153 Embedded statements are not allowed in constant expressions, such as
154 the value of an enumeration constant, the width of a bit-field, or
155 the initial value of a static variable.
156
157 If you don't know the type of the operand, you can still do this, but you
158 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
159
160 In G++, the result value of a statement expression undergoes array and
161 function pointer decay, and is returned by value to the enclosing
162 expression. For instance, if @code{A} is a class, then
163
164 @smallexample
165 A a;
166
167 (@{a;@}).Foo ()
168 @end smallexample
169
170 @noindent
171 constructs a temporary @code{A} object to hold the result of the
172 statement expression, and that is used to invoke @code{Foo}.
173 Therefore the @code{this} pointer observed by @code{Foo} is not the
174 address of @code{a}.
175
176 In a statement expression, any temporaries created within a statement
177 are destroyed at that statement's end. This makes statement
178 expressions inside macros slightly different from function calls. In
179 the latter case temporaries introduced during argument evaluation are
180 destroyed at the end of the statement that includes the function
181 call. In the statement expression case they are destroyed during
182 the statement expression. For instance,
183
184 @smallexample
185 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
186 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
187
188 void foo ()
189 @{
190 macro (X ());
191 function (X ());
192 @}
193 @end smallexample
194
195 @noindent
196 has different places where temporaries are destroyed. For the
197 @code{macro} case, the temporary @code{X} is destroyed just after
198 the initialization of @code{b}. In the @code{function} case that
199 temporary is destroyed when the function returns.
200
201 These considerations mean that it is probably a bad idea to use
202 statement expressions of this form in header files that are designed to
203 work with C++. (Note that some versions of the GNU C Library contained
204 header files using statement expressions that lead to precisely this
205 bug.)
206
207 Jumping into a statement expression with @code{goto} or using a
208 @code{switch} statement outside the statement expression with a
209 @code{case} or @code{default} label inside the statement expression is
210 not permitted. Jumping into a statement expression with a computed
211 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
212 Jumping out of a statement expression is permitted, but if the
213 statement expression is part of a larger expression then it is
214 unspecified which other subexpressions of that expression have been
215 evaluated except where the language definition requires certain
216 subexpressions to be evaluated before or after the statement
217 expression. In any case, as with a function call, the evaluation of a
218 statement expression is not interleaved with the evaluation of other
219 parts of the containing expression. For example,
220
221 @smallexample
222 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
223 @end smallexample
224
225 @noindent
226 calls @code{foo} and @code{bar1} and does not call @code{baz} but
227 may or may not call @code{bar2}. If @code{bar2} is called, it is
228 called after @code{foo} and before @code{bar1}.
229
230 @node Local Labels
231 @section Locally Declared Labels
232 @cindex local labels
233 @cindex macros, local labels
234
235 GCC allows you to declare @dfn{local labels} in any nested block
236 scope. A local label is just like an ordinary label, but you can
237 only reference it (with a @code{goto} statement, or by taking its
238 address) within the block in which it is declared.
239
240 A local label declaration looks like this:
241
242 @smallexample
243 __label__ @var{label};
244 @end smallexample
245
246 @noindent
247 or
248
249 @smallexample
250 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
251 @end smallexample
252
253 Local label declarations must come at the beginning of the block,
254 before any ordinary declarations or statements.
255
256 The label declaration defines the label @emph{name}, but does not define
257 the label itself. You must do this in the usual way, with
258 @code{@var{label}:}, within the statements of the statement expression.
259
260 The local label feature is useful for complex macros. If a macro
261 contains nested loops, a @code{goto} can be useful for breaking out of
262 them. However, an ordinary label whose scope is the whole function
263 cannot be used: if the macro can be expanded several times in one
264 function, the label is multiply defined in that function. A
265 local label avoids this problem. For example:
266
267 @smallexample
268 #define SEARCH(value, array, target) \
269 do @{ \
270 __label__ found; \
271 typeof (target) _SEARCH_target = (target); \
272 typeof (*(array)) *_SEARCH_array = (array); \
273 int i, j; \
274 int value; \
275 for (i = 0; i < max; i++) \
276 for (j = 0; j < max; j++) \
277 if (_SEARCH_array[i][j] == _SEARCH_target) \
278 @{ (value) = i; goto found; @} \
279 (value) = -1; \
280 found:; \
281 @} while (0)
282 @end smallexample
283
284 This could also be written using a statement expression:
285
286 @smallexample
287 #define SEARCH(array, target) \
288 (@{ \
289 __label__ found; \
290 typeof (target) _SEARCH_target = (target); \
291 typeof (*(array)) *_SEARCH_array = (array); \
292 int i, j; \
293 int value; \
294 for (i = 0; i < max; i++) \
295 for (j = 0; j < max; j++) \
296 if (_SEARCH_array[i][j] == _SEARCH_target) \
297 @{ value = i; goto found; @} \
298 value = -1; \
299 found: \
300 value; \
301 @})
302 @end smallexample
303
304 Local label declarations also make the labels they declare visible to
305 nested functions, if there are any. @xref{Nested Functions}, for details.
306
307 @node Labels as Values
308 @section Labels as Values
309 @cindex labels as values
310 @cindex computed gotos
311 @cindex goto with computed label
312 @cindex address of a label
313
314 You can get the address of a label defined in the current function
315 (or a containing function) with the unary operator @samp{&&}. The
316 value has type @code{void *}. This value is a constant and can be used
317 wherever a constant of that type is valid. For example:
318
319 @smallexample
320 void *ptr;
321 /* @r{@dots{}} */
322 ptr = &&foo;
323 @end smallexample
324
325 To use these values, you need to be able to jump to one. This is done
326 with the computed goto statement@footnote{The analogous feature in
327 Fortran is called an assigned goto, but that name seems inappropriate in
328 C, where one can do more than simply store label addresses in label
329 variables.}, @code{goto *@var{exp};}. For example,
330
331 @smallexample
332 goto *ptr;
333 @end smallexample
334
335 @noindent
336 Any expression of type @code{void *} is allowed.
337
338 One way of using these constants is in initializing a static array that
339 serves as a jump table:
340
341 @smallexample
342 static void *array[] = @{ &&foo, &&bar, &&hack @};
343 @end smallexample
344
345 @noindent
346 Then you can select a label with indexing, like this:
347
348 @smallexample
349 goto *array[i];
350 @end smallexample
351
352 @noindent
353 Note that this does not check whether the subscript is in bounds---array
354 indexing in C never does that.
355
356 Such an array of label values serves a purpose much like that of the
357 @code{switch} statement. The @code{switch} statement is cleaner, so
358 use that rather than an array unless the problem does not fit a
359 @code{switch} statement very well.
360
361 Another use of label values is in an interpreter for threaded code.
362 The labels within the interpreter function can be stored in the
363 threaded code for super-fast dispatching.
364
365 You may not use this mechanism to jump to code in a different function.
366 If you do that, totally unpredictable things happen. The best way to
367 avoid this is to store the label address only in automatic variables and
368 never pass it as an argument.
369
370 An alternate way to write the above example is
371
372 @smallexample
373 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
374 &&hack - &&foo @};
375 goto *(&&foo + array[i]);
376 @end smallexample
377
378 @noindent
379 This is more friendly to code living in shared libraries, as it reduces
380 the number of dynamic relocations that are needed, and by consequence,
381 allows the data to be read-only.
382 This alternative with label differences is not supported for the AVR target,
383 please use the first approach for AVR programs.
384
385 The @code{&&foo} expressions for the same label might have different
386 values if the containing function is inlined or cloned. If a program
387 relies on them being always the same,
388 @code{__attribute__((__noinline__,__noclone__))} should be used to
389 prevent inlining and cloning. If @code{&&foo} is used in a static
390 variable initializer, inlining and cloning is forbidden.
391
392 @node Nested Functions
393 @section Nested Functions
394 @cindex nested functions
395 @cindex downward funargs
396 @cindex thunks
397
398 A @dfn{nested function} is a function defined inside another function.
399 Nested functions are supported as an extension in GNU C, but are not
400 supported by GNU C++.
401
402 The nested function's name is local to the block where it is defined.
403 For example, here we define a nested function named @code{square}, and
404 call it twice:
405
406 @smallexample
407 @group
408 foo (double a, double b)
409 @{
410 double square (double z) @{ return z * z; @}
411
412 return square (a) + square (b);
413 @}
414 @end group
415 @end smallexample
416
417 The nested function can access all the variables of the containing
418 function that are visible at the point of its definition. This is
419 called @dfn{lexical scoping}. For example, here we show a nested
420 function which uses an inherited variable named @code{offset}:
421
422 @smallexample
423 @group
424 bar (int *array, int offset, int size)
425 @{
426 int access (int *array, int index)
427 @{ return array[index + offset]; @}
428 int i;
429 /* @r{@dots{}} */
430 for (i = 0; i < size; i++)
431 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
432 @}
433 @end group
434 @end smallexample
435
436 Nested function definitions are permitted within functions in the places
437 where variable definitions are allowed; that is, in any block, mixed
438 with the other declarations and statements in the block.
439
440 It is possible to call the nested function from outside the scope of its
441 name by storing its address or passing the address to another function:
442
443 @smallexample
444 hack (int *array, int size)
445 @{
446 void store (int index, int value)
447 @{ array[index] = value; @}
448
449 intermediate (store, size);
450 @}
451 @end smallexample
452
453 Here, the function @code{intermediate} receives the address of
454 @code{store} as an argument. If @code{intermediate} calls @code{store},
455 the arguments given to @code{store} are used to store into @code{array}.
456 But this technique works only so long as the containing function
457 (@code{hack}, in this example) does not exit.
458
459 If you try to call the nested function through its address after the
460 containing function exits, all hell breaks loose. If you try
461 to call it after a containing scope level exits, and if it refers
462 to some of the variables that are no longer in scope, you may be lucky,
463 but it's not wise to take the risk. If, however, the nested function
464 does not refer to anything that has gone out of scope, you should be
465 safe.
466
467 GCC implements taking the address of a nested function using a technique
468 called @dfn{trampolines}. This technique was described in
469 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
470 C++ Conference Proceedings, October 17-21, 1988).
471
472 A nested function can jump to a label inherited from a containing
473 function, provided the label is explicitly declared in the containing
474 function (@pxref{Local Labels}). Such a jump returns instantly to the
475 containing function, exiting the nested function that did the
476 @code{goto} and any intermediate functions as well. Here is an example:
477
478 @smallexample
479 @group
480 bar (int *array, int offset, int size)
481 @{
482 __label__ failure;
483 int access (int *array, int index)
484 @{
485 if (index > size)
486 goto failure;
487 return array[index + offset];
488 @}
489 int i;
490 /* @r{@dots{}} */
491 for (i = 0; i < size; i++)
492 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
493 /* @r{@dots{}} */
494 return 0;
495
496 /* @r{Control comes here from @code{access}
497 if it detects an error.} */
498 failure:
499 return -1;
500 @}
501 @end group
502 @end smallexample
503
504 A nested function always has no linkage. Declaring one with
505 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
506 before its definition, use @code{auto} (which is otherwise meaningless
507 for function declarations).
508
509 @smallexample
510 bar (int *array, int offset, int size)
511 @{
512 __label__ failure;
513 auto int access (int *, int);
514 /* @r{@dots{}} */
515 int access (int *array, int index)
516 @{
517 if (index > size)
518 goto failure;
519 return array[index + offset];
520 @}
521 /* @r{@dots{}} */
522 @}
523 @end smallexample
524
525 @node Constructing Calls
526 @section Constructing Function Calls
527 @cindex constructing calls
528 @cindex forwarding calls
529
530 Using the built-in functions described below, you can record
531 the arguments a function received, and call another function
532 with the same arguments, without knowing the number or types
533 of the arguments.
534
535 You can also record the return value of that function call,
536 and later return that value, without knowing what data type
537 the function tried to return (as long as your caller expects
538 that data type).
539
540 However, these built-in functions may interact badly with some
541 sophisticated features or other extensions of the language. It
542 is, therefore, not recommended to use them outside very simple
543 functions acting as mere forwarders for their arguments.
544
545 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
546 This built-in function returns a pointer to data
547 describing how to perform a call with the same arguments as are passed
548 to the current function.
549
550 The function saves the arg pointer register, structure value address,
551 and all registers that might be used to pass arguments to a function
552 into a block of memory allocated on the stack. Then it returns the
553 address of that block.
554 @end deftypefn
555
556 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
557 This built-in function invokes @var{function}
558 with a copy of the parameters described by @var{arguments}
559 and @var{size}.
560
561 The value of @var{arguments} should be the value returned by
562 @code{__builtin_apply_args}. The argument @var{size} specifies the size
563 of the stack argument data, in bytes.
564
565 This function returns a pointer to data describing
566 how to return whatever value is returned by @var{function}. The data
567 is saved in a block of memory allocated on the stack.
568
569 It is not always simple to compute the proper value for @var{size}. The
570 value is used by @code{__builtin_apply} to compute the amount of data
571 that should be pushed on the stack and copied from the incoming argument
572 area.
573 @end deftypefn
574
575 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
576 This built-in function returns the value described by @var{result} from
577 the containing function. You should specify, for @var{result}, a value
578 returned by @code{__builtin_apply}.
579 @end deftypefn
580
581 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
582 This built-in function represents all anonymous arguments of an inline
583 function. It can be used only in inline functions that are always
584 inlined, never compiled as a separate function, such as those using
585 @code{__attribute__ ((__always_inline__))} or
586 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
587 It must be only passed as last argument to some other function
588 with variable arguments. This is useful for writing small wrapper
589 inlines for variable argument functions, when using preprocessor
590 macros is undesirable. For example:
591 @smallexample
592 extern int myprintf (FILE *f, const char *format, ...);
593 extern inline __attribute__ ((__gnu_inline__)) int
594 myprintf (FILE *f, const char *format, ...)
595 @{
596 int r = fprintf (f, "myprintf: ");
597 if (r < 0)
598 return r;
599 int s = fprintf (f, format, __builtin_va_arg_pack ());
600 if (s < 0)
601 return s;
602 return r + s;
603 @}
604 @end smallexample
605 @end deftypefn
606
607 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
608 This built-in function returns the number of anonymous arguments of
609 an inline function. It can be used only in inline functions that
610 are always inlined, never compiled as a separate function, such
611 as those using @code{__attribute__ ((__always_inline__))} or
612 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
613 For example following does link- or run-time checking of open
614 arguments for optimized code:
615 @smallexample
616 #ifdef __OPTIMIZE__
617 extern inline __attribute__((__gnu_inline__)) int
618 myopen (const char *path, int oflag, ...)
619 @{
620 if (__builtin_va_arg_pack_len () > 1)
621 warn_open_too_many_arguments ();
622
623 if (__builtin_constant_p (oflag))
624 @{
625 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
626 @{
627 warn_open_missing_mode ();
628 return __open_2 (path, oflag);
629 @}
630 return open (path, oflag, __builtin_va_arg_pack ());
631 @}
632
633 if (__builtin_va_arg_pack_len () < 1)
634 return __open_2 (path, oflag);
635
636 return open (path, oflag, __builtin_va_arg_pack ());
637 @}
638 #endif
639 @end smallexample
640 @end deftypefn
641
642 @node Typeof
643 @section Referring to a Type with @code{typeof}
644 @findex typeof
645 @findex sizeof
646 @cindex macros, types of arguments
647
648 Another way to refer to the type of an expression is with @code{typeof}.
649 The syntax of using of this keyword looks like @code{sizeof}, but the
650 construct acts semantically like a type name defined with @code{typedef}.
651
652 There are two ways of writing the argument to @code{typeof}: with an
653 expression or with a type. Here is an example with an expression:
654
655 @smallexample
656 typeof (x[0](1))
657 @end smallexample
658
659 @noindent
660 This assumes that @code{x} is an array of pointers to functions;
661 the type described is that of the values of the functions.
662
663 Here is an example with a typename as the argument:
664
665 @smallexample
666 typeof (int *)
667 @end smallexample
668
669 @noindent
670 Here the type described is that of pointers to @code{int}.
671
672 If you are writing a header file that must work when included in ISO C
673 programs, write @code{__typeof__} instead of @code{typeof}.
674 @xref{Alternate Keywords}.
675
676 A @code{typeof} construct can be used anywhere a typedef name can be
677 used. For example, you can use it in a declaration, in a cast, or inside
678 of @code{sizeof} or @code{typeof}.
679
680 The operand of @code{typeof} is evaluated for its side effects if and
681 only if it is an expression of variably modified type or the name of
682 such a type.
683
684 @code{typeof} is often useful in conjunction with
685 statement expressions (@pxref{Statement Exprs}).
686 Here is how the two together can
687 be used to define a safe ``maximum'' macro which operates on any
688 arithmetic type and evaluates each of its arguments exactly once:
689
690 @smallexample
691 #define max(a,b) \
692 (@{ typeof (a) _a = (a); \
693 typeof (b) _b = (b); \
694 _a > _b ? _a : _b; @})
695 @end smallexample
696
697 @cindex underscores in variables in macros
698 @cindex @samp{_} in variables in macros
699 @cindex local variables in macros
700 @cindex variables, local, in macros
701 @cindex macros, local variables in
702
703 The reason for using names that start with underscores for the local
704 variables is to avoid conflicts with variable names that occur within the
705 expressions that are substituted for @code{a} and @code{b}. Eventually we
706 hope to design a new form of declaration syntax that allows you to declare
707 variables whose scopes start only after their initializers; this will be a
708 more reliable way to prevent such conflicts.
709
710 @noindent
711 Some more examples of the use of @code{typeof}:
712
713 @itemize @bullet
714 @item
715 This declares @code{y} with the type of what @code{x} points to.
716
717 @smallexample
718 typeof (*x) y;
719 @end smallexample
720
721 @item
722 This declares @code{y} as an array of such values.
723
724 @smallexample
725 typeof (*x) y[4];
726 @end smallexample
727
728 @item
729 This declares @code{y} as an array of pointers to characters:
730
731 @smallexample
732 typeof (typeof (char *)[4]) y;
733 @end smallexample
734
735 @noindent
736 It is equivalent to the following traditional C declaration:
737
738 @smallexample
739 char *y[4];
740 @end smallexample
741
742 To see the meaning of the declaration using @code{typeof}, and why it
743 might be a useful way to write, rewrite it with these macros:
744
745 @smallexample
746 #define pointer(T) typeof(T *)
747 #define array(T, N) typeof(T [N])
748 @end smallexample
749
750 @noindent
751 Now the declaration can be rewritten this way:
752
753 @smallexample
754 array (pointer (char), 4) y;
755 @end smallexample
756
757 @noindent
758 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
759 pointers to @code{char}.
760 @end itemize
761
762 In GNU C, but not GNU C++, you may also declare the type of a variable
763 as @code{__auto_type}. In that case, the declaration must declare
764 only one variable, whose declarator must just be an identifier, the
765 declaration must be initialized, and the type of the variable is
766 determined by the initializer; the name of the variable is not in
767 scope until after the initializer. (In C++, you should use C++11
768 @code{auto} for this purpose.) Using @code{__auto_type}, the
769 ``maximum'' macro above could be written as:
770
771 @smallexample
772 #define max(a,b) \
773 (@{ __auto_type _a = (a); \
774 __auto_type _b = (b); \
775 _a > _b ? _a : _b; @})
776 @end smallexample
777
778 Using @code{__auto_type} instead of @code{typeof} has two advantages:
779
780 @itemize @bullet
781 @item Each argument to the macro appears only once in the expansion of
782 the macro. This prevents the size of the macro expansion growing
783 exponentially when calls to such macros are nested inside arguments of
784 such macros.
785
786 @item If the argument to the macro has variably modified type, it is
787 evaluated only once when using @code{__auto_type}, but twice if
788 @code{typeof} is used.
789 @end itemize
790
791 @node Conditionals
792 @section Conditionals with Omitted Operands
793 @cindex conditional expressions, extensions
794 @cindex omitted middle-operands
795 @cindex middle-operands, omitted
796 @cindex extensions, @code{?:}
797 @cindex @code{?:} extensions
798
799 The middle operand in a conditional expression may be omitted. Then
800 if the first operand is nonzero, its value is the value of the conditional
801 expression.
802
803 Therefore, the expression
804
805 @smallexample
806 x ? : y
807 @end smallexample
808
809 @noindent
810 has the value of @code{x} if that is nonzero; otherwise, the value of
811 @code{y}.
812
813 This example is perfectly equivalent to
814
815 @smallexample
816 x ? x : y
817 @end smallexample
818
819 @cindex side effect in @code{?:}
820 @cindex @code{?:} side effect
821 @noindent
822 In this simple case, the ability to omit the middle operand is not
823 especially useful. When it becomes useful is when the first operand does,
824 or may (if it is a macro argument), contain a side effect. Then repeating
825 the operand in the middle would perform the side effect twice. Omitting
826 the middle operand uses the value already computed without the undesirable
827 effects of recomputing it.
828
829 @node __int128
830 @section 128-bit Integers
831 @cindex @code{__int128} data types
832
833 As an extension the integer scalar type @code{__int128} is supported for
834 targets which have an integer mode wide enough to hold 128 bits.
835 Simply write @code{__int128} for a signed 128-bit integer, or
836 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
837 support in GCC for expressing an integer constant of type @code{__int128}
838 for targets with @code{long long} integer less than 128 bits wide.
839
840 @node Long Long
841 @section Double-Word Integers
842 @cindex @code{long long} data types
843 @cindex double-word arithmetic
844 @cindex multiprecision arithmetic
845 @cindex @code{LL} integer suffix
846 @cindex @code{ULL} integer suffix
847
848 ISO C99 supports data types for integers that are at least 64 bits wide,
849 and as an extension GCC supports them in C90 mode and in C++.
850 Simply write @code{long long int} for a signed integer, or
851 @code{unsigned long long int} for an unsigned integer. To make an
852 integer constant of type @code{long long int}, add the suffix @samp{LL}
853 to the integer. To make an integer constant of type @code{unsigned long
854 long int}, add the suffix @samp{ULL} to the integer.
855
856 You can use these types in arithmetic like any other integer types.
857 Addition, subtraction, and bitwise boolean operations on these types
858 are open-coded on all types of machines. Multiplication is open-coded
859 if the machine supports a fullword-to-doubleword widening multiply
860 instruction. Division and shifts are open-coded only on machines that
861 provide special support. The operations that are not open-coded use
862 special library routines that come with GCC@.
863
864 There may be pitfalls when you use @code{long long} types for function
865 arguments without function prototypes. If a function
866 expects type @code{int} for its argument, and you pass a value of type
867 @code{long long int}, confusion results because the caller and the
868 subroutine disagree about the number of bytes for the argument.
869 Likewise, if the function expects @code{long long int} and you pass
870 @code{int}. The best way to avoid such problems is to use prototypes.
871
872 @node Complex
873 @section Complex Numbers
874 @cindex complex numbers
875 @cindex @code{_Complex} keyword
876 @cindex @code{__complex__} keyword
877
878 ISO C99 supports complex floating data types, and as an extension GCC
879 supports them in C90 mode and in C++. GCC also supports complex integer data
880 types which are not part of ISO C99. You can declare complex types
881 using the keyword @code{_Complex}. As an extension, the older GNU
882 keyword @code{__complex__} is also supported.
883
884 For example, @samp{_Complex double x;} declares @code{x} as a
885 variable whose real part and imaginary part are both of type
886 @code{double}. @samp{_Complex short int y;} declares @code{y} to
887 have real and imaginary parts of type @code{short int}; this is not
888 likely to be useful, but it shows that the set of complex types is
889 complete.
890
891 To write a constant with a complex data type, use the suffix @samp{i} or
892 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
893 has type @code{_Complex float} and @code{3i} has type
894 @code{_Complex int}. Such a constant always has a pure imaginary
895 value, but you can form any complex value you like by adding one to a
896 real constant. This is a GNU extension; if you have an ISO C99
897 conforming C library (such as the GNU C Library), and want to construct complex
898 constants of floating type, you should include @code{<complex.h>} and
899 use the macros @code{I} or @code{_Complex_I} instead.
900
901 @cindex @code{__real__} keyword
902 @cindex @code{__imag__} keyword
903 To extract the real part of a complex-valued expression @var{exp}, write
904 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
905 extract the imaginary part. This is a GNU extension; for values of
906 floating type, you should use the ISO C99 functions @code{crealf},
907 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
908 @code{cimagl}, declared in @code{<complex.h>} and also provided as
909 built-in functions by GCC@.
910
911 @cindex complex conjugation
912 The operator @samp{~} performs complex conjugation when used on a value
913 with a complex type. This is a GNU extension; for values of
914 floating type, you should use the ISO C99 functions @code{conjf},
915 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
916 provided as built-in functions by GCC@.
917
918 GCC can allocate complex automatic variables in a noncontiguous
919 fashion; it's even possible for the real part to be in a register while
920 the imaginary part is on the stack (or vice versa). Only the DWARF
921 debug info format can represent this, so use of DWARF is recommended.
922 If you are using the stabs debug info format, GCC describes a noncontiguous
923 complex variable as if it were two separate variables of noncomplex type.
924 If the variable's actual name is @code{foo}, the two fictitious
925 variables are named @code{foo$real} and @code{foo$imag}. You can
926 examine and set these two fictitious variables with your debugger.
927
928 @node Floating Types
929 @section Additional Floating Types
930 @cindex additional floating types
931 @cindex @code{_Float@var{n}} data types
932 @cindex @code{_Float@var{n}x} data types
933 @cindex @code{__float80} data type
934 @cindex @code{__float128} data type
935 @cindex @code{__ibm128} data type
936 @cindex @code{w} floating point suffix
937 @cindex @code{q} floating point suffix
938 @cindex @code{W} floating point suffix
939 @cindex @code{Q} floating point suffix
940
941 ISO/IEC TS 18661-3:2015 defines C support for additional floating
942 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
943 these type names; the set of types supported depends on the target
944 architecture. These types are not supported when compiling C++.
945 Constants with these types use suffixes @code{f@var{n}} or
946 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}. These type
947 names can be used together with @code{_Complex} to declare complex
948 types.
949
950 As an extension, GNU C and GNU C++ support additional floating
951 types, which are not supported by all targets.
952 @itemize @bullet
953 @item @code{__float128} is available on i386, x86_64, IA-64, and
954 hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable
955 the vector scalar (VSX) instruction set. @code{__float128} supports
956 the 128-bit floating type. On i386, x86_64, PowerPC, and IA-64
957 other than HP-UX, @code{__float128} is an alias for @code{_Float128}.
958 On hppa and IA-64 HP-UX, @code{__float128} is an alias for @code{long
959 double}.
960
961 @item @code{__float80} is available on the i386, x86_64, and IA-64
962 targets, and supports the 80-bit (@code{XFmode}) floating type. It is
963 an alias for the type name @code{_Float64x} on these targets.
964
965 @item @code{__ibm128} is available on PowerPC targets, and provides
966 access to the IBM extended double format which is the current format
967 used for @code{long double}. When @code{long double} transitions to
968 @code{__float128} on PowerPC in the future, @code{__ibm128} will remain
969 for use in conversions between the two types.
970 @end itemize
971
972 Support for these additional types includes the arithmetic operators:
973 add, subtract, multiply, divide; unary arithmetic operators;
974 relational operators; equality operators; and conversions to and from
975 integer and other floating types. Use a suffix @samp{w} or @samp{W}
976 in a literal constant of type @code{__float80} or type
977 @code{__ibm128}. Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
978
979 In order to use @code{_Float128}, @code{__float128}, and @code{__ibm128}
980 on PowerPC Linux systems, you must use the @option{-mfloat128} option. It is
981 expected in future versions of GCC that @code{_Float128} and @code{__float128}
982 will be enabled automatically.
983
984 The @code{_Float128} type is supported on all systems where
985 @code{__float128} is supported or where @code{long double} has the
986 IEEE binary128 format. The @code{_Float64x} type is supported on all
987 systems where @code{__float128} is supported. The @code{_Float32}
988 type is supported on all systems supporting IEEE binary32; the
989 @code{_Float64} and @code{_Float32x} types are supported on all systems
990 supporting IEEE binary64. The @code{_Float16} type is supported on AArch64
991 systems by default, and on ARM systems when the IEEE format for 16-bit
992 floating-point types is selected with @option{-mfp16-format=ieee}.
993 GCC does not currently support @code{_Float128x} on any systems.
994
995 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
996 types using the corresponding internal complex type, @code{XCmode} for
997 @code{__float80} type and @code{TCmode} for @code{__float128} type:
998
999 @smallexample
1000 typedef _Complex float __attribute__((mode(TC))) _Complex128;
1001 typedef _Complex float __attribute__((mode(XC))) _Complex80;
1002 @end smallexample
1003
1004 On the PowerPC Linux VSX targets, you can declare complex types using
1005 the corresponding internal complex type, @code{KCmode} for
1006 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
1007
1008 @smallexample
1009 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
1010 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
1011 @end smallexample
1012
1013 @node Half-Precision
1014 @section Half-Precision Floating Point
1015 @cindex half-precision floating point
1016 @cindex @code{__fp16} data type
1017
1018 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1019 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1020 On ARM systems, you must enable this type explicitly with the
1021 @option{-mfp16-format} command-line option in order to use it.
1022
1023 ARM targets support two incompatible representations for half-precision
1024 floating-point values. You must choose one of the representations and
1025 use it consistently in your program.
1026
1027 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1028 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1029 There are 11 bits of significand precision, approximately 3
1030 decimal digits.
1031
1032 Specifying @option{-mfp16-format=alternative} selects the ARM
1033 alternative format. This representation is similar to the IEEE
1034 format, but does not support infinities or NaNs. Instead, the range
1035 of exponents is extended, so that this format can represent normalized
1036 values in the range of @math{2^{-14}} to 131008.
1037
1038 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1039 not require use of the @option{-mfp16-format} command-line option.
1040
1041 The @code{__fp16} type may only be used as an argument to intrinsics defined
1042 in @code{<arm_fp16.h>}, or as a storage format. For purposes of
1043 arithmetic and other operations, @code{__fp16} values in C or C++
1044 expressions are automatically promoted to @code{float}.
1045
1046 The ARM target provides hardware support for conversions between
1047 @code{__fp16} and @code{float} values
1048 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8 provides
1049 hardware support for conversions between @code{__fp16} and @code{double}
1050 values. GCC generates code using these hardware instructions if you
1051 compile with options to select an FPU that provides them;
1052 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1053 in addition to the @option{-mfp16-format} option to select
1054 a half-precision format.
1055
1056 Language-level support for the @code{__fp16} data type is
1057 independent of whether GCC generates code using hardware floating-point
1058 instructions. In cases where hardware support is not specified, GCC
1059 implements conversions between @code{__fp16} and other types as library
1060 calls.
1061
1062 It is recommended that portable code use the @code{_Float16} type defined
1063 by ISO/IEC TS 18661-3:2015. @xref{Floating Types}.
1064
1065 @node Decimal Float
1066 @section Decimal Floating Types
1067 @cindex decimal floating types
1068 @cindex @code{_Decimal32} data type
1069 @cindex @code{_Decimal64} data type
1070 @cindex @code{_Decimal128} data type
1071 @cindex @code{df} integer suffix
1072 @cindex @code{dd} integer suffix
1073 @cindex @code{dl} integer suffix
1074 @cindex @code{DF} integer suffix
1075 @cindex @code{DD} integer suffix
1076 @cindex @code{DL} integer suffix
1077
1078 As an extension, GNU C supports decimal floating types as
1079 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1080 floating types in GCC will evolve as the draft technical report changes.
1081 Calling conventions for any target might also change. Not all targets
1082 support decimal floating types.
1083
1084 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1085 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1086 @code{float}, @code{double}, and @code{long double} whose radix is not
1087 specified by the C standard but is usually two.
1088
1089 Support for decimal floating types includes the arithmetic operators
1090 add, subtract, multiply, divide; unary arithmetic operators;
1091 relational operators; equality operators; and conversions to and from
1092 integer and other floating types. Use a suffix @samp{df} or
1093 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1094 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1095 @code{_Decimal128}.
1096
1097 GCC support of decimal float as specified by the draft technical report
1098 is incomplete:
1099
1100 @itemize @bullet
1101 @item
1102 When the value of a decimal floating type cannot be represented in the
1103 integer type to which it is being converted, the result is undefined
1104 rather than the result value specified by the draft technical report.
1105
1106 @item
1107 GCC does not provide the C library functionality associated with
1108 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1109 @file{wchar.h}, which must come from a separate C library implementation.
1110 Because of this the GNU C compiler does not define macro
1111 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1112 the technical report.
1113 @end itemize
1114
1115 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1116 are supported by the DWARF debug information format.
1117
1118 @node Hex Floats
1119 @section Hex Floats
1120 @cindex hex floats
1121
1122 ISO C99 supports floating-point numbers written not only in the usual
1123 decimal notation, such as @code{1.55e1}, but also numbers such as
1124 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1125 supports this in C90 mode (except in some cases when strictly
1126 conforming) and in C++. In that format the
1127 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1128 mandatory. The exponent is a decimal number that indicates the power of
1129 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1130 @tex
1131 $1 {15\over16}$,
1132 @end tex
1133 @ifnottex
1134 1 15/16,
1135 @end ifnottex
1136 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1137 is the same as @code{1.55e1}.
1138
1139 Unlike for floating-point numbers in the decimal notation the exponent
1140 is always required in the hexadecimal notation. Otherwise the compiler
1141 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1142 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1143 extension for floating-point constants of type @code{float}.
1144
1145 @node Fixed-Point
1146 @section Fixed-Point Types
1147 @cindex fixed-point types
1148 @cindex @code{_Fract} data type
1149 @cindex @code{_Accum} data type
1150 @cindex @code{_Sat} data type
1151 @cindex @code{hr} fixed-suffix
1152 @cindex @code{r} fixed-suffix
1153 @cindex @code{lr} fixed-suffix
1154 @cindex @code{llr} fixed-suffix
1155 @cindex @code{uhr} fixed-suffix
1156 @cindex @code{ur} fixed-suffix
1157 @cindex @code{ulr} fixed-suffix
1158 @cindex @code{ullr} fixed-suffix
1159 @cindex @code{hk} fixed-suffix
1160 @cindex @code{k} fixed-suffix
1161 @cindex @code{lk} fixed-suffix
1162 @cindex @code{llk} fixed-suffix
1163 @cindex @code{uhk} fixed-suffix
1164 @cindex @code{uk} fixed-suffix
1165 @cindex @code{ulk} fixed-suffix
1166 @cindex @code{ullk} fixed-suffix
1167 @cindex @code{HR} fixed-suffix
1168 @cindex @code{R} fixed-suffix
1169 @cindex @code{LR} fixed-suffix
1170 @cindex @code{LLR} fixed-suffix
1171 @cindex @code{UHR} fixed-suffix
1172 @cindex @code{UR} fixed-suffix
1173 @cindex @code{ULR} fixed-suffix
1174 @cindex @code{ULLR} fixed-suffix
1175 @cindex @code{HK} fixed-suffix
1176 @cindex @code{K} fixed-suffix
1177 @cindex @code{LK} fixed-suffix
1178 @cindex @code{LLK} fixed-suffix
1179 @cindex @code{UHK} fixed-suffix
1180 @cindex @code{UK} fixed-suffix
1181 @cindex @code{ULK} fixed-suffix
1182 @cindex @code{ULLK} fixed-suffix
1183
1184 As an extension, GNU C supports fixed-point types as
1185 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1186 types in GCC will evolve as the draft technical report changes.
1187 Calling conventions for any target might also change. Not all targets
1188 support fixed-point types.
1189
1190 The fixed-point types are
1191 @code{short _Fract},
1192 @code{_Fract},
1193 @code{long _Fract},
1194 @code{long long _Fract},
1195 @code{unsigned short _Fract},
1196 @code{unsigned _Fract},
1197 @code{unsigned long _Fract},
1198 @code{unsigned long long _Fract},
1199 @code{_Sat short _Fract},
1200 @code{_Sat _Fract},
1201 @code{_Sat long _Fract},
1202 @code{_Sat long long _Fract},
1203 @code{_Sat unsigned short _Fract},
1204 @code{_Sat unsigned _Fract},
1205 @code{_Sat unsigned long _Fract},
1206 @code{_Sat unsigned long long _Fract},
1207 @code{short _Accum},
1208 @code{_Accum},
1209 @code{long _Accum},
1210 @code{long long _Accum},
1211 @code{unsigned short _Accum},
1212 @code{unsigned _Accum},
1213 @code{unsigned long _Accum},
1214 @code{unsigned long long _Accum},
1215 @code{_Sat short _Accum},
1216 @code{_Sat _Accum},
1217 @code{_Sat long _Accum},
1218 @code{_Sat long long _Accum},
1219 @code{_Sat unsigned short _Accum},
1220 @code{_Sat unsigned _Accum},
1221 @code{_Sat unsigned long _Accum},
1222 @code{_Sat unsigned long long _Accum}.
1223
1224 Fixed-point data values contain fractional and optional integral parts.
1225 The format of fixed-point data varies and depends on the target machine.
1226
1227 Support for fixed-point types includes:
1228 @itemize @bullet
1229 @item
1230 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1231 @item
1232 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1233 @item
1234 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1235 @item
1236 binary shift operators (@code{<<}, @code{>>})
1237 @item
1238 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1239 @item
1240 equality operators (@code{==}, @code{!=})
1241 @item
1242 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1243 @code{<<=}, @code{>>=})
1244 @item
1245 conversions to and from integer, floating-point, or fixed-point types
1246 @end itemize
1247
1248 Use a suffix in a fixed-point literal constant:
1249 @itemize
1250 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1251 @code{_Sat short _Fract}
1252 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1253 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1254 @code{_Sat long _Fract}
1255 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1256 @code{_Sat long long _Fract}
1257 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1258 @code{_Sat unsigned short _Fract}
1259 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1260 @code{_Sat unsigned _Fract}
1261 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1262 @code{_Sat unsigned long _Fract}
1263 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1264 and @code{_Sat unsigned long long _Fract}
1265 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1266 @code{_Sat short _Accum}
1267 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1268 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1269 @code{_Sat long _Accum}
1270 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1271 @code{_Sat long long _Accum}
1272 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1273 @code{_Sat unsigned short _Accum}
1274 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1275 @code{_Sat unsigned _Accum}
1276 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1277 @code{_Sat unsigned long _Accum}
1278 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1279 and @code{_Sat unsigned long long _Accum}
1280 @end itemize
1281
1282 GCC support of fixed-point types as specified by the draft technical report
1283 is incomplete:
1284
1285 @itemize @bullet
1286 @item
1287 Pragmas to control overflow and rounding behaviors are not implemented.
1288 @end itemize
1289
1290 Fixed-point types are supported by the DWARF debug information format.
1291
1292 @node Named Address Spaces
1293 @section Named Address Spaces
1294 @cindex Named Address Spaces
1295
1296 As an extension, GNU C supports named address spaces as
1297 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1298 address spaces in GCC will evolve as the draft technical report
1299 changes. Calling conventions for any target might also change. At
1300 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1301 address spaces other than the generic address space.
1302
1303 Address space identifiers may be used exactly like any other C type
1304 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1305 document for more details.
1306
1307 @anchor{AVR Named Address Spaces}
1308 @subsection AVR Named Address Spaces
1309
1310 On the AVR target, there are several address spaces that can be used
1311 in order to put read-only data into the flash memory and access that
1312 data by means of the special instructions @code{LPM} or @code{ELPM}
1313 needed to read from flash.
1314
1315 Devices belonging to @code{avrtiny} and @code{avrxmega3} can access
1316 flash memory by means of @code{LD*} instructions because the flash
1317 memory is mapped into the RAM address space. There is @emph{no need}
1318 for language extensions like @code{__flash} or attribute
1319 @ref{AVR Variable Attributes,,@code{progmem}}.
1320 The default linker description files for these devices cater for that
1321 feature and @code{.rodata} stays in flash: The compiler just generates
1322 @code{LD*} instructions, and the linker script adds core specific
1323 offsets to all @code{.rodata} symbols: @code{0x4000} in the case of
1324 @code{avrtiny} and @code{0x8000} in the case of @code{avrxmega3}.
1325 See @ref{AVR Options} for a list of respective devices.
1326
1327 For devices not in @code{avrtiny} or @code{avrxmega3},
1328 any data including read-only data is located in RAM (the generic
1329 address space) because flash memory is not visible in the RAM address
1330 space. In order to locate read-only data in flash memory @emph{and}
1331 to generate the right instructions to access this data without
1332 using (inline) assembler code, special address spaces are needed.
1333
1334 @table @code
1335 @item __flash
1336 @cindex @code{__flash} AVR Named Address Spaces
1337 The @code{__flash} qualifier locates data in the
1338 @code{.progmem.data} section. Data is read using the @code{LPM}
1339 instruction. Pointers to this address space are 16 bits wide.
1340
1341 @item __flash1
1342 @itemx __flash2
1343 @itemx __flash3
1344 @itemx __flash4
1345 @itemx __flash5
1346 @cindex @code{__flash1} AVR Named Address Spaces
1347 @cindex @code{__flash2} AVR Named Address Spaces
1348 @cindex @code{__flash3} AVR Named Address Spaces
1349 @cindex @code{__flash4} AVR Named Address Spaces
1350 @cindex @code{__flash5} AVR Named Address Spaces
1351 These are 16-bit address spaces locating data in section
1352 @code{.progmem@var{N}.data} where @var{N} refers to
1353 address space @code{__flash@var{N}}.
1354 The compiler sets the @code{RAMPZ} segment register appropriately
1355 before reading data by means of the @code{ELPM} instruction.
1356
1357 @item __memx
1358 @cindex @code{__memx} AVR Named Address Spaces
1359 This is a 24-bit address space that linearizes flash and RAM:
1360 If the high bit of the address is set, data is read from
1361 RAM using the lower two bytes as RAM address.
1362 If the high bit of the address is clear, data is read from flash
1363 with @code{RAMPZ} set according to the high byte of the address.
1364 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1365
1366 Objects in this address space are located in @code{.progmemx.data}.
1367 @end table
1368
1369 @b{Example}
1370
1371 @smallexample
1372 char my_read (const __flash char ** p)
1373 @{
1374 /* p is a pointer to RAM that points to a pointer to flash.
1375 The first indirection of p reads that flash pointer
1376 from RAM and the second indirection reads a char from this
1377 flash address. */
1378
1379 return **p;
1380 @}
1381
1382 /* Locate array[] in flash memory */
1383 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1384
1385 int i = 1;
1386
1387 int main (void)
1388 @{
1389 /* Return 17 by reading from flash memory */
1390 return array[array[i]];
1391 @}
1392 @end smallexample
1393
1394 @noindent
1395 For each named address space supported by avr-gcc there is an equally
1396 named but uppercase built-in macro defined.
1397 The purpose is to facilitate testing if respective address space
1398 support is available or not:
1399
1400 @smallexample
1401 #ifdef __FLASH
1402 const __flash int var = 1;
1403
1404 int read_var (void)
1405 @{
1406 return var;
1407 @}
1408 #else
1409 #include <avr/pgmspace.h> /* From AVR-LibC */
1410
1411 const int var PROGMEM = 1;
1412
1413 int read_var (void)
1414 @{
1415 return (int) pgm_read_word (&var);
1416 @}
1417 #endif /* __FLASH */
1418 @end smallexample
1419
1420 @noindent
1421 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1422 locates data in flash but
1423 accesses to these data read from generic address space, i.e.@:
1424 from RAM,
1425 so that you need special accessors like @code{pgm_read_byte}
1426 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1427 together with attribute @code{progmem}.
1428
1429 @noindent
1430 @b{Limitations and caveats}
1431
1432 @itemize
1433 @item
1434 Reading across the 64@tie{}KiB section boundary of
1435 the @code{__flash} or @code{__flash@var{N}} address spaces
1436 shows undefined behavior. The only address space that
1437 supports reading across the 64@tie{}KiB flash segment boundaries is
1438 @code{__memx}.
1439
1440 @item
1441 If you use one of the @code{__flash@var{N}} address spaces
1442 you must arrange your linker script to locate the
1443 @code{.progmem@var{N}.data} sections according to your needs.
1444
1445 @item
1446 Any data or pointers to the non-generic address spaces must
1447 be qualified as @code{const}, i.e.@: as read-only data.
1448 This still applies if the data in one of these address
1449 spaces like software version number or calibration lookup table are intended to
1450 be changed after load time by, say, a boot loader. In this case
1451 the right qualification is @code{const} @code{volatile} so that the compiler
1452 must not optimize away known values or insert them
1453 as immediates into operands of instructions.
1454
1455 @item
1456 The following code initializes a variable @code{pfoo}
1457 located in static storage with a 24-bit address:
1458 @smallexample
1459 extern const __memx char foo;
1460 const __memx void *pfoo = &foo;
1461 @end smallexample
1462
1463 @item
1464 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1465 Just use vanilla C / C++ code without overhead as outlined above.
1466 Attribute @code{progmem} is supported but works differently,
1467 see @ref{AVR Variable Attributes}.
1468
1469 @end itemize
1470
1471 @subsection M32C Named Address Spaces
1472 @cindex @code{__far} M32C Named Address Spaces
1473
1474 On the M32C target, with the R8C and M16C CPU variants, variables
1475 qualified with @code{__far} are accessed using 32-bit addresses in
1476 order to access memory beyond the first 64@tie{}Ki bytes. If
1477 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1478 effect.
1479
1480 @subsection RL78 Named Address Spaces
1481 @cindex @code{__far} RL78 Named Address Spaces
1482
1483 On the RL78 target, variables qualified with @code{__far} are accessed
1484 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1485 addresses. Non-far variables are assumed to appear in the topmost
1486 64@tie{}KiB of the address space.
1487
1488 @subsection SPU Named Address Spaces
1489 @cindex @code{__ea} SPU Named Address Spaces
1490
1491 On the SPU target variables may be declared as
1492 belonging to another address space by qualifying the type with the
1493 @code{__ea} address space identifier:
1494
1495 @smallexample
1496 extern int __ea i;
1497 @end smallexample
1498
1499 @noindent
1500 The compiler generates special code to access the variable @code{i}.
1501 It may use runtime library
1502 support, or generate special machine instructions to access that address
1503 space.
1504
1505 @subsection x86 Named Address Spaces
1506 @cindex x86 named address spaces
1507
1508 On the x86 target, variables may be declared as being relative
1509 to the @code{%fs} or @code{%gs} segments.
1510
1511 @table @code
1512 @item __seg_fs
1513 @itemx __seg_gs
1514 @cindex @code{__seg_fs} x86 named address space
1515 @cindex @code{__seg_gs} x86 named address space
1516 The object is accessed with the respective segment override prefix.
1517
1518 The respective segment base must be set via some method specific to
1519 the operating system. Rather than require an expensive system call
1520 to retrieve the segment base, these address spaces are not considered
1521 to be subspaces of the generic (flat) address space. This means that
1522 explicit casts are required to convert pointers between these address
1523 spaces and the generic address space. In practice the application
1524 should cast to @code{uintptr_t} and apply the segment base offset
1525 that it installed previously.
1526
1527 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1528 defined when these address spaces are supported.
1529 @end table
1530
1531 @node Zero Length
1532 @section Arrays of Length Zero
1533 @cindex arrays of length zero
1534 @cindex zero-length arrays
1535 @cindex length-zero arrays
1536 @cindex flexible array members
1537
1538 Zero-length arrays are allowed in GNU C@. They are very useful as the
1539 last element of a structure that is really a header for a variable-length
1540 object:
1541
1542 @smallexample
1543 struct line @{
1544 int length;
1545 char contents[0];
1546 @};
1547
1548 struct line *thisline = (struct line *)
1549 malloc (sizeof (struct line) + this_length);
1550 thisline->length = this_length;
1551 @end smallexample
1552
1553 In ISO C90, you would have to give @code{contents} a length of 1, which
1554 means either you waste space or complicate the argument to @code{malloc}.
1555
1556 In ISO C99, you would use a @dfn{flexible array member}, which is
1557 slightly different in syntax and semantics:
1558
1559 @itemize @bullet
1560 @item
1561 Flexible array members are written as @code{contents[]} without
1562 the @code{0}.
1563
1564 @item
1565 Flexible array members have incomplete type, and so the @code{sizeof}
1566 operator may not be applied. As a quirk of the original implementation
1567 of zero-length arrays, @code{sizeof} evaluates to zero.
1568
1569 @item
1570 Flexible array members may only appear as the last member of a
1571 @code{struct} that is otherwise non-empty.
1572
1573 @item
1574 A structure containing a flexible array member, or a union containing
1575 such a structure (possibly recursively), may not be a member of a
1576 structure or an element of an array. (However, these uses are
1577 permitted by GCC as extensions.)
1578 @end itemize
1579
1580 Non-empty initialization of zero-length
1581 arrays is treated like any case where there are more initializer
1582 elements than the array holds, in that a suitable warning about ``excess
1583 elements in array'' is given, and the excess elements (all of them, in
1584 this case) are ignored.
1585
1586 GCC allows static initialization of flexible array members.
1587 This is equivalent to defining a new structure containing the original
1588 structure followed by an array of sufficient size to contain the data.
1589 E.g.@: in the following, @code{f1} is constructed as if it were declared
1590 like @code{f2}.
1591
1592 @smallexample
1593 struct f1 @{
1594 int x; int y[];
1595 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1596
1597 struct f2 @{
1598 struct f1 f1; int data[3];
1599 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1600 @end smallexample
1601
1602 @noindent
1603 The convenience of this extension is that @code{f1} has the desired
1604 type, eliminating the need to consistently refer to @code{f2.f1}.
1605
1606 This has symmetry with normal static arrays, in that an array of
1607 unknown size is also written with @code{[]}.
1608
1609 Of course, this extension only makes sense if the extra data comes at
1610 the end of a top-level object, as otherwise we would be overwriting
1611 data at subsequent offsets. To avoid undue complication and confusion
1612 with initialization of deeply nested arrays, we simply disallow any
1613 non-empty initialization except when the structure is the top-level
1614 object. For example:
1615
1616 @smallexample
1617 struct foo @{ int x; int y[]; @};
1618 struct bar @{ struct foo z; @};
1619
1620 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1621 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1622 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1623 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1624 @end smallexample
1625
1626 @node Empty Structures
1627 @section Structures with No Members
1628 @cindex empty structures
1629 @cindex zero-size structures
1630
1631 GCC permits a C structure to have no members:
1632
1633 @smallexample
1634 struct empty @{
1635 @};
1636 @end smallexample
1637
1638 The structure has size zero. In C++, empty structures are part
1639 of the language. G++ treats empty structures as if they had a single
1640 member of type @code{char}.
1641
1642 @node Variable Length
1643 @section Arrays of Variable Length
1644 @cindex variable-length arrays
1645 @cindex arrays of variable length
1646 @cindex VLAs
1647
1648 Variable-length automatic arrays are allowed in ISO C99, and as an
1649 extension GCC accepts them in C90 mode and in C++. These arrays are
1650 declared like any other automatic arrays, but with a length that is not
1651 a constant expression. The storage is allocated at the point of
1652 declaration and deallocated when the block scope containing the declaration
1653 exits. For
1654 example:
1655
1656 @smallexample
1657 FILE *
1658 concat_fopen (char *s1, char *s2, char *mode)
1659 @{
1660 char str[strlen (s1) + strlen (s2) + 1];
1661 strcpy (str, s1);
1662 strcat (str, s2);
1663 return fopen (str, mode);
1664 @}
1665 @end smallexample
1666
1667 @cindex scope of a variable length array
1668 @cindex variable-length array scope
1669 @cindex deallocating variable length arrays
1670 Jumping or breaking out of the scope of the array name deallocates the
1671 storage. Jumping into the scope is not allowed; you get an error
1672 message for it.
1673
1674 @cindex variable-length array in a structure
1675 As an extension, GCC accepts variable-length arrays as a member of
1676 a structure or a union. For example:
1677
1678 @smallexample
1679 void
1680 foo (int n)
1681 @{
1682 struct S @{ int x[n]; @};
1683 @}
1684 @end smallexample
1685
1686 @cindex @code{alloca} vs variable-length arrays
1687 You can use the function @code{alloca} to get an effect much like
1688 variable-length arrays. The function @code{alloca} is available in
1689 many other C implementations (but not in all). On the other hand,
1690 variable-length arrays are more elegant.
1691
1692 There are other differences between these two methods. Space allocated
1693 with @code{alloca} exists until the containing @emph{function} returns.
1694 The space for a variable-length array is deallocated as soon as the array
1695 name's scope ends, unless you also use @code{alloca} in this scope.
1696
1697 You can also use variable-length arrays as arguments to functions:
1698
1699 @smallexample
1700 struct entry
1701 tester (int len, char data[len][len])
1702 @{
1703 /* @r{@dots{}} */
1704 @}
1705 @end smallexample
1706
1707 The length of an array is computed once when the storage is allocated
1708 and is remembered for the scope of the array in case you access it with
1709 @code{sizeof}.
1710
1711 If you want to pass the array first and the length afterward, you can
1712 use a forward declaration in the parameter list---another GNU extension.
1713
1714 @smallexample
1715 struct entry
1716 tester (int len; char data[len][len], int len)
1717 @{
1718 /* @r{@dots{}} */
1719 @}
1720 @end smallexample
1721
1722 @cindex parameter forward declaration
1723 The @samp{int len} before the semicolon is a @dfn{parameter forward
1724 declaration}, and it serves the purpose of making the name @code{len}
1725 known when the declaration of @code{data} is parsed.
1726
1727 You can write any number of such parameter forward declarations in the
1728 parameter list. They can be separated by commas or semicolons, but the
1729 last one must end with a semicolon, which is followed by the ``real''
1730 parameter declarations. Each forward declaration must match a ``real''
1731 declaration in parameter name and data type. ISO C99 does not support
1732 parameter forward declarations.
1733
1734 @node Variadic Macros
1735 @section Macros with a Variable Number of Arguments.
1736 @cindex variable number of arguments
1737 @cindex macro with variable arguments
1738 @cindex rest argument (in macro)
1739 @cindex variadic macros
1740
1741 In the ISO C standard of 1999, a macro can be declared to accept a
1742 variable number of arguments much as a function can. The syntax for
1743 defining the macro is similar to that of a function. Here is an
1744 example:
1745
1746 @smallexample
1747 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1748 @end smallexample
1749
1750 @noindent
1751 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1752 such a macro, it represents the zero or more tokens until the closing
1753 parenthesis that ends the invocation, including any commas. This set of
1754 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1755 wherever it appears. See the CPP manual for more information.
1756
1757 GCC has long supported variadic macros, and used a different syntax that
1758 allowed you to give a name to the variable arguments just like any other
1759 argument. Here is an example:
1760
1761 @smallexample
1762 #define debug(format, args...) fprintf (stderr, format, args)
1763 @end smallexample
1764
1765 @noindent
1766 This is in all ways equivalent to the ISO C example above, but arguably
1767 more readable and descriptive.
1768
1769 GNU CPP has two further variadic macro extensions, and permits them to
1770 be used with either of the above forms of macro definition.
1771
1772 In standard C, you are not allowed to leave the variable argument out
1773 entirely; but you are allowed to pass an empty argument. For example,
1774 this invocation is invalid in ISO C, because there is no comma after
1775 the string:
1776
1777 @smallexample
1778 debug ("A message")
1779 @end smallexample
1780
1781 GNU CPP permits you to completely omit the variable arguments in this
1782 way. In the above examples, the compiler would complain, though since
1783 the expansion of the macro still has the extra comma after the format
1784 string.
1785
1786 To help solve this problem, CPP behaves specially for variable arguments
1787 used with the token paste operator, @samp{##}. If instead you write
1788
1789 @smallexample
1790 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1791 @end smallexample
1792
1793 @noindent
1794 and if the variable arguments are omitted or empty, the @samp{##}
1795 operator causes the preprocessor to remove the comma before it. If you
1796 do provide some variable arguments in your macro invocation, GNU CPP
1797 does not complain about the paste operation and instead places the
1798 variable arguments after the comma. Just like any other pasted macro
1799 argument, these arguments are not macro expanded.
1800
1801 @node Escaped Newlines
1802 @section Slightly Looser Rules for Escaped Newlines
1803 @cindex escaped newlines
1804 @cindex newlines (escaped)
1805
1806 The preprocessor treatment of escaped newlines is more relaxed
1807 than that specified by the C90 standard, which requires the newline
1808 to immediately follow a backslash.
1809 GCC's implementation allows whitespace in the form
1810 of spaces, horizontal and vertical tabs, and form feeds between the
1811 backslash and the subsequent newline. The preprocessor issues a
1812 warning, but treats it as a valid escaped newline and combines the two
1813 lines to form a single logical line. This works within comments and
1814 tokens, as well as between tokens. Comments are @emph{not} treated as
1815 whitespace for the purposes of this relaxation, since they have not
1816 yet been replaced with spaces.
1817
1818 @node Subscripting
1819 @section Non-Lvalue Arrays May Have Subscripts
1820 @cindex subscripting
1821 @cindex arrays, non-lvalue
1822
1823 @cindex subscripting and function values
1824 In ISO C99, arrays that are not lvalues still decay to pointers, and
1825 may be subscripted, although they may not be modified or used after
1826 the next sequence point and the unary @samp{&} operator may not be
1827 applied to them. As an extension, GNU C allows such arrays to be
1828 subscripted in C90 mode, though otherwise they do not decay to
1829 pointers outside C99 mode. For example,
1830 this is valid in GNU C though not valid in C90:
1831
1832 @smallexample
1833 @group
1834 struct foo @{int a[4];@};
1835
1836 struct foo f();
1837
1838 bar (int index)
1839 @{
1840 return f().a[index];
1841 @}
1842 @end group
1843 @end smallexample
1844
1845 @node Pointer Arith
1846 @section Arithmetic on @code{void}- and Function-Pointers
1847 @cindex void pointers, arithmetic
1848 @cindex void, size of pointer to
1849 @cindex function pointers, arithmetic
1850 @cindex function, size of pointer to
1851
1852 In GNU C, addition and subtraction operations are supported on pointers to
1853 @code{void} and on pointers to functions. This is done by treating the
1854 size of a @code{void} or of a function as 1.
1855
1856 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1857 and on function types, and returns 1.
1858
1859 @opindex Wpointer-arith
1860 The option @option{-Wpointer-arith} requests a warning if these extensions
1861 are used.
1862
1863 @node Pointers to Arrays
1864 @section Pointers to Arrays with Qualifiers Work as Expected
1865 @cindex pointers to arrays
1866 @cindex const qualifier
1867
1868 In GNU C, pointers to arrays with qualifiers work similar to pointers
1869 to other qualified types. For example, a value of type @code{int (*)[5]}
1870 can be used to initialize a variable of type @code{const int (*)[5]}.
1871 These types are incompatible in ISO C because the @code{const} qualifier
1872 is formally attached to the element type of the array and not the
1873 array itself.
1874
1875 @smallexample
1876 extern void
1877 transpose (int N, int M, double out[M][N], const double in[N][M]);
1878 double x[3][2];
1879 double y[2][3];
1880 @r{@dots{}}
1881 transpose(3, 2, y, x);
1882 @end smallexample
1883
1884 @node Initializers
1885 @section Non-Constant Initializers
1886 @cindex initializers, non-constant
1887 @cindex non-constant initializers
1888
1889 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1890 automatic variable are not required to be constant expressions in GNU C@.
1891 Here is an example of an initializer with run-time varying elements:
1892
1893 @smallexample
1894 foo (float f, float g)
1895 @{
1896 float beat_freqs[2] = @{ f-g, f+g @};
1897 /* @r{@dots{}} */
1898 @}
1899 @end smallexample
1900
1901 @node Compound Literals
1902 @section Compound Literals
1903 @cindex constructor expressions
1904 @cindex initializations in expressions
1905 @cindex structures, constructor expression
1906 @cindex expressions, constructor
1907 @cindex compound literals
1908 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1909
1910 A compound literal looks like a cast of a brace-enclosed aggregate
1911 initializer list. Its value is an object of the type specified in
1912 the cast, containing the elements specified in the initializer.
1913 Unlike the result of a cast, a compound literal is an lvalue. ISO
1914 C99 and later support compound literals. As an extension, GCC
1915 supports compound literals also in C90 mode and in C++, although
1916 as explained below, the C++ semantics are somewhat different.
1917
1918 Usually, the specified type of a compound literal is a structure. Assume
1919 that @code{struct foo} and @code{structure} are declared as shown:
1920
1921 @smallexample
1922 struct foo @{int a; char b[2];@} structure;
1923 @end smallexample
1924
1925 @noindent
1926 Here is an example of constructing a @code{struct foo} with a compound literal:
1927
1928 @smallexample
1929 structure = ((struct foo) @{x + y, 'a', 0@});
1930 @end smallexample
1931
1932 @noindent
1933 This is equivalent to writing the following:
1934
1935 @smallexample
1936 @{
1937 struct foo temp = @{x + y, 'a', 0@};
1938 structure = temp;
1939 @}
1940 @end smallexample
1941
1942 You can also construct an array, though this is dangerous in C++, as
1943 explained below. If all the elements of the compound literal are
1944 (made up of) simple constant expressions suitable for use in
1945 initializers of objects of static storage duration, then the compound
1946 literal can be coerced to a pointer to its first element and used in
1947 such an initializer, as shown here:
1948
1949 @smallexample
1950 char **foo = (char *[]) @{ "x", "y", "z" @};
1951 @end smallexample
1952
1953 Compound literals for scalar types and union types are also allowed. In
1954 the following example the variable @code{i} is initialized to the value
1955 @code{2}, the result of incrementing the unnamed object created by
1956 the compound literal.
1957
1958 @smallexample
1959 int i = ++(int) @{ 1 @};
1960 @end smallexample
1961
1962 As a GNU extension, GCC allows initialization of objects with static storage
1963 duration by compound literals (which is not possible in ISO C99 because
1964 the initializer is not a constant).
1965 It is handled as if the object were initialized only with the brace-enclosed
1966 list if the types of the compound literal and the object match.
1967 The elements of the compound literal must be constant.
1968 If the object being initialized has array type of unknown size, the size is
1969 determined by the size of the compound literal.
1970
1971 @smallexample
1972 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1973 static int y[] = (int []) @{1, 2, 3@};
1974 static int z[] = (int [3]) @{1@};
1975 @end smallexample
1976
1977 @noindent
1978 The above lines are equivalent to the following:
1979 @smallexample
1980 static struct foo x = @{1, 'a', 'b'@};
1981 static int y[] = @{1, 2, 3@};
1982 static int z[] = @{1, 0, 0@};
1983 @end smallexample
1984
1985 In C, a compound literal designates an unnamed object with static or
1986 automatic storage duration. In C++, a compound literal designates a
1987 temporary object that only lives until the end of its full-expression.
1988 As a result, well-defined C code that takes the address of a subobject
1989 of a compound literal can be undefined in C++, so G++ rejects
1990 the conversion of a temporary array to a pointer. For instance, if
1991 the array compound literal example above appeared inside a function,
1992 any subsequent use of @code{foo} in C++ would have undefined behavior
1993 because the lifetime of the array ends after the declaration of @code{foo}.
1994
1995 As an optimization, G++ sometimes gives array compound literals longer
1996 lifetimes: when the array either appears outside a function or has
1997 a @code{const}-qualified type. If @code{foo} and its initializer had
1998 elements of type @code{char *const} rather than @code{char *}, or if
1999 @code{foo} were a global variable, the array would have static storage
2000 duration. But it is probably safest just to avoid the use of array
2001 compound literals in C++ code.
2002
2003 @node Designated Inits
2004 @section Designated Initializers
2005 @cindex initializers with labeled elements
2006 @cindex labeled elements in initializers
2007 @cindex case labels in initializers
2008 @cindex designated initializers
2009
2010 Standard C90 requires the elements of an initializer to appear in a fixed
2011 order, the same as the order of the elements in the array or structure
2012 being initialized.
2013
2014 In ISO C99 you can give the elements in any order, specifying the array
2015 indices or structure field names they apply to, and GNU C allows this as
2016 an extension in C90 mode as well. This extension is not
2017 implemented in GNU C++.
2018
2019 To specify an array index, write
2020 @samp{[@var{index}] =} before the element value. For example,
2021
2022 @smallexample
2023 int a[6] = @{ [4] = 29, [2] = 15 @};
2024 @end smallexample
2025
2026 @noindent
2027 is equivalent to
2028
2029 @smallexample
2030 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2031 @end smallexample
2032
2033 @noindent
2034 The index values must be constant expressions, even if the array being
2035 initialized is automatic.
2036
2037 An alternative syntax for this that has been obsolete since GCC 2.5 but
2038 GCC still accepts is to write @samp{[@var{index}]} before the element
2039 value, with no @samp{=}.
2040
2041 To initialize a range of elements to the same value, write
2042 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
2043 extension. For example,
2044
2045 @smallexample
2046 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2047 @end smallexample
2048
2049 @noindent
2050 If the value in it has side-effects, the side-effects happen only once,
2051 not for each initialized field by the range initializer.
2052
2053 @noindent
2054 Note that the length of the array is the highest value specified
2055 plus one.
2056
2057 In a structure initializer, specify the name of a field to initialize
2058 with @samp{.@var{fieldname} =} before the element value. For example,
2059 given the following structure,
2060
2061 @smallexample
2062 struct point @{ int x, y; @};
2063 @end smallexample
2064
2065 @noindent
2066 the following initialization
2067
2068 @smallexample
2069 struct point p = @{ .y = yvalue, .x = xvalue @};
2070 @end smallexample
2071
2072 @noindent
2073 is equivalent to
2074
2075 @smallexample
2076 struct point p = @{ xvalue, yvalue @};
2077 @end smallexample
2078
2079 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2080 @samp{@var{fieldname}:}, as shown here:
2081
2082 @smallexample
2083 struct point p = @{ y: yvalue, x: xvalue @};
2084 @end smallexample
2085
2086 Omitted field members are implicitly initialized the same as objects
2087 that have static storage duration.
2088
2089 @cindex designators
2090 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2091 @dfn{designator}. You can also use a designator (or the obsolete colon
2092 syntax) when initializing a union, to specify which element of the union
2093 should be used. For example,
2094
2095 @smallexample
2096 union foo @{ int i; double d; @};
2097
2098 union foo f = @{ .d = 4 @};
2099 @end smallexample
2100
2101 @noindent
2102 converts 4 to a @code{double} to store it in the union using
2103 the second element. By contrast, casting 4 to type @code{union foo}
2104 stores it into the union as the integer @code{i}, since it is
2105 an integer. @xref{Cast to Union}.
2106
2107 You can combine this technique of naming elements with ordinary C
2108 initialization of successive elements. Each initializer element that
2109 does not have a designator applies to the next consecutive element of the
2110 array or structure. For example,
2111
2112 @smallexample
2113 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2114 @end smallexample
2115
2116 @noindent
2117 is equivalent to
2118
2119 @smallexample
2120 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2121 @end smallexample
2122
2123 Labeling the elements of an array initializer is especially useful
2124 when the indices are characters or belong to an @code{enum} type.
2125 For example:
2126
2127 @smallexample
2128 int whitespace[256]
2129 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2130 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2131 @end smallexample
2132
2133 @cindex designator lists
2134 You can also write a series of @samp{.@var{fieldname}} and
2135 @samp{[@var{index}]} designators before an @samp{=} to specify a
2136 nested subobject to initialize; the list is taken relative to the
2137 subobject corresponding to the closest surrounding brace pair. For
2138 example, with the @samp{struct point} declaration above:
2139
2140 @smallexample
2141 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2142 @end smallexample
2143
2144 @noindent
2145 If the same field is initialized multiple times, it has the value from
2146 the last initialization. If any such overridden initialization has
2147 side-effect, it is unspecified whether the side-effect happens or not.
2148 Currently, GCC discards them and issues a warning.
2149
2150 @node Case Ranges
2151 @section Case Ranges
2152 @cindex case ranges
2153 @cindex ranges in case statements
2154
2155 You can specify a range of consecutive values in a single @code{case} label,
2156 like this:
2157
2158 @smallexample
2159 case @var{low} ... @var{high}:
2160 @end smallexample
2161
2162 @noindent
2163 This has the same effect as the proper number of individual @code{case}
2164 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2165
2166 This feature is especially useful for ranges of ASCII character codes:
2167
2168 @smallexample
2169 case 'A' ... 'Z':
2170 @end smallexample
2171
2172 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2173 it may be parsed wrong when you use it with integer values. For example,
2174 write this:
2175
2176 @smallexample
2177 case 1 ... 5:
2178 @end smallexample
2179
2180 @noindent
2181 rather than this:
2182
2183 @smallexample
2184 case 1...5:
2185 @end smallexample
2186
2187 @node Cast to Union
2188 @section Cast to a Union Type
2189 @cindex cast to a union
2190 @cindex union, casting to a
2191
2192 A cast to union type looks similar to other casts, except that the type
2193 specified is a union type. You can specify the type either with the
2194 @code{union} keyword or with a @code{typedef} name that refers to
2195 a union. A cast to a union actually creates a compound literal and
2196 yields an lvalue, not an rvalue like true casts do.
2197 @xref{Compound Literals}.
2198
2199 The types that may be cast to the union type are those of the members
2200 of the union. Thus, given the following union and variables:
2201
2202 @smallexample
2203 union foo @{ int i; double d; @};
2204 int x;
2205 double y;
2206 @end smallexample
2207
2208 @noindent
2209 both @code{x} and @code{y} can be cast to type @code{union foo}.
2210
2211 Using the cast as the right-hand side of an assignment to a variable of
2212 union type is equivalent to storing in a member of the union:
2213
2214 @smallexample
2215 union foo u;
2216 /* @r{@dots{}} */
2217 u = (union foo) x @equiv{} u.i = x
2218 u = (union foo) y @equiv{} u.d = y
2219 @end smallexample
2220
2221 You can also use the union cast as a function argument:
2222
2223 @smallexample
2224 void hack (union foo);
2225 /* @r{@dots{}} */
2226 hack ((union foo) x);
2227 @end smallexample
2228
2229 @node Mixed Declarations
2230 @section Mixed Declarations and Code
2231 @cindex mixed declarations and code
2232 @cindex declarations, mixed with code
2233 @cindex code, mixed with declarations
2234
2235 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2236 within compound statements. As an extension, GNU C also allows this in
2237 C90 mode. For example, you could do:
2238
2239 @smallexample
2240 int i;
2241 /* @r{@dots{}} */
2242 i++;
2243 int j = i + 2;
2244 @end smallexample
2245
2246 Each identifier is visible from where it is declared until the end of
2247 the enclosing block.
2248
2249 @node Function Attributes
2250 @section Declaring Attributes of Functions
2251 @cindex function attributes
2252 @cindex declaring attributes of functions
2253 @cindex @code{volatile} applied to function
2254 @cindex @code{const} applied to function
2255
2256 In GNU C, you can use function attributes to declare certain things
2257 about functions called in your program which help the compiler
2258 optimize calls and check your code more carefully. For example, you
2259 can use attributes to declare that a function never returns
2260 (@code{noreturn}), returns a value depending only on its arguments
2261 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2262
2263 You can also use attributes to control memory placement, code
2264 generation options or call/return conventions within the function
2265 being annotated. Many of these attributes are target-specific. For
2266 example, many targets support attributes for defining interrupt
2267 handler functions, which typically must follow special register usage
2268 and return conventions.
2269
2270 Function attributes are introduced by the @code{__attribute__} keyword
2271 on a declaration, followed by an attribute specification inside double
2272 parentheses. You can specify multiple attributes in a declaration by
2273 separating them by commas within the double parentheses or by
2274 immediately following an attribute declaration with another attribute
2275 declaration. @xref{Attribute Syntax}, for the exact rules on
2276 attribute syntax and placement.
2277
2278 GCC also supports attributes on
2279 variable declarations (@pxref{Variable Attributes}),
2280 labels (@pxref{Label Attributes}),
2281 enumerators (@pxref{Enumerator Attributes}),
2282 statements (@pxref{Statement Attributes}),
2283 and types (@pxref{Type Attributes}).
2284
2285 There is some overlap between the purposes of attributes and pragmas
2286 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2287 found convenient to use @code{__attribute__} to achieve a natural
2288 attachment of attributes to their corresponding declarations, whereas
2289 @code{#pragma} is of use for compatibility with other compilers
2290 or constructs that do not naturally form part of the grammar.
2291
2292 In addition to the attributes documented here,
2293 GCC plugins may provide their own attributes.
2294
2295 @menu
2296 * Common Function Attributes::
2297 * AArch64 Function Attributes::
2298 * ARC Function Attributes::
2299 * ARM Function Attributes::
2300 * AVR Function Attributes::
2301 * Blackfin Function Attributes::
2302 * CR16 Function Attributes::
2303 * Epiphany Function Attributes::
2304 * H8/300 Function Attributes::
2305 * IA-64 Function Attributes::
2306 * M32C Function Attributes::
2307 * M32R/D Function Attributes::
2308 * m68k Function Attributes::
2309 * MCORE Function Attributes::
2310 * MeP Function Attributes::
2311 * MicroBlaze Function Attributes::
2312 * Microsoft Windows Function Attributes::
2313 * MIPS Function Attributes::
2314 * MSP430 Function Attributes::
2315 * NDS32 Function Attributes::
2316 * Nios II Function Attributes::
2317 * Nvidia PTX Function Attributes::
2318 * PowerPC Function Attributes::
2319 * RL78 Function Attributes::
2320 * RX Function Attributes::
2321 * S/390 Function Attributes::
2322 * SH Function Attributes::
2323 * SPU Function Attributes::
2324 * Symbian OS Function Attributes::
2325 * V850 Function Attributes::
2326 * Visium Function Attributes::
2327 * x86 Function Attributes::
2328 * Xstormy16 Function Attributes::
2329 @end menu
2330
2331 @node Common Function Attributes
2332 @subsection Common Function Attributes
2333
2334 The following attributes are supported on most targets.
2335
2336 @table @code
2337 @c Keep this table alphabetized by attribute name. Treat _ as space.
2338
2339 @item alias ("@var{target}")
2340 @cindex @code{alias} function attribute
2341 The @code{alias} attribute causes the declaration to be emitted as an
2342 alias for another symbol, which must be specified. For instance,
2343
2344 @smallexample
2345 void __f () @{ /* @r{Do something.} */; @}
2346 void f () __attribute__ ((weak, alias ("__f")));
2347 @end smallexample
2348
2349 @noindent
2350 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2351 mangled name for the target must be used. It is an error if @samp{__f}
2352 is not defined in the same translation unit.
2353
2354 This attribute requires assembler and object file support,
2355 and may not be available on all targets.
2356
2357 @item aligned (@var{alignment})
2358 @cindex @code{aligned} function attribute
2359 This attribute specifies a minimum alignment for the function,
2360 measured in bytes.
2361
2362 You cannot use this attribute to decrease the alignment of a function,
2363 only to increase it. However, when you explicitly specify a function
2364 alignment this overrides the effect of the
2365 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2366 function.
2367
2368 Note that the effectiveness of @code{aligned} attributes may be
2369 limited by inherent limitations in your linker. On many systems, the
2370 linker is only able to arrange for functions to be aligned up to a
2371 certain maximum alignment. (For some linkers, the maximum supported
2372 alignment may be very very small.) See your linker documentation for
2373 further information.
2374
2375 The @code{aligned} attribute can also be used for variables and fields
2376 (@pxref{Variable Attributes}.)
2377
2378 @item alloc_align
2379 @cindex @code{alloc_align} function attribute
2380 The @code{alloc_align} attribute is used to tell the compiler that the
2381 function return value points to memory, where the returned pointer minimum
2382 alignment is given by one of the functions parameters. GCC uses this
2383 information to improve pointer alignment analysis.
2384
2385 The function parameter denoting the allocated alignment is specified by
2386 one integer argument, whose number is the argument of the attribute.
2387 Argument numbering starts at one.
2388
2389 For instance,
2390
2391 @smallexample
2392 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2393 @end smallexample
2394
2395 @noindent
2396 declares that @code{my_memalign} returns memory with minimum alignment
2397 given by parameter 1.
2398
2399 @item alloc_size
2400 @cindex @code{alloc_size} function attribute
2401 The @code{alloc_size} attribute is used to tell the compiler that the
2402 function return value points to memory, where the size is given by
2403 one or two of the functions parameters. GCC uses this
2404 information to improve the correctness of @code{__builtin_object_size}.
2405
2406 The function parameter(s) denoting the allocated size are specified by
2407 one or two integer arguments supplied to the attribute. The allocated size
2408 is either the value of the single function argument specified or the product
2409 of the two function arguments specified. Argument numbering starts at
2410 one.
2411
2412 For instance,
2413
2414 @smallexample
2415 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2416 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2417 @end smallexample
2418
2419 @noindent
2420 declares that @code{my_calloc} returns memory of the size given by
2421 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2422 of the size given by parameter 2.
2423
2424 @item always_inline
2425 @cindex @code{always_inline} function attribute
2426 Generally, functions are not inlined unless optimization is specified.
2427 For functions declared inline, this attribute inlines the function
2428 independent of any restrictions that otherwise apply to inlining.
2429 Failure to inline such a function is diagnosed as an error.
2430 Note that if such a function is called indirectly the compiler may
2431 or may not inline it depending on optimization level and a failure
2432 to inline an indirect call may or may not be diagnosed.
2433
2434 @item artificial
2435 @cindex @code{artificial} function attribute
2436 This attribute is useful for small inline wrappers that if possible
2437 should appear during debugging as a unit. Depending on the debug
2438 info format it either means marking the function as artificial
2439 or using the caller location for all instructions within the inlined
2440 body.
2441
2442 @item assume_aligned
2443 @cindex @code{assume_aligned} function attribute
2444 The @code{assume_aligned} attribute is used to tell the compiler that the
2445 function return value points to memory, where the returned pointer minimum
2446 alignment is given by the first argument.
2447 If the attribute has two arguments, the second argument is misalignment offset.
2448
2449 For instance
2450
2451 @smallexample
2452 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2453 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2454 @end smallexample
2455
2456 @noindent
2457 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2458 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2459 to 8.
2460
2461 @item bnd_instrument
2462 @cindex @code{bnd_instrument} function attribute
2463 The @code{bnd_instrument} attribute on functions is used to inform the
2464 compiler that the function should be instrumented when compiled
2465 with the @option{-fchkp-instrument-marked-only} option.
2466
2467 @item bnd_legacy
2468 @cindex @code{bnd_legacy} function attribute
2469 @cindex Pointer Bounds Checker attributes
2470 The @code{bnd_legacy} attribute on functions is used to inform the
2471 compiler that the function should not be instrumented when compiled
2472 with the @option{-fcheck-pointer-bounds} option.
2473
2474 @item cold
2475 @cindex @code{cold} function attribute
2476 The @code{cold} attribute on functions is used to inform the compiler that
2477 the function is unlikely to be executed. The function is optimized for
2478 size rather than speed and on many targets it is placed into a special
2479 subsection of the text section so all cold functions appear close together,
2480 improving code locality of non-cold parts of program. The paths leading
2481 to calls of cold functions within code are marked as unlikely by the branch
2482 prediction mechanism. It is thus useful to mark functions used to handle
2483 unlikely conditions, such as @code{perror}, as cold to improve optimization
2484 of hot functions that do call marked functions in rare occasions.
2485
2486 When profile feedback is available, via @option{-fprofile-use}, cold functions
2487 are automatically detected and this attribute is ignored.
2488
2489 @item const
2490 @cindex @code{const} function attribute
2491 @cindex functions that have no side effects
2492 Many functions do not examine any values except their arguments, and
2493 have no effects except the return value. Basically this is just slightly
2494 more strict class than the @code{pure} attribute below, since function is not
2495 allowed to read global memory.
2496
2497 @cindex pointer arguments
2498 Note that a function that has pointer arguments and examines the data
2499 pointed to must @emph{not} be declared @code{const}. Likewise, a
2500 function that calls a non-@code{const} function usually must not be
2501 @code{const}. It does not make sense for a @code{const} function to
2502 return @code{void}.
2503
2504 @item constructor
2505 @itemx destructor
2506 @itemx constructor (@var{priority})
2507 @itemx destructor (@var{priority})
2508 @cindex @code{constructor} function attribute
2509 @cindex @code{destructor} function attribute
2510 The @code{constructor} attribute causes the function to be called
2511 automatically before execution enters @code{main ()}. Similarly, the
2512 @code{destructor} attribute causes the function to be called
2513 automatically after @code{main ()} completes or @code{exit ()} is
2514 called. Functions with these attributes are useful for
2515 initializing data that is used implicitly during the execution of
2516 the program.
2517
2518 You may provide an optional integer priority to control the order in
2519 which constructor and destructor functions are run. A constructor
2520 with a smaller priority number runs before a constructor with a larger
2521 priority number; the opposite relationship holds for destructors. So,
2522 if you have a constructor that allocates a resource and a destructor
2523 that deallocates the same resource, both functions typically have the
2524 same priority. The priorities for constructor and destructor
2525 functions are the same as those specified for namespace-scope C++
2526 objects (@pxref{C++ Attributes}). However, at present, the order in which
2527 constructors for C++ objects with static storage duration and functions
2528 decorated with attribute @code{constructor} are invoked is unspecified.
2529 In mixed declarations, attribute @code{init_priority} can be used to
2530 impose a specific ordering.
2531
2532 @item deprecated
2533 @itemx deprecated (@var{msg})
2534 @cindex @code{deprecated} function attribute
2535 The @code{deprecated} attribute results in a warning if the function
2536 is used anywhere in the source file. This is useful when identifying
2537 functions that are expected to be removed in a future version of a
2538 program. The warning also includes the location of the declaration
2539 of the deprecated function, to enable users to easily find further
2540 information about why the function is deprecated, or what they should
2541 do instead. Note that the warnings only occurs for uses:
2542
2543 @smallexample
2544 int old_fn () __attribute__ ((deprecated));
2545 int old_fn ();
2546 int (*fn_ptr)() = old_fn;
2547 @end smallexample
2548
2549 @noindent
2550 results in a warning on line 3 but not line 2. The optional @var{msg}
2551 argument, which must be a string, is printed in the warning if
2552 present.
2553
2554 The @code{deprecated} attribute can also be used for variables and
2555 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2556
2557 @item error ("@var{message}")
2558 @itemx warning ("@var{message}")
2559 @cindex @code{error} function attribute
2560 @cindex @code{warning} function attribute
2561 If the @code{error} or @code{warning} attribute
2562 is used on a function declaration and a call to such a function
2563 is not eliminated through dead code elimination or other optimizations,
2564 an error or warning (respectively) that includes @var{message} is diagnosed.
2565 This is useful
2566 for compile-time checking, especially together with @code{__builtin_constant_p}
2567 and inline functions where checking the inline function arguments is not
2568 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2569
2570 While it is possible to leave the function undefined and thus invoke
2571 a link failure (to define the function with
2572 a message in @code{.gnu.warning*} section),
2573 when using these attributes the problem is diagnosed
2574 earlier and with exact location of the call even in presence of inline
2575 functions or when not emitting debugging information.
2576
2577 @item externally_visible
2578 @cindex @code{externally_visible} function attribute
2579 This attribute, attached to a global variable or function, nullifies
2580 the effect of the @option{-fwhole-program} command-line option, so the
2581 object remains visible outside the current compilation unit.
2582
2583 If @option{-fwhole-program} is used together with @option{-flto} and
2584 @command{gold} is used as the linker plugin,
2585 @code{externally_visible} attributes are automatically added to functions
2586 (not variable yet due to a current @command{gold} issue)
2587 that are accessed outside of LTO objects according to resolution file
2588 produced by @command{gold}.
2589 For other linkers that cannot generate resolution file,
2590 explicit @code{externally_visible} attributes are still necessary.
2591
2592 @item flatten
2593 @cindex @code{flatten} function attribute
2594 Generally, inlining into a function is limited. For a function marked with
2595 this attribute, every call inside this function is inlined, if possible.
2596 Whether the function itself is considered for inlining depends on its size and
2597 the current inlining parameters.
2598
2599 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2600 @cindex @code{format} function attribute
2601 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2602 @opindex Wformat
2603 The @code{format} attribute specifies that a function takes @code{printf},
2604 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2605 should be type-checked against a format string. For example, the
2606 declaration:
2607
2608 @smallexample
2609 extern int
2610 my_printf (void *my_object, const char *my_format, ...)
2611 __attribute__ ((format (printf, 2, 3)));
2612 @end smallexample
2613
2614 @noindent
2615 causes the compiler to check the arguments in calls to @code{my_printf}
2616 for consistency with the @code{printf} style format string argument
2617 @code{my_format}.
2618
2619 The parameter @var{archetype} determines how the format string is
2620 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2621 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2622 @code{strfmon}. (You can also use @code{__printf__},
2623 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2624 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2625 @code{ms_strftime} are also present.
2626 @var{archetype} values such as @code{printf} refer to the formats accepted
2627 by the system's C runtime library,
2628 while values prefixed with @samp{gnu_} always refer
2629 to the formats accepted by the GNU C Library. On Microsoft Windows
2630 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2631 @file{msvcrt.dll} library.
2632 The parameter @var{string-index}
2633 specifies which argument is the format string argument (starting
2634 from 1), while @var{first-to-check} is the number of the first
2635 argument to check against the format string. For functions
2636 where the arguments are not available to be checked (such as
2637 @code{vprintf}), specify the third parameter as zero. In this case the
2638 compiler only checks the format string for consistency. For
2639 @code{strftime} formats, the third parameter is required to be zero.
2640 Since non-static C++ methods have an implicit @code{this} argument, the
2641 arguments of such methods should be counted from two, not one, when
2642 giving values for @var{string-index} and @var{first-to-check}.
2643
2644 In the example above, the format string (@code{my_format}) is the second
2645 argument of the function @code{my_print}, and the arguments to check
2646 start with the third argument, so the correct parameters for the format
2647 attribute are 2 and 3.
2648
2649 @opindex ffreestanding
2650 @opindex fno-builtin
2651 The @code{format} attribute allows you to identify your own functions
2652 that take format strings as arguments, so that GCC can check the
2653 calls to these functions for errors. The compiler always (unless
2654 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2655 for the standard library functions @code{printf}, @code{fprintf},
2656 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2657 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2658 warnings are requested (using @option{-Wformat}), so there is no need to
2659 modify the header file @file{stdio.h}. In C99 mode, the functions
2660 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2661 @code{vsscanf} are also checked. Except in strictly conforming C
2662 standard modes, the X/Open function @code{strfmon} is also checked as
2663 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2664 @xref{C Dialect Options,,Options Controlling C Dialect}.
2665
2666 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2667 recognized in the same context. Declarations including these format attributes
2668 are parsed for correct syntax, however the result of checking of such format
2669 strings is not yet defined, and is not carried out by this version of the
2670 compiler.
2671
2672 The target may also provide additional types of format checks.
2673 @xref{Target Format Checks,,Format Checks Specific to Particular
2674 Target Machines}.
2675
2676 @item format_arg (@var{string-index})
2677 @cindex @code{format_arg} function attribute
2678 @opindex Wformat-nonliteral
2679 The @code{format_arg} attribute specifies that a function takes a format
2680 string for a @code{printf}, @code{scanf}, @code{strftime} or
2681 @code{strfmon} style function and modifies it (for example, to translate
2682 it into another language), so the result can be passed to a
2683 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2684 function (with the remaining arguments to the format function the same
2685 as they would have been for the unmodified string). For example, the
2686 declaration:
2687
2688 @smallexample
2689 extern char *
2690 my_dgettext (char *my_domain, const char *my_format)
2691 __attribute__ ((format_arg (2)));
2692 @end smallexample
2693
2694 @noindent
2695 causes the compiler to check the arguments in calls to a @code{printf},
2696 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2697 format string argument is a call to the @code{my_dgettext} function, for
2698 consistency with the format string argument @code{my_format}. If the
2699 @code{format_arg} attribute had not been specified, all the compiler
2700 could tell in such calls to format functions would be that the format
2701 string argument is not constant; this would generate a warning when
2702 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2703 without the attribute.
2704
2705 The parameter @var{string-index} specifies which argument is the format
2706 string argument (starting from one). Since non-static C++ methods have
2707 an implicit @code{this} argument, the arguments of such methods should
2708 be counted from two.
2709
2710 The @code{format_arg} attribute allows you to identify your own
2711 functions that modify format strings, so that GCC can check the
2712 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2713 type function whose operands are a call to one of your own function.
2714 The compiler always treats @code{gettext}, @code{dgettext}, and
2715 @code{dcgettext} in this manner except when strict ISO C support is
2716 requested by @option{-ansi} or an appropriate @option{-std} option, or
2717 @option{-ffreestanding} or @option{-fno-builtin}
2718 is used. @xref{C Dialect Options,,Options
2719 Controlling C Dialect}.
2720
2721 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2722 @code{NSString} reference for compatibility with the @code{format} attribute
2723 above.
2724
2725 The target may also allow additional types in @code{format-arg} attributes.
2726 @xref{Target Format Checks,,Format Checks Specific to Particular
2727 Target Machines}.
2728
2729 @item gnu_inline
2730 @cindex @code{gnu_inline} function attribute
2731 This attribute should be used with a function that is also declared
2732 with the @code{inline} keyword. It directs GCC to treat the function
2733 as if it were defined in gnu90 mode even when compiling in C99 or
2734 gnu99 mode.
2735
2736 If the function is declared @code{extern}, then this definition of the
2737 function is used only for inlining. In no case is the function
2738 compiled as a standalone function, not even if you take its address
2739 explicitly. Such an address becomes an external reference, as if you
2740 had only declared the function, and had not defined it. This has
2741 almost the effect of a macro. The way to use this is to put a
2742 function definition in a header file with this attribute, and put
2743 another copy of the function, without @code{extern}, in a library
2744 file. The definition in the header file causes most calls to the
2745 function to be inlined. If any uses of the function remain, they
2746 refer to the single copy in the library. Note that the two
2747 definitions of the functions need not be precisely the same, although
2748 if they do not have the same effect your program may behave oddly.
2749
2750 In C, if the function is neither @code{extern} nor @code{static}, then
2751 the function is compiled as a standalone function, as well as being
2752 inlined where possible.
2753
2754 This is how GCC traditionally handled functions declared
2755 @code{inline}. Since ISO C99 specifies a different semantics for
2756 @code{inline}, this function attribute is provided as a transition
2757 measure and as a useful feature in its own right. This attribute is
2758 available in GCC 4.1.3 and later. It is available if either of the
2759 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2760 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2761 Function is As Fast As a Macro}.
2762
2763 In C++, this attribute does not depend on @code{extern} in any way,
2764 but it still requires the @code{inline} keyword to enable its special
2765 behavior.
2766
2767 @item hot
2768 @cindex @code{hot} function attribute
2769 The @code{hot} attribute on a function is used to inform the compiler that
2770 the function is a hot spot of the compiled program. The function is
2771 optimized more aggressively and on many targets it is placed into a special
2772 subsection of the text section so all hot functions appear close together,
2773 improving locality.
2774
2775 When profile feedback is available, via @option{-fprofile-use}, hot functions
2776 are automatically detected and this attribute is ignored.
2777
2778 @item ifunc ("@var{resolver}")
2779 @cindex @code{ifunc} function attribute
2780 @cindex indirect functions
2781 @cindex functions that are dynamically resolved
2782 The @code{ifunc} attribute is used to mark a function as an indirect
2783 function using the STT_GNU_IFUNC symbol type extension to the ELF
2784 standard. This allows the resolution of the symbol value to be
2785 determined dynamically at load time, and an optimized version of the
2786 routine can be selected for the particular processor or other system
2787 characteristics determined then. To use this attribute, first define
2788 the implementation functions available, and a resolver function that
2789 returns a pointer to the selected implementation function. The
2790 implementation functions' declarations must match the API of the
2791 function being implemented, the resolver's declaration is be a
2792 function returning pointer to void function returning void:
2793
2794 @smallexample
2795 void *my_memcpy (void *dst, const void *src, size_t len)
2796 @{
2797 @dots{}
2798 @}
2799
2800 static void (*resolve_memcpy (void)) (void)
2801 @{
2802 return my_memcpy; // we'll just always select this routine
2803 @}
2804 @end smallexample
2805
2806 @noindent
2807 The exported header file declaring the function the user calls would
2808 contain:
2809
2810 @smallexample
2811 extern void *memcpy (void *, const void *, size_t);
2812 @end smallexample
2813
2814 @noindent
2815 allowing the user to call this as a regular function, unaware of the
2816 implementation. Finally, the indirect function needs to be defined in
2817 the same translation unit as the resolver function:
2818
2819 @smallexample
2820 void *memcpy (void *, const void *, size_t)
2821 __attribute__ ((ifunc ("resolve_memcpy")));
2822 @end smallexample
2823
2824 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
2825 and GNU C Library version 2.11.1 are required to use this feature.
2826
2827 @item interrupt
2828 @itemx interrupt_handler
2829 Many GCC back ends support attributes to indicate that a function is
2830 an interrupt handler, which tells the compiler to generate function
2831 entry and exit sequences that differ from those from regular
2832 functions. The exact syntax and behavior are target-specific;
2833 refer to the following subsections for details.
2834
2835 @item leaf
2836 @cindex @code{leaf} function attribute
2837 Calls to external functions with this attribute must return to the
2838 current compilation unit only by return or by exception handling. In
2839 particular, a leaf function is not allowed to invoke callback functions
2840 passed to it from the current compilation unit, directly call functions
2841 exported by the unit, or @code{longjmp} into the unit. Leaf functions
2842 might still call functions from other compilation units and thus they
2843 are not necessarily leaf in the sense that they contain no function
2844 calls at all.
2845
2846 The attribute is intended for library functions to improve dataflow
2847 analysis. The compiler takes the hint that any data not escaping the
2848 current compilation unit cannot be used or modified by the leaf
2849 function. For example, the @code{sin} function is a leaf function, but
2850 @code{qsort} is not.
2851
2852 Note that leaf functions might indirectly run a signal handler defined
2853 in the current compilation unit that uses static variables. Similarly,
2854 when lazy symbol resolution is in effect, leaf functions might invoke
2855 indirect functions whose resolver function or implementation function is
2856 defined in the current compilation unit and uses static variables. There
2857 is no standard-compliant way to write such a signal handler, resolver
2858 function, or implementation function, and the best that you can do is to
2859 remove the @code{leaf} attribute or mark all such static variables
2860 @code{volatile}. Lastly, for ELF-based systems that support symbol
2861 interposition, care should be taken that functions defined in the
2862 current compilation unit do not unexpectedly interpose other symbols
2863 based on the defined standards mode and defined feature test macros;
2864 otherwise an inadvertent callback would be added.
2865
2866 The attribute has no effect on functions defined within the current
2867 compilation unit. This is to allow easy merging of multiple compilation
2868 units into one, for example, by using the link-time optimization. For
2869 this reason the attribute is not allowed on types to annotate indirect
2870 calls.
2871
2872 @item malloc
2873 @cindex @code{malloc} function attribute
2874 @cindex functions that behave like malloc
2875 This tells the compiler that a function is @code{malloc}-like, i.e.,
2876 that the pointer @var{P} returned by the function cannot alias any
2877 other pointer valid when the function returns, and moreover no
2878 pointers to valid objects occur in any storage addressed by @var{P}.
2879
2880 Using this attribute can improve optimization. Functions like
2881 @code{malloc} and @code{calloc} have this property because they return
2882 a pointer to uninitialized or zeroed-out storage. However, functions
2883 like @code{realloc} do not have this property, as they can return a
2884 pointer to storage containing pointers.
2885
2886 @item no_icf
2887 @cindex @code{no_icf} function attribute
2888 This function attribute prevents a functions from being merged with another
2889 semantically equivalent function.
2890
2891 @item no_instrument_function
2892 @cindex @code{no_instrument_function} function attribute
2893 @opindex finstrument-functions
2894 If @option{-finstrument-functions} is given, profiling function calls are
2895 generated at entry and exit of most user-compiled functions.
2896 Functions with this attribute are not so instrumented.
2897
2898 @item no_profile_instrument_function
2899 @cindex @code{no_profile_instrument_function} function attribute
2900 The @code{no_profile_instrument_function} attribute on functions is used
2901 to inform the compiler that it should not process any profile feedback based
2902 optimization code instrumentation.
2903
2904 @item no_reorder
2905 @cindex @code{no_reorder} function attribute
2906 Do not reorder functions or variables marked @code{no_reorder}
2907 against each other or top level assembler statements the executable.
2908 The actual order in the program will depend on the linker command
2909 line. Static variables marked like this are also not removed.
2910 This has a similar effect
2911 as the @option{-fno-toplevel-reorder} option, but only applies to the
2912 marked symbols.
2913
2914 @item no_sanitize ("@var{sanitize_option}")
2915 @cindex @code{no_sanitize} function attribute
2916 The @code{no_sanitize} attribute on functions is used
2917 to inform the compiler that it should not do sanitization of all options
2918 mentioned in @var{sanitize_option}. A list of values acceptable by
2919 @option{-fsanitize} option can be provided.
2920
2921 @smallexample
2922 void __attribute__ ((no_sanitize ("alignment", "object-size")))
2923 f () @{ /* @r{Do something.} */; @}
2924 @end smallexample
2925
2926 @item no_sanitize_address
2927 @itemx no_address_safety_analysis
2928 @cindex @code{no_sanitize_address} function attribute
2929 The @code{no_sanitize_address} attribute on functions is used
2930 to inform the compiler that it should not instrument memory accesses
2931 in the function when compiling with the @option{-fsanitize=address} option.
2932 The @code{no_address_safety_analysis} is a deprecated alias of the
2933 @code{no_sanitize_address} attribute, new code should use
2934 @code{no_sanitize_address}.
2935
2936 @item no_sanitize_thread
2937 @cindex @code{no_sanitize_thread} function attribute
2938 The @code{no_sanitize_thread} attribute on functions is used
2939 to inform the compiler that it should not instrument memory accesses
2940 in the function when compiling with the @option{-fsanitize=thread} option.
2941
2942 @item no_sanitize_undefined
2943 @cindex @code{no_sanitize_undefined} function attribute
2944 The @code{no_sanitize_undefined} attribute on functions is used
2945 to inform the compiler that it should not check for undefined behavior
2946 in the function when compiling with the @option{-fsanitize=undefined} option.
2947
2948 @item no_split_stack
2949 @cindex @code{no_split_stack} function attribute
2950 @opindex fsplit-stack
2951 If @option{-fsplit-stack} is given, functions have a small
2952 prologue which decides whether to split the stack. Functions with the
2953 @code{no_split_stack} attribute do not have that prologue, and thus
2954 may run with only a small amount of stack space available.
2955
2956 @item no_stack_limit
2957 @cindex @code{no_stack_limit} function attribute
2958 This attribute locally overrides the @option{-fstack-limit-register}
2959 and @option{-fstack-limit-symbol} command-line options; it has the effect
2960 of disabling stack limit checking in the function it applies to.
2961
2962 @item noclone
2963 @cindex @code{noclone} function attribute
2964 This function attribute prevents a function from being considered for
2965 cloning---a mechanism that produces specialized copies of functions
2966 and which is (currently) performed by interprocedural constant
2967 propagation.
2968
2969 @item noinline
2970 @cindex @code{noinline} function attribute
2971 This function attribute prevents a function from being considered for
2972 inlining.
2973 @c Don't enumerate the optimizations by name here; we try to be
2974 @c future-compatible with this mechanism.
2975 If the function does not have side-effects, there are optimizations
2976 other than inlining that cause function calls to be optimized away,
2977 although the function call is live. To keep such calls from being
2978 optimized away, put
2979 @smallexample
2980 asm ("");
2981 @end smallexample
2982
2983 @noindent
2984 (@pxref{Extended Asm}) in the called function, to serve as a special
2985 side-effect.
2986
2987 @item noipa
2988 @cindex @code{noipa} function attribute
2989 Disable interprocedural optimizations between the function with this
2990 attribute and its callers, as if the body of the function is not available
2991 when optimizing callers and the callers are unavailable when optimizing
2992 the body. This attribute implies @code{noinline}, @code{noclone} and
2993 @code{no_icf} attributes. However, this attribute is not equivalent
2994 to a combination of other attributes, because its purpose is to suppress
2995 existing and future optimizations employing interprocedural analysis,
2996 including those that do not have an attribute suitable for disabling
2997 them individually. This attribute is supported mainly for the purpose
2998 of testing the compiler.
2999
3000 @item nonnull (@var{arg-index}, @dots{})
3001 @cindex @code{nonnull} function attribute
3002 @cindex functions with non-null pointer arguments
3003 The @code{nonnull} attribute specifies that some function parameters should
3004 be non-null pointers. For instance, the declaration:
3005
3006 @smallexample
3007 extern void *
3008 my_memcpy (void *dest, const void *src, size_t len)
3009 __attribute__((nonnull (1, 2)));
3010 @end smallexample
3011
3012 @noindent
3013 causes the compiler to check that, in calls to @code{my_memcpy},
3014 arguments @var{dest} and @var{src} are non-null. If the compiler
3015 determines that a null pointer is passed in an argument slot marked
3016 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3017 is issued. The compiler may also choose to make optimizations based
3018 on the knowledge that certain function arguments will never be null.
3019
3020 If no argument index list is given to the @code{nonnull} attribute,
3021 all pointer arguments are marked as non-null. To illustrate, the
3022 following declaration is equivalent to the previous example:
3023
3024 @smallexample
3025 extern void *
3026 my_memcpy (void *dest, const void *src, size_t len)
3027 __attribute__((nonnull));
3028 @end smallexample
3029
3030 @item noplt
3031 @cindex @code{noplt} function attribute
3032 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3033 Calls to functions marked with this attribute in position-independent code
3034 do not use the PLT.
3035
3036 @smallexample
3037 @group
3038 /* Externally defined function foo. */
3039 int foo () __attribute__ ((noplt));
3040
3041 int
3042 main (/* @r{@dots{}} */)
3043 @{
3044 /* @r{@dots{}} */
3045 foo ();
3046 /* @r{@dots{}} */
3047 @}
3048 @end group
3049 @end smallexample
3050
3051 The @code{noplt} attribute on function @code{foo}
3052 tells the compiler to assume that
3053 the function @code{foo} is externally defined and that the call to
3054 @code{foo} must avoid the PLT
3055 in position-independent code.
3056
3057 In position-dependent code, a few targets also convert calls to
3058 functions that are marked to not use the PLT to use the GOT instead.
3059
3060 @item noreturn
3061 @cindex @code{noreturn} function attribute
3062 @cindex functions that never return
3063 A few standard library functions, such as @code{abort} and @code{exit},
3064 cannot return. GCC knows this automatically. Some programs define
3065 their own functions that never return. You can declare them
3066 @code{noreturn} to tell the compiler this fact. For example,
3067
3068 @smallexample
3069 @group
3070 void fatal () __attribute__ ((noreturn));
3071
3072 void
3073 fatal (/* @r{@dots{}} */)
3074 @{
3075 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3076 exit (1);
3077 @}
3078 @end group
3079 @end smallexample
3080
3081 The @code{noreturn} keyword tells the compiler to assume that
3082 @code{fatal} cannot return. It can then optimize without regard to what
3083 would happen if @code{fatal} ever did return. This makes slightly
3084 better code. More importantly, it helps avoid spurious warnings of
3085 uninitialized variables.
3086
3087 The @code{noreturn} keyword does not affect the exceptional path when that
3088 applies: a @code{noreturn}-marked function may still return to the caller
3089 by throwing an exception or calling @code{longjmp}.
3090
3091 Do not assume that registers saved by the calling function are
3092 restored before calling the @code{noreturn} function.
3093
3094 It does not make sense for a @code{noreturn} function to have a return
3095 type other than @code{void}.
3096
3097 @item nothrow
3098 @cindex @code{nothrow} function attribute
3099 The @code{nothrow} attribute is used to inform the compiler that a
3100 function cannot throw an exception. For example, most functions in
3101 the standard C library can be guaranteed not to throw an exception
3102 with the notable exceptions of @code{qsort} and @code{bsearch} that
3103 take function pointer arguments.
3104
3105 @item optimize
3106 @cindex @code{optimize} function attribute
3107 The @code{optimize} attribute is used to specify that a function is to
3108 be compiled with different optimization options than specified on the
3109 command line. Arguments can either be numbers or strings. Numbers
3110 are assumed to be an optimization level. Strings that begin with
3111 @code{O} are assumed to be an optimization option, while other options
3112 are assumed to be used with a @code{-f} prefix. You can also use the
3113 @samp{#pragma GCC optimize} pragma to set the optimization options
3114 that affect more than one function.
3115 @xref{Function Specific Option Pragmas}, for details about the
3116 @samp{#pragma GCC optimize} pragma.
3117
3118 This attribute should be used for debugging purposes only. It is not
3119 suitable in production code.
3120
3121 @item patchable_function_entry
3122 @cindex @code{patchable_function_entry} function attribute
3123 @cindex extra NOP instructions at the function entry point
3124 In case the target's text segment can be made writable at run time by
3125 any means, padding the function entry with a number of NOPs can be
3126 used to provide a universal tool for instrumentation.
3127
3128 The @code{patchable_function_entry} function attribute can be used to
3129 change the number of NOPs to any desired value. The two-value syntax
3130 is the same as for the command-line switch
3131 @option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with
3132 the function entry point before the @var{M}th NOP instruction.
3133 @var{M} defaults to 0 if omitted e.g. function entry point is before
3134 the first NOP.
3135
3136 If patchable function entries are enabled globally using the command-line
3137 option @option{-fpatchable-function-entry=N,M}, then you must disable
3138 instrumentation on all functions that are part of the instrumentation
3139 framework with the attribute @code{patchable_function_entry (0)}
3140 to prevent recursion.
3141
3142 @item pure
3143 @cindex @code{pure} function attribute
3144 @cindex functions that have no side effects
3145 Many functions have no effects except the return value and their
3146 return value depends only on the parameters and/or global variables.
3147 Such a function can be subject
3148 to common subexpression elimination and loop optimization just as an
3149 arithmetic operator would be. These functions should be declared
3150 with the attribute @code{pure}. For example,
3151
3152 @smallexample
3153 int square (int) __attribute__ ((pure));
3154 @end smallexample
3155
3156 @noindent
3157 says that the hypothetical function @code{square} is safe to call
3158 fewer times than the program says.
3159
3160 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3161 Interesting non-pure functions are functions with infinite loops or those
3162 depending on volatile memory or other system resource, that may change between
3163 two consecutive calls (such as @code{feof} in a multithreading environment).
3164
3165 @item returns_nonnull
3166 @cindex @code{returns_nonnull} function attribute
3167 The @code{returns_nonnull} attribute specifies that the function
3168 return value should be a non-null pointer. For instance, the declaration:
3169
3170 @smallexample
3171 extern void *
3172 mymalloc (size_t len) __attribute__((returns_nonnull));
3173 @end smallexample
3174
3175 @noindent
3176 lets the compiler optimize callers based on the knowledge
3177 that the return value will never be null.
3178
3179 @item returns_twice
3180 @cindex @code{returns_twice} function attribute
3181 @cindex functions that return more than once
3182 The @code{returns_twice} attribute tells the compiler that a function may
3183 return more than one time. The compiler ensures that all registers
3184 are dead before calling such a function and emits a warning about
3185 the variables that may be clobbered after the second return from the
3186 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3187 The @code{longjmp}-like counterpart of such function, if any, might need
3188 to be marked with the @code{noreturn} attribute.
3189
3190 @item section ("@var{section-name}")
3191 @cindex @code{section} function attribute
3192 @cindex functions in arbitrary sections
3193 Normally, the compiler places the code it generates in the @code{text} section.
3194 Sometimes, however, you need additional sections, or you need certain
3195 particular functions to appear in special sections. The @code{section}
3196 attribute specifies that a function lives in a particular section.
3197 For example, the declaration:
3198
3199 @smallexample
3200 extern void foobar (void) __attribute__ ((section ("bar")));
3201 @end smallexample
3202
3203 @noindent
3204 puts the function @code{foobar} in the @code{bar} section.
3205
3206 Some file formats do not support arbitrary sections so the @code{section}
3207 attribute is not available on all platforms.
3208 If you need to map the entire contents of a module to a particular
3209 section, consider using the facilities of the linker instead.
3210
3211 @item sentinel
3212 @cindex @code{sentinel} function attribute
3213 This function attribute ensures that a parameter in a function call is
3214 an explicit @code{NULL}. The attribute is only valid on variadic
3215 functions. By default, the sentinel is located at position zero, the
3216 last parameter of the function call. If an optional integer position
3217 argument P is supplied to the attribute, the sentinel must be located at
3218 position P counting backwards from the end of the argument list.
3219
3220 @smallexample
3221 __attribute__ ((sentinel))
3222 is equivalent to
3223 __attribute__ ((sentinel(0)))
3224 @end smallexample
3225
3226 The attribute is automatically set with a position of 0 for the built-in
3227 functions @code{execl} and @code{execlp}. The built-in function
3228 @code{execle} has the attribute set with a position of 1.
3229
3230 A valid @code{NULL} in this context is defined as zero with any pointer
3231 type. If your system defines the @code{NULL} macro with an integer type
3232 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3233 with a copy that redefines NULL appropriately.
3234
3235 The warnings for missing or incorrect sentinels are enabled with
3236 @option{-Wformat}.
3237
3238 @item simd
3239 @itemx simd("@var{mask}")
3240 @cindex @code{simd} function attribute
3241 This attribute enables creation of one or more function versions that
3242 can process multiple arguments using SIMD instructions from a
3243 single invocation. Specifying this attribute allows compiler to
3244 assume that such versions are available at link time (provided
3245 in the same or another translation unit). Generated versions are
3246 target-dependent and described in the corresponding Vector ABI document. For
3247 x86_64 target this document can be found
3248 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3249
3250 The optional argument @var{mask} may have the value
3251 @code{notinbranch} or @code{inbranch},
3252 and instructs the compiler to generate non-masked or masked
3253 clones correspondingly. By default, all clones are generated.
3254
3255 The attribute should not be used together with Cilk Plus @code{vector}
3256 attribute on the same function.
3257
3258 If the attribute is specified and @code{#pragma omp declare simd} is
3259 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3260 switch is specified, then the attribute is ignored.
3261
3262 @item stack_protect
3263 @cindex @code{stack_protect} function attribute
3264 This attribute adds stack protection code to the function if
3265 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3266 or @option{-fstack-protector-explicit} are set.
3267
3268 @item target (@var{options})
3269 @cindex @code{target} function attribute
3270 Multiple target back ends implement the @code{target} attribute
3271 to specify that a function is to
3272 be compiled with different target options than specified on the
3273 command line. This can be used for instance to have functions
3274 compiled with a different ISA (instruction set architecture) than the
3275 default. You can also use the @samp{#pragma GCC target} pragma to set
3276 more than one function to be compiled with specific target options.
3277 @xref{Function Specific Option Pragmas}, for details about the
3278 @samp{#pragma GCC target} pragma.
3279
3280 For instance, on an x86, you could declare one function with the
3281 @code{target("sse4.1,arch=core2")} attribute and another with
3282 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3283 compiling the first function with @option{-msse4.1} and
3284 @option{-march=core2} options, and the second function with
3285 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3286 to make sure that a function is only invoked on a machine that
3287 supports the particular ISA it is compiled for (for example by using
3288 @code{cpuid} on x86 to determine what feature bits and architecture
3289 family are used).
3290
3291 @smallexample
3292 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3293 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3294 @end smallexample
3295
3296 You can either use multiple
3297 strings separated by commas to specify multiple options,
3298 or separate the options with a comma (@samp{,}) within a single string.
3299
3300 The options supported are specific to each target; refer to @ref{x86
3301 Function Attributes}, @ref{PowerPC Function Attributes},
3302 @ref{ARM Function Attributes}, @ref{AArch64 Function Attributes},
3303 @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
3304 for details.
3305
3306 @item target_clones (@var{options})
3307 @cindex @code{target_clones} function attribute
3308 The @code{target_clones} attribute is used to specify that a function
3309 be cloned into multiple versions compiled with different target options
3310 than specified on the command line. The supported options and restrictions
3311 are the same as for @code{target} attribute.
3312
3313 For instance, on an x86, you could compile a function with
3314 @code{target_clones("sse4.1,avx")}. GCC creates two function clones,
3315 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3316
3317 On a PowerPC, you can compile a function with
3318 @code{target_clones("cpu=power9,default")}. GCC will create two
3319 function clones, one compiled with @option{-mcpu=power9} and another
3320 with the default options. GCC must be configured to use GLIBC 2.23 or
3321 newer in order to use the @code{target_clones} attribute.
3322
3323 It also creates a resolver function (see
3324 the @code{ifunc} attribute above) that dynamically selects a clone
3325 suitable for current architecture. The resolver is created only if there
3326 is a usage of a function with @code{target_clones} attribute.
3327
3328 @item unused
3329 @cindex @code{unused} function attribute
3330 This attribute, attached to a function, means that the function is meant
3331 to be possibly unused. GCC does not produce a warning for this
3332 function.
3333
3334 @item used
3335 @cindex @code{used} function attribute
3336 This attribute, attached to a function, means that code must be emitted
3337 for the function even if it appears that the function is not referenced.
3338 This is useful, for example, when the function is referenced only in
3339 inline assembly.
3340
3341 When applied to a member function of a C++ class template, the
3342 attribute also means that the function is instantiated if the
3343 class itself is instantiated.
3344
3345 @item visibility ("@var{visibility_type}")
3346 @cindex @code{visibility} function attribute
3347 This attribute affects the linkage of the declaration to which it is attached.
3348 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3349 (@pxref{Common Type Attributes}) as well as functions.
3350
3351 There are four supported @var{visibility_type} values: default,
3352 hidden, protected or internal visibility.
3353
3354 @smallexample
3355 void __attribute__ ((visibility ("protected")))
3356 f () @{ /* @r{Do something.} */; @}
3357 int i __attribute__ ((visibility ("hidden")));
3358 @end smallexample
3359
3360 The possible values of @var{visibility_type} correspond to the
3361 visibility settings in the ELF gABI.
3362
3363 @table @code
3364 @c keep this list of visibilities in alphabetical order.
3365
3366 @item default
3367 Default visibility is the normal case for the object file format.
3368 This value is available for the visibility attribute to override other
3369 options that may change the assumed visibility of entities.
3370
3371 On ELF, default visibility means that the declaration is visible to other
3372 modules and, in shared libraries, means that the declared entity may be
3373 overridden.
3374
3375 On Darwin, default visibility means that the declaration is visible to
3376 other modules.
3377
3378 Default visibility corresponds to ``external linkage'' in the language.
3379
3380 @item hidden
3381 Hidden visibility indicates that the entity declared has a new
3382 form of linkage, which we call ``hidden linkage''. Two
3383 declarations of an object with hidden linkage refer to the same object
3384 if they are in the same shared object.
3385
3386 @item internal
3387 Internal visibility is like hidden visibility, but with additional
3388 processor specific semantics. Unless otherwise specified by the
3389 psABI, GCC defines internal visibility to mean that a function is
3390 @emph{never} called from another module. Compare this with hidden
3391 functions which, while they cannot be referenced directly by other
3392 modules, can be referenced indirectly via function pointers. By
3393 indicating that a function cannot be called from outside the module,
3394 GCC may for instance omit the load of a PIC register since it is known
3395 that the calling function loaded the correct value.
3396
3397 @item protected
3398 Protected visibility is like default visibility except that it
3399 indicates that references within the defining module bind to the
3400 definition in that module. That is, the declared entity cannot be
3401 overridden by another module.
3402
3403 @end table
3404
3405 All visibilities are supported on many, but not all, ELF targets
3406 (supported when the assembler supports the @samp{.visibility}
3407 pseudo-op). Default visibility is supported everywhere. Hidden
3408 visibility is supported on Darwin targets.
3409
3410 The visibility attribute should be applied only to declarations that
3411 would otherwise have external linkage. The attribute should be applied
3412 consistently, so that the same entity should not be declared with
3413 different settings of the attribute.
3414
3415 In C++, the visibility attribute applies to types as well as functions
3416 and objects, because in C++ types have linkage. A class must not have
3417 greater visibility than its non-static data member types and bases,
3418 and class members default to the visibility of their class. Also, a
3419 declaration without explicit visibility is limited to the visibility
3420 of its type.
3421
3422 In C++, you can mark member functions and static member variables of a
3423 class with the visibility attribute. This is useful if you know a
3424 particular method or static member variable should only be used from
3425 one shared object; then you can mark it hidden while the rest of the
3426 class has default visibility. Care must be taken to avoid breaking
3427 the One Definition Rule; for example, it is usually not useful to mark
3428 an inline method as hidden without marking the whole class as hidden.
3429
3430 A C++ namespace declaration can also have the visibility attribute.
3431
3432 @smallexample
3433 namespace nspace1 __attribute__ ((visibility ("protected")))
3434 @{ /* @r{Do something.} */; @}
3435 @end smallexample
3436
3437 This attribute applies only to the particular namespace body, not to
3438 other definitions of the same namespace; it is equivalent to using
3439 @samp{#pragma GCC visibility} before and after the namespace
3440 definition (@pxref{Visibility Pragmas}).
3441
3442 In C++, if a template argument has limited visibility, this
3443 restriction is implicitly propagated to the template instantiation.
3444 Otherwise, template instantiations and specializations default to the
3445 visibility of their template.
3446
3447 If both the template and enclosing class have explicit visibility, the
3448 visibility from the template is used.
3449
3450 @item warn_unused_result
3451 @cindex @code{warn_unused_result} function attribute
3452 The @code{warn_unused_result} attribute causes a warning to be emitted
3453 if a caller of the function with this attribute does not use its
3454 return value. This is useful for functions where not checking
3455 the result is either a security problem or always a bug, such as
3456 @code{realloc}.
3457
3458 @smallexample
3459 int fn () __attribute__ ((warn_unused_result));
3460 int foo ()
3461 @{
3462 if (fn () < 0) return -1;
3463 fn ();
3464 return 0;
3465 @}
3466 @end smallexample
3467
3468 @noindent
3469 results in warning on line 5.
3470
3471 @item weak
3472 @cindex @code{weak} function attribute
3473 The @code{weak} attribute causes the declaration to be emitted as a weak
3474 symbol rather than a global. This is primarily useful in defining
3475 library functions that can be overridden in user code, though it can
3476 also be used with non-function declarations. Weak symbols are supported
3477 for ELF targets, and also for a.out targets when using the GNU assembler
3478 and linker.
3479
3480 @item weakref
3481 @itemx weakref ("@var{target}")
3482 @cindex @code{weakref} function attribute
3483 The @code{weakref} attribute marks a declaration as a weak reference.
3484 Without arguments, it should be accompanied by an @code{alias} attribute
3485 naming the target symbol. Optionally, the @var{target} may be given as
3486 an argument to @code{weakref} itself. In either case, @code{weakref}
3487 implicitly marks the declaration as @code{weak}. Without a
3488 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3489 @code{weakref} is equivalent to @code{weak}.
3490
3491 @smallexample
3492 static int x() __attribute__ ((weakref ("y")));
3493 /* is equivalent to... */
3494 static int x() __attribute__ ((weak, weakref, alias ("y")));
3495 /* and to... */
3496 static int x() __attribute__ ((weakref));
3497 static int x() __attribute__ ((alias ("y")));
3498 @end smallexample
3499
3500 A weak reference is an alias that does not by itself require a
3501 definition to be given for the target symbol. If the target symbol is
3502 only referenced through weak references, then it becomes a @code{weak}
3503 undefined symbol. If it is directly referenced, however, then such
3504 strong references prevail, and a definition is required for the
3505 symbol, not necessarily in the same translation unit.
3506
3507 The effect is equivalent to moving all references to the alias to a
3508 separate translation unit, renaming the alias to the aliased symbol,
3509 declaring it as weak, compiling the two separate translation units and
3510 performing a reloadable link on them.
3511
3512 At present, a declaration to which @code{weakref} is attached can
3513 only be @code{static}.
3514
3515
3516 @end table
3517
3518 @c This is the end of the target-independent attribute table
3519
3520 @node AArch64 Function Attributes
3521 @subsection AArch64 Function Attributes
3522
3523 The following target-specific function attributes are available for the
3524 AArch64 target. For the most part, these options mirror the behavior of
3525 similar command-line options (@pxref{AArch64 Options}), but on a
3526 per-function basis.
3527
3528 @table @code
3529 @item general-regs-only
3530 @cindex @code{general-regs-only} function attribute, AArch64
3531 Indicates that no floating-point or Advanced SIMD registers should be
3532 used when generating code for this function. If the function explicitly
3533 uses floating-point code, then the compiler gives an error. This is
3534 the same behavior as that of the command-line option
3535 @option{-mgeneral-regs-only}.
3536
3537 @item fix-cortex-a53-835769
3538 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3539 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3540 applied to this function. To explicitly disable the workaround for this
3541 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3542 This corresponds to the behavior of the command line options
3543 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3544
3545 @item cmodel=
3546 @cindex @code{cmodel=} function attribute, AArch64
3547 Indicates that code should be generated for a particular code model for
3548 this function. The behavior and permissible arguments are the same as
3549 for the command line option @option{-mcmodel=}.
3550
3551 @item strict-align
3552 @cindex @code{strict-align} function attribute, AArch64
3553 Indicates that the compiler should not assume that unaligned memory references
3554 are handled by the system. The behavior is the same as for the command-line
3555 option @option{-mstrict-align}.
3556
3557 @item omit-leaf-frame-pointer
3558 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3559 Indicates that the frame pointer should be omitted for a leaf function call.
3560 To keep the frame pointer, the inverse attribute
3561 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3562 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3563 and @option{-mno-omit-leaf-frame-pointer}.
3564
3565 @item tls-dialect=
3566 @cindex @code{tls-dialect=} function attribute, AArch64
3567 Specifies the TLS dialect to use for this function. The behavior and
3568 permissible arguments are the same as for the command-line option
3569 @option{-mtls-dialect=}.
3570
3571 @item arch=
3572 @cindex @code{arch=} function attribute, AArch64
3573 Specifies the architecture version and architectural extensions to use
3574 for this function. The behavior and permissible arguments are the same as
3575 for the @option{-march=} command-line option.
3576
3577 @item tune=
3578 @cindex @code{tune=} function attribute, AArch64
3579 Specifies the core for which to tune the performance of this function.
3580 The behavior and permissible arguments are the same as for the @option{-mtune=}
3581 command-line option.
3582
3583 @item cpu=
3584 @cindex @code{cpu=} function attribute, AArch64
3585 Specifies the core for which to tune the performance of this function and also
3586 whose architectural features to use. The behavior and valid arguments are the
3587 same as for the @option{-mcpu=} command-line option.
3588
3589 @item sign-return-address
3590 @cindex @code{sign-return-address} function attribute, AArch64
3591 Select the function scope on which return address signing will be applied. The
3592 behavior and permissible arguments are the same as for the command-line option
3593 @option{-msign-return-address=}. The default value is @code{none}.
3594
3595 @end table
3596
3597 The above target attributes can be specified as follows:
3598
3599 @smallexample
3600 __attribute__((target("@var{attr-string}")))
3601 int
3602 f (int a)
3603 @{
3604 return a + 5;
3605 @}
3606 @end smallexample
3607
3608 where @code{@var{attr-string}} is one of the attribute strings specified above.
3609
3610 Additionally, the architectural extension string may be specified on its
3611 own. This can be used to turn on and off particular architectural extensions
3612 without having to specify a particular architecture version or core. Example:
3613
3614 @smallexample
3615 __attribute__((target("+crc+nocrypto")))
3616 int
3617 foo (int a)
3618 @{
3619 return a + 5;
3620 @}
3621 @end smallexample
3622
3623 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3624 extension and disables the @code{crypto} extension for the function @code{foo}
3625 without modifying an existing @option{-march=} or @option{-mcpu} option.
3626
3627 Multiple target function attributes can be specified by separating them with
3628 a comma. For example:
3629 @smallexample
3630 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3631 int
3632 foo (int a)
3633 @{
3634 return a + 5;
3635 @}
3636 @end smallexample
3637
3638 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3639 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3640
3641 @subsubsection Inlining rules
3642 Specifying target attributes on individual functions or performing link-time
3643 optimization across translation units compiled with different target options
3644 can affect function inlining rules:
3645
3646 In particular, a caller function can inline a callee function only if the
3647 architectural features available to the callee are a subset of the features
3648 available to the caller.
3649 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3650 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3651 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3652 because the all the architectural features that function @code{bar} requires
3653 are available to function @code{foo}. Conversely, function @code{bar} cannot
3654 inline function @code{foo}.
3655
3656 Additionally inlining a function compiled with @option{-mstrict-align} into a
3657 function compiled without @code{-mstrict-align} is not allowed.
3658 However, inlining a function compiled without @option{-mstrict-align} into a
3659 function compiled with @option{-mstrict-align} is allowed.
3660
3661 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3662 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3663 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3664 architectural feature rules specified above.
3665
3666 @node ARC Function Attributes
3667 @subsection ARC Function Attributes
3668
3669 These function attributes are supported by the ARC back end:
3670
3671 @table @code
3672 @item interrupt
3673 @cindex @code{interrupt} function attribute, ARC
3674 Use this attribute to indicate
3675 that the specified function is an interrupt handler. The compiler generates
3676 function entry and exit sequences suitable for use in an interrupt handler
3677 when this attribute is present.
3678
3679 On the ARC, you must specify the kind of interrupt to be handled
3680 in a parameter to the interrupt attribute like this:
3681
3682 @smallexample
3683 void f () __attribute__ ((interrupt ("ilink1")));
3684 @end smallexample
3685
3686 Permissible values for this parameter are: @w{@code{ilink1}} and
3687 @w{@code{ilink2}}.
3688
3689 @item long_call
3690 @itemx medium_call
3691 @itemx short_call
3692 @cindex @code{long_call} function attribute, ARC
3693 @cindex @code{medium_call} function attribute, ARC
3694 @cindex @code{short_call} function attribute, ARC
3695 @cindex indirect calls, ARC
3696 These attributes specify how a particular function is called.
3697 These attributes override the
3698 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3699 command-line switches and @code{#pragma long_calls} settings.
3700
3701 For ARC, a function marked with the @code{long_call} attribute is
3702 always called using register-indirect jump-and-link instructions,
3703 thereby enabling the called function to be placed anywhere within the
3704 32-bit address space. A function marked with the @code{medium_call}
3705 attribute will always be close enough to be called with an unconditional
3706 branch-and-link instruction, which has a 25-bit offset from
3707 the call site. A function marked with the @code{short_call}
3708 attribute will always be close enough to be called with a conditional
3709 branch-and-link instruction, which has a 21-bit offset from
3710 the call site.
3711 @end table
3712
3713 @node ARM Function Attributes
3714 @subsection ARM Function Attributes
3715
3716 These function attributes are supported for ARM targets:
3717
3718 @table @code
3719 @item interrupt
3720 @cindex @code{interrupt} function attribute, ARM
3721 Use this attribute to indicate
3722 that the specified function is an interrupt handler. The compiler generates
3723 function entry and exit sequences suitable for use in an interrupt handler
3724 when this attribute is present.
3725
3726 You can specify the kind of interrupt to be handled by
3727 adding an optional parameter to the interrupt attribute like this:
3728
3729 @smallexample
3730 void f () __attribute__ ((interrupt ("IRQ")));
3731 @end smallexample
3732
3733 @noindent
3734 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3735 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3736
3737 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3738 may be called with a word-aligned stack pointer.
3739
3740 @item isr
3741 @cindex @code{isr} function attribute, ARM
3742 Use this attribute on ARM to write Interrupt Service Routines. This is an
3743 alias to the @code{interrupt} attribute above.
3744
3745 @item long_call
3746 @itemx short_call
3747 @cindex @code{long_call} function attribute, ARM
3748 @cindex @code{short_call} function attribute, ARM
3749 @cindex indirect calls, ARM
3750 These attributes specify how a particular function is called.
3751 These attributes override the
3752 @option{-mlong-calls} (@pxref{ARM Options})
3753 command-line switch and @code{#pragma long_calls} settings. For ARM, the
3754 @code{long_call} attribute indicates that the function might be far
3755 away from the call site and require a different (more expensive)
3756 calling sequence. The @code{short_call} attribute always places
3757 the offset to the function from the call site into the @samp{BL}
3758 instruction directly.
3759
3760 @item naked
3761 @cindex @code{naked} function attribute, ARM
3762 This attribute allows the compiler to construct the
3763 requisite function declaration, while allowing the body of the
3764 function to be assembly code. The specified function will not have
3765 prologue/epilogue sequences generated by the compiler. Only basic
3766 @code{asm} statements can safely be included in naked functions
3767 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3768 basic @code{asm} and C code may appear to work, they cannot be
3769 depended upon to work reliably and are not supported.
3770
3771 @item pcs
3772 @cindex @code{pcs} function attribute, ARM
3773
3774 The @code{pcs} attribute can be used to control the calling convention
3775 used for a function on ARM. The attribute takes an argument that specifies
3776 the calling convention to use.
3777
3778 When compiling using the AAPCS ABI (or a variant of it) then valid
3779 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3780 order to use a variant other than @code{"aapcs"} then the compiler must
3781 be permitted to use the appropriate co-processor registers (i.e., the
3782 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3783 For example,
3784
3785 @smallexample
3786 /* Argument passed in r0, and result returned in r0+r1. */
3787 double f2d (float) __attribute__((pcs("aapcs")));
3788 @end smallexample
3789
3790 Variadic functions always use the @code{"aapcs"} calling convention and
3791 the compiler rejects attempts to specify an alternative.
3792
3793 @item target (@var{options})
3794 @cindex @code{target} function attribute
3795 As discussed in @ref{Common Function Attributes}, this attribute
3796 allows specification of target-specific compilation options.
3797
3798 On ARM, the following options are allowed:
3799
3800 @table @samp
3801 @item thumb
3802 @cindex @code{target("thumb")} function attribute, ARM
3803 Force code generation in the Thumb (T16/T32) ISA, depending on the
3804 architecture level.
3805
3806 @item arm
3807 @cindex @code{target("arm")} function attribute, ARM
3808 Force code generation in the ARM (A32) ISA.
3809
3810 Functions from different modes can be inlined in the caller's mode.
3811
3812 @item fpu=
3813 @cindex @code{target("fpu=")} function attribute, ARM
3814 Specifies the fpu for which to tune the performance of this function.
3815 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3816 command-line option.
3817
3818 @end table
3819
3820 @end table
3821
3822 @node AVR Function Attributes
3823 @subsection AVR Function Attributes
3824
3825 These function attributes are supported by the AVR back end:
3826
3827 @table @code
3828 @item interrupt
3829 @cindex @code{interrupt} function attribute, AVR
3830 Use this attribute to indicate
3831 that the specified function is an interrupt handler. The compiler generates
3832 function entry and exit sequences suitable for use in an interrupt handler
3833 when this attribute is present.
3834
3835 On the AVR, the hardware globally disables interrupts when an
3836 interrupt is executed. The first instruction of an interrupt handler
3837 declared with this attribute is a @code{SEI} instruction to
3838 re-enable interrupts. See also the @code{signal} function attribute
3839 that does not insert a @code{SEI} instruction. If both @code{signal} and
3840 @code{interrupt} are specified for the same function, @code{signal}
3841 is silently ignored.
3842
3843 @item naked
3844 @cindex @code{naked} function attribute, AVR
3845 This attribute allows the compiler to construct the
3846 requisite function declaration, while allowing the body of the
3847 function to be assembly code. The specified function will not have
3848 prologue/epilogue sequences generated by the compiler. Only basic
3849 @code{asm} statements can safely be included in naked functions
3850 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3851 basic @code{asm} and C code may appear to work, they cannot be
3852 depended upon to work reliably and are not supported.
3853
3854 @item no_gccisr
3855 @cindex @code{no_gccisr} function attribute, AVR
3856 Do not use @code{__gcc_isr} pseudo instructions in a function with
3857 the @code{interrupt} or @code{signal} attribute aka. interrupt
3858 service routine (ISR).
3859 Use this attribute if the preamble of the ISR prologue should always read
3860 @example
3861 push __zero_reg__
3862 push __tmp_reg__
3863 in __tmp_reg__, __SREG__
3864 push __tmp_reg__
3865 clr __zero_reg__
3866 @end example
3867 and accordingly for the postamble of the epilogue --- no matter whether
3868 the mentioned registers are actually used in the ISR or not.
3869 Situations where you might want to use this attribute include:
3870 @itemize @bullet
3871 @item
3872 Code that (effectively) clobbers bits of @code{SREG} other than the
3873 @code{I}-flag by writing to the memory location of @code{SREG}.
3874 @item
3875 Code that uses inline assembler to jump to a different function which
3876 expects (parts of) the prologue code as outlined above to be present.
3877 @end itemize
3878 To disable @code{__gcc_isr} generation for the whole compilation unit,
3879 there is option @option{-mno-gas-isr-prologues}, @pxref{AVR Options}.
3880
3881 @item OS_main
3882 @itemx OS_task
3883 @cindex @code{OS_main} function attribute, AVR
3884 @cindex @code{OS_task} function attribute, AVR
3885 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3886 do not save/restore any call-saved register in their prologue/epilogue.
3887
3888 The @code{OS_main} attribute can be used when there @emph{is
3889 guarantee} that interrupts are disabled at the time when the function
3890 is entered. This saves resources when the stack pointer has to be
3891 changed to set up a frame for local variables.
3892
3893 The @code{OS_task} attribute can be used when there is @emph{no
3894 guarantee} that interrupts are disabled at that time when the function
3895 is entered like for, e@.g@. task functions in a multi-threading operating
3896 system. In that case, changing the stack pointer register is
3897 guarded by save/clear/restore of the global interrupt enable flag.
3898
3899 The differences to the @code{naked} function attribute are:
3900 @itemize @bullet
3901 @item @code{naked} functions do not have a return instruction whereas
3902 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3903 @code{RETI} return instruction.
3904 @item @code{naked} functions do not set up a frame for local variables
3905 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3906 as needed.
3907 @end itemize
3908
3909 @item signal
3910 @cindex @code{signal} function attribute, AVR
3911 Use this attribute on the AVR to indicate that the specified
3912 function is an interrupt handler. The compiler generates function
3913 entry and exit sequences suitable for use in an interrupt handler when this
3914 attribute is present.
3915
3916 See also the @code{interrupt} function attribute.
3917
3918 The AVR hardware globally disables interrupts when an interrupt is executed.
3919 Interrupt handler functions defined with the @code{signal} attribute
3920 do not re-enable interrupts. It is save to enable interrupts in a
3921 @code{signal} handler. This ``save'' only applies to the code
3922 generated by the compiler and not to the IRQ layout of the
3923 application which is responsibility of the application.
3924
3925 If both @code{signal} and @code{interrupt} are specified for the same
3926 function, @code{signal} is silently ignored.
3927 @end table
3928
3929 @node Blackfin Function Attributes
3930 @subsection Blackfin Function Attributes
3931
3932 These function attributes are supported by the Blackfin back end:
3933
3934 @table @code
3935
3936 @item exception_handler
3937 @cindex @code{exception_handler} function attribute
3938 @cindex exception handler functions, Blackfin
3939 Use this attribute on the Blackfin to indicate that the specified function
3940 is an exception handler. The compiler generates function entry and
3941 exit sequences suitable for use in an exception handler when this
3942 attribute is present.
3943
3944 @item interrupt_handler
3945 @cindex @code{interrupt_handler} function attribute, Blackfin
3946 Use this attribute to
3947 indicate that the specified function is an interrupt handler. The compiler
3948 generates function entry and exit sequences suitable for use in an
3949 interrupt handler when this attribute is present.
3950
3951 @item kspisusp
3952 @cindex @code{kspisusp} function attribute, Blackfin
3953 @cindex User stack pointer in interrupts on the Blackfin
3954 When used together with @code{interrupt_handler}, @code{exception_handler}
3955 or @code{nmi_handler}, code is generated to load the stack pointer
3956 from the USP register in the function prologue.
3957
3958 @item l1_text
3959 @cindex @code{l1_text} function attribute, Blackfin
3960 This attribute specifies a function to be placed into L1 Instruction
3961 SRAM@. The function is put into a specific section named @code{.l1.text}.
3962 With @option{-mfdpic}, function calls with a such function as the callee
3963 or caller uses inlined PLT.
3964
3965 @item l2
3966 @cindex @code{l2} function attribute, Blackfin
3967 This attribute specifies a function to be placed into L2
3968 SRAM. The function is put into a specific section named
3969 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3970 an inlined PLT.
3971
3972 @item longcall
3973 @itemx shortcall
3974 @cindex indirect calls, Blackfin
3975 @cindex @code{longcall} function attribute, Blackfin
3976 @cindex @code{shortcall} function attribute, Blackfin
3977 The @code{longcall} attribute
3978 indicates that the function might be far away from the call site and
3979 require a different (more expensive) calling sequence. The
3980 @code{shortcall} attribute indicates that the function is always close
3981 enough for the shorter calling sequence to be used. These attributes
3982 override the @option{-mlongcall} switch.
3983
3984 @item nesting
3985 @cindex @code{nesting} function attribute, Blackfin
3986 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3987 Use this attribute together with @code{interrupt_handler},
3988 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3989 entry code should enable nested interrupts or exceptions.
3990
3991 @item nmi_handler
3992 @cindex @code{nmi_handler} function attribute, Blackfin
3993 @cindex NMI handler functions on the Blackfin processor
3994 Use this attribute on the Blackfin to indicate that the specified function
3995 is an NMI handler. The compiler generates function entry and
3996 exit sequences suitable for use in an NMI handler when this
3997 attribute is present.
3998
3999 @item saveall
4000 @cindex @code{saveall} function attribute, Blackfin
4001 @cindex save all registers on the Blackfin
4002 Use this attribute to indicate that
4003 all registers except the stack pointer should be saved in the prologue
4004 regardless of whether they are used or not.
4005 @end table
4006
4007 @node CR16 Function Attributes
4008 @subsection CR16 Function Attributes
4009
4010 These function attributes are supported by the CR16 back end:
4011
4012 @table @code
4013 @item interrupt
4014 @cindex @code{interrupt} function attribute, CR16
4015 Use this attribute to indicate
4016 that the specified function is an interrupt handler. The compiler generates
4017 function entry and exit sequences suitable for use in an interrupt handler
4018 when this attribute is present.
4019 @end table
4020
4021 @node Epiphany Function Attributes
4022 @subsection Epiphany Function Attributes
4023
4024 These function attributes are supported by the Epiphany back end:
4025
4026 @table @code
4027 @item disinterrupt
4028 @cindex @code{disinterrupt} function attribute, Epiphany
4029 This attribute causes the compiler to emit
4030 instructions to disable interrupts for the duration of the given
4031 function.
4032
4033 @item forwarder_section
4034 @cindex @code{forwarder_section} function attribute, Epiphany
4035 This attribute modifies the behavior of an interrupt handler.
4036 The interrupt handler may be in external memory which cannot be
4037 reached by a branch instruction, so generate a local memory trampoline
4038 to transfer control. The single parameter identifies the section where
4039 the trampoline is placed.
4040
4041 @item interrupt
4042 @cindex @code{interrupt} function attribute, Epiphany
4043 Use this attribute to indicate
4044 that the specified function is an interrupt handler. The compiler generates
4045 function entry and exit sequences suitable for use in an interrupt handler
4046 when this attribute is present. It may also generate
4047 a special section with code to initialize the interrupt vector table.
4048
4049 On Epiphany targets one or more optional parameters can be added like this:
4050
4051 @smallexample
4052 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
4053 @end smallexample
4054
4055 Permissible values for these parameters are: @w{@code{reset}},
4056 @w{@code{software_exception}}, @w{@code{page_miss}},
4057 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
4058 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
4059 Multiple parameters indicate that multiple entries in the interrupt
4060 vector table should be initialized for this function, i.e.@: for each
4061 parameter @w{@var{name}}, a jump to the function is emitted in
4062 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
4063 entirely, in which case no interrupt vector table entry is provided.
4064
4065 Note that interrupts are enabled inside the function
4066 unless the @code{disinterrupt} attribute is also specified.
4067
4068 The following examples are all valid uses of these attributes on
4069 Epiphany targets:
4070 @smallexample
4071 void __attribute__ ((interrupt)) universal_handler ();
4072 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
4073 void __attribute__ ((interrupt ("dma0, dma1")))
4074 universal_dma_handler ();
4075 void __attribute__ ((interrupt ("timer0"), disinterrupt))
4076 fast_timer_handler ();
4077 void __attribute__ ((interrupt ("dma0, dma1"),
4078 forwarder_section ("tramp")))
4079 external_dma_handler ();
4080 @end smallexample
4081
4082 @item long_call
4083 @itemx short_call
4084 @cindex @code{long_call} function attribute, Epiphany
4085 @cindex @code{short_call} function attribute, Epiphany
4086 @cindex indirect calls, Epiphany
4087 These attributes specify how a particular function is called.
4088 These attributes override the
4089 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4090 command-line switch and @code{#pragma long_calls} settings.
4091 @end table
4092
4093
4094 @node H8/300 Function Attributes
4095 @subsection H8/300 Function Attributes
4096
4097 These function attributes are available for H8/300 targets:
4098
4099 @table @code
4100 @item function_vector
4101 @cindex @code{function_vector} function attribute, H8/300
4102 Use this attribute on the H8/300, H8/300H, and H8S to indicate
4103 that the specified function should be called through the function vector.
4104 Calling a function through the function vector reduces code size; however,
4105 the function vector has a limited size (maximum 128 entries on the H8/300
4106 and 64 entries on the H8/300H and H8S)
4107 and shares space with the interrupt vector.
4108
4109 @item interrupt_handler
4110 @cindex @code{interrupt_handler} function attribute, H8/300
4111 Use this attribute on the H8/300, H8/300H, and H8S to
4112 indicate that the specified function is an interrupt handler. The compiler
4113 generates function entry and exit sequences suitable for use in an
4114 interrupt handler when this attribute is present.
4115
4116 @item saveall
4117 @cindex @code{saveall} function attribute, H8/300
4118 @cindex save all registers on the H8/300, H8/300H, and H8S
4119 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4120 all registers except the stack pointer should be saved in the prologue
4121 regardless of whether they are used or not.
4122 @end table
4123
4124 @node IA-64 Function Attributes
4125 @subsection IA-64 Function Attributes
4126
4127 These function attributes are supported on IA-64 targets:
4128
4129 @table @code
4130 @item syscall_linkage
4131 @cindex @code{syscall_linkage} function attribute, IA-64
4132 This attribute is used to modify the IA-64 calling convention by marking
4133 all input registers as live at all function exits. This makes it possible
4134 to restart a system call after an interrupt without having to save/restore
4135 the input registers. This also prevents kernel data from leaking into
4136 application code.
4137
4138 @item version_id
4139 @cindex @code{version_id} function attribute, IA-64
4140 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4141 symbol to contain a version string, thus allowing for function level
4142 versioning. HP-UX system header files may use function level versioning
4143 for some system calls.
4144
4145 @smallexample
4146 extern int foo () __attribute__((version_id ("20040821")));
4147 @end smallexample
4148
4149 @noindent
4150 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4151 @end table
4152
4153 @node M32C Function Attributes
4154 @subsection M32C Function Attributes
4155
4156 These function attributes are supported by the M32C back end:
4157
4158 @table @code
4159 @item bank_switch
4160 @cindex @code{bank_switch} function attribute, M32C
4161 When added to an interrupt handler with the M32C port, causes the
4162 prologue and epilogue to use bank switching to preserve the registers
4163 rather than saving them on the stack.
4164
4165 @item fast_interrupt
4166 @cindex @code{fast_interrupt} function attribute, M32C
4167 Use this attribute on the M32C port to indicate that the specified
4168 function is a fast interrupt handler. This is just like the
4169 @code{interrupt} attribute, except that @code{freit} is used to return
4170 instead of @code{reit}.
4171
4172 @item function_vector
4173 @cindex @code{function_vector} function attribute, M16C/M32C
4174 On M16C/M32C targets, the @code{function_vector} attribute declares a
4175 special page subroutine call function. Use of this attribute reduces
4176 the code size by 2 bytes for each call generated to the
4177 subroutine. The argument to the attribute is the vector number entry
4178 from the special page vector table which contains the 16 low-order
4179 bits of the subroutine's entry address. Each vector table has special
4180 page number (18 to 255) that is used in @code{jsrs} instructions.
4181 Jump addresses of the routines are generated by adding 0x0F0000 (in
4182 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4183 2-byte addresses set in the vector table. Therefore you need to ensure
4184 that all the special page vector routines should get mapped within the
4185 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4186 (for M32C).
4187
4188 In the following example 2 bytes are saved for each call to
4189 function @code{foo}.
4190
4191 @smallexample
4192 void foo (void) __attribute__((function_vector(0x18)));
4193 void foo (void)
4194 @{
4195 @}
4196
4197 void bar (void)
4198 @{
4199 foo();
4200 @}
4201 @end smallexample
4202
4203 If functions are defined in one file and are called in another file,
4204 then be sure to write this declaration in both files.
4205
4206 This attribute is ignored for R8C target.
4207
4208 @item interrupt
4209 @cindex @code{interrupt} function attribute, M32C
4210 Use this attribute to indicate
4211 that the specified function is an interrupt handler. The compiler generates
4212 function entry and exit sequences suitable for use in an interrupt handler
4213 when this attribute is present.
4214 @end table
4215
4216 @node M32R/D Function Attributes
4217 @subsection M32R/D Function Attributes
4218
4219 These function attributes are supported by the M32R/D back end:
4220
4221 @table @code
4222 @item interrupt
4223 @cindex @code{interrupt} function attribute, M32R/D
4224 Use this attribute to indicate
4225 that the specified function is an interrupt handler. The compiler generates
4226 function entry and exit sequences suitable for use in an interrupt handler
4227 when this attribute is present.
4228
4229 @item model (@var{model-name})
4230 @cindex @code{model} function attribute, M32R/D
4231 @cindex function addressability on the M32R/D
4232
4233 On the M32R/D, use this attribute to set the addressability of an
4234 object, and of the code generated for a function. The identifier
4235 @var{model-name} is one of @code{small}, @code{medium}, or
4236 @code{large}, representing each of the code models.
4237
4238 Small model objects live in the lower 16MB of memory (so that their
4239 addresses can be loaded with the @code{ld24} instruction), and are
4240 callable with the @code{bl} instruction.
4241
4242 Medium model objects may live anywhere in the 32-bit address space (the
4243 compiler generates @code{seth/add3} instructions to load their addresses),
4244 and are callable with the @code{bl} instruction.
4245
4246 Large model objects may live anywhere in the 32-bit address space (the
4247 compiler generates @code{seth/add3} instructions to load their addresses),
4248 and may not be reachable with the @code{bl} instruction (the compiler
4249 generates the much slower @code{seth/add3/jl} instruction sequence).
4250 @end table
4251
4252 @node m68k Function Attributes
4253 @subsection m68k Function Attributes
4254
4255 These function attributes are supported by the m68k back end:
4256
4257 @table @code
4258 @item interrupt
4259 @itemx interrupt_handler
4260 @cindex @code{interrupt} function attribute, m68k
4261 @cindex @code{interrupt_handler} function attribute, m68k
4262 Use this attribute to
4263 indicate that the specified function is an interrupt handler. The compiler
4264 generates function entry and exit sequences suitable for use in an
4265 interrupt handler when this attribute is present. Either name may be used.
4266
4267 @item interrupt_thread
4268 @cindex @code{interrupt_thread} function attribute, fido
4269 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4270 that the specified function is an interrupt handler that is designed
4271 to run as a thread. The compiler omits generate prologue/epilogue
4272 sequences and replaces the return instruction with a @code{sleep}
4273 instruction. This attribute is available only on fido.
4274 @end table
4275
4276 @node MCORE Function Attributes
4277 @subsection MCORE Function Attributes
4278
4279 These function attributes are supported by the MCORE back end:
4280
4281 @table @code
4282 @item naked
4283 @cindex @code{naked} function attribute, MCORE
4284 This attribute allows the compiler to construct the
4285 requisite function declaration, while allowing the body of the
4286 function to be assembly code. The specified function will not have
4287 prologue/epilogue sequences generated by the compiler. Only basic
4288 @code{asm} statements can safely be included in naked functions
4289 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4290 basic @code{asm} and C code may appear to work, they cannot be
4291 depended upon to work reliably and are not supported.
4292 @end table
4293
4294 @node MeP Function Attributes
4295 @subsection MeP Function Attributes
4296
4297 These function attributes are supported by the MeP back end:
4298
4299 @table @code
4300 @item disinterrupt
4301 @cindex @code{disinterrupt} function attribute, MeP
4302 On MeP targets, this attribute causes the compiler to emit
4303 instructions to disable interrupts for the duration of the given
4304 function.
4305
4306 @item interrupt
4307 @cindex @code{interrupt} function attribute, MeP
4308 Use this attribute to indicate
4309 that the specified function is an interrupt handler. The compiler generates
4310 function entry and exit sequences suitable for use in an interrupt handler
4311 when this attribute is present.
4312
4313 @item near
4314 @cindex @code{near} function attribute, MeP
4315 This attribute causes the compiler to assume the called
4316 function is close enough to use the normal calling convention,
4317 overriding the @option{-mtf} command-line option.
4318
4319 @item far
4320 @cindex @code{far} function attribute, MeP
4321 On MeP targets this causes the compiler to use a calling convention
4322 that assumes the called function is too far away for the built-in
4323 addressing modes.
4324
4325 @item vliw
4326 @cindex @code{vliw} function attribute, MeP
4327 The @code{vliw} attribute tells the compiler to emit
4328 instructions in VLIW mode instead of core mode. Note that this
4329 attribute is not allowed unless a VLIW coprocessor has been configured
4330 and enabled through command-line options.
4331 @end table
4332
4333 @node MicroBlaze Function Attributes
4334 @subsection MicroBlaze Function Attributes
4335
4336 These function attributes are supported on MicroBlaze targets:
4337
4338 @table @code
4339 @item save_volatiles
4340 @cindex @code{save_volatiles} function attribute, MicroBlaze
4341 Use this attribute to indicate that the function is
4342 an interrupt handler. All volatile registers (in addition to non-volatile
4343 registers) are saved in the function prologue. If the function is a leaf
4344 function, only volatiles used by the function are saved. A normal function
4345 return is generated instead of a return from interrupt.
4346
4347 @item break_handler
4348 @cindex @code{break_handler} function attribute, MicroBlaze
4349 @cindex break handler functions
4350 Use this attribute to indicate that
4351 the specified function is a break handler. The compiler generates function
4352 entry and exit sequences suitable for use in an break handler when this
4353 attribute is present. The return from @code{break_handler} is done through
4354 the @code{rtbd} instead of @code{rtsd}.
4355
4356 @smallexample
4357 void f () __attribute__ ((break_handler));
4358 @end smallexample
4359
4360 @item interrupt_handler
4361 @itemx fast_interrupt
4362 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4363 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4364 These attributes indicate that the specified function is an interrupt
4365 handler. Use the @code{fast_interrupt} attribute to indicate handlers
4366 used in low-latency interrupt mode, and @code{interrupt_handler} for
4367 interrupts that do not use low-latency handlers. In both cases, GCC
4368 emits appropriate prologue code and generates a return from the handler
4369 using @code{rtid} instead of @code{rtsd}.
4370 @end table
4371
4372 @node Microsoft Windows Function Attributes
4373 @subsection Microsoft Windows Function Attributes
4374
4375 The following attributes are available on Microsoft Windows and Symbian OS
4376 targets.
4377
4378 @table @code
4379 @item dllexport
4380 @cindex @code{dllexport} function attribute
4381 @cindex @code{__declspec(dllexport)}
4382 On Microsoft Windows targets and Symbian OS targets the
4383 @code{dllexport} attribute causes the compiler to provide a global
4384 pointer to a pointer in a DLL, so that it can be referenced with the
4385 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4386 name is formed by combining @code{_imp__} and the function or variable
4387 name.
4388
4389 You can use @code{__declspec(dllexport)} as a synonym for
4390 @code{__attribute__ ((dllexport))} for compatibility with other
4391 compilers.
4392
4393 On systems that support the @code{visibility} attribute, this
4394 attribute also implies ``default'' visibility. It is an error to
4395 explicitly specify any other visibility.
4396
4397 GCC's default behavior is to emit all inline functions with the
4398 @code{dllexport} attribute. Since this can cause object file-size bloat,
4399 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4400 ignore the attribute for inlined functions unless the
4401 @option{-fkeep-inline-functions} flag is used instead.
4402
4403 The attribute is ignored for undefined symbols.
4404
4405 When applied to C++ classes, the attribute marks defined non-inlined
4406 member functions and static data members as exports. Static consts
4407 initialized in-class are not marked unless they are also defined
4408 out-of-class.
4409
4410 For Microsoft Windows targets there are alternative methods for
4411 including the symbol in the DLL's export table such as using a
4412 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4413 the @option{--export-all} linker flag.
4414
4415 @item dllimport
4416 @cindex @code{dllimport} function attribute
4417 @cindex @code{__declspec(dllimport)}
4418 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4419 attribute causes the compiler to reference a function or variable via
4420 a global pointer to a pointer that is set up by the DLL exporting the
4421 symbol. The attribute implies @code{extern}. On Microsoft Windows
4422 targets, the pointer name is formed by combining @code{_imp__} and the
4423 function or variable name.
4424
4425 You can use @code{__declspec(dllimport)} as a synonym for
4426 @code{__attribute__ ((dllimport))} for compatibility with other
4427 compilers.
4428
4429 On systems that support the @code{visibility} attribute, this
4430 attribute also implies ``default'' visibility. It is an error to
4431 explicitly specify any other visibility.
4432
4433 Currently, the attribute is ignored for inlined functions. If the
4434 attribute is applied to a symbol @emph{definition}, an error is reported.
4435 If a symbol previously declared @code{dllimport} is later defined, the
4436 attribute is ignored in subsequent references, and a warning is emitted.
4437 The attribute is also overridden by a subsequent declaration as
4438 @code{dllexport}.
4439
4440 When applied to C++ classes, the attribute marks non-inlined
4441 member functions and static data members as imports. However, the
4442 attribute is ignored for virtual methods to allow creation of vtables
4443 using thunks.
4444
4445 On the SH Symbian OS target the @code{dllimport} attribute also has
4446 another affect---it can cause the vtable and run-time type information
4447 for a class to be exported. This happens when the class has a
4448 dllimported constructor or a non-inline, non-pure virtual function
4449 and, for either of those two conditions, the class also has an inline
4450 constructor or destructor and has a key function that is defined in
4451 the current translation unit.
4452
4453 For Microsoft Windows targets the use of the @code{dllimport}
4454 attribute on functions is not necessary, but provides a small
4455 performance benefit by eliminating a thunk in the DLL@. The use of the
4456 @code{dllimport} attribute on imported variables can be avoided by passing the
4457 @option{--enable-auto-import} switch to the GNU linker. As with
4458 functions, using the attribute for a variable eliminates a thunk in
4459 the DLL@.
4460
4461 One drawback to using this attribute is that a pointer to a
4462 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4463 address. However, a pointer to a @emph{function} with the
4464 @code{dllimport} attribute can be used as a constant initializer; in
4465 this case, the address of a stub function in the import lib is
4466 referenced. On Microsoft Windows targets, the attribute can be disabled
4467 for functions by setting the @option{-mnop-fun-dllimport} flag.
4468 @end table
4469
4470 @node MIPS Function Attributes
4471 @subsection MIPS Function Attributes
4472
4473 These function attributes are supported by the MIPS back end:
4474
4475 @table @code
4476 @item interrupt
4477 @cindex @code{interrupt} function attribute, MIPS
4478 Use this attribute to indicate that the specified function is an interrupt
4479 handler. The compiler generates function entry and exit sequences suitable
4480 for use in an interrupt handler when this attribute is present.
4481 An optional argument is supported for the interrupt attribute which allows
4482 the interrupt mode to be described. By default GCC assumes the external
4483 interrupt controller (EIC) mode is in use, this can be explicitly set using
4484 @code{eic}. When interrupts are non-masked then the requested Interrupt
4485 Priority Level (IPL) is copied to the current IPL which has the effect of only
4486 enabling higher priority interrupts. To use vectored interrupt mode use
4487 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4488 the behavior of the non-masked interrupt support and GCC will arrange to mask
4489 all interrupts from sw0 up to and including the specified interrupt vector.
4490
4491 You can use the following attributes to modify the behavior
4492 of an interrupt handler:
4493 @table @code
4494 @item use_shadow_register_set
4495 @cindex @code{use_shadow_register_set} function attribute, MIPS
4496 Assume that the handler uses a shadow register set, instead of
4497 the main general-purpose registers. An optional argument @code{intstack} is
4498 supported to indicate that the shadow register set contains a valid stack
4499 pointer.
4500
4501 @item keep_interrupts_masked
4502 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4503 Keep interrupts masked for the whole function. Without this attribute,
4504 GCC tries to reenable interrupts for as much of the function as it can.
4505
4506 @item use_debug_exception_return
4507 @cindex @code{use_debug_exception_return} function attribute, MIPS
4508 Return using the @code{deret} instruction. Interrupt handlers that don't
4509 have this attribute return using @code{eret} instead.
4510 @end table
4511
4512 You can use any combination of these attributes, as shown below:
4513 @smallexample
4514 void __attribute__ ((interrupt)) v0 ();
4515 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4516 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4517 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4518 void __attribute__ ((interrupt, use_shadow_register_set,
4519 keep_interrupts_masked)) v4 ();
4520 void __attribute__ ((interrupt, use_shadow_register_set,
4521 use_debug_exception_return)) v5 ();
4522 void __attribute__ ((interrupt, keep_interrupts_masked,
4523 use_debug_exception_return)) v6 ();
4524 void __attribute__ ((interrupt, use_shadow_register_set,
4525 keep_interrupts_masked,
4526 use_debug_exception_return)) v7 ();
4527 void __attribute__ ((interrupt("eic"))) v8 ();
4528 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4529 @end smallexample
4530
4531 @item long_call
4532 @itemx short_call
4533 @itemx near
4534 @itemx far
4535 @cindex indirect calls, MIPS
4536 @cindex @code{long_call} function attribute, MIPS
4537 @cindex @code{short_call} function attribute, MIPS
4538 @cindex @code{near} function attribute, MIPS
4539 @cindex @code{far} function attribute, MIPS
4540 These attributes specify how a particular function is called on MIPS@.
4541 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4542 command-line switch. The @code{long_call} and @code{far} attributes are
4543 synonyms, and cause the compiler to always call
4544 the function by first loading its address into a register, and then using
4545 the contents of that register. The @code{short_call} and @code{near}
4546 attributes are synonyms, and have the opposite
4547 effect; they specify that non-PIC calls should be made using the more
4548 efficient @code{jal} instruction.
4549
4550 @item mips16
4551 @itemx nomips16
4552 @cindex @code{mips16} function attribute, MIPS
4553 @cindex @code{nomips16} function attribute, MIPS
4554
4555 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4556 function attributes to locally select or turn off MIPS16 code generation.
4557 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4558 while MIPS16 code generation is disabled for functions with the
4559 @code{nomips16} attribute. These attributes override the
4560 @option{-mips16} and @option{-mno-mips16} options on the command line
4561 (@pxref{MIPS Options}).
4562
4563 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4564 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4565 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4566 may interact badly with some GCC extensions such as @code{__builtin_apply}
4567 (@pxref{Constructing Calls}).
4568
4569 @item micromips, MIPS
4570 @itemx nomicromips, MIPS
4571 @cindex @code{micromips} function attribute
4572 @cindex @code{nomicromips} function attribute
4573
4574 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4575 function attributes to locally select or turn off microMIPS code generation.
4576 A function with the @code{micromips} attribute is emitted as microMIPS code,
4577 while microMIPS code generation is disabled for functions with the
4578 @code{nomicromips} attribute. These attributes override the
4579 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4580 (@pxref{MIPS Options}).
4581
4582 When compiling files containing mixed microMIPS and non-microMIPS code, the
4583 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4584 command line,
4585 not that within individual functions. Mixed microMIPS and non-microMIPS code
4586 may interact badly with some GCC extensions such as @code{__builtin_apply}
4587 (@pxref{Constructing Calls}).
4588
4589 @item nocompression
4590 @cindex @code{nocompression} function attribute, MIPS
4591 On MIPS targets, you can use the @code{nocompression} function attribute
4592 to locally turn off MIPS16 and microMIPS code generation. This attribute
4593 overrides the @option{-mips16} and @option{-mmicromips} options on the
4594 command line (@pxref{MIPS Options}).
4595 @end table
4596
4597 @node MSP430 Function Attributes
4598 @subsection MSP430 Function Attributes
4599
4600 These function attributes are supported by the MSP430 back end:
4601
4602 @table @code
4603 @item critical
4604 @cindex @code{critical} function attribute, MSP430
4605 Critical functions disable interrupts upon entry and restore the
4606 previous interrupt state upon exit. Critical functions cannot also
4607 have the @code{naked} or @code{reentrant} attributes. They can have
4608 the @code{interrupt} attribute.
4609
4610 @item interrupt
4611 @cindex @code{interrupt} function attribute, MSP430
4612 Use this attribute to indicate
4613 that the specified function is an interrupt handler. The compiler generates
4614 function entry and exit sequences suitable for use in an interrupt handler
4615 when this attribute is present.
4616
4617 You can provide an argument to the interrupt
4618 attribute which specifies a name or number. If the argument is a
4619 number it indicates the slot in the interrupt vector table (0 - 31) to
4620 which this handler should be assigned. If the argument is a name it
4621 is treated as a symbolic name for the vector slot. These names should
4622 match up with appropriate entries in the linker script. By default
4623 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4624 @code{reset} for vector 31 are recognized.
4625
4626 @item naked
4627 @cindex @code{naked} function attribute, MSP430
4628 This attribute allows the compiler to construct the
4629 requisite function declaration, while allowing the body of the
4630 function to be assembly code. The specified function will not have
4631 prologue/epilogue sequences generated by the compiler. Only basic
4632 @code{asm} statements can safely be included in naked functions
4633 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4634 basic @code{asm} and C code may appear to work, they cannot be
4635 depended upon to work reliably and are not supported.
4636
4637 @item reentrant
4638 @cindex @code{reentrant} function attribute, MSP430
4639 Reentrant functions disable interrupts upon entry and enable them
4640 upon exit. Reentrant functions cannot also have the @code{naked}
4641 or @code{critical} attributes. They can have the @code{interrupt}
4642 attribute.
4643
4644 @item wakeup
4645 @cindex @code{wakeup} function attribute, MSP430
4646 This attribute only applies to interrupt functions. It is silently
4647 ignored if applied to a non-interrupt function. A wakeup interrupt
4648 function will rouse the processor from any low-power state that it
4649 might be in when the function exits.
4650
4651 @item lower
4652 @itemx upper
4653 @itemx either
4654 @cindex @code{lower} function attribute, MSP430
4655 @cindex @code{upper} function attribute, MSP430
4656 @cindex @code{either} function attribute, MSP430
4657 On the MSP430 target these attributes can be used to specify whether
4658 the function or variable should be placed into low memory, high
4659 memory, or the placement should be left to the linker to decide. The
4660 attributes are only significant if compiling for the MSP430X
4661 architecture.
4662
4663 The attributes work in conjunction with a linker script that has been
4664 augmented to specify where to place sections with a @code{.lower} and
4665 a @code{.upper} prefix. So, for example, as well as placing the
4666 @code{.data} section, the script also specifies the placement of a
4667 @code{.lower.data} and a @code{.upper.data} section. The intention
4668 is that @code{lower} sections are placed into a small but easier to
4669 access memory region and the upper sections are placed into a larger, but
4670 slower to access, region.
4671
4672 The @code{either} attribute is special. It tells the linker to place
4673 the object into the corresponding @code{lower} section if there is
4674 room for it. If there is insufficient room then the object is placed
4675 into the corresponding @code{upper} section instead. Note that the
4676 placement algorithm is not very sophisticated. It does not attempt to
4677 find an optimal packing of the @code{lower} sections. It just makes
4678 one pass over the objects and does the best that it can. Using the
4679 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4680 options can help the packing, however, since they produce smaller,
4681 easier to pack regions.
4682 @end table
4683
4684 @node NDS32 Function Attributes
4685 @subsection NDS32 Function Attributes
4686
4687 These function attributes are supported by the NDS32 back end:
4688
4689 @table @code
4690 @item exception
4691 @cindex @code{exception} function attribute
4692 @cindex exception handler functions, NDS32
4693 Use this attribute on the NDS32 target to indicate that the specified function
4694 is an exception handler. The compiler will generate corresponding sections
4695 for use in an exception handler.
4696
4697 @item interrupt
4698 @cindex @code{interrupt} function attribute, NDS32
4699 On NDS32 target, this attribute indicates that the specified function
4700 is an interrupt handler. The compiler generates corresponding sections
4701 for use in an interrupt handler. You can use the following attributes
4702 to modify the behavior:
4703 @table @code
4704 @item nested
4705 @cindex @code{nested} function attribute, NDS32
4706 This interrupt service routine is interruptible.
4707 @item not_nested
4708 @cindex @code{not_nested} function attribute, NDS32
4709 This interrupt service routine is not interruptible.
4710 @item nested_ready
4711 @cindex @code{nested_ready} function attribute, NDS32
4712 This interrupt service routine is interruptible after @code{PSW.GIE}
4713 (global interrupt enable) is set. This allows interrupt service routine to
4714 finish some short critical code before enabling interrupts.
4715 @item save_all
4716 @cindex @code{save_all} function attribute, NDS32
4717 The system will help save all registers into stack before entering
4718 interrupt handler.
4719 @item partial_save
4720 @cindex @code{partial_save} function attribute, NDS32
4721 The system will help save caller registers into stack before entering
4722 interrupt handler.
4723 @end table
4724
4725 @item naked
4726 @cindex @code{naked} function attribute, NDS32
4727 This attribute allows the compiler to construct the
4728 requisite function declaration, while allowing the body of the
4729 function to be assembly code. The specified function will not have
4730 prologue/epilogue sequences generated by the compiler. Only basic
4731 @code{asm} statements can safely be included in naked functions
4732 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4733 basic @code{asm} and C code may appear to work, they cannot be
4734 depended upon to work reliably and are not supported.
4735
4736 @item reset
4737 @cindex @code{reset} function attribute, NDS32
4738 @cindex reset handler functions
4739 Use this attribute on the NDS32 target to indicate that the specified function
4740 is a reset handler. The compiler will generate corresponding sections
4741 for use in a reset handler. You can use the following attributes
4742 to provide extra exception handling:
4743 @table @code
4744 @item nmi
4745 @cindex @code{nmi} function attribute, NDS32
4746 Provide a user-defined function to handle NMI exception.
4747 @item warm
4748 @cindex @code{warm} function attribute, NDS32
4749 Provide a user-defined function to handle warm reset exception.
4750 @end table
4751 @end table
4752
4753 @node Nios II Function Attributes
4754 @subsection Nios II Function Attributes
4755
4756 These function attributes are supported by the Nios II back end:
4757
4758 @table @code
4759 @item target (@var{options})
4760 @cindex @code{target} function attribute
4761 As discussed in @ref{Common Function Attributes}, this attribute
4762 allows specification of target-specific compilation options.
4763
4764 When compiling for Nios II, the following options are allowed:
4765
4766 @table @samp
4767 @item custom-@var{insn}=@var{N}
4768 @itemx no-custom-@var{insn}
4769 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4770 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4771 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4772 custom instruction with encoding @var{N} when generating code that uses
4773 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4774 the custom instruction @var{insn}.
4775 These target attributes correspond to the
4776 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4777 command-line options, and support the same set of @var{insn} keywords.
4778 @xref{Nios II Options}, for more information.
4779
4780 @item custom-fpu-cfg=@var{name}
4781 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4782 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4783 command-line option, to select a predefined set of custom instructions
4784 named @var{name}.
4785 @xref{Nios II Options}, for more information.
4786 @end table
4787 @end table
4788
4789 @node Nvidia PTX Function Attributes
4790 @subsection Nvidia PTX Function Attributes
4791
4792 These function attributes are supported by the Nvidia PTX back end:
4793
4794 @table @code
4795 @item kernel
4796 @cindex @code{kernel} attribute, Nvidia PTX
4797 This attribute indicates that the corresponding function should be compiled
4798 as a kernel function, which can be invoked from the host via the CUDA RT
4799 library.
4800 By default functions are only callable only from other PTX functions.
4801
4802 Kernel functions must have @code{void} return type.
4803 @end table
4804
4805 @node PowerPC Function Attributes
4806 @subsection PowerPC Function Attributes
4807
4808 These function attributes are supported by the PowerPC back end:
4809
4810 @table @code
4811 @item longcall
4812 @itemx shortcall
4813 @cindex indirect calls, PowerPC
4814 @cindex @code{longcall} function attribute, PowerPC
4815 @cindex @code{shortcall} function attribute, PowerPC
4816 The @code{longcall} attribute
4817 indicates that the function might be far away from the call site and
4818 require a different (more expensive) calling sequence. The
4819 @code{shortcall} attribute indicates that the function is always close
4820 enough for the shorter calling sequence to be used. These attributes
4821 override both the @option{-mlongcall} switch and
4822 the @code{#pragma longcall} setting.
4823
4824 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4825 calls are necessary.
4826
4827 @item target (@var{options})
4828 @cindex @code{target} function attribute
4829 As discussed in @ref{Common Function Attributes}, this attribute
4830 allows specification of target-specific compilation options.
4831
4832 On the PowerPC, the following options are allowed:
4833
4834 @table @samp
4835 @item altivec
4836 @itemx no-altivec
4837 @cindex @code{target("altivec")} function attribute, PowerPC
4838 Generate code that uses (does not use) AltiVec instructions. In
4839 32-bit code, you cannot enable AltiVec instructions unless
4840 @option{-mabi=altivec} is used on the command line.
4841
4842 @item cmpb
4843 @itemx no-cmpb
4844 @cindex @code{target("cmpb")} function attribute, PowerPC
4845 Generate code that uses (does not use) the compare bytes instruction
4846 implemented on the POWER6 processor and other processors that support
4847 the PowerPC V2.05 architecture.
4848
4849 @item dlmzb
4850 @itemx no-dlmzb
4851 @cindex @code{target("dlmzb")} function attribute, PowerPC
4852 Generate code that uses (does not use) the string-search @samp{dlmzb}
4853 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4854 generated by default when targeting those processors.
4855
4856 @item fprnd
4857 @itemx no-fprnd
4858 @cindex @code{target("fprnd")} function attribute, PowerPC
4859 Generate code that uses (does not use) the FP round to integer
4860 instructions implemented on the POWER5+ processor and other processors
4861 that support the PowerPC V2.03 architecture.
4862
4863 @item hard-dfp
4864 @itemx no-hard-dfp
4865 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4866 Generate code that uses (does not use) the decimal floating-point
4867 instructions implemented on some POWER processors.
4868
4869 @item isel
4870 @itemx no-isel
4871 @cindex @code{target("isel")} function attribute, PowerPC
4872 Generate code that uses (does not use) ISEL instruction.
4873
4874 @item mfcrf
4875 @itemx no-mfcrf
4876 @cindex @code{target("mfcrf")} function attribute, PowerPC
4877 Generate code that uses (does not use) the move from condition
4878 register field instruction implemented on the POWER4 processor and
4879 other processors that support the PowerPC V2.01 architecture.
4880
4881 @item mfpgpr
4882 @itemx no-mfpgpr
4883 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4884 Generate code that uses (does not use) the FP move to/from general
4885 purpose register instructions implemented on the POWER6X processor and
4886 other processors that support the extended PowerPC V2.05 architecture.
4887
4888 @item mulhw
4889 @itemx no-mulhw
4890 @cindex @code{target("mulhw")} function attribute, PowerPC
4891 Generate code that uses (does not use) the half-word multiply and
4892 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4893 These instructions are generated by default when targeting those
4894 processors.
4895
4896 @item multiple
4897 @itemx no-multiple
4898 @cindex @code{target("multiple")} function attribute, PowerPC
4899 Generate code that uses (does not use) the load multiple word
4900 instructions and the store multiple word instructions.
4901
4902 @item update
4903 @itemx no-update
4904 @cindex @code{target("update")} function attribute, PowerPC
4905 Generate code that uses (does not use) the load or store instructions
4906 that update the base register to the address of the calculated memory
4907 location.
4908
4909 @item popcntb
4910 @itemx no-popcntb
4911 @cindex @code{target("popcntb")} function attribute, PowerPC
4912 Generate code that uses (does not use) the popcount and double-precision
4913 FP reciprocal estimate instruction implemented on the POWER5
4914 processor and other processors that support the PowerPC V2.02
4915 architecture.
4916
4917 @item popcntd
4918 @itemx no-popcntd
4919 @cindex @code{target("popcntd")} function attribute, PowerPC
4920 Generate code that uses (does not use) the popcount instruction
4921 implemented on the POWER7 processor and other processors that support
4922 the PowerPC V2.06 architecture.
4923
4924 @item powerpc-gfxopt
4925 @itemx no-powerpc-gfxopt
4926 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4927 Generate code that uses (does not use) the optional PowerPC
4928 architecture instructions in the Graphics group, including
4929 floating-point select.
4930
4931 @item powerpc-gpopt
4932 @itemx no-powerpc-gpopt
4933 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4934 Generate code that uses (does not use) the optional PowerPC
4935 architecture instructions in the General Purpose group, including
4936 floating-point square root.
4937
4938 @item recip-precision
4939 @itemx no-recip-precision
4940 @cindex @code{target("recip-precision")} function attribute, PowerPC
4941 Assume (do not assume) that the reciprocal estimate instructions
4942 provide higher-precision estimates than is mandated by the PowerPC
4943 ABI.
4944
4945 @item string
4946 @itemx no-string
4947 @cindex @code{target("string")} function attribute, PowerPC
4948 Generate code that uses (does not use) the load string instructions
4949 and the store string word instructions to save multiple registers and
4950 do small block moves.
4951
4952 @item vsx
4953 @itemx no-vsx
4954 @cindex @code{target("vsx")} function attribute, PowerPC
4955 Generate code that uses (does not use) vector/scalar (VSX)
4956 instructions, and also enable the use of built-in functions that allow
4957 more direct access to the VSX instruction set. In 32-bit code, you
4958 cannot enable VSX or AltiVec instructions unless
4959 @option{-mabi=altivec} is used on the command line.
4960
4961 @item friz
4962 @itemx no-friz
4963 @cindex @code{target("friz")} function attribute, PowerPC
4964 Generate (do not generate) the @code{friz} instruction when the
4965 @option{-funsafe-math-optimizations} option is used to optimize
4966 rounding a floating-point value to 64-bit integer and back to floating
4967 point. The @code{friz} instruction does not return the same value if
4968 the floating-point number is too large to fit in an integer.
4969
4970 @item avoid-indexed-addresses
4971 @itemx no-avoid-indexed-addresses
4972 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4973 Generate code that tries to avoid (not avoid) the use of indexed load
4974 or store instructions.
4975
4976 @item paired
4977 @itemx no-paired
4978 @cindex @code{target("paired")} function attribute, PowerPC
4979 Generate code that uses (does not use) the generation of PAIRED simd
4980 instructions.
4981
4982 @item longcall
4983 @itemx no-longcall
4984 @cindex @code{target("longcall")} function attribute, PowerPC
4985 Generate code that assumes (does not assume) that all calls are far
4986 away so that a longer more expensive calling sequence is required.
4987
4988 @item cpu=@var{CPU}
4989 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4990 Specify the architecture to generate code for when compiling the
4991 function. If you select the @code{target("cpu=power7")} attribute when
4992 generating 32-bit code, VSX and AltiVec instructions are not generated
4993 unless you use the @option{-mabi=altivec} option on the command line.
4994
4995 @item tune=@var{TUNE}
4996 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4997 Specify the architecture to tune for when compiling the function. If
4998 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4999 you do specify the @code{target("cpu=@var{CPU}")} attribute,
5000 compilation tunes for the @var{CPU} architecture, and not the
5001 default tuning specified on the command line.
5002 @end table
5003
5004 On the PowerPC, the inliner does not inline a
5005 function that has different target options than the caller, unless the
5006 callee has a subset of the target options of the caller.
5007 @end table
5008
5009 @node RL78 Function Attributes
5010 @subsection RL78 Function Attributes
5011
5012 These function attributes are supported by the RL78 back end:
5013
5014 @table @code
5015 @item interrupt
5016 @itemx brk_interrupt
5017 @cindex @code{interrupt} function attribute, RL78
5018 @cindex @code{brk_interrupt} function attribute, RL78
5019 These attributes indicate
5020 that the specified function is an interrupt handler. The compiler generates
5021 function entry and exit sequences suitable for use in an interrupt handler
5022 when this attribute is present.
5023
5024 Use @code{brk_interrupt} instead of @code{interrupt} for
5025 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
5026 that must end with @code{RETB} instead of @code{RETI}).
5027
5028 @item naked
5029 @cindex @code{naked} function attribute, RL78
5030 This attribute allows the compiler to construct the
5031 requisite function declaration, while allowing the body of the
5032 function to be assembly code. The specified function will not have
5033 prologue/epilogue sequences generated by the compiler. Only basic
5034 @code{asm} statements can safely be included in naked functions
5035 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5036 basic @code{asm} and C code may appear to work, they cannot be
5037 depended upon to work reliably and are not supported.
5038 @end table
5039
5040 @node RX Function Attributes
5041 @subsection RX Function Attributes
5042
5043 These function attributes are supported by the RX back end:
5044
5045 @table @code
5046 @item fast_interrupt
5047 @cindex @code{fast_interrupt} function attribute, RX
5048 Use this attribute on the RX port to indicate that the specified
5049 function is a fast interrupt handler. This is just like the
5050 @code{interrupt} attribute, except that @code{freit} is used to return
5051 instead of @code{reit}.
5052
5053 @item interrupt
5054 @cindex @code{interrupt} function attribute, RX
5055 Use this attribute to indicate
5056 that the specified function is an interrupt handler. The compiler generates
5057 function entry and exit sequences suitable for use in an interrupt handler
5058 when this attribute is present.
5059
5060 On RX targets, you may specify one or more vector numbers as arguments
5061 to the attribute, as well as naming an alternate table name.
5062 Parameters are handled sequentially, so one handler can be assigned to
5063 multiple entries in multiple tables. One may also pass the magic
5064 string @code{"$default"} which causes the function to be used for any
5065 unfilled slots in the current table.
5066
5067 This example shows a simple assignment of a function to one vector in
5068 the default table (note that preprocessor macros may be used for
5069 chip-specific symbolic vector names):
5070 @smallexample
5071 void __attribute__ ((interrupt (5))) txd1_handler ();
5072 @end smallexample
5073
5074 This example assigns a function to two slots in the default table
5075 (using preprocessor macros defined elsewhere) and makes it the default
5076 for the @code{dct} table:
5077 @smallexample
5078 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
5079 txd1_handler ();
5080 @end smallexample
5081
5082 @item naked
5083 @cindex @code{naked} function attribute, RX
5084 This attribute allows the compiler to construct the
5085 requisite function declaration, while allowing the body of the
5086 function to be assembly code. The specified function will not have
5087 prologue/epilogue sequences generated by the compiler. Only basic
5088 @code{asm} statements can safely be included in naked functions
5089 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5090 basic @code{asm} and C code may appear to work, they cannot be
5091 depended upon to work reliably and are not supported.
5092
5093 @item vector
5094 @cindex @code{vector} function attribute, RX
5095 This RX attribute is similar to the @code{interrupt} attribute, including its
5096 parameters, but does not make the function an interrupt-handler type
5097 function (i.e. it retains the normal C function calling ABI). See the
5098 @code{interrupt} attribute for a description of its arguments.
5099 @end table
5100
5101 @node S/390 Function Attributes
5102 @subsection S/390 Function Attributes
5103
5104 These function attributes are supported on the S/390:
5105
5106 @table @code
5107 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5108 @cindex @code{hotpatch} function attribute, S/390
5109
5110 On S/390 System z targets, you can use this function attribute to
5111 make GCC generate a ``hot-patching'' function prologue. If the
5112 @option{-mhotpatch=} command-line option is used at the same time,
5113 the @code{hotpatch} attribute takes precedence. The first of the
5114 two arguments specifies the number of halfwords to be added before
5115 the function label. A second argument can be used to specify the
5116 number of halfwords to be added after the function label. For
5117 both arguments the maximum allowed value is 1000000.
5118
5119 If both arguments are zero, hotpatching is disabled.
5120
5121 @item target (@var{options})
5122 @cindex @code{target} function attribute
5123 As discussed in @ref{Common Function Attributes}, this attribute
5124 allows specification of target-specific compilation options.
5125
5126 On S/390, the following options are supported:
5127
5128 @table @samp
5129 @item arch=
5130 @item tune=
5131 @item stack-guard=
5132 @item stack-size=
5133 @item branch-cost=
5134 @item warn-framesize=
5135 @item backchain
5136 @itemx no-backchain
5137 @item hard-dfp
5138 @itemx no-hard-dfp
5139 @item hard-float
5140 @itemx soft-float
5141 @item htm
5142 @itemx no-htm
5143 @item vx
5144 @itemx no-vx
5145 @item packed-stack
5146 @itemx no-packed-stack
5147 @item small-exec
5148 @itemx no-small-exec
5149 @item mvcle
5150 @itemx no-mvcle
5151 @item warn-dynamicstack
5152 @itemx no-warn-dynamicstack
5153 @end table
5154
5155 The options work exactly like the S/390 specific command line
5156 options (without the prefix @option{-m}) except that they do not
5157 change any feature macros. For example,
5158
5159 @smallexample
5160 @code{target("no-vx")}
5161 @end smallexample
5162
5163 does not undefine the @code{__VEC__} macro.
5164 @end table
5165
5166 @node SH Function Attributes
5167 @subsection SH Function Attributes
5168
5169 These function attributes are supported on the SH family of processors:
5170
5171 @table @code
5172 @item function_vector
5173 @cindex @code{function_vector} function attribute, SH
5174 @cindex calling functions through the function vector on SH2A
5175 On SH2A targets, this attribute declares a function to be called using the
5176 TBR relative addressing mode. The argument to this attribute is the entry
5177 number of the same function in a vector table containing all the TBR
5178 relative addressable functions. For correct operation the TBR must be setup
5179 accordingly to point to the start of the vector table before any functions with
5180 this attribute are invoked. Usually a good place to do the initialization is
5181 the startup routine. The TBR relative vector table can have at max 256 function
5182 entries. The jumps to these functions are generated using a SH2A specific,
5183 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
5184 from GNU binutils version 2.7 or later for this attribute to work correctly.
5185
5186 In an application, for a function being called once, this attribute
5187 saves at least 8 bytes of code; and if other successive calls are being
5188 made to the same function, it saves 2 bytes of code per each of these
5189 calls.
5190
5191 @item interrupt_handler
5192 @cindex @code{interrupt_handler} function attribute, SH
5193 Use this attribute to
5194 indicate that the specified function is an interrupt handler. The compiler
5195 generates function entry and exit sequences suitable for use in an
5196 interrupt handler when this attribute is present.
5197
5198 @item nosave_low_regs
5199 @cindex @code{nosave_low_regs} function attribute, SH
5200 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5201 function should not save and restore registers R0..R7. This can be used on SH3*
5202 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5203 interrupt handlers.
5204
5205 @item renesas
5206 @cindex @code{renesas} function attribute, SH
5207 On SH targets this attribute specifies that the function or struct follows the
5208 Renesas ABI.
5209
5210 @item resbank
5211 @cindex @code{resbank} function attribute, SH
5212 On the SH2A target, this attribute enables the high-speed register
5213 saving and restoration using a register bank for @code{interrupt_handler}
5214 routines. Saving to the bank is performed automatically after the CPU
5215 accepts an interrupt that uses a register bank.
5216
5217 The nineteen 32-bit registers comprising general register R0 to R14,
5218 control register GBR, and system registers MACH, MACL, and PR and the
5219 vector table address offset are saved into a register bank. Register
5220 banks are stacked in first-in last-out (FILO) sequence. Restoration
5221 from the bank is executed by issuing a RESBANK instruction.
5222
5223 @item sp_switch
5224 @cindex @code{sp_switch} function attribute, SH
5225 Use this attribute on the SH to indicate an @code{interrupt_handler}
5226 function should switch to an alternate stack. It expects a string
5227 argument that names a global variable holding the address of the
5228 alternate stack.
5229
5230 @smallexample
5231 void *alt_stack;
5232 void f () __attribute__ ((interrupt_handler,
5233 sp_switch ("alt_stack")));
5234 @end smallexample
5235
5236 @item trap_exit
5237 @cindex @code{trap_exit} function attribute, SH
5238 Use this attribute on the SH for an @code{interrupt_handler} to return using
5239 @code{trapa} instead of @code{rte}. This attribute expects an integer
5240 argument specifying the trap number to be used.
5241
5242 @item trapa_handler
5243 @cindex @code{trapa_handler} function attribute, SH
5244 On SH targets this function attribute is similar to @code{interrupt_handler}
5245 but it does not save and restore all registers.
5246 @end table
5247
5248 @node SPU Function Attributes
5249 @subsection SPU Function Attributes
5250
5251 These function attributes are supported by the SPU back end:
5252
5253 @table @code
5254 @item naked
5255 @cindex @code{naked} function attribute, SPU
5256 This attribute allows the compiler to construct the
5257 requisite function declaration, while allowing the body of the
5258 function to be assembly code. The specified function will not have
5259 prologue/epilogue sequences generated by the compiler. Only basic
5260 @code{asm} statements can safely be included in naked functions
5261 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5262 basic @code{asm} and C code may appear to work, they cannot be
5263 depended upon to work reliably and are not supported.
5264 @end table
5265
5266 @node Symbian OS Function Attributes
5267 @subsection Symbian OS Function Attributes
5268
5269 @xref{Microsoft Windows Function Attributes}, for discussion of the
5270 @code{dllexport} and @code{dllimport} attributes.
5271
5272 @node V850 Function Attributes
5273 @subsection V850 Function Attributes
5274
5275 The V850 back end supports these function attributes:
5276
5277 @table @code
5278 @item interrupt
5279 @itemx interrupt_handler
5280 @cindex @code{interrupt} function attribute, V850
5281 @cindex @code{interrupt_handler} function attribute, V850
5282 Use these attributes to indicate
5283 that the specified function is an interrupt handler. The compiler generates
5284 function entry and exit sequences suitable for use in an interrupt handler
5285 when either attribute is present.
5286 @end table
5287
5288 @node Visium Function Attributes
5289 @subsection Visium Function Attributes
5290
5291 These function attributes are supported by the Visium back end:
5292
5293 @table @code
5294 @item interrupt
5295 @cindex @code{interrupt} function attribute, Visium
5296 Use this attribute to indicate
5297 that the specified function is an interrupt handler. The compiler generates
5298 function entry and exit sequences suitable for use in an interrupt handler
5299 when this attribute is present.
5300 @end table
5301
5302 @node x86 Function Attributes
5303 @subsection x86 Function Attributes
5304
5305 These function attributes are supported by the x86 back end:
5306
5307 @table @code
5308 @item cdecl
5309 @cindex @code{cdecl} function attribute, x86-32
5310 @cindex functions that pop the argument stack on x86-32
5311 @opindex mrtd
5312 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5313 assume that the calling function pops off the stack space used to
5314 pass arguments. This is
5315 useful to override the effects of the @option{-mrtd} switch.
5316
5317 @item fastcall
5318 @cindex @code{fastcall} function attribute, x86-32
5319 @cindex functions that pop the argument stack on x86-32
5320 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5321 pass the first argument (if of integral type) in the register ECX and
5322 the second argument (if of integral type) in the register EDX@. Subsequent
5323 and other typed arguments are passed on the stack. The called function
5324 pops the arguments off the stack. If the number of arguments is variable all
5325 arguments are pushed on the stack.
5326
5327 @item thiscall
5328 @cindex @code{thiscall} function attribute, x86-32
5329 @cindex functions that pop the argument stack on x86-32
5330 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5331 pass the first argument (if of integral type) in the register ECX.
5332 Subsequent and other typed arguments are passed on the stack. The called
5333 function pops the arguments off the stack.
5334 If the number of arguments is variable all arguments are pushed on the
5335 stack.
5336 The @code{thiscall} attribute is intended for C++ non-static member functions.
5337 As a GCC extension, this calling convention can be used for C functions
5338 and for static member methods.
5339
5340 @item ms_abi
5341 @itemx sysv_abi
5342 @cindex @code{ms_abi} function attribute, x86
5343 @cindex @code{sysv_abi} function attribute, x86
5344
5345 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5346 to indicate which calling convention should be used for a function. The
5347 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5348 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5349 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5350 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5351
5352 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5353 requires the @option{-maccumulate-outgoing-args} option.
5354
5355 @item callee_pop_aggregate_return (@var{number})
5356 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5357
5358 On x86-32 targets, you can use this attribute to control how
5359 aggregates are returned in memory. If the caller is responsible for
5360 popping the hidden pointer together with the rest of the arguments, specify
5361 @var{number} equal to zero. If callee is responsible for popping the
5362 hidden pointer, specify @var{number} equal to one.
5363
5364 The default x86-32 ABI assumes that the callee pops the
5365 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5366 the compiler assumes that the
5367 caller pops the stack for hidden pointer.
5368
5369 @item ms_hook_prologue
5370 @cindex @code{ms_hook_prologue} function attribute, x86
5371
5372 On 32-bit and 64-bit x86 targets, you can use
5373 this function attribute to make GCC generate the ``hot-patching'' function
5374 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5375 and newer.
5376
5377 @item naked
5378 @cindex @code{naked} function attribute, x86
5379 This attribute allows the compiler to construct the
5380 requisite function declaration, while allowing the body of the
5381 function to be assembly code. The specified function will not have
5382 prologue/epilogue sequences generated by the compiler. Only basic
5383 @code{asm} statements can safely be included in naked functions
5384 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5385 basic @code{asm} and C code may appear to work, they cannot be
5386 depended upon to work reliably and are not supported.
5387
5388 @item regparm (@var{number})
5389 @cindex @code{regparm} function attribute, x86
5390 @cindex functions that are passed arguments in registers on x86-32
5391 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5392 pass arguments number one to @var{number} if they are of integral type
5393 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5394 take a variable number of arguments continue to be passed all of their
5395 arguments on the stack.
5396
5397 Beware that on some ELF systems this attribute is unsuitable for
5398 global functions in shared libraries with lazy binding (which is the
5399 default). Lazy binding sends the first call via resolving code in
5400 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5401 per the standard calling conventions. Solaris 8 is affected by this.
5402 Systems with the GNU C Library version 2.1 or higher
5403 and FreeBSD are believed to be
5404 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5405 disabled with the linker or the loader if desired, to avoid the
5406 problem.)
5407
5408 @item sseregparm
5409 @cindex @code{sseregparm} function attribute, x86
5410 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5411 causes the compiler to pass up to 3 floating-point arguments in
5412 SSE registers instead of on the stack. Functions that take a
5413 variable number of arguments continue to pass all of their
5414 floating-point arguments on the stack.
5415
5416 @item force_align_arg_pointer
5417 @cindex @code{force_align_arg_pointer} function attribute, x86
5418 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5419 applied to individual function definitions, generating an alternate
5420 prologue and epilogue that realigns the run-time stack if necessary.
5421 This supports mixing legacy codes that run with a 4-byte aligned stack
5422 with modern codes that keep a 16-byte stack for SSE compatibility.
5423
5424 @item stdcall
5425 @cindex @code{stdcall} function attribute, x86-32
5426 @cindex functions that pop the argument stack on x86-32
5427 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5428 assume that the called function pops off the stack space used to
5429 pass arguments, unless it takes a variable number of arguments.
5430
5431 @item no_caller_saved_registers
5432 @cindex @code{no_caller_saved_registers} function attribute, x86
5433 Use this attribute to indicate that the specified function has no
5434 caller-saved registers. That is, all registers are callee-saved. For
5435 example, this attribute can be used for a function called from an
5436 interrupt handler. The compiler generates proper function entry and
5437 exit sequences to save and restore any modified registers, except for
5438 the EFLAGS register. Since GCC doesn't preserve MPX, SSE, MMX nor x87
5439 states, the GCC option @option{-mgeneral-regs-only} should be used to
5440 compile functions with @code{no_caller_saved_registers} attribute.
5441
5442 @item interrupt
5443 @cindex @code{interrupt} function attribute, x86
5444 Use this attribute to indicate that the specified function is an
5445 interrupt handler or an exception handler (depending on parameters passed
5446 to the function, explained further). The compiler generates function
5447 entry and exit sequences suitable for use in an interrupt handler when
5448 this attribute is present. The @code{IRET} instruction, instead of the
5449 @code{RET} instruction, is used to return from interrupt handlers. All
5450 registers, except for the EFLAGS register which is restored by the
5451 @code{IRET} instruction, are preserved by the compiler. Since GCC
5452 doesn't preserve MPX, SSE, MMX nor x87 states, the GCC option
5453 @option{-mgeneral-regs-only} should be used to compile interrupt and
5454 exception handlers.
5455
5456 Any interruptible-without-stack-switch code must be compiled with
5457 @option{-mno-red-zone} since interrupt handlers can and will, because
5458 of the hardware design, touch the red zone.
5459
5460 An interrupt handler must be declared with a mandatory pointer
5461 argument:
5462
5463 @smallexample
5464 struct interrupt_frame;
5465
5466 __attribute__ ((interrupt))
5467 void
5468 f (struct interrupt_frame *frame)
5469 @{
5470 @}
5471 @end smallexample
5472
5473 @noindent
5474 and you must define @code{struct interrupt_frame} as described in the
5475 processor's manual.
5476
5477 Exception handlers differ from interrupt handlers because the system
5478 pushes an error code on the stack. An exception handler declaration is
5479 similar to that for an interrupt handler, but with a different mandatory
5480 function signature. The compiler arranges to pop the error code off the
5481 stack before the @code{IRET} instruction.
5482
5483 @smallexample
5484 #ifdef __x86_64__
5485 typedef unsigned long long int uword_t;
5486 #else
5487 typedef unsigned int uword_t;
5488 #endif
5489
5490 struct interrupt_frame;
5491
5492 __attribute__ ((interrupt))
5493 void
5494 f (struct interrupt_frame *frame, uword_t error_code)
5495 @{
5496 ...
5497 @}
5498 @end smallexample
5499
5500 Exception handlers should only be used for exceptions that push an error
5501 code; you should use an interrupt handler in other cases. The system
5502 will crash if the wrong kind of handler is used.
5503
5504 @item target (@var{options})
5505 @cindex @code{target} function attribute
5506 As discussed in @ref{Common Function Attributes}, this attribute
5507 allows specification of target-specific compilation options.
5508
5509 On the x86, the following options are allowed:
5510 @table @samp
5511 @item abm
5512 @itemx no-abm
5513 @cindex @code{target("abm")} function attribute, x86
5514 Enable/disable the generation of the advanced bit instructions.
5515
5516 @item aes
5517 @itemx no-aes
5518 @cindex @code{target("aes")} function attribute, x86
5519 Enable/disable the generation of the AES instructions.
5520
5521 @item default
5522 @cindex @code{target("default")} function attribute, x86
5523 @xref{Function Multiversioning}, where it is used to specify the
5524 default function version.
5525
5526 @item mmx
5527 @itemx no-mmx
5528 @cindex @code{target("mmx")} function attribute, x86
5529 Enable/disable the generation of the MMX instructions.
5530
5531 @item pclmul
5532 @itemx no-pclmul
5533 @cindex @code{target("pclmul")} function attribute, x86
5534 Enable/disable the generation of the PCLMUL instructions.
5535
5536 @item popcnt
5537 @itemx no-popcnt
5538 @cindex @code{target("popcnt")} function attribute, x86
5539 Enable/disable the generation of the POPCNT instruction.
5540
5541 @item sse
5542 @itemx no-sse
5543 @cindex @code{target("sse")} function attribute, x86
5544 Enable/disable the generation of the SSE instructions.
5545
5546 @item sse2
5547 @itemx no-sse2
5548 @cindex @code{target("sse2")} function attribute, x86
5549 Enable/disable the generation of the SSE2 instructions.
5550
5551 @item sse3
5552 @itemx no-sse3
5553 @cindex @code{target("sse3")} function attribute, x86
5554 Enable/disable the generation of the SSE3 instructions.
5555
5556 @item sse4
5557 @itemx no-sse4
5558 @cindex @code{target("sse4")} function attribute, x86
5559 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5560 and SSE4.2).
5561
5562 @item sse4.1
5563 @itemx no-sse4.1
5564 @cindex @code{target("sse4.1")} function attribute, x86
5565 Enable/disable the generation of the sse4.1 instructions.
5566
5567 @item sse4.2
5568 @itemx no-sse4.2
5569 @cindex @code{target("sse4.2")} function attribute, x86
5570 Enable/disable the generation of the sse4.2 instructions.
5571
5572 @item sse4a
5573 @itemx no-sse4a
5574 @cindex @code{target("sse4a")} function attribute, x86
5575 Enable/disable the generation of the SSE4A instructions.
5576
5577 @item fma4
5578 @itemx no-fma4
5579 @cindex @code{target("fma4")} function attribute, x86
5580 Enable/disable the generation of the FMA4 instructions.
5581
5582 @item xop
5583 @itemx no-xop
5584 @cindex @code{target("xop")} function attribute, x86
5585 Enable/disable the generation of the XOP instructions.
5586
5587 @item lwp
5588 @itemx no-lwp
5589 @cindex @code{target("lwp")} function attribute, x86
5590 Enable/disable the generation of the LWP instructions.
5591
5592 @item ssse3
5593 @itemx no-ssse3
5594 @cindex @code{target("ssse3")} function attribute, x86
5595 Enable/disable the generation of the SSSE3 instructions.
5596
5597 @item cld
5598 @itemx no-cld
5599 @cindex @code{target("cld")} function attribute, x86
5600 Enable/disable the generation of the CLD before string moves.
5601
5602 @item fancy-math-387
5603 @itemx no-fancy-math-387
5604 @cindex @code{target("fancy-math-387")} function attribute, x86
5605 Enable/disable the generation of the @code{sin}, @code{cos}, and
5606 @code{sqrt} instructions on the 387 floating-point unit.
5607
5608 @item ieee-fp
5609 @itemx no-ieee-fp
5610 @cindex @code{target("ieee-fp")} function attribute, x86
5611 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5612
5613 @item inline-all-stringops
5614 @itemx no-inline-all-stringops
5615 @cindex @code{target("inline-all-stringops")} function attribute, x86
5616 Enable/disable inlining of string operations.
5617
5618 @item inline-stringops-dynamically
5619 @itemx no-inline-stringops-dynamically
5620 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5621 Enable/disable the generation of the inline code to do small string
5622 operations and calling the library routines for large operations.
5623
5624 @item align-stringops
5625 @itemx no-align-stringops
5626 @cindex @code{target("align-stringops")} function attribute, x86
5627 Do/do not align destination of inlined string operations.
5628
5629 @item recip
5630 @itemx no-recip
5631 @cindex @code{target("recip")} function attribute, x86
5632 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5633 instructions followed an additional Newton-Raphson step instead of
5634 doing a floating-point division.
5635
5636 @item arch=@var{ARCH}
5637 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5638 Specify the architecture to generate code for in compiling the function.
5639
5640 @item tune=@var{TUNE}
5641 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5642 Specify the architecture to tune for in compiling the function.
5643
5644 @item fpmath=@var{FPMATH}
5645 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5646 Specify which floating-point unit to use. You must specify the
5647 @code{target("fpmath=sse,387")} option as
5648 @code{target("fpmath=sse+387")} because the comma would separate
5649 different options.
5650 @end table
5651
5652 On the x86, the inliner does not inline a
5653 function that has different target options than the caller, unless the
5654 callee has a subset of the target options of the caller. For example
5655 a function declared with @code{target("sse3")} can inline a function
5656 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5657 @end table
5658
5659 @node Xstormy16 Function Attributes
5660 @subsection Xstormy16 Function Attributes
5661
5662 These function attributes are supported by the Xstormy16 back end:
5663
5664 @table @code
5665 @item interrupt
5666 @cindex @code{interrupt} function attribute, Xstormy16
5667 Use this attribute to indicate
5668 that the specified function is an interrupt handler. The compiler generates
5669 function entry and exit sequences suitable for use in an interrupt handler
5670 when this attribute is present.
5671 @end table
5672
5673 @node Variable Attributes
5674 @section Specifying Attributes of Variables
5675 @cindex attribute of variables
5676 @cindex variable attributes
5677
5678 The keyword @code{__attribute__} allows you to specify special
5679 attributes of variables or structure fields. This keyword is followed
5680 by an attribute specification inside double parentheses. Some
5681 attributes are currently defined generically for variables.
5682 Other attributes are defined for variables on particular target
5683 systems. Other attributes are available for functions
5684 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5685 enumerators (@pxref{Enumerator Attributes}), statements
5686 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
5687 Other front ends might define more attributes
5688 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5689
5690 @xref{Attribute Syntax}, for details of the exact syntax for using
5691 attributes.
5692
5693 @menu
5694 * Common Variable Attributes::
5695 * AVR Variable Attributes::
5696 * Blackfin Variable Attributes::
5697 * H8/300 Variable Attributes::
5698 * IA-64 Variable Attributes::
5699 * M32R/D Variable Attributes::
5700 * MeP Variable Attributes::
5701 * Microsoft Windows Variable Attributes::
5702 * MSP430 Variable Attributes::
5703 * Nvidia PTX Variable Attributes::
5704 * PowerPC Variable Attributes::
5705 * RL78 Variable Attributes::
5706 * SPU Variable Attributes::
5707 * V850 Variable Attributes::
5708 * x86 Variable Attributes::
5709 * Xstormy16 Variable Attributes::
5710 @end menu
5711
5712 @node Common Variable Attributes
5713 @subsection Common Variable Attributes
5714
5715 The following attributes are supported on most targets.
5716
5717 @table @code
5718 @cindex @code{aligned} variable attribute
5719 @item aligned (@var{alignment})
5720 This attribute specifies a minimum alignment for the variable or
5721 structure field, measured in bytes. For example, the declaration:
5722
5723 @smallexample
5724 int x __attribute__ ((aligned (16))) = 0;
5725 @end smallexample
5726
5727 @noindent
5728 causes the compiler to allocate the global variable @code{x} on a
5729 16-byte boundary. On a 68040, this could be used in conjunction with
5730 an @code{asm} expression to access the @code{move16} instruction which
5731 requires 16-byte aligned operands.
5732
5733 You can also specify the alignment of structure fields. For example, to
5734 create a double-word aligned @code{int} pair, you could write:
5735
5736 @smallexample
5737 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5738 @end smallexample
5739
5740 @noindent
5741 This is an alternative to creating a union with a @code{double} member,
5742 which forces the union to be double-word aligned.
5743
5744 As in the preceding examples, you can explicitly specify the alignment
5745 (in bytes) that you wish the compiler to use for a given variable or
5746 structure field. Alternatively, you can leave out the alignment factor
5747 and just ask the compiler to align a variable or field to the
5748 default alignment for the target architecture you are compiling for.
5749 The default alignment is sufficient for all scalar types, but may not be
5750 enough for all vector types on a target that supports vector operations.
5751 The default alignment is fixed for a particular target ABI.
5752
5753 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5754 which is the largest alignment ever used for any data type on the
5755 target machine you are compiling for. For example, you could write:
5756
5757 @smallexample
5758 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5759 @end smallexample
5760
5761 The compiler automatically sets the alignment for the declared
5762 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5763 often make copy operations more efficient, because the compiler can
5764 use whatever instructions copy the biggest chunks of memory when
5765 performing copies to or from the variables or fields that you have
5766 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5767 may change depending on command-line options.
5768
5769 When used on a struct, or struct member, the @code{aligned} attribute can
5770 only increase the alignment; in order to decrease it, the @code{packed}
5771 attribute must be specified as well. When used as part of a typedef, the
5772 @code{aligned} attribute can both increase and decrease alignment, and
5773 specifying the @code{packed} attribute generates a warning.
5774
5775 Note that the effectiveness of @code{aligned} attributes may be limited
5776 by inherent limitations in your linker. On many systems, the linker is
5777 only able to arrange for variables to be aligned up to a certain maximum
5778 alignment. (For some linkers, the maximum supported alignment may
5779 be very very small.) If your linker is only able to align variables
5780 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5781 in an @code{__attribute__} still only provides you with 8-byte
5782 alignment. See your linker documentation for further information.
5783
5784 The @code{aligned} attribute can also be used for functions
5785 (@pxref{Common Function Attributes}.)
5786
5787 @cindex @code{warn_if_not_aligned} variable attribute
5788 @item warn_if_not_aligned (@var{alignment})
5789 This attribute specifies a threshold for the structure field, measured
5790 in bytes. If the structure field is aligned below the threshold, a
5791 warning will be issued. For example, the declaration:
5792
5793 @smallexample
5794 struct foo
5795 @{
5796 int i1;
5797 int i2;
5798 unsigned long long x __attribute__((warn_if_not_aligned(16)));
5799 @};
5800 @end smallexample
5801
5802 @noindent
5803 causes the compiler to issue an warning on @code{struct foo}, like
5804 @samp{warning: alignment 8 of 'struct foo' is less than 16}.
5805 The compiler also issues a warning, like @samp{warning: 'x' offset
5806 8 in 'struct foo' isn't aligned to 16}, when the structure field has
5807 the misaligned offset:
5808
5809 @smallexample
5810 struct foo
5811 @{
5812 int i1;
5813 int i2;
5814 unsigned long long x __attribute__((warn_if_not_aligned(16)));
5815 @} __attribute__((aligned(16)));
5816 @end smallexample
5817
5818 This warning can be disabled by @option{-Wno-if-not-aligned}.
5819 The @code{warn_if_not_aligned} attribute can also be used for types
5820 (@pxref{Common Type Attributes}.)
5821
5822 @item cleanup (@var{cleanup_function})
5823 @cindex @code{cleanup} variable attribute
5824 The @code{cleanup} attribute runs a function when the variable goes
5825 out of scope. This attribute can only be applied to auto function
5826 scope variables; it may not be applied to parameters or variables
5827 with static storage duration. The function must take one parameter,
5828 a pointer to a type compatible with the variable. The return value
5829 of the function (if any) is ignored.
5830
5831 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5832 is run during the stack unwinding that happens during the
5833 processing of the exception. Note that the @code{cleanup} attribute
5834 does not allow the exception to be caught, only to perform an action.
5835 It is undefined what happens if @var{cleanup_function} does not
5836 return normally.
5837
5838 @item common
5839 @itemx nocommon
5840 @cindex @code{common} variable attribute
5841 @cindex @code{nocommon} variable attribute
5842 @opindex fcommon
5843 @opindex fno-common
5844 The @code{common} attribute requests GCC to place a variable in
5845 ``common'' storage. The @code{nocommon} attribute requests the
5846 opposite---to allocate space for it directly.
5847
5848 These attributes override the default chosen by the
5849 @option{-fno-common} and @option{-fcommon} flags respectively.
5850
5851 @item deprecated
5852 @itemx deprecated (@var{msg})
5853 @cindex @code{deprecated} variable attribute
5854 The @code{deprecated} attribute results in a warning if the variable
5855 is used anywhere in the source file. This is useful when identifying
5856 variables that are expected to be removed in a future version of a
5857 program. The warning also includes the location of the declaration
5858 of the deprecated variable, to enable users to easily find further
5859 information about why the variable is deprecated, or what they should
5860 do instead. Note that the warning only occurs for uses:
5861
5862 @smallexample
5863 extern int old_var __attribute__ ((deprecated));
5864 extern int old_var;
5865 int new_fn () @{ return old_var; @}
5866 @end smallexample
5867
5868 @noindent
5869 results in a warning on line 3 but not line 2. The optional @var{msg}
5870 argument, which must be a string, is printed in the warning if
5871 present.
5872
5873 The @code{deprecated} attribute can also be used for functions and
5874 types (@pxref{Common Function Attributes},
5875 @pxref{Common Type Attributes}).
5876
5877 @item nonstring (@var{nonstring})
5878 @cindex @code{nonstring} variable attribute
5879 The @code{nonstring} variable attribute specifies that an object or member
5880 declaration with type array of @code{char} or pointer to @code{char} is
5881 intended to store character arrays that do not necessarily contain
5882 a terminating @code{NUL} character. This is useful to avoid warnings
5883 when such an array or pointer is used as an argument to a bounded string
5884 manipulation function such as @code{strncpy}. For example, without the
5885 attribute, GCC will issue a warning for the call below because it may
5886 truncate the copy without appending the terminating NUL character. Using
5887 the attribute makes it possible to suppress the warning.
5888
5889 @smallexample
5890 struct Data
5891 @{
5892 char name [32] __attribute__ ((nonstring));
5893 @};
5894 void f (struct Data *pd, const char *s)
5895 @{
5896 strncpy (pd->name, s, sizeof pd->name);
5897 @dots{}
5898 @}
5899 @end smallexample
5900
5901 @item mode (@var{mode})
5902 @cindex @code{mode} variable attribute
5903 This attribute specifies the data type for the declaration---whichever
5904 type corresponds to the mode @var{mode}. This in effect lets you
5905 request an integer or floating-point type according to its width.
5906
5907 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
5908 for a list of the possible keywords for @var{mode}.
5909 You may also specify a mode of @code{byte} or @code{__byte__} to
5910 indicate the mode corresponding to a one-byte integer, @code{word} or
5911 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5912 or @code{__pointer__} for the mode used to represent pointers.
5913
5914 @item packed
5915 @cindex @code{packed} variable attribute
5916 The @code{packed} attribute specifies that a variable or structure field
5917 should have the smallest possible alignment---one byte for a variable,
5918 and one bit for a field, unless you specify a larger value with the
5919 @code{aligned} attribute.
5920
5921 Here is a structure in which the field @code{x} is packed, so that it
5922 immediately follows @code{a}:
5923
5924 @smallexample
5925 struct foo
5926 @{
5927 char a;
5928 int x[2] __attribute__ ((packed));
5929 @};
5930 @end smallexample
5931
5932 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5933 @code{packed} attribute on bit-fields of type @code{char}. This has
5934 been fixed in GCC 4.4 but the change can lead to differences in the
5935 structure layout. See the documentation of
5936 @option{-Wpacked-bitfield-compat} for more information.
5937
5938 @item section ("@var{section-name}")
5939 @cindex @code{section} variable attribute
5940 Normally, the compiler places the objects it generates in sections like
5941 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5942 or you need certain particular variables to appear in special sections,
5943 for example to map to special hardware. The @code{section}
5944 attribute specifies that a variable (or function) lives in a particular
5945 section. For example, this small program uses several specific section names:
5946
5947 @smallexample
5948 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5949 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5950 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5951 int init_data __attribute__ ((section ("INITDATA")));
5952
5953 main()
5954 @{
5955 /* @r{Initialize stack pointer} */
5956 init_sp (stack + sizeof (stack));
5957
5958 /* @r{Initialize initialized data} */
5959 memcpy (&init_data, &data, &edata - &data);
5960
5961 /* @r{Turn on the serial ports} */
5962 init_duart (&a);
5963 init_duart (&b);
5964 @}
5965 @end smallexample
5966
5967 @noindent
5968 Use the @code{section} attribute with
5969 @emph{global} variables and not @emph{local} variables,
5970 as shown in the example.
5971
5972 You may use the @code{section} attribute with initialized or
5973 uninitialized global variables but the linker requires
5974 each object be defined once, with the exception that uninitialized
5975 variables tentatively go in the @code{common} (or @code{bss}) section
5976 and can be multiply ``defined''. Using the @code{section} attribute
5977 changes what section the variable goes into and may cause the
5978 linker to issue an error if an uninitialized variable has multiple
5979 definitions. You can force a variable to be initialized with the
5980 @option{-fno-common} flag or the @code{nocommon} attribute.
5981
5982 Some file formats do not support arbitrary sections so the @code{section}
5983 attribute is not available on all platforms.
5984 If you need to map the entire contents of a module to a particular
5985 section, consider using the facilities of the linker instead.
5986
5987 @item tls_model ("@var{tls_model}")
5988 @cindex @code{tls_model} variable attribute
5989 The @code{tls_model} attribute sets thread-local storage model
5990 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5991 overriding @option{-ftls-model=} command-line switch on a per-variable
5992 basis.
5993 The @var{tls_model} argument should be one of @code{global-dynamic},
5994 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5995
5996 Not all targets support this attribute.
5997
5998 @item unused
5999 @cindex @code{unused} variable attribute
6000 This attribute, attached to a variable, means that the variable is meant
6001 to be possibly unused. GCC does not produce a warning for this
6002 variable.
6003
6004 @item used
6005 @cindex @code{used} variable attribute
6006 This attribute, attached to a variable with static storage, means that
6007 the variable must be emitted even if it appears that the variable is not
6008 referenced.
6009
6010 When applied to a static data member of a C++ class template, the
6011 attribute also means that the member is instantiated if the
6012 class itself is instantiated.
6013
6014 @item vector_size (@var{bytes})
6015 @cindex @code{vector_size} variable attribute
6016 This attribute specifies the vector size for the variable, measured in
6017 bytes. For example, the declaration:
6018
6019 @smallexample
6020 int foo __attribute__ ((vector_size (16)));
6021 @end smallexample
6022
6023 @noindent
6024 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
6025 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
6026 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
6027
6028 This attribute is only applicable to integral and float scalars,
6029 although arrays, pointers, and function return values are allowed in
6030 conjunction with this construct.
6031
6032 Aggregates with this attribute are invalid, even if they are of the same
6033 size as a corresponding scalar. For example, the declaration:
6034
6035 @smallexample
6036 struct S @{ int a; @};
6037 struct S __attribute__ ((vector_size (16))) foo;
6038 @end smallexample
6039
6040 @noindent
6041 is invalid even if the size of the structure is the same as the size of
6042 the @code{int}.
6043
6044 @item visibility ("@var{visibility_type}")
6045 @cindex @code{visibility} variable attribute
6046 This attribute affects the linkage of the declaration to which it is attached.
6047 The @code{visibility} attribute is described in
6048 @ref{Common Function Attributes}.
6049
6050 @item weak
6051 @cindex @code{weak} variable attribute
6052 The @code{weak} attribute is described in
6053 @ref{Common Function Attributes}.
6054
6055 @end table
6056
6057 @node AVR Variable Attributes
6058 @subsection AVR Variable Attributes
6059
6060 @table @code
6061 @item progmem
6062 @cindex @code{progmem} variable attribute, AVR
6063 The @code{progmem} attribute is used on the AVR to place read-only
6064 data in the non-volatile program memory (flash). The @code{progmem}
6065 attribute accomplishes this by putting respective variables into a
6066 section whose name starts with @code{.progmem}.
6067
6068 This attribute works similar to the @code{section} attribute
6069 but adds additional checking.
6070
6071 @table @asis
6072 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
6073 @code{progmem} affects the location
6074 of the data but not how this data is accessed.
6075 In order to read data located with the @code{progmem} attribute
6076 (inline) assembler must be used.
6077 @smallexample
6078 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
6079 #include <avr/pgmspace.h>
6080
6081 /* Locate var in flash memory */
6082 const int var[2] PROGMEM = @{ 1, 2 @};
6083
6084 int read_var (int i)
6085 @{
6086 /* Access var[] by accessor macro from avr/pgmspace.h */
6087 return (int) pgm_read_word (& var[i]);
6088 @}
6089 @end smallexample
6090
6091 AVR is a Harvard architecture processor and data and read-only data
6092 normally resides in the data memory (RAM).
6093
6094 See also the @ref{AVR Named Address Spaces} section for
6095 an alternate way to locate and access data in flash memory.
6096
6097 @item @bullet{}@tie{} AVR cores with flash memory visible in the RAM address range:
6098 On such devices, there is no need for attribute @code{progmem} or
6099 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
6100 Just use standard C / C++. The compiler will generate @code{LD*}
6101 instructions. As flash memory is visible in the RAM address range,
6102 and the default linker script does @emph{not} locate @code{.rodata} in
6103 RAM, no special features are needed in order not to waste RAM for
6104 read-only data or to read from flash. You might even get slightly better
6105 performance by
6106 avoiding @code{progmem} and @code{__flash}. This applies to devices from
6107 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
6108 an overview.
6109
6110 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
6111 The compiler adds @code{0x4000}
6112 to the addresses of objects and declarations in @code{progmem} and locates
6113 the objects in flash memory, namely in section @code{.progmem.data}.
6114 The offset is needed because the flash memory is visible in the RAM
6115 address space starting at address @code{0x4000}.
6116
6117 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
6118 no special functions or macros are needed.
6119
6120 @smallexample
6121 /* var is located in flash memory */
6122 extern const int var[2] __attribute__((progmem));
6123
6124 int read_var (int i)
6125 @{
6126 return var[i];
6127 @}
6128 @end smallexample
6129
6130 Please notice that on these devices, there is no need for @code{progmem}
6131 at all.
6132
6133 @end table
6134
6135 @item io
6136 @itemx io (@var{addr})
6137 @cindex @code{io} variable attribute, AVR
6138 Variables with the @code{io} attribute are used to address
6139 memory-mapped peripherals in the io address range.
6140 If an address is specified, the variable
6141 is assigned that address, and the value is interpreted as an
6142 address in the data address space.
6143 Example:
6144
6145 @smallexample
6146 volatile int porta __attribute__((io (0x22)));
6147 @end smallexample
6148
6149 The address specified in the address in the data address range.
6150
6151 Otherwise, the variable it is not assigned an address, but the
6152 compiler will still use in/out instructions where applicable,
6153 assuming some other module assigns an address in the io address range.
6154 Example:
6155
6156 @smallexample
6157 extern volatile int porta __attribute__((io));
6158 @end smallexample
6159
6160 @item io_low
6161 @itemx io_low (@var{addr})
6162 @cindex @code{io_low} variable attribute, AVR
6163 This is like the @code{io} attribute, but additionally it informs the
6164 compiler that the object lies in the lower half of the I/O area,
6165 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
6166 instructions.
6167
6168 @item address
6169 @itemx address (@var{addr})
6170 @cindex @code{address} variable attribute, AVR
6171 Variables with the @code{address} attribute are used to address
6172 memory-mapped peripherals that may lie outside the io address range.
6173
6174 @smallexample
6175 volatile int porta __attribute__((address (0x600)));
6176 @end smallexample
6177
6178 @item absdata
6179 @cindex @code{absdata} variable attribute, AVR
6180 Variables in static storage and with the @code{absdata} attribute can
6181 be accessed by the @code{LDS} and @code{STS} instructions which take
6182 absolute addresses.
6183
6184 @itemize @bullet
6185 @item
6186 This attribute is only supported for the reduced AVR Tiny core
6187 like ATtiny40.
6188
6189 @item
6190 You must make sure that respective data is located in the
6191 address range @code{0x40}@dots{}@code{0xbf} accessible by
6192 @code{LDS} and @code{STS}. One way to achieve this as an
6193 appropriate linker description file.
6194
6195 @item
6196 If the location does not fit the address range of @code{LDS}
6197 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6198 warning like
6199 @quotation
6200 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6201 @end quotation
6202
6203 @end itemize
6204
6205 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6206
6207 @end table
6208
6209 @node Blackfin Variable Attributes
6210 @subsection Blackfin Variable Attributes
6211
6212 Three attributes are currently defined for the Blackfin.
6213
6214 @table @code
6215 @item l1_data
6216 @itemx l1_data_A
6217 @itemx l1_data_B
6218 @cindex @code{l1_data} variable attribute, Blackfin
6219 @cindex @code{l1_data_A} variable attribute, Blackfin
6220 @cindex @code{l1_data_B} variable attribute, Blackfin
6221 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6222 Variables with @code{l1_data} attribute are put into the specific section
6223 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6224 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6225 attribute are put into the specific section named @code{.l1.data.B}.
6226
6227 @item l2
6228 @cindex @code{l2} variable attribute, Blackfin
6229 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6230 Variables with @code{l2} attribute are put into the specific section
6231 named @code{.l2.data}.
6232 @end table
6233
6234 @node H8/300 Variable Attributes
6235 @subsection H8/300 Variable Attributes
6236
6237 These variable attributes are available for H8/300 targets:
6238
6239 @table @code
6240 @item eightbit_data
6241 @cindex @code{eightbit_data} variable attribute, H8/300
6242 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6243 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6244 variable should be placed into the eight-bit data section.
6245 The compiler generates more efficient code for certain operations
6246 on data in the eight-bit data area. Note the eight-bit data area is limited to
6247 256 bytes of data.
6248
6249 You must use GAS and GLD from GNU binutils version 2.7 or later for
6250 this attribute to work correctly.
6251
6252 @item tiny_data
6253 @cindex @code{tiny_data} variable attribute, H8/300
6254 @cindex tiny data section on the H8/300H and H8S
6255 Use this attribute on the H8/300H and H8S to indicate that the specified
6256 variable should be placed into the tiny data section.
6257 The compiler generates more efficient code for loads and stores
6258 on data in the tiny data section. Note the tiny data area is limited to
6259 slightly under 32KB of data.
6260
6261 @end table
6262
6263 @node IA-64 Variable Attributes
6264 @subsection IA-64 Variable Attributes
6265
6266 The IA-64 back end supports the following variable attribute:
6267
6268 @table @code
6269 @item model (@var{model-name})
6270 @cindex @code{model} variable attribute, IA-64
6271
6272 On IA-64, use this attribute to set the addressability of an object.
6273 At present, the only supported identifier for @var{model-name} is
6274 @code{small}, indicating addressability via ``small'' (22-bit)
6275 addresses (so that their addresses can be loaded with the @code{addl}
6276 instruction). Caveat: such addressing is by definition not position
6277 independent and hence this attribute must not be used for objects
6278 defined by shared libraries.
6279
6280 @end table
6281
6282 @node M32R/D Variable Attributes
6283 @subsection M32R/D Variable Attributes
6284
6285 One attribute is currently defined for the M32R/D@.
6286
6287 @table @code
6288 @item model (@var{model-name})
6289 @cindex @code{model-name} variable attribute, M32R/D
6290 @cindex variable addressability on the M32R/D
6291 Use this attribute on the M32R/D to set the addressability of an object.
6292 The identifier @var{model-name} is one of @code{small}, @code{medium},
6293 or @code{large}, representing each of the code models.
6294
6295 Small model objects live in the lower 16MB of memory (so that their
6296 addresses can be loaded with the @code{ld24} instruction).
6297
6298 Medium and large model objects may live anywhere in the 32-bit address space
6299 (the compiler generates @code{seth/add3} instructions to load their
6300 addresses).
6301 @end table
6302
6303 @node MeP Variable Attributes
6304 @subsection MeP Variable Attributes
6305
6306 The MeP target has a number of addressing modes and busses. The
6307 @code{near} space spans the standard memory space's first 16 megabytes
6308 (24 bits). The @code{far} space spans the entire 32-bit memory space.
6309 The @code{based} space is a 128-byte region in the memory space that
6310 is addressed relative to the @code{$tp} register. The @code{tiny}
6311 space is a 65536-byte region relative to the @code{$gp} register. In
6312 addition to these memory regions, the MeP target has a separate 16-bit
6313 control bus which is specified with @code{cb} attributes.
6314
6315 @table @code
6316
6317 @item based
6318 @cindex @code{based} variable attribute, MeP
6319 Any variable with the @code{based} attribute is assigned to the
6320 @code{.based} section, and is accessed with relative to the
6321 @code{$tp} register.
6322
6323 @item tiny
6324 @cindex @code{tiny} variable attribute, MeP
6325 Likewise, the @code{tiny} attribute assigned variables to the
6326 @code{.tiny} section, relative to the @code{$gp} register.
6327
6328 @item near
6329 @cindex @code{near} variable attribute, MeP
6330 Variables with the @code{near} attribute are assumed to have addresses
6331 that fit in a 24-bit addressing mode. This is the default for large
6332 variables (@code{-mtiny=4} is the default) but this attribute can
6333 override @code{-mtiny=} for small variables, or override @code{-ml}.
6334
6335 @item far
6336 @cindex @code{far} variable attribute, MeP
6337 Variables with the @code{far} attribute are addressed using a full
6338 32-bit address. Since this covers the entire memory space, this
6339 allows modules to make no assumptions about where variables might be
6340 stored.
6341
6342 @item io
6343 @cindex @code{io} variable attribute, MeP
6344 @itemx io (@var{addr})
6345 Variables with the @code{io} attribute are used to address
6346 memory-mapped peripherals. If an address is specified, the variable
6347 is assigned that address, else it is not assigned an address (it is
6348 assumed some other module assigns an address). Example:
6349
6350 @smallexample
6351 int timer_count __attribute__((io(0x123)));
6352 @end smallexample
6353
6354 @item cb
6355 @itemx cb (@var{addr})
6356 @cindex @code{cb} variable attribute, MeP
6357 Variables with the @code{cb} attribute are used to access the control
6358 bus, using special instructions. @code{addr} indicates the control bus
6359 address. Example:
6360
6361 @smallexample
6362 int cpu_clock __attribute__((cb(0x123)));
6363 @end smallexample
6364
6365 @end table
6366
6367 @node Microsoft Windows Variable Attributes
6368 @subsection Microsoft Windows Variable Attributes
6369
6370 You can use these attributes on Microsoft Windows targets.
6371 @ref{x86 Variable Attributes} for additional Windows compatibility
6372 attributes available on all x86 targets.
6373
6374 @table @code
6375 @item dllimport
6376 @itemx dllexport
6377 @cindex @code{dllimport} variable attribute
6378 @cindex @code{dllexport} variable attribute
6379 The @code{dllimport} and @code{dllexport} attributes are described in
6380 @ref{Microsoft Windows Function Attributes}.
6381
6382 @item selectany
6383 @cindex @code{selectany} variable attribute
6384 The @code{selectany} attribute causes an initialized global variable to
6385 have link-once semantics. When multiple definitions of the variable are
6386 encountered by the linker, the first is selected and the remainder are
6387 discarded. Following usage by the Microsoft compiler, the linker is told
6388 @emph{not} to warn about size or content differences of the multiple
6389 definitions.
6390
6391 Although the primary usage of this attribute is for POD types, the
6392 attribute can also be applied to global C++ objects that are initialized
6393 by a constructor. In this case, the static initialization and destruction
6394 code for the object is emitted in each translation defining the object,
6395 but the calls to the constructor and destructor are protected by a
6396 link-once guard variable.
6397
6398 The @code{selectany} attribute is only available on Microsoft Windows
6399 targets. You can use @code{__declspec (selectany)} as a synonym for
6400 @code{__attribute__ ((selectany))} for compatibility with other
6401 compilers.
6402
6403 @item shared
6404 @cindex @code{shared} variable attribute
6405 On Microsoft Windows, in addition to putting variable definitions in a named
6406 section, the section can also be shared among all running copies of an
6407 executable or DLL@. For example, this small program defines shared data
6408 by putting it in a named section @code{shared} and marking the section
6409 shareable:
6410
6411 @smallexample
6412 int foo __attribute__((section ("shared"), shared)) = 0;
6413
6414 int
6415 main()
6416 @{
6417 /* @r{Read and write foo. All running
6418 copies see the same value.} */
6419 return 0;
6420 @}
6421 @end smallexample
6422
6423 @noindent
6424 You may only use the @code{shared} attribute along with @code{section}
6425 attribute with a fully-initialized global definition because of the way
6426 linkers work. See @code{section} attribute for more information.
6427
6428 The @code{shared} attribute is only available on Microsoft Windows@.
6429
6430 @end table
6431
6432 @node MSP430 Variable Attributes
6433 @subsection MSP430 Variable Attributes
6434
6435 @table @code
6436 @item noinit
6437 @cindex @code{noinit} variable attribute, MSP430
6438 Any data with the @code{noinit} attribute will not be initialised by
6439 the C runtime startup code, or the program loader. Not initialising
6440 data in this way can reduce program startup times.
6441
6442 @item persistent
6443 @cindex @code{persistent} variable attribute, MSP430
6444 Any variable with the @code{persistent} attribute will not be
6445 initialised by the C runtime startup code. Instead its value will be
6446 set once, when the application is loaded, and then never initialised
6447 again, even if the processor is reset or the program restarts.
6448 Persistent data is intended to be placed into FLASH RAM, where its
6449 value will be retained across resets. The linker script being used to
6450 create the application should ensure that persistent data is correctly
6451 placed.
6452
6453 @item lower
6454 @itemx upper
6455 @itemx either
6456 @cindex @code{lower} variable attribute, MSP430
6457 @cindex @code{upper} variable attribute, MSP430
6458 @cindex @code{either} variable attribute, MSP430
6459 These attributes are the same as the MSP430 function attributes of the
6460 same name (@pxref{MSP430 Function Attributes}).
6461 These attributes can be applied to both functions and variables.
6462 @end table
6463
6464 @node Nvidia PTX Variable Attributes
6465 @subsection Nvidia PTX Variable Attributes
6466
6467 These variable attributes are supported by the Nvidia PTX back end:
6468
6469 @table @code
6470 @item shared
6471 @cindex @code{shared} attribute, Nvidia PTX
6472 Use this attribute to place a variable in the @code{.shared} memory space.
6473 This memory space is private to each cooperative thread array; only threads
6474 within one thread block refer to the same instance of the variable.
6475 The runtime does not initialize variables in this memory space.
6476 @end table
6477
6478 @node PowerPC Variable Attributes
6479 @subsection PowerPC Variable Attributes
6480
6481 Three attributes currently are defined for PowerPC configurations:
6482 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6483
6484 @cindex @code{ms_struct} variable attribute, PowerPC
6485 @cindex @code{gcc_struct} variable attribute, PowerPC
6486 For full documentation of the struct attributes please see the
6487 documentation in @ref{x86 Variable Attributes}.
6488
6489 @cindex @code{altivec} variable attribute, PowerPC
6490 For documentation of @code{altivec} attribute please see the
6491 documentation in @ref{PowerPC Type Attributes}.
6492
6493 @node RL78 Variable Attributes
6494 @subsection RL78 Variable Attributes
6495
6496 @cindex @code{saddr} variable attribute, RL78
6497 The RL78 back end supports the @code{saddr} variable attribute. This
6498 specifies placement of the corresponding variable in the SADDR area,
6499 which can be accessed more efficiently than the default memory region.
6500
6501 @node SPU Variable Attributes
6502 @subsection SPU Variable Attributes
6503
6504 @cindex @code{spu_vector} variable attribute, SPU
6505 The SPU supports the @code{spu_vector} attribute for variables. For
6506 documentation of this attribute please see the documentation in
6507 @ref{SPU Type Attributes}.
6508
6509 @node V850 Variable Attributes
6510 @subsection V850 Variable Attributes
6511
6512 These variable attributes are supported by the V850 back end:
6513
6514 @table @code
6515
6516 @item sda
6517 @cindex @code{sda} variable attribute, V850
6518 Use this attribute to explicitly place a variable in the small data area,
6519 which can hold up to 64 kilobytes.
6520
6521 @item tda
6522 @cindex @code{tda} variable attribute, V850
6523 Use this attribute to explicitly place a variable in the tiny data area,
6524 which can hold up to 256 bytes in total.
6525
6526 @item zda
6527 @cindex @code{zda} variable attribute, V850
6528 Use this attribute to explicitly place a variable in the first 32 kilobytes
6529 of memory.
6530 @end table
6531
6532 @node x86 Variable Attributes
6533 @subsection x86 Variable Attributes
6534
6535 Two attributes are currently defined for x86 configurations:
6536 @code{ms_struct} and @code{gcc_struct}.
6537
6538 @table @code
6539 @item ms_struct
6540 @itemx gcc_struct
6541 @cindex @code{ms_struct} variable attribute, x86
6542 @cindex @code{gcc_struct} variable attribute, x86
6543
6544 If @code{packed} is used on a structure, or if bit-fields are used,
6545 it may be that the Microsoft ABI lays out the structure differently
6546 than the way GCC normally does. Particularly when moving packed
6547 data between functions compiled with GCC and the native Microsoft compiler
6548 (either via function call or as data in a file), it may be necessary to access
6549 either format.
6550
6551 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6552 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6553 command-line options, respectively;
6554 see @ref{x86 Options}, for details of how structure layout is affected.
6555 @xref{x86 Type Attributes}, for information about the corresponding
6556 attributes on types.
6557
6558 @end table
6559
6560 @node Xstormy16 Variable Attributes
6561 @subsection Xstormy16 Variable Attributes
6562
6563 One attribute is currently defined for xstormy16 configurations:
6564 @code{below100}.
6565
6566 @table @code
6567 @item below100
6568 @cindex @code{below100} variable attribute, Xstormy16
6569
6570 If a variable has the @code{below100} attribute (@code{BELOW100} is
6571 allowed also), GCC places the variable in the first 0x100 bytes of
6572 memory and use special opcodes to access it. Such variables are
6573 placed in either the @code{.bss_below100} section or the
6574 @code{.data_below100} section.
6575
6576 @end table
6577
6578 @node Type Attributes
6579 @section Specifying Attributes of Types
6580 @cindex attribute of types
6581 @cindex type attributes
6582
6583 The keyword @code{__attribute__} allows you to specify special
6584 attributes of types. Some type attributes apply only to @code{struct}
6585 and @code{union} types, while others can apply to any type defined
6586 via a @code{typedef} declaration. Other attributes are defined for
6587 functions (@pxref{Function Attributes}), labels (@pxref{Label
6588 Attributes}), enumerators (@pxref{Enumerator Attributes}),
6589 statements (@pxref{Statement Attributes}), and for
6590 variables (@pxref{Variable Attributes}).
6591
6592 The @code{__attribute__} keyword is followed by an attribute specification
6593 inside double parentheses.
6594
6595 You may specify type attributes in an enum, struct or union type
6596 declaration or definition by placing them immediately after the
6597 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6598 syntax is to place them just past the closing curly brace of the
6599 definition.
6600
6601 You can also include type attributes in a @code{typedef} declaration.
6602 @xref{Attribute Syntax}, for details of the exact syntax for using
6603 attributes.
6604
6605 @menu
6606 * Common Type Attributes::
6607 * ARM Type Attributes::
6608 * MeP Type Attributes::
6609 * PowerPC Type Attributes::
6610 * SPU Type Attributes::
6611 * x86 Type Attributes::
6612 @end menu
6613
6614 @node Common Type Attributes
6615 @subsection Common Type Attributes
6616
6617 The following type attributes are supported on most targets.
6618
6619 @table @code
6620 @cindex @code{aligned} type attribute
6621 @item aligned (@var{alignment})
6622 This attribute specifies a minimum alignment (in bytes) for variables
6623 of the specified type. For example, the declarations:
6624
6625 @smallexample
6626 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6627 typedef int more_aligned_int __attribute__ ((aligned (8)));
6628 @end smallexample
6629
6630 @noindent
6631 force the compiler to ensure (as far as it can) that each variable whose
6632 type is @code{struct S} or @code{more_aligned_int} is allocated and
6633 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6634 variables of type @code{struct S} aligned to 8-byte boundaries allows
6635 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6636 store) instructions when copying one variable of type @code{struct S} to
6637 another, thus improving run-time efficiency.
6638
6639 Note that the alignment of any given @code{struct} or @code{union} type
6640 is required by the ISO C standard to be at least a perfect multiple of
6641 the lowest common multiple of the alignments of all of the members of
6642 the @code{struct} or @code{union} in question. This means that you @emph{can}
6643 effectively adjust the alignment of a @code{struct} or @code{union}
6644 type by attaching an @code{aligned} attribute to any one of the members
6645 of such a type, but the notation illustrated in the example above is a
6646 more obvious, intuitive, and readable way to request the compiler to
6647 adjust the alignment of an entire @code{struct} or @code{union} type.
6648
6649 As in the preceding example, you can explicitly specify the alignment
6650 (in bytes) that you wish the compiler to use for a given @code{struct}
6651 or @code{union} type. Alternatively, you can leave out the alignment factor
6652 and just ask the compiler to align a type to the maximum
6653 useful alignment for the target machine you are compiling for. For
6654 example, you could write:
6655
6656 @smallexample
6657 struct S @{ short f[3]; @} __attribute__ ((aligned));
6658 @end smallexample
6659
6660 Whenever you leave out the alignment factor in an @code{aligned}
6661 attribute specification, the compiler automatically sets the alignment
6662 for the type to the largest alignment that is ever used for any data
6663 type on the target machine you are compiling for. Doing this can often
6664 make copy operations more efficient, because the compiler can use
6665 whatever instructions copy the biggest chunks of memory when performing
6666 copies to or from the variables that have types that you have aligned
6667 this way.
6668
6669 In the example above, if the size of each @code{short} is 2 bytes, then
6670 the size of the entire @code{struct S} type is 6 bytes. The smallest
6671 power of two that is greater than or equal to that is 8, so the
6672 compiler sets the alignment for the entire @code{struct S} type to 8
6673 bytes.
6674
6675 Note that although you can ask the compiler to select a time-efficient
6676 alignment for a given type and then declare only individual stand-alone
6677 objects of that type, the compiler's ability to select a time-efficient
6678 alignment is primarily useful only when you plan to create arrays of
6679 variables having the relevant (efficiently aligned) type. If you
6680 declare or use arrays of variables of an efficiently-aligned type, then
6681 it is likely that your program also does pointer arithmetic (or
6682 subscripting, which amounts to the same thing) on pointers to the
6683 relevant type, and the code that the compiler generates for these
6684 pointer arithmetic operations is often more efficient for
6685 efficiently-aligned types than for other types.
6686
6687 Note that the effectiveness of @code{aligned} attributes may be limited
6688 by inherent limitations in your linker. On many systems, the linker is
6689 only able to arrange for variables to be aligned up to a certain maximum
6690 alignment. (For some linkers, the maximum supported alignment may
6691 be very very small.) If your linker is only able to align variables
6692 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6693 in an @code{__attribute__} still only provides you with 8-byte
6694 alignment. See your linker documentation for further information.
6695
6696 The @code{aligned} attribute can only increase alignment. Alignment
6697 can be decreased by specifying the @code{packed} attribute. See below.
6698
6699 @cindex @code{warn_if_not_aligned} type attribute
6700 @item warn_if_not_aligned (@var{alignment})
6701 This attribute specifies a threshold for the structure field, measured
6702 in bytes. If the structure field is aligned below the threshold, a
6703 warning will be issued. For example, the declaration:
6704
6705 @smallexample
6706 typedef unsigned long long __u64
6707 __attribute__((aligned(4),warn_if_not_aligned(8)));
6708
6709 struct foo
6710 @{
6711 int i1;
6712 int i2;
6713 __u64 x;
6714 @};
6715 @end smallexample
6716
6717 @noindent
6718 causes the compiler to issue an warning on @code{struct foo}, like
6719 @samp{warning: alignment 4 of 'struct foo' is less than 8}.
6720 It is used to define @code{struct foo} in such a way that
6721 @code{struct foo} has the same layout and the structure field @code{x}
6722 has the same alignment when @code{__u64} is aligned at either 4 or
6723 8 bytes. Align @code{struct foo} to 8 bytes:
6724
6725 @smallexample
6726 struct foo
6727 @{
6728 int i1;
6729 int i2;
6730 __u64 x;
6731 @} __attribute__((aligned(8)));
6732 @end smallexample
6733
6734 @noindent
6735 silences the warning. The compiler also issues a warning, like
6736 @samp{warning: 'x' offset 12 in 'struct foo' isn't aligned to 8},
6737 when the structure field has the misaligned offset:
6738
6739 @smallexample
6740 struct foo
6741 @{
6742 int i1;
6743 int i2;
6744 int i3;
6745 __u64 x;
6746 @} __attribute__((aligned(8)));
6747 @end smallexample
6748
6749 This warning can be disabled by @option{-Wno-if-not-aligned}.
6750
6751 @item bnd_variable_size
6752 @cindex @code{bnd_variable_size} type attribute
6753 @cindex Pointer Bounds Checker attributes
6754 When applied to a structure field, this attribute tells Pointer
6755 Bounds Checker that the size of this field should not be computed
6756 using static type information. It may be used to mark variably-sized
6757 static array fields placed at the end of a structure.
6758
6759 @smallexample
6760 struct S
6761 @{
6762 int size;
6763 char data[1];
6764 @}
6765 S *p = (S *)malloc (sizeof(S) + 100);
6766 p->data[10] = 0; //Bounds violation
6767 @end smallexample
6768
6769 @noindent
6770 By using an attribute for the field we may avoid unwanted bound
6771 violation checks:
6772
6773 @smallexample
6774 struct S
6775 @{
6776 int size;
6777 char data[1] __attribute__((bnd_variable_size));
6778 @}
6779 S *p = (S *)malloc (sizeof(S) + 100);
6780 p->data[10] = 0; //OK
6781 @end smallexample
6782
6783 @item deprecated
6784 @itemx deprecated (@var{msg})
6785 @cindex @code{deprecated} type attribute
6786 The @code{deprecated} attribute results in a warning if the type
6787 is used anywhere in the source file. This is useful when identifying
6788 types that are expected to be removed in a future version of a program.
6789 If possible, the warning also includes the location of the declaration
6790 of the deprecated type, to enable users to easily find further
6791 information about why the type is deprecated, or what they should do
6792 instead. Note that the warnings only occur for uses and then only
6793 if the type is being applied to an identifier that itself is not being
6794 declared as deprecated.
6795
6796 @smallexample
6797 typedef int T1 __attribute__ ((deprecated));
6798 T1 x;
6799 typedef T1 T2;
6800 T2 y;
6801 typedef T1 T3 __attribute__ ((deprecated));
6802 T3 z __attribute__ ((deprecated));
6803 @end smallexample
6804
6805 @noindent
6806 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
6807 warning is issued for line 4 because T2 is not explicitly
6808 deprecated. Line 5 has no warning because T3 is explicitly
6809 deprecated. Similarly for line 6. The optional @var{msg}
6810 argument, which must be a string, is printed in the warning if
6811 present.
6812
6813 The @code{deprecated} attribute can also be used for functions and
6814 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6815
6816 @item designated_init
6817 @cindex @code{designated_init} type attribute
6818 This attribute may only be applied to structure types. It indicates
6819 that any initialization of an object of this type must use designated
6820 initializers rather than positional initializers. The intent of this
6821 attribute is to allow the programmer to indicate that a structure's
6822 layout may change, and that therefore relying on positional
6823 initialization will result in future breakage.
6824
6825 GCC emits warnings based on this attribute by default; use
6826 @option{-Wno-designated-init} to suppress them.
6827
6828 @item may_alias
6829 @cindex @code{may_alias} type attribute
6830 Accesses through pointers to types with this attribute are not subject
6831 to type-based alias analysis, but are instead assumed to be able to alias
6832 any other type of objects.
6833 In the context of section 6.5 paragraph 7 of the C99 standard,
6834 an lvalue expression
6835 dereferencing such a pointer is treated like having a character type.
6836 See @option{-fstrict-aliasing} for more information on aliasing issues.
6837 This extension exists to support some vector APIs, in which pointers to
6838 one vector type are permitted to alias pointers to a different vector type.
6839
6840 Note that an object of a type with this attribute does not have any
6841 special semantics.
6842
6843 Example of use:
6844
6845 @smallexample
6846 typedef short __attribute__((__may_alias__)) short_a;
6847
6848 int
6849 main (void)
6850 @{
6851 int a = 0x12345678;
6852 short_a *b = (short_a *) &a;
6853
6854 b[1] = 0;
6855
6856 if (a == 0x12345678)
6857 abort();
6858
6859 exit(0);
6860 @}
6861 @end smallexample
6862
6863 @noindent
6864 If you replaced @code{short_a} with @code{short} in the variable
6865 declaration, the above program would abort when compiled with
6866 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6867 above.
6868
6869 @item packed
6870 @cindex @code{packed} type attribute
6871 This attribute, attached to @code{struct} or @code{union} type
6872 definition, specifies that each member (other than zero-width bit-fields)
6873 of the structure or union is placed to minimize the memory required. When
6874 attached to an @code{enum} definition, it indicates that the smallest
6875 integral type should be used.
6876
6877 @opindex fshort-enums
6878 Specifying the @code{packed} attribute for @code{struct} and @code{union}
6879 types is equivalent to specifying the @code{packed} attribute on each
6880 of the structure or union members. Specifying the @option{-fshort-enums}
6881 flag on the command line is equivalent to specifying the @code{packed}
6882 attribute on all @code{enum} definitions.
6883
6884 In the following example @code{struct my_packed_struct}'s members are
6885 packed closely together, but the internal layout of its @code{s} member
6886 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6887 be packed too.
6888
6889 @smallexample
6890 struct my_unpacked_struct
6891 @{
6892 char c;
6893 int i;
6894 @};
6895
6896 struct __attribute__ ((__packed__)) my_packed_struct
6897 @{
6898 char c;
6899 int i;
6900 struct my_unpacked_struct s;
6901 @};
6902 @end smallexample
6903
6904 You may only specify the @code{packed} attribute attribute on the definition
6905 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
6906 that does not also define the enumerated type, structure or union.
6907
6908 @item scalar_storage_order ("@var{endianness}")
6909 @cindex @code{scalar_storage_order} type attribute
6910 When attached to a @code{union} or a @code{struct}, this attribute sets
6911 the storage order, aka endianness, of the scalar fields of the type, as
6912 well as the array fields whose component is scalar. The supported
6913 endiannesses are @code{big-endian} and @code{little-endian}. The attribute
6914 has no effects on fields which are themselves a @code{union}, a @code{struct}
6915 or an array whose component is a @code{union} or a @code{struct}, and it is
6916 possible for these fields to have a different scalar storage order than the
6917 enclosing type.
6918
6919 This attribute is supported only for targets that use a uniform default
6920 scalar storage order (fortunately, most of them), i.e. targets that store
6921 the scalars either all in big-endian or all in little-endian.
6922
6923 Additional restrictions are enforced for types with the reverse scalar
6924 storage order with regard to the scalar storage order of the target:
6925
6926 @itemize
6927 @item Taking the address of a scalar field of a @code{union} or a
6928 @code{struct} with reverse scalar storage order is not permitted and yields
6929 an error.
6930 @item Taking the address of an array field, whose component is scalar, of
6931 a @code{union} or a @code{struct} with reverse scalar storage order is
6932 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
6933 is specified.
6934 @item Taking the address of a @code{union} or a @code{struct} with reverse
6935 scalar storage order is permitted.
6936 @end itemize
6937
6938 These restrictions exist because the storage order attribute is lost when
6939 the address of a scalar or the address of an array with scalar component is
6940 taken, so storing indirectly through this address generally does not work.
6941 The second case is nevertheless allowed to be able to perform a block copy
6942 from or to the array.
6943
6944 Moreover, the use of type punning or aliasing to toggle the storage order
6945 is not supported; that is to say, a given scalar object cannot be accessed
6946 through distinct types that assign a different storage order to it.
6947
6948 @item transparent_union
6949 @cindex @code{transparent_union} type attribute
6950
6951 This attribute, attached to a @code{union} type definition, indicates
6952 that any function parameter having that union type causes calls to that
6953 function to be treated in a special way.
6954
6955 First, the argument corresponding to a transparent union type can be of
6956 any type in the union; no cast is required. Also, if the union contains
6957 a pointer type, the corresponding argument can be a null pointer
6958 constant or a void pointer expression; and if the union contains a void
6959 pointer type, the corresponding argument can be any pointer expression.
6960 If the union member type is a pointer, qualifiers like @code{const} on
6961 the referenced type must be respected, just as with normal pointer
6962 conversions.
6963
6964 Second, the argument is passed to the function using the calling
6965 conventions of the first member of the transparent union, not the calling
6966 conventions of the union itself. All members of the union must have the
6967 same machine representation; this is necessary for this argument passing
6968 to work properly.
6969
6970 Transparent unions are designed for library functions that have multiple
6971 interfaces for compatibility reasons. For example, suppose the
6972 @code{wait} function must accept either a value of type @code{int *} to
6973 comply with POSIX, or a value of type @code{union wait *} to comply with
6974 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
6975 @code{wait} would accept both kinds of arguments, but it would also
6976 accept any other pointer type and this would make argument type checking
6977 less useful. Instead, @code{<sys/wait.h>} might define the interface
6978 as follows:
6979
6980 @smallexample
6981 typedef union __attribute__ ((__transparent_union__))
6982 @{
6983 int *__ip;
6984 union wait *__up;
6985 @} wait_status_ptr_t;
6986
6987 pid_t wait (wait_status_ptr_t);
6988 @end smallexample
6989
6990 @noindent
6991 This interface allows either @code{int *} or @code{union wait *}
6992 arguments to be passed, using the @code{int *} calling convention.
6993 The program can call @code{wait} with arguments of either type:
6994
6995 @smallexample
6996 int w1 () @{ int w; return wait (&w); @}
6997 int w2 () @{ union wait w; return wait (&w); @}
6998 @end smallexample
6999
7000 @noindent
7001 With this interface, @code{wait}'s implementation might look like this:
7002
7003 @smallexample
7004 pid_t wait (wait_status_ptr_t p)
7005 @{
7006 return waitpid (-1, p.__ip, 0);
7007 @}
7008 @end smallexample
7009
7010 @item unused
7011 @cindex @code{unused} type attribute
7012 When attached to a type (including a @code{union} or a @code{struct}),
7013 this attribute means that variables of that type are meant to appear
7014 possibly unused. GCC does not produce a warning for any variables of
7015 that type, even if the variable appears to do nothing. This is often
7016 the case with lock or thread classes, which are usually defined and then
7017 not referenced, but contain constructors and destructors that have
7018 nontrivial bookkeeping functions.
7019
7020 @item visibility
7021 @cindex @code{visibility} type attribute
7022 In C++, attribute visibility (@pxref{Function Attributes}) can also be
7023 applied to class, struct, union and enum types. Unlike other type
7024 attributes, the attribute must appear between the initial keyword and
7025 the name of the type; it cannot appear after the body of the type.
7026
7027 Note that the type visibility is applied to vague linkage entities
7028 associated with the class (vtable, typeinfo node, etc.). In
7029 particular, if a class is thrown as an exception in one shared object
7030 and caught in another, the class must have default visibility.
7031 Otherwise the two shared objects are unable to use the same
7032 typeinfo node and exception handling will break.
7033
7034 @end table
7035
7036 To specify multiple attributes, separate them by commas within the
7037 double parentheses: for example, @samp{__attribute__ ((aligned (16),
7038 packed))}.
7039
7040 @node ARM Type Attributes
7041 @subsection ARM Type Attributes
7042
7043 @cindex @code{notshared} type attribute, ARM
7044 On those ARM targets that support @code{dllimport} (such as Symbian
7045 OS), you can use the @code{notshared} attribute to indicate that the
7046 virtual table and other similar data for a class should not be
7047 exported from a DLL@. For example:
7048
7049 @smallexample
7050 class __declspec(notshared) C @{
7051 public:
7052 __declspec(dllimport) C();
7053 virtual void f();
7054 @}
7055
7056 __declspec(dllexport)
7057 C::C() @{@}
7058 @end smallexample
7059
7060 @noindent
7061 In this code, @code{C::C} is exported from the current DLL, but the
7062 virtual table for @code{C} is not exported. (You can use
7063 @code{__attribute__} instead of @code{__declspec} if you prefer, but
7064 most Symbian OS code uses @code{__declspec}.)
7065
7066 @node MeP Type Attributes
7067 @subsection MeP Type Attributes
7068
7069 @cindex @code{based} type attribute, MeP
7070 @cindex @code{tiny} type attribute, MeP
7071 @cindex @code{near} type attribute, MeP
7072 @cindex @code{far} type attribute, MeP
7073 Many of the MeP variable attributes may be applied to types as well.
7074 Specifically, the @code{based}, @code{tiny}, @code{near}, and
7075 @code{far} attributes may be applied to either. The @code{io} and
7076 @code{cb} attributes may not be applied to types.
7077
7078 @node PowerPC Type Attributes
7079 @subsection PowerPC Type Attributes
7080
7081 Three attributes currently are defined for PowerPC configurations:
7082 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7083
7084 @cindex @code{ms_struct} type attribute, PowerPC
7085 @cindex @code{gcc_struct} type attribute, PowerPC
7086 For full documentation of the @code{ms_struct} and @code{gcc_struct}
7087 attributes please see the documentation in @ref{x86 Type Attributes}.
7088
7089 @cindex @code{altivec} type attribute, PowerPC
7090 The @code{altivec} attribute allows one to declare AltiVec vector data
7091 types supported by the AltiVec Programming Interface Manual. The
7092 attribute requires an argument to specify one of three vector types:
7093 @code{vector__}, @code{pixel__} (always followed by unsigned short),
7094 and @code{bool__} (always followed by unsigned).
7095
7096 @smallexample
7097 __attribute__((altivec(vector__)))
7098 __attribute__((altivec(pixel__))) unsigned short
7099 __attribute__((altivec(bool__))) unsigned
7100 @end smallexample
7101
7102 These attributes mainly are intended to support the @code{__vector},
7103 @code{__pixel}, and @code{__bool} AltiVec keywords.
7104
7105 @node SPU Type Attributes
7106 @subsection SPU Type Attributes
7107
7108 @cindex @code{spu_vector} type attribute, SPU
7109 The SPU supports the @code{spu_vector} attribute for types. This attribute
7110 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
7111 Language Extensions Specification. It is intended to support the
7112 @code{__vector} keyword.
7113
7114 @node x86 Type Attributes
7115 @subsection x86 Type Attributes
7116
7117 Two attributes are currently defined for x86 configurations:
7118 @code{ms_struct} and @code{gcc_struct}.
7119
7120 @table @code
7121
7122 @item ms_struct
7123 @itemx gcc_struct
7124 @cindex @code{ms_struct} type attribute, x86
7125 @cindex @code{gcc_struct} type attribute, x86
7126
7127 If @code{packed} is used on a structure, or if bit-fields are used
7128 it may be that the Microsoft ABI packs them differently
7129 than GCC normally packs them. Particularly when moving packed
7130 data between functions compiled with GCC and the native Microsoft compiler
7131 (either via function call or as data in a file), it may be necessary to access
7132 either format.
7133
7134 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7135 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7136 command-line options, respectively;
7137 see @ref{x86 Options}, for details of how structure layout is affected.
7138 @xref{x86 Variable Attributes}, for information about the corresponding
7139 attributes on variables.
7140
7141 @end table
7142
7143 @node Label Attributes
7144 @section Label Attributes
7145 @cindex Label Attributes
7146
7147 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
7148 details of the exact syntax for using attributes. Other attributes are
7149 available for functions (@pxref{Function Attributes}), variables
7150 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
7151 statements (@pxref{Statement Attributes}), and for types
7152 (@pxref{Type Attributes}).
7153
7154 This example uses the @code{cold} label attribute to indicate the
7155 @code{ErrorHandling} branch is unlikely to be taken and that the
7156 @code{ErrorHandling} label is unused:
7157
7158 @smallexample
7159
7160 asm goto ("some asm" : : : : NoError);
7161
7162 /* This branch (the fall-through from the asm) is less commonly used */
7163 ErrorHandling:
7164 __attribute__((cold, unused)); /* Semi-colon is required here */
7165 printf("error\n");
7166 return 0;
7167
7168 NoError:
7169 printf("no error\n");
7170 return 1;
7171 @end smallexample
7172
7173 @table @code
7174 @item unused
7175 @cindex @code{unused} label attribute
7176 This feature is intended for program-generated code that may contain
7177 unused labels, but which is compiled with @option{-Wall}. It is
7178 not normally appropriate to use in it human-written code, though it
7179 could be useful in cases where the code that jumps to the label is
7180 contained within an @code{#ifdef} conditional.
7181
7182 @item hot
7183 @cindex @code{hot} label attribute
7184 The @code{hot} attribute on a label is used to inform the compiler that
7185 the path following the label is more likely than paths that are not so
7186 annotated. This attribute is used in cases where @code{__builtin_expect}
7187 cannot be used, for instance with computed goto or @code{asm goto}.
7188
7189 @item cold
7190 @cindex @code{cold} label attribute
7191 The @code{cold} attribute on labels is used to inform the compiler that
7192 the path following the label is unlikely to be executed. This attribute
7193 is used in cases where @code{__builtin_expect} cannot be used, for instance
7194 with computed goto or @code{asm goto}.
7195
7196 @end table
7197
7198 @node Enumerator Attributes
7199 @section Enumerator Attributes
7200 @cindex Enumerator Attributes
7201
7202 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
7203 details of the exact syntax for using attributes. Other attributes are
7204 available for functions (@pxref{Function Attributes}), variables
7205 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
7206 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
7207
7208 This example uses the @code{deprecated} enumerator attribute to indicate the
7209 @code{oldval} enumerator is deprecated:
7210
7211 @smallexample
7212 enum E @{
7213 oldval __attribute__((deprecated)),
7214 newval
7215 @};
7216
7217 int
7218 fn (void)
7219 @{
7220 return oldval;
7221 @}
7222 @end smallexample
7223
7224 @table @code
7225 @item deprecated
7226 @cindex @code{deprecated} enumerator attribute
7227 The @code{deprecated} attribute results in a warning if the enumerator
7228 is used anywhere in the source file. This is useful when identifying
7229 enumerators that are expected to be removed in a future version of a
7230 program. The warning also includes the location of the declaration
7231 of the deprecated enumerator, to enable users to easily find further
7232 information about why the enumerator is deprecated, or what they should
7233 do instead. Note that the warnings only occurs for uses.
7234
7235 @end table
7236
7237 @node Statement Attributes
7238 @section Statement Attributes
7239 @cindex Statement Attributes
7240
7241 GCC allows attributes to be set on null statements. @xref{Attribute Syntax},
7242 for details of the exact syntax for using attributes. Other attributes are
7243 available for functions (@pxref{Function Attributes}), variables
7244 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7245 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7246
7247 This example uses the @code{fallthrough} statement attribute to indicate that
7248 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7249
7250 @smallexample
7251 switch (cond)
7252 @{
7253 case 1:
7254 bar (1);
7255 __attribute__((fallthrough));
7256 case 2:
7257 @dots{}
7258 @}
7259 @end smallexample
7260
7261 @table @code
7262 @item fallthrough
7263 @cindex @code{fallthrough} statement attribute
7264 The @code{fallthrough} attribute with a null statement serves as a
7265 fallthrough statement. It hints to the compiler that a statement
7266 that falls through to another case label, or user-defined label
7267 in a switch statement is intentional and thus the
7268 @option{-Wimplicit-fallthrough} warning must not trigger. The
7269 fallthrough attribute may appear at most once in each attribute
7270 list, and may not be mixed with other attributes. It can only
7271 be used in a switch statement (the compiler will issue an error
7272 otherwise), after a preceding statement and before a logically
7273 succeeding case label, or user-defined label.
7274
7275 @end table
7276
7277 @node Attribute Syntax
7278 @section Attribute Syntax
7279 @cindex attribute syntax
7280
7281 This section describes the syntax with which @code{__attribute__} may be
7282 used, and the constructs to which attribute specifiers bind, for the C
7283 language. Some details may vary for C++ and Objective-C@. Because of
7284 infelicities in the grammar for attributes, some forms described here
7285 may not be successfully parsed in all cases.
7286
7287 There are some problems with the semantics of attributes in C++. For
7288 example, there are no manglings for attributes, although they may affect
7289 code generation, so problems may arise when attributed types are used in
7290 conjunction with templates or overloading. Similarly, @code{typeid}
7291 does not distinguish between types with different attributes. Support
7292 for attributes in C++ may be restricted in future to attributes on
7293 declarations only, but not on nested declarators.
7294
7295 @xref{Function Attributes}, for details of the semantics of attributes
7296 applying to functions. @xref{Variable Attributes}, for details of the
7297 semantics of attributes applying to variables. @xref{Type Attributes},
7298 for details of the semantics of attributes applying to structure, union
7299 and enumerated types.
7300 @xref{Label Attributes}, for details of the semantics of attributes
7301 applying to labels.
7302 @xref{Enumerator Attributes}, for details of the semantics of attributes
7303 applying to enumerators.
7304 @xref{Statement Attributes}, for details of the semantics of attributes
7305 applying to statements.
7306
7307 An @dfn{attribute specifier} is of the form
7308 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
7309 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7310 each attribute is one of the following:
7311
7312 @itemize @bullet
7313 @item
7314 Empty. Empty attributes are ignored.
7315
7316 @item
7317 An attribute name
7318 (which may be an identifier such as @code{unused}, or a reserved
7319 word such as @code{const}).
7320
7321 @item
7322 An attribute name followed by a parenthesized list of
7323 parameters for the attribute.
7324 These parameters take one of the following forms:
7325
7326 @itemize @bullet
7327 @item
7328 An identifier. For example, @code{mode} attributes use this form.
7329
7330 @item
7331 An identifier followed by a comma and a non-empty comma-separated list
7332 of expressions. For example, @code{format} attributes use this form.
7333
7334 @item
7335 A possibly empty comma-separated list of expressions. For example,
7336 @code{format_arg} attributes use this form with the list being a single
7337 integer constant expression, and @code{alias} attributes use this form
7338 with the list being a single string constant.
7339 @end itemize
7340 @end itemize
7341
7342 An @dfn{attribute specifier list} is a sequence of one or more attribute
7343 specifiers, not separated by any other tokens.
7344
7345 You may optionally specify attribute names with @samp{__}
7346 preceding and following the name.
7347 This allows you to use them in header files without
7348 being concerned about a possible macro of the same name. For example,
7349 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7350
7351
7352 @subsubheading Label Attributes
7353
7354 In GNU C, an attribute specifier list may appear after the colon following a
7355 label, other than a @code{case} or @code{default} label. GNU C++ only permits
7356 attributes on labels if the attribute specifier is immediately
7357 followed by a semicolon (i.e., the label applies to an empty
7358 statement). If the semicolon is missing, C++ label attributes are
7359 ambiguous, as it is permissible for a declaration, which could begin
7360 with an attribute list, to be labelled in C++. Declarations cannot be
7361 labelled in C90 or C99, so the ambiguity does not arise there.
7362
7363 @subsubheading Enumerator Attributes
7364
7365 In GNU C, an attribute specifier list may appear as part of an enumerator.
7366 The attribute goes after the enumeration constant, before @code{=}, if
7367 present. The optional attribute in the enumerator appertains to the
7368 enumeration constant. It is not possible to place the attribute after
7369 the constant expression, if present.
7370
7371 @subsubheading Statement Attributes
7372 In GNU C, an attribute specifier list may appear as part of a null
7373 statement. The attribute goes before the semicolon.
7374
7375 @subsubheading Type Attributes
7376
7377 An attribute specifier list may appear as part of a @code{struct},
7378 @code{union} or @code{enum} specifier. It may go either immediately
7379 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7380 the closing brace. The former syntax is preferred.
7381 Where attribute specifiers follow the closing brace, they are considered
7382 to relate to the structure, union or enumerated type defined, not to any
7383 enclosing declaration the type specifier appears in, and the type
7384 defined is not complete until after the attribute specifiers.
7385 @c Otherwise, there would be the following problems: a shift/reduce
7386 @c conflict between attributes binding the struct/union/enum and
7387 @c binding to the list of specifiers/qualifiers; and "aligned"
7388 @c attributes could use sizeof for the structure, but the size could be
7389 @c changed later by "packed" attributes.
7390
7391
7392 @subsubheading All other attributes
7393
7394 Otherwise, an attribute specifier appears as part of a declaration,
7395 counting declarations of unnamed parameters and type names, and relates
7396 to that declaration (which may be nested in another declaration, for
7397 example in the case of a parameter declaration), or to a particular declarator
7398 within a declaration. Where an
7399 attribute specifier is applied to a parameter declared as a function or
7400 an array, it should apply to the function or array rather than the
7401 pointer to which the parameter is implicitly converted, but this is not
7402 yet correctly implemented.
7403
7404 Any list of specifiers and qualifiers at the start of a declaration may
7405 contain attribute specifiers, whether or not such a list may in that
7406 context contain storage class specifiers. (Some attributes, however,
7407 are essentially in the nature of storage class specifiers, and only make
7408 sense where storage class specifiers may be used; for example,
7409 @code{section}.) There is one necessary limitation to this syntax: the
7410 first old-style parameter declaration in a function definition cannot
7411 begin with an attribute specifier, because such an attribute applies to
7412 the function instead by syntax described below (which, however, is not
7413 yet implemented in this case). In some other cases, attribute
7414 specifiers are permitted by this grammar but not yet supported by the
7415 compiler. All attribute specifiers in this place relate to the
7416 declaration as a whole. In the obsolescent usage where a type of
7417 @code{int} is implied by the absence of type specifiers, such a list of
7418 specifiers and qualifiers may be an attribute specifier list with no
7419 other specifiers or qualifiers.
7420
7421 At present, the first parameter in a function prototype must have some
7422 type specifier that is not an attribute specifier; this resolves an
7423 ambiguity in the interpretation of @code{void f(int
7424 (__attribute__((foo)) x))}, but is subject to change. At present, if
7425 the parentheses of a function declarator contain only attributes then
7426 those attributes are ignored, rather than yielding an error or warning
7427 or implying a single parameter of type int, but this is subject to
7428 change.
7429
7430 An attribute specifier list may appear immediately before a declarator
7431 (other than the first) in a comma-separated list of declarators in a
7432 declaration of more than one identifier using a single list of
7433 specifiers and qualifiers. Such attribute specifiers apply
7434 only to the identifier before whose declarator they appear. For
7435 example, in
7436
7437 @smallexample
7438 __attribute__((noreturn)) void d0 (void),
7439 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7440 d2 (void);
7441 @end smallexample
7442
7443 @noindent
7444 the @code{noreturn} attribute applies to all the functions
7445 declared; the @code{format} attribute only applies to @code{d1}.
7446
7447 An attribute specifier list may appear immediately before the comma,
7448 @code{=} or semicolon terminating the declaration of an identifier other
7449 than a function definition. Such attribute specifiers apply
7450 to the declared object or function. Where an
7451 assembler name for an object or function is specified (@pxref{Asm
7452 Labels}), the attribute must follow the @code{asm}
7453 specification.
7454
7455 An attribute specifier list may, in future, be permitted to appear after
7456 the declarator in a function definition (before any old-style parameter
7457 declarations or the function body).
7458
7459 Attribute specifiers may be mixed with type qualifiers appearing inside
7460 the @code{[]} of a parameter array declarator, in the C99 construct by
7461 which such qualifiers are applied to the pointer to which the array is
7462 implicitly converted. Such attribute specifiers apply to the pointer,
7463 not to the array, but at present this is not implemented and they are
7464 ignored.
7465
7466 An attribute specifier list may appear at the start of a nested
7467 declarator. At present, there are some limitations in this usage: the
7468 attributes correctly apply to the declarator, but for most individual
7469 attributes the semantics this implies are not implemented.
7470 When attribute specifiers follow the @code{*} of a pointer
7471 declarator, they may be mixed with any type qualifiers present.
7472 The following describes the formal semantics of this syntax. It makes the
7473 most sense if you are familiar with the formal specification of
7474 declarators in the ISO C standard.
7475
7476 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7477 D1}, where @code{T} contains declaration specifiers that specify a type
7478 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7479 contains an identifier @var{ident}. The type specified for @var{ident}
7480 for derived declarators whose type does not include an attribute
7481 specifier is as in the ISO C standard.
7482
7483 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7484 and the declaration @code{T D} specifies the type
7485 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7486 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7487 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7488
7489 If @code{D1} has the form @code{*
7490 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7491 declaration @code{T D} specifies the type
7492 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7493 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7494 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7495 @var{ident}.
7496
7497 For example,
7498
7499 @smallexample
7500 void (__attribute__((noreturn)) ****f) (void);
7501 @end smallexample
7502
7503 @noindent
7504 specifies the type ``pointer to pointer to pointer to pointer to
7505 non-returning function returning @code{void}''. As another example,
7506
7507 @smallexample
7508 char *__attribute__((aligned(8))) *f;
7509 @end smallexample
7510
7511 @noindent
7512 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7513 Note again that this does not work with most attributes; for example,
7514 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7515 is not yet supported.
7516
7517 For compatibility with existing code written for compiler versions that
7518 did not implement attributes on nested declarators, some laxity is
7519 allowed in the placing of attributes. If an attribute that only applies
7520 to types is applied to a declaration, it is treated as applying to
7521 the type of that declaration. If an attribute that only applies to
7522 declarations is applied to the type of a declaration, it is treated
7523 as applying to that declaration; and, for compatibility with code
7524 placing the attributes immediately before the identifier declared, such
7525 an attribute applied to a function return type is treated as
7526 applying to the function type, and such an attribute applied to an array
7527 element type is treated as applying to the array type. If an
7528 attribute that only applies to function types is applied to a
7529 pointer-to-function type, it is treated as applying to the pointer
7530 target type; if such an attribute is applied to a function return type
7531 that is not a pointer-to-function type, it is treated as applying
7532 to the function type.
7533
7534 @node Function Prototypes
7535 @section Prototypes and Old-Style Function Definitions
7536 @cindex function prototype declarations
7537 @cindex old-style function definitions
7538 @cindex promotion of formal parameters
7539
7540 GNU C extends ISO C to allow a function prototype to override a later
7541 old-style non-prototype definition. Consider the following example:
7542
7543 @smallexample
7544 /* @r{Use prototypes unless the compiler is old-fashioned.} */
7545 #ifdef __STDC__
7546 #define P(x) x
7547 #else
7548 #define P(x) ()
7549 #endif
7550
7551 /* @r{Prototype function declaration.} */
7552 int isroot P((uid_t));
7553
7554 /* @r{Old-style function definition.} */
7555 int
7556 isroot (x) /* @r{??? lossage here ???} */
7557 uid_t x;
7558 @{
7559 return x == 0;
7560 @}
7561 @end smallexample
7562
7563 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
7564 not allow this example, because subword arguments in old-style
7565 non-prototype definitions are promoted. Therefore in this example the
7566 function definition's argument is really an @code{int}, which does not
7567 match the prototype argument type of @code{short}.
7568
7569 This restriction of ISO C makes it hard to write code that is portable
7570 to traditional C compilers, because the programmer does not know
7571 whether the @code{uid_t} type is @code{short}, @code{int}, or
7572 @code{long}. Therefore, in cases like these GNU C allows a prototype
7573 to override a later old-style definition. More precisely, in GNU C, a
7574 function prototype argument type overrides the argument type specified
7575 by a later old-style definition if the former type is the same as the
7576 latter type before promotion. Thus in GNU C the above example is
7577 equivalent to the following:
7578
7579 @smallexample
7580 int isroot (uid_t);
7581
7582 int
7583 isroot (uid_t x)
7584 @{
7585 return x == 0;
7586 @}
7587 @end smallexample
7588
7589 @noindent
7590 GNU C++ does not support old-style function definitions, so this
7591 extension is irrelevant.
7592
7593 @node C++ Comments
7594 @section C++ Style Comments
7595 @cindex @code{//}
7596 @cindex C++ comments
7597 @cindex comments, C++ style
7598
7599 In GNU C, you may use C++ style comments, which start with @samp{//} and
7600 continue until the end of the line. Many other C implementations allow
7601 such comments, and they are included in the 1999 C standard. However,
7602 C++ style comments are not recognized if you specify an @option{-std}
7603 option specifying a version of ISO C before C99, or @option{-ansi}
7604 (equivalent to @option{-std=c90}).
7605
7606 @node Dollar Signs
7607 @section Dollar Signs in Identifier Names
7608 @cindex $
7609 @cindex dollar signs in identifier names
7610 @cindex identifier names, dollar signs in
7611
7612 In GNU C, you may normally use dollar signs in identifier names.
7613 This is because many traditional C implementations allow such identifiers.
7614 However, dollar signs in identifiers are not supported on a few target
7615 machines, typically because the target assembler does not allow them.
7616
7617 @node Character Escapes
7618 @section The Character @key{ESC} in Constants
7619
7620 You can use the sequence @samp{\e} in a string or character constant to
7621 stand for the ASCII character @key{ESC}.
7622
7623 @node Alignment
7624 @section Inquiring on Alignment of Types or Variables
7625 @cindex alignment
7626 @cindex type alignment
7627 @cindex variable alignment
7628
7629 The keyword @code{__alignof__} allows you to inquire about how an object
7630 is aligned, or the minimum alignment usually required by a type. Its
7631 syntax is just like @code{sizeof}.
7632
7633 For example, if the target machine requires a @code{double} value to be
7634 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7635 This is true on many RISC machines. On more traditional machine
7636 designs, @code{__alignof__ (double)} is 4 or even 2.
7637
7638 Some machines never actually require alignment; they allow reference to any
7639 data type even at an odd address. For these machines, @code{__alignof__}
7640 reports the smallest alignment that GCC gives the data type, usually as
7641 mandated by the target ABI.
7642
7643 If the operand of @code{__alignof__} is an lvalue rather than a type,
7644 its value is the required alignment for its type, taking into account
7645 any minimum alignment specified with GCC's @code{__attribute__}
7646 extension (@pxref{Variable Attributes}). For example, after this
7647 declaration:
7648
7649 @smallexample
7650 struct foo @{ int x; char y; @} foo1;
7651 @end smallexample
7652
7653 @noindent
7654 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7655 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7656
7657 It is an error to ask for the alignment of an incomplete type.
7658
7659
7660 @node Inline
7661 @section An Inline Function is As Fast As a Macro
7662 @cindex inline functions
7663 @cindex integrating function code
7664 @cindex open coding
7665 @cindex macros, inline alternative
7666
7667 By declaring a function inline, you can direct GCC to make
7668 calls to that function faster. One way GCC can achieve this is to
7669 integrate that function's code into the code for its callers. This
7670 makes execution faster by eliminating the function-call overhead; in
7671 addition, if any of the actual argument values are constant, their
7672 known values may permit simplifications at compile time so that not
7673 all of the inline function's code needs to be included. The effect on
7674 code size is less predictable; object code may be larger or smaller
7675 with function inlining, depending on the particular case. You can
7676 also direct GCC to try to integrate all ``simple enough'' functions
7677 into their callers with the option @option{-finline-functions}.
7678
7679 GCC implements three different semantics of declaring a function
7680 inline. One is available with @option{-std=gnu89} or
7681 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7682 on all inline declarations, another when
7683 @option{-std=c99}, @option{-std=c11},
7684 @option{-std=gnu99} or @option{-std=gnu11}
7685 (without @option{-fgnu89-inline}), and the third
7686 is used when compiling C++.
7687
7688 To declare a function inline, use the @code{inline} keyword in its
7689 declaration, like this:
7690
7691 @smallexample
7692 static inline int
7693 inc (int *a)
7694 @{
7695 return (*a)++;
7696 @}
7697 @end smallexample
7698
7699 If you are writing a header file to be included in ISO C90 programs, write
7700 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
7701
7702 The three types of inlining behave similarly in two important cases:
7703 when the @code{inline} keyword is used on a @code{static} function,
7704 like the example above, and when a function is first declared without
7705 using the @code{inline} keyword and then is defined with
7706 @code{inline}, like this:
7707
7708 @smallexample
7709 extern int inc (int *a);
7710 inline int
7711 inc (int *a)
7712 @{
7713 return (*a)++;
7714 @}
7715 @end smallexample
7716
7717 In both of these common cases, the program behaves the same as if you
7718 had not used the @code{inline} keyword, except for its speed.
7719
7720 @cindex inline functions, omission of
7721 @opindex fkeep-inline-functions
7722 When a function is both inline and @code{static}, if all calls to the
7723 function are integrated into the caller, and the function's address is
7724 never used, then the function's own assembler code is never referenced.
7725 In this case, GCC does not actually output assembler code for the
7726 function, unless you specify the option @option{-fkeep-inline-functions}.
7727 If there is a nonintegrated call, then the function is compiled to
7728 assembler code as usual. The function must also be compiled as usual if
7729 the program refers to its address, because that cannot be inlined.
7730
7731 @opindex Winline
7732 Note that certain usages in a function definition can make it unsuitable
7733 for inline substitution. Among these usages are: variadic functions,
7734 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7735 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7736 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7737 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
7738 function marked @code{inline} could not be substituted, and gives the
7739 reason for the failure.
7740
7741 @cindex automatic @code{inline} for C++ member fns
7742 @cindex @code{inline} automatic for C++ member fns
7743 @cindex member fns, automatically @code{inline}
7744 @cindex C++ member fns, automatically @code{inline}
7745 @opindex fno-default-inline
7746 As required by ISO C++, GCC considers member functions defined within
7747 the body of a class to be marked inline even if they are
7748 not explicitly declared with the @code{inline} keyword. You can
7749 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7750 Options,,Options Controlling C++ Dialect}.
7751
7752 GCC does not inline any functions when not optimizing unless you specify
7753 the @samp{always_inline} attribute for the function, like this:
7754
7755 @smallexample
7756 /* @r{Prototype.} */
7757 inline void foo (const char) __attribute__((always_inline));
7758 @end smallexample
7759
7760 The remainder of this section is specific to GNU C90 inlining.
7761
7762 @cindex non-static inline function
7763 When an inline function is not @code{static}, then the compiler must assume
7764 that there may be calls from other source files; since a global symbol can
7765 be defined only once in any program, the function must not be defined in
7766 the other source files, so the calls therein cannot be integrated.
7767 Therefore, a non-@code{static} inline function is always compiled on its
7768 own in the usual fashion.
7769
7770 If you specify both @code{inline} and @code{extern} in the function
7771 definition, then the definition is used only for inlining. In no case
7772 is the function compiled on its own, not even if you refer to its
7773 address explicitly. Such an address becomes an external reference, as
7774 if you had only declared the function, and had not defined it.
7775
7776 This combination of @code{inline} and @code{extern} has almost the
7777 effect of a macro. The way to use it is to put a function definition in
7778 a header file with these keywords, and put another copy of the
7779 definition (lacking @code{inline} and @code{extern}) in a library file.
7780 The definition in the header file causes most calls to the function
7781 to be inlined. If any uses of the function remain, they refer to
7782 the single copy in the library.
7783
7784 @node Volatiles
7785 @section When is a Volatile Object Accessed?
7786 @cindex accessing volatiles
7787 @cindex volatile read
7788 @cindex volatile write
7789 @cindex volatile access
7790
7791 C has the concept of volatile objects. These are normally accessed by
7792 pointers and used for accessing hardware or inter-thread
7793 communication. The standard encourages compilers to refrain from
7794 optimizations concerning accesses to volatile objects, but leaves it
7795 implementation defined as to what constitutes a volatile access. The
7796 minimum requirement is that at a sequence point all previous accesses
7797 to volatile objects have stabilized and no subsequent accesses have
7798 occurred. Thus an implementation is free to reorder and combine
7799 volatile accesses that occur between sequence points, but cannot do
7800 so for accesses across a sequence point. The use of volatile does
7801 not allow you to violate the restriction on updating objects multiple
7802 times between two sequence points.
7803
7804 Accesses to non-volatile objects are not ordered with respect to
7805 volatile accesses. You cannot use a volatile object as a memory
7806 barrier to order a sequence of writes to non-volatile memory. For
7807 instance:
7808
7809 @smallexample
7810 int *ptr = @var{something};
7811 volatile int vobj;
7812 *ptr = @var{something};
7813 vobj = 1;
7814 @end smallexample
7815
7816 @noindent
7817 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7818 that the write to @var{*ptr} occurs by the time the update
7819 of @var{vobj} happens. If you need this guarantee, you must use
7820 a stronger memory barrier such as:
7821
7822 @smallexample
7823 int *ptr = @var{something};
7824 volatile int vobj;
7825 *ptr = @var{something};
7826 asm volatile ("" : : : "memory");
7827 vobj = 1;
7828 @end smallexample
7829
7830 A scalar volatile object is read when it is accessed in a void context:
7831
7832 @smallexample
7833 volatile int *src = @var{somevalue};
7834 *src;
7835 @end smallexample
7836
7837 Such expressions are rvalues, and GCC implements this as a
7838 read of the volatile object being pointed to.
7839
7840 Assignments are also expressions and have an rvalue. However when
7841 assigning to a scalar volatile, the volatile object is not reread,
7842 regardless of whether the assignment expression's rvalue is used or
7843 not. If the assignment's rvalue is used, the value is that assigned
7844 to the volatile object. For instance, there is no read of @var{vobj}
7845 in all the following cases:
7846
7847 @smallexample
7848 int obj;
7849 volatile int vobj;
7850 vobj = @var{something};
7851 obj = vobj = @var{something};
7852 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7853 obj = (@var{something}, vobj = @var{anotherthing});
7854 @end smallexample
7855
7856 If you need to read the volatile object after an assignment has
7857 occurred, you must use a separate expression with an intervening
7858 sequence point.
7859
7860 As bit-fields are not individually addressable, volatile bit-fields may
7861 be implicitly read when written to, or when adjacent bit-fields are
7862 accessed. Bit-field operations may be optimized such that adjacent
7863 bit-fields are only partially accessed, if they straddle a storage unit
7864 boundary. For these reasons it is unwise to use volatile bit-fields to
7865 access hardware.
7866
7867 @node Using Assembly Language with C
7868 @section How to Use Inline Assembly Language in C Code
7869 @cindex @code{asm} keyword
7870 @cindex assembly language in C
7871 @cindex inline assembly language
7872 @cindex mixing assembly language and C
7873
7874 The @code{asm} keyword allows you to embed assembler instructions
7875 within C code. GCC provides two forms of inline @code{asm}
7876 statements. A @dfn{basic @code{asm}} statement is one with no
7877 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7878 statement (@pxref{Extended Asm}) includes one or more operands.
7879 The extended form is preferred for mixing C and assembly language
7880 within a function, but to include assembly language at
7881 top level you must use basic @code{asm}.
7882
7883 You can also use the @code{asm} keyword to override the assembler name
7884 for a C symbol, or to place a C variable in a specific register.
7885
7886 @menu
7887 * Basic Asm:: Inline assembler without operands.
7888 * Extended Asm:: Inline assembler with operands.
7889 * Constraints:: Constraints for @code{asm} operands
7890 * Asm Labels:: Specifying the assembler name to use for a C symbol.
7891 * Explicit Register Variables:: Defining variables residing in specified
7892 registers.
7893 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
7894 @end menu
7895
7896 @node Basic Asm
7897 @subsection Basic Asm --- Assembler Instructions Without Operands
7898 @cindex basic @code{asm}
7899 @cindex assembly language in C, basic
7900
7901 A basic @code{asm} statement has the following syntax:
7902
7903 @example
7904 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7905 @end example
7906
7907 The @code{asm} keyword is a GNU extension.
7908 When writing code that can be compiled with @option{-ansi} and the
7909 various @option{-std} options, use @code{__asm__} instead of
7910 @code{asm} (@pxref{Alternate Keywords}).
7911
7912 @subsubheading Qualifiers
7913 @table @code
7914 @item volatile
7915 The optional @code{volatile} qualifier has no effect.
7916 All basic @code{asm} blocks are implicitly volatile.
7917 @end table
7918
7919 @subsubheading Parameters
7920 @table @var
7921
7922 @item AssemblerInstructions
7923 This is a literal string that specifies the assembler code. The string can
7924 contain any instructions recognized by the assembler, including directives.
7925 GCC does not parse the assembler instructions themselves and
7926 does not know what they mean or even whether they are valid assembler input.
7927
7928 You may place multiple assembler instructions together in a single @code{asm}
7929 string, separated by the characters normally used in assembly code for the
7930 system. A combination that works in most places is a newline to break the
7931 line, plus a tab character (written as @samp{\n\t}).
7932 Some assemblers allow semicolons as a line separator. However,
7933 note that some assembler dialects use semicolons to start a comment.
7934 @end table
7935
7936 @subsubheading Remarks
7937 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
7938 smaller, safer, and more efficient code, and in most cases it is a
7939 better solution than basic @code{asm}. However, there are two
7940 situations where only basic @code{asm} can be used:
7941
7942 @itemize @bullet
7943 @item
7944 Extended @code{asm} statements have to be inside a C
7945 function, so to write inline assembly language at file scope (``top-level''),
7946 outside of C functions, you must use basic @code{asm}.
7947 You can use this technique to emit assembler directives,
7948 define assembly language macros that can be invoked elsewhere in the file,
7949 or write entire functions in assembly language.
7950
7951 @item
7952 Functions declared
7953 with the @code{naked} attribute also require basic @code{asm}
7954 (@pxref{Function Attributes}).
7955 @end itemize
7956
7957 Safely accessing C data and calling functions from basic @code{asm} is more
7958 complex than it may appear. To access C data, it is better to use extended
7959 @code{asm}.
7960
7961 Do not expect a sequence of @code{asm} statements to remain perfectly
7962 consecutive after compilation. If certain instructions need to remain
7963 consecutive in the output, put them in a single multi-instruction @code{asm}
7964 statement. Note that GCC's optimizers can move @code{asm} statements
7965 relative to other code, including across jumps.
7966
7967 @code{asm} statements may not perform jumps into other @code{asm} statements.
7968 GCC does not know about these jumps, and therefore cannot take
7969 account of them when deciding how to optimize. Jumps from @code{asm} to C
7970 labels are only supported in extended @code{asm}.
7971
7972 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7973 assembly code when optimizing. This can lead to unexpected duplicate
7974 symbol errors during compilation if your assembly code defines symbols or
7975 labels.
7976
7977 @strong{Warning:} The C standards do not specify semantics for @code{asm},
7978 making it a potential source of incompatibilities between compilers. These
7979 incompatibilities may not produce compiler warnings/errors.
7980
7981 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
7982 means there is no way to communicate to the compiler what is happening
7983 inside them. GCC has no visibility of symbols in the @code{asm} and may
7984 discard them as unreferenced. It also does not know about side effects of
7985 the assembler code, such as modifications to memory or registers. Unlike
7986 some compilers, GCC assumes that no changes to general purpose registers
7987 occur. This assumption may change in a future release.
7988
7989 To avoid complications from future changes to the semantics and the
7990 compatibility issues between compilers, consider replacing basic @code{asm}
7991 with extended @code{asm}. See
7992 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
7993 from basic asm to extended asm} for information about how to perform this
7994 conversion.
7995
7996 The compiler copies the assembler instructions in a basic @code{asm}
7997 verbatim to the assembly language output file, without
7998 processing dialects or any of the @samp{%} operators that are available with
7999 extended @code{asm}. This results in minor differences between basic
8000 @code{asm} strings and extended @code{asm} templates. For example, to refer to
8001 registers you might use @samp{%eax} in basic @code{asm} and
8002 @samp{%%eax} in extended @code{asm}.
8003
8004 On targets such as x86 that support multiple assembler dialects,
8005 all basic @code{asm} blocks use the assembler dialect specified by the
8006 @option{-masm} command-line option (@pxref{x86 Options}).
8007 Basic @code{asm} provides no
8008 mechanism to provide different assembler strings for different dialects.
8009
8010 For basic @code{asm} with non-empty assembler string GCC assumes
8011 the assembler block does not change any general purpose registers,
8012 but it may read or write any globally accessible variable.
8013
8014 Here is an example of basic @code{asm} for i386:
8015
8016 @example
8017 /* Note that this code will not compile with -masm=intel */
8018 #define DebugBreak() asm("int $3")
8019 @end example
8020
8021 @node Extended Asm
8022 @subsection Extended Asm - Assembler Instructions with C Expression Operands
8023 @cindex extended @code{asm}
8024 @cindex assembly language in C, extended
8025
8026 With extended @code{asm} you can read and write C variables from
8027 assembler and perform jumps from assembler code to C labels.
8028 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
8029 the operand parameters after the assembler template:
8030
8031 @example
8032 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
8033 : @var{OutputOperands}
8034 @r{[} : @var{InputOperands}
8035 @r{[} : @var{Clobbers} @r{]} @r{]})
8036
8037 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
8038 :
8039 : @var{InputOperands}
8040 : @var{Clobbers}
8041 : @var{GotoLabels})
8042 @end example
8043
8044 The @code{asm} keyword is a GNU extension.
8045 When writing code that can be compiled with @option{-ansi} and the
8046 various @option{-std} options, use @code{__asm__} instead of
8047 @code{asm} (@pxref{Alternate Keywords}).
8048
8049 @subsubheading Qualifiers
8050 @table @code
8051
8052 @item volatile
8053 The typical use of extended @code{asm} statements is to manipulate input
8054 values to produce output values. However, your @code{asm} statements may
8055 also produce side effects. If so, you may need to use the @code{volatile}
8056 qualifier to disable certain optimizations. @xref{Volatile}.
8057
8058 @item goto
8059 This qualifier informs the compiler that the @code{asm} statement may
8060 perform a jump to one of the labels listed in the @var{GotoLabels}.
8061 @xref{GotoLabels}.
8062 @end table
8063
8064 @subsubheading Parameters
8065 @table @var
8066 @item AssemblerTemplate
8067 This is a literal string that is the template for the assembler code. It is a
8068 combination of fixed text and tokens that refer to the input, output,
8069 and goto parameters. @xref{AssemblerTemplate}.
8070
8071 @item OutputOperands
8072 A comma-separated list of the C variables modified by the instructions in the
8073 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
8074
8075 @item InputOperands
8076 A comma-separated list of C expressions read by the instructions in the
8077 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
8078
8079 @item Clobbers
8080 A comma-separated list of registers or other values changed by the
8081 @var{AssemblerTemplate}, beyond those listed as outputs.
8082 An empty list is permitted. @xref{Clobbers}.
8083
8084 @item GotoLabels
8085 When you are using the @code{goto} form of @code{asm}, this section contains
8086 the list of all C labels to which the code in the
8087 @var{AssemblerTemplate} may jump.
8088 @xref{GotoLabels}.
8089
8090 @code{asm} statements may not perform jumps into other @code{asm} statements,
8091 only to the listed @var{GotoLabels}.
8092 GCC's optimizers do not know about other jumps; therefore they cannot take
8093 account of them when deciding how to optimize.
8094 @end table
8095
8096 The total number of input + output + goto operands is limited to 30.
8097
8098 @subsubheading Remarks
8099 The @code{asm} statement allows you to include assembly instructions directly
8100 within C code. This may help you to maximize performance in time-sensitive
8101 code or to access assembly instructions that are not readily available to C
8102 programs.
8103
8104 Note that extended @code{asm} statements must be inside a function. Only
8105 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
8106 Functions declared with the @code{naked} attribute also require basic
8107 @code{asm} (@pxref{Function Attributes}).
8108
8109 While the uses of @code{asm} are many and varied, it may help to think of an
8110 @code{asm} statement as a series of low-level instructions that convert input
8111 parameters to output parameters. So a simple (if not particularly useful)
8112 example for i386 using @code{asm} might look like this:
8113
8114 @example
8115 int src = 1;
8116 int dst;
8117
8118 asm ("mov %1, %0\n\t"
8119 "add $1, %0"
8120 : "=r" (dst)
8121 : "r" (src));
8122
8123 printf("%d\n", dst);
8124 @end example
8125
8126 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
8127
8128 @anchor{Volatile}
8129 @subsubsection Volatile
8130 @cindex volatile @code{asm}
8131 @cindex @code{asm} volatile
8132
8133 GCC's optimizers sometimes discard @code{asm} statements if they determine
8134 there is no need for the output variables. Also, the optimizers may move
8135 code out of loops if they believe that the code will always return the same
8136 result (i.e. none of its input values change between calls). Using the
8137 @code{volatile} qualifier disables these optimizations. @code{asm} statements
8138 that have no output operands, including @code{asm goto} statements,
8139 are implicitly volatile.
8140
8141 This i386 code demonstrates a case that does not use (or require) the
8142 @code{volatile} qualifier. If it is performing assertion checking, this code
8143 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
8144 unreferenced by any code. As a result, the optimizers can discard the
8145 @code{asm} statement, which in turn removes the need for the entire
8146 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
8147 isn't needed you allow the optimizers to produce the most efficient code
8148 possible.
8149
8150 @example
8151 void DoCheck(uint32_t dwSomeValue)
8152 @{
8153 uint32_t dwRes;
8154
8155 // Assumes dwSomeValue is not zero.
8156 asm ("bsfl %1,%0"
8157 : "=r" (dwRes)
8158 : "r" (dwSomeValue)
8159 : "cc");
8160
8161 assert(dwRes > 3);
8162 @}
8163 @end example
8164
8165 The next example shows a case where the optimizers can recognize that the input
8166 (@code{dwSomeValue}) never changes during the execution of the function and can
8167 therefore move the @code{asm} outside the loop to produce more efficient code.
8168 Again, using @code{volatile} disables this type of optimization.
8169
8170 @example
8171 void do_print(uint32_t dwSomeValue)
8172 @{
8173 uint32_t dwRes;
8174
8175 for (uint32_t x=0; x < 5; x++)
8176 @{
8177 // Assumes dwSomeValue is not zero.
8178 asm ("bsfl %1,%0"
8179 : "=r" (dwRes)
8180 : "r" (dwSomeValue)
8181 : "cc");
8182
8183 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
8184 @}
8185 @}
8186 @end example
8187
8188 The following example demonstrates a case where you need to use the
8189 @code{volatile} qualifier.
8190 It uses the x86 @code{rdtsc} instruction, which reads
8191 the computer's time-stamp counter. Without the @code{volatile} qualifier,
8192 the optimizers might assume that the @code{asm} block will always return the
8193 same value and therefore optimize away the second call.
8194
8195 @example
8196 uint64_t msr;
8197
8198 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
8199 "shl $32, %%rdx\n\t" // Shift the upper bits left.
8200 "or %%rdx, %0" // 'Or' in the lower bits.
8201 : "=a" (msr)
8202 :
8203 : "rdx");
8204
8205 printf("msr: %llx\n", msr);
8206
8207 // Do other work...
8208
8209 // Reprint the timestamp
8210 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
8211 "shl $32, %%rdx\n\t" // Shift the upper bits left.
8212 "or %%rdx, %0" // 'Or' in the lower bits.
8213 : "=a" (msr)
8214 :
8215 : "rdx");
8216
8217 printf("msr: %llx\n", msr);
8218 @end example
8219
8220 GCC's optimizers do not treat this code like the non-volatile code in the
8221 earlier examples. They do not move it out of loops or omit it on the
8222 assumption that the result from a previous call is still valid.
8223
8224 Note that the compiler can move even volatile @code{asm} instructions relative
8225 to other code, including across jump instructions. For example, on many
8226 targets there is a system register that controls the rounding mode of
8227 floating-point operations. Setting it with a volatile @code{asm}, as in the
8228 following PowerPC example, does not work reliably.
8229
8230 @example
8231 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8232 sum = x + y;
8233 @end example
8234
8235 The compiler may move the addition back before the volatile @code{asm}. To
8236 make it work as expected, add an artificial dependency to the @code{asm} by
8237 referencing a variable in the subsequent code, for example:
8238
8239 @example
8240 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8241 sum = x + y;
8242 @end example
8243
8244 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
8245 assembly code when optimizing. This can lead to unexpected duplicate symbol
8246 errors during compilation if your asm code defines symbols or labels.
8247 Using @samp{%=}
8248 (@pxref{AssemblerTemplate}) may help resolve this problem.
8249
8250 @anchor{AssemblerTemplate}
8251 @subsubsection Assembler Template
8252 @cindex @code{asm} assembler template
8253
8254 An assembler template is a literal string containing assembler instructions.
8255 The compiler replaces tokens in the template that refer
8256 to inputs, outputs, and goto labels,
8257 and then outputs the resulting string to the assembler. The
8258 string can contain any instructions recognized by the assembler, including
8259 directives. GCC does not parse the assembler instructions
8260 themselves and does not know what they mean or even whether they are valid
8261 assembler input. However, it does count the statements
8262 (@pxref{Size of an asm}).
8263
8264 You may place multiple assembler instructions together in a single @code{asm}
8265 string, separated by the characters normally used in assembly code for the
8266 system. A combination that works in most places is a newline to break the
8267 line, plus a tab character to move to the instruction field (written as
8268 @samp{\n\t}).
8269 Some assemblers allow semicolons as a line separator. However, note
8270 that some assembler dialects use semicolons to start a comment.
8271
8272 Do not expect a sequence of @code{asm} statements to remain perfectly
8273 consecutive after compilation, even when you are using the @code{volatile}
8274 qualifier. If certain instructions need to remain consecutive in the output,
8275 put them in a single multi-instruction asm statement.
8276
8277 Accessing data from C programs without using input/output operands (such as
8278 by using global symbols directly from the assembler template) may not work as
8279 expected. Similarly, calling functions directly from an assembler template
8280 requires a detailed understanding of the target assembler and ABI.
8281
8282 Since GCC does not parse the assembler template,
8283 it has no visibility of any
8284 symbols it references. This may result in GCC discarding those symbols as
8285 unreferenced unless they are also listed as input, output, or goto operands.
8286
8287 @subsubheading Special format strings
8288
8289 In addition to the tokens described by the input, output, and goto operands,
8290 these tokens have special meanings in the assembler template:
8291
8292 @table @samp
8293 @item %%
8294 Outputs a single @samp{%} into the assembler code.
8295
8296 @item %=
8297 Outputs a number that is unique to each instance of the @code{asm}
8298 statement in the entire compilation. This option is useful when creating local
8299 labels and referring to them multiple times in a single template that
8300 generates multiple assembler instructions.
8301
8302 @item %@{
8303 @itemx %|
8304 @itemx %@}
8305 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8306 into the assembler code. When unescaped, these characters have special
8307 meaning to indicate multiple assembler dialects, as described below.
8308 @end table
8309
8310 @subsubheading Multiple assembler dialects in @code{asm} templates
8311
8312 On targets such as x86, GCC supports multiple assembler dialects.
8313 The @option{-masm} option controls which dialect GCC uses as its
8314 default for inline assembler. The target-specific documentation for the
8315 @option{-masm} option contains the list of supported dialects, as well as the
8316 default dialect if the option is not specified. This information may be
8317 important to understand, since assembler code that works correctly when
8318 compiled using one dialect will likely fail if compiled using another.
8319 @xref{x86 Options}.
8320
8321 If your code needs to support multiple assembler dialects (for example, if
8322 you are writing public headers that need to support a variety of compilation
8323 options), use constructs of this form:
8324
8325 @example
8326 @{ dialect0 | dialect1 | dialect2... @}
8327 @end example
8328
8329 This construct outputs @code{dialect0}
8330 when using dialect #0 to compile the code,
8331 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
8332 braces than the number of dialects the compiler supports, the construct
8333 outputs nothing.
8334
8335 For example, if an x86 compiler supports two dialects
8336 (@samp{att}, @samp{intel}), an
8337 assembler template such as this:
8338
8339 @example
8340 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8341 @end example
8342
8343 @noindent
8344 is equivalent to one of
8345
8346 @example
8347 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
8348 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
8349 @end example
8350
8351 Using that same compiler, this code:
8352
8353 @example
8354 "xchg@{l@}\t@{%%@}ebx, %1"
8355 @end example
8356
8357 @noindent
8358 corresponds to either
8359
8360 @example
8361 "xchgl\t%%ebx, %1" @r{/* att dialect */}
8362 "xchg\tebx, %1" @r{/* intel dialect */}
8363 @end example
8364
8365 There is no support for nesting dialect alternatives.
8366
8367 @anchor{OutputOperands}
8368 @subsubsection Output Operands
8369 @cindex @code{asm} output operands
8370
8371 An @code{asm} statement has zero or more output operands indicating the names
8372 of C variables modified by the assembler code.
8373
8374 In this i386 example, @code{old} (referred to in the template string as
8375 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
8376 (@code{%2}) is an input:
8377
8378 @example
8379 bool old;
8380
8381 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8382 "sbb %0,%0" // Use the CF to calculate old.
8383 : "=r" (old), "+rm" (*Base)
8384 : "Ir" (Offset)
8385 : "cc");
8386
8387 return old;
8388 @end example
8389
8390 Operands are separated by commas. Each operand has this format:
8391
8392 @example
8393 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8394 @end example
8395
8396 @table @var
8397 @item asmSymbolicName
8398 Specifies a symbolic name for the operand.
8399 Reference the name in the assembler template
8400 by enclosing it in square brackets
8401 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8402 that contains the definition. Any valid C variable name is acceptable,
8403 including names already defined in the surrounding code. No two operands
8404 within the same @code{asm} statement can use the same symbolic name.
8405
8406 When not using an @var{asmSymbolicName}, use the (zero-based) position
8407 of the operand
8408 in the list of operands in the assembler template. For example if there are
8409 three output operands, use @samp{%0} in the template to refer to the first,
8410 @samp{%1} for the second, and @samp{%2} for the third.
8411
8412 @item constraint
8413 A string constant specifying constraints on the placement of the operand;
8414 @xref{Constraints}, for details.
8415
8416 Output constraints must begin with either @samp{=} (a variable overwriting an
8417 existing value) or @samp{+} (when reading and writing). When using
8418 @samp{=}, do not assume the location contains the existing value
8419 on entry to the @code{asm}, except
8420 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8421
8422 After the prefix, there must be one or more additional constraints
8423 (@pxref{Constraints}) that describe where the value resides. Common
8424 constraints include @samp{r} for register and @samp{m} for memory.
8425 When you list more than one possible location (for example, @code{"=rm"}),
8426 the compiler chooses the most efficient one based on the current context.
8427 If you list as many alternates as the @code{asm} statement allows, you permit
8428 the optimizers to produce the best possible code.
8429 If you must use a specific register, but your Machine Constraints do not
8430 provide sufficient control to select the specific register you want,
8431 local register variables may provide a solution (@pxref{Local Register
8432 Variables}).
8433
8434 @item cvariablename
8435 Specifies a C lvalue expression to hold the output, typically a variable name.
8436 The enclosing parentheses are a required part of the syntax.
8437
8438 @end table
8439
8440 When the compiler selects the registers to use to
8441 represent the output operands, it does not use any of the clobbered registers
8442 (@pxref{Clobbers}).
8443
8444 Output operand expressions must be lvalues. The compiler cannot check whether
8445 the operands have data types that are reasonable for the instruction being
8446 executed. For output expressions that are not directly addressable (for
8447 example a bit-field), the constraint must allow a register. In that case, GCC
8448 uses the register as the output of the @code{asm}, and then stores that
8449 register into the output.
8450
8451 Operands using the @samp{+} constraint modifier count as two operands
8452 (that is, both as input and output) towards the total maximum of 30 operands
8453 per @code{asm} statement.
8454
8455 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8456 operands that must not overlap an input. Otherwise,
8457 GCC may allocate the output operand in the same register as an unrelated
8458 input operand, on the assumption that the assembler code consumes its
8459 inputs before producing outputs. This assumption may be false if the assembler
8460 code actually consists of more than one instruction.
8461
8462 The same problem can occur if one output parameter (@var{a}) allows a register
8463 constraint and another output parameter (@var{b}) allows a memory constraint.
8464 The code generated by GCC to access the memory address in @var{b} can contain
8465 registers which @emph{might} be shared by @var{a}, and GCC considers those
8466 registers to be inputs to the asm. As above, GCC assumes that such input
8467 registers are consumed before any outputs are written. This assumption may
8468 result in incorrect behavior if the asm writes to @var{a} before using
8469 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8470 ensures that modifying @var{a} does not affect the address referenced by
8471 @var{b}. Otherwise, the location of @var{b}
8472 is undefined if @var{a} is modified before using @var{b}.
8473
8474 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8475 instead of simply @samp{%2}). Typically these qualifiers are hardware
8476 dependent. The list of supported modifiers for x86 is found at
8477 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8478
8479 If the C code that follows the @code{asm} makes no use of any of the output
8480 operands, use @code{volatile} for the @code{asm} statement to prevent the
8481 optimizers from discarding the @code{asm} statement as unneeded
8482 (see @ref{Volatile}).
8483
8484 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
8485 references the first output operand as @code{%0} (were there a second, it
8486 would be @code{%1}, etc). The number of the first input operand is one greater
8487 than that of the last output operand. In this i386 example, that makes
8488 @code{Mask} referenced as @code{%1}:
8489
8490 @example
8491 uint32_t Mask = 1234;
8492 uint32_t Index;
8493
8494 asm ("bsfl %1, %0"
8495 : "=r" (Index)
8496 : "r" (Mask)
8497 : "cc");
8498 @end example
8499
8500 That code overwrites the variable @code{Index} (@samp{=}),
8501 placing the value in a register (@samp{r}).
8502 Using the generic @samp{r} constraint instead of a constraint for a specific
8503 register allows the compiler to pick the register to use, which can result
8504 in more efficient code. This may not be possible if an assembler instruction
8505 requires a specific register.
8506
8507 The following i386 example uses the @var{asmSymbolicName} syntax.
8508 It produces the
8509 same result as the code above, but some may consider it more readable or more
8510 maintainable since reordering index numbers is not necessary when adding or
8511 removing operands. The names @code{aIndex} and @code{aMask}
8512 are only used in this example to emphasize which
8513 names get used where.
8514 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8515
8516 @example
8517 uint32_t Mask = 1234;
8518 uint32_t Index;
8519
8520 asm ("bsfl %[aMask], %[aIndex]"
8521 : [aIndex] "=r" (Index)
8522 : [aMask] "r" (Mask)
8523 : "cc");
8524 @end example
8525
8526 Here are some more examples of output operands.
8527
8528 @example
8529 uint32_t c = 1;
8530 uint32_t d;
8531 uint32_t *e = &c;
8532
8533 asm ("mov %[e], %[d]"
8534 : [d] "=rm" (d)
8535 : [e] "rm" (*e));
8536 @end example
8537
8538 Here, @code{d} may either be in a register or in memory. Since the compiler
8539 might already have the current value of the @code{uint32_t} location
8540 pointed to by @code{e}
8541 in a register, you can enable it to choose the best location
8542 for @code{d} by specifying both constraints.
8543
8544 @anchor{FlagOutputOperands}
8545 @subsubsection Flag Output Operands
8546 @cindex @code{asm} flag output operands
8547
8548 Some targets have a special register that holds the ``flags'' for the
8549 result of an operation or comparison. Normally, the contents of that
8550 register are either unmodifed by the asm, or the asm is considered to
8551 clobber the contents.
8552
8553 On some targets, a special form of output operand exists by which
8554 conditions in the flags register may be outputs of the asm. The set of
8555 conditions supported are target specific, but the general rule is that
8556 the output variable must be a scalar integer, and the value is boolean.
8557 When supported, the target defines the preprocessor symbol
8558 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8559
8560 Because of the special nature of the flag output operands, the constraint
8561 may not include alternatives.
8562
8563 Most often, the target has only one flags register, and thus is an implied
8564 operand of many instructions. In this case, the operand should not be
8565 referenced within the assembler template via @code{%0} etc, as there's
8566 no corresponding text in the assembly language.
8567
8568 @table @asis
8569 @item x86 family
8570 The flag output constraints for the x86 family are of the form
8571 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8572 conditions defined in the ISA manual for @code{j@var{cc}} or
8573 @code{set@var{cc}}.
8574
8575 @table @code
8576 @item a
8577 ``above'' or unsigned greater than
8578 @item ae
8579 ``above or equal'' or unsigned greater than or equal
8580 @item b
8581 ``below'' or unsigned less than
8582 @item be
8583 ``below or equal'' or unsigned less than or equal
8584 @item c
8585 carry flag set
8586 @item e
8587 @itemx z
8588 ``equal'' or zero flag set
8589 @item g
8590 signed greater than
8591 @item ge
8592 signed greater than or equal
8593 @item l
8594 signed less than
8595 @item le
8596 signed less than or equal
8597 @item o
8598 overflow flag set
8599 @item p
8600 parity flag set
8601 @item s
8602 sign flag set
8603 @item na
8604 @itemx nae
8605 @itemx nb
8606 @itemx nbe
8607 @itemx nc
8608 @itemx ne
8609 @itemx ng
8610 @itemx nge
8611 @itemx nl
8612 @itemx nle
8613 @itemx no
8614 @itemx np
8615 @itemx ns
8616 @itemx nz
8617 ``not'' @var{flag}, or inverted versions of those above
8618 @end table
8619
8620 @end table
8621
8622 @anchor{InputOperands}
8623 @subsubsection Input Operands
8624 @cindex @code{asm} input operands
8625 @cindex @code{asm} expressions
8626
8627 Input operands make values from C variables and expressions available to the
8628 assembly code.
8629
8630 Operands are separated by commas. Each operand has this format:
8631
8632 @example
8633 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8634 @end example
8635
8636 @table @var
8637 @item asmSymbolicName
8638 Specifies a symbolic name for the operand.
8639 Reference the name in the assembler template
8640 by enclosing it in square brackets
8641 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8642 that contains the definition. Any valid C variable name is acceptable,
8643 including names already defined in the surrounding code. No two operands
8644 within the same @code{asm} statement can use the same symbolic name.
8645
8646 When not using an @var{asmSymbolicName}, use the (zero-based) position
8647 of the operand
8648 in the list of operands in the assembler template. For example if there are
8649 two output operands and three inputs,
8650 use @samp{%2} in the template to refer to the first input operand,
8651 @samp{%3} for the second, and @samp{%4} for the third.
8652
8653 @item constraint
8654 A string constant specifying constraints on the placement of the operand;
8655 @xref{Constraints}, for details.
8656
8657 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8658 When you list more than one possible location (for example, @samp{"irm"}),
8659 the compiler chooses the most efficient one based on the current context.
8660 If you must use a specific register, but your Machine Constraints do not
8661 provide sufficient control to select the specific register you want,
8662 local register variables may provide a solution (@pxref{Local Register
8663 Variables}).
8664
8665 Input constraints can also be digits (for example, @code{"0"}). This indicates
8666 that the specified input must be in the same place as the output constraint
8667 at the (zero-based) index in the output constraint list.
8668 When using @var{asmSymbolicName} syntax for the output operands,
8669 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8670
8671 @item cexpression
8672 This is the C variable or expression being passed to the @code{asm} statement
8673 as input. The enclosing parentheses are a required part of the syntax.
8674
8675 @end table
8676
8677 When the compiler selects the registers to use to represent the input
8678 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8679
8680 If there are no output operands but there are input operands, place two
8681 consecutive colons where the output operands would go:
8682
8683 @example
8684 __asm__ ("some instructions"
8685 : /* No outputs. */
8686 : "r" (Offset / 8));
8687 @end example
8688
8689 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8690 (except for inputs tied to outputs). The compiler assumes that on exit from
8691 the @code{asm} statement these operands contain the same values as they
8692 had before executing the statement.
8693 It is @emph{not} possible to use clobbers
8694 to inform the compiler that the values in these inputs are changing. One
8695 common work-around is to tie the changing input variable to an output variable
8696 that never gets used. Note, however, that if the code that follows the
8697 @code{asm} statement makes no use of any of the output operands, the GCC
8698 optimizers may discard the @code{asm} statement as unneeded
8699 (see @ref{Volatile}).
8700
8701 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8702 instead of simply @samp{%2}). Typically these qualifiers are hardware
8703 dependent. The list of supported modifiers for x86 is found at
8704 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8705
8706 In this example using the fictitious @code{combine} instruction, the
8707 constraint @code{"0"} for input operand 1 says that it must occupy the same
8708 location as output operand 0. Only input operands may use numbers in
8709 constraints, and they must each refer to an output operand. Only a number (or
8710 the symbolic assembler name) in the constraint can guarantee that one operand
8711 is in the same place as another. The mere fact that @code{foo} is the value of
8712 both operands is not enough to guarantee that they are in the same place in
8713 the generated assembler code.
8714
8715 @example
8716 asm ("combine %2, %0"
8717 : "=r" (foo)
8718 : "0" (foo), "g" (bar));
8719 @end example
8720
8721 Here is an example using symbolic names.
8722
8723 @example
8724 asm ("cmoveq %1, %2, %[result]"
8725 : [result] "=r"(result)
8726 : "r" (test), "r" (new), "[result]" (old));
8727 @end example
8728
8729 @anchor{Clobbers}
8730 @subsubsection Clobbers
8731 @cindex @code{asm} clobbers
8732
8733 While the compiler is aware of changes to entries listed in the output
8734 operands, the inline @code{asm} code may modify more than just the outputs. For
8735 example, calculations may require additional registers, or the processor may
8736 overwrite a register as a side effect of a particular assembler instruction.
8737 In order to inform the compiler of these changes, list them in the clobber
8738 list. Clobber list items are either register names or the special clobbers
8739 (listed below). Each clobber list item is a string constant
8740 enclosed in double quotes and separated by commas.
8741
8742 Clobber descriptions may not in any way overlap with an input or output
8743 operand. For example, you may not have an operand describing a register class
8744 with one member when listing that register in the clobber list. Variables
8745 declared to live in specific registers (@pxref{Explicit Register
8746 Variables}) and used
8747 as @code{asm} input or output operands must have no part mentioned in the
8748 clobber description. In particular, there is no way to specify that input
8749 operands get modified without also specifying them as output operands.
8750
8751 When the compiler selects which registers to use to represent input and output
8752 operands, it does not use any of the clobbered registers. As a result,
8753 clobbered registers are available for any use in the assembler code.
8754
8755 Here is a realistic example for the VAX showing the use of clobbered
8756 registers:
8757
8758 @example
8759 asm volatile ("movc3 %0, %1, %2"
8760 : /* No outputs. */
8761 : "g" (from), "g" (to), "g" (count)
8762 : "r0", "r1", "r2", "r3", "r4", "r5");
8763 @end example
8764
8765 Also, there are two special clobber arguments:
8766
8767 @table @code
8768 @item "cc"
8769 The @code{"cc"} clobber indicates that the assembler code modifies the flags
8770 register. On some machines, GCC represents the condition codes as a specific
8771 hardware register; @code{"cc"} serves to name this register.
8772 On other machines, condition code handling is different,
8773 and specifying @code{"cc"} has no effect. But
8774 it is valid no matter what the target.
8775
8776 @item "memory"
8777 The @code{"memory"} clobber tells the compiler that the assembly code
8778 performs memory
8779 reads or writes to items other than those listed in the input and output
8780 operands (for example, accessing the memory pointed to by one of the input
8781 parameters). To ensure memory contains correct values, GCC may need to flush
8782 specific register values to memory before executing the @code{asm}. Further,
8783 the compiler does not assume that any values read from memory before an
8784 @code{asm} remain unchanged after that @code{asm}; it reloads them as
8785 needed.
8786 Using the @code{"memory"} clobber effectively forms a read/write
8787 memory barrier for the compiler.
8788
8789 Note that this clobber does not prevent the @emph{processor} from doing
8790 speculative reads past the @code{asm} statement. To prevent that, you need
8791 processor-specific fence instructions.
8792
8793 Flushing registers to memory has performance implications and may be an issue
8794 for time-sensitive code. You can use a trick to avoid this if the size of
8795 the memory being accessed is known at compile time. For example, if accessing
8796 ten bytes of a string, use a memory input like:
8797
8798 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8799
8800 @end table
8801
8802 @anchor{GotoLabels}
8803 @subsubsection Goto Labels
8804 @cindex @code{asm} goto labels
8805
8806 @code{asm goto} allows assembly code to jump to one or more C labels. The
8807 @var{GotoLabels} section in an @code{asm goto} statement contains
8808 a comma-separated
8809 list of all C labels to which the assembler code may jump. GCC assumes that
8810 @code{asm} execution falls through to the next statement (if this is not the
8811 case, consider using the @code{__builtin_unreachable} intrinsic after the
8812 @code{asm} statement). Optimization of @code{asm goto} may be improved by
8813 using the @code{hot} and @code{cold} label attributes (@pxref{Label
8814 Attributes}).
8815
8816 An @code{asm goto} statement cannot have outputs.
8817 This is due to an internal restriction of
8818 the compiler: control transfer instructions cannot have outputs.
8819 If the assembler code does modify anything, use the @code{"memory"} clobber
8820 to force the
8821 optimizers to flush all register values to memory and reload them if
8822 necessary after the @code{asm} statement.
8823
8824 Also note that an @code{asm goto} statement is always implicitly
8825 considered volatile.
8826
8827 To reference a label in the assembler template,
8828 prefix it with @samp{%l} (lowercase @samp{L}) followed
8829 by its (zero-based) position in @var{GotoLabels} plus the number of input
8830 operands. For example, if the @code{asm} has three inputs and references two
8831 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8832
8833 Alternately, you can reference labels using the actual C label name enclosed
8834 in brackets. For example, to reference a label named @code{carry}, you can
8835 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
8836 section when using this approach.
8837
8838 Here is an example of @code{asm goto} for i386:
8839
8840 @example
8841 asm goto (
8842 "btl %1, %0\n\t"
8843 "jc %l2"
8844 : /* No outputs. */
8845 : "r" (p1), "r" (p2)
8846 : "cc"
8847 : carry);
8848
8849 return 0;
8850
8851 carry:
8852 return 1;
8853 @end example
8854
8855 The following example shows an @code{asm goto} that uses a memory clobber.
8856
8857 @example
8858 int frob(int x)
8859 @{
8860 int y;
8861 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8862 : /* No outputs. */
8863 : "r"(x), "r"(&y)
8864 : "r5", "memory"
8865 : error);
8866 return y;
8867 error:
8868 return -1;
8869 @}
8870 @end example
8871
8872 @anchor{x86Operandmodifiers}
8873 @subsubsection x86 Operand Modifiers
8874
8875 References to input, output, and goto operands in the assembler template
8876 of extended @code{asm} statements can use
8877 modifiers to affect the way the operands are formatted in
8878 the code output to the assembler. For example, the
8879 following code uses the @samp{h} and @samp{b} modifiers for x86:
8880
8881 @example
8882 uint16_t num;
8883 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8884 @end example
8885
8886 @noindent
8887 These modifiers generate this assembler code:
8888
8889 @example
8890 xchg %ah, %al
8891 @end example
8892
8893 The rest of this discussion uses the following code for illustrative purposes.
8894
8895 @example
8896 int main()
8897 @{
8898 int iInt = 1;
8899
8900 top:
8901
8902 asm volatile goto ("some assembler instructions here"
8903 : /* No outputs. */
8904 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8905 : /* No clobbers. */
8906 : top);
8907 @}
8908 @end example
8909
8910 With no modifiers, this is what the output from the operands would be for the
8911 @samp{att} and @samp{intel} dialects of assembler:
8912
8913 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
8914 @headitem Operand @tab @samp{att} @tab @samp{intel}
8915 @item @code{%0}
8916 @tab @code{%eax}
8917 @tab @code{eax}
8918 @item @code{%1}
8919 @tab @code{$2}
8920 @tab @code{2}
8921 @item @code{%2}
8922 @tab @code{$.L2}
8923 @tab @code{OFFSET FLAT:.L2}
8924 @end multitable
8925
8926 The table below shows the list of supported modifiers and their effects.
8927
8928 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
8929 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
8930 @item @code{z}
8931 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8932 @tab @code{%z0}
8933 @tab @code{l}
8934 @tab
8935 @item @code{b}
8936 @tab Print the QImode name of the register.
8937 @tab @code{%b0}
8938 @tab @code{%al}
8939 @tab @code{al}
8940 @item @code{h}
8941 @tab Print the QImode name for a ``high'' register.
8942 @tab @code{%h0}
8943 @tab @code{%ah}
8944 @tab @code{ah}
8945 @item @code{w}
8946 @tab Print the HImode name of the register.
8947 @tab @code{%w0}
8948 @tab @code{%ax}
8949 @tab @code{ax}
8950 @item @code{k}
8951 @tab Print the SImode name of the register.
8952 @tab @code{%k0}
8953 @tab @code{%eax}
8954 @tab @code{eax}
8955 @item @code{q}
8956 @tab Print the DImode name of the register.
8957 @tab @code{%q0}
8958 @tab @code{%rax}
8959 @tab @code{rax}
8960 @item @code{l}
8961 @tab Print the label name with no punctuation.
8962 @tab @code{%l2}
8963 @tab @code{.L2}
8964 @tab @code{.L2}
8965 @item @code{c}
8966 @tab Require a constant operand and print the constant expression with no punctuation.
8967 @tab @code{%c1}
8968 @tab @code{2}
8969 @tab @code{2}
8970 @end multitable
8971
8972 @anchor{x86floatingpointasmoperands}
8973 @subsubsection x86 Floating-Point @code{asm} Operands
8974
8975 On x86 targets, there are several rules on the usage of stack-like registers
8976 in the operands of an @code{asm}. These rules apply only to the operands
8977 that are stack-like registers:
8978
8979 @enumerate
8980 @item
8981 Given a set of input registers that die in an @code{asm}, it is
8982 necessary to know which are implicitly popped by the @code{asm}, and
8983 which must be explicitly popped by GCC@.
8984
8985 An input register that is implicitly popped by the @code{asm} must be
8986 explicitly clobbered, unless it is constrained to match an
8987 output operand.
8988
8989 @item
8990 For any input register that is implicitly popped by an @code{asm}, it is
8991 necessary to know how to adjust the stack to compensate for the pop.
8992 If any non-popped input is closer to the top of the reg-stack than
8993 the implicitly popped register, it would not be possible to know what the
8994 stack looked like---it's not clear how the rest of the stack ``slides
8995 up''.
8996
8997 All implicitly popped input registers must be closer to the top of
8998 the reg-stack than any input that is not implicitly popped.
8999
9000 It is possible that if an input dies in an @code{asm}, the compiler might
9001 use the input register for an output reload. Consider this example:
9002
9003 @smallexample
9004 asm ("foo" : "=t" (a) : "f" (b));
9005 @end smallexample
9006
9007 @noindent
9008 This code says that input @code{b} is not popped by the @code{asm}, and that
9009 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
9010 deeper after the @code{asm} than it was before. But, it is possible that
9011 reload may think that it can use the same register for both the input and
9012 the output.
9013
9014 To prevent this from happening,
9015 if any input operand uses the @samp{f} constraint, all output register
9016 constraints must use the @samp{&} early-clobber modifier.
9017
9018 The example above is correctly written as:
9019
9020 @smallexample
9021 asm ("foo" : "=&t" (a) : "f" (b));
9022 @end smallexample
9023
9024 @item
9025 Some operands need to be in particular places on the stack. All
9026 output operands fall in this category---GCC has no other way to
9027 know which registers the outputs appear in unless you indicate
9028 this in the constraints.
9029
9030 Output operands must specifically indicate which register an output
9031 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
9032 constraints must select a class with a single register.
9033
9034 @item
9035 Output operands may not be ``inserted'' between existing stack registers.
9036 Since no 387 opcode uses a read/write operand, all output operands
9037 are dead before the @code{asm}, and are pushed by the @code{asm}.
9038 It makes no sense to push anywhere but the top of the reg-stack.
9039
9040 Output operands must start at the top of the reg-stack: output
9041 operands may not ``skip'' a register.
9042
9043 @item
9044 Some @code{asm} statements may need extra stack space for internal
9045 calculations. This can be guaranteed by clobbering stack registers
9046 unrelated to the inputs and outputs.
9047
9048 @end enumerate
9049
9050 This @code{asm}
9051 takes one input, which is internally popped, and produces two outputs.
9052
9053 @smallexample
9054 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
9055 @end smallexample
9056
9057 @noindent
9058 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
9059 and replaces them with one output. The @code{st(1)} clobber is necessary
9060 for the compiler to know that @code{fyl2xp1} pops both inputs.
9061
9062 @smallexample
9063 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
9064 @end smallexample
9065
9066 @lowersections
9067 @include md.texi
9068 @raisesections
9069
9070 @node Asm Labels
9071 @subsection Controlling Names Used in Assembler Code
9072 @cindex assembler names for identifiers
9073 @cindex names used in assembler code
9074 @cindex identifiers, names in assembler code
9075
9076 You can specify the name to be used in the assembler code for a C
9077 function or variable by writing the @code{asm} (or @code{__asm__})
9078 keyword after the declarator.
9079 It is up to you to make sure that the assembler names you choose do not
9080 conflict with any other assembler symbols, or reference registers.
9081
9082 @subsubheading Assembler names for data:
9083
9084 This sample shows how to specify the assembler name for data:
9085
9086 @smallexample
9087 int foo asm ("myfoo") = 2;
9088 @end smallexample
9089
9090 @noindent
9091 This specifies that the name to be used for the variable @code{foo} in
9092 the assembler code should be @samp{myfoo} rather than the usual
9093 @samp{_foo}.
9094
9095 On systems where an underscore is normally prepended to the name of a C
9096 variable, this feature allows you to define names for the
9097 linker that do not start with an underscore.
9098
9099 GCC does not support using this feature with a non-static local variable
9100 since such variables do not have assembler names. If you are
9101 trying to put the variable in a particular register, see
9102 @ref{Explicit Register Variables}.
9103
9104 @subsubheading Assembler names for functions:
9105
9106 To specify the assembler name for functions, write a declaration for the
9107 function before its definition and put @code{asm} there, like this:
9108
9109 @smallexample
9110 int func (int x, int y) asm ("MYFUNC");
9111
9112 int func (int x, int y)
9113 @{
9114 /* @r{@dots{}} */
9115 @end smallexample
9116
9117 @noindent
9118 This specifies that the name to be used for the function @code{func} in
9119 the assembler code should be @code{MYFUNC}.
9120
9121 @node Explicit Register Variables
9122 @subsection Variables in Specified Registers
9123 @anchor{Explicit Reg Vars}
9124 @cindex explicit register variables
9125 @cindex variables in specified registers
9126 @cindex specified registers
9127
9128 GNU C allows you to associate specific hardware registers with C
9129 variables. In almost all cases, allowing the compiler to assign
9130 registers produces the best code. However under certain unusual
9131 circumstances, more precise control over the variable storage is
9132 required.
9133
9134 Both global and local variables can be associated with a register. The
9135 consequences of performing this association are very different between
9136 the two, as explained in the sections below.
9137
9138 @menu
9139 * Global Register Variables:: Variables declared at global scope.
9140 * Local Register Variables:: Variables declared within a function.
9141 @end menu
9142
9143 @node Global Register Variables
9144 @subsubsection Defining Global Register Variables
9145 @anchor{Global Reg Vars}
9146 @cindex global register variables
9147 @cindex registers, global variables in
9148 @cindex registers, global allocation
9149
9150 You can define a global register variable and associate it with a specified
9151 register like this:
9152
9153 @smallexample
9154 register int *foo asm ("r12");
9155 @end smallexample
9156
9157 @noindent
9158 Here @code{r12} is the name of the register that should be used. Note that
9159 this is the same syntax used for defining local register variables, but for
9160 a global variable the declaration appears outside a function. The
9161 @code{register} keyword is required, and cannot be combined with
9162 @code{static}. The register name must be a valid register name for the
9163 target platform.
9164
9165 Registers are a scarce resource on most systems and allowing the
9166 compiler to manage their usage usually results in the best code. However,
9167 under special circumstances it can make sense to reserve some globally.
9168 For example this may be useful in programs such as programming language
9169 interpreters that have a couple of global variables that are accessed
9170 very often.
9171
9172 After defining a global register variable, for the current compilation
9173 unit:
9174
9175 @itemize @bullet
9176 @item The register is reserved entirely for this use, and will not be
9177 allocated for any other purpose.
9178 @item The register is not saved and restored by any functions.
9179 @item Stores into this register are never deleted even if they appear to be
9180 dead, but references may be deleted, moved or simplified.
9181 @end itemize
9182
9183 Note that these points @emph{only} apply to code that is compiled with the
9184 definition. The behavior of code that is merely linked in (for example
9185 code from libraries) is not affected.
9186
9187 If you want to recompile source files that do not actually use your global
9188 register variable so they do not use the specified register for any other
9189 purpose, you need not actually add the global register declaration to
9190 their source code. It suffices to specify the compiler option
9191 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
9192 register.
9193
9194 @subsubheading Declaring the variable
9195
9196 Global register variables can not have initial values, because an
9197 executable file has no means to supply initial contents for a register.
9198
9199 When selecting a register, choose one that is normally saved and
9200 restored by function calls on your machine. This ensures that code
9201 which is unaware of this reservation (such as library routines) will
9202 restore it before returning.
9203
9204 On machines with register windows, be sure to choose a global
9205 register that is not affected magically by the function call mechanism.
9206
9207 @subsubheading Using the variable
9208
9209 @cindex @code{qsort}, and global register variables
9210 When calling routines that are not aware of the reservation, be
9211 cautious if those routines call back into code which uses them. As an
9212 example, if you call the system library version of @code{qsort}, it may
9213 clobber your registers during execution, but (if you have selected
9214 appropriate registers) it will restore them before returning. However
9215 it will @emph{not} restore them before calling @code{qsort}'s comparison
9216 function. As a result, global values will not reliably be available to
9217 the comparison function unless the @code{qsort} function itself is rebuilt.
9218
9219 Similarly, it is not safe to access the global register variables from signal
9220 handlers or from more than one thread of control. Unless you recompile
9221 them specially for the task at hand, the system library routines may
9222 temporarily use the register for other things.
9223
9224 @cindex register variable after @code{longjmp}
9225 @cindex global register after @code{longjmp}
9226 @cindex value after @code{longjmp}
9227 @findex longjmp
9228 @findex setjmp
9229 On most machines, @code{longjmp} restores to each global register
9230 variable the value it had at the time of the @code{setjmp}. On some
9231 machines, however, @code{longjmp} does not change the value of global
9232 register variables. To be portable, the function that called @code{setjmp}
9233 should make other arrangements to save the values of the global register
9234 variables, and to restore them in a @code{longjmp}. This way, the same
9235 thing happens regardless of what @code{longjmp} does.
9236
9237 Eventually there may be a way of asking the compiler to choose a register
9238 automatically, but first we need to figure out how it should choose and
9239 how to enable you to guide the choice. No solution is evident.
9240
9241 @node Local Register Variables
9242 @subsubsection Specifying Registers for Local Variables
9243 @anchor{Local Reg Vars}
9244 @cindex local variables, specifying registers
9245 @cindex specifying registers for local variables
9246 @cindex registers for local variables
9247
9248 You can define a local register variable and associate it with a specified
9249 register like this:
9250
9251 @smallexample
9252 register int *foo asm ("r12");
9253 @end smallexample
9254
9255 @noindent
9256 Here @code{r12} is the name of the register that should be used. Note
9257 that this is the same syntax used for defining global register variables,
9258 but for a local variable the declaration appears within a function. The
9259 @code{register} keyword is required, and cannot be combined with
9260 @code{static}. The register name must be a valid register name for the
9261 target platform.
9262
9263 As with global register variables, it is recommended that you choose
9264 a register that is normally saved and restored by function calls on your
9265 machine, so that calls to library routines will not clobber it.
9266
9267 The only supported use for this feature is to specify registers
9268 for input and output operands when calling Extended @code{asm}
9269 (@pxref{Extended Asm}). This may be necessary if the constraints for a
9270 particular machine don't provide sufficient control to select the desired
9271 register. To force an operand into a register, create a local variable
9272 and specify the register name after the variable's declaration. Then use
9273 the local variable for the @code{asm} operand and specify any constraint
9274 letter that matches the register:
9275
9276 @smallexample
9277 register int *p1 asm ("r0") = @dots{};
9278 register int *p2 asm ("r1") = @dots{};
9279 register int *result asm ("r0");
9280 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9281 @end smallexample
9282
9283 @emph{Warning:} In the above example, be aware that a register (for example
9284 @code{r0}) can be call-clobbered by subsequent code, including function
9285 calls and library calls for arithmetic operators on other variables (for
9286 example the initialization of @code{p2}). In this case, use temporary
9287 variables for expressions between the register assignments:
9288
9289 @smallexample
9290 int t1 = @dots{};
9291 register int *p1 asm ("r0") = @dots{};
9292 register int *p2 asm ("r1") = t1;
9293 register int *result asm ("r0");
9294 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9295 @end smallexample
9296
9297 Defining a register variable does not reserve the register. Other than
9298 when invoking the Extended @code{asm}, the contents of the specified
9299 register are not guaranteed. For this reason, the following uses
9300 are explicitly @emph{not} supported. If they appear to work, it is only
9301 happenstance, and may stop working as intended due to (seemingly)
9302 unrelated changes in surrounding code, or even minor changes in the
9303 optimization of a future version of gcc:
9304
9305 @itemize @bullet
9306 @item Passing parameters to or from Basic @code{asm}
9307 @item Passing parameters to or from Extended @code{asm} without using input
9308 or output operands.
9309 @item Passing parameters to or from routines written in assembler (or
9310 other languages) using non-standard calling conventions.
9311 @end itemize
9312
9313 Some developers use Local Register Variables in an attempt to improve
9314 gcc's allocation of registers, especially in large functions. In this
9315 case the register name is essentially a hint to the register allocator.
9316 While in some instances this can generate better code, improvements are
9317 subject to the whims of the allocator/optimizers. Since there are no
9318 guarantees that your improvements won't be lost, this usage of Local
9319 Register Variables is discouraged.
9320
9321 On the MIPS platform, there is related use for local register variables
9322 with slightly different characteristics (@pxref{MIPS Coprocessors,,
9323 Defining coprocessor specifics for MIPS targets, gccint,
9324 GNU Compiler Collection (GCC) Internals}).
9325
9326 @node Size of an asm
9327 @subsection Size of an @code{asm}
9328
9329 Some targets require that GCC track the size of each instruction used
9330 in order to generate correct code. Because the final length of the
9331 code produced by an @code{asm} statement is only known by the
9332 assembler, GCC must make an estimate as to how big it will be. It
9333 does this by counting the number of instructions in the pattern of the
9334 @code{asm} and multiplying that by the length of the longest
9335 instruction supported by that processor. (When working out the number
9336 of instructions, it assumes that any occurrence of a newline or of
9337 whatever statement separator character is supported by the assembler --
9338 typically @samp{;} --- indicates the end of an instruction.)
9339
9340 Normally, GCC's estimate is adequate to ensure that correct
9341 code is generated, but it is possible to confuse the compiler if you use
9342 pseudo instructions or assembler macros that expand into multiple real
9343 instructions, or if you use assembler directives that expand to more
9344 space in the object file than is needed for a single instruction.
9345 If this happens then the assembler may produce a diagnostic saying that
9346 a label is unreachable.
9347
9348 @node Alternate Keywords
9349 @section Alternate Keywords
9350 @cindex alternate keywords
9351 @cindex keywords, alternate
9352
9353 @option{-ansi} and the various @option{-std} options disable certain
9354 keywords. This causes trouble when you want to use GNU C extensions, or
9355 a general-purpose header file that should be usable by all programs,
9356 including ISO C programs. The keywords @code{asm}, @code{typeof} and
9357 @code{inline} are not available in programs compiled with
9358 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9359 program compiled with @option{-std=c99} or @option{-std=c11}). The
9360 ISO C99 keyword
9361 @code{restrict} is only available when @option{-std=gnu99} (which will
9362 eventually be the default) or @option{-std=c99} (or the equivalent
9363 @option{-std=iso9899:1999}), or an option for a later standard
9364 version, is used.
9365
9366 The way to solve these problems is to put @samp{__} at the beginning and
9367 end of each problematical keyword. For example, use @code{__asm__}
9368 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9369
9370 Other C compilers won't accept these alternative keywords; if you want to
9371 compile with another compiler, you can define the alternate keywords as
9372 macros to replace them with the customary keywords. It looks like this:
9373
9374 @smallexample
9375 #ifndef __GNUC__
9376 #define __asm__ asm
9377 #endif
9378 @end smallexample
9379
9380 @findex __extension__
9381 @opindex pedantic
9382 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9383 You can
9384 prevent such warnings within one expression by writing
9385 @code{__extension__} before the expression. @code{__extension__} has no
9386 effect aside from this.
9387
9388 @node Incomplete Enums
9389 @section Incomplete @code{enum} Types
9390
9391 You can define an @code{enum} tag without specifying its possible values.
9392 This results in an incomplete type, much like what you get if you write
9393 @code{struct foo} without describing the elements. A later declaration
9394 that does specify the possible values completes the type.
9395
9396 You cannot allocate variables or storage using the type while it is
9397 incomplete. However, you can work with pointers to that type.
9398
9399 This extension may not be very useful, but it makes the handling of
9400 @code{enum} more consistent with the way @code{struct} and @code{union}
9401 are handled.
9402
9403 This extension is not supported by GNU C++.
9404
9405 @node Function Names
9406 @section Function Names as Strings
9407 @cindex @code{__func__} identifier
9408 @cindex @code{__FUNCTION__} identifier
9409 @cindex @code{__PRETTY_FUNCTION__} identifier
9410
9411 GCC provides three magic constants that hold the name of the current
9412 function as a string. In C++11 and later modes, all three are treated
9413 as constant expressions and can be used in @code{constexpr} constexts.
9414 The first of these constants is @code{__func__}, which is part of
9415 the C99 standard:
9416
9417 The identifier @code{__func__} is implicitly declared by the translator
9418 as if, immediately following the opening brace of each function
9419 definition, the declaration
9420
9421 @smallexample
9422 static const char __func__[] = "function-name";
9423 @end smallexample
9424
9425 @noindent
9426 appeared, where function-name is the name of the lexically-enclosing
9427 function. This name is the unadorned name of the function. As an
9428 extension, at file (or, in C++, namespace scope), @code{__func__}
9429 evaluates to the empty string.
9430
9431 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9432 backward compatibility with old versions of GCC.
9433
9434 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9435 @code{__func__}, except that at file (or, in C++, namespace scope),
9436 it evaluates to the string @code{"top level"}. In addition, in C++,
9437 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9438 well as its bare name. For example, this program:
9439
9440 @smallexample
9441 extern "C" int printf (const char *, ...);
9442
9443 class a @{
9444 public:
9445 void sub (int i)
9446 @{
9447 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9448 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9449 @}
9450 @};
9451
9452 int
9453 main (void)
9454 @{
9455 a ax;
9456 ax.sub (0);
9457 return 0;
9458 @}
9459 @end smallexample
9460
9461 @noindent
9462 gives this output:
9463
9464 @smallexample
9465 __FUNCTION__ = sub
9466 __PRETTY_FUNCTION__ = void a::sub(int)
9467 @end smallexample
9468
9469 These identifiers are variables, not preprocessor macros, and may not
9470 be used to initialize @code{char} arrays or be concatenated with string
9471 literals.
9472
9473 @node Return Address
9474 @section Getting the Return or Frame Address of a Function
9475
9476 These functions may be used to get information about the callers of a
9477 function.
9478
9479 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9480 This function returns the return address of the current function, or of
9481 one of its callers. The @var{level} argument is number of frames to
9482 scan up the call stack. A value of @code{0} yields the return address
9483 of the current function, a value of @code{1} yields the return address
9484 of the caller of the current function, and so forth. When inlining
9485 the expected behavior is that the function returns the address of
9486 the function that is returned to. To work around this behavior use
9487 the @code{noinline} function attribute.
9488
9489 The @var{level} argument must be a constant integer.
9490
9491 On some machines it may be impossible to determine the return address of
9492 any function other than the current one; in such cases, or when the top
9493 of the stack has been reached, this function returns @code{0} or a
9494 random value. In addition, @code{__builtin_frame_address} may be used
9495 to determine if the top of the stack has been reached.
9496
9497 Additional post-processing of the returned value may be needed, see
9498 @code{__builtin_extract_return_addr}.
9499
9500 Calling this function with a nonzero argument can have unpredictable
9501 effects, including crashing the calling program. As a result, calls
9502 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9503 option is in effect. Such calls should only be made in debugging
9504 situations.
9505 @end deftypefn
9506
9507 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9508 The address as returned by @code{__builtin_return_address} may have to be fed
9509 through this function to get the actual encoded address. For example, on the
9510 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9511 platforms an offset has to be added for the true next instruction to be
9512 executed.
9513
9514 If no fixup is needed, this function simply passes through @var{addr}.
9515 @end deftypefn
9516
9517 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9518 This function does the reverse of @code{__builtin_extract_return_addr}.
9519 @end deftypefn
9520
9521 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9522 This function is similar to @code{__builtin_return_address}, but it
9523 returns the address of the function frame rather than the return address
9524 of the function. Calling @code{__builtin_frame_address} with a value of
9525 @code{0} yields the frame address of the current function, a value of
9526 @code{1} yields the frame address of the caller of the current function,
9527 and so forth.
9528
9529 The frame is the area on the stack that holds local variables and saved
9530 registers. The frame address is normally the address of the first word
9531 pushed on to the stack by the function. However, the exact definition
9532 depends upon the processor and the calling convention. If the processor
9533 has a dedicated frame pointer register, and the function has a frame,
9534 then @code{__builtin_frame_address} returns the value of the frame
9535 pointer register.
9536
9537 On some machines it may be impossible to determine the frame address of
9538 any function other than the current one; in such cases, or when the top
9539 of the stack has been reached, this function returns @code{0} if
9540 the first frame pointer is properly initialized by the startup code.
9541
9542 Calling this function with a nonzero argument can have unpredictable
9543 effects, including crashing the calling program. As a result, calls
9544 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9545 option is in effect. Such calls should only be made in debugging
9546 situations.
9547 @end deftypefn
9548
9549 @node Vector Extensions
9550 @section Using Vector Instructions through Built-in Functions
9551
9552 On some targets, the instruction set contains SIMD vector instructions which
9553 operate on multiple values contained in one large register at the same time.
9554 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9555 this way.
9556
9557 The first step in using these extensions is to provide the necessary data
9558 types. This should be done using an appropriate @code{typedef}:
9559
9560 @smallexample
9561 typedef int v4si __attribute__ ((vector_size (16)));
9562 @end smallexample
9563
9564 @noindent
9565 The @code{int} type specifies the base type, while the attribute specifies
9566 the vector size for the variable, measured in bytes. For example, the
9567 declaration above causes the compiler to set the mode for the @code{v4si}
9568 type to be 16 bytes wide and divided into @code{int} sized units. For
9569 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9570 corresponding mode of @code{foo} is @acronym{V4SI}.
9571
9572 The @code{vector_size} attribute is only applicable to integral and
9573 float scalars, although arrays, pointers, and function return values
9574 are allowed in conjunction with this construct. Only sizes that are
9575 a power of two are currently allowed.
9576
9577 All the basic integer types can be used as base types, both as signed
9578 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9579 @code{long long}. In addition, @code{float} and @code{double} can be
9580 used to build floating-point vector types.
9581
9582 Specifying a combination that is not valid for the current architecture
9583 causes GCC to synthesize the instructions using a narrower mode.
9584 For example, if you specify a variable of type @code{V4SI} and your
9585 architecture does not allow for this specific SIMD type, GCC
9586 produces code that uses 4 @code{SIs}.
9587
9588 The types defined in this manner can be used with a subset of normal C
9589 operations. Currently, GCC allows using the following operators
9590 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9591
9592 The operations behave like C++ @code{valarrays}. Addition is defined as
9593 the addition of the corresponding elements of the operands. For
9594 example, in the code below, each of the 4 elements in @var{a} is
9595 added to the corresponding 4 elements in @var{b} and the resulting
9596 vector is stored in @var{c}.
9597
9598 @smallexample
9599 typedef int v4si __attribute__ ((vector_size (16)));
9600
9601 v4si a, b, c;
9602
9603 c = a + b;
9604 @end smallexample
9605
9606 Subtraction, multiplication, division, and the logical operations
9607 operate in a similar manner. Likewise, the result of using the unary
9608 minus or complement operators on a vector type is a vector whose
9609 elements are the negative or complemented values of the corresponding
9610 elements in the operand.
9611
9612 It is possible to use shifting operators @code{<<}, @code{>>} on
9613 integer-type vectors. The operation is defined as following: @code{@{a0,
9614 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9615 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9616 elements.
9617
9618 For convenience, it is allowed to use a binary vector operation
9619 where one operand is a scalar. In that case the compiler transforms
9620 the scalar operand into a vector where each element is the scalar from
9621 the operation. The transformation happens only if the scalar could be
9622 safely converted to the vector-element type.
9623 Consider the following code.
9624
9625 @smallexample
9626 typedef int v4si __attribute__ ((vector_size (16)));
9627
9628 v4si a, b, c;
9629 long l;
9630
9631 a = b + 1; /* a = b + @{1,1,1,1@}; */
9632 a = 2 * b; /* a = @{2,2,2,2@} * b; */
9633
9634 a = l + a; /* Error, cannot convert long to int. */
9635 @end smallexample
9636
9637 Vectors can be subscripted as if the vector were an array with
9638 the same number of elements and base type. Out of bound accesses
9639 invoke undefined behavior at run time. Warnings for out of bound
9640 accesses for vector subscription can be enabled with
9641 @option{-Warray-bounds}.
9642
9643 Vector comparison is supported with standard comparison
9644 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9645 vector expressions of integer-type or real-type. Comparison between
9646 integer-type vectors and real-type vectors are not supported. The
9647 result of the comparison is a vector of the same width and number of
9648 elements as the comparison operands with a signed integral element
9649 type.
9650
9651 Vectors are compared element-wise producing 0 when comparison is false
9652 and -1 (constant of the appropriate type where all bits are set)
9653 otherwise. Consider the following example.
9654
9655 @smallexample
9656 typedef int v4si __attribute__ ((vector_size (16)));
9657
9658 v4si a = @{1,2,3,4@};
9659 v4si b = @{3,2,1,4@};
9660 v4si c;
9661
9662 c = a > b; /* The result would be @{0, 0,-1, 0@} */
9663 c = a == b; /* The result would be @{0,-1, 0,-1@} */
9664 @end smallexample
9665
9666 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9667 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9668 integer vector with the same number of elements of the same size as @code{b}
9669 and @code{c}, computes all three arguments and creates a vector
9670 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
9671 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9672 As in the case of binary operations, this syntax is also accepted when
9673 one of @code{b} or @code{c} is a scalar that is then transformed into a
9674 vector. If both @code{b} and @code{c} are scalars and the type of
9675 @code{true?b:c} has the same size as the element type of @code{a}, then
9676 @code{b} and @code{c} are converted to a vector type whose elements have
9677 this type and with the same number of elements as @code{a}.
9678
9679 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9680 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9681 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9682 For mixed operations between a scalar @code{s} and a vector @code{v},
9683 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9684 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9685
9686 Vector shuffling is available using functions
9687 @code{__builtin_shuffle (vec, mask)} and
9688 @code{__builtin_shuffle (vec0, vec1, mask)}.
9689 Both functions construct a permutation of elements from one or two
9690 vectors and return a vector of the same type as the input vector(s).
9691 The @var{mask} is an integral vector with the same width (@var{W})
9692 and element count (@var{N}) as the output vector.
9693
9694 The elements of the input vectors are numbered in memory ordering of
9695 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
9696 elements of @var{mask} are considered modulo @var{N} in the single-operand
9697 case and modulo @math{2*@var{N}} in the two-operand case.
9698
9699 Consider the following example,
9700
9701 @smallexample
9702 typedef int v4si __attribute__ ((vector_size (16)));
9703
9704 v4si a = @{1,2,3,4@};
9705 v4si b = @{5,6,7,8@};
9706 v4si mask1 = @{0,1,1,3@};
9707 v4si mask2 = @{0,4,2,5@};
9708 v4si res;
9709
9710 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
9711 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
9712 @end smallexample
9713
9714 Note that @code{__builtin_shuffle} is intentionally semantically
9715 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9716
9717 You can declare variables and use them in function calls and returns, as
9718 well as in assignments and some casts. You can specify a vector type as
9719 a return type for a function. Vector types can also be used as function
9720 arguments. It is possible to cast from one vector type to another,
9721 provided they are of the same size (in fact, you can also cast vectors
9722 to and from other datatypes of the same size).
9723
9724 You cannot operate between vectors of different lengths or different
9725 signedness without a cast.
9726
9727 @node Offsetof
9728 @section Support for @code{offsetof}
9729 @findex __builtin_offsetof
9730
9731 GCC implements for both C and C++ a syntactic extension to implement
9732 the @code{offsetof} macro.
9733
9734 @smallexample
9735 primary:
9736 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9737
9738 offsetof_member_designator:
9739 @code{identifier}
9740 | offsetof_member_designator "." @code{identifier}
9741 | offsetof_member_designator "[" @code{expr} "]"
9742 @end smallexample
9743
9744 This extension is sufficient such that
9745
9746 @smallexample
9747 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
9748 @end smallexample
9749
9750 @noindent
9751 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
9752 may be dependent. In either case, @var{member} may consist of a single
9753 identifier, or a sequence of member accesses and array references.
9754
9755 @node __sync Builtins
9756 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9757
9758 The following built-in functions
9759 are intended to be compatible with those described
9760 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9761 section 7.4. As such, they depart from normal GCC practice by not using
9762 the @samp{__builtin_} prefix and also by being overloaded so that they
9763 work on multiple types.
9764
9765 The definition given in the Intel documentation allows only for the use of
9766 the types @code{int}, @code{long}, @code{long long} or their unsigned
9767 counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
9768 size other than the C type @code{_Bool} or the C++ type @code{bool}.
9769 Operations on pointer arguments are performed as if the operands were
9770 of the @code{uintptr_t} type. That is, they are not scaled by the size
9771 of the type to which the pointer points.
9772
9773 These functions are implemented in terms of the @samp{__atomic}
9774 builtins (@pxref{__atomic Builtins}). They should not be used for new
9775 code which should use the @samp{__atomic} builtins instead.
9776
9777 Not all operations are supported by all target processors. If a particular
9778 operation cannot be implemented on the target processor, a warning is
9779 generated and a call to an external function is generated. The external
9780 function carries the same name as the built-in version,
9781 with an additional suffix
9782 @samp{_@var{n}} where @var{n} is the size of the data type.
9783
9784 @c ??? Should we have a mechanism to suppress this warning? This is almost
9785 @c useful for implementing the operation under the control of an external
9786 @c mutex.
9787
9788 In most cases, these built-in functions are considered a @dfn{full barrier}.
9789 That is,
9790 no memory operand is moved across the operation, either forward or
9791 backward. Further, instructions are issued as necessary to prevent the
9792 processor from speculating loads across the operation and from queuing stores
9793 after the operation.
9794
9795 All of the routines are described in the Intel documentation to take
9796 ``an optional list of variables protected by the memory barrier''. It's
9797 not clear what is meant by that; it could mean that @emph{only} the
9798 listed variables are protected, or it could mean a list of additional
9799 variables to be protected. The list is ignored by GCC which treats it as
9800 empty. GCC interprets an empty list as meaning that all globally
9801 accessible variables should be protected.
9802
9803 @table @code
9804 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9805 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9806 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9807 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9808 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9809 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9810 @findex __sync_fetch_and_add
9811 @findex __sync_fetch_and_sub
9812 @findex __sync_fetch_and_or
9813 @findex __sync_fetch_and_and
9814 @findex __sync_fetch_and_xor
9815 @findex __sync_fetch_and_nand
9816 These built-in functions perform the operation suggested by the name, and
9817 returns the value that had previously been in memory. That is, operations
9818 on integer operands have the following semantics. Operations on pointer
9819 arguments are performed as if the operands were of the @code{uintptr_t}
9820 type. That is, they are not scaled by the size of the type to which
9821 the pointer points.
9822
9823 @smallexample
9824 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9825 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
9826 @end smallexample
9827
9828 The object pointed to by the first argument must be of integer or pointer
9829 type. It must not be a boolean type.
9830
9831 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9832 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9833
9834 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9835 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9836 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9837 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9838 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9839 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9840 @findex __sync_add_and_fetch
9841 @findex __sync_sub_and_fetch
9842 @findex __sync_or_and_fetch
9843 @findex __sync_and_and_fetch
9844 @findex __sync_xor_and_fetch
9845 @findex __sync_nand_and_fetch
9846 These built-in functions perform the operation suggested by the name, and
9847 return the new value. That is, operations on integer operands have
9848 the following semantics. Operations on pointer operands are performed as
9849 if the operand's type were @code{uintptr_t}.
9850
9851 @smallexample
9852 @{ *ptr @var{op}= value; return *ptr; @}
9853 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
9854 @end smallexample
9855
9856 The same constraints on arguments apply as for the corresponding
9857 @code{__sync_op_and_fetch} built-in functions.
9858
9859 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9860 as @code{*ptr = ~(*ptr & value)} instead of
9861 @code{*ptr = ~*ptr & value}.
9862
9863 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9864 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9865 @findex __sync_bool_compare_and_swap
9866 @findex __sync_val_compare_and_swap
9867 These built-in functions perform an atomic compare and swap.
9868 That is, if the current
9869 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9870 @code{*@var{ptr}}.
9871
9872 The ``bool'' version returns true if the comparison is successful and
9873 @var{newval} is written. The ``val'' version returns the contents
9874 of @code{*@var{ptr}} before the operation.
9875
9876 @item __sync_synchronize (...)
9877 @findex __sync_synchronize
9878 This built-in function issues a full memory barrier.
9879
9880 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9881 @findex __sync_lock_test_and_set
9882 This built-in function, as described by Intel, is not a traditional test-and-set
9883 operation, but rather an atomic exchange operation. It writes @var{value}
9884 into @code{*@var{ptr}}, and returns the previous contents of
9885 @code{*@var{ptr}}.
9886
9887 Many targets have only minimal support for such locks, and do not support
9888 a full exchange operation. In this case, a target may support reduced
9889 functionality here by which the @emph{only} valid value to store is the
9890 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
9891 is implementation defined.
9892
9893 This built-in function is not a full barrier,
9894 but rather an @dfn{acquire barrier}.
9895 This means that references after the operation cannot move to (or be
9896 speculated to) before the operation, but previous memory stores may not
9897 be globally visible yet, and previous memory loads may not yet be
9898 satisfied.
9899
9900 @item void __sync_lock_release (@var{type} *ptr, ...)
9901 @findex __sync_lock_release
9902 This built-in function releases the lock acquired by
9903 @code{__sync_lock_test_and_set}.
9904 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9905
9906 This built-in function is not a full barrier,
9907 but rather a @dfn{release barrier}.
9908 This means that all previous memory stores are globally visible, and all
9909 previous memory loads have been satisfied, but following memory reads
9910 are not prevented from being speculated to before the barrier.
9911 @end table
9912
9913 @node __atomic Builtins
9914 @section Built-in Functions for Memory Model Aware Atomic Operations
9915
9916 The following built-in functions approximately match the requirements
9917 for the C++11 memory model. They are all
9918 identified by being prefixed with @samp{__atomic} and most are
9919 overloaded so that they work with multiple types.
9920
9921 These functions are intended to replace the legacy @samp{__sync}
9922 builtins. The main difference is that the memory order that is requested
9923 is a parameter to the functions. New code should always use the
9924 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9925
9926 Note that the @samp{__atomic} builtins assume that programs will
9927 conform to the C++11 memory model. In particular, they assume
9928 that programs are free of data races. See the C++11 standard for
9929 detailed requirements.
9930
9931 The @samp{__atomic} builtins can be used with any integral scalar or
9932 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
9933 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9934 supported by the architecture.
9935
9936 The four non-arithmetic functions (load, store, exchange, and
9937 compare_exchange) all have a generic version as well. This generic
9938 version works on any data type. It uses the lock-free built-in function
9939 if the specific data type size makes that possible; otherwise, an
9940 external call is left to be resolved at run time. This external call is
9941 the same format with the addition of a @samp{size_t} parameter inserted
9942 as the first parameter indicating the size of the object being pointed to.
9943 All objects must be the same size.
9944
9945 There are 6 different memory orders that can be specified. These map
9946 to the C++11 memory orders with the same names, see the C++11 standard
9947 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9948 on atomic synchronization} for detailed definitions. Individual
9949 targets may also support additional memory orders for use on specific
9950 architectures. Refer to the target documentation for details of
9951 these.
9952
9953 An atomic operation can both constrain code motion and
9954 be mapped to hardware instructions for synchronization between threads
9955 (e.g., a fence). To which extent this happens is controlled by the
9956 memory orders, which are listed here in approximately ascending order of
9957 strength. The description of each memory order is only meant to roughly
9958 illustrate the effects and is not a specification; see the C++11
9959 memory model for precise semantics.
9960
9961 @table @code
9962 @item __ATOMIC_RELAXED
9963 Implies no inter-thread ordering constraints.
9964 @item __ATOMIC_CONSUME
9965 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9966 memory order because of a deficiency in C++11's semantics for
9967 @code{memory_order_consume}.
9968 @item __ATOMIC_ACQUIRE
9969 Creates an inter-thread happens-before constraint from the release (or
9970 stronger) semantic store to this acquire load. Can prevent hoisting
9971 of code to before the operation.
9972 @item __ATOMIC_RELEASE
9973 Creates an inter-thread happens-before constraint to acquire (or stronger)
9974 semantic loads that read from this release store. Can prevent sinking
9975 of code to after the operation.
9976 @item __ATOMIC_ACQ_REL
9977 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9978 @code{__ATOMIC_RELEASE}.
9979 @item __ATOMIC_SEQ_CST
9980 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9981 @end table
9982
9983 Note that in the C++11 memory model, @emph{fences} (e.g.,
9984 @samp{__atomic_thread_fence}) take effect in combination with other
9985 atomic operations on specific memory locations (e.g., atomic loads);
9986 operations on specific memory locations do not necessarily affect other
9987 operations in the same way.
9988
9989 Target architectures are encouraged to provide their own patterns for
9990 each of the atomic built-in functions. If no target is provided, the original
9991 non-memory model set of @samp{__sync} atomic built-in functions are
9992 used, along with any required synchronization fences surrounding it in
9993 order to achieve the proper behavior. Execution in this case is subject
9994 to the same restrictions as those built-in functions.
9995
9996 If there is no pattern or mechanism to provide a lock-free instruction
9997 sequence, a call is made to an external routine with the same parameters
9998 to be resolved at run time.
9999
10000 When implementing patterns for these built-in functions, the memory order
10001 parameter can be ignored as long as the pattern implements the most
10002 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
10003 orders execute correctly with this memory order but they may not execute as
10004 efficiently as they could with a more appropriate implementation of the
10005 relaxed requirements.
10006
10007 Note that the C++11 standard allows for the memory order parameter to be
10008 determined at run time rather than at compile time. These built-in
10009 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
10010 than invoke a runtime library call or inline a switch statement. This is
10011 standard compliant, safe, and the simplest approach for now.
10012
10013 The memory order parameter is a signed int, but only the lower 16 bits are
10014 reserved for the memory order. The remainder of the signed int is reserved
10015 for target use and should be 0. Use of the predefined atomic values
10016 ensures proper usage.
10017
10018 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
10019 This built-in function implements an atomic load operation. It returns the
10020 contents of @code{*@var{ptr}}.
10021
10022 The valid memory order variants are
10023 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10024 and @code{__ATOMIC_CONSUME}.
10025
10026 @end deftypefn
10027
10028 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
10029 This is the generic version of an atomic load. It returns the
10030 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
10031
10032 @end deftypefn
10033
10034 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
10035 This built-in function implements an atomic store operation. It writes
10036 @code{@var{val}} into @code{*@var{ptr}}.
10037
10038 The valid memory order variants are
10039 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
10040
10041 @end deftypefn
10042
10043 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
10044 This is the generic version of an atomic store. It stores the value
10045 of @code{*@var{val}} into @code{*@var{ptr}}.
10046
10047 @end deftypefn
10048
10049 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
10050 This built-in function implements an atomic exchange operation. It writes
10051 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
10052 @code{*@var{ptr}}.
10053
10054 The valid memory order variants are
10055 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10056 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
10057
10058 @end deftypefn
10059
10060 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
10061 This is the generic version of an atomic exchange. It stores the
10062 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
10063 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
10064
10065 @end deftypefn
10066
10067 @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)
10068 This built-in function implements an atomic compare and exchange operation.
10069 This compares the contents of @code{*@var{ptr}} with the contents of
10070 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
10071 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
10072 equal, the operation is a @emph{read} and the current contents of
10073 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is true
10074 for weak compare_exchange, which may fail spuriously, and false for
10075 the strong variation, which never fails spuriously. Many targets
10076 only offer the strong variation and ignore the parameter. When in doubt, use
10077 the strong variation.
10078
10079 If @var{desired} is written into @code{*@var{ptr}} then true is returned
10080 and memory is affected according to the
10081 memory order specified by @var{success_memorder}. There are no
10082 restrictions on what memory order can be used here.
10083
10084 Otherwise, false is returned and memory is affected according
10085 to @var{failure_memorder}. This memory order cannot be
10086 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
10087 stronger order than that specified by @var{success_memorder}.
10088
10089 @end deftypefn
10090
10091 @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)
10092 This built-in function implements the generic version of
10093 @code{__atomic_compare_exchange}. The function is virtually identical to
10094 @code{__atomic_compare_exchange_n}, except the desired value is also a
10095 pointer.
10096
10097 @end deftypefn
10098
10099 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
10100 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
10101 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
10102 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
10103 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
10104 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
10105 These built-in functions perform the operation suggested by the name, and
10106 return the result of the operation. Operations on pointer arguments are
10107 performed as if the operands were of the @code{uintptr_t} type. That is,
10108 they are not scaled by the size of the type to which the pointer points.
10109
10110 @smallexample
10111 @{ *ptr @var{op}= val; return *ptr; @}
10112 @end smallexample
10113
10114 The object pointed to by the first argument must be of integer or pointer
10115 type. It must not be a boolean type. All memory orders are valid.
10116
10117 @end deftypefn
10118
10119 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
10120 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
10121 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
10122 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
10123 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
10124 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
10125 These built-in functions perform the operation suggested by the name, and
10126 return the value that had previously been in @code{*@var{ptr}}. Operations
10127 on pointer arguments are performed as if the operands were of
10128 the @code{uintptr_t} type. That is, they are not scaled by the size of
10129 the type to which the pointer points.
10130
10131 @smallexample
10132 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
10133 @end smallexample
10134
10135 The same constraints on arguments apply as for the corresponding
10136 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
10137
10138 @end deftypefn
10139
10140 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
10141
10142 This built-in function performs an atomic test-and-set operation on
10143 the byte at @code{*@var{ptr}}. The byte is set to some implementation
10144 defined nonzero ``set'' value and the return value is @code{true} if and only
10145 if the previous contents were ``set''.
10146 It should be only used for operands of type @code{bool} or @code{char}. For
10147 other types only part of the value may be set.
10148
10149 All memory orders are valid.
10150
10151 @end deftypefn
10152
10153 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
10154
10155 This built-in function performs an atomic clear operation on
10156 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
10157 It should be only used for operands of type @code{bool} or @code{char} and
10158 in conjunction with @code{__atomic_test_and_set}.
10159 For other types it may only clear partially. If the type is not @code{bool}
10160 prefer using @code{__atomic_store}.
10161
10162 The valid memory order variants are
10163 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
10164 @code{__ATOMIC_RELEASE}.
10165
10166 @end deftypefn
10167
10168 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
10169
10170 This built-in function acts as a synchronization fence between threads
10171 based on the specified memory order.
10172
10173 All memory orders are valid.
10174
10175 @end deftypefn
10176
10177 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
10178
10179 This built-in function acts as a synchronization fence between a thread
10180 and signal handlers based in the same thread.
10181
10182 All memory orders are valid.
10183
10184 @end deftypefn
10185
10186 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
10187
10188 This built-in function returns true if objects of @var{size} bytes always
10189 generate lock-free atomic instructions for the target architecture.
10190 @var{size} must resolve to a compile-time constant and the result also
10191 resolves to a compile-time constant.
10192
10193 @var{ptr} is an optional pointer to the object that may be used to determine
10194 alignment. A value of 0 indicates typical alignment should be used. The
10195 compiler may also ignore this parameter.
10196
10197 @smallexample
10198 if (__atomic_always_lock_free (sizeof (long long), 0))
10199 @end smallexample
10200
10201 @end deftypefn
10202
10203 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
10204
10205 This built-in function returns true if objects of @var{size} bytes always
10206 generate lock-free atomic instructions for the target architecture. If
10207 the built-in function is not known to be lock-free, a call is made to a
10208 runtime routine named @code{__atomic_is_lock_free}.
10209
10210 @var{ptr} is an optional pointer to the object that may be used to determine
10211 alignment. A value of 0 indicates typical alignment should be used. The
10212 compiler may also ignore this parameter.
10213 @end deftypefn
10214
10215 @node Integer Overflow Builtins
10216 @section Built-in Functions to Perform Arithmetic with Overflow Checking
10217
10218 The following built-in functions allow performing simple arithmetic operations
10219 together with checking whether the operations overflowed.
10220
10221 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10222 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
10223 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
10224 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
10225 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
10226 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10227 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10228
10229 These built-in functions promote the first two operands into infinite precision signed
10230 type and perform addition on those promoted operands. The result is then
10231 cast to the type the third pointer argument points to and stored there.
10232 If the stored result is equal to the infinite precision result, the built-in
10233 functions return false, otherwise they return true. As the addition is
10234 performed in infinite signed precision, these built-in functions have fully defined
10235 behavior for all argument values.
10236
10237 The first built-in function allows arbitrary integral types for operands and
10238 the result type must be pointer to some integral type other than enumerated or
10239 boolean type, the rest of the built-in functions have explicit integer types.
10240
10241 The compiler will attempt to use hardware instructions to implement
10242 these built-in functions where possible, like conditional jump on overflow
10243 after addition, conditional jump on carry etc.
10244
10245 @end deftypefn
10246
10247 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10248 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
10249 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
10250 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
10251 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
10252 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10253 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10254
10255 These built-in functions are similar to the add overflow checking built-in
10256 functions above, except they perform subtraction, subtract the second argument
10257 from the first one, instead of addition.
10258
10259 @end deftypefn
10260
10261 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10262 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
10263 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
10264 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
10265 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
10266 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10267 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10268
10269 These built-in functions are similar to the add overflow checking built-in
10270 functions above, except they perform multiplication, instead of addition.
10271
10272 @end deftypefn
10273
10274 The following built-in functions allow checking if simple arithmetic operation
10275 would overflow.
10276
10277 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10278 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10279 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10280
10281 These built-in functions are similar to @code{__builtin_add_overflow},
10282 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
10283 they don't store the result of the arithmetic operation anywhere and the
10284 last argument is not a pointer, but some expression with integral type other
10285 than enumerated or boolean type.
10286
10287 The built-in functions promote the first two operands into infinite precision signed type
10288 and perform addition on those promoted operands. The result is then
10289 cast to the type of the third argument. If the cast result is equal to the infinite
10290 precision result, the built-in functions return false, otherwise they return true.
10291 The value of the third argument is ignored, just the side-effects in the third argument
10292 are evaluated, and no integral argument promotions are performed on the last argument.
10293 If the third argument is a bit-field, the type used for the result cast has the
10294 precision and signedness of the given bit-field, rather than precision and signedness
10295 of the underlying type.
10296
10297 For example, the following macro can be used to portably check, at
10298 compile-time, whether or not adding two constant integers will overflow,
10299 and perform the addition only when it is known to be safe and not to trigger
10300 a @option{-Woverflow} warning.
10301
10302 @smallexample
10303 #define INT_ADD_OVERFLOW_P(a, b) \
10304 __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
10305
10306 enum @{
10307 A = INT_MAX, B = 3,
10308 C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
10309 D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
10310 @};
10311 @end smallexample
10312
10313 The compiler will attempt to use hardware instructions to implement
10314 these built-in functions where possible, like conditional jump on overflow
10315 after addition, conditional jump on carry etc.
10316
10317 @end deftypefn
10318
10319 @node x86 specific memory model extensions for transactional memory
10320 @section x86-Specific Memory Model Extensions for Transactional Memory
10321
10322 The x86 architecture supports additional memory ordering flags
10323 to mark critical sections for hardware lock elision.
10324 These must be specified in addition to an existing memory order to
10325 atomic intrinsics.
10326
10327 @table @code
10328 @item __ATOMIC_HLE_ACQUIRE
10329 Start lock elision on a lock variable.
10330 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
10331 @item __ATOMIC_HLE_RELEASE
10332 End lock elision on a lock variable.
10333 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
10334 @end table
10335
10336 When a lock acquire fails, it is required for good performance to abort
10337 the transaction quickly. This can be done with a @code{_mm_pause}.
10338
10339 @smallexample
10340 #include <immintrin.h> // For _mm_pause
10341
10342 int lockvar;
10343
10344 /* Acquire lock with lock elision */
10345 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10346 _mm_pause(); /* Abort failed transaction */
10347 ...
10348 /* Free lock with lock elision */
10349 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10350 @end smallexample
10351
10352 @node Object Size Checking
10353 @section Object Size Checking Built-in Functions
10354 @findex __builtin_object_size
10355 @findex __builtin___memcpy_chk
10356 @findex __builtin___mempcpy_chk
10357 @findex __builtin___memmove_chk
10358 @findex __builtin___memset_chk
10359 @findex __builtin___strcpy_chk
10360 @findex __builtin___stpcpy_chk
10361 @findex __builtin___strncpy_chk
10362 @findex __builtin___strcat_chk
10363 @findex __builtin___strncat_chk
10364 @findex __builtin___sprintf_chk
10365 @findex __builtin___snprintf_chk
10366 @findex __builtin___vsprintf_chk
10367 @findex __builtin___vsnprintf_chk
10368 @findex __builtin___printf_chk
10369 @findex __builtin___vprintf_chk
10370 @findex __builtin___fprintf_chk
10371 @findex __builtin___vfprintf_chk
10372
10373 GCC implements a limited buffer overflow protection mechanism that can
10374 prevent some buffer overflow attacks by determining the sizes of objects
10375 into which data is about to be written and preventing the writes when
10376 the size isn't sufficient. The built-in functions described below yield
10377 the best results when used together and when optimization is enabled.
10378 For example, to detect object sizes across function boundaries or to
10379 follow pointer assignments through non-trivial control flow they rely
10380 on various optimization passes enabled with @option{-O2}. However, to
10381 a limited extent, they can be used without optimization as well.
10382
10383 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
10384 is a built-in construct that returns a constant number of bytes from
10385 @var{ptr} to the end of the object @var{ptr} pointer points to
10386 (if known at compile time). @code{__builtin_object_size} never evaluates
10387 its arguments for side-effects. If there are any side-effects in them, it
10388 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10389 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
10390 point to and all of them are known at compile time, the returned number
10391 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10392 0 and minimum if nonzero. If it is not possible to determine which objects
10393 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10394 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10395 for @var{type} 2 or 3.
10396
10397 @var{type} is an integer constant from 0 to 3. If the least significant
10398 bit is clear, objects are whole variables, if it is set, a closest
10399 surrounding subobject is considered the object a pointer points to.
10400 The second bit determines if maximum or minimum of remaining bytes
10401 is computed.
10402
10403 @smallexample
10404 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10405 char *p = &var.buf1[1], *q = &var.b;
10406
10407 /* Here the object p points to is var. */
10408 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10409 /* The subobject p points to is var.buf1. */
10410 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10411 /* The object q points to is var. */
10412 assert (__builtin_object_size (q, 0)
10413 == (char *) (&var + 1) - (char *) &var.b);
10414 /* The subobject q points to is var.b. */
10415 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10416 @end smallexample
10417 @end deftypefn
10418
10419 There are built-in functions added for many common string operation
10420 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10421 built-in is provided. This built-in has an additional last argument,
10422 which is the number of bytes remaining in the object the @var{dest}
10423 argument points to or @code{(size_t) -1} if the size is not known.
10424
10425 The built-in functions are optimized into the normal string functions
10426 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10427 it is known at compile time that the destination object will not
10428 be overflowed. If the compiler can determine at compile time that the
10429 object will always be overflowed, it issues a warning.
10430
10431 The intended use can be e.g.@:
10432
10433 @smallexample
10434 #undef memcpy
10435 #define bos0(dest) __builtin_object_size (dest, 0)
10436 #define memcpy(dest, src, n) \
10437 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10438
10439 char *volatile p;
10440 char buf[10];
10441 /* It is unknown what object p points to, so this is optimized
10442 into plain memcpy - no checking is possible. */
10443 memcpy (p, "abcde", n);
10444 /* Destination is known and length too. It is known at compile
10445 time there will be no overflow. */
10446 memcpy (&buf[5], "abcde", 5);
10447 /* Destination is known, but the length is not known at compile time.
10448 This will result in __memcpy_chk call that can check for overflow
10449 at run time. */
10450 memcpy (&buf[5], "abcde", n);
10451 /* Destination is known and it is known at compile time there will
10452 be overflow. There will be a warning and __memcpy_chk call that
10453 will abort the program at run time. */
10454 memcpy (&buf[6], "abcde", 5);
10455 @end smallexample
10456
10457 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10458 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10459 @code{strcat} and @code{strncat}.
10460
10461 There are also checking built-in functions for formatted output functions.
10462 @smallexample
10463 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10464 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10465 const char *fmt, ...);
10466 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10467 va_list ap);
10468 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10469 const char *fmt, va_list ap);
10470 @end smallexample
10471
10472 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10473 etc.@: functions and can contain implementation specific flags on what
10474 additional security measures the checking function might take, such as
10475 handling @code{%n} differently.
10476
10477 The @var{os} argument is the object size @var{s} points to, like in the
10478 other built-in functions. There is a small difference in the behavior
10479 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10480 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10481 the checking function is called with @var{os} argument set to
10482 @code{(size_t) -1}.
10483
10484 In addition to this, there are checking built-in functions
10485 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10486 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10487 These have just one additional argument, @var{flag}, right before
10488 format string @var{fmt}. If the compiler is able to optimize them to
10489 @code{fputc} etc.@: functions, it does, otherwise the checking function
10490 is called and the @var{flag} argument passed to it.
10491
10492 @node Pointer Bounds Checker builtins
10493 @section Pointer Bounds Checker Built-in Functions
10494 @cindex Pointer Bounds Checker builtins
10495 @findex __builtin___bnd_set_ptr_bounds
10496 @findex __builtin___bnd_narrow_ptr_bounds
10497 @findex __builtin___bnd_copy_ptr_bounds
10498 @findex __builtin___bnd_init_ptr_bounds
10499 @findex __builtin___bnd_null_ptr_bounds
10500 @findex __builtin___bnd_store_ptr_bounds
10501 @findex __builtin___bnd_chk_ptr_lbounds
10502 @findex __builtin___bnd_chk_ptr_ubounds
10503 @findex __builtin___bnd_chk_ptr_bounds
10504 @findex __builtin___bnd_get_ptr_lbound
10505 @findex __builtin___bnd_get_ptr_ubound
10506
10507 GCC provides a set of built-in functions to control Pointer Bounds Checker
10508 instrumentation. Note that all Pointer Bounds Checker builtins can be used
10509 even if you compile with Pointer Bounds Checker off
10510 (@option{-fno-check-pointer-bounds}).
10511 The behavior may differ in such case as documented below.
10512
10513 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
10514
10515 This built-in function returns a new pointer with the value of @var{q}, and
10516 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
10517 Bounds Checker off, the built-in function just returns the first argument.
10518
10519 @smallexample
10520 extern void *__wrap_malloc (size_t n)
10521 @{
10522 void *p = (void *)__real_malloc (n);
10523 if (!p) return __builtin___bnd_null_ptr_bounds (p);
10524 return __builtin___bnd_set_ptr_bounds (p, n);
10525 @}
10526 @end smallexample
10527
10528 @end deftypefn
10529
10530 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
10531
10532 This built-in function returns a new pointer with the value of @var{p}
10533 and associates it with the narrowed bounds formed by the intersection
10534 of bounds associated with @var{q} and the bounds
10535 [@var{p}, @var{p} + @var{size} - 1].
10536 With Pointer Bounds Checker off, the built-in function just returns the first
10537 argument.
10538
10539 @smallexample
10540 void init_objects (object *objs, size_t size)
10541 @{
10542 size_t i;
10543 /* Initialize objects one-by-one passing pointers with bounds of
10544 an object, not the full array of objects. */
10545 for (i = 0; i < size; i++)
10546 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10547 sizeof(object)));
10548 @}
10549 @end smallexample
10550
10551 @end deftypefn
10552
10553 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10554
10555 This built-in function returns a new pointer with the value of @var{q},
10556 and associates it with the bounds already associated with pointer @var{r}.
10557 With Pointer Bounds Checker off, the built-in function just returns the first
10558 argument.
10559
10560 @smallexample
10561 /* Here is a way to get pointer to object's field but
10562 still with the full object's bounds. */
10563 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
10564 objptr);
10565 @end smallexample
10566
10567 @end deftypefn
10568
10569 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10570
10571 This built-in function returns a new pointer with the value of @var{q}, and
10572 associates it with INIT (allowing full memory access) bounds. With Pointer
10573 Bounds Checker off, the built-in function just returns the first argument.
10574
10575 @end deftypefn
10576
10577 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10578
10579 This built-in function returns a new pointer with the value of @var{q}, and
10580 associates it with NULL (allowing no memory access) bounds. With Pointer
10581 Bounds Checker off, the built-in function just returns the first argument.
10582
10583 @end deftypefn
10584
10585 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10586
10587 This built-in function stores the bounds associated with pointer @var{ptr_val}
10588 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
10589 bounds from legacy code without touching the associated pointer's memory when
10590 pointers are copied as integers. With Pointer Bounds Checker off, the built-in
10591 function call is ignored.
10592
10593 @end deftypefn
10594
10595 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10596
10597 This built-in function checks if the pointer @var{q} is within the lower
10598 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10599 function call is ignored.
10600
10601 @smallexample
10602 extern void *__wrap_memset (void *dst, int c, size_t len)
10603 @{
10604 if (len > 0)
10605 @{
10606 __builtin___bnd_chk_ptr_lbounds (dst);
10607 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10608 __real_memset (dst, c, len);
10609 @}
10610 return dst;
10611 @}
10612 @end smallexample
10613
10614 @end deftypefn
10615
10616 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10617
10618 This built-in function checks if the pointer @var{q} is within the upper
10619 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10620 function call is ignored.
10621
10622 @end deftypefn
10623
10624 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10625
10626 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10627 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
10628 off, the built-in function call is ignored.
10629
10630 @smallexample
10631 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10632 @{
10633 if (n > 0)
10634 @{
10635 __bnd_chk_ptr_bounds (dst, n);
10636 __bnd_chk_ptr_bounds (src, n);
10637 __real_memcpy (dst, src, n);
10638 @}
10639 return dst;
10640 @}
10641 @end smallexample
10642
10643 @end deftypefn
10644
10645 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10646
10647 This built-in function returns the lower bound associated
10648 with the pointer @var{q}, as a pointer value.
10649 This is useful for debugging using @code{printf}.
10650 With Pointer Bounds Checker off, the built-in function returns 0.
10651
10652 @smallexample
10653 void *lb = __builtin___bnd_get_ptr_lbound (q);
10654 void *ub = __builtin___bnd_get_ptr_ubound (q);
10655 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
10656 @end smallexample
10657
10658 @end deftypefn
10659
10660 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10661
10662 This built-in function returns the upper bound (which is a pointer) associated
10663 with the pointer @var{q}. With Pointer Bounds Checker off,
10664 the built-in function returns -1.
10665
10666 @end deftypefn
10667
10668 @node Cilk Plus Builtins
10669 @section Cilk Plus C/C++ Language Extension Built-in Functions
10670
10671 GCC provides support for the following built-in reduction functions if Cilk Plus
10672 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10673
10674 @itemize @bullet
10675 @item @code{__sec_implicit_index}
10676 @item @code{__sec_reduce}
10677 @item @code{__sec_reduce_add}
10678 @item @code{__sec_reduce_all_nonzero}
10679 @item @code{__sec_reduce_all_zero}
10680 @item @code{__sec_reduce_any_nonzero}
10681 @item @code{__sec_reduce_any_zero}
10682 @item @code{__sec_reduce_max}
10683 @item @code{__sec_reduce_min}
10684 @item @code{__sec_reduce_max_ind}
10685 @item @code{__sec_reduce_min_ind}
10686 @item @code{__sec_reduce_mul}
10687 @item @code{__sec_reduce_mutating}
10688 @end itemize
10689
10690 Further details and examples about these built-in functions are described
10691 in the Cilk Plus language manual which can be found at
10692 @uref{https://www.cilkplus.org}.
10693
10694 @node Other Builtins
10695 @section Other Built-in Functions Provided by GCC
10696 @cindex built-in functions
10697 @findex __builtin_alloca
10698 @findex __builtin_alloca_with_align
10699 @findex __builtin_call_with_static_chain
10700 @findex __builtin_fpclassify
10701 @findex __builtin_isfinite
10702 @findex __builtin_isnormal
10703 @findex __builtin_isgreater
10704 @findex __builtin_isgreaterequal
10705 @findex __builtin_isinf_sign
10706 @findex __builtin_isless
10707 @findex __builtin_islessequal
10708 @findex __builtin_islessgreater
10709 @findex __builtin_isunordered
10710 @findex __builtin_powi
10711 @findex __builtin_powif
10712 @findex __builtin_powil
10713 @findex _Exit
10714 @findex _exit
10715 @findex abort
10716 @findex abs
10717 @findex acos
10718 @findex acosf
10719 @findex acosh
10720 @findex acoshf
10721 @findex acoshl
10722 @findex acosl
10723 @findex alloca
10724 @findex asin
10725 @findex asinf
10726 @findex asinh
10727 @findex asinhf
10728 @findex asinhl
10729 @findex asinl
10730 @findex atan
10731 @findex atan2
10732 @findex atan2f
10733 @findex atan2l
10734 @findex atanf
10735 @findex atanh
10736 @findex atanhf
10737 @findex atanhl
10738 @findex atanl
10739 @findex bcmp
10740 @findex bzero
10741 @findex cabs
10742 @findex cabsf
10743 @findex cabsl
10744 @findex cacos
10745 @findex cacosf
10746 @findex cacosh
10747 @findex cacoshf
10748 @findex cacoshl
10749 @findex cacosl
10750 @findex calloc
10751 @findex carg
10752 @findex cargf
10753 @findex cargl
10754 @findex casin
10755 @findex casinf
10756 @findex casinh
10757 @findex casinhf
10758 @findex casinhl
10759 @findex casinl
10760 @findex catan
10761 @findex catanf
10762 @findex catanh
10763 @findex catanhf
10764 @findex catanhl
10765 @findex catanl
10766 @findex cbrt
10767 @findex cbrtf
10768 @findex cbrtl
10769 @findex ccos
10770 @findex ccosf
10771 @findex ccosh
10772 @findex ccoshf
10773 @findex ccoshl
10774 @findex ccosl
10775 @findex ceil
10776 @findex ceilf
10777 @findex ceill
10778 @findex cexp
10779 @findex cexpf
10780 @findex cexpl
10781 @findex cimag
10782 @findex cimagf
10783 @findex cimagl
10784 @findex clog
10785 @findex clogf
10786 @findex clogl
10787 @findex clog10
10788 @findex clog10f
10789 @findex clog10l
10790 @findex conj
10791 @findex conjf
10792 @findex conjl
10793 @findex copysign
10794 @findex copysignf
10795 @findex copysignl
10796 @findex cos
10797 @findex cosf
10798 @findex cosh
10799 @findex coshf
10800 @findex coshl
10801 @findex cosl
10802 @findex cpow
10803 @findex cpowf
10804 @findex cpowl
10805 @findex cproj
10806 @findex cprojf
10807 @findex cprojl
10808 @findex creal
10809 @findex crealf
10810 @findex creall
10811 @findex csin
10812 @findex csinf
10813 @findex csinh
10814 @findex csinhf
10815 @findex csinhl
10816 @findex csinl
10817 @findex csqrt
10818 @findex csqrtf
10819 @findex csqrtl
10820 @findex ctan
10821 @findex ctanf
10822 @findex ctanh
10823 @findex ctanhf
10824 @findex ctanhl
10825 @findex ctanl
10826 @findex dcgettext
10827 @findex dgettext
10828 @findex drem
10829 @findex dremf
10830 @findex dreml
10831 @findex erf
10832 @findex erfc
10833 @findex erfcf
10834 @findex erfcl
10835 @findex erff
10836 @findex erfl
10837 @findex exit
10838 @findex exp
10839 @findex exp10
10840 @findex exp10f
10841 @findex exp10l
10842 @findex exp2
10843 @findex exp2f
10844 @findex exp2l
10845 @findex expf
10846 @findex expl
10847 @findex expm1
10848 @findex expm1f
10849 @findex expm1l
10850 @findex fabs
10851 @findex fabsf
10852 @findex fabsl
10853 @findex fdim
10854 @findex fdimf
10855 @findex fdiml
10856 @findex ffs
10857 @findex floor
10858 @findex floorf
10859 @findex floorl
10860 @findex fma
10861 @findex fmaf
10862 @findex fmal
10863 @findex fmax
10864 @findex fmaxf
10865 @findex fmaxl
10866 @findex fmin
10867 @findex fminf
10868 @findex fminl
10869 @findex fmod
10870 @findex fmodf
10871 @findex fmodl
10872 @findex fprintf
10873 @findex fprintf_unlocked
10874 @findex fputs
10875 @findex fputs_unlocked
10876 @findex frexp
10877 @findex frexpf
10878 @findex frexpl
10879 @findex fscanf
10880 @findex gamma
10881 @findex gammaf
10882 @findex gammal
10883 @findex gamma_r
10884 @findex gammaf_r
10885 @findex gammal_r
10886 @findex gettext
10887 @findex hypot
10888 @findex hypotf
10889 @findex hypotl
10890 @findex ilogb
10891 @findex ilogbf
10892 @findex ilogbl
10893 @findex imaxabs
10894 @findex index
10895 @findex isalnum
10896 @findex isalpha
10897 @findex isascii
10898 @findex isblank
10899 @findex iscntrl
10900 @findex isdigit
10901 @findex isgraph
10902 @findex islower
10903 @findex isprint
10904 @findex ispunct
10905 @findex isspace
10906 @findex isupper
10907 @findex iswalnum
10908 @findex iswalpha
10909 @findex iswblank
10910 @findex iswcntrl
10911 @findex iswdigit
10912 @findex iswgraph
10913 @findex iswlower
10914 @findex iswprint
10915 @findex iswpunct
10916 @findex iswspace
10917 @findex iswupper
10918 @findex iswxdigit
10919 @findex isxdigit
10920 @findex j0
10921 @findex j0f
10922 @findex j0l
10923 @findex j1
10924 @findex j1f
10925 @findex j1l
10926 @findex jn
10927 @findex jnf
10928 @findex jnl
10929 @findex labs
10930 @findex ldexp
10931 @findex ldexpf
10932 @findex ldexpl
10933 @findex lgamma
10934 @findex lgammaf
10935 @findex lgammal
10936 @findex lgamma_r
10937 @findex lgammaf_r
10938 @findex lgammal_r
10939 @findex llabs
10940 @findex llrint
10941 @findex llrintf
10942 @findex llrintl
10943 @findex llround
10944 @findex llroundf
10945 @findex llroundl
10946 @findex log
10947 @findex log10
10948 @findex log10f
10949 @findex log10l
10950 @findex log1p
10951 @findex log1pf
10952 @findex log1pl
10953 @findex log2
10954 @findex log2f
10955 @findex log2l
10956 @findex logb
10957 @findex logbf
10958 @findex logbl
10959 @findex logf
10960 @findex logl
10961 @findex lrint
10962 @findex lrintf
10963 @findex lrintl
10964 @findex lround
10965 @findex lroundf
10966 @findex lroundl
10967 @findex malloc
10968 @findex memchr
10969 @findex memcmp
10970 @findex memcpy
10971 @findex mempcpy
10972 @findex memset
10973 @findex modf
10974 @findex modff
10975 @findex modfl
10976 @findex nearbyint
10977 @findex nearbyintf
10978 @findex nearbyintl
10979 @findex nextafter
10980 @findex nextafterf
10981 @findex nextafterl
10982 @findex nexttoward
10983 @findex nexttowardf
10984 @findex nexttowardl
10985 @findex pow
10986 @findex pow10
10987 @findex pow10f
10988 @findex pow10l
10989 @findex powf
10990 @findex powl
10991 @findex printf
10992 @findex printf_unlocked
10993 @findex putchar
10994 @findex puts
10995 @findex remainder
10996 @findex remainderf
10997 @findex remainderl
10998 @findex remquo
10999 @findex remquof
11000 @findex remquol
11001 @findex rindex
11002 @findex rint
11003 @findex rintf
11004 @findex rintl
11005 @findex round
11006 @findex roundf
11007 @findex roundl
11008 @findex scalb
11009 @findex scalbf
11010 @findex scalbl
11011 @findex scalbln
11012 @findex scalblnf
11013 @findex scalblnf
11014 @findex scalbn
11015 @findex scalbnf
11016 @findex scanfnl
11017 @findex signbit
11018 @findex signbitf
11019 @findex signbitl
11020 @findex signbitd32
11021 @findex signbitd64
11022 @findex signbitd128
11023 @findex significand
11024 @findex significandf
11025 @findex significandl
11026 @findex sin
11027 @findex sincos
11028 @findex sincosf
11029 @findex sincosl
11030 @findex sinf
11031 @findex sinh
11032 @findex sinhf
11033 @findex sinhl
11034 @findex sinl
11035 @findex snprintf
11036 @findex sprintf
11037 @findex sqrt
11038 @findex sqrtf
11039 @findex sqrtl
11040 @findex sscanf
11041 @findex stpcpy
11042 @findex stpncpy
11043 @findex strcasecmp
11044 @findex strcat
11045 @findex strchr
11046 @findex strcmp
11047 @findex strcpy
11048 @findex strcspn
11049 @findex strdup
11050 @findex strfmon
11051 @findex strftime
11052 @findex strlen
11053 @findex strncasecmp
11054 @findex strncat
11055 @findex strncmp
11056 @findex strncpy
11057 @findex strndup
11058 @findex strpbrk
11059 @findex strrchr
11060 @findex strspn
11061 @findex strstr
11062 @findex tan
11063 @findex tanf
11064 @findex tanh
11065 @findex tanhf
11066 @findex tanhl
11067 @findex tanl
11068 @findex tgamma
11069 @findex tgammaf
11070 @findex tgammal
11071 @findex toascii
11072 @findex tolower
11073 @findex toupper
11074 @findex towlower
11075 @findex towupper
11076 @findex trunc
11077 @findex truncf
11078 @findex truncl
11079 @findex vfprintf
11080 @findex vfscanf
11081 @findex vprintf
11082 @findex vscanf
11083 @findex vsnprintf
11084 @findex vsprintf
11085 @findex vsscanf
11086 @findex y0
11087 @findex y0f
11088 @findex y0l
11089 @findex y1
11090 @findex y1f
11091 @findex y1l
11092 @findex yn
11093 @findex ynf
11094 @findex ynl
11095
11096 GCC provides a large number of built-in functions other than the ones
11097 mentioned above. Some of these are for internal use in the processing
11098 of exceptions or variable-length argument lists and are not
11099 documented here because they may change from time to time; we do not
11100 recommend general use of these functions.
11101
11102 The remaining functions are provided for optimization purposes.
11103
11104 With the exception of built-ins that have library equivalents such as
11105 the standard C library functions discussed below, or that expand to
11106 library calls, GCC built-in functions are always expanded inline and
11107 thus do not have corresponding entry points and their address cannot
11108 be obtained. Attempting to use them in an expression other than
11109 a function call results in a compile-time error.
11110
11111 @opindex fno-builtin
11112 GCC includes built-in versions of many of the functions in the standard
11113 C library. These functions come in two forms: one whose names start with
11114 the @code{__builtin_} prefix, and the other without. Both forms have the
11115 same type (including prototype), the same address (when their address is
11116 taken), and the same meaning as the C library functions even if you specify
11117 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
11118 functions are only optimized in certain cases; if they are not optimized in
11119 a particular case, a call to the library function is emitted.
11120
11121 @opindex ansi
11122 @opindex std
11123 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
11124 @option{-std=c99} or @option{-std=c11}), the functions
11125 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
11126 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
11127 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
11128 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
11129 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
11130 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
11131 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
11132 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
11133 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
11134 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
11135 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
11136 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
11137 @code{signbitd64}, @code{signbitd128}, @code{significandf},
11138 @code{significandl}, @code{significand}, @code{sincosf},
11139 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
11140 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
11141 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
11142 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
11143 @code{yn}
11144 may be handled as built-in functions.
11145 All these functions have corresponding versions
11146 prefixed with @code{__builtin_}, which may be used even in strict C90
11147 mode.
11148
11149 The ISO C99 functions
11150 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
11151 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
11152 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
11153 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
11154 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
11155 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
11156 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
11157 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
11158 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
11159 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
11160 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
11161 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
11162 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
11163 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
11164 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
11165 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
11166 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
11167 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
11168 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
11169 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
11170 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
11171 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
11172 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
11173 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
11174 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
11175 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
11176 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
11177 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
11178 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
11179 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
11180 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
11181 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
11182 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
11183 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
11184 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
11185 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
11186 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
11187 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
11188 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
11189 are handled as built-in functions
11190 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11191
11192 There are also built-in versions of the ISO C99 functions
11193 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
11194 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
11195 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
11196 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
11197 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
11198 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
11199 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
11200 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
11201 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
11202 that are recognized in any mode since ISO C90 reserves these names for
11203 the purpose to which ISO C99 puts them. All these functions have
11204 corresponding versions prefixed with @code{__builtin_}.
11205
11206 There are also built-in functions @code{__builtin_fabsf@var{n}},
11207 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
11208 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
11209 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
11210 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
11211 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
11212
11213 There are also GNU extension functions @code{clog10}, @code{clog10f} and
11214 @code{clog10l} which names are reserved by ISO C99 for future use.
11215 All these functions have versions prefixed with @code{__builtin_}.
11216
11217 The ISO C94 functions
11218 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
11219 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
11220 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
11221 @code{towupper}
11222 are handled as built-in functions
11223 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11224
11225 The ISO C90 functions
11226 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11227 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11228 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11229 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11230 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11231 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11232 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11233 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11234 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11235 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11236 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11237 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11238 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11239 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11240 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11241 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11242 are all recognized as built-in functions unless
11243 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11244 is specified for an individual function). All of these functions have
11245 corresponding versions prefixed with @code{__builtin_}.
11246
11247 GCC provides built-in versions of the ISO C99 floating-point comparison
11248 macros that avoid raising exceptions for unordered operands. They have
11249 the same names as the standard macros ( @code{isgreater},
11250 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11251 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11252 prefixed. We intend for a library implementor to be able to simply
11253 @code{#define} each standard macro to its built-in equivalent.
11254 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11255 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11256 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
11257 built-in functions appear both with and without the @code{__builtin_} prefix.
11258
11259 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11260 The @code{__builtin_alloca} function must be called at block scope.
11261 The function allocates an object @var{size} bytes large on the stack
11262 of the calling function. The object is aligned on the default stack
11263 alignment boundary for the target determined by the
11264 @code{__BIGGEST_ALIGNMENT__} macro. The @code{__builtin_alloca}
11265 function returns a pointer to the first byte of the allocated object.
11266 The lifetime of the allocated object ends just before the calling
11267 function returns to its caller. This is so even when
11268 @code{__builtin_alloca} is called within a nested block.
11269
11270 For example, the following function allocates eight objects of @code{n}
11271 bytes each on the stack, storing a pointer to each in consecutive elements
11272 of the array @code{a}. It then passes the array to function @code{g}
11273 which can safely use the storage pointed to by each of the array elements.
11274
11275 @smallexample
11276 void f (unsigned n)
11277 @{
11278 void *a [8];
11279 for (int i = 0; i != 8; ++i)
11280 a [i] = __builtin_alloca (n);
11281
11282 g (a, n); // @r{safe}
11283 @}
11284 @end smallexample
11285
11286 Since the @code{__builtin_alloca} function doesn't validate its argument
11287 it is the responsibility of its caller to make sure the argument doesn't
11288 cause it to exceed the stack size limit.
11289 The @code{__builtin_alloca} function is provided to make it possible to
11290 allocate on the stack arrays of bytes with an upper bound that may be
11291 computed at run time. Since C99 Variable Length Arrays offer
11292 similar functionality under a portable, more convenient, and safer
11293 interface they are recommended instead, in both C99 and C++ programs
11294 where GCC provides them as an extension.
11295 @xref{Variable Length}, for details.
11296
11297 @end deftypefn
11298
11299 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11300 The @code{__builtin_alloca_with_align} function must be called at block
11301 scope. The function allocates an object @var{size} bytes large on
11302 the stack of the calling function. The allocated object is aligned on
11303 the boundary specified by the argument @var{alignment} whose unit is given
11304 in bits (not bytes). The @var{size} argument must be positive and not
11305 exceed the stack size limit. The @var{alignment} argument must be a constant
11306 integer expression that evaluates to a power of 2 greater than or equal to
11307 @code{CHAR_BIT} and less than some unspecified maximum. Invocations
11308 with other values are rejected with an error indicating the valid bounds.
11309 The function returns a pointer to the first byte of the allocated object.
11310 The lifetime of the allocated object ends at the end of the block in which
11311 the function was called. The allocated storage is released no later than
11312 just before the calling function returns to its caller, but may be released
11313 at the end of the block in which the function was called.
11314
11315 For example, in the following function the call to @code{g} is unsafe
11316 because when @code{overalign} is non-zero, the space allocated by
11317 @code{__builtin_alloca_with_align} may have been released at the end
11318 of the @code{if} statement in which it was called.
11319
11320 @smallexample
11321 void f (unsigned n, bool overalign)
11322 @{
11323 void *p;
11324 if (overalign)
11325 p = __builtin_alloca_with_align (n, 64 /* bits */);
11326 else
11327 p = __builtin_alloc (n);
11328
11329 g (p, n); // @r{unsafe}
11330 @}
11331 @end smallexample
11332
11333 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11334 @var{size} argument it is the responsibility of its caller to make sure
11335 the argument doesn't cause it to exceed the stack size limit.
11336 The @code{__builtin_alloca_with_align} function is provided to make
11337 it possible to allocate on the stack overaligned arrays of bytes with
11338 an upper bound that may be computed at run time. Since C99
11339 Variable Length Arrays offer the same functionality under
11340 a portable, more convenient, and safer interface they are recommended
11341 instead, in both C99 and C++ programs where GCC provides them as
11342 an extension. @xref{Variable Length}, for details.
11343
11344 @end deftypefn
11345
11346 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11347
11348 You can use the built-in function @code{__builtin_types_compatible_p} to
11349 determine whether two types are the same.
11350
11351 This built-in function returns 1 if the unqualified versions of the
11352 types @var{type1} and @var{type2} (which are types, not expressions) are
11353 compatible, 0 otherwise. The result of this built-in function can be
11354 used in integer constant expressions.
11355
11356 This built-in function ignores top level qualifiers (e.g., @code{const},
11357 @code{volatile}). For example, @code{int} is equivalent to @code{const
11358 int}.
11359
11360 The type @code{int[]} and @code{int[5]} are compatible. On the other
11361 hand, @code{int} and @code{char *} are not compatible, even if the size
11362 of their types, on the particular architecture are the same. Also, the
11363 amount of pointer indirection is taken into account when determining
11364 similarity. Consequently, @code{short *} is not similar to
11365 @code{short **}. Furthermore, two types that are typedefed are
11366 considered compatible if their underlying types are compatible.
11367
11368 An @code{enum} type is not considered to be compatible with another
11369 @code{enum} type even if both are compatible with the same integer
11370 type; this is what the C standard specifies.
11371 For example, @code{enum @{foo, bar@}} is not similar to
11372 @code{enum @{hot, dog@}}.
11373
11374 You typically use this function in code whose execution varies
11375 depending on the arguments' types. For example:
11376
11377 @smallexample
11378 #define foo(x) \
11379 (@{ \
11380 typeof (x) tmp = (x); \
11381 if (__builtin_types_compatible_p (typeof (x), long double)) \
11382 tmp = foo_long_double (tmp); \
11383 else if (__builtin_types_compatible_p (typeof (x), double)) \
11384 tmp = foo_double (tmp); \
11385 else if (__builtin_types_compatible_p (typeof (x), float)) \
11386 tmp = foo_float (tmp); \
11387 else \
11388 abort (); \
11389 tmp; \
11390 @})
11391 @end smallexample
11392
11393 @emph{Note:} This construct is only available for C@.
11394
11395 @end deftypefn
11396
11397 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11398
11399 The @var{call_exp} expression must be a function call, and the
11400 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
11401 is passed to the function call in the target's static chain location.
11402 The result of builtin is the result of the function call.
11403
11404 @emph{Note:} This builtin is only available for C@.
11405 This builtin can be used to call Go closures from C.
11406
11407 @end deftypefn
11408
11409 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11410
11411 You can use the built-in function @code{__builtin_choose_expr} to
11412 evaluate code depending on the value of a constant expression. This
11413 built-in function returns @var{exp1} if @var{const_exp}, which is an
11414 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
11415
11416 This built-in function is analogous to the @samp{? :} operator in C,
11417 except that the expression returned has its type unaltered by promotion
11418 rules. Also, the built-in function does not evaluate the expression
11419 that is not chosen. For example, if @var{const_exp} evaluates to true,
11420 @var{exp2} is not evaluated even if it has side-effects.
11421
11422 This built-in function can return an lvalue if the chosen argument is an
11423 lvalue.
11424
11425 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11426 type. Similarly, if @var{exp2} is returned, its return type is the same
11427 as @var{exp2}.
11428
11429 Example:
11430
11431 @smallexample
11432 #define foo(x) \
11433 __builtin_choose_expr ( \
11434 __builtin_types_compatible_p (typeof (x), double), \
11435 foo_double (x), \
11436 __builtin_choose_expr ( \
11437 __builtin_types_compatible_p (typeof (x), float), \
11438 foo_float (x), \
11439 /* @r{The void expression results in a compile-time error} \
11440 @r{when assigning the result to something.} */ \
11441 (void)0))
11442 @end smallexample
11443
11444 @emph{Note:} This construct is only available for C@. Furthermore, the
11445 unused expression (@var{exp1} or @var{exp2} depending on the value of
11446 @var{const_exp}) may still generate syntax errors. This may change in
11447 future revisions.
11448
11449 @end deftypefn
11450
11451 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11452
11453 The built-in function @code{__builtin_complex} is provided for use in
11454 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11455 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
11456 real binary floating-point type, and the result has the corresponding
11457 complex type with real and imaginary parts @var{real} and @var{imag}.
11458 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11459 infinities, NaNs and negative zeros are involved.
11460
11461 @end deftypefn
11462
11463 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11464 You can use the built-in function @code{__builtin_constant_p} to
11465 determine if a value is known to be constant at compile time and hence
11466 that GCC can perform constant-folding on expressions involving that
11467 value. The argument of the function is the value to test. The function
11468 returns the integer 1 if the argument is known to be a compile-time
11469 constant and 0 if it is not known to be a compile-time constant. A
11470 return of 0 does not indicate that the value is @emph{not} a constant,
11471 but merely that GCC cannot prove it is a constant with the specified
11472 value of the @option{-O} option.
11473
11474 You typically use this function in an embedded application where
11475 memory is a critical resource. If you have some complex calculation,
11476 you may want it to be folded if it involves constants, but need to call
11477 a function if it does not. For example:
11478
11479 @smallexample
11480 #define Scale_Value(X) \
11481 (__builtin_constant_p (X) \
11482 ? ((X) * SCALE + OFFSET) : Scale (X))
11483 @end smallexample
11484
11485 You may use this built-in function in either a macro or an inline
11486 function. However, if you use it in an inlined function and pass an
11487 argument of the function as the argument to the built-in, GCC
11488 never returns 1 when you call the inline function with a string constant
11489 or compound literal (@pxref{Compound Literals}) and does not return 1
11490 when you pass a constant numeric value to the inline function unless you
11491 specify the @option{-O} option.
11492
11493 You may also use @code{__builtin_constant_p} in initializers for static
11494 data. For instance, you can write
11495
11496 @smallexample
11497 static const int table[] = @{
11498 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11499 /* @r{@dots{}} */
11500 @};
11501 @end smallexample
11502
11503 @noindent
11504 This is an acceptable initializer even if @var{EXPRESSION} is not a
11505 constant expression, including the case where
11506 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11507 folded to a constant but @var{EXPRESSION} contains operands that are
11508 not otherwise permitted in a static initializer (for example,
11509 @code{0 && foo ()}). GCC must be more conservative about evaluating the
11510 built-in in this case, because it has no opportunity to perform
11511 optimization.
11512 @end deftypefn
11513
11514 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11515 @opindex fprofile-arcs
11516 You may use @code{__builtin_expect} to provide the compiler with
11517 branch prediction information. In general, you should prefer to
11518 use actual profile feedback for this (@option{-fprofile-arcs}), as
11519 programmers are notoriously bad at predicting how their programs
11520 actually perform. However, there are applications in which this
11521 data is hard to collect.
11522
11523 The return value is the value of @var{exp}, which should be an integral
11524 expression. The semantics of the built-in are that it is expected that
11525 @var{exp} == @var{c}. For example:
11526
11527 @smallexample
11528 if (__builtin_expect (x, 0))
11529 foo ();
11530 @end smallexample
11531
11532 @noindent
11533 indicates that we do not expect to call @code{foo}, since
11534 we expect @code{x} to be zero. Since you are limited to integral
11535 expressions for @var{exp}, you should use constructions such as
11536
11537 @smallexample
11538 if (__builtin_expect (ptr != NULL, 1))
11539 foo (*ptr);
11540 @end smallexample
11541
11542 @noindent
11543 when testing pointer or floating-point values.
11544 @end deftypefn
11545
11546 @deftypefn {Built-in Function} void __builtin_trap (void)
11547 This function causes the program to exit abnormally. GCC implements
11548 this function by using a target-dependent mechanism (such as
11549 intentionally executing an illegal instruction) or by calling
11550 @code{abort}. The mechanism used may vary from release to release so
11551 you should not rely on any particular implementation.
11552 @end deftypefn
11553
11554 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11555 If control flow reaches the point of the @code{__builtin_unreachable},
11556 the program is undefined. It is useful in situations where the
11557 compiler cannot deduce the unreachability of the code.
11558
11559 One such case is immediately following an @code{asm} statement that
11560 either never terminates, or one that transfers control elsewhere
11561 and never returns. In this example, without the
11562 @code{__builtin_unreachable}, GCC issues a warning that control
11563 reaches the end of a non-void function. It also generates code
11564 to return after the @code{asm}.
11565
11566 @smallexample
11567 int f (int c, int v)
11568 @{
11569 if (c)
11570 @{
11571 return v;
11572 @}
11573 else
11574 @{
11575 asm("jmp error_handler");
11576 __builtin_unreachable ();
11577 @}
11578 @}
11579 @end smallexample
11580
11581 @noindent
11582 Because the @code{asm} statement unconditionally transfers control out
11583 of the function, control never reaches the end of the function
11584 body. The @code{__builtin_unreachable} is in fact unreachable and
11585 communicates this fact to the compiler.
11586
11587 Another use for @code{__builtin_unreachable} is following a call a
11588 function that never returns but that is not declared
11589 @code{__attribute__((noreturn))}, as in this example:
11590
11591 @smallexample
11592 void function_that_never_returns (void);
11593
11594 int g (int c)
11595 @{
11596 if (c)
11597 @{
11598 return 1;
11599 @}
11600 else
11601 @{
11602 function_that_never_returns ();
11603 __builtin_unreachable ();
11604 @}
11605 @}
11606 @end smallexample
11607
11608 @end deftypefn
11609
11610 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11611 This function returns its first argument, and allows the compiler
11612 to assume that the returned pointer is at least @var{align} bytes
11613 aligned. This built-in can have either two or three arguments,
11614 if it has three, the third argument should have integer type, and
11615 if it is nonzero means misalignment offset. For example:
11616
11617 @smallexample
11618 void *x = __builtin_assume_aligned (arg, 16);
11619 @end smallexample
11620
11621 @noindent
11622 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11623 16-byte aligned, while:
11624
11625 @smallexample
11626 void *x = __builtin_assume_aligned (arg, 32, 8);
11627 @end smallexample
11628
11629 @noindent
11630 means that the compiler can assume for @code{x}, set to @code{arg}, that
11631 @code{(char *) x - 8} is 32-byte aligned.
11632 @end deftypefn
11633
11634 @deftypefn {Built-in Function} int __builtin_LINE ()
11635 This function is the equivalent of the preprocessor @code{__LINE__}
11636 macro and returns a constant integer expression that evaluates to
11637 the line number of the invocation of the built-in. When used as a C++
11638 default argument for a function @var{F}, it returns the line number
11639 of the call to @var{F}.
11640 @end deftypefn
11641
11642 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11643 This function is the equivalent of the @code{__FUNCTION__} symbol
11644 and returns an address constant pointing to the name of the function
11645 from which the built-in was invoked, or the empty string if
11646 the invocation is not at function scope. When used as a C++ default
11647 argument for a function @var{F}, it returns the name of @var{F}'s
11648 caller or the empty string if the call was not made at function
11649 scope.
11650 @end deftypefn
11651
11652 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11653 This function is the equivalent of the preprocessor @code{__FILE__}
11654 macro and returns an address constant pointing to the file name
11655 containing the invocation of the built-in, or the empty string if
11656 the invocation is not at function scope. When used as a C++ default
11657 argument for a function @var{F}, it returns the file name of the call
11658 to @var{F} or the empty string if the call was not made at function
11659 scope.
11660
11661 For example, in the following, each call to function @code{foo} will
11662 print a line similar to @code{"file.c:123: foo: message"} with the name
11663 of the file and the line number of the @code{printf} call, the name of
11664 the function @code{foo}, followed by the word @code{message}.
11665
11666 @smallexample
11667 const char*
11668 function (const char *func = __builtin_FUNCTION ())
11669 @{
11670 return func;
11671 @}
11672
11673 void foo (void)
11674 @{
11675 printf ("%s:%i: %s: message\n", file (), line (), function ());
11676 @}
11677 @end smallexample
11678
11679 @end deftypefn
11680
11681 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11682 This function is used to flush the processor's instruction cache for
11683 the region of memory between @var{begin} inclusive and @var{end}
11684 exclusive. Some targets require that the instruction cache be
11685 flushed, after modifying memory containing code, in order to obtain
11686 deterministic behavior.
11687
11688 If the target does not require instruction cache flushes,
11689 @code{__builtin___clear_cache} has no effect. Otherwise either
11690 instructions are emitted in-line to clear the instruction cache or a
11691 call to the @code{__clear_cache} function in libgcc is made.
11692 @end deftypefn
11693
11694 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11695 This function is used to minimize cache-miss latency by moving data into
11696 a cache before it is accessed.
11697 You can insert calls to @code{__builtin_prefetch} into code for which
11698 you know addresses of data in memory that is likely to be accessed soon.
11699 If the target supports them, data prefetch instructions are generated.
11700 If the prefetch is done early enough before the access then the data will
11701 be in the cache by the time it is accessed.
11702
11703 The value of @var{addr} is the address of the memory to prefetch.
11704 There are two optional arguments, @var{rw} and @var{locality}.
11705 The value of @var{rw} is a compile-time constant one or zero; one
11706 means that the prefetch is preparing for a write to the memory address
11707 and zero, the default, means that the prefetch is preparing for a read.
11708 The value @var{locality} must be a compile-time constant integer between
11709 zero and three. A value of zero means that the data has no temporal
11710 locality, so it need not be left in the cache after the access. A value
11711 of three means that the data has a high degree of temporal locality and
11712 should be left in all levels of cache possible. Values of one and two
11713 mean, respectively, a low or moderate degree of temporal locality. The
11714 default is three.
11715
11716 @smallexample
11717 for (i = 0; i < n; i++)
11718 @{
11719 a[i] = a[i] + b[i];
11720 __builtin_prefetch (&a[i+j], 1, 1);
11721 __builtin_prefetch (&b[i+j], 0, 1);
11722 /* @r{@dots{}} */
11723 @}
11724 @end smallexample
11725
11726 Data prefetch does not generate faults if @var{addr} is invalid, but
11727 the address expression itself must be valid. For example, a prefetch
11728 of @code{p->next} does not fault if @code{p->next} is not a valid
11729 address, but evaluation faults if @code{p} is not a valid address.
11730
11731 If the target does not support data prefetch, the address expression
11732 is evaluated if it includes side effects but no other code is generated
11733 and GCC does not issue a warning.
11734 @end deftypefn
11735
11736 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11737 Returns a positive infinity, if supported by the floating-point format,
11738 else @code{DBL_MAX}. This function is suitable for implementing the
11739 ISO C macro @code{HUGE_VAL}.
11740 @end deftypefn
11741
11742 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11743 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11744 @end deftypefn
11745
11746 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11747 Similar to @code{__builtin_huge_val}, except the return
11748 type is @code{long double}.
11749 @end deftypefn
11750
11751 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
11752 Similar to @code{__builtin_huge_val}, except the return type is
11753 @code{_Float@var{n}}.
11754 @end deftypefn
11755
11756 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
11757 Similar to @code{__builtin_huge_val}, except the return type is
11758 @code{_Float@var{n}x}.
11759 @end deftypefn
11760
11761 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11762 This built-in implements the C99 fpclassify functionality. The first
11763 five int arguments should be the target library's notion of the
11764 possible FP classes and are used for return values. They must be
11765 constant values and they must appear in this order: @code{FP_NAN},
11766 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11767 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
11768 to classify. GCC treats the last argument as type-generic, which
11769 means it does not do default promotion from float to double.
11770 @end deftypefn
11771
11772 @deftypefn {Built-in Function} double __builtin_inf (void)
11773 Similar to @code{__builtin_huge_val}, except a warning is generated
11774 if the target floating-point format does not support infinities.
11775 @end deftypefn
11776
11777 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11778 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11779 @end deftypefn
11780
11781 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11782 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11783 @end deftypefn
11784
11785 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11786 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11787 @end deftypefn
11788
11789 @deftypefn {Built-in Function} float __builtin_inff (void)
11790 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11791 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11792 @end deftypefn
11793
11794 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11795 Similar to @code{__builtin_inf}, except the return
11796 type is @code{long double}.
11797 @end deftypefn
11798
11799 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
11800 Similar to @code{__builtin_inf}, except the return
11801 type is @code{_Float@var{n}}.
11802 @end deftypefn
11803
11804 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
11805 Similar to @code{__builtin_inf}, except the return
11806 type is @code{_Float@var{n}x}.
11807 @end deftypefn
11808
11809 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11810 Similar to @code{isinf}, except the return value is -1 for
11811 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11812 Note while the parameter list is an
11813 ellipsis, this function only accepts exactly one floating-point
11814 argument. GCC treats this parameter as type-generic, which means it
11815 does not do default promotion from float to double.
11816 @end deftypefn
11817
11818 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11819 This is an implementation of the ISO C99 function @code{nan}.
11820
11821 Since ISO C99 defines this function in terms of @code{strtod}, which we
11822 do not implement, a description of the parsing is in order. The string
11823 is parsed as by @code{strtol}; that is, the base is recognized by
11824 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
11825 in the significand such that the least significant bit of the number
11826 is at the least significant bit of the significand. The number is
11827 truncated to fit the significand field provided. The significand is
11828 forced to be a quiet NaN@.
11829
11830 This function, if given a string literal all of which would have been
11831 consumed by @code{strtol}, is evaluated early enough that it is considered a
11832 compile-time constant.
11833 @end deftypefn
11834
11835 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11836 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11837 @end deftypefn
11838
11839 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11840 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11841 @end deftypefn
11842
11843 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11844 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11845 @end deftypefn
11846
11847 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11848 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11849 @end deftypefn
11850
11851 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11852 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11853 @end deftypefn
11854
11855 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
11856 Similar to @code{__builtin_nan}, except the return type is
11857 @code{_Float@var{n}}.
11858 @end deftypefn
11859
11860 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
11861 Similar to @code{__builtin_nan}, except the return type is
11862 @code{_Float@var{n}x}.
11863 @end deftypefn
11864
11865 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11866 Similar to @code{__builtin_nan}, except the significand is forced
11867 to be a signaling NaN@. The @code{nans} function is proposed by
11868 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11869 @end deftypefn
11870
11871 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11872 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11873 @end deftypefn
11874
11875 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11876 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11877 @end deftypefn
11878
11879 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
11880 Similar to @code{__builtin_nans}, except the return type is
11881 @code{_Float@var{n}}.
11882 @end deftypefn
11883
11884 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
11885 Similar to @code{__builtin_nans}, except the return type is
11886 @code{_Float@var{n}x}.
11887 @end deftypefn
11888
11889 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11890 Returns one plus the index of the least significant 1-bit of @var{x}, or
11891 if @var{x} is zero, returns zero.
11892 @end deftypefn
11893
11894 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11895 Returns the number of leading 0-bits in @var{x}, starting at the most
11896 significant bit position. If @var{x} is 0, the result is undefined.
11897 @end deftypefn
11898
11899 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11900 Returns the number of trailing 0-bits in @var{x}, starting at the least
11901 significant bit position. If @var{x} is 0, the result is undefined.
11902 @end deftypefn
11903
11904 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11905 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11906 number of bits following the most significant bit that are identical
11907 to it. There are no special cases for 0 or other values.
11908 @end deftypefn
11909
11910 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11911 Returns the number of 1-bits in @var{x}.
11912 @end deftypefn
11913
11914 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11915 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11916 modulo 2.
11917 @end deftypefn
11918
11919 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11920 Similar to @code{__builtin_ffs}, except the argument type is
11921 @code{long}.
11922 @end deftypefn
11923
11924 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11925 Similar to @code{__builtin_clz}, except the argument type is
11926 @code{unsigned long}.
11927 @end deftypefn
11928
11929 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11930 Similar to @code{__builtin_ctz}, except the argument type is
11931 @code{unsigned long}.
11932 @end deftypefn
11933
11934 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11935 Similar to @code{__builtin_clrsb}, except the argument type is
11936 @code{long}.
11937 @end deftypefn
11938
11939 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11940 Similar to @code{__builtin_popcount}, except the argument type is
11941 @code{unsigned long}.
11942 @end deftypefn
11943
11944 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11945 Similar to @code{__builtin_parity}, except the argument type is
11946 @code{unsigned long}.
11947 @end deftypefn
11948
11949 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11950 Similar to @code{__builtin_ffs}, except the argument type is
11951 @code{long long}.
11952 @end deftypefn
11953
11954 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11955 Similar to @code{__builtin_clz}, except the argument type is
11956 @code{unsigned long long}.
11957 @end deftypefn
11958
11959 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11960 Similar to @code{__builtin_ctz}, except the argument type is
11961 @code{unsigned long long}.
11962 @end deftypefn
11963
11964 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11965 Similar to @code{__builtin_clrsb}, except the argument type is
11966 @code{long long}.
11967 @end deftypefn
11968
11969 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11970 Similar to @code{__builtin_popcount}, except the argument type is
11971 @code{unsigned long long}.
11972 @end deftypefn
11973
11974 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11975 Similar to @code{__builtin_parity}, except the argument type is
11976 @code{unsigned long long}.
11977 @end deftypefn
11978
11979 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11980 Returns the first argument raised to the power of the second. Unlike the
11981 @code{pow} function no guarantees about precision and rounding are made.
11982 @end deftypefn
11983
11984 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11985 Similar to @code{__builtin_powi}, except the argument and return types
11986 are @code{float}.
11987 @end deftypefn
11988
11989 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11990 Similar to @code{__builtin_powi}, except the argument and return types
11991 are @code{long double}.
11992 @end deftypefn
11993
11994 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11995 Returns @var{x} with the order of the bytes reversed; for example,
11996 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
11997 exactly 8 bits.
11998 @end deftypefn
11999
12000 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
12001 Similar to @code{__builtin_bswap16}, except the argument and return types
12002 are 32 bit.
12003 @end deftypefn
12004
12005 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
12006 Similar to @code{__builtin_bswap32}, except the argument and return types
12007 are 64 bit.
12008 @end deftypefn
12009
12010 @node Target Builtins
12011 @section Built-in Functions Specific to Particular Target Machines
12012
12013 On some target machines, GCC supports many built-in functions specific
12014 to those machines. Generally these generate calls to specific machine
12015 instructions, but allow the compiler to schedule those calls.
12016
12017 @menu
12018 * AArch64 Built-in Functions::
12019 * Alpha Built-in Functions::
12020 * Altera Nios II Built-in Functions::
12021 * ARC Built-in Functions::
12022 * ARC SIMD Built-in Functions::
12023 * ARM iWMMXt Built-in Functions::
12024 * ARM C Language Extensions (ACLE)::
12025 * ARM Floating Point Status and Control Intrinsics::
12026 * ARM ARMv8-M Security Extensions::
12027 * AVR Built-in Functions::
12028 * Blackfin Built-in Functions::
12029 * FR-V Built-in Functions::
12030 * MIPS DSP Built-in Functions::
12031 * MIPS Paired-Single Support::
12032 * MIPS Loongson Built-in Functions::
12033 * MIPS SIMD Architecture (MSA) Support::
12034 * Other MIPS Built-in Functions::
12035 * MSP430 Built-in Functions::
12036 * NDS32 Built-in Functions::
12037 * picoChip Built-in Functions::
12038 * PowerPC Built-in Functions::
12039 * PowerPC AltiVec/VSX Built-in Functions::
12040 * PowerPC Hardware Transactional Memory Built-in Functions::
12041 * RX Built-in Functions::
12042 * S/390 System z Built-in Functions::
12043 * SH Built-in Functions::
12044 * SPARC VIS Built-in Functions::
12045 * SPU Built-in Functions::
12046 * TI C6X Built-in Functions::
12047 * TILE-Gx Built-in Functions::
12048 * TILEPro Built-in Functions::
12049 * x86 Built-in Functions::
12050 * x86 transactional memory intrinsics::
12051 @end menu
12052
12053 @node AArch64 Built-in Functions
12054 @subsection AArch64 Built-in Functions
12055
12056 These built-in functions are available for the AArch64 family of
12057 processors.
12058 @smallexample
12059 unsigned int __builtin_aarch64_get_fpcr ()
12060 void __builtin_aarch64_set_fpcr (unsigned int)
12061 unsigned int __builtin_aarch64_get_fpsr ()
12062 void __builtin_aarch64_set_fpsr (unsigned int)
12063 @end smallexample
12064
12065 @node Alpha Built-in Functions
12066 @subsection Alpha Built-in Functions
12067
12068 These built-in functions are available for the Alpha family of
12069 processors, depending on the command-line switches used.
12070
12071 The following built-in functions are always available. They
12072 all generate the machine instruction that is part of the name.
12073
12074 @smallexample
12075 long __builtin_alpha_implver (void)
12076 long __builtin_alpha_rpcc (void)
12077 long __builtin_alpha_amask (long)
12078 long __builtin_alpha_cmpbge (long, long)
12079 long __builtin_alpha_extbl (long, long)
12080 long __builtin_alpha_extwl (long, long)
12081 long __builtin_alpha_extll (long, long)
12082 long __builtin_alpha_extql (long, long)
12083 long __builtin_alpha_extwh (long, long)
12084 long __builtin_alpha_extlh (long, long)
12085 long __builtin_alpha_extqh (long, long)
12086 long __builtin_alpha_insbl (long, long)
12087 long __builtin_alpha_inswl (long, long)
12088 long __builtin_alpha_insll (long, long)
12089 long __builtin_alpha_insql (long, long)
12090 long __builtin_alpha_inswh (long, long)
12091 long __builtin_alpha_inslh (long, long)
12092 long __builtin_alpha_insqh (long, long)
12093 long __builtin_alpha_mskbl (long, long)
12094 long __builtin_alpha_mskwl (long, long)
12095 long __builtin_alpha_mskll (long, long)
12096 long __builtin_alpha_mskql (long, long)
12097 long __builtin_alpha_mskwh (long, long)
12098 long __builtin_alpha_msklh (long, long)
12099 long __builtin_alpha_mskqh (long, long)
12100 long __builtin_alpha_umulh (long, long)
12101 long __builtin_alpha_zap (long, long)
12102 long __builtin_alpha_zapnot (long, long)
12103 @end smallexample
12104
12105 The following built-in functions are always with @option{-mmax}
12106 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
12107 later. They all generate the machine instruction that is part
12108 of the name.
12109
12110 @smallexample
12111 long __builtin_alpha_pklb (long)
12112 long __builtin_alpha_pkwb (long)
12113 long __builtin_alpha_unpkbl (long)
12114 long __builtin_alpha_unpkbw (long)
12115 long __builtin_alpha_minub8 (long, long)
12116 long __builtin_alpha_minsb8 (long, long)
12117 long __builtin_alpha_minuw4 (long, long)
12118 long __builtin_alpha_minsw4 (long, long)
12119 long __builtin_alpha_maxub8 (long, long)
12120 long __builtin_alpha_maxsb8 (long, long)
12121 long __builtin_alpha_maxuw4 (long, long)
12122 long __builtin_alpha_maxsw4 (long, long)
12123 long __builtin_alpha_perr (long, long)
12124 @end smallexample
12125
12126 The following built-in functions are always with @option{-mcix}
12127 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
12128 later. They all generate the machine instruction that is part
12129 of the name.
12130
12131 @smallexample
12132 long __builtin_alpha_cttz (long)
12133 long __builtin_alpha_ctlz (long)
12134 long __builtin_alpha_ctpop (long)
12135 @end smallexample
12136
12137 The following built-in functions are available on systems that use the OSF/1
12138 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
12139 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
12140 @code{rdval} and @code{wrval}.
12141
12142 @smallexample
12143 void *__builtin_thread_pointer (void)
12144 void __builtin_set_thread_pointer (void *)
12145 @end smallexample
12146
12147 @node Altera Nios II Built-in Functions
12148 @subsection Altera Nios II Built-in Functions
12149
12150 These built-in functions are available for the Altera Nios II
12151 family of processors.
12152
12153 The following built-in functions are always available. They
12154 all generate the machine instruction that is part of the name.
12155
12156 @example
12157 int __builtin_ldbio (volatile const void *)
12158 int __builtin_ldbuio (volatile const void *)
12159 int __builtin_ldhio (volatile const void *)
12160 int __builtin_ldhuio (volatile const void *)
12161 int __builtin_ldwio (volatile const void *)
12162 void __builtin_stbio (volatile void *, int)
12163 void __builtin_sthio (volatile void *, int)
12164 void __builtin_stwio (volatile void *, int)
12165 void __builtin_sync (void)
12166 int __builtin_rdctl (int)
12167 int __builtin_rdprs (int, int)
12168 void __builtin_wrctl (int, int)
12169 void __builtin_flushd (volatile void *)
12170 void __builtin_flushda (volatile void *)
12171 int __builtin_wrpie (int);
12172 void __builtin_eni (int);
12173 int __builtin_ldex (volatile const void *)
12174 int __builtin_stex (volatile void *, int)
12175 int __builtin_ldsex (volatile const void *)
12176 int __builtin_stsex (volatile void *, int)
12177 @end example
12178
12179 The following built-in functions are always available. They
12180 all generate a Nios II Custom Instruction. The name of the
12181 function represents the types that the function takes and
12182 returns. The letter before the @code{n} is the return type
12183 or void if absent. The @code{n} represents the first parameter
12184 to all the custom instructions, the custom instruction number.
12185 The two letters after the @code{n} represent the up to two
12186 parameters to the function.
12187
12188 The letters represent the following data types:
12189 @table @code
12190 @item <no letter>
12191 @code{void} for return type and no parameter for parameter types.
12192
12193 @item i
12194 @code{int} for return type and parameter type
12195
12196 @item f
12197 @code{float} for return type and parameter type
12198
12199 @item p
12200 @code{void *} for return type and parameter type
12201
12202 @end table
12203
12204 And the function names are:
12205 @example
12206 void __builtin_custom_n (void)
12207 void __builtin_custom_ni (int)
12208 void __builtin_custom_nf (float)
12209 void __builtin_custom_np (void *)
12210 void __builtin_custom_nii (int, int)
12211 void __builtin_custom_nif (int, float)
12212 void __builtin_custom_nip (int, void *)
12213 void __builtin_custom_nfi (float, int)
12214 void __builtin_custom_nff (float, float)
12215 void __builtin_custom_nfp (float, void *)
12216 void __builtin_custom_npi (void *, int)
12217 void __builtin_custom_npf (void *, float)
12218 void __builtin_custom_npp (void *, void *)
12219 int __builtin_custom_in (void)
12220 int __builtin_custom_ini (int)
12221 int __builtin_custom_inf (float)
12222 int __builtin_custom_inp (void *)
12223 int __builtin_custom_inii (int, int)
12224 int __builtin_custom_inif (int, float)
12225 int __builtin_custom_inip (int, void *)
12226 int __builtin_custom_infi (float, int)
12227 int __builtin_custom_inff (float, float)
12228 int __builtin_custom_infp (float, void *)
12229 int __builtin_custom_inpi (void *, int)
12230 int __builtin_custom_inpf (void *, float)
12231 int __builtin_custom_inpp (void *, void *)
12232 float __builtin_custom_fn (void)
12233 float __builtin_custom_fni (int)
12234 float __builtin_custom_fnf (float)
12235 float __builtin_custom_fnp (void *)
12236 float __builtin_custom_fnii (int, int)
12237 float __builtin_custom_fnif (int, float)
12238 float __builtin_custom_fnip (int, void *)
12239 float __builtin_custom_fnfi (float, int)
12240 float __builtin_custom_fnff (float, float)
12241 float __builtin_custom_fnfp (float, void *)
12242 float __builtin_custom_fnpi (void *, int)
12243 float __builtin_custom_fnpf (void *, float)
12244 float __builtin_custom_fnpp (void *, void *)
12245 void * __builtin_custom_pn (void)
12246 void * __builtin_custom_pni (int)
12247 void * __builtin_custom_pnf (float)
12248 void * __builtin_custom_pnp (void *)
12249 void * __builtin_custom_pnii (int, int)
12250 void * __builtin_custom_pnif (int, float)
12251 void * __builtin_custom_pnip (int, void *)
12252 void * __builtin_custom_pnfi (float, int)
12253 void * __builtin_custom_pnff (float, float)
12254 void * __builtin_custom_pnfp (float, void *)
12255 void * __builtin_custom_pnpi (void *, int)
12256 void * __builtin_custom_pnpf (void *, float)
12257 void * __builtin_custom_pnpp (void *, void *)
12258 @end example
12259
12260 @node ARC Built-in Functions
12261 @subsection ARC Built-in Functions
12262
12263 The following built-in functions are provided for ARC targets. The
12264 built-ins generate the corresponding assembly instructions. In the
12265 examples given below, the generated code often requires an operand or
12266 result to be in a register. Where necessary further code will be
12267 generated to ensure this is true, but for brevity this is not
12268 described in each case.
12269
12270 @emph{Note:} Using a built-in to generate an instruction not supported
12271 by a target may cause problems. At present the compiler is not
12272 guaranteed to detect such misuse, and as a result an internal compiler
12273 error may be generated.
12274
12275 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
12276 Return 1 if @var{val} is known to have the byte alignment given
12277 by @var{alignval}, otherwise return 0.
12278 Note that this is different from
12279 @smallexample
12280 __alignof__(*(char *)@var{val}) >= alignval
12281 @end smallexample
12282 because __alignof__ sees only the type of the dereference, whereas
12283 __builtin_arc_align uses alignment information from the pointer
12284 as well as from the pointed-to type.
12285 The information available will depend on optimization level.
12286 @end deftypefn
12287
12288 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
12289 Generates
12290 @example
12291 brk
12292 @end example
12293 @end deftypefn
12294
12295 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
12296 The operand is the number of a register to be read. Generates:
12297 @example
12298 mov @var{dest}, r@var{regno}
12299 @end example
12300 where the value in @var{dest} will be the result returned from the
12301 built-in.
12302 @end deftypefn
12303
12304 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
12305 The first operand is the number of a register to be written, the
12306 second operand is a compile time constant to write into that
12307 register. Generates:
12308 @example
12309 mov r@var{regno}, @var{val}
12310 @end example
12311 @end deftypefn
12312
12313 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
12314 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
12315 Generates:
12316 @example
12317 divaw @var{dest}, @var{a}, @var{b}
12318 @end example
12319 where the value in @var{dest} will be the result returned from the
12320 built-in.
12321 @end deftypefn
12322
12323 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
12324 Generates
12325 @example
12326 flag @var{a}
12327 @end example
12328 @end deftypefn
12329
12330 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
12331 The operand, @var{auxv}, is the address of an auxiliary register and
12332 must be a compile time constant. Generates:
12333 @example
12334 lr @var{dest}, [@var{auxr}]
12335 @end example
12336 Where the value in @var{dest} will be the result returned from the
12337 built-in.
12338 @end deftypefn
12339
12340 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
12341 Only available with @option{-mmul64}. Generates:
12342 @example
12343 mul64 @var{a}, @var{b}
12344 @end example
12345 @end deftypefn
12346
12347 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12348 Only available with @option{-mmul64}. Generates:
12349 @example
12350 mulu64 @var{a}, @var{b}
12351 @end example
12352 @end deftypefn
12353
12354 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12355 Generates:
12356 @example
12357 nop
12358 @end example
12359 @end deftypefn
12360
12361 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12362 Only valid if the @samp{norm} instruction is available through the
12363 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12364 Generates:
12365 @example
12366 norm @var{dest}, @var{src}
12367 @end example
12368 Where the value in @var{dest} will be the result returned from the
12369 built-in.
12370 @end deftypefn
12371
12372 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
12373 Only valid if the @samp{normw} instruction is available through the
12374 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12375 Generates:
12376 @example
12377 normw @var{dest}, @var{src}
12378 @end example
12379 Where the value in @var{dest} will be the result returned from the
12380 built-in.
12381 @end deftypefn
12382
12383 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
12384 Generates:
12385 @example
12386 rtie
12387 @end example
12388 @end deftypefn
12389
12390 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
12391 Generates:
12392 @example
12393 sleep @var{a}
12394 @end example
12395 @end deftypefn
12396
12397 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
12398 The first argument, @var{auxv}, is the address of an auxiliary
12399 register, the second argument, @var{val}, is a compile time constant
12400 to be written to the register. Generates:
12401 @example
12402 sr @var{auxr}, [@var{val}]
12403 @end example
12404 @end deftypefn
12405
12406 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
12407 Only valid with @option{-mswap}. Generates:
12408 @example
12409 swap @var{dest}, @var{src}
12410 @end example
12411 Where the value in @var{dest} will be the result returned from the
12412 built-in.
12413 @end deftypefn
12414
12415 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
12416 Generates:
12417 @example
12418 swi
12419 @end example
12420 @end deftypefn
12421
12422 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
12423 Only available with @option{-mcpu=ARC700}. Generates:
12424 @example
12425 sync
12426 @end example
12427 @end deftypefn
12428
12429 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
12430 Only available with @option{-mcpu=ARC700}. Generates:
12431 @example
12432 trap_s @var{c}
12433 @end example
12434 @end deftypefn
12435
12436 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
12437 Only available with @option{-mcpu=ARC700}. Generates:
12438 @example
12439 unimp_s
12440 @end example
12441 @end deftypefn
12442
12443 The instructions generated by the following builtins are not
12444 considered as candidates for scheduling. They are not moved around by
12445 the compiler during scheduling, and thus can be expected to appear
12446 where they are put in the C code:
12447 @example
12448 __builtin_arc_brk()
12449 __builtin_arc_core_read()
12450 __builtin_arc_core_write()
12451 __builtin_arc_flag()
12452 __builtin_arc_lr()
12453 __builtin_arc_sleep()
12454 __builtin_arc_sr()
12455 __builtin_arc_swi()
12456 @end example
12457
12458 @node ARC SIMD Built-in Functions
12459 @subsection ARC SIMD Built-in Functions
12460
12461 SIMD builtins provided by the compiler can be used to generate the
12462 vector instructions. This section describes the available builtins
12463 and their usage in programs. With the @option{-msimd} option, the
12464 compiler provides 128-bit vector types, which can be specified using
12465 the @code{vector_size} attribute. The header file @file{arc-simd.h}
12466 can be included to use the following predefined types:
12467 @example
12468 typedef int __v4si __attribute__((vector_size(16)));
12469 typedef short __v8hi __attribute__((vector_size(16)));
12470 @end example
12471
12472 These types can be used to define 128-bit variables. The built-in
12473 functions listed in the following section can be used on these
12474 variables to generate the vector operations.
12475
12476 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12477 @file{arc-simd.h} also provides equivalent macros called
12478 @code{_@var{someinsn}} that can be used for programming ease and
12479 improved readability. The following macros for DMA control are also
12480 provided:
12481 @example
12482 #define _setup_dma_in_channel_reg _vdiwr
12483 #define _setup_dma_out_channel_reg _vdowr
12484 @end example
12485
12486 The following is a complete list of all the SIMD built-ins provided
12487 for ARC, grouped by calling signature.
12488
12489 The following take two @code{__v8hi} arguments and return a
12490 @code{__v8hi} result:
12491 @example
12492 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12493 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12494 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12495 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12496 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12497 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12498 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12499 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
12500 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
12501 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
12502 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
12503 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
12504 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
12505 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12506 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12507 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12508 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12509 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12510 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12511 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12512 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12513 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
12514 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
12515 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
12516 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
12517 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
12518 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
12519 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
12520 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
12521 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
12522 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
12523 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
12524 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
12525 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
12526 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
12527 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
12528 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
12529 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
12530 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
12531 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
12532 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
12533 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
12534 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
12535 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
12536 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
12537 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
12538 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
12539 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
12540 @end example
12541
12542 The following take one @code{__v8hi} and one @code{int} argument and return a
12543 @code{__v8hi} result:
12544
12545 @example
12546 __v8hi __builtin_arc_vbaddw (__v8hi, int)
12547 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
12548 __v8hi __builtin_arc_vbminw (__v8hi, int)
12549 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
12550 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
12551 __v8hi __builtin_arc_vbmulw (__v8hi, int)
12552 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
12553 __v8hi __builtin_arc_vbsubw (__v8hi, int)
12554 @end example
12555
12556 The following take one @code{__v8hi} argument and one @code{int} argument which
12557 must be a 3-bit compile time constant indicating a register number
12558 I0-I7. They return a @code{__v8hi} result.
12559 @example
12560 __v8hi __builtin_arc_vasrw (__v8hi, const int)
12561 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
12562 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
12563 @end example
12564
12565 The following take one @code{__v8hi} argument and one @code{int}
12566 argument which must be a 6-bit compile time constant. They return a
12567 @code{__v8hi} result.
12568 @example
12569 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
12570 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
12571 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
12572 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
12573 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
12574 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
12575 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
12576 @end example
12577
12578 The following take one @code{__v8hi} argument and one @code{int} argument which
12579 must be a 8-bit compile time constant. They return a @code{__v8hi}
12580 result.
12581 @example
12582 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
12583 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
12584 __v8hi __builtin_arc_vmvw (__v8hi, const int)
12585 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
12586 @end example
12587
12588 The following take two @code{int} arguments, the second of which which
12589 must be a 8-bit compile time constant. They return a @code{__v8hi}
12590 result:
12591 @example
12592 __v8hi __builtin_arc_vmovaw (int, const int)
12593 __v8hi __builtin_arc_vmovw (int, const int)
12594 __v8hi __builtin_arc_vmovzw (int, const int)
12595 @end example
12596
12597 The following take a single @code{__v8hi} argument and return a
12598 @code{__v8hi} result:
12599 @example
12600 __v8hi __builtin_arc_vabsaw (__v8hi)
12601 __v8hi __builtin_arc_vabsw (__v8hi)
12602 __v8hi __builtin_arc_vaddsuw (__v8hi)
12603 __v8hi __builtin_arc_vexch1 (__v8hi)
12604 __v8hi __builtin_arc_vexch2 (__v8hi)
12605 __v8hi __builtin_arc_vexch4 (__v8hi)
12606 __v8hi __builtin_arc_vsignw (__v8hi)
12607 __v8hi __builtin_arc_vupbaw (__v8hi)
12608 __v8hi __builtin_arc_vupbw (__v8hi)
12609 __v8hi __builtin_arc_vupsbaw (__v8hi)
12610 __v8hi __builtin_arc_vupsbw (__v8hi)
12611 @end example
12612
12613 The following take two @code{int} arguments and return no result:
12614 @example
12615 void __builtin_arc_vdirun (int, int)
12616 void __builtin_arc_vdorun (int, int)
12617 @end example
12618
12619 The following take two @code{int} arguments and return no result. The
12620 first argument must a 3-bit compile time constant indicating one of
12621 the DR0-DR7 DMA setup channels:
12622 @example
12623 void __builtin_arc_vdiwr (const int, int)
12624 void __builtin_arc_vdowr (const int, int)
12625 @end example
12626
12627 The following take an @code{int} argument and return no result:
12628 @example
12629 void __builtin_arc_vendrec (int)
12630 void __builtin_arc_vrec (int)
12631 void __builtin_arc_vrecrun (int)
12632 void __builtin_arc_vrun (int)
12633 @end example
12634
12635 The following take a @code{__v8hi} argument and two @code{int}
12636 arguments and return a @code{__v8hi} result. The second argument must
12637 be a 3-bit compile time constants, indicating one the registers I0-I7,
12638 and the third argument must be an 8-bit compile time constant.
12639
12640 @emph{Note:} Although the equivalent hardware instructions do not take
12641 an SIMD register as an operand, these builtins overwrite the relevant
12642 bits of the @code{__v8hi} register provided as the first argument with
12643 the value loaded from the @code{[Ib, u8]} location in the SDM.
12644
12645 @example
12646 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12647 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12648 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12649 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12650 @end example
12651
12652 The following take two @code{int} arguments and return a @code{__v8hi}
12653 result. The first argument must be a 3-bit compile time constants,
12654 indicating one the registers I0-I7, and the second argument must be an
12655 8-bit compile time constant.
12656
12657 @example
12658 __v8hi __builtin_arc_vld128 (const int, const int)
12659 __v8hi __builtin_arc_vld64w (const int, const int)
12660 @end example
12661
12662 The following take a @code{__v8hi} argument and two @code{int}
12663 arguments and return no result. The second argument must be a 3-bit
12664 compile time constants, indicating one the registers I0-I7, and the
12665 third argument must be an 8-bit compile time constant.
12666
12667 @example
12668 void __builtin_arc_vst128 (__v8hi, const int, const int)
12669 void __builtin_arc_vst64 (__v8hi, const int, const int)
12670 @end example
12671
12672 The following take a @code{__v8hi} argument and three @code{int}
12673 arguments and return no result. The second argument must be a 3-bit
12674 compile-time constant, identifying the 16-bit sub-register to be
12675 stored, the third argument must be a 3-bit compile time constants,
12676 indicating one the registers I0-I7, and the fourth argument must be an
12677 8-bit compile time constant.
12678
12679 @example
12680 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12681 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12682 @end example
12683
12684 @node ARM iWMMXt Built-in Functions
12685 @subsection ARM iWMMXt Built-in Functions
12686
12687 These built-in functions are available for the ARM family of
12688 processors when the @option{-mcpu=iwmmxt} switch is used:
12689
12690 @smallexample
12691 typedef int v2si __attribute__ ((vector_size (8)));
12692 typedef short v4hi __attribute__ ((vector_size (8)));
12693 typedef char v8qi __attribute__ ((vector_size (8)));
12694
12695 int __builtin_arm_getwcgr0 (void)
12696 void __builtin_arm_setwcgr0 (int)
12697 int __builtin_arm_getwcgr1 (void)
12698 void __builtin_arm_setwcgr1 (int)
12699 int __builtin_arm_getwcgr2 (void)
12700 void __builtin_arm_setwcgr2 (int)
12701 int __builtin_arm_getwcgr3 (void)
12702 void __builtin_arm_setwcgr3 (int)
12703 int __builtin_arm_textrmsb (v8qi, int)
12704 int __builtin_arm_textrmsh (v4hi, int)
12705 int __builtin_arm_textrmsw (v2si, int)
12706 int __builtin_arm_textrmub (v8qi, int)
12707 int __builtin_arm_textrmuh (v4hi, int)
12708 int __builtin_arm_textrmuw (v2si, int)
12709 v8qi __builtin_arm_tinsrb (v8qi, int, int)
12710 v4hi __builtin_arm_tinsrh (v4hi, int, int)
12711 v2si __builtin_arm_tinsrw (v2si, int, int)
12712 long long __builtin_arm_tmia (long long, int, int)
12713 long long __builtin_arm_tmiabb (long long, int, int)
12714 long long __builtin_arm_tmiabt (long long, int, int)
12715 long long __builtin_arm_tmiaph (long long, int, int)
12716 long long __builtin_arm_tmiatb (long long, int, int)
12717 long long __builtin_arm_tmiatt (long long, int, int)
12718 int __builtin_arm_tmovmskb (v8qi)
12719 int __builtin_arm_tmovmskh (v4hi)
12720 int __builtin_arm_tmovmskw (v2si)
12721 long long __builtin_arm_waccb (v8qi)
12722 long long __builtin_arm_wacch (v4hi)
12723 long long __builtin_arm_waccw (v2si)
12724 v8qi __builtin_arm_waddb (v8qi, v8qi)
12725 v8qi __builtin_arm_waddbss (v8qi, v8qi)
12726 v8qi __builtin_arm_waddbus (v8qi, v8qi)
12727 v4hi __builtin_arm_waddh (v4hi, v4hi)
12728 v4hi __builtin_arm_waddhss (v4hi, v4hi)
12729 v4hi __builtin_arm_waddhus (v4hi, v4hi)
12730 v2si __builtin_arm_waddw (v2si, v2si)
12731 v2si __builtin_arm_waddwss (v2si, v2si)
12732 v2si __builtin_arm_waddwus (v2si, v2si)
12733 v8qi __builtin_arm_walign (v8qi, v8qi, int)
12734 long long __builtin_arm_wand(long long, long long)
12735 long long __builtin_arm_wandn (long long, long long)
12736 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
12737 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
12738 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
12739 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
12740 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12741 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12742 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12743 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12744 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12745 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12746 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12747 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12748 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12749 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12750 long long __builtin_arm_wmacsz (v4hi, v4hi)
12751 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12752 long long __builtin_arm_wmacuz (v4hi, v4hi)
12753 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12754 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12755 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12756 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12757 v2si __builtin_arm_wmaxsw (v2si, v2si)
12758 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12759 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12760 v2si __builtin_arm_wmaxuw (v2si, v2si)
12761 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12762 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12763 v2si __builtin_arm_wminsw (v2si, v2si)
12764 v8qi __builtin_arm_wminub (v8qi, v8qi)
12765 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12766 v2si __builtin_arm_wminuw (v2si, v2si)
12767 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12768 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12769 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12770 long long __builtin_arm_wor (long long, long long)
12771 v2si __builtin_arm_wpackdss (long long, long long)
12772 v2si __builtin_arm_wpackdus (long long, long long)
12773 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12774 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12775 v4hi __builtin_arm_wpackwss (v2si, v2si)
12776 v4hi __builtin_arm_wpackwus (v2si, v2si)
12777 long long __builtin_arm_wrord (long long, long long)
12778 long long __builtin_arm_wrordi (long long, int)
12779 v4hi __builtin_arm_wrorh (v4hi, long long)
12780 v4hi __builtin_arm_wrorhi (v4hi, int)
12781 v2si __builtin_arm_wrorw (v2si, long long)
12782 v2si __builtin_arm_wrorwi (v2si, int)
12783 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12784 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12785 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12786 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12787 v4hi __builtin_arm_wshufh (v4hi, int)
12788 long long __builtin_arm_wslld (long long, long long)
12789 long long __builtin_arm_wslldi (long long, int)
12790 v4hi __builtin_arm_wsllh (v4hi, long long)
12791 v4hi __builtin_arm_wsllhi (v4hi, int)
12792 v2si __builtin_arm_wsllw (v2si, long long)
12793 v2si __builtin_arm_wsllwi (v2si, int)
12794 long long __builtin_arm_wsrad (long long, long long)
12795 long long __builtin_arm_wsradi (long long, int)
12796 v4hi __builtin_arm_wsrah (v4hi, long long)
12797 v4hi __builtin_arm_wsrahi (v4hi, int)
12798 v2si __builtin_arm_wsraw (v2si, long long)
12799 v2si __builtin_arm_wsrawi (v2si, int)
12800 long long __builtin_arm_wsrld (long long, long long)
12801 long long __builtin_arm_wsrldi (long long, int)
12802 v4hi __builtin_arm_wsrlh (v4hi, long long)
12803 v4hi __builtin_arm_wsrlhi (v4hi, int)
12804 v2si __builtin_arm_wsrlw (v2si, long long)
12805 v2si __builtin_arm_wsrlwi (v2si, int)
12806 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12807 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12808 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12809 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12810 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12811 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12812 v2si __builtin_arm_wsubw (v2si, v2si)
12813 v2si __builtin_arm_wsubwss (v2si, v2si)
12814 v2si __builtin_arm_wsubwus (v2si, v2si)
12815 v4hi __builtin_arm_wunpckehsb (v8qi)
12816 v2si __builtin_arm_wunpckehsh (v4hi)
12817 long long __builtin_arm_wunpckehsw (v2si)
12818 v4hi __builtin_arm_wunpckehub (v8qi)
12819 v2si __builtin_arm_wunpckehuh (v4hi)
12820 long long __builtin_arm_wunpckehuw (v2si)
12821 v4hi __builtin_arm_wunpckelsb (v8qi)
12822 v2si __builtin_arm_wunpckelsh (v4hi)
12823 long long __builtin_arm_wunpckelsw (v2si)
12824 v4hi __builtin_arm_wunpckelub (v8qi)
12825 v2si __builtin_arm_wunpckeluh (v4hi)
12826 long long __builtin_arm_wunpckeluw (v2si)
12827 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12828 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12829 v2si __builtin_arm_wunpckihw (v2si, v2si)
12830 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12831 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12832 v2si __builtin_arm_wunpckilw (v2si, v2si)
12833 long long __builtin_arm_wxor (long long, long long)
12834 long long __builtin_arm_wzero ()
12835 @end smallexample
12836
12837
12838 @node ARM C Language Extensions (ACLE)
12839 @subsection ARM C Language Extensions (ACLE)
12840
12841 GCC implements extensions for C as described in the ARM C Language
12842 Extensions (ACLE) specification, which can be found at
12843 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12844
12845 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12846 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
12847 intrinsics can be found at
12848 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12849 The built-in intrinsics for the Advanced SIMD extension are available when
12850 NEON is enabled.
12851
12852 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
12853 back ends support CRC32 intrinsics and the ARM back end supports the
12854 Coprocessor intrinsics, all from @file{arm_acle.h}. The ARM back end's 16-bit
12855 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12856 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12857 intrinsics yet.
12858
12859 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12860 availability of extensions.
12861
12862 @node ARM Floating Point Status and Control Intrinsics
12863 @subsection ARM Floating Point Status and Control Intrinsics
12864
12865 These built-in functions are available for the ARM family of
12866 processors with floating-point unit.
12867
12868 @smallexample
12869 unsigned int __builtin_arm_get_fpscr ()
12870 void __builtin_arm_set_fpscr (unsigned int)
12871 @end smallexample
12872
12873 @node ARM ARMv8-M Security Extensions
12874 @subsection ARM ARMv8-M Security Extensions
12875
12876 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
12877 Security Extensions: Requirements on Development Tools Engineering
12878 Specification, which can be found at
12879 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
12880
12881 As part of the Security Extensions GCC implements two new function attributes:
12882 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
12883
12884 As part of the Security Extensions GCC implements the intrinsics below. FPTR
12885 is used here to mean any function pointer type.
12886
12887 @smallexample
12888 cmse_address_info_t cmse_TT (void *)
12889 cmse_address_info_t cmse_TT_fptr (FPTR)
12890 cmse_address_info_t cmse_TTT (void *)
12891 cmse_address_info_t cmse_TTT_fptr (FPTR)
12892 cmse_address_info_t cmse_TTA (void *)
12893 cmse_address_info_t cmse_TTA_fptr (FPTR)
12894 cmse_address_info_t cmse_TTAT (void *)
12895 cmse_address_info_t cmse_TTAT_fptr (FPTR)
12896 void * cmse_check_address_range (void *, size_t, int)
12897 typeof(p) cmse_nsfptr_create (FPTR p)
12898 intptr_t cmse_is_nsfptr (FPTR)
12899 int cmse_nonsecure_caller (void)
12900 @end smallexample
12901
12902 @node AVR Built-in Functions
12903 @subsection AVR Built-in Functions
12904
12905 For each built-in function for AVR, there is an equally named,
12906 uppercase built-in macro defined. That way users can easily query if
12907 or if not a specific built-in is implemented or not. For example, if
12908 @code{__builtin_avr_nop} is available the macro
12909 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12910
12911 @table @code
12912
12913 @item void __builtin_avr_nop (void)
12914 @itemx void __builtin_avr_sei (void)
12915 @itemx void __builtin_avr_cli (void)
12916 @itemx void __builtin_avr_sleep (void)
12917 @itemx void __builtin_avr_wdr (void)
12918 @itemx unsigned char __builtin_avr_swap (unsigned char)
12919 @itemx unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12920 @itemx int __builtin_avr_fmuls (char, char)
12921 @itemx int __builtin_avr_fmulsu (char, unsigned char)
12922 These built-in functions map to the respective machine
12923 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12924 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12925 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12926 as library call if no hardware multiplier is available.
12927
12928 @item void __builtin_avr_delay_cycles (unsigned long ticks)
12929 Delay execution for @var{ticks} cycles. Note that this
12930 built-in does not take into account the effect of interrupts that
12931 might increase delay time. @var{ticks} must be a compile-time
12932 integer constant; delays with a variable number of cycles are not supported.
12933
12934 @item char __builtin_avr_flash_segment (const __memx void*)
12935 This built-in takes a byte address to the 24-bit
12936 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12937 the number of the flash segment (the 64 KiB chunk) where the address
12938 points to. Counting starts at @code{0}.
12939 If the address does not point to flash memory, return @code{-1}.
12940
12941 @item uint8_t __builtin_avr_insert_bits (uint32_t map, uint8_t bits, uint8_t val)
12942 Insert bits from @var{bits} into @var{val} and return the resulting
12943 value. The nibbles of @var{map} determine how the insertion is
12944 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12945 @enumerate
12946 @item If @var{X} is @code{0xf},
12947 then the @var{n}-th bit of @var{val} is returned unaltered.
12948
12949 @item If X is in the range 0@dots{}7,
12950 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12951
12952 @item If X is in the range 8@dots{}@code{0xe},
12953 then the @var{n}-th result bit is undefined.
12954 @end enumerate
12955
12956 @noindent
12957 One typical use case for this built-in is adjusting input and
12958 output values to non-contiguous port layouts. Some examples:
12959
12960 @smallexample
12961 // same as val, bits is unused
12962 __builtin_avr_insert_bits (0xffffffff, bits, val)
12963 @end smallexample
12964
12965 @smallexample
12966 // same as bits, val is unused
12967 __builtin_avr_insert_bits (0x76543210, bits, val)
12968 @end smallexample
12969
12970 @smallexample
12971 // same as rotating bits by 4
12972 __builtin_avr_insert_bits (0x32107654, bits, 0)
12973 @end smallexample
12974
12975 @smallexample
12976 // high nibble of result is the high nibble of val
12977 // low nibble of result is the low nibble of bits
12978 __builtin_avr_insert_bits (0xffff3210, bits, val)
12979 @end smallexample
12980
12981 @smallexample
12982 // reverse the bit order of bits
12983 __builtin_avr_insert_bits (0x01234567, bits, 0)
12984 @end smallexample
12985
12986 @item void __builtin_avr_nops (unsigned count)
12987 Insert @var{count} @code{NOP} instructions.
12988 The number of instructions must be a compile-time integer constant.
12989
12990 @end table
12991
12992 @noindent
12993 There are many more AVR-specific built-in functions that are used to
12994 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
12995 section 7.18a.6. You don't need to use these built-ins directly.
12996 Instead, use the declarations as supplied by the @code{stdfix.h} header
12997 with GNU-C99:
12998
12999 @smallexample
13000 #include <stdfix.h>
13001
13002 // Re-interpret the bit representation of unsigned 16-bit
13003 // integer @var{uval} as Q-format 0.16 value.
13004 unsigned fract get_bits (uint_ur_t uval)
13005 @{
13006 return urbits (uval);
13007 @}
13008 @end smallexample
13009
13010 @node Blackfin Built-in Functions
13011 @subsection Blackfin Built-in Functions
13012
13013 Currently, there are two Blackfin-specific built-in functions. These are
13014 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
13015 using inline assembly; by using these built-in functions the compiler can
13016 automatically add workarounds for hardware errata involving these
13017 instructions. These functions are named as follows:
13018
13019 @smallexample
13020 void __builtin_bfin_csync (void)
13021 void __builtin_bfin_ssync (void)
13022 @end smallexample
13023
13024 @node FR-V Built-in Functions
13025 @subsection FR-V Built-in Functions
13026
13027 GCC provides many FR-V-specific built-in functions. In general,
13028 these functions are intended to be compatible with those described
13029 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
13030 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
13031 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
13032 pointer rather than by value.
13033
13034 Most of the functions are named after specific FR-V instructions.
13035 Such functions are said to be ``directly mapped'' and are summarized
13036 here in tabular form.
13037
13038 @menu
13039 * Argument Types::
13040 * Directly-mapped Integer Functions::
13041 * Directly-mapped Media Functions::
13042 * Raw read/write Functions::
13043 * Other Built-in Functions::
13044 @end menu
13045
13046 @node Argument Types
13047 @subsubsection Argument Types
13048
13049 The arguments to the built-in functions can be divided into three groups:
13050 register numbers, compile-time constants and run-time values. In order
13051 to make this classification clear at a glance, the arguments and return
13052 values are given the following pseudo types:
13053
13054 @multitable @columnfractions .20 .30 .15 .35
13055 @item Pseudo type @tab Real C type @tab Constant? @tab Description
13056 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
13057 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
13058 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
13059 @item @code{uw2} @tab @code{unsigned long long} @tab No
13060 @tab an unsigned doubleword
13061 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
13062 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
13063 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
13064 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
13065 @end multitable
13066
13067 These pseudo types are not defined by GCC, they are simply a notational
13068 convenience used in this manual.
13069
13070 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
13071 and @code{sw2} are evaluated at run time. They correspond to
13072 register operands in the underlying FR-V instructions.
13073
13074 @code{const} arguments represent immediate operands in the underlying
13075 FR-V instructions. They must be compile-time constants.
13076
13077 @code{acc} arguments are evaluated at compile time and specify the number
13078 of an accumulator register. For example, an @code{acc} argument of 2
13079 selects the ACC2 register.
13080
13081 @code{iacc} arguments are similar to @code{acc} arguments but specify the
13082 number of an IACC register. See @pxref{Other Built-in Functions}
13083 for more details.
13084
13085 @node Directly-mapped Integer Functions
13086 @subsubsection Directly-Mapped Integer Functions
13087
13088 The functions listed below map directly to FR-V I-type instructions.
13089
13090 @multitable @columnfractions .45 .32 .23
13091 @item Function prototype @tab Example usage @tab Assembly output
13092 @item @code{sw1 __ADDSS (sw1, sw1)}
13093 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
13094 @tab @code{ADDSS @var{a},@var{b},@var{c}}
13095 @item @code{sw1 __SCAN (sw1, sw1)}
13096 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
13097 @tab @code{SCAN @var{a},@var{b},@var{c}}
13098 @item @code{sw1 __SCUTSS (sw1)}
13099 @tab @code{@var{b} = __SCUTSS (@var{a})}
13100 @tab @code{SCUTSS @var{a},@var{b}}
13101 @item @code{sw1 __SLASS (sw1, sw1)}
13102 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
13103 @tab @code{SLASS @var{a},@var{b},@var{c}}
13104 @item @code{void __SMASS (sw1, sw1)}
13105 @tab @code{__SMASS (@var{a}, @var{b})}
13106 @tab @code{SMASS @var{a},@var{b}}
13107 @item @code{void __SMSSS (sw1, sw1)}
13108 @tab @code{__SMSSS (@var{a}, @var{b})}
13109 @tab @code{SMSSS @var{a},@var{b}}
13110 @item @code{void __SMU (sw1, sw1)}
13111 @tab @code{__SMU (@var{a}, @var{b})}
13112 @tab @code{SMU @var{a},@var{b}}
13113 @item @code{sw2 __SMUL (sw1, sw1)}
13114 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
13115 @tab @code{SMUL @var{a},@var{b},@var{c}}
13116 @item @code{sw1 __SUBSS (sw1, sw1)}
13117 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
13118 @tab @code{SUBSS @var{a},@var{b},@var{c}}
13119 @item @code{uw2 __UMUL (uw1, uw1)}
13120 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
13121 @tab @code{UMUL @var{a},@var{b},@var{c}}
13122 @end multitable
13123
13124 @node Directly-mapped Media Functions
13125 @subsubsection Directly-Mapped Media Functions
13126
13127 The functions listed below map directly to FR-V M-type instructions.
13128
13129 @multitable @columnfractions .45 .32 .23
13130 @item Function prototype @tab Example usage @tab Assembly output
13131 @item @code{uw1 __MABSHS (sw1)}
13132 @tab @code{@var{b} = __MABSHS (@var{a})}
13133 @tab @code{MABSHS @var{a},@var{b}}
13134 @item @code{void __MADDACCS (acc, acc)}
13135 @tab @code{__MADDACCS (@var{b}, @var{a})}
13136 @tab @code{MADDACCS @var{a},@var{b}}
13137 @item @code{sw1 __MADDHSS (sw1, sw1)}
13138 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
13139 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
13140 @item @code{uw1 __MADDHUS (uw1, uw1)}
13141 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
13142 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
13143 @item @code{uw1 __MAND (uw1, uw1)}
13144 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
13145 @tab @code{MAND @var{a},@var{b},@var{c}}
13146 @item @code{void __MASACCS (acc, acc)}
13147 @tab @code{__MASACCS (@var{b}, @var{a})}
13148 @tab @code{MASACCS @var{a},@var{b}}
13149 @item @code{uw1 __MAVEH (uw1, uw1)}
13150 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
13151 @tab @code{MAVEH @var{a},@var{b},@var{c}}
13152 @item @code{uw2 __MBTOH (uw1)}
13153 @tab @code{@var{b} = __MBTOH (@var{a})}
13154 @tab @code{MBTOH @var{a},@var{b}}
13155 @item @code{void __MBTOHE (uw1 *, uw1)}
13156 @tab @code{__MBTOHE (&@var{b}, @var{a})}
13157 @tab @code{MBTOHE @var{a},@var{b}}
13158 @item @code{void __MCLRACC (acc)}
13159 @tab @code{__MCLRACC (@var{a})}
13160 @tab @code{MCLRACC @var{a}}
13161 @item @code{void __MCLRACCA (void)}
13162 @tab @code{__MCLRACCA ()}
13163 @tab @code{MCLRACCA}
13164 @item @code{uw1 __Mcop1 (uw1, uw1)}
13165 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
13166 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
13167 @item @code{uw1 __Mcop2 (uw1, uw1)}
13168 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
13169 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
13170 @item @code{uw1 __MCPLHI (uw2, const)}
13171 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
13172 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
13173 @item @code{uw1 __MCPLI (uw2, const)}
13174 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
13175 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
13176 @item @code{void __MCPXIS (acc, sw1, sw1)}
13177 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
13178 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
13179 @item @code{void __MCPXIU (acc, uw1, uw1)}
13180 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
13181 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
13182 @item @code{void __MCPXRS (acc, sw1, sw1)}
13183 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
13184 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
13185 @item @code{void __MCPXRU (acc, uw1, uw1)}
13186 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
13187 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
13188 @item @code{uw1 __MCUT (acc, uw1)}
13189 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
13190 @tab @code{MCUT @var{a},@var{b},@var{c}}
13191 @item @code{uw1 __MCUTSS (acc, sw1)}
13192 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
13193 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
13194 @item @code{void __MDADDACCS (acc, acc)}
13195 @tab @code{__MDADDACCS (@var{b}, @var{a})}
13196 @tab @code{MDADDACCS @var{a},@var{b}}
13197 @item @code{void __MDASACCS (acc, acc)}
13198 @tab @code{__MDASACCS (@var{b}, @var{a})}
13199 @tab @code{MDASACCS @var{a},@var{b}}
13200 @item @code{uw2 __MDCUTSSI (acc, const)}
13201 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
13202 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
13203 @item @code{uw2 __MDPACKH (uw2, uw2)}
13204 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
13205 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
13206 @item @code{uw2 __MDROTLI (uw2, const)}
13207 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
13208 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
13209 @item @code{void __MDSUBACCS (acc, acc)}
13210 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
13211 @tab @code{MDSUBACCS @var{a},@var{b}}
13212 @item @code{void __MDUNPACKH (uw1 *, uw2)}
13213 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
13214 @tab @code{MDUNPACKH @var{a},@var{b}}
13215 @item @code{uw2 __MEXPDHD (uw1, const)}
13216 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
13217 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
13218 @item @code{uw1 __MEXPDHW (uw1, const)}
13219 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
13220 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
13221 @item @code{uw1 __MHDSETH (uw1, const)}
13222 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
13223 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
13224 @item @code{sw1 __MHDSETS (const)}
13225 @tab @code{@var{b} = __MHDSETS (@var{a})}
13226 @tab @code{MHDSETS #@var{a},@var{b}}
13227 @item @code{uw1 __MHSETHIH (uw1, const)}
13228 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
13229 @tab @code{MHSETHIH #@var{a},@var{b}}
13230 @item @code{sw1 __MHSETHIS (sw1, const)}
13231 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
13232 @tab @code{MHSETHIS #@var{a},@var{b}}
13233 @item @code{uw1 __MHSETLOH (uw1, const)}
13234 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
13235 @tab @code{MHSETLOH #@var{a},@var{b}}
13236 @item @code{sw1 __MHSETLOS (sw1, const)}
13237 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
13238 @tab @code{MHSETLOS #@var{a},@var{b}}
13239 @item @code{uw1 __MHTOB (uw2)}
13240 @tab @code{@var{b} = __MHTOB (@var{a})}
13241 @tab @code{MHTOB @var{a},@var{b}}
13242 @item @code{void __MMACHS (acc, sw1, sw1)}
13243 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
13244 @tab @code{MMACHS @var{a},@var{b},@var{c}}
13245 @item @code{void __MMACHU (acc, uw1, uw1)}
13246 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
13247 @tab @code{MMACHU @var{a},@var{b},@var{c}}
13248 @item @code{void __MMRDHS (acc, sw1, sw1)}
13249 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
13250 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
13251 @item @code{void __MMRDHU (acc, uw1, uw1)}
13252 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
13253 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
13254 @item @code{void __MMULHS (acc, sw1, sw1)}
13255 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
13256 @tab @code{MMULHS @var{a},@var{b},@var{c}}
13257 @item @code{void __MMULHU (acc, uw1, uw1)}
13258 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
13259 @tab @code{MMULHU @var{a},@var{b},@var{c}}
13260 @item @code{void __MMULXHS (acc, sw1, sw1)}
13261 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
13262 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
13263 @item @code{void __MMULXHU (acc, uw1, uw1)}
13264 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
13265 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
13266 @item @code{uw1 __MNOT (uw1)}
13267 @tab @code{@var{b} = __MNOT (@var{a})}
13268 @tab @code{MNOT @var{a},@var{b}}
13269 @item @code{uw1 __MOR (uw1, uw1)}
13270 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
13271 @tab @code{MOR @var{a},@var{b},@var{c}}
13272 @item @code{uw1 __MPACKH (uh, uh)}
13273 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
13274 @tab @code{MPACKH @var{a},@var{b},@var{c}}
13275 @item @code{sw2 __MQADDHSS (sw2, sw2)}
13276 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
13277 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
13278 @item @code{uw2 __MQADDHUS (uw2, uw2)}
13279 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
13280 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
13281 @item @code{void __MQCPXIS (acc, sw2, sw2)}
13282 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
13283 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
13284 @item @code{void __MQCPXIU (acc, uw2, uw2)}
13285 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
13286 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
13287 @item @code{void __MQCPXRS (acc, sw2, sw2)}
13288 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
13289 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
13290 @item @code{void __MQCPXRU (acc, uw2, uw2)}
13291 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
13292 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
13293 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
13294 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
13295 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
13296 @item @code{sw2 __MQLMTHS (sw2, sw2)}
13297 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
13298 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
13299 @item @code{void __MQMACHS (acc, sw2, sw2)}
13300 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
13301 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
13302 @item @code{void __MQMACHU (acc, uw2, uw2)}
13303 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
13304 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
13305 @item @code{void __MQMACXHS (acc, sw2, sw2)}
13306 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
13307 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
13308 @item @code{void __MQMULHS (acc, sw2, sw2)}
13309 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
13310 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
13311 @item @code{void __MQMULHU (acc, uw2, uw2)}
13312 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
13313 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
13314 @item @code{void __MQMULXHS (acc, sw2, sw2)}
13315 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
13316 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
13317 @item @code{void __MQMULXHU (acc, uw2, uw2)}
13318 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
13319 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
13320 @item @code{sw2 __MQSATHS (sw2, sw2)}
13321 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
13322 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
13323 @item @code{uw2 __MQSLLHI (uw2, int)}
13324 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
13325 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
13326 @item @code{sw2 __MQSRAHI (sw2, int)}
13327 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
13328 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
13329 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
13330 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
13331 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
13332 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
13333 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
13334 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
13335 @item @code{void __MQXMACHS (acc, sw2, sw2)}
13336 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
13337 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
13338 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
13339 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
13340 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
13341 @item @code{uw1 __MRDACC (acc)}
13342 @tab @code{@var{b} = __MRDACC (@var{a})}
13343 @tab @code{MRDACC @var{a},@var{b}}
13344 @item @code{uw1 __MRDACCG (acc)}
13345 @tab @code{@var{b} = __MRDACCG (@var{a})}
13346 @tab @code{MRDACCG @var{a},@var{b}}
13347 @item @code{uw1 __MROTLI (uw1, const)}
13348 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
13349 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
13350 @item @code{uw1 __MROTRI (uw1, const)}
13351 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
13352 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
13353 @item @code{sw1 __MSATHS (sw1, sw1)}
13354 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
13355 @tab @code{MSATHS @var{a},@var{b},@var{c}}
13356 @item @code{uw1 __MSATHU (uw1, uw1)}
13357 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
13358 @tab @code{MSATHU @var{a},@var{b},@var{c}}
13359 @item @code{uw1 __MSLLHI (uw1, const)}
13360 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
13361 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
13362 @item @code{sw1 __MSRAHI (sw1, const)}
13363 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
13364 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
13365 @item @code{uw1 __MSRLHI (uw1, const)}
13366 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
13367 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
13368 @item @code{void __MSUBACCS (acc, acc)}
13369 @tab @code{__MSUBACCS (@var{b}, @var{a})}
13370 @tab @code{MSUBACCS @var{a},@var{b}}
13371 @item @code{sw1 __MSUBHSS (sw1, sw1)}
13372 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
13373 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
13374 @item @code{uw1 __MSUBHUS (uw1, uw1)}
13375 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
13376 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
13377 @item @code{void __MTRAP (void)}
13378 @tab @code{__MTRAP ()}
13379 @tab @code{MTRAP}
13380 @item @code{uw2 __MUNPACKH (uw1)}
13381 @tab @code{@var{b} = __MUNPACKH (@var{a})}
13382 @tab @code{MUNPACKH @var{a},@var{b}}
13383 @item @code{uw1 __MWCUT (uw2, uw1)}
13384 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
13385 @tab @code{MWCUT @var{a},@var{b},@var{c}}
13386 @item @code{void __MWTACC (acc, uw1)}
13387 @tab @code{__MWTACC (@var{b}, @var{a})}
13388 @tab @code{MWTACC @var{a},@var{b}}
13389 @item @code{void __MWTACCG (acc, uw1)}
13390 @tab @code{__MWTACCG (@var{b}, @var{a})}
13391 @tab @code{MWTACCG @var{a},@var{b}}
13392 @item @code{uw1 __MXOR (uw1, uw1)}
13393 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
13394 @tab @code{MXOR @var{a},@var{b},@var{c}}
13395 @end multitable
13396
13397 @node Raw read/write Functions
13398 @subsubsection Raw Read/Write Functions
13399
13400 This sections describes built-in functions related to read and write
13401 instructions to access memory. These functions generate
13402 @code{membar} instructions to flush the I/O load and stores where
13403 appropriate, as described in Fujitsu's manual described above.
13404
13405 @table @code
13406
13407 @item unsigned char __builtin_read8 (void *@var{data})
13408 @item unsigned short __builtin_read16 (void *@var{data})
13409 @item unsigned long __builtin_read32 (void *@var{data})
13410 @item unsigned long long __builtin_read64 (void *@var{data})
13411
13412 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
13413 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
13414 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
13415 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
13416 @end table
13417
13418 @node Other Built-in Functions
13419 @subsubsection Other Built-in Functions
13420
13421 This section describes built-in functions that are not named after
13422 a specific FR-V instruction.
13423
13424 @table @code
13425 @item sw2 __IACCreadll (iacc @var{reg})
13426 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
13427 for future expansion and must be 0.
13428
13429 @item sw1 __IACCreadl (iacc @var{reg})
13430 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
13431 Other values of @var{reg} are rejected as invalid.
13432
13433 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
13434 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
13435 is reserved for future expansion and must be 0.
13436
13437 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
13438 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
13439 is 1. Other values of @var{reg} are rejected as invalid.
13440
13441 @item void __data_prefetch0 (const void *@var{x})
13442 Use the @code{dcpl} instruction to load the contents of address @var{x}
13443 into the data cache.
13444
13445 @item void __data_prefetch (const void *@var{x})
13446 Use the @code{nldub} instruction to load the contents of address @var{x}
13447 into the data cache. The instruction is issued in slot I1@.
13448 @end table
13449
13450 @node MIPS DSP Built-in Functions
13451 @subsection MIPS DSP Built-in Functions
13452
13453 The MIPS DSP Application-Specific Extension (ASE) includes new
13454 instructions that are designed to improve the performance of DSP and
13455 media applications. It provides instructions that operate on packed
13456 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13457
13458 GCC supports MIPS DSP operations using both the generic
13459 vector extensions (@pxref{Vector Extensions}) and a collection of
13460 MIPS-specific built-in functions. Both kinds of support are
13461 enabled by the @option{-mdsp} command-line option.
13462
13463 Revision 2 of the ASE was introduced in the second half of 2006.
13464 This revision adds extra instructions to the original ASE, but is
13465 otherwise backwards-compatible with it. You can select revision 2
13466 using the command-line option @option{-mdspr2}; this option implies
13467 @option{-mdsp}.
13468
13469 The SCOUNT and POS bits of the DSP control register are global. The
13470 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13471 POS bits. During optimization, the compiler does not delete these
13472 instructions and it does not delete calls to functions containing
13473 these instructions.
13474
13475 At present, GCC only provides support for operations on 32-bit
13476 vectors. The vector type associated with 8-bit integer data is
13477 usually called @code{v4i8}, the vector type associated with Q7
13478 is usually called @code{v4q7}, the vector type associated with 16-bit
13479 integer data is usually called @code{v2i16}, and the vector type
13480 associated with Q15 is usually called @code{v2q15}. They can be
13481 defined in C as follows:
13482
13483 @smallexample
13484 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13485 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13486 typedef short v2i16 __attribute__ ((vector_size(4)));
13487 typedef short v2q15 __attribute__ ((vector_size(4)));
13488 @end smallexample
13489
13490 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13491 initialized in the same way as aggregates. For example:
13492
13493 @smallexample
13494 v4i8 a = @{1, 2, 3, 4@};
13495 v4i8 b;
13496 b = (v4i8) @{5, 6, 7, 8@};
13497
13498 v2q15 c = @{0x0fcb, 0x3a75@};
13499 v2q15 d;
13500 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13501 @end smallexample
13502
13503 @emph{Note:} The CPU's endianness determines the order in which values
13504 are packed. On little-endian targets, the first value is the least
13505 significant and the last value is the most significant. The opposite
13506 order applies to big-endian targets. For example, the code above
13507 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13508 and @code{4} on big-endian targets.
13509
13510 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13511 representation. As shown in this example, the integer representation
13512 of a Q7 value can be obtained by multiplying the fractional value by
13513 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
13514 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
13515 @code{0x1.0p31}.
13516
13517 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13518 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
13519 and @code{c} and @code{d} are @code{v2q15} values.
13520
13521 @multitable @columnfractions .50 .50
13522 @item C code @tab MIPS instruction
13523 @item @code{a + b} @tab @code{addu.qb}
13524 @item @code{c + d} @tab @code{addq.ph}
13525 @item @code{a - b} @tab @code{subu.qb}
13526 @item @code{c - d} @tab @code{subq.ph}
13527 @end multitable
13528
13529 The table below lists the @code{v2i16} operation for which
13530 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
13531 @code{v2i16} values.
13532
13533 @multitable @columnfractions .50 .50
13534 @item C code @tab MIPS instruction
13535 @item @code{e * f} @tab @code{mul.ph}
13536 @end multitable
13537
13538 It is easier to describe the DSP built-in functions if we first define
13539 the following types:
13540
13541 @smallexample
13542 typedef int q31;
13543 typedef int i32;
13544 typedef unsigned int ui32;
13545 typedef long long a64;
13546 @end smallexample
13547
13548 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13549 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13550 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
13551 @code{long long}, but we use @code{a64} to indicate values that are
13552 placed in one of the four DSP accumulators (@code{$ac0},
13553 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13554
13555 Also, some built-in functions prefer or require immediate numbers as
13556 parameters, because the corresponding DSP instructions accept both immediate
13557 numbers and register operands, or accept immediate numbers only. The
13558 immediate parameters are listed as follows.
13559
13560 @smallexample
13561 imm0_3: 0 to 3.
13562 imm0_7: 0 to 7.
13563 imm0_15: 0 to 15.
13564 imm0_31: 0 to 31.
13565 imm0_63: 0 to 63.
13566 imm0_255: 0 to 255.
13567 imm_n32_31: -32 to 31.
13568 imm_n512_511: -512 to 511.
13569 @end smallexample
13570
13571 The following built-in functions map directly to a particular MIPS DSP
13572 instruction. Please refer to the architecture specification
13573 for details on what each instruction does.
13574
13575 @smallexample
13576 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13577 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13578 q31 __builtin_mips_addq_s_w (q31, q31)
13579 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13580 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13581 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13582 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13583 q31 __builtin_mips_subq_s_w (q31, q31)
13584 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13585 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13586 i32 __builtin_mips_addsc (i32, i32)
13587 i32 __builtin_mips_addwc (i32, i32)
13588 i32 __builtin_mips_modsub (i32, i32)
13589 i32 __builtin_mips_raddu_w_qb (v4i8)
13590 v2q15 __builtin_mips_absq_s_ph (v2q15)
13591 q31 __builtin_mips_absq_s_w (q31)
13592 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13593 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13594 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13595 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13596 q31 __builtin_mips_preceq_w_phl (v2q15)
13597 q31 __builtin_mips_preceq_w_phr (v2q15)
13598 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13599 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13600 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13601 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13602 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13603 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13604 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13605 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13606 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13607 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13608 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13609 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13610 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13611 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13612 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13613 q31 __builtin_mips_shll_s_w (q31, i32)
13614 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13615 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13616 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13617 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13618 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13619 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13620 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13621 q31 __builtin_mips_shra_r_w (q31, i32)
13622 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13623 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13624 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13625 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13626 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13627 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13628 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13629 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13630 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13631 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13632 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13633 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13634 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13635 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13636 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13637 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13638 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13639 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13640 i32 __builtin_mips_bitrev (i32)
13641 i32 __builtin_mips_insv (i32, i32)
13642 v4i8 __builtin_mips_repl_qb (imm0_255)
13643 v4i8 __builtin_mips_repl_qb (i32)
13644 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13645 v2q15 __builtin_mips_repl_ph (i32)
13646 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13647 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13648 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13649 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13650 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13651 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13652 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13653 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13654 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13655 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13656 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13657 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13658 i32 __builtin_mips_extr_w (a64, imm0_31)
13659 i32 __builtin_mips_extr_w (a64, i32)
13660 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13661 i32 __builtin_mips_extr_s_h (a64, i32)
13662 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13663 i32 __builtin_mips_extr_rs_w (a64, i32)
13664 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13665 i32 __builtin_mips_extr_r_w (a64, i32)
13666 i32 __builtin_mips_extp (a64, imm0_31)
13667 i32 __builtin_mips_extp (a64, i32)
13668 i32 __builtin_mips_extpdp (a64, imm0_31)
13669 i32 __builtin_mips_extpdp (a64, i32)
13670 a64 __builtin_mips_shilo (a64, imm_n32_31)
13671 a64 __builtin_mips_shilo (a64, i32)
13672 a64 __builtin_mips_mthlip (a64, i32)
13673 void __builtin_mips_wrdsp (i32, imm0_63)
13674 i32 __builtin_mips_rddsp (imm0_63)
13675 i32 __builtin_mips_lbux (void *, i32)
13676 i32 __builtin_mips_lhx (void *, i32)
13677 i32 __builtin_mips_lwx (void *, i32)
13678 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13679 i32 __builtin_mips_bposge32 (void)
13680 a64 __builtin_mips_madd (a64, i32, i32);
13681 a64 __builtin_mips_maddu (a64, ui32, ui32);
13682 a64 __builtin_mips_msub (a64, i32, i32);
13683 a64 __builtin_mips_msubu (a64, ui32, ui32);
13684 a64 __builtin_mips_mult (i32, i32);
13685 a64 __builtin_mips_multu (ui32, ui32);
13686 @end smallexample
13687
13688 The following built-in functions map directly to a particular MIPS DSP REV 2
13689 instruction. Please refer to the architecture specification
13690 for details on what each instruction does.
13691
13692 @smallexample
13693 v4q7 __builtin_mips_absq_s_qb (v4q7);
13694 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13695 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13696 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13697 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13698 i32 __builtin_mips_append (i32, i32, imm0_31);
13699 i32 __builtin_mips_balign (i32, i32, imm0_3);
13700 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13701 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13702 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13703 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13704 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13705 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13706 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13707 q31 __builtin_mips_mulq_rs_w (q31, q31);
13708 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13709 q31 __builtin_mips_mulq_s_w (q31, q31);
13710 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13711 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13712 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13713 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13714 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13715 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13716 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13717 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13718 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13719 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13720 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13721 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13722 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13723 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13724 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13725 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13726 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13727 q31 __builtin_mips_addqh_w (q31, q31);
13728 q31 __builtin_mips_addqh_r_w (q31, q31);
13729 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13730 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13731 q31 __builtin_mips_subqh_w (q31, q31);
13732 q31 __builtin_mips_subqh_r_w (q31, q31);
13733 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13734 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13735 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13736 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13737 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13738 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13739 @end smallexample
13740
13741
13742 @node MIPS Paired-Single Support
13743 @subsection MIPS Paired-Single Support
13744
13745 The MIPS64 architecture includes a number of instructions that
13746 operate on pairs of single-precision floating-point values.
13747 Each pair is packed into a 64-bit floating-point register,
13748 with one element being designated the ``upper half'' and
13749 the other being designated the ``lower half''.
13750
13751 GCC supports paired-single operations using both the generic
13752 vector extensions (@pxref{Vector Extensions}) and a collection of
13753 MIPS-specific built-in functions. Both kinds of support are
13754 enabled by the @option{-mpaired-single} command-line option.
13755
13756 The vector type associated with paired-single values is usually
13757 called @code{v2sf}. It can be defined in C as follows:
13758
13759 @smallexample
13760 typedef float v2sf __attribute__ ((vector_size (8)));
13761 @end smallexample
13762
13763 @code{v2sf} values are initialized in the same way as aggregates.
13764 For example:
13765
13766 @smallexample
13767 v2sf a = @{1.5, 9.1@};
13768 v2sf b;
13769 float e, f;
13770 b = (v2sf) @{e, f@};
13771 @end smallexample
13772
13773 @emph{Note:} The CPU's endianness determines which value is stored in
13774 the upper half of a register and which value is stored in the lower half.
13775 On little-endian targets, the first value is the lower one and the second
13776 value is the upper one. The opposite order applies to big-endian targets.
13777 For example, the code above sets the lower half of @code{a} to
13778 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13779
13780 @node MIPS Loongson Built-in Functions
13781 @subsection MIPS Loongson Built-in Functions
13782
13783 GCC provides intrinsics to access the SIMD instructions provided by the
13784 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
13785 available after inclusion of the @code{loongson.h} header file,
13786 operate on the following 64-bit vector types:
13787
13788 @itemize
13789 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13790 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13791 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13792 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13793 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13794 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13795 @end itemize
13796
13797 The intrinsics provided are listed below; each is named after the
13798 machine instruction to which it corresponds, with suffixes added as
13799 appropriate to distinguish intrinsics that expand to the same machine
13800 instruction yet have different argument types. Refer to the architecture
13801 documentation for a description of the functionality of each
13802 instruction.
13803
13804 @smallexample
13805 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13806 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13807 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13808 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13809 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13810 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13811 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13812 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13813 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13814 uint64_t paddd_u (uint64_t s, uint64_t t);
13815 int64_t paddd_s (int64_t s, int64_t t);
13816 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13817 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13818 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13819 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13820 uint64_t pandn_ud (uint64_t s, uint64_t t);
13821 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13822 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13823 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13824 int64_t pandn_sd (int64_t s, int64_t t);
13825 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13826 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13827 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13828 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13829 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13830 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13831 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13832 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13833 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13834 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13835 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13836 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13837 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13838 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13839 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13840 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13841 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13842 uint16x4_t pextrh_u (uint16x4_t s, int field);
13843 int16x4_t pextrh_s (int16x4_t s, int field);
13844 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13845 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13846 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13847 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13848 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13849 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13850 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13851 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13852 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13853 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13854 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13855 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13856 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13857 uint8x8_t pmovmskb_u (uint8x8_t s);
13858 int8x8_t pmovmskb_s (int8x8_t s);
13859 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13860 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13861 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13862 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13863 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13864 uint16x4_t biadd (uint8x8_t s);
13865 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13866 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13867 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13868 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13869 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13870 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13871 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13872 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13873 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13874 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13875 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13876 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13877 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13878 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13879 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13880 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13881 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13882 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13883 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13884 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13885 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13886 uint64_t psubd_u (uint64_t s, uint64_t t);
13887 int64_t psubd_s (int64_t s, int64_t t);
13888 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13889 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13890 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13891 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13892 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13893 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13894 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13895 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13896 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13897 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13898 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13899 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13900 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13901 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13902 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13903 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13904 @end smallexample
13905
13906 @menu
13907 * Paired-Single Arithmetic::
13908 * Paired-Single Built-in Functions::
13909 * MIPS-3D Built-in Functions::
13910 @end menu
13911
13912 @node Paired-Single Arithmetic
13913 @subsubsection Paired-Single Arithmetic
13914
13915 The table below lists the @code{v2sf} operations for which hardware
13916 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13917 values and @code{x} is an integral value.
13918
13919 @multitable @columnfractions .50 .50
13920 @item C code @tab MIPS instruction
13921 @item @code{a + b} @tab @code{add.ps}
13922 @item @code{a - b} @tab @code{sub.ps}
13923 @item @code{-a} @tab @code{neg.ps}
13924 @item @code{a * b} @tab @code{mul.ps}
13925 @item @code{a * b + c} @tab @code{madd.ps}
13926 @item @code{a * b - c} @tab @code{msub.ps}
13927 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13928 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13929 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13930 @end multitable
13931
13932 Note that the multiply-accumulate instructions can be disabled
13933 using the command-line option @code{-mno-fused-madd}.
13934
13935 @node Paired-Single Built-in Functions
13936 @subsubsection Paired-Single Built-in Functions
13937
13938 The following paired-single functions map directly to a particular
13939 MIPS instruction. Please refer to the architecture specification
13940 for details on what each instruction does.
13941
13942 @table @code
13943 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13944 Pair lower lower (@code{pll.ps}).
13945
13946 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13947 Pair upper lower (@code{pul.ps}).
13948
13949 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13950 Pair lower upper (@code{plu.ps}).
13951
13952 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13953 Pair upper upper (@code{puu.ps}).
13954
13955 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13956 Convert pair to paired single (@code{cvt.ps.s}).
13957
13958 @item float __builtin_mips_cvt_s_pl (v2sf)
13959 Convert pair lower to single (@code{cvt.s.pl}).
13960
13961 @item float __builtin_mips_cvt_s_pu (v2sf)
13962 Convert pair upper to single (@code{cvt.s.pu}).
13963
13964 @item v2sf __builtin_mips_abs_ps (v2sf)
13965 Absolute value (@code{abs.ps}).
13966
13967 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13968 Align variable (@code{alnv.ps}).
13969
13970 @emph{Note:} The value of the third parameter must be 0 or 4
13971 modulo 8, otherwise the result is unpredictable. Please read the
13972 instruction description for details.
13973 @end table
13974
13975 The following multi-instruction functions are also available.
13976 In each case, @var{cond} can be any of the 16 floating-point conditions:
13977 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13978 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13979 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13980
13981 @table @code
13982 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13983 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13984 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13985 @code{movt.ps}/@code{movf.ps}).
13986
13987 The @code{movt} functions return the value @var{x} computed by:
13988
13989 @smallexample
13990 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13991 mov.ps @var{x},@var{c}
13992 movt.ps @var{x},@var{d},@var{cc}
13993 @end smallexample
13994
13995 The @code{movf} functions are similar but use @code{movf.ps} instead
13996 of @code{movt.ps}.
13997
13998 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13999 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14000 Comparison of two paired-single values (@code{c.@var{cond}.ps},
14001 @code{bc1t}/@code{bc1f}).
14002
14003 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14004 and return either the upper or lower half of the result. For example:
14005
14006 @smallexample
14007 v2sf a, b;
14008 if (__builtin_mips_upper_c_eq_ps (a, b))
14009 upper_halves_are_equal ();
14010 else
14011 upper_halves_are_unequal ();
14012
14013 if (__builtin_mips_lower_c_eq_ps (a, b))
14014 lower_halves_are_equal ();
14015 else
14016 lower_halves_are_unequal ();
14017 @end smallexample
14018 @end table
14019
14020 @node MIPS-3D Built-in Functions
14021 @subsubsection MIPS-3D Built-in Functions
14022
14023 The MIPS-3D Application-Specific Extension (ASE) includes additional
14024 paired-single instructions that are designed to improve the performance
14025 of 3D graphics operations. Support for these instructions is controlled
14026 by the @option{-mips3d} command-line option.
14027
14028 The functions listed below map directly to a particular MIPS-3D
14029 instruction. Please refer to the architecture specification for
14030 more details on what each instruction does.
14031
14032 @table @code
14033 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
14034 Reduction add (@code{addr.ps}).
14035
14036 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
14037 Reduction multiply (@code{mulr.ps}).
14038
14039 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
14040 Convert paired single to paired word (@code{cvt.pw.ps}).
14041
14042 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
14043 Convert paired word to paired single (@code{cvt.ps.pw}).
14044
14045 @item float __builtin_mips_recip1_s (float)
14046 @itemx double __builtin_mips_recip1_d (double)
14047 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
14048 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
14049
14050 @item float __builtin_mips_recip2_s (float, float)
14051 @itemx double __builtin_mips_recip2_d (double, double)
14052 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
14053 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
14054
14055 @item float __builtin_mips_rsqrt1_s (float)
14056 @itemx double __builtin_mips_rsqrt1_d (double)
14057 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
14058 Reduced-precision reciprocal square root (sequence step 1)
14059 (@code{rsqrt1.@var{fmt}}).
14060
14061 @item float __builtin_mips_rsqrt2_s (float, float)
14062 @itemx double __builtin_mips_rsqrt2_d (double, double)
14063 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
14064 Reduced-precision reciprocal square root (sequence step 2)
14065 (@code{rsqrt2.@var{fmt}}).
14066 @end table
14067
14068 The following multi-instruction functions are also available.
14069 In each case, @var{cond} can be any of the 16 floating-point conditions:
14070 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14071 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
14072 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14073
14074 @table @code
14075 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
14076 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
14077 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
14078 @code{bc1t}/@code{bc1f}).
14079
14080 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
14081 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
14082 For example:
14083
14084 @smallexample
14085 float a, b;
14086 if (__builtin_mips_cabs_eq_s (a, b))
14087 true ();
14088 else
14089 false ();
14090 @end smallexample
14091
14092 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14093 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14094 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
14095 @code{bc1t}/@code{bc1f}).
14096
14097 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
14098 and return either the upper or lower half of the result. For example:
14099
14100 @smallexample
14101 v2sf a, b;
14102 if (__builtin_mips_upper_cabs_eq_ps (a, b))
14103 upper_halves_are_equal ();
14104 else
14105 upper_halves_are_unequal ();
14106
14107 if (__builtin_mips_lower_cabs_eq_ps (a, b))
14108 lower_halves_are_equal ();
14109 else
14110 lower_halves_are_unequal ();
14111 @end smallexample
14112
14113 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14114 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14115 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
14116 @code{movt.ps}/@code{movf.ps}).
14117
14118 The @code{movt} functions return the value @var{x} computed by:
14119
14120 @smallexample
14121 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
14122 mov.ps @var{x},@var{c}
14123 movt.ps @var{x},@var{d},@var{cc}
14124 @end smallexample
14125
14126 The @code{movf} functions are similar but use @code{movf.ps} instead
14127 of @code{movt.ps}.
14128
14129 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14130 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14131 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14132 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14133 Comparison of two paired-single values
14134 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14135 @code{bc1any2t}/@code{bc1any2f}).
14136
14137 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14138 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
14139 result is true and the @code{all} forms return true if both results are true.
14140 For example:
14141
14142 @smallexample
14143 v2sf a, b;
14144 if (__builtin_mips_any_c_eq_ps (a, b))
14145 one_is_true ();
14146 else
14147 both_are_false ();
14148
14149 if (__builtin_mips_all_c_eq_ps (a, b))
14150 both_are_true ();
14151 else
14152 one_is_false ();
14153 @end smallexample
14154
14155 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14156 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14157 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14158 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14159 Comparison of four paired-single values
14160 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14161 @code{bc1any4t}/@code{bc1any4f}).
14162
14163 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
14164 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
14165 The @code{any} forms return true if any of the four results are true
14166 and the @code{all} forms return true if all four results are true.
14167 For example:
14168
14169 @smallexample
14170 v2sf a, b, c, d;
14171 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
14172 some_are_true ();
14173 else
14174 all_are_false ();
14175
14176 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
14177 all_are_true ();
14178 else
14179 some_are_false ();
14180 @end smallexample
14181 @end table
14182
14183 @node MIPS SIMD Architecture (MSA) Support
14184 @subsection MIPS SIMD Architecture (MSA) Support
14185
14186 @menu
14187 * MIPS SIMD Architecture Built-in Functions::
14188 @end menu
14189
14190 GCC provides intrinsics to access the SIMD instructions provided by the
14191 MSA MIPS SIMD Architecture. The interface is made available by including
14192 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
14193 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
14194 @code{__msa_*}.
14195
14196 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
14197 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
14198 data elements. The following vectors typedefs are included in @code{msa.h}:
14199 @itemize
14200 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
14201 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
14202 @item @code{v8i16}, a vector of eight signed 16-bit integers;
14203 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
14204 @item @code{v4i32}, a vector of four signed 32-bit integers;
14205 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
14206 @item @code{v2i64}, a vector of two signed 64-bit integers;
14207 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
14208 @item @code{v4f32}, a vector of four 32-bit floats;
14209 @item @code{v2f64}, a vector of two 64-bit doubles.
14210 @end itemize
14211
14212 Instructions and corresponding built-ins may have additional restrictions and/or
14213 input/output values manipulated:
14214 @itemize
14215 @item @code{imm0_1}, an integer literal in range 0 to 1;
14216 @item @code{imm0_3}, an integer literal in range 0 to 3;
14217 @item @code{imm0_7}, an integer literal in range 0 to 7;
14218 @item @code{imm0_15}, an integer literal in range 0 to 15;
14219 @item @code{imm0_31}, an integer literal in range 0 to 31;
14220 @item @code{imm0_63}, an integer literal in range 0 to 63;
14221 @item @code{imm0_255}, an integer literal in range 0 to 255;
14222 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
14223 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
14224 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
14225 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
14226 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
14227 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
14228 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
14229 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
14230 @item @code{imm1_4}, an integer literal in range 1 to 4;
14231 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
14232 @end itemize
14233
14234 @smallexample
14235 @{
14236 typedef int i32;
14237 #if __LONG_MAX__ == __LONG_LONG_MAX__
14238 typedef long i64;
14239 #else
14240 typedef long long i64;
14241 #endif
14242
14243 typedef unsigned int u32;
14244 #if __LONG_MAX__ == __LONG_LONG_MAX__
14245 typedef unsigned long u64;
14246 #else
14247 typedef unsigned long long u64;
14248 #endif
14249
14250 typedef double f64;
14251 typedef float f32;
14252 @}
14253 @end smallexample
14254
14255 @node MIPS SIMD Architecture Built-in Functions
14256 @subsubsection MIPS SIMD Architecture Built-in Functions
14257
14258 The intrinsics provided are listed below; each is named after the
14259 machine instruction.
14260
14261 @smallexample
14262 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
14263 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
14264 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
14265 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
14266
14267 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
14268 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
14269 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
14270 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
14271
14272 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
14273 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
14274 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
14275 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
14276
14277 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
14278 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
14279 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
14280 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
14281
14282 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
14283 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
14284 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
14285 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
14286
14287 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
14288 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
14289 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
14290 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
14291
14292 v16u8 __builtin_msa_and_v (v16u8, v16u8);
14293
14294 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
14295
14296 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
14297 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
14298 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
14299 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
14300
14301 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
14302 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
14303 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
14304 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
14305
14306 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
14307 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
14308 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
14309 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
14310
14311 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
14312 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
14313 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
14314 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
14315
14316 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
14317 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
14318 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
14319 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
14320
14321 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
14322 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
14323 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
14324 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
14325
14326 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
14327 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
14328 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
14329 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
14330
14331 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
14332 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
14333 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
14334 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
14335
14336 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
14337 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
14338 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
14339 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
14340
14341 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
14342 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
14343 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
14344 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
14345
14346 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
14347 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
14348 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
14349 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
14350
14351 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
14352 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
14353 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
14354 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
14355
14356 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
14357
14358 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
14359
14360 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
14361
14362 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
14363
14364 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
14365 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
14366 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
14367 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
14368
14369 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
14370 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
14371 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
14372 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
14373
14374 i32 __builtin_msa_bnz_b (v16u8);
14375 i32 __builtin_msa_bnz_h (v8u16);
14376 i32 __builtin_msa_bnz_w (v4u32);
14377 i32 __builtin_msa_bnz_d (v2u64);
14378
14379 i32 __builtin_msa_bnz_v (v16u8);
14380
14381 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
14382
14383 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
14384
14385 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
14386 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
14387 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
14388 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
14389
14390 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
14391 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
14392 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
14393 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
14394
14395 i32 __builtin_msa_bz_b (v16u8);
14396 i32 __builtin_msa_bz_h (v8u16);
14397 i32 __builtin_msa_bz_w (v4u32);
14398 i32 __builtin_msa_bz_d (v2u64);
14399
14400 i32 __builtin_msa_bz_v (v16u8);
14401
14402 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
14403 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
14404 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
14405 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
14406
14407 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
14408 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
14409 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
14410 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
14411
14412 i32 __builtin_msa_cfcmsa (imm0_31);
14413
14414 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
14415 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
14416 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
14417 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
14418
14419 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
14420 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
14421 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
14422 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
14423
14424 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
14425 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
14426 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
14427 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
14428
14429 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
14430 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
14431 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
14432 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
14433
14434 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
14435 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
14436 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
14437 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
14438
14439 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
14440 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
14441 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
14442 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
14443
14444 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
14445 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
14446 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14447 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14448
14449 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14450 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14451 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14452 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14453
14454 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14455 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14456 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14457 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14458
14459 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14460 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14461 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14462 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14463
14464 void __builtin_msa_ctcmsa (imm0_31, i32);
14465
14466 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14467 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14468 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14469 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14470
14471 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14472 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14473 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14474 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14475
14476 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14477 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14478 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14479
14480 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14481 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14482 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14483
14484 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14485 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14486 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14487
14488 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14489 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14490 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14491
14492 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14493 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14494 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14495
14496 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14497 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14498 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14499
14500 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
14501 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
14502
14503 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
14504 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
14505
14506 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
14507 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
14508
14509 v4i32 __builtin_msa_fclass_w (v4f32);
14510 v2i64 __builtin_msa_fclass_d (v2f64);
14511
14512 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
14513 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
14514
14515 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
14516 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
14517
14518 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
14519 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
14520
14521 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
14522 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
14523
14524 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
14525 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
14526
14527 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
14528 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
14529
14530 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
14531 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
14532
14533 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
14534 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
14535
14536 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
14537 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
14538
14539 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
14540 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
14541
14542 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
14543 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
14544
14545 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
14546 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
14547
14548 v4f32 __builtin_msa_fexupl_w (v8i16);
14549 v2f64 __builtin_msa_fexupl_d (v4f32);
14550
14551 v4f32 __builtin_msa_fexupr_w (v8i16);
14552 v2f64 __builtin_msa_fexupr_d (v4f32);
14553
14554 v4f32 __builtin_msa_ffint_s_w (v4i32);
14555 v2f64 __builtin_msa_ffint_s_d (v2i64);
14556
14557 v4f32 __builtin_msa_ffint_u_w (v4u32);
14558 v2f64 __builtin_msa_ffint_u_d (v2u64);
14559
14560 v4f32 __builtin_msa_ffql_w (v8i16);
14561 v2f64 __builtin_msa_ffql_d (v4i32);
14562
14563 v4f32 __builtin_msa_ffqr_w (v8i16);
14564 v2f64 __builtin_msa_ffqr_d (v4i32);
14565
14566 v16i8 __builtin_msa_fill_b (i32);
14567 v8i16 __builtin_msa_fill_h (i32);
14568 v4i32 __builtin_msa_fill_w (i32);
14569 v2i64 __builtin_msa_fill_d (i64);
14570
14571 v4f32 __builtin_msa_flog2_w (v4f32);
14572 v2f64 __builtin_msa_flog2_d (v2f64);
14573
14574 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
14575 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
14576
14577 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
14578 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
14579
14580 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
14581 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
14582
14583 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
14584 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
14585
14586 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
14587 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
14588
14589 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
14590 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
14591
14592 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
14593 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
14594
14595 v4f32 __builtin_msa_frint_w (v4f32);
14596 v2f64 __builtin_msa_frint_d (v2f64);
14597
14598 v4f32 __builtin_msa_frcp_w (v4f32);
14599 v2f64 __builtin_msa_frcp_d (v2f64);
14600
14601 v4f32 __builtin_msa_frsqrt_w (v4f32);
14602 v2f64 __builtin_msa_frsqrt_d (v2f64);
14603
14604 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
14605 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
14606
14607 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
14608 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
14609
14610 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
14611 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
14612
14613 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
14614 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
14615
14616 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
14617 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
14618
14619 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
14620 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
14621
14622 v4f32 __builtin_msa_fsqrt_w (v4f32);
14623 v2f64 __builtin_msa_fsqrt_d (v2f64);
14624
14625 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
14626 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
14627
14628 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
14629 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
14630
14631 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
14632 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
14633
14634 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
14635 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
14636
14637 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
14638 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
14639
14640 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
14641 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
14642
14643 v4i32 __builtin_msa_ftint_s_w (v4f32);
14644 v2i64 __builtin_msa_ftint_s_d (v2f64);
14645
14646 v4u32 __builtin_msa_ftint_u_w (v4f32);
14647 v2u64 __builtin_msa_ftint_u_d (v2f64);
14648
14649 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
14650 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
14651
14652 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
14653 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
14654
14655 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
14656 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
14657
14658 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
14659 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
14660 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
14661
14662 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
14663 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
14664 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
14665
14666 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
14667 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
14668 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
14669
14670 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
14671 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
14672 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
14673
14674 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
14675 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
14676 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
14677 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
14678
14679 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
14680 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
14681 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
14682 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
14683
14684 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
14685 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
14686 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
14687 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
14688
14689 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
14690 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
14691 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
14692 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
14693
14694 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
14695 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
14696 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
14697 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
14698
14699 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
14700 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
14701 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
14702 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
14703
14704 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
14705 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
14706 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
14707 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
14708
14709 v16i8 __builtin_msa_ldi_b (imm_n512_511);
14710 v8i16 __builtin_msa_ldi_h (imm_n512_511);
14711 v4i32 __builtin_msa_ldi_w (imm_n512_511);
14712 v2i64 __builtin_msa_ldi_d (imm_n512_511);
14713
14714 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
14715 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
14716
14717 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
14718 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
14719
14720 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
14721 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
14722 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
14723 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
14724
14725 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
14726 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
14727 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
14728 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
14729
14730 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
14731 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
14732 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
14733 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
14734
14735 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
14736 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
14737 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
14738 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
14739
14740 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
14741 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
14742 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
14743 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
14744
14745 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
14746 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
14747 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
14748 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
14749
14750 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
14751 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
14752 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
14753 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
14754
14755 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
14756 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
14757 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
14758 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
14759
14760 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
14761 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
14762 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
14763 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
14764
14765 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
14766 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
14767 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
14768 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
14769
14770 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
14771 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
14772 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
14773 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
14774
14775 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
14776 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
14777 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
14778 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
14779
14780 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
14781 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
14782 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
14783 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
14784
14785 v16i8 __builtin_msa_move_v (v16i8);
14786
14787 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
14788 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
14789
14790 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
14791 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
14792
14793 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
14794 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
14795 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
14796 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
14797
14798 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
14799 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
14800
14801 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
14802 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
14803
14804 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
14805 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
14806 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
14807 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
14808
14809 v16i8 __builtin_msa_nloc_b (v16i8);
14810 v8i16 __builtin_msa_nloc_h (v8i16);
14811 v4i32 __builtin_msa_nloc_w (v4i32);
14812 v2i64 __builtin_msa_nloc_d (v2i64);
14813
14814 v16i8 __builtin_msa_nlzc_b (v16i8);
14815 v8i16 __builtin_msa_nlzc_h (v8i16);
14816 v4i32 __builtin_msa_nlzc_w (v4i32);
14817 v2i64 __builtin_msa_nlzc_d (v2i64);
14818
14819 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
14820
14821 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
14822
14823 v16u8 __builtin_msa_or_v (v16u8, v16u8);
14824
14825 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
14826
14827 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
14828 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
14829 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
14830 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
14831
14832 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
14833 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
14834 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
14835 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
14836
14837 v16i8 __builtin_msa_pcnt_b (v16i8);
14838 v8i16 __builtin_msa_pcnt_h (v8i16);
14839 v4i32 __builtin_msa_pcnt_w (v4i32);
14840 v2i64 __builtin_msa_pcnt_d (v2i64);
14841
14842 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
14843 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
14844 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
14845 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
14846
14847 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
14848 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
14849 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
14850 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
14851
14852 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
14853 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
14854 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
14855
14856 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
14857 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
14858 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
14859 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
14860
14861 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
14862 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
14863 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
14864 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
14865
14866 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
14867 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
14868 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
14869 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
14870
14871 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
14872 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
14873 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
14874 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
14875
14876 v16i8 __builtin_msa_splat_b (v16i8, i32);
14877 v8i16 __builtin_msa_splat_h (v8i16, i32);
14878 v4i32 __builtin_msa_splat_w (v4i32, i32);
14879 v2i64 __builtin_msa_splat_d (v2i64, i32);
14880
14881 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
14882 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
14883 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
14884 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
14885
14886 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
14887 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
14888 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
14889 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
14890
14891 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
14892 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
14893 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
14894 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
14895
14896 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
14897 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
14898 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
14899 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
14900
14901 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
14902 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
14903 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
14904 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
14905
14906 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
14907 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
14908 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
14909 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
14910
14911 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
14912 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
14913 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
14914 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
14915
14916 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
14917 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
14918 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
14919 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
14920
14921 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
14922 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
14923 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
14924 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
14925
14926 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
14927 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
14928 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
14929 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
14930
14931 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
14932 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
14933 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
14934 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
14935
14936 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
14937 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
14938 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
14939 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
14940
14941 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
14942 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
14943 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
14944 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
14945
14946 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
14947 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
14948 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
14949 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
14950
14951 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
14952 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
14953 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
14954 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
14955
14956 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
14957 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
14958 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
14959 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
14960
14961 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
14962 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
14963 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
14964 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
14965
14966 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
14967
14968 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
14969 @end smallexample
14970
14971 @node Other MIPS Built-in Functions
14972 @subsection Other MIPS Built-in Functions
14973
14974 GCC provides other MIPS-specific built-in functions:
14975
14976 @table @code
14977 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
14978 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
14979 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
14980 when this function is available.
14981
14982 @item unsigned int __builtin_mips_get_fcsr (void)
14983 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
14984 Get and set the contents of the floating-point control and status register
14985 (FPU control register 31). These functions are only available in hard-float
14986 code but can be called in both MIPS16 and non-MIPS16 contexts.
14987
14988 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
14989 register except the condition codes, which GCC assumes are preserved.
14990 @end table
14991
14992 @node MSP430 Built-in Functions
14993 @subsection MSP430 Built-in Functions
14994
14995 GCC provides a couple of special builtin functions to aid in the
14996 writing of interrupt handlers in C.
14997
14998 @table @code
14999 @item __bic_SR_register_on_exit (int @var{mask})
15000 This clears the indicated bits in the saved copy of the status register
15001 currently residing on the stack. This only works inside interrupt
15002 handlers and the changes to the status register will only take affect
15003 once the handler returns.
15004
15005 @item __bis_SR_register_on_exit (int @var{mask})
15006 This sets the indicated bits in the saved copy of the status register
15007 currently residing on the stack. This only works inside interrupt
15008 handlers and the changes to the status register will only take affect
15009 once the handler returns.
15010
15011 @item __delay_cycles (long long @var{cycles})
15012 This inserts an instruction sequence that takes exactly @var{cycles}
15013 cycles (between 0 and about 17E9) to complete. The inserted sequence
15014 may use jumps, loops, or no-ops, and does not interfere with any other
15015 instructions. Note that @var{cycles} must be a compile-time constant
15016 integer - that is, you must pass a number, not a variable that may be
15017 optimized to a constant later. The number of cycles delayed by this
15018 builtin is exact.
15019 @end table
15020
15021 @node NDS32 Built-in Functions
15022 @subsection NDS32 Built-in Functions
15023
15024 These built-in functions are available for the NDS32 target:
15025
15026 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
15027 Insert an ISYNC instruction into the instruction stream where
15028 @var{addr} is an instruction address for serialization.
15029 @end deftypefn
15030
15031 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
15032 Insert an ISB instruction into the instruction stream.
15033 @end deftypefn
15034
15035 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
15036 Return the content of a system register which is mapped by @var{sr}.
15037 @end deftypefn
15038
15039 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
15040 Return the content of a user space register which is mapped by @var{usr}.
15041 @end deftypefn
15042
15043 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
15044 Move the @var{value} to a system register which is mapped by @var{sr}.
15045 @end deftypefn
15046
15047 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
15048 Move the @var{value} to a user space register which is mapped by @var{usr}.
15049 @end deftypefn
15050
15051 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
15052 Enable global interrupt.
15053 @end deftypefn
15054
15055 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
15056 Disable global interrupt.
15057 @end deftypefn
15058
15059 @node picoChip Built-in Functions
15060 @subsection picoChip Built-in Functions
15061
15062 GCC provides an interface to selected machine instructions from the
15063 picoChip instruction set.
15064
15065 @table @code
15066 @item int __builtin_sbc (int @var{value})
15067 Sign bit count. Return the number of consecutive bits in @var{value}
15068 that have the same value as the sign bit. The result is the number of
15069 leading sign bits minus one, giving the number of redundant sign bits in
15070 @var{value}.
15071
15072 @item int __builtin_byteswap (int @var{value})
15073 Byte swap. Return the result of swapping the upper and lower bytes of
15074 @var{value}.
15075
15076 @item int __builtin_brev (int @var{value})
15077 Bit reversal. Return the result of reversing the bits in
15078 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
15079 and so on.
15080
15081 @item int __builtin_adds (int @var{x}, int @var{y})
15082 Saturating addition. Return the result of adding @var{x} and @var{y},
15083 storing the value 32767 if the result overflows.
15084
15085 @item int __builtin_subs (int @var{x}, int @var{y})
15086 Saturating subtraction. Return the result of subtracting @var{y} from
15087 @var{x}, storing the value @minus{}32768 if the result overflows.
15088
15089 @item void __builtin_halt (void)
15090 Halt. The processor stops execution. This built-in is useful for
15091 implementing assertions.
15092
15093 @end table
15094
15095 @node PowerPC Built-in Functions
15096 @subsection PowerPC Built-in Functions
15097
15098 The following built-in functions are always available and can be used to
15099 check the PowerPC target platform type:
15100
15101 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
15102 This function is a @code{nop} on the PowerPC platform and is included solely
15103 to maintain API compatibility with the x86 builtins.
15104 @end deftypefn
15105
15106 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
15107 This function returns a value of @code{1} if the run-time CPU is of type
15108 @var{cpuname} and returns @code{0} otherwise
15109
15110 The @code{__builtin_cpu_is} function requires GLIBC 2.23 or newer
15111 which exports the hardware capability bits. GCC defines the macro
15112 @code{__BUILTIN_CPU_SUPPORTS__} if the @code{__builtin_cpu_supports}
15113 built-in function is fully supported.
15114
15115 If GCC was configured to use a GLIBC before 2.23, the built-in
15116 function @code{__builtin_cpu_is} always returns a 0 and the compiler
15117 issues a warning.
15118
15119 The following CPU names can be detected:
15120
15121 @table @samp
15122 @item power9
15123 IBM POWER9 Server CPU.
15124 @item power8
15125 IBM POWER8 Server CPU.
15126 @item power7
15127 IBM POWER7 Server CPU.
15128 @item power6x
15129 IBM POWER6 Server CPU (RAW mode).
15130 @item power6
15131 IBM POWER6 Server CPU (Architected mode).
15132 @item power5+
15133 IBM POWER5+ Server CPU.
15134 @item power5
15135 IBM POWER5 Server CPU.
15136 @item ppc970
15137 IBM 970 Server CPU (ie, Apple G5).
15138 @item power4
15139 IBM POWER4 Server CPU.
15140 @item ppca2
15141 IBM A2 64-bit Embedded CPU
15142 @item ppc476
15143 IBM PowerPC 476FP 32-bit Embedded CPU.
15144 @item ppc464
15145 IBM PowerPC 464 32-bit Embedded CPU.
15146 @item ppc440
15147 PowerPC 440 32-bit Embedded CPU.
15148 @item ppc405
15149 PowerPC 405 32-bit Embedded CPU.
15150 @item ppc-cell-be
15151 IBM PowerPC Cell Broadband Engine Architecture CPU.
15152 @end table
15153
15154 Here is an example:
15155 @smallexample
15156 #ifdef __BUILTIN_CPU_SUPPORTS__
15157 if (__builtin_cpu_is ("power8"))
15158 @{
15159 do_power8 (); // POWER8 specific implementation.
15160 @}
15161 else
15162 #endif
15163 @{
15164 do_generic (); // Generic implementation.
15165 @}
15166 @end smallexample
15167 @end deftypefn
15168
15169 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
15170 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
15171 feature @var{feature} and returns @code{0} otherwise.
15172
15173 The @code{__builtin_cpu_supports} function requires GLIBC 2.23 or
15174 newer which exports the hardware capability bits. GCC defines the
15175 macro @code{__BUILTIN_CPU_SUPPORTS__} if the
15176 @code{__builtin_cpu_supports} built-in function is fully supported.
15177
15178 If GCC was configured to use a GLIBC before 2.23, the built-in
15179 function @code{__builtin_cpu_suports} always returns a 0 and the
15180 compiler issues a warning.
15181
15182 The following features can be
15183 detected:
15184
15185 @table @samp
15186 @item 4xxmac
15187 4xx CPU has a Multiply Accumulator.
15188 @item altivec
15189 CPU has a SIMD/Vector Unit.
15190 @item arch_2_05
15191 CPU supports ISA 2.05 (eg, POWER6)
15192 @item arch_2_06
15193 CPU supports ISA 2.06 (eg, POWER7)
15194 @item arch_2_07
15195 CPU supports ISA 2.07 (eg, POWER8)
15196 @item arch_3_00
15197 CPU supports ISA 3.0 (eg, POWER9)
15198 @item archpmu
15199 CPU supports the set of compatible performance monitoring events.
15200 @item booke
15201 CPU supports the Embedded ISA category.
15202 @item cellbe
15203 CPU has a CELL broadband engine.
15204 @item dfp
15205 CPU has a decimal floating point unit.
15206 @item dscr
15207 CPU supports the data stream control register.
15208 @item ebb
15209 CPU supports event base branching.
15210 @item efpdouble
15211 CPU has a SPE double precision floating point unit.
15212 @item efpsingle
15213 CPU has a SPE single precision floating point unit.
15214 @item fpu
15215 CPU has a floating point unit.
15216 @item htm
15217 CPU has hardware transaction memory instructions.
15218 @item htm-nosc
15219 Kernel aborts hardware transactions when a syscall is made.
15220 @item ic_snoop
15221 CPU supports icache snooping capabilities.
15222 @item ieee128
15223 CPU supports 128-bit IEEE binary floating point instructions.
15224 @item isel
15225 CPU supports the integer select instruction.
15226 @item mmu
15227 CPU has a memory management unit.
15228 @item notb
15229 CPU does not have a timebase (eg, 601 and 403gx).
15230 @item pa6t
15231 CPU supports the PA Semi 6T CORE ISA.
15232 @item power4
15233 CPU supports ISA 2.00 (eg, POWER4)
15234 @item power5
15235 CPU supports ISA 2.02 (eg, POWER5)
15236 @item power5+
15237 CPU supports ISA 2.03 (eg, POWER5+)
15238 @item power6x
15239 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
15240 @item ppc32
15241 CPU supports 32-bit mode execution.
15242 @item ppc601
15243 CPU supports the old POWER ISA (eg, 601)
15244 @item ppc64
15245 CPU supports 64-bit mode execution.
15246 @item ppcle
15247 CPU supports a little-endian mode that uses address swizzling.
15248 @item smt
15249 CPU support simultaneous multi-threading.
15250 @item spe
15251 CPU has a signal processing extension unit.
15252 @item tar
15253 CPU supports the target address register.
15254 @item true_le
15255 CPU supports true little-endian mode.
15256 @item ucache
15257 CPU has unified I/D cache.
15258 @item vcrypto
15259 CPU supports the vector cryptography instructions.
15260 @item vsx
15261 CPU supports the vector-scalar extension.
15262 @end table
15263
15264 Here is an example:
15265 @smallexample
15266 #ifdef __BUILTIN_CPU_SUPPORTS__
15267 if (__builtin_cpu_supports ("fpu"))
15268 @{
15269 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
15270 @}
15271 else
15272 #endif
15273 @{
15274 dst = __fadd (src1, src2); // Software FP addition function.
15275 @}
15276 @end smallexample
15277 @end deftypefn
15278
15279 These built-in functions are available for the PowerPC family of
15280 processors:
15281 @smallexample
15282 float __builtin_recipdivf (float, float);
15283 float __builtin_rsqrtf (float);
15284 double __builtin_recipdiv (double, double);
15285 double __builtin_rsqrt (double);
15286 uint64_t __builtin_ppc_get_timebase ();
15287 unsigned long __builtin_ppc_mftb ();
15288 double __builtin_unpack_longdouble (long double, int);
15289 long double __builtin_pack_longdouble (double, double);
15290 @end smallexample
15291
15292 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
15293 @code{__builtin_rsqrtf} functions generate multiple instructions to
15294 implement the reciprocal sqrt functionality using reciprocal sqrt
15295 estimate instructions.
15296
15297 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
15298 functions generate multiple instructions to implement division using
15299 the reciprocal estimate instructions.
15300
15301 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
15302 functions generate instructions to read the Time Base Register. The
15303 @code{__builtin_ppc_get_timebase} function may generate multiple
15304 instructions and always returns the 64 bits of the Time Base Register.
15305 The @code{__builtin_ppc_mftb} function always generates one instruction and
15306 returns the Time Base Register value as an unsigned long, throwing away
15307 the most significant word on 32-bit environments.
15308
15309 Additional built-in functions are available for the 64-bit PowerPC
15310 family of processors, for efficient use of 128-bit floating point
15311 (@code{__float128}) values.
15312
15313 The following floating-point built-in functions are available with
15314 @code{-mfloat128} and Altivec support. All of them implement the
15315 function that is part of the name.
15316
15317 @smallexample
15318 __float128 __builtin_fabsq (__float128)
15319 __float128 __builtin_copysignq (__float128, __float128)
15320 @end smallexample
15321
15322 The following built-in functions are available with @code{-mfloat128}
15323 and Altivec support.
15324
15325 @table @code
15326 @item __float128 __builtin_infq (void)
15327 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
15328 @findex __builtin_infq
15329
15330 @item __float128 __builtin_huge_valq (void)
15331 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
15332 @findex __builtin_huge_valq
15333
15334 @item __float128 __builtin_nanq (void)
15335 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
15336 @findex __builtin_nanq
15337
15338 @item __float128 __builtin_nansq (void)
15339 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
15340 @findex __builtin_nansq
15341 @end table
15342
15343 The following built-in functions are available on Linux 64-bit systems
15344 that use the ISA 3.0 instruction set.
15345
15346 @table @code
15347 @item __float128 __builtin_sqrtf128 (__float128)
15348 Similar to @code{__builtin_sqrtf}, except the return and input types
15349 are @code{__float128}.
15350 @findex __builtin_sqrtf128
15351
15352 @item __float128 __builtin_fmaf128 (__float128, __float128, __float128)
15353 Similar to @code{__builtin_fma}, except the return and input types are
15354 @code{__float128}.
15355 @findex __builtin_fmaf128
15356 @end table
15357
15358 The following built-in functions are available for the PowerPC family
15359 of processors, starting with ISA 2.05 or later (@option{-mcpu=power6}
15360 or @option{-mcmpb}):
15361 @smallexample
15362 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
15363 unsigned int __builtin_cmpb (unsigned int, unsigned int);
15364 @end smallexample
15365
15366 The @code{__builtin_cmpb} function
15367 performs a byte-wise compare on the contents of its two arguments,
15368 returning the result of the byte-wise comparison as the returned
15369 value. For each byte comparison, the corresponding byte of the return
15370 value holds 0xff if the input bytes are equal and 0 if the input bytes
15371 are not equal. If either of the arguments to this built-in function
15372 is wider than 32 bits, the function call expands into the form that
15373 expects @code{unsigned long long int} arguments
15374 which is only available on 64-bit targets.
15375
15376 The following built-in functions are available for the PowerPC family
15377 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
15378 or @option{-mpopcntd}):
15379 @smallexample
15380 long __builtin_bpermd (long, long);
15381 int __builtin_divwe (int, int);
15382 int __builtin_divweo (int, int);
15383 unsigned int __builtin_divweu (unsigned int, unsigned int);
15384 unsigned int __builtin_divweuo (unsigned int, unsigned int);
15385 long __builtin_divde (long, long);
15386 long __builtin_divdeo (long, long);
15387 unsigned long __builtin_divdeu (unsigned long, unsigned long);
15388 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
15389 unsigned int cdtbcd (unsigned int);
15390 unsigned int cbcdtd (unsigned int);
15391 unsigned int addg6s (unsigned int, unsigned int);
15392 @end smallexample
15393
15394 The @code{__builtin_divde}, @code{__builtin_divdeo},
15395 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
15396 64-bit environment support ISA 2.06 or later.
15397
15398 The following built-in functions are available for the PowerPC family
15399 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
15400 @smallexample
15401 long long __builtin_darn (void);
15402 long long __builtin_darn_raw (void);
15403 int __builtin_darn_32 (void);
15404
15405 unsigned int scalar_extract_exp (double source);
15406 unsigned long long int scalar_extract_exp (__ieee128 source);
15407
15408 unsigned long long int scalar_extract_sig (double source);
15409 unsigned __int128 scalar_extract_sig (__ieee128 source);
15410
15411 double
15412 scalar_insert_exp (unsigned long long int significand, unsigned long long int exponent);
15413 double
15414 scalar_insert_exp (double significand, unsigned long long int exponent);
15415
15416 ieee_128
15417 scalar_insert_exp (unsigned __int128 significand, unsigned long long int exponent);
15418 ieee_128
15419 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent);
15420
15421 int scalar_cmp_exp_gt (double arg1, double arg2);
15422 int scalar_cmp_exp_lt (double arg1, double arg2);
15423 int scalar_cmp_exp_eq (double arg1, double arg2);
15424 int scalar_cmp_exp_unordered (double arg1, double arg2);
15425
15426 bool scalar_test_data_class (float source, const int condition);
15427 bool scalar_test_data_class (double source, const int condition);
15428 bool scalar_test_data_class (__ieee128 source, const int condition);
15429
15430 bool scalar_test_neg (float source);
15431 bool scalar_test_neg (double source);
15432 bool scalar_test_neg (__ieee128 source);
15433
15434 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
15435 int __builtin_byte_in_range (unsigned char u, unsigned int range);
15436 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
15437
15438 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
15439 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
15440 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
15441 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
15442
15443 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
15444 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
15445 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
15446 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
15447
15448 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
15449 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
15450 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
15451 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
15452
15453 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
15454 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
15455 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
15456 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
15457 @end smallexample
15458
15459 The @code{__builtin_darn} and @code{__builtin_darn_raw}
15460 functions require a
15461 64-bit environment supporting ISA 3.0 or later.
15462 The @code{__builtin_darn} function provides a 64-bit conditioned
15463 random number. The @code{__builtin_darn_raw} function provides a
15464 64-bit raw random number. The @code{__builtin_darn_32} function
15465 provides a 32-bit random number.
15466
15467 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
15468 functions require a 64-bit environment supporting ISA 3.0 or later.
15469 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
15470 functions return the significand and the biased exponent value
15471 respectively of their @code{source} arguments.
15472 When supplied with a 64-bit @code{source} argument, the
15473 result returned by @code{scalar_extract_sig} has
15474 the @code{0x0010000000000000} bit set if the
15475 function's @code{source} argument is in normalized form.
15476 Otherwise, this bit is set to 0.
15477 When supplied with a 128-bit @code{source} argument, the
15478 @code{0x00010000000000000000000000000000} bit of the result is
15479 treated similarly.
15480 Note that the sign of the significand is not represented in the result
15481 returned from the @code{scalar_extract_sig} function. Use the
15482 @code{scalar_test_neg} function to test the sign of its @code{double}
15483 argument.
15484
15485 The @code{scalar_insert_exp}
15486 functions require a 64-bit environment supporting ISA 3.0 or later.
15487 When supplied with a 64-bit first argument, the
15488 @code{scalar_insert_exp} built-in function returns a double-precision
15489 floating point value that is constructed by assembling the values of its
15490 @code{significand} and @code{exponent} arguments. The sign of the
15491 result is copied from the most significant bit of the
15492 @code{significand} argument. The significand and exponent components
15493 of the result are composed of the least significant 11 bits of the
15494 @code{exponent} argument and the least significant 52 bits of the
15495 @code{significand} argument respectively.
15496
15497 When supplied with a 128-bit first argument, the
15498 @code{scalar_insert_exp} built-in function returns a quad-precision
15499 ieee floating point value. The sign bit of the result is copied from
15500 the most significant bit of the @code{significand} argument.
15501 The significand and exponent components of the result are composed of
15502 the least significant 15 bits of the @code{exponent} argument and the
15503 least significant 112 bits of the @code{significand} argument respectively.
15504
15505 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
15506 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
15507 functions return a non-zero value if @code{arg1} is greater than, less
15508 than, equal to, or not comparable to @code{arg2} respectively. The
15509 arguments are not comparable if one or the other equals NaN (not a
15510 number).
15511
15512 The @code{scalar_test_data_class} built-in function returns 1
15513 if any of the condition tests enabled by the value of the
15514 @code{condition} variable are true, and 0 otherwise. The
15515 @code{condition} argument must be a compile-time constant integer with
15516 value not exceeding 127. The
15517 @code{condition} argument is encoded as a bitmask with each bit
15518 enabling the testing of a different condition, as characterized by the
15519 following:
15520 @smallexample
15521 0x40 Test for NaN
15522 0x20 Test for +Infinity
15523 0x10 Test for -Infinity
15524 0x08 Test for +Zero
15525 0x04 Test for -Zero
15526 0x02 Test for +Denormal
15527 0x01 Test for -Denormal
15528 @end smallexample
15529
15530 The @code{scalar_test_neg} built-in function returns 1 if its
15531 @code{source} argument holds a negative value, 0 otherwise.
15532
15533 The @code{__builtin_byte_in_set} function requires a
15534 64-bit environment supporting ISA 3.0 or later. This function returns
15535 a non-zero value if and only if its @code{u} argument exactly equals one of
15536 the eight bytes contained within its 64-bit @code{set} argument.
15537
15538 The @code{__builtin_byte_in_range} and
15539 @code{__builtin_byte_in_either_range} require an environment
15540 supporting ISA 3.0 or later. For these two functions, the
15541 @code{range} argument is encoded as 4 bytes, organized as
15542 @code{hi_1:lo_1:hi_2:lo_2}.
15543 The @code{__builtin_byte_in_range} function returns a
15544 non-zero value if and only if its @code{u} argument is within the
15545 range bounded between @code{lo_2} and @code{hi_2} inclusive.
15546 The @code{__builtin_byte_in_either_range} function returns non-zero if
15547 and only if its @code{u} argument is within either the range bounded
15548 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
15549 between @code{lo_2} and @code{hi_2} inclusive.
15550
15551 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
15552 if and only if the number of signficant digits of its @code{value} argument
15553 is less than its @code{comparison} argument. The
15554 @code{__builtin_dfp_dtstsfi_lt_dd} and
15555 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
15556 require that the type of the @code{value} argument be
15557 @code{__Decimal64} and @code{__Decimal128} respectively.
15558
15559 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
15560 if and only if the number of signficant digits of its @code{value} argument
15561 is greater than its @code{comparison} argument. The
15562 @code{__builtin_dfp_dtstsfi_gt_dd} and
15563 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
15564 require that the type of the @code{value} argument be
15565 @code{__Decimal64} and @code{__Decimal128} respectively.
15566
15567 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
15568 if and only if the number of signficant digits of its @code{value} argument
15569 equals its @code{comparison} argument. The
15570 @code{__builtin_dfp_dtstsfi_eq_dd} and
15571 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
15572 require that the type of the @code{value} argument be
15573 @code{__Decimal64} and @code{__Decimal128} respectively.
15574
15575 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
15576 if and only if its @code{value} argument has an undefined number of
15577 significant digits, such as when @code{value} is an encoding of @code{NaN}.
15578 The @code{__builtin_dfp_dtstsfi_ov_dd} and
15579 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
15580 require that the type of the @code{value} argument be
15581 @code{__Decimal64} and @code{__Decimal128} respectively.
15582
15583 The following built-in functions are also available for the PowerPC family
15584 of processors, starting with ISA 3.0 or later
15585 (@option{-mcpu=power9}). These string functions are described
15586 separately in order to group the descriptions closer to the function
15587 prototypes:
15588 @smallexample
15589 int vec_all_nez (vector signed char, vector signed char);
15590 int vec_all_nez (vector unsigned char, vector unsigned char);
15591 int vec_all_nez (vector signed short, vector signed short);
15592 int vec_all_nez (vector unsigned short, vector unsigned short);
15593 int vec_all_nez (vector signed int, vector signed int);
15594 int vec_all_nez (vector unsigned int, vector unsigned int);
15595
15596 int vec_any_eqz (vector signed char, vector signed char);
15597 int vec_any_eqz (vector unsigned char, vector unsigned char);
15598 int vec_any_eqz (vector signed short, vector signed short);
15599 int vec_any_eqz (vector unsigned short, vector unsigned short);
15600 int vec_any_eqz (vector signed int, vector signed int);
15601 int vec_any_eqz (vector unsigned int, vector unsigned int);
15602
15603 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
15604 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
15605 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
15606 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
15607 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
15608 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
15609
15610 vector signed char vec_cnttz (vector signed char);
15611 vector unsigned char vec_cnttz (vector unsigned char);
15612 vector signed short vec_cnttz (vector signed short);
15613 vector unsigned short vec_cnttz (vector unsigned short);
15614 vector signed int vec_cnttz (vector signed int);
15615 vector unsigned int vec_cnttz (vector unsigned int);
15616 vector signed long long vec_cnttz (vector signed long long);
15617 vector unsigned long long vec_cnttz (vector unsigned long long);
15618
15619 signed int vec_cntlz_lsbb (vector signed char);
15620 signed int vec_cntlz_lsbb (vector unsigned char);
15621
15622 signed int vec_cnttz_lsbb (vector signed char);
15623 signed int vec_cnttz_lsbb (vector unsigned char);
15624
15625 vector unsigned short vec_pack_to_short_fp32 (vector float, vector float);
15626
15627 vector signed char vec_xl_be (signed long long, signed char *);
15628 vector unsigned char vec_xl_be (signed long long, unsigned char *);
15629 vector signed int vec_xl_be (signed long long, signed int *);
15630 vector unsigned int vec_xl_be (signed long long, unsigned int *);
15631 vector signed __int128 vec_xl_be (signed long long, signed __int128 *);
15632 vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *);
15633 vector signed long long vec_xl_be (signed long long, signed long long *);
15634 vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
15635 vector signed short vec_xl_be (signed long long, signed short *);
15636 vector unsigned short vec_xl_be (signed long long, unsigned short *);
15637 vector double vec_xl_be (signed long long, double *);
15638 vector float vec_xl_be (signed long long, float *);
15639
15640 vector signed char vec_xl_len (signed char *addr, size_t len);
15641 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
15642 vector signed int vec_xl_len (signed int *addr, size_t len);
15643 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
15644 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
15645 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
15646 vector signed long long vec_xl_len (signed long long *addr, size_t len);
15647 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
15648 vector signed short vec_xl_len (signed short *addr, size_t len);
15649 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
15650 vector double vec_xl_len (double *addr, size_t len);
15651 vector float vec_xl_len (float *addr, size_t len);
15652
15653 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
15654 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
15655 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
15656 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
15657 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
15658 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
15659 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
15660 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
15661 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
15662 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
15663 void vec_xst_len (vector double data, double *addr, size_t len);
15664 void vec_xst_len (vector float data, float *addr, size_t len);
15665
15666 signed char vec_xlx (unsigned int index, vector signed char data);
15667 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
15668 signed short vec_xlx (unsigned int index, vector signed short data);
15669 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
15670 signed int vec_xlx (unsigned int index, vector signed int data);
15671 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
15672 float vec_xlx (unsigned int index, vector float data);
15673
15674 signed char vec_xrx (unsigned int index, vector signed char data);
15675 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
15676 signed short vec_xrx (unsigned int index, vector signed short data);
15677 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
15678 signed int vec_xrx (unsigned int index, vector signed int data);
15679 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
15680 float vec_xrx (unsigned int index, vector float data);
15681 @end smallexample
15682
15683 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
15684 perform pairwise comparisons between the elements at the same
15685 positions within their two vector arguments.
15686 The @code{vec_all_nez} function returns a
15687 non-zero value if and only if all pairwise comparisons are not
15688 equal and no element of either vector argument contains a zero.
15689 The @code{vec_any_eqz} function returns a
15690 non-zero value if and only if at least one pairwise comparison is equal
15691 or if at least one element of either vector argument contains a zero.
15692 The @code{vec_cmpnez} function returns a vector of the same type as
15693 its two arguments, within which each element consists of all ones to
15694 denote that either the corresponding elements of the incoming arguments are
15695 not equal or that at least one of the corresponding elements contains
15696 zero. Otherwise, the element of the returned vector contains all zeros.
15697
15698 The @code{vec_cntlz_lsbb} function returns the count of the number of
15699 consecutive leading byte elements (starting from position 0 within the
15700 supplied vector argument) for which the least-significant bit
15701 equals zero. The @code{vec_cnttz_lsbb} function returns the count of
15702 the number of consecutive trailing byte elements (starting from
15703 position 15 and counting backwards within the supplied vector
15704 argument) for which the least-significant bit equals zero.
15705
15706 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
15707 64-bit environment supporting ISA 3.0 or later. The @code{vec_xl_len}
15708 function loads a variable length vector from memory. The
15709 @code{vec_xst_len} function stores a variable length vector to memory.
15710 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
15711 @code{addr} argument represents the memory address to or from which
15712 data will be transferred, and the
15713 @code{len} argument represents the number of bytes to be
15714 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
15715 If this expression's value is not a multiple of the vector element's
15716 size, the behavior of this function is undefined.
15717 In the case that the underlying computer is configured to run in
15718 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
15719 the corresponding vector. In little-endian mode, the data transfer
15720 moves bytes @code{(16 - len)} to @code{15} of the corresponding
15721 vector. For the load function, any bytes of the result vector that
15722 are not loaded from memory are set to zero.
15723 The value of the @code{addr} argument need not be aligned on a
15724 multiple of the vector's element size.
15725
15726 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
15727 element selected by the @code{index} argument from the vector
15728 represented by the @code{data} argument. The @code{index} argument
15729 always specifies a byte offset, regardless of the size of the vector
15730 element. With @code{vec_xlx}, @code{index} is the offset of the first
15731 byte of the element to be extracted. With @code{vec_xrx}, @code{index}
15732 represents the last byte of the element to be extracted, measured
15733 from the right end of the vector. In other words, the last byte of
15734 the element to be extracted is found at position @code{(15 - index)}.
15735 There is no requirement that @code{index} be a multiple of the vector
15736 element size. However, if the size of the vector element added to
15737 @code{index} is greater than 15, the content of the returned value is
15738 undefined.
15739
15740 The following built-in functions are available for the PowerPC family
15741 of processors when hardware decimal floating point
15742 (@option{-mhard-dfp}) is available:
15743 @smallexample
15744 long long __builtin_dxex (_Decimal64);
15745 long long __builtin_dxexq (_Decimal128);
15746 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15747 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15748 _Decimal64 __builtin_denbcd (int, _Decimal64);
15749 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15750 _Decimal64 __builtin_diex (long long, _Decimal64);
15751 _Decimal128 _builtin_diexq (long long, _Decimal128);
15752 _Decimal64 __builtin_dscli (_Decimal64, int);
15753 _Decimal128 __builtin_dscliq (_Decimal128, int);
15754 _Decimal64 __builtin_dscri (_Decimal64, int);
15755 _Decimal128 __builtin_dscriq (_Decimal128, int);
15756 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
15757 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
15758 @end smallexample
15759
15760 The following built-in functions are available for the PowerPC family
15761 of processors when the Vector Scalar (vsx) instruction set is
15762 available:
15763 @smallexample
15764 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
15765 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
15766 unsigned long long);
15767 @end smallexample
15768
15769 @node PowerPC AltiVec/VSX Built-in Functions
15770 @subsection PowerPC AltiVec Built-in Functions
15771
15772 GCC provides an interface for the PowerPC family of processors to access
15773 the AltiVec operations described in Motorola's AltiVec Programming
15774 Interface Manual. The interface is made available by including
15775 @code{<altivec.h>} and using @option{-maltivec} and
15776 @option{-mabi=altivec}. The interface supports the following vector
15777 types.
15778
15779 @smallexample
15780 vector unsigned char
15781 vector signed char
15782 vector bool char
15783
15784 vector unsigned short
15785 vector signed short
15786 vector bool short
15787 vector pixel
15788
15789 vector unsigned int
15790 vector signed int
15791 vector bool int
15792 vector float
15793 @end smallexample
15794
15795 If @option{-mvsx} is used the following additional vector types are
15796 implemented.
15797
15798 @smallexample
15799 vector unsigned long
15800 vector signed long
15801 vector double
15802 @end smallexample
15803
15804 The long types are only implemented for 64-bit code generation, and
15805 the long type is only used in the floating point/integer conversion
15806 instructions.
15807
15808 GCC's implementation of the high-level language interface available from
15809 C and C++ code differs from Motorola's documentation in several ways.
15810
15811 @itemize @bullet
15812
15813 @item
15814 A vector constant is a list of constant expressions within curly braces.
15815
15816 @item
15817 A vector initializer requires no cast if the vector constant is of the
15818 same type as the variable it is initializing.
15819
15820 @item
15821 If @code{signed} or @code{unsigned} is omitted, the signedness of the
15822 vector type is the default signedness of the base type. The default
15823 varies depending on the operating system, so a portable program should
15824 always specify the signedness.
15825
15826 @item
15827 Compiling with @option{-maltivec} adds keywords @code{__vector},
15828 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
15829 @code{bool}. When compiling ISO C, the context-sensitive substitution
15830 of the keywords @code{vector}, @code{pixel} and @code{bool} is
15831 disabled. To use them, you must include @code{<altivec.h>} instead.
15832
15833 @item
15834 GCC allows using a @code{typedef} name as the type specifier for a
15835 vector type.
15836
15837 @item
15838 For C, overloaded functions are implemented with macros so the following
15839 does not work:
15840
15841 @smallexample
15842 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
15843 @end smallexample
15844
15845 @noindent
15846 Since @code{vec_add} is a macro, the vector constant in the example
15847 is treated as four separate arguments. Wrap the entire argument in
15848 parentheses for this to work.
15849 @end itemize
15850
15851 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
15852 Internally, GCC uses built-in functions to achieve the functionality in
15853 the aforementioned header file, but they are not supported and are
15854 subject to change without notice.
15855
15856 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
15857 which may be found at
15858 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
15859 Appendix A of this document lists the vector API interfaces that must be
15860 provided by compliant compilers. Programmers should preferentially use
15861 the interfaces described therein. However, historically GCC has provided
15862 additional interfaces for access to vector instructions. These are
15863 briefly described below.
15864
15865 The following interfaces are supported for the generic and specific
15866 AltiVec operations and the AltiVec predicates. In cases where there
15867 is a direct mapping between generic and specific operations, only the
15868 generic names are shown here, although the specific operations can also
15869 be used.
15870
15871 Arguments that are documented as @code{const int} require literal
15872 integral values within the range required for that operation.
15873
15874 @smallexample
15875 vector signed char vec_abs (vector signed char);
15876 vector signed short vec_abs (vector signed short);
15877 vector signed int vec_abs (vector signed int);
15878 vector float vec_abs (vector float);
15879
15880 vector signed char vec_abss (vector signed char);
15881 vector signed short vec_abss (vector signed short);
15882 vector signed int vec_abss (vector signed int);
15883
15884 vector signed char vec_add (vector bool char, vector signed char);
15885 vector signed char vec_add (vector signed char, vector bool char);
15886 vector signed char vec_add (vector signed char, vector signed char);
15887 vector unsigned char vec_add (vector bool char, vector unsigned char);
15888 vector unsigned char vec_add (vector unsigned char, vector bool char);
15889 vector unsigned char vec_add (vector unsigned char,
15890 vector unsigned char);
15891 vector signed short vec_add (vector bool short, vector signed short);
15892 vector signed short vec_add (vector signed short, vector bool short);
15893 vector signed short vec_add (vector signed short, vector signed short);
15894 vector unsigned short vec_add (vector bool short,
15895 vector unsigned short);
15896 vector unsigned short vec_add (vector unsigned short,
15897 vector bool short);
15898 vector unsigned short vec_add (vector unsigned short,
15899 vector unsigned short);
15900 vector signed int vec_add (vector bool int, vector signed int);
15901 vector signed int vec_add (vector signed int, vector bool int);
15902 vector signed int vec_add (vector signed int, vector signed int);
15903 vector unsigned int vec_add (vector bool int, vector unsigned int);
15904 vector unsigned int vec_add (vector unsigned int, vector bool int);
15905 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
15906 vector float vec_add (vector float, vector float);
15907
15908 vector float vec_vaddfp (vector float, vector float);
15909
15910 vector signed int vec_vadduwm (vector bool int, vector signed int);
15911 vector signed int vec_vadduwm (vector signed int, vector bool int);
15912 vector signed int vec_vadduwm (vector signed int, vector signed int);
15913 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
15914 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
15915 vector unsigned int vec_vadduwm (vector unsigned int,
15916 vector unsigned int);
15917
15918 vector signed short vec_vadduhm (vector bool short,
15919 vector signed short);
15920 vector signed short vec_vadduhm (vector signed short,
15921 vector bool short);
15922 vector signed short vec_vadduhm (vector signed short,
15923 vector signed short);
15924 vector unsigned short vec_vadduhm (vector bool short,
15925 vector unsigned short);
15926 vector unsigned short vec_vadduhm (vector unsigned short,
15927 vector bool short);
15928 vector unsigned short vec_vadduhm (vector unsigned short,
15929 vector unsigned short);
15930
15931 vector signed char vec_vaddubm (vector bool char, vector signed char);
15932 vector signed char vec_vaddubm (vector signed char, vector bool char);
15933 vector signed char vec_vaddubm (vector signed char, vector signed char);
15934 vector unsigned char vec_vaddubm (vector bool char,
15935 vector unsigned char);
15936 vector unsigned char vec_vaddubm (vector unsigned char,
15937 vector bool char);
15938 vector unsigned char vec_vaddubm (vector unsigned char,
15939 vector unsigned char);
15940
15941 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
15942
15943 vector unsigned char vec_adds (vector bool char, vector unsigned char);
15944 vector unsigned char vec_adds (vector unsigned char, vector bool char);
15945 vector unsigned char vec_adds (vector unsigned char,
15946 vector unsigned char);
15947 vector signed char vec_adds (vector bool char, vector signed char);
15948 vector signed char vec_adds (vector signed char, vector bool char);
15949 vector signed char vec_adds (vector signed char, vector signed char);
15950 vector unsigned short vec_adds (vector bool short,
15951 vector unsigned short);
15952 vector unsigned short vec_adds (vector unsigned short,
15953 vector bool short);
15954 vector unsigned short vec_adds (vector unsigned short,
15955 vector unsigned short);
15956 vector signed short vec_adds (vector bool short, vector signed short);
15957 vector signed short vec_adds (vector signed short, vector bool short);
15958 vector signed short vec_adds (vector signed short, vector signed short);
15959 vector unsigned int vec_adds (vector bool int, vector unsigned int);
15960 vector unsigned int vec_adds (vector unsigned int, vector bool int);
15961 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
15962 vector signed int vec_adds (vector bool int, vector signed int);
15963 vector signed int vec_adds (vector signed int, vector bool int);
15964 vector signed int vec_adds (vector signed int, vector signed int);
15965
15966 vector signed int vec_vaddsws (vector bool int, vector signed int);
15967 vector signed int vec_vaddsws (vector signed int, vector bool int);
15968 vector signed int vec_vaddsws (vector signed int, vector signed int);
15969
15970 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
15971 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
15972 vector unsigned int vec_vadduws (vector unsigned int,
15973 vector unsigned int);
15974
15975 vector signed short vec_vaddshs (vector bool short,
15976 vector signed short);
15977 vector signed short vec_vaddshs (vector signed short,
15978 vector bool short);
15979 vector signed short vec_vaddshs (vector signed short,
15980 vector signed short);
15981
15982 vector unsigned short vec_vadduhs (vector bool short,
15983 vector unsigned short);
15984 vector unsigned short vec_vadduhs (vector unsigned short,
15985 vector bool short);
15986 vector unsigned short vec_vadduhs (vector unsigned short,
15987 vector unsigned short);
15988
15989 vector signed char vec_vaddsbs (vector bool char, vector signed char);
15990 vector signed char vec_vaddsbs (vector signed char, vector bool char);
15991 vector signed char vec_vaddsbs (vector signed char, vector signed char);
15992
15993 vector unsigned char vec_vaddubs (vector bool char,
15994 vector unsigned char);
15995 vector unsigned char vec_vaddubs (vector unsigned char,
15996 vector bool char);
15997 vector unsigned char vec_vaddubs (vector unsigned char,
15998 vector unsigned char);
15999
16000 vector float vec_and (vector float, vector float);
16001 vector float vec_and (vector float, vector bool int);
16002 vector float vec_and (vector bool int, vector float);
16003 vector bool int vec_and (vector bool int, vector bool int);
16004 vector signed int vec_and (vector bool int, vector signed int);
16005 vector signed int vec_and (vector signed int, vector bool int);
16006 vector signed int vec_and (vector signed int, vector signed int);
16007 vector unsigned int vec_and (vector bool int, vector unsigned int);
16008 vector unsigned int vec_and (vector unsigned int, vector bool int);
16009 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
16010 vector bool short vec_and (vector bool short, vector bool short);
16011 vector signed short vec_and (vector bool short, vector signed short);
16012 vector signed short vec_and (vector signed short, vector bool short);
16013 vector signed short vec_and (vector signed short, vector signed short);
16014 vector unsigned short vec_and (vector bool short,
16015 vector unsigned short);
16016 vector unsigned short vec_and (vector unsigned short,
16017 vector bool short);
16018 vector unsigned short vec_and (vector unsigned short,
16019 vector unsigned short);
16020 vector signed char vec_and (vector bool char, vector signed char);
16021 vector bool char vec_and (vector bool char, vector bool char);
16022 vector signed char vec_and (vector signed char, vector bool char);
16023 vector signed char vec_and (vector signed char, vector signed char);
16024 vector unsigned char vec_and (vector bool char, vector unsigned char);
16025 vector unsigned char vec_and (vector unsigned char, vector bool char);
16026 vector unsigned char vec_and (vector unsigned char,
16027 vector unsigned char);
16028
16029 vector float vec_andc (vector float, vector float);
16030 vector float vec_andc (vector float, vector bool int);
16031 vector float vec_andc (vector bool int, vector float);
16032 vector bool int vec_andc (vector bool int, vector bool int);
16033 vector signed int vec_andc (vector bool int, vector signed int);
16034 vector signed int vec_andc (vector signed int, vector bool int);
16035 vector signed int vec_andc (vector signed int, vector signed int);
16036 vector unsigned int vec_andc (vector bool int, vector unsigned int);
16037 vector unsigned int vec_andc (vector unsigned int, vector bool int);
16038 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
16039 vector bool short vec_andc (vector bool short, vector bool short);
16040 vector signed short vec_andc (vector bool short, vector signed short);
16041 vector signed short vec_andc (vector signed short, vector bool short);
16042 vector signed short vec_andc (vector signed short, vector signed short);
16043 vector unsigned short vec_andc (vector bool short,
16044 vector unsigned short);
16045 vector unsigned short vec_andc (vector unsigned short,
16046 vector bool short);
16047 vector unsigned short vec_andc (vector unsigned short,
16048 vector unsigned short);
16049 vector signed char vec_andc (vector bool char, vector signed char);
16050 vector bool char vec_andc (vector bool char, vector bool char);
16051 vector signed char vec_andc (vector signed char, vector bool char);
16052 vector signed char vec_andc (vector signed char, vector signed char);
16053 vector unsigned char vec_andc (vector bool char, vector unsigned char);
16054 vector unsigned char vec_andc (vector unsigned char, vector bool char);
16055 vector unsigned char vec_andc (vector unsigned char,
16056 vector unsigned char);
16057
16058 vector unsigned char vec_avg (vector unsigned char,
16059 vector unsigned char);
16060 vector signed char vec_avg (vector signed char, vector signed char);
16061 vector unsigned short vec_avg (vector unsigned short,
16062 vector unsigned short);
16063 vector signed short vec_avg (vector signed short, vector signed short);
16064 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
16065 vector signed int vec_avg (vector signed int, vector signed int);
16066
16067 vector signed int vec_vavgsw (vector signed int, vector signed int);
16068
16069 vector unsigned int vec_vavguw (vector unsigned int,
16070 vector unsigned int);
16071
16072 vector signed short vec_vavgsh (vector signed short,
16073 vector signed short);
16074
16075 vector unsigned short vec_vavguh (vector unsigned short,
16076 vector unsigned short);
16077
16078 vector signed char vec_vavgsb (vector signed char, vector signed char);
16079
16080 vector unsigned char vec_vavgub (vector unsigned char,
16081 vector unsigned char);
16082
16083 vector float vec_copysign (vector float);
16084
16085 vector float vec_ceil (vector float);
16086
16087 vector signed int vec_cmpb (vector float, vector float);
16088
16089 vector bool char vec_cmpeq (vector bool char, vector bool char);
16090 vector bool short vec_cmpeq (vector bool short, vector bool short);
16091 vector bool int vec_cmpeq (vector bool int, vector bool int);
16092 vector bool char vec_cmpeq (vector signed char, vector signed char);
16093 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
16094 vector bool short vec_cmpeq (vector signed short, vector signed short);
16095 vector bool short vec_cmpeq (vector unsigned short,
16096 vector unsigned short);
16097 vector bool int vec_cmpeq (vector signed int, vector signed int);
16098 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
16099 vector bool int vec_cmpeq (vector float, vector float);
16100
16101 vector bool int vec_vcmpeqfp (vector float, vector float);
16102
16103 vector bool int vec_vcmpequw (vector signed int, vector signed int);
16104 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
16105
16106 vector bool short vec_vcmpequh (vector signed short,
16107 vector signed short);
16108 vector bool short vec_vcmpequh (vector unsigned short,
16109 vector unsigned short);
16110
16111 vector bool char vec_vcmpequb (vector signed char, vector signed char);
16112 vector bool char vec_vcmpequb (vector unsigned char,
16113 vector unsigned char);
16114
16115 vector bool int vec_cmpge (vector float, vector float);
16116
16117 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
16118 vector bool char vec_cmpgt (vector signed char, vector signed char);
16119 vector bool short vec_cmpgt (vector unsigned short,
16120 vector unsigned short);
16121 vector bool short vec_cmpgt (vector signed short, vector signed short);
16122 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
16123 vector bool int vec_cmpgt (vector signed int, vector signed int);
16124 vector bool int vec_cmpgt (vector float, vector float);
16125
16126 vector bool int vec_vcmpgtfp (vector float, vector float);
16127
16128 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
16129
16130 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
16131
16132 vector bool short vec_vcmpgtsh (vector signed short,
16133 vector signed short);
16134
16135 vector bool short vec_vcmpgtuh (vector unsigned short,
16136 vector unsigned short);
16137
16138 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
16139
16140 vector bool char vec_vcmpgtub (vector unsigned char,
16141 vector unsigned char);
16142
16143 vector bool int vec_cmple (vector float, vector float);
16144
16145 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
16146 vector bool char vec_cmplt (vector signed char, vector signed char);
16147 vector bool short vec_cmplt (vector unsigned short,
16148 vector unsigned short);
16149 vector bool short vec_cmplt (vector signed short, vector signed short);
16150 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
16151 vector bool int vec_cmplt (vector signed int, vector signed int);
16152 vector bool int vec_cmplt (vector float, vector float);
16153
16154 vector float vec_cpsgn (vector float, vector float);
16155
16156 vector float vec_ctf (vector unsigned int, const int);
16157 vector float vec_ctf (vector signed int, const int);
16158 vector double vec_ctf (vector unsigned long, const int);
16159 vector double vec_ctf (vector signed long, const int);
16160
16161 vector float vec_vcfsx (vector signed int, const int);
16162
16163 vector float vec_vcfux (vector unsigned int, const int);
16164
16165 vector signed int vec_cts (vector float, const int);
16166 vector signed long vec_cts (vector double, const int);
16167
16168 vector unsigned int vec_ctu (vector float, const int);
16169 vector unsigned long vec_ctu (vector double, const int);
16170
16171 vector double vec_doublee (vector float);
16172 vector double vec_doublee (vector signed int);
16173 vector double vec_doublee (vector unsigned int);
16174
16175 vector double vec_doubleo (vector float);
16176 vector double vec_doubleo (vector signed int);
16177 vector double vec_doubleo (vector unsigned int);
16178
16179 vector double vec_doubleh (vector float);
16180 vector double vec_doubleh (vector signed int);
16181 vector double vec_doubleh (vector unsigned int);
16182
16183 vector double vec_doublel (vector float);
16184 vector double vec_doublel (vector signed int);
16185 vector double vec_doublel (vector unsigned int);
16186
16187 void vec_dss (const int);
16188
16189 void vec_dssall (void);
16190
16191 void vec_dst (const vector unsigned char *, int, const int);
16192 void vec_dst (const vector signed char *, int, const int);
16193 void vec_dst (const vector bool char *, int, const int);
16194 void vec_dst (const vector unsigned short *, int, const int);
16195 void vec_dst (const vector signed short *, int, const int);
16196 void vec_dst (const vector bool short *, int, const int);
16197 void vec_dst (const vector pixel *, int, const int);
16198 void vec_dst (const vector unsigned int *, int, const int);
16199 void vec_dst (const vector signed int *, int, const int);
16200 void vec_dst (const vector bool int *, int, const int);
16201 void vec_dst (const vector float *, int, const int);
16202 void vec_dst (const unsigned char *, int, const int);
16203 void vec_dst (const signed char *, int, const int);
16204 void vec_dst (const unsigned short *, int, const int);
16205 void vec_dst (const short *, int, const int);
16206 void vec_dst (const unsigned int *, int, const int);
16207 void vec_dst (const int *, int, const int);
16208 void vec_dst (const unsigned long *, int, const int);
16209 void vec_dst (const long *, int, const int);
16210 void vec_dst (const float *, int, const int);
16211
16212 void vec_dstst (const vector unsigned char *, int, const int);
16213 void vec_dstst (const vector signed char *, int, const int);
16214 void vec_dstst (const vector bool char *, int, const int);
16215 void vec_dstst (const vector unsigned short *, int, const int);
16216 void vec_dstst (const vector signed short *, int, const int);
16217 void vec_dstst (const vector bool short *, int, const int);
16218 void vec_dstst (const vector pixel *, int, const int);
16219 void vec_dstst (const vector unsigned int *, int, const int);
16220 void vec_dstst (const vector signed int *, int, const int);
16221 void vec_dstst (const vector bool int *, int, const int);
16222 void vec_dstst (const vector float *, int, const int);
16223 void vec_dstst (const unsigned char *, int, const int);
16224 void vec_dstst (const signed char *, int, const int);
16225 void vec_dstst (const unsigned short *, int, const int);
16226 void vec_dstst (const short *, int, const int);
16227 void vec_dstst (const unsigned int *, int, const int);
16228 void vec_dstst (const int *, int, const int);
16229 void vec_dstst (const unsigned long *, int, const int);
16230 void vec_dstst (const long *, int, const int);
16231 void vec_dstst (const float *, int, const int);
16232
16233 void vec_dststt (const vector unsigned char *, int, const int);
16234 void vec_dststt (const vector signed char *, int, const int);
16235 void vec_dststt (const vector bool char *, int, const int);
16236 void vec_dststt (const vector unsigned short *, int, const int);
16237 void vec_dststt (const vector signed short *, int, const int);
16238 void vec_dststt (const vector bool short *, int, const int);
16239 void vec_dststt (const vector pixel *, int, const int);
16240 void vec_dststt (const vector unsigned int *, int, const int);
16241 void vec_dststt (const vector signed int *, int, const int);
16242 void vec_dststt (const vector bool int *, int, const int);
16243 void vec_dststt (const vector float *, int, const int);
16244 void vec_dststt (const unsigned char *, int, const int);
16245 void vec_dststt (const signed char *, int, const int);
16246 void vec_dststt (const unsigned short *, int, const int);
16247 void vec_dststt (const short *, int, const int);
16248 void vec_dststt (const unsigned int *, int, const int);
16249 void vec_dststt (const int *, int, const int);
16250 void vec_dststt (const unsigned long *, int, const int);
16251 void vec_dststt (const long *, int, const int);
16252 void vec_dststt (const float *, int, const int);
16253
16254 void vec_dstt (const vector unsigned char *, int, const int);
16255 void vec_dstt (const vector signed char *, int, const int);
16256 void vec_dstt (const vector bool char *, int, const int);
16257 void vec_dstt (const vector unsigned short *, int, const int);
16258 void vec_dstt (const vector signed short *, int, const int);
16259 void vec_dstt (const vector bool short *, int, const int);
16260 void vec_dstt (const vector pixel *, int, const int);
16261 void vec_dstt (const vector unsigned int *, int, const int);
16262 void vec_dstt (const vector signed int *, int, const int);
16263 void vec_dstt (const vector bool int *, int, const int);
16264 void vec_dstt (const vector float *, int, const int);
16265 void vec_dstt (const unsigned char *, int, const int);
16266 void vec_dstt (const signed char *, int, const int);
16267 void vec_dstt (const unsigned short *, int, const int);
16268 void vec_dstt (const short *, int, const int);
16269 void vec_dstt (const unsigned int *, int, const int);
16270 void vec_dstt (const int *, int, const int);
16271 void vec_dstt (const unsigned long *, int, const int);
16272 void vec_dstt (const long *, int, const int);
16273 void vec_dstt (const float *, int, const int);
16274
16275 vector float vec_expte (vector float);
16276
16277 vector float vec_floor (vector float);
16278
16279 vector float vec_float (vector signed int);
16280 vector float vec_float (vector unsigned int);
16281
16282 vector float vec_float2 (vector signed long long, vector signed long long);
16283 vector float vec_float2 (vector unsigned long long, vector signed long long);
16284
16285 vector float vec_floate (vector double);
16286 vector float vec_floate (vector signed long long);
16287 vector float vec_floate (vector unsigned long long);
16288
16289 vector float vec_floato (vector double);
16290 vector float vec_floato (vector signed long long);
16291 vector float vec_floato (vector unsigned long long);
16292
16293 vector float vec_ld (int, const vector float *);
16294 vector float vec_ld (int, const float *);
16295 vector bool int vec_ld (int, const vector bool int *);
16296 vector signed int vec_ld (int, const vector signed int *);
16297 vector signed int vec_ld (int, const int *);
16298 vector signed int vec_ld (int, const long *);
16299 vector unsigned int vec_ld (int, const vector unsigned int *);
16300 vector unsigned int vec_ld (int, const unsigned int *);
16301 vector unsigned int vec_ld (int, const unsigned long *);
16302 vector bool short vec_ld (int, const vector bool short *);
16303 vector pixel vec_ld (int, const vector pixel *);
16304 vector signed short vec_ld (int, const vector signed short *);
16305 vector signed short vec_ld (int, const short *);
16306 vector unsigned short vec_ld (int, const vector unsigned short *);
16307 vector unsigned short vec_ld (int, const unsigned short *);
16308 vector bool char vec_ld (int, const vector bool char *);
16309 vector signed char vec_ld (int, const vector signed char *);
16310 vector signed char vec_ld (int, const signed char *);
16311 vector unsigned char vec_ld (int, const vector unsigned char *);
16312 vector unsigned char vec_ld (int, const unsigned char *);
16313
16314 vector signed char vec_lde (int, const signed char *);
16315 vector unsigned char vec_lde (int, const unsigned char *);
16316 vector signed short vec_lde (int, const short *);
16317 vector unsigned short vec_lde (int, const unsigned short *);
16318 vector float vec_lde (int, const float *);
16319 vector signed int vec_lde (int, const int *);
16320 vector unsigned int vec_lde (int, const unsigned int *);
16321 vector signed int vec_lde (int, const long *);
16322 vector unsigned int vec_lde (int, const unsigned long *);
16323
16324 vector float vec_lvewx (int, float *);
16325 vector signed int vec_lvewx (int, int *);
16326 vector unsigned int vec_lvewx (int, unsigned int *);
16327 vector signed int vec_lvewx (int, long *);
16328 vector unsigned int vec_lvewx (int, unsigned long *);
16329
16330 vector signed short vec_lvehx (int, short *);
16331 vector unsigned short vec_lvehx (int, unsigned short *);
16332
16333 vector signed char vec_lvebx (int, char *);
16334 vector unsigned char vec_lvebx (int, unsigned char *);
16335
16336 vector float vec_ldl (int, const vector float *);
16337 vector float vec_ldl (int, const float *);
16338 vector bool int vec_ldl (int, const vector bool int *);
16339 vector signed int vec_ldl (int, const vector signed int *);
16340 vector signed int vec_ldl (int, const int *);
16341 vector signed int vec_ldl (int, const long *);
16342 vector unsigned int vec_ldl (int, const vector unsigned int *);
16343 vector unsigned int vec_ldl (int, const unsigned int *);
16344 vector unsigned int vec_ldl (int, const unsigned long *);
16345 vector bool short vec_ldl (int, const vector bool short *);
16346 vector pixel vec_ldl (int, const vector pixel *);
16347 vector signed short vec_ldl (int, const vector signed short *);
16348 vector signed short vec_ldl (int, const short *);
16349 vector unsigned short vec_ldl (int, const vector unsigned short *);
16350 vector unsigned short vec_ldl (int, const unsigned short *);
16351 vector bool char vec_ldl (int, const vector bool char *);
16352 vector signed char vec_ldl (int, const vector signed char *);
16353 vector signed char vec_ldl (int, const signed char *);
16354 vector unsigned char vec_ldl (int, const vector unsigned char *);
16355 vector unsigned char vec_ldl (int, const unsigned char *);
16356
16357 vector float vec_loge (vector float);
16358
16359 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
16360 vector unsigned char vec_lvsl (int, const volatile signed char *);
16361 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
16362 vector unsigned char vec_lvsl (int, const volatile short *);
16363 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
16364 vector unsigned char vec_lvsl (int, const volatile int *);
16365 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
16366 vector unsigned char vec_lvsl (int, const volatile long *);
16367 vector unsigned char vec_lvsl (int, const volatile float *);
16368
16369 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
16370 vector unsigned char vec_lvsr (int, const volatile signed char *);
16371 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
16372 vector unsigned char vec_lvsr (int, const volatile short *);
16373 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
16374 vector unsigned char vec_lvsr (int, const volatile int *);
16375 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
16376 vector unsigned char vec_lvsr (int, const volatile long *);
16377 vector unsigned char vec_lvsr (int, const volatile float *);
16378
16379 vector float vec_madd (vector float, vector float, vector float);
16380
16381 vector signed short vec_madds (vector signed short,
16382 vector signed short,
16383 vector signed short);
16384
16385 vector unsigned char vec_max (vector bool char, vector unsigned char);
16386 vector unsigned char vec_max (vector unsigned char, vector bool char);
16387 vector unsigned char vec_max (vector unsigned char,
16388 vector unsigned char);
16389 vector signed char vec_max (vector bool char, vector signed char);
16390 vector signed char vec_max (vector signed char, vector bool char);
16391 vector signed char vec_max (vector signed char, vector signed char);
16392 vector unsigned short vec_max (vector bool short,
16393 vector unsigned short);
16394 vector unsigned short vec_max (vector unsigned short,
16395 vector bool short);
16396 vector unsigned short vec_max (vector unsigned short,
16397 vector unsigned short);
16398 vector signed short vec_max (vector bool short, vector signed short);
16399 vector signed short vec_max (vector signed short, vector bool short);
16400 vector signed short vec_max (vector signed short, vector signed short);
16401 vector unsigned int vec_max (vector bool int, vector unsigned int);
16402 vector unsigned int vec_max (vector unsigned int, vector bool int);
16403 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
16404 vector signed int vec_max (vector bool int, vector signed int);
16405 vector signed int vec_max (vector signed int, vector bool int);
16406 vector signed int vec_max (vector signed int, vector signed int);
16407 vector float vec_max (vector float, vector float);
16408
16409 vector float vec_vmaxfp (vector float, vector float);
16410
16411 vector signed int vec_vmaxsw (vector bool int, vector signed int);
16412 vector signed int vec_vmaxsw (vector signed int, vector bool int);
16413 vector signed int vec_vmaxsw (vector signed int, vector signed int);
16414
16415 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
16416 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
16417 vector unsigned int vec_vmaxuw (vector unsigned int,
16418 vector unsigned int);
16419
16420 vector signed short vec_vmaxsh (vector bool short, vector signed short);
16421 vector signed short vec_vmaxsh (vector signed short, vector bool short);
16422 vector signed short vec_vmaxsh (vector signed short,
16423 vector signed short);
16424
16425 vector unsigned short vec_vmaxuh (vector bool short,
16426 vector unsigned short);
16427 vector unsigned short vec_vmaxuh (vector unsigned short,
16428 vector bool short);
16429 vector unsigned short vec_vmaxuh (vector unsigned short,
16430 vector unsigned short);
16431
16432 vector signed char vec_vmaxsb (vector bool char, vector signed char);
16433 vector signed char vec_vmaxsb (vector signed char, vector bool char);
16434 vector signed char vec_vmaxsb (vector signed char, vector signed char);
16435
16436 vector unsigned char vec_vmaxub (vector bool char,
16437 vector unsigned char);
16438 vector unsigned char vec_vmaxub (vector unsigned char,
16439 vector bool char);
16440 vector unsigned char vec_vmaxub (vector unsigned char,
16441 vector unsigned char);
16442
16443 vector bool char vec_mergeh (vector bool char, vector bool char);
16444 vector signed char vec_mergeh (vector signed char, vector signed char);
16445 vector unsigned char vec_mergeh (vector unsigned char,
16446 vector unsigned char);
16447 vector bool short vec_mergeh (vector bool short, vector bool short);
16448 vector pixel vec_mergeh (vector pixel, vector pixel);
16449 vector signed short vec_mergeh (vector signed short,
16450 vector signed short);
16451 vector unsigned short vec_mergeh (vector unsigned short,
16452 vector unsigned short);
16453 vector float vec_mergeh (vector float, vector float);
16454 vector bool int vec_mergeh (vector bool int, vector bool int);
16455 vector signed int vec_mergeh (vector signed int, vector signed int);
16456 vector unsigned int vec_mergeh (vector unsigned int,
16457 vector unsigned int);
16458
16459 vector float vec_vmrghw (vector float, vector float);
16460 vector bool int vec_vmrghw (vector bool int, vector bool int);
16461 vector signed int vec_vmrghw (vector signed int, vector signed int);
16462 vector unsigned int vec_vmrghw (vector unsigned int,
16463 vector unsigned int);
16464
16465 vector bool short vec_vmrghh (vector bool short, vector bool short);
16466 vector signed short vec_vmrghh (vector signed short,
16467 vector signed short);
16468 vector unsigned short vec_vmrghh (vector unsigned short,
16469 vector unsigned short);
16470 vector pixel vec_vmrghh (vector pixel, vector pixel);
16471
16472 vector bool char vec_vmrghb (vector bool char, vector bool char);
16473 vector signed char vec_vmrghb (vector signed char, vector signed char);
16474 vector unsigned char vec_vmrghb (vector unsigned char,
16475 vector unsigned char);
16476
16477 vector bool char vec_mergel (vector bool char, vector bool char);
16478 vector signed char vec_mergel (vector signed char, vector signed char);
16479 vector unsigned char vec_mergel (vector unsigned char,
16480 vector unsigned char);
16481 vector bool short vec_mergel (vector bool short, vector bool short);
16482 vector pixel vec_mergel (vector pixel, vector pixel);
16483 vector signed short vec_mergel (vector signed short,
16484 vector signed short);
16485 vector unsigned short vec_mergel (vector unsigned short,
16486 vector unsigned short);
16487 vector float vec_mergel (vector float, vector float);
16488 vector bool int vec_mergel (vector bool int, vector bool int);
16489 vector signed int vec_mergel (vector signed int, vector signed int);
16490 vector unsigned int vec_mergel (vector unsigned int,
16491 vector unsigned int);
16492
16493 vector float vec_vmrglw (vector float, vector float);
16494 vector signed int vec_vmrglw (vector signed int, vector signed int);
16495 vector unsigned int vec_vmrglw (vector unsigned int,
16496 vector unsigned int);
16497 vector bool int vec_vmrglw (vector bool int, vector bool int);
16498
16499 vector bool short vec_vmrglh (vector bool short, vector bool short);
16500 vector signed short vec_vmrglh (vector signed short,
16501 vector signed short);
16502 vector unsigned short vec_vmrglh (vector unsigned short,
16503 vector unsigned short);
16504 vector pixel vec_vmrglh (vector pixel, vector pixel);
16505
16506 vector bool char vec_vmrglb (vector bool char, vector bool char);
16507 vector signed char vec_vmrglb (vector signed char, vector signed char);
16508 vector unsigned char vec_vmrglb (vector unsigned char,
16509 vector unsigned char);
16510
16511 vector unsigned short vec_mfvscr (void);
16512
16513 vector unsigned char vec_min (vector bool char, vector unsigned char);
16514 vector unsigned char vec_min (vector unsigned char, vector bool char);
16515 vector unsigned char vec_min (vector unsigned char,
16516 vector unsigned char);
16517 vector signed char vec_min (vector bool char, vector signed char);
16518 vector signed char vec_min (vector signed char, vector bool char);
16519 vector signed char vec_min (vector signed char, vector signed char);
16520 vector unsigned short vec_min (vector bool short,
16521 vector unsigned short);
16522 vector unsigned short vec_min (vector unsigned short,
16523 vector bool short);
16524 vector unsigned short vec_min (vector unsigned short,
16525 vector unsigned short);
16526 vector signed short vec_min (vector bool short, vector signed short);
16527 vector signed short vec_min (vector signed short, vector bool short);
16528 vector signed short vec_min (vector signed short, vector signed short);
16529 vector unsigned int vec_min (vector bool int, vector unsigned int);
16530 vector unsigned int vec_min (vector unsigned int, vector bool int);
16531 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
16532 vector signed int vec_min (vector bool int, vector signed int);
16533 vector signed int vec_min (vector signed int, vector bool int);
16534 vector signed int vec_min (vector signed int, vector signed int);
16535 vector float vec_min (vector float, vector float);
16536
16537 vector float vec_vminfp (vector float, vector float);
16538
16539 vector signed int vec_vminsw (vector bool int, vector signed int);
16540 vector signed int vec_vminsw (vector signed int, vector bool int);
16541 vector signed int vec_vminsw (vector signed int, vector signed int);
16542
16543 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
16544 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
16545 vector unsigned int vec_vminuw (vector unsigned int,
16546 vector unsigned int);
16547
16548 vector signed short vec_vminsh (vector bool short, vector signed short);
16549 vector signed short vec_vminsh (vector signed short, vector bool short);
16550 vector signed short vec_vminsh (vector signed short,
16551 vector signed short);
16552
16553 vector unsigned short vec_vminuh (vector bool short,
16554 vector unsigned short);
16555 vector unsigned short vec_vminuh (vector unsigned short,
16556 vector bool short);
16557 vector unsigned short vec_vminuh (vector unsigned short,
16558 vector unsigned short);
16559
16560 vector signed char vec_vminsb (vector bool char, vector signed char);
16561 vector signed char vec_vminsb (vector signed char, vector bool char);
16562 vector signed char vec_vminsb (vector signed char, vector signed char);
16563
16564 vector unsigned char vec_vminub (vector bool char,
16565 vector unsigned char);
16566 vector unsigned char vec_vminub (vector unsigned char,
16567 vector bool char);
16568 vector unsigned char vec_vminub (vector unsigned char,
16569 vector unsigned char);
16570
16571 vector signed short vec_mladd (vector signed short,
16572 vector signed short,
16573 vector signed short);
16574 vector signed short vec_mladd (vector signed short,
16575 vector unsigned short,
16576 vector unsigned short);
16577 vector signed short vec_mladd (vector unsigned short,
16578 vector signed short,
16579 vector signed short);
16580 vector unsigned short vec_mladd (vector unsigned short,
16581 vector unsigned short,
16582 vector unsigned short);
16583
16584 vector signed short vec_mradds (vector signed short,
16585 vector signed short,
16586 vector signed short);
16587
16588 vector unsigned int vec_msum (vector unsigned char,
16589 vector unsigned char,
16590 vector unsigned int);
16591 vector signed int vec_msum (vector signed char,
16592 vector unsigned char,
16593 vector signed int);
16594 vector unsigned int vec_msum (vector unsigned short,
16595 vector unsigned short,
16596 vector unsigned int);
16597 vector signed int vec_msum (vector signed short,
16598 vector signed short,
16599 vector signed int);
16600
16601 vector signed int vec_vmsumshm (vector signed short,
16602 vector signed short,
16603 vector signed int);
16604
16605 vector unsigned int vec_vmsumuhm (vector unsigned short,
16606 vector unsigned short,
16607 vector unsigned int);
16608
16609 vector signed int vec_vmsummbm (vector signed char,
16610 vector unsigned char,
16611 vector signed int);
16612
16613 vector unsigned int vec_vmsumubm (vector unsigned char,
16614 vector unsigned char,
16615 vector unsigned int);
16616
16617 vector unsigned int vec_msums (vector unsigned short,
16618 vector unsigned short,
16619 vector unsigned int);
16620 vector signed int vec_msums (vector signed short,
16621 vector signed short,
16622 vector signed int);
16623
16624 vector signed int vec_vmsumshs (vector signed short,
16625 vector signed short,
16626 vector signed int);
16627
16628 vector unsigned int vec_vmsumuhs (vector unsigned short,
16629 vector unsigned short,
16630 vector unsigned int);
16631
16632 void vec_mtvscr (vector signed int);
16633 void vec_mtvscr (vector unsigned int);
16634 void vec_mtvscr (vector bool int);
16635 void vec_mtvscr (vector signed short);
16636 void vec_mtvscr (vector unsigned short);
16637 void vec_mtvscr (vector bool short);
16638 void vec_mtvscr (vector pixel);
16639 void vec_mtvscr (vector signed char);
16640 void vec_mtvscr (vector unsigned char);
16641 void vec_mtvscr (vector bool char);
16642
16643 vector unsigned short vec_mule (vector unsigned char,
16644 vector unsigned char);
16645 vector signed short vec_mule (vector signed char,
16646 vector signed char);
16647 vector unsigned int vec_mule (vector unsigned short,
16648 vector unsigned short);
16649 vector signed int vec_mule (vector signed short, vector signed short);
16650 vector unsigned long long vec_mule (vector unsigned int,
16651 vector unsigned int);
16652 vector signed long long vec_mule (vector signed int,
16653 vector signed int);
16654
16655 vector signed int vec_vmulesh (vector signed short,
16656 vector signed short);
16657
16658 vector unsigned int vec_vmuleuh (vector unsigned short,
16659 vector unsigned short);
16660
16661 vector signed short vec_vmulesb (vector signed char,
16662 vector signed char);
16663
16664 vector unsigned short vec_vmuleub (vector unsigned char,
16665 vector unsigned char);
16666
16667 vector unsigned short vec_mulo (vector unsigned char,
16668 vector unsigned char);
16669 vector signed short vec_mulo (vector signed char, vector signed char);
16670 vector unsigned int vec_mulo (vector unsigned short,
16671 vector unsigned short);
16672 vector signed int vec_mulo (vector signed short, vector signed short);
16673 vector unsigned long long vec_mulo (vector unsigned int,
16674 vector unsigned int);
16675 vector signed long long vec_mulo (vector signed int,
16676 vector signed int);
16677
16678 vector signed int vec_vmulosh (vector signed short,
16679 vector signed short);
16680
16681 vector unsigned int vec_vmulouh (vector unsigned short,
16682 vector unsigned short);
16683
16684 vector signed short vec_vmulosb (vector signed char,
16685 vector signed char);
16686
16687 vector unsigned short vec_vmuloub (vector unsigned char,
16688 vector unsigned char);
16689
16690 vector float vec_nmsub (vector float, vector float, vector float);
16691
16692 vector signed char vec_nabs (vector signed char);
16693 vector signed short vec_nabs (vector signed short);
16694 vector signed int vec_nabs (vector signed int);
16695 vector float vec_nabs (vector float);
16696 vector double vec_nabs (vector double);
16697
16698 vector signed char vec_neg (vector signed char);
16699 vector signed short vec_neg (vector signed short);
16700 vector signed int vec_neg (vector signed int);
16701 vector signed long long vec_neg (vector signed long long);
16702 vector float char vec_neg (vector float);
16703 vector double vec_neg (vector double);
16704
16705 vector float vec_nor (vector float, vector float);
16706 vector signed int vec_nor (vector signed int, vector signed int);
16707 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
16708 vector bool int vec_nor (vector bool int, vector bool int);
16709 vector signed short vec_nor (vector signed short, vector signed short);
16710 vector unsigned short vec_nor (vector unsigned short,
16711 vector unsigned short);
16712 vector bool short vec_nor (vector bool short, vector bool short);
16713 vector signed char vec_nor (vector signed char, vector signed char);
16714 vector unsigned char vec_nor (vector unsigned char,
16715 vector unsigned char);
16716 vector bool char vec_nor (vector bool char, vector bool char);
16717
16718 vector float vec_or (vector float, vector float);
16719 vector float vec_or (vector float, vector bool int);
16720 vector float vec_or (vector bool int, vector float);
16721 vector bool int vec_or (vector bool int, vector bool int);
16722 vector signed int vec_or (vector bool int, vector signed int);
16723 vector signed int vec_or (vector signed int, vector bool int);
16724 vector signed int vec_or (vector signed int, vector signed int);
16725 vector unsigned int vec_or (vector bool int, vector unsigned int);
16726 vector unsigned int vec_or (vector unsigned int, vector bool int);
16727 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
16728 vector bool short vec_or (vector bool short, vector bool short);
16729 vector signed short vec_or (vector bool short, vector signed short);
16730 vector signed short vec_or (vector signed short, vector bool short);
16731 vector signed short vec_or (vector signed short, vector signed short);
16732 vector unsigned short vec_or (vector bool short, vector unsigned short);
16733 vector unsigned short vec_or (vector unsigned short, vector bool short);
16734 vector unsigned short vec_or (vector unsigned short,
16735 vector unsigned short);
16736 vector signed char vec_or (vector bool char, vector signed char);
16737 vector bool char vec_or (vector bool char, vector bool char);
16738 vector signed char vec_or (vector signed char, vector bool char);
16739 vector signed char vec_or (vector signed char, vector signed char);
16740 vector unsigned char vec_or (vector bool char, vector unsigned char);
16741 vector unsigned char vec_or (vector unsigned char, vector bool char);
16742 vector unsigned char vec_or (vector unsigned char,
16743 vector unsigned char);
16744
16745 vector signed char vec_pack (vector signed short, vector signed short);
16746 vector unsigned char vec_pack (vector unsigned short,
16747 vector unsigned short);
16748 vector bool char vec_pack (vector bool short, vector bool short);
16749 vector signed short vec_pack (vector signed int, vector signed int);
16750 vector unsigned short vec_pack (vector unsigned int,
16751 vector unsigned int);
16752 vector bool short vec_pack (vector bool int, vector bool int);
16753
16754 vector bool short vec_vpkuwum (vector bool int, vector bool int);
16755 vector signed short vec_vpkuwum (vector signed int, vector signed int);
16756 vector unsigned short vec_vpkuwum (vector unsigned int,
16757 vector unsigned int);
16758
16759 vector bool char vec_vpkuhum (vector bool short, vector bool short);
16760 vector signed char vec_vpkuhum (vector signed short,
16761 vector signed short);
16762 vector unsigned char vec_vpkuhum (vector unsigned short,
16763 vector unsigned short);
16764
16765 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
16766
16767 vector unsigned char vec_packs (vector unsigned short,
16768 vector unsigned short);
16769 vector signed char vec_packs (vector signed short, vector signed short);
16770 vector unsigned short vec_packs (vector unsigned int,
16771 vector unsigned int);
16772 vector signed short vec_packs (vector signed int, vector signed int);
16773
16774 vector signed short vec_vpkswss (vector signed int, vector signed int);
16775
16776 vector unsigned short vec_vpkuwus (vector unsigned int,
16777 vector unsigned int);
16778
16779 vector signed char vec_vpkshss (vector signed short,
16780 vector signed short);
16781
16782 vector unsigned char vec_vpkuhus (vector unsigned short,
16783 vector unsigned short);
16784
16785 vector unsigned char vec_packsu (vector unsigned short,
16786 vector unsigned short);
16787 vector unsigned char vec_packsu (vector signed short,
16788 vector signed short);
16789 vector unsigned short vec_packsu (vector unsigned int,
16790 vector unsigned int);
16791 vector unsigned short vec_packsu (vector signed int, vector signed int);
16792
16793 vector unsigned short vec_vpkswus (vector signed int,
16794 vector signed int);
16795
16796 vector unsigned char vec_vpkshus (vector signed short,
16797 vector signed short);
16798
16799 vector float vec_perm (vector float,
16800 vector float,
16801 vector unsigned char);
16802 vector signed int vec_perm (vector signed int,
16803 vector signed int,
16804 vector unsigned char);
16805 vector unsigned int vec_perm (vector unsigned int,
16806 vector unsigned int,
16807 vector unsigned char);
16808 vector bool int vec_perm (vector bool int,
16809 vector bool int,
16810 vector unsigned char);
16811 vector signed short vec_perm (vector signed short,
16812 vector signed short,
16813 vector unsigned char);
16814 vector unsigned short vec_perm (vector unsigned short,
16815 vector unsigned short,
16816 vector unsigned char);
16817 vector bool short vec_perm (vector bool short,
16818 vector bool short,
16819 vector unsigned char);
16820 vector pixel vec_perm (vector pixel,
16821 vector pixel,
16822 vector unsigned char);
16823 vector signed char vec_perm (vector signed char,
16824 vector signed char,
16825 vector unsigned char);
16826 vector unsigned char vec_perm (vector unsigned char,
16827 vector unsigned char,
16828 vector unsigned char);
16829 vector bool char vec_perm (vector bool char,
16830 vector bool char,
16831 vector unsigned char);
16832
16833 vector float vec_re (vector float);
16834
16835 vector bool char vec_reve (vector bool char);
16836 vector signed char vec_reve (vector signed char);
16837 vector unsigned char vec_reve (vector unsigned char);
16838 vector bool int vec_reve (vector bool int);
16839 vector signed int vec_reve (vector signed int);
16840 vector unsigned int vec_reve (vector unsigned int);
16841 vector bool long long vec_reve (vector bool long long);
16842 vector signed long long vec_reve (vector signed long long);
16843 vector unsigned long long vec_reve (vector unsigned long long);
16844 vector bool short vec_reve (vector bool short);
16845 vector signed short vec_reve (vector signed short);
16846 vector unsigned short vec_reve (vector unsigned short);
16847
16848 vector signed char vec_rl (vector signed char,
16849 vector unsigned char);
16850 vector unsigned char vec_rl (vector unsigned char,
16851 vector unsigned char);
16852 vector signed short vec_rl (vector signed short, vector unsigned short);
16853 vector unsigned short vec_rl (vector unsigned short,
16854 vector unsigned short);
16855 vector signed int vec_rl (vector signed int, vector unsigned int);
16856 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
16857
16858 vector signed int vec_vrlw (vector signed int, vector unsigned int);
16859 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
16860
16861 vector signed short vec_vrlh (vector signed short,
16862 vector unsigned short);
16863 vector unsigned short vec_vrlh (vector unsigned short,
16864 vector unsigned short);
16865
16866 vector signed char vec_vrlb (vector signed char, vector unsigned char);
16867 vector unsigned char vec_vrlb (vector unsigned char,
16868 vector unsigned char);
16869
16870 vector float vec_round (vector float);
16871
16872 vector float vec_recip (vector float, vector float);
16873
16874 vector float vec_rsqrt (vector float);
16875
16876 vector float vec_rsqrte (vector float);
16877
16878 vector float vec_sel (vector float, vector float, vector bool int);
16879 vector float vec_sel (vector float, vector float, vector unsigned int);
16880 vector signed int vec_sel (vector signed int,
16881 vector signed int,
16882 vector bool int);
16883 vector signed int vec_sel (vector signed int,
16884 vector signed int,
16885 vector unsigned int);
16886 vector unsigned int vec_sel (vector unsigned int,
16887 vector unsigned int,
16888 vector bool int);
16889 vector unsigned int vec_sel (vector unsigned int,
16890 vector unsigned int,
16891 vector unsigned int);
16892 vector bool int vec_sel (vector bool int,
16893 vector bool int,
16894 vector bool int);
16895 vector bool int vec_sel (vector bool int,
16896 vector bool int,
16897 vector unsigned int);
16898 vector signed short vec_sel (vector signed short,
16899 vector signed short,
16900 vector bool short);
16901 vector signed short vec_sel (vector signed short,
16902 vector signed short,
16903 vector unsigned short);
16904 vector unsigned short vec_sel (vector unsigned short,
16905 vector unsigned short,
16906 vector bool short);
16907 vector unsigned short vec_sel (vector unsigned short,
16908 vector unsigned short,
16909 vector unsigned short);
16910 vector bool short vec_sel (vector bool short,
16911 vector bool short,
16912 vector bool short);
16913 vector bool short vec_sel (vector bool short,
16914 vector bool short,
16915 vector unsigned short);
16916 vector signed char vec_sel (vector signed char,
16917 vector signed char,
16918 vector bool char);
16919 vector signed char vec_sel (vector signed char,
16920 vector signed char,
16921 vector unsigned char);
16922 vector unsigned char vec_sel (vector unsigned char,
16923 vector unsigned char,
16924 vector bool char);
16925 vector unsigned char vec_sel (vector unsigned char,
16926 vector unsigned char,
16927 vector unsigned char);
16928 vector bool char vec_sel (vector bool char,
16929 vector bool char,
16930 vector bool char);
16931 vector bool char vec_sel (vector bool char,
16932 vector bool char,
16933 vector unsigned char);
16934
16935 vector signed long long vec_signed (vector double);
16936 vector signed int vec_signed (vector float);
16937
16938 vector signed int vec_signede (vector double);
16939 vector signed int vec_signedo (vector double);
16940 vector signed int vec_signed2 (vector double, vector double);
16941
16942 vector signed char vec_sl (vector signed char,
16943 vector unsigned char);
16944 vector unsigned char vec_sl (vector unsigned char,
16945 vector unsigned char);
16946 vector signed short vec_sl (vector signed short, vector unsigned short);
16947 vector unsigned short vec_sl (vector unsigned short,
16948 vector unsigned short);
16949 vector signed int vec_sl (vector signed int, vector unsigned int);
16950 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
16951
16952 vector signed int vec_vslw (vector signed int, vector unsigned int);
16953 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
16954
16955 vector signed short vec_vslh (vector signed short,
16956 vector unsigned short);
16957 vector unsigned short vec_vslh (vector unsigned short,
16958 vector unsigned short);
16959
16960 vector signed char vec_vslb (vector signed char, vector unsigned char);
16961 vector unsigned char vec_vslb (vector unsigned char,
16962 vector unsigned char);
16963
16964 vector float vec_sld (vector float, vector float, const int);
16965 vector double vec_sld (vector double, vector double, const int);
16966
16967 vector signed int vec_sld (vector signed int,
16968 vector signed int,
16969 const int);
16970 vector unsigned int vec_sld (vector unsigned int,
16971 vector unsigned int,
16972 const int);
16973 vector bool int vec_sld (vector bool int,
16974 vector bool int,
16975 const int);
16976 vector signed short vec_sld (vector signed short,
16977 vector signed short,
16978 const int);
16979 vector unsigned short vec_sld (vector unsigned short,
16980 vector unsigned short,
16981 const int);
16982 vector bool short vec_sld (vector bool short,
16983 vector bool short,
16984 const int);
16985 vector pixel vec_sld (vector pixel,
16986 vector pixel,
16987 const int);
16988 vector signed char vec_sld (vector signed char,
16989 vector signed char,
16990 const int);
16991 vector unsigned char vec_sld (vector unsigned char,
16992 vector unsigned char,
16993 const int);
16994 vector bool char vec_sld (vector bool char,
16995 vector bool char,
16996 const int);
16997
16998 vector signed char vec_sldw (vector signed char,
16999 vector signed char,
17000 const int);
17001 vector unsigned char vec_sldw (vector unsigned char,
17002 vector unsigned char,
17003 const int);
17004 vector signed short vec_sldw (vector signed short,
17005 vector signed short,
17006 const int);
17007 vector unsigned short vec_sldw (vector unsigned short,
17008 vector unsigned short,
17009 const int);
17010 vector signed int vec_sldw (vector signed int,
17011 vector signed int,
17012 const int);
17013 vector unsigned int vec_sldw (vector unsigned int,
17014 vector unsigned int,
17015 const int);
17016 vector signed long long vec_sldw (vector signed long long,
17017 vector signed long long,
17018 const int);
17019 vector unsigned long long vec_sldw (vector unsigned long long,
17020 vector unsigned long long,
17021 const int);
17022
17023 vector signed int vec_sll (vector signed int,
17024 vector unsigned int);
17025 vector signed int vec_sll (vector signed int,
17026 vector unsigned short);
17027 vector signed int vec_sll (vector signed int,
17028 vector unsigned char);
17029 vector unsigned int vec_sll (vector unsigned int,
17030 vector unsigned int);
17031 vector unsigned int vec_sll (vector unsigned int,
17032 vector unsigned short);
17033 vector unsigned int vec_sll (vector unsigned int,
17034 vector unsigned char);
17035 vector bool int vec_sll (vector bool int,
17036 vector unsigned int);
17037 vector bool int vec_sll (vector bool int,
17038 vector unsigned short);
17039 vector bool int vec_sll (vector bool int,
17040 vector unsigned char);
17041 vector signed short vec_sll (vector signed short,
17042 vector unsigned int);
17043 vector signed short vec_sll (vector signed short,
17044 vector unsigned short);
17045 vector signed short vec_sll (vector signed short,
17046 vector unsigned char);
17047 vector unsigned short vec_sll (vector unsigned short,
17048 vector unsigned int);
17049 vector unsigned short vec_sll (vector unsigned short,
17050 vector unsigned short);
17051 vector unsigned short vec_sll (vector unsigned short,
17052 vector unsigned char);
17053 vector bool short vec_sll (vector bool short, vector unsigned int);
17054 vector bool short vec_sll (vector bool short, vector unsigned short);
17055 vector bool short vec_sll (vector bool short, vector unsigned char);
17056 vector pixel vec_sll (vector pixel, vector unsigned int);
17057 vector pixel vec_sll (vector pixel, vector unsigned short);
17058 vector pixel vec_sll (vector pixel, vector unsigned char);
17059 vector signed char vec_sll (vector signed char, vector unsigned int);
17060 vector signed char vec_sll (vector signed char, vector unsigned short);
17061 vector signed char vec_sll (vector signed char, vector unsigned char);
17062 vector unsigned char vec_sll (vector unsigned char,
17063 vector unsigned int);
17064 vector unsigned char vec_sll (vector unsigned char,
17065 vector unsigned short);
17066 vector unsigned char vec_sll (vector unsigned char,
17067 vector unsigned char);
17068 vector bool char vec_sll (vector bool char, vector unsigned int);
17069 vector bool char vec_sll (vector bool char, vector unsigned short);
17070 vector bool char vec_sll (vector bool char, vector unsigned char);
17071
17072 vector float vec_slo (vector float, vector signed char);
17073 vector float vec_slo (vector float, vector unsigned char);
17074 vector signed int vec_slo (vector signed int, vector signed char);
17075 vector signed int vec_slo (vector signed int, vector unsigned char);
17076 vector unsigned int vec_slo (vector unsigned int, vector signed char);
17077 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
17078 vector signed short vec_slo (vector signed short, vector signed char);
17079 vector signed short vec_slo (vector signed short, vector unsigned char);
17080 vector unsigned short vec_slo (vector unsigned short,
17081 vector signed char);
17082 vector unsigned short vec_slo (vector unsigned short,
17083 vector unsigned char);
17084 vector pixel vec_slo (vector pixel, vector signed char);
17085 vector pixel vec_slo (vector pixel, vector unsigned char);
17086 vector signed char vec_slo (vector signed char, vector signed char);
17087 vector signed char vec_slo (vector signed char, vector unsigned char);
17088 vector unsigned char vec_slo (vector unsigned char, vector signed char);
17089 vector unsigned char vec_slo (vector unsigned char,
17090 vector unsigned char);
17091 vector signed long long vec_slo (vector signed long long, vector signed char);
17092 vector signed long long vec_slo (vector signed long long, vector unsigned char);
17093 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
17094 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
17095
17096 vector signed char vec_splat (vector signed char, const int);
17097 vector unsigned char vec_splat (vector unsigned char, const int);
17098 vector bool char vec_splat (vector bool char, const int);
17099 vector signed short vec_splat (vector signed short, const int);
17100 vector unsigned short vec_splat (vector unsigned short, const int);
17101 vector bool short vec_splat (vector bool short, const int);
17102 vector pixel vec_splat (vector pixel, const int);
17103 vector float vec_splat (vector float, const int);
17104 vector signed int vec_splat (vector signed int, const int);
17105 vector unsigned int vec_splat (vector unsigned int, const int);
17106 vector bool int vec_splat (vector bool int, const int);
17107 vector signed long vec_splat (vector signed long, const int);
17108 vector unsigned long vec_splat (vector unsigned long, const int);
17109
17110 vector signed char vec_splats (signed char);
17111 vector unsigned char vec_splats (unsigned char);
17112 vector signed short vec_splats (signed short);
17113 vector unsigned short vec_splats (unsigned short);
17114 vector signed int vec_splats (signed int);
17115 vector unsigned int vec_splats (unsigned int);
17116 vector float vec_splats (float);
17117
17118 vector float vec_vspltw (vector float, const int);
17119 vector signed int vec_vspltw (vector signed int, const int);
17120 vector unsigned int vec_vspltw (vector unsigned int, const int);
17121 vector bool int vec_vspltw (vector bool int, const int);
17122
17123 vector bool short vec_vsplth (vector bool short, const int);
17124 vector signed short vec_vsplth (vector signed short, const int);
17125 vector unsigned short vec_vsplth (vector unsigned short, const int);
17126 vector pixel vec_vsplth (vector pixel, const int);
17127
17128 vector signed char vec_vspltb (vector signed char, const int);
17129 vector unsigned char vec_vspltb (vector unsigned char, const int);
17130 vector bool char vec_vspltb (vector bool char, const int);
17131
17132 vector signed char vec_splat_s8 (const int);
17133
17134 vector signed short vec_splat_s16 (const int);
17135
17136 vector signed int vec_splat_s32 (const int);
17137
17138 vector unsigned char vec_splat_u8 (const int);
17139
17140 vector unsigned short vec_splat_u16 (const int);
17141
17142 vector unsigned int vec_splat_u32 (const int);
17143
17144 vector signed char vec_sr (vector signed char, vector unsigned char);
17145 vector unsigned char vec_sr (vector unsigned char,
17146 vector unsigned char);
17147 vector signed short vec_sr (vector signed short,
17148 vector unsigned short);
17149 vector unsigned short vec_sr (vector unsigned short,
17150 vector unsigned short);
17151 vector signed int vec_sr (vector signed int, vector unsigned int);
17152 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
17153
17154 vector signed int vec_vsrw (vector signed int, vector unsigned int);
17155 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
17156
17157 vector signed short vec_vsrh (vector signed short,
17158 vector unsigned short);
17159 vector unsigned short vec_vsrh (vector unsigned short,
17160 vector unsigned short);
17161
17162 vector signed char vec_vsrb (vector signed char, vector unsigned char);
17163 vector unsigned char vec_vsrb (vector unsigned char,
17164 vector unsigned char);
17165
17166 vector signed char vec_sra (vector signed char, vector unsigned char);
17167 vector unsigned char vec_sra (vector unsigned char,
17168 vector unsigned char);
17169 vector signed short vec_sra (vector signed short,
17170 vector unsigned short);
17171 vector unsigned short vec_sra (vector unsigned short,
17172 vector unsigned short);
17173 vector signed int vec_sra (vector signed int, vector unsigned int);
17174 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
17175
17176 vector signed int vec_vsraw (vector signed int, vector unsigned int);
17177 vector unsigned int vec_vsraw (vector unsigned int,
17178 vector unsigned int);
17179
17180 vector signed short vec_vsrah (vector signed short,
17181 vector unsigned short);
17182 vector unsigned short vec_vsrah (vector unsigned short,
17183 vector unsigned short);
17184
17185 vector signed char vec_vsrab (vector signed char, vector unsigned char);
17186 vector unsigned char vec_vsrab (vector unsigned char,
17187 vector unsigned char);
17188
17189 vector signed int vec_srl (vector signed int, vector unsigned int);
17190 vector signed int vec_srl (vector signed int, vector unsigned short);
17191 vector signed int vec_srl (vector signed int, vector unsigned char);
17192 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
17193 vector unsigned int vec_srl (vector unsigned int,
17194 vector unsigned short);
17195 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
17196 vector bool int vec_srl (vector bool int, vector unsigned int);
17197 vector bool int vec_srl (vector bool int, vector unsigned short);
17198 vector bool int vec_srl (vector bool int, vector unsigned char);
17199 vector signed short vec_srl (vector signed short, vector unsigned int);
17200 vector signed short vec_srl (vector signed short,
17201 vector unsigned short);
17202 vector signed short vec_srl (vector signed short, vector unsigned char);
17203 vector unsigned short vec_srl (vector unsigned short,
17204 vector unsigned int);
17205 vector unsigned short vec_srl (vector unsigned short,
17206 vector unsigned short);
17207 vector unsigned short vec_srl (vector unsigned short,
17208 vector unsigned char);
17209 vector bool short vec_srl (vector bool short, vector unsigned int);
17210 vector bool short vec_srl (vector bool short, vector unsigned short);
17211 vector bool short vec_srl (vector bool short, vector unsigned char);
17212 vector pixel vec_srl (vector pixel, vector unsigned int);
17213 vector pixel vec_srl (vector pixel, vector unsigned short);
17214 vector pixel vec_srl (vector pixel, vector unsigned char);
17215 vector signed char vec_srl (vector signed char, vector unsigned int);
17216 vector signed char vec_srl (vector signed char, vector unsigned short);
17217 vector signed char vec_srl (vector signed char, vector unsigned char);
17218 vector unsigned char vec_srl (vector unsigned char,
17219 vector unsigned int);
17220 vector unsigned char vec_srl (vector unsigned char,
17221 vector unsigned short);
17222 vector unsigned char vec_srl (vector unsigned char,
17223 vector unsigned char);
17224 vector bool char vec_srl (vector bool char, vector unsigned int);
17225 vector bool char vec_srl (vector bool char, vector unsigned short);
17226 vector bool char vec_srl (vector bool char, vector unsigned char);
17227
17228 vector float vec_sro (vector float, vector signed char);
17229 vector float vec_sro (vector float, vector unsigned char);
17230 vector signed int vec_sro (vector signed int, vector signed char);
17231 vector signed int vec_sro (vector signed int, vector unsigned char);
17232 vector unsigned int vec_sro (vector unsigned int, vector signed char);
17233 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
17234 vector signed short vec_sro (vector signed short, vector signed char);
17235 vector signed short vec_sro (vector signed short, vector unsigned char);
17236 vector unsigned short vec_sro (vector unsigned short,
17237 vector signed char);
17238 vector unsigned short vec_sro (vector unsigned short,
17239 vector unsigned char);
17240 vector pixel vec_sro (vector pixel, vector signed char);
17241 vector pixel vec_sro (vector pixel, vector unsigned char);
17242 vector signed char vec_sro (vector signed char, vector signed char);
17243 vector signed char vec_sro (vector signed char, vector unsigned char);
17244 vector unsigned char vec_sro (vector unsigned char, vector signed char);
17245 vector unsigned char vec_sro (vector unsigned char,
17246 vector unsigned char);
17247
17248 void vec_st (vector float, int, vector float *);
17249 void vec_st (vector float, int, float *);
17250 void vec_st (vector signed int, int, vector signed int *);
17251 void vec_st (vector signed int, int, int *);
17252 void vec_st (vector unsigned int, int, vector unsigned int *);
17253 void vec_st (vector unsigned int, int, unsigned int *);
17254 void vec_st (vector bool int, int, vector bool int *);
17255 void vec_st (vector bool int, int, unsigned int *);
17256 void vec_st (vector bool int, int, int *);
17257 void vec_st (vector signed short, int, vector signed short *);
17258 void vec_st (vector signed short, int, short *);
17259 void vec_st (vector unsigned short, int, vector unsigned short *);
17260 void vec_st (vector unsigned short, int, unsigned short *);
17261 void vec_st (vector bool short, int, vector bool short *);
17262 void vec_st (vector bool short, int, unsigned short *);
17263 void vec_st (vector pixel, int, vector pixel *);
17264 void vec_st (vector pixel, int, unsigned short *);
17265 void vec_st (vector pixel, int, short *);
17266 void vec_st (vector bool short, int, short *);
17267 void vec_st (vector signed char, int, vector signed char *);
17268 void vec_st (vector signed char, int, signed char *);
17269 void vec_st (vector unsigned char, int, vector unsigned char *);
17270 void vec_st (vector unsigned char, int, unsigned char *);
17271 void vec_st (vector bool char, int, vector bool char *);
17272 void vec_st (vector bool char, int, unsigned char *);
17273 void vec_st (vector bool char, int, signed char *);
17274
17275 void vec_ste (vector signed char, int, signed char *);
17276 void vec_ste (vector unsigned char, int, unsigned char *);
17277 void vec_ste (vector bool char, int, signed char *);
17278 void vec_ste (vector bool char, int, unsigned char *);
17279 void vec_ste (vector signed short, int, short *);
17280 void vec_ste (vector unsigned short, int, unsigned short *);
17281 void vec_ste (vector bool short, int, short *);
17282 void vec_ste (vector bool short, int, unsigned short *);
17283 void vec_ste (vector pixel, int, short *);
17284 void vec_ste (vector pixel, int, unsigned short *);
17285 void vec_ste (vector float, int, float *);
17286 void vec_ste (vector signed int, int, int *);
17287 void vec_ste (vector unsigned int, int, unsigned int *);
17288 void vec_ste (vector bool int, int, int *);
17289 void vec_ste (vector bool int, int, unsigned int *);
17290
17291 void vec_stvewx (vector float, int, float *);
17292 void vec_stvewx (vector signed int, int, int *);
17293 void vec_stvewx (vector unsigned int, int, unsigned int *);
17294 void vec_stvewx (vector bool int, int, int *);
17295 void vec_stvewx (vector bool int, int, unsigned int *);
17296
17297 void vec_stvehx (vector signed short, int, short *);
17298 void vec_stvehx (vector unsigned short, int, unsigned short *);
17299 void vec_stvehx (vector bool short, int, short *);
17300 void vec_stvehx (vector bool short, int, unsigned short *);
17301 void vec_stvehx (vector pixel, int, short *);
17302 void vec_stvehx (vector pixel, int, unsigned short *);
17303
17304 void vec_stvebx (vector signed char, int, signed char *);
17305 void vec_stvebx (vector unsigned char, int, unsigned char *);
17306 void vec_stvebx (vector bool char, int, signed char *);
17307 void vec_stvebx (vector bool char, int, unsigned char *);
17308
17309 void vec_stl (vector float, int, vector float *);
17310 void vec_stl (vector float, int, float *);
17311 void vec_stl (vector signed int, int, vector signed int *);
17312 void vec_stl (vector signed int, int, int *);
17313 void vec_stl (vector unsigned int, int, vector unsigned int *);
17314 void vec_stl (vector unsigned int, int, unsigned int *);
17315 void vec_stl (vector bool int, int, vector bool int *);
17316 void vec_stl (vector bool int, int, unsigned int *);
17317 void vec_stl (vector bool int, int, int *);
17318 void vec_stl (vector signed short, int, vector signed short *);
17319 void vec_stl (vector signed short, int, short *);
17320 void vec_stl (vector unsigned short, int, vector unsigned short *);
17321 void vec_stl (vector unsigned short, int, unsigned short *);
17322 void vec_stl (vector bool short, int, vector bool short *);
17323 void vec_stl (vector bool short, int, unsigned short *);
17324 void vec_stl (vector bool short, int, short *);
17325 void vec_stl (vector pixel, int, vector pixel *);
17326 void vec_stl (vector pixel, int, unsigned short *);
17327 void vec_stl (vector pixel, int, short *);
17328 void vec_stl (vector signed char, int, vector signed char *);
17329 void vec_stl (vector signed char, int, signed char *);
17330 void vec_stl (vector unsigned char, int, vector unsigned char *);
17331 void vec_stl (vector unsigned char, int, unsigned char *);
17332 void vec_stl (vector bool char, int, vector bool char *);
17333 void vec_stl (vector bool char, int, unsigned char *);
17334 void vec_stl (vector bool char, int, signed char *);
17335
17336 vector signed char vec_sub (vector bool char, vector signed char);
17337 vector signed char vec_sub (vector signed char, vector bool char);
17338 vector signed char vec_sub (vector signed char, vector signed char);
17339 vector unsigned char vec_sub (vector bool char, vector unsigned char);
17340 vector unsigned char vec_sub (vector unsigned char, vector bool char);
17341 vector unsigned char vec_sub (vector unsigned char,
17342 vector unsigned char);
17343 vector signed short vec_sub (vector bool short, vector signed short);
17344 vector signed short vec_sub (vector signed short, vector bool short);
17345 vector signed short vec_sub (vector signed short, vector signed short);
17346 vector unsigned short vec_sub (vector bool short,
17347 vector unsigned short);
17348 vector unsigned short vec_sub (vector unsigned short,
17349 vector bool short);
17350 vector unsigned short vec_sub (vector unsigned short,
17351 vector unsigned short);
17352 vector signed int vec_sub (vector bool int, vector signed int);
17353 vector signed int vec_sub (vector signed int, vector bool int);
17354 vector signed int vec_sub (vector signed int, vector signed int);
17355 vector unsigned int vec_sub (vector bool int, vector unsigned int);
17356 vector unsigned int vec_sub (vector unsigned int, vector bool int);
17357 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
17358 vector float vec_sub (vector float, vector float);
17359
17360 vector float vec_vsubfp (vector float, vector float);
17361
17362 vector signed int vec_vsubuwm (vector bool int, vector signed int);
17363 vector signed int vec_vsubuwm (vector signed int, vector bool int);
17364 vector signed int vec_vsubuwm (vector signed int, vector signed int);
17365 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
17366 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
17367 vector unsigned int vec_vsubuwm (vector unsigned int,
17368 vector unsigned int);
17369
17370 vector signed short vec_vsubuhm (vector bool short,
17371 vector signed short);
17372 vector signed short vec_vsubuhm (vector signed short,
17373 vector bool short);
17374 vector signed short vec_vsubuhm (vector signed short,
17375 vector signed short);
17376 vector unsigned short vec_vsubuhm (vector bool short,
17377 vector unsigned short);
17378 vector unsigned short vec_vsubuhm (vector unsigned short,
17379 vector bool short);
17380 vector unsigned short vec_vsubuhm (vector unsigned short,
17381 vector unsigned short);
17382
17383 vector signed char vec_vsububm (vector bool char, vector signed char);
17384 vector signed char vec_vsububm (vector signed char, vector bool char);
17385 vector signed char vec_vsububm (vector signed char, vector signed char);
17386 vector unsigned char vec_vsububm (vector bool char,
17387 vector unsigned char);
17388 vector unsigned char vec_vsububm (vector unsigned char,
17389 vector bool char);
17390 vector unsigned char vec_vsububm (vector unsigned char,
17391 vector unsigned char);
17392
17393 vector signed int vec_subc (vector signed int, vector signed int);
17394 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
17395 vector signed __int128 vec_subc (vector signed __int128,
17396 vector signed __int128);
17397 vector unsigned __int128 vec_subc (vector unsigned __int128,
17398 vector unsigned __int128);
17399
17400 vector signed int vec_sube (vector signed int, vector signed int,
17401 vector signed int);
17402 vector unsigned int vec_sube (vector unsigned int, vector unsigned int,
17403 vector unsigned int);
17404 vector signed __int128 vec_sube (vector signed __int128,
17405 vector signed __int128,
17406 vector signed __int128);
17407 vector unsigned __int128 vec_sube (vector unsigned __int128,
17408 vector unsigned __int128,
17409 vector unsigned __int128);
17410
17411 vector signed int vec_subec (vector signed int, vector signed int,
17412 vector signed int);
17413 vector unsigned int vec_subec (vector unsigned int, vector unsigned int,
17414 vector unsigned int);
17415 vector signed __int128 vec_subec (vector signed __int128,
17416 vector signed __int128,
17417 vector signed __int128);
17418 vector unsigned __int128 vec_subec (vector unsigned __int128,
17419 vector unsigned __int128,
17420 vector unsigned __int128);
17421
17422 vector unsigned char vec_subs (vector bool char, vector unsigned char);
17423 vector unsigned char vec_subs (vector unsigned char, vector bool char);
17424 vector unsigned char vec_subs (vector unsigned char,
17425 vector unsigned char);
17426 vector signed char vec_subs (vector bool char, vector signed char);
17427 vector signed char vec_subs (vector signed char, vector bool char);
17428 vector signed char vec_subs (vector signed char, vector signed char);
17429 vector unsigned short vec_subs (vector bool short,
17430 vector unsigned short);
17431 vector unsigned short vec_subs (vector unsigned short,
17432 vector bool short);
17433 vector unsigned short vec_subs (vector unsigned short,
17434 vector unsigned short);
17435 vector signed short vec_subs (vector bool short, vector signed short);
17436 vector signed short vec_subs (vector signed short, vector bool short);
17437 vector signed short vec_subs (vector signed short, vector signed short);
17438 vector unsigned int vec_subs (vector bool int, vector unsigned int);
17439 vector unsigned int vec_subs (vector unsigned int, vector bool int);
17440 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
17441 vector signed int vec_subs (vector bool int, vector signed int);
17442 vector signed int vec_subs (vector signed int, vector bool int);
17443 vector signed int vec_subs (vector signed int, vector signed int);
17444
17445 vector signed int vec_vsubsws (vector bool int, vector signed int);
17446 vector signed int vec_vsubsws (vector signed int, vector bool int);
17447 vector signed int vec_vsubsws (vector signed int, vector signed int);
17448
17449 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
17450 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
17451 vector unsigned int vec_vsubuws (vector unsigned int,
17452 vector unsigned int);
17453
17454 vector signed short vec_vsubshs (vector bool short,
17455 vector signed short);
17456 vector signed short vec_vsubshs (vector signed short,
17457 vector bool short);
17458 vector signed short vec_vsubshs (vector signed short,
17459 vector signed short);
17460
17461 vector unsigned short vec_vsubuhs (vector bool short,
17462 vector unsigned short);
17463 vector unsigned short vec_vsubuhs (vector unsigned short,
17464 vector bool short);
17465 vector unsigned short vec_vsubuhs (vector unsigned short,
17466 vector unsigned short);
17467
17468 vector signed char vec_vsubsbs (vector bool char, vector signed char);
17469 vector signed char vec_vsubsbs (vector signed char, vector bool char);
17470 vector signed char vec_vsubsbs (vector signed char, vector signed char);
17471
17472 vector unsigned char vec_vsububs (vector bool char,
17473 vector unsigned char);
17474 vector unsigned char vec_vsububs (vector unsigned char,
17475 vector bool char);
17476 vector unsigned char vec_vsububs (vector unsigned char,
17477 vector unsigned char);
17478
17479 vector unsigned int vec_sum4s (vector unsigned char,
17480 vector unsigned int);
17481 vector signed int vec_sum4s (vector signed char, vector signed int);
17482 vector signed int vec_sum4s (vector signed short, vector signed int);
17483
17484 vector signed int vec_vsum4shs (vector signed short, vector signed int);
17485
17486 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
17487
17488 vector unsigned int vec_vsum4ubs (vector unsigned char,
17489 vector unsigned int);
17490
17491 vector signed int vec_sum2s (vector signed int, vector signed int);
17492
17493 vector signed int vec_sums (vector signed int, vector signed int);
17494
17495 vector float vec_trunc (vector float);
17496
17497 vector signed long long vec_unsigned (vector double);
17498 vector signed int vec_unsigned (vector float);
17499
17500 vector signed int vec_unsignede (vector double);
17501 vector signed int vec_unsignedo (vector double);
17502 vector signed int vec_unsigned2 (vector double, vector double);
17503
17504 vector signed short vec_unpackh (vector signed char);
17505 vector bool short vec_unpackh (vector bool char);
17506 vector signed int vec_unpackh (vector signed short);
17507 vector bool int vec_unpackh (vector bool short);
17508 vector unsigned int vec_unpackh (vector pixel);
17509
17510 vector bool int vec_vupkhsh (vector bool short);
17511 vector signed int vec_vupkhsh (vector signed short);
17512
17513 vector unsigned int vec_vupkhpx (vector pixel);
17514
17515 vector bool short vec_vupkhsb (vector bool char);
17516 vector signed short vec_vupkhsb (vector signed char);
17517
17518 vector signed short vec_unpackl (vector signed char);
17519 vector bool short vec_unpackl (vector bool char);
17520 vector unsigned int vec_unpackl (vector pixel);
17521 vector signed int vec_unpackl (vector signed short);
17522 vector bool int vec_unpackl (vector bool short);
17523
17524 vector unsigned int vec_vupklpx (vector pixel);
17525
17526 vector bool int vec_vupklsh (vector bool short);
17527 vector signed int vec_vupklsh (vector signed short);
17528
17529 vector bool short vec_vupklsb (vector bool char);
17530 vector signed short vec_vupklsb (vector signed char);
17531
17532 vector float vec_xor (vector float, vector float);
17533 vector float vec_xor (vector float, vector bool int);
17534 vector float vec_xor (vector bool int, vector float);
17535 vector bool int vec_xor (vector bool int, vector bool int);
17536 vector signed int vec_xor (vector bool int, vector signed int);
17537 vector signed int vec_xor (vector signed int, vector bool int);
17538 vector signed int vec_xor (vector signed int, vector signed int);
17539 vector unsigned int vec_xor (vector bool int, vector unsigned int);
17540 vector unsigned int vec_xor (vector unsigned int, vector bool int);
17541 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
17542 vector bool short vec_xor (vector bool short, vector bool short);
17543 vector signed short vec_xor (vector bool short, vector signed short);
17544 vector signed short vec_xor (vector signed short, vector bool short);
17545 vector signed short vec_xor (vector signed short, vector signed short);
17546 vector unsigned short vec_xor (vector bool short,
17547 vector unsigned short);
17548 vector unsigned short vec_xor (vector unsigned short,
17549 vector bool short);
17550 vector unsigned short vec_xor (vector unsigned short,
17551 vector unsigned short);
17552 vector signed char vec_xor (vector bool char, vector signed char);
17553 vector bool char vec_xor (vector bool char, vector bool char);
17554 vector signed char vec_xor (vector signed char, vector bool char);
17555 vector signed char vec_xor (vector signed char, vector signed char);
17556 vector unsigned char vec_xor (vector bool char, vector unsigned char);
17557 vector unsigned char vec_xor (vector unsigned char, vector bool char);
17558 vector unsigned char vec_xor (vector unsigned char,
17559 vector unsigned char);
17560
17561 int vec_all_eq (vector signed char, vector bool char);
17562 int vec_all_eq (vector signed char, vector signed char);
17563 int vec_all_eq (vector unsigned char, vector bool char);
17564 int vec_all_eq (vector unsigned char, vector unsigned char);
17565 int vec_all_eq (vector bool char, vector bool char);
17566 int vec_all_eq (vector bool char, vector unsigned char);
17567 int vec_all_eq (vector bool char, vector signed char);
17568 int vec_all_eq (vector signed short, vector bool short);
17569 int vec_all_eq (vector signed short, vector signed short);
17570 int vec_all_eq (vector unsigned short, vector bool short);
17571 int vec_all_eq (vector unsigned short, vector unsigned short);
17572 int vec_all_eq (vector bool short, vector bool short);
17573 int vec_all_eq (vector bool short, vector unsigned short);
17574 int vec_all_eq (vector bool short, vector signed short);
17575 int vec_all_eq (vector pixel, vector pixel);
17576 int vec_all_eq (vector signed int, vector bool int);
17577 int vec_all_eq (vector signed int, vector signed int);
17578 int vec_all_eq (vector unsigned int, vector bool int);
17579 int vec_all_eq (vector unsigned int, vector unsigned int);
17580 int vec_all_eq (vector bool int, vector bool int);
17581 int vec_all_eq (vector bool int, vector unsigned int);
17582 int vec_all_eq (vector bool int, vector signed int);
17583 int vec_all_eq (vector float, vector float);
17584
17585 int vec_all_ge (vector bool char, vector unsigned char);
17586 int vec_all_ge (vector unsigned char, vector bool char);
17587 int vec_all_ge (vector unsigned char, vector unsigned char);
17588 int vec_all_ge (vector bool char, vector signed char);
17589 int vec_all_ge (vector signed char, vector bool char);
17590 int vec_all_ge (vector signed char, vector signed char);
17591 int vec_all_ge (vector bool short, vector unsigned short);
17592 int vec_all_ge (vector unsigned short, vector bool short);
17593 int vec_all_ge (vector unsigned short, vector unsigned short);
17594 int vec_all_ge (vector signed short, vector signed short);
17595 int vec_all_ge (vector bool short, vector signed short);
17596 int vec_all_ge (vector signed short, vector bool short);
17597 int vec_all_ge (vector bool int, vector unsigned int);
17598 int vec_all_ge (vector unsigned int, vector bool int);
17599 int vec_all_ge (vector unsigned int, vector unsigned int);
17600 int vec_all_ge (vector bool int, vector signed int);
17601 int vec_all_ge (vector signed int, vector bool int);
17602 int vec_all_ge (vector signed int, vector signed int);
17603 int vec_all_ge (vector float, vector float);
17604
17605 int vec_all_gt (vector bool char, vector unsigned char);
17606 int vec_all_gt (vector unsigned char, vector bool char);
17607 int vec_all_gt (vector unsigned char, vector unsigned char);
17608 int vec_all_gt (vector bool char, vector signed char);
17609 int vec_all_gt (vector signed char, vector bool char);
17610 int vec_all_gt (vector signed char, vector signed char);
17611 int vec_all_gt (vector bool short, vector unsigned short);
17612 int vec_all_gt (vector unsigned short, vector bool short);
17613 int vec_all_gt (vector unsigned short, vector unsigned short);
17614 int vec_all_gt (vector bool short, vector signed short);
17615 int vec_all_gt (vector signed short, vector bool short);
17616 int vec_all_gt (vector signed short, vector signed short);
17617 int vec_all_gt (vector bool int, vector unsigned int);
17618 int vec_all_gt (vector unsigned int, vector bool int);
17619 int vec_all_gt (vector unsigned int, vector unsigned int);
17620 int vec_all_gt (vector bool int, vector signed int);
17621 int vec_all_gt (vector signed int, vector bool int);
17622 int vec_all_gt (vector signed int, vector signed int);
17623 int vec_all_gt (vector float, vector float);
17624
17625 int vec_all_in (vector float, vector float);
17626
17627 int vec_all_le (vector bool char, vector unsigned char);
17628 int vec_all_le (vector unsigned char, vector bool char);
17629 int vec_all_le (vector unsigned char, vector unsigned char);
17630 int vec_all_le (vector bool char, vector signed char);
17631 int vec_all_le (vector signed char, vector bool char);
17632 int vec_all_le (vector signed char, vector signed char);
17633 int vec_all_le (vector bool short, vector unsigned short);
17634 int vec_all_le (vector unsigned short, vector bool short);
17635 int vec_all_le (vector unsigned short, vector unsigned short);
17636 int vec_all_le (vector bool short, vector signed short);
17637 int vec_all_le (vector signed short, vector bool short);
17638 int vec_all_le (vector signed short, vector signed short);
17639 int vec_all_le (vector bool int, vector unsigned int);
17640 int vec_all_le (vector unsigned int, vector bool int);
17641 int vec_all_le (vector unsigned int, vector unsigned int);
17642 int vec_all_le (vector bool int, vector signed int);
17643 int vec_all_le (vector signed int, vector bool int);
17644 int vec_all_le (vector signed int, vector signed int);
17645 int vec_all_le (vector float, vector float);
17646
17647 int vec_all_lt (vector bool char, vector unsigned char);
17648 int vec_all_lt (vector unsigned char, vector bool char);
17649 int vec_all_lt (vector unsigned char, vector unsigned char);
17650 int vec_all_lt (vector bool char, vector signed char);
17651 int vec_all_lt (vector signed char, vector bool char);
17652 int vec_all_lt (vector signed char, vector signed char);
17653 int vec_all_lt (vector bool short, vector unsigned short);
17654 int vec_all_lt (vector unsigned short, vector bool short);
17655 int vec_all_lt (vector unsigned short, vector unsigned short);
17656 int vec_all_lt (vector bool short, vector signed short);
17657 int vec_all_lt (vector signed short, vector bool short);
17658 int vec_all_lt (vector signed short, vector signed short);
17659 int vec_all_lt (vector bool int, vector unsigned int);
17660 int vec_all_lt (vector unsigned int, vector bool int);
17661 int vec_all_lt (vector unsigned int, vector unsigned int);
17662 int vec_all_lt (vector bool int, vector signed int);
17663 int vec_all_lt (vector signed int, vector bool int);
17664 int vec_all_lt (vector signed int, vector signed int);
17665 int vec_all_lt (vector float, vector float);
17666
17667 int vec_all_nan (vector float);
17668
17669 int vec_all_ne (vector signed char, vector bool char);
17670 int vec_all_ne (vector signed char, vector signed char);
17671 int vec_all_ne (vector unsigned char, vector bool char);
17672 int vec_all_ne (vector unsigned char, vector unsigned char);
17673 int vec_all_ne (vector bool char, vector bool char);
17674 int vec_all_ne (vector bool char, vector unsigned char);
17675 int vec_all_ne (vector bool char, vector signed char);
17676 int vec_all_ne (vector signed short, vector bool short);
17677 int vec_all_ne (vector signed short, vector signed short);
17678 int vec_all_ne (vector unsigned short, vector bool short);
17679 int vec_all_ne (vector unsigned short, vector unsigned short);
17680 int vec_all_ne (vector bool short, vector bool short);
17681 int vec_all_ne (vector bool short, vector unsigned short);
17682 int vec_all_ne (vector bool short, vector signed short);
17683 int vec_all_ne (vector pixel, vector pixel);
17684 int vec_all_ne (vector signed int, vector bool int);
17685 int vec_all_ne (vector signed int, vector signed int);
17686 int vec_all_ne (vector unsigned int, vector bool int);
17687 int vec_all_ne (vector unsigned int, vector unsigned int);
17688 int vec_all_ne (vector bool int, vector bool int);
17689 int vec_all_ne (vector bool int, vector unsigned int);
17690 int vec_all_ne (vector bool int, vector signed int);
17691 int vec_all_ne (vector float, vector float);
17692
17693 int vec_all_nge (vector float, vector float);
17694
17695 int vec_all_ngt (vector float, vector float);
17696
17697 int vec_all_nle (vector float, vector float);
17698
17699 int vec_all_nlt (vector float, vector float);
17700
17701 int vec_all_numeric (vector float);
17702
17703 int vec_any_eq (vector signed char, vector bool char);
17704 int vec_any_eq (vector signed char, vector signed char);
17705 int vec_any_eq (vector unsigned char, vector bool char);
17706 int vec_any_eq (vector unsigned char, vector unsigned char);
17707 int vec_any_eq (vector bool char, vector bool char);
17708 int vec_any_eq (vector bool char, vector unsigned char);
17709 int vec_any_eq (vector bool char, vector signed char);
17710 int vec_any_eq (vector signed short, vector bool short);
17711 int vec_any_eq (vector signed short, vector signed short);
17712 int vec_any_eq (vector unsigned short, vector bool short);
17713 int vec_any_eq (vector unsigned short, vector unsigned short);
17714 int vec_any_eq (vector bool short, vector bool short);
17715 int vec_any_eq (vector bool short, vector unsigned short);
17716 int vec_any_eq (vector bool short, vector signed short);
17717 int vec_any_eq (vector pixel, vector pixel);
17718 int vec_any_eq (vector signed int, vector bool int);
17719 int vec_any_eq (vector signed int, vector signed int);
17720 int vec_any_eq (vector unsigned int, vector bool int);
17721 int vec_any_eq (vector unsigned int, vector unsigned int);
17722 int vec_any_eq (vector bool int, vector bool int);
17723 int vec_any_eq (vector bool int, vector unsigned int);
17724 int vec_any_eq (vector bool int, vector signed int);
17725 int vec_any_eq (vector float, vector float);
17726
17727 int vec_any_ge (vector signed char, vector bool char);
17728 int vec_any_ge (vector unsigned char, vector bool char);
17729 int vec_any_ge (vector unsigned char, vector unsigned char);
17730 int vec_any_ge (vector signed char, vector signed char);
17731 int vec_any_ge (vector bool char, vector unsigned char);
17732 int vec_any_ge (vector bool char, vector signed char);
17733 int vec_any_ge (vector unsigned short, vector bool short);
17734 int vec_any_ge (vector unsigned short, vector unsigned short);
17735 int vec_any_ge (vector signed short, vector signed short);
17736 int vec_any_ge (vector signed short, vector bool short);
17737 int vec_any_ge (vector bool short, vector unsigned short);
17738 int vec_any_ge (vector bool short, vector signed short);
17739 int vec_any_ge (vector signed int, vector bool int);
17740 int vec_any_ge (vector unsigned int, vector bool int);
17741 int vec_any_ge (vector unsigned int, vector unsigned int);
17742 int vec_any_ge (vector signed int, vector signed int);
17743 int vec_any_ge (vector bool int, vector unsigned int);
17744 int vec_any_ge (vector bool int, vector signed int);
17745 int vec_any_ge (vector float, vector float);
17746
17747 int vec_any_gt (vector bool char, vector unsigned char);
17748 int vec_any_gt (vector unsigned char, vector bool char);
17749 int vec_any_gt (vector unsigned char, vector unsigned char);
17750 int vec_any_gt (vector bool char, vector signed char);
17751 int vec_any_gt (vector signed char, vector bool char);
17752 int vec_any_gt (vector signed char, vector signed char);
17753 int vec_any_gt (vector bool short, vector unsigned short);
17754 int vec_any_gt (vector unsigned short, vector bool short);
17755 int vec_any_gt (vector unsigned short, vector unsigned short);
17756 int vec_any_gt (vector bool short, vector signed short);
17757 int vec_any_gt (vector signed short, vector bool short);
17758 int vec_any_gt (vector signed short, vector signed short);
17759 int vec_any_gt (vector bool int, vector unsigned int);
17760 int vec_any_gt (vector unsigned int, vector bool int);
17761 int vec_any_gt (vector unsigned int, vector unsigned int);
17762 int vec_any_gt (vector bool int, vector signed int);
17763 int vec_any_gt (vector signed int, vector bool int);
17764 int vec_any_gt (vector signed int, vector signed int);
17765 int vec_any_gt (vector float, vector float);
17766
17767 int vec_any_le (vector bool char, vector unsigned char);
17768 int vec_any_le (vector unsigned char, vector bool char);
17769 int vec_any_le (vector unsigned char, vector unsigned char);
17770 int vec_any_le (vector bool char, vector signed char);
17771 int vec_any_le (vector signed char, vector bool char);
17772 int vec_any_le (vector signed char, vector signed char);
17773 int vec_any_le (vector bool short, vector unsigned short);
17774 int vec_any_le (vector unsigned short, vector bool short);
17775 int vec_any_le (vector unsigned short, vector unsigned short);
17776 int vec_any_le (vector bool short, vector signed short);
17777 int vec_any_le (vector signed short, vector bool short);
17778 int vec_any_le (vector signed short, vector signed short);
17779 int vec_any_le (vector bool int, vector unsigned int);
17780 int vec_any_le (vector unsigned int, vector bool int);
17781 int vec_any_le (vector unsigned int, vector unsigned int);
17782 int vec_any_le (vector bool int, vector signed int);
17783 int vec_any_le (vector signed int, vector bool int);
17784 int vec_any_le (vector signed int, vector signed int);
17785 int vec_any_le (vector float, vector float);
17786
17787 int vec_any_lt (vector bool char, vector unsigned char);
17788 int vec_any_lt (vector unsigned char, vector bool char);
17789 int vec_any_lt (vector unsigned char, vector unsigned char);
17790 int vec_any_lt (vector bool char, vector signed char);
17791 int vec_any_lt (vector signed char, vector bool char);
17792 int vec_any_lt (vector signed char, vector signed char);
17793 int vec_any_lt (vector bool short, vector unsigned short);
17794 int vec_any_lt (vector unsigned short, vector bool short);
17795 int vec_any_lt (vector unsigned short, vector unsigned short);
17796 int vec_any_lt (vector bool short, vector signed short);
17797 int vec_any_lt (vector signed short, vector bool short);
17798 int vec_any_lt (vector signed short, vector signed short);
17799 int vec_any_lt (vector bool int, vector unsigned int);
17800 int vec_any_lt (vector unsigned int, vector bool int);
17801 int vec_any_lt (vector unsigned int, vector unsigned int);
17802 int vec_any_lt (vector bool int, vector signed int);
17803 int vec_any_lt (vector signed int, vector bool int);
17804 int vec_any_lt (vector signed int, vector signed int);
17805 int vec_any_lt (vector float, vector float);
17806
17807 int vec_any_nan (vector float);
17808
17809 int vec_any_ne (vector signed char, vector bool char);
17810 int vec_any_ne (vector signed char, vector signed char);
17811 int vec_any_ne (vector unsigned char, vector bool char);
17812 int vec_any_ne (vector unsigned char, vector unsigned char);
17813 int vec_any_ne (vector bool char, vector bool char);
17814 int vec_any_ne (vector bool char, vector unsigned char);
17815 int vec_any_ne (vector bool char, vector signed char);
17816 int vec_any_ne (vector signed short, vector bool short);
17817 int vec_any_ne (vector signed short, vector signed short);
17818 int vec_any_ne (vector unsigned short, vector bool short);
17819 int vec_any_ne (vector unsigned short, vector unsigned short);
17820 int vec_any_ne (vector bool short, vector bool short);
17821 int vec_any_ne (vector bool short, vector unsigned short);
17822 int vec_any_ne (vector bool short, vector signed short);
17823 int vec_any_ne (vector pixel, vector pixel);
17824 int vec_any_ne (vector signed int, vector bool int);
17825 int vec_any_ne (vector signed int, vector signed int);
17826 int vec_any_ne (vector unsigned int, vector bool int);
17827 int vec_any_ne (vector unsigned int, vector unsigned int);
17828 int vec_any_ne (vector bool int, vector bool int);
17829 int vec_any_ne (vector bool int, vector unsigned int);
17830 int vec_any_ne (vector bool int, vector signed int);
17831 int vec_any_ne (vector float, vector float);
17832
17833 int vec_any_nge (vector float, vector float);
17834
17835 int vec_any_ngt (vector float, vector float);
17836
17837 int vec_any_nle (vector float, vector float);
17838
17839 int vec_any_nlt (vector float, vector float);
17840
17841 int vec_any_numeric (vector float);
17842
17843 int vec_any_out (vector float, vector float);
17844 @end smallexample
17845
17846 If the vector/scalar (VSX) instruction set is available, the following
17847 additional functions are available:
17848
17849 @smallexample
17850 vector double vec_abs (vector double);
17851 vector double vec_add (vector double, vector double);
17852 vector double vec_and (vector double, vector double);
17853 vector double vec_and (vector double, vector bool long);
17854 vector double vec_and (vector bool long, vector double);
17855 vector long vec_and (vector long, vector long);
17856 vector long vec_and (vector long, vector bool long);
17857 vector long vec_and (vector bool long, vector long);
17858 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
17859 vector unsigned long vec_and (vector unsigned long, vector bool long);
17860 vector unsigned long vec_and (vector bool long, vector unsigned long);
17861 vector double vec_andc (vector double, vector double);
17862 vector double vec_andc (vector double, vector bool long);
17863 vector double vec_andc (vector bool long, vector double);
17864 vector long vec_andc (vector long, vector long);
17865 vector long vec_andc (vector long, vector bool long);
17866 vector long vec_andc (vector bool long, vector long);
17867 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
17868 vector unsigned long vec_andc (vector unsigned long, vector bool long);
17869 vector unsigned long vec_andc (vector bool long, vector unsigned long);
17870 vector double vec_ceil (vector double);
17871 vector bool long vec_cmpeq (vector double, vector double);
17872 vector bool long vec_cmpge (vector double, vector double);
17873 vector bool long vec_cmpgt (vector double, vector double);
17874 vector bool long vec_cmple (vector double, vector double);
17875 vector bool long vec_cmplt (vector double, vector double);
17876 vector double vec_cpsgn (vector double, vector double);
17877 vector float vec_div (vector float, vector float);
17878 vector double vec_div (vector double, vector double);
17879 vector long vec_div (vector long, vector long);
17880 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
17881 vector double vec_floor (vector double);
17882 vector double vec_ld (int, const vector double *);
17883 vector double vec_ld (int, const double *);
17884 vector double vec_ldl (int, const vector double *);
17885 vector double vec_ldl (int, const double *);
17886 vector unsigned char vec_lvsl (int, const volatile double *);
17887 vector unsigned char vec_lvsr (int, const volatile double *);
17888 vector double vec_madd (vector double, vector double, vector double);
17889 vector double vec_max (vector double, vector double);
17890 vector signed long vec_mergeh (vector signed long, vector signed long);
17891 vector signed long vec_mergeh (vector signed long, vector bool long);
17892 vector signed long vec_mergeh (vector bool long, vector signed long);
17893 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
17894 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
17895 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
17896 vector signed long vec_mergel (vector signed long, vector signed long);
17897 vector signed long vec_mergel (vector signed long, vector bool long);
17898 vector signed long vec_mergel (vector bool long, vector signed long);
17899 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
17900 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
17901 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
17902 vector double vec_min (vector double, vector double);
17903 vector float vec_msub (vector float, vector float, vector float);
17904 vector double vec_msub (vector double, vector double, vector double);
17905 vector float vec_mul (vector float, vector float);
17906 vector double vec_mul (vector double, vector double);
17907 vector long vec_mul (vector long, vector long);
17908 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
17909 vector float vec_nearbyint (vector float);
17910 vector double vec_nearbyint (vector double);
17911 vector float vec_nmadd (vector float, vector float, vector float);
17912 vector double vec_nmadd (vector double, vector double, vector double);
17913 vector double vec_nmsub (vector double, vector double, vector double);
17914 vector double vec_nor (vector double, vector double);
17915 vector long vec_nor (vector long, vector long);
17916 vector long vec_nor (vector long, vector bool long);
17917 vector long vec_nor (vector bool long, vector long);
17918 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
17919 vector unsigned long vec_nor (vector unsigned long, vector bool long);
17920 vector unsigned long vec_nor (vector bool long, vector unsigned long);
17921 vector double vec_or (vector double, vector double);
17922 vector double vec_or (vector double, vector bool long);
17923 vector double vec_or (vector bool long, vector double);
17924 vector long vec_or (vector long, vector long);
17925 vector long vec_or (vector long, vector bool long);
17926 vector long vec_or (vector bool long, vector long);
17927 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
17928 vector unsigned long vec_or (vector unsigned long, vector bool long);
17929 vector unsigned long vec_or (vector bool long, vector unsigned long);
17930 vector double vec_perm (vector double, vector double, vector unsigned char);
17931 vector long vec_perm (vector long, vector long, vector unsigned char);
17932 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
17933 vector unsigned char);
17934 vector double vec_rint (vector double);
17935 vector double vec_recip (vector double, vector double);
17936 vector double vec_rsqrt (vector double);
17937 vector double vec_rsqrte (vector double);
17938 vector double vec_sel (vector double, vector double, vector bool long);
17939 vector double vec_sel (vector double, vector double, vector unsigned long);
17940 vector long vec_sel (vector long, vector long, vector long);
17941 vector long vec_sel (vector long, vector long, vector unsigned long);
17942 vector long vec_sel (vector long, vector long, vector bool long);
17943 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17944 vector long);
17945 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17946 vector unsigned long);
17947 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17948 vector bool long);
17949 vector double vec_splats (double);
17950 vector signed long vec_splats (signed long);
17951 vector unsigned long vec_splats (unsigned long);
17952 vector float vec_sqrt (vector float);
17953 vector double vec_sqrt (vector double);
17954 void vec_st (vector double, int, vector double *);
17955 void vec_st (vector double, int, double *);
17956 vector double vec_sub (vector double, vector double);
17957 vector double vec_trunc (vector double);
17958 vector double vec_xl (int, vector double *);
17959 vector double vec_xl (int, double *);
17960 vector long long vec_xl (int, vector long long *);
17961 vector long long vec_xl (int, long long *);
17962 vector unsigned long long vec_xl (int, vector unsigned long long *);
17963 vector unsigned long long vec_xl (int, unsigned long long *);
17964 vector float vec_xl (int, vector float *);
17965 vector float vec_xl (int, float *);
17966 vector int vec_xl (int, vector int *);
17967 vector int vec_xl (int, int *);
17968 vector unsigned int vec_xl (int, vector unsigned int *);
17969 vector unsigned int vec_xl (int, unsigned int *);
17970 vector double vec_xor (vector double, vector double);
17971 vector double vec_xor (vector double, vector bool long);
17972 vector double vec_xor (vector bool long, vector double);
17973 vector long vec_xor (vector long, vector long);
17974 vector long vec_xor (vector long, vector bool long);
17975 vector long vec_xor (vector bool long, vector long);
17976 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
17977 vector unsigned long vec_xor (vector unsigned long, vector bool long);
17978 vector unsigned long vec_xor (vector bool long, vector unsigned long);
17979 void vec_xst (vector double, int, vector double *);
17980 void vec_xst (vector double, int, double *);
17981 void vec_xst (vector long long, int, vector long long *);
17982 void vec_xst (vector long long, int, long long *);
17983 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
17984 void vec_xst (vector unsigned long long, int, unsigned long long *);
17985 void vec_xst (vector float, int, vector float *);
17986 void vec_xst (vector float, int, float *);
17987 void vec_xst (vector int, int, vector int *);
17988 void vec_xst (vector int, int, int *);
17989 void vec_xst (vector unsigned int, int, vector unsigned int *);
17990 void vec_xst (vector unsigned int, int, unsigned int *);
17991 int vec_all_eq (vector double, vector double);
17992 int vec_all_ge (vector double, vector double);
17993 int vec_all_gt (vector double, vector double);
17994 int vec_all_le (vector double, vector double);
17995 int vec_all_lt (vector double, vector double);
17996 int vec_all_nan (vector double);
17997 int vec_all_ne (vector double, vector double);
17998 int vec_all_nge (vector double, vector double);
17999 int vec_all_ngt (vector double, vector double);
18000 int vec_all_nle (vector double, vector double);
18001 int vec_all_nlt (vector double, vector double);
18002 int vec_all_numeric (vector double);
18003 int vec_any_eq (vector double, vector double);
18004 int vec_any_ge (vector double, vector double);
18005 int vec_any_gt (vector double, vector double);
18006 int vec_any_le (vector double, vector double);
18007 int vec_any_lt (vector double, vector double);
18008 int vec_any_nan (vector double);
18009 int vec_any_ne (vector double, vector double);
18010 int vec_any_nge (vector double, vector double);
18011 int vec_any_ngt (vector double, vector double);
18012 int vec_any_nle (vector double, vector double);
18013 int vec_any_nlt (vector double, vector double);
18014 int vec_any_numeric (vector double);
18015
18016 vector double vec_vsx_ld (int, const vector double *);
18017 vector double vec_vsx_ld (int, const double *);
18018 vector float vec_vsx_ld (int, const vector float *);
18019 vector float vec_vsx_ld (int, const float *);
18020 vector bool int vec_vsx_ld (int, const vector bool int *);
18021 vector signed int vec_vsx_ld (int, const vector signed int *);
18022 vector signed int vec_vsx_ld (int, const int *);
18023 vector signed int vec_vsx_ld (int, const long *);
18024 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
18025 vector unsigned int vec_vsx_ld (int, const unsigned int *);
18026 vector unsigned int vec_vsx_ld (int, const unsigned long *);
18027 vector bool short vec_vsx_ld (int, const vector bool short *);
18028 vector pixel vec_vsx_ld (int, const vector pixel *);
18029 vector signed short vec_vsx_ld (int, const vector signed short *);
18030 vector signed short vec_vsx_ld (int, const short *);
18031 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
18032 vector unsigned short vec_vsx_ld (int, const unsigned short *);
18033 vector bool char vec_vsx_ld (int, const vector bool char *);
18034 vector signed char vec_vsx_ld (int, const vector signed char *);
18035 vector signed char vec_vsx_ld (int, const signed char *);
18036 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
18037 vector unsigned char vec_vsx_ld (int, const unsigned char *);
18038
18039 void vec_vsx_st (vector double, int, vector double *);
18040 void vec_vsx_st (vector double, int, double *);
18041 void vec_vsx_st (vector float, int, vector float *);
18042 void vec_vsx_st (vector float, int, float *);
18043 void vec_vsx_st (vector signed int, int, vector signed int *);
18044 void vec_vsx_st (vector signed int, int, int *);
18045 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
18046 void vec_vsx_st (vector unsigned int, int, unsigned int *);
18047 void vec_vsx_st (vector bool int, int, vector bool int *);
18048 void vec_vsx_st (vector bool int, int, unsigned int *);
18049 void vec_vsx_st (vector bool int, int, int *);
18050 void vec_vsx_st (vector signed short, int, vector signed short *);
18051 void vec_vsx_st (vector signed short, int, short *);
18052 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
18053 void vec_vsx_st (vector unsigned short, int, unsigned short *);
18054 void vec_vsx_st (vector bool short, int, vector bool short *);
18055 void vec_vsx_st (vector bool short, int, unsigned short *);
18056 void vec_vsx_st (vector pixel, int, vector pixel *);
18057 void vec_vsx_st (vector pixel, int, unsigned short *);
18058 void vec_vsx_st (vector pixel, int, short *);
18059 void vec_vsx_st (vector bool short, int, short *);
18060 void vec_vsx_st (vector signed char, int, vector signed char *);
18061 void vec_vsx_st (vector signed char, int, signed char *);
18062 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
18063 void vec_vsx_st (vector unsigned char, int, unsigned char *);
18064 void vec_vsx_st (vector bool char, int, vector bool char *);
18065 void vec_vsx_st (vector bool char, int, unsigned char *);
18066 void vec_vsx_st (vector bool char, int, signed char *);
18067
18068 vector double vec_xxpermdi (vector double, vector double, const int);
18069 vector float vec_xxpermdi (vector float, vector float, const int);
18070 vector long long vec_xxpermdi (vector long long, vector long long, const int);
18071 vector unsigned long long vec_xxpermdi (vector unsigned long long,
18072 vector unsigned long long, const int);
18073 vector int vec_xxpermdi (vector int, vector int, const int);
18074 vector unsigned int vec_xxpermdi (vector unsigned int,
18075 vector unsigned int, const int);
18076 vector short vec_xxpermdi (vector short, vector short, const int);
18077 vector unsigned short vec_xxpermdi (vector unsigned short,
18078 vector unsigned short, const int);
18079 vector signed char vec_xxpermdi (vector signed char, vector signed char,
18080 const int);
18081 vector unsigned char vec_xxpermdi (vector unsigned char,
18082 vector unsigned char, const int);
18083
18084 vector double vec_xxsldi (vector double, vector double, int);
18085 vector float vec_xxsldi (vector float, vector float, int);
18086 vector long long vec_xxsldi (vector long long, vector long long, int);
18087 vector unsigned long long vec_xxsldi (vector unsigned long long,
18088 vector unsigned long long, int);
18089 vector int vec_xxsldi (vector int, vector int, int);
18090 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
18091 vector short vec_xxsldi (vector short, vector short, int);
18092 vector unsigned short vec_xxsldi (vector unsigned short,
18093 vector unsigned short, int);
18094 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
18095 vector unsigned char vec_xxsldi (vector unsigned char,
18096 vector unsigned char, int);
18097 @end smallexample
18098
18099 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
18100 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
18101 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
18102 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
18103 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
18104
18105 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18106 instruction set are available, the following additional functions are
18107 available for both 32-bit and 64-bit targets. For 64-bit targets, you
18108 can use @var{vector long} instead of @var{vector long long},
18109 @var{vector bool long} instead of @var{vector bool long long}, and
18110 @var{vector unsigned long} instead of @var{vector unsigned long long}.
18111
18112 @smallexample
18113 vector long long vec_abs (vector long long);
18114
18115 vector long long vec_add (vector long long, vector long long);
18116 vector unsigned long long vec_add (vector unsigned long long,
18117 vector unsigned long long);
18118
18119 int vec_all_eq (vector long long, vector long long);
18120 int vec_all_eq (vector unsigned long long, vector unsigned long long);
18121 int vec_all_ge (vector long long, vector long long);
18122 int vec_all_ge (vector unsigned long long, vector unsigned long long);
18123 int vec_all_gt (vector long long, vector long long);
18124 int vec_all_gt (vector unsigned long long, vector unsigned long long);
18125 int vec_all_le (vector long long, vector long long);
18126 int vec_all_le (vector unsigned long long, vector unsigned long long);
18127 int vec_all_lt (vector long long, vector long long);
18128 int vec_all_lt (vector unsigned long long, vector unsigned long long);
18129 int vec_all_ne (vector long long, vector long long);
18130 int vec_all_ne (vector unsigned long long, vector unsigned long long);
18131
18132 int vec_any_eq (vector long long, vector long long);
18133 int vec_any_eq (vector unsigned long long, vector unsigned long long);
18134 int vec_any_ge (vector long long, vector long long);
18135 int vec_any_ge (vector unsigned long long, vector unsigned long long);
18136 int vec_any_gt (vector long long, vector long long);
18137 int vec_any_gt (vector unsigned long long, vector unsigned long long);
18138 int vec_any_le (vector long long, vector long long);
18139 int vec_any_le (vector unsigned long long, vector unsigned long long);
18140 int vec_any_lt (vector long long, vector long long);
18141 int vec_any_lt (vector unsigned long long, vector unsigned long long);
18142 int vec_any_ne (vector long long, vector long long);
18143 int vec_any_ne (vector unsigned long long, vector unsigned long long);
18144
18145 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
18146
18147 vector long long vec_eqv (vector long long, vector long long);
18148 vector long long vec_eqv (vector bool long long, vector long long);
18149 vector long long vec_eqv (vector long long, vector bool long long);
18150 vector unsigned long long vec_eqv (vector unsigned long long,
18151 vector unsigned long long);
18152 vector unsigned long long vec_eqv (vector bool long long,
18153 vector unsigned long long);
18154 vector unsigned long long vec_eqv (vector unsigned long long,
18155 vector bool long long);
18156 vector int vec_eqv (vector int, vector int);
18157 vector int vec_eqv (vector bool int, vector int);
18158 vector int vec_eqv (vector int, vector bool int);
18159 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
18160 vector unsigned int vec_eqv (vector bool unsigned int,
18161 vector unsigned int);
18162 vector unsigned int vec_eqv (vector unsigned int,
18163 vector bool unsigned int);
18164 vector short vec_eqv (vector short, vector short);
18165 vector short vec_eqv (vector bool short, vector short);
18166 vector short vec_eqv (vector short, vector bool short);
18167 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
18168 vector unsigned short vec_eqv (vector bool unsigned short,
18169 vector unsigned short);
18170 vector unsigned short vec_eqv (vector unsigned short,
18171 vector bool unsigned short);
18172 vector signed char vec_eqv (vector signed char, vector signed char);
18173 vector signed char vec_eqv (vector bool signed char, vector signed char);
18174 vector signed char vec_eqv (vector signed char, vector bool signed char);
18175 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
18176 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
18177 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
18178
18179 vector long long vec_max (vector long long, vector long long);
18180 vector unsigned long long vec_max (vector unsigned long long,
18181 vector unsigned long long);
18182
18183 vector signed int vec_mergee (vector signed int, vector signed int);
18184 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
18185 vector bool int vec_mergee (vector bool int, vector bool int);
18186
18187 vector signed int vec_mergeo (vector signed int, vector signed int);
18188 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
18189 vector bool int vec_mergeo (vector bool int, vector bool int);
18190
18191 vector long long vec_min (vector long long, vector long long);
18192 vector unsigned long long vec_min (vector unsigned long long,
18193 vector unsigned long long);
18194
18195 vector signed long long vec_nabs (vector signed long long);
18196
18197 vector long long vec_nand (vector long long, vector long long);
18198 vector long long vec_nand (vector bool long long, vector long long);
18199 vector long long vec_nand (vector long long, vector bool long long);
18200 vector unsigned long long vec_nand (vector unsigned long long,
18201 vector unsigned long long);
18202 vector unsigned long long vec_nand (vector bool long long,
18203 vector unsigned long long);
18204 vector unsigned long long vec_nand (vector unsigned long long,
18205 vector bool long long);
18206 vector int vec_nand (vector int, vector int);
18207 vector int vec_nand (vector bool int, vector int);
18208 vector int vec_nand (vector int, vector bool int);
18209 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
18210 vector unsigned int vec_nand (vector bool unsigned int,
18211 vector unsigned int);
18212 vector unsigned int vec_nand (vector unsigned int,
18213 vector bool unsigned int);
18214 vector short vec_nand (vector short, vector short);
18215 vector short vec_nand (vector bool short, vector short);
18216 vector short vec_nand (vector short, vector bool short);
18217 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
18218 vector unsigned short vec_nand (vector bool unsigned short,
18219 vector unsigned short);
18220 vector unsigned short vec_nand (vector unsigned short,
18221 vector bool unsigned short);
18222 vector signed char vec_nand (vector signed char, vector signed char);
18223 vector signed char vec_nand (vector bool signed char, vector signed char);
18224 vector signed char vec_nand (vector signed char, vector bool signed char);
18225 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
18226 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
18227 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
18228
18229 vector long long vec_orc (vector long long, vector long long);
18230 vector long long vec_orc (vector bool long long, vector long long);
18231 vector long long vec_orc (vector long long, vector bool long long);
18232 vector unsigned long long vec_orc (vector unsigned long long,
18233 vector unsigned long long);
18234 vector unsigned long long vec_orc (vector bool long long,
18235 vector unsigned long long);
18236 vector unsigned long long vec_orc (vector unsigned long long,
18237 vector bool long long);
18238 vector int vec_orc (vector int, vector int);
18239 vector int vec_orc (vector bool int, vector int);
18240 vector int vec_orc (vector int, vector bool int);
18241 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
18242 vector unsigned int vec_orc (vector bool unsigned int,
18243 vector unsigned int);
18244 vector unsigned int vec_orc (vector unsigned int,
18245 vector bool unsigned int);
18246 vector short vec_orc (vector short, vector short);
18247 vector short vec_orc (vector bool short, vector short);
18248 vector short vec_orc (vector short, vector bool short);
18249 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
18250 vector unsigned short vec_orc (vector bool unsigned short,
18251 vector unsigned short);
18252 vector unsigned short vec_orc (vector unsigned short,
18253 vector bool unsigned short);
18254 vector signed char vec_orc (vector signed char, vector signed char);
18255 vector signed char vec_orc (vector bool signed char, vector signed char);
18256 vector signed char vec_orc (vector signed char, vector bool signed char);
18257 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
18258 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
18259 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
18260
18261 vector int vec_pack (vector long long, vector long long);
18262 vector unsigned int vec_pack (vector unsigned long long,
18263 vector unsigned long long);
18264 vector bool int vec_pack (vector bool long long, vector bool long long);
18265 vector float vec_pack (vector double, vector double);
18266
18267 vector int vec_packs (vector long long, vector long long);
18268 vector unsigned int vec_packs (vector unsigned long long,
18269 vector unsigned long long);
18270
18271 vector unsigned int vec_packsu (vector long long, vector long long);
18272 vector unsigned int vec_packsu (vector unsigned long long,
18273 vector unsigned long long);
18274
18275 vector unsigned char vec_popcnt (vector signed char);
18276 vector unsigned char vec_popcnt (vector unsigned char);
18277 vector unsigned short vec_popcnt (vector signed short);
18278 vector unsigned short vec_popcnt (vector unsigned short);
18279 vector unsigned int vec_popcnt (vector signed int);
18280 vector unsigned int vec_popcnt (vector unsigned int);
18281 vector unsigned long long vec_popcnt (vector signed long long);
18282 vector unsigned long long vec_popcnt (vector unsigned long long);
18283
18284 vector long long vec_rl (vector long long,
18285 vector unsigned long long);
18286 vector long long vec_rl (vector unsigned long long,
18287 vector unsigned long long);
18288
18289 vector long long vec_sl (vector long long, vector unsigned long long);
18290 vector long long vec_sl (vector unsigned long long,
18291 vector unsigned long long);
18292
18293 vector long long vec_sr (vector long long, vector unsigned long long);
18294 vector unsigned long long char vec_sr (vector unsigned long long,
18295 vector unsigned long long);
18296
18297 vector long long vec_sra (vector long long, vector unsigned long long);
18298 vector unsigned long long vec_sra (vector unsigned long long,
18299 vector unsigned long long);
18300
18301 vector long long vec_sub (vector long long, vector long long);
18302 vector unsigned long long vec_sub (vector unsigned long long,
18303 vector unsigned long long);
18304
18305 vector long long vec_unpackh (vector int);
18306 vector unsigned long long vec_unpackh (vector unsigned int);
18307
18308 vector long long vec_unpackl (vector int);
18309 vector unsigned long long vec_unpackl (vector unsigned int);
18310
18311 vector long long vec_vaddudm (vector long long, vector long long);
18312 vector long long vec_vaddudm (vector bool long long, vector long long);
18313 vector long long vec_vaddudm (vector long long, vector bool long long);
18314 vector unsigned long long vec_vaddudm (vector unsigned long long,
18315 vector unsigned long long);
18316 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
18317 vector unsigned long long);
18318 vector unsigned long long vec_vaddudm (vector unsigned long long,
18319 vector bool unsigned long long);
18320
18321 vector long long vec_vbpermq (vector signed char, vector signed char);
18322 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
18323
18324 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
18325 vector unsigned char vec_bperm (vector unsigned long long,
18326 vector unsigned char);
18327 vector unsigned long long vec_bperm (vector unsigned __int128,
18328 vector unsigned char);
18329
18330 vector long long vec_cntlz (vector long long);
18331 vector unsigned long long vec_cntlz (vector unsigned long long);
18332 vector int vec_cntlz (vector int);
18333 vector unsigned int vec_cntlz (vector int);
18334 vector short vec_cntlz (vector short);
18335 vector unsigned short vec_cntlz (vector unsigned short);
18336 vector signed char vec_cntlz (vector signed char);
18337 vector unsigned char vec_cntlz (vector unsigned char);
18338
18339 vector long long vec_vclz (vector long long);
18340 vector unsigned long long vec_vclz (vector unsigned long long);
18341 vector int vec_vclz (vector int);
18342 vector unsigned int vec_vclz (vector int);
18343 vector short vec_vclz (vector short);
18344 vector unsigned short vec_vclz (vector unsigned short);
18345 vector signed char vec_vclz (vector signed char);
18346 vector unsigned char vec_vclz (vector unsigned char);
18347
18348 vector signed char vec_vclzb (vector signed char);
18349 vector unsigned char vec_vclzb (vector unsigned char);
18350
18351 vector long long vec_vclzd (vector long long);
18352 vector unsigned long long vec_vclzd (vector unsigned long long);
18353
18354 vector short vec_vclzh (vector short);
18355 vector unsigned short vec_vclzh (vector unsigned short);
18356
18357 vector int vec_vclzw (vector int);
18358 vector unsigned int vec_vclzw (vector int);
18359
18360 vector signed char vec_vgbbd (vector signed char);
18361 vector unsigned char vec_vgbbd (vector unsigned char);
18362
18363 vector long long vec_vmaxsd (vector long long, vector long long);
18364
18365 vector unsigned long long vec_vmaxud (vector unsigned long long,
18366 unsigned vector long long);
18367
18368 vector long long vec_vminsd (vector long long, vector long long);
18369
18370 vector unsigned long long vec_vminud (vector long long,
18371 vector long long);
18372
18373 vector int vec_vpksdss (vector long long, vector long long);
18374 vector unsigned int vec_vpksdss (vector long long, vector long long);
18375
18376 vector unsigned int vec_vpkudus (vector unsigned long long,
18377 vector unsigned long long);
18378
18379 vector int vec_vpkudum (vector long long, vector long long);
18380 vector unsigned int vec_vpkudum (vector unsigned long long,
18381 vector unsigned long long);
18382 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
18383
18384 vector long long vec_vpopcnt (vector long long);
18385 vector unsigned long long vec_vpopcnt (vector unsigned long long);
18386 vector int vec_vpopcnt (vector int);
18387 vector unsigned int vec_vpopcnt (vector int);
18388 vector short vec_vpopcnt (vector short);
18389 vector unsigned short vec_vpopcnt (vector unsigned short);
18390 vector signed char vec_vpopcnt (vector signed char);
18391 vector unsigned char vec_vpopcnt (vector unsigned char);
18392
18393 vector signed char vec_vpopcntb (vector signed char);
18394 vector unsigned char vec_vpopcntb (vector unsigned char);
18395
18396 vector long long vec_vpopcntd (vector long long);
18397 vector unsigned long long vec_vpopcntd (vector unsigned long long);
18398
18399 vector short vec_vpopcnth (vector short);
18400 vector unsigned short vec_vpopcnth (vector unsigned short);
18401
18402 vector int vec_vpopcntw (vector int);
18403 vector unsigned int vec_vpopcntw (vector int);
18404
18405 vector long long vec_vrld (vector long long, vector unsigned long long);
18406 vector unsigned long long vec_vrld (vector unsigned long long,
18407 vector unsigned long long);
18408
18409 vector long long vec_vsld (vector long long, vector unsigned long long);
18410 vector long long vec_vsld (vector unsigned long long,
18411 vector unsigned long long);
18412
18413 vector long long vec_vsrad (vector long long, vector unsigned long long);
18414 vector unsigned long long vec_vsrad (vector unsigned long long,
18415 vector unsigned long long);
18416
18417 vector long long vec_vsrd (vector long long, vector unsigned long long);
18418 vector unsigned long long char vec_vsrd (vector unsigned long long,
18419 vector unsigned long long);
18420
18421 vector long long vec_vsubudm (vector long long, vector long long);
18422 vector long long vec_vsubudm (vector bool long long, vector long long);
18423 vector long long vec_vsubudm (vector long long, vector bool long long);
18424 vector unsigned long long vec_vsubudm (vector unsigned long long,
18425 vector unsigned long long);
18426 vector unsigned long long vec_vsubudm (vector bool long long,
18427 vector unsigned long long);
18428 vector unsigned long long vec_vsubudm (vector unsigned long long,
18429 vector bool long long);
18430
18431 vector long long vec_vupkhsw (vector int);
18432 vector unsigned long long vec_vupkhsw (vector unsigned int);
18433
18434 vector long long vec_vupklsw (vector int);
18435 vector unsigned long long vec_vupklsw (vector int);
18436 @end smallexample
18437
18438 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18439 instruction set are available, the following additional functions are
18440 available for 64-bit targets. New vector types
18441 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
18442 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
18443 builtins.
18444
18445 The normal vector extract, and set operations work on
18446 @var{vector __int128_t} and @var{vector __uint128_t} types,
18447 but the index value must be 0.
18448
18449 @smallexample
18450 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
18451 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
18452
18453 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
18454 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
18455
18456 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
18457 vector __int128_t);
18458 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
18459 vector __uint128_t);
18460
18461 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
18462 vector __int128_t);
18463 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
18464 vector __uint128_t);
18465
18466 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
18467 vector __int128_t);
18468 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
18469 vector __uint128_t);
18470
18471 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
18472 vector __int128_t);
18473 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
18474 vector __uint128_t);
18475
18476 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
18477 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
18478
18479 __int128_t vec_vsubuqm (__int128_t, __int128_t);
18480 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
18481
18482 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
18483 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
18484 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
18485 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
18486 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
18487 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
18488 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
18489 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
18490 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
18491 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
18492 @end smallexample
18493
18494 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18495 are available:
18496
18497 @smallexample
18498 vector unsigned long long vec_bperm (vector unsigned long long,
18499 vector unsigned char);
18500
18501 vector bool char vec_cmpne (vector bool char, vector bool char);
18502 vector bool short vec_cmpne (vector bool short, vector bool short);
18503 vector bool int vec_cmpne (vector bool int, vector bool int);
18504 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
18505
18506 vector float vec_extract_fp32_from_shorth (vector unsigned short);
18507 vector float vec_extract_fp32_from_shortl (vector unsigned short);
18508
18509 vector long long vec_vctz (vector long long);
18510 vector unsigned long long vec_vctz (vector unsigned long long);
18511 vector int vec_vctz (vector int);
18512 vector unsigned int vec_vctz (vector int);
18513 vector short vec_vctz (vector short);
18514 vector unsigned short vec_vctz (vector unsigned short);
18515 vector signed char vec_vctz (vector signed char);
18516 vector unsigned char vec_vctz (vector unsigned char);
18517
18518 vector signed char vec_vctzb (vector signed char);
18519 vector unsigned char vec_vctzb (vector unsigned char);
18520
18521 vector long long vec_vctzd (vector long long);
18522 vector unsigned long long vec_vctzd (vector unsigned long long);
18523
18524 vector short vec_vctzh (vector short);
18525 vector unsigned short vec_vctzh (vector unsigned short);
18526
18527 vector int vec_vctzw (vector int);
18528 vector unsigned int vec_vctzw (vector int);
18529
18530 long long vec_vextract4b (const vector signed char, const int);
18531 long long vec_vextract4b (const vector unsigned char, const int);
18532
18533 vector signed char vec_insert4b (vector int, vector signed char, const int);
18534 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
18535 const int);
18536 vector signed char vec_insert4b (long long, vector signed char, const int);
18537 vector unsigned char vec_insert4b (long long, vector unsigned char, const int);
18538
18539 vector unsigned int vec_parity_lsbb (vector signed int);
18540 vector unsigned int vec_parity_lsbb (vector unsigned int);
18541 vector unsigned __int128 vec_parity_lsbb (vector signed __int128);
18542 vector unsigned __int128 vec_parity_lsbb (vector unsigned __int128);
18543 vector unsigned long long vec_parity_lsbb (vector signed long long);
18544 vector unsigned long long vec_parity_lsbb (vector unsigned long long);
18545
18546 vector int vec_vprtyb (vector int);
18547 vector unsigned int vec_vprtyb (vector unsigned int);
18548 vector long long vec_vprtyb (vector long long);
18549 vector unsigned long long vec_vprtyb (vector unsigned long long);
18550
18551 vector int vec_vprtybw (vector int);
18552 vector unsigned int vec_vprtybw (vector unsigned int);
18553
18554 vector long long vec_vprtybd (vector long long);
18555 vector unsigned long long vec_vprtybd (vector unsigned long long);
18556 @end smallexample
18557
18558 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
18559 are available:
18560
18561 @smallexample
18562 vector long vec_vprtyb (vector long);
18563 vector unsigned long vec_vprtyb (vector unsigned long);
18564 vector __int128_t vec_vprtyb (vector __int128_t);
18565 vector __uint128_t vec_vprtyb (vector __uint128_t);
18566
18567 vector long vec_vprtybd (vector long);
18568 vector unsigned long vec_vprtybd (vector unsigned long);
18569
18570 vector __int128_t vec_vprtybq (vector __int128_t);
18571 vector __uint128_t vec_vprtybd (vector __uint128_t);
18572 @end smallexample
18573
18574 The following built-in vector functions are available for the PowerPC family
18575 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18576 @smallexample
18577 __vector unsigned char
18578 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
18579 __vector unsigned char
18580 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
18581 @end smallexample
18582
18583 The @code{vec_slv} and @code{vec_srv} functions operate on
18584 all of the bytes of their @code{src} and @code{shift_distance}
18585 arguments in parallel. The behavior of the @code{vec_slv} is as if
18586 there existed a temporary array of 17 unsigned characters
18587 @code{slv_array} within which elements 0 through 15 are the same as
18588 the entries in the @code{src} array and element 16 equals 0. The
18589 result returned from the @code{vec_slv} function is a
18590 @code{__vector} of 16 unsigned characters within which element
18591 @code{i} is computed using the C expression
18592 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
18593 shift_distance[i]))},
18594 with this resulting value coerced to the @code{unsigned char} type.
18595 The behavior of the @code{vec_srv} is as if
18596 there existed a temporary array of 17 unsigned characters
18597 @code{srv_array} within which element 0 equals zero and
18598 elements 1 through 16 equal the elements 0 through 15 of
18599 the @code{src} array. The
18600 result returned from the @code{vec_srv} function is a
18601 @code{__vector} of 16 unsigned characters within which element
18602 @code{i} is computed using the C expression
18603 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
18604 (0x07 & shift_distance[i]))},
18605 with this resulting value coerced to the @code{unsigned char} type.
18606
18607 The following built-in functions are available for the PowerPC family
18608 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18609 @smallexample
18610 __vector unsigned char
18611 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
18612 __vector unsigned short
18613 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
18614 __vector unsigned int
18615 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
18616
18617 __vector unsigned char
18618 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
18619 __vector unsigned short
18620 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
18621 __vector unsigned int
18622 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
18623 @end smallexample
18624
18625 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
18626 @code{vec_absdw} built-in functions each computes the absolute
18627 differences of the pairs of vector elements supplied in its two vector
18628 arguments, placing the absolute differences into the corresponding
18629 elements of the vector result.
18630
18631 The following built-in functions are available for the PowerPC family
18632 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18633 @smallexample
18634 __vector unsigned int
18635 vec_extract_exp (__vector float source);
18636 __vector unsigned long long int
18637 vec_extract_exp (__vector double source);
18638
18639 __vector unsigned int
18640 vec_extract_sig (__vector float source);
18641 __vector unsigned long long int
18642 vec_extract_sig (__vector double source);
18643
18644 __vector float
18645 vec_insert_exp (__vector unsigned int significands,
18646 __vector unsigned int exponents);
18647 __vector float
18648 vec_insert_exp (__vector unsigned float significands,
18649 __vector unsigned int exponents);
18650 __vector double
18651 vec_insert_exp (__vector unsigned long long int significands,
18652 __vector unsigned long long int exponents);
18653 __vector double
18654 vec_insert_exp (__vector unsigned double significands,
18655 __vector unsigned long long int exponents);
18656
18657 __vector bool int vec_test_data_class (__vector float source,
18658 const int condition);
18659 __vector bool long long int vec_test_data_class (__vector double source,
18660 const int condition);
18661 @end smallexample
18662
18663 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
18664 functions return vectors representing the significands and biased
18665 exponent values of their @code{source} arguments respectively.
18666 Within the result vector returned by @code{vec_extract_sig}, the
18667 @code{0x800000} bit of each vector element returned when the
18668 function's @code{source} argument is of type @code{float} is set to 1
18669 if the corresponding floating point value is in normalized form.
18670 Otherwise, this bit is set to 0. When the @code{source} argument is
18671 of type @code{double}, the @code{0x10000000000000} bit within each of
18672 the result vector's elements is set according to the same rules.
18673 Note that the sign of the significand is not represented in the result
18674 returned from the @code{vec_extract_sig} function. To extract the
18675 sign bits, use the
18676 @code{vec_cpsgn} function, which returns a new vector within which all
18677 of the sign bits of its second argument vector are overwritten with the
18678 sign bits copied from the coresponding elements of its first argument
18679 vector, and all other (non-sign) bits of the second argument vector
18680 are copied unchanged into the result vector.
18681
18682 The @code{vec_insert_exp} built-in functions return a vector of
18683 single- or double-precision floating
18684 point values constructed by assembling the values of their
18685 @code{significands} and @code{exponents} arguments into the
18686 corresponding elements of the returned vector.
18687 The sign of each
18688 element of the result is copied from the most significant bit of the
18689 corresponding entry within the @code{significands} argument.
18690 Note that the relevant
18691 bits of the @code{significands} argument are the same, for both integer
18692 and floating point types.
18693 The
18694 significand and exponent components of each element of the result are
18695 composed of the least significant bits of the corresponding
18696 @code{significands} element and the least significant bits of the
18697 corresponding @code{exponents} element.
18698
18699 The @code{vec_test_data_class} built-in function returns a vector
18700 representing the results of testing the @code{source} vector for the
18701 condition selected by the @code{condition} argument. The
18702 @code{condition} argument must be a compile-time constant integer with
18703 value not exceeding 127. The
18704 @code{condition} argument is encoded as a bitmask with each bit
18705 enabling the testing of a different condition, as characterized by the
18706 following:
18707 @smallexample
18708 0x40 Test for NaN
18709 0x20 Test for +Infinity
18710 0x10 Test for -Infinity
18711 0x08 Test for +Zero
18712 0x04 Test for -Zero
18713 0x02 Test for +Denormal
18714 0x01 Test for -Denormal
18715 @end smallexample
18716
18717 If any of the enabled test conditions is true, the corresponding entry
18718 in the result vector is -1. Otherwise (all of the enabled test
18719 conditions are false), the corresponding entry of the result vector is 0.
18720
18721 The following built-in functions are available for the PowerPC family
18722 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18723 @smallexample
18724 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
18725 vector unsigned int);
18726 vector unsigned long long vec_rlmi (vector unsigned long long,
18727 vector unsigned long long,
18728 vector unsigned long long);
18729 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
18730 vector unsigned int);
18731 vector unsigned long long vec_rlnm (vector unsigned long long,
18732 vector unsigned long long,
18733 vector unsigned long long);
18734 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
18735 vector unsigned long long vec_vrlnm (vector unsigned long long,
18736 vector unsigned long long);
18737 @end smallexample
18738
18739 The result of @code{vec_rlmi} is obtained by rotating each element of
18740 the first argument vector left and inserting it under mask into the
18741 second argument vector. The third argument vector contains the mask
18742 beginning in bits 11:15, the mask end in bits 19:23, and the shift
18743 count in bits 27:31, of each element.
18744
18745 The result of @code{vec_rlnm} is obtained by rotating each element of
18746 the first argument vector left and ANDing it with a mask specified by
18747 the second and third argument vectors. The second argument vector
18748 contains the shift count for each element in the low-order byte. The
18749 third argument vector contains the mask end for each element in the
18750 low-order byte, with the mask begin in the next higher byte.
18751
18752 The result of @code{vec_vrlnm} is obtained by rotating each element
18753 of the first argument vector left and ANDing it with a mask. The
18754 second argument vector contains the mask beginning in bits 11:15,
18755 the mask end in bits 19:23, and the shift count in bits 27:31,
18756 of each element.
18757
18758 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18759 are available:
18760 @smallexample
18761 vector signed bool char vec_revb (vector signed char);
18762 vector signed char vec_revb (vector signed char);
18763 vector unsigned char vec_revb (vector unsigned char);
18764 vector bool short vec_revb (vector bool short);
18765 vector short vec_revb (vector short);
18766 vector unsigned short vec_revb (vector unsigned short);
18767 vector bool int vec_revb (vector bool int);
18768 vector int vec_revb (vector int);
18769 vector unsigned int vec_revb (vector unsigned int);
18770 vector float vec_revb (vector float);
18771 vector bool long long vec_revb (vector bool long long);
18772 vector long long vec_revb (vector long long);
18773 vector unsigned long long vec_revb (vector unsigned long long);
18774 vector double vec_revb (vector double);
18775 @end smallexample
18776
18777 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
18778 are available:
18779 @smallexample
18780 vector long vec_revb (vector long);
18781 vector unsigned long vec_revb (vector unsigned long);
18782 vector __int128_t vec_revb (vector __int128_t);
18783 vector __uint128_t vec_revb (vector __uint128_t);
18784 @end smallexample
18785
18786 The @code{vec_revb} built-in function reverses the bytes on an element
18787 by element basis. A vector of @code{vector unsigned char} or
18788 @code{vector signed char} reverses the bytes in the whole word.
18789
18790 If the cryptographic instructions are enabled (@option{-mcrypto} or
18791 @option{-mcpu=power8}), the following builtins are enabled.
18792
18793 @smallexample
18794 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
18795
18796 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
18797 vector unsigned long long);
18798
18799 vector unsigned long long __builtin_crypto_vcipherlast
18800 (vector unsigned long long,
18801 vector unsigned long long);
18802
18803 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
18804 vector unsigned long long);
18805
18806 vector unsigned long long __builtin_crypto_vncipherlast
18807 (vector unsigned long long,
18808 vector unsigned long long);
18809
18810 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
18811 vector unsigned char,
18812 vector unsigned char);
18813
18814 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
18815 vector unsigned short,
18816 vector unsigned short);
18817
18818 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
18819 vector unsigned int,
18820 vector unsigned int);
18821
18822 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
18823 vector unsigned long long,
18824 vector unsigned long long);
18825
18826 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
18827 vector unsigned char);
18828
18829 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
18830 vector unsigned short);
18831
18832 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
18833 vector unsigned int);
18834
18835 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
18836 vector unsigned long long);
18837
18838 vector unsigned long long __builtin_crypto_vshasigmad
18839 (vector unsigned long long, int, int);
18840
18841 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
18842 int, int);
18843 @end smallexample
18844
18845 The second argument to @var{__builtin_crypto_vshasigmad} and
18846 @var{__builtin_crypto_vshasigmaw} must be a constant
18847 integer that is 0 or 1. The third argument to these built-in functions
18848 must be a constant integer in the range of 0 to 15.
18849
18850 If the ISA 3.0 instruction set additions
18851 are enabled (@option{-mcpu=power9}), the following additional
18852 functions are available for both 32-bit and 64-bit targets.
18853
18854 vector short vec_xl (int, vector short *);
18855 vector short vec_xl (int, short *);
18856 vector unsigned short vec_xl (int, vector unsigned short *);
18857 vector unsigned short vec_xl (int, unsigned short *);
18858 vector char vec_xl (int, vector char *);
18859 vector char vec_xl (int, char *);
18860 vector unsigned char vec_xl (int, vector unsigned char *);
18861 vector unsigned char vec_xl (int, unsigned char *);
18862
18863 void vec_xst (vector short, int, vector short *);
18864 void vec_xst (vector short, int, short *);
18865 void vec_xst (vector unsigned short, int, vector unsigned short *);
18866 void vec_xst (vector unsigned short, int, unsigned short *);
18867 void vec_xst (vector char, int, vector char *);
18868 void vec_xst (vector char, int, char *);
18869 void vec_xst (vector unsigned char, int, vector unsigned char *);
18870 void vec_xst (vector unsigned char, int, unsigned char *);
18871
18872 @node PowerPC Hardware Transactional Memory Built-in Functions
18873 @subsection PowerPC Hardware Transactional Memory Built-in Functions
18874 GCC provides two interfaces for accessing the Hardware Transactional
18875 Memory (HTM) instructions available on some of the PowerPC family
18876 of processors (eg, POWER8). The two interfaces come in a low level
18877 interface, consisting of built-in functions specific to PowerPC and a
18878 higher level interface consisting of inline functions that are common
18879 between PowerPC and S/390.
18880
18881 @subsubsection PowerPC HTM Low Level Built-in Functions
18882
18883 The following low level built-in functions are available with
18884 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
18885 They all generate the machine instruction that is part of the name.
18886
18887 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
18888 the full 4-bit condition register value set by their associated hardware
18889 instruction. The header file @code{htmintrin.h} defines some macros that can
18890 be used to decipher the return value. The @code{__builtin_tbegin} builtin
18891 returns a simple true or false value depending on whether a transaction was
18892 successfully started or not. The arguments of the builtins match exactly the
18893 type and order of the associated hardware instruction's operands, except for
18894 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
18895 Refer to the ISA manual for a description of each instruction's operands.
18896
18897 @smallexample
18898 unsigned int __builtin_tbegin (unsigned int)
18899 unsigned int __builtin_tend (unsigned int)
18900
18901 unsigned int __builtin_tabort (unsigned int)
18902 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
18903 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
18904 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
18905 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
18906
18907 unsigned int __builtin_tcheck (void)
18908 unsigned int __builtin_treclaim (unsigned int)
18909 unsigned int __builtin_trechkpt (void)
18910 unsigned int __builtin_tsr (unsigned int)
18911 @end smallexample
18912
18913 In addition to the above HTM built-ins, we have added built-ins for
18914 some common extended mnemonics of the HTM instructions:
18915
18916 @smallexample
18917 unsigned int __builtin_tendall (void)
18918 unsigned int __builtin_tresume (void)
18919 unsigned int __builtin_tsuspend (void)
18920 @end smallexample
18921
18922 Note that the semantics of the above HTM builtins are required to mimic
18923 the locking semantics used for critical sections. Builtins that are used
18924 to create a new transaction or restart a suspended transaction must have
18925 lock acquisition like semantics while those builtins that end or suspend a
18926 transaction must have lock release like semantics. Specifically, this must
18927 mimic lock semantics as specified by C++11, for example: Lock acquisition is
18928 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
18929 that returns 0, and lock release is as-if an execution of
18930 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
18931 implicit implementation-defined lock used for all transactions. The HTM
18932 instructions associated with with the builtins inherently provide the
18933 correct acquisition and release hardware barriers required. However,
18934 the compiler must also be prohibited from moving loads and stores across
18935 the builtins in a way that would violate their semantics. This has been
18936 accomplished by adding memory barriers to the associated HTM instructions
18937 (which is a conservative approach to provide acquire and release semantics).
18938 Earlier versions of the compiler did not treat the HTM instructions as
18939 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
18940 be used to determine whether the current compiler treats HTM instructions
18941 as memory barriers or not. This allows the user to explicitly add memory
18942 barriers to their code when using an older version of the compiler.
18943
18944 The following set of built-in functions are available to gain access
18945 to the HTM specific special purpose registers.
18946
18947 @smallexample
18948 unsigned long __builtin_get_texasr (void)
18949 unsigned long __builtin_get_texasru (void)
18950 unsigned long __builtin_get_tfhar (void)
18951 unsigned long __builtin_get_tfiar (void)
18952
18953 void __builtin_set_texasr (unsigned long);
18954 void __builtin_set_texasru (unsigned long);
18955 void __builtin_set_tfhar (unsigned long);
18956 void __builtin_set_tfiar (unsigned long);
18957 @end smallexample
18958
18959 Example usage of these low level built-in functions may look like:
18960
18961 @smallexample
18962 #include <htmintrin.h>
18963
18964 int num_retries = 10;
18965
18966 while (1)
18967 @{
18968 if (__builtin_tbegin (0))
18969 @{
18970 /* Transaction State Initiated. */
18971 if (is_locked (lock))
18972 __builtin_tabort (0);
18973 ... transaction code...
18974 __builtin_tend (0);
18975 break;
18976 @}
18977 else
18978 @{
18979 /* Transaction State Failed. Use locks if the transaction
18980 failure is "persistent" or we've tried too many times. */
18981 if (num_retries-- <= 0
18982 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
18983 @{
18984 acquire_lock (lock);
18985 ... non transactional fallback path...
18986 release_lock (lock);
18987 break;
18988 @}
18989 @}
18990 @}
18991 @end smallexample
18992
18993 One final built-in function has been added that returns the value of
18994 the 2-bit Transaction State field of the Machine Status Register (MSR)
18995 as stored in @code{CR0}.
18996
18997 @smallexample
18998 unsigned long __builtin_ttest (void)
18999 @end smallexample
19000
19001 This built-in can be used to determine the current transaction state
19002 using the following code example:
19003
19004 @smallexample
19005 #include <htmintrin.h>
19006
19007 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
19008
19009 if (tx_state == _HTM_TRANSACTIONAL)
19010 @{
19011 /* Code to use in transactional state. */
19012 @}
19013 else if (tx_state == _HTM_NONTRANSACTIONAL)
19014 @{
19015 /* Code to use in non-transactional state. */
19016 @}
19017 else if (tx_state == _HTM_SUSPENDED)
19018 @{
19019 /* Code to use in transaction suspended state. */
19020 @}
19021 @end smallexample
19022
19023 @subsubsection PowerPC HTM High Level Inline Functions
19024
19025 The following high level HTM interface is made available by including
19026 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
19027 where CPU is `power8' or later. This interface is common between PowerPC
19028 and S/390, allowing users to write one HTM source implementation that
19029 can be compiled and executed on either system.
19030
19031 @smallexample
19032 long __TM_simple_begin (void)
19033 long __TM_begin (void* const TM_buff)
19034 long __TM_end (void)
19035 void __TM_abort (void)
19036 void __TM_named_abort (unsigned char const code)
19037 void __TM_resume (void)
19038 void __TM_suspend (void)
19039
19040 long __TM_is_user_abort (void* const TM_buff)
19041 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
19042 long __TM_is_illegal (void* const TM_buff)
19043 long __TM_is_footprint_exceeded (void* const TM_buff)
19044 long __TM_nesting_depth (void* const TM_buff)
19045 long __TM_is_nested_too_deep(void* const TM_buff)
19046 long __TM_is_conflict(void* const TM_buff)
19047 long __TM_is_failure_persistent(void* const TM_buff)
19048 long __TM_failure_address(void* const TM_buff)
19049 long long __TM_failure_code(void* const TM_buff)
19050 @end smallexample
19051
19052 Using these common set of HTM inline functions, we can create
19053 a more portable version of the HTM example in the previous
19054 section that will work on either PowerPC or S/390:
19055
19056 @smallexample
19057 #include <htmxlintrin.h>
19058
19059 int num_retries = 10;
19060 TM_buff_type TM_buff;
19061
19062 while (1)
19063 @{
19064 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
19065 @{
19066 /* Transaction State Initiated. */
19067 if (is_locked (lock))
19068 __TM_abort ();
19069 ... transaction code...
19070 __TM_end ();
19071 break;
19072 @}
19073 else
19074 @{
19075 /* Transaction State Failed. Use locks if the transaction
19076 failure is "persistent" or we've tried too many times. */
19077 if (num_retries-- <= 0
19078 || __TM_is_failure_persistent (TM_buff))
19079 @{
19080 acquire_lock (lock);
19081 ... non transactional fallback path...
19082 release_lock (lock);
19083 break;
19084 @}
19085 @}
19086 @}
19087 @end smallexample
19088
19089 @node RX Built-in Functions
19090 @subsection RX Built-in Functions
19091 GCC supports some of the RX instructions which cannot be expressed in
19092 the C programming language via the use of built-in functions. The
19093 following functions are supported:
19094
19095 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
19096 Generates the @code{brk} machine instruction.
19097 @end deftypefn
19098
19099 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
19100 Generates the @code{clrpsw} machine instruction to clear the specified
19101 bit in the processor status word.
19102 @end deftypefn
19103
19104 @deftypefn {Built-in Function} void __builtin_rx_int (int)
19105 Generates the @code{int} machine instruction to generate an interrupt
19106 with the specified value.
19107 @end deftypefn
19108
19109 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
19110 Generates the @code{machi} machine instruction to add the result of
19111 multiplying the top 16 bits of the two arguments into the
19112 accumulator.
19113 @end deftypefn
19114
19115 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
19116 Generates the @code{maclo} machine instruction to add the result of
19117 multiplying the bottom 16 bits of the two arguments into the
19118 accumulator.
19119 @end deftypefn
19120
19121 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
19122 Generates the @code{mulhi} machine instruction to place the result of
19123 multiplying the top 16 bits of the two arguments into the
19124 accumulator.
19125 @end deftypefn
19126
19127 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
19128 Generates the @code{mullo} machine instruction to place the result of
19129 multiplying the bottom 16 bits of the two arguments into the
19130 accumulator.
19131 @end deftypefn
19132
19133 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
19134 Generates the @code{mvfachi} machine instruction to read the top
19135 32 bits of the accumulator.
19136 @end deftypefn
19137
19138 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
19139 Generates the @code{mvfacmi} machine instruction to read the middle
19140 32 bits of the accumulator.
19141 @end deftypefn
19142
19143 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
19144 Generates the @code{mvfc} machine instruction which reads the control
19145 register specified in its argument and returns its value.
19146 @end deftypefn
19147
19148 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
19149 Generates the @code{mvtachi} machine instruction to set the top
19150 32 bits of the accumulator.
19151 @end deftypefn
19152
19153 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
19154 Generates the @code{mvtaclo} machine instruction to set the bottom
19155 32 bits of the accumulator.
19156 @end deftypefn
19157
19158 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
19159 Generates the @code{mvtc} machine instruction which sets control
19160 register number @code{reg} to @code{val}.
19161 @end deftypefn
19162
19163 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
19164 Generates the @code{mvtipl} machine instruction set the interrupt
19165 priority level.
19166 @end deftypefn
19167
19168 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
19169 Generates the @code{racw} machine instruction to round the accumulator
19170 according to the specified mode.
19171 @end deftypefn
19172
19173 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
19174 Generates the @code{revw} machine instruction which swaps the bytes in
19175 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
19176 and also bits 16--23 occupy bits 24--31 and vice versa.
19177 @end deftypefn
19178
19179 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
19180 Generates the @code{rmpa} machine instruction which initiates a
19181 repeated multiply and accumulate sequence.
19182 @end deftypefn
19183
19184 @deftypefn {Built-in Function} void __builtin_rx_round (float)
19185 Generates the @code{round} machine instruction which returns the
19186 floating-point argument rounded according to the current rounding mode
19187 set in the floating-point status word register.
19188 @end deftypefn
19189
19190 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
19191 Generates the @code{sat} machine instruction which returns the
19192 saturated value of the argument.
19193 @end deftypefn
19194
19195 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
19196 Generates the @code{setpsw} machine instruction to set the specified
19197 bit in the processor status word.
19198 @end deftypefn
19199
19200 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
19201 Generates the @code{wait} machine instruction.
19202 @end deftypefn
19203
19204 @node S/390 System z Built-in Functions
19205 @subsection S/390 System z Built-in Functions
19206 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
19207 Generates the @code{tbegin} machine instruction starting a
19208 non-constrained hardware transaction. If the parameter is non-NULL the
19209 memory area is used to store the transaction diagnostic buffer and
19210 will be passed as first operand to @code{tbegin}. This buffer can be
19211 defined using the @code{struct __htm_tdb} C struct defined in
19212 @code{htmintrin.h} and must reside on a double-word boundary. The
19213 second tbegin operand is set to @code{0xff0c}. This enables
19214 save/restore of all GPRs and disables aborts for FPR and AR
19215 manipulations inside the transaction body. The condition code set by
19216 the tbegin instruction is returned as integer value. The tbegin
19217 instruction by definition overwrites the content of all FPRs. The
19218 compiler will generate code which saves and restores the FPRs. For
19219 soft-float code it is recommended to used the @code{*_nofloat}
19220 variant. In order to prevent a TDB from being written it is required
19221 to pass a constant zero value as parameter. Passing a zero value
19222 through a variable is not sufficient. Although modifications of
19223 access registers inside the transaction will not trigger an
19224 transaction abort it is not supported to actually modify them. Access
19225 registers do not get saved when entering a transaction. They will have
19226 undefined state when reaching the abort code.
19227 @end deftypefn
19228
19229 Macros for the possible return codes of tbegin are defined in the
19230 @code{htmintrin.h} header file:
19231
19232 @table @code
19233 @item _HTM_TBEGIN_STARTED
19234 @code{tbegin} has been executed as part of normal processing. The
19235 transaction body is supposed to be executed.
19236 @item _HTM_TBEGIN_INDETERMINATE
19237 The transaction was aborted due to an indeterminate condition which
19238 might be persistent.
19239 @item _HTM_TBEGIN_TRANSIENT
19240 The transaction aborted due to a transient failure. The transaction
19241 should be re-executed in that case.
19242 @item _HTM_TBEGIN_PERSISTENT
19243 The transaction aborted due to a persistent failure. Re-execution
19244 under same circumstances will not be productive.
19245 @end table
19246
19247 @defmac _HTM_FIRST_USER_ABORT_CODE
19248 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
19249 specifies the first abort code which can be used for
19250 @code{__builtin_tabort}. Values below this threshold are reserved for
19251 machine use.
19252 @end defmac
19253
19254 @deftp {Data type} {struct __htm_tdb}
19255 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
19256 the structure of the transaction diagnostic block as specified in the
19257 Principles of Operation manual chapter 5-91.
19258 @end deftp
19259
19260 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
19261 Same as @code{__builtin_tbegin} but without FPR saves and restores.
19262 Using this variant in code making use of FPRs will leave the FPRs in
19263 undefined state when entering the transaction abort handler code.
19264 @end deftypefn
19265
19266 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
19267 In addition to @code{__builtin_tbegin} a loop for transient failures
19268 is generated. If tbegin returns a condition code of 2 the transaction
19269 will be retried as often as specified in the second argument. The
19270 perform processor assist instruction is used to tell the CPU about the
19271 number of fails so far.
19272 @end deftypefn
19273
19274 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
19275 Same as @code{__builtin_tbegin_retry} but without FPR saves and
19276 restores. Using this variant in code making use of FPRs will leave
19277 the FPRs in undefined state when entering the transaction abort
19278 handler code.
19279 @end deftypefn
19280
19281 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
19282 Generates the @code{tbeginc} machine instruction starting a constrained
19283 hardware transaction. The second operand is set to @code{0xff08}.
19284 @end deftypefn
19285
19286 @deftypefn {Built-in Function} int __builtin_tend (void)
19287 Generates the @code{tend} machine instruction finishing a transaction
19288 and making the changes visible to other threads. The condition code
19289 generated by tend is returned as integer value.
19290 @end deftypefn
19291
19292 @deftypefn {Built-in Function} void __builtin_tabort (int)
19293 Generates the @code{tabort} machine instruction with the specified
19294 abort code. Abort codes from 0 through 255 are reserved and will
19295 result in an error message.
19296 @end deftypefn
19297
19298 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
19299 Generates the @code{ppa rX,rY,1} machine instruction. Where the
19300 integer parameter is loaded into rX and a value of zero is loaded into
19301 rY. The integer parameter specifies the number of times the
19302 transaction repeatedly aborted.
19303 @end deftypefn
19304
19305 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
19306 Generates the @code{etnd} machine instruction. The current nesting
19307 depth is returned as integer value. For a nesting depth of 0 the code
19308 is not executed as part of an transaction.
19309 @end deftypefn
19310
19311 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
19312
19313 Generates the @code{ntstg} machine instruction. The second argument
19314 is written to the first arguments location. The store operation will
19315 not be rolled-back in case of an transaction abort.
19316 @end deftypefn
19317
19318 @node SH Built-in Functions
19319 @subsection SH Built-in Functions
19320 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
19321 families of processors:
19322
19323 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
19324 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
19325 used by system code that manages threads and execution contexts. The compiler
19326 normally does not generate code that modifies the contents of @samp{GBR} and
19327 thus the value is preserved across function calls. Changing the @samp{GBR}
19328 value in user code must be done with caution, since the compiler might use
19329 @samp{GBR} in order to access thread local variables.
19330
19331 @end deftypefn
19332
19333 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
19334 Returns the value that is currently set in the @samp{GBR} register.
19335 Memory loads and stores that use the thread pointer as a base address are
19336 turned into @samp{GBR} based displacement loads and stores, if possible.
19337 For example:
19338 @smallexample
19339 struct my_tcb
19340 @{
19341 int a, b, c, d, e;
19342 @};
19343
19344 int get_tcb_value (void)
19345 @{
19346 // Generate @samp{mov.l @@(8,gbr),r0} instruction
19347 return ((my_tcb*)__builtin_thread_pointer ())->c;
19348 @}
19349
19350 @end smallexample
19351 @end deftypefn
19352
19353 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
19354 Returns the value that is currently set in the @samp{FPSCR} register.
19355 @end deftypefn
19356
19357 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
19358 Sets the @samp{FPSCR} register to the specified value @var{val}, while
19359 preserving the current values of the FR, SZ and PR bits.
19360 @end deftypefn
19361
19362 @node SPARC VIS Built-in Functions
19363 @subsection SPARC VIS Built-in Functions
19364
19365 GCC supports SIMD operations on the SPARC using both the generic vector
19366 extensions (@pxref{Vector Extensions}) as well as built-in functions for
19367 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
19368 switch, the VIS extension is exposed as the following built-in functions:
19369
19370 @smallexample
19371 typedef int v1si __attribute__ ((vector_size (4)));
19372 typedef int v2si __attribute__ ((vector_size (8)));
19373 typedef short v4hi __attribute__ ((vector_size (8)));
19374 typedef short v2hi __attribute__ ((vector_size (4)));
19375 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
19376 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
19377
19378 void __builtin_vis_write_gsr (int64_t);
19379 int64_t __builtin_vis_read_gsr (void);
19380
19381 void * __builtin_vis_alignaddr (void *, long);
19382 void * __builtin_vis_alignaddrl (void *, long);
19383 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
19384 v2si __builtin_vis_faligndatav2si (v2si, v2si);
19385 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
19386 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
19387
19388 v4hi __builtin_vis_fexpand (v4qi);
19389
19390 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
19391 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
19392 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
19393 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
19394 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
19395 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
19396 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
19397
19398 v4qi __builtin_vis_fpack16 (v4hi);
19399 v8qi __builtin_vis_fpack32 (v2si, v8qi);
19400 v2hi __builtin_vis_fpackfix (v2si);
19401 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
19402
19403 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
19404
19405 long __builtin_vis_edge8 (void *, void *);
19406 long __builtin_vis_edge8l (void *, void *);
19407 long __builtin_vis_edge16 (void *, void *);
19408 long __builtin_vis_edge16l (void *, void *);
19409 long __builtin_vis_edge32 (void *, void *);
19410 long __builtin_vis_edge32l (void *, void *);
19411
19412 long __builtin_vis_fcmple16 (v4hi, v4hi);
19413 long __builtin_vis_fcmple32 (v2si, v2si);
19414 long __builtin_vis_fcmpne16 (v4hi, v4hi);
19415 long __builtin_vis_fcmpne32 (v2si, v2si);
19416 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
19417 long __builtin_vis_fcmpgt32 (v2si, v2si);
19418 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
19419 long __builtin_vis_fcmpeq32 (v2si, v2si);
19420
19421 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
19422 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
19423 v2si __builtin_vis_fpadd32 (v2si, v2si);
19424 v1si __builtin_vis_fpadd32s (v1si, v1si);
19425 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
19426 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
19427 v2si __builtin_vis_fpsub32 (v2si, v2si);
19428 v1si __builtin_vis_fpsub32s (v1si, v1si);
19429
19430 long __builtin_vis_array8 (long, long);
19431 long __builtin_vis_array16 (long, long);
19432 long __builtin_vis_array32 (long, long);
19433 @end smallexample
19434
19435 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
19436 functions also become available:
19437
19438 @smallexample
19439 long __builtin_vis_bmask (long, long);
19440 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
19441 v2si __builtin_vis_bshufflev2si (v2si, v2si);
19442 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
19443 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
19444
19445 long __builtin_vis_edge8n (void *, void *);
19446 long __builtin_vis_edge8ln (void *, void *);
19447 long __builtin_vis_edge16n (void *, void *);
19448 long __builtin_vis_edge16ln (void *, void *);
19449 long __builtin_vis_edge32n (void *, void *);
19450 long __builtin_vis_edge32ln (void *, void *);
19451 @end smallexample
19452
19453 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
19454 functions also become available:
19455
19456 @smallexample
19457 void __builtin_vis_cmask8 (long);
19458 void __builtin_vis_cmask16 (long);
19459 void __builtin_vis_cmask32 (long);
19460
19461 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
19462
19463 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
19464 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
19465 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
19466 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
19467 v2si __builtin_vis_fsll16 (v2si, v2si);
19468 v2si __builtin_vis_fslas16 (v2si, v2si);
19469 v2si __builtin_vis_fsrl16 (v2si, v2si);
19470 v2si __builtin_vis_fsra16 (v2si, v2si);
19471
19472 long __builtin_vis_pdistn (v8qi, v8qi);
19473
19474 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
19475
19476 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
19477 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
19478
19479 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
19480 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
19481 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
19482 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
19483 v2si __builtin_vis_fpadds32 (v2si, v2si);
19484 v1si __builtin_vis_fpadds32s (v1si, v1si);
19485 v2si __builtin_vis_fpsubs32 (v2si, v2si);
19486 v1si __builtin_vis_fpsubs32s (v1si, v1si);
19487
19488 long __builtin_vis_fucmple8 (v8qi, v8qi);
19489 long __builtin_vis_fucmpne8 (v8qi, v8qi);
19490 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
19491 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
19492
19493 float __builtin_vis_fhadds (float, float);
19494 double __builtin_vis_fhaddd (double, double);
19495 float __builtin_vis_fhsubs (float, float);
19496 double __builtin_vis_fhsubd (double, double);
19497 float __builtin_vis_fnhadds (float, float);
19498 double __builtin_vis_fnhaddd (double, double);
19499
19500 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
19501 int64_t __builtin_vis_xmulx (int64_t, int64_t);
19502 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
19503 @end smallexample
19504
19505 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
19506 functions also become available:
19507
19508 @smallexample
19509 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
19510 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
19511 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
19512 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
19513
19514 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
19515 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
19516 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
19517 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
19518
19519 long __builtin_vis_fpcmple8 (v8qi, v8qi);
19520 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
19521 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
19522 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
19523 long __builtin_vis_fpcmpule32 (v2si, v2si);
19524 long __builtin_vis_fpcmpugt32 (v2si, v2si);
19525
19526 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
19527 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
19528 v2si __builtin_vis_fpmax32 (v2si, v2si);
19529
19530 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
19531 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
19532 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
19533
19534
19535 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
19536 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
19537 v2si __builtin_vis_fpmin32 (v2si, v2si);
19538
19539 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
19540 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
19541 v2si __builtin_vis_fpminu32 (v2si, v2si);
19542 @end smallexample
19543
19544 When you use the @option{-mvis4b} switch, the VIS version 4.0B
19545 built-in functions also become available:
19546
19547 @smallexample
19548 v8qi __builtin_vis_dictunpack8 (double, int);
19549 v4hi __builtin_vis_dictunpack16 (double, int);
19550 v2si __builtin_vis_dictunpack32 (double, int);
19551
19552 long __builtin_vis_fpcmple8shl (v8qi, v8qi, int);
19553 long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int);
19554 long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int);
19555 long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int);
19556
19557 long __builtin_vis_fpcmple16shl (v4hi, v4hi, int);
19558 long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int);
19559 long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int);
19560 long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int);
19561
19562 long __builtin_vis_fpcmple32shl (v2si, v2si, int);
19563 long __builtin_vis_fpcmpgt32shl (v2si, v2si, int);
19564 long __builtin_vis_fpcmpeq32shl (v2si, v2si, int);
19565 long __builtin_vis_fpcmpne32shl (v2si, v2si, int);
19566
19567 long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int);
19568 long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int);
19569 long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int);
19570 long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int);
19571 long __builtin_vis_fpcmpule32shl (v2si, v2si, int);
19572 long __builtin_vis_fpcmpugt32shl (v2si, v2si, int);
19573
19574 long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int);
19575 long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int);
19576 long __builtin_vis_fpcmpde32shl (v2si, v2si, int);
19577
19578 long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int);
19579 long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int);
19580 long __builtin_vis_fpcmpur32shl (v2si, v2si, int);
19581 @end smallexample
19582
19583 @node SPU Built-in Functions
19584 @subsection SPU Built-in Functions
19585
19586 GCC provides extensions for the SPU processor as described in the
19587 Sony/Toshiba/IBM SPU Language Extensions Specification. GCC's
19588 implementation differs in several ways.
19589
19590 @itemize @bullet
19591
19592 @item
19593 The optional extension of specifying vector constants in parentheses is
19594 not supported.
19595
19596 @item
19597 A vector initializer requires no cast if the vector constant is of the
19598 same type as the variable it is initializing.
19599
19600 @item
19601 If @code{signed} or @code{unsigned} is omitted, the signedness of the
19602 vector type is the default signedness of the base type. The default
19603 varies depending on the operating system, so a portable program should
19604 always specify the signedness.
19605
19606 @item
19607 By default, the keyword @code{__vector} is added. The macro
19608 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
19609 undefined.
19610
19611 @item
19612 GCC allows using a @code{typedef} name as the type specifier for a
19613 vector type.
19614
19615 @item
19616 For C, overloaded functions are implemented with macros so the following
19617 does not work:
19618
19619 @smallexample
19620 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
19621 @end smallexample
19622
19623 @noindent
19624 Since @code{spu_add} is a macro, the vector constant in the example
19625 is treated as four separate arguments. Wrap the entire argument in
19626 parentheses for this to work.
19627
19628 @item
19629 The extended version of @code{__builtin_expect} is not supported.
19630
19631 @end itemize
19632
19633 @emph{Note:} Only the interface described in the aforementioned
19634 specification is supported. Internally, GCC uses built-in functions to
19635 implement the required functionality, but these are not supported and
19636 are subject to change without notice.
19637
19638 @node TI C6X Built-in Functions
19639 @subsection TI C6X Built-in Functions
19640
19641 GCC provides intrinsics to access certain instructions of the TI C6X
19642 processors. These intrinsics, listed below, are available after
19643 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
19644 to C6X instructions.
19645
19646 @smallexample
19647
19648 int _sadd (int, int)
19649 int _ssub (int, int)
19650 int _sadd2 (int, int)
19651 int _ssub2 (int, int)
19652 long long _mpy2 (int, int)
19653 long long _smpy2 (int, int)
19654 int _add4 (int, int)
19655 int _sub4 (int, int)
19656 int _saddu4 (int, int)
19657
19658 int _smpy (int, int)
19659 int _smpyh (int, int)
19660 int _smpyhl (int, int)
19661 int _smpylh (int, int)
19662
19663 int _sshl (int, int)
19664 int _subc (int, int)
19665
19666 int _avg2 (int, int)
19667 int _avgu4 (int, int)
19668
19669 int _clrr (int, int)
19670 int _extr (int, int)
19671 int _extru (int, int)
19672 int _abs (int)
19673 int _abs2 (int)
19674
19675 @end smallexample
19676
19677 @node TILE-Gx Built-in Functions
19678 @subsection TILE-Gx Built-in Functions
19679
19680 GCC provides intrinsics to access every instruction of the TILE-Gx
19681 processor. The intrinsics are of the form:
19682
19683 @smallexample
19684
19685 unsigned long long __insn_@var{op} (...)
19686
19687 @end smallexample
19688
19689 Where @var{op} is the name of the instruction. Refer to the ISA manual
19690 for the complete list of instructions.
19691
19692 GCC also provides intrinsics to directly access the network registers.
19693 The intrinsics are:
19694
19695 @smallexample
19696
19697 unsigned long long __tile_idn0_receive (void)
19698 unsigned long long __tile_idn1_receive (void)
19699 unsigned long long __tile_udn0_receive (void)
19700 unsigned long long __tile_udn1_receive (void)
19701 unsigned long long __tile_udn2_receive (void)
19702 unsigned long long __tile_udn3_receive (void)
19703 void __tile_idn_send (unsigned long long)
19704 void __tile_udn_send (unsigned long long)
19705
19706 @end smallexample
19707
19708 The intrinsic @code{void __tile_network_barrier (void)} is used to
19709 guarantee that no network operations before it are reordered with
19710 those after it.
19711
19712 @node TILEPro Built-in Functions
19713 @subsection TILEPro Built-in Functions
19714
19715 GCC provides intrinsics to access every instruction of the TILEPro
19716 processor. The intrinsics are of the form:
19717
19718 @smallexample
19719
19720 unsigned __insn_@var{op} (...)
19721
19722 @end smallexample
19723
19724 @noindent
19725 where @var{op} is the name of the instruction. Refer to the ISA manual
19726 for the complete list of instructions.
19727
19728 GCC also provides intrinsics to directly access the network registers.
19729 The intrinsics are:
19730
19731 @smallexample
19732
19733 unsigned __tile_idn0_receive (void)
19734 unsigned __tile_idn1_receive (void)
19735 unsigned __tile_sn_receive (void)
19736 unsigned __tile_udn0_receive (void)
19737 unsigned __tile_udn1_receive (void)
19738 unsigned __tile_udn2_receive (void)
19739 unsigned __tile_udn3_receive (void)
19740 void __tile_idn_send (unsigned)
19741 void __tile_sn_send (unsigned)
19742 void __tile_udn_send (unsigned)
19743
19744 @end smallexample
19745
19746 The intrinsic @code{void __tile_network_barrier (void)} is used to
19747 guarantee that no network operations before it are reordered with
19748 those after it.
19749
19750 @node x86 Built-in Functions
19751 @subsection x86 Built-in Functions
19752
19753 These built-in functions are available for the x86-32 and x86-64 family
19754 of computers, depending on the command-line switches used.
19755
19756 If you specify command-line switches such as @option{-msse},
19757 the compiler could use the extended instruction sets even if the built-ins
19758 are not used explicitly in the program. For this reason, applications
19759 that perform run-time CPU detection must compile separate files for each
19760 supported architecture, using the appropriate flags. In particular,
19761 the file containing the CPU detection code should be compiled without
19762 these options.
19763
19764 The following machine modes are available for use with MMX built-in functions
19765 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
19766 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
19767 vector of eight 8-bit integers. Some of the built-in functions operate on
19768 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
19769
19770 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
19771 of two 32-bit floating-point values.
19772
19773 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
19774 floating-point values. Some instructions use a vector of four 32-bit
19775 integers, these use @code{V4SI}. Finally, some instructions operate on an
19776 entire vector register, interpreting it as a 128-bit integer, these use mode
19777 @code{TI}.
19778
19779 The x86-32 and x86-64 family of processors use additional built-in
19780 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
19781 floating point and @code{TC} 128-bit complex floating-point values.
19782
19783 The following floating-point built-in functions are always available. All
19784 of them implement the function that is part of the name.
19785
19786 @smallexample
19787 __float128 __builtin_fabsq (__float128)
19788 __float128 __builtin_copysignq (__float128, __float128)
19789 @end smallexample
19790
19791 The following built-in functions are always available.
19792
19793 @table @code
19794 @item __float128 __builtin_infq (void)
19795 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
19796 @findex __builtin_infq
19797
19798 @item __float128 __builtin_huge_valq (void)
19799 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
19800 @findex __builtin_huge_valq
19801
19802 @item __float128 __builtin_nanq (void)
19803 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
19804 @findex __builtin_nanq
19805
19806 @item __float128 __builtin_nansq (void)
19807 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
19808 @findex __builtin_nansq
19809 @end table
19810
19811 The following built-in function is always available.
19812
19813 @table @code
19814 @item void __builtin_ia32_pause (void)
19815 Generates the @code{pause} machine instruction with a compiler memory
19816 barrier.
19817 @end table
19818
19819 The following built-in functions are always available and can be used to
19820 check the target platform type.
19821
19822 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
19823 This function runs the CPU detection code to check the type of CPU and the
19824 features supported. This built-in function needs to be invoked along with the built-in functions
19825 to check CPU type and features, @code{__builtin_cpu_is} and
19826 @code{__builtin_cpu_supports}, only when used in a function that is
19827 executed before any constructors are called. The CPU detection code is
19828 automatically executed in a very high priority constructor.
19829
19830 For example, this function has to be used in @code{ifunc} resolvers that
19831 check for CPU type using the built-in functions @code{__builtin_cpu_is}
19832 and @code{__builtin_cpu_supports}, or in constructors on targets that
19833 don't support constructor priority.
19834 @smallexample
19835
19836 static void (*resolve_memcpy (void)) (void)
19837 @{
19838 // ifunc resolvers fire before constructors, explicitly call the init
19839 // function.
19840 __builtin_cpu_init ();
19841 if (__builtin_cpu_supports ("ssse3"))
19842 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
19843 else
19844 return default_memcpy;
19845 @}
19846
19847 void *memcpy (void *, const void *, size_t)
19848 __attribute__ ((ifunc ("resolve_memcpy")));
19849 @end smallexample
19850
19851 @end deftypefn
19852
19853 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
19854 This function returns a positive integer if the run-time CPU
19855 is of type @var{cpuname}
19856 and returns @code{0} otherwise. The following CPU names can be detected:
19857
19858 @table @samp
19859 @item intel
19860 Intel CPU.
19861
19862 @item atom
19863 Intel Atom CPU.
19864
19865 @item core2
19866 Intel Core 2 CPU.
19867
19868 @item corei7
19869 Intel Core i7 CPU.
19870
19871 @item nehalem
19872 Intel Core i7 Nehalem CPU.
19873
19874 @item westmere
19875 Intel Core i7 Westmere CPU.
19876
19877 @item sandybridge
19878 Intel Core i7 Sandy Bridge CPU.
19879
19880 @item amd
19881 AMD CPU.
19882
19883 @item amdfam10h
19884 AMD Family 10h CPU.
19885
19886 @item barcelona
19887 AMD Family 10h Barcelona CPU.
19888
19889 @item shanghai
19890 AMD Family 10h Shanghai CPU.
19891
19892 @item istanbul
19893 AMD Family 10h Istanbul CPU.
19894
19895 @item btver1
19896 AMD Family 14h CPU.
19897
19898 @item amdfam15h
19899 AMD Family 15h CPU.
19900
19901 @item bdver1
19902 AMD Family 15h Bulldozer version 1.
19903
19904 @item bdver2
19905 AMD Family 15h Bulldozer version 2.
19906
19907 @item bdver3
19908 AMD Family 15h Bulldozer version 3.
19909
19910 @item bdver4
19911 AMD Family 15h Bulldozer version 4.
19912
19913 @item btver2
19914 AMD Family 16h CPU.
19915
19916 @item znver1
19917 AMD Family 17h CPU.
19918 @end table
19919
19920 Here is an example:
19921 @smallexample
19922 if (__builtin_cpu_is ("corei7"))
19923 @{
19924 do_corei7 (); // Core i7 specific implementation.
19925 @}
19926 else
19927 @{
19928 do_generic (); // Generic implementation.
19929 @}
19930 @end smallexample
19931 @end deftypefn
19932
19933 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
19934 This function returns a positive integer if the run-time CPU
19935 supports @var{feature}
19936 and returns @code{0} otherwise. The following features can be detected:
19937
19938 @table @samp
19939 @item cmov
19940 CMOV instruction.
19941 @item mmx
19942 MMX instructions.
19943 @item popcnt
19944 POPCNT instruction.
19945 @item sse
19946 SSE instructions.
19947 @item sse2
19948 SSE2 instructions.
19949 @item sse3
19950 SSE3 instructions.
19951 @item ssse3
19952 SSSE3 instructions.
19953 @item sse4.1
19954 SSE4.1 instructions.
19955 @item sse4.2
19956 SSE4.2 instructions.
19957 @item avx
19958 AVX instructions.
19959 @item avx2
19960 AVX2 instructions.
19961 @item avx512f
19962 AVX512F instructions.
19963 @end table
19964
19965 Here is an example:
19966 @smallexample
19967 if (__builtin_cpu_supports ("popcnt"))
19968 @{
19969 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
19970 @}
19971 else
19972 @{
19973 count = generic_countbits (n); //generic implementation.
19974 @}
19975 @end smallexample
19976 @end deftypefn
19977
19978
19979 The following built-in functions are made available by @option{-mmmx}.
19980 All of them generate the machine instruction that is part of the name.
19981
19982 @smallexample
19983 v8qi __builtin_ia32_paddb (v8qi, v8qi)
19984 v4hi __builtin_ia32_paddw (v4hi, v4hi)
19985 v2si __builtin_ia32_paddd (v2si, v2si)
19986 v8qi __builtin_ia32_psubb (v8qi, v8qi)
19987 v4hi __builtin_ia32_psubw (v4hi, v4hi)
19988 v2si __builtin_ia32_psubd (v2si, v2si)
19989 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
19990 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
19991 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
19992 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
19993 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
19994 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
19995 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
19996 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
19997 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
19998 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
19999 di __builtin_ia32_pand (di, di)
20000 di __builtin_ia32_pandn (di,di)
20001 di __builtin_ia32_por (di, di)
20002 di __builtin_ia32_pxor (di, di)
20003 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
20004 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
20005 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
20006 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
20007 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
20008 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
20009 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
20010 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
20011 v2si __builtin_ia32_punpckhdq (v2si, v2si)
20012 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
20013 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
20014 v2si __builtin_ia32_punpckldq (v2si, v2si)
20015 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
20016 v4hi __builtin_ia32_packssdw (v2si, v2si)
20017 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
20018
20019 v4hi __builtin_ia32_psllw (v4hi, v4hi)
20020 v2si __builtin_ia32_pslld (v2si, v2si)
20021 v1di __builtin_ia32_psllq (v1di, v1di)
20022 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
20023 v2si __builtin_ia32_psrld (v2si, v2si)
20024 v1di __builtin_ia32_psrlq (v1di, v1di)
20025 v4hi __builtin_ia32_psraw (v4hi, v4hi)
20026 v2si __builtin_ia32_psrad (v2si, v2si)
20027 v4hi __builtin_ia32_psllwi (v4hi, int)
20028 v2si __builtin_ia32_pslldi (v2si, int)
20029 v1di __builtin_ia32_psllqi (v1di, int)
20030 v4hi __builtin_ia32_psrlwi (v4hi, int)
20031 v2si __builtin_ia32_psrldi (v2si, int)
20032 v1di __builtin_ia32_psrlqi (v1di, int)
20033 v4hi __builtin_ia32_psrawi (v4hi, int)
20034 v2si __builtin_ia32_psradi (v2si, int)
20035
20036 @end smallexample
20037
20038 The following built-in functions are made available either with
20039 @option{-msse}, or with @option{-m3dnowa}. All of them generate
20040 the machine instruction that is part of the name.
20041
20042 @smallexample
20043 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
20044 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
20045 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
20046 v1di __builtin_ia32_psadbw (v8qi, v8qi)
20047 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
20048 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
20049 v8qi __builtin_ia32_pminub (v8qi, v8qi)
20050 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
20051 int __builtin_ia32_pmovmskb (v8qi)
20052 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
20053 void __builtin_ia32_movntq (di *, di)
20054 void __builtin_ia32_sfence (void)
20055 @end smallexample
20056
20057 The following built-in functions are available when @option{-msse} is used.
20058 All of them generate the machine instruction that is part of the name.
20059
20060 @smallexample
20061 int __builtin_ia32_comieq (v4sf, v4sf)
20062 int __builtin_ia32_comineq (v4sf, v4sf)
20063 int __builtin_ia32_comilt (v4sf, v4sf)
20064 int __builtin_ia32_comile (v4sf, v4sf)
20065 int __builtin_ia32_comigt (v4sf, v4sf)
20066 int __builtin_ia32_comige (v4sf, v4sf)
20067 int __builtin_ia32_ucomieq (v4sf, v4sf)
20068 int __builtin_ia32_ucomineq (v4sf, v4sf)
20069 int __builtin_ia32_ucomilt (v4sf, v4sf)
20070 int __builtin_ia32_ucomile (v4sf, v4sf)
20071 int __builtin_ia32_ucomigt (v4sf, v4sf)
20072 int __builtin_ia32_ucomige (v4sf, v4sf)
20073 v4sf __builtin_ia32_addps (v4sf, v4sf)
20074 v4sf __builtin_ia32_subps (v4sf, v4sf)
20075 v4sf __builtin_ia32_mulps (v4sf, v4sf)
20076 v4sf __builtin_ia32_divps (v4sf, v4sf)
20077 v4sf __builtin_ia32_addss (v4sf, v4sf)
20078 v4sf __builtin_ia32_subss (v4sf, v4sf)
20079 v4sf __builtin_ia32_mulss (v4sf, v4sf)
20080 v4sf __builtin_ia32_divss (v4sf, v4sf)
20081 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
20082 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
20083 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
20084 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
20085 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
20086 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
20087 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
20088 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
20089 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
20090 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
20091 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
20092 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
20093 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
20094 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
20095 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
20096 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
20097 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
20098 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
20099 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
20100 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
20101 v4sf __builtin_ia32_maxps (v4sf, v4sf)
20102 v4sf __builtin_ia32_maxss (v4sf, v4sf)
20103 v4sf __builtin_ia32_minps (v4sf, v4sf)
20104 v4sf __builtin_ia32_minss (v4sf, v4sf)
20105 v4sf __builtin_ia32_andps (v4sf, v4sf)
20106 v4sf __builtin_ia32_andnps (v4sf, v4sf)
20107 v4sf __builtin_ia32_orps (v4sf, v4sf)
20108 v4sf __builtin_ia32_xorps (v4sf, v4sf)
20109 v4sf __builtin_ia32_movss (v4sf, v4sf)
20110 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
20111 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
20112 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
20113 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
20114 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
20115 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
20116 v2si __builtin_ia32_cvtps2pi (v4sf)
20117 int __builtin_ia32_cvtss2si (v4sf)
20118 v2si __builtin_ia32_cvttps2pi (v4sf)
20119 int __builtin_ia32_cvttss2si (v4sf)
20120 v4sf __builtin_ia32_rcpps (v4sf)
20121 v4sf __builtin_ia32_rsqrtps (v4sf)
20122 v4sf __builtin_ia32_sqrtps (v4sf)
20123 v4sf __builtin_ia32_rcpss (v4sf)
20124 v4sf __builtin_ia32_rsqrtss (v4sf)
20125 v4sf __builtin_ia32_sqrtss (v4sf)
20126 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
20127 void __builtin_ia32_movntps (float *, v4sf)
20128 int __builtin_ia32_movmskps (v4sf)
20129 @end smallexample
20130
20131 The following built-in functions are available when @option{-msse} is used.
20132
20133 @table @code
20134 @item v4sf __builtin_ia32_loadups (float *)
20135 Generates the @code{movups} machine instruction as a load from memory.
20136 @item void __builtin_ia32_storeups (float *, v4sf)
20137 Generates the @code{movups} machine instruction as a store to memory.
20138 @item v4sf __builtin_ia32_loadss (float *)
20139 Generates the @code{movss} machine instruction as a load from memory.
20140 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
20141 Generates the @code{movhps} machine instruction as a load from memory.
20142 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
20143 Generates the @code{movlps} machine instruction as a load from memory
20144 @item void __builtin_ia32_storehps (v2sf *, v4sf)
20145 Generates the @code{movhps} machine instruction as a store to memory.
20146 @item void __builtin_ia32_storelps (v2sf *, v4sf)
20147 Generates the @code{movlps} machine instruction as a store to memory.
20148 @end table
20149
20150 The following built-in functions are available when @option{-msse2} is used.
20151 All of them generate the machine instruction that is part of the name.
20152
20153 @smallexample
20154 int __builtin_ia32_comisdeq (v2df, v2df)
20155 int __builtin_ia32_comisdlt (v2df, v2df)
20156 int __builtin_ia32_comisdle (v2df, v2df)
20157 int __builtin_ia32_comisdgt (v2df, v2df)
20158 int __builtin_ia32_comisdge (v2df, v2df)
20159 int __builtin_ia32_comisdneq (v2df, v2df)
20160 int __builtin_ia32_ucomisdeq (v2df, v2df)
20161 int __builtin_ia32_ucomisdlt (v2df, v2df)
20162 int __builtin_ia32_ucomisdle (v2df, v2df)
20163 int __builtin_ia32_ucomisdgt (v2df, v2df)
20164 int __builtin_ia32_ucomisdge (v2df, v2df)
20165 int __builtin_ia32_ucomisdneq (v2df, v2df)
20166 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
20167 v2df __builtin_ia32_cmpltpd (v2df, v2df)
20168 v2df __builtin_ia32_cmplepd (v2df, v2df)
20169 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
20170 v2df __builtin_ia32_cmpgepd (v2df, v2df)
20171 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
20172 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
20173 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
20174 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
20175 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
20176 v2df __builtin_ia32_cmpngepd (v2df, v2df)
20177 v2df __builtin_ia32_cmpordpd (v2df, v2df)
20178 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
20179 v2df __builtin_ia32_cmpltsd (v2df, v2df)
20180 v2df __builtin_ia32_cmplesd (v2df, v2df)
20181 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
20182 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
20183 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
20184 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
20185 v2df __builtin_ia32_cmpordsd (v2df, v2df)
20186 v2di __builtin_ia32_paddq (v2di, v2di)
20187 v2di __builtin_ia32_psubq (v2di, v2di)
20188 v2df __builtin_ia32_addpd (v2df, v2df)
20189 v2df __builtin_ia32_subpd (v2df, v2df)
20190 v2df __builtin_ia32_mulpd (v2df, v2df)
20191 v2df __builtin_ia32_divpd (v2df, v2df)
20192 v2df __builtin_ia32_addsd (v2df, v2df)
20193 v2df __builtin_ia32_subsd (v2df, v2df)
20194 v2df __builtin_ia32_mulsd (v2df, v2df)
20195 v2df __builtin_ia32_divsd (v2df, v2df)
20196 v2df __builtin_ia32_minpd (v2df, v2df)
20197 v2df __builtin_ia32_maxpd (v2df, v2df)
20198 v2df __builtin_ia32_minsd (v2df, v2df)
20199 v2df __builtin_ia32_maxsd (v2df, v2df)
20200 v2df __builtin_ia32_andpd (v2df, v2df)
20201 v2df __builtin_ia32_andnpd (v2df, v2df)
20202 v2df __builtin_ia32_orpd (v2df, v2df)
20203 v2df __builtin_ia32_xorpd (v2df, v2df)
20204 v2df __builtin_ia32_movsd (v2df, v2df)
20205 v2df __builtin_ia32_unpckhpd (v2df, v2df)
20206 v2df __builtin_ia32_unpcklpd (v2df, v2df)
20207 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
20208 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
20209 v4si __builtin_ia32_paddd128 (v4si, v4si)
20210 v2di __builtin_ia32_paddq128 (v2di, v2di)
20211 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
20212 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
20213 v4si __builtin_ia32_psubd128 (v4si, v4si)
20214 v2di __builtin_ia32_psubq128 (v2di, v2di)
20215 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
20216 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
20217 v2di __builtin_ia32_pand128 (v2di, v2di)
20218 v2di __builtin_ia32_pandn128 (v2di, v2di)
20219 v2di __builtin_ia32_por128 (v2di, v2di)
20220 v2di __builtin_ia32_pxor128 (v2di, v2di)
20221 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
20222 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
20223 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
20224 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
20225 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
20226 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
20227 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
20228 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
20229 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
20230 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
20231 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
20232 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
20233 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
20234 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
20235 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
20236 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
20237 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
20238 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
20239 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
20240 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
20241 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
20242 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
20243 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
20244 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
20245 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
20246 v2df __builtin_ia32_loadupd (double *)
20247 void __builtin_ia32_storeupd (double *, v2df)
20248 v2df __builtin_ia32_loadhpd (v2df, double const *)
20249 v2df __builtin_ia32_loadlpd (v2df, double const *)
20250 int __builtin_ia32_movmskpd (v2df)
20251 int __builtin_ia32_pmovmskb128 (v16qi)
20252 void __builtin_ia32_movnti (int *, int)
20253 void __builtin_ia32_movnti64 (long long int *, long long int)
20254 void __builtin_ia32_movntpd (double *, v2df)
20255 void __builtin_ia32_movntdq (v2df *, v2df)
20256 v4si __builtin_ia32_pshufd (v4si, int)
20257 v8hi __builtin_ia32_pshuflw (v8hi, int)
20258 v8hi __builtin_ia32_pshufhw (v8hi, int)
20259 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
20260 v2df __builtin_ia32_sqrtpd (v2df)
20261 v2df __builtin_ia32_sqrtsd (v2df)
20262 v2df __builtin_ia32_shufpd (v2df, v2df, int)
20263 v2df __builtin_ia32_cvtdq2pd (v4si)
20264 v4sf __builtin_ia32_cvtdq2ps (v4si)
20265 v4si __builtin_ia32_cvtpd2dq (v2df)
20266 v2si __builtin_ia32_cvtpd2pi (v2df)
20267 v4sf __builtin_ia32_cvtpd2ps (v2df)
20268 v4si __builtin_ia32_cvttpd2dq (v2df)
20269 v2si __builtin_ia32_cvttpd2pi (v2df)
20270 v2df __builtin_ia32_cvtpi2pd (v2si)
20271 int __builtin_ia32_cvtsd2si (v2df)
20272 int __builtin_ia32_cvttsd2si (v2df)
20273 long long __builtin_ia32_cvtsd2si64 (v2df)
20274 long long __builtin_ia32_cvttsd2si64 (v2df)
20275 v4si __builtin_ia32_cvtps2dq (v4sf)
20276 v2df __builtin_ia32_cvtps2pd (v4sf)
20277 v4si __builtin_ia32_cvttps2dq (v4sf)
20278 v2df __builtin_ia32_cvtsi2sd (v2df, int)
20279 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
20280 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
20281 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
20282 void __builtin_ia32_clflush (const void *)
20283 void __builtin_ia32_lfence (void)
20284 void __builtin_ia32_mfence (void)
20285 v16qi __builtin_ia32_loaddqu (const char *)
20286 void __builtin_ia32_storedqu (char *, v16qi)
20287 v1di __builtin_ia32_pmuludq (v2si, v2si)
20288 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
20289 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
20290 v4si __builtin_ia32_pslld128 (v4si, v4si)
20291 v2di __builtin_ia32_psllq128 (v2di, v2di)
20292 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
20293 v4si __builtin_ia32_psrld128 (v4si, v4si)
20294 v2di __builtin_ia32_psrlq128 (v2di, v2di)
20295 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
20296 v4si __builtin_ia32_psrad128 (v4si, v4si)
20297 v2di __builtin_ia32_pslldqi128 (v2di, int)
20298 v8hi __builtin_ia32_psllwi128 (v8hi, int)
20299 v4si __builtin_ia32_pslldi128 (v4si, int)
20300 v2di __builtin_ia32_psllqi128 (v2di, int)
20301 v2di __builtin_ia32_psrldqi128 (v2di, int)
20302 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
20303 v4si __builtin_ia32_psrldi128 (v4si, int)
20304 v2di __builtin_ia32_psrlqi128 (v2di, int)
20305 v8hi __builtin_ia32_psrawi128 (v8hi, int)
20306 v4si __builtin_ia32_psradi128 (v4si, int)
20307 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
20308 v2di __builtin_ia32_movq128 (v2di)
20309 @end smallexample
20310
20311 The following built-in functions are available when @option{-msse3} is used.
20312 All of them generate the machine instruction that is part of the name.
20313
20314 @smallexample
20315 v2df __builtin_ia32_addsubpd (v2df, v2df)
20316 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
20317 v2df __builtin_ia32_haddpd (v2df, v2df)
20318 v4sf __builtin_ia32_haddps (v4sf, v4sf)
20319 v2df __builtin_ia32_hsubpd (v2df, v2df)
20320 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
20321 v16qi __builtin_ia32_lddqu (char const *)
20322 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
20323 v4sf __builtin_ia32_movshdup (v4sf)
20324 v4sf __builtin_ia32_movsldup (v4sf)
20325 void __builtin_ia32_mwait (unsigned int, unsigned int)
20326 @end smallexample
20327
20328 The following built-in functions are available when @option{-mssse3} is used.
20329 All of them generate the machine instruction that is part of the name.
20330
20331 @smallexample
20332 v2si __builtin_ia32_phaddd (v2si, v2si)
20333 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
20334 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
20335 v2si __builtin_ia32_phsubd (v2si, v2si)
20336 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
20337 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
20338 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
20339 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
20340 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
20341 v8qi __builtin_ia32_psignb (v8qi, v8qi)
20342 v2si __builtin_ia32_psignd (v2si, v2si)
20343 v4hi __builtin_ia32_psignw (v4hi, v4hi)
20344 v1di __builtin_ia32_palignr (v1di, v1di, int)
20345 v8qi __builtin_ia32_pabsb (v8qi)
20346 v2si __builtin_ia32_pabsd (v2si)
20347 v4hi __builtin_ia32_pabsw (v4hi)
20348 @end smallexample
20349
20350 The following built-in functions are available when @option{-mssse3} is used.
20351 All of them generate the machine instruction that is part of the name.
20352
20353 @smallexample
20354 v4si __builtin_ia32_phaddd128 (v4si, v4si)
20355 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
20356 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
20357 v4si __builtin_ia32_phsubd128 (v4si, v4si)
20358 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
20359 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
20360 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
20361 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
20362 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
20363 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
20364 v4si __builtin_ia32_psignd128 (v4si, v4si)
20365 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
20366 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
20367 v16qi __builtin_ia32_pabsb128 (v16qi)
20368 v4si __builtin_ia32_pabsd128 (v4si)
20369 v8hi __builtin_ia32_pabsw128 (v8hi)
20370 @end smallexample
20371
20372 The following built-in functions are available when @option{-msse4.1} is
20373 used. All of them generate the machine instruction that is part of the
20374 name.
20375
20376 @smallexample
20377 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
20378 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
20379 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
20380 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
20381 v2df __builtin_ia32_dppd (v2df, v2df, const int)
20382 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
20383 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
20384 v2di __builtin_ia32_movntdqa (v2di *);
20385 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
20386 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
20387 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
20388 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
20389 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
20390 v8hi __builtin_ia32_phminposuw128 (v8hi)
20391 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
20392 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
20393 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
20394 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
20395 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
20396 v4si __builtin_ia32_pminsd128 (v4si, v4si)
20397 v4si __builtin_ia32_pminud128 (v4si, v4si)
20398 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
20399 v4si __builtin_ia32_pmovsxbd128 (v16qi)
20400 v2di __builtin_ia32_pmovsxbq128 (v16qi)
20401 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
20402 v2di __builtin_ia32_pmovsxdq128 (v4si)
20403 v4si __builtin_ia32_pmovsxwd128 (v8hi)
20404 v2di __builtin_ia32_pmovsxwq128 (v8hi)
20405 v4si __builtin_ia32_pmovzxbd128 (v16qi)
20406 v2di __builtin_ia32_pmovzxbq128 (v16qi)
20407 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
20408 v2di __builtin_ia32_pmovzxdq128 (v4si)
20409 v4si __builtin_ia32_pmovzxwd128 (v8hi)
20410 v2di __builtin_ia32_pmovzxwq128 (v8hi)
20411 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
20412 v4si __builtin_ia32_pmulld128 (v4si, v4si)
20413 int __builtin_ia32_ptestc128 (v2di, v2di)
20414 int __builtin_ia32_ptestnzc128 (v2di, v2di)
20415 int __builtin_ia32_ptestz128 (v2di, v2di)
20416 v2df __builtin_ia32_roundpd (v2df, const int)
20417 v4sf __builtin_ia32_roundps (v4sf, const int)
20418 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
20419 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
20420 @end smallexample
20421
20422 The following built-in functions are available when @option{-msse4.1} is
20423 used.
20424
20425 @table @code
20426 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
20427 Generates the @code{insertps} machine instruction.
20428 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
20429 Generates the @code{pextrb} machine instruction.
20430 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
20431 Generates the @code{pinsrb} machine instruction.
20432 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
20433 Generates the @code{pinsrd} machine instruction.
20434 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
20435 Generates the @code{pinsrq} machine instruction in 64bit mode.
20436 @end table
20437
20438 The following built-in functions are changed to generate new SSE4.1
20439 instructions when @option{-msse4.1} is used.
20440
20441 @table @code
20442 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
20443 Generates the @code{extractps} machine instruction.
20444 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
20445 Generates the @code{pextrd} machine instruction.
20446 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
20447 Generates the @code{pextrq} machine instruction in 64bit mode.
20448 @end table
20449
20450 The following built-in functions are available when @option{-msse4.2} is
20451 used. All of them generate the machine instruction that is part of the
20452 name.
20453
20454 @smallexample
20455 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
20456 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
20457 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
20458 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
20459 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
20460 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
20461 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
20462 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
20463 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
20464 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
20465 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
20466 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
20467 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
20468 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
20469 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
20470 @end smallexample
20471
20472 The following built-in functions are available when @option{-msse4.2} is
20473 used.
20474
20475 @table @code
20476 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
20477 Generates the @code{crc32b} machine instruction.
20478 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
20479 Generates the @code{crc32w} machine instruction.
20480 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
20481 Generates the @code{crc32l} machine instruction.
20482 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
20483 Generates the @code{crc32q} machine instruction.
20484 @end table
20485
20486 The following built-in functions are changed to generate new SSE4.2
20487 instructions when @option{-msse4.2} is used.
20488
20489 @table @code
20490 @item int __builtin_popcount (unsigned int)
20491 Generates the @code{popcntl} machine instruction.
20492 @item int __builtin_popcountl (unsigned long)
20493 Generates the @code{popcntl} or @code{popcntq} machine instruction,
20494 depending on the size of @code{unsigned long}.
20495 @item int __builtin_popcountll (unsigned long long)
20496 Generates the @code{popcntq} machine instruction.
20497 @end table
20498
20499 The following built-in functions are available when @option{-mavx} is
20500 used. All of them generate the machine instruction that is part of the
20501 name.
20502
20503 @smallexample
20504 v4df __builtin_ia32_addpd256 (v4df,v4df)
20505 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
20506 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
20507 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
20508 v4df __builtin_ia32_andnpd256 (v4df,v4df)
20509 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
20510 v4df __builtin_ia32_andpd256 (v4df,v4df)
20511 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
20512 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
20513 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
20514 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
20515 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
20516 v2df __builtin_ia32_cmppd (v2df,v2df,int)
20517 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
20518 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
20519 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
20520 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
20521 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
20522 v4df __builtin_ia32_cvtdq2pd256 (v4si)
20523 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
20524 v4si __builtin_ia32_cvtpd2dq256 (v4df)
20525 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
20526 v8si __builtin_ia32_cvtps2dq256 (v8sf)
20527 v4df __builtin_ia32_cvtps2pd256 (v4sf)
20528 v4si __builtin_ia32_cvttpd2dq256 (v4df)
20529 v8si __builtin_ia32_cvttps2dq256 (v8sf)
20530 v4df __builtin_ia32_divpd256 (v4df,v4df)
20531 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
20532 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
20533 v4df __builtin_ia32_haddpd256 (v4df,v4df)
20534 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
20535 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
20536 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
20537 v32qi __builtin_ia32_lddqu256 (pcchar)
20538 v32qi __builtin_ia32_loaddqu256 (pcchar)
20539 v4df __builtin_ia32_loadupd256 (pcdouble)
20540 v8sf __builtin_ia32_loadups256 (pcfloat)
20541 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
20542 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
20543 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
20544 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
20545 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
20546 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
20547 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
20548 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
20549 v4df __builtin_ia32_maxpd256 (v4df,v4df)
20550 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
20551 v4df __builtin_ia32_minpd256 (v4df,v4df)
20552 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
20553 v4df __builtin_ia32_movddup256 (v4df)
20554 int __builtin_ia32_movmskpd256 (v4df)
20555 int __builtin_ia32_movmskps256 (v8sf)
20556 v8sf __builtin_ia32_movshdup256 (v8sf)
20557 v8sf __builtin_ia32_movsldup256 (v8sf)
20558 v4df __builtin_ia32_mulpd256 (v4df,v4df)
20559 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
20560 v4df __builtin_ia32_orpd256 (v4df,v4df)
20561 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
20562 v2df __builtin_ia32_pd_pd256 (v4df)
20563 v4df __builtin_ia32_pd256_pd (v2df)
20564 v4sf __builtin_ia32_ps_ps256 (v8sf)
20565 v8sf __builtin_ia32_ps256_ps (v4sf)
20566 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
20567 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
20568 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
20569 v8sf __builtin_ia32_rcpps256 (v8sf)
20570 v4df __builtin_ia32_roundpd256 (v4df,int)
20571 v8sf __builtin_ia32_roundps256 (v8sf,int)
20572 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
20573 v8sf __builtin_ia32_rsqrtps256 (v8sf)
20574 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
20575 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
20576 v4si __builtin_ia32_si_si256 (v8si)
20577 v8si __builtin_ia32_si256_si (v4si)
20578 v4df __builtin_ia32_sqrtpd256 (v4df)
20579 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
20580 v8sf __builtin_ia32_sqrtps256 (v8sf)
20581 void __builtin_ia32_storedqu256 (pchar,v32qi)
20582 void __builtin_ia32_storeupd256 (pdouble,v4df)
20583 void __builtin_ia32_storeups256 (pfloat,v8sf)
20584 v4df __builtin_ia32_subpd256 (v4df,v4df)
20585 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
20586 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
20587 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
20588 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
20589 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
20590 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
20591 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
20592 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
20593 v4sf __builtin_ia32_vbroadcastss (pcfloat)
20594 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
20595 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
20596 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
20597 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
20598 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
20599 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
20600 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
20601 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
20602 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
20603 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
20604 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
20605 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
20606 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
20607 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
20608 v2df __builtin_ia32_vpermilpd (v2df,int)
20609 v4df __builtin_ia32_vpermilpd256 (v4df,int)
20610 v4sf __builtin_ia32_vpermilps (v4sf,int)
20611 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
20612 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
20613 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
20614 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
20615 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
20616 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
20617 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
20618 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
20619 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
20620 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
20621 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
20622 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
20623 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
20624 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
20625 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
20626 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
20627 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
20628 void __builtin_ia32_vzeroall (void)
20629 void __builtin_ia32_vzeroupper (void)
20630 v4df __builtin_ia32_xorpd256 (v4df,v4df)
20631 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
20632 @end smallexample
20633
20634 The following built-in functions are available when @option{-mavx2} is
20635 used. All of them generate the machine instruction that is part of the
20636 name.
20637
20638 @smallexample
20639 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
20640 v32qi __builtin_ia32_pabsb256 (v32qi)
20641 v16hi __builtin_ia32_pabsw256 (v16hi)
20642 v8si __builtin_ia32_pabsd256 (v8si)
20643 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
20644 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
20645 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
20646 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
20647 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
20648 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
20649 v8si __builtin_ia32_paddd256 (v8si,v8si)
20650 v4di __builtin_ia32_paddq256 (v4di,v4di)
20651 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
20652 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
20653 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
20654 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
20655 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
20656 v4di __builtin_ia32_andsi256 (v4di,v4di)
20657 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
20658 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
20659 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
20660 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
20661 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
20662 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
20663 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
20664 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
20665 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
20666 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
20667 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
20668 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
20669 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
20670 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
20671 v8si __builtin_ia32_phaddd256 (v8si,v8si)
20672 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
20673 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
20674 v8si __builtin_ia32_phsubd256 (v8si,v8si)
20675 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
20676 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
20677 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
20678 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
20679 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
20680 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
20681 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
20682 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
20683 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
20684 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
20685 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
20686 v8si __builtin_ia32_pminsd256 (v8si,v8si)
20687 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
20688 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
20689 v8si __builtin_ia32_pminud256 (v8si,v8si)
20690 int __builtin_ia32_pmovmskb256 (v32qi)
20691 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
20692 v8si __builtin_ia32_pmovsxbd256 (v16qi)
20693 v4di __builtin_ia32_pmovsxbq256 (v16qi)
20694 v8si __builtin_ia32_pmovsxwd256 (v8hi)
20695 v4di __builtin_ia32_pmovsxwq256 (v8hi)
20696 v4di __builtin_ia32_pmovsxdq256 (v4si)
20697 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
20698 v8si __builtin_ia32_pmovzxbd256 (v16qi)
20699 v4di __builtin_ia32_pmovzxbq256 (v16qi)
20700 v8si __builtin_ia32_pmovzxwd256 (v8hi)
20701 v4di __builtin_ia32_pmovzxwq256 (v8hi)
20702 v4di __builtin_ia32_pmovzxdq256 (v4si)
20703 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
20704 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
20705 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
20706 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
20707 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
20708 v8si __builtin_ia32_pmulld256 (v8si,v8si)
20709 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
20710 v4di __builtin_ia32_por256 (v4di,v4di)
20711 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
20712 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
20713 v8si __builtin_ia32_pshufd256 (v8si,int)
20714 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
20715 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
20716 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
20717 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
20718 v8si __builtin_ia32_psignd256 (v8si,v8si)
20719 v4di __builtin_ia32_pslldqi256 (v4di,int)
20720 v16hi __builtin_ia32_psllwi256 (16hi,int)
20721 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
20722 v8si __builtin_ia32_pslldi256 (v8si,int)
20723 v8si __builtin_ia32_pslld256(v8si,v4si)
20724 v4di __builtin_ia32_psllqi256 (v4di,int)
20725 v4di __builtin_ia32_psllq256(v4di,v2di)
20726 v16hi __builtin_ia32_psrawi256 (v16hi,int)
20727 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
20728 v8si __builtin_ia32_psradi256 (v8si,int)
20729 v8si __builtin_ia32_psrad256 (v8si,v4si)
20730 v4di __builtin_ia32_psrldqi256 (v4di, int)
20731 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
20732 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
20733 v8si __builtin_ia32_psrldi256 (v8si,int)
20734 v8si __builtin_ia32_psrld256 (v8si,v4si)
20735 v4di __builtin_ia32_psrlqi256 (v4di,int)
20736 v4di __builtin_ia32_psrlq256(v4di,v2di)
20737 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
20738 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
20739 v8si __builtin_ia32_psubd256 (v8si,v8si)
20740 v4di __builtin_ia32_psubq256 (v4di,v4di)
20741 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
20742 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
20743 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
20744 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
20745 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
20746 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
20747 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
20748 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
20749 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
20750 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
20751 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
20752 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
20753 v4di __builtin_ia32_pxor256 (v4di,v4di)
20754 v4di __builtin_ia32_movntdqa256 (pv4di)
20755 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
20756 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
20757 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
20758 v4di __builtin_ia32_vbroadcastsi256 (v2di)
20759 v4si __builtin_ia32_pblendd128 (v4si,v4si)
20760 v8si __builtin_ia32_pblendd256 (v8si,v8si)
20761 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
20762 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
20763 v8si __builtin_ia32_pbroadcastd256 (v4si)
20764 v4di __builtin_ia32_pbroadcastq256 (v2di)
20765 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
20766 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
20767 v4si __builtin_ia32_pbroadcastd128 (v4si)
20768 v2di __builtin_ia32_pbroadcastq128 (v2di)
20769 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
20770 v4df __builtin_ia32_permdf256 (v4df,int)
20771 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
20772 v4di __builtin_ia32_permdi256 (v4di,int)
20773 v4di __builtin_ia32_permti256 (v4di,v4di,int)
20774 v4di __builtin_ia32_extract128i256 (v4di,int)
20775 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
20776 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
20777 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
20778 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
20779 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
20780 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
20781 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
20782 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
20783 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
20784 v8si __builtin_ia32_psllv8si (v8si,v8si)
20785 v4si __builtin_ia32_psllv4si (v4si,v4si)
20786 v4di __builtin_ia32_psllv4di (v4di,v4di)
20787 v2di __builtin_ia32_psllv2di (v2di,v2di)
20788 v8si __builtin_ia32_psrav8si (v8si,v8si)
20789 v4si __builtin_ia32_psrav4si (v4si,v4si)
20790 v8si __builtin_ia32_psrlv8si (v8si,v8si)
20791 v4si __builtin_ia32_psrlv4si (v4si,v4si)
20792 v4di __builtin_ia32_psrlv4di (v4di,v4di)
20793 v2di __builtin_ia32_psrlv2di (v2di,v2di)
20794 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
20795 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
20796 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
20797 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
20798 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
20799 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
20800 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
20801 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
20802 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
20803 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
20804 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
20805 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
20806 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
20807 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
20808 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
20809 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
20810 @end smallexample
20811
20812 The following built-in functions are available when @option{-maes} is
20813 used. All of them generate the machine instruction that is part of the
20814 name.
20815
20816 @smallexample
20817 v2di __builtin_ia32_aesenc128 (v2di, v2di)
20818 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
20819 v2di __builtin_ia32_aesdec128 (v2di, v2di)
20820 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
20821 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
20822 v2di __builtin_ia32_aesimc128 (v2di)
20823 @end smallexample
20824
20825 The following built-in function is available when @option{-mpclmul} is
20826 used.
20827
20828 @table @code
20829 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
20830 Generates the @code{pclmulqdq} machine instruction.
20831 @end table
20832
20833 The following built-in function is available when @option{-mfsgsbase} is
20834 used. All of them generate the machine instruction that is part of the
20835 name.
20836
20837 @smallexample
20838 unsigned int __builtin_ia32_rdfsbase32 (void)
20839 unsigned long long __builtin_ia32_rdfsbase64 (void)
20840 unsigned int __builtin_ia32_rdgsbase32 (void)
20841 unsigned long long __builtin_ia32_rdgsbase64 (void)
20842 void _writefsbase_u32 (unsigned int)
20843 void _writefsbase_u64 (unsigned long long)
20844 void _writegsbase_u32 (unsigned int)
20845 void _writegsbase_u64 (unsigned long long)
20846 @end smallexample
20847
20848 The following built-in function is available when @option{-mrdrnd} is
20849 used. All of them generate the machine instruction that is part of the
20850 name.
20851
20852 @smallexample
20853 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
20854 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
20855 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
20856 @end smallexample
20857
20858 The following built-in functions are available when @option{-msse4a} is used.
20859 All of them generate the machine instruction that is part of the name.
20860
20861 @smallexample
20862 void __builtin_ia32_movntsd (double *, v2df)
20863 void __builtin_ia32_movntss (float *, v4sf)
20864 v2di __builtin_ia32_extrq (v2di, v16qi)
20865 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
20866 v2di __builtin_ia32_insertq (v2di, v2di)
20867 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
20868 @end smallexample
20869
20870 The following built-in functions are available when @option{-mxop} is used.
20871 @smallexample
20872 v2df __builtin_ia32_vfrczpd (v2df)
20873 v4sf __builtin_ia32_vfrczps (v4sf)
20874 v2df __builtin_ia32_vfrczsd (v2df)
20875 v4sf __builtin_ia32_vfrczss (v4sf)
20876 v4df __builtin_ia32_vfrczpd256 (v4df)
20877 v8sf __builtin_ia32_vfrczps256 (v8sf)
20878 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
20879 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
20880 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
20881 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
20882 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
20883 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
20884 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
20885 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
20886 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
20887 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
20888 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
20889 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
20890 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
20891 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
20892 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
20893 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
20894 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
20895 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
20896 v4si __builtin_ia32_vpcomequd (v4si, v4si)
20897 v2di __builtin_ia32_vpcomequq (v2di, v2di)
20898 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
20899 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
20900 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
20901 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
20902 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
20903 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
20904 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
20905 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
20906 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
20907 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
20908 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
20909 v4si __builtin_ia32_vpcomged (v4si, v4si)
20910 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
20911 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
20912 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
20913 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
20914 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
20915 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
20916 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
20917 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
20918 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
20919 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
20920 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
20921 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
20922 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
20923 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
20924 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
20925 v4si __builtin_ia32_vpcomled (v4si, v4si)
20926 v2di __builtin_ia32_vpcomleq (v2di, v2di)
20927 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
20928 v4si __builtin_ia32_vpcomleud (v4si, v4si)
20929 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
20930 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
20931 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
20932 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
20933 v4si __builtin_ia32_vpcomltd (v4si, v4si)
20934 v2di __builtin_ia32_vpcomltq (v2di, v2di)
20935 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
20936 v4si __builtin_ia32_vpcomltud (v4si, v4si)
20937 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
20938 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
20939 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
20940 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
20941 v4si __builtin_ia32_vpcomned (v4si, v4si)
20942 v2di __builtin_ia32_vpcomneq (v2di, v2di)
20943 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
20944 v4si __builtin_ia32_vpcomneud (v4si, v4si)
20945 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
20946 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
20947 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
20948 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
20949 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
20950 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
20951 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
20952 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
20953 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
20954 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
20955 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
20956 v4si __builtin_ia32_vphaddbd (v16qi)
20957 v2di __builtin_ia32_vphaddbq (v16qi)
20958 v8hi __builtin_ia32_vphaddbw (v16qi)
20959 v2di __builtin_ia32_vphadddq (v4si)
20960 v4si __builtin_ia32_vphaddubd (v16qi)
20961 v2di __builtin_ia32_vphaddubq (v16qi)
20962 v8hi __builtin_ia32_vphaddubw (v16qi)
20963 v2di __builtin_ia32_vphaddudq (v4si)
20964 v4si __builtin_ia32_vphadduwd (v8hi)
20965 v2di __builtin_ia32_vphadduwq (v8hi)
20966 v4si __builtin_ia32_vphaddwd (v8hi)
20967 v2di __builtin_ia32_vphaddwq (v8hi)
20968 v8hi __builtin_ia32_vphsubbw (v16qi)
20969 v2di __builtin_ia32_vphsubdq (v4si)
20970 v4si __builtin_ia32_vphsubwd (v8hi)
20971 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
20972 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
20973 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
20974 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
20975 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
20976 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
20977 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
20978 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
20979 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
20980 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
20981 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
20982 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
20983 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
20984 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
20985 v4si __builtin_ia32_vprotd (v4si, v4si)
20986 v2di __builtin_ia32_vprotq (v2di, v2di)
20987 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
20988 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
20989 v4si __builtin_ia32_vpshad (v4si, v4si)
20990 v2di __builtin_ia32_vpshaq (v2di, v2di)
20991 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
20992 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
20993 v4si __builtin_ia32_vpshld (v4si, v4si)
20994 v2di __builtin_ia32_vpshlq (v2di, v2di)
20995 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
20996 @end smallexample
20997
20998 The following built-in functions are available when @option{-mfma4} is used.
20999 All of them generate the machine instruction that is part of the name.
21000
21001 @smallexample
21002 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
21003 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
21004 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
21005 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
21006 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
21007 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
21008 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
21009 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
21010 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
21011 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
21012 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
21013 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
21014 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
21015 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
21016 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
21017 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
21018 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
21019 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
21020 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
21021 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
21022 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
21023 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
21024 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
21025 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
21026 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
21027 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
21028 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
21029 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
21030 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
21031 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
21032 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
21033 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
21034
21035 @end smallexample
21036
21037 The following built-in functions are available when @option{-mlwp} is used.
21038
21039 @smallexample
21040 void __builtin_ia32_llwpcb16 (void *);
21041 void __builtin_ia32_llwpcb32 (void *);
21042 void __builtin_ia32_llwpcb64 (void *);
21043 void * __builtin_ia32_llwpcb16 (void);
21044 void * __builtin_ia32_llwpcb32 (void);
21045 void * __builtin_ia32_llwpcb64 (void);
21046 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
21047 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
21048 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
21049 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
21050 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
21051 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
21052 @end smallexample
21053
21054 The following built-in functions are available when @option{-mbmi} is used.
21055 All of them generate the machine instruction that is part of the name.
21056 @smallexample
21057 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
21058 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
21059 @end smallexample
21060
21061 The following built-in functions are available when @option{-mbmi2} is used.
21062 All of them generate the machine instruction that is part of the name.
21063 @smallexample
21064 unsigned int _bzhi_u32 (unsigned int, unsigned int)
21065 unsigned int _pdep_u32 (unsigned int, unsigned int)
21066 unsigned int _pext_u32 (unsigned int, unsigned int)
21067 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
21068 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
21069 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
21070 @end smallexample
21071
21072 The following built-in functions are available when @option{-mlzcnt} is used.
21073 All of them generate the machine instruction that is part of the name.
21074 @smallexample
21075 unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
21076 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
21077 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
21078 @end smallexample
21079
21080 The following built-in functions are available when @option{-mfxsr} is used.
21081 All of them generate the machine instruction that is part of the name.
21082 @smallexample
21083 void __builtin_ia32_fxsave (void *)
21084 void __builtin_ia32_fxrstor (void *)
21085 void __builtin_ia32_fxsave64 (void *)
21086 void __builtin_ia32_fxrstor64 (void *)
21087 @end smallexample
21088
21089 The following built-in functions are available when @option{-mxsave} is used.
21090 All of them generate the machine instruction that is part of the name.
21091 @smallexample
21092 void __builtin_ia32_xsave (void *, long long)
21093 void __builtin_ia32_xrstor (void *, long long)
21094 void __builtin_ia32_xsave64 (void *, long long)
21095 void __builtin_ia32_xrstor64 (void *, long long)
21096 @end smallexample
21097
21098 The following built-in functions are available when @option{-mxsaveopt} is used.
21099 All of them generate the machine instruction that is part of the name.
21100 @smallexample
21101 void __builtin_ia32_xsaveopt (void *, long long)
21102 void __builtin_ia32_xsaveopt64 (void *, long long)
21103 @end smallexample
21104
21105 The following built-in functions are available when @option{-mtbm} is used.
21106 Both of them generate the immediate form of the bextr machine instruction.
21107 @smallexample
21108 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
21109 const unsigned int);
21110 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
21111 const unsigned long long);
21112 @end smallexample
21113
21114
21115 The following built-in functions are available when @option{-m3dnow} is used.
21116 All of them generate the machine instruction that is part of the name.
21117
21118 @smallexample
21119 void __builtin_ia32_femms (void)
21120 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
21121 v2si __builtin_ia32_pf2id (v2sf)
21122 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
21123 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
21124 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
21125 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
21126 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
21127 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
21128 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
21129 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
21130 v2sf __builtin_ia32_pfrcp (v2sf)
21131 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
21132 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
21133 v2sf __builtin_ia32_pfrsqrt (v2sf)
21134 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
21135 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
21136 v2sf __builtin_ia32_pi2fd (v2si)
21137 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
21138 @end smallexample
21139
21140 The following built-in functions are available when @option{-m3dnowa} is used.
21141 All of them generate the machine instruction that is part of the name.
21142
21143 @smallexample
21144 v2si __builtin_ia32_pf2iw (v2sf)
21145 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
21146 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
21147 v2sf __builtin_ia32_pi2fw (v2si)
21148 v2sf __builtin_ia32_pswapdsf (v2sf)
21149 v2si __builtin_ia32_pswapdsi (v2si)
21150 @end smallexample
21151
21152 The following built-in functions are available when @option{-mrtm} is used
21153 They are used for restricted transactional memory. These are the internal
21154 low level functions. Normally the functions in
21155 @ref{x86 transactional memory intrinsics} should be used instead.
21156
21157 @smallexample
21158 int __builtin_ia32_xbegin ()
21159 void __builtin_ia32_xend ()
21160 void __builtin_ia32_xabort (status)
21161 int __builtin_ia32_xtest ()
21162 @end smallexample
21163
21164 The following built-in functions are available when @option{-mmwaitx} is used.
21165 All of them generate the machine instruction that is part of the name.
21166 @smallexample
21167 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
21168 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
21169 @end smallexample
21170
21171 The following built-in functions are available when @option{-mclzero} is used.
21172 All of them generate the machine instruction that is part of the name.
21173 @smallexample
21174 void __builtin_i32_clzero (void *)
21175 @end smallexample
21176
21177 The following built-in functions are available when @option{-mpku} is used.
21178 They generate reads and writes to PKRU.
21179 @smallexample
21180 void __builtin_ia32_wrpkru (unsigned int)
21181 unsigned int __builtin_ia32_rdpkru ()
21182 @end smallexample
21183
21184 @node x86 transactional memory intrinsics
21185 @subsection x86 Transactional Memory Intrinsics
21186
21187 These hardware transactional memory intrinsics for x86 allow you to use
21188 memory transactions with RTM (Restricted Transactional Memory).
21189 This support is enabled with the @option{-mrtm} option.
21190 For using HLE (Hardware Lock Elision) see
21191 @ref{x86 specific memory model extensions for transactional memory} instead.
21192
21193 A memory transaction commits all changes to memory in an atomic way,
21194 as visible to other threads. If the transaction fails it is rolled back
21195 and all side effects discarded.
21196
21197 Generally there is no guarantee that a memory transaction ever succeeds
21198 and suitable fallback code always needs to be supplied.
21199
21200 @deftypefn {RTM Function} {unsigned} _xbegin ()
21201 Start a RTM (Restricted Transactional Memory) transaction.
21202 Returns @code{_XBEGIN_STARTED} when the transaction
21203 started successfully (note this is not 0, so the constant has to be
21204 explicitly tested).
21205
21206 If the transaction aborts, all side-effects
21207 are undone and an abort code encoded as a bit mask is returned.
21208 The following macros are defined:
21209
21210 @table @code
21211 @item _XABORT_EXPLICIT
21212 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
21213 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
21214 @item _XABORT_RETRY
21215 Transaction retry is possible.
21216 @item _XABORT_CONFLICT
21217 Transaction abort due to a memory conflict with another thread.
21218 @item _XABORT_CAPACITY
21219 Transaction abort due to the transaction using too much memory.
21220 @item _XABORT_DEBUG
21221 Transaction abort due to a debug trap.
21222 @item _XABORT_NESTED
21223 Transaction abort in an inner nested transaction.
21224 @end table
21225
21226 There is no guarantee
21227 any transaction ever succeeds, so there always needs to be a valid
21228 fallback path.
21229 @end deftypefn
21230
21231 @deftypefn {RTM Function} {void} _xend ()
21232 Commit the current transaction. When no transaction is active this faults.
21233 All memory side-effects of the transaction become visible
21234 to other threads in an atomic manner.
21235 @end deftypefn
21236
21237 @deftypefn {RTM Function} {int} _xtest ()
21238 Return a nonzero value if a transaction is currently active, otherwise 0.
21239 @end deftypefn
21240
21241 @deftypefn {RTM Function} {void} _xabort (status)
21242 Abort the current transaction. When no transaction is active this is a no-op.
21243 The @var{status} is an 8-bit constant; its value is encoded in the return
21244 value from @code{_xbegin}.
21245 @end deftypefn
21246
21247 Here is an example showing handling for @code{_XABORT_RETRY}
21248 and a fallback path for other failures:
21249
21250 @smallexample
21251 #include <immintrin.h>
21252
21253 int n_tries, max_tries;
21254 unsigned status = _XABORT_EXPLICIT;
21255 ...
21256
21257 for (n_tries = 0; n_tries < max_tries; n_tries++)
21258 @{
21259 status = _xbegin ();
21260 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
21261 break;
21262 @}
21263 if (status == _XBEGIN_STARTED)
21264 @{
21265 ... transaction code...
21266 _xend ();
21267 @}
21268 else
21269 @{
21270 ... non-transactional fallback path...
21271 @}
21272 @end smallexample
21273
21274 @noindent
21275 Note that, in most cases, the transactional and non-transactional code
21276 must synchronize together to ensure consistency.
21277
21278 @node Target Format Checks
21279 @section Format Checks Specific to Particular Target Machines
21280
21281 For some target machines, GCC supports additional options to the
21282 format attribute
21283 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
21284
21285 @menu
21286 * Solaris Format Checks::
21287 * Darwin Format Checks::
21288 @end menu
21289
21290 @node Solaris Format Checks
21291 @subsection Solaris Format Checks
21292
21293 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
21294 check. @code{cmn_err} accepts a subset of the standard @code{printf}
21295 conversions, and the two-argument @code{%b} conversion for displaying
21296 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
21297
21298 @node Darwin Format Checks
21299 @subsection Darwin Format Checks
21300
21301 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
21302 attribute context. Declarations made with such attribution are parsed for correct syntax
21303 and format argument types. However, parsing of the format string itself is currently undefined
21304 and is not carried out by this version of the compiler.
21305
21306 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
21307 also be used as format arguments. Note that the relevant headers are only likely to be
21308 available on Darwin (OSX) installations. On such installations, the XCode and system
21309 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
21310 associated functions.
21311
21312 @node Pragmas
21313 @section Pragmas Accepted by GCC
21314 @cindex pragmas
21315 @cindex @code{#pragma}
21316
21317 GCC supports several types of pragmas, primarily in order to compile
21318 code originally written for other compilers. Note that in general
21319 we do not recommend the use of pragmas; @xref{Function Attributes},
21320 for further explanation.
21321
21322 @menu
21323 * AArch64 Pragmas::
21324 * ARM Pragmas::
21325 * M32C Pragmas::
21326 * MeP Pragmas::
21327 * RS/6000 and PowerPC Pragmas::
21328 * S/390 Pragmas::
21329 * Darwin Pragmas::
21330 * Solaris Pragmas::
21331 * Symbol-Renaming Pragmas::
21332 * Structure-Layout Pragmas::
21333 * Weak Pragmas::
21334 * Diagnostic Pragmas::
21335 * Visibility Pragmas::
21336 * Push/Pop Macro Pragmas::
21337 * Function Specific Option Pragmas::
21338 * Loop-Specific Pragmas::
21339 @end menu
21340
21341 @node AArch64 Pragmas
21342 @subsection AArch64 Pragmas
21343
21344 The pragmas defined by the AArch64 target correspond to the AArch64
21345 target function attributes. They can be specified as below:
21346 @smallexample
21347 #pragma GCC target("string")
21348 @end smallexample
21349
21350 where @code{@var{string}} can be any string accepted as an AArch64 target
21351 attribute. @xref{AArch64 Function Attributes}, for more details
21352 on the permissible values of @code{string}.
21353
21354 @node ARM Pragmas
21355 @subsection ARM Pragmas
21356
21357 The ARM target defines pragmas for controlling the default addition of
21358 @code{long_call} and @code{short_call} attributes to functions.
21359 @xref{Function Attributes}, for information about the effects of these
21360 attributes.
21361
21362 @table @code
21363 @item long_calls
21364 @cindex pragma, long_calls
21365 Set all subsequent functions to have the @code{long_call} attribute.
21366
21367 @item no_long_calls
21368 @cindex pragma, no_long_calls
21369 Set all subsequent functions to have the @code{short_call} attribute.
21370
21371 @item long_calls_off
21372 @cindex pragma, long_calls_off
21373 Do not affect the @code{long_call} or @code{short_call} attributes of
21374 subsequent functions.
21375 @end table
21376
21377 @node M32C Pragmas
21378 @subsection M32C Pragmas
21379
21380 @table @code
21381 @item GCC memregs @var{number}
21382 @cindex pragma, memregs
21383 Overrides the command-line option @code{-memregs=} for the current
21384 file. Use with care! This pragma must be before any function in the
21385 file, and mixing different memregs values in different objects may
21386 make them incompatible. This pragma is useful when a
21387 performance-critical function uses a memreg for temporary values,
21388 as it may allow you to reduce the number of memregs used.
21389
21390 @item ADDRESS @var{name} @var{address}
21391 @cindex pragma, address
21392 For any declared symbols matching @var{name}, this does three things
21393 to that symbol: it forces the symbol to be located at the given
21394 address (a number), it forces the symbol to be volatile, and it
21395 changes the symbol's scope to be static. This pragma exists for
21396 compatibility with other compilers, but note that the common
21397 @code{1234H} numeric syntax is not supported (use @code{0x1234}
21398 instead). Example:
21399
21400 @smallexample
21401 #pragma ADDRESS port3 0x103
21402 char port3;
21403 @end smallexample
21404
21405 @end table
21406
21407 @node MeP Pragmas
21408 @subsection MeP Pragmas
21409
21410 @table @code
21411
21412 @item custom io_volatile (on|off)
21413 @cindex pragma, custom io_volatile
21414 Overrides the command-line option @code{-mio-volatile} for the current
21415 file. Note that for compatibility with future GCC releases, this
21416 option should only be used once before any @code{io} variables in each
21417 file.
21418
21419 @item GCC coprocessor available @var{registers}
21420 @cindex pragma, coprocessor available
21421 Specifies which coprocessor registers are available to the register
21422 allocator. @var{registers} may be a single register, register range
21423 separated by ellipses, or comma-separated list of those. Example:
21424
21425 @smallexample
21426 #pragma GCC coprocessor available $c0...$c10, $c28
21427 @end smallexample
21428
21429 @item GCC coprocessor call_saved @var{registers}
21430 @cindex pragma, coprocessor call_saved
21431 Specifies which coprocessor registers are to be saved and restored by
21432 any function using them. @var{registers} may be a single register,
21433 register range separated by ellipses, or comma-separated list of
21434 those. Example:
21435
21436 @smallexample
21437 #pragma GCC coprocessor call_saved $c4...$c6, $c31
21438 @end smallexample
21439
21440 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
21441 @cindex pragma, coprocessor subclass
21442 Creates and defines a register class. These register classes can be
21443 used by inline @code{asm} constructs. @var{registers} may be a single
21444 register, register range separated by ellipses, or comma-separated
21445 list of those. Example:
21446
21447 @smallexample
21448 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
21449
21450 asm ("cpfoo %0" : "=B" (x));
21451 @end smallexample
21452
21453 @item GCC disinterrupt @var{name} , @var{name} @dots{}
21454 @cindex pragma, disinterrupt
21455 For the named functions, the compiler adds code to disable interrupts
21456 for the duration of those functions. If any functions so named
21457 are not encountered in the source, a warning is emitted that the pragma is
21458 not used. Examples:
21459
21460 @smallexample
21461 #pragma disinterrupt foo
21462 #pragma disinterrupt bar, grill
21463 int foo () @{ @dots{} @}
21464 @end smallexample
21465
21466 @item GCC call @var{name} , @var{name} @dots{}
21467 @cindex pragma, call
21468 For the named functions, the compiler always uses a register-indirect
21469 call model when calling the named functions. Examples:
21470
21471 @smallexample
21472 extern int foo ();
21473 #pragma call foo
21474 @end smallexample
21475
21476 @end table
21477
21478 @node RS/6000 and PowerPC Pragmas
21479 @subsection RS/6000 and PowerPC Pragmas
21480
21481 The RS/6000 and PowerPC targets define one pragma for controlling
21482 whether or not the @code{longcall} attribute is added to function
21483 declarations by default. This pragma overrides the @option{-mlongcall}
21484 option, but not the @code{longcall} and @code{shortcall} attributes.
21485 @xref{RS/6000 and PowerPC Options}, for more information about when long
21486 calls are and are not necessary.
21487
21488 @table @code
21489 @item longcall (1)
21490 @cindex pragma, longcall
21491 Apply the @code{longcall} attribute to all subsequent function
21492 declarations.
21493
21494 @item longcall (0)
21495 Do not apply the @code{longcall} attribute to subsequent function
21496 declarations.
21497 @end table
21498
21499 @c Describe h8300 pragmas here.
21500 @c Describe sh pragmas here.
21501 @c Describe v850 pragmas here.
21502
21503 @node S/390 Pragmas
21504 @subsection S/390 Pragmas
21505
21506 The pragmas defined by the S/390 target correspond to the S/390
21507 target function attributes and some the additional options:
21508
21509 @table @samp
21510 @item zvector
21511 @itemx no-zvector
21512 @end table
21513
21514 Note that options of the pragma, unlike options of the target
21515 attribute, do change the value of preprocessor macros like
21516 @code{__VEC__}. They can be specified as below:
21517
21518 @smallexample
21519 #pragma GCC target("string[,string]...")
21520 #pragma GCC target("string"[,"string"]...)
21521 @end smallexample
21522
21523 @node Darwin Pragmas
21524 @subsection Darwin Pragmas
21525
21526 The following pragmas are available for all architectures running the
21527 Darwin operating system. These are useful for compatibility with other
21528 Mac OS compilers.
21529
21530 @table @code
21531 @item mark @var{tokens}@dots{}
21532 @cindex pragma, mark
21533 This pragma is accepted, but has no effect.
21534
21535 @item options align=@var{alignment}
21536 @cindex pragma, options align
21537 This pragma sets the alignment of fields in structures. The values of
21538 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
21539 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
21540 properly; to restore the previous setting, use @code{reset} for the
21541 @var{alignment}.
21542
21543 @item segment @var{tokens}@dots{}
21544 @cindex pragma, segment
21545 This pragma is accepted, but has no effect.
21546
21547 @item unused (@var{var} [, @var{var}]@dots{})
21548 @cindex pragma, unused
21549 This pragma declares variables to be possibly unused. GCC does not
21550 produce warnings for the listed variables. The effect is similar to
21551 that of the @code{unused} attribute, except that this pragma may appear
21552 anywhere within the variables' scopes.
21553 @end table
21554
21555 @node Solaris Pragmas
21556 @subsection Solaris Pragmas
21557
21558 The Solaris target supports @code{#pragma redefine_extname}
21559 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
21560 @code{#pragma} directives for compatibility with the system compiler.
21561
21562 @table @code
21563 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
21564 @cindex pragma, align
21565
21566 Increase the minimum alignment of each @var{variable} to @var{alignment}.
21567 This is the same as GCC's @code{aligned} attribute @pxref{Variable
21568 Attributes}). Macro expansion occurs on the arguments to this pragma
21569 when compiling C and Objective-C@. It does not currently occur when
21570 compiling C++, but this is a bug which may be fixed in a future
21571 release.
21572
21573 @item fini (@var{function} [, @var{function}]...)
21574 @cindex pragma, fini
21575
21576 This pragma causes each listed @var{function} to be called after
21577 main, or during shared module unloading, by adding a call to the
21578 @code{.fini} section.
21579
21580 @item init (@var{function} [, @var{function}]...)
21581 @cindex pragma, init
21582
21583 This pragma causes each listed @var{function} to be called during
21584 initialization (before @code{main}) or during shared module loading, by
21585 adding a call to the @code{.init} section.
21586
21587 @end table
21588
21589 @node Symbol-Renaming Pragmas
21590 @subsection Symbol-Renaming Pragmas
21591
21592 GCC supports a @code{#pragma} directive that changes the name used in
21593 assembly for a given declaration. While this pragma is supported on all
21594 platforms, it is intended primarily to provide compatibility with the
21595 Solaris system headers. This effect can also be achieved using the asm
21596 labels extension (@pxref{Asm Labels}).
21597
21598 @table @code
21599 @item redefine_extname @var{oldname} @var{newname}
21600 @cindex pragma, redefine_extname
21601
21602 This pragma gives the C function @var{oldname} the assembly symbol
21603 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
21604 is defined if this pragma is available (currently on all platforms).
21605 @end table
21606
21607 This pragma and the asm labels extension interact in a complicated
21608 manner. Here are some corner cases you may want to be aware of:
21609
21610 @enumerate
21611 @item This pragma silently applies only to declarations with external
21612 linkage. Asm labels do not have this restriction.
21613
21614 @item In C++, this pragma silently applies only to declarations with
21615 ``C'' linkage. Again, asm labels do not have this restriction.
21616
21617 @item If either of the ways of changing the assembly name of a
21618 declaration are applied to a declaration whose assembly name has
21619 already been determined (either by a previous use of one of these
21620 features, or because the compiler needed the assembly name in order to
21621 generate code), and the new name is different, a warning issues and
21622 the name does not change.
21623
21624 @item The @var{oldname} used by @code{#pragma redefine_extname} is
21625 always the C-language name.
21626 @end enumerate
21627
21628 @node Structure-Layout Pragmas
21629 @subsection Structure-Layout Pragmas
21630
21631 For compatibility with Microsoft Windows compilers, GCC supports a
21632 set of @code{#pragma} directives that change the maximum alignment of
21633 members of structures (other than zero-width bit-fields), unions, and
21634 classes subsequently defined. The @var{n} value below always is required
21635 to be a small power of two and specifies the new alignment in bytes.
21636
21637 @enumerate
21638 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
21639 @item @code{#pragma pack()} sets the alignment to the one that was in
21640 effect when compilation started (see also command-line option
21641 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
21642 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
21643 setting on an internal stack and then optionally sets the new alignment.
21644 @item @code{#pragma pack(pop)} restores the alignment setting to the one
21645 saved at the top of the internal stack (and removes that stack entry).
21646 Note that @code{#pragma pack([@var{n}])} does not influence this internal
21647 stack; thus it is possible to have @code{#pragma pack(push)} followed by
21648 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
21649 @code{#pragma pack(pop)}.
21650 @end enumerate
21651
21652 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
21653 directive which lays out structures and unions subsequently defined as the
21654 documented @code{__attribute__ ((ms_struct))}.
21655
21656 @enumerate
21657 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
21658 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
21659 @item @code{#pragma ms_struct reset} goes back to the default layout.
21660 @end enumerate
21661
21662 Most targets also support the @code{#pragma scalar_storage_order} directive
21663 which lays out structures and unions subsequently defined as the documented
21664 @code{__attribute__ ((scalar_storage_order))}.
21665
21666 @enumerate
21667 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
21668 of the scalar fields to big-endian.
21669 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
21670 of the scalar fields to little-endian.
21671 @item @code{#pragma scalar_storage_order default} goes back to the endianness
21672 that was in effect when compilation started (see also command-line option
21673 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
21674 @end enumerate
21675
21676 @node Weak Pragmas
21677 @subsection Weak Pragmas
21678
21679 For compatibility with SVR4, GCC supports a set of @code{#pragma}
21680 directives for declaring symbols to be weak, and defining weak
21681 aliases.
21682
21683 @table @code
21684 @item #pragma weak @var{symbol}
21685 @cindex pragma, weak
21686 This pragma declares @var{symbol} to be weak, as if the declaration
21687 had the attribute of the same name. The pragma may appear before
21688 or after the declaration of @var{symbol}. It is not an error for
21689 @var{symbol} to never be defined at all.
21690
21691 @item #pragma weak @var{symbol1} = @var{symbol2}
21692 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
21693 It is an error if @var{symbol2} is not defined in the current
21694 translation unit.
21695 @end table
21696
21697 @node Diagnostic Pragmas
21698 @subsection Diagnostic Pragmas
21699
21700 GCC allows the user to selectively enable or disable certain types of
21701 diagnostics, and change the kind of the diagnostic. For example, a
21702 project's policy might require that all sources compile with
21703 @option{-Werror} but certain files might have exceptions allowing
21704 specific types of warnings. Or, a project might selectively enable
21705 diagnostics and treat them as errors depending on which preprocessor
21706 macros are defined.
21707
21708 @table @code
21709 @item #pragma GCC diagnostic @var{kind} @var{option}
21710 @cindex pragma, diagnostic
21711
21712 Modifies the disposition of a diagnostic. Note that not all
21713 diagnostics are modifiable; at the moment only warnings (normally
21714 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
21715 Use @option{-fdiagnostics-show-option} to determine which diagnostics
21716 are controllable and which option controls them.
21717
21718 @var{kind} is @samp{error} to treat this diagnostic as an error,
21719 @samp{warning} to treat it like a warning (even if @option{-Werror} is
21720 in effect), or @samp{ignored} if the diagnostic is to be ignored.
21721 @var{option} is a double quoted string that matches the command-line
21722 option.
21723
21724 @smallexample
21725 #pragma GCC diagnostic warning "-Wformat"
21726 #pragma GCC diagnostic error "-Wformat"
21727 #pragma GCC diagnostic ignored "-Wformat"
21728 @end smallexample
21729
21730 Note that these pragmas override any command-line options. GCC keeps
21731 track of the location of each pragma, and issues diagnostics according
21732 to the state as of that point in the source file. Thus, pragmas occurring
21733 after a line do not affect diagnostics caused by that line.
21734
21735 @item #pragma GCC diagnostic push
21736 @itemx #pragma GCC diagnostic pop
21737
21738 Causes GCC to remember the state of the diagnostics as of each
21739 @code{push}, and restore to that point at each @code{pop}. If a
21740 @code{pop} has no matching @code{push}, the command-line options are
21741 restored.
21742
21743 @smallexample
21744 #pragma GCC diagnostic error "-Wuninitialized"
21745 foo(a); /* error is given for this one */
21746 #pragma GCC diagnostic push
21747 #pragma GCC diagnostic ignored "-Wuninitialized"
21748 foo(b); /* no diagnostic for this one */
21749 #pragma GCC diagnostic pop
21750 foo(c); /* error is given for this one */
21751 #pragma GCC diagnostic pop
21752 foo(d); /* depends on command-line options */
21753 @end smallexample
21754
21755 @end table
21756
21757 GCC also offers a simple mechanism for printing messages during
21758 compilation.
21759
21760 @table @code
21761 @item #pragma message @var{string}
21762 @cindex pragma, diagnostic
21763
21764 Prints @var{string} as a compiler message on compilation. The message
21765 is informational only, and is neither a compilation warning nor an error.
21766
21767 @smallexample
21768 #pragma message "Compiling " __FILE__ "..."
21769 @end smallexample
21770
21771 @var{string} may be parenthesized, and is printed with location
21772 information. For example,
21773
21774 @smallexample
21775 #define DO_PRAGMA(x) _Pragma (#x)
21776 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
21777
21778 TODO(Remember to fix this)
21779 @end smallexample
21780
21781 @noindent
21782 prints @samp{/tmp/file.c:4: note: #pragma message:
21783 TODO - Remember to fix this}.
21784
21785 @end table
21786
21787 @node Visibility Pragmas
21788 @subsection Visibility Pragmas
21789
21790 @table @code
21791 @item #pragma GCC visibility push(@var{visibility})
21792 @itemx #pragma GCC visibility pop
21793 @cindex pragma, visibility
21794
21795 This pragma allows the user to set the visibility for multiple
21796 declarations without having to give each a visibility attribute
21797 (@pxref{Function Attributes}).
21798
21799 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
21800 declarations. Class members and template specializations are not
21801 affected; if you want to override the visibility for a particular
21802 member or instantiation, you must use an attribute.
21803
21804 @end table
21805
21806
21807 @node Push/Pop Macro Pragmas
21808 @subsection Push/Pop Macro Pragmas
21809
21810 For compatibility with Microsoft Windows compilers, GCC supports
21811 @samp{#pragma push_macro(@var{"macro_name"})}
21812 and @samp{#pragma pop_macro(@var{"macro_name"})}.
21813
21814 @table @code
21815 @item #pragma push_macro(@var{"macro_name"})
21816 @cindex pragma, push_macro
21817 This pragma saves the value of the macro named as @var{macro_name} to
21818 the top of the stack for this macro.
21819
21820 @item #pragma pop_macro(@var{"macro_name"})
21821 @cindex pragma, pop_macro
21822 This pragma sets the value of the macro named as @var{macro_name} to
21823 the value on top of the stack for this macro. If the stack for
21824 @var{macro_name} is empty, the value of the macro remains unchanged.
21825 @end table
21826
21827 For example:
21828
21829 @smallexample
21830 #define X 1
21831 #pragma push_macro("X")
21832 #undef X
21833 #define X -1
21834 #pragma pop_macro("X")
21835 int x [X];
21836 @end smallexample
21837
21838 @noindent
21839 In this example, the definition of X as 1 is saved by @code{#pragma
21840 push_macro} and restored by @code{#pragma pop_macro}.
21841
21842 @node Function Specific Option Pragmas
21843 @subsection Function Specific Option Pragmas
21844
21845 @table @code
21846 @item #pragma GCC target (@var{"string"}...)
21847 @cindex pragma GCC target
21848
21849 This pragma allows you to set target specific options for functions
21850 defined later in the source file. One or more strings can be
21851 specified. Each function that is defined after this point is as
21852 if @code{attribute((target("STRING")))} was specified for that
21853 function. The parenthesis around the options is optional.
21854 @xref{Function Attributes}, for more information about the
21855 @code{target} attribute and the attribute syntax.
21856
21857 The @code{#pragma GCC target} pragma is presently implemented for
21858 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
21859 @end table
21860
21861 @table @code
21862 @item #pragma GCC optimize (@var{"string"}...)
21863 @cindex pragma GCC optimize
21864
21865 This pragma allows you to set global optimization options for functions
21866 defined later in the source file. One or more strings can be
21867 specified. Each function that is defined after this point is as
21868 if @code{attribute((optimize("STRING")))} was specified for that
21869 function. The parenthesis around the options is optional.
21870 @xref{Function Attributes}, for more information about the
21871 @code{optimize} attribute and the attribute syntax.
21872 @end table
21873
21874 @table @code
21875 @item #pragma GCC push_options
21876 @itemx #pragma GCC pop_options
21877 @cindex pragma GCC push_options
21878 @cindex pragma GCC pop_options
21879
21880 These pragmas maintain a stack of the current target and optimization
21881 options. It is intended for include files where you temporarily want
21882 to switch to using a different @samp{#pragma GCC target} or
21883 @samp{#pragma GCC optimize} and then to pop back to the previous
21884 options.
21885 @end table
21886
21887 @table @code
21888 @item #pragma GCC reset_options
21889 @cindex pragma GCC reset_options
21890
21891 This pragma clears the current @code{#pragma GCC target} and
21892 @code{#pragma GCC optimize} to use the default switches as specified
21893 on the command line.
21894 @end table
21895
21896 @node Loop-Specific Pragmas
21897 @subsection Loop-Specific Pragmas
21898
21899 @table @code
21900 @item #pragma GCC ivdep
21901 @cindex pragma GCC ivdep
21902 @end table
21903
21904 With this pragma, the programmer asserts that there are no loop-carried
21905 dependencies which would prevent consecutive iterations of
21906 the following loop from executing concurrently with SIMD
21907 (single instruction multiple data) instructions.
21908
21909 For example, the compiler can only unconditionally vectorize the following
21910 loop with the pragma:
21911
21912 @smallexample
21913 void foo (int n, int *a, int *b, int *c)
21914 @{
21915 int i, j;
21916 #pragma GCC ivdep
21917 for (i = 0; i < n; ++i)
21918 a[i] = b[i] + c[i];
21919 @}
21920 @end smallexample
21921
21922 @noindent
21923 In this example, using the @code{restrict} qualifier had the same
21924 effect. In the following example, that would not be possible. Assume
21925 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
21926 that it can unconditionally vectorize the following loop:
21927
21928 @smallexample
21929 void ignore_vec_dep (int *a, int k, int c, int m)
21930 @{
21931 #pragma GCC ivdep
21932 for (int i = 0; i < m; i++)
21933 a[i] = a[i + k] * c;
21934 @}
21935 @end smallexample
21936
21937
21938 @node Unnamed Fields
21939 @section Unnamed Structure and Union Fields
21940 @cindex @code{struct}
21941 @cindex @code{union}
21942
21943 As permitted by ISO C11 and for compatibility with other compilers,
21944 GCC allows you to define
21945 a structure or union that contains, as fields, structures and unions
21946 without names. For example:
21947
21948 @smallexample
21949 struct @{
21950 int a;
21951 union @{
21952 int b;
21953 float c;
21954 @};
21955 int d;
21956 @} foo;
21957 @end smallexample
21958
21959 @noindent
21960 In this example, you are able to access members of the unnamed
21961 union with code like @samp{foo.b}. Note that only unnamed structs and
21962 unions are allowed, you may not have, for example, an unnamed
21963 @code{int}.
21964
21965 You must never create such structures that cause ambiguous field definitions.
21966 For example, in this structure:
21967
21968 @smallexample
21969 struct @{
21970 int a;
21971 struct @{
21972 int a;
21973 @};
21974 @} foo;
21975 @end smallexample
21976
21977 @noindent
21978 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
21979 The compiler gives errors for such constructs.
21980
21981 @opindex fms-extensions
21982 Unless @option{-fms-extensions} is used, the unnamed field must be a
21983 structure or union definition without a tag (for example, @samp{struct
21984 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
21985 also be a definition with a tag such as @samp{struct foo @{ int a;
21986 @};}, a reference to a previously defined structure or union such as
21987 @samp{struct foo;}, or a reference to a @code{typedef} name for a
21988 previously defined structure or union type.
21989
21990 @opindex fplan9-extensions
21991 The option @option{-fplan9-extensions} enables
21992 @option{-fms-extensions} as well as two other extensions. First, a
21993 pointer to a structure is automatically converted to a pointer to an
21994 anonymous field for assignments and function calls. For example:
21995
21996 @smallexample
21997 struct s1 @{ int a; @};
21998 struct s2 @{ struct s1; @};
21999 extern void f1 (struct s1 *);
22000 void f2 (struct s2 *p) @{ f1 (p); @}
22001 @end smallexample
22002
22003 @noindent
22004 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
22005 converted into a pointer to the anonymous field.
22006
22007 Second, when the type of an anonymous field is a @code{typedef} for a
22008 @code{struct} or @code{union}, code may refer to the field using the
22009 name of the @code{typedef}.
22010
22011 @smallexample
22012 typedef struct @{ int a; @} s1;
22013 struct s2 @{ s1; @};
22014 s1 f1 (struct s2 *p) @{ return p->s1; @}
22015 @end smallexample
22016
22017 These usages are only permitted when they are not ambiguous.
22018
22019 @node Thread-Local
22020 @section Thread-Local Storage
22021 @cindex Thread-Local Storage
22022 @cindex @acronym{TLS}
22023 @cindex @code{__thread}
22024
22025 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
22026 are allocated such that there is one instance of the variable per extant
22027 thread. The runtime model GCC uses to implement this originates
22028 in the IA-64 processor-specific ABI, but has since been migrated
22029 to other processors as well. It requires significant support from
22030 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
22031 system libraries (@file{libc.so} and @file{libpthread.so}), so it
22032 is not available everywhere.
22033
22034 At the user level, the extension is visible with a new storage
22035 class keyword: @code{__thread}. For example:
22036
22037 @smallexample
22038 __thread int i;
22039 extern __thread struct state s;
22040 static __thread char *p;
22041 @end smallexample
22042
22043 The @code{__thread} specifier may be used alone, with the @code{extern}
22044 or @code{static} specifiers, but with no other storage class specifier.
22045 When used with @code{extern} or @code{static}, @code{__thread} must appear
22046 immediately after the other storage class specifier.
22047
22048 The @code{__thread} specifier may be applied to any global, file-scoped
22049 static, function-scoped static, or static data member of a class. It may
22050 not be applied to block-scoped automatic or non-static data member.
22051
22052 When the address-of operator is applied to a thread-local variable, it is
22053 evaluated at run time and returns the address of the current thread's
22054 instance of that variable. An address so obtained may be used by any
22055 thread. When a thread terminates, any pointers to thread-local variables
22056 in that thread become invalid.
22057
22058 No static initialization may refer to the address of a thread-local variable.
22059
22060 In C++, if an initializer is present for a thread-local variable, it must
22061 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
22062 standard.
22063
22064 See @uref{https://www.akkadia.org/drepper/tls.pdf,
22065 ELF Handling For Thread-Local Storage} for a detailed explanation of
22066 the four thread-local storage addressing models, and how the runtime
22067 is expected to function.
22068
22069 @menu
22070 * C99 Thread-Local Edits::
22071 * C++98 Thread-Local Edits::
22072 @end menu
22073
22074 @node C99 Thread-Local Edits
22075 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
22076
22077 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
22078 that document the exact semantics of the language extension.
22079
22080 @itemize @bullet
22081 @item
22082 @cite{5.1.2 Execution environments}
22083
22084 Add new text after paragraph 1
22085
22086 @quotation
22087 Within either execution environment, a @dfn{thread} is a flow of
22088 control within a program. It is implementation defined whether
22089 or not there may be more than one thread associated with a program.
22090 It is implementation defined how threads beyond the first are
22091 created, the name and type of the function called at thread
22092 startup, and how threads may be terminated. However, objects
22093 with thread storage duration shall be initialized before thread
22094 startup.
22095 @end quotation
22096
22097 @item
22098 @cite{6.2.4 Storage durations of objects}
22099
22100 Add new text before paragraph 3
22101
22102 @quotation
22103 An object whose identifier is declared with the storage-class
22104 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
22105 Its lifetime is the entire execution of the thread, and its
22106 stored value is initialized only once, prior to thread startup.
22107 @end quotation
22108
22109 @item
22110 @cite{6.4.1 Keywords}
22111
22112 Add @code{__thread}.
22113
22114 @item
22115 @cite{6.7.1 Storage-class specifiers}
22116
22117 Add @code{__thread} to the list of storage class specifiers in
22118 paragraph 1.
22119
22120 Change paragraph 2 to
22121
22122 @quotation
22123 With the exception of @code{__thread}, at most one storage-class
22124 specifier may be given [@dots{}]. The @code{__thread} specifier may
22125 be used alone, or immediately following @code{extern} or
22126 @code{static}.
22127 @end quotation
22128
22129 Add new text after paragraph 6
22130
22131 @quotation
22132 The declaration of an identifier for a variable that has
22133 block scope that specifies @code{__thread} shall also
22134 specify either @code{extern} or @code{static}.
22135
22136 The @code{__thread} specifier shall be used only with
22137 variables.
22138 @end quotation
22139 @end itemize
22140
22141 @node C++98 Thread-Local Edits
22142 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
22143
22144 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
22145 that document the exact semantics of the language extension.
22146
22147 @itemize @bullet
22148 @item
22149 @b{[intro.execution]}
22150
22151 New text after paragraph 4
22152
22153 @quotation
22154 A @dfn{thread} is a flow of control within the abstract machine.
22155 It is implementation defined whether or not there may be more than
22156 one thread.
22157 @end quotation
22158
22159 New text after paragraph 7
22160
22161 @quotation
22162 It is unspecified whether additional action must be taken to
22163 ensure when and whether side effects are visible to other threads.
22164 @end quotation
22165
22166 @item
22167 @b{[lex.key]}
22168
22169 Add @code{__thread}.
22170
22171 @item
22172 @b{[basic.start.main]}
22173
22174 Add after paragraph 5
22175
22176 @quotation
22177 The thread that begins execution at the @code{main} function is called
22178 the @dfn{main thread}. It is implementation defined how functions
22179 beginning threads other than the main thread are designated or typed.
22180 A function so designated, as well as the @code{main} function, is called
22181 a @dfn{thread startup function}. It is implementation defined what
22182 happens if a thread startup function returns. It is implementation
22183 defined what happens to other threads when any thread calls @code{exit}.
22184 @end quotation
22185
22186 @item
22187 @b{[basic.start.init]}
22188
22189 Add after paragraph 4
22190
22191 @quotation
22192 The storage for an object of thread storage duration shall be
22193 statically initialized before the first statement of the thread startup
22194 function. An object of thread storage duration shall not require
22195 dynamic initialization.
22196 @end quotation
22197
22198 @item
22199 @b{[basic.start.term]}
22200
22201 Add after paragraph 3
22202
22203 @quotation
22204 The type of an object with thread storage duration shall not have a
22205 non-trivial destructor, nor shall it be an array type whose elements
22206 (directly or indirectly) have non-trivial destructors.
22207 @end quotation
22208
22209 @item
22210 @b{[basic.stc]}
22211
22212 Add ``thread storage duration'' to the list in paragraph 1.
22213
22214 Change paragraph 2
22215
22216 @quotation
22217 Thread, static, and automatic storage durations are associated with
22218 objects introduced by declarations [@dots{}].
22219 @end quotation
22220
22221 Add @code{__thread} to the list of specifiers in paragraph 3.
22222
22223 @item
22224 @b{[basic.stc.thread]}
22225
22226 New section before @b{[basic.stc.static]}
22227
22228 @quotation
22229 The keyword @code{__thread} applied to a non-local object gives the
22230 object thread storage duration.
22231
22232 A local variable or class data member declared both @code{static}
22233 and @code{__thread} gives the variable or member thread storage
22234 duration.
22235 @end quotation
22236
22237 @item
22238 @b{[basic.stc.static]}
22239
22240 Change paragraph 1
22241
22242 @quotation
22243 All objects that have neither thread storage duration, dynamic
22244 storage duration nor are local [@dots{}].
22245 @end quotation
22246
22247 @item
22248 @b{[dcl.stc]}
22249
22250 Add @code{__thread} to the list in paragraph 1.
22251
22252 Change paragraph 1
22253
22254 @quotation
22255 With the exception of @code{__thread}, at most one
22256 @var{storage-class-specifier} shall appear in a given
22257 @var{decl-specifier-seq}. The @code{__thread} specifier may
22258 be used alone, or immediately following the @code{extern} or
22259 @code{static} specifiers. [@dots{}]
22260 @end quotation
22261
22262 Add after paragraph 5
22263
22264 @quotation
22265 The @code{__thread} specifier can be applied only to the names of objects
22266 and to anonymous unions.
22267 @end quotation
22268
22269 @item
22270 @b{[class.mem]}
22271
22272 Add after paragraph 6
22273
22274 @quotation
22275 Non-@code{static} members shall not be @code{__thread}.
22276 @end quotation
22277 @end itemize
22278
22279 @node Binary constants
22280 @section Binary Constants using the @samp{0b} Prefix
22281 @cindex Binary constants using the @samp{0b} prefix
22282
22283 Integer constants can be written as binary constants, consisting of a
22284 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
22285 @samp{0B}. This is particularly useful in environments that operate a
22286 lot on the bit level (like microcontrollers).
22287
22288 The following statements are identical:
22289
22290 @smallexample
22291 i = 42;
22292 i = 0x2a;
22293 i = 052;
22294 i = 0b101010;
22295 @end smallexample
22296
22297 The type of these constants follows the same rules as for octal or
22298 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
22299 can be applied.
22300
22301 @node C++ Extensions
22302 @chapter Extensions to the C++ Language
22303 @cindex extensions, C++ language
22304 @cindex C++ language extensions
22305
22306 The GNU compiler provides these extensions to the C++ language (and you
22307 can also use most of the C language extensions in your C++ programs). If you
22308 want to write code that checks whether these features are available, you can
22309 test for the GNU compiler the same way as for C programs: check for a
22310 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
22311 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
22312 Predefined Macros,cpp,The GNU C Preprocessor}).
22313
22314 @menu
22315 * C++ Volatiles:: What constitutes an access to a volatile object.
22316 * Restricted Pointers:: C99 restricted pointers and references.
22317 * Vague Linkage:: Where G++ puts inlines, vtables and such.
22318 * C++ Interface:: You can use a single C++ header file for both
22319 declarations and definitions.
22320 * Template Instantiation:: Methods for ensuring that exactly one copy of
22321 each needed template instantiation is emitted.
22322 * Bound member functions:: You can extract a function pointer to the
22323 method denoted by a @samp{->*} or @samp{.*} expression.
22324 * C++ Attributes:: Variable, function, and type attributes for C++ only.
22325 * Function Multiversioning:: Declaring multiple function versions.
22326 * Type Traits:: Compiler support for type traits.
22327 * C++ Concepts:: Improved support for generic programming.
22328 * Deprecated Features:: Things will disappear from G++.
22329 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
22330 @end menu
22331
22332 @node C++ Volatiles
22333 @section When is a Volatile C++ Object Accessed?
22334 @cindex accessing volatiles
22335 @cindex volatile read
22336 @cindex volatile write
22337 @cindex volatile access
22338
22339 The C++ standard differs from the C standard in its treatment of
22340 volatile objects. It fails to specify what constitutes a volatile
22341 access, except to say that C++ should behave in a similar manner to C
22342 with respect to volatiles, where possible. However, the different
22343 lvalueness of expressions between C and C++ complicate the behavior.
22344 G++ behaves the same as GCC for volatile access, @xref{C
22345 Extensions,,Volatiles}, for a description of GCC's behavior.
22346
22347 The C and C++ language specifications differ when an object is
22348 accessed in a void context:
22349
22350 @smallexample
22351 volatile int *src = @var{somevalue};
22352 *src;
22353 @end smallexample
22354
22355 The C++ standard specifies that such expressions do not undergo lvalue
22356 to rvalue conversion, and that the type of the dereferenced object may
22357 be incomplete. The C++ standard does not specify explicitly that it
22358 is lvalue to rvalue conversion that is responsible for causing an
22359 access. There is reason to believe that it is, because otherwise
22360 certain simple expressions become undefined. However, because it
22361 would surprise most programmers, G++ treats dereferencing a pointer to
22362 volatile object of complete type as GCC would do for an equivalent
22363 type in C@. When the object has incomplete type, G++ issues a
22364 warning; if you wish to force an error, you must force a conversion to
22365 rvalue with, for instance, a static cast.
22366
22367 When using a reference to volatile, G++ does not treat equivalent
22368 expressions as accesses to volatiles, but instead issues a warning that
22369 no volatile is accessed. The rationale for this is that otherwise it
22370 becomes difficult to determine where volatile access occur, and not
22371 possible to ignore the return value from functions returning volatile
22372 references. Again, if you wish to force a read, cast the reference to
22373 an rvalue.
22374
22375 G++ implements the same behavior as GCC does when assigning to a
22376 volatile object---there is no reread of the assigned-to object, the
22377 assigned rvalue is reused. Note that in C++ assignment expressions
22378 are lvalues, and if used as an lvalue, the volatile object is
22379 referred to. For instance, @var{vref} refers to @var{vobj}, as
22380 expected, in the following example:
22381
22382 @smallexample
22383 volatile int vobj;
22384 volatile int &vref = vobj = @var{something};
22385 @end smallexample
22386
22387 @node Restricted Pointers
22388 @section Restricting Pointer Aliasing
22389 @cindex restricted pointers
22390 @cindex restricted references
22391 @cindex restricted this pointer
22392
22393 As with the C front end, G++ understands the C99 feature of restricted pointers,
22394 specified with the @code{__restrict__}, or @code{__restrict} type
22395 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
22396 language flag, @code{restrict} is not a keyword in C++.
22397
22398 In addition to allowing restricted pointers, you can specify restricted
22399 references, which indicate that the reference is not aliased in the local
22400 context.
22401
22402 @smallexample
22403 void fn (int *__restrict__ rptr, int &__restrict__ rref)
22404 @{
22405 /* @r{@dots{}} */
22406 @}
22407 @end smallexample
22408
22409 @noindent
22410 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
22411 @var{rref} refers to a (different) unaliased integer.
22412
22413 You may also specify whether a member function's @var{this} pointer is
22414 unaliased by using @code{__restrict__} as a member function qualifier.
22415
22416 @smallexample
22417 void T::fn () __restrict__
22418 @{
22419 /* @r{@dots{}} */
22420 @}
22421 @end smallexample
22422
22423 @noindent
22424 Within the body of @code{T::fn}, @var{this} has the effective
22425 definition @code{T *__restrict__ const this}. Notice that the
22426 interpretation of a @code{__restrict__} member function qualifier is
22427 different to that of @code{const} or @code{volatile} qualifier, in that it
22428 is applied to the pointer rather than the object. This is consistent with
22429 other compilers that implement restricted pointers.
22430
22431 As with all outermost parameter qualifiers, @code{__restrict__} is
22432 ignored in function definition matching. This means you only need to
22433 specify @code{__restrict__} in a function definition, rather than
22434 in a function prototype as well.
22435
22436 @node Vague Linkage
22437 @section Vague Linkage
22438 @cindex vague linkage
22439
22440 There are several constructs in C++ that require space in the object
22441 file but are not clearly tied to a single translation unit. We say that
22442 these constructs have ``vague linkage''. Typically such constructs are
22443 emitted wherever they are needed, though sometimes we can be more
22444 clever.
22445
22446 @table @asis
22447 @item Inline Functions
22448 Inline functions are typically defined in a header file which can be
22449 included in many different compilations. Hopefully they can usually be
22450 inlined, but sometimes an out-of-line copy is necessary, if the address
22451 of the function is taken or if inlining fails. In general, we emit an
22452 out-of-line copy in all translation units where one is needed. As an
22453 exception, we only emit inline virtual functions with the vtable, since
22454 it always requires a copy.
22455
22456 Local static variables and string constants used in an inline function
22457 are also considered to have vague linkage, since they must be shared
22458 between all inlined and out-of-line instances of the function.
22459
22460 @item VTables
22461 @cindex vtable
22462 C++ virtual functions are implemented in most compilers using a lookup
22463 table, known as a vtable. The vtable contains pointers to the virtual
22464 functions provided by a class, and each object of the class contains a
22465 pointer to its vtable (or vtables, in some multiple-inheritance
22466 situations). If the class declares any non-inline, non-pure virtual
22467 functions, the first one is chosen as the ``key method'' for the class,
22468 and the vtable is only emitted in the translation unit where the key
22469 method is defined.
22470
22471 @emph{Note:} If the chosen key method is later defined as inline, the
22472 vtable is still emitted in every translation unit that defines it.
22473 Make sure that any inline virtuals are declared inline in the class
22474 body, even if they are not defined there.
22475
22476 @item @code{type_info} objects
22477 @cindex @code{type_info}
22478 @cindex RTTI
22479 C++ requires information about types to be written out in order to
22480 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
22481 For polymorphic classes (classes with virtual functions), the @samp{type_info}
22482 object is written out along with the vtable so that @samp{dynamic_cast}
22483 can determine the dynamic type of a class object at run time. For all
22484 other types, we write out the @samp{type_info} object when it is used: when
22485 applying @samp{typeid} to an expression, throwing an object, or
22486 referring to a type in a catch clause or exception specification.
22487
22488 @item Template Instantiations
22489 Most everything in this section also applies to template instantiations,
22490 but there are other options as well.
22491 @xref{Template Instantiation,,Where's the Template?}.
22492
22493 @end table
22494
22495 When used with GNU ld version 2.8 or later on an ELF system such as
22496 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
22497 these constructs will be discarded at link time. This is known as
22498 COMDAT support.
22499
22500 On targets that don't support COMDAT, but do support weak symbols, GCC
22501 uses them. This way one copy overrides all the others, but
22502 the unused copies still take up space in the executable.
22503
22504 For targets that do not support either COMDAT or weak symbols,
22505 most entities with vague linkage are emitted as local symbols to
22506 avoid duplicate definition errors from the linker. This does not happen
22507 for local statics in inlines, however, as having multiple copies
22508 almost certainly breaks things.
22509
22510 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
22511 another way to control placement of these constructs.
22512
22513 @node C++ Interface
22514 @section C++ Interface and Implementation Pragmas
22515
22516 @cindex interface and implementation headers, C++
22517 @cindex C++ interface and implementation headers
22518 @cindex pragmas, interface and implementation
22519
22520 @code{#pragma interface} and @code{#pragma implementation} provide the
22521 user with a way of explicitly directing the compiler to emit entities
22522 with vague linkage (and debugging information) in a particular
22523 translation unit.
22524
22525 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
22526 by COMDAT support and the ``key method'' heuristic
22527 mentioned in @ref{Vague Linkage}. Using them can actually cause your
22528 program to grow due to unnecessary out-of-line copies of inline
22529 functions.
22530
22531 @table @code
22532 @item #pragma interface
22533 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
22534 @kindex #pragma interface
22535 Use this directive in @emph{header files} that define object classes, to save
22536 space in most of the object files that use those classes. Normally,
22537 local copies of certain information (backup copies of inline member
22538 functions, debugging information, and the internal tables that implement
22539 virtual functions) must be kept in each object file that includes class
22540 definitions. You can use this pragma to avoid such duplication. When a
22541 header file containing @samp{#pragma interface} is included in a
22542 compilation, this auxiliary information is not generated (unless
22543 the main input source file itself uses @samp{#pragma implementation}).
22544 Instead, the object files contain references to be resolved at link
22545 time.
22546
22547 The second form of this directive is useful for the case where you have
22548 multiple headers with the same name in different directories. If you
22549 use this form, you must specify the same string to @samp{#pragma
22550 implementation}.
22551
22552 @item #pragma implementation
22553 @itemx #pragma implementation "@var{objects}.h"
22554 @kindex #pragma implementation
22555 Use this pragma in a @emph{main input file}, when you want full output from
22556 included header files to be generated (and made globally visible). The
22557 included header file, in turn, should use @samp{#pragma interface}.
22558 Backup copies of inline member functions, debugging information, and the
22559 internal tables used to implement virtual functions are all generated in
22560 implementation files.
22561
22562 @cindex implied @code{#pragma implementation}
22563 @cindex @code{#pragma implementation}, implied
22564 @cindex naming convention, implementation headers
22565 If you use @samp{#pragma implementation} with no argument, it applies to
22566 an include file with the same basename@footnote{A file's @dfn{basename}
22567 is the name stripped of all leading path information and of trailing
22568 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
22569 file. For example, in @file{allclass.cc}, giving just
22570 @samp{#pragma implementation}
22571 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
22572
22573 Use the string argument if you want a single implementation file to
22574 include code from multiple header files. (You must also use
22575 @samp{#include} to include the header file; @samp{#pragma
22576 implementation} only specifies how to use the file---it doesn't actually
22577 include it.)
22578
22579 There is no way to split up the contents of a single header file into
22580 multiple implementation files.
22581 @end table
22582
22583 @cindex inlining and C++ pragmas
22584 @cindex C++ pragmas, effect on inlining
22585 @cindex pragmas in C++, effect on inlining
22586 @samp{#pragma implementation} and @samp{#pragma interface} also have an
22587 effect on function inlining.
22588
22589 If you define a class in a header file marked with @samp{#pragma
22590 interface}, the effect on an inline function defined in that class is
22591 similar to an explicit @code{extern} declaration---the compiler emits
22592 no code at all to define an independent version of the function. Its
22593 definition is used only for inlining with its callers.
22594
22595 @opindex fno-implement-inlines
22596 Conversely, when you include the same header file in a main source file
22597 that declares it as @samp{#pragma implementation}, the compiler emits
22598 code for the function itself; this defines a version of the function
22599 that can be found via pointers (or by callers compiled without
22600 inlining). If all calls to the function can be inlined, you can avoid
22601 emitting the function by compiling with @option{-fno-implement-inlines}.
22602 If any calls are not inlined, you will get linker errors.
22603
22604 @node Template Instantiation
22605 @section Where's the Template?
22606 @cindex template instantiation
22607
22608 C++ templates were the first language feature to require more
22609 intelligence from the environment than was traditionally found on a UNIX
22610 system. Somehow the compiler and linker have to make sure that each
22611 template instance occurs exactly once in the executable if it is needed,
22612 and not at all otherwise. There are two basic approaches to this
22613 problem, which are referred to as the Borland model and the Cfront model.
22614
22615 @table @asis
22616 @item Borland model
22617 Borland C++ solved the template instantiation problem by adding the code
22618 equivalent of common blocks to their linker; the compiler emits template
22619 instances in each translation unit that uses them, and the linker
22620 collapses them together. The advantage of this model is that the linker
22621 only has to consider the object files themselves; there is no external
22622 complexity to worry about. The disadvantage is that compilation time
22623 is increased because the template code is being compiled repeatedly.
22624 Code written for this model tends to include definitions of all
22625 templates in the header file, since they must be seen to be
22626 instantiated.
22627
22628 @item Cfront model
22629 The AT&T C++ translator, Cfront, solved the template instantiation
22630 problem by creating the notion of a template repository, an
22631 automatically maintained place where template instances are stored. A
22632 more modern version of the repository works as follows: As individual
22633 object files are built, the compiler places any template definitions and
22634 instantiations encountered in the repository. At link time, the link
22635 wrapper adds in the objects in the repository and compiles any needed
22636 instances that were not previously emitted. The advantages of this
22637 model are more optimal compilation speed and the ability to use the
22638 system linker; to implement the Borland model a compiler vendor also
22639 needs to replace the linker. The disadvantages are vastly increased
22640 complexity, and thus potential for error; for some code this can be
22641 just as transparent, but in practice it can been very difficult to build
22642 multiple programs in one directory and one program in multiple
22643 directories. Code written for this model tends to separate definitions
22644 of non-inline member templates into a separate file, which should be
22645 compiled separately.
22646 @end table
22647
22648 G++ implements the Borland model on targets where the linker supports it,
22649 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
22650 Otherwise G++ implements neither automatic model.
22651
22652 You have the following options for dealing with template instantiations:
22653
22654 @enumerate
22655 @item
22656 Do nothing. Code written for the Borland model works fine, but
22657 each translation unit contains instances of each of the templates it
22658 uses. The duplicate instances will be discarded by the linker, but in
22659 a large program, this can lead to an unacceptable amount of code
22660 duplication in object files or shared libraries.
22661
22662 Duplicate instances of a template can be avoided by defining an explicit
22663 instantiation in one object file, and preventing the compiler from doing
22664 implicit instantiations in any other object files by using an explicit
22665 instantiation declaration, using the @code{extern template} syntax:
22666
22667 @smallexample
22668 extern template int max (int, int);
22669 @end smallexample
22670
22671 This syntax is defined in the C++ 2011 standard, but has been supported by
22672 G++ and other compilers since well before 2011.
22673
22674 Explicit instantiations can be used for the largest or most frequently
22675 duplicated instances, without having to know exactly which other instances
22676 are used in the rest of the program. You can scatter the explicit
22677 instantiations throughout your program, perhaps putting them in the
22678 translation units where the instances are used or the translation units
22679 that define the templates themselves; you can put all of the explicit
22680 instantiations you need into one big file; or you can create small files
22681 like
22682
22683 @smallexample
22684 #include "Foo.h"
22685 #include "Foo.cc"
22686
22687 template class Foo<int>;
22688 template ostream& operator <<
22689 (ostream&, const Foo<int>&);
22690 @end smallexample
22691
22692 @noindent
22693 for each of the instances you need, and create a template instantiation
22694 library from those.
22695
22696 This is the simplest option, but also offers flexibility and
22697 fine-grained control when necessary. It is also the most portable
22698 alternative and programs using this approach will work with most modern
22699 compilers.
22700
22701 @item
22702 @opindex frepo
22703 Compile your template-using code with @option{-frepo}. The compiler
22704 generates files with the extension @samp{.rpo} listing all of the
22705 template instantiations used in the corresponding object files that
22706 could be instantiated there; the link wrapper, @samp{collect2},
22707 then updates the @samp{.rpo} files to tell the compiler where to place
22708 those instantiations and rebuild any affected object files. The
22709 link-time overhead is negligible after the first pass, as the compiler
22710 continues to place the instantiations in the same files.
22711
22712 This can be a suitable option for application code written for the Borland
22713 model, as it usually just works. Code written for the Cfront model
22714 needs to be modified so that the template definitions are available at
22715 one or more points of instantiation; usually this is as simple as adding
22716 @code{#include <tmethods.cc>} to the end of each template header.
22717
22718 For library code, if you want the library to provide all of the template
22719 instantiations it needs, just try to link all of its object files
22720 together; the link will fail, but cause the instantiations to be
22721 generated as a side effect. Be warned, however, that this may cause
22722 conflicts if multiple libraries try to provide the same instantiations.
22723 For greater control, use explicit instantiation as described in the next
22724 option.
22725
22726 @item
22727 @opindex fno-implicit-templates
22728 Compile your code with @option{-fno-implicit-templates} to disable the
22729 implicit generation of template instances, and explicitly instantiate
22730 all the ones you use. This approach requires more knowledge of exactly
22731 which instances you need than do the others, but it's less
22732 mysterious and allows greater control if you want to ensure that only
22733 the intended instances are used.
22734
22735 If you are using Cfront-model code, you can probably get away with not
22736 using @option{-fno-implicit-templates} when compiling files that don't
22737 @samp{#include} the member template definitions.
22738
22739 If you use one big file to do the instantiations, you may want to
22740 compile it without @option{-fno-implicit-templates} so you get all of the
22741 instances required by your explicit instantiations (but not by any
22742 other files) without having to specify them as well.
22743
22744 In addition to forward declaration of explicit instantiations
22745 (with @code{extern}), G++ has extended the template instantiation
22746 syntax to support instantiation of the compiler support data for a
22747 template class (i.e.@: the vtable) without instantiating any of its
22748 members (with @code{inline}), and instantiation of only the static data
22749 members of a template class, without the support data or member
22750 functions (with @code{static}):
22751
22752 @smallexample
22753 inline template class Foo<int>;
22754 static template class Foo<int>;
22755 @end smallexample
22756 @end enumerate
22757
22758 @node Bound member functions
22759 @section Extracting the Function Pointer from a Bound Pointer to Member Function
22760 @cindex pmf
22761 @cindex pointer to member function
22762 @cindex bound pointer to member function
22763
22764 In C++, pointer to member functions (PMFs) are implemented using a wide
22765 pointer of sorts to handle all the possible call mechanisms; the PMF
22766 needs to store information about how to adjust the @samp{this} pointer,
22767 and if the function pointed to is virtual, where to find the vtable, and
22768 where in the vtable to look for the member function. If you are using
22769 PMFs in an inner loop, you should really reconsider that decision. If
22770 that is not an option, you can extract the pointer to the function that
22771 would be called for a given object/PMF pair and call it directly inside
22772 the inner loop, to save a bit of time.
22773
22774 Note that you still pay the penalty for the call through a
22775 function pointer; on most modern architectures, such a call defeats the
22776 branch prediction features of the CPU@. This is also true of normal
22777 virtual function calls.
22778
22779 The syntax for this extension is
22780
22781 @smallexample
22782 extern A a;
22783 extern int (A::*fp)();
22784 typedef int (*fptr)(A *);
22785
22786 fptr p = (fptr)(a.*fp);
22787 @end smallexample
22788
22789 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
22790 no object is needed to obtain the address of the function. They can be
22791 converted to function pointers directly:
22792
22793 @smallexample
22794 fptr p1 = (fptr)(&A::foo);
22795 @end smallexample
22796
22797 @opindex Wno-pmf-conversions
22798 You must specify @option{-Wno-pmf-conversions} to use this extension.
22799
22800 @node C++ Attributes
22801 @section C++-Specific Variable, Function, and Type Attributes
22802
22803 Some attributes only make sense for C++ programs.
22804
22805 @table @code
22806 @item abi_tag ("@var{tag}", ...)
22807 @cindex @code{abi_tag} function attribute
22808 @cindex @code{abi_tag} variable attribute
22809 @cindex @code{abi_tag} type attribute
22810 The @code{abi_tag} attribute can be applied to a function, variable, or class
22811 declaration. It modifies the mangled name of the entity to
22812 incorporate the tag name, in order to distinguish the function or
22813 class from an earlier version with a different ABI; perhaps the class
22814 has changed size, or the function has a different return type that is
22815 not encoded in the mangled name.
22816
22817 The attribute can also be applied to an inline namespace, but does not
22818 affect the mangled name of the namespace; in this case it is only used
22819 for @option{-Wabi-tag} warnings and automatic tagging of functions and
22820 variables. Tagging inline namespaces is generally preferable to
22821 tagging individual declarations, but the latter is sometimes
22822 necessary, such as when only certain members of a class need to be
22823 tagged.
22824
22825 The argument can be a list of strings of arbitrary length. The
22826 strings are sorted on output, so the order of the list is
22827 unimportant.
22828
22829 A redeclaration of an entity must not add new ABI tags,
22830 since doing so would change the mangled name.
22831
22832 The ABI tags apply to a name, so all instantiations and
22833 specializations of a template have the same tags. The attribute will
22834 be ignored if applied to an explicit specialization or instantiation.
22835
22836 The @option{-Wabi-tag} flag enables a warning about a class which does
22837 not have all the ABI tags used by its subobjects and virtual functions; for users with code
22838 that needs to coexist with an earlier ABI, using this option can help
22839 to find all affected types that need to be tagged.
22840
22841 When a type involving an ABI tag is used as the type of a variable or
22842 return type of a function where that tag is not already present in the
22843 signature of the function, the tag is automatically applied to the
22844 variable or function. @option{-Wabi-tag} also warns about this
22845 situation; this warning can be avoided by explicitly tagging the
22846 variable or function or moving it into a tagged inline namespace.
22847
22848 @item init_priority (@var{priority})
22849 @cindex @code{init_priority} variable attribute
22850
22851 In Standard C++, objects defined at namespace scope are guaranteed to be
22852 initialized in an order in strict accordance with that of their definitions
22853 @emph{in a given translation unit}. No guarantee is made for initializations
22854 across translation units. However, GNU C++ allows users to control the
22855 order of initialization of objects defined at namespace scope with the
22856 @code{init_priority} attribute by specifying a relative @var{priority},
22857 a constant integral expression currently bounded between 101 and 65535
22858 inclusive. Lower numbers indicate a higher priority.
22859
22860 In the following example, @code{A} would normally be created before
22861 @code{B}, but the @code{init_priority} attribute reverses that order:
22862
22863 @smallexample
22864 Some_Class A __attribute__ ((init_priority (2000)));
22865 Some_Class B __attribute__ ((init_priority (543)));
22866 @end smallexample
22867
22868 @noindent
22869 Note that the particular values of @var{priority} do not matter; only their
22870 relative ordering.
22871
22872 @item warn_unused
22873 @cindex @code{warn_unused} type attribute
22874
22875 For C++ types with non-trivial constructors and/or destructors it is
22876 impossible for the compiler to determine whether a variable of this
22877 type is truly unused if it is not referenced. This type attribute
22878 informs the compiler that variables of this type should be warned
22879 about if they appear to be unused, just like variables of fundamental
22880 types.
22881
22882 This attribute is appropriate for types which just represent a value,
22883 such as @code{std::string}; it is not appropriate for types which
22884 control a resource, such as @code{std::lock_guard}.
22885
22886 This attribute is also accepted in C, but it is unnecessary because C
22887 does not have constructors or destructors.
22888
22889 @end table
22890
22891 @node Function Multiversioning
22892 @section Function Multiversioning
22893 @cindex function versions
22894
22895 With the GNU C++ front end, for x86 targets, you may specify multiple
22896 versions of a function, where each function is specialized for a
22897 specific target feature. At runtime, the appropriate version of the
22898 function is automatically executed depending on the characteristics of
22899 the execution platform. Here is an example.
22900
22901 @smallexample
22902 __attribute__ ((target ("default")))
22903 int foo ()
22904 @{
22905 // The default version of foo.
22906 return 0;
22907 @}
22908
22909 __attribute__ ((target ("sse4.2")))
22910 int foo ()
22911 @{
22912 // foo version for SSE4.2
22913 return 1;
22914 @}
22915
22916 __attribute__ ((target ("arch=atom")))
22917 int foo ()
22918 @{
22919 // foo version for the Intel ATOM processor
22920 return 2;
22921 @}
22922
22923 __attribute__ ((target ("arch=amdfam10")))
22924 int foo ()
22925 @{
22926 // foo version for the AMD Family 0x10 processors.
22927 return 3;
22928 @}
22929
22930 int main ()
22931 @{
22932 int (*p)() = &foo;
22933 assert ((*p) () == foo ());
22934 return 0;
22935 @}
22936 @end smallexample
22937
22938 In the above example, four versions of function foo are created. The
22939 first version of foo with the target attribute "default" is the default
22940 version. This version gets executed when no other target specific
22941 version qualifies for execution on a particular platform. A new version
22942 of foo is created by using the same function signature but with a
22943 different target string. Function foo is called or a pointer to it is
22944 taken just like a regular function. GCC takes care of doing the
22945 dispatching to call the right version at runtime. Refer to the
22946 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
22947 Function Multiversioning} for more details.
22948
22949 @node Type Traits
22950 @section Type Traits
22951
22952 The C++ front end implements syntactic extensions that allow
22953 compile-time determination of
22954 various characteristics of a type (or of a
22955 pair of types).
22956
22957 @table @code
22958 @item __has_nothrow_assign (type)
22959 If @code{type} is const qualified or is a reference type then the trait is
22960 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
22961 is true, else if @code{type} is a cv class or union type with copy assignment
22962 operators that are known not to throw an exception then the trait is true,
22963 else it is false. Requires: @code{type} shall be a complete type,
22964 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22965
22966 @item __has_nothrow_copy (type)
22967 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
22968 @code{type} is a cv class or union type with copy constructors that
22969 are known not to throw an exception then the trait is true, else it is false.
22970 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
22971 @code{void}, or an array of unknown bound.
22972
22973 @item __has_nothrow_constructor (type)
22974 If @code{__has_trivial_constructor (type)} is true then the trait is
22975 true, else if @code{type} is a cv class or union type (or array
22976 thereof) with a default constructor that is known not to throw an
22977 exception then the trait is true, else it is false. Requires:
22978 @code{type} shall be a complete type, (possibly cv-qualified)
22979 @code{void}, or an array of unknown bound.
22980
22981 @item __has_trivial_assign (type)
22982 If @code{type} is const qualified or is a reference type then the trait is
22983 false. Otherwise if @code{__is_pod (type)} is true then the trait is
22984 true, else if @code{type} is a cv class or union type with a trivial
22985 copy assignment ([class.copy]) then the trait is true, else it is
22986 false. Requires: @code{type} shall be a complete type, (possibly
22987 cv-qualified) @code{void}, or an array of unknown bound.
22988
22989 @item __has_trivial_copy (type)
22990 If @code{__is_pod (type)} is true or @code{type} is a reference type
22991 then the trait is true, else if @code{type} is a cv class or union type
22992 with a trivial copy constructor ([class.copy]) then the trait
22993 is true, else it is false. Requires: @code{type} shall be a complete
22994 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22995
22996 @item __has_trivial_constructor (type)
22997 If @code{__is_pod (type)} is true then the trait is true, else if
22998 @code{type} is a cv class or union type (or array thereof) with a
22999 trivial default constructor ([class.ctor]) then the trait is true,
23000 else it is false. Requires: @code{type} shall be a complete
23001 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23002
23003 @item __has_trivial_destructor (type)
23004 If @code{__is_pod (type)} is true or @code{type} is a reference type then
23005 the trait is true, else if @code{type} is a cv class or union type (or
23006 array thereof) with a trivial destructor ([class.dtor]) then the trait
23007 is true, else it is false. Requires: @code{type} shall be a complete
23008 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23009
23010 @item __has_virtual_destructor (type)
23011 If @code{type} is a class type with a virtual destructor
23012 ([class.dtor]) then the trait is true, else it is false. Requires:
23013 @code{type} shall be a complete type, (possibly cv-qualified)
23014 @code{void}, or an array of unknown bound.
23015
23016 @item __is_abstract (type)
23017 If @code{type} is an abstract class ([class.abstract]) then the trait
23018 is true, else it is false. Requires: @code{type} shall be a complete
23019 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23020
23021 @item __is_base_of (base_type, derived_type)
23022 If @code{base_type} is a base class of @code{derived_type}
23023 ([class.derived]) then the trait is true, otherwise it is false.
23024 Top-level cv qualifications of @code{base_type} and
23025 @code{derived_type} are ignored. For the purposes of this trait, a
23026 class type is considered is own base. Requires: if @code{__is_class
23027 (base_type)} and @code{__is_class (derived_type)} are true and
23028 @code{base_type} and @code{derived_type} are not the same type
23029 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
23030 type. A diagnostic is produced if this requirement is not met.
23031
23032 @item __is_class (type)
23033 If @code{type} is a cv class type, and not a union type
23034 ([basic.compound]) the trait is true, else it is false.
23035
23036 @item __is_empty (type)
23037 If @code{__is_class (type)} is false then the trait is false.
23038 Otherwise @code{type} is considered empty if and only if: @code{type}
23039 has no non-static data members, or all non-static data members, if
23040 any, are bit-fields of length 0, and @code{type} has no virtual
23041 members, and @code{type} has no virtual base classes, and @code{type}
23042 has no base classes @code{base_type} for which
23043 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
23044 be a complete type, (possibly cv-qualified) @code{void}, or an array
23045 of unknown bound.
23046
23047 @item __is_enum (type)
23048 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
23049 true, else it is false.
23050
23051 @item __is_literal_type (type)
23052 If @code{type} is a literal type ([basic.types]) the trait is
23053 true, else it is false. Requires: @code{type} shall be a complete type,
23054 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23055
23056 @item __is_pod (type)
23057 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
23058 else it is false. Requires: @code{type} shall be a complete type,
23059 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23060
23061 @item __is_polymorphic (type)
23062 If @code{type} is a polymorphic class ([class.virtual]) then the trait
23063 is true, else it is false. Requires: @code{type} shall be a complete
23064 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23065
23066 @item __is_standard_layout (type)
23067 If @code{type} is a standard-layout type ([basic.types]) the trait is
23068 true, else it is false. Requires: @code{type} shall be a complete
23069 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23070
23071 @item __is_trivial (type)
23072 If @code{type} is a trivial type ([basic.types]) the trait is
23073 true, else it is false. Requires: @code{type} shall be a complete
23074 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23075
23076 @item __is_union (type)
23077 If @code{type} is a cv union type ([basic.compound]) the trait is
23078 true, else it is false.
23079
23080 @item __underlying_type (type)
23081 The underlying type of @code{type}. Requires: @code{type} shall be
23082 an enumeration type ([dcl.enum]).
23083
23084 @item __integer_pack (length)
23085 When used as the pattern of a pack expansion within a template
23086 definition, expands to a template argument pack containing integers
23087 from @code{0} to @code{length-1}. This is provided for efficient
23088 implementation of @code{std::make_integer_sequence}.
23089
23090 @end table
23091
23092
23093 @node C++ Concepts
23094 @section C++ Concepts
23095
23096 C++ concepts provide much-improved support for generic programming. In
23097 particular, they allow the specification of constraints on template arguments.
23098 The constraints are used to extend the usual overloading and partial
23099 specialization capabilities of the language, allowing generic data structures
23100 and algorithms to be ``refined'' based on their properties rather than their
23101 type names.
23102
23103 The following keywords are reserved for concepts.
23104
23105 @table @code
23106 @item assumes
23107 States an expression as an assumption, and if possible, verifies that the
23108 assumption is valid. For example, @code{assume(n > 0)}.
23109
23110 @item axiom
23111 Introduces an axiom definition. Axioms introduce requirements on values.
23112
23113 @item forall
23114 Introduces a universally quantified object in an axiom. For example,
23115 @code{forall (int n) n + 0 == n}).
23116
23117 @item concept
23118 Introduces a concept definition. Concepts are sets of syntactic and semantic
23119 requirements on types and their values.
23120
23121 @item requires
23122 Introduces constraints on template arguments or requirements for a member
23123 function of a class template.
23124
23125 @end table
23126
23127 The front end also exposes a number of internal mechanism that can be used
23128 to simplify the writing of type traits. Note that some of these traits are
23129 likely to be removed in the future.
23130
23131 @table @code
23132 @item __is_same (type1, type2)
23133 A binary type trait: true whenever the type arguments are the same.
23134
23135 @end table
23136
23137
23138 @node Deprecated Features
23139 @section Deprecated Features
23140
23141 In the past, the GNU C++ compiler was extended to experiment with new
23142 features, at a time when the C++ language was still evolving. Now that
23143 the C++ standard is complete, some of those features are superseded by
23144 superior alternatives. Using the old features might cause a warning in
23145 some cases that the feature will be dropped in the future. In other
23146 cases, the feature might be gone already.
23147
23148 While the list below is not exhaustive, it documents some of the options
23149 that are now deprecated:
23150
23151 @table @code
23152 @item -fexternal-templates
23153 @itemx -falt-external-templates
23154 These are two of the many ways for G++ to implement template
23155 instantiation. @xref{Template Instantiation}. The C++ standard clearly
23156 defines how template definitions have to be organized across
23157 implementation units. G++ has an implicit instantiation mechanism that
23158 should work just fine for standard-conforming code.
23159
23160 @item -fstrict-prototype
23161 @itemx -fno-strict-prototype
23162 Previously it was possible to use an empty prototype parameter list to
23163 indicate an unspecified number of parameters (like C), rather than no
23164 parameters, as C++ demands. This feature has been removed, except where
23165 it is required for backwards compatibility. @xref{Backwards Compatibility}.
23166 @end table
23167
23168 G++ allows a virtual function returning @samp{void *} to be overridden
23169 by one returning a different pointer type. This extension to the
23170 covariant return type rules is now deprecated and will be removed from a
23171 future version.
23172
23173 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
23174 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
23175 and are now removed from G++. Code using these operators should be
23176 modified to use @code{std::min} and @code{std::max} instead.
23177
23178 The named return value extension has been deprecated, and is now
23179 removed from G++.
23180
23181 The use of initializer lists with new expressions has been deprecated,
23182 and is now removed from G++.
23183
23184 Floating and complex non-type template parameters have been deprecated,
23185 and are now removed from G++.
23186
23187 The implicit typename extension has been deprecated and is now
23188 removed from G++.
23189
23190 The use of default arguments in function pointers, function typedefs
23191 and other places where they are not permitted by the standard is
23192 deprecated and will be removed from a future version of G++.
23193
23194 G++ allows floating-point literals to appear in integral constant expressions,
23195 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
23196 This extension is deprecated and will be removed from a future version.
23197
23198 G++ allows static data members of const floating-point type to be declared
23199 with an initializer in a class definition. The standard only allows
23200 initializers for static members of const integral types and const
23201 enumeration types so this extension has been deprecated and will be removed
23202 from a future version.
23203
23204 @node Backwards Compatibility
23205 @section Backwards Compatibility
23206 @cindex Backwards Compatibility
23207 @cindex ARM [Annotated C++ Reference Manual]
23208
23209 Now that there is a definitive ISO standard C++, G++ has a specification
23210 to adhere to. The C++ language evolved over time, and features that
23211 used to be acceptable in previous drafts of the standard, such as the ARM
23212 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
23213 compilation of C++ written to such drafts, G++ contains some backwards
23214 compatibilities. @emph{All such backwards compatibility features are
23215 liable to disappear in future versions of G++.} They should be considered
23216 deprecated. @xref{Deprecated Features}.
23217
23218 @table @code
23219 @item For scope
23220 If a variable is declared at for scope, it used to remain in scope until
23221 the end of the scope that contained the for statement (rather than just
23222 within the for scope). G++ retains this, but issues a warning, if such a
23223 variable is accessed outside the for scope.
23224
23225 @item Implicit C language
23226 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
23227 scope to set the language. On such systems, all header files are
23228 implicitly scoped inside a C language scope. Also, an empty prototype
23229 @code{()} is treated as an unspecified number of arguments, rather
23230 than no arguments, as C++ demands.
23231 @end table
23232
23233 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
23234 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr