altivec.h (vec_extract_exp): New macro.
[gcc.git] / gcc / doc / extend.texi
1 @c Copyright (C) 1988-2016 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 * Attribute Syntax:: Formal syntax for attributes.
64 * Function Prototypes:: Prototype declarations and old-style definitions.
65 * C++ Comments:: C++ comments are recognized.
66 * Dollar Signs:: Dollar sign is allowed in identifiers.
67 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
68 * Alignment:: Inquiring about the alignment of a type or variable.
69 * Inline:: Defining inline functions (as fast as macros).
70 * Volatiles:: What constitutes an access to a volatile object.
71 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
72 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
73 * Incomplete Enums:: @code{enum foo;}, with details to follow.
74 * Function Names:: Printable strings which are the name of the current
75 function.
76 * Return Address:: Getting the return or frame address of a function.
77 * Vector Extensions:: Using vector instructions through built-in functions.
78 * Offsetof:: Special syntax for implementing @code{offsetof}.
79 * __sync Builtins:: Legacy built-in functions for atomic memory access.
80 * __atomic Builtins:: Atomic built-in functions with memory model.
81 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
82 arithmetic overflow checking.
83 * x86 specific memory model extensions for transactional memory:: x86 memory models.
84 * Object Size Checking:: Built-in functions for limited buffer overflow
85 checking.
86 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
87 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
88 * Other Builtins:: Other built-in functions.
89 * Target Builtins:: Built-in functions specific to particular targets.
90 * Target Format Checks:: Format checks specific to particular targets.
91 * Pragmas:: Pragmas accepted by GCC.
92 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
93 * Thread-Local:: Per-thread variables.
94 * Binary constants:: Binary constants using the @samp{0b} prefix.
95 @end menu
96
97 @node Statement Exprs
98 @section Statements and Declarations in Expressions
99 @cindex statements inside expressions
100 @cindex declarations inside expressions
101 @cindex expressions containing statements
102 @cindex macros, statements in expressions
103
104 @c the above section title wrapped and causes an underfull hbox.. i
105 @c changed it from "within" to "in". --mew 4feb93
106 A compound statement enclosed in parentheses may appear as an expression
107 in GNU C@. This allows you to use loops, switches, and local variables
108 within an expression.
109
110 Recall that a compound statement is a sequence of statements surrounded
111 by braces; in this construct, parentheses go around the braces. For
112 example:
113
114 @smallexample
115 (@{ int y = foo (); int z;
116 if (y > 0) z = y;
117 else z = - y;
118 z; @})
119 @end smallexample
120
121 @noindent
122 is a valid (though slightly more complex than necessary) expression
123 for the absolute value of @code{foo ()}.
124
125 The last thing in the compound statement should be an expression
126 followed by a semicolon; the value of this subexpression serves as the
127 value of the entire construct. (If you use some other kind of statement
128 last within the braces, the construct has type @code{void}, and thus
129 effectively no value.)
130
131 This feature is especially useful in making macro definitions ``safe'' (so
132 that they evaluate each operand exactly once). For example, the
133 ``maximum'' function is commonly defined as a macro in standard C as
134 follows:
135
136 @smallexample
137 #define max(a,b) ((a) > (b) ? (a) : (b))
138 @end smallexample
139
140 @noindent
141 @cindex side effects, macro argument
142 But this definition computes either @var{a} or @var{b} twice, with bad
143 results if the operand has side effects. In GNU C, if you know the
144 type of the operands (here taken as @code{int}), you can define
145 the macro safely as follows:
146
147 @smallexample
148 #define maxint(a,b) \
149 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
150 @end smallexample
151
152 Embedded statements are not allowed in constant expressions, such as
153 the value of an enumeration constant, the width of a bit-field, or
154 the initial value of a static variable.
155
156 If you don't know the type of the operand, you can still do this, but you
157 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
158
159 In G++, the result value of a statement expression undergoes array and
160 function pointer decay, and is returned by value to the enclosing
161 expression. For instance, if @code{A} is a class, then
162
163 @smallexample
164 A a;
165
166 (@{a;@}).Foo ()
167 @end smallexample
168
169 @noindent
170 constructs a temporary @code{A} object to hold the result of the
171 statement expression, and that is used to invoke @code{Foo}.
172 Therefore the @code{this} pointer observed by @code{Foo} is not the
173 address of @code{a}.
174
175 In a statement expression, any temporaries created within a statement
176 are destroyed at that statement's end. This makes statement
177 expressions inside macros slightly different from function calls. In
178 the latter case temporaries introduced during argument evaluation are
179 destroyed at the end of the statement that includes the function
180 call. In the statement expression case they are destroyed during
181 the statement expression. For instance,
182
183 @smallexample
184 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
185 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
186
187 void foo ()
188 @{
189 macro (X ());
190 function (X ());
191 @}
192 @end smallexample
193
194 @noindent
195 has different places where temporaries are destroyed. For the
196 @code{macro} case, the temporary @code{X} is destroyed just after
197 the initialization of @code{b}. In the @code{function} case that
198 temporary is destroyed when the function returns.
199
200 These considerations mean that it is probably a bad idea to use
201 statement expressions of this form in header files that are designed to
202 work with C++. (Note that some versions of the GNU C Library contained
203 header files using statement expressions that lead to precisely this
204 bug.)
205
206 Jumping into a statement expression with @code{goto} or using a
207 @code{switch} statement outside the statement expression with a
208 @code{case} or @code{default} label inside the statement expression is
209 not permitted. Jumping into a statement expression with a computed
210 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
211 Jumping out of a statement expression is permitted, but if the
212 statement expression is part of a larger expression then it is
213 unspecified which other subexpressions of that expression have been
214 evaluated except where the language definition requires certain
215 subexpressions to be evaluated before or after the statement
216 expression. In any case, as with a function call, the evaluation of a
217 statement expression is not interleaved with the evaluation of other
218 parts of the containing expression. For example,
219
220 @smallexample
221 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
222 @end smallexample
223
224 @noindent
225 calls @code{foo} and @code{bar1} and does not call @code{baz} but
226 may or may not call @code{bar2}. If @code{bar2} is called, it is
227 called after @code{foo} and before @code{bar1}.
228
229 @node Local Labels
230 @section Locally Declared Labels
231 @cindex local labels
232 @cindex macros, local labels
233
234 GCC allows you to declare @dfn{local labels} in any nested block
235 scope. A local label is just like an ordinary label, but you can
236 only reference it (with a @code{goto} statement, or by taking its
237 address) within the block in which it is declared.
238
239 A local label declaration looks like this:
240
241 @smallexample
242 __label__ @var{label};
243 @end smallexample
244
245 @noindent
246 or
247
248 @smallexample
249 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
250 @end smallexample
251
252 Local label declarations must come at the beginning of the block,
253 before any ordinary declarations or statements.
254
255 The label declaration defines the label @emph{name}, but does not define
256 the label itself. You must do this in the usual way, with
257 @code{@var{label}:}, within the statements of the statement expression.
258
259 The local label feature is useful for complex macros. If a macro
260 contains nested loops, a @code{goto} can be useful for breaking out of
261 them. However, an ordinary label whose scope is the whole function
262 cannot be used: if the macro can be expanded several times in one
263 function, the label is multiply defined in that function. A
264 local label avoids this problem. For example:
265
266 @smallexample
267 #define SEARCH(value, array, target) \
268 do @{ \
269 __label__ found; \
270 typeof (target) _SEARCH_target = (target); \
271 typeof (*(array)) *_SEARCH_array = (array); \
272 int i, j; \
273 int value; \
274 for (i = 0; i < max; i++) \
275 for (j = 0; j < max; j++) \
276 if (_SEARCH_array[i][j] == _SEARCH_target) \
277 @{ (value) = i; goto found; @} \
278 (value) = -1; \
279 found:; \
280 @} while (0)
281 @end smallexample
282
283 This could also be written using a statement expression:
284
285 @smallexample
286 #define SEARCH(array, target) \
287 (@{ \
288 __label__ found; \
289 typeof (target) _SEARCH_target = (target); \
290 typeof (*(array)) *_SEARCH_array = (array); \
291 int i, j; \
292 int value; \
293 for (i = 0; i < max; i++) \
294 for (j = 0; j < max; j++) \
295 if (_SEARCH_array[i][j] == _SEARCH_target) \
296 @{ value = i; goto found; @} \
297 value = -1; \
298 found: \
299 value; \
300 @})
301 @end smallexample
302
303 Local label declarations also make the labels they declare visible to
304 nested functions, if there are any. @xref{Nested Functions}, for details.
305
306 @node Labels as Values
307 @section Labels as Values
308 @cindex labels as values
309 @cindex computed gotos
310 @cindex goto with computed label
311 @cindex address of a label
312
313 You can get the address of a label defined in the current function
314 (or a containing function) with the unary operator @samp{&&}. The
315 value has type @code{void *}. This value is a constant and can be used
316 wherever a constant of that type is valid. For example:
317
318 @smallexample
319 void *ptr;
320 /* @r{@dots{}} */
321 ptr = &&foo;
322 @end smallexample
323
324 To use these values, you need to be able to jump to one. This is done
325 with the computed goto statement@footnote{The analogous feature in
326 Fortran is called an assigned goto, but that name seems inappropriate in
327 C, where one can do more than simply store label addresses in label
328 variables.}, @code{goto *@var{exp};}. For example,
329
330 @smallexample
331 goto *ptr;
332 @end smallexample
333
334 @noindent
335 Any expression of type @code{void *} is allowed.
336
337 One way of using these constants is in initializing a static array that
338 serves as a jump table:
339
340 @smallexample
341 static void *array[] = @{ &&foo, &&bar, &&hack @};
342 @end smallexample
343
344 @noindent
345 Then you can select a label with indexing, like this:
346
347 @smallexample
348 goto *array[i];
349 @end smallexample
350
351 @noindent
352 Note that this does not check whether the subscript is in bounds---array
353 indexing in C never does that.
354
355 Such an array of label values serves a purpose much like that of the
356 @code{switch} statement. The @code{switch} statement is cleaner, so
357 use that rather than an array unless the problem does not fit a
358 @code{switch} statement very well.
359
360 Another use of label values is in an interpreter for threaded code.
361 The labels within the interpreter function can be stored in the
362 threaded code for super-fast dispatching.
363
364 You may not use this mechanism to jump to code in a different function.
365 If you do that, totally unpredictable things happen. The best way to
366 avoid this is to store the label address only in automatic variables and
367 never pass it as an argument.
368
369 An alternate way to write the above example is
370
371 @smallexample
372 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
373 &&hack - &&foo @};
374 goto *(&&foo + array[i]);
375 @end smallexample
376
377 @noindent
378 This is more friendly to code living in shared libraries, as it reduces
379 the number of dynamic relocations that are needed, and by consequence,
380 allows the data to be read-only.
381 This alternative with label differences is not supported for the AVR target,
382 please use the first approach for AVR programs.
383
384 The @code{&&foo} expressions for the same label might have different
385 values if the containing function is inlined or cloned. If a program
386 relies on them being always the same,
387 @code{__attribute__((__noinline__,__noclone__))} should be used to
388 prevent inlining and cloning. If @code{&&foo} is used in a static
389 variable initializer, inlining and cloning is forbidden.
390
391 @node Nested Functions
392 @section Nested Functions
393 @cindex nested functions
394 @cindex downward funargs
395 @cindex thunks
396
397 A @dfn{nested function} is a function defined inside another function.
398 Nested functions are supported as an extension in GNU C, but are not
399 supported by GNU C++.
400
401 The nested function's name is local to the block where it is defined.
402 For example, here we define a nested function named @code{square}, and
403 call it twice:
404
405 @smallexample
406 @group
407 foo (double a, double b)
408 @{
409 double square (double z) @{ return z * z; @}
410
411 return square (a) + square (b);
412 @}
413 @end group
414 @end smallexample
415
416 The nested function can access all the variables of the containing
417 function that are visible at the point of its definition. This is
418 called @dfn{lexical scoping}. For example, here we show a nested
419 function which uses an inherited variable named @code{offset}:
420
421 @smallexample
422 @group
423 bar (int *array, int offset, int size)
424 @{
425 int access (int *array, int index)
426 @{ return array[index + offset]; @}
427 int i;
428 /* @r{@dots{}} */
429 for (i = 0; i < size; i++)
430 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
431 @}
432 @end group
433 @end smallexample
434
435 Nested function definitions are permitted within functions in the places
436 where variable definitions are allowed; that is, in any block, mixed
437 with the other declarations and statements in the block.
438
439 It is possible to call the nested function from outside the scope of its
440 name by storing its address or passing the address to another function:
441
442 @smallexample
443 hack (int *array, int size)
444 @{
445 void store (int index, int value)
446 @{ array[index] = value; @}
447
448 intermediate (store, size);
449 @}
450 @end smallexample
451
452 Here, the function @code{intermediate} receives the address of
453 @code{store} as an argument. If @code{intermediate} calls @code{store},
454 the arguments given to @code{store} are used to store into @code{array}.
455 But this technique works only so long as the containing function
456 (@code{hack}, in this example) does not exit.
457
458 If you try to call the nested function through its address after the
459 containing function exits, all hell breaks loose. If you try
460 to call it after a containing scope level exits, and if it refers
461 to some of the variables that are no longer in scope, you may be lucky,
462 but it's not wise to take the risk. If, however, the nested function
463 does not refer to anything that has gone out of scope, you should be
464 safe.
465
466 GCC implements taking the address of a nested function using a technique
467 called @dfn{trampolines}. This technique was described in
468 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
469 C++ Conference Proceedings, October 17-21, 1988).
470
471 A nested function can jump to a label inherited from a containing
472 function, provided the label is explicitly declared in the containing
473 function (@pxref{Local Labels}). Such a jump returns instantly to the
474 containing function, exiting the nested function that did the
475 @code{goto} and any intermediate functions as well. Here is an example:
476
477 @smallexample
478 @group
479 bar (int *array, int offset, int size)
480 @{
481 __label__ failure;
482 int access (int *array, int index)
483 @{
484 if (index > size)
485 goto failure;
486 return array[index + offset];
487 @}
488 int i;
489 /* @r{@dots{}} */
490 for (i = 0; i < size; i++)
491 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
492 /* @r{@dots{}} */
493 return 0;
494
495 /* @r{Control comes here from @code{access}
496 if it detects an error.} */
497 failure:
498 return -1;
499 @}
500 @end group
501 @end smallexample
502
503 A nested function always has no linkage. Declaring one with
504 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
505 before its definition, use @code{auto} (which is otherwise meaningless
506 for function declarations).
507
508 @smallexample
509 bar (int *array, int offset, int size)
510 @{
511 __label__ failure;
512 auto int access (int *, int);
513 /* @r{@dots{}} */
514 int access (int *array, int index)
515 @{
516 if (index > size)
517 goto failure;
518 return array[index + offset];
519 @}
520 /* @r{@dots{}} */
521 @}
522 @end smallexample
523
524 @node Constructing Calls
525 @section Constructing Function Calls
526 @cindex constructing calls
527 @cindex forwarding calls
528
529 Using the built-in functions described below, you can record
530 the arguments a function received, and call another function
531 with the same arguments, without knowing the number or types
532 of the arguments.
533
534 You can also record the return value of that function call,
535 and later return that value, without knowing what data type
536 the function tried to return (as long as your caller expects
537 that data type).
538
539 However, these built-in functions may interact badly with some
540 sophisticated features or other extensions of the language. It
541 is, therefore, not recommended to use them outside very simple
542 functions acting as mere forwarders for their arguments.
543
544 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
545 This built-in function returns a pointer to data
546 describing how to perform a call with the same arguments as are passed
547 to the current function.
548
549 The function saves the arg pointer register, structure value address,
550 and all registers that might be used to pass arguments to a function
551 into a block of memory allocated on the stack. Then it returns the
552 address of that block.
553 @end deftypefn
554
555 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
556 This built-in function invokes @var{function}
557 with a copy of the parameters described by @var{arguments}
558 and @var{size}.
559
560 The value of @var{arguments} should be the value returned by
561 @code{__builtin_apply_args}. The argument @var{size} specifies the size
562 of the stack argument data, in bytes.
563
564 This function returns a pointer to data describing
565 how to return whatever value is returned by @var{function}. The data
566 is saved in a block of memory allocated on the stack.
567
568 It is not always simple to compute the proper value for @var{size}. The
569 value is used by @code{__builtin_apply} to compute the amount of data
570 that should be pushed on the stack and copied from the incoming argument
571 area.
572 @end deftypefn
573
574 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
575 This built-in function returns the value described by @var{result} from
576 the containing function. You should specify, for @var{result}, a value
577 returned by @code{__builtin_apply}.
578 @end deftypefn
579
580 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
581 This built-in function represents all anonymous arguments of an inline
582 function. It can be used only in inline functions that are always
583 inlined, never compiled as a separate function, such as those using
584 @code{__attribute__ ((__always_inline__))} or
585 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
586 It must be only passed as last argument to some other function
587 with variable arguments. This is useful for writing small wrapper
588 inlines for variable argument functions, when using preprocessor
589 macros is undesirable. For example:
590 @smallexample
591 extern int myprintf (FILE *f, const char *format, ...);
592 extern inline __attribute__ ((__gnu_inline__)) int
593 myprintf (FILE *f, const char *format, ...)
594 @{
595 int r = fprintf (f, "myprintf: ");
596 if (r < 0)
597 return r;
598 int s = fprintf (f, format, __builtin_va_arg_pack ());
599 if (s < 0)
600 return s;
601 return r + s;
602 @}
603 @end smallexample
604 @end deftypefn
605
606 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
607 This built-in function returns the number of anonymous arguments of
608 an inline function. It can be used only in inline functions that
609 are always inlined, never compiled as a separate function, such
610 as those using @code{__attribute__ ((__always_inline__))} or
611 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
612 For example following does link- or run-time checking of open
613 arguments for optimized code:
614 @smallexample
615 #ifdef __OPTIMIZE__
616 extern inline __attribute__((__gnu_inline__)) int
617 myopen (const char *path, int oflag, ...)
618 @{
619 if (__builtin_va_arg_pack_len () > 1)
620 warn_open_too_many_arguments ();
621
622 if (__builtin_constant_p (oflag))
623 @{
624 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
625 @{
626 warn_open_missing_mode ();
627 return __open_2 (path, oflag);
628 @}
629 return open (path, oflag, __builtin_va_arg_pack ());
630 @}
631
632 if (__builtin_va_arg_pack_len () < 1)
633 return __open_2 (path, oflag);
634
635 return open (path, oflag, __builtin_va_arg_pack ());
636 @}
637 #endif
638 @end smallexample
639 @end deftypefn
640
641 @node Typeof
642 @section Referring to a Type with @code{typeof}
643 @findex typeof
644 @findex sizeof
645 @cindex macros, types of arguments
646
647 Another way to refer to the type of an expression is with @code{typeof}.
648 The syntax of using of this keyword looks like @code{sizeof}, but the
649 construct acts semantically like a type name defined with @code{typedef}.
650
651 There are two ways of writing the argument to @code{typeof}: with an
652 expression or with a type. Here is an example with an expression:
653
654 @smallexample
655 typeof (x[0](1))
656 @end smallexample
657
658 @noindent
659 This assumes that @code{x} is an array of pointers to functions;
660 the type described is that of the values of the functions.
661
662 Here is an example with a typename as the argument:
663
664 @smallexample
665 typeof (int *)
666 @end smallexample
667
668 @noindent
669 Here the type described is that of pointers to @code{int}.
670
671 If you are writing a header file that must work when included in ISO C
672 programs, write @code{__typeof__} instead of @code{typeof}.
673 @xref{Alternate Keywords}.
674
675 A @code{typeof} construct can be used anywhere a typedef name can be
676 used. For example, you can use it in a declaration, in a cast, or inside
677 of @code{sizeof} or @code{typeof}.
678
679 The operand of @code{typeof} is evaluated for its side effects if and
680 only if it is an expression of variably modified type or the name of
681 such a type.
682
683 @code{typeof} is often useful in conjunction with
684 statement expressions (@pxref{Statement Exprs}).
685 Here is how the two together can
686 be used to define a safe ``maximum'' macro which operates on any
687 arithmetic type and evaluates each of its arguments exactly once:
688
689 @smallexample
690 #define max(a,b) \
691 (@{ typeof (a) _a = (a); \
692 typeof (b) _b = (b); \
693 _a > _b ? _a : _b; @})
694 @end smallexample
695
696 @cindex underscores in variables in macros
697 @cindex @samp{_} in variables in macros
698 @cindex local variables in macros
699 @cindex variables, local, in macros
700 @cindex macros, local variables in
701
702 The reason for using names that start with underscores for the local
703 variables is to avoid conflicts with variable names that occur within the
704 expressions that are substituted for @code{a} and @code{b}. Eventually we
705 hope to design a new form of declaration syntax that allows you to declare
706 variables whose scopes start only after their initializers; this will be a
707 more reliable way to prevent such conflicts.
708
709 @noindent
710 Some more examples of the use of @code{typeof}:
711
712 @itemize @bullet
713 @item
714 This declares @code{y} with the type of what @code{x} points to.
715
716 @smallexample
717 typeof (*x) y;
718 @end smallexample
719
720 @item
721 This declares @code{y} as an array of such values.
722
723 @smallexample
724 typeof (*x) y[4];
725 @end smallexample
726
727 @item
728 This declares @code{y} as an array of pointers to characters:
729
730 @smallexample
731 typeof (typeof (char *)[4]) y;
732 @end smallexample
733
734 @noindent
735 It is equivalent to the following traditional C declaration:
736
737 @smallexample
738 char *y[4];
739 @end smallexample
740
741 To see the meaning of the declaration using @code{typeof}, and why it
742 might be a useful way to write, rewrite it with these macros:
743
744 @smallexample
745 #define pointer(T) typeof(T *)
746 #define array(T, N) typeof(T [N])
747 @end smallexample
748
749 @noindent
750 Now the declaration can be rewritten this way:
751
752 @smallexample
753 array (pointer (char), 4) y;
754 @end smallexample
755
756 @noindent
757 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
758 pointers to @code{char}.
759 @end itemize
760
761 In GNU C, but not GNU C++, you may also declare the type of a variable
762 as @code{__auto_type}. In that case, the declaration must declare
763 only one variable, whose declarator must just be an identifier, the
764 declaration must be initialized, and the type of the variable is
765 determined by the initializer; the name of the variable is not in
766 scope until after the initializer. (In C++, you should use C++11
767 @code{auto} for this purpose.) Using @code{__auto_type}, the
768 ``maximum'' macro above could be written as:
769
770 @smallexample
771 #define max(a,b) \
772 (@{ __auto_type _a = (a); \
773 __auto_type _b = (b); \
774 _a > _b ? _a : _b; @})
775 @end smallexample
776
777 Using @code{__auto_type} instead of @code{typeof} has two advantages:
778
779 @itemize @bullet
780 @item Each argument to the macro appears only once in the expansion of
781 the macro. This prevents the size of the macro expansion growing
782 exponentially when calls to such macros are nested inside arguments of
783 such macros.
784
785 @item If the argument to the macro has variably modified type, it is
786 evaluated only once when using @code{__auto_type}, but twice if
787 @code{typeof} is used.
788 @end itemize
789
790 @node Conditionals
791 @section Conditionals with Omitted Operands
792 @cindex conditional expressions, extensions
793 @cindex omitted middle-operands
794 @cindex middle-operands, omitted
795 @cindex extensions, @code{?:}
796 @cindex @code{?:} extensions
797
798 The middle operand in a conditional expression may be omitted. Then
799 if the first operand is nonzero, its value is the value of the conditional
800 expression.
801
802 Therefore, the expression
803
804 @smallexample
805 x ? : y
806 @end smallexample
807
808 @noindent
809 has the value of @code{x} if that is nonzero; otherwise, the value of
810 @code{y}.
811
812 This example is perfectly equivalent to
813
814 @smallexample
815 x ? x : y
816 @end smallexample
817
818 @cindex side effect in @code{?:}
819 @cindex @code{?:} side effect
820 @noindent
821 In this simple case, the ability to omit the middle operand is not
822 especially useful. When it becomes useful is when the first operand does,
823 or may (if it is a macro argument), contain a side effect. Then repeating
824 the operand in the middle would perform the side effect twice. Omitting
825 the middle operand uses the value already computed without the undesirable
826 effects of recomputing it.
827
828 @node __int128
829 @section 128-bit Integers
830 @cindex @code{__int128} data types
831
832 As an extension the integer scalar type @code{__int128} is supported for
833 targets which have an integer mode wide enough to hold 128 bits.
834 Simply write @code{__int128} for a signed 128-bit integer, or
835 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
836 support in GCC for expressing an integer constant of type @code{__int128}
837 for targets with @code{long long} integer less than 128 bits wide.
838
839 @node Long Long
840 @section Double-Word Integers
841 @cindex @code{long long} data types
842 @cindex double-word arithmetic
843 @cindex multiprecision arithmetic
844 @cindex @code{LL} integer suffix
845 @cindex @code{ULL} integer suffix
846
847 ISO C99 supports data types for integers that are at least 64 bits wide,
848 and as an extension GCC supports them in C90 mode and in C++.
849 Simply write @code{long long int} for a signed integer, or
850 @code{unsigned long long int} for an unsigned integer. To make an
851 integer constant of type @code{long long int}, add the suffix @samp{LL}
852 to the integer. To make an integer constant of type @code{unsigned long
853 long int}, add the suffix @samp{ULL} to the integer.
854
855 You can use these types in arithmetic like any other integer types.
856 Addition, subtraction, and bitwise boolean operations on these types
857 are open-coded on all types of machines. Multiplication is open-coded
858 if the machine supports a fullword-to-doubleword widening multiply
859 instruction. Division and shifts are open-coded only on machines that
860 provide special support. The operations that are not open-coded use
861 special library routines that come with GCC@.
862
863 There may be pitfalls when you use @code{long long} types for function
864 arguments without function prototypes. If a function
865 expects type @code{int} for its argument, and you pass a value of type
866 @code{long long int}, confusion results because the caller and the
867 subroutine disagree about the number of bytes for the argument.
868 Likewise, if the function expects @code{long long int} and you pass
869 @code{int}. The best way to avoid such problems is to use prototypes.
870
871 @node Complex
872 @section Complex Numbers
873 @cindex complex numbers
874 @cindex @code{_Complex} keyword
875 @cindex @code{__complex__} keyword
876
877 ISO C99 supports complex floating data types, and as an extension GCC
878 supports them in C90 mode and in C++. GCC also supports complex integer data
879 types which are not part of ISO C99. You can declare complex types
880 using the keyword @code{_Complex}. As an extension, the older GNU
881 keyword @code{__complex__} is also supported.
882
883 For example, @samp{_Complex double x;} declares @code{x} as a
884 variable whose real part and imaginary part are both of type
885 @code{double}. @samp{_Complex short int y;} declares @code{y} to
886 have real and imaginary parts of type @code{short int}; this is not
887 likely to be useful, but it shows that the set of complex types is
888 complete.
889
890 To write a constant with a complex data type, use the suffix @samp{i} or
891 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
892 has type @code{_Complex float} and @code{3i} has type
893 @code{_Complex int}. Such a constant always has a pure imaginary
894 value, but you can form any complex value you like by adding one to a
895 real constant. This is a GNU extension; if you have an ISO C99
896 conforming C library (such as the GNU C Library), and want to construct complex
897 constants of floating type, you should include @code{<complex.h>} and
898 use the macros @code{I} or @code{_Complex_I} instead.
899
900 @cindex @code{__real__} keyword
901 @cindex @code{__imag__} keyword
902 To extract the real part of a complex-valued expression @var{exp}, write
903 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
904 extract the imaginary part. This is a GNU extension; for values of
905 floating type, you should use the ISO C99 functions @code{crealf},
906 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
907 @code{cimagl}, declared in @code{<complex.h>} and also provided as
908 built-in functions by GCC@.
909
910 @cindex complex conjugation
911 The operator @samp{~} performs complex conjugation when used on a value
912 with a complex type. This is a GNU extension; for values of
913 floating type, you should use the ISO C99 functions @code{conjf},
914 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
915 provided as built-in functions by GCC@.
916
917 GCC can allocate complex automatic variables in a noncontiguous
918 fashion; it's even possible for the real part to be in a register while
919 the imaginary part is on the stack (or vice versa). Only the DWARF
920 debug info format can represent this, so use of DWARF is recommended.
921 If you are using the stabs debug info format, GCC describes a noncontiguous
922 complex variable as if it were two separate variables of noncomplex type.
923 If the variable's actual name is @code{foo}, the two fictitious
924 variables are named @code{foo$real} and @code{foo$imag}. You can
925 examine and set these two fictitious variables with your debugger.
926
927 @node Floating Types
928 @section Additional Floating Types
929 @cindex additional floating types
930 @cindex @code{__float80} data type
931 @cindex @code{__float128} data type
932 @cindex @code{__ibm128} data type
933 @cindex @code{w} floating point suffix
934 @cindex @code{q} floating point suffix
935 @cindex @code{W} floating point suffix
936 @cindex @code{Q} floating point suffix
937
938 As an extension, GNU C supports additional floating
939 types, @code{__float80} and @code{__float128} to support 80-bit
940 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
941 Support for additional types includes the arithmetic operators:
942 add, subtract, multiply, divide; unary arithmetic operators;
943 relational operators; equality operators; and conversions to and from
944 integer and other floating types. Use a suffix @samp{w} or @samp{W}
945 in a literal constant of type @code{__float80} or type
946 @code{__ibm128}. Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
947
948 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
949 types using the corresponding internal complex type, @code{XCmode} for
950 @code{__float80} type and @code{TCmode} for @code{__float128} type:
951
952 @smallexample
953 typedef _Complex float __attribute__((mode(TC))) _Complex128;
954 typedef _Complex float __attribute__((mode(XC))) _Complex80;
955 @end smallexample
956
957 In order to use @code{__float128} and @code{__ibm128} on PowerPC Linux
958 systems, you must use the @option{-mfloat128}. It is expected in
959 future versions of GCC that @code{__float128} will be enabled
960 automatically. In addition, there are currently problems in using the
961 complex @code{__float128} type. When these problems are fixed, you
962 would use the following syntax to declare @code{_Complex128} to be a
963 complex @code{__float128} type:
964
965 On the PowerPC Linux VSX targets, you can declare complex types using
966 the corresponding internal complex type, @code{KCmode} for
967 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
968
969 @smallexample
970 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
971 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
972 @end smallexample
973
974 Not all targets support additional floating-point types.
975 @code{__float80} and @code{__float128} types are supported on x86 and
976 IA-64 targets. The @code{__float128} type is supported on hppa HP-UX.
977 The @code{__float128} type is supported on PowerPC 64-bit Linux
978 systems by default if the vector scalar instruction set (VSX) is
979 enabled.
980
981 On the PowerPC, @code{__ibm128} provides access to the IBM extended
982 double format, and it is intended to be used by the library functions
983 that handle conversions if/when long double is changed to be IEEE
984 128-bit floating point.
985
986 @node Half-Precision
987 @section Half-Precision Floating Point
988 @cindex half-precision floating point
989 @cindex @code{__fp16} data type
990
991 On ARM targets, GCC supports half-precision (16-bit) floating point via
992 the @code{__fp16} type. You must enable this type explicitly
993 with the @option{-mfp16-format} command-line option in order to use it.
994
995 ARM supports two incompatible representations for half-precision
996 floating-point values. You must choose one of the representations and
997 use it consistently in your program.
998
999 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1000 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1001 There are 11 bits of significand precision, approximately 3
1002 decimal digits.
1003
1004 Specifying @option{-mfp16-format=alternative} selects the ARM
1005 alternative format. This representation is similar to the IEEE
1006 format, but does not support infinities or NaNs. Instead, the range
1007 of exponents is extended, so that this format can represent normalized
1008 values in the range of @math{2^{-14}} to 131008.
1009
1010 The @code{__fp16} type is a storage format only. For purposes
1011 of arithmetic and other operations, @code{__fp16} values in C or C++
1012 expressions are automatically promoted to @code{float}. In addition,
1013 you cannot declare a function with a return value or parameters
1014 of type @code{__fp16}.
1015
1016 Note that conversions from @code{double} to @code{__fp16}
1017 involve an intermediate conversion to @code{float}. Because
1018 of rounding, this can sometimes produce a different result than a
1019 direct conversion.
1020
1021 ARM provides hardware support for conversions between
1022 @code{__fp16} and @code{float} values
1023 as an extension to VFP and NEON (Advanced SIMD). GCC generates
1024 code using these hardware instructions if you compile with
1025 options to select an FPU that provides them;
1026 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1027 in addition to the @option{-mfp16-format} option to select
1028 a half-precision format.
1029
1030 Language-level support for the @code{__fp16} data type is
1031 independent of whether GCC generates code using hardware floating-point
1032 instructions. In cases where hardware support is not specified, GCC
1033 implements conversions between @code{__fp16} and @code{float} values
1034 as library calls.
1035
1036 @node Decimal Float
1037 @section Decimal Floating Types
1038 @cindex decimal floating types
1039 @cindex @code{_Decimal32} data type
1040 @cindex @code{_Decimal64} data type
1041 @cindex @code{_Decimal128} data type
1042 @cindex @code{df} integer suffix
1043 @cindex @code{dd} integer suffix
1044 @cindex @code{dl} integer suffix
1045 @cindex @code{DF} integer suffix
1046 @cindex @code{DD} integer suffix
1047 @cindex @code{DL} integer suffix
1048
1049 As an extension, GNU C supports decimal floating types as
1050 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1051 floating types in GCC will evolve as the draft technical report changes.
1052 Calling conventions for any target might also change. Not all targets
1053 support decimal floating types.
1054
1055 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1056 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1057 @code{float}, @code{double}, and @code{long double} whose radix is not
1058 specified by the C standard but is usually two.
1059
1060 Support for decimal floating types includes the arithmetic operators
1061 add, subtract, multiply, divide; unary arithmetic operators;
1062 relational operators; equality operators; and conversions to and from
1063 integer and other floating types. Use a suffix @samp{df} or
1064 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1065 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1066 @code{_Decimal128}.
1067
1068 GCC support of decimal float as specified by the draft technical report
1069 is incomplete:
1070
1071 @itemize @bullet
1072 @item
1073 When the value of a decimal floating type cannot be represented in the
1074 integer type to which it is being converted, the result is undefined
1075 rather than the result value specified by the draft technical report.
1076
1077 @item
1078 GCC does not provide the C library functionality associated with
1079 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1080 @file{wchar.h}, which must come from a separate C library implementation.
1081 Because of this the GNU C compiler does not define macro
1082 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1083 the technical report.
1084 @end itemize
1085
1086 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1087 are supported by the DWARF debug information format.
1088
1089 @node Hex Floats
1090 @section Hex Floats
1091 @cindex hex floats
1092
1093 ISO C99 supports floating-point numbers written not only in the usual
1094 decimal notation, such as @code{1.55e1}, but also numbers such as
1095 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1096 supports this in C90 mode (except in some cases when strictly
1097 conforming) and in C++. In that format the
1098 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1099 mandatory. The exponent is a decimal number that indicates the power of
1100 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1101 @tex
1102 $1 {15\over16}$,
1103 @end tex
1104 @ifnottex
1105 1 15/16,
1106 @end ifnottex
1107 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1108 is the same as @code{1.55e1}.
1109
1110 Unlike for floating-point numbers in the decimal notation the exponent
1111 is always required in the hexadecimal notation. Otherwise the compiler
1112 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1113 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1114 extension for floating-point constants of type @code{float}.
1115
1116 @node Fixed-Point
1117 @section Fixed-Point Types
1118 @cindex fixed-point types
1119 @cindex @code{_Fract} data type
1120 @cindex @code{_Accum} data type
1121 @cindex @code{_Sat} data type
1122 @cindex @code{hr} fixed-suffix
1123 @cindex @code{r} fixed-suffix
1124 @cindex @code{lr} fixed-suffix
1125 @cindex @code{llr} fixed-suffix
1126 @cindex @code{uhr} fixed-suffix
1127 @cindex @code{ur} fixed-suffix
1128 @cindex @code{ulr} fixed-suffix
1129 @cindex @code{ullr} fixed-suffix
1130 @cindex @code{hk} fixed-suffix
1131 @cindex @code{k} fixed-suffix
1132 @cindex @code{lk} fixed-suffix
1133 @cindex @code{llk} fixed-suffix
1134 @cindex @code{uhk} fixed-suffix
1135 @cindex @code{uk} fixed-suffix
1136 @cindex @code{ulk} fixed-suffix
1137 @cindex @code{ullk} fixed-suffix
1138 @cindex @code{HR} fixed-suffix
1139 @cindex @code{R} fixed-suffix
1140 @cindex @code{LR} fixed-suffix
1141 @cindex @code{LLR} fixed-suffix
1142 @cindex @code{UHR} fixed-suffix
1143 @cindex @code{UR} fixed-suffix
1144 @cindex @code{ULR} fixed-suffix
1145 @cindex @code{ULLR} fixed-suffix
1146 @cindex @code{HK} fixed-suffix
1147 @cindex @code{K} fixed-suffix
1148 @cindex @code{LK} fixed-suffix
1149 @cindex @code{LLK} fixed-suffix
1150 @cindex @code{UHK} fixed-suffix
1151 @cindex @code{UK} fixed-suffix
1152 @cindex @code{ULK} fixed-suffix
1153 @cindex @code{ULLK} fixed-suffix
1154
1155 As an extension, GNU C supports fixed-point types as
1156 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1157 types in GCC will evolve as the draft technical report changes.
1158 Calling conventions for any target might also change. Not all targets
1159 support fixed-point types.
1160
1161 The fixed-point types are
1162 @code{short _Fract},
1163 @code{_Fract},
1164 @code{long _Fract},
1165 @code{long long _Fract},
1166 @code{unsigned short _Fract},
1167 @code{unsigned _Fract},
1168 @code{unsigned long _Fract},
1169 @code{unsigned long long _Fract},
1170 @code{_Sat short _Fract},
1171 @code{_Sat _Fract},
1172 @code{_Sat long _Fract},
1173 @code{_Sat long long _Fract},
1174 @code{_Sat unsigned short _Fract},
1175 @code{_Sat unsigned _Fract},
1176 @code{_Sat unsigned long _Fract},
1177 @code{_Sat unsigned long long _Fract},
1178 @code{short _Accum},
1179 @code{_Accum},
1180 @code{long _Accum},
1181 @code{long long _Accum},
1182 @code{unsigned short _Accum},
1183 @code{unsigned _Accum},
1184 @code{unsigned long _Accum},
1185 @code{unsigned long long _Accum},
1186 @code{_Sat short _Accum},
1187 @code{_Sat _Accum},
1188 @code{_Sat long _Accum},
1189 @code{_Sat long long _Accum},
1190 @code{_Sat unsigned short _Accum},
1191 @code{_Sat unsigned _Accum},
1192 @code{_Sat unsigned long _Accum},
1193 @code{_Sat unsigned long long _Accum}.
1194
1195 Fixed-point data values contain fractional and optional integral parts.
1196 The format of fixed-point data varies and depends on the target machine.
1197
1198 Support for fixed-point types includes:
1199 @itemize @bullet
1200 @item
1201 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1202 @item
1203 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1204 @item
1205 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1206 @item
1207 binary shift operators (@code{<<}, @code{>>})
1208 @item
1209 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1210 @item
1211 equality operators (@code{==}, @code{!=})
1212 @item
1213 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1214 @code{<<=}, @code{>>=})
1215 @item
1216 conversions to and from integer, floating-point, or fixed-point types
1217 @end itemize
1218
1219 Use a suffix in a fixed-point literal constant:
1220 @itemize
1221 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1222 @code{_Sat short _Fract}
1223 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1224 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1225 @code{_Sat long _Fract}
1226 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1227 @code{_Sat long long _Fract}
1228 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1229 @code{_Sat unsigned short _Fract}
1230 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1231 @code{_Sat unsigned _Fract}
1232 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1233 @code{_Sat unsigned long _Fract}
1234 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1235 and @code{_Sat unsigned long long _Fract}
1236 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1237 @code{_Sat short _Accum}
1238 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1239 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1240 @code{_Sat long _Accum}
1241 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1242 @code{_Sat long long _Accum}
1243 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1244 @code{_Sat unsigned short _Accum}
1245 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1246 @code{_Sat unsigned _Accum}
1247 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1248 @code{_Sat unsigned long _Accum}
1249 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1250 and @code{_Sat unsigned long long _Accum}
1251 @end itemize
1252
1253 GCC support of fixed-point types as specified by the draft technical report
1254 is incomplete:
1255
1256 @itemize @bullet
1257 @item
1258 Pragmas to control overflow and rounding behaviors are not implemented.
1259 @end itemize
1260
1261 Fixed-point types are supported by the DWARF debug information format.
1262
1263 @node Named Address Spaces
1264 @section Named Address Spaces
1265 @cindex Named Address Spaces
1266
1267 As an extension, GNU C supports named address spaces as
1268 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1269 address spaces in GCC will evolve as the draft technical report
1270 changes. Calling conventions for any target might also change. At
1271 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1272 address spaces other than the generic address space.
1273
1274 Address space identifiers may be used exactly like any other C type
1275 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1276 document for more details.
1277
1278 @anchor{AVR Named Address Spaces}
1279 @subsection AVR Named Address Spaces
1280
1281 On the AVR target, there are several address spaces that can be used
1282 in order to put read-only data into the flash memory and access that
1283 data by means of the special instructions @code{LPM} or @code{ELPM}
1284 needed to read from flash.
1285
1286 Per default, any data including read-only data is located in RAM
1287 (the generic address space) so that non-generic address spaces are
1288 needed to locate read-only data in flash memory
1289 @emph{and} to generate the right instructions to access this data
1290 without using (inline) assembler code.
1291
1292 @table @code
1293 @item __flash
1294 @cindex @code{__flash} AVR Named Address Spaces
1295 The @code{__flash} qualifier locates data in the
1296 @code{.progmem.data} section. Data is read using the @code{LPM}
1297 instruction. Pointers to this address space are 16 bits wide.
1298
1299 @item __flash1
1300 @itemx __flash2
1301 @itemx __flash3
1302 @itemx __flash4
1303 @itemx __flash5
1304 @cindex @code{__flash1} AVR Named Address Spaces
1305 @cindex @code{__flash2} AVR Named Address Spaces
1306 @cindex @code{__flash3} AVR Named Address Spaces
1307 @cindex @code{__flash4} AVR Named Address Spaces
1308 @cindex @code{__flash5} AVR Named Address Spaces
1309 These are 16-bit address spaces locating data in section
1310 @code{.progmem@var{N}.data} where @var{N} refers to
1311 address space @code{__flash@var{N}}.
1312 The compiler sets the @code{RAMPZ} segment register appropriately
1313 before reading data by means of the @code{ELPM} instruction.
1314
1315 @item __memx
1316 @cindex @code{__memx} AVR Named Address Spaces
1317 This is a 24-bit address space that linearizes flash and RAM:
1318 If the high bit of the address is set, data is read from
1319 RAM using the lower two bytes as RAM address.
1320 If the high bit of the address is clear, data is read from flash
1321 with @code{RAMPZ} set according to the high byte of the address.
1322 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1323
1324 Objects in this address space are located in @code{.progmemx.data}.
1325 @end table
1326
1327 @b{Example}
1328
1329 @smallexample
1330 char my_read (const __flash char ** p)
1331 @{
1332 /* p is a pointer to RAM that points to a pointer to flash.
1333 The first indirection of p reads that flash pointer
1334 from RAM and the second indirection reads a char from this
1335 flash address. */
1336
1337 return **p;
1338 @}
1339
1340 /* Locate array[] in flash memory */
1341 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1342
1343 int i = 1;
1344
1345 int main (void)
1346 @{
1347 /* Return 17 by reading from flash memory */
1348 return array[array[i]];
1349 @}
1350 @end smallexample
1351
1352 @noindent
1353 For each named address space supported by avr-gcc there is an equally
1354 named but uppercase built-in macro defined.
1355 The purpose is to facilitate testing if respective address space
1356 support is available or not:
1357
1358 @smallexample
1359 #ifdef __FLASH
1360 const __flash int var = 1;
1361
1362 int read_var (void)
1363 @{
1364 return var;
1365 @}
1366 #else
1367 #include <avr/pgmspace.h> /* From AVR-LibC */
1368
1369 const int var PROGMEM = 1;
1370
1371 int read_var (void)
1372 @{
1373 return (int) pgm_read_word (&var);
1374 @}
1375 #endif /* __FLASH */
1376 @end smallexample
1377
1378 @noindent
1379 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1380 locates data in flash but
1381 accesses to these data read from generic address space, i.e.@:
1382 from RAM,
1383 so that you need special accessors like @code{pgm_read_byte}
1384 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1385 together with attribute @code{progmem}.
1386
1387 @noindent
1388 @b{Limitations and caveats}
1389
1390 @itemize
1391 @item
1392 Reading across the 64@tie{}KiB section boundary of
1393 the @code{__flash} or @code{__flash@var{N}} address spaces
1394 shows undefined behavior. The only address space that
1395 supports reading across the 64@tie{}KiB flash segment boundaries is
1396 @code{__memx}.
1397
1398 @item
1399 If you use one of the @code{__flash@var{N}} address spaces
1400 you must arrange your linker script to locate the
1401 @code{.progmem@var{N}.data} sections according to your needs.
1402
1403 @item
1404 Any data or pointers to the non-generic address spaces must
1405 be qualified as @code{const}, i.e.@: as read-only data.
1406 This still applies if the data in one of these address
1407 spaces like software version number or calibration lookup table are intended to
1408 be changed after load time by, say, a boot loader. In this case
1409 the right qualification is @code{const} @code{volatile} so that the compiler
1410 must not optimize away known values or insert them
1411 as immediates into operands of instructions.
1412
1413 @item
1414 The following code initializes a variable @code{pfoo}
1415 located in static storage with a 24-bit address:
1416 @smallexample
1417 extern const __memx char foo;
1418 const __memx void *pfoo = &foo;
1419 @end smallexample
1420
1421 @noindent
1422 Such code requires at least binutils 2.23, see
1423 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1424
1425 @item
1426 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1427 Data can be put into and read from flash memory by means of
1428 attribute @code{progmem}, see @ref{AVR Variable Attributes}.
1429
1430 @end itemize
1431
1432 @subsection M32C Named Address Spaces
1433 @cindex @code{__far} M32C Named Address Spaces
1434
1435 On the M32C target, with the R8C and M16C CPU variants, variables
1436 qualified with @code{__far} are accessed using 32-bit addresses in
1437 order to access memory beyond the first 64@tie{}Ki bytes. If
1438 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1439 effect.
1440
1441 @subsection RL78 Named Address Spaces
1442 @cindex @code{__far} RL78 Named Address Spaces
1443
1444 On the RL78 target, variables qualified with @code{__far} are accessed
1445 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1446 addresses. Non-far variables are assumed to appear in the topmost
1447 64@tie{}KiB of the address space.
1448
1449 @subsection SPU Named Address Spaces
1450 @cindex @code{__ea} SPU Named Address Spaces
1451
1452 On the SPU target variables may be declared as
1453 belonging to another address space by qualifying the type with the
1454 @code{__ea} address space identifier:
1455
1456 @smallexample
1457 extern int __ea i;
1458 @end smallexample
1459
1460 @noindent
1461 The compiler generates special code to access the variable @code{i}.
1462 It may use runtime library
1463 support, or generate special machine instructions to access that address
1464 space.
1465
1466 @subsection x86 Named Address Spaces
1467 @cindex x86 named address spaces
1468
1469 On the x86 target, variables may be declared as being relative
1470 to the @code{%fs} or @code{%gs} segments.
1471
1472 @table @code
1473 @item __seg_fs
1474 @itemx __seg_gs
1475 @cindex @code{__seg_fs} x86 named address space
1476 @cindex @code{__seg_gs} x86 named address space
1477 The object is accessed with the respective segment override prefix.
1478
1479 The respective segment base must be set via some method specific to
1480 the operating system. Rather than require an expensive system call
1481 to retrieve the segment base, these address spaces are not considered
1482 to be subspaces of the generic (flat) address space. This means that
1483 explicit casts are required to convert pointers between these address
1484 spaces and the generic address space. In practice the application
1485 should cast to @code{uintptr_t} and apply the segment base offset
1486 that it installed previously.
1487
1488 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1489 defined when these address spaces are supported.
1490 @end table
1491
1492 @node Zero Length
1493 @section Arrays of Length Zero
1494 @cindex arrays of length zero
1495 @cindex zero-length arrays
1496 @cindex length-zero arrays
1497 @cindex flexible array members
1498
1499 Zero-length arrays are allowed in GNU C@. They are very useful as the
1500 last element of a structure that is really a header for a variable-length
1501 object:
1502
1503 @smallexample
1504 struct line @{
1505 int length;
1506 char contents[0];
1507 @};
1508
1509 struct line *thisline = (struct line *)
1510 malloc (sizeof (struct line) + this_length);
1511 thisline->length = this_length;
1512 @end smallexample
1513
1514 In ISO C90, you would have to give @code{contents} a length of 1, which
1515 means either you waste space or complicate the argument to @code{malloc}.
1516
1517 In ISO C99, you would use a @dfn{flexible array member}, which is
1518 slightly different in syntax and semantics:
1519
1520 @itemize @bullet
1521 @item
1522 Flexible array members are written as @code{contents[]} without
1523 the @code{0}.
1524
1525 @item
1526 Flexible array members have incomplete type, and so the @code{sizeof}
1527 operator may not be applied. As a quirk of the original implementation
1528 of zero-length arrays, @code{sizeof} evaluates to zero.
1529
1530 @item
1531 Flexible array members may only appear as the last member of a
1532 @code{struct} that is otherwise non-empty.
1533
1534 @item
1535 A structure containing a flexible array member, or a union containing
1536 such a structure (possibly recursively), may not be a member of a
1537 structure or an element of an array. (However, these uses are
1538 permitted by GCC as extensions.)
1539 @end itemize
1540
1541 Non-empty initialization of zero-length
1542 arrays is treated like any case where there are more initializer
1543 elements than the array holds, in that a suitable warning about ``excess
1544 elements in array'' is given, and the excess elements (all of them, in
1545 this case) are ignored.
1546
1547 GCC allows static initialization of flexible array members.
1548 This is equivalent to defining a new structure containing the original
1549 structure followed by an array of sufficient size to contain the data.
1550 E.g.@: in the following, @code{f1} is constructed as if it were declared
1551 like @code{f2}.
1552
1553 @smallexample
1554 struct f1 @{
1555 int x; int y[];
1556 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1557
1558 struct f2 @{
1559 struct f1 f1; int data[3];
1560 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1561 @end smallexample
1562
1563 @noindent
1564 The convenience of this extension is that @code{f1} has the desired
1565 type, eliminating the need to consistently refer to @code{f2.f1}.
1566
1567 This has symmetry with normal static arrays, in that an array of
1568 unknown size is also written with @code{[]}.
1569
1570 Of course, this extension only makes sense if the extra data comes at
1571 the end of a top-level object, as otherwise we would be overwriting
1572 data at subsequent offsets. To avoid undue complication and confusion
1573 with initialization of deeply nested arrays, we simply disallow any
1574 non-empty initialization except when the structure is the top-level
1575 object. For example:
1576
1577 @smallexample
1578 struct foo @{ int x; int y[]; @};
1579 struct bar @{ struct foo z; @};
1580
1581 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1582 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1583 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1584 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1585 @end smallexample
1586
1587 @node Empty Structures
1588 @section Structures with No Members
1589 @cindex empty structures
1590 @cindex zero-size structures
1591
1592 GCC permits a C structure to have no members:
1593
1594 @smallexample
1595 struct empty @{
1596 @};
1597 @end smallexample
1598
1599 The structure has size zero. In C++, empty structures are part
1600 of the language. G++ treats empty structures as if they had a single
1601 member of type @code{char}.
1602
1603 @node Variable Length
1604 @section Arrays of Variable Length
1605 @cindex variable-length arrays
1606 @cindex arrays of variable length
1607 @cindex VLAs
1608
1609 Variable-length automatic arrays are allowed in ISO C99, and as an
1610 extension GCC accepts them in C90 mode and in C++. These arrays are
1611 declared like any other automatic arrays, but with a length that is not
1612 a constant expression. The storage is allocated at the point of
1613 declaration and deallocated when the block scope containing the declaration
1614 exits. For
1615 example:
1616
1617 @smallexample
1618 FILE *
1619 concat_fopen (char *s1, char *s2, char *mode)
1620 @{
1621 char str[strlen (s1) + strlen (s2) + 1];
1622 strcpy (str, s1);
1623 strcat (str, s2);
1624 return fopen (str, mode);
1625 @}
1626 @end smallexample
1627
1628 @cindex scope of a variable length array
1629 @cindex variable-length array scope
1630 @cindex deallocating variable length arrays
1631 Jumping or breaking out of the scope of the array name deallocates the
1632 storage. Jumping into the scope is not allowed; you get an error
1633 message for it.
1634
1635 @cindex variable-length array in a structure
1636 As an extension, GCC accepts variable-length arrays as a member of
1637 a structure or a union. For example:
1638
1639 @smallexample
1640 void
1641 foo (int n)
1642 @{
1643 struct S @{ int x[n]; @};
1644 @}
1645 @end smallexample
1646
1647 @cindex @code{alloca} vs variable-length arrays
1648 You can use the function @code{alloca} to get an effect much like
1649 variable-length arrays. The function @code{alloca} is available in
1650 many other C implementations (but not in all). On the other hand,
1651 variable-length arrays are more elegant.
1652
1653 There are other differences between these two methods. Space allocated
1654 with @code{alloca} exists until the containing @emph{function} returns.
1655 The space for a variable-length array is deallocated as soon as the array
1656 name's scope ends, unless you also use @code{alloca} in this scope.
1657
1658 You can also use variable-length arrays as arguments to functions:
1659
1660 @smallexample
1661 struct entry
1662 tester (int len, char data[len][len])
1663 @{
1664 /* @r{@dots{}} */
1665 @}
1666 @end smallexample
1667
1668 The length of an array is computed once when the storage is allocated
1669 and is remembered for the scope of the array in case you access it with
1670 @code{sizeof}.
1671
1672 If you want to pass the array first and the length afterward, you can
1673 use a forward declaration in the parameter list---another GNU extension.
1674
1675 @smallexample
1676 struct entry
1677 tester (int len; char data[len][len], int len)
1678 @{
1679 /* @r{@dots{}} */
1680 @}
1681 @end smallexample
1682
1683 @cindex parameter forward declaration
1684 The @samp{int len} before the semicolon is a @dfn{parameter forward
1685 declaration}, and it serves the purpose of making the name @code{len}
1686 known when the declaration of @code{data} is parsed.
1687
1688 You can write any number of such parameter forward declarations in the
1689 parameter list. They can be separated by commas or semicolons, but the
1690 last one must end with a semicolon, which is followed by the ``real''
1691 parameter declarations. Each forward declaration must match a ``real''
1692 declaration in parameter name and data type. ISO C99 does not support
1693 parameter forward declarations.
1694
1695 @node Variadic Macros
1696 @section Macros with a Variable Number of Arguments.
1697 @cindex variable number of arguments
1698 @cindex macro with variable arguments
1699 @cindex rest argument (in macro)
1700 @cindex variadic macros
1701
1702 In the ISO C standard of 1999, a macro can be declared to accept a
1703 variable number of arguments much as a function can. The syntax for
1704 defining the macro is similar to that of a function. Here is an
1705 example:
1706
1707 @smallexample
1708 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1709 @end smallexample
1710
1711 @noindent
1712 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1713 such a macro, it represents the zero or more tokens until the closing
1714 parenthesis that ends the invocation, including any commas. This set of
1715 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1716 wherever it appears. See the CPP manual for more information.
1717
1718 GCC has long supported variadic macros, and used a different syntax that
1719 allowed you to give a name to the variable arguments just like any other
1720 argument. Here is an example:
1721
1722 @smallexample
1723 #define debug(format, args...) fprintf (stderr, format, args)
1724 @end smallexample
1725
1726 @noindent
1727 This is in all ways equivalent to the ISO C example above, but arguably
1728 more readable and descriptive.
1729
1730 GNU CPP has two further variadic macro extensions, and permits them to
1731 be used with either of the above forms of macro definition.
1732
1733 In standard C, you are not allowed to leave the variable argument out
1734 entirely; but you are allowed to pass an empty argument. For example,
1735 this invocation is invalid in ISO C, because there is no comma after
1736 the string:
1737
1738 @smallexample
1739 debug ("A message")
1740 @end smallexample
1741
1742 GNU CPP permits you to completely omit the variable arguments in this
1743 way. In the above examples, the compiler would complain, though since
1744 the expansion of the macro still has the extra comma after the format
1745 string.
1746
1747 To help solve this problem, CPP behaves specially for variable arguments
1748 used with the token paste operator, @samp{##}. If instead you write
1749
1750 @smallexample
1751 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1752 @end smallexample
1753
1754 @noindent
1755 and if the variable arguments are omitted or empty, the @samp{##}
1756 operator causes the preprocessor to remove the comma before it. If you
1757 do provide some variable arguments in your macro invocation, GNU CPP
1758 does not complain about the paste operation and instead places the
1759 variable arguments after the comma. Just like any other pasted macro
1760 argument, these arguments are not macro expanded.
1761
1762 @node Escaped Newlines
1763 @section Slightly Looser Rules for Escaped Newlines
1764 @cindex escaped newlines
1765 @cindex newlines (escaped)
1766
1767 The preprocessor treatment of escaped newlines is more relaxed
1768 than that specified by the C90 standard, which requires the newline
1769 to immediately follow a backslash.
1770 GCC's implementation allows whitespace in the form
1771 of spaces, horizontal and vertical tabs, and form feeds between the
1772 backslash and the subsequent newline. The preprocessor issues a
1773 warning, but treats it as a valid escaped newline and combines the two
1774 lines to form a single logical line. This works within comments and
1775 tokens, as well as between tokens. Comments are @emph{not} treated as
1776 whitespace for the purposes of this relaxation, since they have not
1777 yet been replaced with spaces.
1778
1779 @node Subscripting
1780 @section Non-Lvalue Arrays May Have Subscripts
1781 @cindex subscripting
1782 @cindex arrays, non-lvalue
1783
1784 @cindex subscripting and function values
1785 In ISO C99, arrays that are not lvalues still decay to pointers, and
1786 may be subscripted, although they may not be modified or used after
1787 the next sequence point and the unary @samp{&} operator may not be
1788 applied to them. As an extension, GNU C allows such arrays to be
1789 subscripted in C90 mode, though otherwise they do not decay to
1790 pointers outside C99 mode. For example,
1791 this is valid in GNU C though not valid in C90:
1792
1793 @smallexample
1794 @group
1795 struct foo @{int a[4];@};
1796
1797 struct foo f();
1798
1799 bar (int index)
1800 @{
1801 return f().a[index];
1802 @}
1803 @end group
1804 @end smallexample
1805
1806 @node Pointer Arith
1807 @section Arithmetic on @code{void}- and Function-Pointers
1808 @cindex void pointers, arithmetic
1809 @cindex void, size of pointer to
1810 @cindex function pointers, arithmetic
1811 @cindex function, size of pointer to
1812
1813 In GNU C, addition and subtraction operations are supported on pointers to
1814 @code{void} and on pointers to functions. This is done by treating the
1815 size of a @code{void} or of a function as 1.
1816
1817 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1818 and on function types, and returns 1.
1819
1820 @opindex Wpointer-arith
1821 The option @option{-Wpointer-arith} requests a warning if these extensions
1822 are used.
1823
1824 @node Pointers to Arrays
1825 @section Pointers to Arrays with Qualifiers Work as Expected
1826 @cindex pointers to arrays
1827 @cindex const qualifier
1828
1829 In GNU C, pointers to arrays with qualifiers work similar to pointers
1830 to other qualified types. For example, a value of type @code{int (*)[5]}
1831 can be used to initialize a variable of type @code{const int (*)[5]}.
1832 These types are incompatible in ISO C because the @code{const} qualifier
1833 is formally attached to the element type of the array and not the
1834 array itself.
1835
1836 @smallexample
1837 extern void
1838 transpose (int N, int M, double out[M][N], const double in[N][M]);
1839 double x[3][2];
1840 double y[2][3];
1841 @r{@dots{}}
1842 transpose(3, 2, y, x);
1843 @end smallexample
1844
1845 @node Initializers
1846 @section Non-Constant Initializers
1847 @cindex initializers, non-constant
1848 @cindex non-constant initializers
1849
1850 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1851 automatic variable are not required to be constant expressions in GNU C@.
1852 Here is an example of an initializer with run-time varying elements:
1853
1854 @smallexample
1855 foo (float f, float g)
1856 @{
1857 float beat_freqs[2] = @{ f-g, f+g @};
1858 /* @r{@dots{}} */
1859 @}
1860 @end smallexample
1861
1862 @node Compound Literals
1863 @section Compound Literals
1864 @cindex constructor expressions
1865 @cindex initializations in expressions
1866 @cindex structures, constructor expression
1867 @cindex expressions, constructor
1868 @cindex compound literals
1869 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1870
1871 A compound literal looks like a cast of a brace-enclosed aggregate
1872 initializer list. Its value is an object of the type specified in
1873 the cast, containing the elements specified in the initializer.
1874 Unlike the result of a cast, a compound literal is an lvalue. ISO
1875 C99 and later support compound literals. As an extension, GCC
1876 supports compound literals also in C90 mode and in C++, although
1877 as explained below, the C++ semantics are somewhat different.
1878
1879 Usually, the specified type of a compound literal is a structure. Assume
1880 that @code{struct foo} and @code{structure} are declared as shown:
1881
1882 @smallexample
1883 struct foo @{int a; char b[2];@} structure;
1884 @end smallexample
1885
1886 @noindent
1887 Here is an example of constructing a @code{struct foo} with a compound literal:
1888
1889 @smallexample
1890 structure = ((struct foo) @{x + y, 'a', 0@});
1891 @end smallexample
1892
1893 @noindent
1894 This is equivalent to writing the following:
1895
1896 @smallexample
1897 @{
1898 struct foo temp = @{x + y, 'a', 0@};
1899 structure = temp;
1900 @}
1901 @end smallexample
1902
1903 You can also construct an array, though this is dangerous in C++, as
1904 explained below. If all the elements of the compound literal are
1905 (made up of) simple constant expressions suitable for use in
1906 initializers of objects of static storage duration, then the compound
1907 literal can be coerced to a pointer to its first element and used in
1908 such an initializer, as shown here:
1909
1910 @smallexample
1911 char **foo = (char *[]) @{ "x", "y", "z" @};
1912 @end smallexample
1913
1914 Compound literals for scalar types and union types are also allowed. In
1915 the following example the variable @code{i} is initialized to the value
1916 @code{2}, the result of incrementing the unnamed object created by
1917 the compound literal.
1918
1919 @smallexample
1920 int i = ++(int) @{ 1 @};
1921 @end smallexample
1922
1923 As a GNU extension, GCC allows initialization of objects with static storage
1924 duration by compound literals (which is not possible in ISO C99 because
1925 the initializer is not a constant).
1926 It is handled as if the object were initialized only with the brace-enclosed
1927 list if the types of the compound literal and the object match.
1928 The elements of the compound literal must be constant.
1929 If the object being initialized has array type of unknown size, the size is
1930 determined by the size of the compound literal.
1931
1932 @smallexample
1933 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1934 static int y[] = (int []) @{1, 2, 3@};
1935 static int z[] = (int [3]) @{1@};
1936 @end smallexample
1937
1938 @noindent
1939 The above lines are equivalent to the following:
1940 @smallexample
1941 static struct foo x = @{1, 'a', 'b'@};
1942 static int y[] = @{1, 2, 3@};
1943 static int z[] = @{1, 0, 0@};
1944 @end smallexample
1945
1946 In C, a compound literal designates an unnamed object with static or
1947 automatic storage duration. In C++, a compound literal designates a
1948 temporary object that only lives until the end of its full-expression.
1949 As a result, well-defined C code that takes the address of a subobject
1950 of a compound literal can be undefined in C++, so G++ rejects
1951 the conversion of a temporary array to a pointer. For instance, if
1952 the array compound literal example above appeared inside a function,
1953 any subsequent use of @code{foo} in C++ would have undefined behavior
1954 because the lifetime of the array ends after the declaration of @code{foo}.
1955
1956 As an optimization, G++ sometimes gives array compound literals longer
1957 lifetimes: when the array either appears outside a function or has
1958 a @code{const}-qualified type. If @code{foo} and its initializer had
1959 elements of type @code{char *const} rather than @code{char *}, or if
1960 @code{foo} were a global variable, the array would have static storage
1961 duration. But it is probably safest just to avoid the use of array
1962 compound literals in C++ code.
1963
1964 @node Designated Inits
1965 @section Designated Initializers
1966 @cindex initializers with labeled elements
1967 @cindex labeled elements in initializers
1968 @cindex case labels in initializers
1969 @cindex designated initializers
1970
1971 Standard C90 requires the elements of an initializer to appear in a fixed
1972 order, the same as the order of the elements in the array or structure
1973 being initialized.
1974
1975 In ISO C99 you can give the elements in any order, specifying the array
1976 indices or structure field names they apply to, and GNU C allows this as
1977 an extension in C90 mode as well. This extension is not
1978 implemented in GNU C++.
1979
1980 To specify an array index, write
1981 @samp{[@var{index}] =} before the element value. For example,
1982
1983 @smallexample
1984 int a[6] = @{ [4] = 29, [2] = 15 @};
1985 @end smallexample
1986
1987 @noindent
1988 is equivalent to
1989
1990 @smallexample
1991 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1992 @end smallexample
1993
1994 @noindent
1995 The index values must be constant expressions, even if the array being
1996 initialized is automatic.
1997
1998 An alternative syntax for this that has been obsolete since GCC 2.5 but
1999 GCC still accepts is to write @samp{[@var{index}]} before the element
2000 value, with no @samp{=}.
2001
2002 To initialize a range of elements to the same value, write
2003 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
2004 extension. For example,
2005
2006 @smallexample
2007 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2008 @end smallexample
2009
2010 @noindent
2011 If the value in it has side-effects, the side-effects happen only once,
2012 not for each initialized field by the range initializer.
2013
2014 @noindent
2015 Note that the length of the array is the highest value specified
2016 plus one.
2017
2018 In a structure initializer, specify the name of a field to initialize
2019 with @samp{.@var{fieldname} =} before the element value. For example,
2020 given the following structure,
2021
2022 @smallexample
2023 struct point @{ int x, y; @};
2024 @end smallexample
2025
2026 @noindent
2027 the following initialization
2028
2029 @smallexample
2030 struct point p = @{ .y = yvalue, .x = xvalue @};
2031 @end smallexample
2032
2033 @noindent
2034 is equivalent to
2035
2036 @smallexample
2037 struct point p = @{ xvalue, yvalue @};
2038 @end smallexample
2039
2040 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2041 @samp{@var{fieldname}:}, as shown here:
2042
2043 @smallexample
2044 struct point p = @{ y: yvalue, x: xvalue @};
2045 @end smallexample
2046
2047 Omitted field members are implicitly initialized the same as objects
2048 that have static storage duration.
2049
2050 @cindex designators
2051 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2052 @dfn{designator}. You can also use a designator (or the obsolete colon
2053 syntax) when initializing a union, to specify which element of the union
2054 should be used. For example,
2055
2056 @smallexample
2057 union foo @{ int i; double d; @};
2058
2059 union foo f = @{ .d = 4 @};
2060 @end smallexample
2061
2062 @noindent
2063 converts 4 to a @code{double} to store it in the union using
2064 the second element. By contrast, casting 4 to type @code{union foo}
2065 stores it into the union as the integer @code{i}, since it is
2066 an integer. (@xref{Cast to Union}.)
2067
2068 You can combine this technique of naming elements with ordinary C
2069 initialization of successive elements. Each initializer element that
2070 does not have a designator applies to the next consecutive element of the
2071 array or structure. For example,
2072
2073 @smallexample
2074 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2075 @end smallexample
2076
2077 @noindent
2078 is equivalent to
2079
2080 @smallexample
2081 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2082 @end smallexample
2083
2084 Labeling the elements of an array initializer is especially useful
2085 when the indices are characters or belong to an @code{enum} type.
2086 For example:
2087
2088 @smallexample
2089 int whitespace[256]
2090 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2091 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2092 @end smallexample
2093
2094 @cindex designator lists
2095 You can also write a series of @samp{.@var{fieldname}} and
2096 @samp{[@var{index}]} designators before an @samp{=} to specify a
2097 nested subobject to initialize; the list is taken relative to the
2098 subobject corresponding to the closest surrounding brace pair. For
2099 example, with the @samp{struct point} declaration above:
2100
2101 @smallexample
2102 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2103 @end smallexample
2104
2105 @noindent
2106 If the same field is initialized multiple times, it has the value from
2107 the last initialization. If any such overridden initialization has
2108 side-effect, it is unspecified whether the side-effect happens or not.
2109 Currently, GCC discards them and issues a warning.
2110
2111 @node Case Ranges
2112 @section Case Ranges
2113 @cindex case ranges
2114 @cindex ranges in case statements
2115
2116 You can specify a range of consecutive values in a single @code{case} label,
2117 like this:
2118
2119 @smallexample
2120 case @var{low} ... @var{high}:
2121 @end smallexample
2122
2123 @noindent
2124 This has the same effect as the proper number of individual @code{case}
2125 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2126
2127 This feature is especially useful for ranges of ASCII character codes:
2128
2129 @smallexample
2130 case 'A' ... 'Z':
2131 @end smallexample
2132
2133 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2134 it may be parsed wrong when you use it with integer values. For example,
2135 write this:
2136
2137 @smallexample
2138 case 1 ... 5:
2139 @end smallexample
2140
2141 @noindent
2142 rather than this:
2143
2144 @smallexample
2145 case 1...5:
2146 @end smallexample
2147
2148 @node Cast to Union
2149 @section Cast to a Union Type
2150 @cindex cast to a union
2151 @cindex union, casting to a
2152
2153 A cast to union type looks similar to other casts, except that the type
2154 specified is a union type. You can specify the type either with the
2155 @code{union} keyword or with a @code{typedef} name that refers to
2156 a union. A cast to a union actually creates a compound literal and
2157 yields an lvalue, not an rvalue like true casts do.
2158 (@xref{Compound Literals}.)
2159
2160 The types that may be cast to the union type are those of the members
2161 of the union. Thus, given the following union and variables:
2162
2163 @smallexample
2164 union foo @{ int i; double d; @};
2165 int x;
2166 double y;
2167 @end smallexample
2168
2169 @noindent
2170 both @code{x} and @code{y} can be cast to type @code{union foo}.
2171
2172 Using the cast as the right-hand side of an assignment to a variable of
2173 union type is equivalent to storing in a member of the union:
2174
2175 @smallexample
2176 union foo u;
2177 /* @r{@dots{}} */
2178 u = (union foo) x @equiv{} u.i = x
2179 u = (union foo) y @equiv{} u.d = y
2180 @end smallexample
2181
2182 You can also use the union cast as a function argument:
2183
2184 @smallexample
2185 void hack (union foo);
2186 /* @r{@dots{}} */
2187 hack ((union foo) x);
2188 @end smallexample
2189
2190 @node Mixed Declarations
2191 @section Mixed Declarations and Code
2192 @cindex mixed declarations and code
2193 @cindex declarations, mixed with code
2194 @cindex code, mixed with declarations
2195
2196 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2197 within compound statements. As an extension, GNU C also allows this in
2198 C90 mode. For example, you could do:
2199
2200 @smallexample
2201 int i;
2202 /* @r{@dots{}} */
2203 i++;
2204 int j = i + 2;
2205 @end smallexample
2206
2207 Each identifier is visible from where it is declared until the end of
2208 the enclosing block.
2209
2210 @node Function Attributes
2211 @section Declaring Attributes of Functions
2212 @cindex function attributes
2213 @cindex declaring attributes of functions
2214 @cindex @code{volatile} applied to function
2215 @cindex @code{const} applied to function
2216
2217 In GNU C, you can use function attributes to declare certain things
2218 about functions called in your program which help the compiler
2219 optimize calls and check your code more carefully. For example, you
2220 can use attributes to declare that a function never returns
2221 (@code{noreturn}), returns a value depending only on its arguments
2222 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2223
2224 You can also use attributes to control memory placement, code
2225 generation options or call/return conventions within the function
2226 being annotated. Many of these attributes are target-specific. For
2227 example, many targets support attributes for defining interrupt
2228 handler functions, which typically must follow special register usage
2229 and return conventions.
2230
2231 Function attributes are introduced by the @code{__attribute__} keyword
2232 on a declaration, followed by an attribute specification inside double
2233 parentheses. You can specify multiple attributes in a declaration by
2234 separating them by commas within the double parentheses or by
2235 immediately following an attribute declaration with another attribute
2236 declaration. @xref{Attribute Syntax}, for the exact rules on
2237 attribute syntax and placement.
2238
2239 GCC also supports attributes on
2240 variable declarations (@pxref{Variable Attributes}),
2241 labels (@pxref{Label Attributes}),
2242 enumerators (@pxref{Enumerator Attributes}),
2243 and types (@pxref{Type Attributes}).
2244
2245 There is some overlap between the purposes of attributes and pragmas
2246 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2247 found convenient to use @code{__attribute__} to achieve a natural
2248 attachment of attributes to their corresponding declarations, whereas
2249 @code{#pragma} is of use for compatibility with other compilers
2250 or constructs that do not naturally form part of the grammar.
2251
2252 In addition to the attributes documented here,
2253 GCC plugins may provide their own attributes.
2254
2255 @menu
2256 * Common Function Attributes::
2257 * AArch64 Function Attributes::
2258 * ARC Function Attributes::
2259 * ARM Function Attributes::
2260 * AVR Function Attributes::
2261 * Blackfin Function Attributes::
2262 * CR16 Function Attributes::
2263 * Epiphany Function Attributes::
2264 * H8/300 Function Attributes::
2265 * IA-64 Function Attributes::
2266 * M32C Function Attributes::
2267 * M32R/D Function Attributes::
2268 * m68k Function Attributes::
2269 * MCORE Function Attributes::
2270 * MeP Function Attributes::
2271 * MicroBlaze Function Attributes::
2272 * Microsoft Windows Function Attributes::
2273 * MIPS Function Attributes::
2274 * MSP430 Function Attributes::
2275 * NDS32 Function Attributes::
2276 * Nios II Function Attributes::
2277 * Nvidia PTX Function Attributes::
2278 * PowerPC Function Attributes::
2279 * RL78 Function Attributes::
2280 * RX Function Attributes::
2281 * S/390 Function Attributes::
2282 * SH Function Attributes::
2283 * SPU Function Attributes::
2284 * Symbian OS Function Attributes::
2285 * V850 Function Attributes::
2286 * Visium Function Attributes::
2287 * x86 Function Attributes::
2288 * Xstormy16 Function Attributes::
2289 @end menu
2290
2291 @node Common Function Attributes
2292 @subsection Common Function Attributes
2293
2294 The following attributes are supported on most targets.
2295
2296 @table @code
2297 @c Keep this table alphabetized by attribute name. Treat _ as space.
2298
2299 @item alias ("@var{target}")
2300 @cindex @code{alias} function attribute
2301 The @code{alias} attribute causes the declaration to be emitted as an
2302 alias for another symbol, which must be specified. For instance,
2303
2304 @smallexample
2305 void __f () @{ /* @r{Do something.} */; @}
2306 void f () __attribute__ ((weak, alias ("__f")));
2307 @end smallexample
2308
2309 @noindent
2310 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2311 mangled name for the target must be used. It is an error if @samp{__f}
2312 is not defined in the same translation unit.
2313
2314 This attribute requires assembler and object file support,
2315 and may not be available on all targets.
2316
2317 @item aligned (@var{alignment})
2318 @cindex @code{aligned} function attribute
2319 This attribute specifies a minimum alignment for the function,
2320 measured in bytes.
2321
2322 You cannot use this attribute to decrease the alignment of a function,
2323 only to increase it. However, when you explicitly specify a function
2324 alignment this overrides the effect of the
2325 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2326 function.
2327
2328 Note that the effectiveness of @code{aligned} attributes may be
2329 limited by inherent limitations in your linker. On many systems, the
2330 linker is only able to arrange for functions to be aligned up to a
2331 certain maximum alignment. (For some linkers, the maximum supported
2332 alignment may be very very small.) See your linker documentation for
2333 further information.
2334
2335 The @code{aligned} attribute can also be used for variables and fields
2336 (@pxref{Variable Attributes}.)
2337
2338 @item alloc_align
2339 @cindex @code{alloc_align} function attribute
2340 The @code{alloc_align} attribute is used to tell the compiler that the
2341 function return value points to memory, where the returned pointer minimum
2342 alignment is given by one of the functions parameters. GCC uses this
2343 information to improve pointer alignment analysis.
2344
2345 The function parameter denoting the allocated alignment is specified by
2346 one integer argument, whose number is the argument of the attribute.
2347 Argument numbering starts at one.
2348
2349 For instance,
2350
2351 @smallexample
2352 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2353 @end smallexample
2354
2355 @noindent
2356 declares that @code{my_memalign} returns memory with minimum alignment
2357 given by parameter 1.
2358
2359 @item alloc_size
2360 @cindex @code{alloc_size} function attribute
2361 The @code{alloc_size} attribute is used to tell the compiler that the
2362 function return value points to memory, where the size is given by
2363 one or two of the functions parameters. GCC uses this
2364 information to improve the correctness of @code{__builtin_object_size}.
2365
2366 The function parameter(s) denoting the allocated size are specified by
2367 one or two integer arguments supplied to the attribute. The allocated size
2368 is either the value of the single function argument specified or the product
2369 of the two function arguments specified. Argument numbering starts at
2370 one.
2371
2372 For instance,
2373
2374 @smallexample
2375 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2376 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2377 @end smallexample
2378
2379 @noindent
2380 declares that @code{my_calloc} returns memory of the size given by
2381 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2382 of the size given by parameter 2.
2383
2384 @item always_inline
2385 @cindex @code{always_inline} function attribute
2386 Generally, functions are not inlined unless optimization is specified.
2387 For functions declared inline, this attribute inlines the function
2388 independent of any restrictions that otherwise apply to inlining.
2389 Failure to inline such a function is diagnosed as an error.
2390 Note that if such a function is called indirectly the compiler may
2391 or may not inline it depending on optimization level and a failure
2392 to inline an indirect call may or may not be diagnosed.
2393
2394 @item artificial
2395 @cindex @code{artificial} function attribute
2396 This attribute is useful for small inline wrappers that if possible
2397 should appear during debugging as a unit. Depending on the debug
2398 info format it either means marking the function as artificial
2399 or using the caller location for all instructions within the inlined
2400 body.
2401
2402 @item assume_aligned
2403 @cindex @code{assume_aligned} function attribute
2404 The @code{assume_aligned} attribute is used to tell the compiler that the
2405 function return value points to memory, where the returned pointer minimum
2406 alignment is given by the first argument.
2407 If the attribute has two arguments, the second argument is misalignment offset.
2408
2409 For instance
2410
2411 @smallexample
2412 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2413 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2414 @end smallexample
2415
2416 @noindent
2417 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2418 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2419 to 8.
2420
2421 @item bnd_instrument
2422 @cindex @code{bnd_instrument} function attribute
2423 The @code{bnd_instrument} attribute on functions is used to inform the
2424 compiler that the function should be instrumented when compiled
2425 with the @option{-fchkp-instrument-marked-only} option.
2426
2427 @item bnd_legacy
2428 @cindex @code{bnd_legacy} function attribute
2429 @cindex Pointer Bounds Checker attributes
2430 The @code{bnd_legacy} attribute on functions is used to inform the
2431 compiler that the function should not be instrumented when compiled
2432 with the @option{-fcheck-pointer-bounds} option.
2433
2434 @item cold
2435 @cindex @code{cold} function attribute
2436 The @code{cold} attribute on functions is used to inform the compiler that
2437 the function is unlikely to be executed. The function is optimized for
2438 size rather than speed and on many targets it is placed into a special
2439 subsection of the text section so all cold functions appear close together,
2440 improving code locality of non-cold parts of program. The paths leading
2441 to calls of cold functions within code are marked as unlikely by the branch
2442 prediction mechanism. It is thus useful to mark functions used to handle
2443 unlikely conditions, such as @code{perror}, as cold to improve optimization
2444 of hot functions that do call marked functions in rare occasions.
2445
2446 When profile feedback is available, via @option{-fprofile-use}, cold functions
2447 are automatically detected and this attribute is ignored.
2448
2449 @item const
2450 @cindex @code{const} function attribute
2451 @cindex functions that have no side effects
2452 Many functions do not examine any values except their arguments, and
2453 have no effects except the return value. Basically this is just slightly
2454 more strict class than the @code{pure} attribute below, since function is not
2455 allowed to read global memory.
2456
2457 @cindex pointer arguments
2458 Note that a function that has pointer arguments and examines the data
2459 pointed to must @emph{not} be declared @code{const}. Likewise, a
2460 function that calls a non-@code{const} function usually must not be
2461 @code{const}. It does not make sense for a @code{const} function to
2462 return @code{void}.
2463
2464 @item constructor
2465 @itemx destructor
2466 @itemx constructor (@var{priority})
2467 @itemx destructor (@var{priority})
2468 @cindex @code{constructor} function attribute
2469 @cindex @code{destructor} function attribute
2470 The @code{constructor} attribute causes the function to be called
2471 automatically before execution enters @code{main ()}. Similarly, the
2472 @code{destructor} attribute causes the function to be called
2473 automatically after @code{main ()} completes or @code{exit ()} is
2474 called. Functions with these attributes are useful for
2475 initializing data that is used implicitly during the execution of
2476 the program.
2477
2478 You may provide an optional integer priority to control the order in
2479 which constructor and destructor functions are run. A constructor
2480 with a smaller priority number runs before a constructor with a larger
2481 priority number; the opposite relationship holds for destructors. So,
2482 if you have a constructor that allocates a resource and a destructor
2483 that deallocates the same resource, both functions typically have the
2484 same priority. The priorities for constructor and destructor
2485 functions are the same as those specified for namespace-scope C++
2486 objects (@pxref{C++ Attributes}).
2487
2488 These attributes are not currently implemented for Objective-C@.
2489
2490 @item deprecated
2491 @itemx deprecated (@var{msg})
2492 @cindex @code{deprecated} function attribute
2493 The @code{deprecated} attribute results in a warning if the function
2494 is used anywhere in the source file. This is useful when identifying
2495 functions that are expected to be removed in a future version of a
2496 program. The warning also includes the location of the declaration
2497 of the deprecated function, to enable users to easily find further
2498 information about why the function is deprecated, or what they should
2499 do instead. Note that the warnings only occurs for uses:
2500
2501 @smallexample
2502 int old_fn () __attribute__ ((deprecated));
2503 int old_fn ();
2504 int (*fn_ptr)() = old_fn;
2505 @end smallexample
2506
2507 @noindent
2508 results in a warning on line 3 but not line 2. The optional @var{msg}
2509 argument, which must be a string, is printed in the warning if
2510 present.
2511
2512 The @code{deprecated} attribute can also be used for variables and
2513 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2514
2515 @item error ("@var{message}")
2516 @itemx warning ("@var{message}")
2517 @cindex @code{error} function attribute
2518 @cindex @code{warning} function attribute
2519 If the @code{error} or @code{warning} attribute
2520 is used on a function declaration and a call to such a function
2521 is not eliminated through dead code elimination or other optimizations,
2522 an error or warning (respectively) that includes @var{message} is diagnosed.
2523 This is useful
2524 for compile-time checking, especially together with @code{__builtin_constant_p}
2525 and inline functions where checking the inline function arguments is not
2526 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2527
2528 While it is possible to leave the function undefined and thus invoke
2529 a link failure (to define the function with
2530 a message in @code{.gnu.warning*} section),
2531 when using these attributes the problem is diagnosed
2532 earlier and with exact location of the call even in presence of inline
2533 functions or when not emitting debugging information.
2534
2535 @item externally_visible
2536 @cindex @code{externally_visible} function attribute
2537 This attribute, attached to a global variable or function, nullifies
2538 the effect of the @option{-fwhole-program} command-line option, so the
2539 object remains visible outside the current compilation unit.
2540
2541 If @option{-fwhole-program} is used together with @option{-flto} and
2542 @command{gold} is used as the linker plugin,
2543 @code{externally_visible} attributes are automatically added to functions
2544 (not variable yet due to a current @command{gold} issue)
2545 that are accessed outside of LTO objects according to resolution file
2546 produced by @command{gold}.
2547 For other linkers that cannot generate resolution file,
2548 explicit @code{externally_visible} attributes are still necessary.
2549
2550 @item flatten
2551 @cindex @code{flatten} function attribute
2552 Generally, inlining into a function is limited. For a function marked with
2553 this attribute, every call inside this function is inlined, if possible.
2554 Whether the function itself is considered for inlining depends on its size and
2555 the current inlining parameters.
2556
2557 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2558 @cindex @code{format} function attribute
2559 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2560 @opindex Wformat
2561 The @code{format} attribute specifies that a function takes @code{printf},
2562 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2563 should be type-checked against a format string. For example, the
2564 declaration:
2565
2566 @smallexample
2567 extern int
2568 my_printf (void *my_object, const char *my_format, ...)
2569 __attribute__ ((format (printf, 2, 3)));
2570 @end smallexample
2571
2572 @noindent
2573 causes the compiler to check the arguments in calls to @code{my_printf}
2574 for consistency with the @code{printf} style format string argument
2575 @code{my_format}.
2576
2577 The parameter @var{archetype} determines how the format string is
2578 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2579 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2580 @code{strfmon}. (You can also use @code{__printf__},
2581 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2582 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2583 @code{ms_strftime} are also present.
2584 @var{archetype} values such as @code{printf} refer to the formats accepted
2585 by the system's C runtime library,
2586 while values prefixed with @samp{gnu_} always refer
2587 to the formats accepted by the GNU C Library. On Microsoft Windows
2588 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2589 @file{msvcrt.dll} library.
2590 The parameter @var{string-index}
2591 specifies which argument is the format string argument (starting
2592 from 1), while @var{first-to-check} is the number of the first
2593 argument to check against the format string. For functions
2594 where the arguments are not available to be checked (such as
2595 @code{vprintf}), specify the third parameter as zero. In this case the
2596 compiler only checks the format string for consistency. For
2597 @code{strftime} formats, the third parameter is required to be zero.
2598 Since non-static C++ methods have an implicit @code{this} argument, the
2599 arguments of such methods should be counted from two, not one, when
2600 giving values for @var{string-index} and @var{first-to-check}.
2601
2602 In the example above, the format string (@code{my_format}) is the second
2603 argument of the function @code{my_print}, and the arguments to check
2604 start with the third argument, so the correct parameters for the format
2605 attribute are 2 and 3.
2606
2607 @opindex ffreestanding
2608 @opindex fno-builtin
2609 The @code{format} attribute allows you to identify your own functions
2610 that take format strings as arguments, so that GCC can check the
2611 calls to these functions for errors. The compiler always (unless
2612 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2613 for the standard library functions @code{printf}, @code{fprintf},
2614 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2615 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2616 warnings are requested (using @option{-Wformat}), so there is no need to
2617 modify the header file @file{stdio.h}. In C99 mode, the functions
2618 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2619 @code{vsscanf} are also checked. Except in strictly conforming C
2620 standard modes, the X/Open function @code{strfmon} is also checked as
2621 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2622 @xref{C Dialect Options,,Options Controlling C Dialect}.
2623
2624 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2625 recognized in the same context. Declarations including these format attributes
2626 are parsed for correct syntax, however the result of checking of such format
2627 strings is not yet defined, and is not carried out by this version of the
2628 compiler.
2629
2630 The target may also provide additional types of format checks.
2631 @xref{Target Format Checks,,Format Checks Specific to Particular
2632 Target Machines}.
2633
2634 @item format_arg (@var{string-index})
2635 @cindex @code{format_arg} function attribute
2636 @opindex Wformat-nonliteral
2637 The @code{format_arg} attribute specifies that a function takes a format
2638 string for a @code{printf}, @code{scanf}, @code{strftime} or
2639 @code{strfmon} style function and modifies it (for example, to translate
2640 it into another language), so the result can be passed to a
2641 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2642 function (with the remaining arguments to the format function the same
2643 as they would have been for the unmodified string). For example, the
2644 declaration:
2645
2646 @smallexample
2647 extern char *
2648 my_dgettext (char *my_domain, const char *my_format)
2649 __attribute__ ((format_arg (2)));
2650 @end smallexample
2651
2652 @noindent
2653 causes the compiler to check the arguments in calls to a @code{printf},
2654 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2655 format string argument is a call to the @code{my_dgettext} function, for
2656 consistency with the format string argument @code{my_format}. If the
2657 @code{format_arg} attribute had not been specified, all the compiler
2658 could tell in such calls to format functions would be that the format
2659 string argument is not constant; this would generate a warning when
2660 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2661 without the attribute.
2662
2663 The parameter @var{string-index} specifies which argument is the format
2664 string argument (starting from one). Since non-static C++ methods have
2665 an implicit @code{this} argument, the arguments of such methods should
2666 be counted from two.
2667
2668 The @code{format_arg} attribute allows you to identify your own
2669 functions that modify format strings, so that GCC can check the
2670 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2671 type function whose operands are a call to one of your own function.
2672 The compiler always treats @code{gettext}, @code{dgettext}, and
2673 @code{dcgettext} in this manner except when strict ISO C support is
2674 requested by @option{-ansi} or an appropriate @option{-std} option, or
2675 @option{-ffreestanding} or @option{-fno-builtin}
2676 is used. @xref{C Dialect Options,,Options
2677 Controlling C Dialect}.
2678
2679 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2680 @code{NSString} reference for compatibility with the @code{format} attribute
2681 above.
2682
2683 The target may also allow additional types in @code{format-arg} attributes.
2684 @xref{Target Format Checks,,Format Checks Specific to Particular
2685 Target Machines}.
2686
2687 @item gnu_inline
2688 @cindex @code{gnu_inline} function attribute
2689 This attribute should be used with a function that is also declared
2690 with the @code{inline} keyword. It directs GCC to treat the function
2691 as if it were defined in gnu90 mode even when compiling in C99 or
2692 gnu99 mode.
2693
2694 If the function is declared @code{extern}, then this definition of the
2695 function is used only for inlining. In no case is the function
2696 compiled as a standalone function, not even if you take its address
2697 explicitly. Such an address becomes an external reference, as if you
2698 had only declared the function, and had not defined it. This has
2699 almost the effect of a macro. The way to use this is to put a
2700 function definition in a header file with this attribute, and put
2701 another copy of the function, without @code{extern}, in a library
2702 file. The definition in the header file causes most calls to the
2703 function to be inlined. If any uses of the function remain, they
2704 refer to the single copy in the library. Note that the two
2705 definitions of the functions need not be precisely the same, although
2706 if they do not have the same effect your program may behave oddly.
2707
2708 In C, if the function is neither @code{extern} nor @code{static}, then
2709 the function is compiled as a standalone function, as well as being
2710 inlined where possible.
2711
2712 This is how GCC traditionally handled functions declared
2713 @code{inline}. Since ISO C99 specifies a different semantics for
2714 @code{inline}, this function attribute is provided as a transition
2715 measure and as a useful feature in its own right. This attribute is
2716 available in GCC 4.1.3 and later. It is available if either of the
2717 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2718 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2719 Function is As Fast As a Macro}.
2720
2721 In C++, this attribute does not depend on @code{extern} in any way,
2722 but it still requires the @code{inline} keyword to enable its special
2723 behavior.
2724
2725 @item hot
2726 @cindex @code{hot} function attribute
2727 The @code{hot} attribute on a function is used to inform the compiler that
2728 the function is a hot spot of the compiled program. The function is
2729 optimized more aggressively and on many targets it is placed into a special
2730 subsection of the text section so all hot functions appear close together,
2731 improving locality.
2732
2733 When profile feedback is available, via @option{-fprofile-use}, hot functions
2734 are automatically detected and this attribute is ignored.
2735
2736 @item ifunc ("@var{resolver}")
2737 @cindex @code{ifunc} function attribute
2738 @cindex indirect functions
2739 @cindex functions that are dynamically resolved
2740 The @code{ifunc} attribute is used to mark a function as an indirect
2741 function using the STT_GNU_IFUNC symbol type extension to the ELF
2742 standard. This allows the resolution of the symbol value to be
2743 determined dynamically at load time, and an optimized version of the
2744 routine can be selected for the particular processor or other system
2745 characteristics determined then. To use this attribute, first define
2746 the implementation functions available, and a resolver function that
2747 returns a pointer to the selected implementation function. The
2748 implementation functions' declarations must match the API of the
2749 function being implemented, the resolver's declaration is be a
2750 function returning pointer to void function returning void:
2751
2752 @smallexample
2753 void *my_memcpy (void *dst, const void *src, size_t len)
2754 @{
2755 @dots{}
2756 @}
2757
2758 static void (*resolve_memcpy (void)) (void)
2759 @{
2760 return my_memcpy; // we'll just always select this routine
2761 @}
2762 @end smallexample
2763
2764 @noindent
2765 The exported header file declaring the function the user calls would
2766 contain:
2767
2768 @smallexample
2769 extern void *memcpy (void *, const void *, size_t);
2770 @end smallexample
2771
2772 @noindent
2773 allowing the user to call this as a regular function, unaware of the
2774 implementation. Finally, the indirect function needs to be defined in
2775 the same translation unit as the resolver function:
2776
2777 @smallexample
2778 void *memcpy (void *, const void *, size_t)
2779 __attribute__ ((ifunc ("resolve_memcpy")));
2780 @end smallexample
2781
2782 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
2783 and GNU C Library version 2.11.1 are required to use this feature.
2784
2785 @item interrupt
2786 @itemx interrupt_handler
2787 Many GCC back ends support attributes to indicate that a function is
2788 an interrupt handler, which tells the compiler to generate function
2789 entry and exit sequences that differ from those from regular
2790 functions. The exact syntax and behavior are target-specific;
2791 refer to the following subsections for details.
2792
2793 @item leaf
2794 @cindex @code{leaf} function attribute
2795 Calls to external functions with this attribute must return to the
2796 current compilation unit only by return or by exception handling. In
2797 particular, a leaf function is not allowed to invoke callback functions
2798 passed to it from the current compilation unit, directly call functions
2799 exported by the unit, or @code{longjmp} into the unit. Leaf functions
2800 might still call functions from other compilation units and thus they
2801 are not necessarily leaf in the sense that they contain no function
2802 calls at all.
2803
2804 The attribute is intended for library functions to improve dataflow
2805 analysis. The compiler takes the hint that any data not escaping the
2806 current compilation unit cannot be used or modified by the leaf
2807 function. For example, the @code{sin} function is a leaf function, but
2808 @code{qsort} is not.
2809
2810 Note that leaf functions might indirectly run a signal handler defined
2811 in the current compilation unit that uses static variables. Similarly,
2812 when lazy symbol resolution is in effect, leaf functions might invoke
2813 indirect functions whose resolver function or implementation function is
2814 defined in the current compilation unit and uses static variables. There
2815 is no standard-compliant way to write such a signal handler, resolver
2816 function, or implementation function, and the best that you can do is to
2817 remove the @code{leaf} attribute or mark all such static variables
2818 @code{volatile}. Lastly, for ELF-based systems that support symbol
2819 interposition, care should be taken that functions defined in the
2820 current compilation unit do not unexpectedly interpose other symbols
2821 based on the defined standards mode and defined feature test macros;
2822 otherwise an inadvertent callback would be added.
2823
2824 The attribute has no effect on functions defined within the current
2825 compilation unit. This is to allow easy merging of multiple compilation
2826 units into one, for example, by using the link-time optimization. For
2827 this reason the attribute is not allowed on types to annotate indirect
2828 calls.
2829
2830 @item malloc
2831 @cindex @code{malloc} function attribute
2832 @cindex functions that behave like malloc
2833 This tells the compiler that a function is @code{malloc}-like, i.e.,
2834 that the pointer @var{P} returned by the function cannot alias any
2835 other pointer valid when the function returns, and moreover no
2836 pointers to valid objects occur in any storage addressed by @var{P}.
2837
2838 Using this attribute can improve optimization. Functions like
2839 @code{malloc} and @code{calloc} have this property because they return
2840 a pointer to uninitialized or zeroed-out storage. However, functions
2841 like @code{realloc} do not have this property, as they can return a
2842 pointer to storage containing pointers.
2843
2844 @item no_icf
2845 @cindex @code{no_icf} function attribute
2846 This function attribute prevents a functions from being merged with another
2847 semantically equivalent function.
2848
2849 @item no_instrument_function
2850 @cindex @code{no_instrument_function} function attribute
2851 @opindex finstrument-functions
2852 If @option{-finstrument-functions} is given, profiling function calls are
2853 generated at entry and exit of most user-compiled functions.
2854 Functions with this attribute are not so instrumented.
2855
2856 @item no_profile_instrument_function
2857 @cindex @code{no_profile_instrument_function} function attribute
2858 The @code{no_profile_instrument_function} attribute on functions is used
2859 to inform the compiler that it should not process any profile feedback based
2860 optimization code instrumentation.
2861
2862 @item no_reorder
2863 @cindex @code{no_reorder} function attribute
2864 Do not reorder functions or variables marked @code{no_reorder}
2865 against each other or top level assembler statements the executable.
2866 The actual order in the program will depend on the linker command
2867 line. Static variables marked like this are also not removed.
2868 This has a similar effect
2869 as the @option{-fno-toplevel-reorder} option, but only applies to the
2870 marked symbols.
2871
2872 @item no_sanitize_address
2873 @itemx no_address_safety_analysis
2874 @cindex @code{no_sanitize_address} function attribute
2875 The @code{no_sanitize_address} attribute on functions is used
2876 to inform the compiler that it should not instrument memory accesses
2877 in the function when compiling with the @option{-fsanitize=address} option.
2878 The @code{no_address_safety_analysis} is a deprecated alias of the
2879 @code{no_sanitize_address} attribute, new code should use
2880 @code{no_sanitize_address}.
2881
2882 @item no_sanitize_thread
2883 @cindex @code{no_sanitize_thread} function attribute
2884 The @code{no_sanitize_thread} attribute on functions is used
2885 to inform the compiler that it should not instrument memory accesses
2886 in the function when compiling with the @option{-fsanitize=thread} option.
2887
2888 @item no_sanitize_undefined
2889 @cindex @code{no_sanitize_undefined} function attribute
2890 The @code{no_sanitize_undefined} attribute on functions is used
2891 to inform the compiler that it should not check for undefined behavior
2892 in the function when compiling with the @option{-fsanitize=undefined} option.
2893
2894 @item no_split_stack
2895 @cindex @code{no_split_stack} function attribute
2896 @opindex fsplit-stack
2897 If @option{-fsplit-stack} is given, functions have a small
2898 prologue which decides whether to split the stack. Functions with the
2899 @code{no_split_stack} attribute do not have that prologue, and thus
2900 may run with only a small amount of stack space available.
2901
2902 @item no_stack_limit
2903 @cindex @code{no_stack_limit} function attribute
2904 This attribute locally overrides the @option{-fstack-limit-register}
2905 and @option{-fstack-limit-symbol} command-line options; it has the effect
2906 of disabling stack limit checking in the function it applies to.
2907
2908 @item noclone
2909 @cindex @code{noclone} function attribute
2910 This function attribute prevents a function from being considered for
2911 cloning---a mechanism that produces specialized copies of functions
2912 and which is (currently) performed by interprocedural constant
2913 propagation.
2914
2915 @item noinline
2916 @cindex @code{noinline} function attribute
2917 This function attribute prevents a function from being considered for
2918 inlining.
2919 @c Don't enumerate the optimizations by name here; we try to be
2920 @c future-compatible with this mechanism.
2921 If the function does not have side-effects, there are optimizations
2922 other than inlining that cause function calls to be optimized away,
2923 although the function call is live. To keep such calls from being
2924 optimized away, put
2925 @smallexample
2926 asm ("");
2927 @end smallexample
2928
2929 @noindent
2930 (@pxref{Extended Asm}) in the called function, to serve as a special
2931 side-effect.
2932
2933 @item nonnull (@var{arg-index}, @dots{})
2934 @cindex @code{nonnull} function attribute
2935 @cindex functions with non-null pointer arguments
2936 The @code{nonnull} attribute specifies that some function parameters should
2937 be non-null pointers. For instance, the declaration:
2938
2939 @smallexample
2940 extern void *
2941 my_memcpy (void *dest, const void *src, size_t len)
2942 __attribute__((nonnull (1, 2)));
2943 @end smallexample
2944
2945 @noindent
2946 causes the compiler to check that, in calls to @code{my_memcpy},
2947 arguments @var{dest} and @var{src} are non-null. If the compiler
2948 determines that a null pointer is passed in an argument slot marked
2949 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2950 is issued. The compiler may also choose to make optimizations based
2951 on the knowledge that certain function arguments will never be null.
2952
2953 If no argument index list is given to the @code{nonnull} attribute,
2954 all pointer arguments are marked as non-null. To illustrate, the
2955 following declaration is equivalent to the previous example:
2956
2957 @smallexample
2958 extern void *
2959 my_memcpy (void *dest, const void *src, size_t len)
2960 __attribute__((nonnull));
2961 @end smallexample
2962
2963 @item noplt
2964 @cindex @code{noplt} function attribute
2965 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
2966 Calls to functions marked with this attribute in position-independent code
2967 do not use the PLT.
2968
2969 @smallexample
2970 @group
2971 /* Externally defined function foo. */
2972 int foo () __attribute__ ((noplt));
2973
2974 int
2975 main (/* @r{@dots{}} */)
2976 @{
2977 /* @r{@dots{}} */
2978 foo ();
2979 /* @r{@dots{}} */
2980 @}
2981 @end group
2982 @end smallexample
2983
2984 The @code{noplt} attribute on function @code{foo}
2985 tells the compiler to assume that
2986 the function @code{foo} is externally defined and that the call to
2987 @code{foo} must avoid the PLT
2988 in position-independent code.
2989
2990 In position-dependent code, a few targets also convert calls to
2991 functions that are marked to not use the PLT to use the GOT instead.
2992
2993 @item noreturn
2994 @cindex @code{noreturn} function attribute
2995 @cindex functions that never return
2996 A few standard library functions, such as @code{abort} and @code{exit},
2997 cannot return. GCC knows this automatically. Some programs define
2998 their own functions that never return. You can declare them
2999 @code{noreturn} to tell the compiler this fact. For example,
3000
3001 @smallexample
3002 @group
3003 void fatal () __attribute__ ((noreturn));
3004
3005 void
3006 fatal (/* @r{@dots{}} */)
3007 @{
3008 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3009 exit (1);
3010 @}
3011 @end group
3012 @end smallexample
3013
3014 The @code{noreturn} keyword tells the compiler to assume that
3015 @code{fatal} cannot return. It can then optimize without regard to what
3016 would happen if @code{fatal} ever did return. This makes slightly
3017 better code. More importantly, it helps avoid spurious warnings of
3018 uninitialized variables.
3019
3020 The @code{noreturn} keyword does not affect the exceptional path when that
3021 applies: a @code{noreturn}-marked function may still return to the caller
3022 by throwing an exception or calling @code{longjmp}.
3023
3024 Do not assume that registers saved by the calling function are
3025 restored before calling the @code{noreturn} function.
3026
3027 It does not make sense for a @code{noreturn} function to have a return
3028 type other than @code{void}.
3029
3030 @item nothrow
3031 @cindex @code{nothrow} function attribute
3032 The @code{nothrow} attribute is used to inform the compiler that a
3033 function cannot throw an exception. For example, most functions in
3034 the standard C library can be guaranteed not to throw an exception
3035 with the notable exceptions of @code{qsort} and @code{bsearch} that
3036 take function pointer arguments.
3037
3038 @item optimize
3039 @cindex @code{optimize} function attribute
3040 The @code{optimize} attribute is used to specify that a function is to
3041 be compiled with different optimization options than specified on the
3042 command line. Arguments can either be numbers or strings. Numbers
3043 are assumed to be an optimization level. Strings that begin with
3044 @code{O} are assumed to be an optimization option, while other options
3045 are assumed to be used with a @code{-f} prefix. You can also use the
3046 @samp{#pragma GCC optimize} pragma to set the optimization options
3047 that affect more than one function.
3048 @xref{Function Specific Option Pragmas}, for details about the
3049 @samp{#pragma GCC optimize} pragma.
3050
3051 This attribute should be used for debugging purposes only. It is not
3052 suitable in production code.
3053
3054 @item pure
3055 @cindex @code{pure} function attribute
3056 @cindex functions that have no side effects
3057 Many functions have no effects except the return value and their
3058 return value depends only on the parameters and/or global variables.
3059 Such a function can be subject
3060 to common subexpression elimination and loop optimization just as an
3061 arithmetic operator would be. These functions should be declared
3062 with the attribute @code{pure}. For example,
3063
3064 @smallexample
3065 int square (int) __attribute__ ((pure));
3066 @end smallexample
3067
3068 @noindent
3069 says that the hypothetical function @code{square} is safe to call
3070 fewer times than the program says.
3071
3072 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3073 Interesting non-pure functions are functions with infinite loops or those
3074 depending on volatile memory or other system resource, that may change between
3075 two consecutive calls (such as @code{feof} in a multithreading environment).
3076
3077 @item returns_nonnull
3078 @cindex @code{returns_nonnull} function attribute
3079 The @code{returns_nonnull} attribute specifies that the function
3080 return value should be a non-null pointer. For instance, the declaration:
3081
3082 @smallexample
3083 extern void *
3084 mymalloc (size_t len) __attribute__((returns_nonnull));
3085 @end smallexample
3086
3087 @noindent
3088 lets the compiler optimize callers based on the knowledge
3089 that the return value will never be null.
3090
3091 @item returns_twice
3092 @cindex @code{returns_twice} function attribute
3093 @cindex functions that return more than once
3094 The @code{returns_twice} attribute tells the compiler that a function may
3095 return more than one time. The compiler ensures that all registers
3096 are dead before calling such a function and emits a warning about
3097 the variables that may be clobbered after the second return from the
3098 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3099 The @code{longjmp}-like counterpart of such function, if any, might need
3100 to be marked with the @code{noreturn} attribute.
3101
3102 @item section ("@var{section-name}")
3103 @cindex @code{section} function attribute
3104 @cindex functions in arbitrary sections
3105 Normally, the compiler places the code it generates in the @code{text} section.
3106 Sometimes, however, you need additional sections, or you need certain
3107 particular functions to appear in special sections. The @code{section}
3108 attribute specifies that a function lives in a particular section.
3109 For example, the declaration:
3110
3111 @smallexample
3112 extern void foobar (void) __attribute__ ((section ("bar")));
3113 @end smallexample
3114
3115 @noindent
3116 puts the function @code{foobar} in the @code{bar} section.
3117
3118 Some file formats do not support arbitrary sections so the @code{section}
3119 attribute is not available on all platforms.
3120 If you need to map the entire contents of a module to a particular
3121 section, consider using the facilities of the linker instead.
3122
3123 @item sentinel
3124 @cindex @code{sentinel} function attribute
3125 This function attribute ensures that a parameter in a function call is
3126 an explicit @code{NULL}. The attribute is only valid on variadic
3127 functions. By default, the sentinel is located at position zero, the
3128 last parameter of the function call. If an optional integer position
3129 argument P is supplied to the attribute, the sentinel must be located at
3130 position P counting backwards from the end of the argument list.
3131
3132 @smallexample
3133 __attribute__ ((sentinel))
3134 is equivalent to
3135 __attribute__ ((sentinel(0)))
3136 @end smallexample
3137
3138 The attribute is automatically set with a position of 0 for the built-in
3139 functions @code{execl} and @code{execlp}. The built-in function
3140 @code{execle} has the attribute set with a position of 1.
3141
3142 A valid @code{NULL} in this context is defined as zero with any pointer
3143 type. If your system defines the @code{NULL} macro with an integer type
3144 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3145 with a copy that redefines NULL appropriately.
3146
3147 The warnings for missing or incorrect sentinels are enabled with
3148 @option{-Wformat}.
3149
3150 @item simd
3151 @itemx simd("@var{mask}")
3152 @cindex @code{simd} function attribute
3153 This attribute enables creation of one or more function versions that
3154 can process multiple arguments using SIMD instructions from a
3155 single invocation. Specifying this attribute allows compiler to
3156 assume that such versions are available at link time (provided
3157 in the same or another translation unit). Generated versions are
3158 target-dependent and described in the corresponding Vector ABI document. For
3159 x86_64 target this document can be found
3160 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3161
3162 The optional argument @var{mask} may have the value
3163 @code{notinbranch} or @code{inbranch},
3164 and instructs the compiler to generate non-masked or masked
3165 clones correspondingly. By default, all clones are generated.
3166
3167 The attribute should not be used together with Cilk Plus @code{vector}
3168 attribute on the same function.
3169
3170 If the attribute is specified and @code{#pragma omp declare simd} is
3171 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3172 switch is specified, then the attribute is ignored.
3173
3174 @item stack_protect
3175 @cindex @code{stack_protect} function attribute
3176 This attribute adds stack protection code to the function if
3177 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3178 or @option{-fstack-protector-explicit} are set.
3179
3180 @item target (@var{options})
3181 @cindex @code{target} function attribute
3182 Multiple target back ends implement the @code{target} attribute
3183 to specify that a function is to
3184 be compiled with different target options than specified on the
3185 command line. This can be used for instance to have functions
3186 compiled with a different ISA (instruction set architecture) than the
3187 default. You can also use the @samp{#pragma GCC target} pragma to set
3188 more than one function to be compiled with specific target options.
3189 @xref{Function Specific Option Pragmas}, for details about the
3190 @samp{#pragma GCC target} pragma.
3191
3192 For instance, on an x86, you could declare one function with the
3193 @code{target("sse4.1,arch=core2")} attribute and another with
3194 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3195 compiling the first function with @option{-msse4.1} and
3196 @option{-march=core2} options, and the second function with
3197 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3198 to make sure that a function is only invoked on a machine that
3199 supports the particular ISA it is compiled for (for example by using
3200 @code{cpuid} on x86 to determine what feature bits and architecture
3201 family are used).
3202
3203 @smallexample
3204 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3205 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3206 @end smallexample
3207
3208 You can either use multiple
3209 strings separated by commas to specify multiple options,
3210 or separate the options with a comma (@samp{,}) within a single string.
3211
3212 The options supported are specific to each target; refer to @ref{x86
3213 Function Attributes}, @ref{PowerPC Function Attributes},
3214 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3215 for details.
3216
3217 @item target_clones (@var{options})
3218 @cindex @code{target_clones} function attribute
3219 The @code{target_clones} attribute is used to specify that a function
3220 be cloned into multiple versions compiled with different target options
3221 than specified on the command line. The supported options and restrictions
3222 are the same as for @code{target} attribute.
3223
3224 For instance, on an x86, you could compile a function with
3225 @code{target_clones("sse4.1,avx")}. GCC creates two function clones,
3226 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3227 It also creates a resolver function (see the @code{ifunc} attribute
3228 above) that dynamically selects a clone suitable for current architecture.
3229
3230 @item unused
3231 @cindex @code{unused} function attribute
3232 This attribute, attached to a function, means that the function is meant
3233 to be possibly unused. GCC does not produce a warning for this
3234 function.
3235
3236 @item used
3237 @cindex @code{used} function attribute
3238 This attribute, attached to a function, means that code must be emitted
3239 for the function even if it appears that the function is not referenced.
3240 This is useful, for example, when the function is referenced only in
3241 inline assembly.
3242
3243 When applied to a member function of a C++ class template, the
3244 attribute also means that the function is instantiated if the
3245 class itself is instantiated.
3246
3247 @item visibility ("@var{visibility_type}")
3248 @cindex @code{visibility} function attribute
3249 This attribute affects the linkage of the declaration to which it is attached.
3250 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3251 (@pxref{Common Type Attributes}) as well as functions.
3252
3253 There are four supported @var{visibility_type} values: default,
3254 hidden, protected or internal visibility.
3255
3256 @smallexample
3257 void __attribute__ ((visibility ("protected")))
3258 f () @{ /* @r{Do something.} */; @}
3259 int i __attribute__ ((visibility ("hidden")));
3260 @end smallexample
3261
3262 The possible values of @var{visibility_type} correspond to the
3263 visibility settings in the ELF gABI.
3264
3265 @table @code
3266 @c keep this list of visibilities in alphabetical order.
3267
3268 @item default
3269 Default visibility is the normal case for the object file format.
3270 This value is available for the visibility attribute to override other
3271 options that may change the assumed visibility of entities.
3272
3273 On ELF, default visibility means that the declaration is visible to other
3274 modules and, in shared libraries, means that the declared entity may be
3275 overridden.
3276
3277 On Darwin, default visibility means that the declaration is visible to
3278 other modules.
3279
3280 Default visibility corresponds to ``external linkage'' in the language.
3281
3282 @item hidden
3283 Hidden visibility indicates that the entity declared has a new
3284 form of linkage, which we call ``hidden linkage''. Two
3285 declarations of an object with hidden linkage refer to the same object
3286 if they are in the same shared object.
3287
3288 @item internal
3289 Internal visibility is like hidden visibility, but with additional
3290 processor specific semantics. Unless otherwise specified by the
3291 psABI, GCC defines internal visibility to mean that a function is
3292 @emph{never} called from another module. Compare this with hidden
3293 functions which, while they cannot be referenced directly by other
3294 modules, can be referenced indirectly via function pointers. By
3295 indicating that a function cannot be called from outside the module,
3296 GCC may for instance omit the load of a PIC register since it is known
3297 that the calling function loaded the correct value.
3298
3299 @item protected
3300 Protected visibility is like default visibility except that it
3301 indicates that references within the defining module bind to the
3302 definition in that module. That is, the declared entity cannot be
3303 overridden by another module.
3304
3305 @end table
3306
3307 All visibilities are supported on many, but not all, ELF targets
3308 (supported when the assembler supports the @samp{.visibility}
3309 pseudo-op). Default visibility is supported everywhere. Hidden
3310 visibility is supported on Darwin targets.
3311
3312 The visibility attribute should be applied only to declarations that
3313 would otherwise have external linkage. The attribute should be applied
3314 consistently, so that the same entity should not be declared with
3315 different settings of the attribute.
3316
3317 In C++, the visibility attribute applies to types as well as functions
3318 and objects, because in C++ types have linkage. A class must not have
3319 greater visibility than its non-static data member types and bases,
3320 and class members default to the visibility of their class. Also, a
3321 declaration without explicit visibility is limited to the visibility
3322 of its type.
3323
3324 In C++, you can mark member functions and static member variables of a
3325 class with the visibility attribute. This is useful if you know a
3326 particular method or static member variable should only be used from
3327 one shared object; then you can mark it hidden while the rest of the
3328 class has default visibility. Care must be taken to avoid breaking
3329 the One Definition Rule; for example, it is usually not useful to mark
3330 an inline method as hidden without marking the whole class as hidden.
3331
3332 A C++ namespace declaration can also have the visibility attribute.
3333
3334 @smallexample
3335 namespace nspace1 __attribute__ ((visibility ("protected")))
3336 @{ /* @r{Do something.} */; @}
3337 @end smallexample
3338
3339 This attribute applies only to the particular namespace body, not to
3340 other definitions of the same namespace; it is equivalent to using
3341 @samp{#pragma GCC visibility} before and after the namespace
3342 definition (@pxref{Visibility Pragmas}).
3343
3344 In C++, if a template argument has limited visibility, this
3345 restriction is implicitly propagated to the template instantiation.
3346 Otherwise, template instantiations and specializations default to the
3347 visibility of their template.
3348
3349 If both the template and enclosing class have explicit visibility, the
3350 visibility from the template is used.
3351
3352 @item warn_unused_result
3353 @cindex @code{warn_unused_result} function attribute
3354 The @code{warn_unused_result} attribute causes a warning to be emitted
3355 if a caller of the function with this attribute does not use its
3356 return value. This is useful for functions where not checking
3357 the result is either a security problem or always a bug, such as
3358 @code{realloc}.
3359
3360 @smallexample
3361 int fn () __attribute__ ((warn_unused_result));
3362 int foo ()
3363 @{
3364 if (fn () < 0) return -1;
3365 fn ();
3366 return 0;
3367 @}
3368 @end smallexample
3369
3370 @noindent
3371 results in warning on line 5.
3372
3373 @item weak
3374 @cindex @code{weak} function attribute
3375 The @code{weak} attribute causes the declaration to be emitted as a weak
3376 symbol rather than a global. This is primarily useful in defining
3377 library functions that can be overridden in user code, though it can
3378 also be used with non-function declarations. Weak symbols are supported
3379 for ELF targets, and also for a.out targets when using the GNU assembler
3380 and linker.
3381
3382 @item weakref
3383 @itemx weakref ("@var{target}")
3384 @cindex @code{weakref} function attribute
3385 The @code{weakref} attribute marks a declaration as a weak reference.
3386 Without arguments, it should be accompanied by an @code{alias} attribute
3387 naming the target symbol. Optionally, the @var{target} may be given as
3388 an argument to @code{weakref} itself. In either case, @code{weakref}
3389 implicitly marks the declaration as @code{weak}. Without a
3390 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3391 @code{weakref} is equivalent to @code{weak}.
3392
3393 @smallexample
3394 static int x() __attribute__ ((weakref ("y")));
3395 /* is equivalent to... */
3396 static int x() __attribute__ ((weak, weakref, alias ("y")));
3397 /* and to... */
3398 static int x() __attribute__ ((weakref));
3399 static int x() __attribute__ ((alias ("y")));
3400 @end smallexample
3401
3402 A weak reference is an alias that does not by itself require a
3403 definition to be given for the target symbol. If the target symbol is
3404 only referenced through weak references, then it becomes a @code{weak}
3405 undefined symbol. If it is directly referenced, however, then such
3406 strong references prevail, and a definition is required for the
3407 symbol, not necessarily in the same translation unit.
3408
3409 The effect is equivalent to moving all references to the alias to a
3410 separate translation unit, renaming the alias to the aliased symbol,
3411 declaring it as weak, compiling the two separate translation units and
3412 performing a reloadable link on them.
3413
3414 At present, a declaration to which @code{weakref} is attached can
3415 only be @code{static}.
3416
3417
3418 @end table
3419
3420 @c This is the end of the target-independent attribute table
3421
3422 @node AArch64 Function Attributes
3423 @subsection AArch64 Function Attributes
3424
3425 The following target-specific function attributes are available for the
3426 AArch64 target. For the most part, these options mirror the behavior of
3427 similar command-line options (@pxref{AArch64 Options}), but on a
3428 per-function basis.
3429
3430 @table @code
3431 @item general-regs-only
3432 @cindex @code{general-regs-only} function attribute, AArch64
3433 Indicates that no floating-point or Advanced SIMD registers should be
3434 used when generating code for this function. If the function explicitly
3435 uses floating-point code, then the compiler gives an error. This is
3436 the same behavior as that of the command-line option
3437 @option{-mgeneral-regs-only}.
3438
3439 @item fix-cortex-a53-835769
3440 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3441 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3442 applied to this function. To explicitly disable the workaround for this
3443 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3444 This corresponds to the behavior of the command line options
3445 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3446
3447 @item cmodel=
3448 @cindex @code{cmodel=} function attribute, AArch64
3449 Indicates that code should be generated for a particular code model for
3450 this function. The behavior and permissible arguments are the same as
3451 for the command line option @option{-mcmodel=}.
3452
3453 @item strict-align
3454 @cindex @code{strict-align} function attribute, AArch64
3455 Indicates that the compiler should not assume that unaligned memory references
3456 are handled by the system. The behavior is the same as for the command-line
3457 option @option{-mstrict-align}.
3458
3459 @item omit-leaf-frame-pointer
3460 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3461 Indicates that the frame pointer should be omitted for a leaf function call.
3462 To keep the frame pointer, the inverse attribute
3463 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3464 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3465 and @option{-mno-omit-leaf-frame-pointer}.
3466
3467 @item tls-dialect=
3468 @cindex @code{tls-dialect=} function attribute, AArch64
3469 Specifies the TLS dialect to use for this function. The behavior and
3470 permissible arguments are the same as for the command-line option
3471 @option{-mtls-dialect=}.
3472
3473 @item arch=
3474 @cindex @code{arch=} function attribute, AArch64
3475 Specifies the architecture version and architectural extensions to use
3476 for this function. The behavior and permissible arguments are the same as
3477 for the @option{-march=} command-line option.
3478
3479 @item tune=
3480 @cindex @code{tune=} function attribute, AArch64
3481 Specifies the core for which to tune the performance of this function.
3482 The behavior and permissible arguments are the same as for the @option{-mtune=}
3483 command-line option.
3484
3485 @item cpu=
3486 @cindex @code{cpu=} function attribute, AArch64
3487 Specifies the core for which to tune the performance of this function and also
3488 whose architectural features to use. The behavior and valid arguments are the
3489 same as for the @option{-mcpu=} command-line option.
3490
3491 @end table
3492
3493 The above target attributes can be specified as follows:
3494
3495 @smallexample
3496 __attribute__((target("@var{attr-string}")))
3497 int
3498 f (int a)
3499 @{
3500 return a + 5;
3501 @}
3502 @end smallexample
3503
3504 where @code{@var{attr-string}} is one of the attribute strings specified above.
3505
3506 Additionally, the architectural extension string may be specified on its
3507 own. This can be used to turn on and off particular architectural extensions
3508 without having to specify a particular architecture version or core. Example:
3509
3510 @smallexample
3511 __attribute__((target("+crc+nocrypto")))
3512 int
3513 foo (int a)
3514 @{
3515 return a + 5;
3516 @}
3517 @end smallexample
3518
3519 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3520 extension and disables the @code{crypto} extension for the function @code{foo}
3521 without modifying an existing @option{-march=} or @option{-mcpu} option.
3522
3523 Multiple target function attributes can be specified by separating them with
3524 a comma. For example:
3525 @smallexample
3526 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3527 int
3528 foo (int a)
3529 @{
3530 return a + 5;
3531 @}
3532 @end smallexample
3533
3534 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3535 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3536
3537 @subsubsection Inlining rules
3538 Specifying target attributes on individual functions or performing link-time
3539 optimization across translation units compiled with different target options
3540 can affect function inlining rules:
3541
3542 In particular, a caller function can inline a callee function only if the
3543 architectural features available to the callee are a subset of the features
3544 available to the caller.
3545 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3546 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3547 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3548 because the all the architectural features that function @code{bar} requires
3549 are available to function @code{foo}. Conversely, function @code{bar} cannot
3550 inline function @code{foo}.
3551
3552 Additionally inlining a function compiled with @option{-mstrict-align} into a
3553 function compiled without @code{-mstrict-align} is not allowed.
3554 However, inlining a function compiled without @option{-mstrict-align} into a
3555 function compiled with @option{-mstrict-align} is allowed.
3556
3557 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3558 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3559 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3560 architectural feature rules specified above.
3561
3562 @node ARC Function Attributes
3563 @subsection ARC Function Attributes
3564
3565 These function attributes are supported by the ARC back end:
3566
3567 @table @code
3568 @item interrupt
3569 @cindex @code{interrupt} function attribute, ARC
3570 Use this attribute to indicate
3571 that the specified function is an interrupt handler. The compiler generates
3572 function entry and exit sequences suitable for use in an interrupt handler
3573 when this attribute is present.
3574
3575 On the ARC, you must specify the kind of interrupt to be handled
3576 in a parameter to the interrupt attribute like this:
3577
3578 @smallexample
3579 void f () __attribute__ ((interrupt ("ilink1")));
3580 @end smallexample
3581
3582 Permissible values for this parameter are: @w{@code{ilink1}} and
3583 @w{@code{ilink2}}.
3584
3585 @item long_call
3586 @itemx medium_call
3587 @itemx short_call
3588 @cindex @code{long_call} function attribute, ARC
3589 @cindex @code{medium_call} function attribute, ARC
3590 @cindex @code{short_call} function attribute, ARC
3591 @cindex indirect calls, ARC
3592 These attributes specify how a particular function is called.
3593 These attributes override the
3594 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3595 command-line switches and @code{#pragma long_calls} settings.
3596
3597 For ARC, a function marked with the @code{long_call} attribute is
3598 always called using register-indirect jump-and-link instructions,
3599 thereby enabling the called function to be placed anywhere within the
3600 32-bit address space. A function marked with the @code{medium_call}
3601 attribute will always be close enough to be called with an unconditional
3602 branch-and-link instruction, which has a 25-bit offset from
3603 the call site. A function marked with the @code{short_call}
3604 attribute will always be close enough to be called with a conditional
3605 branch-and-link instruction, which has a 21-bit offset from
3606 the call site.
3607 @end table
3608
3609 @node ARM Function Attributes
3610 @subsection ARM Function Attributes
3611
3612 These function attributes are supported for ARM targets:
3613
3614 @table @code
3615 @item interrupt
3616 @cindex @code{interrupt} function attribute, ARM
3617 Use this attribute to indicate
3618 that the specified function is an interrupt handler. The compiler generates
3619 function entry and exit sequences suitable for use in an interrupt handler
3620 when this attribute is present.
3621
3622 You can specify the kind of interrupt to be handled by
3623 adding an optional parameter to the interrupt attribute like this:
3624
3625 @smallexample
3626 void f () __attribute__ ((interrupt ("IRQ")));
3627 @end smallexample
3628
3629 @noindent
3630 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3631 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3632
3633 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3634 may be called with a word-aligned stack pointer.
3635
3636 @item isr
3637 @cindex @code{isr} function attribute, ARM
3638 Use this attribute on ARM to write Interrupt Service Routines. This is an
3639 alias to the @code{interrupt} attribute above.
3640
3641 @item long_call
3642 @itemx short_call
3643 @cindex @code{long_call} function attribute, ARM
3644 @cindex @code{short_call} function attribute, ARM
3645 @cindex indirect calls, ARM
3646 These attributes specify how a particular function is called.
3647 These attributes override the
3648 @option{-mlong-calls} (@pxref{ARM Options})
3649 command-line switch and @code{#pragma long_calls} settings. For ARM, the
3650 @code{long_call} attribute indicates that the function might be far
3651 away from the call site and require a different (more expensive)
3652 calling sequence. The @code{short_call} attribute always places
3653 the offset to the function from the call site into the @samp{BL}
3654 instruction directly.
3655
3656 @item naked
3657 @cindex @code{naked} function attribute, ARM
3658 This attribute allows the compiler to construct the
3659 requisite function declaration, while allowing the body of the
3660 function to be assembly code. The specified function will not have
3661 prologue/epilogue sequences generated by the compiler. Only basic
3662 @code{asm} statements can safely be included in naked functions
3663 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3664 basic @code{asm} and C code may appear to work, they cannot be
3665 depended upon to work reliably and are not supported.
3666
3667 @item pcs
3668 @cindex @code{pcs} function attribute, ARM
3669
3670 The @code{pcs} attribute can be used to control the calling convention
3671 used for a function on ARM. The attribute takes an argument that specifies
3672 the calling convention to use.
3673
3674 When compiling using the AAPCS ABI (or a variant of it) then valid
3675 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3676 order to use a variant other than @code{"aapcs"} then the compiler must
3677 be permitted to use the appropriate co-processor registers (i.e., the
3678 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3679 For example,
3680
3681 @smallexample
3682 /* Argument passed in r0, and result returned in r0+r1. */
3683 double f2d (float) __attribute__((pcs("aapcs")));
3684 @end smallexample
3685
3686 Variadic functions always use the @code{"aapcs"} calling convention and
3687 the compiler rejects attempts to specify an alternative.
3688
3689 @item target (@var{options})
3690 @cindex @code{target} function attribute
3691 As discussed in @ref{Common Function Attributes}, this attribute
3692 allows specification of target-specific compilation options.
3693
3694 On ARM, the following options are allowed:
3695
3696 @table @samp
3697 @item thumb
3698 @cindex @code{target("thumb")} function attribute, ARM
3699 Force code generation in the Thumb (T16/T32) ISA, depending on the
3700 architecture level.
3701
3702 @item arm
3703 @cindex @code{target("arm")} function attribute, ARM
3704 Force code generation in the ARM (A32) ISA.
3705
3706 Functions from different modes can be inlined in the caller's mode.
3707
3708 @item fpu=
3709 @cindex @code{target("fpu=")} function attribute, ARM
3710 Specifies the fpu for which to tune the performance of this function.
3711 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3712 command-line option.
3713
3714 @end table
3715
3716 @end table
3717
3718 @node AVR Function Attributes
3719 @subsection AVR Function Attributes
3720
3721 These function attributes are supported by the AVR back end:
3722
3723 @table @code
3724 @item interrupt
3725 @cindex @code{interrupt} function attribute, AVR
3726 Use this attribute to indicate
3727 that the specified function is an interrupt handler. The compiler generates
3728 function entry and exit sequences suitable for use in an interrupt handler
3729 when this attribute is present.
3730
3731 On the AVR, the hardware globally disables interrupts when an
3732 interrupt is executed. The first instruction of an interrupt handler
3733 declared with this attribute is a @code{SEI} instruction to
3734 re-enable interrupts. See also the @code{signal} function attribute
3735 that does not insert a @code{SEI} instruction. If both @code{signal} and
3736 @code{interrupt} are specified for the same function, @code{signal}
3737 is silently ignored.
3738
3739 @item naked
3740 @cindex @code{naked} function attribute, AVR
3741 This attribute allows the compiler to construct the
3742 requisite function declaration, while allowing the body of the
3743 function to be assembly code. The specified function will not have
3744 prologue/epilogue sequences generated by the compiler. Only basic
3745 @code{asm} statements can safely be included in naked functions
3746 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3747 basic @code{asm} and C code may appear to work, they cannot be
3748 depended upon to work reliably and are not supported.
3749
3750 @item OS_main
3751 @itemx OS_task
3752 @cindex @code{OS_main} function attribute, AVR
3753 @cindex @code{OS_task} function attribute, AVR
3754 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3755 do not save/restore any call-saved register in their prologue/epilogue.
3756
3757 The @code{OS_main} attribute can be used when there @emph{is
3758 guarantee} that interrupts are disabled at the time when the function
3759 is entered. This saves resources when the stack pointer has to be
3760 changed to set up a frame for local variables.
3761
3762 The @code{OS_task} attribute can be used when there is @emph{no
3763 guarantee} that interrupts are disabled at that time when the function
3764 is entered like for, e@.g@. task functions in a multi-threading operating
3765 system. In that case, changing the stack pointer register is
3766 guarded by save/clear/restore of the global interrupt enable flag.
3767
3768 The differences to the @code{naked} function attribute are:
3769 @itemize @bullet
3770 @item @code{naked} functions do not have a return instruction whereas
3771 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3772 @code{RETI} return instruction.
3773 @item @code{naked} functions do not set up a frame for local variables
3774 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3775 as needed.
3776 @end itemize
3777
3778 @item signal
3779 @cindex @code{signal} function attribute, AVR
3780 Use this attribute on the AVR to indicate that the specified
3781 function is an interrupt handler. The compiler generates function
3782 entry and exit sequences suitable for use in an interrupt handler when this
3783 attribute is present.
3784
3785 See also the @code{interrupt} function attribute.
3786
3787 The AVR hardware globally disables interrupts when an interrupt is executed.
3788 Interrupt handler functions defined with the @code{signal} attribute
3789 do not re-enable interrupts. It is save to enable interrupts in a
3790 @code{signal} handler. This ``save'' only applies to the code
3791 generated by the compiler and not to the IRQ layout of the
3792 application which is responsibility of the application.
3793
3794 If both @code{signal} and @code{interrupt} are specified for the same
3795 function, @code{signal} is silently ignored.
3796 @end table
3797
3798 @node Blackfin Function Attributes
3799 @subsection Blackfin Function Attributes
3800
3801 These function attributes are supported by the Blackfin back end:
3802
3803 @table @code
3804
3805 @item exception_handler
3806 @cindex @code{exception_handler} function attribute
3807 @cindex exception handler functions, Blackfin
3808 Use this attribute on the Blackfin to indicate that the specified function
3809 is an exception handler. The compiler generates function entry and
3810 exit sequences suitable for use in an exception handler when this
3811 attribute is present.
3812
3813 @item interrupt_handler
3814 @cindex @code{interrupt_handler} function attribute, Blackfin
3815 Use this attribute to
3816 indicate that the specified function is an interrupt handler. The compiler
3817 generates function entry and exit sequences suitable for use in an
3818 interrupt handler when this attribute is present.
3819
3820 @item kspisusp
3821 @cindex @code{kspisusp} function attribute, Blackfin
3822 @cindex User stack pointer in interrupts on the Blackfin
3823 When used together with @code{interrupt_handler}, @code{exception_handler}
3824 or @code{nmi_handler}, code is generated to load the stack pointer
3825 from the USP register in the function prologue.
3826
3827 @item l1_text
3828 @cindex @code{l1_text} function attribute, Blackfin
3829 This attribute specifies a function to be placed into L1 Instruction
3830 SRAM@. The function is put into a specific section named @code{.l1.text}.
3831 With @option{-mfdpic}, function calls with a such function as the callee
3832 or caller uses inlined PLT.
3833
3834 @item l2
3835 @cindex @code{l2} function attribute, Blackfin
3836 This attribute specifies a function to be placed into L2
3837 SRAM. The function is put into a specific section named
3838 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3839 an inlined PLT.
3840
3841 @item longcall
3842 @itemx shortcall
3843 @cindex indirect calls, Blackfin
3844 @cindex @code{longcall} function attribute, Blackfin
3845 @cindex @code{shortcall} function attribute, Blackfin
3846 The @code{longcall} attribute
3847 indicates that the function might be far away from the call site and
3848 require a different (more expensive) calling sequence. The
3849 @code{shortcall} attribute indicates that the function is always close
3850 enough for the shorter calling sequence to be used. These attributes
3851 override the @option{-mlongcall} switch.
3852
3853 @item nesting
3854 @cindex @code{nesting} function attribute, Blackfin
3855 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3856 Use this attribute together with @code{interrupt_handler},
3857 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3858 entry code should enable nested interrupts or exceptions.
3859
3860 @item nmi_handler
3861 @cindex @code{nmi_handler} function attribute, Blackfin
3862 @cindex NMI handler functions on the Blackfin processor
3863 Use this attribute on the Blackfin to indicate that the specified function
3864 is an NMI handler. The compiler generates function entry and
3865 exit sequences suitable for use in an NMI handler when this
3866 attribute is present.
3867
3868 @item saveall
3869 @cindex @code{saveall} function attribute, Blackfin
3870 @cindex save all registers on the Blackfin
3871 Use this attribute to indicate that
3872 all registers except the stack pointer should be saved in the prologue
3873 regardless of whether they are used or not.
3874 @end table
3875
3876 @node CR16 Function Attributes
3877 @subsection CR16 Function Attributes
3878
3879 These function attributes are supported by the CR16 back end:
3880
3881 @table @code
3882 @item interrupt
3883 @cindex @code{interrupt} function attribute, CR16
3884 Use this attribute to indicate
3885 that the specified function is an interrupt handler. The compiler generates
3886 function entry and exit sequences suitable for use in an interrupt handler
3887 when this attribute is present.
3888 @end table
3889
3890 @node Epiphany Function Attributes
3891 @subsection Epiphany Function Attributes
3892
3893 These function attributes are supported by the Epiphany back end:
3894
3895 @table @code
3896 @item disinterrupt
3897 @cindex @code{disinterrupt} function attribute, Epiphany
3898 This attribute causes the compiler to emit
3899 instructions to disable interrupts for the duration of the given
3900 function.
3901
3902 @item forwarder_section
3903 @cindex @code{forwarder_section} function attribute, Epiphany
3904 This attribute modifies the behavior of an interrupt handler.
3905 The interrupt handler may be in external memory which cannot be
3906 reached by a branch instruction, so generate a local memory trampoline
3907 to transfer control. The single parameter identifies the section where
3908 the trampoline is placed.
3909
3910 @item interrupt
3911 @cindex @code{interrupt} function attribute, Epiphany
3912 Use this attribute to indicate
3913 that the specified function is an interrupt handler. The compiler generates
3914 function entry and exit sequences suitable for use in an interrupt handler
3915 when this attribute is present. It may also generate
3916 a special section with code to initialize the interrupt vector table.
3917
3918 On Epiphany targets one or more optional parameters can be added like this:
3919
3920 @smallexample
3921 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3922 @end smallexample
3923
3924 Permissible values for these parameters are: @w{@code{reset}},
3925 @w{@code{software_exception}}, @w{@code{page_miss}},
3926 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3927 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3928 Multiple parameters indicate that multiple entries in the interrupt
3929 vector table should be initialized for this function, i.e.@: for each
3930 parameter @w{@var{name}}, a jump to the function is emitted in
3931 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
3932 entirely, in which case no interrupt vector table entry is provided.
3933
3934 Note that interrupts are enabled inside the function
3935 unless the @code{disinterrupt} attribute is also specified.
3936
3937 The following examples are all valid uses of these attributes on
3938 Epiphany targets:
3939 @smallexample
3940 void __attribute__ ((interrupt)) universal_handler ();
3941 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3942 void __attribute__ ((interrupt ("dma0, dma1")))
3943 universal_dma_handler ();
3944 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3945 fast_timer_handler ();
3946 void __attribute__ ((interrupt ("dma0, dma1"),
3947 forwarder_section ("tramp")))
3948 external_dma_handler ();
3949 @end smallexample
3950
3951 @item long_call
3952 @itemx short_call
3953 @cindex @code{long_call} function attribute, Epiphany
3954 @cindex @code{short_call} function attribute, Epiphany
3955 @cindex indirect calls, Epiphany
3956 These attributes specify how a particular function is called.
3957 These attributes override the
3958 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3959 command-line switch and @code{#pragma long_calls} settings.
3960 @end table
3961
3962
3963 @node H8/300 Function Attributes
3964 @subsection H8/300 Function Attributes
3965
3966 These function attributes are available for H8/300 targets:
3967
3968 @table @code
3969 @item function_vector
3970 @cindex @code{function_vector} function attribute, H8/300
3971 Use this attribute on the H8/300, H8/300H, and H8S to indicate
3972 that the specified function should be called through the function vector.
3973 Calling a function through the function vector reduces code size; however,
3974 the function vector has a limited size (maximum 128 entries on the H8/300
3975 and 64 entries on the H8/300H and H8S)
3976 and shares space with the interrupt vector.
3977
3978 @item interrupt_handler
3979 @cindex @code{interrupt_handler} function attribute, H8/300
3980 Use this attribute on the H8/300, H8/300H, and H8S to
3981 indicate that the specified function is an interrupt handler. The compiler
3982 generates function entry and exit sequences suitable for use in an
3983 interrupt handler when this attribute is present.
3984
3985 @item saveall
3986 @cindex @code{saveall} function attribute, H8/300
3987 @cindex save all registers on the H8/300, H8/300H, and H8S
3988 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
3989 all registers except the stack pointer should be saved in the prologue
3990 regardless of whether they are used or not.
3991 @end table
3992
3993 @node IA-64 Function Attributes
3994 @subsection IA-64 Function Attributes
3995
3996 These function attributes are supported on IA-64 targets:
3997
3998 @table @code
3999 @item syscall_linkage
4000 @cindex @code{syscall_linkage} function attribute, IA-64
4001 This attribute is used to modify the IA-64 calling convention by marking
4002 all input registers as live at all function exits. This makes it possible
4003 to restart a system call after an interrupt without having to save/restore
4004 the input registers. This also prevents kernel data from leaking into
4005 application code.
4006
4007 @item version_id
4008 @cindex @code{version_id} function attribute, IA-64
4009 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4010 symbol to contain a version string, thus allowing for function level
4011 versioning. HP-UX system header files may use function level versioning
4012 for some system calls.
4013
4014 @smallexample
4015 extern int foo () __attribute__((version_id ("20040821")));
4016 @end smallexample
4017
4018 @noindent
4019 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4020 @end table
4021
4022 @node M32C Function Attributes
4023 @subsection M32C Function Attributes
4024
4025 These function attributes are supported by the M32C back end:
4026
4027 @table @code
4028 @item bank_switch
4029 @cindex @code{bank_switch} function attribute, M32C
4030 When added to an interrupt handler with the M32C port, causes the
4031 prologue and epilogue to use bank switching to preserve the registers
4032 rather than saving them on the stack.
4033
4034 @item fast_interrupt
4035 @cindex @code{fast_interrupt} function attribute, M32C
4036 Use this attribute on the M32C port to indicate that the specified
4037 function is a fast interrupt handler. This is just like the
4038 @code{interrupt} attribute, except that @code{freit} is used to return
4039 instead of @code{reit}.
4040
4041 @item function_vector
4042 @cindex @code{function_vector} function attribute, M16C/M32C
4043 On M16C/M32C targets, the @code{function_vector} attribute declares a
4044 special page subroutine call function. Use of this attribute reduces
4045 the code size by 2 bytes for each call generated to the
4046 subroutine. The argument to the attribute is the vector number entry
4047 from the special page vector table which contains the 16 low-order
4048 bits of the subroutine's entry address. Each vector table has special
4049 page number (18 to 255) that is used in @code{jsrs} instructions.
4050 Jump addresses of the routines are generated by adding 0x0F0000 (in
4051 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4052 2-byte addresses set in the vector table. Therefore you need to ensure
4053 that all the special page vector routines should get mapped within the
4054 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4055 (for M32C).
4056
4057 In the following example 2 bytes are saved for each call to
4058 function @code{foo}.
4059
4060 @smallexample
4061 void foo (void) __attribute__((function_vector(0x18)));
4062 void foo (void)
4063 @{
4064 @}
4065
4066 void bar (void)
4067 @{
4068 foo();
4069 @}
4070 @end smallexample
4071
4072 If functions are defined in one file and are called in another file,
4073 then be sure to write this declaration in both files.
4074
4075 This attribute is ignored for R8C target.
4076
4077 @item interrupt
4078 @cindex @code{interrupt} function attribute, M32C
4079 Use this attribute to indicate
4080 that the specified function is an interrupt handler. The compiler generates
4081 function entry and exit sequences suitable for use in an interrupt handler
4082 when this attribute is present.
4083 @end table
4084
4085 @node M32R/D Function Attributes
4086 @subsection M32R/D Function Attributes
4087
4088 These function attributes are supported by the M32R/D back end:
4089
4090 @table @code
4091 @item interrupt
4092 @cindex @code{interrupt} function attribute, M32R/D
4093 Use this attribute to indicate
4094 that the specified function is an interrupt handler. The compiler generates
4095 function entry and exit sequences suitable for use in an interrupt handler
4096 when this attribute is present.
4097
4098 @item model (@var{model-name})
4099 @cindex @code{model} function attribute, M32R/D
4100 @cindex function addressability on the M32R/D
4101
4102 On the M32R/D, use this attribute to set the addressability of an
4103 object, and of the code generated for a function. The identifier
4104 @var{model-name} is one of @code{small}, @code{medium}, or
4105 @code{large}, representing each of the code models.
4106
4107 Small model objects live in the lower 16MB of memory (so that their
4108 addresses can be loaded with the @code{ld24} instruction), and are
4109 callable with the @code{bl} instruction.
4110
4111 Medium model objects may live anywhere in the 32-bit address space (the
4112 compiler generates @code{seth/add3} instructions to load their addresses),
4113 and are callable with the @code{bl} instruction.
4114
4115 Large model objects may live anywhere in the 32-bit address space (the
4116 compiler generates @code{seth/add3} instructions to load their addresses),
4117 and may not be reachable with the @code{bl} instruction (the compiler
4118 generates the much slower @code{seth/add3/jl} instruction sequence).
4119 @end table
4120
4121 @node m68k Function Attributes
4122 @subsection m68k Function Attributes
4123
4124 These function attributes are supported by the m68k back end:
4125
4126 @table @code
4127 @item interrupt
4128 @itemx interrupt_handler
4129 @cindex @code{interrupt} function attribute, m68k
4130 @cindex @code{interrupt_handler} function attribute, m68k
4131 Use this attribute to
4132 indicate that the specified function is an interrupt handler. The compiler
4133 generates function entry and exit sequences suitable for use in an
4134 interrupt handler when this attribute is present. Either name may be used.
4135
4136 @item interrupt_thread
4137 @cindex @code{interrupt_thread} function attribute, fido
4138 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4139 that the specified function is an interrupt handler that is designed
4140 to run as a thread. The compiler omits generate prologue/epilogue
4141 sequences and replaces the return instruction with a @code{sleep}
4142 instruction. This attribute is available only on fido.
4143 @end table
4144
4145 @node MCORE Function Attributes
4146 @subsection MCORE Function Attributes
4147
4148 These function attributes are supported by the MCORE back end:
4149
4150 @table @code
4151 @item naked
4152 @cindex @code{naked} function attribute, MCORE
4153 This attribute allows the compiler to construct the
4154 requisite function declaration, while allowing the body of the
4155 function to be assembly code. The specified function will not have
4156 prologue/epilogue sequences generated by the compiler. Only basic
4157 @code{asm} statements can safely be included in naked functions
4158 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4159 basic @code{asm} and C code may appear to work, they cannot be
4160 depended upon to work reliably and are not supported.
4161 @end table
4162
4163 @node MeP Function Attributes
4164 @subsection MeP Function Attributes
4165
4166 These function attributes are supported by the MeP back end:
4167
4168 @table @code
4169 @item disinterrupt
4170 @cindex @code{disinterrupt} function attribute, MeP
4171 On MeP targets, this attribute causes the compiler to emit
4172 instructions to disable interrupts for the duration of the given
4173 function.
4174
4175 @item interrupt
4176 @cindex @code{interrupt} function attribute, MeP
4177 Use this attribute to indicate
4178 that the specified function is an interrupt handler. The compiler generates
4179 function entry and exit sequences suitable for use in an interrupt handler
4180 when this attribute is present.
4181
4182 @item near
4183 @cindex @code{near} function attribute, MeP
4184 This attribute causes the compiler to assume the called
4185 function is close enough to use the normal calling convention,
4186 overriding the @option{-mtf} command-line option.
4187
4188 @item far
4189 @cindex @code{far} function attribute, MeP
4190 On MeP targets this causes the compiler to use a calling convention
4191 that assumes the called function is too far away for the built-in
4192 addressing modes.
4193
4194 @item vliw
4195 @cindex @code{vliw} function attribute, MeP
4196 The @code{vliw} attribute tells the compiler to emit
4197 instructions in VLIW mode instead of core mode. Note that this
4198 attribute is not allowed unless a VLIW coprocessor has been configured
4199 and enabled through command-line options.
4200 @end table
4201
4202 @node MicroBlaze Function Attributes
4203 @subsection MicroBlaze Function Attributes
4204
4205 These function attributes are supported on MicroBlaze targets:
4206
4207 @table @code
4208 @item save_volatiles
4209 @cindex @code{save_volatiles} function attribute, MicroBlaze
4210 Use this attribute to indicate that the function is
4211 an interrupt handler. All volatile registers (in addition to non-volatile
4212 registers) are saved in the function prologue. If the function is a leaf
4213 function, only volatiles used by the function are saved. A normal function
4214 return is generated instead of a return from interrupt.
4215
4216 @item break_handler
4217 @cindex @code{break_handler} function attribute, MicroBlaze
4218 @cindex break handler functions
4219 Use this attribute to indicate that
4220 the specified function is a break handler. The compiler generates function
4221 entry and exit sequences suitable for use in an break handler when this
4222 attribute is present. The return from @code{break_handler} is done through
4223 the @code{rtbd} instead of @code{rtsd}.
4224
4225 @smallexample
4226 void f () __attribute__ ((break_handler));
4227 @end smallexample
4228
4229 @item interrupt_handler
4230 @itemx fast_interrupt
4231 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4232 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4233 These attributes indicate that the specified function is an interrupt
4234 handler. Use the @code{fast_interrupt} attribute to indicate handlers
4235 used in low-latency interrupt mode, and @code{interrupt_handler} for
4236 interrupts that do not use low-latency handlers. In both cases, GCC
4237 emits appropriate prologue code and generates a return from the handler
4238 using @code{rtid} instead of @code{rtsd}.
4239 @end table
4240
4241 @node Microsoft Windows Function Attributes
4242 @subsection Microsoft Windows Function Attributes
4243
4244 The following attributes are available on Microsoft Windows and Symbian OS
4245 targets.
4246
4247 @table @code
4248 @item dllexport
4249 @cindex @code{dllexport} function attribute
4250 @cindex @code{__declspec(dllexport)}
4251 On Microsoft Windows targets and Symbian OS targets the
4252 @code{dllexport} attribute causes the compiler to provide a global
4253 pointer to a pointer in a DLL, so that it can be referenced with the
4254 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4255 name is formed by combining @code{_imp__} and the function or variable
4256 name.
4257
4258 You can use @code{__declspec(dllexport)} as a synonym for
4259 @code{__attribute__ ((dllexport))} for compatibility with other
4260 compilers.
4261
4262 On systems that support the @code{visibility} attribute, this
4263 attribute also implies ``default'' visibility. It is an error to
4264 explicitly specify any other visibility.
4265
4266 GCC's default behavior is to emit all inline functions with the
4267 @code{dllexport} attribute. Since this can cause object file-size bloat,
4268 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4269 ignore the attribute for inlined functions unless the
4270 @option{-fkeep-inline-functions} flag is used instead.
4271
4272 The attribute is ignored for undefined symbols.
4273
4274 When applied to C++ classes, the attribute marks defined non-inlined
4275 member functions and static data members as exports. Static consts
4276 initialized in-class are not marked unless they are also defined
4277 out-of-class.
4278
4279 For Microsoft Windows targets there are alternative methods for
4280 including the symbol in the DLL's export table such as using a
4281 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4282 the @option{--export-all} linker flag.
4283
4284 @item dllimport
4285 @cindex @code{dllimport} function attribute
4286 @cindex @code{__declspec(dllimport)}
4287 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4288 attribute causes the compiler to reference a function or variable via
4289 a global pointer to a pointer that is set up by the DLL exporting the
4290 symbol. The attribute implies @code{extern}. On Microsoft Windows
4291 targets, the pointer name is formed by combining @code{_imp__} and the
4292 function or variable name.
4293
4294 You can use @code{__declspec(dllimport)} as a synonym for
4295 @code{__attribute__ ((dllimport))} for compatibility with other
4296 compilers.
4297
4298 On systems that support the @code{visibility} attribute, this
4299 attribute also implies ``default'' visibility. It is an error to
4300 explicitly specify any other visibility.
4301
4302 Currently, the attribute is ignored for inlined functions. If the
4303 attribute is applied to a symbol @emph{definition}, an error is reported.
4304 If a symbol previously declared @code{dllimport} is later defined, the
4305 attribute is ignored in subsequent references, and a warning is emitted.
4306 The attribute is also overridden by a subsequent declaration as
4307 @code{dllexport}.
4308
4309 When applied to C++ classes, the attribute marks non-inlined
4310 member functions and static data members as imports. However, the
4311 attribute is ignored for virtual methods to allow creation of vtables
4312 using thunks.
4313
4314 On the SH Symbian OS target the @code{dllimport} attribute also has
4315 another affect---it can cause the vtable and run-time type information
4316 for a class to be exported. This happens when the class has a
4317 dllimported constructor or a non-inline, non-pure virtual function
4318 and, for either of those two conditions, the class also has an inline
4319 constructor or destructor and has a key function that is defined in
4320 the current translation unit.
4321
4322 For Microsoft Windows targets the use of the @code{dllimport}
4323 attribute on functions is not necessary, but provides a small
4324 performance benefit by eliminating a thunk in the DLL@. The use of the
4325 @code{dllimport} attribute on imported variables can be avoided by passing the
4326 @option{--enable-auto-import} switch to the GNU linker. As with
4327 functions, using the attribute for a variable eliminates a thunk in
4328 the DLL@.
4329
4330 One drawback to using this attribute is that a pointer to a
4331 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4332 address. However, a pointer to a @emph{function} with the
4333 @code{dllimport} attribute can be used as a constant initializer; in
4334 this case, the address of a stub function in the import lib is
4335 referenced. On Microsoft Windows targets, the attribute can be disabled
4336 for functions by setting the @option{-mnop-fun-dllimport} flag.
4337 @end table
4338
4339 @node MIPS Function Attributes
4340 @subsection MIPS Function Attributes
4341
4342 These function attributes are supported by the MIPS back end:
4343
4344 @table @code
4345 @item interrupt
4346 @cindex @code{interrupt} function attribute, MIPS
4347 Use this attribute to indicate that the specified function is an interrupt
4348 handler. The compiler generates function entry and exit sequences suitable
4349 for use in an interrupt handler when this attribute is present.
4350 An optional argument is supported for the interrupt attribute which allows
4351 the interrupt mode to be described. By default GCC assumes the external
4352 interrupt controller (EIC) mode is in use, this can be explicitly set using
4353 @code{eic}. When interrupts are non-masked then the requested Interrupt
4354 Priority Level (IPL) is copied to the current IPL which has the effect of only
4355 enabling higher priority interrupts. To use vectored interrupt mode use
4356 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4357 the behavior of the non-masked interrupt support and GCC will arrange to mask
4358 all interrupts from sw0 up to and including the specified interrupt vector.
4359
4360 You can use the following attributes to modify the behavior
4361 of an interrupt handler:
4362 @table @code
4363 @item use_shadow_register_set
4364 @cindex @code{use_shadow_register_set} function attribute, MIPS
4365 Assume that the handler uses a shadow register set, instead of
4366 the main general-purpose registers. An optional argument @code{intstack} is
4367 supported to indicate that the shadow register set contains a valid stack
4368 pointer.
4369
4370 @item keep_interrupts_masked
4371 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4372 Keep interrupts masked for the whole function. Without this attribute,
4373 GCC tries to reenable interrupts for as much of the function as it can.
4374
4375 @item use_debug_exception_return
4376 @cindex @code{use_debug_exception_return} function attribute, MIPS
4377 Return using the @code{deret} instruction. Interrupt handlers that don't
4378 have this attribute return using @code{eret} instead.
4379 @end table
4380
4381 You can use any combination of these attributes, as shown below:
4382 @smallexample
4383 void __attribute__ ((interrupt)) v0 ();
4384 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4385 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4386 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4387 void __attribute__ ((interrupt, use_shadow_register_set,
4388 keep_interrupts_masked)) v4 ();
4389 void __attribute__ ((interrupt, use_shadow_register_set,
4390 use_debug_exception_return)) v5 ();
4391 void __attribute__ ((interrupt, keep_interrupts_masked,
4392 use_debug_exception_return)) v6 ();
4393 void __attribute__ ((interrupt, use_shadow_register_set,
4394 keep_interrupts_masked,
4395 use_debug_exception_return)) v7 ();
4396 void __attribute__ ((interrupt("eic"))) v8 ();
4397 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4398 @end smallexample
4399
4400 @item long_call
4401 @itemx near
4402 @itemx far
4403 @cindex indirect calls, MIPS
4404 @cindex @code{long_call} function attribute, MIPS
4405 @cindex @code{near} function attribute, MIPS
4406 @cindex @code{far} function attribute, MIPS
4407 These attributes specify how a particular function is called on MIPS@.
4408 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4409 command-line switch. The @code{long_call} and @code{far} attributes are
4410 synonyms, and cause the compiler to always call
4411 the function by first loading its address into a register, and then using
4412 the contents of that register. The @code{near} attribute has the opposite
4413 effect; it specifies that non-PIC calls should be made using the more
4414 efficient @code{jal} instruction.
4415
4416 @item mips16
4417 @itemx nomips16
4418 @cindex @code{mips16} function attribute, MIPS
4419 @cindex @code{nomips16} function attribute, MIPS
4420
4421 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4422 function attributes to locally select or turn off MIPS16 code generation.
4423 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4424 while MIPS16 code generation is disabled for functions with the
4425 @code{nomips16} attribute. These attributes override the
4426 @option{-mips16} and @option{-mno-mips16} options on the command line
4427 (@pxref{MIPS Options}).
4428
4429 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4430 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4431 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4432 may interact badly with some GCC extensions such as @code{__builtin_apply}
4433 (@pxref{Constructing Calls}).
4434
4435 @item micromips, MIPS
4436 @itemx nomicromips, MIPS
4437 @cindex @code{micromips} function attribute
4438 @cindex @code{nomicromips} function attribute
4439
4440 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4441 function attributes to locally select or turn off microMIPS code generation.
4442 A function with the @code{micromips} attribute is emitted as microMIPS code,
4443 while microMIPS code generation is disabled for functions with the
4444 @code{nomicromips} attribute. These attributes override the
4445 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4446 (@pxref{MIPS Options}).
4447
4448 When compiling files containing mixed microMIPS and non-microMIPS code, the
4449 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4450 command line,
4451 not that within individual functions. Mixed microMIPS and non-microMIPS code
4452 may interact badly with some GCC extensions such as @code{__builtin_apply}
4453 (@pxref{Constructing Calls}).
4454
4455 @item nocompression
4456 @cindex @code{nocompression} function attribute, MIPS
4457 On MIPS targets, you can use the @code{nocompression} function attribute
4458 to locally turn off MIPS16 and microMIPS code generation. This attribute
4459 overrides the @option{-mips16} and @option{-mmicromips} options on the
4460 command line (@pxref{MIPS Options}).
4461 @end table
4462
4463 @node MSP430 Function Attributes
4464 @subsection MSP430 Function Attributes
4465
4466 These function attributes are supported by the MSP430 back end:
4467
4468 @table @code
4469 @item critical
4470 @cindex @code{critical} function attribute, MSP430
4471 Critical functions disable interrupts upon entry and restore the
4472 previous interrupt state upon exit. Critical functions cannot also
4473 have the @code{naked} or @code{reentrant} attributes. They can have
4474 the @code{interrupt} attribute.
4475
4476 @item interrupt
4477 @cindex @code{interrupt} function attribute, MSP430
4478 Use this attribute to indicate
4479 that the specified function is an interrupt handler. The compiler generates
4480 function entry and exit sequences suitable for use in an interrupt handler
4481 when this attribute is present.
4482
4483 You can provide an argument to the interrupt
4484 attribute which specifies a name or number. If the argument is a
4485 number it indicates the slot in the interrupt vector table (0 - 31) to
4486 which this handler should be assigned. If the argument is a name it
4487 is treated as a symbolic name for the vector slot. These names should
4488 match up with appropriate entries in the linker script. By default
4489 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4490 @code{reset} for vector 31 are recognized.
4491
4492 @item naked
4493 @cindex @code{naked} function attribute, MSP430
4494 This attribute allows the compiler to construct the
4495 requisite function declaration, while allowing the body of the
4496 function to be assembly code. The specified function will not have
4497 prologue/epilogue sequences generated by the compiler. Only basic
4498 @code{asm} statements can safely be included in naked functions
4499 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4500 basic @code{asm} and C code may appear to work, they cannot be
4501 depended upon to work reliably and are not supported.
4502
4503 @item reentrant
4504 @cindex @code{reentrant} function attribute, MSP430
4505 Reentrant functions disable interrupts upon entry and enable them
4506 upon exit. Reentrant functions cannot also have the @code{naked}
4507 or @code{critical} attributes. They can have the @code{interrupt}
4508 attribute.
4509
4510 @item wakeup
4511 @cindex @code{wakeup} function attribute, MSP430
4512 This attribute only applies to interrupt functions. It is silently
4513 ignored if applied to a non-interrupt function. A wakeup interrupt
4514 function will rouse the processor from any low-power state that it
4515 might be in when the function exits.
4516
4517 @item lower
4518 @itemx upper
4519 @itemx either
4520 @cindex @code{lower} function attribute, MSP430
4521 @cindex @code{upper} function attribute, MSP430
4522 @cindex @code{either} function attribute, MSP430
4523 On the MSP430 target these attributes can be used to specify whether
4524 the function or variable should be placed into low memory, high
4525 memory, or the placement should be left to the linker to decide. The
4526 attributes are only significant if compiling for the MSP430X
4527 architecture.
4528
4529 The attributes work in conjunction with a linker script that has been
4530 augmented to specify where to place sections with a @code{.lower} and
4531 a @code{.upper} prefix. So, for example, as well as placing the
4532 @code{.data} section, the script also specifies the placement of a
4533 @code{.lower.data} and a @code{.upper.data} section. The intention
4534 is that @code{lower} sections are placed into a small but easier to
4535 access memory region and the upper sections are placed into a larger, but
4536 slower to access, region.
4537
4538 The @code{either} attribute is special. It tells the linker to place
4539 the object into the corresponding @code{lower} section if there is
4540 room for it. If there is insufficient room then the object is placed
4541 into the corresponding @code{upper} section instead. Note that the
4542 placement algorithm is not very sophisticated. It does not attempt to
4543 find an optimal packing of the @code{lower} sections. It just makes
4544 one pass over the objects and does the best that it can. Using the
4545 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4546 options can help the packing, however, since they produce smaller,
4547 easier to pack regions.
4548 @end table
4549
4550 @node NDS32 Function Attributes
4551 @subsection NDS32 Function Attributes
4552
4553 These function attributes are supported by the NDS32 back end:
4554
4555 @table @code
4556 @item exception
4557 @cindex @code{exception} function attribute
4558 @cindex exception handler functions, NDS32
4559 Use this attribute on the NDS32 target to indicate that the specified function
4560 is an exception handler. The compiler will generate corresponding sections
4561 for use in an exception handler.
4562
4563 @item interrupt
4564 @cindex @code{interrupt} function attribute, NDS32
4565 On NDS32 target, this attribute indicates that the specified function
4566 is an interrupt handler. The compiler generates corresponding sections
4567 for use in an interrupt handler. You can use the following attributes
4568 to modify the behavior:
4569 @table @code
4570 @item nested
4571 @cindex @code{nested} function attribute, NDS32
4572 This interrupt service routine is interruptible.
4573 @item not_nested
4574 @cindex @code{not_nested} function attribute, NDS32
4575 This interrupt service routine is not interruptible.
4576 @item nested_ready
4577 @cindex @code{nested_ready} function attribute, NDS32
4578 This interrupt service routine is interruptible after @code{PSW.GIE}
4579 (global interrupt enable) is set. This allows interrupt service routine to
4580 finish some short critical code before enabling interrupts.
4581 @item save_all
4582 @cindex @code{save_all} function attribute, NDS32
4583 The system will help save all registers into stack before entering
4584 interrupt handler.
4585 @item partial_save
4586 @cindex @code{partial_save} function attribute, NDS32
4587 The system will help save caller registers into stack before entering
4588 interrupt handler.
4589 @end table
4590
4591 @item naked
4592 @cindex @code{naked} function attribute, NDS32
4593 This attribute allows the compiler to construct the
4594 requisite function declaration, while allowing the body of the
4595 function to be assembly code. The specified function will not have
4596 prologue/epilogue sequences generated by the compiler. Only basic
4597 @code{asm} statements can safely be included in naked functions
4598 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4599 basic @code{asm} and C code may appear to work, they cannot be
4600 depended upon to work reliably and are not supported.
4601
4602 @item reset
4603 @cindex @code{reset} function attribute, NDS32
4604 @cindex reset handler functions
4605 Use this attribute on the NDS32 target to indicate that the specified function
4606 is a reset handler. The compiler will generate corresponding sections
4607 for use in a reset handler. You can use the following attributes
4608 to provide extra exception handling:
4609 @table @code
4610 @item nmi
4611 @cindex @code{nmi} function attribute, NDS32
4612 Provide a user-defined function to handle NMI exception.
4613 @item warm
4614 @cindex @code{warm} function attribute, NDS32
4615 Provide a user-defined function to handle warm reset exception.
4616 @end table
4617 @end table
4618
4619 @node Nios II Function Attributes
4620 @subsection Nios II Function Attributes
4621
4622 These function attributes are supported by the Nios II back end:
4623
4624 @table @code
4625 @item target (@var{options})
4626 @cindex @code{target} function attribute
4627 As discussed in @ref{Common Function Attributes}, this attribute
4628 allows specification of target-specific compilation options.
4629
4630 When compiling for Nios II, the following options are allowed:
4631
4632 @table @samp
4633 @item custom-@var{insn}=@var{N}
4634 @itemx no-custom-@var{insn}
4635 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4636 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4637 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4638 custom instruction with encoding @var{N} when generating code that uses
4639 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4640 the custom instruction @var{insn}.
4641 These target attributes correspond to the
4642 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4643 command-line options, and support the same set of @var{insn} keywords.
4644 @xref{Nios II Options}, for more information.
4645
4646 @item custom-fpu-cfg=@var{name}
4647 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4648 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4649 command-line option, to select a predefined set of custom instructions
4650 named @var{name}.
4651 @xref{Nios II Options}, for more information.
4652 @end table
4653 @end table
4654
4655 @node Nvidia PTX Function Attributes
4656 @subsection Nvidia PTX Function Attributes
4657
4658 These function attributes are supported by the Nvidia PTX back end:
4659
4660 @table @code
4661 @item kernel
4662 @cindex @code{kernel} attribute, Nvidia PTX
4663 This attribute indicates that the corresponding function should be compiled
4664 as a kernel function, which can be invoked from the host via the CUDA RT
4665 library.
4666 By default functions are only callable only from other PTX functions.
4667
4668 Kernel functions must have @code{void} return type.
4669 @end table
4670
4671 @node PowerPC Function Attributes
4672 @subsection PowerPC Function Attributes
4673
4674 These function attributes are supported by the PowerPC back end:
4675
4676 @table @code
4677 @item longcall
4678 @itemx shortcall
4679 @cindex indirect calls, PowerPC
4680 @cindex @code{longcall} function attribute, PowerPC
4681 @cindex @code{shortcall} function attribute, PowerPC
4682 The @code{longcall} attribute
4683 indicates that the function might be far away from the call site and
4684 require a different (more expensive) calling sequence. The
4685 @code{shortcall} attribute indicates that the function is always close
4686 enough for the shorter calling sequence to be used. These attributes
4687 override both the @option{-mlongcall} switch and
4688 the @code{#pragma longcall} setting.
4689
4690 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4691 calls are necessary.
4692
4693 @item target (@var{options})
4694 @cindex @code{target} function attribute
4695 As discussed in @ref{Common Function Attributes}, this attribute
4696 allows specification of target-specific compilation options.
4697
4698 On the PowerPC, the following options are allowed:
4699
4700 @table @samp
4701 @item altivec
4702 @itemx no-altivec
4703 @cindex @code{target("altivec")} function attribute, PowerPC
4704 Generate code that uses (does not use) AltiVec instructions. In
4705 32-bit code, you cannot enable AltiVec instructions unless
4706 @option{-mabi=altivec} is used on the command line.
4707
4708 @item cmpb
4709 @itemx no-cmpb
4710 @cindex @code{target("cmpb")} function attribute, PowerPC
4711 Generate code that uses (does not use) the compare bytes instruction
4712 implemented on the POWER6 processor and other processors that support
4713 the PowerPC V2.05 architecture.
4714
4715 @item dlmzb
4716 @itemx no-dlmzb
4717 @cindex @code{target("dlmzb")} function attribute, PowerPC
4718 Generate code that uses (does not use) the string-search @samp{dlmzb}
4719 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4720 generated by default when targeting those processors.
4721
4722 @item fprnd
4723 @itemx no-fprnd
4724 @cindex @code{target("fprnd")} function attribute, PowerPC
4725 Generate code that uses (does not use) the FP round to integer
4726 instructions implemented on the POWER5+ processor and other processors
4727 that support the PowerPC V2.03 architecture.
4728
4729 @item hard-dfp
4730 @itemx no-hard-dfp
4731 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4732 Generate code that uses (does not use) the decimal floating-point
4733 instructions implemented on some POWER processors.
4734
4735 @item isel
4736 @itemx no-isel
4737 @cindex @code{target("isel")} function attribute, PowerPC
4738 Generate code that uses (does not use) ISEL instruction.
4739
4740 @item mfcrf
4741 @itemx no-mfcrf
4742 @cindex @code{target("mfcrf")} function attribute, PowerPC
4743 Generate code that uses (does not use) the move from condition
4744 register field instruction implemented on the POWER4 processor and
4745 other processors that support the PowerPC V2.01 architecture.
4746
4747 @item mfpgpr
4748 @itemx no-mfpgpr
4749 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4750 Generate code that uses (does not use) the FP move to/from general
4751 purpose register instructions implemented on the POWER6X processor and
4752 other processors that support the extended PowerPC V2.05 architecture.
4753
4754 @item mulhw
4755 @itemx no-mulhw
4756 @cindex @code{target("mulhw")} function attribute, PowerPC
4757 Generate code that uses (does not use) the half-word multiply and
4758 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4759 These instructions are generated by default when targeting those
4760 processors.
4761
4762 @item multiple
4763 @itemx no-multiple
4764 @cindex @code{target("multiple")} function attribute, PowerPC
4765 Generate code that uses (does not use) the load multiple word
4766 instructions and the store multiple word instructions.
4767
4768 @item update
4769 @itemx no-update
4770 @cindex @code{target("update")} function attribute, PowerPC
4771 Generate code that uses (does not use) the load or store instructions
4772 that update the base register to the address of the calculated memory
4773 location.
4774
4775 @item popcntb
4776 @itemx no-popcntb
4777 @cindex @code{target("popcntb")} function attribute, PowerPC
4778 Generate code that uses (does not use) the popcount and double-precision
4779 FP reciprocal estimate instruction implemented on the POWER5
4780 processor and other processors that support the PowerPC V2.02
4781 architecture.
4782
4783 @item popcntd
4784 @itemx no-popcntd
4785 @cindex @code{target("popcntd")} function attribute, PowerPC
4786 Generate code that uses (does not use) the popcount instruction
4787 implemented on the POWER7 processor and other processors that support
4788 the PowerPC V2.06 architecture.
4789
4790 @item powerpc-gfxopt
4791 @itemx no-powerpc-gfxopt
4792 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4793 Generate code that uses (does not use) the optional PowerPC
4794 architecture instructions in the Graphics group, including
4795 floating-point select.
4796
4797 @item powerpc-gpopt
4798 @itemx no-powerpc-gpopt
4799 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4800 Generate code that uses (does not use) the optional PowerPC
4801 architecture instructions in the General Purpose group, including
4802 floating-point square root.
4803
4804 @item recip-precision
4805 @itemx no-recip-precision
4806 @cindex @code{target("recip-precision")} function attribute, PowerPC
4807 Assume (do not assume) that the reciprocal estimate instructions
4808 provide higher-precision estimates than is mandated by the PowerPC
4809 ABI.
4810
4811 @item string
4812 @itemx no-string
4813 @cindex @code{target("string")} function attribute, PowerPC
4814 Generate code that uses (does not use) the load string instructions
4815 and the store string word instructions to save multiple registers and
4816 do small block moves.
4817
4818 @item vsx
4819 @itemx no-vsx
4820 @cindex @code{target("vsx")} function attribute, PowerPC
4821 Generate code that uses (does not use) vector/scalar (VSX)
4822 instructions, and also enable the use of built-in functions that allow
4823 more direct access to the VSX instruction set. In 32-bit code, you
4824 cannot enable VSX or AltiVec instructions unless
4825 @option{-mabi=altivec} is used on the command line.
4826
4827 @item friz
4828 @itemx no-friz
4829 @cindex @code{target("friz")} function attribute, PowerPC
4830 Generate (do not generate) the @code{friz} instruction when the
4831 @option{-funsafe-math-optimizations} option is used to optimize
4832 rounding a floating-point value to 64-bit integer and back to floating
4833 point. The @code{friz} instruction does not return the same value if
4834 the floating-point number is too large to fit in an integer.
4835
4836 @item avoid-indexed-addresses
4837 @itemx no-avoid-indexed-addresses
4838 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4839 Generate code that tries to avoid (not avoid) the use of indexed load
4840 or store instructions.
4841
4842 @item paired
4843 @itemx no-paired
4844 @cindex @code{target("paired")} function attribute, PowerPC
4845 Generate code that uses (does not use) the generation of PAIRED simd
4846 instructions.
4847
4848 @item longcall
4849 @itemx no-longcall
4850 @cindex @code{target("longcall")} function attribute, PowerPC
4851 Generate code that assumes (does not assume) that all calls are far
4852 away so that a longer more expensive calling sequence is required.
4853
4854 @item cpu=@var{CPU}
4855 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4856 Specify the architecture to generate code for when compiling the
4857 function. If you select the @code{target("cpu=power7")} attribute when
4858 generating 32-bit code, VSX and AltiVec instructions are not generated
4859 unless you use the @option{-mabi=altivec} option on the command line.
4860
4861 @item tune=@var{TUNE}
4862 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4863 Specify the architecture to tune for when compiling the function. If
4864 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4865 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4866 compilation tunes for the @var{CPU} architecture, and not the
4867 default tuning specified on the command line.
4868 @end table
4869
4870 On the PowerPC, the inliner does not inline a
4871 function that has different target options than the caller, unless the
4872 callee has a subset of the target options of the caller.
4873 @end table
4874
4875 @node RL78 Function Attributes
4876 @subsection RL78 Function Attributes
4877
4878 These function attributes are supported by the RL78 back end:
4879
4880 @table @code
4881 @item interrupt
4882 @itemx brk_interrupt
4883 @cindex @code{interrupt} function attribute, RL78
4884 @cindex @code{brk_interrupt} function attribute, RL78
4885 These attributes indicate
4886 that the specified function is an interrupt handler. The compiler generates
4887 function entry and exit sequences suitable for use in an interrupt handler
4888 when this attribute is present.
4889
4890 Use @code{brk_interrupt} instead of @code{interrupt} for
4891 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4892 that must end with @code{RETB} instead of @code{RETI}).
4893
4894 @item naked
4895 @cindex @code{naked} function attribute, RL78
4896 This attribute allows the compiler to construct the
4897 requisite function declaration, while allowing the body of the
4898 function to be assembly code. The specified function will not have
4899 prologue/epilogue sequences generated by the compiler. Only basic
4900 @code{asm} statements can safely be included in naked functions
4901 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4902 basic @code{asm} and C code may appear to work, they cannot be
4903 depended upon to work reliably and are not supported.
4904 @end table
4905
4906 @node RX Function Attributes
4907 @subsection RX Function Attributes
4908
4909 These function attributes are supported by the RX back end:
4910
4911 @table @code
4912 @item fast_interrupt
4913 @cindex @code{fast_interrupt} function attribute, RX
4914 Use this attribute on the RX port to indicate that the specified
4915 function is a fast interrupt handler. This is just like the
4916 @code{interrupt} attribute, except that @code{freit} is used to return
4917 instead of @code{reit}.
4918
4919 @item interrupt
4920 @cindex @code{interrupt} function attribute, RX
4921 Use this attribute to indicate
4922 that the specified function is an interrupt handler. The compiler generates
4923 function entry and exit sequences suitable for use in an interrupt handler
4924 when this attribute is present.
4925
4926 On RX targets, you may specify one or more vector numbers as arguments
4927 to the attribute, as well as naming an alternate table name.
4928 Parameters are handled sequentially, so one handler can be assigned to
4929 multiple entries in multiple tables. One may also pass the magic
4930 string @code{"$default"} which causes the function to be used for any
4931 unfilled slots in the current table.
4932
4933 This example shows a simple assignment of a function to one vector in
4934 the default table (note that preprocessor macros may be used for
4935 chip-specific symbolic vector names):
4936 @smallexample
4937 void __attribute__ ((interrupt (5))) txd1_handler ();
4938 @end smallexample
4939
4940 This example assigns a function to two slots in the default table
4941 (using preprocessor macros defined elsewhere) and makes it the default
4942 for the @code{dct} table:
4943 @smallexample
4944 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4945 txd1_handler ();
4946 @end smallexample
4947
4948 @item naked
4949 @cindex @code{naked} function attribute, RX
4950 This attribute allows the compiler to construct the
4951 requisite function declaration, while allowing the body of the
4952 function to be assembly code. The specified function will not have
4953 prologue/epilogue sequences generated by the compiler. Only basic
4954 @code{asm} statements can safely be included in naked functions
4955 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4956 basic @code{asm} and C code may appear to work, they cannot be
4957 depended upon to work reliably and are not supported.
4958
4959 @item vector
4960 @cindex @code{vector} function attribute, RX
4961 This RX attribute is similar to the @code{interrupt} attribute, including its
4962 parameters, but does not make the function an interrupt-handler type
4963 function (i.e. it retains the normal C function calling ABI). See the
4964 @code{interrupt} attribute for a description of its arguments.
4965 @end table
4966
4967 @node S/390 Function Attributes
4968 @subsection S/390 Function Attributes
4969
4970 These function attributes are supported on the S/390:
4971
4972 @table @code
4973 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4974 @cindex @code{hotpatch} function attribute, S/390
4975
4976 On S/390 System z targets, you can use this function attribute to
4977 make GCC generate a ``hot-patching'' function prologue. If the
4978 @option{-mhotpatch=} command-line option is used at the same time,
4979 the @code{hotpatch} attribute takes precedence. The first of the
4980 two arguments specifies the number of halfwords to be added before
4981 the function label. A second argument can be used to specify the
4982 number of halfwords to be added after the function label. For
4983 both arguments the maximum allowed value is 1000000.
4984
4985 If both arguments are zero, hotpatching is disabled.
4986
4987 @item target (@var{options})
4988 @cindex @code{target} function attribute
4989 As discussed in @ref{Common Function Attributes}, this attribute
4990 allows specification of target-specific compilation options.
4991
4992 On S/390, the following options are supported:
4993
4994 @table @samp
4995 @item arch=
4996 @item tune=
4997 @item stack-guard=
4998 @item stack-size=
4999 @item branch-cost=
5000 @item warn-framesize=
5001 @item backchain
5002 @itemx no-backchain
5003 @item hard-dfp
5004 @itemx no-hard-dfp
5005 @item hard-float
5006 @itemx soft-float
5007 @item htm
5008 @itemx no-htm
5009 @item vx
5010 @itemx no-vx
5011 @item packed-stack
5012 @itemx no-packed-stack
5013 @item small-exec
5014 @itemx no-small-exec
5015 @item mvcle
5016 @itemx no-mvcle
5017 @item warn-dynamicstack
5018 @itemx no-warn-dynamicstack
5019 @end table
5020
5021 The options work exactly like the S/390 specific command line
5022 options (without the prefix @option{-m}) except that they do not
5023 change any feature macros. For example,
5024
5025 @smallexample
5026 @code{target("no-vx")}
5027 @end smallexample
5028
5029 does not undefine the @code{__VEC__} macro.
5030 @end table
5031
5032 @node SH Function Attributes
5033 @subsection SH Function Attributes
5034
5035 These function attributes are supported on the SH family of processors:
5036
5037 @table @code
5038 @item function_vector
5039 @cindex @code{function_vector} function attribute, SH
5040 @cindex calling functions through the function vector on SH2A
5041 On SH2A targets, this attribute declares a function to be called using the
5042 TBR relative addressing mode. The argument to this attribute is the entry
5043 number of the same function in a vector table containing all the TBR
5044 relative addressable functions. For correct operation the TBR must be setup
5045 accordingly to point to the start of the vector table before any functions with
5046 this attribute are invoked. Usually a good place to do the initialization is
5047 the startup routine. The TBR relative vector table can have at max 256 function
5048 entries. The jumps to these functions are generated using a SH2A specific,
5049 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
5050 from GNU binutils version 2.7 or later for this attribute to work correctly.
5051
5052 In an application, for a function being called once, this attribute
5053 saves at least 8 bytes of code; and if other successive calls are being
5054 made to the same function, it saves 2 bytes of code per each of these
5055 calls.
5056
5057 @item interrupt_handler
5058 @cindex @code{interrupt_handler} function attribute, SH
5059 Use this attribute to
5060 indicate that the specified function is an interrupt handler. The compiler
5061 generates function entry and exit sequences suitable for use in an
5062 interrupt handler when this attribute is present.
5063
5064 @item nosave_low_regs
5065 @cindex @code{nosave_low_regs} function attribute, SH
5066 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5067 function should not save and restore registers R0..R7. This can be used on SH3*
5068 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5069 interrupt handlers.
5070
5071 @item renesas
5072 @cindex @code{renesas} function attribute, SH
5073 On SH targets this attribute specifies that the function or struct follows the
5074 Renesas ABI.
5075
5076 @item resbank
5077 @cindex @code{resbank} function attribute, SH
5078 On the SH2A target, this attribute enables the high-speed register
5079 saving and restoration using a register bank for @code{interrupt_handler}
5080 routines. Saving to the bank is performed automatically after the CPU
5081 accepts an interrupt that uses a register bank.
5082
5083 The nineteen 32-bit registers comprising general register R0 to R14,
5084 control register GBR, and system registers MACH, MACL, and PR and the
5085 vector table address offset are saved into a register bank. Register
5086 banks are stacked in first-in last-out (FILO) sequence. Restoration
5087 from the bank is executed by issuing a RESBANK instruction.
5088
5089 @item sp_switch
5090 @cindex @code{sp_switch} function attribute, SH
5091 Use this attribute on the SH to indicate an @code{interrupt_handler}
5092 function should switch to an alternate stack. It expects a string
5093 argument that names a global variable holding the address of the
5094 alternate stack.
5095
5096 @smallexample
5097 void *alt_stack;
5098 void f () __attribute__ ((interrupt_handler,
5099 sp_switch ("alt_stack")));
5100 @end smallexample
5101
5102 @item trap_exit
5103 @cindex @code{trap_exit} function attribute, SH
5104 Use this attribute on the SH for an @code{interrupt_handler} to return using
5105 @code{trapa} instead of @code{rte}. This attribute expects an integer
5106 argument specifying the trap number to be used.
5107
5108 @item trapa_handler
5109 @cindex @code{trapa_handler} function attribute, SH
5110 On SH targets this function attribute is similar to @code{interrupt_handler}
5111 but it does not save and restore all registers.
5112 @end table
5113
5114 @node SPU Function Attributes
5115 @subsection SPU Function Attributes
5116
5117 These function attributes are supported by the SPU back end:
5118
5119 @table @code
5120 @item naked
5121 @cindex @code{naked} function attribute, SPU
5122 This attribute allows the compiler to construct the
5123 requisite function declaration, while allowing the body of the
5124 function to be assembly code. The specified function will not have
5125 prologue/epilogue sequences generated by the compiler. Only basic
5126 @code{asm} statements can safely be included in naked functions
5127 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5128 basic @code{asm} and C code may appear to work, they cannot be
5129 depended upon to work reliably and are not supported.
5130 @end table
5131
5132 @node Symbian OS Function Attributes
5133 @subsection Symbian OS Function Attributes
5134
5135 @xref{Microsoft Windows Function Attributes}, for discussion of the
5136 @code{dllexport} and @code{dllimport} attributes.
5137
5138 @node V850 Function Attributes
5139 @subsection V850 Function Attributes
5140
5141 The V850 back end supports these function attributes:
5142
5143 @table @code
5144 @item interrupt
5145 @itemx interrupt_handler
5146 @cindex @code{interrupt} function attribute, V850
5147 @cindex @code{interrupt_handler} function attribute, V850
5148 Use these attributes to indicate
5149 that the specified function is an interrupt handler. The compiler generates
5150 function entry and exit sequences suitable for use in an interrupt handler
5151 when either attribute is present.
5152 @end table
5153
5154 @node Visium Function Attributes
5155 @subsection Visium Function Attributes
5156
5157 These function attributes are supported by the Visium back end:
5158
5159 @table @code
5160 @item interrupt
5161 @cindex @code{interrupt} function attribute, Visium
5162 Use this attribute to indicate
5163 that the specified function is an interrupt handler. The compiler generates
5164 function entry and exit sequences suitable for use in an interrupt handler
5165 when this attribute is present.
5166 @end table
5167
5168 @node x86 Function Attributes
5169 @subsection x86 Function Attributes
5170
5171 These function attributes are supported by the x86 back end:
5172
5173 @table @code
5174 @item cdecl
5175 @cindex @code{cdecl} function attribute, x86-32
5176 @cindex functions that pop the argument stack on x86-32
5177 @opindex mrtd
5178 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5179 assume that the calling function pops off the stack space used to
5180 pass arguments. This is
5181 useful to override the effects of the @option{-mrtd} switch.
5182
5183 @item fastcall
5184 @cindex @code{fastcall} function attribute, x86-32
5185 @cindex functions that pop the argument stack on x86-32
5186 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5187 pass the first argument (if of integral type) in the register ECX and
5188 the second argument (if of integral type) in the register EDX@. Subsequent
5189 and other typed arguments are passed on the stack. The called function
5190 pops the arguments off the stack. If the number of arguments is variable all
5191 arguments are pushed on the stack.
5192
5193 @item thiscall
5194 @cindex @code{thiscall} function attribute, x86-32
5195 @cindex functions that pop the argument stack on x86-32
5196 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5197 pass the first argument (if of integral type) in the register ECX.
5198 Subsequent and other typed arguments are passed on the stack. The called
5199 function pops the arguments off the stack.
5200 If the number of arguments is variable all arguments are pushed on the
5201 stack.
5202 The @code{thiscall} attribute is intended for C++ non-static member functions.
5203 As a GCC extension, this calling convention can be used for C functions
5204 and for static member methods.
5205
5206 @item ms_abi
5207 @itemx sysv_abi
5208 @cindex @code{ms_abi} function attribute, x86
5209 @cindex @code{sysv_abi} function attribute, x86
5210
5211 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5212 to indicate which calling convention should be used for a function. The
5213 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5214 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5215 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5216 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5217
5218 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5219 requires the @option{-maccumulate-outgoing-args} option.
5220
5221 @item callee_pop_aggregate_return (@var{number})
5222 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5223
5224 On x86-32 targets, you can use this attribute to control how
5225 aggregates are returned in memory. If the caller is responsible for
5226 popping the hidden pointer together with the rest of the arguments, specify
5227 @var{number} equal to zero. If callee is responsible for popping the
5228 hidden pointer, specify @var{number} equal to one.
5229
5230 The default x86-32 ABI assumes that the callee pops the
5231 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5232 the compiler assumes that the
5233 caller pops the stack for hidden pointer.
5234
5235 @item ms_hook_prologue
5236 @cindex @code{ms_hook_prologue} function attribute, x86
5237
5238 On 32-bit and 64-bit x86 targets, you can use
5239 this function attribute to make GCC generate the ``hot-patching'' function
5240 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5241 and newer.
5242
5243 @item regparm (@var{number})
5244 @cindex @code{regparm} function attribute, x86
5245 @cindex functions that are passed arguments in registers on x86-32
5246 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5247 pass arguments number one to @var{number} if they are of integral type
5248 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5249 take a variable number of arguments continue to be passed all of their
5250 arguments on the stack.
5251
5252 Beware that on some ELF systems this attribute is unsuitable for
5253 global functions in shared libraries with lazy binding (which is the
5254 default). Lazy binding sends the first call via resolving code in
5255 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5256 per the standard calling conventions. Solaris 8 is affected by this.
5257 Systems with the GNU C Library version 2.1 or higher
5258 and FreeBSD are believed to be
5259 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5260 disabled with the linker or the loader if desired, to avoid the
5261 problem.)
5262
5263 @item sseregparm
5264 @cindex @code{sseregparm} function attribute, x86
5265 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5266 causes the compiler to pass up to 3 floating-point arguments in
5267 SSE registers instead of on the stack. Functions that take a
5268 variable number of arguments continue to pass all of their
5269 floating-point arguments on the stack.
5270
5271 @item force_align_arg_pointer
5272 @cindex @code{force_align_arg_pointer} function attribute, x86
5273 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5274 applied to individual function definitions, generating an alternate
5275 prologue and epilogue that realigns the run-time stack if necessary.
5276 This supports mixing legacy codes that run with a 4-byte aligned stack
5277 with modern codes that keep a 16-byte stack for SSE compatibility.
5278
5279 @item stdcall
5280 @cindex @code{stdcall} function attribute, x86-32
5281 @cindex functions that pop the argument stack on x86-32
5282 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5283 assume that the called function pops off the stack space used to
5284 pass arguments, unless it takes a variable number of arguments.
5285
5286 @item no_caller_saved_registers
5287 @cindex @code{no_caller_saved_registers} function attribute, x86
5288 Use this attribute to indicate that the specified function has no
5289 caller-saved registers. That is, all registers are callee-saved. For
5290 example, this attribute can be used for a function called from an
5291 interrupt handler. The compiler generates proper function entry and
5292 exit sequences to save and restore any modified registers, except for
5293 the EFLAGS register. Since GCC doesn't preserve MPX, SSE, MMX nor x87
5294 states, the GCC option @option{-mgeneral-regs-only} should be used to
5295 compile functions with @code{no_caller_saved_registers} attribute.
5296
5297 @item interrupt
5298 @cindex @code{interrupt} function attribute, x86
5299 Use this attribute to indicate that the specified function is an
5300 interrupt handler or an exception handler (depending on parameters passed
5301 to the function, explained further). The compiler generates function
5302 entry and exit sequences suitable for use in an interrupt handler when
5303 this attribute is present. The @code{IRET} instruction, instead of the
5304 @code{RET} instruction, is used to return from interrupt handlers. All
5305 registers, except for the EFLAGS register which is restored by the
5306 @code{IRET} instruction, are preserved by the compiler. Since GCC
5307 doesn't preserve MPX, SSE, MMX nor x87 states, the GCC option
5308 @option{-mgeneral-regs-only} should be used to compile interrupt and
5309 exception handlers.
5310
5311 Any interruptible-without-stack-switch code must be compiled with
5312 @option{-mno-red-zone} since interrupt handlers can and will, because
5313 of the hardware design, touch the red zone.
5314
5315 An interrupt handler must be declared with a mandatory pointer
5316 argument:
5317
5318 @smallexample
5319 struct interrupt_frame;
5320
5321 __attribute__ ((interrupt))
5322 void
5323 f (struct interrupt_frame *frame)
5324 @{
5325 @}
5326 @end smallexample
5327
5328 @noindent
5329 and you must define @code{struct interrupt_frame} as described in the
5330 processor's manual.
5331
5332 Exception handlers differ from interrupt handlers because the system
5333 pushes an error code on the stack. An exception handler declaration is
5334 similar to that for an interrupt handler, but with a different mandatory
5335 function signature. The compiler arranges to pop the error code off the
5336 stack before the @code{IRET} instruction.
5337
5338 @smallexample
5339 #ifdef __x86_64__
5340 typedef unsigned long long int uword_t;
5341 #else
5342 typedef unsigned int uword_t;
5343 #endif
5344
5345 struct interrupt_frame;
5346
5347 __attribute__ ((interrupt))
5348 void
5349 f (struct interrupt_frame *frame, uword_t error_code)
5350 @{
5351 ...
5352 @}
5353 @end smallexample
5354
5355 Exception handlers should only be used for exceptions that push an error
5356 code; you should use an interrupt handler in other cases. The system
5357 will crash if the wrong kind of handler is used.
5358
5359 @item target (@var{options})
5360 @cindex @code{target} function attribute
5361 As discussed in @ref{Common Function Attributes}, this attribute
5362 allows specification of target-specific compilation options.
5363
5364 On the x86, the following options are allowed:
5365 @table @samp
5366 @item abm
5367 @itemx no-abm
5368 @cindex @code{target("abm")} function attribute, x86
5369 Enable/disable the generation of the advanced bit instructions.
5370
5371 @item aes
5372 @itemx no-aes
5373 @cindex @code{target("aes")} function attribute, x86
5374 Enable/disable the generation of the AES instructions.
5375
5376 @item default
5377 @cindex @code{target("default")} function attribute, x86
5378 @xref{Function Multiversioning}, where it is used to specify the
5379 default function version.
5380
5381 @item mmx
5382 @itemx no-mmx
5383 @cindex @code{target("mmx")} function attribute, x86
5384 Enable/disable the generation of the MMX instructions.
5385
5386 @item pclmul
5387 @itemx no-pclmul
5388 @cindex @code{target("pclmul")} function attribute, x86
5389 Enable/disable the generation of the PCLMUL instructions.
5390
5391 @item popcnt
5392 @itemx no-popcnt
5393 @cindex @code{target("popcnt")} function attribute, x86
5394 Enable/disable the generation of the POPCNT instruction.
5395
5396 @item sse
5397 @itemx no-sse
5398 @cindex @code{target("sse")} function attribute, x86
5399 Enable/disable the generation of the SSE instructions.
5400
5401 @item sse2
5402 @itemx no-sse2
5403 @cindex @code{target("sse2")} function attribute, x86
5404 Enable/disable the generation of the SSE2 instructions.
5405
5406 @item sse3
5407 @itemx no-sse3
5408 @cindex @code{target("sse3")} function attribute, x86
5409 Enable/disable the generation of the SSE3 instructions.
5410
5411 @item sse4
5412 @itemx no-sse4
5413 @cindex @code{target("sse4")} function attribute, x86
5414 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5415 and SSE4.2).
5416
5417 @item sse4.1
5418 @itemx no-sse4.1
5419 @cindex @code{target("sse4.1")} function attribute, x86
5420 Enable/disable the generation of the sse4.1 instructions.
5421
5422 @item sse4.2
5423 @itemx no-sse4.2
5424 @cindex @code{target("sse4.2")} function attribute, x86
5425 Enable/disable the generation of the sse4.2 instructions.
5426
5427 @item sse4a
5428 @itemx no-sse4a
5429 @cindex @code{target("sse4a")} function attribute, x86
5430 Enable/disable the generation of the SSE4A instructions.
5431
5432 @item fma4
5433 @itemx no-fma4
5434 @cindex @code{target("fma4")} function attribute, x86
5435 Enable/disable the generation of the FMA4 instructions.
5436
5437 @item xop
5438 @itemx no-xop
5439 @cindex @code{target("xop")} function attribute, x86
5440 Enable/disable the generation of the XOP instructions.
5441
5442 @item lwp
5443 @itemx no-lwp
5444 @cindex @code{target("lwp")} function attribute, x86
5445 Enable/disable the generation of the LWP instructions.
5446
5447 @item ssse3
5448 @itemx no-ssse3
5449 @cindex @code{target("ssse3")} function attribute, x86
5450 Enable/disable the generation of the SSSE3 instructions.
5451
5452 @item cld
5453 @itemx no-cld
5454 @cindex @code{target("cld")} function attribute, x86
5455 Enable/disable the generation of the CLD before string moves.
5456
5457 @item fancy-math-387
5458 @itemx no-fancy-math-387
5459 @cindex @code{target("fancy-math-387")} function attribute, x86
5460 Enable/disable the generation of the @code{sin}, @code{cos}, and
5461 @code{sqrt} instructions on the 387 floating-point unit.
5462
5463 @item fused-madd
5464 @itemx no-fused-madd
5465 @cindex @code{target("fused-madd")} function attribute, x86
5466 Enable/disable the generation of the fused multiply/add instructions.
5467
5468 @item ieee-fp
5469 @itemx no-ieee-fp
5470 @cindex @code{target("ieee-fp")} function attribute, x86
5471 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5472
5473 @item inline-all-stringops
5474 @itemx no-inline-all-stringops
5475 @cindex @code{target("inline-all-stringops")} function attribute, x86
5476 Enable/disable inlining of string operations.
5477
5478 @item inline-stringops-dynamically
5479 @itemx no-inline-stringops-dynamically
5480 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5481 Enable/disable the generation of the inline code to do small string
5482 operations and calling the library routines for large operations.
5483
5484 @item align-stringops
5485 @itemx no-align-stringops
5486 @cindex @code{target("align-stringops")} function attribute, x86
5487 Do/do not align destination of inlined string operations.
5488
5489 @item recip
5490 @itemx no-recip
5491 @cindex @code{target("recip")} function attribute, x86
5492 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5493 instructions followed an additional Newton-Raphson step instead of
5494 doing a floating-point division.
5495
5496 @item arch=@var{ARCH}
5497 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5498 Specify the architecture to generate code for in compiling the function.
5499
5500 @item tune=@var{TUNE}
5501 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5502 Specify the architecture to tune for in compiling the function.
5503
5504 @item fpmath=@var{FPMATH}
5505 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5506 Specify which floating-point unit to use. You must specify the
5507 @code{target("fpmath=sse,387")} option as
5508 @code{target("fpmath=sse+387")} because the comma would separate
5509 different options.
5510 @end table
5511
5512 On the x86, the inliner does not inline a
5513 function that has different target options than the caller, unless the
5514 callee has a subset of the target options of the caller. For example
5515 a function declared with @code{target("sse3")} can inline a function
5516 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5517 @end table
5518
5519 @node Xstormy16 Function Attributes
5520 @subsection Xstormy16 Function Attributes
5521
5522 These function attributes are supported by the Xstormy16 back end:
5523
5524 @table @code
5525 @item interrupt
5526 @cindex @code{interrupt} function attribute, Xstormy16
5527 Use this attribute to indicate
5528 that the specified function is an interrupt handler. The compiler generates
5529 function entry and exit sequences suitable for use in an interrupt handler
5530 when this attribute is present.
5531 @end table
5532
5533 @node Variable Attributes
5534 @section Specifying Attributes of Variables
5535 @cindex attribute of variables
5536 @cindex variable attributes
5537
5538 The keyword @code{__attribute__} allows you to specify special
5539 attributes of variables or structure fields. This keyword is followed
5540 by an attribute specification inside double parentheses. Some
5541 attributes are currently defined generically for variables.
5542 Other attributes are defined for variables on particular target
5543 systems. Other attributes are available for functions
5544 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5545 enumerators (@pxref{Enumerator Attributes}), and for types
5546 (@pxref{Type Attributes}).
5547 Other front ends might define more attributes
5548 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5549
5550 @xref{Attribute Syntax}, for details of the exact syntax for using
5551 attributes.
5552
5553 @menu
5554 * Common Variable Attributes::
5555 * AVR Variable Attributes::
5556 * Blackfin Variable Attributes::
5557 * H8/300 Variable Attributes::
5558 * IA-64 Variable Attributes::
5559 * M32R/D Variable Attributes::
5560 * MeP Variable Attributes::
5561 * Microsoft Windows Variable Attributes::
5562 * MSP430 Variable Attributes::
5563 * PowerPC Variable Attributes::
5564 * RL78 Variable Attributes::
5565 * SPU Variable Attributes::
5566 * V850 Variable Attributes::
5567 * x86 Variable Attributes::
5568 * Xstormy16 Variable Attributes::
5569 @end menu
5570
5571 @node Common Variable Attributes
5572 @subsection Common Variable Attributes
5573
5574 The following attributes are supported on most targets.
5575
5576 @table @code
5577 @cindex @code{aligned} variable attribute
5578 @item aligned (@var{alignment})
5579 This attribute specifies a minimum alignment for the variable or
5580 structure field, measured in bytes. For example, the declaration:
5581
5582 @smallexample
5583 int x __attribute__ ((aligned (16))) = 0;
5584 @end smallexample
5585
5586 @noindent
5587 causes the compiler to allocate the global variable @code{x} on a
5588 16-byte boundary. On a 68040, this could be used in conjunction with
5589 an @code{asm} expression to access the @code{move16} instruction which
5590 requires 16-byte aligned operands.
5591
5592 You can also specify the alignment of structure fields. For example, to
5593 create a double-word aligned @code{int} pair, you could write:
5594
5595 @smallexample
5596 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5597 @end smallexample
5598
5599 @noindent
5600 This is an alternative to creating a union with a @code{double} member,
5601 which forces the union to be double-word aligned.
5602
5603 As in the preceding examples, you can explicitly specify the alignment
5604 (in bytes) that you wish the compiler to use for a given variable or
5605 structure field. Alternatively, you can leave out the alignment factor
5606 and just ask the compiler to align a variable or field to the
5607 default alignment for the target architecture you are compiling for.
5608 The default alignment is sufficient for all scalar types, but may not be
5609 enough for all vector types on a target that supports vector operations.
5610 The default alignment is fixed for a particular target ABI.
5611
5612 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5613 which is the largest alignment ever used for any data type on the
5614 target machine you are compiling for. For example, you could write:
5615
5616 @smallexample
5617 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5618 @end smallexample
5619
5620 The compiler automatically sets the alignment for the declared
5621 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5622 often make copy operations more efficient, because the compiler can
5623 use whatever instructions copy the biggest chunks of memory when
5624 performing copies to or from the variables or fields that you have
5625 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5626 may change depending on command-line options.
5627
5628 When used on a struct, or struct member, the @code{aligned} attribute can
5629 only increase the alignment; in order to decrease it, the @code{packed}
5630 attribute must be specified as well. When used as part of a typedef, the
5631 @code{aligned} attribute can both increase and decrease alignment, and
5632 specifying the @code{packed} attribute generates a warning.
5633
5634 Note that the effectiveness of @code{aligned} attributes may be limited
5635 by inherent limitations in your linker. On many systems, the linker is
5636 only able to arrange for variables to be aligned up to a certain maximum
5637 alignment. (For some linkers, the maximum supported alignment may
5638 be very very small.) If your linker is only able to align variables
5639 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5640 in an @code{__attribute__} still only provides you with 8-byte
5641 alignment. See your linker documentation for further information.
5642
5643 The @code{aligned} attribute can also be used for functions
5644 (@pxref{Common Function Attributes}.)
5645
5646 @item cleanup (@var{cleanup_function})
5647 @cindex @code{cleanup} variable attribute
5648 The @code{cleanup} attribute runs a function when the variable goes
5649 out of scope. This attribute can only be applied to auto function
5650 scope variables; it may not be applied to parameters or variables
5651 with static storage duration. The function must take one parameter,
5652 a pointer to a type compatible with the variable. The return value
5653 of the function (if any) is ignored.
5654
5655 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5656 is run during the stack unwinding that happens during the
5657 processing of the exception. Note that the @code{cleanup} attribute
5658 does not allow the exception to be caught, only to perform an action.
5659 It is undefined what happens if @var{cleanup_function} does not
5660 return normally.
5661
5662 @item common
5663 @itemx nocommon
5664 @cindex @code{common} variable attribute
5665 @cindex @code{nocommon} variable attribute
5666 @opindex fcommon
5667 @opindex fno-common
5668 The @code{common} attribute requests GCC to place a variable in
5669 ``common'' storage. The @code{nocommon} attribute requests the
5670 opposite---to allocate space for it directly.
5671
5672 These attributes override the default chosen by the
5673 @option{-fno-common} and @option{-fcommon} flags respectively.
5674
5675 @item deprecated
5676 @itemx deprecated (@var{msg})
5677 @cindex @code{deprecated} variable attribute
5678 The @code{deprecated} attribute results in a warning if the variable
5679 is used anywhere in the source file. This is useful when identifying
5680 variables that are expected to be removed in a future version of a
5681 program. The warning also includes the location of the declaration
5682 of the deprecated variable, to enable users to easily find further
5683 information about why the variable is deprecated, or what they should
5684 do instead. Note that the warning only occurs for uses:
5685
5686 @smallexample
5687 extern int old_var __attribute__ ((deprecated));
5688 extern int old_var;
5689 int new_fn () @{ return old_var; @}
5690 @end smallexample
5691
5692 @noindent
5693 results in a warning on line 3 but not line 2. The optional @var{msg}
5694 argument, which must be a string, is printed in the warning if
5695 present.
5696
5697 The @code{deprecated} attribute can also be used for functions and
5698 types (@pxref{Common Function Attributes},
5699 @pxref{Common Type Attributes}).
5700
5701 @item mode (@var{mode})
5702 @cindex @code{mode} variable attribute
5703 This attribute specifies the data type for the declaration---whichever
5704 type corresponds to the mode @var{mode}. This in effect lets you
5705 request an integer or floating-point type according to its width.
5706
5707 You may also specify a mode of @code{byte} or @code{__byte__} to
5708 indicate the mode corresponding to a one-byte integer, @code{word} or
5709 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5710 or @code{__pointer__} for the mode used to represent pointers.
5711
5712 @item packed
5713 @cindex @code{packed} variable attribute
5714 The @code{packed} attribute specifies that a variable or structure field
5715 should have the smallest possible alignment---one byte for a variable,
5716 and one bit for a field, unless you specify a larger value with the
5717 @code{aligned} attribute.
5718
5719 Here is a structure in which the field @code{x} is packed, so that it
5720 immediately follows @code{a}:
5721
5722 @smallexample
5723 struct foo
5724 @{
5725 char a;
5726 int x[2] __attribute__ ((packed));
5727 @};
5728 @end smallexample
5729
5730 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5731 @code{packed} attribute on bit-fields of type @code{char}. This has
5732 been fixed in GCC 4.4 but the change can lead to differences in the
5733 structure layout. See the documentation of
5734 @option{-Wpacked-bitfield-compat} for more information.
5735
5736 @item section ("@var{section-name}")
5737 @cindex @code{section} variable attribute
5738 Normally, the compiler places the objects it generates in sections like
5739 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5740 or you need certain particular variables to appear in special sections,
5741 for example to map to special hardware. The @code{section}
5742 attribute specifies that a variable (or function) lives in a particular
5743 section. For example, this small program uses several specific section names:
5744
5745 @smallexample
5746 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5747 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5748 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5749 int init_data __attribute__ ((section ("INITDATA")));
5750
5751 main()
5752 @{
5753 /* @r{Initialize stack pointer} */
5754 init_sp (stack + sizeof (stack));
5755
5756 /* @r{Initialize initialized data} */
5757 memcpy (&init_data, &data, &edata - &data);
5758
5759 /* @r{Turn on the serial ports} */
5760 init_duart (&a);
5761 init_duart (&b);
5762 @}
5763 @end smallexample
5764
5765 @noindent
5766 Use the @code{section} attribute with
5767 @emph{global} variables and not @emph{local} variables,
5768 as shown in the example.
5769
5770 You may use the @code{section} attribute with initialized or
5771 uninitialized global variables but the linker requires
5772 each object be defined once, with the exception that uninitialized
5773 variables tentatively go in the @code{common} (or @code{bss}) section
5774 and can be multiply ``defined''. Using the @code{section} attribute
5775 changes what section the variable goes into and may cause the
5776 linker to issue an error if an uninitialized variable has multiple
5777 definitions. You can force a variable to be initialized with the
5778 @option{-fno-common} flag or the @code{nocommon} attribute.
5779
5780 Some file formats do not support arbitrary sections so the @code{section}
5781 attribute is not available on all platforms.
5782 If you need to map the entire contents of a module to a particular
5783 section, consider using the facilities of the linker instead.
5784
5785 @item tls_model ("@var{tls_model}")
5786 @cindex @code{tls_model} variable attribute
5787 The @code{tls_model} attribute sets thread-local storage model
5788 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5789 overriding @option{-ftls-model=} command-line switch on a per-variable
5790 basis.
5791 The @var{tls_model} argument should be one of @code{global-dynamic},
5792 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5793
5794 Not all targets support this attribute.
5795
5796 @item unused
5797 @cindex @code{unused} variable attribute
5798 This attribute, attached to a variable, means that the variable is meant
5799 to be possibly unused. GCC does not produce a warning for this
5800 variable.
5801
5802 @item used
5803 @cindex @code{used} variable attribute
5804 This attribute, attached to a variable with static storage, means that
5805 the variable must be emitted even if it appears that the variable is not
5806 referenced.
5807
5808 When applied to a static data member of a C++ class template, the
5809 attribute also means that the member is instantiated if the
5810 class itself is instantiated.
5811
5812 @item vector_size (@var{bytes})
5813 @cindex @code{vector_size} variable attribute
5814 This attribute specifies the vector size for the variable, measured in
5815 bytes. For example, the declaration:
5816
5817 @smallexample
5818 int foo __attribute__ ((vector_size (16)));
5819 @end smallexample
5820
5821 @noindent
5822 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5823 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5824 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5825
5826 This attribute is only applicable to integral and float scalars,
5827 although arrays, pointers, and function return values are allowed in
5828 conjunction with this construct.
5829
5830 Aggregates with this attribute are invalid, even if they are of the same
5831 size as a corresponding scalar. For example, the declaration:
5832
5833 @smallexample
5834 struct S @{ int a; @};
5835 struct S __attribute__ ((vector_size (16))) foo;
5836 @end smallexample
5837
5838 @noindent
5839 is invalid even if the size of the structure is the same as the size of
5840 the @code{int}.
5841
5842 @item visibility ("@var{visibility_type}")
5843 @cindex @code{visibility} variable attribute
5844 This attribute affects the linkage of the declaration to which it is attached.
5845 The @code{visibility} attribute is described in
5846 @ref{Common Function Attributes}.
5847
5848 @item weak
5849 @cindex @code{weak} variable attribute
5850 The @code{weak} attribute is described in
5851 @ref{Common Function Attributes}.
5852
5853 @end table
5854
5855 @node AVR Variable Attributes
5856 @subsection AVR Variable Attributes
5857
5858 @table @code
5859 @item progmem
5860 @cindex @code{progmem} variable attribute, AVR
5861 The @code{progmem} attribute is used on the AVR to place read-only
5862 data in the non-volatile program memory (flash). The @code{progmem}
5863 attribute accomplishes this by putting respective variables into a
5864 section whose name starts with @code{.progmem}.
5865
5866 This attribute works similar to the @code{section} attribute
5867 but adds additional checking.
5868
5869 @table @asis
5870 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
5871 @code{progmem} affects the location
5872 of the data but not how this data is accessed.
5873 In order to read data located with the @code{progmem} attribute
5874 (inline) assembler must be used.
5875 @smallexample
5876 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5877 #include <avr/pgmspace.h>
5878
5879 /* Locate var in flash memory */
5880 const int var[2] PROGMEM = @{ 1, 2 @};
5881
5882 int read_var (int i)
5883 @{
5884 /* Access var[] by accessor macro from avr/pgmspace.h */
5885 return (int) pgm_read_word (& var[i]);
5886 @}
5887 @end smallexample
5888
5889 AVR is a Harvard architecture processor and data and read-only data
5890 normally resides in the data memory (RAM).
5891
5892 See also the @ref{AVR Named Address Spaces} section for
5893 an alternate way to locate and access data in flash memory.
5894
5895 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
5896 The compiler adds @code{0x4000}
5897 to the addresses of objects and declarations in @code{progmem} and locates
5898 the objects in flash memory, namely in section @code{.progmem.data}.
5899 The offset is needed because the flash memory is visible in the RAM
5900 address space starting at address @code{0x4000}.
5901
5902 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
5903 no special functions or macros are needed.
5904
5905 @smallexample
5906 /* var is located in flash memory */
5907 extern const int var[2] __attribute__((progmem));
5908
5909 int read_var (int i)
5910 @{
5911 return var[i];
5912 @}
5913 @end smallexample
5914
5915 @end table
5916
5917 @item io
5918 @itemx io (@var{addr})
5919 @cindex @code{io} variable attribute, AVR
5920 Variables with the @code{io} attribute are used to address
5921 memory-mapped peripherals in the io address range.
5922 If an address is specified, the variable
5923 is assigned that address, and the value is interpreted as an
5924 address in the data address space.
5925 Example:
5926
5927 @smallexample
5928 volatile int porta __attribute__((io (0x22)));
5929 @end smallexample
5930
5931 The address specified in the address in the data address range.
5932
5933 Otherwise, the variable it is not assigned an address, but the
5934 compiler will still use in/out instructions where applicable,
5935 assuming some other module assigns an address in the io address range.
5936 Example:
5937
5938 @smallexample
5939 extern volatile int porta __attribute__((io));
5940 @end smallexample
5941
5942 @item io_low
5943 @itemx io_low (@var{addr})
5944 @cindex @code{io_low} variable attribute, AVR
5945 This is like the @code{io} attribute, but additionally it informs the
5946 compiler that the object lies in the lower half of the I/O area,
5947 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5948 instructions.
5949
5950 @item address
5951 @itemx address (@var{addr})
5952 @cindex @code{address} variable attribute, AVR
5953 Variables with the @code{address} attribute are used to address
5954 memory-mapped peripherals that may lie outside the io address range.
5955
5956 @smallexample
5957 volatile int porta __attribute__((address (0x600)));
5958 @end smallexample
5959
5960 @end table
5961
5962 @node Blackfin Variable Attributes
5963 @subsection Blackfin Variable Attributes
5964
5965 Three attributes are currently defined for the Blackfin.
5966
5967 @table @code
5968 @item l1_data
5969 @itemx l1_data_A
5970 @itemx l1_data_B
5971 @cindex @code{l1_data} variable attribute, Blackfin
5972 @cindex @code{l1_data_A} variable attribute, Blackfin
5973 @cindex @code{l1_data_B} variable attribute, Blackfin
5974 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5975 Variables with @code{l1_data} attribute are put into the specific section
5976 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5977 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5978 attribute are put into the specific section named @code{.l1.data.B}.
5979
5980 @item l2
5981 @cindex @code{l2} variable attribute, Blackfin
5982 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5983 Variables with @code{l2} attribute are put into the specific section
5984 named @code{.l2.data}.
5985 @end table
5986
5987 @node H8/300 Variable Attributes
5988 @subsection H8/300 Variable Attributes
5989
5990 These variable attributes are available for H8/300 targets:
5991
5992 @table @code
5993 @item eightbit_data
5994 @cindex @code{eightbit_data} variable attribute, H8/300
5995 @cindex eight-bit data on the H8/300, H8/300H, and H8S
5996 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
5997 variable should be placed into the eight-bit data section.
5998 The compiler generates more efficient code for certain operations
5999 on data in the eight-bit data area. Note the eight-bit data area is limited to
6000 256 bytes of data.
6001
6002 You must use GAS and GLD from GNU binutils version 2.7 or later for
6003 this attribute to work correctly.
6004
6005 @item tiny_data
6006 @cindex @code{tiny_data} variable attribute, H8/300
6007 @cindex tiny data section on the H8/300H and H8S
6008 Use this attribute on the H8/300H and H8S to indicate that the specified
6009 variable should be placed into the tiny data section.
6010 The compiler generates more efficient code for loads and stores
6011 on data in the tiny data section. Note the tiny data area is limited to
6012 slightly under 32KB of data.
6013
6014 @end table
6015
6016 @node IA-64 Variable Attributes
6017 @subsection IA-64 Variable Attributes
6018
6019 The IA-64 back end supports the following variable attribute:
6020
6021 @table @code
6022 @item model (@var{model-name})
6023 @cindex @code{model} variable attribute, IA-64
6024
6025 On IA-64, use this attribute to set the addressability of an object.
6026 At present, the only supported identifier for @var{model-name} is
6027 @code{small}, indicating addressability via ``small'' (22-bit)
6028 addresses (so that their addresses can be loaded with the @code{addl}
6029 instruction). Caveat: such addressing is by definition not position
6030 independent and hence this attribute must not be used for objects
6031 defined by shared libraries.
6032
6033 @end table
6034
6035 @node M32R/D Variable Attributes
6036 @subsection M32R/D Variable Attributes
6037
6038 One attribute is currently defined for the M32R/D@.
6039
6040 @table @code
6041 @item model (@var{model-name})
6042 @cindex @code{model-name} variable attribute, M32R/D
6043 @cindex variable addressability on the M32R/D
6044 Use this attribute on the M32R/D to set the addressability of an object.
6045 The identifier @var{model-name} is one of @code{small}, @code{medium},
6046 or @code{large}, representing each of the code models.
6047
6048 Small model objects live in the lower 16MB of memory (so that their
6049 addresses can be loaded with the @code{ld24} instruction).
6050
6051 Medium and large model objects may live anywhere in the 32-bit address space
6052 (the compiler generates @code{seth/add3} instructions to load their
6053 addresses).
6054 @end table
6055
6056 @node MeP Variable Attributes
6057 @subsection MeP Variable Attributes
6058
6059 The MeP target has a number of addressing modes and busses. The
6060 @code{near} space spans the standard memory space's first 16 megabytes
6061 (24 bits). The @code{far} space spans the entire 32-bit memory space.
6062 The @code{based} space is a 128-byte region in the memory space that
6063 is addressed relative to the @code{$tp} register. The @code{tiny}
6064 space is a 65536-byte region relative to the @code{$gp} register. In
6065 addition to these memory regions, the MeP target has a separate 16-bit
6066 control bus which is specified with @code{cb} attributes.
6067
6068 @table @code
6069
6070 @item based
6071 @cindex @code{based} variable attribute, MeP
6072 Any variable with the @code{based} attribute is assigned to the
6073 @code{.based} section, and is accessed with relative to the
6074 @code{$tp} register.
6075
6076 @item tiny
6077 @cindex @code{tiny} variable attribute, MeP
6078 Likewise, the @code{tiny} attribute assigned variables to the
6079 @code{.tiny} section, relative to the @code{$gp} register.
6080
6081 @item near
6082 @cindex @code{near} variable attribute, MeP
6083 Variables with the @code{near} attribute are assumed to have addresses
6084 that fit in a 24-bit addressing mode. This is the default for large
6085 variables (@code{-mtiny=4} is the default) but this attribute can
6086 override @code{-mtiny=} for small variables, or override @code{-ml}.
6087
6088 @item far
6089 @cindex @code{far} variable attribute, MeP
6090 Variables with the @code{far} attribute are addressed using a full
6091 32-bit address. Since this covers the entire memory space, this
6092 allows modules to make no assumptions about where variables might be
6093 stored.
6094
6095 @item io
6096 @cindex @code{io} variable attribute, MeP
6097 @itemx io (@var{addr})
6098 Variables with the @code{io} attribute are used to address
6099 memory-mapped peripherals. If an address is specified, the variable
6100 is assigned that address, else it is not assigned an address (it is
6101 assumed some other module assigns an address). Example:
6102
6103 @smallexample
6104 int timer_count __attribute__((io(0x123)));
6105 @end smallexample
6106
6107 @item cb
6108 @itemx cb (@var{addr})
6109 @cindex @code{cb} variable attribute, MeP
6110 Variables with the @code{cb} attribute are used to access the control
6111 bus, using special instructions. @code{addr} indicates the control bus
6112 address. Example:
6113
6114 @smallexample
6115 int cpu_clock __attribute__((cb(0x123)));
6116 @end smallexample
6117
6118 @end table
6119
6120 @node Microsoft Windows Variable Attributes
6121 @subsection Microsoft Windows Variable Attributes
6122
6123 You can use these attributes on Microsoft Windows targets.
6124 @ref{x86 Variable Attributes} for additional Windows compatibility
6125 attributes available on all x86 targets.
6126
6127 @table @code
6128 @item dllimport
6129 @itemx dllexport
6130 @cindex @code{dllimport} variable attribute
6131 @cindex @code{dllexport} variable attribute
6132 The @code{dllimport} and @code{dllexport} attributes are described in
6133 @ref{Microsoft Windows Function Attributes}.
6134
6135 @item selectany
6136 @cindex @code{selectany} variable attribute
6137 The @code{selectany} attribute causes an initialized global variable to
6138 have link-once semantics. When multiple definitions of the variable are
6139 encountered by the linker, the first is selected and the remainder are
6140 discarded. Following usage by the Microsoft compiler, the linker is told
6141 @emph{not} to warn about size or content differences of the multiple
6142 definitions.
6143
6144 Although the primary usage of this attribute is for POD types, the
6145 attribute can also be applied to global C++ objects that are initialized
6146 by a constructor. In this case, the static initialization and destruction
6147 code for the object is emitted in each translation defining the object,
6148 but the calls to the constructor and destructor are protected by a
6149 link-once guard variable.
6150
6151 The @code{selectany} attribute is only available on Microsoft Windows
6152 targets. You can use @code{__declspec (selectany)} as a synonym for
6153 @code{__attribute__ ((selectany))} for compatibility with other
6154 compilers.
6155
6156 @item shared
6157 @cindex @code{shared} variable attribute
6158 On Microsoft Windows, in addition to putting variable definitions in a named
6159 section, the section can also be shared among all running copies of an
6160 executable or DLL@. For example, this small program defines shared data
6161 by putting it in a named section @code{shared} and marking the section
6162 shareable:
6163
6164 @smallexample
6165 int foo __attribute__((section ("shared"), shared)) = 0;
6166
6167 int
6168 main()
6169 @{
6170 /* @r{Read and write foo. All running
6171 copies see the same value.} */
6172 return 0;
6173 @}
6174 @end smallexample
6175
6176 @noindent
6177 You may only use the @code{shared} attribute along with @code{section}
6178 attribute with a fully-initialized global definition because of the way
6179 linkers work. See @code{section} attribute for more information.
6180
6181 The @code{shared} attribute is only available on Microsoft Windows@.
6182
6183 @end table
6184
6185 @node MSP430 Variable Attributes
6186 @subsection MSP430 Variable Attributes
6187
6188 @table @code
6189 @item noinit
6190 @cindex @code{noinit} variable attribute, MSP430
6191 Any data with the @code{noinit} attribute will not be initialised by
6192 the C runtime startup code, or the program loader. Not initialising
6193 data in this way can reduce program startup times.
6194
6195 @item persistent
6196 @cindex @code{persistent} variable attribute, MSP430
6197 Any variable with the @code{persistent} attribute will not be
6198 initialised by the C runtime startup code. Instead its value will be
6199 set once, when the application is loaded, and then never initialised
6200 again, even if the processor is reset or the program restarts.
6201 Persistent data is intended to be placed into FLASH RAM, where its
6202 value will be retained across resets. The linker script being used to
6203 create the application should ensure that persistent data is correctly
6204 placed.
6205
6206 @item lower
6207 @itemx upper
6208 @itemx either
6209 @cindex @code{lower} variable attribute, MSP430
6210 @cindex @code{upper} variable attribute, MSP430
6211 @cindex @code{either} variable attribute, MSP430
6212 These attributes are the same as the MSP430 function attributes of the
6213 same name (@pxref{MSP430 Function Attributes}).
6214 These attributes can be applied to both functions and variables.
6215 @end table
6216
6217 @node PowerPC Variable Attributes
6218 @subsection PowerPC Variable Attributes
6219
6220 Three attributes currently are defined for PowerPC configurations:
6221 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6222
6223 @cindex @code{ms_struct} variable attribute, PowerPC
6224 @cindex @code{gcc_struct} variable attribute, PowerPC
6225 For full documentation of the struct attributes please see the
6226 documentation in @ref{x86 Variable Attributes}.
6227
6228 @cindex @code{altivec} variable attribute, PowerPC
6229 For documentation of @code{altivec} attribute please see the
6230 documentation in @ref{PowerPC Type Attributes}.
6231
6232 @node RL78 Variable Attributes
6233 @subsection RL78 Variable Attributes
6234
6235 @cindex @code{saddr} variable attribute, RL78
6236 The RL78 back end supports the @code{saddr} variable attribute. This
6237 specifies placement of the corresponding variable in the SADDR area,
6238 which can be accessed more efficiently than the default memory region.
6239
6240 @node SPU Variable Attributes
6241 @subsection SPU Variable Attributes
6242
6243 @cindex @code{spu_vector} variable attribute, SPU
6244 The SPU supports the @code{spu_vector} attribute for variables. For
6245 documentation of this attribute please see the documentation in
6246 @ref{SPU Type Attributes}.
6247
6248 @node V850 Variable Attributes
6249 @subsection V850 Variable Attributes
6250
6251 These variable attributes are supported by the V850 back end:
6252
6253 @table @code
6254
6255 @item sda
6256 @cindex @code{sda} variable attribute, V850
6257 Use this attribute to explicitly place a variable in the small data area,
6258 which can hold up to 64 kilobytes.
6259
6260 @item tda
6261 @cindex @code{tda} variable attribute, V850
6262 Use this attribute to explicitly place a variable in the tiny data area,
6263 which can hold up to 256 bytes in total.
6264
6265 @item zda
6266 @cindex @code{zda} variable attribute, V850
6267 Use this attribute to explicitly place a variable in the first 32 kilobytes
6268 of memory.
6269 @end table
6270
6271 @node x86 Variable Attributes
6272 @subsection x86 Variable Attributes
6273
6274 Two attributes are currently defined for x86 configurations:
6275 @code{ms_struct} and @code{gcc_struct}.
6276
6277 @table @code
6278 @item ms_struct
6279 @itemx gcc_struct
6280 @cindex @code{ms_struct} variable attribute, x86
6281 @cindex @code{gcc_struct} variable attribute, x86
6282
6283 If @code{packed} is used on a structure, or if bit-fields are used,
6284 it may be that the Microsoft ABI lays out the structure differently
6285 than the way GCC normally does. Particularly when moving packed
6286 data between functions compiled with GCC and the native Microsoft compiler
6287 (either via function call or as data in a file), it may be necessary to access
6288 either format.
6289
6290 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6291 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6292 command-line options, respectively;
6293 see @ref{x86 Options}, for details of how structure layout is affected.
6294 @xref{x86 Type Attributes}, for information about the corresponding
6295 attributes on types.
6296
6297 @end table
6298
6299 @node Xstormy16 Variable Attributes
6300 @subsection Xstormy16 Variable Attributes
6301
6302 One attribute is currently defined for xstormy16 configurations:
6303 @code{below100}.
6304
6305 @table @code
6306 @item below100
6307 @cindex @code{below100} variable attribute, Xstormy16
6308
6309 If a variable has the @code{below100} attribute (@code{BELOW100} is
6310 allowed also), GCC places the variable in the first 0x100 bytes of
6311 memory and use special opcodes to access it. Such variables are
6312 placed in either the @code{.bss_below100} section or the
6313 @code{.data_below100} section.
6314
6315 @end table
6316
6317 @node Type Attributes
6318 @section Specifying Attributes of Types
6319 @cindex attribute of types
6320 @cindex type attributes
6321
6322 The keyword @code{__attribute__} allows you to specify special
6323 attributes of types. Some type attributes apply only to @code{struct}
6324 and @code{union} types, while others can apply to any type defined
6325 via a @code{typedef} declaration. Other attributes are defined for
6326 functions (@pxref{Function Attributes}), labels (@pxref{Label
6327 Attributes}), enumerators (@pxref{Enumerator Attributes}), and for
6328 variables (@pxref{Variable Attributes}).
6329
6330 The @code{__attribute__} keyword is followed by an attribute specification
6331 inside double parentheses.
6332
6333 You may specify type attributes in an enum, struct or union type
6334 declaration or definition by placing them immediately after the
6335 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6336 syntax is to place them just past the closing curly brace of the
6337 definition.
6338
6339 You can also include type attributes in a @code{typedef} declaration.
6340 @xref{Attribute Syntax}, for details of the exact syntax for using
6341 attributes.
6342
6343 @menu
6344 * Common Type Attributes::
6345 * ARM Type Attributes::
6346 * MeP Type Attributes::
6347 * PowerPC Type Attributes::
6348 * SPU Type Attributes::
6349 * x86 Type Attributes::
6350 @end menu
6351
6352 @node Common Type Attributes
6353 @subsection Common Type Attributes
6354
6355 The following type attributes are supported on most targets.
6356
6357 @table @code
6358 @cindex @code{aligned} type attribute
6359 @item aligned (@var{alignment})
6360 This attribute specifies a minimum alignment (in bytes) for variables
6361 of the specified type. For example, the declarations:
6362
6363 @smallexample
6364 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6365 typedef int more_aligned_int __attribute__ ((aligned (8)));
6366 @end smallexample
6367
6368 @noindent
6369 force the compiler to ensure (as far as it can) that each variable whose
6370 type is @code{struct S} or @code{more_aligned_int} is allocated and
6371 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6372 variables of type @code{struct S} aligned to 8-byte boundaries allows
6373 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6374 store) instructions when copying one variable of type @code{struct S} to
6375 another, thus improving run-time efficiency.
6376
6377 Note that the alignment of any given @code{struct} or @code{union} type
6378 is required by the ISO C standard to be at least a perfect multiple of
6379 the lowest common multiple of the alignments of all of the members of
6380 the @code{struct} or @code{union} in question. This means that you @emph{can}
6381 effectively adjust the alignment of a @code{struct} or @code{union}
6382 type by attaching an @code{aligned} attribute to any one of the members
6383 of such a type, but the notation illustrated in the example above is a
6384 more obvious, intuitive, and readable way to request the compiler to
6385 adjust the alignment of an entire @code{struct} or @code{union} type.
6386
6387 As in the preceding example, you can explicitly specify the alignment
6388 (in bytes) that you wish the compiler to use for a given @code{struct}
6389 or @code{union} type. Alternatively, you can leave out the alignment factor
6390 and just ask the compiler to align a type to the maximum
6391 useful alignment for the target machine you are compiling for. For
6392 example, you could write:
6393
6394 @smallexample
6395 struct S @{ short f[3]; @} __attribute__ ((aligned));
6396 @end smallexample
6397
6398 Whenever you leave out the alignment factor in an @code{aligned}
6399 attribute specification, the compiler automatically sets the alignment
6400 for the type to the largest alignment that is ever used for any data
6401 type on the target machine you are compiling for. Doing this can often
6402 make copy operations more efficient, because the compiler can use
6403 whatever instructions copy the biggest chunks of memory when performing
6404 copies to or from the variables that have types that you have aligned
6405 this way.
6406
6407 In the example above, if the size of each @code{short} is 2 bytes, then
6408 the size of the entire @code{struct S} type is 6 bytes. The smallest
6409 power of two that is greater than or equal to that is 8, so the
6410 compiler sets the alignment for the entire @code{struct S} type to 8
6411 bytes.
6412
6413 Note that although you can ask the compiler to select a time-efficient
6414 alignment for a given type and then declare only individual stand-alone
6415 objects of that type, the compiler's ability to select a time-efficient
6416 alignment is primarily useful only when you plan to create arrays of
6417 variables having the relevant (efficiently aligned) type. If you
6418 declare or use arrays of variables of an efficiently-aligned type, then
6419 it is likely that your program also does pointer arithmetic (or
6420 subscripting, which amounts to the same thing) on pointers to the
6421 relevant type, and the code that the compiler generates for these
6422 pointer arithmetic operations is often more efficient for
6423 efficiently-aligned types than for other types.
6424
6425 Note that the effectiveness of @code{aligned} attributes may be limited
6426 by inherent limitations in your linker. On many systems, the linker is
6427 only able to arrange for variables to be aligned up to a certain maximum
6428 alignment. (For some linkers, the maximum supported alignment may
6429 be very very small.) If your linker is only able to align variables
6430 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6431 in an @code{__attribute__} still only provides you with 8-byte
6432 alignment. See your linker documentation for further information.
6433
6434 The @code{aligned} attribute can only increase alignment. Alignment
6435 can be decreased by specifying the @code{packed} attribute. See below.
6436
6437 @item bnd_variable_size
6438 @cindex @code{bnd_variable_size} type attribute
6439 @cindex Pointer Bounds Checker attributes
6440 When applied to a structure field, this attribute tells Pointer
6441 Bounds Checker that the size of this field should not be computed
6442 using static type information. It may be used to mark variably-sized
6443 static array fields placed at the end of a structure.
6444
6445 @smallexample
6446 struct S
6447 @{
6448 int size;
6449 char data[1];
6450 @}
6451 S *p = (S *)malloc (sizeof(S) + 100);
6452 p->data[10] = 0; //Bounds violation
6453 @end smallexample
6454
6455 @noindent
6456 By using an attribute for the field we may avoid unwanted bound
6457 violation checks:
6458
6459 @smallexample
6460 struct S
6461 @{
6462 int size;
6463 char data[1] __attribute__((bnd_variable_size));
6464 @}
6465 S *p = (S *)malloc (sizeof(S) + 100);
6466 p->data[10] = 0; //OK
6467 @end smallexample
6468
6469 @item deprecated
6470 @itemx deprecated (@var{msg})
6471 @cindex @code{deprecated} type attribute
6472 The @code{deprecated} attribute results in a warning if the type
6473 is used anywhere in the source file. This is useful when identifying
6474 types that are expected to be removed in a future version of a program.
6475 If possible, the warning also includes the location of the declaration
6476 of the deprecated type, to enable users to easily find further
6477 information about why the type is deprecated, or what they should do
6478 instead. Note that the warnings only occur for uses and then only
6479 if the type is being applied to an identifier that itself is not being
6480 declared as deprecated.
6481
6482 @smallexample
6483 typedef int T1 __attribute__ ((deprecated));
6484 T1 x;
6485 typedef T1 T2;
6486 T2 y;
6487 typedef T1 T3 __attribute__ ((deprecated));
6488 T3 z __attribute__ ((deprecated));
6489 @end smallexample
6490
6491 @noindent
6492 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
6493 warning is issued for line 4 because T2 is not explicitly
6494 deprecated. Line 5 has no warning because T3 is explicitly
6495 deprecated. Similarly for line 6. The optional @var{msg}
6496 argument, which must be a string, is printed in the warning if
6497 present.
6498
6499 The @code{deprecated} attribute can also be used for functions and
6500 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6501
6502 @item designated_init
6503 @cindex @code{designated_init} type attribute
6504 This attribute may only be applied to structure types. It indicates
6505 that any initialization of an object of this type must use designated
6506 initializers rather than positional initializers. The intent of this
6507 attribute is to allow the programmer to indicate that a structure's
6508 layout may change, and that therefore relying on positional
6509 initialization will result in future breakage.
6510
6511 GCC emits warnings based on this attribute by default; use
6512 @option{-Wno-designated-init} to suppress them.
6513
6514 @item may_alias
6515 @cindex @code{may_alias} type attribute
6516 Accesses through pointers to types with this attribute are not subject
6517 to type-based alias analysis, but are instead assumed to be able to alias
6518 any other type of objects.
6519 In the context of section 6.5 paragraph 7 of the C99 standard,
6520 an lvalue expression
6521 dereferencing such a pointer is treated like having a character type.
6522 See @option{-fstrict-aliasing} for more information on aliasing issues.
6523 This extension exists to support some vector APIs, in which pointers to
6524 one vector type are permitted to alias pointers to a different vector type.
6525
6526 Note that an object of a type with this attribute does not have any
6527 special semantics.
6528
6529 Example of use:
6530
6531 @smallexample
6532 typedef short __attribute__((__may_alias__)) short_a;
6533
6534 int
6535 main (void)
6536 @{
6537 int a = 0x12345678;
6538 short_a *b = (short_a *) &a;
6539
6540 b[1] = 0;
6541
6542 if (a == 0x12345678)
6543 abort();
6544
6545 exit(0);
6546 @}
6547 @end smallexample
6548
6549 @noindent
6550 If you replaced @code{short_a} with @code{short} in the variable
6551 declaration, the above program would abort when compiled with
6552 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6553 above.
6554
6555 @item packed
6556 @cindex @code{packed} type attribute
6557 This attribute, attached to @code{struct} or @code{union} type
6558 definition, specifies that each member (other than zero-width bit-fields)
6559 of the structure or union is placed to minimize the memory required. When
6560 attached to an @code{enum} definition, it indicates that the smallest
6561 integral type should be used.
6562
6563 @opindex fshort-enums
6564 Specifying the @code{packed} attribute for @code{struct} and @code{union}
6565 types is equivalent to specifying the @code{packed} attribute on each
6566 of the structure or union members. Specifying the @option{-fshort-enums}
6567 flag on the command line is equivalent to specifying the @code{packed}
6568 attribute on all @code{enum} definitions.
6569
6570 In the following example @code{struct my_packed_struct}'s members are
6571 packed closely together, but the internal layout of its @code{s} member
6572 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6573 be packed too.
6574
6575 @smallexample
6576 struct my_unpacked_struct
6577 @{
6578 char c;
6579 int i;
6580 @};
6581
6582 struct __attribute__ ((__packed__)) my_packed_struct
6583 @{
6584 char c;
6585 int i;
6586 struct my_unpacked_struct s;
6587 @};
6588 @end smallexample
6589
6590 You may only specify the @code{packed} attribute attribute on the definition
6591 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
6592 that does not also define the enumerated type, structure or union.
6593
6594 @item scalar_storage_order ("@var{endianness}")
6595 @cindex @code{scalar_storage_order} type attribute
6596 When attached to a @code{union} or a @code{struct}, this attribute sets
6597 the storage order, aka endianness, of the scalar fields of the type, as
6598 well as the array fields whose component is scalar. The supported
6599 endiannesses are @code{big-endian} and @code{little-endian}. The attribute
6600 has no effects on fields which are themselves a @code{union}, a @code{struct}
6601 or an array whose component is a @code{union} or a @code{struct}, and it is
6602 possible for these fields to have a different scalar storage order than the
6603 enclosing type.
6604
6605 This attribute is supported only for targets that use a uniform default
6606 scalar storage order (fortunately, most of them), i.e. targets that store
6607 the scalars either all in big-endian or all in little-endian.
6608
6609 Additional restrictions are enforced for types with the reverse scalar
6610 storage order with regard to the scalar storage order of the target:
6611
6612 @itemize
6613 @item Taking the address of a scalar field of a @code{union} or a
6614 @code{struct} with reverse scalar storage order is not permitted and yields
6615 an error.
6616 @item Taking the address of an array field, whose component is scalar, of
6617 a @code{union} or a @code{struct} with reverse scalar storage order is
6618 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
6619 is specified.
6620 @item Taking the address of a @code{union} or a @code{struct} with reverse
6621 scalar storage order is permitted.
6622 @end itemize
6623
6624 These restrictions exist because the storage order attribute is lost when
6625 the address of a scalar or the address of an array with scalar component is
6626 taken, so storing indirectly through this address generally does not work.
6627 The second case is nevertheless allowed to be able to perform a block copy
6628 from or to the array.
6629
6630 Moreover, the use of type punning or aliasing to toggle the storage order
6631 is not supported; that is to say, a given scalar object cannot be accessed
6632 through distinct types that assign a different storage order to it.
6633
6634 @item transparent_union
6635 @cindex @code{transparent_union} type attribute
6636
6637 This attribute, attached to a @code{union} type definition, indicates
6638 that any function parameter having that union type causes calls to that
6639 function to be treated in a special way.
6640
6641 First, the argument corresponding to a transparent union type can be of
6642 any type in the union; no cast is required. Also, if the union contains
6643 a pointer type, the corresponding argument can be a null pointer
6644 constant or a void pointer expression; and if the union contains a void
6645 pointer type, the corresponding argument can be any pointer expression.
6646 If the union member type is a pointer, qualifiers like @code{const} on
6647 the referenced type must be respected, just as with normal pointer
6648 conversions.
6649
6650 Second, the argument is passed to the function using the calling
6651 conventions of the first member of the transparent union, not the calling
6652 conventions of the union itself. All members of the union must have the
6653 same machine representation; this is necessary for this argument passing
6654 to work properly.
6655
6656 Transparent unions are designed for library functions that have multiple
6657 interfaces for compatibility reasons. For example, suppose the
6658 @code{wait} function must accept either a value of type @code{int *} to
6659 comply with POSIX, or a value of type @code{union wait *} to comply with
6660 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
6661 @code{wait} would accept both kinds of arguments, but it would also
6662 accept any other pointer type and this would make argument type checking
6663 less useful. Instead, @code{<sys/wait.h>} might define the interface
6664 as follows:
6665
6666 @smallexample
6667 typedef union __attribute__ ((__transparent_union__))
6668 @{
6669 int *__ip;
6670 union wait *__up;
6671 @} wait_status_ptr_t;
6672
6673 pid_t wait (wait_status_ptr_t);
6674 @end smallexample
6675
6676 @noindent
6677 This interface allows either @code{int *} or @code{union wait *}
6678 arguments to be passed, using the @code{int *} calling convention.
6679 The program can call @code{wait} with arguments of either type:
6680
6681 @smallexample
6682 int w1 () @{ int w; return wait (&w); @}
6683 int w2 () @{ union wait w; return wait (&w); @}
6684 @end smallexample
6685
6686 @noindent
6687 With this interface, @code{wait}'s implementation might look like this:
6688
6689 @smallexample
6690 pid_t wait (wait_status_ptr_t p)
6691 @{
6692 return waitpid (-1, p.__ip, 0);
6693 @}
6694 @end smallexample
6695
6696 @item unused
6697 @cindex @code{unused} type attribute
6698 When attached to a type (including a @code{union} or a @code{struct}),
6699 this attribute means that variables of that type are meant to appear
6700 possibly unused. GCC does not produce a warning for any variables of
6701 that type, even if the variable appears to do nothing. This is often
6702 the case with lock or thread classes, which are usually defined and then
6703 not referenced, but contain constructors and destructors that have
6704 nontrivial bookkeeping functions.
6705
6706 @item visibility
6707 @cindex @code{visibility} type attribute
6708 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6709 applied to class, struct, union and enum types. Unlike other type
6710 attributes, the attribute must appear between the initial keyword and
6711 the name of the type; it cannot appear after the body of the type.
6712
6713 Note that the type visibility is applied to vague linkage entities
6714 associated with the class (vtable, typeinfo node, etc.). In
6715 particular, if a class is thrown as an exception in one shared object
6716 and caught in another, the class must have default visibility.
6717 Otherwise the two shared objects are unable to use the same
6718 typeinfo node and exception handling will break.
6719
6720 @end table
6721
6722 To specify multiple attributes, separate them by commas within the
6723 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6724 packed))}.
6725
6726 @node ARM Type Attributes
6727 @subsection ARM Type Attributes
6728
6729 @cindex @code{notshared} type attribute, ARM
6730 On those ARM targets that support @code{dllimport} (such as Symbian
6731 OS), you can use the @code{notshared} attribute to indicate that the
6732 virtual table and other similar data for a class should not be
6733 exported from a DLL@. For example:
6734
6735 @smallexample
6736 class __declspec(notshared) C @{
6737 public:
6738 __declspec(dllimport) C();
6739 virtual void f();
6740 @}
6741
6742 __declspec(dllexport)
6743 C::C() @{@}
6744 @end smallexample
6745
6746 @noindent
6747 In this code, @code{C::C} is exported from the current DLL, but the
6748 virtual table for @code{C} is not exported. (You can use
6749 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6750 most Symbian OS code uses @code{__declspec}.)
6751
6752 @node MeP Type Attributes
6753 @subsection MeP Type Attributes
6754
6755 @cindex @code{based} type attribute, MeP
6756 @cindex @code{tiny} type attribute, MeP
6757 @cindex @code{near} type attribute, MeP
6758 @cindex @code{far} type attribute, MeP
6759 Many of the MeP variable attributes may be applied to types as well.
6760 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6761 @code{far} attributes may be applied to either. The @code{io} and
6762 @code{cb} attributes may not be applied to types.
6763
6764 @node PowerPC Type Attributes
6765 @subsection PowerPC Type Attributes
6766
6767 Three attributes currently are defined for PowerPC configurations:
6768 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6769
6770 @cindex @code{ms_struct} type attribute, PowerPC
6771 @cindex @code{gcc_struct} type attribute, PowerPC
6772 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6773 attributes please see the documentation in @ref{x86 Type Attributes}.
6774
6775 @cindex @code{altivec} type attribute, PowerPC
6776 The @code{altivec} attribute allows one to declare AltiVec vector data
6777 types supported by the AltiVec Programming Interface Manual. The
6778 attribute requires an argument to specify one of three vector types:
6779 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6780 and @code{bool__} (always followed by unsigned).
6781
6782 @smallexample
6783 __attribute__((altivec(vector__)))
6784 __attribute__((altivec(pixel__))) unsigned short
6785 __attribute__((altivec(bool__))) unsigned
6786 @end smallexample
6787
6788 These attributes mainly are intended to support the @code{__vector},
6789 @code{__pixel}, and @code{__bool} AltiVec keywords.
6790
6791 @node SPU Type Attributes
6792 @subsection SPU Type Attributes
6793
6794 @cindex @code{spu_vector} type attribute, SPU
6795 The SPU supports the @code{spu_vector} attribute for types. This attribute
6796 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6797 Language Extensions Specification. It is intended to support the
6798 @code{__vector} keyword.
6799
6800 @node x86 Type Attributes
6801 @subsection x86 Type Attributes
6802
6803 Two attributes are currently defined for x86 configurations:
6804 @code{ms_struct} and @code{gcc_struct}.
6805
6806 @table @code
6807
6808 @item ms_struct
6809 @itemx gcc_struct
6810 @cindex @code{ms_struct} type attribute, x86
6811 @cindex @code{gcc_struct} type attribute, x86
6812
6813 If @code{packed} is used on a structure, or if bit-fields are used
6814 it may be that the Microsoft ABI packs them differently
6815 than GCC normally packs them. Particularly when moving packed
6816 data between functions compiled with GCC and the native Microsoft compiler
6817 (either via function call or as data in a file), it may be necessary to access
6818 either format.
6819
6820 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6821 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6822 command-line options, respectively;
6823 see @ref{x86 Options}, for details of how structure layout is affected.
6824 @xref{x86 Variable Attributes}, for information about the corresponding
6825 attributes on variables.
6826
6827 @end table
6828
6829 @node Label Attributes
6830 @section Label Attributes
6831 @cindex Label Attributes
6832
6833 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
6834 details of the exact syntax for using attributes. Other attributes are
6835 available for functions (@pxref{Function Attributes}), variables
6836 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6837 and for types (@pxref{Type Attributes}).
6838
6839 This example uses the @code{cold} label attribute to indicate the
6840 @code{ErrorHandling} branch is unlikely to be taken and that the
6841 @code{ErrorHandling} label is unused:
6842
6843 @smallexample
6844
6845 asm goto ("some asm" : : : : NoError);
6846
6847 /* This branch (the fall-through from the asm) is less commonly used */
6848 ErrorHandling:
6849 __attribute__((cold, unused)); /* Semi-colon is required here */
6850 printf("error\n");
6851 return 0;
6852
6853 NoError:
6854 printf("no error\n");
6855 return 1;
6856 @end smallexample
6857
6858 @table @code
6859 @item unused
6860 @cindex @code{unused} label attribute
6861 This feature is intended for program-generated code that may contain
6862 unused labels, but which is compiled with @option{-Wall}. It is
6863 not normally appropriate to use in it human-written code, though it
6864 could be useful in cases where the code that jumps to the label is
6865 contained within an @code{#ifdef} conditional.
6866
6867 @item hot
6868 @cindex @code{hot} label attribute
6869 The @code{hot} attribute on a label is used to inform the compiler that
6870 the path following the label is more likely than paths that are not so
6871 annotated. This attribute is used in cases where @code{__builtin_expect}
6872 cannot be used, for instance with computed goto or @code{asm goto}.
6873
6874 @item cold
6875 @cindex @code{cold} label attribute
6876 The @code{cold} attribute on labels is used to inform the compiler that
6877 the path following the label is unlikely to be executed. This attribute
6878 is used in cases where @code{__builtin_expect} cannot be used, for instance
6879 with computed goto or @code{asm goto}.
6880
6881 @end table
6882
6883 @node Enumerator Attributes
6884 @section Enumerator Attributes
6885 @cindex Enumerator Attributes
6886
6887 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
6888 details of the exact syntax for using attributes. Other attributes are
6889 available for functions (@pxref{Function Attributes}), variables
6890 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}),
6891 and for types (@pxref{Type Attributes}).
6892
6893 This example uses the @code{deprecated} enumerator attribute to indicate the
6894 @code{oldval} enumerator is deprecated:
6895
6896 @smallexample
6897 enum E @{
6898 oldval __attribute__((deprecated)),
6899 newval
6900 @};
6901
6902 int
6903 fn (void)
6904 @{
6905 return oldval;
6906 @}
6907 @end smallexample
6908
6909 @table @code
6910 @item deprecated
6911 @cindex @code{deprecated} enumerator attribute
6912 The @code{deprecated} attribute results in a warning if the enumerator
6913 is used anywhere in the source file. This is useful when identifying
6914 enumerators that are expected to be removed in a future version of a
6915 program. The warning also includes the location of the declaration
6916 of the deprecated enumerator, to enable users to easily find further
6917 information about why the enumerator is deprecated, or what they should
6918 do instead. Note that the warnings only occurs for uses.
6919
6920 @end table
6921
6922 @node Attribute Syntax
6923 @section Attribute Syntax
6924 @cindex attribute syntax
6925
6926 This section describes the syntax with which @code{__attribute__} may be
6927 used, and the constructs to which attribute specifiers bind, for the C
6928 language. Some details may vary for C++ and Objective-C@. Because of
6929 infelicities in the grammar for attributes, some forms described here
6930 may not be successfully parsed in all cases.
6931
6932 There are some problems with the semantics of attributes in C++. For
6933 example, there are no manglings for attributes, although they may affect
6934 code generation, so problems may arise when attributed types are used in
6935 conjunction with templates or overloading. Similarly, @code{typeid}
6936 does not distinguish between types with different attributes. Support
6937 for attributes in C++ may be restricted in future to attributes on
6938 declarations only, but not on nested declarators.
6939
6940 @xref{Function Attributes}, for details of the semantics of attributes
6941 applying to functions. @xref{Variable Attributes}, for details of the
6942 semantics of attributes applying to variables. @xref{Type Attributes},
6943 for details of the semantics of attributes applying to structure, union
6944 and enumerated types.
6945 @xref{Label Attributes}, for details of the semantics of attributes
6946 applying to labels.
6947 @xref{Enumerator Attributes}, for details of the semantics of attributes
6948 applying to enumerators.
6949
6950 An @dfn{attribute specifier} is of the form
6951 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
6952 is a possibly empty comma-separated sequence of @dfn{attributes}, where
6953 each attribute is one of the following:
6954
6955 @itemize @bullet
6956 @item
6957 Empty. Empty attributes are ignored.
6958
6959 @item
6960 An attribute name
6961 (which may be an identifier such as @code{unused}, or a reserved
6962 word such as @code{const}).
6963
6964 @item
6965 An attribute name followed by a parenthesized list of
6966 parameters for the attribute.
6967 These parameters take one of the following forms:
6968
6969 @itemize @bullet
6970 @item
6971 An identifier. For example, @code{mode} attributes use this form.
6972
6973 @item
6974 An identifier followed by a comma and a non-empty comma-separated list
6975 of expressions. For example, @code{format} attributes use this form.
6976
6977 @item
6978 A possibly empty comma-separated list of expressions. For example,
6979 @code{format_arg} attributes use this form with the list being a single
6980 integer constant expression, and @code{alias} attributes use this form
6981 with the list being a single string constant.
6982 @end itemize
6983 @end itemize
6984
6985 An @dfn{attribute specifier list} is a sequence of one or more attribute
6986 specifiers, not separated by any other tokens.
6987
6988 You may optionally specify attribute names with @samp{__}
6989 preceding and following the name.
6990 This allows you to use them in header files without
6991 being concerned about a possible macro of the same name. For example,
6992 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
6993
6994
6995 @subsubheading Label Attributes
6996
6997 In GNU C, an attribute specifier list may appear after the colon following a
6998 label, other than a @code{case} or @code{default} label. GNU C++ only permits
6999 attributes on labels if the attribute specifier is immediately
7000 followed by a semicolon (i.e., the label applies to an empty
7001 statement). If the semicolon is missing, C++ label attributes are
7002 ambiguous, as it is permissible for a declaration, which could begin
7003 with an attribute list, to be labelled in C++. Declarations cannot be
7004 labelled in C90 or C99, so the ambiguity does not arise there.
7005
7006 @subsubheading Enumerator Attributes
7007
7008 In GNU C, an attribute specifier list may appear as part of an enumerator.
7009 The attribute goes after the enumeration constant, before @code{=}, if
7010 present. The optional attribute in the enumerator appertains to the
7011 enumeration constant. It is not possible to place the attribute after
7012 the constant expression, if present.
7013
7014 @subsubheading Type Attributes
7015
7016 An attribute specifier list may appear as part of a @code{struct},
7017 @code{union} or @code{enum} specifier. It may go either immediately
7018 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7019 the closing brace. The former syntax is preferred.
7020 Where attribute specifiers follow the closing brace, they are considered
7021 to relate to the structure, union or enumerated type defined, not to any
7022 enclosing declaration the type specifier appears in, and the type
7023 defined is not complete until after the attribute specifiers.
7024 @c Otherwise, there would be the following problems: a shift/reduce
7025 @c conflict between attributes binding the struct/union/enum and
7026 @c binding to the list of specifiers/qualifiers; and "aligned"
7027 @c attributes could use sizeof for the structure, but the size could be
7028 @c changed later by "packed" attributes.
7029
7030
7031 @subsubheading All other attributes
7032
7033 Otherwise, an attribute specifier appears as part of a declaration,
7034 counting declarations of unnamed parameters and type names, and relates
7035 to that declaration (which may be nested in another declaration, for
7036 example in the case of a parameter declaration), or to a particular declarator
7037 within a declaration. Where an
7038 attribute specifier is applied to a parameter declared as a function or
7039 an array, it should apply to the function or array rather than the
7040 pointer to which the parameter is implicitly converted, but this is not
7041 yet correctly implemented.
7042
7043 Any list of specifiers and qualifiers at the start of a declaration may
7044 contain attribute specifiers, whether or not such a list may in that
7045 context contain storage class specifiers. (Some attributes, however,
7046 are essentially in the nature of storage class specifiers, and only make
7047 sense where storage class specifiers may be used; for example,
7048 @code{section}.) There is one necessary limitation to this syntax: the
7049 first old-style parameter declaration in a function definition cannot
7050 begin with an attribute specifier, because such an attribute applies to
7051 the function instead by syntax described below (which, however, is not
7052 yet implemented in this case). In some other cases, attribute
7053 specifiers are permitted by this grammar but not yet supported by the
7054 compiler. All attribute specifiers in this place relate to the
7055 declaration as a whole. In the obsolescent usage where a type of
7056 @code{int} is implied by the absence of type specifiers, such a list of
7057 specifiers and qualifiers may be an attribute specifier list with no
7058 other specifiers or qualifiers.
7059
7060 At present, the first parameter in a function prototype must have some
7061 type specifier that is not an attribute specifier; this resolves an
7062 ambiguity in the interpretation of @code{void f(int
7063 (__attribute__((foo)) x))}, but is subject to change. At present, if
7064 the parentheses of a function declarator contain only attributes then
7065 those attributes are ignored, rather than yielding an error or warning
7066 or implying a single parameter of type int, but this is subject to
7067 change.
7068
7069 An attribute specifier list may appear immediately before a declarator
7070 (other than the first) in a comma-separated list of declarators in a
7071 declaration of more than one identifier using a single list of
7072 specifiers and qualifiers. Such attribute specifiers apply
7073 only to the identifier before whose declarator they appear. For
7074 example, in
7075
7076 @smallexample
7077 __attribute__((noreturn)) void d0 (void),
7078 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7079 d2 (void);
7080 @end smallexample
7081
7082 @noindent
7083 the @code{noreturn} attribute applies to all the functions
7084 declared; the @code{format} attribute only applies to @code{d1}.
7085
7086 An attribute specifier list may appear immediately before the comma,
7087 @code{=} or semicolon terminating the declaration of an identifier other
7088 than a function definition. Such attribute specifiers apply
7089 to the declared object or function. Where an
7090 assembler name for an object or function is specified (@pxref{Asm
7091 Labels}), the attribute must follow the @code{asm}
7092 specification.
7093
7094 An attribute specifier list may, in future, be permitted to appear after
7095 the declarator in a function definition (before any old-style parameter
7096 declarations or the function body).
7097
7098 Attribute specifiers may be mixed with type qualifiers appearing inside
7099 the @code{[]} of a parameter array declarator, in the C99 construct by
7100 which such qualifiers are applied to the pointer to which the array is
7101 implicitly converted. Such attribute specifiers apply to the pointer,
7102 not to the array, but at present this is not implemented and they are
7103 ignored.
7104
7105 An attribute specifier list may appear at the start of a nested
7106 declarator. At present, there are some limitations in this usage: the
7107 attributes correctly apply to the declarator, but for most individual
7108 attributes the semantics this implies are not implemented.
7109 When attribute specifiers follow the @code{*} of a pointer
7110 declarator, they may be mixed with any type qualifiers present.
7111 The following describes the formal semantics of this syntax. It makes the
7112 most sense if you are familiar with the formal specification of
7113 declarators in the ISO C standard.
7114
7115 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7116 D1}, where @code{T} contains declaration specifiers that specify a type
7117 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7118 contains an identifier @var{ident}. The type specified for @var{ident}
7119 for derived declarators whose type does not include an attribute
7120 specifier is as in the ISO C standard.
7121
7122 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7123 and the declaration @code{T D} specifies the type
7124 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7125 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7126 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7127
7128 If @code{D1} has the form @code{*
7129 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7130 declaration @code{T D} specifies the type
7131 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7132 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7133 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7134 @var{ident}.
7135
7136 For example,
7137
7138 @smallexample
7139 void (__attribute__((noreturn)) ****f) (void);
7140 @end smallexample
7141
7142 @noindent
7143 specifies the type ``pointer to pointer to pointer to pointer to
7144 non-returning function returning @code{void}''. As another example,
7145
7146 @smallexample
7147 char *__attribute__((aligned(8))) *f;
7148 @end smallexample
7149
7150 @noindent
7151 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7152 Note again that this does not work with most attributes; for example,
7153 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7154 is not yet supported.
7155
7156 For compatibility with existing code written for compiler versions that
7157 did not implement attributes on nested declarators, some laxity is
7158 allowed in the placing of attributes. If an attribute that only applies
7159 to types is applied to a declaration, it is treated as applying to
7160 the type of that declaration. If an attribute that only applies to
7161 declarations is applied to the type of a declaration, it is treated
7162 as applying to that declaration; and, for compatibility with code
7163 placing the attributes immediately before the identifier declared, such
7164 an attribute applied to a function return type is treated as
7165 applying to the function type, and such an attribute applied to an array
7166 element type is treated as applying to the array type. If an
7167 attribute that only applies to function types is applied to a
7168 pointer-to-function type, it is treated as applying to the pointer
7169 target type; if such an attribute is applied to a function return type
7170 that is not a pointer-to-function type, it is treated as applying
7171 to the function type.
7172
7173 @node Function Prototypes
7174 @section Prototypes and Old-Style Function Definitions
7175 @cindex function prototype declarations
7176 @cindex old-style function definitions
7177 @cindex promotion of formal parameters
7178
7179 GNU C extends ISO C to allow a function prototype to override a later
7180 old-style non-prototype definition. Consider the following example:
7181
7182 @smallexample
7183 /* @r{Use prototypes unless the compiler is old-fashioned.} */
7184 #ifdef __STDC__
7185 #define P(x) x
7186 #else
7187 #define P(x) ()
7188 #endif
7189
7190 /* @r{Prototype function declaration.} */
7191 int isroot P((uid_t));
7192
7193 /* @r{Old-style function definition.} */
7194 int
7195 isroot (x) /* @r{??? lossage here ???} */
7196 uid_t x;
7197 @{
7198 return x == 0;
7199 @}
7200 @end smallexample
7201
7202 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
7203 not allow this example, because subword arguments in old-style
7204 non-prototype definitions are promoted. Therefore in this example the
7205 function definition's argument is really an @code{int}, which does not
7206 match the prototype argument type of @code{short}.
7207
7208 This restriction of ISO C makes it hard to write code that is portable
7209 to traditional C compilers, because the programmer does not know
7210 whether the @code{uid_t} type is @code{short}, @code{int}, or
7211 @code{long}. Therefore, in cases like these GNU C allows a prototype
7212 to override a later old-style definition. More precisely, in GNU C, a
7213 function prototype argument type overrides the argument type specified
7214 by a later old-style definition if the former type is the same as the
7215 latter type before promotion. Thus in GNU C the above example is
7216 equivalent to the following:
7217
7218 @smallexample
7219 int isroot (uid_t);
7220
7221 int
7222 isroot (uid_t x)
7223 @{
7224 return x == 0;
7225 @}
7226 @end smallexample
7227
7228 @noindent
7229 GNU C++ does not support old-style function definitions, so this
7230 extension is irrelevant.
7231
7232 @node C++ Comments
7233 @section C++ Style Comments
7234 @cindex @code{//}
7235 @cindex C++ comments
7236 @cindex comments, C++ style
7237
7238 In GNU C, you may use C++ style comments, which start with @samp{//} and
7239 continue until the end of the line. Many other C implementations allow
7240 such comments, and they are included in the 1999 C standard. However,
7241 C++ style comments are not recognized if you specify an @option{-std}
7242 option specifying a version of ISO C before C99, or @option{-ansi}
7243 (equivalent to @option{-std=c90}).
7244
7245 @node Dollar Signs
7246 @section Dollar Signs in Identifier Names
7247 @cindex $
7248 @cindex dollar signs in identifier names
7249 @cindex identifier names, dollar signs in
7250
7251 In GNU C, you may normally use dollar signs in identifier names.
7252 This is because many traditional C implementations allow such identifiers.
7253 However, dollar signs in identifiers are not supported on a few target
7254 machines, typically because the target assembler does not allow them.
7255
7256 @node Character Escapes
7257 @section The Character @key{ESC} in Constants
7258
7259 You can use the sequence @samp{\e} in a string or character constant to
7260 stand for the ASCII character @key{ESC}.
7261
7262 @node Alignment
7263 @section Inquiring on Alignment of Types or Variables
7264 @cindex alignment
7265 @cindex type alignment
7266 @cindex variable alignment
7267
7268 The keyword @code{__alignof__} allows you to inquire about how an object
7269 is aligned, or the minimum alignment usually required by a type. Its
7270 syntax is just like @code{sizeof}.
7271
7272 For example, if the target machine requires a @code{double} value to be
7273 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7274 This is true on many RISC machines. On more traditional machine
7275 designs, @code{__alignof__ (double)} is 4 or even 2.
7276
7277 Some machines never actually require alignment; they allow reference to any
7278 data type even at an odd address. For these machines, @code{__alignof__}
7279 reports the smallest alignment that GCC gives the data type, usually as
7280 mandated by the target ABI.
7281
7282 If the operand of @code{__alignof__} is an lvalue rather than a type,
7283 its value is the required alignment for its type, taking into account
7284 any minimum alignment specified with GCC's @code{__attribute__}
7285 extension (@pxref{Variable Attributes}). For example, after this
7286 declaration:
7287
7288 @smallexample
7289 struct foo @{ int x; char y; @} foo1;
7290 @end smallexample
7291
7292 @noindent
7293 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7294 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7295
7296 It is an error to ask for the alignment of an incomplete type.
7297
7298
7299 @node Inline
7300 @section An Inline Function is As Fast As a Macro
7301 @cindex inline functions
7302 @cindex integrating function code
7303 @cindex open coding
7304 @cindex macros, inline alternative
7305
7306 By declaring a function inline, you can direct GCC to make
7307 calls to that function faster. One way GCC can achieve this is to
7308 integrate that function's code into the code for its callers. This
7309 makes execution faster by eliminating the function-call overhead; in
7310 addition, if any of the actual argument values are constant, their
7311 known values may permit simplifications at compile time so that not
7312 all of the inline function's code needs to be included. The effect on
7313 code size is less predictable; object code may be larger or smaller
7314 with function inlining, depending on the particular case. You can
7315 also direct GCC to try to integrate all ``simple enough'' functions
7316 into their callers with the option @option{-finline-functions}.
7317
7318 GCC implements three different semantics of declaring a function
7319 inline. One is available with @option{-std=gnu89} or
7320 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7321 on all inline declarations, another when
7322 @option{-std=c99}, @option{-std=c11},
7323 @option{-std=gnu99} or @option{-std=gnu11}
7324 (without @option{-fgnu89-inline}), and the third
7325 is used when compiling C++.
7326
7327 To declare a function inline, use the @code{inline} keyword in its
7328 declaration, like this:
7329
7330 @smallexample
7331 static inline int
7332 inc (int *a)
7333 @{
7334 return (*a)++;
7335 @}
7336 @end smallexample
7337
7338 If you are writing a header file to be included in ISO C90 programs, write
7339 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
7340
7341 The three types of inlining behave similarly in two important cases:
7342 when the @code{inline} keyword is used on a @code{static} function,
7343 like the example above, and when a function is first declared without
7344 using the @code{inline} keyword and then is defined with
7345 @code{inline}, like this:
7346
7347 @smallexample
7348 extern int inc (int *a);
7349 inline int
7350 inc (int *a)
7351 @{
7352 return (*a)++;
7353 @}
7354 @end smallexample
7355
7356 In both of these common cases, the program behaves the same as if you
7357 had not used the @code{inline} keyword, except for its speed.
7358
7359 @cindex inline functions, omission of
7360 @opindex fkeep-inline-functions
7361 When a function is both inline and @code{static}, if all calls to the
7362 function are integrated into the caller, and the function's address is
7363 never used, then the function's own assembler code is never referenced.
7364 In this case, GCC does not actually output assembler code for the
7365 function, unless you specify the option @option{-fkeep-inline-functions}.
7366 If there is a nonintegrated call, then the function is compiled to
7367 assembler code as usual. The function must also be compiled as usual if
7368 the program refers to its address, because that can't be inlined.
7369
7370 @opindex Winline
7371 Note that certain usages in a function definition can make it unsuitable
7372 for inline substitution. Among these usages are: variadic functions,
7373 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7374 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7375 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7376 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
7377 function marked @code{inline} could not be substituted, and gives the
7378 reason for the failure.
7379
7380 @cindex automatic @code{inline} for C++ member fns
7381 @cindex @code{inline} automatic for C++ member fns
7382 @cindex member fns, automatically @code{inline}
7383 @cindex C++ member fns, automatically @code{inline}
7384 @opindex fno-default-inline
7385 As required by ISO C++, GCC considers member functions defined within
7386 the body of a class to be marked inline even if they are
7387 not explicitly declared with the @code{inline} keyword. You can
7388 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7389 Options,,Options Controlling C++ Dialect}.
7390
7391 GCC does not inline any functions when not optimizing unless you specify
7392 the @samp{always_inline} attribute for the function, like this:
7393
7394 @smallexample
7395 /* @r{Prototype.} */
7396 inline void foo (const char) __attribute__((always_inline));
7397 @end smallexample
7398
7399 The remainder of this section is specific to GNU C90 inlining.
7400
7401 @cindex non-static inline function
7402 When an inline function is not @code{static}, then the compiler must assume
7403 that there may be calls from other source files; since a global symbol can
7404 be defined only once in any program, the function must not be defined in
7405 the other source files, so the calls therein cannot be integrated.
7406 Therefore, a non-@code{static} inline function is always compiled on its
7407 own in the usual fashion.
7408
7409 If you specify both @code{inline} and @code{extern} in the function
7410 definition, then the definition is used only for inlining. In no case
7411 is the function compiled on its own, not even if you refer to its
7412 address explicitly. Such an address becomes an external reference, as
7413 if you had only declared the function, and had not defined it.
7414
7415 This combination of @code{inline} and @code{extern} has almost the
7416 effect of a macro. The way to use it is to put a function definition in
7417 a header file with these keywords, and put another copy of the
7418 definition (lacking @code{inline} and @code{extern}) in a library file.
7419 The definition in the header file causes most calls to the function
7420 to be inlined. If any uses of the function remain, they refer to
7421 the single copy in the library.
7422
7423 @node Volatiles
7424 @section When is a Volatile Object Accessed?
7425 @cindex accessing volatiles
7426 @cindex volatile read
7427 @cindex volatile write
7428 @cindex volatile access
7429
7430 C has the concept of volatile objects. These are normally accessed by
7431 pointers and used for accessing hardware or inter-thread
7432 communication. The standard encourages compilers to refrain from
7433 optimizations concerning accesses to volatile objects, but leaves it
7434 implementation defined as to what constitutes a volatile access. The
7435 minimum requirement is that at a sequence point all previous accesses
7436 to volatile objects have stabilized and no subsequent accesses have
7437 occurred. Thus an implementation is free to reorder and combine
7438 volatile accesses that occur between sequence points, but cannot do
7439 so for accesses across a sequence point. The use of volatile does
7440 not allow you to violate the restriction on updating objects multiple
7441 times between two sequence points.
7442
7443 Accesses to non-volatile objects are not ordered with respect to
7444 volatile accesses. You cannot use a volatile object as a memory
7445 barrier to order a sequence of writes to non-volatile memory. For
7446 instance:
7447
7448 @smallexample
7449 int *ptr = @var{something};
7450 volatile int vobj;
7451 *ptr = @var{something};
7452 vobj = 1;
7453 @end smallexample
7454
7455 @noindent
7456 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7457 that the write to @var{*ptr} occurs by the time the update
7458 of @var{vobj} happens. If you need this guarantee, you must use
7459 a stronger memory barrier such as:
7460
7461 @smallexample
7462 int *ptr = @var{something};
7463 volatile int vobj;
7464 *ptr = @var{something};
7465 asm volatile ("" : : : "memory");
7466 vobj = 1;
7467 @end smallexample
7468
7469 A scalar volatile object is read when it is accessed in a void context:
7470
7471 @smallexample
7472 volatile int *src = @var{somevalue};
7473 *src;
7474 @end smallexample
7475
7476 Such expressions are rvalues, and GCC implements this as a
7477 read of the volatile object being pointed to.
7478
7479 Assignments are also expressions and have an rvalue. However when
7480 assigning to a scalar volatile, the volatile object is not reread,
7481 regardless of whether the assignment expression's rvalue is used or
7482 not. If the assignment's rvalue is used, the value is that assigned
7483 to the volatile object. For instance, there is no read of @var{vobj}
7484 in all the following cases:
7485
7486 @smallexample
7487 int obj;
7488 volatile int vobj;
7489 vobj = @var{something};
7490 obj = vobj = @var{something};
7491 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7492 obj = (@var{something}, vobj = @var{anotherthing});
7493 @end smallexample
7494
7495 If you need to read the volatile object after an assignment has
7496 occurred, you must use a separate expression with an intervening
7497 sequence point.
7498
7499 As bit-fields are not individually addressable, volatile bit-fields may
7500 be implicitly read when written to, or when adjacent bit-fields are
7501 accessed. Bit-field operations may be optimized such that adjacent
7502 bit-fields are only partially accessed, if they straddle a storage unit
7503 boundary. For these reasons it is unwise to use volatile bit-fields to
7504 access hardware.
7505
7506 @node Using Assembly Language with C
7507 @section How to Use Inline Assembly Language in C Code
7508 @cindex @code{asm} keyword
7509 @cindex assembly language in C
7510 @cindex inline assembly language
7511 @cindex mixing assembly language and C
7512
7513 The @code{asm} keyword allows you to embed assembler instructions
7514 within C code. GCC provides two forms of inline @code{asm}
7515 statements. A @dfn{basic @code{asm}} statement is one with no
7516 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7517 statement (@pxref{Extended Asm}) includes one or more operands.
7518 The extended form is preferred for mixing C and assembly language
7519 within a function, but to include assembly language at
7520 top level you must use basic @code{asm}.
7521
7522 You can also use the @code{asm} keyword to override the assembler name
7523 for a C symbol, or to place a C variable in a specific register.
7524
7525 @menu
7526 * Basic Asm:: Inline assembler without operands.
7527 * Extended Asm:: Inline assembler with operands.
7528 * Constraints:: Constraints for @code{asm} operands
7529 * Asm Labels:: Specifying the assembler name to use for a C symbol.
7530 * Explicit Register Variables:: Defining variables residing in specified
7531 registers.
7532 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
7533 @end menu
7534
7535 @node Basic Asm
7536 @subsection Basic Asm --- Assembler Instructions Without Operands
7537 @cindex basic @code{asm}
7538 @cindex assembly language in C, basic
7539
7540 A basic @code{asm} statement has the following syntax:
7541
7542 @example
7543 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7544 @end example
7545
7546 The @code{asm} keyword is a GNU extension.
7547 When writing code that can be compiled with @option{-ansi} and the
7548 various @option{-std} options, use @code{__asm__} instead of
7549 @code{asm} (@pxref{Alternate Keywords}).
7550
7551 @subsubheading Qualifiers
7552 @table @code
7553 @item volatile
7554 The optional @code{volatile} qualifier has no effect.
7555 All basic @code{asm} blocks are implicitly volatile.
7556 @end table
7557
7558 @subsubheading Parameters
7559 @table @var
7560
7561 @item AssemblerInstructions
7562 This is a literal string that specifies the assembler code. The string can
7563 contain any instructions recognized by the assembler, including directives.
7564 GCC does not parse the assembler instructions themselves and
7565 does not know what they mean or even whether they are valid assembler input.
7566
7567 You may place multiple assembler instructions together in a single @code{asm}
7568 string, separated by the characters normally used in assembly code for the
7569 system. A combination that works in most places is a newline to break the
7570 line, plus a tab character (written as @samp{\n\t}).
7571 Some assemblers allow semicolons as a line separator. However,
7572 note that some assembler dialects use semicolons to start a comment.
7573 @end table
7574
7575 @subsubheading Remarks
7576 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
7577 smaller, safer, and more efficient code, and in most cases it is a
7578 better solution than basic @code{asm}. However, there are two
7579 situations where only basic @code{asm} can be used:
7580
7581 @itemize @bullet
7582 @item
7583 Extended @code{asm} statements have to be inside a C
7584 function, so to write inline assembly language at file scope (``top-level''),
7585 outside of C functions, you must use basic @code{asm}.
7586 You can use this technique to emit assembler directives,
7587 define assembly language macros that can be invoked elsewhere in the file,
7588 or write entire functions in assembly language.
7589
7590 @item
7591 Functions declared
7592 with the @code{naked} attribute also require basic @code{asm}
7593 (@pxref{Function Attributes}).
7594 @end itemize
7595
7596 Safely accessing C data and calling functions from basic @code{asm} is more
7597 complex than it may appear. To access C data, it is better to use extended
7598 @code{asm}.
7599
7600 Do not expect a sequence of @code{asm} statements to remain perfectly
7601 consecutive after compilation. If certain instructions need to remain
7602 consecutive in the output, put them in a single multi-instruction @code{asm}
7603 statement. Note that GCC's optimizers can move @code{asm} statements
7604 relative to other code, including across jumps.
7605
7606 @code{asm} statements may not perform jumps into other @code{asm} statements.
7607 GCC does not know about these jumps, and therefore cannot take
7608 account of them when deciding how to optimize. Jumps from @code{asm} to C
7609 labels are only supported in extended @code{asm}.
7610
7611 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7612 assembly code when optimizing. This can lead to unexpected duplicate
7613 symbol errors during compilation if your assembly code defines symbols or
7614 labels.
7615
7616 @strong{Warning:} The C standards do not specify semantics for @code{asm},
7617 making it a potential source of incompatibilities between compilers. These
7618 incompatibilities may not produce compiler warnings/errors.
7619
7620 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
7621 means there is no way to communicate to the compiler what is happening
7622 inside them. GCC has no visibility of symbols in the @code{asm} and may
7623 discard them as unreferenced. It also does not know about side effects of
7624 the assembler code, such as modifications to memory or registers. Unlike
7625 some compilers, GCC assumes that no changes to general purpose registers
7626 occur. This assumption may change in a future release.
7627
7628 To avoid complications from future changes to the semantics and the
7629 compatibility issues between compilers, consider replacing basic @code{asm}
7630 with extended @code{asm}. See
7631 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
7632 from basic asm to extended asm} for information about how to perform this
7633 conversion.
7634
7635 The compiler copies the assembler instructions in a basic @code{asm}
7636 verbatim to the assembly language output file, without
7637 processing dialects or any of the @samp{%} operators that are available with
7638 extended @code{asm}. This results in minor differences between basic
7639 @code{asm} strings and extended @code{asm} templates. For example, to refer to
7640 registers you might use @samp{%eax} in basic @code{asm} and
7641 @samp{%%eax} in extended @code{asm}.
7642
7643 On targets such as x86 that support multiple assembler dialects,
7644 all basic @code{asm} blocks use the assembler dialect specified by the
7645 @option{-masm} command-line option (@pxref{x86 Options}).
7646 Basic @code{asm} provides no
7647 mechanism to provide different assembler strings for different dialects.
7648
7649 For basic @code{asm} with non-empty assembler string GCC assumes
7650 the assembler block does not change any general purpose registers,
7651 but it may read or write any globally accessible variable.
7652
7653 Here is an example of basic @code{asm} for i386:
7654
7655 @example
7656 /* Note that this code will not compile with -masm=intel */
7657 #define DebugBreak() asm("int $3")
7658 @end example
7659
7660 @node Extended Asm
7661 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7662 @cindex extended @code{asm}
7663 @cindex assembly language in C, extended
7664
7665 With extended @code{asm} you can read and write C variables from
7666 assembler and perform jumps from assembler code to C labels.
7667 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7668 the operand parameters after the assembler template:
7669
7670 @example
7671 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
7672 : @var{OutputOperands}
7673 @r{[} : @var{InputOperands}
7674 @r{[} : @var{Clobbers} @r{]} @r{]})
7675
7676 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
7677 :
7678 : @var{InputOperands}
7679 : @var{Clobbers}
7680 : @var{GotoLabels})
7681 @end example
7682
7683 The @code{asm} keyword is a GNU extension.
7684 When writing code that can be compiled with @option{-ansi} and the
7685 various @option{-std} options, use @code{__asm__} instead of
7686 @code{asm} (@pxref{Alternate Keywords}).
7687
7688 @subsubheading Qualifiers
7689 @table @code
7690
7691 @item volatile
7692 The typical use of extended @code{asm} statements is to manipulate input
7693 values to produce output values. However, your @code{asm} statements may
7694 also produce side effects. If so, you may need to use the @code{volatile}
7695 qualifier to disable certain optimizations. @xref{Volatile}.
7696
7697 @item goto
7698 This qualifier informs the compiler that the @code{asm} statement may
7699 perform a jump to one of the labels listed in the @var{GotoLabels}.
7700 @xref{GotoLabels}.
7701 @end table
7702
7703 @subsubheading Parameters
7704 @table @var
7705 @item AssemblerTemplate
7706 This is a literal string that is the template for the assembler code. It is a
7707 combination of fixed text and tokens that refer to the input, output,
7708 and goto parameters. @xref{AssemblerTemplate}.
7709
7710 @item OutputOperands
7711 A comma-separated list of the C variables modified by the instructions in the
7712 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
7713
7714 @item InputOperands
7715 A comma-separated list of C expressions read by the instructions in the
7716 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
7717
7718 @item Clobbers
7719 A comma-separated list of registers or other values changed by the
7720 @var{AssemblerTemplate}, beyond those listed as outputs.
7721 An empty list is permitted. @xref{Clobbers}.
7722
7723 @item GotoLabels
7724 When you are using the @code{goto} form of @code{asm}, this section contains
7725 the list of all C labels to which the code in the
7726 @var{AssemblerTemplate} may jump.
7727 @xref{GotoLabels}.
7728
7729 @code{asm} statements may not perform jumps into other @code{asm} statements,
7730 only to the listed @var{GotoLabels}.
7731 GCC's optimizers do not know about other jumps; therefore they cannot take
7732 account of them when deciding how to optimize.
7733 @end table
7734
7735 The total number of input + output + goto operands is limited to 30.
7736
7737 @subsubheading Remarks
7738 The @code{asm} statement allows you to include assembly instructions directly
7739 within C code. This may help you to maximize performance in time-sensitive
7740 code or to access assembly instructions that are not readily available to C
7741 programs.
7742
7743 Note that extended @code{asm} statements must be inside a function. Only
7744 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7745 Functions declared with the @code{naked} attribute also require basic
7746 @code{asm} (@pxref{Function Attributes}).
7747
7748 While the uses of @code{asm} are many and varied, it may help to think of an
7749 @code{asm} statement as a series of low-level instructions that convert input
7750 parameters to output parameters. So a simple (if not particularly useful)
7751 example for i386 using @code{asm} might look like this:
7752
7753 @example
7754 int src = 1;
7755 int dst;
7756
7757 asm ("mov %1, %0\n\t"
7758 "add $1, %0"
7759 : "=r" (dst)
7760 : "r" (src));
7761
7762 printf("%d\n", dst);
7763 @end example
7764
7765 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7766
7767 @anchor{Volatile}
7768 @subsubsection Volatile
7769 @cindex volatile @code{asm}
7770 @cindex @code{asm} volatile
7771
7772 GCC's optimizers sometimes discard @code{asm} statements if they determine
7773 there is no need for the output variables. Also, the optimizers may move
7774 code out of loops if they believe that the code will always return the same
7775 result (i.e. none of its input values change between calls). Using the
7776 @code{volatile} qualifier disables these optimizations. @code{asm} statements
7777 that have no output operands, including @code{asm goto} statements,
7778 are implicitly volatile.
7779
7780 This i386 code demonstrates a case that does not use (or require) the
7781 @code{volatile} qualifier. If it is performing assertion checking, this code
7782 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
7783 unreferenced by any code. As a result, the optimizers can discard the
7784 @code{asm} statement, which in turn removes the need for the entire
7785 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
7786 isn't needed you allow the optimizers to produce the most efficient code
7787 possible.
7788
7789 @example
7790 void DoCheck(uint32_t dwSomeValue)
7791 @{
7792 uint32_t dwRes;
7793
7794 // Assumes dwSomeValue is not zero.
7795 asm ("bsfl %1,%0"
7796 : "=r" (dwRes)
7797 : "r" (dwSomeValue)
7798 : "cc");
7799
7800 assert(dwRes > 3);
7801 @}
7802 @end example
7803
7804 The next example shows a case where the optimizers can recognize that the input
7805 (@code{dwSomeValue}) never changes during the execution of the function and can
7806 therefore move the @code{asm} outside the loop to produce more efficient code.
7807 Again, using @code{volatile} disables this type of optimization.
7808
7809 @example
7810 void do_print(uint32_t dwSomeValue)
7811 @{
7812 uint32_t dwRes;
7813
7814 for (uint32_t x=0; x < 5; x++)
7815 @{
7816 // Assumes dwSomeValue is not zero.
7817 asm ("bsfl %1,%0"
7818 : "=r" (dwRes)
7819 : "r" (dwSomeValue)
7820 : "cc");
7821
7822 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7823 @}
7824 @}
7825 @end example
7826
7827 The following example demonstrates a case where you need to use the
7828 @code{volatile} qualifier.
7829 It uses the x86 @code{rdtsc} instruction, which reads
7830 the computer's time-stamp counter. Without the @code{volatile} qualifier,
7831 the optimizers might assume that the @code{asm} block will always return the
7832 same value and therefore optimize away the second call.
7833
7834 @example
7835 uint64_t msr;
7836
7837 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7838 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7839 "or %%rdx, %0" // 'Or' in the lower bits.
7840 : "=a" (msr)
7841 :
7842 : "rdx");
7843
7844 printf("msr: %llx\n", msr);
7845
7846 // Do other work...
7847
7848 // Reprint the timestamp
7849 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7850 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7851 "or %%rdx, %0" // 'Or' in the lower bits.
7852 : "=a" (msr)
7853 :
7854 : "rdx");
7855
7856 printf("msr: %llx\n", msr);
7857 @end example
7858
7859 GCC's optimizers do not treat this code like the non-volatile code in the
7860 earlier examples. They do not move it out of loops or omit it on the
7861 assumption that the result from a previous call is still valid.
7862
7863 Note that the compiler can move even volatile @code{asm} instructions relative
7864 to other code, including across jump instructions. For example, on many
7865 targets there is a system register that controls the rounding mode of
7866 floating-point operations. Setting it with a volatile @code{asm}, as in the
7867 following PowerPC example, does not work reliably.
7868
7869 @example
7870 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7871 sum = x + y;
7872 @end example
7873
7874 The compiler may move the addition back before the volatile @code{asm}. To
7875 make it work as expected, add an artificial dependency to the @code{asm} by
7876 referencing a variable in the subsequent code, for example:
7877
7878 @example
7879 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7880 sum = x + y;
7881 @end example
7882
7883 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7884 assembly code when optimizing. This can lead to unexpected duplicate symbol
7885 errors during compilation if your asm code defines symbols or labels.
7886 Using @samp{%=}
7887 (@pxref{AssemblerTemplate}) may help resolve this problem.
7888
7889 @anchor{AssemblerTemplate}
7890 @subsubsection Assembler Template
7891 @cindex @code{asm} assembler template
7892
7893 An assembler template is a literal string containing assembler instructions.
7894 The compiler replaces tokens in the template that refer
7895 to inputs, outputs, and goto labels,
7896 and then outputs the resulting string to the assembler. The
7897 string can contain any instructions recognized by the assembler, including
7898 directives. GCC does not parse the assembler instructions
7899 themselves and does not know what they mean or even whether they are valid
7900 assembler input. However, it does count the statements
7901 (@pxref{Size of an asm}).
7902
7903 You may place multiple assembler instructions together in a single @code{asm}
7904 string, separated by the characters normally used in assembly code for the
7905 system. A combination that works in most places is a newline to break the
7906 line, plus a tab character to move to the instruction field (written as
7907 @samp{\n\t}).
7908 Some assemblers allow semicolons as a line separator. However, note
7909 that some assembler dialects use semicolons to start a comment.
7910
7911 Do not expect a sequence of @code{asm} statements to remain perfectly
7912 consecutive after compilation, even when you are using the @code{volatile}
7913 qualifier. If certain instructions need to remain consecutive in the output,
7914 put them in a single multi-instruction asm statement.
7915
7916 Accessing data from C programs without using input/output operands (such as
7917 by using global symbols directly from the assembler template) may not work as
7918 expected. Similarly, calling functions directly from an assembler template
7919 requires a detailed understanding of the target assembler and ABI.
7920
7921 Since GCC does not parse the assembler template,
7922 it has no visibility of any
7923 symbols it references. This may result in GCC discarding those symbols as
7924 unreferenced unless they are also listed as input, output, or goto operands.
7925
7926 @subsubheading Special format strings
7927
7928 In addition to the tokens described by the input, output, and goto operands,
7929 these tokens have special meanings in the assembler template:
7930
7931 @table @samp
7932 @item %%
7933 Outputs a single @samp{%} into the assembler code.
7934
7935 @item %=
7936 Outputs a number that is unique to each instance of the @code{asm}
7937 statement in the entire compilation. This option is useful when creating local
7938 labels and referring to them multiple times in a single template that
7939 generates multiple assembler instructions.
7940
7941 @item %@{
7942 @itemx %|
7943 @itemx %@}
7944 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
7945 into the assembler code. When unescaped, these characters have special
7946 meaning to indicate multiple assembler dialects, as described below.
7947 @end table
7948
7949 @subsubheading Multiple assembler dialects in @code{asm} templates
7950
7951 On targets such as x86, GCC supports multiple assembler dialects.
7952 The @option{-masm} option controls which dialect GCC uses as its
7953 default for inline assembler. The target-specific documentation for the
7954 @option{-masm} option contains the list of supported dialects, as well as the
7955 default dialect if the option is not specified. This information may be
7956 important to understand, since assembler code that works correctly when
7957 compiled using one dialect will likely fail if compiled using another.
7958 @xref{x86 Options}.
7959
7960 If your code needs to support multiple assembler dialects (for example, if
7961 you are writing public headers that need to support a variety of compilation
7962 options), use constructs of this form:
7963
7964 @example
7965 @{ dialect0 | dialect1 | dialect2... @}
7966 @end example
7967
7968 This construct outputs @code{dialect0}
7969 when using dialect #0 to compile the code,
7970 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
7971 braces than the number of dialects the compiler supports, the construct
7972 outputs nothing.
7973
7974 For example, if an x86 compiler supports two dialects
7975 (@samp{att}, @samp{intel}), an
7976 assembler template such as this:
7977
7978 @example
7979 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
7980 @end example
7981
7982 @noindent
7983 is equivalent to one of
7984
7985 @example
7986 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
7987 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
7988 @end example
7989
7990 Using that same compiler, this code:
7991
7992 @example
7993 "xchg@{l@}\t@{%%@}ebx, %1"
7994 @end example
7995
7996 @noindent
7997 corresponds to either
7998
7999 @example
8000 "xchgl\t%%ebx, %1" @r{/* att dialect */}
8001 "xchg\tebx, %1" @r{/* intel dialect */}
8002 @end example
8003
8004 There is no support for nesting dialect alternatives.
8005
8006 @anchor{OutputOperands}
8007 @subsubsection Output Operands
8008 @cindex @code{asm} output operands
8009
8010 An @code{asm} statement has zero or more output operands indicating the names
8011 of C variables modified by the assembler code.
8012
8013 In this i386 example, @code{old} (referred to in the template string as
8014 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
8015 (@code{%2}) is an input:
8016
8017 @example
8018 bool old;
8019
8020 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8021 "sbb %0,%0" // Use the CF to calculate old.
8022 : "=r" (old), "+rm" (*Base)
8023 : "Ir" (Offset)
8024 : "cc");
8025
8026 return old;
8027 @end example
8028
8029 Operands are separated by commas. Each operand has this format:
8030
8031 @example
8032 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8033 @end example
8034
8035 @table @var
8036 @item asmSymbolicName
8037 Specifies a symbolic name for the operand.
8038 Reference the name in the assembler template
8039 by enclosing it in square brackets
8040 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8041 that contains the definition. Any valid C variable name is acceptable,
8042 including names already defined in the surrounding code. No two operands
8043 within the same @code{asm} statement can use the same symbolic name.
8044
8045 When not using an @var{asmSymbolicName}, use the (zero-based) position
8046 of the operand
8047 in the list of operands in the assembler template. For example if there are
8048 three output operands, use @samp{%0} in the template to refer to the first,
8049 @samp{%1} for the second, and @samp{%2} for the third.
8050
8051 @item constraint
8052 A string constant specifying constraints on the placement of the operand;
8053 @xref{Constraints}, for details.
8054
8055 Output constraints must begin with either @samp{=} (a variable overwriting an
8056 existing value) or @samp{+} (when reading and writing). When using
8057 @samp{=}, do not assume the location contains the existing value
8058 on entry to the @code{asm}, except
8059 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8060
8061 After the prefix, there must be one or more additional constraints
8062 (@pxref{Constraints}) that describe where the value resides. Common
8063 constraints include @samp{r} for register and @samp{m} for memory.
8064 When you list more than one possible location (for example, @code{"=rm"}),
8065 the compiler chooses the most efficient one based on the current context.
8066 If you list as many alternates as the @code{asm} statement allows, you permit
8067 the optimizers to produce the best possible code.
8068 If you must use a specific register, but your Machine Constraints do not
8069 provide sufficient control to select the specific register you want,
8070 local register variables may provide a solution (@pxref{Local Register
8071 Variables}).
8072
8073 @item cvariablename
8074 Specifies a C lvalue expression to hold the output, typically a variable name.
8075 The enclosing parentheses are a required part of the syntax.
8076
8077 @end table
8078
8079 When the compiler selects the registers to use to
8080 represent the output operands, it does not use any of the clobbered registers
8081 (@pxref{Clobbers}).
8082
8083 Output operand expressions must be lvalues. The compiler cannot check whether
8084 the operands have data types that are reasonable for the instruction being
8085 executed. For output expressions that are not directly addressable (for
8086 example a bit-field), the constraint must allow a register. In that case, GCC
8087 uses the register as the output of the @code{asm}, and then stores that
8088 register into the output.
8089
8090 Operands using the @samp{+} constraint modifier count as two operands
8091 (that is, both as input and output) towards the total maximum of 30 operands
8092 per @code{asm} statement.
8093
8094 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8095 operands that must not overlap an input. Otherwise,
8096 GCC may allocate the output operand in the same register as an unrelated
8097 input operand, on the assumption that the assembler code consumes its
8098 inputs before producing outputs. This assumption may be false if the assembler
8099 code actually consists of more than one instruction.
8100
8101 The same problem can occur if one output parameter (@var{a}) allows a register
8102 constraint and another output parameter (@var{b}) allows a memory constraint.
8103 The code generated by GCC to access the memory address in @var{b} can contain
8104 registers which @emph{might} be shared by @var{a}, and GCC considers those
8105 registers to be inputs to the asm. As above, GCC assumes that such input
8106 registers are consumed before any outputs are written. This assumption may
8107 result in incorrect behavior if the asm writes to @var{a} before using
8108 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8109 ensures that modifying @var{a} does not affect the address referenced by
8110 @var{b}. Otherwise, the location of @var{b}
8111 is undefined if @var{a} is modified before using @var{b}.
8112
8113 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8114 instead of simply @samp{%2}). Typically these qualifiers are hardware
8115 dependent. The list of supported modifiers for x86 is found at
8116 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8117
8118 If the C code that follows the @code{asm} makes no use of any of the output
8119 operands, use @code{volatile} for the @code{asm} statement to prevent the
8120 optimizers from discarding the @code{asm} statement as unneeded
8121 (see @ref{Volatile}).
8122
8123 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
8124 references the first output operand as @code{%0} (were there a second, it
8125 would be @code{%1}, etc). The number of the first input operand is one greater
8126 than that of the last output operand. In this i386 example, that makes
8127 @code{Mask} referenced as @code{%1}:
8128
8129 @example
8130 uint32_t Mask = 1234;
8131 uint32_t Index;
8132
8133 asm ("bsfl %1, %0"
8134 : "=r" (Index)
8135 : "r" (Mask)
8136 : "cc");
8137 @end example
8138
8139 That code overwrites the variable @code{Index} (@samp{=}),
8140 placing the value in a register (@samp{r}).
8141 Using the generic @samp{r} constraint instead of a constraint for a specific
8142 register allows the compiler to pick the register to use, which can result
8143 in more efficient code. This may not be possible if an assembler instruction
8144 requires a specific register.
8145
8146 The following i386 example uses the @var{asmSymbolicName} syntax.
8147 It produces the
8148 same result as the code above, but some may consider it more readable or more
8149 maintainable since reordering index numbers is not necessary when adding or
8150 removing operands. The names @code{aIndex} and @code{aMask}
8151 are only used in this example to emphasize which
8152 names get used where.
8153 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8154
8155 @example
8156 uint32_t Mask = 1234;
8157 uint32_t Index;
8158
8159 asm ("bsfl %[aMask], %[aIndex]"
8160 : [aIndex] "=r" (Index)
8161 : [aMask] "r" (Mask)
8162 : "cc");
8163 @end example
8164
8165 Here are some more examples of output operands.
8166
8167 @example
8168 uint32_t c = 1;
8169 uint32_t d;
8170 uint32_t *e = &c;
8171
8172 asm ("mov %[e], %[d]"
8173 : [d] "=rm" (d)
8174 : [e] "rm" (*e));
8175 @end example
8176
8177 Here, @code{d} may either be in a register or in memory. Since the compiler
8178 might already have the current value of the @code{uint32_t} location
8179 pointed to by @code{e}
8180 in a register, you can enable it to choose the best location
8181 for @code{d} by specifying both constraints.
8182
8183 @anchor{FlagOutputOperands}
8184 @subsubsection Flag Output Operands
8185 @cindex @code{asm} flag output operands
8186
8187 Some targets have a special register that holds the ``flags'' for the
8188 result of an operation or comparison. Normally, the contents of that
8189 register are either unmodifed by the asm, or the asm is considered to
8190 clobber the contents.
8191
8192 On some targets, a special form of output operand exists by which
8193 conditions in the flags register may be outputs of the asm. The set of
8194 conditions supported are target specific, but the general rule is that
8195 the output variable must be a scalar integer, and the value is boolean.
8196 When supported, the target defines the preprocessor symbol
8197 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8198
8199 Because of the special nature of the flag output operands, the constraint
8200 may not include alternatives.
8201
8202 Most often, the target has only one flags register, and thus is an implied
8203 operand of many instructions. In this case, the operand should not be
8204 referenced within the assembler template via @code{%0} etc, as there's
8205 no corresponding text in the assembly language.
8206
8207 @table @asis
8208 @item x86 family
8209 The flag output constraints for the x86 family are of the form
8210 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8211 conditions defined in the ISA manual for @code{j@var{cc}} or
8212 @code{set@var{cc}}.
8213
8214 @table @code
8215 @item a
8216 ``above'' or unsigned greater than
8217 @item ae
8218 ``above or equal'' or unsigned greater than or equal
8219 @item b
8220 ``below'' or unsigned less than
8221 @item be
8222 ``below or equal'' or unsigned less than or equal
8223 @item c
8224 carry flag set
8225 @item e
8226 @itemx z
8227 ``equal'' or zero flag set
8228 @item g
8229 signed greater than
8230 @item ge
8231 signed greater than or equal
8232 @item l
8233 signed less than
8234 @item le
8235 signed less than or equal
8236 @item o
8237 overflow flag set
8238 @item p
8239 parity flag set
8240 @item s
8241 sign flag set
8242 @item na
8243 @itemx nae
8244 @itemx nb
8245 @itemx nbe
8246 @itemx nc
8247 @itemx ne
8248 @itemx ng
8249 @itemx nge
8250 @itemx nl
8251 @itemx nle
8252 @itemx no
8253 @itemx np
8254 @itemx ns
8255 @itemx nz
8256 ``not'' @var{flag}, or inverted versions of those above
8257 @end table
8258
8259 @end table
8260
8261 @anchor{InputOperands}
8262 @subsubsection Input Operands
8263 @cindex @code{asm} input operands
8264 @cindex @code{asm} expressions
8265
8266 Input operands make values from C variables and expressions available to the
8267 assembly code.
8268
8269 Operands are separated by commas. Each operand has this format:
8270
8271 @example
8272 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8273 @end example
8274
8275 @table @var
8276 @item asmSymbolicName
8277 Specifies a symbolic name for the operand.
8278 Reference the name in the assembler template
8279 by enclosing it in square brackets
8280 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8281 that contains the definition. Any valid C variable name is acceptable,
8282 including names already defined in the surrounding code. No two operands
8283 within the same @code{asm} statement can use the same symbolic name.
8284
8285 When not using an @var{asmSymbolicName}, use the (zero-based) position
8286 of the operand
8287 in the list of operands in the assembler template. For example if there are
8288 two output operands and three inputs,
8289 use @samp{%2} in the template to refer to the first input operand,
8290 @samp{%3} for the second, and @samp{%4} for the third.
8291
8292 @item constraint
8293 A string constant specifying constraints on the placement of the operand;
8294 @xref{Constraints}, for details.
8295
8296 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8297 When you list more than one possible location (for example, @samp{"irm"}),
8298 the compiler chooses the most efficient one based on the current context.
8299 If you must use a specific register, but your Machine Constraints do not
8300 provide sufficient control to select the specific register you want,
8301 local register variables may provide a solution (@pxref{Local Register
8302 Variables}).
8303
8304 Input constraints can also be digits (for example, @code{"0"}). This indicates
8305 that the specified input must be in the same place as the output constraint
8306 at the (zero-based) index in the output constraint list.
8307 When using @var{asmSymbolicName} syntax for the output operands,
8308 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8309
8310 @item cexpression
8311 This is the C variable or expression being passed to the @code{asm} statement
8312 as input. The enclosing parentheses are a required part of the syntax.
8313
8314 @end table
8315
8316 When the compiler selects the registers to use to represent the input
8317 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8318
8319 If there are no output operands but there are input operands, place two
8320 consecutive colons where the output operands would go:
8321
8322 @example
8323 __asm__ ("some instructions"
8324 : /* No outputs. */
8325 : "r" (Offset / 8));
8326 @end example
8327
8328 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8329 (except for inputs tied to outputs). The compiler assumes that on exit from
8330 the @code{asm} statement these operands contain the same values as they
8331 had before executing the statement.
8332 It is @emph{not} possible to use clobbers
8333 to inform the compiler that the values in these inputs are changing. One
8334 common work-around is to tie the changing input variable to an output variable
8335 that never gets used. Note, however, that if the code that follows the
8336 @code{asm} statement makes no use of any of the output operands, the GCC
8337 optimizers may discard the @code{asm} statement as unneeded
8338 (see @ref{Volatile}).
8339
8340 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8341 instead of simply @samp{%2}). Typically these qualifiers are hardware
8342 dependent. The list of supported modifiers for x86 is found at
8343 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8344
8345 In this example using the fictitious @code{combine} instruction, the
8346 constraint @code{"0"} for input operand 1 says that it must occupy the same
8347 location as output operand 0. Only input operands may use numbers in
8348 constraints, and they must each refer to an output operand. Only a number (or
8349 the symbolic assembler name) in the constraint can guarantee that one operand
8350 is in the same place as another. The mere fact that @code{foo} is the value of
8351 both operands is not enough to guarantee that they are in the same place in
8352 the generated assembler code.
8353
8354 @example
8355 asm ("combine %2, %0"
8356 : "=r" (foo)
8357 : "0" (foo), "g" (bar));
8358 @end example
8359
8360 Here is an example using symbolic names.
8361
8362 @example
8363 asm ("cmoveq %1, %2, %[result]"
8364 : [result] "=r"(result)
8365 : "r" (test), "r" (new), "[result]" (old));
8366 @end example
8367
8368 @anchor{Clobbers}
8369 @subsubsection Clobbers
8370 @cindex @code{asm} clobbers
8371
8372 While the compiler is aware of changes to entries listed in the output
8373 operands, the inline @code{asm} code may modify more than just the outputs. For
8374 example, calculations may require additional registers, or the processor may
8375 overwrite a register as a side effect of a particular assembler instruction.
8376 In order to inform the compiler of these changes, list them in the clobber
8377 list. Clobber list items are either register names or the special clobbers
8378 (listed below). Each clobber list item is a string constant
8379 enclosed in double quotes and separated by commas.
8380
8381 Clobber descriptions may not in any way overlap with an input or output
8382 operand. For example, you may not have an operand describing a register class
8383 with one member when listing that register in the clobber list. Variables
8384 declared to live in specific registers (@pxref{Explicit Register
8385 Variables}) and used
8386 as @code{asm} input or output operands must have no part mentioned in the
8387 clobber description. In particular, there is no way to specify that input
8388 operands get modified without also specifying them as output operands.
8389
8390 When the compiler selects which registers to use to represent input and output
8391 operands, it does not use any of the clobbered registers. As a result,
8392 clobbered registers are available for any use in the assembler code.
8393
8394 Here is a realistic example for the VAX showing the use of clobbered
8395 registers:
8396
8397 @example
8398 asm volatile ("movc3 %0, %1, %2"
8399 : /* No outputs. */
8400 : "g" (from), "g" (to), "g" (count)
8401 : "r0", "r1", "r2", "r3", "r4", "r5");
8402 @end example
8403
8404 Also, there are two special clobber arguments:
8405
8406 @table @code
8407 @item "cc"
8408 The @code{"cc"} clobber indicates that the assembler code modifies the flags
8409 register. On some machines, GCC represents the condition codes as a specific
8410 hardware register; @code{"cc"} serves to name this register.
8411 On other machines, condition code handling is different,
8412 and specifying @code{"cc"} has no effect. But
8413 it is valid no matter what the target.
8414
8415 @item "memory"
8416 The @code{"memory"} clobber tells the compiler that the assembly code
8417 performs memory
8418 reads or writes to items other than those listed in the input and output
8419 operands (for example, accessing the memory pointed to by one of the input
8420 parameters). To ensure memory contains correct values, GCC may need to flush
8421 specific register values to memory before executing the @code{asm}. Further,
8422 the compiler does not assume that any values read from memory before an
8423 @code{asm} remain unchanged after that @code{asm}; it reloads them as
8424 needed.
8425 Using the @code{"memory"} clobber effectively forms a read/write
8426 memory barrier for the compiler.
8427
8428 Note that this clobber does not prevent the @emph{processor} from doing
8429 speculative reads past the @code{asm} statement. To prevent that, you need
8430 processor-specific fence instructions.
8431
8432 Flushing registers to memory has performance implications and may be an issue
8433 for time-sensitive code. You can use a trick to avoid this if the size of
8434 the memory being accessed is known at compile time. For example, if accessing
8435 ten bytes of a string, use a memory input like:
8436
8437 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8438
8439 @end table
8440
8441 @anchor{GotoLabels}
8442 @subsubsection Goto Labels
8443 @cindex @code{asm} goto labels
8444
8445 @code{asm goto} allows assembly code to jump to one or more C labels. The
8446 @var{GotoLabels} section in an @code{asm goto} statement contains
8447 a comma-separated
8448 list of all C labels to which the assembler code may jump. GCC assumes that
8449 @code{asm} execution falls through to the next statement (if this is not the
8450 case, consider using the @code{__builtin_unreachable} intrinsic after the
8451 @code{asm} statement). Optimization of @code{asm goto} may be improved by
8452 using the @code{hot} and @code{cold} label attributes (@pxref{Label
8453 Attributes}).
8454
8455 An @code{asm goto} statement cannot have outputs.
8456 This is due to an internal restriction of
8457 the compiler: control transfer instructions cannot have outputs.
8458 If the assembler code does modify anything, use the @code{"memory"} clobber
8459 to force the
8460 optimizers to flush all register values to memory and reload them if
8461 necessary after the @code{asm} statement.
8462
8463 Also note that an @code{asm goto} statement is always implicitly
8464 considered volatile.
8465
8466 To reference a label in the assembler template,
8467 prefix it with @samp{%l} (lowercase @samp{L}) followed
8468 by its (zero-based) position in @var{GotoLabels} plus the number of input
8469 operands. For example, if the @code{asm} has three inputs and references two
8470 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8471
8472 Alternately, you can reference labels using the actual C label name enclosed
8473 in brackets. For example, to reference a label named @code{carry}, you can
8474 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
8475 section when using this approach.
8476
8477 Here is an example of @code{asm goto} for i386:
8478
8479 @example
8480 asm goto (
8481 "btl %1, %0\n\t"
8482 "jc %l2"
8483 : /* No outputs. */
8484 : "r" (p1), "r" (p2)
8485 : "cc"
8486 : carry);
8487
8488 return 0;
8489
8490 carry:
8491 return 1;
8492 @end example
8493
8494 The following example shows an @code{asm goto} that uses a memory clobber.
8495
8496 @example
8497 int frob(int x)
8498 @{
8499 int y;
8500 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8501 : /* No outputs. */
8502 : "r"(x), "r"(&y)
8503 : "r5", "memory"
8504 : error);
8505 return y;
8506 error:
8507 return -1;
8508 @}
8509 @end example
8510
8511 @anchor{x86Operandmodifiers}
8512 @subsubsection x86 Operand Modifiers
8513
8514 References to input, output, and goto operands in the assembler template
8515 of extended @code{asm} statements can use
8516 modifiers to affect the way the operands are formatted in
8517 the code output to the assembler. For example, the
8518 following code uses the @samp{h} and @samp{b} modifiers for x86:
8519
8520 @example
8521 uint16_t num;
8522 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8523 @end example
8524
8525 @noindent
8526 These modifiers generate this assembler code:
8527
8528 @example
8529 xchg %ah, %al
8530 @end example
8531
8532 The rest of this discussion uses the following code for illustrative purposes.
8533
8534 @example
8535 int main()
8536 @{
8537 int iInt = 1;
8538
8539 top:
8540
8541 asm volatile goto ("some assembler instructions here"
8542 : /* No outputs. */
8543 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8544 : /* No clobbers. */
8545 : top);
8546 @}
8547 @end example
8548
8549 With no modifiers, this is what the output from the operands would be for the
8550 @samp{att} and @samp{intel} dialects of assembler:
8551
8552 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
8553 @headitem Operand @tab masm=att @tab masm=intel
8554 @item @code{%0}
8555 @tab @code{%eax}
8556 @tab @code{eax}
8557 @item @code{%1}
8558 @tab @code{$2}
8559 @tab @code{2}
8560 @item @code{%2}
8561 @tab @code{$.L2}
8562 @tab @code{OFFSET FLAT:.L2}
8563 @end multitable
8564
8565 The table below shows the list of supported modifiers and their effects.
8566
8567 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
8568 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
8569 @item @code{z}
8570 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8571 @tab @code{%z0}
8572 @tab @code{l}
8573 @tab
8574 @item @code{b}
8575 @tab Print the QImode name of the register.
8576 @tab @code{%b0}
8577 @tab @code{%al}
8578 @tab @code{al}
8579 @item @code{h}
8580 @tab Print the QImode name for a ``high'' register.
8581 @tab @code{%h0}
8582 @tab @code{%ah}
8583 @tab @code{ah}
8584 @item @code{w}
8585 @tab Print the HImode name of the register.
8586 @tab @code{%w0}
8587 @tab @code{%ax}
8588 @tab @code{ax}
8589 @item @code{k}
8590 @tab Print the SImode name of the register.
8591 @tab @code{%k0}
8592 @tab @code{%eax}
8593 @tab @code{eax}
8594 @item @code{q}
8595 @tab Print the DImode name of the register.
8596 @tab @code{%q0}
8597 @tab @code{%rax}
8598 @tab @code{rax}
8599 @item @code{l}
8600 @tab Print the label name with no punctuation.
8601 @tab @code{%l2}
8602 @tab @code{.L2}
8603 @tab @code{.L2}
8604 @item @code{c}
8605 @tab Require a constant operand and print the constant expression with no punctuation.
8606 @tab @code{%c1}
8607 @tab @code{2}
8608 @tab @code{2}
8609 @end multitable
8610
8611 @anchor{x86floatingpointasmoperands}
8612 @subsubsection x86 Floating-Point @code{asm} Operands
8613
8614 On x86 targets, there are several rules on the usage of stack-like registers
8615 in the operands of an @code{asm}. These rules apply only to the operands
8616 that are stack-like registers:
8617
8618 @enumerate
8619 @item
8620 Given a set of input registers that die in an @code{asm}, it is
8621 necessary to know which are implicitly popped by the @code{asm}, and
8622 which must be explicitly popped by GCC@.
8623
8624 An input register that is implicitly popped by the @code{asm} must be
8625 explicitly clobbered, unless it is constrained to match an
8626 output operand.
8627
8628 @item
8629 For any input register that is implicitly popped by an @code{asm}, it is
8630 necessary to know how to adjust the stack to compensate for the pop.
8631 If any non-popped input is closer to the top of the reg-stack than
8632 the implicitly popped register, it would not be possible to know what the
8633 stack looked like---it's not clear how the rest of the stack ``slides
8634 up''.
8635
8636 All implicitly popped input registers must be closer to the top of
8637 the reg-stack than any input that is not implicitly popped.
8638
8639 It is possible that if an input dies in an @code{asm}, the compiler might
8640 use the input register for an output reload. Consider this example:
8641
8642 @smallexample
8643 asm ("foo" : "=t" (a) : "f" (b));
8644 @end smallexample
8645
8646 @noindent
8647 This code says that input @code{b} is not popped by the @code{asm}, and that
8648 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8649 deeper after the @code{asm} than it was before. But, it is possible that
8650 reload may think that it can use the same register for both the input and
8651 the output.
8652
8653 To prevent this from happening,
8654 if any input operand uses the @samp{f} constraint, all output register
8655 constraints must use the @samp{&} early-clobber modifier.
8656
8657 The example above is correctly written as:
8658
8659 @smallexample
8660 asm ("foo" : "=&t" (a) : "f" (b));
8661 @end smallexample
8662
8663 @item
8664 Some operands need to be in particular places on the stack. All
8665 output operands fall in this category---GCC has no other way to
8666 know which registers the outputs appear in unless you indicate
8667 this in the constraints.
8668
8669 Output operands must specifically indicate which register an output
8670 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
8671 constraints must select a class with a single register.
8672
8673 @item
8674 Output operands may not be ``inserted'' between existing stack registers.
8675 Since no 387 opcode uses a read/write operand, all output operands
8676 are dead before the @code{asm}, and are pushed by the @code{asm}.
8677 It makes no sense to push anywhere but the top of the reg-stack.
8678
8679 Output operands must start at the top of the reg-stack: output
8680 operands may not ``skip'' a register.
8681
8682 @item
8683 Some @code{asm} statements may need extra stack space for internal
8684 calculations. This can be guaranteed by clobbering stack registers
8685 unrelated to the inputs and outputs.
8686
8687 @end enumerate
8688
8689 This @code{asm}
8690 takes one input, which is internally popped, and produces two outputs.
8691
8692 @smallexample
8693 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8694 @end smallexample
8695
8696 @noindent
8697 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8698 and replaces them with one output. The @code{st(1)} clobber is necessary
8699 for the compiler to know that @code{fyl2xp1} pops both inputs.
8700
8701 @smallexample
8702 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8703 @end smallexample
8704
8705 @lowersections
8706 @include md.texi
8707 @raisesections
8708
8709 @node Asm Labels
8710 @subsection Controlling Names Used in Assembler Code
8711 @cindex assembler names for identifiers
8712 @cindex names used in assembler code
8713 @cindex identifiers, names in assembler code
8714
8715 You can specify the name to be used in the assembler code for a C
8716 function or variable by writing the @code{asm} (or @code{__asm__})
8717 keyword after the declarator.
8718 It is up to you to make sure that the assembler names you choose do not
8719 conflict with any other assembler symbols, or reference registers.
8720
8721 @subsubheading Assembler names for data:
8722
8723 This sample shows how to specify the assembler name for data:
8724
8725 @smallexample
8726 int foo asm ("myfoo") = 2;
8727 @end smallexample
8728
8729 @noindent
8730 This specifies that the name to be used for the variable @code{foo} in
8731 the assembler code should be @samp{myfoo} rather than the usual
8732 @samp{_foo}.
8733
8734 On systems where an underscore is normally prepended to the name of a C
8735 variable, this feature allows you to define names for the
8736 linker that do not start with an underscore.
8737
8738 GCC does not support using this feature with a non-static local variable
8739 since such variables do not have assembler names. If you are
8740 trying to put the variable in a particular register, see
8741 @ref{Explicit Register Variables}.
8742
8743 @subsubheading Assembler names for functions:
8744
8745 To specify the assembler name for functions, write a declaration for the
8746 function before its definition and put @code{asm} there, like this:
8747
8748 @smallexample
8749 int func (int x, int y) asm ("MYFUNC");
8750
8751 int func (int x, int y)
8752 @{
8753 /* @r{@dots{}} */
8754 @end smallexample
8755
8756 @noindent
8757 This specifies that the name to be used for the function @code{func} in
8758 the assembler code should be @code{MYFUNC}.
8759
8760 @node Explicit Register Variables
8761 @subsection Variables in Specified Registers
8762 @anchor{Explicit Reg Vars}
8763 @cindex explicit register variables
8764 @cindex variables in specified registers
8765 @cindex specified registers
8766
8767 GNU C allows you to associate specific hardware registers with C
8768 variables. In almost all cases, allowing the compiler to assign
8769 registers produces the best code. However under certain unusual
8770 circumstances, more precise control over the variable storage is
8771 required.
8772
8773 Both global and local variables can be associated with a register. The
8774 consequences of performing this association are very different between
8775 the two, as explained in the sections below.
8776
8777 @menu
8778 * Global Register Variables:: Variables declared at global scope.
8779 * Local Register Variables:: Variables declared within a function.
8780 @end menu
8781
8782 @node Global Register Variables
8783 @subsubsection Defining Global Register Variables
8784 @anchor{Global Reg Vars}
8785 @cindex global register variables
8786 @cindex registers, global variables in
8787 @cindex registers, global allocation
8788
8789 You can define a global register variable and associate it with a specified
8790 register like this:
8791
8792 @smallexample
8793 register int *foo asm ("r12");
8794 @end smallexample
8795
8796 @noindent
8797 Here @code{r12} is the name of the register that should be used. Note that
8798 this is the same syntax used for defining local register variables, but for
8799 a global variable the declaration appears outside a function. The
8800 @code{register} keyword is required, and cannot be combined with
8801 @code{static}. The register name must be a valid register name for the
8802 target platform.
8803
8804 Registers are a scarce resource on most systems and allowing the
8805 compiler to manage their usage usually results in the best code. However,
8806 under special circumstances it can make sense to reserve some globally.
8807 For example this may be useful in programs such as programming language
8808 interpreters that have a couple of global variables that are accessed
8809 very often.
8810
8811 After defining a global register variable, for the current compilation
8812 unit:
8813
8814 @itemize @bullet
8815 @item The register is reserved entirely for this use, and will not be
8816 allocated for any other purpose.
8817 @item The register is not saved and restored by any functions.
8818 @item Stores into this register are never deleted even if they appear to be
8819 dead, but references may be deleted, moved or simplified.
8820 @end itemize
8821
8822 Note that these points @emph{only} apply to code that is compiled with the
8823 definition. The behavior of code that is merely linked in (for example
8824 code from libraries) is not affected.
8825
8826 If you want to recompile source files that do not actually use your global
8827 register variable so they do not use the specified register for any other
8828 purpose, you need not actually add the global register declaration to
8829 their source code. It suffices to specify the compiler option
8830 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
8831 register.
8832
8833 @subsubheading Declaring the variable
8834
8835 Global register variables can not have initial values, because an
8836 executable file has no means to supply initial contents for a register.
8837
8838 When selecting a register, choose one that is normally saved and
8839 restored by function calls on your machine. This ensures that code
8840 which is unaware of this reservation (such as library routines) will
8841 restore it before returning.
8842
8843 On machines with register windows, be sure to choose a global
8844 register that is not affected magically by the function call mechanism.
8845
8846 @subsubheading Using the variable
8847
8848 @cindex @code{qsort}, and global register variables
8849 When calling routines that are not aware of the reservation, be
8850 cautious if those routines call back into code which uses them. As an
8851 example, if you call the system library version of @code{qsort}, it may
8852 clobber your registers during execution, but (if you have selected
8853 appropriate registers) it will restore them before returning. However
8854 it will @emph{not} restore them before calling @code{qsort}'s comparison
8855 function. As a result, global values will not reliably be available to
8856 the comparison function unless the @code{qsort} function itself is rebuilt.
8857
8858 Similarly, it is not safe to access the global register variables from signal
8859 handlers or from more than one thread of control. Unless you recompile
8860 them specially for the task at hand, the system library routines may
8861 temporarily use the register for other things.
8862
8863 @cindex register variable after @code{longjmp}
8864 @cindex global register after @code{longjmp}
8865 @cindex value after @code{longjmp}
8866 @findex longjmp
8867 @findex setjmp
8868 On most machines, @code{longjmp} restores to each global register
8869 variable the value it had at the time of the @code{setjmp}. On some
8870 machines, however, @code{longjmp} does not change the value of global
8871 register variables. To be portable, the function that called @code{setjmp}
8872 should make other arrangements to save the values of the global register
8873 variables, and to restore them in a @code{longjmp}. This way, the same
8874 thing happens regardless of what @code{longjmp} does.
8875
8876 Eventually there may be a way of asking the compiler to choose a register
8877 automatically, but first we need to figure out how it should choose and
8878 how to enable you to guide the choice. No solution is evident.
8879
8880 @node Local Register Variables
8881 @subsubsection Specifying Registers for Local Variables
8882 @anchor{Local Reg Vars}
8883 @cindex local variables, specifying registers
8884 @cindex specifying registers for local variables
8885 @cindex registers for local variables
8886
8887 You can define a local register variable and associate it with a specified
8888 register like this:
8889
8890 @smallexample
8891 register int *foo asm ("r12");
8892 @end smallexample
8893
8894 @noindent
8895 Here @code{r12} is the name of the register that should be used. Note
8896 that this is the same syntax used for defining global register variables,
8897 but for a local variable the declaration appears within a function. The
8898 @code{register} keyword is required, and cannot be combined with
8899 @code{static}. The register name must be a valid register name for the
8900 target platform.
8901
8902 As with global register variables, it is recommended that you choose
8903 a register that is normally saved and restored by function calls on your
8904 machine, so that calls to library routines will not clobber it.
8905
8906 The only supported use for this feature is to specify registers
8907 for input and output operands when calling Extended @code{asm}
8908 (@pxref{Extended Asm}). This may be necessary if the constraints for a
8909 particular machine don't provide sufficient control to select the desired
8910 register. To force an operand into a register, create a local variable
8911 and specify the register name after the variable's declaration. Then use
8912 the local variable for the @code{asm} operand and specify any constraint
8913 letter that matches the register:
8914
8915 @smallexample
8916 register int *p1 asm ("r0") = @dots{};
8917 register int *p2 asm ("r1") = @dots{};
8918 register int *result asm ("r0");
8919 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8920 @end smallexample
8921
8922 @emph{Warning:} In the above example, be aware that a register (for example
8923 @code{r0}) can be call-clobbered by subsequent code, including function
8924 calls and library calls for arithmetic operators on other variables (for
8925 example the initialization of @code{p2}). In this case, use temporary
8926 variables for expressions between the register assignments:
8927
8928 @smallexample
8929 int t1 = @dots{};
8930 register int *p1 asm ("r0") = @dots{};
8931 register int *p2 asm ("r1") = t1;
8932 register int *result asm ("r0");
8933 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8934 @end smallexample
8935
8936 Defining a register variable does not reserve the register. Other than
8937 when invoking the Extended @code{asm}, the contents of the specified
8938 register are not guaranteed. For this reason, the following uses
8939 are explicitly @emph{not} supported. If they appear to work, it is only
8940 happenstance, and may stop working as intended due to (seemingly)
8941 unrelated changes in surrounding code, or even minor changes in the
8942 optimization of a future version of gcc:
8943
8944 @itemize @bullet
8945 @item Passing parameters to or from Basic @code{asm}
8946 @item Passing parameters to or from Extended @code{asm} without using input
8947 or output operands.
8948 @item Passing parameters to or from routines written in assembler (or
8949 other languages) using non-standard calling conventions.
8950 @end itemize
8951
8952 Some developers use Local Register Variables in an attempt to improve
8953 gcc's allocation of registers, especially in large functions. In this
8954 case the register name is essentially a hint to the register allocator.
8955 While in some instances this can generate better code, improvements are
8956 subject to the whims of the allocator/optimizers. Since there are no
8957 guarantees that your improvements won't be lost, this usage of Local
8958 Register Variables is discouraged.
8959
8960 On the MIPS platform, there is related use for local register variables
8961 with slightly different characteristics (@pxref{MIPS Coprocessors,,
8962 Defining coprocessor specifics for MIPS targets, gccint,
8963 GNU Compiler Collection (GCC) Internals}).
8964
8965 @node Size of an asm
8966 @subsection Size of an @code{asm}
8967
8968 Some targets require that GCC track the size of each instruction used
8969 in order to generate correct code. Because the final length of the
8970 code produced by an @code{asm} statement is only known by the
8971 assembler, GCC must make an estimate as to how big it will be. It
8972 does this by counting the number of instructions in the pattern of the
8973 @code{asm} and multiplying that by the length of the longest
8974 instruction supported by that processor. (When working out the number
8975 of instructions, it assumes that any occurrence of a newline or of
8976 whatever statement separator character is supported by the assembler --
8977 typically @samp{;} --- indicates the end of an instruction.)
8978
8979 Normally, GCC's estimate is adequate to ensure that correct
8980 code is generated, but it is possible to confuse the compiler if you use
8981 pseudo instructions or assembler macros that expand into multiple real
8982 instructions, or if you use assembler directives that expand to more
8983 space in the object file than is needed for a single instruction.
8984 If this happens then the assembler may produce a diagnostic saying that
8985 a label is unreachable.
8986
8987 @node Alternate Keywords
8988 @section Alternate Keywords
8989 @cindex alternate keywords
8990 @cindex keywords, alternate
8991
8992 @option{-ansi} and the various @option{-std} options disable certain
8993 keywords. This causes trouble when you want to use GNU C extensions, or
8994 a general-purpose header file that should be usable by all programs,
8995 including ISO C programs. The keywords @code{asm}, @code{typeof} and
8996 @code{inline} are not available in programs compiled with
8997 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
8998 program compiled with @option{-std=c99} or @option{-std=c11}). The
8999 ISO C99 keyword
9000 @code{restrict} is only available when @option{-std=gnu99} (which will
9001 eventually be the default) or @option{-std=c99} (or the equivalent
9002 @option{-std=iso9899:1999}), or an option for a later standard
9003 version, is used.
9004
9005 The way to solve these problems is to put @samp{__} at the beginning and
9006 end of each problematical keyword. For example, use @code{__asm__}
9007 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9008
9009 Other C compilers won't accept these alternative keywords; if you want to
9010 compile with another compiler, you can define the alternate keywords as
9011 macros to replace them with the customary keywords. It looks like this:
9012
9013 @smallexample
9014 #ifndef __GNUC__
9015 #define __asm__ asm
9016 #endif
9017 @end smallexample
9018
9019 @findex __extension__
9020 @opindex pedantic
9021 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9022 You can
9023 prevent such warnings within one expression by writing
9024 @code{__extension__} before the expression. @code{__extension__} has no
9025 effect aside from this.
9026
9027 @node Incomplete Enums
9028 @section Incomplete @code{enum} Types
9029
9030 You can define an @code{enum} tag without specifying its possible values.
9031 This results in an incomplete type, much like what you get if you write
9032 @code{struct foo} without describing the elements. A later declaration
9033 that does specify the possible values completes the type.
9034
9035 You can't allocate variables or storage using the type while it is
9036 incomplete. However, you can work with pointers to that type.
9037
9038 This extension may not be very useful, but it makes the handling of
9039 @code{enum} more consistent with the way @code{struct} and @code{union}
9040 are handled.
9041
9042 This extension is not supported by GNU C++.
9043
9044 @node Function Names
9045 @section Function Names as Strings
9046 @cindex @code{__func__} identifier
9047 @cindex @code{__FUNCTION__} identifier
9048 @cindex @code{__PRETTY_FUNCTION__} identifier
9049
9050 GCC provides three magic constants that hold the name of the current
9051 function as a string. In C++11 and later modes, all three are treated
9052 as constant expressions and can be used in @code{constexpr} constexts.
9053 The first of these constants is @code{__func__}, which is part of
9054 the C99 standard:
9055
9056 The identifier @code{__func__} is implicitly declared by the translator
9057 as if, immediately following the opening brace of each function
9058 definition, the declaration
9059
9060 @smallexample
9061 static const char __func__[] = "function-name";
9062 @end smallexample
9063
9064 @noindent
9065 appeared, where function-name is the name of the lexically-enclosing
9066 function. This name is the unadorned name of the function. As an
9067 extension, at file (or, in C++, namespace scope), @code{__func__}
9068 evaluates to the empty string.
9069
9070 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9071 backward compatibility with old versions of GCC.
9072
9073 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9074 @code{__func__}, except that at file (or, in C++, namespace scope),
9075 it evaluates to the string @code{"top level"}. In addition, in C++,
9076 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9077 well as its bare name. For example, this program:
9078
9079 @smallexample
9080 extern "C" int printf (const char *, ...);
9081
9082 class a @{
9083 public:
9084 void sub (int i)
9085 @{
9086 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9087 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9088 @}
9089 @};
9090
9091 int
9092 main (void)
9093 @{
9094 a ax;
9095 ax.sub (0);
9096 return 0;
9097 @}
9098 @end smallexample
9099
9100 @noindent
9101 gives this output:
9102
9103 @smallexample
9104 __FUNCTION__ = sub
9105 __PRETTY_FUNCTION__ = void a::sub(int)
9106 @end smallexample
9107
9108 These identifiers are variables, not preprocessor macros, and may not
9109 be used to initialize @code{char} arrays or be concatenated with string
9110 literals.
9111
9112 @node Return Address
9113 @section Getting the Return or Frame Address of a Function
9114
9115 These functions may be used to get information about the callers of a
9116 function.
9117
9118 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9119 This function returns the return address of the current function, or of
9120 one of its callers. The @var{level} argument is number of frames to
9121 scan up the call stack. A value of @code{0} yields the return address
9122 of the current function, a value of @code{1} yields the return address
9123 of the caller of the current function, and so forth. When inlining
9124 the expected behavior is that the function returns the address of
9125 the function that is returned to. To work around this behavior use
9126 the @code{noinline} function attribute.
9127
9128 The @var{level} argument must be a constant integer.
9129
9130 On some machines it may be impossible to determine the return address of
9131 any function other than the current one; in such cases, or when the top
9132 of the stack has been reached, this function returns @code{0} or a
9133 random value. In addition, @code{__builtin_frame_address} may be used
9134 to determine if the top of the stack has been reached.
9135
9136 Additional post-processing of the returned value may be needed, see
9137 @code{__builtin_extract_return_addr}.
9138
9139 Calling this function with a nonzero argument can have unpredictable
9140 effects, including crashing the calling program. As a result, calls
9141 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9142 option is in effect. Such calls should only be made in debugging
9143 situations.
9144 @end deftypefn
9145
9146 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9147 The address as returned by @code{__builtin_return_address} may have to be fed
9148 through this function to get the actual encoded address. For example, on the
9149 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9150 platforms an offset has to be added for the true next instruction to be
9151 executed.
9152
9153 If no fixup is needed, this function simply passes through @var{addr}.
9154 @end deftypefn
9155
9156 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9157 This function does the reverse of @code{__builtin_extract_return_addr}.
9158 @end deftypefn
9159
9160 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9161 This function is similar to @code{__builtin_return_address}, but it
9162 returns the address of the function frame rather than the return address
9163 of the function. Calling @code{__builtin_frame_address} with a value of
9164 @code{0} yields the frame address of the current function, a value of
9165 @code{1} yields the frame address of the caller of the current function,
9166 and so forth.
9167
9168 The frame is the area on the stack that holds local variables and saved
9169 registers. The frame address is normally the address of the first word
9170 pushed on to the stack by the function. However, the exact definition
9171 depends upon the processor and the calling convention. If the processor
9172 has a dedicated frame pointer register, and the function has a frame,
9173 then @code{__builtin_frame_address} returns the value of the frame
9174 pointer register.
9175
9176 On some machines it may be impossible to determine the frame address of
9177 any function other than the current one; in such cases, or when the top
9178 of the stack has been reached, this function returns @code{0} if
9179 the first frame pointer is properly initialized by the startup code.
9180
9181 Calling this function with a nonzero argument can have unpredictable
9182 effects, including crashing the calling program. As a result, calls
9183 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9184 option is in effect. Such calls should only be made in debugging
9185 situations.
9186 @end deftypefn
9187
9188 @node Vector Extensions
9189 @section Using Vector Instructions through Built-in Functions
9190
9191 On some targets, the instruction set contains SIMD vector instructions which
9192 operate on multiple values contained in one large register at the same time.
9193 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9194 this way.
9195
9196 The first step in using these extensions is to provide the necessary data
9197 types. This should be done using an appropriate @code{typedef}:
9198
9199 @smallexample
9200 typedef int v4si __attribute__ ((vector_size (16)));
9201 @end smallexample
9202
9203 @noindent
9204 The @code{int} type specifies the base type, while the attribute specifies
9205 the vector size for the variable, measured in bytes. For example, the
9206 declaration above causes the compiler to set the mode for the @code{v4si}
9207 type to be 16 bytes wide and divided into @code{int} sized units. For
9208 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9209 corresponding mode of @code{foo} is @acronym{V4SI}.
9210
9211 The @code{vector_size} attribute is only applicable to integral and
9212 float scalars, although arrays, pointers, and function return values
9213 are allowed in conjunction with this construct. Only sizes that are
9214 a power of two are currently allowed.
9215
9216 All the basic integer types can be used as base types, both as signed
9217 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9218 @code{long long}. In addition, @code{float} and @code{double} can be
9219 used to build floating-point vector types.
9220
9221 Specifying a combination that is not valid for the current architecture
9222 causes GCC to synthesize the instructions using a narrower mode.
9223 For example, if you specify a variable of type @code{V4SI} and your
9224 architecture does not allow for this specific SIMD type, GCC
9225 produces code that uses 4 @code{SIs}.
9226
9227 The types defined in this manner can be used with a subset of normal C
9228 operations. Currently, GCC allows using the following operators
9229 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9230
9231 The operations behave like C++ @code{valarrays}. Addition is defined as
9232 the addition of the corresponding elements of the operands. For
9233 example, in the code below, each of the 4 elements in @var{a} is
9234 added to the corresponding 4 elements in @var{b} and the resulting
9235 vector is stored in @var{c}.
9236
9237 @smallexample
9238 typedef int v4si __attribute__ ((vector_size (16)));
9239
9240 v4si a, b, c;
9241
9242 c = a + b;
9243 @end smallexample
9244
9245 Subtraction, multiplication, division, and the logical operations
9246 operate in a similar manner. Likewise, the result of using the unary
9247 minus or complement operators on a vector type is a vector whose
9248 elements are the negative or complemented values of the corresponding
9249 elements in the operand.
9250
9251 It is possible to use shifting operators @code{<<}, @code{>>} on
9252 integer-type vectors. The operation is defined as following: @code{@{a0,
9253 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9254 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9255 elements.
9256
9257 For convenience, it is allowed to use a binary vector operation
9258 where one operand is a scalar. In that case the compiler transforms
9259 the scalar operand into a vector where each element is the scalar from
9260 the operation. The transformation happens only if the scalar could be
9261 safely converted to the vector-element type.
9262 Consider the following code.
9263
9264 @smallexample
9265 typedef int v4si __attribute__ ((vector_size (16)));
9266
9267 v4si a, b, c;
9268 long l;
9269
9270 a = b + 1; /* a = b + @{1,1,1,1@}; */
9271 a = 2 * b; /* a = @{2,2,2,2@} * b; */
9272
9273 a = l + a; /* Error, cannot convert long to int. */
9274 @end smallexample
9275
9276 Vectors can be subscripted as if the vector were an array with
9277 the same number of elements and base type. Out of bound accesses
9278 invoke undefined behavior at run time. Warnings for out of bound
9279 accesses for vector subscription can be enabled with
9280 @option{-Warray-bounds}.
9281
9282 Vector comparison is supported with standard comparison
9283 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9284 vector expressions of integer-type or real-type. Comparison between
9285 integer-type vectors and real-type vectors are not supported. The
9286 result of the comparison is a vector of the same width and number of
9287 elements as the comparison operands with a signed integral element
9288 type.
9289
9290 Vectors are compared element-wise producing 0 when comparison is false
9291 and -1 (constant of the appropriate type where all bits are set)
9292 otherwise. Consider the following example.
9293
9294 @smallexample
9295 typedef int v4si __attribute__ ((vector_size (16)));
9296
9297 v4si a = @{1,2,3,4@};
9298 v4si b = @{3,2,1,4@};
9299 v4si c;
9300
9301 c = a > b; /* The result would be @{0, 0,-1, 0@} */
9302 c = a == b; /* The result would be @{0,-1, 0,-1@} */
9303 @end smallexample
9304
9305 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9306 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9307 integer vector with the same number of elements of the same size as @code{b}
9308 and @code{c}, computes all three arguments and creates a vector
9309 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
9310 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9311 As in the case of binary operations, this syntax is also accepted when
9312 one of @code{b} or @code{c} is a scalar that is then transformed into a
9313 vector. If both @code{b} and @code{c} are scalars and the type of
9314 @code{true?b:c} has the same size as the element type of @code{a}, then
9315 @code{b} and @code{c} are converted to a vector type whose elements have
9316 this type and with the same number of elements as @code{a}.
9317
9318 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9319 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9320 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9321 For mixed operations between a scalar @code{s} and a vector @code{v},
9322 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9323 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9324
9325 Vector shuffling is available using functions
9326 @code{__builtin_shuffle (vec, mask)} and
9327 @code{__builtin_shuffle (vec0, vec1, mask)}.
9328 Both functions construct a permutation of elements from one or two
9329 vectors and return a vector of the same type as the input vector(s).
9330 The @var{mask} is an integral vector with the same width (@var{W})
9331 and element count (@var{N}) as the output vector.
9332
9333 The elements of the input vectors are numbered in memory ordering of
9334 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
9335 elements of @var{mask} are considered modulo @var{N} in the single-operand
9336 case and modulo @math{2*@var{N}} in the two-operand case.
9337
9338 Consider the following example,
9339
9340 @smallexample
9341 typedef int v4si __attribute__ ((vector_size (16)));
9342
9343 v4si a = @{1,2,3,4@};
9344 v4si b = @{5,6,7,8@};
9345 v4si mask1 = @{0,1,1,3@};
9346 v4si mask2 = @{0,4,2,5@};
9347 v4si res;
9348
9349 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
9350 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
9351 @end smallexample
9352
9353 Note that @code{__builtin_shuffle} is intentionally semantically
9354 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9355
9356 You can declare variables and use them in function calls and returns, as
9357 well as in assignments and some casts. You can specify a vector type as
9358 a return type for a function. Vector types can also be used as function
9359 arguments. It is possible to cast from one vector type to another,
9360 provided they are of the same size (in fact, you can also cast vectors
9361 to and from other datatypes of the same size).
9362
9363 You cannot operate between vectors of different lengths or different
9364 signedness without a cast.
9365
9366 @node Offsetof
9367 @section Support for @code{offsetof}
9368 @findex __builtin_offsetof
9369
9370 GCC implements for both C and C++ a syntactic extension to implement
9371 the @code{offsetof} macro.
9372
9373 @smallexample
9374 primary:
9375 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9376
9377 offsetof_member_designator:
9378 @code{identifier}
9379 | offsetof_member_designator "." @code{identifier}
9380 | offsetof_member_designator "[" @code{expr} "]"
9381 @end smallexample
9382
9383 This extension is sufficient such that
9384
9385 @smallexample
9386 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
9387 @end smallexample
9388
9389 @noindent
9390 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
9391 may be dependent. In either case, @var{member} may consist of a single
9392 identifier, or a sequence of member accesses and array references.
9393
9394 @node __sync Builtins
9395 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9396
9397 The following built-in functions
9398 are intended to be compatible with those described
9399 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9400 section 7.4. As such, they depart from normal GCC practice by not using
9401 the @samp{__builtin_} prefix and also by being overloaded so that they
9402 work on multiple types.
9403
9404 The definition given in the Intel documentation allows only for the use of
9405 the types @code{int}, @code{long}, @code{long long} or their unsigned
9406 counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
9407 size other than the C type @code{_Bool} or the C++ type @code{bool}.
9408 Operations on pointer arguments are performed as if the operands were
9409 of the @code{uintptr_t} type. That is, they are not scaled by the size
9410 of the type to which the pointer points.
9411
9412 These functions are implemented in terms of the @samp{__atomic}
9413 builtins (@pxref{__atomic Builtins}). They should not be used for new
9414 code which should use the @samp{__atomic} builtins instead.
9415
9416 Not all operations are supported by all target processors. If a particular
9417 operation cannot be implemented on the target processor, a warning is
9418 generated and a call to an external function is generated. The external
9419 function carries the same name as the built-in version,
9420 with an additional suffix
9421 @samp{_@var{n}} where @var{n} is the size of the data type.
9422
9423 @c ??? Should we have a mechanism to suppress this warning? This is almost
9424 @c useful for implementing the operation under the control of an external
9425 @c mutex.
9426
9427 In most cases, these built-in functions are considered a @dfn{full barrier}.
9428 That is,
9429 no memory operand is moved across the operation, either forward or
9430 backward. Further, instructions are issued as necessary to prevent the
9431 processor from speculating loads across the operation and from queuing stores
9432 after the operation.
9433
9434 All of the routines are described in the Intel documentation to take
9435 ``an optional list of variables protected by the memory barrier''. It's
9436 not clear what is meant by that; it could mean that @emph{only} the
9437 listed variables are protected, or it could mean a list of additional
9438 variables to be protected. The list is ignored by GCC which treats it as
9439 empty. GCC interprets an empty list as meaning that all globally
9440 accessible variables should be protected.
9441
9442 @table @code
9443 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9444 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9445 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9446 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9447 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9448 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9449 @findex __sync_fetch_and_add
9450 @findex __sync_fetch_and_sub
9451 @findex __sync_fetch_and_or
9452 @findex __sync_fetch_and_and
9453 @findex __sync_fetch_and_xor
9454 @findex __sync_fetch_and_nand
9455 These built-in functions perform the operation suggested by the name, and
9456 returns the value that had previously been in memory. That is, operations
9457 on integer operands have the following semantics. Operations on pointer
9458 arguments are performed as if the operands were of the @code{uintptr_t}
9459 type. That is, they are not scaled by the size of the type to which
9460 the pointer points.
9461
9462 @smallexample
9463 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9464 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
9465 @end smallexample
9466
9467 The object pointed to by the first argument must be of integer or pointer
9468 type. It must not be a Boolean type.
9469
9470 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9471 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9472
9473 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9474 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9475 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9476 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9477 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9478 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9479 @findex __sync_add_and_fetch
9480 @findex __sync_sub_and_fetch
9481 @findex __sync_or_and_fetch
9482 @findex __sync_and_and_fetch
9483 @findex __sync_xor_and_fetch
9484 @findex __sync_nand_and_fetch
9485 These built-in functions perform the operation suggested by the name, and
9486 return the new value. That is, operations on integer operands have
9487 the following semantics. Operations on pointer operands are performed as
9488 if the operand's type were @code{uintptr_t}.
9489
9490 @smallexample
9491 @{ *ptr @var{op}= value; return *ptr; @}
9492 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
9493 @end smallexample
9494
9495 The same constraints on arguments apply as for the corresponding
9496 @code{__sync_op_and_fetch} built-in functions.
9497
9498 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9499 as @code{*ptr = ~(*ptr & value)} instead of
9500 @code{*ptr = ~*ptr & value}.
9501
9502 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9503 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9504 @findex __sync_bool_compare_and_swap
9505 @findex __sync_val_compare_and_swap
9506 These built-in functions perform an atomic compare and swap.
9507 That is, if the current
9508 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9509 @code{*@var{ptr}}.
9510
9511 The ``bool'' version returns true if the comparison is successful and
9512 @var{newval} is written. The ``val'' version returns the contents
9513 of @code{*@var{ptr}} before the operation.
9514
9515 @item __sync_synchronize (...)
9516 @findex __sync_synchronize
9517 This built-in function issues a full memory barrier.
9518
9519 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9520 @findex __sync_lock_test_and_set
9521 This built-in function, as described by Intel, is not a traditional test-and-set
9522 operation, but rather an atomic exchange operation. It writes @var{value}
9523 into @code{*@var{ptr}}, and returns the previous contents of
9524 @code{*@var{ptr}}.
9525
9526 Many targets have only minimal support for such locks, and do not support
9527 a full exchange operation. In this case, a target may support reduced
9528 functionality here by which the @emph{only} valid value to store is the
9529 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
9530 is implementation defined.
9531
9532 This built-in function is not a full barrier,
9533 but rather an @dfn{acquire barrier}.
9534 This means that references after the operation cannot move to (or be
9535 speculated to) before the operation, but previous memory stores may not
9536 be globally visible yet, and previous memory loads may not yet be
9537 satisfied.
9538
9539 @item void __sync_lock_release (@var{type} *ptr, ...)
9540 @findex __sync_lock_release
9541 This built-in function releases the lock acquired by
9542 @code{__sync_lock_test_and_set}.
9543 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9544
9545 This built-in function is not a full barrier,
9546 but rather a @dfn{release barrier}.
9547 This means that all previous memory stores are globally visible, and all
9548 previous memory loads have been satisfied, but following memory reads
9549 are not prevented from being speculated to before the barrier.
9550 @end table
9551
9552 @node __atomic Builtins
9553 @section Built-in Functions for Memory Model Aware Atomic Operations
9554
9555 The following built-in functions approximately match the requirements
9556 for the C++11 memory model. They are all
9557 identified by being prefixed with @samp{__atomic} and most are
9558 overloaded so that they work with multiple types.
9559
9560 These functions are intended to replace the legacy @samp{__sync}
9561 builtins. The main difference is that the memory order that is requested
9562 is a parameter to the functions. New code should always use the
9563 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9564
9565 Note that the @samp{__atomic} builtins assume that programs will
9566 conform to the C++11 memory model. In particular, they assume
9567 that programs are free of data races. See the C++11 standard for
9568 detailed requirements.
9569
9570 The @samp{__atomic} builtins can be used with any integral scalar or
9571 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
9572 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9573 supported by the architecture.
9574
9575 The four non-arithmetic functions (load, store, exchange, and
9576 compare_exchange) all have a generic version as well. This generic
9577 version works on any data type. It uses the lock-free built-in function
9578 if the specific data type size makes that possible; otherwise, an
9579 external call is left to be resolved at run time. This external call is
9580 the same format with the addition of a @samp{size_t} parameter inserted
9581 as the first parameter indicating the size of the object being pointed to.
9582 All objects must be the same size.
9583
9584 There are 6 different memory orders that can be specified. These map
9585 to the C++11 memory orders with the same names, see the C++11 standard
9586 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9587 on atomic synchronization} for detailed definitions. Individual
9588 targets may also support additional memory orders for use on specific
9589 architectures. Refer to the target documentation for details of
9590 these.
9591
9592 An atomic operation can both constrain code motion and
9593 be mapped to hardware instructions for synchronization between threads
9594 (e.g., a fence). To which extent this happens is controlled by the
9595 memory orders, which are listed here in approximately ascending order of
9596 strength. The description of each memory order is only meant to roughly
9597 illustrate the effects and is not a specification; see the C++11
9598 memory model for precise semantics.
9599
9600 @table @code
9601 @item __ATOMIC_RELAXED
9602 Implies no inter-thread ordering constraints.
9603 @item __ATOMIC_CONSUME
9604 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9605 memory order because of a deficiency in C++11's semantics for
9606 @code{memory_order_consume}.
9607 @item __ATOMIC_ACQUIRE
9608 Creates an inter-thread happens-before constraint from the release (or
9609 stronger) semantic store to this acquire load. Can prevent hoisting
9610 of code to before the operation.
9611 @item __ATOMIC_RELEASE
9612 Creates an inter-thread happens-before constraint to acquire (or stronger)
9613 semantic loads that read from this release store. Can prevent sinking
9614 of code to after the operation.
9615 @item __ATOMIC_ACQ_REL
9616 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9617 @code{__ATOMIC_RELEASE}.
9618 @item __ATOMIC_SEQ_CST
9619 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9620 @end table
9621
9622 Note that in the C++11 memory model, @emph{fences} (e.g.,
9623 @samp{__atomic_thread_fence}) take effect in combination with other
9624 atomic operations on specific memory locations (e.g., atomic loads);
9625 operations on specific memory locations do not necessarily affect other
9626 operations in the same way.
9627
9628 Target architectures are encouraged to provide their own patterns for
9629 each of the atomic built-in functions. If no target is provided, the original
9630 non-memory model set of @samp{__sync} atomic built-in functions are
9631 used, along with any required synchronization fences surrounding it in
9632 order to achieve the proper behavior. Execution in this case is subject
9633 to the same restrictions as those built-in functions.
9634
9635 If there is no pattern or mechanism to provide a lock-free instruction
9636 sequence, a call is made to an external routine with the same parameters
9637 to be resolved at run time.
9638
9639 When implementing patterns for these built-in functions, the memory order
9640 parameter can be ignored as long as the pattern implements the most
9641 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
9642 orders execute correctly with this memory order but they may not execute as
9643 efficiently as they could with a more appropriate implementation of the
9644 relaxed requirements.
9645
9646 Note that the C++11 standard allows for the memory order parameter to be
9647 determined at run time rather than at compile time. These built-in
9648 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9649 than invoke a runtime library call or inline a switch statement. This is
9650 standard compliant, safe, and the simplest approach for now.
9651
9652 The memory order parameter is a signed int, but only the lower 16 bits are
9653 reserved for the memory order. The remainder of the signed int is reserved
9654 for target use and should be 0. Use of the predefined atomic values
9655 ensures proper usage.
9656
9657 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9658 This built-in function implements an atomic load operation. It returns the
9659 contents of @code{*@var{ptr}}.
9660
9661 The valid memory order variants are
9662 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9663 and @code{__ATOMIC_CONSUME}.
9664
9665 @end deftypefn
9666
9667 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9668 This is the generic version of an atomic load. It returns the
9669 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9670
9671 @end deftypefn
9672
9673 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9674 This built-in function implements an atomic store operation. It writes
9675 @code{@var{val}} into @code{*@var{ptr}}.
9676
9677 The valid memory order variants are
9678 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9679
9680 @end deftypefn
9681
9682 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9683 This is the generic version of an atomic store. It stores the value
9684 of @code{*@var{val}} into @code{*@var{ptr}}.
9685
9686 @end deftypefn
9687
9688 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9689 This built-in function implements an atomic exchange operation. It writes
9690 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9691 @code{*@var{ptr}}.
9692
9693 The valid memory order variants are
9694 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9695 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9696
9697 @end deftypefn
9698
9699 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9700 This is the generic version of an atomic exchange. It stores the
9701 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9702 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9703
9704 @end deftypefn
9705
9706 @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)
9707 This built-in function implements an atomic compare and exchange operation.
9708 This compares the contents of @code{*@var{ptr}} with the contents of
9709 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9710 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
9711 equal, the operation is a @emph{read} and the current contents of
9712 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is true
9713 for weak compare_exchange, which may fail spuriously, and false for
9714 the strong variation, which never fails spuriously. Many targets
9715 only offer the strong variation and ignore the parameter. When in doubt, use
9716 the strong variation.
9717
9718 If @var{desired} is written into @code{*@var{ptr}} then true is returned
9719 and memory is affected according to the
9720 memory order specified by @var{success_memorder}. There are no
9721 restrictions on what memory order can be used here.
9722
9723 Otherwise, false is returned and memory is affected according
9724 to @var{failure_memorder}. This memory order cannot be
9725 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
9726 stronger order than that specified by @var{success_memorder}.
9727
9728 @end deftypefn
9729
9730 @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)
9731 This built-in function implements the generic version of
9732 @code{__atomic_compare_exchange}. The function is virtually identical to
9733 @code{__atomic_compare_exchange_n}, except the desired value is also a
9734 pointer.
9735
9736 @end deftypefn
9737
9738 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9739 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9740 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9741 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9742 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9743 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9744 These built-in functions perform the operation suggested by the name, and
9745 return the result of the operation. Operations on pointer arguments are
9746 performed as if the operands were of the @code{uintptr_t} type. That is,
9747 they are not scaled by the size of the type to which the pointer points.
9748
9749 @smallexample
9750 @{ *ptr @var{op}= val; return *ptr; @}
9751 @end smallexample
9752
9753 The object pointed to by the first argument must be of integer or pointer
9754 type. It must not be a Boolean type. All memory orders are valid.
9755
9756 @end deftypefn
9757
9758 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9759 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9760 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9761 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9762 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9763 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9764 These built-in functions perform the operation suggested by the name, and
9765 return the value that had previously been in @code{*@var{ptr}}. Operations
9766 on pointer arguments are performed as if the operands were of
9767 the @code{uintptr_t} type. That is, they are not scaled by the size of
9768 the type to which the pointer points.
9769
9770 @smallexample
9771 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9772 @end smallexample
9773
9774 The same constraints on arguments apply as for the corresponding
9775 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
9776
9777 @end deftypefn
9778
9779 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9780
9781 This built-in function performs an atomic test-and-set operation on
9782 the byte at @code{*@var{ptr}}. The byte is set to some implementation
9783 defined nonzero ``set'' value and the return value is @code{true} if and only
9784 if the previous contents were ``set''.
9785 It should be only used for operands of type @code{bool} or @code{char}. For
9786 other types only part of the value may be set.
9787
9788 All memory orders are valid.
9789
9790 @end deftypefn
9791
9792 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9793
9794 This built-in function performs an atomic clear operation on
9795 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
9796 It should be only used for operands of type @code{bool} or @code{char} and
9797 in conjunction with @code{__atomic_test_and_set}.
9798 For other types it may only clear partially. If the type is not @code{bool}
9799 prefer using @code{__atomic_store}.
9800
9801 The valid memory order variants are
9802 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9803 @code{__ATOMIC_RELEASE}.
9804
9805 @end deftypefn
9806
9807 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9808
9809 This built-in function acts as a synchronization fence between threads
9810 based on the specified memory order.
9811
9812 All memory orders are valid.
9813
9814 @end deftypefn
9815
9816 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9817
9818 This built-in function acts as a synchronization fence between a thread
9819 and signal handlers based in the same thread.
9820
9821 All memory orders are valid.
9822
9823 @end deftypefn
9824
9825 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
9826
9827 This built-in function returns true if objects of @var{size} bytes always
9828 generate lock-free atomic instructions for the target architecture.
9829 @var{size} must resolve to a compile-time constant and the result also
9830 resolves to a compile-time constant.
9831
9832 @var{ptr} is an optional pointer to the object that may be used to determine
9833 alignment. A value of 0 indicates typical alignment should be used. The
9834 compiler may also ignore this parameter.
9835
9836 @smallexample
9837 if (__atomic_always_lock_free (sizeof (long long), 0))
9838 @end smallexample
9839
9840 @end deftypefn
9841
9842 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9843
9844 This built-in function returns true if objects of @var{size} bytes always
9845 generate lock-free atomic instructions for the target architecture. If
9846 the built-in function is not known to be lock-free, a call is made to a
9847 runtime routine named @code{__atomic_is_lock_free}.
9848
9849 @var{ptr} is an optional pointer to the object that may be used to determine
9850 alignment. A value of 0 indicates typical alignment should be used. The
9851 compiler may also ignore this parameter.
9852 @end deftypefn
9853
9854 @node Integer Overflow Builtins
9855 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9856
9857 The following built-in functions allow performing simple arithmetic operations
9858 together with checking whether the operations overflowed.
9859
9860 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9861 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9862 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9863 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
9864 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9865 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9866 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9867
9868 These built-in functions promote the first two operands into infinite precision signed
9869 type and perform addition on those promoted operands. The result is then
9870 cast to the type the third pointer argument points to and stored there.
9871 If the stored result is equal to the infinite precision result, the built-in
9872 functions return false, otherwise they return true. As the addition is
9873 performed in infinite signed precision, these built-in functions have fully defined
9874 behavior for all argument values.
9875
9876 The first built-in function allows arbitrary integral types for operands and
9877 the result type must be pointer to some integral type other than enumerated or
9878 Boolean type, the rest of the built-in functions have explicit integer types.
9879
9880 The compiler will attempt to use hardware instructions to implement
9881 these built-in functions where possible, like conditional jump on overflow
9882 after addition, conditional jump on carry etc.
9883
9884 @end deftypefn
9885
9886 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9887 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9888 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9889 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
9890 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9891 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9892 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9893
9894 These built-in functions are similar to the add overflow checking built-in
9895 functions above, except they perform subtraction, subtract the second argument
9896 from the first one, instead of addition.
9897
9898 @end deftypefn
9899
9900 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9901 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9902 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9903 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
9904 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9905 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9906 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9907
9908 These built-in functions are similar to the add overflow checking built-in
9909 functions above, except they perform multiplication, instead of addition.
9910
9911 @end deftypefn
9912
9913 The following built-in functions allow checking if simple arithmetic operation
9914 would overflow.
9915
9916 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
9917 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
9918 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
9919
9920 These built-in functions are similar to @code{__builtin_add_overflow},
9921 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
9922 they don't store the result of the arithmetic operation anywhere and the
9923 last argument is not a pointer, but some expression with integral type other
9924 than enumerated or Boolean type.
9925
9926 The built-in functions promote the first two operands into infinite precision signed type
9927 and perform addition on those promoted operands. The result is then
9928 cast to the type of the third argument. If the cast result is equal to the infinite
9929 precision result, the built-in functions return false, otherwise they return true.
9930 The value of the third argument is ignored, just the side-effects in the third argument
9931 are evaluated, and no integral argument promotions are performed on the last argument.
9932 If the third argument is a bit-field, the type used for the result cast has the
9933 precision and signedness of the given bit-field, rather than precision and signedness
9934 of the underlying type.
9935
9936 For example, the following macro can be used to portably check, at
9937 compile-time, whether or not adding two constant integers will overflow,
9938 and perform the addition only when it is known to be safe and not to trigger
9939 a @option{-Woverflow} warning.
9940
9941 @smallexample
9942 #define INT_ADD_OVERFLOW_P(a, b) \
9943 __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
9944
9945 enum @{
9946 A = INT_MAX, B = 3,
9947 C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
9948 D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
9949 @};
9950 @end smallexample
9951
9952 The compiler will attempt to use hardware instructions to implement
9953 these built-in functions where possible, like conditional jump on overflow
9954 after addition, conditional jump on carry etc.
9955
9956 @end deftypefn
9957
9958 @node x86 specific memory model extensions for transactional memory
9959 @section x86-Specific Memory Model Extensions for Transactional Memory
9960
9961 The x86 architecture supports additional memory ordering flags
9962 to mark lock critical sections for hardware lock elision.
9963 These must be specified in addition to an existing memory order to
9964 atomic intrinsics.
9965
9966 @table @code
9967 @item __ATOMIC_HLE_ACQUIRE
9968 Start lock elision on a lock variable.
9969 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
9970 @item __ATOMIC_HLE_RELEASE
9971 End lock elision on a lock variable.
9972 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
9973 @end table
9974
9975 When a lock acquire fails, it is required for good performance to abort
9976 the transaction quickly. This can be done with a @code{_mm_pause}.
9977
9978 @smallexample
9979 #include <immintrin.h> // For _mm_pause
9980
9981 int lockvar;
9982
9983 /* Acquire lock with lock elision */
9984 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
9985 _mm_pause(); /* Abort failed transaction */
9986 ...
9987 /* Free lock with lock elision */
9988 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
9989 @end smallexample
9990
9991 @node Object Size Checking
9992 @section Object Size Checking Built-in Functions
9993 @findex __builtin_object_size
9994 @findex __builtin___memcpy_chk
9995 @findex __builtin___mempcpy_chk
9996 @findex __builtin___memmove_chk
9997 @findex __builtin___memset_chk
9998 @findex __builtin___strcpy_chk
9999 @findex __builtin___stpcpy_chk
10000 @findex __builtin___strncpy_chk
10001 @findex __builtin___strcat_chk
10002 @findex __builtin___strncat_chk
10003 @findex __builtin___sprintf_chk
10004 @findex __builtin___snprintf_chk
10005 @findex __builtin___vsprintf_chk
10006 @findex __builtin___vsnprintf_chk
10007 @findex __builtin___printf_chk
10008 @findex __builtin___vprintf_chk
10009 @findex __builtin___fprintf_chk
10010 @findex __builtin___vfprintf_chk
10011
10012 GCC implements a limited buffer overflow protection mechanism
10013 that can prevent some buffer overflow attacks.
10014
10015 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
10016 is a built-in construct that returns a constant number of bytes from
10017 @var{ptr} to the end of the object @var{ptr} pointer points to
10018 (if known at compile time). @code{__builtin_object_size} never evaluates
10019 its arguments for side-effects. If there are any side-effects in them, it
10020 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10021 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
10022 point to and all of them are known at compile time, the returned number
10023 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10024 0 and minimum if nonzero. If it is not possible to determine which objects
10025 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10026 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10027 for @var{type} 2 or 3.
10028
10029 @var{type} is an integer constant from 0 to 3. If the least significant
10030 bit is clear, objects are whole variables, if it is set, a closest
10031 surrounding subobject is considered the object a pointer points to.
10032 The second bit determines if maximum or minimum of remaining bytes
10033 is computed.
10034
10035 @smallexample
10036 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10037 char *p = &var.buf1[1], *q = &var.b;
10038
10039 /* Here the object p points to is var. */
10040 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10041 /* The subobject p points to is var.buf1. */
10042 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10043 /* The object q points to is var. */
10044 assert (__builtin_object_size (q, 0)
10045 == (char *) (&var + 1) - (char *) &var.b);
10046 /* The subobject q points to is var.b. */
10047 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10048 @end smallexample
10049 @end deftypefn
10050
10051 There are built-in functions added for many common string operation
10052 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10053 built-in is provided. This built-in has an additional last argument,
10054 which is the number of bytes remaining in object the @var{dest}
10055 argument points to or @code{(size_t) -1} if the size is not known.
10056
10057 The built-in functions are optimized into the normal string functions
10058 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10059 it is known at compile time that the destination object will not
10060 be overflown. If the compiler can determine at compile time the
10061 object will be always overflown, it issues a warning.
10062
10063 The intended use can be e.g.@:
10064
10065 @smallexample
10066 #undef memcpy
10067 #define bos0(dest) __builtin_object_size (dest, 0)
10068 #define memcpy(dest, src, n) \
10069 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10070
10071 char *volatile p;
10072 char buf[10];
10073 /* It is unknown what object p points to, so this is optimized
10074 into plain memcpy - no checking is possible. */
10075 memcpy (p, "abcde", n);
10076 /* Destination is known and length too. It is known at compile
10077 time there will be no overflow. */
10078 memcpy (&buf[5], "abcde", 5);
10079 /* Destination is known, but the length is not known at compile time.
10080 This will result in __memcpy_chk call that can check for overflow
10081 at run time. */
10082 memcpy (&buf[5], "abcde", n);
10083 /* Destination is known and it is known at compile time there will
10084 be overflow. There will be a warning and __memcpy_chk call that
10085 will abort the program at run time. */
10086 memcpy (&buf[6], "abcde", 5);
10087 @end smallexample
10088
10089 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10090 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10091 @code{strcat} and @code{strncat}.
10092
10093 There are also checking built-in functions for formatted output functions.
10094 @smallexample
10095 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10096 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10097 const char *fmt, ...);
10098 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10099 va_list ap);
10100 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10101 const char *fmt, va_list ap);
10102 @end smallexample
10103
10104 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10105 etc.@: functions and can contain implementation specific flags on what
10106 additional security measures the checking function might take, such as
10107 handling @code{%n} differently.
10108
10109 The @var{os} argument is the object size @var{s} points to, like in the
10110 other built-in functions. There is a small difference in the behavior
10111 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10112 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10113 the checking function is called with @var{os} argument set to
10114 @code{(size_t) -1}.
10115
10116 In addition to this, there are checking built-in functions
10117 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10118 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10119 These have just one additional argument, @var{flag}, right before
10120 format string @var{fmt}. If the compiler is able to optimize them to
10121 @code{fputc} etc.@: functions, it does, otherwise the checking function
10122 is called and the @var{flag} argument passed to it.
10123
10124 @node Pointer Bounds Checker builtins
10125 @section Pointer Bounds Checker Built-in Functions
10126 @cindex Pointer Bounds Checker builtins
10127 @findex __builtin___bnd_set_ptr_bounds
10128 @findex __builtin___bnd_narrow_ptr_bounds
10129 @findex __builtin___bnd_copy_ptr_bounds
10130 @findex __builtin___bnd_init_ptr_bounds
10131 @findex __builtin___bnd_null_ptr_bounds
10132 @findex __builtin___bnd_store_ptr_bounds
10133 @findex __builtin___bnd_chk_ptr_lbounds
10134 @findex __builtin___bnd_chk_ptr_ubounds
10135 @findex __builtin___bnd_chk_ptr_bounds
10136 @findex __builtin___bnd_get_ptr_lbound
10137 @findex __builtin___bnd_get_ptr_ubound
10138
10139 GCC provides a set of built-in functions to control Pointer Bounds Checker
10140 instrumentation. Note that all Pointer Bounds Checker builtins can be used
10141 even if you compile with Pointer Bounds Checker off
10142 (@option{-fno-check-pointer-bounds}).
10143 The behavior may differ in such case as documented below.
10144
10145 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
10146
10147 This built-in function returns a new pointer with the value of @var{q}, and
10148 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
10149 Bounds Checker off, the built-in function just returns the first argument.
10150
10151 @smallexample
10152 extern void *__wrap_malloc (size_t n)
10153 @{
10154 void *p = (void *)__real_malloc (n);
10155 if (!p) return __builtin___bnd_null_ptr_bounds (p);
10156 return __builtin___bnd_set_ptr_bounds (p, n);
10157 @}
10158 @end smallexample
10159
10160 @end deftypefn
10161
10162 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
10163
10164 This built-in function returns a new pointer with the value of @var{p}
10165 and associates it with the narrowed bounds formed by the intersection
10166 of bounds associated with @var{q} and the bounds
10167 [@var{p}, @var{p} + @var{size} - 1].
10168 With Pointer Bounds Checker off, the built-in function just returns the first
10169 argument.
10170
10171 @smallexample
10172 void init_objects (object *objs, size_t size)
10173 @{
10174 size_t i;
10175 /* Initialize objects one-by-one passing pointers with bounds of
10176 an object, not the full array of objects. */
10177 for (i = 0; i < size; i++)
10178 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10179 sizeof(object)));
10180 @}
10181 @end smallexample
10182
10183 @end deftypefn
10184
10185 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10186
10187 This built-in function returns a new pointer with the value of @var{q},
10188 and associates it with the bounds already associated with pointer @var{r}.
10189 With Pointer Bounds Checker off, the built-in function just returns the first
10190 argument.
10191
10192 @smallexample
10193 /* Here is a way to get pointer to object's field but
10194 still with the full object's bounds. */
10195 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
10196 objptr);
10197 @end smallexample
10198
10199 @end deftypefn
10200
10201 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10202
10203 This built-in function returns a new pointer with the value of @var{q}, and
10204 associates it with INIT (allowing full memory access) bounds. With Pointer
10205 Bounds Checker off, the built-in function just returns the first argument.
10206
10207 @end deftypefn
10208
10209 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10210
10211 This built-in function returns a new pointer with the value of @var{q}, and
10212 associates it with NULL (allowing no memory access) bounds. With Pointer
10213 Bounds Checker off, the built-in function just returns the first argument.
10214
10215 @end deftypefn
10216
10217 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10218
10219 This built-in function stores the bounds associated with pointer @var{ptr_val}
10220 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
10221 bounds from legacy code without touching the associated pointer's memory when
10222 pointers are copied as integers. With Pointer Bounds Checker off, the built-in
10223 function call is ignored.
10224
10225 @end deftypefn
10226
10227 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10228
10229 This built-in function checks if the pointer @var{q} is within the lower
10230 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10231 function call is ignored.
10232
10233 @smallexample
10234 extern void *__wrap_memset (void *dst, int c, size_t len)
10235 @{
10236 if (len > 0)
10237 @{
10238 __builtin___bnd_chk_ptr_lbounds (dst);
10239 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10240 __real_memset (dst, c, len);
10241 @}
10242 return dst;
10243 @}
10244 @end smallexample
10245
10246 @end deftypefn
10247
10248 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10249
10250 This built-in function checks if the pointer @var{q} is within the upper
10251 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10252 function call is ignored.
10253
10254 @end deftypefn
10255
10256 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10257
10258 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10259 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
10260 off, the built-in function call is ignored.
10261
10262 @smallexample
10263 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10264 @{
10265 if (n > 0)
10266 @{
10267 __bnd_chk_ptr_bounds (dst, n);
10268 __bnd_chk_ptr_bounds (src, n);
10269 __real_memcpy (dst, src, n);
10270 @}
10271 return dst;
10272 @}
10273 @end smallexample
10274
10275 @end deftypefn
10276
10277 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10278
10279 This built-in function returns the lower bound associated
10280 with the pointer @var{q}, as a pointer value.
10281 This is useful for debugging using @code{printf}.
10282 With Pointer Bounds Checker off, the built-in function returns 0.
10283
10284 @smallexample
10285 void *lb = __builtin___bnd_get_ptr_lbound (q);
10286 void *ub = __builtin___bnd_get_ptr_ubound (q);
10287 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
10288 @end smallexample
10289
10290 @end deftypefn
10291
10292 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10293
10294 This built-in function returns the upper bound (which is a pointer) associated
10295 with the pointer @var{q}. With Pointer Bounds Checker off,
10296 the built-in function returns -1.
10297
10298 @end deftypefn
10299
10300 @node Cilk Plus Builtins
10301 @section Cilk Plus C/C++ Language Extension Built-in Functions
10302
10303 GCC provides support for the following built-in reduction functions if Cilk Plus
10304 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10305
10306 @itemize @bullet
10307 @item @code{__sec_implicit_index}
10308 @item @code{__sec_reduce}
10309 @item @code{__sec_reduce_add}
10310 @item @code{__sec_reduce_all_nonzero}
10311 @item @code{__sec_reduce_all_zero}
10312 @item @code{__sec_reduce_any_nonzero}
10313 @item @code{__sec_reduce_any_zero}
10314 @item @code{__sec_reduce_max}
10315 @item @code{__sec_reduce_min}
10316 @item @code{__sec_reduce_max_ind}
10317 @item @code{__sec_reduce_min_ind}
10318 @item @code{__sec_reduce_mul}
10319 @item @code{__sec_reduce_mutating}
10320 @end itemize
10321
10322 Further details and examples about these built-in functions are described
10323 in the Cilk Plus language manual which can be found at
10324 @uref{http://www.cilkplus.org}.
10325
10326 @node Other Builtins
10327 @section Other Built-in Functions Provided by GCC
10328 @cindex built-in functions
10329 @findex __builtin_alloca
10330 @findex __builtin_alloca_with_align
10331 @findex __builtin_call_with_static_chain
10332 @findex __builtin_fpclassify
10333 @findex __builtin_isfinite
10334 @findex __builtin_isnormal
10335 @findex __builtin_isgreater
10336 @findex __builtin_isgreaterequal
10337 @findex __builtin_isinf_sign
10338 @findex __builtin_isless
10339 @findex __builtin_islessequal
10340 @findex __builtin_islessgreater
10341 @findex __builtin_isunordered
10342 @findex __builtin_powi
10343 @findex __builtin_powif
10344 @findex __builtin_powil
10345 @findex _Exit
10346 @findex _exit
10347 @findex abort
10348 @findex abs
10349 @findex acos
10350 @findex acosf
10351 @findex acosh
10352 @findex acoshf
10353 @findex acoshl
10354 @findex acosl
10355 @findex alloca
10356 @findex asin
10357 @findex asinf
10358 @findex asinh
10359 @findex asinhf
10360 @findex asinhl
10361 @findex asinl
10362 @findex atan
10363 @findex atan2
10364 @findex atan2f
10365 @findex atan2l
10366 @findex atanf
10367 @findex atanh
10368 @findex atanhf
10369 @findex atanhl
10370 @findex atanl
10371 @findex bcmp
10372 @findex bzero
10373 @findex cabs
10374 @findex cabsf
10375 @findex cabsl
10376 @findex cacos
10377 @findex cacosf
10378 @findex cacosh
10379 @findex cacoshf
10380 @findex cacoshl
10381 @findex cacosl
10382 @findex calloc
10383 @findex carg
10384 @findex cargf
10385 @findex cargl
10386 @findex casin
10387 @findex casinf
10388 @findex casinh
10389 @findex casinhf
10390 @findex casinhl
10391 @findex casinl
10392 @findex catan
10393 @findex catanf
10394 @findex catanh
10395 @findex catanhf
10396 @findex catanhl
10397 @findex catanl
10398 @findex cbrt
10399 @findex cbrtf
10400 @findex cbrtl
10401 @findex ccos
10402 @findex ccosf
10403 @findex ccosh
10404 @findex ccoshf
10405 @findex ccoshl
10406 @findex ccosl
10407 @findex ceil
10408 @findex ceilf
10409 @findex ceill
10410 @findex cexp
10411 @findex cexpf
10412 @findex cexpl
10413 @findex cimag
10414 @findex cimagf
10415 @findex cimagl
10416 @findex clog
10417 @findex clogf
10418 @findex clogl
10419 @findex clog10
10420 @findex clog10f
10421 @findex clog10l
10422 @findex conj
10423 @findex conjf
10424 @findex conjl
10425 @findex copysign
10426 @findex copysignf
10427 @findex copysignl
10428 @findex cos
10429 @findex cosf
10430 @findex cosh
10431 @findex coshf
10432 @findex coshl
10433 @findex cosl
10434 @findex cpow
10435 @findex cpowf
10436 @findex cpowl
10437 @findex cproj
10438 @findex cprojf
10439 @findex cprojl
10440 @findex creal
10441 @findex crealf
10442 @findex creall
10443 @findex csin
10444 @findex csinf
10445 @findex csinh
10446 @findex csinhf
10447 @findex csinhl
10448 @findex csinl
10449 @findex csqrt
10450 @findex csqrtf
10451 @findex csqrtl
10452 @findex ctan
10453 @findex ctanf
10454 @findex ctanh
10455 @findex ctanhf
10456 @findex ctanhl
10457 @findex ctanl
10458 @findex dcgettext
10459 @findex dgettext
10460 @findex drem
10461 @findex dremf
10462 @findex dreml
10463 @findex erf
10464 @findex erfc
10465 @findex erfcf
10466 @findex erfcl
10467 @findex erff
10468 @findex erfl
10469 @findex exit
10470 @findex exp
10471 @findex exp10
10472 @findex exp10f
10473 @findex exp10l
10474 @findex exp2
10475 @findex exp2f
10476 @findex exp2l
10477 @findex expf
10478 @findex expl
10479 @findex expm1
10480 @findex expm1f
10481 @findex expm1l
10482 @findex fabs
10483 @findex fabsf
10484 @findex fabsl
10485 @findex fdim
10486 @findex fdimf
10487 @findex fdiml
10488 @findex ffs
10489 @findex floor
10490 @findex floorf
10491 @findex floorl
10492 @findex fma
10493 @findex fmaf
10494 @findex fmal
10495 @findex fmax
10496 @findex fmaxf
10497 @findex fmaxl
10498 @findex fmin
10499 @findex fminf
10500 @findex fminl
10501 @findex fmod
10502 @findex fmodf
10503 @findex fmodl
10504 @findex fprintf
10505 @findex fprintf_unlocked
10506 @findex fputs
10507 @findex fputs_unlocked
10508 @findex frexp
10509 @findex frexpf
10510 @findex frexpl
10511 @findex fscanf
10512 @findex gamma
10513 @findex gammaf
10514 @findex gammal
10515 @findex gamma_r
10516 @findex gammaf_r
10517 @findex gammal_r
10518 @findex gettext
10519 @findex hypot
10520 @findex hypotf
10521 @findex hypotl
10522 @findex ilogb
10523 @findex ilogbf
10524 @findex ilogbl
10525 @findex imaxabs
10526 @findex index
10527 @findex isalnum
10528 @findex isalpha
10529 @findex isascii
10530 @findex isblank
10531 @findex iscntrl
10532 @findex isdigit
10533 @findex isgraph
10534 @findex islower
10535 @findex isprint
10536 @findex ispunct
10537 @findex isspace
10538 @findex isupper
10539 @findex iswalnum
10540 @findex iswalpha
10541 @findex iswblank
10542 @findex iswcntrl
10543 @findex iswdigit
10544 @findex iswgraph
10545 @findex iswlower
10546 @findex iswprint
10547 @findex iswpunct
10548 @findex iswspace
10549 @findex iswupper
10550 @findex iswxdigit
10551 @findex isxdigit
10552 @findex j0
10553 @findex j0f
10554 @findex j0l
10555 @findex j1
10556 @findex j1f
10557 @findex j1l
10558 @findex jn
10559 @findex jnf
10560 @findex jnl
10561 @findex labs
10562 @findex ldexp
10563 @findex ldexpf
10564 @findex ldexpl
10565 @findex lgamma
10566 @findex lgammaf
10567 @findex lgammal
10568 @findex lgamma_r
10569 @findex lgammaf_r
10570 @findex lgammal_r
10571 @findex llabs
10572 @findex llrint
10573 @findex llrintf
10574 @findex llrintl
10575 @findex llround
10576 @findex llroundf
10577 @findex llroundl
10578 @findex log
10579 @findex log10
10580 @findex log10f
10581 @findex log10l
10582 @findex log1p
10583 @findex log1pf
10584 @findex log1pl
10585 @findex log2
10586 @findex log2f
10587 @findex log2l
10588 @findex logb
10589 @findex logbf
10590 @findex logbl
10591 @findex logf
10592 @findex logl
10593 @findex lrint
10594 @findex lrintf
10595 @findex lrintl
10596 @findex lround
10597 @findex lroundf
10598 @findex lroundl
10599 @findex malloc
10600 @findex memchr
10601 @findex memcmp
10602 @findex memcpy
10603 @findex mempcpy
10604 @findex memset
10605 @findex modf
10606 @findex modff
10607 @findex modfl
10608 @findex nearbyint
10609 @findex nearbyintf
10610 @findex nearbyintl
10611 @findex nextafter
10612 @findex nextafterf
10613 @findex nextafterl
10614 @findex nexttoward
10615 @findex nexttowardf
10616 @findex nexttowardl
10617 @findex pow
10618 @findex pow10
10619 @findex pow10f
10620 @findex pow10l
10621 @findex powf
10622 @findex powl
10623 @findex printf
10624 @findex printf_unlocked
10625 @findex putchar
10626 @findex puts
10627 @findex remainder
10628 @findex remainderf
10629 @findex remainderl
10630 @findex remquo
10631 @findex remquof
10632 @findex remquol
10633 @findex rindex
10634 @findex rint
10635 @findex rintf
10636 @findex rintl
10637 @findex round
10638 @findex roundf
10639 @findex roundl
10640 @findex scalb
10641 @findex scalbf
10642 @findex scalbl
10643 @findex scalbln
10644 @findex scalblnf
10645 @findex scalblnf
10646 @findex scalbn
10647 @findex scalbnf
10648 @findex scanfnl
10649 @findex signbit
10650 @findex signbitf
10651 @findex signbitl
10652 @findex signbitd32
10653 @findex signbitd64
10654 @findex signbitd128
10655 @findex significand
10656 @findex significandf
10657 @findex significandl
10658 @findex sin
10659 @findex sincos
10660 @findex sincosf
10661 @findex sincosl
10662 @findex sinf
10663 @findex sinh
10664 @findex sinhf
10665 @findex sinhl
10666 @findex sinl
10667 @findex snprintf
10668 @findex sprintf
10669 @findex sqrt
10670 @findex sqrtf
10671 @findex sqrtl
10672 @findex sscanf
10673 @findex stpcpy
10674 @findex stpncpy
10675 @findex strcasecmp
10676 @findex strcat
10677 @findex strchr
10678 @findex strcmp
10679 @findex strcpy
10680 @findex strcspn
10681 @findex strdup
10682 @findex strfmon
10683 @findex strftime
10684 @findex strlen
10685 @findex strncasecmp
10686 @findex strncat
10687 @findex strncmp
10688 @findex strncpy
10689 @findex strndup
10690 @findex strpbrk
10691 @findex strrchr
10692 @findex strspn
10693 @findex strstr
10694 @findex tan
10695 @findex tanf
10696 @findex tanh
10697 @findex tanhf
10698 @findex tanhl
10699 @findex tanl
10700 @findex tgamma
10701 @findex tgammaf
10702 @findex tgammal
10703 @findex toascii
10704 @findex tolower
10705 @findex toupper
10706 @findex towlower
10707 @findex towupper
10708 @findex trunc
10709 @findex truncf
10710 @findex truncl
10711 @findex vfprintf
10712 @findex vfscanf
10713 @findex vprintf
10714 @findex vscanf
10715 @findex vsnprintf
10716 @findex vsprintf
10717 @findex vsscanf
10718 @findex y0
10719 @findex y0f
10720 @findex y0l
10721 @findex y1
10722 @findex y1f
10723 @findex y1l
10724 @findex yn
10725 @findex ynf
10726 @findex ynl
10727
10728 GCC provides a large number of built-in functions other than the ones
10729 mentioned above. Some of these are for internal use in the processing
10730 of exceptions or variable-length argument lists and are not
10731 documented here because they may change from time to time; we do not
10732 recommend general use of these functions.
10733
10734 The remaining functions are provided for optimization purposes.
10735
10736 With the exception of built-ins that have library equivalents such as
10737 the standard C library functions discussed below, or that expand to
10738 library calls, GCC built-in functions are always expanded inline and
10739 thus do not have corresponding entry points and their address cannot
10740 be obtained. Attempting to use them in an expression other than
10741 a function call results in a compile-time error.
10742
10743 @opindex fno-builtin
10744 GCC includes built-in versions of many of the functions in the standard
10745 C library. These functions come in two forms: one whose names start with
10746 the @code{__builtin_} prefix, and the other without. Both forms have the
10747 same type (including prototype), the same address (when their address is
10748 taken), and the same meaning as the C library functions even if you specify
10749 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
10750 functions are only optimized in certain cases; if they are not optimized in
10751 a particular case, a call to the library function is emitted.
10752
10753 @opindex ansi
10754 @opindex std
10755 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10756 @option{-std=c99} or @option{-std=c11}), the functions
10757 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10758 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10759 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10760 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10761 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10762 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10763 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10764 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10765 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10766 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10767 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10768 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10769 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10770 @code{significandl}, @code{significand}, @code{sincosf},
10771 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10772 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10773 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10774 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10775 @code{yn}
10776 may be handled as built-in functions.
10777 All these functions have corresponding versions
10778 prefixed with @code{__builtin_}, which may be used even in strict C90
10779 mode.
10780
10781 The ISO C99 functions
10782 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10783 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10784 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10785 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10786 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10787 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10788 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10789 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10790 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10791 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10792 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10793 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10794 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10795 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10796 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10797 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10798 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10799 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10800 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10801 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10802 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10803 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10804 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10805 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10806 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10807 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10808 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10809 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10810 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10811 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10812 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10813 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10814 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10815 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10816 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10817 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10818 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10819 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10820 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10821 are handled as built-in functions
10822 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10823
10824 There are also built-in versions of the ISO C99 functions
10825 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10826 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10827 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10828 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10829 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10830 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10831 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10832 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10833 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10834 that are recognized in any mode since ISO C90 reserves these names for
10835 the purpose to which ISO C99 puts them. All these functions have
10836 corresponding versions prefixed with @code{__builtin_}.
10837
10838 There are also GNU extension functions @code{clog10}, @code{clog10f} and
10839 @code{clog10l} which names are reserved by ISO C99 for future use.
10840 All these functions have versions prefixed with @code{__builtin_}.
10841
10842 The ISO C94 functions
10843 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10844 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10845 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10846 @code{towupper}
10847 are handled as built-in functions
10848 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10849
10850 The ISO C90 functions
10851 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10852 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10853 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10854 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10855 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10856 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10857 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10858 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10859 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10860 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10861 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10862 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10863 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10864 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10865 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10866 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10867 are all recognized as built-in functions unless
10868 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10869 is specified for an individual function). All of these functions have
10870 corresponding versions prefixed with @code{__builtin_}.
10871
10872 GCC provides built-in versions of the ISO C99 floating-point comparison
10873 macros that avoid raising exceptions for unordered operands. They have
10874 the same names as the standard macros ( @code{isgreater},
10875 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10876 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10877 prefixed. We intend for a library implementor to be able to simply
10878 @code{#define} each standard macro to its built-in equivalent.
10879 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10880 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
10881 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
10882 built-in functions appear both with and without the @code{__builtin_} prefix.
10883
10884 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
10885 The @code{__builtin_alloca} function must be called at block scope.
10886 The function allocates an object @var{size} bytes large on the stack
10887 of the calling function. The object is aligned on the default stack
10888 alignment boundary for the target determined by the
10889 @code{__BIGGEST_ALIGNMENT__} macro. The @code{__builtin_alloca}
10890 function returns a pointer to the first byte of the allocated object.
10891 The lifetime of the allocated object ends just before the calling
10892 function returns to its caller. This is so even when
10893 @code{__builtin_alloca} is called within a nested block.
10894
10895 For example, the following function allocates eight objects of @code{n}
10896 bytes each on the stack, storing a pointer to each in consecutive elements
10897 of the array @code{a}. It then passes the array to function @code{g}
10898 which can safely use the storage pointed to by each of the array elements.
10899
10900 @smallexample
10901 void f (unsigned n)
10902 @{
10903 void *a [8];
10904 for (int i = 0; i != 8; ++i)
10905 a [i] = __builtin_alloca (n);
10906
10907 g (a, n); // @r{safe}
10908 @}
10909 @end smallexample
10910
10911 Since the @code{__builtin_alloca} function doesn't validate its argument
10912 it is the responsibility of its caller to make sure the argument doesn't
10913 cause it to exceed the stack size limit.
10914 The @code{__builtin_alloca} function is provided to make it possible to
10915 allocate on the stack arrays of bytes with an upper bound that may be
10916 computed at run time. Since C99 Variable Length Arrays offer
10917 similar functionality under a portable, more convenient, and safer
10918 interface they are recommended instead, in both C99 and C++ programs
10919 where GCC provides them as an extension.
10920 @xref{Variable Length}, for details.
10921
10922 @end deftypefn
10923
10924 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
10925 The @code{__builtin_alloca_with_align} function must be called at block
10926 scope. The function allocates an object @var{size} bytes large on
10927 the stack of the calling function. The allocated object is aligned on
10928 the boundary specified by the argument @var{alignment} whose unit is given
10929 in bits (not bytes). The @var{size} argument must be positive and not
10930 exceed the stack size limit. The @var{alignment} argument must be a constant
10931 integer expression that evaluates to a power of 2 greater than or equal to
10932 @code{CHAR_BIT} and less than some unspecified maximum. Invocations
10933 with other values are rejected with an error indicating the valid bounds.
10934 The function returns a pointer to the first byte of the allocated object.
10935 The lifetime of the allocated object ends at the end of the block in which
10936 the function was called. The allocated storage is released no later than
10937 just before the calling function returns to its caller, but may be released
10938 at the end of the block in which the function was called.
10939
10940 For example, in the following function the call to @code{g} is unsafe
10941 because when @code{overalign} is non-zero, the space allocated by
10942 @code{__builtin_alloca_with_align} may have been released at the end
10943 of the @code{if} statement in which it was called.
10944
10945 @smallexample
10946 void f (unsigned n, bool overalign)
10947 @{
10948 void *p;
10949 if (overalign)
10950 p = __builtin_alloca_with_align (n, 64 /* bits */);
10951 else
10952 p = __builtin_alloc (n);
10953
10954 g (p, n); // @r{unsafe}
10955 @}
10956 @end smallexample
10957
10958 Since the @code{__builtin_alloca_with_align} function doesn't validate its
10959 @var{size} argument it is the responsibility of its caller to make sure
10960 the argument doesn't cause it to exceed the stack size limit.
10961 The @code{__builtin_alloca_with_align} function is provided to make
10962 it possible to allocate on the stack overaligned arrays of bytes with
10963 an upper bound that may be computed at run time. Since C99
10964 Variable Length Arrays offer the same functionality under
10965 a portable, more convenient, and safer interface they are recommended
10966 instead, in both C99 and C++ programs where GCC provides them as
10967 an extension. @xref{Variable Length}, for details.
10968
10969 @end deftypefn
10970
10971 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
10972
10973 You can use the built-in function @code{__builtin_types_compatible_p} to
10974 determine whether two types are the same.
10975
10976 This built-in function returns 1 if the unqualified versions of the
10977 types @var{type1} and @var{type2} (which are types, not expressions) are
10978 compatible, 0 otherwise. The result of this built-in function can be
10979 used in integer constant expressions.
10980
10981 This built-in function ignores top level qualifiers (e.g., @code{const},
10982 @code{volatile}). For example, @code{int} is equivalent to @code{const
10983 int}.
10984
10985 The type @code{int[]} and @code{int[5]} are compatible. On the other
10986 hand, @code{int} and @code{char *} are not compatible, even if the size
10987 of their types, on the particular architecture are the same. Also, the
10988 amount of pointer indirection is taken into account when determining
10989 similarity. Consequently, @code{short *} is not similar to
10990 @code{short **}. Furthermore, two types that are typedefed are
10991 considered compatible if their underlying types are compatible.
10992
10993 An @code{enum} type is not considered to be compatible with another
10994 @code{enum} type even if both are compatible with the same integer
10995 type; this is what the C standard specifies.
10996 For example, @code{enum @{foo, bar@}} is not similar to
10997 @code{enum @{hot, dog@}}.
10998
10999 You typically use this function in code whose execution varies
11000 depending on the arguments' types. For example:
11001
11002 @smallexample
11003 #define foo(x) \
11004 (@{ \
11005 typeof (x) tmp = (x); \
11006 if (__builtin_types_compatible_p (typeof (x), long double)) \
11007 tmp = foo_long_double (tmp); \
11008 else if (__builtin_types_compatible_p (typeof (x), double)) \
11009 tmp = foo_double (tmp); \
11010 else if (__builtin_types_compatible_p (typeof (x), float)) \
11011 tmp = foo_float (tmp); \
11012 else \
11013 abort (); \
11014 tmp; \
11015 @})
11016 @end smallexample
11017
11018 @emph{Note:} This construct is only available for C@.
11019
11020 @end deftypefn
11021
11022 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11023
11024 The @var{call_exp} expression must be a function call, and the
11025 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
11026 is passed to the function call in the target's static chain location.
11027 The result of builtin is the result of the function call.
11028
11029 @emph{Note:} This builtin is only available for C@.
11030 This builtin can be used to call Go closures from C.
11031
11032 @end deftypefn
11033
11034 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11035
11036 You can use the built-in function @code{__builtin_choose_expr} to
11037 evaluate code depending on the value of a constant expression. This
11038 built-in function returns @var{exp1} if @var{const_exp}, which is an
11039 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
11040
11041 This built-in function is analogous to the @samp{? :} operator in C,
11042 except that the expression returned has its type unaltered by promotion
11043 rules. Also, the built-in function does not evaluate the expression
11044 that is not chosen. For example, if @var{const_exp} evaluates to true,
11045 @var{exp2} is not evaluated even if it has side-effects.
11046
11047 This built-in function can return an lvalue if the chosen argument is an
11048 lvalue.
11049
11050 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11051 type. Similarly, if @var{exp2} is returned, its return type is the same
11052 as @var{exp2}.
11053
11054 Example:
11055
11056 @smallexample
11057 #define foo(x) \
11058 __builtin_choose_expr ( \
11059 __builtin_types_compatible_p (typeof (x), double), \
11060 foo_double (x), \
11061 __builtin_choose_expr ( \
11062 __builtin_types_compatible_p (typeof (x), float), \
11063 foo_float (x), \
11064 /* @r{The void expression results in a compile-time error} \
11065 @r{when assigning the result to something.} */ \
11066 (void)0))
11067 @end smallexample
11068
11069 @emph{Note:} This construct is only available for C@. Furthermore, the
11070 unused expression (@var{exp1} or @var{exp2} depending on the value of
11071 @var{const_exp}) may still generate syntax errors. This may change in
11072 future revisions.
11073
11074 @end deftypefn
11075
11076 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11077
11078 The built-in function @code{__builtin_complex} is provided for use in
11079 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11080 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
11081 real binary floating-point type, and the result has the corresponding
11082 complex type with real and imaginary parts @var{real} and @var{imag}.
11083 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11084 infinities, NaNs and negative zeros are involved.
11085
11086 @end deftypefn
11087
11088 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11089 You can use the built-in function @code{__builtin_constant_p} to
11090 determine if a value is known to be constant at compile time and hence
11091 that GCC can perform constant-folding on expressions involving that
11092 value. The argument of the function is the value to test. The function
11093 returns the integer 1 if the argument is known to be a compile-time
11094 constant and 0 if it is not known to be a compile-time constant. A
11095 return of 0 does not indicate that the value is @emph{not} a constant,
11096 but merely that GCC cannot prove it is a constant with the specified
11097 value of the @option{-O} option.
11098
11099 You typically use this function in an embedded application where
11100 memory is a critical resource. If you have some complex calculation,
11101 you may want it to be folded if it involves constants, but need to call
11102 a function if it does not. For example:
11103
11104 @smallexample
11105 #define Scale_Value(X) \
11106 (__builtin_constant_p (X) \
11107 ? ((X) * SCALE + OFFSET) : Scale (X))
11108 @end smallexample
11109
11110 You may use this built-in function in either a macro or an inline
11111 function. However, if you use it in an inlined function and pass an
11112 argument of the function as the argument to the built-in, GCC
11113 never returns 1 when you call the inline function with a string constant
11114 or compound literal (@pxref{Compound Literals}) and does not return 1
11115 when you pass a constant numeric value to the inline function unless you
11116 specify the @option{-O} option.
11117
11118 You may also use @code{__builtin_constant_p} in initializers for static
11119 data. For instance, you can write
11120
11121 @smallexample
11122 static const int table[] = @{
11123 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11124 /* @r{@dots{}} */
11125 @};
11126 @end smallexample
11127
11128 @noindent
11129 This is an acceptable initializer even if @var{EXPRESSION} is not a
11130 constant expression, including the case where
11131 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11132 folded to a constant but @var{EXPRESSION} contains operands that are
11133 not otherwise permitted in a static initializer (for example,
11134 @code{0 && foo ()}). GCC must be more conservative about evaluating the
11135 built-in in this case, because it has no opportunity to perform
11136 optimization.
11137 @end deftypefn
11138
11139 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11140 @opindex fprofile-arcs
11141 You may use @code{__builtin_expect} to provide the compiler with
11142 branch prediction information. In general, you should prefer to
11143 use actual profile feedback for this (@option{-fprofile-arcs}), as
11144 programmers are notoriously bad at predicting how their programs
11145 actually perform. However, there are applications in which this
11146 data is hard to collect.
11147
11148 The return value is the value of @var{exp}, which should be an integral
11149 expression. The semantics of the built-in are that it is expected that
11150 @var{exp} == @var{c}. For example:
11151
11152 @smallexample
11153 if (__builtin_expect (x, 0))
11154 foo ();
11155 @end smallexample
11156
11157 @noindent
11158 indicates that we do not expect to call @code{foo}, since
11159 we expect @code{x} to be zero. Since you are limited to integral
11160 expressions for @var{exp}, you should use constructions such as
11161
11162 @smallexample
11163 if (__builtin_expect (ptr != NULL, 1))
11164 foo (*ptr);
11165 @end smallexample
11166
11167 @noindent
11168 when testing pointer or floating-point values.
11169 @end deftypefn
11170
11171 @deftypefn {Built-in Function} void __builtin_trap (void)
11172 This function causes the program to exit abnormally. GCC implements
11173 this function by using a target-dependent mechanism (such as
11174 intentionally executing an illegal instruction) or by calling
11175 @code{abort}. The mechanism used may vary from release to release so
11176 you should not rely on any particular implementation.
11177 @end deftypefn
11178
11179 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11180 If control flow reaches the point of the @code{__builtin_unreachable},
11181 the program is undefined. It is useful in situations where the
11182 compiler cannot deduce the unreachability of the code.
11183
11184 One such case is immediately following an @code{asm} statement that
11185 either never terminates, or one that transfers control elsewhere
11186 and never returns. In this example, without the
11187 @code{__builtin_unreachable}, GCC issues a warning that control
11188 reaches the end of a non-void function. It also generates code
11189 to return after the @code{asm}.
11190
11191 @smallexample
11192 int f (int c, int v)
11193 @{
11194 if (c)
11195 @{
11196 return v;
11197 @}
11198 else
11199 @{
11200 asm("jmp error_handler");
11201 __builtin_unreachable ();
11202 @}
11203 @}
11204 @end smallexample
11205
11206 @noindent
11207 Because the @code{asm} statement unconditionally transfers control out
11208 of the function, control never reaches the end of the function
11209 body. The @code{__builtin_unreachable} is in fact unreachable and
11210 communicates this fact to the compiler.
11211
11212 Another use for @code{__builtin_unreachable} is following a call a
11213 function that never returns but that is not declared
11214 @code{__attribute__((noreturn))}, as in this example:
11215
11216 @smallexample
11217 void function_that_never_returns (void);
11218
11219 int g (int c)
11220 @{
11221 if (c)
11222 @{
11223 return 1;
11224 @}
11225 else
11226 @{
11227 function_that_never_returns ();
11228 __builtin_unreachable ();
11229 @}
11230 @}
11231 @end smallexample
11232
11233 @end deftypefn
11234
11235 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11236 This function returns its first argument, and allows the compiler
11237 to assume that the returned pointer is at least @var{align} bytes
11238 aligned. This built-in can have either two or three arguments,
11239 if it has three, the third argument should have integer type, and
11240 if it is nonzero means misalignment offset. For example:
11241
11242 @smallexample
11243 void *x = __builtin_assume_aligned (arg, 16);
11244 @end smallexample
11245
11246 @noindent
11247 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11248 16-byte aligned, while:
11249
11250 @smallexample
11251 void *x = __builtin_assume_aligned (arg, 32, 8);
11252 @end smallexample
11253
11254 @noindent
11255 means that the compiler can assume for @code{x}, set to @code{arg}, that
11256 @code{(char *) x - 8} is 32-byte aligned.
11257 @end deftypefn
11258
11259 @deftypefn {Built-in Function} int __builtin_LINE ()
11260 This function is the equivalent of the preprocessor @code{__LINE__}
11261 macro and returns a constant integer expression that evaluates to
11262 the line number of the invocation of the built-in. When used as a C++
11263 default argument for a function @var{F}, it returns the line number
11264 of the call to @var{F}.
11265 @end deftypefn
11266
11267 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11268 This function is the equivalent of the @code{__FUNCTION__} symbol
11269 and returns an address constant pointing to the name of the function
11270 from which the built-in was invoked, or the empty string if
11271 the invocation is not at function scope. When used as a C++ default
11272 argument for a function @var{F}, it returns the name of @var{F}'s
11273 caller or the empty string if the call was not made at function
11274 scope.
11275 @end deftypefn
11276
11277 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11278 This function is the equivalent of the preprocessor @code{__FILE__}
11279 macro and returns an address constant pointing to the file name
11280 containing the invocation of the built-in, or the empty string if
11281 the invocation is not at function scope. When used as a C++ default
11282 argument for a function @var{F}, it returns the file name of the call
11283 to @var{F} or the empty string if the call was not made at function
11284 scope.
11285
11286 For example, in the following, each call to function @code{foo} will
11287 print a line similar to @code{"file.c:123: foo: message"} with the name
11288 of the file and the line number of the @code{printf} call, the name of
11289 the function @code{foo}, followed by the word @code{message}.
11290
11291 @smallexample
11292 const char*
11293 function (const char *func = __builtin_FUNCTION ())
11294 @{
11295 return func;
11296 @}
11297
11298 void foo (void)
11299 @{
11300 printf ("%s:%i: %s: message\n", file (), line (), function ());
11301 @}
11302 @end smallexample
11303
11304 @end deftypefn
11305
11306 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11307 This function is used to flush the processor's instruction cache for
11308 the region of memory between @var{begin} inclusive and @var{end}
11309 exclusive. Some targets require that the instruction cache be
11310 flushed, after modifying memory containing code, in order to obtain
11311 deterministic behavior.
11312
11313 If the target does not require instruction cache flushes,
11314 @code{__builtin___clear_cache} has no effect. Otherwise either
11315 instructions are emitted in-line to clear the instruction cache or a
11316 call to the @code{__clear_cache} function in libgcc is made.
11317 @end deftypefn
11318
11319 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11320 This function is used to minimize cache-miss latency by moving data into
11321 a cache before it is accessed.
11322 You can insert calls to @code{__builtin_prefetch} into code for which
11323 you know addresses of data in memory that is likely to be accessed soon.
11324 If the target supports them, data prefetch instructions are generated.
11325 If the prefetch is done early enough before the access then the data will
11326 be in the cache by the time it is accessed.
11327
11328 The value of @var{addr} is the address of the memory to prefetch.
11329 There are two optional arguments, @var{rw} and @var{locality}.
11330 The value of @var{rw} is a compile-time constant one or zero; one
11331 means that the prefetch is preparing for a write to the memory address
11332 and zero, the default, means that the prefetch is preparing for a read.
11333 The value @var{locality} must be a compile-time constant integer between
11334 zero and three. A value of zero means that the data has no temporal
11335 locality, so it need not be left in the cache after the access. A value
11336 of three means that the data has a high degree of temporal locality and
11337 should be left in all levels of cache possible. Values of one and two
11338 mean, respectively, a low or moderate degree of temporal locality. The
11339 default is three.
11340
11341 @smallexample
11342 for (i = 0; i < n; i++)
11343 @{
11344 a[i] = a[i] + b[i];
11345 __builtin_prefetch (&a[i+j], 1, 1);
11346 __builtin_prefetch (&b[i+j], 0, 1);
11347 /* @r{@dots{}} */
11348 @}
11349 @end smallexample
11350
11351 Data prefetch does not generate faults if @var{addr} is invalid, but
11352 the address expression itself must be valid. For example, a prefetch
11353 of @code{p->next} does not fault if @code{p->next} is not a valid
11354 address, but evaluation faults if @code{p} is not a valid address.
11355
11356 If the target does not support data prefetch, the address expression
11357 is evaluated if it includes side effects but no other code is generated
11358 and GCC does not issue a warning.
11359 @end deftypefn
11360
11361 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11362 Returns a positive infinity, if supported by the floating-point format,
11363 else @code{DBL_MAX}. This function is suitable for implementing the
11364 ISO C macro @code{HUGE_VAL}.
11365 @end deftypefn
11366
11367 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11368 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11369 @end deftypefn
11370
11371 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11372 Similar to @code{__builtin_huge_val}, except the return
11373 type is @code{long double}.
11374 @end deftypefn
11375
11376 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11377 This built-in implements the C99 fpclassify functionality. The first
11378 five int arguments should be the target library's notion of the
11379 possible FP classes and are used for return values. They must be
11380 constant values and they must appear in this order: @code{FP_NAN},
11381 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11382 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
11383 to classify. GCC treats the last argument as type-generic, which
11384 means it does not do default promotion from float to double.
11385 @end deftypefn
11386
11387 @deftypefn {Built-in Function} double __builtin_inf (void)
11388 Similar to @code{__builtin_huge_val}, except a warning is generated
11389 if the target floating-point format does not support infinities.
11390 @end deftypefn
11391
11392 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11393 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11394 @end deftypefn
11395
11396 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11397 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11398 @end deftypefn
11399
11400 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11401 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11402 @end deftypefn
11403
11404 @deftypefn {Built-in Function} float __builtin_inff (void)
11405 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11406 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11407 @end deftypefn
11408
11409 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11410 Similar to @code{__builtin_inf}, except the return
11411 type is @code{long double}.
11412 @end deftypefn
11413
11414 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11415 Similar to @code{isinf}, except the return value is -1 for
11416 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11417 Note while the parameter list is an
11418 ellipsis, this function only accepts exactly one floating-point
11419 argument. GCC treats this parameter as type-generic, which means it
11420 does not do default promotion from float to double.
11421 @end deftypefn
11422
11423 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11424 This is an implementation of the ISO C99 function @code{nan}.
11425
11426 Since ISO C99 defines this function in terms of @code{strtod}, which we
11427 do not implement, a description of the parsing is in order. The string
11428 is parsed as by @code{strtol}; that is, the base is recognized by
11429 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
11430 in the significand such that the least significant bit of the number
11431 is at the least significant bit of the significand. The number is
11432 truncated to fit the significand field provided. The significand is
11433 forced to be a quiet NaN@.
11434
11435 This function, if given a string literal all of which would have been
11436 consumed by @code{strtol}, is evaluated early enough that it is considered a
11437 compile-time constant.
11438 @end deftypefn
11439
11440 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11441 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11442 @end deftypefn
11443
11444 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11445 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11446 @end deftypefn
11447
11448 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11449 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11450 @end deftypefn
11451
11452 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11453 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11454 @end deftypefn
11455
11456 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11457 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11458 @end deftypefn
11459
11460 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11461 Similar to @code{__builtin_nan}, except the significand is forced
11462 to be a signaling NaN@. The @code{nans} function is proposed by
11463 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11464 @end deftypefn
11465
11466 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11467 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11468 @end deftypefn
11469
11470 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11471 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11472 @end deftypefn
11473
11474 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11475 Returns one plus the index of the least significant 1-bit of @var{x}, or
11476 if @var{x} is zero, returns zero.
11477 @end deftypefn
11478
11479 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11480 Returns the number of leading 0-bits in @var{x}, starting at the most
11481 significant bit position. If @var{x} is 0, the result is undefined.
11482 @end deftypefn
11483
11484 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11485 Returns the number of trailing 0-bits in @var{x}, starting at the least
11486 significant bit position. If @var{x} is 0, the result is undefined.
11487 @end deftypefn
11488
11489 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11490 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11491 number of bits following the most significant bit that are identical
11492 to it. There are no special cases for 0 or other values.
11493 @end deftypefn
11494
11495 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11496 Returns the number of 1-bits in @var{x}.
11497 @end deftypefn
11498
11499 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11500 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11501 modulo 2.
11502 @end deftypefn
11503
11504 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11505 Similar to @code{__builtin_ffs}, except the argument type is
11506 @code{long}.
11507 @end deftypefn
11508
11509 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11510 Similar to @code{__builtin_clz}, except the argument type is
11511 @code{unsigned long}.
11512 @end deftypefn
11513
11514 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11515 Similar to @code{__builtin_ctz}, except the argument type is
11516 @code{unsigned long}.
11517 @end deftypefn
11518
11519 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11520 Similar to @code{__builtin_clrsb}, except the argument type is
11521 @code{long}.
11522 @end deftypefn
11523
11524 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11525 Similar to @code{__builtin_popcount}, except the argument type is
11526 @code{unsigned long}.
11527 @end deftypefn
11528
11529 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11530 Similar to @code{__builtin_parity}, except the argument type is
11531 @code{unsigned long}.
11532 @end deftypefn
11533
11534 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11535 Similar to @code{__builtin_ffs}, except the argument type is
11536 @code{long long}.
11537 @end deftypefn
11538
11539 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11540 Similar to @code{__builtin_clz}, except the argument type is
11541 @code{unsigned long long}.
11542 @end deftypefn
11543
11544 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11545 Similar to @code{__builtin_ctz}, except the argument type is
11546 @code{unsigned long long}.
11547 @end deftypefn
11548
11549 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11550 Similar to @code{__builtin_clrsb}, except the argument type is
11551 @code{long long}.
11552 @end deftypefn
11553
11554 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11555 Similar to @code{__builtin_popcount}, except the argument type is
11556 @code{unsigned long long}.
11557 @end deftypefn
11558
11559 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11560 Similar to @code{__builtin_parity}, except the argument type is
11561 @code{unsigned long long}.
11562 @end deftypefn
11563
11564 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11565 Returns the first argument raised to the power of the second. Unlike the
11566 @code{pow} function no guarantees about precision and rounding are made.
11567 @end deftypefn
11568
11569 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11570 Similar to @code{__builtin_powi}, except the argument and return types
11571 are @code{float}.
11572 @end deftypefn
11573
11574 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11575 Similar to @code{__builtin_powi}, except the argument and return types
11576 are @code{long double}.
11577 @end deftypefn
11578
11579 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11580 Returns @var{x} with the order of the bytes reversed; for example,
11581 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
11582 exactly 8 bits.
11583 @end deftypefn
11584
11585 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11586 Similar to @code{__builtin_bswap16}, except the argument and return types
11587 are 32 bit.
11588 @end deftypefn
11589
11590 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11591 Similar to @code{__builtin_bswap32}, except the argument and return types
11592 are 64 bit.
11593 @end deftypefn
11594
11595 @node Target Builtins
11596 @section Built-in Functions Specific to Particular Target Machines
11597
11598 On some target machines, GCC supports many built-in functions specific
11599 to those machines. Generally these generate calls to specific machine
11600 instructions, but allow the compiler to schedule those calls.
11601
11602 @menu
11603 * AArch64 Built-in Functions::
11604 * Alpha Built-in Functions::
11605 * Altera Nios II Built-in Functions::
11606 * ARC Built-in Functions::
11607 * ARC SIMD Built-in Functions::
11608 * ARM iWMMXt Built-in Functions::
11609 * ARM C Language Extensions (ACLE)::
11610 * ARM Floating Point Status and Control Intrinsics::
11611 * AVR Built-in Functions::
11612 * Blackfin Built-in Functions::
11613 * FR-V Built-in Functions::
11614 * MIPS DSP Built-in Functions::
11615 * MIPS Paired-Single Support::
11616 * MIPS Loongson Built-in Functions::
11617 * MIPS SIMD Architecture (MSA) Support::
11618 * Other MIPS Built-in Functions::
11619 * MSP430 Built-in Functions::
11620 * NDS32 Built-in Functions::
11621 * picoChip Built-in Functions::
11622 * PowerPC Built-in Functions::
11623 * PowerPC AltiVec/VSX Built-in Functions::
11624 * PowerPC Hardware Transactional Memory Built-in Functions::
11625 * RX Built-in Functions::
11626 * S/390 System z Built-in Functions::
11627 * SH Built-in Functions::
11628 * SPARC VIS Built-in Functions::
11629 * SPU Built-in Functions::
11630 * TI C6X Built-in Functions::
11631 * TILE-Gx Built-in Functions::
11632 * TILEPro Built-in Functions::
11633 * x86 Built-in Functions::
11634 * x86 transactional memory intrinsics::
11635 @end menu
11636
11637 @node AArch64 Built-in Functions
11638 @subsection AArch64 Built-in Functions
11639
11640 These built-in functions are available for the AArch64 family of
11641 processors.
11642 @smallexample
11643 unsigned int __builtin_aarch64_get_fpcr ()
11644 void __builtin_aarch64_set_fpcr (unsigned int)
11645 unsigned int __builtin_aarch64_get_fpsr ()
11646 void __builtin_aarch64_set_fpsr (unsigned int)
11647 @end smallexample
11648
11649 @node Alpha Built-in Functions
11650 @subsection Alpha Built-in Functions
11651
11652 These built-in functions are available for the Alpha family of
11653 processors, depending on the command-line switches used.
11654
11655 The following built-in functions are always available. They
11656 all generate the machine instruction that is part of the name.
11657
11658 @smallexample
11659 long __builtin_alpha_implver (void)
11660 long __builtin_alpha_rpcc (void)
11661 long __builtin_alpha_amask (long)
11662 long __builtin_alpha_cmpbge (long, long)
11663 long __builtin_alpha_extbl (long, long)
11664 long __builtin_alpha_extwl (long, long)
11665 long __builtin_alpha_extll (long, long)
11666 long __builtin_alpha_extql (long, long)
11667 long __builtin_alpha_extwh (long, long)
11668 long __builtin_alpha_extlh (long, long)
11669 long __builtin_alpha_extqh (long, long)
11670 long __builtin_alpha_insbl (long, long)
11671 long __builtin_alpha_inswl (long, long)
11672 long __builtin_alpha_insll (long, long)
11673 long __builtin_alpha_insql (long, long)
11674 long __builtin_alpha_inswh (long, long)
11675 long __builtin_alpha_inslh (long, long)
11676 long __builtin_alpha_insqh (long, long)
11677 long __builtin_alpha_mskbl (long, long)
11678 long __builtin_alpha_mskwl (long, long)
11679 long __builtin_alpha_mskll (long, long)
11680 long __builtin_alpha_mskql (long, long)
11681 long __builtin_alpha_mskwh (long, long)
11682 long __builtin_alpha_msklh (long, long)
11683 long __builtin_alpha_mskqh (long, long)
11684 long __builtin_alpha_umulh (long, long)
11685 long __builtin_alpha_zap (long, long)
11686 long __builtin_alpha_zapnot (long, long)
11687 @end smallexample
11688
11689 The following built-in functions are always with @option{-mmax}
11690 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11691 later. They all generate the machine instruction that is part
11692 of the name.
11693
11694 @smallexample
11695 long __builtin_alpha_pklb (long)
11696 long __builtin_alpha_pkwb (long)
11697 long __builtin_alpha_unpkbl (long)
11698 long __builtin_alpha_unpkbw (long)
11699 long __builtin_alpha_minub8 (long, long)
11700 long __builtin_alpha_minsb8 (long, long)
11701 long __builtin_alpha_minuw4 (long, long)
11702 long __builtin_alpha_minsw4 (long, long)
11703 long __builtin_alpha_maxub8 (long, long)
11704 long __builtin_alpha_maxsb8 (long, long)
11705 long __builtin_alpha_maxuw4 (long, long)
11706 long __builtin_alpha_maxsw4 (long, long)
11707 long __builtin_alpha_perr (long, long)
11708 @end smallexample
11709
11710 The following built-in functions are always with @option{-mcix}
11711 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11712 later. They all generate the machine instruction that is part
11713 of the name.
11714
11715 @smallexample
11716 long __builtin_alpha_cttz (long)
11717 long __builtin_alpha_ctlz (long)
11718 long __builtin_alpha_ctpop (long)
11719 @end smallexample
11720
11721 The following built-in functions are available on systems that use the OSF/1
11722 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
11723 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11724 @code{rdval} and @code{wrval}.
11725
11726 @smallexample
11727 void *__builtin_thread_pointer (void)
11728 void __builtin_set_thread_pointer (void *)
11729 @end smallexample
11730
11731 @node Altera Nios II Built-in Functions
11732 @subsection Altera Nios II Built-in Functions
11733
11734 These built-in functions are available for the Altera Nios II
11735 family of processors.
11736
11737 The following built-in functions are always available. They
11738 all generate the machine instruction that is part of the name.
11739
11740 @example
11741 int __builtin_ldbio (volatile const void *)
11742 int __builtin_ldbuio (volatile const void *)
11743 int __builtin_ldhio (volatile const void *)
11744 int __builtin_ldhuio (volatile const void *)
11745 int __builtin_ldwio (volatile const void *)
11746 void __builtin_stbio (volatile void *, int)
11747 void __builtin_sthio (volatile void *, int)
11748 void __builtin_stwio (volatile void *, int)
11749 void __builtin_sync (void)
11750 int __builtin_rdctl (int)
11751 int __builtin_rdprs (int, int)
11752 void __builtin_wrctl (int, int)
11753 void __builtin_flushd (volatile void *)
11754 void __builtin_flushda (volatile void *)
11755 int __builtin_wrpie (int);
11756 void __builtin_eni (int);
11757 int __builtin_ldex (volatile const void *)
11758 int __builtin_stex (volatile void *, int)
11759 int __builtin_ldsex (volatile const void *)
11760 int __builtin_stsex (volatile void *, int)
11761 @end example
11762
11763 The following built-in functions are always available. They
11764 all generate a Nios II Custom Instruction. The name of the
11765 function represents the types that the function takes and
11766 returns. The letter before the @code{n} is the return type
11767 or void if absent. The @code{n} represents the first parameter
11768 to all the custom instructions, the custom instruction number.
11769 The two letters after the @code{n} represent the up to two
11770 parameters to the function.
11771
11772 The letters represent the following data types:
11773 @table @code
11774 @item <no letter>
11775 @code{void} for return type and no parameter for parameter types.
11776
11777 @item i
11778 @code{int} for return type and parameter type
11779
11780 @item f
11781 @code{float} for return type and parameter type
11782
11783 @item p
11784 @code{void *} for return type and parameter type
11785
11786 @end table
11787
11788 And the function names are:
11789 @example
11790 void __builtin_custom_n (void)
11791 void __builtin_custom_ni (int)
11792 void __builtin_custom_nf (float)
11793 void __builtin_custom_np (void *)
11794 void __builtin_custom_nii (int, int)
11795 void __builtin_custom_nif (int, float)
11796 void __builtin_custom_nip (int, void *)
11797 void __builtin_custom_nfi (float, int)
11798 void __builtin_custom_nff (float, float)
11799 void __builtin_custom_nfp (float, void *)
11800 void __builtin_custom_npi (void *, int)
11801 void __builtin_custom_npf (void *, float)
11802 void __builtin_custom_npp (void *, void *)
11803 int __builtin_custom_in (void)
11804 int __builtin_custom_ini (int)
11805 int __builtin_custom_inf (float)
11806 int __builtin_custom_inp (void *)
11807 int __builtin_custom_inii (int, int)
11808 int __builtin_custom_inif (int, float)
11809 int __builtin_custom_inip (int, void *)
11810 int __builtin_custom_infi (float, int)
11811 int __builtin_custom_inff (float, float)
11812 int __builtin_custom_infp (float, void *)
11813 int __builtin_custom_inpi (void *, int)
11814 int __builtin_custom_inpf (void *, float)
11815 int __builtin_custom_inpp (void *, void *)
11816 float __builtin_custom_fn (void)
11817 float __builtin_custom_fni (int)
11818 float __builtin_custom_fnf (float)
11819 float __builtin_custom_fnp (void *)
11820 float __builtin_custom_fnii (int, int)
11821 float __builtin_custom_fnif (int, float)
11822 float __builtin_custom_fnip (int, void *)
11823 float __builtin_custom_fnfi (float, int)
11824 float __builtin_custom_fnff (float, float)
11825 float __builtin_custom_fnfp (float, void *)
11826 float __builtin_custom_fnpi (void *, int)
11827 float __builtin_custom_fnpf (void *, float)
11828 float __builtin_custom_fnpp (void *, void *)
11829 void * __builtin_custom_pn (void)
11830 void * __builtin_custom_pni (int)
11831 void * __builtin_custom_pnf (float)
11832 void * __builtin_custom_pnp (void *)
11833 void * __builtin_custom_pnii (int, int)
11834 void * __builtin_custom_pnif (int, float)
11835 void * __builtin_custom_pnip (int, void *)
11836 void * __builtin_custom_pnfi (float, int)
11837 void * __builtin_custom_pnff (float, float)
11838 void * __builtin_custom_pnfp (float, void *)
11839 void * __builtin_custom_pnpi (void *, int)
11840 void * __builtin_custom_pnpf (void *, float)
11841 void * __builtin_custom_pnpp (void *, void *)
11842 @end example
11843
11844 @node ARC Built-in Functions
11845 @subsection ARC Built-in Functions
11846
11847 The following built-in functions are provided for ARC targets. The
11848 built-ins generate the corresponding assembly instructions. In the
11849 examples given below, the generated code often requires an operand or
11850 result to be in a register. Where necessary further code will be
11851 generated to ensure this is true, but for brevity this is not
11852 described in each case.
11853
11854 @emph{Note:} Using a built-in to generate an instruction not supported
11855 by a target may cause problems. At present the compiler is not
11856 guaranteed to detect such misuse, and as a result an internal compiler
11857 error may be generated.
11858
11859 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
11860 Return 1 if @var{val} is known to have the byte alignment given
11861 by @var{alignval}, otherwise return 0.
11862 Note that this is different from
11863 @smallexample
11864 __alignof__(*(char *)@var{val}) >= alignval
11865 @end smallexample
11866 because __alignof__ sees only the type of the dereference, whereas
11867 __builtin_arc_align uses alignment information from the pointer
11868 as well as from the pointed-to type.
11869 The information available will depend on optimization level.
11870 @end deftypefn
11871
11872 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
11873 Generates
11874 @example
11875 brk
11876 @end example
11877 @end deftypefn
11878
11879 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
11880 The operand is the number of a register to be read. Generates:
11881 @example
11882 mov @var{dest}, r@var{regno}
11883 @end example
11884 where the value in @var{dest} will be the result returned from the
11885 built-in.
11886 @end deftypefn
11887
11888 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
11889 The first operand is the number of a register to be written, the
11890 second operand is a compile time constant to write into that
11891 register. Generates:
11892 @example
11893 mov r@var{regno}, @var{val}
11894 @end example
11895 @end deftypefn
11896
11897 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
11898 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
11899 Generates:
11900 @example
11901 divaw @var{dest}, @var{a}, @var{b}
11902 @end example
11903 where the value in @var{dest} will be the result returned from the
11904 built-in.
11905 @end deftypefn
11906
11907 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
11908 Generates
11909 @example
11910 flag @var{a}
11911 @end example
11912 @end deftypefn
11913
11914 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
11915 The operand, @var{auxv}, is the address of an auxiliary register and
11916 must be a compile time constant. Generates:
11917 @example
11918 lr @var{dest}, [@var{auxr}]
11919 @end example
11920 Where the value in @var{dest} will be the result returned from the
11921 built-in.
11922 @end deftypefn
11923
11924 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
11925 Only available with @option{-mmul64}. Generates:
11926 @example
11927 mul64 @var{a}, @var{b}
11928 @end example
11929 @end deftypefn
11930
11931 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
11932 Only available with @option{-mmul64}. Generates:
11933 @example
11934 mulu64 @var{a}, @var{b}
11935 @end example
11936 @end deftypefn
11937
11938 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
11939 Generates:
11940 @example
11941 nop
11942 @end example
11943 @end deftypefn
11944
11945 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
11946 Only valid if the @samp{norm} instruction is available through the
11947 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11948 Generates:
11949 @example
11950 norm @var{dest}, @var{src}
11951 @end example
11952 Where the value in @var{dest} will be the result returned from the
11953 built-in.
11954 @end deftypefn
11955
11956 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
11957 Only valid if the @samp{normw} instruction is available through the
11958 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11959 Generates:
11960 @example
11961 normw @var{dest}, @var{src}
11962 @end example
11963 Where the value in @var{dest} will be the result returned from the
11964 built-in.
11965 @end deftypefn
11966
11967 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
11968 Generates:
11969 @example
11970 rtie
11971 @end example
11972 @end deftypefn
11973
11974 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
11975 Generates:
11976 @example
11977 sleep @var{a}
11978 @end example
11979 @end deftypefn
11980
11981 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
11982 The first argument, @var{auxv}, is the address of an auxiliary
11983 register, the second argument, @var{val}, is a compile time constant
11984 to be written to the register. Generates:
11985 @example
11986 sr @var{auxr}, [@var{val}]
11987 @end example
11988 @end deftypefn
11989
11990 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
11991 Only valid with @option{-mswap}. Generates:
11992 @example
11993 swap @var{dest}, @var{src}
11994 @end example
11995 Where the value in @var{dest} will be the result returned from the
11996 built-in.
11997 @end deftypefn
11998
11999 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
12000 Generates:
12001 @example
12002 swi
12003 @end example
12004 @end deftypefn
12005
12006 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
12007 Only available with @option{-mcpu=ARC700}. Generates:
12008 @example
12009 sync
12010 @end example
12011 @end deftypefn
12012
12013 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
12014 Only available with @option{-mcpu=ARC700}. Generates:
12015 @example
12016 trap_s @var{c}
12017 @end example
12018 @end deftypefn
12019
12020 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
12021 Only available with @option{-mcpu=ARC700}. Generates:
12022 @example
12023 unimp_s
12024 @end example
12025 @end deftypefn
12026
12027 The instructions generated by the following builtins are not
12028 considered as candidates for scheduling. They are not moved around by
12029 the compiler during scheduling, and thus can be expected to appear
12030 where they are put in the C code:
12031 @example
12032 __builtin_arc_brk()
12033 __builtin_arc_core_read()
12034 __builtin_arc_core_write()
12035 __builtin_arc_flag()
12036 __builtin_arc_lr()
12037 __builtin_arc_sleep()
12038 __builtin_arc_sr()
12039 __builtin_arc_swi()
12040 @end example
12041
12042 @node ARC SIMD Built-in Functions
12043 @subsection ARC SIMD Built-in Functions
12044
12045 SIMD builtins provided by the compiler can be used to generate the
12046 vector instructions. This section describes the available builtins
12047 and their usage in programs. With the @option{-msimd} option, the
12048 compiler provides 128-bit vector types, which can be specified using
12049 the @code{vector_size} attribute. The header file @file{arc-simd.h}
12050 can be included to use the following predefined types:
12051 @example
12052 typedef int __v4si __attribute__((vector_size(16)));
12053 typedef short __v8hi __attribute__((vector_size(16)));
12054 @end example
12055
12056 These types can be used to define 128-bit variables. The built-in
12057 functions listed in the following section can be used on these
12058 variables to generate the vector operations.
12059
12060 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12061 @file{arc-simd.h} also provides equivalent macros called
12062 @code{_@var{someinsn}} that can be used for programming ease and
12063 improved readability. The following macros for DMA control are also
12064 provided:
12065 @example
12066 #define _setup_dma_in_channel_reg _vdiwr
12067 #define _setup_dma_out_channel_reg _vdowr
12068 @end example
12069
12070 The following is a complete list of all the SIMD built-ins provided
12071 for ARC, grouped by calling signature.
12072
12073 The following take two @code{__v8hi} arguments and return a
12074 @code{__v8hi} result:
12075 @example
12076 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12077 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12078 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12079 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12080 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12081 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12082 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12083 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
12084 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
12085 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
12086 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
12087 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
12088 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
12089 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12090 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12091 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12092 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12093 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12094 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12095 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12096 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12097 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
12098 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
12099 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
12100 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
12101 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
12102 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
12103 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
12104 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
12105 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
12106 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
12107 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
12108 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
12109 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
12110 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
12111 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
12112 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
12113 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
12114 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
12115 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
12116 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
12117 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
12118 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
12119 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
12120 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
12121 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
12122 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
12123 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
12124 @end example
12125
12126 The following take one @code{__v8hi} and one @code{int} argument and return a
12127 @code{__v8hi} result:
12128
12129 @example
12130 __v8hi __builtin_arc_vbaddw (__v8hi, int)
12131 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
12132 __v8hi __builtin_arc_vbminw (__v8hi, int)
12133 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
12134 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
12135 __v8hi __builtin_arc_vbmulw (__v8hi, int)
12136 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
12137 __v8hi __builtin_arc_vbsubw (__v8hi, int)
12138 @end example
12139
12140 The following take one @code{__v8hi} argument and one @code{int} argument which
12141 must be a 3-bit compile time constant indicating a register number
12142 I0-I7. They return a @code{__v8hi} result.
12143 @example
12144 __v8hi __builtin_arc_vasrw (__v8hi, const int)
12145 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
12146 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
12147 @end example
12148
12149 The following take one @code{__v8hi} argument and one @code{int}
12150 argument which must be a 6-bit compile time constant. They return a
12151 @code{__v8hi} result.
12152 @example
12153 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
12154 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
12155 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
12156 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
12157 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
12158 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
12159 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
12160 @end example
12161
12162 The following take one @code{__v8hi} argument and one @code{int} argument which
12163 must be a 8-bit compile time constant. They return a @code{__v8hi}
12164 result.
12165 @example
12166 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
12167 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
12168 __v8hi __builtin_arc_vmvw (__v8hi, const int)
12169 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
12170 @end example
12171
12172 The following take two @code{int} arguments, the second of which which
12173 must be a 8-bit compile time constant. They return a @code{__v8hi}
12174 result:
12175 @example
12176 __v8hi __builtin_arc_vmovaw (int, const int)
12177 __v8hi __builtin_arc_vmovw (int, const int)
12178 __v8hi __builtin_arc_vmovzw (int, const int)
12179 @end example
12180
12181 The following take a single @code{__v8hi} argument and return a
12182 @code{__v8hi} result:
12183 @example
12184 __v8hi __builtin_arc_vabsaw (__v8hi)
12185 __v8hi __builtin_arc_vabsw (__v8hi)
12186 __v8hi __builtin_arc_vaddsuw (__v8hi)
12187 __v8hi __builtin_arc_vexch1 (__v8hi)
12188 __v8hi __builtin_arc_vexch2 (__v8hi)
12189 __v8hi __builtin_arc_vexch4 (__v8hi)
12190 __v8hi __builtin_arc_vsignw (__v8hi)
12191 __v8hi __builtin_arc_vupbaw (__v8hi)
12192 __v8hi __builtin_arc_vupbw (__v8hi)
12193 __v8hi __builtin_arc_vupsbaw (__v8hi)
12194 __v8hi __builtin_arc_vupsbw (__v8hi)
12195 @end example
12196
12197 The following take two @code{int} arguments and return no result:
12198 @example
12199 void __builtin_arc_vdirun (int, int)
12200 void __builtin_arc_vdorun (int, int)
12201 @end example
12202
12203 The following take two @code{int} arguments and return no result. The
12204 first argument must a 3-bit compile time constant indicating one of
12205 the DR0-DR7 DMA setup channels:
12206 @example
12207 void __builtin_arc_vdiwr (const int, int)
12208 void __builtin_arc_vdowr (const int, int)
12209 @end example
12210
12211 The following take an @code{int} argument and return no result:
12212 @example
12213 void __builtin_arc_vendrec (int)
12214 void __builtin_arc_vrec (int)
12215 void __builtin_arc_vrecrun (int)
12216 void __builtin_arc_vrun (int)
12217 @end example
12218
12219 The following take a @code{__v8hi} argument and two @code{int}
12220 arguments and return a @code{__v8hi} result. The second argument must
12221 be a 3-bit compile time constants, indicating one the registers I0-I7,
12222 and the third argument must be an 8-bit compile time constant.
12223
12224 @emph{Note:} Although the equivalent hardware instructions do not take
12225 an SIMD register as an operand, these builtins overwrite the relevant
12226 bits of the @code{__v8hi} register provided as the first argument with
12227 the value loaded from the @code{[Ib, u8]} location in the SDM.
12228
12229 @example
12230 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12231 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12232 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12233 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12234 @end example
12235
12236 The following take two @code{int} arguments and return a @code{__v8hi}
12237 result. The first argument must be a 3-bit compile time constants,
12238 indicating one the registers I0-I7, and the second argument must be an
12239 8-bit compile time constant.
12240
12241 @example
12242 __v8hi __builtin_arc_vld128 (const int, const int)
12243 __v8hi __builtin_arc_vld64w (const int, const int)
12244 @end example
12245
12246 The following take a @code{__v8hi} argument and two @code{int}
12247 arguments and return no result. The second argument must be a 3-bit
12248 compile time constants, indicating one the registers I0-I7, and the
12249 third argument must be an 8-bit compile time constant.
12250
12251 @example
12252 void __builtin_arc_vst128 (__v8hi, const int, const int)
12253 void __builtin_arc_vst64 (__v8hi, const int, const int)
12254 @end example
12255
12256 The following take a @code{__v8hi} argument and three @code{int}
12257 arguments and return no result. The second argument must be a 3-bit
12258 compile-time constant, identifying the 16-bit sub-register to be
12259 stored, the third argument must be a 3-bit compile time constants,
12260 indicating one the registers I0-I7, and the fourth argument must be an
12261 8-bit compile time constant.
12262
12263 @example
12264 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12265 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12266 @end example
12267
12268 @node ARM iWMMXt Built-in Functions
12269 @subsection ARM iWMMXt Built-in Functions
12270
12271 These built-in functions are available for the ARM family of
12272 processors when the @option{-mcpu=iwmmxt} switch is used:
12273
12274 @smallexample
12275 typedef int v2si __attribute__ ((vector_size (8)));
12276 typedef short v4hi __attribute__ ((vector_size (8)));
12277 typedef char v8qi __attribute__ ((vector_size (8)));
12278
12279 int __builtin_arm_getwcgr0 (void)
12280 void __builtin_arm_setwcgr0 (int)
12281 int __builtin_arm_getwcgr1 (void)
12282 void __builtin_arm_setwcgr1 (int)
12283 int __builtin_arm_getwcgr2 (void)
12284 void __builtin_arm_setwcgr2 (int)
12285 int __builtin_arm_getwcgr3 (void)
12286 void __builtin_arm_setwcgr3 (int)
12287 int __builtin_arm_textrmsb (v8qi, int)
12288 int __builtin_arm_textrmsh (v4hi, int)
12289 int __builtin_arm_textrmsw (v2si, int)
12290 int __builtin_arm_textrmub (v8qi, int)
12291 int __builtin_arm_textrmuh (v4hi, int)
12292 int __builtin_arm_textrmuw (v2si, int)
12293 v8qi __builtin_arm_tinsrb (v8qi, int, int)
12294 v4hi __builtin_arm_tinsrh (v4hi, int, int)
12295 v2si __builtin_arm_tinsrw (v2si, int, int)
12296 long long __builtin_arm_tmia (long long, int, int)
12297 long long __builtin_arm_tmiabb (long long, int, int)
12298 long long __builtin_arm_tmiabt (long long, int, int)
12299 long long __builtin_arm_tmiaph (long long, int, int)
12300 long long __builtin_arm_tmiatb (long long, int, int)
12301 long long __builtin_arm_tmiatt (long long, int, int)
12302 int __builtin_arm_tmovmskb (v8qi)
12303 int __builtin_arm_tmovmskh (v4hi)
12304 int __builtin_arm_tmovmskw (v2si)
12305 long long __builtin_arm_waccb (v8qi)
12306 long long __builtin_arm_wacch (v4hi)
12307 long long __builtin_arm_waccw (v2si)
12308 v8qi __builtin_arm_waddb (v8qi, v8qi)
12309 v8qi __builtin_arm_waddbss (v8qi, v8qi)
12310 v8qi __builtin_arm_waddbus (v8qi, v8qi)
12311 v4hi __builtin_arm_waddh (v4hi, v4hi)
12312 v4hi __builtin_arm_waddhss (v4hi, v4hi)
12313 v4hi __builtin_arm_waddhus (v4hi, v4hi)
12314 v2si __builtin_arm_waddw (v2si, v2si)
12315 v2si __builtin_arm_waddwss (v2si, v2si)
12316 v2si __builtin_arm_waddwus (v2si, v2si)
12317 v8qi __builtin_arm_walign (v8qi, v8qi, int)
12318 long long __builtin_arm_wand(long long, long long)
12319 long long __builtin_arm_wandn (long long, long long)
12320 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
12321 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
12322 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
12323 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
12324 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12325 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12326 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12327 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12328 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12329 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12330 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12331 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12332 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12333 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12334 long long __builtin_arm_wmacsz (v4hi, v4hi)
12335 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12336 long long __builtin_arm_wmacuz (v4hi, v4hi)
12337 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12338 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12339 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12340 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12341 v2si __builtin_arm_wmaxsw (v2si, v2si)
12342 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12343 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12344 v2si __builtin_arm_wmaxuw (v2si, v2si)
12345 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12346 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12347 v2si __builtin_arm_wminsw (v2si, v2si)
12348 v8qi __builtin_arm_wminub (v8qi, v8qi)
12349 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12350 v2si __builtin_arm_wminuw (v2si, v2si)
12351 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12352 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12353 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12354 long long __builtin_arm_wor (long long, long long)
12355 v2si __builtin_arm_wpackdss (long long, long long)
12356 v2si __builtin_arm_wpackdus (long long, long long)
12357 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12358 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12359 v4hi __builtin_arm_wpackwss (v2si, v2si)
12360 v4hi __builtin_arm_wpackwus (v2si, v2si)
12361 long long __builtin_arm_wrord (long long, long long)
12362 long long __builtin_arm_wrordi (long long, int)
12363 v4hi __builtin_arm_wrorh (v4hi, long long)
12364 v4hi __builtin_arm_wrorhi (v4hi, int)
12365 v2si __builtin_arm_wrorw (v2si, long long)
12366 v2si __builtin_arm_wrorwi (v2si, int)
12367 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12368 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12369 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12370 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12371 v4hi __builtin_arm_wshufh (v4hi, int)
12372 long long __builtin_arm_wslld (long long, long long)
12373 long long __builtin_arm_wslldi (long long, int)
12374 v4hi __builtin_arm_wsllh (v4hi, long long)
12375 v4hi __builtin_arm_wsllhi (v4hi, int)
12376 v2si __builtin_arm_wsllw (v2si, long long)
12377 v2si __builtin_arm_wsllwi (v2si, int)
12378 long long __builtin_arm_wsrad (long long, long long)
12379 long long __builtin_arm_wsradi (long long, int)
12380 v4hi __builtin_arm_wsrah (v4hi, long long)
12381 v4hi __builtin_arm_wsrahi (v4hi, int)
12382 v2si __builtin_arm_wsraw (v2si, long long)
12383 v2si __builtin_arm_wsrawi (v2si, int)
12384 long long __builtin_arm_wsrld (long long, long long)
12385 long long __builtin_arm_wsrldi (long long, int)
12386 v4hi __builtin_arm_wsrlh (v4hi, long long)
12387 v4hi __builtin_arm_wsrlhi (v4hi, int)
12388 v2si __builtin_arm_wsrlw (v2si, long long)
12389 v2si __builtin_arm_wsrlwi (v2si, int)
12390 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12391 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12392 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12393 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12394 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12395 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12396 v2si __builtin_arm_wsubw (v2si, v2si)
12397 v2si __builtin_arm_wsubwss (v2si, v2si)
12398 v2si __builtin_arm_wsubwus (v2si, v2si)
12399 v4hi __builtin_arm_wunpckehsb (v8qi)
12400 v2si __builtin_arm_wunpckehsh (v4hi)
12401 long long __builtin_arm_wunpckehsw (v2si)
12402 v4hi __builtin_arm_wunpckehub (v8qi)
12403 v2si __builtin_arm_wunpckehuh (v4hi)
12404 long long __builtin_arm_wunpckehuw (v2si)
12405 v4hi __builtin_arm_wunpckelsb (v8qi)
12406 v2si __builtin_arm_wunpckelsh (v4hi)
12407 long long __builtin_arm_wunpckelsw (v2si)
12408 v4hi __builtin_arm_wunpckelub (v8qi)
12409 v2si __builtin_arm_wunpckeluh (v4hi)
12410 long long __builtin_arm_wunpckeluw (v2si)
12411 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12412 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12413 v2si __builtin_arm_wunpckihw (v2si, v2si)
12414 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12415 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12416 v2si __builtin_arm_wunpckilw (v2si, v2si)
12417 long long __builtin_arm_wxor (long long, long long)
12418 long long __builtin_arm_wzero ()
12419 @end smallexample
12420
12421
12422 @node ARM C Language Extensions (ACLE)
12423 @subsection ARM C Language Extensions (ACLE)
12424
12425 GCC implements extensions for C as described in the ARM C Language
12426 Extensions (ACLE) specification, which can be found at
12427 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12428
12429 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12430 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
12431 intrinsics can be found at
12432 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12433 The built-in intrinsics for the Advanced SIMD extension are available when
12434 NEON is enabled.
12435
12436 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
12437 back ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM back end's
12438 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12439 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12440 intrinsics yet.
12441
12442 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12443 availability of extensions.
12444
12445 @node ARM Floating Point Status and Control Intrinsics
12446 @subsection ARM Floating Point Status and Control Intrinsics
12447
12448 These built-in functions are available for the ARM family of
12449 processors with floating-point unit.
12450
12451 @smallexample
12452 unsigned int __builtin_arm_get_fpscr ()
12453 void __builtin_arm_set_fpscr (unsigned int)
12454 @end smallexample
12455
12456 @node AVR Built-in Functions
12457 @subsection AVR Built-in Functions
12458
12459 For each built-in function for AVR, there is an equally named,
12460 uppercase built-in macro defined. That way users can easily query if
12461 or if not a specific built-in is implemented or not. For example, if
12462 @code{__builtin_avr_nop} is available the macro
12463 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12464
12465 The following built-in functions map to the respective machine
12466 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12467 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12468 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12469 as library call if no hardware multiplier is available.
12470
12471 @smallexample
12472 void __builtin_avr_nop (void)
12473 void __builtin_avr_sei (void)
12474 void __builtin_avr_cli (void)
12475 void __builtin_avr_sleep (void)
12476 void __builtin_avr_wdr (void)
12477 unsigned char __builtin_avr_swap (unsigned char)
12478 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12479 int __builtin_avr_fmuls (char, char)
12480 int __builtin_avr_fmulsu (char, unsigned char)
12481 @end smallexample
12482
12483 In order to delay execution for a specific number of cycles, GCC
12484 implements
12485 @smallexample
12486 void __builtin_avr_delay_cycles (unsigned long ticks)
12487 @end smallexample
12488
12489 @noindent
12490 @code{ticks} is the number of ticks to delay execution. Note that this
12491 built-in does not take into account the effect of interrupts that
12492 might increase delay time. @code{ticks} must be a compile-time
12493 integer constant; delays with a variable number of cycles are not supported.
12494
12495 @smallexample
12496 char __builtin_avr_flash_segment (const __memx void*)
12497 @end smallexample
12498
12499 @noindent
12500 This built-in takes a byte address to the 24-bit
12501 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12502 the number of the flash segment (the 64 KiB chunk) where the address
12503 points to. Counting starts at @code{0}.
12504 If the address does not point to flash memory, return @code{-1}.
12505
12506 @smallexample
12507 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
12508 @end smallexample
12509
12510 @noindent
12511 Insert bits from @var{bits} into @var{val} and return the resulting
12512 value. The nibbles of @var{map} determine how the insertion is
12513 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12514 @enumerate
12515 @item If @var{X} is @code{0xf},
12516 then the @var{n}-th bit of @var{val} is returned unaltered.
12517
12518 @item If X is in the range 0@dots{}7,
12519 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12520
12521 @item If X is in the range 8@dots{}@code{0xe},
12522 then the @var{n}-th result bit is undefined.
12523 @end enumerate
12524
12525 @noindent
12526 One typical use case for this built-in is adjusting input and
12527 output values to non-contiguous port layouts. Some examples:
12528
12529 @smallexample
12530 // same as val, bits is unused
12531 __builtin_avr_insert_bits (0xffffffff, bits, val)
12532 @end smallexample
12533
12534 @smallexample
12535 // same as bits, val is unused
12536 __builtin_avr_insert_bits (0x76543210, bits, val)
12537 @end smallexample
12538
12539 @smallexample
12540 // same as rotating bits by 4
12541 __builtin_avr_insert_bits (0x32107654, bits, 0)
12542 @end smallexample
12543
12544 @smallexample
12545 // high nibble of result is the high nibble of val
12546 // low nibble of result is the low nibble of bits
12547 __builtin_avr_insert_bits (0xffff3210, bits, val)
12548 @end smallexample
12549
12550 @smallexample
12551 // reverse the bit order of bits
12552 __builtin_avr_insert_bits (0x01234567, bits, 0)
12553 @end smallexample
12554
12555 @smallexample
12556 void __builtin_avr_nops (unsigned count)
12557 @end smallexample
12558
12559 @noindent
12560 Insert @code{count} @code{NOP} instructions.
12561 The number of instructions must be a compile-time integer constant.
12562
12563 @node Blackfin Built-in Functions
12564 @subsection Blackfin Built-in Functions
12565
12566 Currently, there are two Blackfin-specific built-in functions. These are
12567 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12568 using inline assembly; by using these built-in functions the compiler can
12569 automatically add workarounds for hardware errata involving these
12570 instructions. These functions are named as follows:
12571
12572 @smallexample
12573 void __builtin_bfin_csync (void)
12574 void __builtin_bfin_ssync (void)
12575 @end smallexample
12576
12577 @node FR-V Built-in Functions
12578 @subsection FR-V Built-in Functions
12579
12580 GCC provides many FR-V-specific built-in functions. In general,
12581 these functions are intended to be compatible with those described
12582 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12583 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
12584 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12585 pointer rather than by value.
12586
12587 Most of the functions are named after specific FR-V instructions.
12588 Such functions are said to be ``directly mapped'' and are summarized
12589 here in tabular form.
12590
12591 @menu
12592 * Argument Types::
12593 * Directly-mapped Integer Functions::
12594 * Directly-mapped Media Functions::
12595 * Raw read/write Functions::
12596 * Other Built-in Functions::
12597 @end menu
12598
12599 @node Argument Types
12600 @subsubsection Argument Types
12601
12602 The arguments to the built-in functions can be divided into three groups:
12603 register numbers, compile-time constants and run-time values. In order
12604 to make this classification clear at a glance, the arguments and return
12605 values are given the following pseudo types:
12606
12607 @multitable @columnfractions .20 .30 .15 .35
12608 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12609 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12610 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12611 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12612 @item @code{uw2} @tab @code{unsigned long long} @tab No
12613 @tab an unsigned doubleword
12614 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12615 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12616 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12617 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12618 @end multitable
12619
12620 These pseudo types are not defined by GCC, they are simply a notational
12621 convenience used in this manual.
12622
12623 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12624 and @code{sw2} are evaluated at run time. They correspond to
12625 register operands in the underlying FR-V instructions.
12626
12627 @code{const} arguments represent immediate operands in the underlying
12628 FR-V instructions. They must be compile-time constants.
12629
12630 @code{acc} arguments are evaluated at compile time and specify the number
12631 of an accumulator register. For example, an @code{acc} argument of 2
12632 selects the ACC2 register.
12633
12634 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12635 number of an IACC register. See @pxref{Other Built-in Functions}
12636 for more details.
12637
12638 @node Directly-mapped Integer Functions
12639 @subsubsection Directly-Mapped Integer Functions
12640
12641 The functions listed below map directly to FR-V I-type instructions.
12642
12643 @multitable @columnfractions .45 .32 .23
12644 @item Function prototype @tab Example usage @tab Assembly output
12645 @item @code{sw1 __ADDSS (sw1, sw1)}
12646 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12647 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12648 @item @code{sw1 __SCAN (sw1, sw1)}
12649 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12650 @tab @code{SCAN @var{a},@var{b},@var{c}}
12651 @item @code{sw1 __SCUTSS (sw1)}
12652 @tab @code{@var{b} = __SCUTSS (@var{a})}
12653 @tab @code{SCUTSS @var{a},@var{b}}
12654 @item @code{sw1 __SLASS (sw1, sw1)}
12655 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12656 @tab @code{SLASS @var{a},@var{b},@var{c}}
12657 @item @code{void __SMASS (sw1, sw1)}
12658 @tab @code{__SMASS (@var{a}, @var{b})}
12659 @tab @code{SMASS @var{a},@var{b}}
12660 @item @code{void __SMSSS (sw1, sw1)}
12661 @tab @code{__SMSSS (@var{a}, @var{b})}
12662 @tab @code{SMSSS @var{a},@var{b}}
12663 @item @code{void __SMU (sw1, sw1)}
12664 @tab @code{__SMU (@var{a}, @var{b})}
12665 @tab @code{SMU @var{a},@var{b}}
12666 @item @code{sw2 __SMUL (sw1, sw1)}
12667 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12668 @tab @code{SMUL @var{a},@var{b},@var{c}}
12669 @item @code{sw1 __SUBSS (sw1, sw1)}
12670 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12671 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12672 @item @code{uw2 __UMUL (uw1, uw1)}
12673 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12674 @tab @code{UMUL @var{a},@var{b},@var{c}}
12675 @end multitable
12676
12677 @node Directly-mapped Media Functions
12678 @subsubsection Directly-Mapped Media Functions
12679
12680 The functions listed below map directly to FR-V M-type instructions.
12681
12682 @multitable @columnfractions .45 .32 .23
12683 @item Function prototype @tab Example usage @tab Assembly output
12684 @item @code{uw1 __MABSHS (sw1)}
12685 @tab @code{@var{b} = __MABSHS (@var{a})}
12686 @tab @code{MABSHS @var{a},@var{b}}
12687 @item @code{void __MADDACCS (acc, acc)}
12688 @tab @code{__MADDACCS (@var{b}, @var{a})}
12689 @tab @code{MADDACCS @var{a},@var{b}}
12690 @item @code{sw1 __MADDHSS (sw1, sw1)}
12691 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12692 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12693 @item @code{uw1 __MADDHUS (uw1, uw1)}
12694 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12695 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12696 @item @code{uw1 __MAND (uw1, uw1)}
12697 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12698 @tab @code{MAND @var{a},@var{b},@var{c}}
12699 @item @code{void __MASACCS (acc, acc)}
12700 @tab @code{__MASACCS (@var{b}, @var{a})}
12701 @tab @code{MASACCS @var{a},@var{b}}
12702 @item @code{uw1 __MAVEH (uw1, uw1)}
12703 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12704 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12705 @item @code{uw2 __MBTOH (uw1)}
12706 @tab @code{@var{b} = __MBTOH (@var{a})}
12707 @tab @code{MBTOH @var{a},@var{b}}
12708 @item @code{void __MBTOHE (uw1 *, uw1)}
12709 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12710 @tab @code{MBTOHE @var{a},@var{b}}
12711 @item @code{void __MCLRACC (acc)}
12712 @tab @code{__MCLRACC (@var{a})}
12713 @tab @code{MCLRACC @var{a}}
12714 @item @code{void __MCLRACCA (void)}
12715 @tab @code{__MCLRACCA ()}
12716 @tab @code{MCLRACCA}
12717 @item @code{uw1 __Mcop1 (uw1, uw1)}
12718 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12719 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12720 @item @code{uw1 __Mcop2 (uw1, uw1)}
12721 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12722 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12723 @item @code{uw1 __MCPLHI (uw2, const)}
12724 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12725 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12726 @item @code{uw1 __MCPLI (uw2, const)}
12727 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12728 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12729 @item @code{void __MCPXIS (acc, sw1, sw1)}
12730 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12731 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12732 @item @code{void __MCPXIU (acc, uw1, uw1)}
12733 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12734 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12735 @item @code{void __MCPXRS (acc, sw1, sw1)}
12736 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12737 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12738 @item @code{void __MCPXRU (acc, uw1, uw1)}
12739 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12740 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12741 @item @code{uw1 __MCUT (acc, uw1)}
12742 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12743 @tab @code{MCUT @var{a},@var{b},@var{c}}
12744 @item @code{uw1 __MCUTSS (acc, sw1)}
12745 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12746 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12747 @item @code{void __MDADDACCS (acc, acc)}
12748 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12749 @tab @code{MDADDACCS @var{a},@var{b}}
12750 @item @code{void __MDASACCS (acc, acc)}
12751 @tab @code{__MDASACCS (@var{b}, @var{a})}
12752 @tab @code{MDASACCS @var{a},@var{b}}
12753 @item @code{uw2 __MDCUTSSI (acc, const)}
12754 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12755 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12756 @item @code{uw2 __MDPACKH (uw2, uw2)}
12757 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12758 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12759 @item @code{uw2 __MDROTLI (uw2, const)}
12760 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12761 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12762 @item @code{void __MDSUBACCS (acc, acc)}
12763 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12764 @tab @code{MDSUBACCS @var{a},@var{b}}
12765 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12766 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12767 @tab @code{MDUNPACKH @var{a},@var{b}}
12768 @item @code{uw2 __MEXPDHD (uw1, const)}
12769 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
12770 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
12771 @item @code{uw1 __MEXPDHW (uw1, const)}
12772 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
12773 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
12774 @item @code{uw1 __MHDSETH (uw1, const)}
12775 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
12776 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
12777 @item @code{sw1 __MHDSETS (const)}
12778 @tab @code{@var{b} = __MHDSETS (@var{a})}
12779 @tab @code{MHDSETS #@var{a},@var{b}}
12780 @item @code{uw1 __MHSETHIH (uw1, const)}
12781 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
12782 @tab @code{MHSETHIH #@var{a},@var{b}}
12783 @item @code{sw1 __MHSETHIS (sw1, const)}
12784 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
12785 @tab @code{MHSETHIS #@var{a},@var{b}}
12786 @item @code{uw1 __MHSETLOH (uw1, const)}
12787 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
12788 @tab @code{MHSETLOH #@var{a},@var{b}}
12789 @item @code{sw1 __MHSETLOS (sw1, const)}
12790 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
12791 @tab @code{MHSETLOS #@var{a},@var{b}}
12792 @item @code{uw1 __MHTOB (uw2)}
12793 @tab @code{@var{b} = __MHTOB (@var{a})}
12794 @tab @code{MHTOB @var{a},@var{b}}
12795 @item @code{void __MMACHS (acc, sw1, sw1)}
12796 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
12797 @tab @code{MMACHS @var{a},@var{b},@var{c}}
12798 @item @code{void __MMACHU (acc, uw1, uw1)}
12799 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
12800 @tab @code{MMACHU @var{a},@var{b},@var{c}}
12801 @item @code{void __MMRDHS (acc, sw1, sw1)}
12802 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
12803 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
12804 @item @code{void __MMRDHU (acc, uw1, uw1)}
12805 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
12806 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
12807 @item @code{void __MMULHS (acc, sw1, sw1)}
12808 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
12809 @tab @code{MMULHS @var{a},@var{b},@var{c}}
12810 @item @code{void __MMULHU (acc, uw1, uw1)}
12811 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
12812 @tab @code{MMULHU @var{a},@var{b},@var{c}}
12813 @item @code{void __MMULXHS (acc, sw1, sw1)}
12814 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
12815 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
12816 @item @code{void __MMULXHU (acc, uw1, uw1)}
12817 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
12818 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
12819 @item @code{uw1 __MNOT (uw1)}
12820 @tab @code{@var{b} = __MNOT (@var{a})}
12821 @tab @code{MNOT @var{a},@var{b}}
12822 @item @code{uw1 __MOR (uw1, uw1)}
12823 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
12824 @tab @code{MOR @var{a},@var{b},@var{c}}
12825 @item @code{uw1 __MPACKH (uh, uh)}
12826 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
12827 @tab @code{MPACKH @var{a},@var{b},@var{c}}
12828 @item @code{sw2 __MQADDHSS (sw2, sw2)}
12829 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
12830 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
12831 @item @code{uw2 __MQADDHUS (uw2, uw2)}
12832 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
12833 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
12834 @item @code{void __MQCPXIS (acc, sw2, sw2)}
12835 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
12836 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
12837 @item @code{void __MQCPXIU (acc, uw2, uw2)}
12838 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
12839 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
12840 @item @code{void __MQCPXRS (acc, sw2, sw2)}
12841 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
12842 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
12843 @item @code{void __MQCPXRU (acc, uw2, uw2)}
12844 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
12845 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
12846 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
12847 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
12848 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
12849 @item @code{sw2 __MQLMTHS (sw2, sw2)}
12850 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
12851 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
12852 @item @code{void __MQMACHS (acc, sw2, sw2)}
12853 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
12854 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
12855 @item @code{void __MQMACHU (acc, uw2, uw2)}
12856 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
12857 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
12858 @item @code{void __MQMACXHS (acc, sw2, sw2)}
12859 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
12860 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
12861 @item @code{void __MQMULHS (acc, sw2, sw2)}
12862 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
12863 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
12864 @item @code{void __MQMULHU (acc, uw2, uw2)}
12865 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
12866 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
12867 @item @code{void __MQMULXHS (acc, sw2, sw2)}
12868 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
12869 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
12870 @item @code{void __MQMULXHU (acc, uw2, uw2)}
12871 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
12872 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
12873 @item @code{sw2 __MQSATHS (sw2, sw2)}
12874 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
12875 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
12876 @item @code{uw2 __MQSLLHI (uw2, int)}
12877 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
12878 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
12879 @item @code{sw2 __MQSRAHI (sw2, int)}
12880 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
12881 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
12882 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
12883 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
12884 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
12885 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
12886 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
12887 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
12888 @item @code{void __MQXMACHS (acc, sw2, sw2)}
12889 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
12890 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
12891 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
12892 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
12893 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
12894 @item @code{uw1 __MRDACC (acc)}
12895 @tab @code{@var{b} = __MRDACC (@var{a})}
12896 @tab @code{MRDACC @var{a},@var{b}}
12897 @item @code{uw1 __MRDACCG (acc)}
12898 @tab @code{@var{b} = __MRDACCG (@var{a})}
12899 @tab @code{MRDACCG @var{a},@var{b}}
12900 @item @code{uw1 __MROTLI (uw1, const)}
12901 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
12902 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
12903 @item @code{uw1 __MROTRI (uw1, const)}
12904 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
12905 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
12906 @item @code{sw1 __MSATHS (sw1, sw1)}
12907 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
12908 @tab @code{MSATHS @var{a},@var{b},@var{c}}
12909 @item @code{uw1 __MSATHU (uw1, uw1)}
12910 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
12911 @tab @code{MSATHU @var{a},@var{b},@var{c}}
12912 @item @code{uw1 __MSLLHI (uw1, const)}
12913 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
12914 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
12915 @item @code{sw1 __MSRAHI (sw1, const)}
12916 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
12917 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
12918 @item @code{uw1 __MSRLHI (uw1, const)}
12919 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
12920 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
12921 @item @code{void __MSUBACCS (acc, acc)}
12922 @tab @code{__MSUBACCS (@var{b}, @var{a})}
12923 @tab @code{MSUBACCS @var{a},@var{b}}
12924 @item @code{sw1 __MSUBHSS (sw1, sw1)}
12925 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
12926 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
12927 @item @code{uw1 __MSUBHUS (uw1, uw1)}
12928 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
12929 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
12930 @item @code{void __MTRAP (void)}
12931 @tab @code{__MTRAP ()}
12932 @tab @code{MTRAP}
12933 @item @code{uw2 __MUNPACKH (uw1)}
12934 @tab @code{@var{b} = __MUNPACKH (@var{a})}
12935 @tab @code{MUNPACKH @var{a},@var{b}}
12936 @item @code{uw1 __MWCUT (uw2, uw1)}
12937 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
12938 @tab @code{MWCUT @var{a},@var{b},@var{c}}
12939 @item @code{void __MWTACC (acc, uw1)}
12940 @tab @code{__MWTACC (@var{b}, @var{a})}
12941 @tab @code{MWTACC @var{a},@var{b}}
12942 @item @code{void __MWTACCG (acc, uw1)}
12943 @tab @code{__MWTACCG (@var{b}, @var{a})}
12944 @tab @code{MWTACCG @var{a},@var{b}}
12945 @item @code{uw1 __MXOR (uw1, uw1)}
12946 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
12947 @tab @code{MXOR @var{a},@var{b},@var{c}}
12948 @end multitable
12949
12950 @node Raw read/write Functions
12951 @subsubsection Raw Read/Write Functions
12952
12953 This sections describes built-in functions related to read and write
12954 instructions to access memory. These functions generate
12955 @code{membar} instructions to flush the I/O load and stores where
12956 appropriate, as described in Fujitsu's manual described above.
12957
12958 @table @code
12959
12960 @item unsigned char __builtin_read8 (void *@var{data})
12961 @item unsigned short __builtin_read16 (void *@var{data})
12962 @item unsigned long __builtin_read32 (void *@var{data})
12963 @item unsigned long long __builtin_read64 (void *@var{data})
12964
12965 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
12966 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
12967 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
12968 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
12969 @end table
12970
12971 @node Other Built-in Functions
12972 @subsubsection Other Built-in Functions
12973
12974 This section describes built-in functions that are not named after
12975 a specific FR-V instruction.
12976
12977 @table @code
12978 @item sw2 __IACCreadll (iacc @var{reg})
12979 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
12980 for future expansion and must be 0.
12981
12982 @item sw1 __IACCreadl (iacc @var{reg})
12983 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
12984 Other values of @var{reg} are rejected as invalid.
12985
12986 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
12987 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
12988 is reserved for future expansion and must be 0.
12989
12990 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
12991 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
12992 is 1. Other values of @var{reg} are rejected as invalid.
12993
12994 @item void __data_prefetch0 (const void *@var{x})
12995 Use the @code{dcpl} instruction to load the contents of address @var{x}
12996 into the data cache.
12997
12998 @item void __data_prefetch (const void *@var{x})
12999 Use the @code{nldub} instruction to load the contents of address @var{x}
13000 into the data cache. The instruction is issued in slot I1@.
13001 @end table
13002
13003 @node MIPS DSP Built-in Functions
13004 @subsection MIPS DSP Built-in Functions
13005
13006 The MIPS DSP Application-Specific Extension (ASE) includes new
13007 instructions that are designed to improve the performance of DSP and
13008 media applications. It provides instructions that operate on packed
13009 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13010
13011 GCC supports MIPS DSP operations using both the generic
13012 vector extensions (@pxref{Vector Extensions}) and a collection of
13013 MIPS-specific built-in functions. Both kinds of support are
13014 enabled by the @option{-mdsp} command-line option.
13015
13016 Revision 2 of the ASE was introduced in the second half of 2006.
13017 This revision adds extra instructions to the original ASE, but is
13018 otherwise backwards-compatible with it. You can select revision 2
13019 using the command-line option @option{-mdspr2}; this option implies
13020 @option{-mdsp}.
13021
13022 The SCOUNT and POS bits of the DSP control register are global. The
13023 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13024 POS bits. During optimization, the compiler does not delete these
13025 instructions and it does not delete calls to functions containing
13026 these instructions.
13027
13028 At present, GCC only provides support for operations on 32-bit
13029 vectors. The vector type associated with 8-bit integer data is
13030 usually called @code{v4i8}, the vector type associated with Q7
13031 is usually called @code{v4q7}, the vector type associated with 16-bit
13032 integer data is usually called @code{v2i16}, and the vector type
13033 associated with Q15 is usually called @code{v2q15}. They can be
13034 defined in C as follows:
13035
13036 @smallexample
13037 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13038 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13039 typedef short v2i16 __attribute__ ((vector_size(4)));
13040 typedef short v2q15 __attribute__ ((vector_size(4)));
13041 @end smallexample
13042
13043 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13044 initialized in the same way as aggregates. For example:
13045
13046 @smallexample
13047 v4i8 a = @{1, 2, 3, 4@};
13048 v4i8 b;
13049 b = (v4i8) @{5, 6, 7, 8@};
13050
13051 v2q15 c = @{0x0fcb, 0x3a75@};
13052 v2q15 d;
13053 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13054 @end smallexample
13055
13056 @emph{Note:} The CPU's endianness determines the order in which values
13057 are packed. On little-endian targets, the first value is the least
13058 significant and the last value is the most significant. The opposite
13059 order applies to big-endian targets. For example, the code above
13060 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13061 and @code{4} on big-endian targets.
13062
13063 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13064 representation. As shown in this example, the integer representation
13065 of a Q7 value can be obtained by multiplying the fractional value by
13066 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
13067 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
13068 @code{0x1.0p31}.
13069
13070 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13071 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
13072 and @code{c} and @code{d} are @code{v2q15} values.
13073
13074 @multitable @columnfractions .50 .50
13075 @item C code @tab MIPS instruction
13076 @item @code{a + b} @tab @code{addu.qb}
13077 @item @code{c + d} @tab @code{addq.ph}
13078 @item @code{a - b} @tab @code{subu.qb}
13079 @item @code{c - d} @tab @code{subq.ph}
13080 @end multitable
13081
13082 The table below lists the @code{v2i16} operation for which
13083 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
13084 @code{v2i16} values.
13085
13086 @multitable @columnfractions .50 .50
13087 @item C code @tab MIPS instruction
13088 @item @code{e * f} @tab @code{mul.ph}
13089 @end multitable
13090
13091 It is easier to describe the DSP built-in functions if we first define
13092 the following types:
13093
13094 @smallexample
13095 typedef int q31;
13096 typedef int i32;
13097 typedef unsigned int ui32;
13098 typedef long long a64;
13099 @end smallexample
13100
13101 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13102 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13103 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
13104 @code{long long}, but we use @code{a64} to indicate values that are
13105 placed in one of the four DSP accumulators (@code{$ac0},
13106 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13107
13108 Also, some built-in functions prefer or require immediate numbers as
13109 parameters, because the corresponding DSP instructions accept both immediate
13110 numbers and register operands, or accept immediate numbers only. The
13111 immediate parameters are listed as follows.
13112
13113 @smallexample
13114 imm0_3: 0 to 3.
13115 imm0_7: 0 to 7.
13116 imm0_15: 0 to 15.
13117 imm0_31: 0 to 31.
13118 imm0_63: 0 to 63.
13119 imm0_255: 0 to 255.
13120 imm_n32_31: -32 to 31.
13121 imm_n512_511: -512 to 511.
13122 @end smallexample
13123
13124 The following built-in functions map directly to a particular MIPS DSP
13125 instruction. Please refer to the architecture specification
13126 for details on what each instruction does.
13127
13128 @smallexample
13129 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13130 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13131 q31 __builtin_mips_addq_s_w (q31, q31)
13132 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13133 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13134 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13135 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13136 q31 __builtin_mips_subq_s_w (q31, q31)
13137 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13138 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13139 i32 __builtin_mips_addsc (i32, i32)
13140 i32 __builtin_mips_addwc (i32, i32)
13141 i32 __builtin_mips_modsub (i32, i32)
13142 i32 __builtin_mips_raddu_w_qb (v4i8)
13143 v2q15 __builtin_mips_absq_s_ph (v2q15)
13144 q31 __builtin_mips_absq_s_w (q31)
13145 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13146 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13147 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13148 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13149 q31 __builtin_mips_preceq_w_phl (v2q15)
13150 q31 __builtin_mips_preceq_w_phr (v2q15)
13151 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13152 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13153 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13154 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13155 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13156 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13157 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13158 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13159 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13160 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13161 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13162 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13163 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13164 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13165 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13166 q31 __builtin_mips_shll_s_w (q31, i32)
13167 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13168 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13169 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13170 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13171 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13172 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13173 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13174 q31 __builtin_mips_shra_r_w (q31, i32)
13175 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13176 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13177 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13178 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13179 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13180 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13181 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13182 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13183 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13184 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13185 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13186 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13187 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13188 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13189 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13190 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13191 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13192 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13193 i32 __builtin_mips_bitrev (i32)
13194 i32 __builtin_mips_insv (i32, i32)
13195 v4i8 __builtin_mips_repl_qb (imm0_255)
13196 v4i8 __builtin_mips_repl_qb (i32)
13197 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13198 v2q15 __builtin_mips_repl_ph (i32)
13199 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13200 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13201 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13202 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13203 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13204 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13205 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13206 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13207 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13208 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13209 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13210 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13211 i32 __builtin_mips_extr_w (a64, imm0_31)
13212 i32 __builtin_mips_extr_w (a64, i32)
13213 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13214 i32 __builtin_mips_extr_s_h (a64, i32)
13215 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13216 i32 __builtin_mips_extr_rs_w (a64, i32)
13217 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13218 i32 __builtin_mips_extr_r_w (a64, i32)
13219 i32 __builtin_mips_extp (a64, imm0_31)
13220 i32 __builtin_mips_extp (a64, i32)
13221 i32 __builtin_mips_extpdp (a64, imm0_31)
13222 i32 __builtin_mips_extpdp (a64, i32)
13223 a64 __builtin_mips_shilo (a64, imm_n32_31)
13224 a64 __builtin_mips_shilo (a64, i32)
13225 a64 __builtin_mips_mthlip (a64, i32)
13226 void __builtin_mips_wrdsp (i32, imm0_63)
13227 i32 __builtin_mips_rddsp (imm0_63)
13228 i32 __builtin_mips_lbux (void *, i32)
13229 i32 __builtin_mips_lhx (void *, i32)
13230 i32 __builtin_mips_lwx (void *, i32)
13231 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13232 i32 __builtin_mips_bposge32 (void)
13233 a64 __builtin_mips_madd (a64, i32, i32);
13234 a64 __builtin_mips_maddu (a64, ui32, ui32);
13235 a64 __builtin_mips_msub (a64, i32, i32);
13236 a64 __builtin_mips_msubu (a64, ui32, ui32);
13237 a64 __builtin_mips_mult (i32, i32);
13238 a64 __builtin_mips_multu (ui32, ui32);
13239 @end smallexample
13240
13241 The following built-in functions map directly to a particular MIPS DSP REV 2
13242 instruction. Please refer to the architecture specification
13243 for details on what each instruction does.
13244
13245 @smallexample
13246 v4q7 __builtin_mips_absq_s_qb (v4q7);
13247 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13248 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13249 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13250 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13251 i32 __builtin_mips_append (i32, i32, imm0_31);
13252 i32 __builtin_mips_balign (i32, i32, imm0_3);
13253 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13254 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13255 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13256 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13257 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13258 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13259 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13260 q31 __builtin_mips_mulq_rs_w (q31, q31);
13261 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13262 q31 __builtin_mips_mulq_s_w (q31, q31);
13263 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13264 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13265 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13266 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13267 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13268 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13269 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13270 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13271 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13272 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13273 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13274 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13275 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13276 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13277 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13278 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13279 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13280 q31 __builtin_mips_addqh_w (q31, q31);
13281 q31 __builtin_mips_addqh_r_w (q31, q31);
13282 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13283 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13284 q31 __builtin_mips_subqh_w (q31, q31);
13285 q31 __builtin_mips_subqh_r_w (q31, q31);
13286 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13287 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13288 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13289 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13290 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13291 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13292 @end smallexample
13293
13294
13295 @node MIPS Paired-Single Support
13296 @subsection MIPS Paired-Single Support
13297
13298 The MIPS64 architecture includes a number of instructions that
13299 operate on pairs of single-precision floating-point values.
13300 Each pair is packed into a 64-bit floating-point register,
13301 with one element being designated the ``upper half'' and
13302 the other being designated the ``lower half''.
13303
13304 GCC supports paired-single operations using both the generic
13305 vector extensions (@pxref{Vector Extensions}) and a collection of
13306 MIPS-specific built-in functions. Both kinds of support are
13307 enabled by the @option{-mpaired-single} command-line option.
13308
13309 The vector type associated with paired-single values is usually
13310 called @code{v2sf}. It can be defined in C as follows:
13311
13312 @smallexample
13313 typedef float v2sf __attribute__ ((vector_size (8)));
13314 @end smallexample
13315
13316 @code{v2sf} values are initialized in the same way as aggregates.
13317 For example:
13318
13319 @smallexample
13320 v2sf a = @{1.5, 9.1@};
13321 v2sf b;
13322 float e, f;
13323 b = (v2sf) @{e, f@};
13324 @end smallexample
13325
13326 @emph{Note:} The CPU's endianness determines which value is stored in
13327 the upper half of a register and which value is stored in the lower half.
13328 On little-endian targets, the first value is the lower one and the second
13329 value is the upper one. The opposite order applies to big-endian targets.
13330 For example, the code above sets the lower half of @code{a} to
13331 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13332
13333 @node MIPS Loongson Built-in Functions
13334 @subsection MIPS Loongson Built-in Functions
13335
13336 GCC provides intrinsics to access the SIMD instructions provided by the
13337 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
13338 available after inclusion of the @code{loongson.h} header file,
13339 operate on the following 64-bit vector types:
13340
13341 @itemize
13342 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13343 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13344 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13345 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13346 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13347 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13348 @end itemize
13349
13350 The intrinsics provided are listed below; each is named after the
13351 machine instruction to which it corresponds, with suffixes added as
13352 appropriate to distinguish intrinsics that expand to the same machine
13353 instruction yet have different argument types. Refer to the architecture
13354 documentation for a description of the functionality of each
13355 instruction.
13356
13357 @smallexample
13358 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13359 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13360 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13361 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13362 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13363 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13364 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13365 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13366 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13367 uint64_t paddd_u (uint64_t s, uint64_t t);
13368 int64_t paddd_s (int64_t s, int64_t t);
13369 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13370 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13371 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13372 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13373 uint64_t pandn_ud (uint64_t s, uint64_t t);
13374 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13375 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13376 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13377 int64_t pandn_sd (int64_t s, int64_t t);
13378 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13379 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13380 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13381 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13382 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13383 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13384 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13385 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13386 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13387 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13388 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13389 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13390 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13391 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13392 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13393 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13394 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13395 uint16x4_t pextrh_u (uint16x4_t s, int field);
13396 int16x4_t pextrh_s (int16x4_t s, int field);
13397 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13398 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13399 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13400 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13401 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13402 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13403 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13404 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13405 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13406 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13407 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13408 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13409 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13410 uint8x8_t pmovmskb_u (uint8x8_t s);
13411 int8x8_t pmovmskb_s (int8x8_t s);
13412 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13413 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13414 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13415 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13416 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13417 uint16x4_t biadd (uint8x8_t s);
13418 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13419 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13420 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13421 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13422 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13423 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13424 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13425 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13426 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13427 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13428 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13429 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13430 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13431 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13432 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13433 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13434 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13435 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13436 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13437 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13438 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13439 uint64_t psubd_u (uint64_t s, uint64_t t);
13440 int64_t psubd_s (int64_t s, int64_t t);
13441 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13442 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13443 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13444 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13445 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13446 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13447 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13448 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13449 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13450 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13451 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13452 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13453 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13454 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13455 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13456 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13457 @end smallexample
13458
13459 @menu
13460 * Paired-Single Arithmetic::
13461 * Paired-Single Built-in Functions::
13462 * MIPS-3D Built-in Functions::
13463 @end menu
13464
13465 @node Paired-Single Arithmetic
13466 @subsubsection Paired-Single Arithmetic
13467
13468 The table below lists the @code{v2sf} operations for which hardware
13469 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13470 values and @code{x} is an integral value.
13471
13472 @multitable @columnfractions .50 .50
13473 @item C code @tab MIPS instruction
13474 @item @code{a + b} @tab @code{add.ps}
13475 @item @code{a - b} @tab @code{sub.ps}
13476 @item @code{-a} @tab @code{neg.ps}
13477 @item @code{a * b} @tab @code{mul.ps}
13478 @item @code{a * b + c} @tab @code{madd.ps}
13479 @item @code{a * b - c} @tab @code{msub.ps}
13480 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13481 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13482 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13483 @end multitable
13484
13485 Note that the multiply-accumulate instructions can be disabled
13486 using the command-line option @code{-mno-fused-madd}.
13487
13488 @node Paired-Single Built-in Functions
13489 @subsubsection Paired-Single Built-in Functions
13490
13491 The following paired-single functions map directly to a particular
13492 MIPS instruction. Please refer to the architecture specification
13493 for details on what each instruction does.
13494
13495 @table @code
13496 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13497 Pair lower lower (@code{pll.ps}).
13498
13499 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13500 Pair upper lower (@code{pul.ps}).
13501
13502 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13503 Pair lower upper (@code{plu.ps}).
13504
13505 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13506 Pair upper upper (@code{puu.ps}).
13507
13508 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13509 Convert pair to paired single (@code{cvt.ps.s}).
13510
13511 @item float __builtin_mips_cvt_s_pl (v2sf)
13512 Convert pair lower to single (@code{cvt.s.pl}).
13513
13514 @item float __builtin_mips_cvt_s_pu (v2sf)
13515 Convert pair upper to single (@code{cvt.s.pu}).
13516
13517 @item v2sf __builtin_mips_abs_ps (v2sf)
13518 Absolute value (@code{abs.ps}).
13519
13520 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13521 Align variable (@code{alnv.ps}).
13522
13523 @emph{Note:} The value of the third parameter must be 0 or 4
13524 modulo 8, otherwise the result is unpredictable. Please read the
13525 instruction description for details.
13526 @end table
13527
13528 The following multi-instruction functions are also available.
13529 In each case, @var{cond} can be any of the 16 floating-point conditions:
13530 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13531 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13532 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13533
13534 @table @code
13535 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13536 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13537 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13538 @code{movt.ps}/@code{movf.ps}).
13539
13540 The @code{movt} functions return the value @var{x} computed by:
13541
13542 @smallexample
13543 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13544 mov.ps @var{x},@var{c}
13545 movt.ps @var{x},@var{d},@var{cc}
13546 @end smallexample
13547
13548 The @code{movf} functions are similar but use @code{movf.ps} instead
13549 of @code{movt.ps}.
13550
13551 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13552 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13553 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13554 @code{bc1t}/@code{bc1f}).
13555
13556 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13557 and return either the upper or lower half of the result. For example:
13558
13559 @smallexample
13560 v2sf a, b;
13561 if (__builtin_mips_upper_c_eq_ps (a, b))
13562 upper_halves_are_equal ();
13563 else
13564 upper_halves_are_unequal ();
13565
13566 if (__builtin_mips_lower_c_eq_ps (a, b))
13567 lower_halves_are_equal ();
13568 else
13569 lower_halves_are_unequal ();
13570 @end smallexample
13571 @end table
13572
13573 @node MIPS-3D Built-in Functions
13574 @subsubsection MIPS-3D Built-in Functions
13575
13576 The MIPS-3D Application-Specific Extension (ASE) includes additional
13577 paired-single instructions that are designed to improve the performance
13578 of 3D graphics operations. Support for these instructions is controlled
13579 by the @option{-mips3d} command-line option.
13580
13581 The functions listed below map directly to a particular MIPS-3D
13582 instruction. Please refer to the architecture specification for
13583 more details on what each instruction does.
13584
13585 @table @code
13586 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13587 Reduction add (@code{addr.ps}).
13588
13589 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13590 Reduction multiply (@code{mulr.ps}).
13591
13592 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13593 Convert paired single to paired word (@code{cvt.pw.ps}).
13594
13595 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13596 Convert paired word to paired single (@code{cvt.ps.pw}).
13597
13598 @item float __builtin_mips_recip1_s (float)
13599 @itemx double __builtin_mips_recip1_d (double)
13600 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13601 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13602
13603 @item float __builtin_mips_recip2_s (float, float)
13604 @itemx double __builtin_mips_recip2_d (double, double)
13605 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13606 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13607
13608 @item float __builtin_mips_rsqrt1_s (float)
13609 @itemx double __builtin_mips_rsqrt1_d (double)
13610 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13611 Reduced-precision reciprocal square root (sequence step 1)
13612 (@code{rsqrt1.@var{fmt}}).
13613
13614 @item float __builtin_mips_rsqrt2_s (float, float)
13615 @itemx double __builtin_mips_rsqrt2_d (double, double)
13616 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13617 Reduced-precision reciprocal square root (sequence step 2)
13618 (@code{rsqrt2.@var{fmt}}).
13619 @end table
13620
13621 The following multi-instruction functions are also available.
13622 In each case, @var{cond} can be any of the 16 floating-point conditions:
13623 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13624 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13625 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13626
13627 @table @code
13628 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13629 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13630 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13631 @code{bc1t}/@code{bc1f}).
13632
13633 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13634 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13635 For example:
13636
13637 @smallexample
13638 float a, b;
13639 if (__builtin_mips_cabs_eq_s (a, b))
13640 true ();
13641 else
13642 false ();
13643 @end smallexample
13644
13645 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13646 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13647 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13648 @code{bc1t}/@code{bc1f}).
13649
13650 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13651 and return either the upper or lower half of the result. For example:
13652
13653 @smallexample
13654 v2sf a, b;
13655 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13656 upper_halves_are_equal ();
13657 else
13658 upper_halves_are_unequal ();
13659
13660 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13661 lower_halves_are_equal ();
13662 else
13663 lower_halves_are_unequal ();
13664 @end smallexample
13665
13666 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13667 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13668 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13669 @code{movt.ps}/@code{movf.ps}).
13670
13671 The @code{movt} functions return the value @var{x} computed by:
13672
13673 @smallexample
13674 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13675 mov.ps @var{x},@var{c}
13676 movt.ps @var{x},@var{d},@var{cc}
13677 @end smallexample
13678
13679 The @code{movf} functions are similar but use @code{movf.ps} instead
13680 of @code{movt.ps}.
13681
13682 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13683 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13684 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13685 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13686 Comparison of two paired-single values
13687 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13688 @code{bc1any2t}/@code{bc1any2f}).
13689
13690 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13691 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13692 result is true and the @code{all} forms return true if both results are true.
13693 For example:
13694
13695 @smallexample
13696 v2sf a, b;
13697 if (__builtin_mips_any_c_eq_ps (a, b))
13698 one_is_true ();
13699 else
13700 both_are_false ();
13701
13702 if (__builtin_mips_all_c_eq_ps (a, b))
13703 both_are_true ();
13704 else
13705 one_is_false ();
13706 @end smallexample
13707
13708 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13709 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13710 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13711 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13712 Comparison of four paired-single values
13713 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13714 @code{bc1any4t}/@code{bc1any4f}).
13715
13716 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13717 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13718 The @code{any} forms return true if any of the four results are true
13719 and the @code{all} forms return true if all four results are true.
13720 For example:
13721
13722 @smallexample
13723 v2sf a, b, c, d;
13724 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13725 some_are_true ();
13726 else
13727 all_are_false ();
13728
13729 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13730 all_are_true ();
13731 else
13732 some_are_false ();
13733 @end smallexample
13734 @end table
13735
13736 @node MIPS SIMD Architecture (MSA) Support
13737 @subsection MIPS SIMD Architecture (MSA) Support
13738
13739 @menu
13740 * MIPS SIMD Architecture Built-in Functions::
13741 @end menu
13742
13743 GCC provides intrinsics to access the SIMD instructions provided by the
13744 MSA MIPS SIMD Architecture. The interface is made available by including
13745 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
13746 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
13747 @code{__msa_*}.
13748
13749 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
13750 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
13751 data elements. The following vectors typedefs are included in @code{msa.h}:
13752 @itemize
13753 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
13754 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
13755 @item @code{v8i16}, a vector of eight signed 16-bit integers;
13756 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
13757 @item @code{v4i32}, a vector of four signed 32-bit integers;
13758 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
13759 @item @code{v2i64}, a vector of two signed 64-bit integers;
13760 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
13761 @item @code{v4f32}, a vector of four 32-bit floats;
13762 @item @code{v2f64}, a vector of two 64-bit doubles.
13763 @end itemize
13764
13765 Intructions and corresponding built-ins may have additional restrictions and/or
13766 input/output values manipulated:
13767 @itemize
13768 @item @code{imm0_1}, an integer literal in range 0 to 1;
13769 @item @code{imm0_3}, an integer literal in range 0 to 3;
13770 @item @code{imm0_7}, an integer literal in range 0 to 7;
13771 @item @code{imm0_15}, an integer literal in range 0 to 15;
13772 @item @code{imm0_31}, an integer literal in range 0 to 31;
13773 @item @code{imm0_63}, an integer literal in range 0 to 63;
13774 @item @code{imm0_255}, an integer literal in range 0 to 255;
13775 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
13776 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
13777 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
13778 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
13779 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
13780 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
13781 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
13782 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
13783 @item @code{imm1_4}, an integer literal in range 1 to 4;
13784 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
13785 @end itemize
13786
13787 @smallexample
13788 @{
13789 typedef int i32;
13790 #if __LONG_MAX__ == __LONG_LONG_MAX__
13791 typedef long i64;
13792 #else
13793 typedef long long i64;
13794 #endif
13795
13796 typedef unsigned int u32;
13797 #if __LONG_MAX__ == __LONG_LONG_MAX__
13798 typedef unsigned long u64;
13799 #else
13800 typedef unsigned long long u64;
13801 #endif
13802
13803 typedef double f64;
13804 typedef float f32;
13805 @}
13806 @end smallexample
13807
13808 @node MIPS SIMD Architecture Built-in Functions
13809 @subsubsection MIPS SIMD Architecture Built-in Functions
13810
13811 The intrinsics provided are listed below; each is named after the
13812 machine instruction.
13813
13814 @smallexample
13815 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
13816 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
13817 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
13818 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
13819
13820 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
13821 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
13822 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
13823 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
13824
13825 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
13826 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
13827 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
13828 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
13829
13830 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
13831 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
13832 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
13833 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
13834
13835 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
13836 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
13837 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
13838 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
13839
13840 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
13841 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
13842 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
13843 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
13844
13845 v16u8 __builtin_msa_and_v (v16u8, v16u8);
13846
13847 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
13848
13849 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
13850 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
13851 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
13852 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
13853
13854 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
13855 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
13856 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
13857 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
13858
13859 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
13860 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
13861 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
13862 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
13863
13864 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
13865 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
13866 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
13867 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
13868
13869 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
13870 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
13871 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
13872 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
13873
13874 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
13875 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
13876 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
13877 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
13878
13879 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
13880 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
13881 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
13882 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
13883
13884 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
13885 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
13886 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
13887 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
13888
13889 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
13890 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
13891 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
13892 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
13893
13894 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
13895 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
13896 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
13897 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
13898
13899 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
13900 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
13901 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
13902 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
13903
13904 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
13905 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
13906 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
13907 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
13908
13909 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
13910
13911 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
13912
13913 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
13914
13915 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
13916
13917 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
13918 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
13919 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
13920 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
13921
13922 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
13923 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
13924 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
13925 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
13926
13927 i32 __builtin_msa_bnz_b (v16u8);
13928 i32 __builtin_msa_bnz_h (v8u16);
13929 i32 __builtin_msa_bnz_w (v4u32);
13930 i32 __builtin_msa_bnz_d (v2u64);
13931
13932 i32 __builtin_msa_bnz_v (v16u8);
13933
13934 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
13935
13936 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
13937
13938 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
13939 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
13940 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
13941 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
13942
13943 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
13944 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
13945 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
13946 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
13947
13948 i32 __builtin_msa_bz_b (v16u8);
13949 i32 __builtin_msa_bz_h (v8u16);
13950 i32 __builtin_msa_bz_w (v4u32);
13951 i32 __builtin_msa_bz_d (v2u64);
13952
13953 i32 __builtin_msa_bz_v (v16u8);
13954
13955 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
13956 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
13957 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
13958 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
13959
13960 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
13961 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
13962 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
13963 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
13964
13965 i32 __builtin_msa_cfcmsa (imm0_31);
13966
13967 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
13968 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
13969 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
13970 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
13971
13972 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
13973 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
13974 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
13975 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
13976
13977 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
13978 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
13979 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
13980 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
13981
13982 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
13983 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
13984 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
13985 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
13986
13987 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
13988 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
13989 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
13990 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
13991
13992 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
13993 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
13994 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
13995 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
13996
13997 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
13998 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
13999 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14000 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14001
14002 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14003 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14004 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14005 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14006
14007 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14008 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14009 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14010 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14011
14012 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14013 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14014 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14015 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14016
14017 void __builtin_msa_ctcmsa (imm0_31, i32);
14018
14019 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14020 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14021 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14022 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14023
14024 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14025 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14026 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14027 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14028
14029 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14030 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14031 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14032
14033 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14034 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14035 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14036
14037 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14038 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14039 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14040
14041 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14042 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14043 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14044
14045 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14046 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14047 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14048
14049 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14050 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14051 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14052
14053 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
14054 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
14055
14056 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
14057 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
14058
14059 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
14060 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
14061
14062 v4i32 __builtin_msa_fclass_w (v4f32);
14063 v2i64 __builtin_msa_fclass_d (v2f64);
14064
14065 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
14066 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
14067
14068 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
14069 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
14070
14071 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
14072 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
14073
14074 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
14075 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
14076
14077 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
14078 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
14079
14080 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
14081 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
14082
14083 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
14084 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
14085
14086 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
14087 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
14088
14089 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
14090 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
14091
14092 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
14093 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
14094
14095 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
14096 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
14097
14098 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
14099 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
14100
14101 v4f32 __builtin_msa_fexupl_w (v8i16);
14102 v2f64 __builtin_msa_fexupl_d (v4f32);
14103
14104 v4f32 __builtin_msa_fexupr_w (v8i16);
14105 v2f64 __builtin_msa_fexupr_d (v4f32);
14106
14107 v4f32 __builtin_msa_ffint_s_w (v4i32);
14108 v2f64 __builtin_msa_ffint_s_d (v2i64);
14109
14110 v4f32 __builtin_msa_ffint_u_w (v4u32);
14111 v2f64 __builtin_msa_ffint_u_d (v2u64);
14112
14113 v4f32 __builtin_msa_ffql_w (v8i16);
14114 v2f64 __builtin_msa_ffql_d (v4i32);
14115
14116 v4f32 __builtin_msa_ffqr_w (v8i16);
14117 v2f64 __builtin_msa_ffqr_d (v4i32);
14118
14119 v16i8 __builtin_msa_fill_b (i32);
14120 v8i16 __builtin_msa_fill_h (i32);
14121 v4i32 __builtin_msa_fill_w (i32);
14122 v2i64 __builtin_msa_fill_d (i64);
14123
14124 v4f32 __builtin_msa_flog2_w (v4f32);
14125 v2f64 __builtin_msa_flog2_d (v2f64);
14126
14127 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
14128 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
14129
14130 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
14131 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
14132
14133 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
14134 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
14135
14136 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
14137 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
14138
14139 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
14140 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
14141
14142 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
14143 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
14144
14145 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
14146 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
14147
14148 v4f32 __builtin_msa_frint_w (v4f32);
14149 v2f64 __builtin_msa_frint_d (v2f64);
14150
14151 v4f32 __builtin_msa_frcp_w (v4f32);
14152 v2f64 __builtin_msa_frcp_d (v2f64);
14153
14154 v4f32 __builtin_msa_frsqrt_w (v4f32);
14155 v2f64 __builtin_msa_frsqrt_d (v2f64);
14156
14157 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
14158 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
14159
14160 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
14161 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
14162
14163 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
14164 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
14165
14166 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
14167 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
14168
14169 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
14170 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
14171
14172 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
14173 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
14174
14175 v4f32 __builtin_msa_fsqrt_w (v4f32);
14176 v2f64 __builtin_msa_fsqrt_d (v2f64);
14177
14178 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
14179 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
14180
14181 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
14182 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
14183
14184 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
14185 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
14186
14187 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
14188 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
14189
14190 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
14191 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
14192
14193 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
14194 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
14195
14196 v4i32 __builtin_msa_ftint_s_w (v4f32);
14197 v2i64 __builtin_msa_ftint_s_d (v2f64);
14198
14199 v4u32 __builtin_msa_ftint_u_w (v4f32);
14200 v2u64 __builtin_msa_ftint_u_d (v2f64);
14201
14202 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
14203 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
14204
14205 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
14206 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
14207
14208 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
14209 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
14210
14211 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
14212 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
14213 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
14214
14215 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
14216 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
14217 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
14218
14219 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
14220 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
14221 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
14222
14223 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
14224 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
14225 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
14226
14227 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
14228 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
14229 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
14230 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
14231
14232 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
14233 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
14234 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
14235 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
14236
14237 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
14238 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
14239 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
14240 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
14241
14242 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
14243 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
14244 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
14245 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
14246
14247 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
14248 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
14249 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
14250 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
14251
14252 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
14253 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
14254 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
14255 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
14256
14257 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
14258 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
14259 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
14260 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
14261
14262 v16i8 __builtin_msa_ldi_b (imm_n512_511);
14263 v8i16 __builtin_msa_ldi_h (imm_n512_511);
14264 v4i32 __builtin_msa_ldi_w (imm_n512_511);
14265 v2i64 __builtin_msa_ldi_d (imm_n512_511);
14266
14267 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
14268 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
14269
14270 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
14271 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
14272
14273 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
14274 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
14275 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
14276 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
14277
14278 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
14279 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
14280 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
14281 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
14282
14283 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
14284 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
14285 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
14286 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
14287
14288 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
14289 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
14290 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
14291 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
14292
14293 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
14294 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
14295 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
14296 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
14297
14298 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
14299 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
14300 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
14301 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
14302
14303 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
14304 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
14305 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
14306 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
14307
14308 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
14309 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
14310 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
14311 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
14312
14313 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
14314 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
14315 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
14316 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
14317
14318 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
14319 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
14320 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
14321 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
14322
14323 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
14324 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
14325 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
14326 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
14327
14328 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
14329 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
14330 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
14331 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
14332
14333 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
14334 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
14335 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
14336 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
14337
14338 v16i8 __builtin_msa_move_v (v16i8);
14339
14340 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
14341 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
14342
14343 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
14344 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
14345
14346 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
14347 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
14348 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
14349 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
14350
14351 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
14352 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
14353
14354 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
14355 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
14356
14357 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
14358 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
14359 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
14360 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
14361
14362 v16i8 __builtin_msa_nloc_b (v16i8);
14363 v8i16 __builtin_msa_nloc_h (v8i16);
14364 v4i32 __builtin_msa_nloc_w (v4i32);
14365 v2i64 __builtin_msa_nloc_d (v2i64);
14366
14367 v16i8 __builtin_msa_nlzc_b (v16i8);
14368 v8i16 __builtin_msa_nlzc_h (v8i16);
14369 v4i32 __builtin_msa_nlzc_w (v4i32);
14370 v2i64 __builtin_msa_nlzc_d (v2i64);
14371
14372 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
14373
14374 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
14375
14376 v16u8 __builtin_msa_or_v (v16u8, v16u8);
14377
14378 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
14379
14380 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
14381 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
14382 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
14383 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
14384
14385 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
14386 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
14387 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
14388 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
14389
14390 v16i8 __builtin_msa_pcnt_b (v16i8);
14391 v8i16 __builtin_msa_pcnt_h (v8i16);
14392 v4i32 __builtin_msa_pcnt_w (v4i32);
14393 v2i64 __builtin_msa_pcnt_d (v2i64);
14394
14395 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
14396 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
14397 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
14398 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
14399
14400 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
14401 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
14402 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
14403 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
14404
14405 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
14406 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
14407 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
14408
14409 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
14410 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
14411 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
14412 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
14413
14414 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
14415 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
14416 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
14417 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
14418
14419 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
14420 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
14421 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
14422 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
14423
14424 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
14425 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
14426 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
14427 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
14428
14429 v16i8 __builtin_msa_splat_b (v16i8, i32);
14430 v8i16 __builtin_msa_splat_h (v8i16, i32);
14431 v4i32 __builtin_msa_splat_w (v4i32, i32);
14432 v2i64 __builtin_msa_splat_d (v2i64, i32);
14433
14434 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
14435 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
14436 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
14437 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
14438
14439 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
14440 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
14441 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
14442 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
14443
14444 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
14445 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
14446 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
14447 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
14448
14449 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
14450 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
14451 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
14452 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
14453
14454 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
14455 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
14456 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
14457 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
14458
14459 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
14460 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
14461 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
14462 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
14463
14464 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
14465 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
14466 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
14467 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
14468
14469 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
14470 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
14471 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
14472 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
14473
14474 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
14475 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
14476 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
14477 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
14478
14479 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
14480 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
14481 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
14482 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
14483
14484 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
14485 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
14486 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
14487 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
14488
14489 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
14490 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
14491 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
14492 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
14493
14494 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
14495 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
14496 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
14497 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
14498
14499 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
14500 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
14501 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
14502 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
14503
14504 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
14505 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
14506 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
14507 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
14508
14509 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
14510 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
14511 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
14512 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
14513
14514 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
14515 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
14516 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
14517 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
14518
14519 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
14520
14521 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
14522 @end smallexample
14523
14524 @node Other MIPS Built-in Functions
14525 @subsection Other MIPS Built-in Functions
14526
14527 GCC provides other MIPS-specific built-in functions:
14528
14529 @table @code
14530 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
14531 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
14532 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
14533 when this function is available.
14534
14535 @item unsigned int __builtin_mips_get_fcsr (void)
14536 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
14537 Get and set the contents of the floating-point control and status register
14538 (FPU control register 31). These functions are only available in hard-float
14539 code but can be called in both MIPS16 and non-MIPS16 contexts.
14540
14541 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
14542 register except the condition codes, which GCC assumes are preserved.
14543 @end table
14544
14545 @node MSP430 Built-in Functions
14546 @subsection MSP430 Built-in Functions
14547
14548 GCC provides a couple of special builtin functions to aid in the
14549 writing of interrupt handlers in C.
14550
14551 @table @code
14552 @item __bic_SR_register_on_exit (int @var{mask})
14553 This clears the indicated bits in the saved copy of the status register
14554 currently residing on the stack. This only works inside interrupt
14555 handlers and the changes to the status register will only take affect
14556 once the handler returns.
14557
14558 @item __bis_SR_register_on_exit (int @var{mask})
14559 This sets the indicated bits in the saved copy of the status register
14560 currently residing on the stack. This only works inside interrupt
14561 handlers and the changes to the status register will only take affect
14562 once the handler returns.
14563
14564 @item __delay_cycles (long long @var{cycles})
14565 This inserts an instruction sequence that takes exactly @var{cycles}
14566 cycles (between 0 and about 17E9) to complete. The inserted sequence
14567 may use jumps, loops, or no-ops, and does not interfere with any other
14568 instructions. Note that @var{cycles} must be a compile-time constant
14569 integer - that is, you must pass a number, not a variable that may be
14570 optimized to a constant later. The number of cycles delayed by this
14571 builtin is exact.
14572 @end table
14573
14574 @node NDS32 Built-in Functions
14575 @subsection NDS32 Built-in Functions
14576
14577 These built-in functions are available for the NDS32 target:
14578
14579 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
14580 Insert an ISYNC instruction into the instruction stream where
14581 @var{addr} is an instruction address for serialization.
14582 @end deftypefn
14583
14584 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
14585 Insert an ISB instruction into the instruction stream.
14586 @end deftypefn
14587
14588 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
14589 Return the content of a system register which is mapped by @var{sr}.
14590 @end deftypefn
14591
14592 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
14593 Return the content of a user space register which is mapped by @var{usr}.
14594 @end deftypefn
14595
14596 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
14597 Move the @var{value} to a system register which is mapped by @var{sr}.
14598 @end deftypefn
14599
14600 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
14601 Move the @var{value} to a user space register which is mapped by @var{usr}.
14602 @end deftypefn
14603
14604 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
14605 Enable global interrupt.
14606 @end deftypefn
14607
14608 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
14609 Disable global interrupt.
14610 @end deftypefn
14611
14612 @node picoChip Built-in Functions
14613 @subsection picoChip Built-in Functions
14614
14615 GCC provides an interface to selected machine instructions from the
14616 picoChip instruction set.
14617
14618 @table @code
14619 @item int __builtin_sbc (int @var{value})
14620 Sign bit count. Return the number of consecutive bits in @var{value}
14621 that have the same value as the sign bit. The result is the number of
14622 leading sign bits minus one, giving the number of redundant sign bits in
14623 @var{value}.
14624
14625 @item int __builtin_byteswap (int @var{value})
14626 Byte swap. Return the result of swapping the upper and lower bytes of
14627 @var{value}.
14628
14629 @item int __builtin_brev (int @var{value})
14630 Bit reversal. Return the result of reversing the bits in
14631 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
14632 and so on.
14633
14634 @item int __builtin_adds (int @var{x}, int @var{y})
14635 Saturating addition. Return the result of adding @var{x} and @var{y},
14636 storing the value 32767 if the result overflows.
14637
14638 @item int __builtin_subs (int @var{x}, int @var{y})
14639 Saturating subtraction. Return the result of subtracting @var{y} from
14640 @var{x}, storing the value @minus{}32768 if the result overflows.
14641
14642 @item void __builtin_halt (void)
14643 Halt. The processor stops execution. This built-in is useful for
14644 implementing assertions.
14645
14646 @end table
14647
14648 @node PowerPC Built-in Functions
14649 @subsection PowerPC Built-in Functions
14650
14651 The following built-in functions are always available and can be used to
14652 check the PowerPC target platform type:
14653
14654 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
14655 This function is a @code{nop} on the PowerPC platform and is included solely
14656 to maintain API compatibility with the x86 builtins.
14657 @end deftypefn
14658
14659 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
14660 This function returns a value of @code{1} if the run-time CPU is of type
14661 @var{cpuname} and returns @code{0} otherwise. The following CPU names can be
14662 detected:
14663
14664 @table @samp
14665 @item power9
14666 IBM POWER9 Server CPU.
14667 @item power8
14668 IBM POWER8 Server CPU.
14669 @item power7
14670 IBM POWER7 Server CPU.
14671 @item power6x
14672 IBM POWER6 Server CPU (RAW mode).
14673 @item power6
14674 IBM POWER6 Server CPU (Architected mode).
14675 @item power5+
14676 IBM POWER5+ Server CPU.
14677 @item power5
14678 IBM POWER5 Server CPU.
14679 @item ppc970
14680 IBM 970 Server CPU (ie, Apple G5).
14681 @item power4
14682 IBM POWER4 Server CPU.
14683 @item ppca2
14684 IBM A2 64-bit Embedded CPU
14685 @item ppc476
14686 IBM PowerPC 476FP 32-bit Embedded CPU.
14687 @item ppc464
14688 IBM PowerPC 464 32-bit Embedded CPU.
14689 @item ppc440
14690 PowerPC 440 32-bit Embedded CPU.
14691 @item ppc405
14692 PowerPC 405 32-bit Embedded CPU.
14693 @item ppc-cell-be
14694 IBM PowerPC Cell Broadband Engine Architecture CPU.
14695 @end table
14696
14697 Here is an example:
14698 @smallexample
14699 if (__builtin_cpu_is ("power8"))
14700 @{
14701 do_power8 (); // POWER8 specific implementation.
14702 @}
14703 else
14704 @{
14705 do_generic (); // Generic implementation.
14706 @}
14707 @end smallexample
14708 @end deftypefn
14709
14710 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
14711 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
14712 feature @var{feature} and returns @code{0} otherwise. The following features can be
14713 detected:
14714
14715 @table @samp
14716 @item 4xxmac
14717 4xx CPU has a Multiply Accumulator.
14718 @item altivec
14719 CPU has a SIMD/Vector Unit.
14720 @item arch_2_05
14721 CPU supports ISA 2.05 (eg, POWER6)
14722 @item arch_2_06
14723 CPU supports ISA 2.06 (eg, POWER7)
14724 @item arch_2_07
14725 CPU supports ISA 2.07 (eg, POWER8)
14726 @item arch_3_00
14727 CPU supports ISA 3.0 (eg, POWER9)
14728 @item archpmu
14729 CPU supports the set of compatible performance monitoring events.
14730 @item booke
14731 CPU supports the Embedded ISA category.
14732 @item cellbe
14733 CPU has a CELL broadband engine.
14734 @item dfp
14735 CPU has a decimal floating point unit.
14736 @item dscr
14737 CPU supports the data stream control register.
14738 @item ebb
14739 CPU supports event base branching.
14740 @item efpdouble
14741 CPU has a SPE double precision floating point unit.
14742 @item efpsingle
14743 CPU has a SPE single precision floating point unit.
14744 @item fpu
14745 CPU has a floating point unit.
14746 @item htm
14747 CPU has hardware transaction memory instructions.
14748 @item htm-nosc
14749 Kernel aborts hardware transactions when a syscall is made.
14750 @item ic_snoop
14751 CPU supports icache snooping capabilities.
14752 @item ieee128
14753 CPU supports 128-bit IEEE binary floating point instructions.
14754 @item isel
14755 CPU supports the integer select instruction.
14756 @item mmu
14757 CPU has a memory management unit.
14758 @item notb
14759 CPU does not have a timebase (eg, 601 and 403gx).
14760 @item pa6t
14761 CPU supports the PA Semi 6T CORE ISA.
14762 @item power4
14763 CPU supports ISA 2.00 (eg, POWER4)
14764 @item power5
14765 CPU supports ISA 2.02 (eg, POWER5)
14766 @item power5+
14767 CPU supports ISA 2.03 (eg, POWER5+)
14768 @item power6x
14769 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
14770 @item ppc32
14771 CPU supports 32-bit mode execution.
14772 @item ppc601
14773 CPU supports the old POWER ISA (eg, 601)
14774 @item ppc64
14775 CPU supports 64-bit mode execution.
14776 @item ppcle
14777 CPU supports a little-endian mode that uses address swizzling.
14778 @item smt
14779 CPU support simultaneous multi-threading.
14780 @item spe
14781 CPU has a signal processing extension unit.
14782 @item tar
14783 CPU supports the target address register.
14784 @item true_le
14785 CPU supports true little-endian mode.
14786 @item ucache
14787 CPU has unified I/D cache.
14788 @item vcrypto
14789 CPU supports the vector cryptography instructions.
14790 @item vsx
14791 CPU supports the vector-scalar extension.
14792 @end table
14793
14794 Here is an example:
14795 @smallexample
14796 if (__builtin_cpu_supports ("fpu"))
14797 @{
14798 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
14799 @}
14800 else
14801 @{
14802 dst = __fadd (src1, src2); // Software FP addition function.
14803 @}
14804 @end smallexample
14805 @end deftypefn
14806
14807 These built-in functions are available for the PowerPC family of
14808 processors:
14809 @smallexample
14810 float __builtin_recipdivf (float, float);
14811 float __builtin_rsqrtf (float);
14812 double __builtin_recipdiv (double, double);
14813 double __builtin_rsqrt (double);
14814 uint64_t __builtin_ppc_get_timebase ();
14815 unsigned long __builtin_ppc_mftb ();
14816 double __builtin_unpack_longdouble (long double, int);
14817 long double __builtin_pack_longdouble (double, double);
14818 @end smallexample
14819
14820 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
14821 @code{__builtin_rsqrtf} functions generate multiple instructions to
14822 implement the reciprocal sqrt functionality using reciprocal sqrt
14823 estimate instructions.
14824
14825 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
14826 functions generate multiple instructions to implement division using
14827 the reciprocal estimate instructions.
14828
14829 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
14830 functions generate instructions to read the Time Base Register. The
14831 @code{__builtin_ppc_get_timebase} function may generate multiple
14832 instructions and always returns the 64 bits of the Time Base Register.
14833 The @code{__builtin_ppc_mftb} function always generates one instruction and
14834 returns the Time Base Register value as an unsigned long, throwing away
14835 the most significant word on 32-bit environments.
14836
14837 Additional built-in functions are available for the 64-bit PowerPC
14838 family of processors, for efficient use of 128-bit floating point
14839 (@code{__float128}) values.
14840
14841 The following floating-point built-in functions are available with
14842 @code{-mfloat128} and Altivec support. All of them implement the
14843 function that is part of the name.
14844
14845 @smallexample
14846 __float128 __builtin_fabsq (__float128)
14847 __float128 __builtin_copysignq (__float128, __float128)
14848 @end smallexample
14849
14850 The following built-in functions are available with @code{-mfloat128}
14851 and Altivec support.
14852
14853 @table @code
14854 @item __float128 __builtin_infq (void)
14855 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
14856 @findex __builtin_infq
14857
14858 @item __float128 __builtin_huge_valq (void)
14859 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
14860 @findex __builtin_huge_valq
14861
14862 @item __float128 __builtin_nanq (void)
14863 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
14864 @findex __builtin_nanq
14865
14866 @item __float128 __builtin_nansq (void)
14867 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
14868 @findex __builtin_nansq
14869 @end table
14870
14871 The following built-in functions are available for the PowerPC family
14872 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
14873 or @option{-mpopcntd}):
14874 @smallexample
14875 long __builtin_bpermd (long, long);
14876 int __builtin_divwe (int, int);
14877 int __builtin_divweo (int, int);
14878 unsigned int __builtin_divweu (unsigned int, unsigned int);
14879 unsigned int __builtin_divweuo (unsigned int, unsigned int);
14880 long __builtin_divde (long, long);
14881 long __builtin_divdeo (long, long);
14882 unsigned long __builtin_divdeu (unsigned long, unsigned long);
14883 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
14884 unsigned int cdtbcd (unsigned int);
14885 unsigned int cbcdtd (unsigned int);
14886 unsigned int addg6s (unsigned int, unsigned int);
14887 @end smallexample
14888
14889 The @code{__builtin_divde}, @code{__builtin_divdeo},
14890 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
14891 64-bit environment support ISA 2.06 or later.
14892
14893 The following built-in functions are available for the PowerPC family
14894 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
14895 @smallexample
14896 long long __builtin_darn (void);
14897 long long __builtin_darn_raw (void);
14898 int __builtin_darn_32 (void);
14899
14900 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
14901 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
14902 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
14903 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
14904
14905 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
14906 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
14907 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
14908 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
14909
14910 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
14911 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
14912 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
14913 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
14914
14915 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
14916 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
14917 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
14918 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
14919
14920 unsigned int scalar_extract_exp (double source);
14921 unsigned long long int scalar_extract_sig (double source);
14922
14923 double
14924 scalar_insert_exp (unsigned long long int significand, unsigned long long int exponent);
14925
14926 int scalar_cmp_exp_gt (double arg1, double arg2);
14927 int scalar_cmp_exp_lt (double arg1, double arg2);
14928 int scalar_cmp_exp_eq (double arg1, double arg2);
14929 int scalar_cmp_exp_unordered (double arg1, double arg2);
14930
14931 int scalar_test_data_class (float source, unsigned int condition);
14932 int scalar_test_data_class (double source, unsigned int condition);
14933
14934 int scalar_test_neg (float source);
14935 int scalar_test_neg (double source);
14936 @end smallexample
14937
14938 The @code{__builtin_darn} and @code{__builtin_darn_raw}
14939 functions require a
14940 64-bit environment supporting ISA 3.0 or later.
14941 The @code{__builtin_darn} function provides a 64-bit conditioned
14942 random number. The @code{__builtin_darn_raw} function provides a
14943 64-bit raw random number. The @code{__builtin_darn_32} function
14944 provides a 32-bit random number.
14945
14946 The @code{scalar_extract_sig} and @code{scalar_insert_exp}
14947 functions require a 64-bit environment supporting ISA 3.0 or later.
14948 The @code{scalar_extract_exp} and @code{vec_extract_sig} built-in
14949 functions return the significand and exponent respectively of their
14950 @code{source} arguments. The
14951 @code{scalar_insert_exp} built-in function returns a double-precision
14952 floating point value that is constructed by assembling the values of its
14953 @code{significand} and @code{exponent} arguments. The sign of the
14954 result is copied from the most significant bit of the
14955 @code{significand} argument. The significand and exponent components
14956 of the result are composed of the least significant 11 bits of the
14957 @code{significand} argument and the least significant 52 bits of the
14958 @code{exponent} argument.
14959
14960 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
14961 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
14962 functions return a non-zero value if @code{arg1} is greater than, less
14963 than, equal to, or not comparable to @code{arg2} respectively. The
14964 arguments are not comparable if one or the other equals NaN (not a
14965 number).
14966
14967 The @code{scalar_test_data_class} built-in functions return a non-zero
14968 value if any of the condition tests enabled by the value of the
14969 @code{condition} variable are true. The
14970 @code{condition} argument must be an unsigned integer with value not
14971 exceeding 127. The
14972 @code{condition} argument is encoded as a bitmask with each bit
14973 enabling the testing of a different condition, as characterized by the
14974 following:
14975 @smallexample
14976 0x40 Test for NaN
14977 0x20 Test for +Infinity
14978 0x10 Test for -Infinity
14979 0x08 Test for +Zero
14980 0x04 Test for -Zero
14981 0x02 Test for +Denormal
14982 0x01 Test for -Denormal
14983 @end smallexample
14984
14985 If all of the enabled test conditions are false, the return value is 0.
14986
14987 The @code{scalar_test_neg} built-in functions return a non-zero value
14988 if their @code{source} argument holds a negative value.
14989
14990 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
14991 if and only if the number of signficant digits of its @code{value} argument
14992 is less than its @code{comparison} argument. The
14993 @code{__builtin_dfp_dtstsfi_lt_dd} and
14994 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
14995 require that the type of the @code{value} argument be
14996 @code{__Decimal64} and @code{__Decimal128} respectively.
14997
14998 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
14999 if and only if the number of signficant digits of its @code{value} argument
15000 is greater than its @code{comparison} argument. The
15001 @code{__builtin_dfp_dtstsfi_gt_dd} and
15002 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
15003 require that the type of the @code{value} argument be
15004 @code{__Decimal64} and @code{__Decimal128} respectively.
15005
15006 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
15007 if and only if the number of signficant digits of its @code{value} argument
15008 equals its @code{comparison} argument. The
15009 @code{__builtin_dfp_dtstsfi_eq_dd} and
15010 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
15011 require that the type of the @code{value} argument be
15012 @code{__Decimal64} and @code{__Decimal128} respectively.
15013
15014 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
15015 if and only if its @code{value} argument has an undefined number of
15016 significant digits, such as when @code{value} is an encoding of @code{NaN}.
15017 The @code{__builtin_dfp_dtstsfi_ov_dd} and
15018 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
15019 require that the type of the @code{value} argument be
15020 @code{__Decimal64} and @code{__Decimal128} respectively.
15021
15022 The following built-in functions are available for the PowerPC family
15023 of processors when hardware decimal floating point
15024 (@option{-mhard-dfp}) is available:
15025 @smallexample
15026 _Decimal64 __builtin_dxex (_Decimal64);
15027 _Decimal128 __builtin_dxexq (_Decimal128);
15028 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15029 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15030 _Decimal64 __builtin_denbcd (int, _Decimal64);
15031 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15032 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
15033 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
15034 _Decimal64 __builtin_dscli (_Decimal64, int);
15035 _Decimal128 __builtin_dscliq (_Decimal128, int);
15036 _Decimal64 __builtin_dscri (_Decimal64, int);
15037 _Decimal128 __builtin_dscriq (_Decimal128, int);
15038 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
15039 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
15040 @end smallexample
15041
15042 The following built-in functions are available for the PowerPC family
15043 of processors when the Vector Scalar (vsx) instruction set is
15044 available:
15045 @smallexample
15046 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
15047 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
15048 unsigned long long);
15049 @end smallexample
15050
15051 @node PowerPC AltiVec/VSX Built-in Functions
15052 @subsection PowerPC AltiVec Built-in Functions
15053
15054 GCC provides an interface for the PowerPC family of processors to access
15055 the AltiVec operations described in Motorola's AltiVec Programming
15056 Interface Manual. The interface is made available by including
15057 @code{<altivec.h>} and using @option{-maltivec} and
15058 @option{-mabi=altivec}. The interface supports the following vector
15059 types.
15060
15061 @smallexample
15062 vector unsigned char
15063 vector signed char
15064 vector bool char
15065
15066 vector unsigned short
15067 vector signed short
15068 vector bool short
15069 vector pixel
15070
15071 vector unsigned int
15072 vector signed int
15073 vector bool int
15074 vector float
15075 @end smallexample
15076
15077 If @option{-mvsx} is used the following additional vector types are
15078 implemented.
15079
15080 @smallexample
15081 vector unsigned long
15082 vector signed long
15083 vector double
15084 @end smallexample
15085
15086 The long types are only implemented for 64-bit code generation, and
15087 the long type is only used in the floating point/integer conversion
15088 instructions.
15089
15090 GCC's implementation of the high-level language interface available from
15091 C and C++ code differs from Motorola's documentation in several ways.
15092
15093 @itemize @bullet
15094
15095 @item
15096 A vector constant is a list of constant expressions within curly braces.
15097
15098 @item
15099 A vector initializer requires no cast if the vector constant is of the
15100 same type as the variable it is initializing.
15101
15102 @item
15103 If @code{signed} or @code{unsigned} is omitted, the signedness of the
15104 vector type is the default signedness of the base type. The default
15105 varies depending on the operating system, so a portable program should
15106 always specify the signedness.
15107
15108 @item
15109 Compiling with @option{-maltivec} adds keywords @code{__vector},
15110 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
15111 @code{bool}. When compiling ISO C, the context-sensitive substitution
15112 of the keywords @code{vector}, @code{pixel} and @code{bool} is
15113 disabled. To use them, you must include @code{<altivec.h>} instead.
15114
15115 @item
15116 GCC allows using a @code{typedef} name as the type specifier for a
15117 vector type.
15118
15119 @item
15120 For C, overloaded functions are implemented with macros so the following
15121 does not work:
15122
15123 @smallexample
15124 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
15125 @end smallexample
15126
15127 @noindent
15128 Since @code{vec_add} is a macro, the vector constant in the example
15129 is treated as four separate arguments. Wrap the entire argument in
15130 parentheses for this to work.
15131 @end itemize
15132
15133 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
15134 Internally, GCC uses built-in functions to achieve the functionality in
15135 the aforementioned header file, but they are not supported and are
15136 subject to change without notice.
15137
15138 The following interfaces are supported for the generic and specific
15139 AltiVec operations and the AltiVec predicates. In cases where there
15140 is a direct mapping between generic and specific operations, only the
15141 generic names are shown here, although the specific operations can also
15142 be used.
15143
15144 Arguments that are documented as @code{const int} require literal
15145 integral values within the range required for that operation.
15146
15147 @smallexample
15148 vector signed char vec_abs (vector signed char);
15149 vector signed short vec_abs (vector signed short);
15150 vector signed int vec_abs (vector signed int);
15151 vector float vec_abs (vector float);
15152
15153 vector signed char vec_abss (vector signed char);
15154 vector signed short vec_abss (vector signed short);
15155 vector signed int vec_abss (vector signed int);
15156
15157 vector signed char vec_add (vector bool char, vector signed char);
15158 vector signed char vec_add (vector signed char, vector bool char);
15159 vector signed char vec_add (vector signed char, vector signed char);
15160 vector unsigned char vec_add (vector bool char, vector unsigned char);
15161 vector unsigned char vec_add (vector unsigned char, vector bool char);
15162 vector unsigned char vec_add (vector unsigned char,
15163 vector unsigned char);
15164 vector signed short vec_add (vector bool short, vector signed short);
15165 vector signed short vec_add (vector signed short, vector bool short);
15166 vector signed short vec_add (vector signed short, vector signed short);
15167 vector unsigned short vec_add (vector bool short,
15168 vector unsigned short);
15169 vector unsigned short vec_add (vector unsigned short,
15170 vector bool short);
15171 vector unsigned short vec_add (vector unsigned short,
15172 vector unsigned short);
15173 vector signed int vec_add (vector bool int, vector signed int);
15174 vector signed int vec_add (vector signed int, vector bool int);
15175 vector signed int vec_add (vector signed int, vector signed int);
15176 vector unsigned int vec_add (vector bool int, vector unsigned int);
15177 vector unsigned int vec_add (vector unsigned int, vector bool int);
15178 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
15179 vector float vec_add (vector float, vector float);
15180
15181 vector float vec_vaddfp (vector float, vector float);
15182
15183 vector signed int vec_vadduwm (vector bool int, vector signed int);
15184 vector signed int vec_vadduwm (vector signed int, vector bool int);
15185 vector signed int vec_vadduwm (vector signed int, vector signed int);
15186 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
15187 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
15188 vector unsigned int vec_vadduwm (vector unsigned int,
15189 vector unsigned int);
15190
15191 vector signed short vec_vadduhm (vector bool short,
15192 vector signed short);
15193 vector signed short vec_vadduhm (vector signed short,
15194 vector bool short);
15195 vector signed short vec_vadduhm (vector signed short,
15196 vector signed short);
15197 vector unsigned short vec_vadduhm (vector bool short,
15198 vector unsigned short);
15199 vector unsigned short vec_vadduhm (vector unsigned short,
15200 vector bool short);
15201 vector unsigned short vec_vadduhm (vector unsigned short,
15202 vector unsigned short);
15203
15204 vector signed char vec_vaddubm (vector bool char, vector signed char);
15205 vector signed char vec_vaddubm (vector signed char, vector bool char);
15206 vector signed char vec_vaddubm (vector signed char, vector signed char);
15207 vector unsigned char vec_vaddubm (vector bool char,
15208 vector unsigned char);
15209 vector unsigned char vec_vaddubm (vector unsigned char,
15210 vector bool char);
15211 vector unsigned char vec_vaddubm (vector unsigned char,
15212 vector unsigned char);
15213
15214 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
15215
15216 vector unsigned char vec_adds (vector bool char, vector unsigned char);
15217 vector unsigned char vec_adds (vector unsigned char, vector bool char);
15218 vector unsigned char vec_adds (vector unsigned char,
15219 vector unsigned char);
15220 vector signed char vec_adds (vector bool char, vector signed char);
15221 vector signed char vec_adds (vector signed char, vector bool char);
15222 vector signed char vec_adds (vector signed char, vector signed char);
15223 vector unsigned short vec_adds (vector bool short,
15224 vector unsigned short);
15225 vector unsigned short vec_adds (vector unsigned short,
15226 vector bool short);
15227 vector unsigned short vec_adds (vector unsigned short,
15228 vector unsigned short);
15229 vector signed short vec_adds (vector bool short, vector signed short);
15230 vector signed short vec_adds (vector signed short, vector bool short);
15231 vector signed short vec_adds (vector signed short, vector signed short);
15232 vector unsigned int vec_adds (vector bool int, vector unsigned int);
15233 vector unsigned int vec_adds (vector unsigned int, vector bool int);
15234 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
15235 vector signed int vec_adds (vector bool int, vector signed int);
15236 vector signed int vec_adds (vector signed int, vector bool int);
15237 vector signed int vec_adds (vector signed int, vector signed int);
15238
15239 vector signed int vec_vaddsws (vector bool int, vector signed int);
15240 vector signed int vec_vaddsws (vector signed int, vector bool int);
15241 vector signed int vec_vaddsws (vector signed int, vector signed int);
15242
15243 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
15244 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
15245 vector unsigned int vec_vadduws (vector unsigned int,
15246 vector unsigned int);
15247
15248 vector signed short vec_vaddshs (vector bool short,
15249 vector signed short);
15250 vector signed short vec_vaddshs (vector signed short,
15251 vector bool short);
15252 vector signed short vec_vaddshs (vector signed short,
15253 vector signed short);
15254
15255 vector unsigned short vec_vadduhs (vector bool short,
15256 vector unsigned short);
15257 vector unsigned short vec_vadduhs (vector unsigned short,
15258 vector bool short);
15259 vector unsigned short vec_vadduhs (vector unsigned short,
15260 vector unsigned short);
15261
15262 vector signed char vec_vaddsbs (vector bool char, vector signed char);
15263 vector signed char vec_vaddsbs (vector signed char, vector bool char);
15264 vector signed char vec_vaddsbs (vector signed char, vector signed char);
15265
15266 vector unsigned char vec_vaddubs (vector bool char,
15267 vector unsigned char);
15268 vector unsigned char vec_vaddubs (vector unsigned char,
15269 vector bool char);
15270 vector unsigned char vec_vaddubs (vector unsigned char,
15271 vector unsigned char);
15272
15273 vector float vec_and (vector float, vector float);
15274 vector float vec_and (vector float, vector bool int);
15275 vector float vec_and (vector bool int, vector float);
15276 vector bool int vec_and (vector bool int, vector bool int);
15277 vector signed int vec_and (vector bool int, vector signed int);
15278 vector signed int vec_and (vector signed int, vector bool int);
15279 vector signed int vec_and (vector signed int, vector signed int);
15280 vector unsigned int vec_and (vector bool int, vector unsigned int);
15281 vector unsigned int vec_and (vector unsigned int, vector bool int);
15282 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
15283 vector bool short vec_and (vector bool short, vector bool short);
15284 vector signed short vec_and (vector bool short, vector signed short);
15285 vector signed short vec_and (vector signed short, vector bool short);
15286 vector signed short vec_and (vector signed short, vector signed short);
15287 vector unsigned short vec_and (vector bool short,
15288 vector unsigned short);
15289 vector unsigned short vec_and (vector unsigned short,
15290 vector bool short);
15291 vector unsigned short vec_and (vector unsigned short,
15292 vector unsigned short);
15293 vector signed char vec_and (vector bool char, vector signed char);
15294 vector bool char vec_and (vector bool char, vector bool char);
15295 vector signed char vec_and (vector signed char, vector bool char);
15296 vector signed char vec_and (vector signed char, vector signed char);
15297 vector unsigned char vec_and (vector bool char, vector unsigned char);
15298 vector unsigned char vec_and (vector unsigned char, vector bool char);
15299 vector unsigned char vec_and (vector unsigned char,
15300 vector unsigned char);
15301
15302 vector float vec_andc (vector float, vector float);
15303 vector float vec_andc (vector float, vector bool int);
15304 vector float vec_andc (vector bool int, vector float);
15305 vector bool int vec_andc (vector bool int, vector bool int);
15306 vector signed int vec_andc (vector bool int, vector signed int);
15307 vector signed int vec_andc (vector signed int, vector bool int);
15308 vector signed int vec_andc (vector signed int, vector signed int);
15309 vector unsigned int vec_andc (vector bool int, vector unsigned int);
15310 vector unsigned int vec_andc (vector unsigned int, vector bool int);
15311 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
15312 vector bool short vec_andc (vector bool short, vector bool short);
15313 vector signed short vec_andc (vector bool short, vector signed short);
15314 vector signed short vec_andc (vector signed short, vector bool short);
15315 vector signed short vec_andc (vector signed short, vector signed short);
15316 vector unsigned short vec_andc (vector bool short,
15317 vector unsigned short);
15318 vector unsigned short vec_andc (vector unsigned short,
15319 vector bool short);
15320 vector unsigned short vec_andc (vector unsigned short,
15321 vector unsigned short);
15322 vector signed char vec_andc (vector bool char, vector signed char);
15323 vector bool char vec_andc (vector bool char, vector bool char);
15324 vector signed char vec_andc (vector signed char, vector bool char);
15325 vector signed char vec_andc (vector signed char, vector signed char);
15326 vector unsigned char vec_andc (vector bool char, vector unsigned char);
15327 vector unsigned char vec_andc (vector unsigned char, vector bool char);
15328 vector unsigned char vec_andc (vector unsigned char,
15329 vector unsigned char);
15330
15331 vector unsigned char vec_avg (vector unsigned char,
15332 vector unsigned char);
15333 vector signed char vec_avg (vector signed char, vector signed char);
15334 vector unsigned short vec_avg (vector unsigned short,
15335 vector unsigned short);
15336 vector signed short vec_avg (vector signed short, vector signed short);
15337 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
15338 vector signed int vec_avg (vector signed int, vector signed int);
15339
15340 vector signed int vec_vavgsw (vector signed int, vector signed int);
15341
15342 vector unsigned int vec_vavguw (vector unsigned int,
15343 vector unsigned int);
15344
15345 vector signed short vec_vavgsh (vector signed short,
15346 vector signed short);
15347
15348 vector unsigned short vec_vavguh (vector unsigned short,
15349 vector unsigned short);
15350
15351 vector signed char vec_vavgsb (vector signed char, vector signed char);
15352
15353 vector unsigned char vec_vavgub (vector unsigned char,
15354 vector unsigned char);
15355
15356 vector float vec_copysign (vector float);
15357
15358 vector float vec_ceil (vector float);
15359
15360 vector signed int vec_cmpb (vector float, vector float);
15361
15362 vector bool char vec_cmpeq (vector signed char, vector signed char);
15363 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
15364 vector bool short vec_cmpeq (vector signed short, vector signed short);
15365 vector bool short vec_cmpeq (vector unsigned short,
15366 vector unsigned short);
15367 vector bool int vec_cmpeq (vector signed int, vector signed int);
15368 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
15369 vector bool int vec_cmpeq (vector float, vector float);
15370
15371 vector bool int vec_vcmpeqfp (vector float, vector float);
15372
15373 vector bool int vec_vcmpequw (vector signed int, vector signed int);
15374 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
15375
15376 vector bool short vec_vcmpequh (vector signed short,
15377 vector signed short);
15378 vector bool short vec_vcmpequh (vector unsigned short,
15379 vector unsigned short);
15380
15381 vector bool char vec_vcmpequb (vector signed char, vector signed char);
15382 vector bool char vec_vcmpequb (vector unsigned char,
15383 vector unsigned char);
15384
15385 vector bool int vec_cmpge (vector float, vector float);
15386
15387 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
15388 vector bool char vec_cmpgt (vector signed char, vector signed char);
15389 vector bool short vec_cmpgt (vector unsigned short,
15390 vector unsigned short);
15391 vector bool short vec_cmpgt (vector signed short, vector signed short);
15392 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
15393 vector bool int vec_cmpgt (vector signed int, vector signed int);
15394 vector bool int vec_cmpgt (vector float, vector float);
15395
15396 vector bool int vec_vcmpgtfp (vector float, vector float);
15397
15398 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
15399
15400 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
15401
15402 vector bool short vec_vcmpgtsh (vector signed short,
15403 vector signed short);
15404
15405 vector bool short vec_vcmpgtuh (vector unsigned short,
15406 vector unsigned short);
15407
15408 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
15409
15410 vector bool char vec_vcmpgtub (vector unsigned char,
15411 vector unsigned char);
15412
15413 vector bool int vec_cmple (vector float, vector float);
15414
15415 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
15416 vector bool char vec_cmplt (vector signed char, vector signed char);
15417 vector bool short vec_cmplt (vector unsigned short,
15418 vector unsigned short);
15419 vector bool short vec_cmplt (vector signed short, vector signed short);
15420 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
15421 vector bool int vec_cmplt (vector signed int, vector signed int);
15422 vector bool int vec_cmplt (vector float, vector float);
15423
15424 vector float vec_cpsgn (vector float, vector float);
15425
15426 vector float vec_ctf (vector unsigned int, const int);
15427 vector float vec_ctf (vector signed int, const int);
15428 vector double vec_ctf (vector unsigned long, const int);
15429 vector double vec_ctf (vector signed long, const int);
15430
15431 vector float vec_vcfsx (vector signed int, const int);
15432
15433 vector float vec_vcfux (vector unsigned int, const int);
15434
15435 vector signed int vec_cts (vector float, const int);
15436 vector signed long vec_cts (vector double, const int);
15437
15438 vector unsigned int vec_ctu (vector float, const int);
15439 vector unsigned long vec_ctu (vector double, const int);
15440
15441 void vec_dss (const int);
15442
15443 void vec_dssall (void);
15444
15445 void vec_dst (const vector unsigned char *, int, const int);
15446 void vec_dst (const vector signed char *, int, const int);
15447 void vec_dst (const vector bool char *, int, const int);
15448 void vec_dst (const vector unsigned short *, int, const int);
15449 void vec_dst (const vector signed short *, int, const int);
15450 void vec_dst (const vector bool short *, int, const int);
15451 void vec_dst (const vector pixel *, int, const int);
15452 void vec_dst (const vector unsigned int *, int, const int);
15453 void vec_dst (const vector signed int *, int, const int);
15454 void vec_dst (const vector bool int *, int, const int);
15455 void vec_dst (const vector float *, int, const int);
15456 void vec_dst (const unsigned char *, int, const int);
15457 void vec_dst (const signed char *, int, const int);
15458 void vec_dst (const unsigned short *, int, const int);
15459 void vec_dst (const short *, int, const int);
15460 void vec_dst (const unsigned int *, int, const int);
15461 void vec_dst (const int *, int, const int);
15462 void vec_dst (const unsigned long *, int, const int);
15463 void vec_dst (const long *, int, const int);
15464 void vec_dst (const float *, int, const int);
15465
15466 void vec_dstst (const vector unsigned char *, int, const int);
15467 void vec_dstst (const vector signed char *, int, const int);
15468 void vec_dstst (const vector bool char *, int, const int);
15469 void vec_dstst (const vector unsigned short *, int, const int);
15470 void vec_dstst (const vector signed short *, int, const int);
15471 void vec_dstst (const vector bool short *, int, const int);
15472 void vec_dstst (const vector pixel *, int, const int);
15473 void vec_dstst (const vector unsigned int *, int, const int);
15474 void vec_dstst (const vector signed int *, int, const int);
15475 void vec_dstst (const vector bool int *, int, const int);
15476 void vec_dstst (const vector float *, int, const int);
15477 void vec_dstst (const unsigned char *, int, const int);
15478 void vec_dstst (const signed char *, int, const int);
15479 void vec_dstst (const unsigned short *, int, const int);
15480 void vec_dstst (const short *, int, const int);
15481 void vec_dstst (const unsigned int *, int, const int);
15482 void vec_dstst (const int *, int, const int);
15483 void vec_dstst (const unsigned long *, int, const int);
15484 void vec_dstst (const long *, int, const int);
15485 void vec_dstst (const float *, int, const int);
15486
15487 void vec_dststt (const vector unsigned char *, int, const int);
15488 void vec_dststt (const vector signed char *, int, const int);
15489 void vec_dststt (const vector bool char *, int, const int);
15490 void vec_dststt (const vector unsigned short *, int, const int);
15491 void vec_dststt (const vector signed short *, int, const int);
15492 void vec_dststt (const vector bool short *, int, const int);
15493 void vec_dststt (const vector pixel *, int, const int);
15494 void vec_dststt (const vector unsigned int *, int, const int);
15495 void vec_dststt (const vector signed int *, int, const int);
15496 void vec_dststt (const vector bool int *, int, const int);
15497 void vec_dststt (const vector float *, int, const int);
15498 void vec_dststt (const unsigned char *, int, const int);
15499 void vec_dststt (const signed char *, int, const int);
15500 void vec_dststt (const unsigned short *, int, const int);
15501 void vec_dststt (const short *, int, const int);
15502 void vec_dststt (const unsigned int *, int, const int);
15503 void vec_dststt (const int *, int, const int);
15504 void vec_dststt (const unsigned long *, int, const int);
15505 void vec_dststt (const long *, int, const int);
15506 void vec_dststt (const float *, int, const int);
15507
15508 void vec_dstt (const vector unsigned char *, int, const int);
15509 void vec_dstt (const vector signed char *, int, const int);
15510 void vec_dstt (const vector bool char *, int, const int);
15511 void vec_dstt (const vector unsigned short *, int, const int);
15512 void vec_dstt (const vector signed short *, int, const int);
15513 void vec_dstt (const vector bool short *, int, const int);
15514 void vec_dstt (const vector pixel *, int, const int);
15515 void vec_dstt (const vector unsigned int *, int, const int);
15516 void vec_dstt (const vector signed int *, int, const int);
15517 void vec_dstt (const vector bool int *, int, const int);
15518 void vec_dstt (const vector float *, int, const int);
15519 void vec_dstt (const unsigned char *, int, const int);
15520 void vec_dstt (const signed char *, int, const int);
15521 void vec_dstt (const unsigned short *, int, const int);
15522 void vec_dstt (const short *, int, const int);
15523 void vec_dstt (const unsigned int *, int, const int);
15524 void vec_dstt (const int *, int, const int);
15525 void vec_dstt (const unsigned long *, int, const int);
15526 void vec_dstt (const long *, int, const int);
15527 void vec_dstt (const float *, int, const int);
15528
15529 vector float vec_expte (vector float);
15530
15531 vector float vec_floor (vector float);
15532
15533 vector float vec_ld (int, const vector float *);
15534 vector float vec_ld (int, const float *);
15535 vector bool int vec_ld (int, const vector bool int *);
15536 vector signed int vec_ld (int, const vector signed int *);
15537 vector signed int vec_ld (int, const int *);
15538 vector signed int vec_ld (int, const long *);
15539 vector unsigned int vec_ld (int, const vector unsigned int *);
15540 vector unsigned int vec_ld (int, const unsigned int *);
15541 vector unsigned int vec_ld (int, const unsigned long *);
15542 vector bool short vec_ld (int, const vector bool short *);
15543 vector pixel vec_ld (int, const vector pixel *);
15544 vector signed short vec_ld (int, const vector signed short *);
15545 vector signed short vec_ld (int, const short *);
15546 vector unsigned short vec_ld (int, const vector unsigned short *);
15547 vector unsigned short vec_ld (int, const unsigned short *);
15548 vector bool char vec_ld (int, const vector bool char *);
15549 vector signed char vec_ld (int, const vector signed char *);
15550 vector signed char vec_ld (int, const signed char *);
15551 vector unsigned char vec_ld (int, const vector unsigned char *);
15552 vector unsigned char vec_ld (int, const unsigned char *);
15553
15554 vector signed char vec_lde (int, const signed char *);
15555 vector unsigned char vec_lde (int, const unsigned char *);
15556 vector signed short vec_lde (int, const short *);
15557 vector unsigned short vec_lde (int, const unsigned short *);
15558 vector float vec_lde (int, const float *);
15559 vector signed int vec_lde (int, const int *);
15560 vector unsigned int vec_lde (int, const unsigned int *);
15561 vector signed int vec_lde (int, const long *);
15562 vector unsigned int vec_lde (int, const unsigned long *);
15563
15564 vector float vec_lvewx (int, float *);
15565 vector signed int vec_lvewx (int, int *);
15566 vector unsigned int vec_lvewx (int, unsigned int *);
15567 vector signed int vec_lvewx (int, long *);
15568 vector unsigned int vec_lvewx (int, unsigned long *);
15569
15570 vector signed short vec_lvehx (int, short *);
15571 vector unsigned short vec_lvehx (int, unsigned short *);
15572
15573 vector signed char vec_lvebx (int, char *);
15574 vector unsigned char vec_lvebx (int, unsigned char *);
15575
15576 vector float vec_ldl (int, const vector float *);
15577 vector float vec_ldl (int, const float *);
15578 vector bool int vec_ldl (int, const vector bool int *);
15579 vector signed int vec_ldl (int, const vector signed int *);
15580 vector signed int vec_ldl (int, const int *);
15581 vector signed int vec_ldl (int, const long *);
15582 vector unsigned int vec_ldl (int, const vector unsigned int *);
15583 vector unsigned int vec_ldl (int, const unsigned int *);
15584 vector unsigned int vec_ldl (int, const unsigned long *);
15585 vector bool short vec_ldl (int, const vector bool short *);
15586 vector pixel vec_ldl (int, const vector pixel *);
15587 vector signed short vec_ldl (int, const vector signed short *);
15588 vector signed short vec_ldl (int, const short *);
15589 vector unsigned short vec_ldl (int, const vector unsigned short *);
15590 vector unsigned short vec_ldl (int, const unsigned short *);
15591 vector bool char vec_ldl (int, const vector bool char *);
15592 vector signed char vec_ldl (int, const vector signed char *);
15593 vector signed char vec_ldl (int, const signed char *);
15594 vector unsigned char vec_ldl (int, const vector unsigned char *);
15595 vector unsigned char vec_ldl (int, const unsigned char *);
15596
15597 vector float vec_loge (vector float);
15598
15599 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
15600 vector unsigned char vec_lvsl (int, const volatile signed char *);
15601 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
15602 vector unsigned char vec_lvsl (int, const volatile short *);
15603 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
15604 vector unsigned char vec_lvsl (int, const volatile int *);
15605 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
15606 vector unsigned char vec_lvsl (int, const volatile long *);
15607 vector unsigned char vec_lvsl (int, const volatile float *);
15608
15609 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
15610 vector unsigned char vec_lvsr (int, const volatile signed char *);
15611 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
15612 vector unsigned char vec_lvsr (int, const volatile short *);
15613 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
15614 vector unsigned char vec_lvsr (int, const volatile int *);
15615 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
15616 vector unsigned char vec_lvsr (int, const volatile long *);
15617 vector unsigned char vec_lvsr (int, const volatile float *);
15618
15619 vector float vec_madd (vector float, vector float, vector float);
15620
15621 vector signed short vec_madds (vector signed short,
15622 vector signed short,
15623 vector signed short);
15624
15625 vector unsigned char vec_max (vector bool char, vector unsigned char);
15626 vector unsigned char vec_max (vector unsigned char, vector bool char);
15627 vector unsigned char vec_max (vector unsigned char,
15628 vector unsigned char);
15629 vector signed char vec_max (vector bool char, vector signed char);
15630 vector signed char vec_max (vector signed char, vector bool char);
15631 vector signed char vec_max (vector signed char, vector signed char);
15632 vector unsigned short vec_max (vector bool short,
15633 vector unsigned short);
15634 vector unsigned short vec_max (vector unsigned short,
15635 vector bool short);
15636 vector unsigned short vec_max (vector unsigned short,
15637 vector unsigned short);
15638 vector signed short vec_max (vector bool short, vector signed short);
15639 vector signed short vec_max (vector signed short, vector bool short);
15640 vector signed short vec_max (vector signed short, vector signed short);
15641 vector unsigned int vec_max (vector bool int, vector unsigned int);
15642 vector unsigned int vec_max (vector unsigned int, vector bool int);
15643 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
15644 vector signed int vec_max (vector bool int, vector signed int);
15645 vector signed int vec_max (vector signed int, vector bool int);
15646 vector signed int vec_max (vector signed int, vector signed int);
15647 vector float vec_max (vector float, vector float);
15648
15649 vector float vec_vmaxfp (vector float, vector float);
15650
15651 vector signed int vec_vmaxsw (vector bool int, vector signed int);
15652 vector signed int vec_vmaxsw (vector signed int, vector bool int);
15653 vector signed int vec_vmaxsw (vector signed int, vector signed int);
15654
15655 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
15656 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
15657 vector unsigned int vec_vmaxuw (vector unsigned int,
15658 vector unsigned int);
15659
15660 vector signed short vec_vmaxsh (vector bool short, vector signed short);
15661 vector signed short vec_vmaxsh (vector signed short, vector bool short);
15662 vector signed short vec_vmaxsh (vector signed short,
15663 vector signed short);
15664
15665 vector unsigned short vec_vmaxuh (vector bool short,
15666 vector unsigned short);
15667 vector unsigned short vec_vmaxuh (vector unsigned short,
15668 vector bool short);
15669 vector unsigned short vec_vmaxuh (vector unsigned short,
15670 vector unsigned short);
15671
15672 vector signed char vec_vmaxsb (vector bool char, vector signed char);
15673 vector signed char vec_vmaxsb (vector signed char, vector bool char);
15674 vector signed char vec_vmaxsb (vector signed char, vector signed char);
15675
15676 vector unsigned char vec_vmaxub (vector bool char,
15677 vector unsigned char);
15678 vector unsigned char vec_vmaxub (vector unsigned char,
15679 vector bool char);
15680 vector unsigned char vec_vmaxub (vector unsigned char,
15681 vector unsigned char);
15682
15683 vector bool char vec_mergeh (vector bool char, vector bool char);
15684 vector signed char vec_mergeh (vector signed char, vector signed char);
15685 vector unsigned char vec_mergeh (vector unsigned char,
15686 vector unsigned char);
15687 vector bool short vec_mergeh (vector bool short, vector bool short);
15688 vector pixel vec_mergeh (vector pixel, vector pixel);
15689 vector signed short vec_mergeh (vector signed short,
15690 vector signed short);
15691 vector unsigned short vec_mergeh (vector unsigned short,
15692 vector unsigned short);
15693 vector float vec_mergeh (vector float, vector float);
15694 vector bool int vec_mergeh (vector bool int, vector bool int);
15695 vector signed int vec_mergeh (vector signed int, vector signed int);
15696 vector unsigned int vec_mergeh (vector unsigned int,
15697 vector unsigned int);
15698
15699 vector float vec_vmrghw (vector float, vector float);
15700 vector bool int vec_vmrghw (vector bool int, vector bool int);
15701 vector signed int vec_vmrghw (vector signed int, vector signed int);
15702 vector unsigned int vec_vmrghw (vector unsigned int,
15703 vector unsigned int);
15704
15705 vector bool short vec_vmrghh (vector bool short, vector bool short);
15706 vector signed short vec_vmrghh (vector signed short,
15707 vector signed short);
15708 vector unsigned short vec_vmrghh (vector unsigned short,
15709 vector unsigned short);
15710 vector pixel vec_vmrghh (vector pixel, vector pixel);
15711
15712 vector bool char vec_vmrghb (vector bool char, vector bool char);
15713 vector signed char vec_vmrghb (vector signed char, vector signed char);
15714 vector unsigned char vec_vmrghb (vector unsigned char,
15715 vector unsigned char);
15716
15717 vector bool char vec_mergel (vector bool char, vector bool char);
15718 vector signed char vec_mergel (vector signed char, vector signed char);
15719 vector unsigned char vec_mergel (vector unsigned char,
15720 vector unsigned char);
15721 vector bool short vec_mergel (vector bool short, vector bool short);
15722 vector pixel vec_mergel (vector pixel, vector pixel);
15723 vector signed short vec_mergel (vector signed short,
15724 vector signed short);
15725 vector unsigned short vec_mergel (vector unsigned short,
15726 vector unsigned short);
15727 vector float vec_mergel (vector float, vector float);
15728 vector bool int vec_mergel (vector bool int, vector bool int);
15729 vector signed int vec_mergel (vector signed int, vector signed int);
15730 vector unsigned int vec_mergel (vector unsigned int,
15731 vector unsigned int);
15732
15733 vector float vec_vmrglw (vector float, vector float);
15734 vector signed int vec_vmrglw (vector signed int, vector signed int);
15735 vector unsigned int vec_vmrglw (vector unsigned int,
15736 vector unsigned int);
15737 vector bool int vec_vmrglw (vector bool int, vector bool int);
15738
15739 vector bool short vec_vmrglh (vector bool short, vector bool short);
15740 vector signed short vec_vmrglh (vector signed short,
15741 vector signed short);
15742 vector unsigned short vec_vmrglh (vector unsigned short,
15743 vector unsigned short);
15744 vector pixel vec_vmrglh (vector pixel, vector pixel);
15745
15746 vector bool char vec_vmrglb (vector bool char, vector bool char);
15747 vector signed char vec_vmrglb (vector signed char, vector signed char);
15748 vector unsigned char vec_vmrglb (vector unsigned char,
15749 vector unsigned char);
15750
15751 vector unsigned short vec_mfvscr (void);
15752
15753 vector unsigned char vec_min (vector bool char, vector unsigned char);
15754 vector unsigned char vec_min (vector unsigned char, vector bool char);
15755 vector unsigned char vec_min (vector unsigned char,
15756 vector unsigned char);
15757 vector signed char vec_min (vector bool char, vector signed char);
15758 vector signed char vec_min (vector signed char, vector bool char);
15759 vector signed char vec_min (vector signed char, vector signed char);
15760 vector unsigned short vec_min (vector bool short,
15761 vector unsigned short);
15762 vector unsigned short vec_min (vector unsigned short,
15763 vector bool short);
15764 vector unsigned short vec_min (vector unsigned short,
15765 vector unsigned short);
15766 vector signed short vec_min (vector bool short, vector signed short);
15767 vector signed short vec_min (vector signed short, vector bool short);
15768 vector signed short vec_min (vector signed short, vector signed short);
15769 vector unsigned int vec_min (vector bool int, vector unsigned int);
15770 vector unsigned int vec_min (vector unsigned int, vector bool int);
15771 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
15772 vector signed int vec_min (vector bool int, vector signed int);
15773 vector signed int vec_min (vector signed int, vector bool int);
15774 vector signed int vec_min (vector signed int, vector signed int);
15775 vector float vec_min (vector float, vector float);
15776
15777 vector float vec_vminfp (vector float, vector float);
15778
15779 vector signed int vec_vminsw (vector bool int, vector signed int);
15780 vector signed int vec_vminsw (vector signed int, vector bool int);
15781 vector signed int vec_vminsw (vector signed int, vector signed int);
15782
15783 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
15784 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
15785 vector unsigned int vec_vminuw (vector unsigned int,
15786 vector unsigned int);
15787
15788 vector signed short vec_vminsh (vector bool short, vector signed short);
15789 vector signed short vec_vminsh (vector signed short, vector bool short);
15790 vector signed short vec_vminsh (vector signed short,
15791 vector signed short);
15792
15793 vector unsigned short vec_vminuh (vector bool short,
15794 vector unsigned short);
15795 vector unsigned short vec_vminuh (vector unsigned short,
15796 vector bool short);
15797 vector unsigned short vec_vminuh (vector unsigned short,
15798 vector unsigned short);
15799
15800 vector signed char vec_vminsb (vector bool char, vector signed char);
15801 vector signed char vec_vminsb (vector signed char, vector bool char);
15802 vector signed char vec_vminsb (vector signed char, vector signed char);
15803
15804 vector unsigned char vec_vminub (vector bool char,
15805 vector unsigned char);
15806 vector unsigned char vec_vminub (vector unsigned char,
15807 vector bool char);
15808 vector unsigned char vec_vminub (vector unsigned char,
15809 vector unsigned char);
15810
15811 vector signed short vec_mladd (vector signed short,
15812 vector signed short,
15813 vector signed short);
15814 vector signed short vec_mladd (vector signed short,
15815 vector unsigned short,
15816 vector unsigned short);
15817 vector signed short vec_mladd (vector unsigned short,
15818 vector signed short,
15819 vector signed short);
15820 vector unsigned short vec_mladd (vector unsigned short,
15821 vector unsigned short,
15822 vector unsigned short);
15823
15824 vector signed short vec_mradds (vector signed short,
15825 vector signed short,
15826 vector signed short);
15827
15828 vector unsigned int vec_msum (vector unsigned char,
15829 vector unsigned char,
15830 vector unsigned int);
15831 vector signed int vec_msum (vector signed char,
15832 vector unsigned char,
15833 vector signed int);
15834 vector unsigned int vec_msum (vector unsigned short,
15835 vector unsigned short,
15836 vector unsigned int);
15837 vector signed int vec_msum (vector signed short,
15838 vector signed short,
15839 vector signed int);
15840
15841 vector signed int vec_vmsumshm (vector signed short,
15842 vector signed short,
15843 vector signed int);
15844
15845 vector unsigned int vec_vmsumuhm (vector unsigned short,
15846 vector unsigned short,
15847 vector unsigned int);
15848
15849 vector signed int vec_vmsummbm (vector signed char,
15850 vector unsigned char,
15851 vector signed int);
15852
15853 vector unsigned int vec_vmsumubm (vector unsigned char,
15854 vector unsigned char,
15855 vector unsigned int);
15856
15857 vector unsigned int vec_msums (vector unsigned short,
15858 vector unsigned short,
15859 vector unsigned int);
15860 vector signed int vec_msums (vector signed short,
15861 vector signed short,
15862 vector signed int);
15863
15864 vector signed int vec_vmsumshs (vector signed short,
15865 vector signed short,
15866 vector signed int);
15867
15868 vector unsigned int vec_vmsumuhs (vector unsigned short,
15869 vector unsigned short,
15870 vector unsigned int);
15871
15872 void vec_mtvscr (vector signed int);
15873 void vec_mtvscr (vector unsigned int);
15874 void vec_mtvscr (vector bool int);
15875 void vec_mtvscr (vector signed short);
15876 void vec_mtvscr (vector unsigned short);
15877 void vec_mtvscr (vector bool short);
15878 void vec_mtvscr (vector pixel);
15879 void vec_mtvscr (vector signed char);
15880 void vec_mtvscr (vector unsigned char);
15881 void vec_mtvscr (vector bool char);
15882
15883 vector unsigned short vec_mule (vector unsigned char,
15884 vector unsigned char);
15885 vector signed short vec_mule (vector signed char,
15886 vector signed char);
15887 vector unsigned int vec_mule (vector unsigned short,
15888 vector unsigned short);
15889 vector signed int vec_mule (vector signed short, vector signed short);
15890
15891 vector signed int vec_vmulesh (vector signed short,
15892 vector signed short);
15893
15894 vector unsigned int vec_vmuleuh (vector unsigned short,
15895 vector unsigned short);
15896
15897 vector signed short vec_vmulesb (vector signed char,
15898 vector signed char);
15899
15900 vector unsigned short vec_vmuleub (vector unsigned char,
15901 vector unsigned char);
15902
15903 vector unsigned short vec_mulo (vector unsigned char,
15904 vector unsigned char);
15905 vector signed short vec_mulo (vector signed char, vector signed char);
15906 vector unsigned int vec_mulo (vector unsigned short,
15907 vector unsigned short);
15908 vector signed int vec_mulo (vector signed short, vector signed short);
15909
15910 vector signed int vec_vmulosh (vector signed short,
15911 vector signed short);
15912
15913 vector unsigned int vec_vmulouh (vector unsigned short,
15914 vector unsigned short);
15915
15916 vector signed short vec_vmulosb (vector signed char,
15917 vector signed char);
15918
15919 vector unsigned short vec_vmuloub (vector unsigned char,
15920 vector unsigned char);
15921
15922 vector float vec_nmsub (vector float, vector float, vector float);
15923
15924 vector float vec_nor (vector float, vector float);
15925 vector signed int vec_nor (vector signed int, vector signed int);
15926 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
15927 vector bool int vec_nor (vector bool int, vector bool int);
15928 vector signed short vec_nor (vector signed short, vector signed short);
15929 vector unsigned short vec_nor (vector unsigned short,
15930 vector unsigned short);
15931 vector bool short vec_nor (vector bool short, vector bool short);
15932 vector signed char vec_nor (vector signed char, vector signed char);
15933 vector unsigned char vec_nor (vector unsigned char,
15934 vector unsigned char);
15935 vector bool char vec_nor (vector bool char, vector bool char);
15936
15937 vector float vec_or (vector float, vector float);
15938 vector float vec_or (vector float, vector bool int);
15939 vector float vec_or (vector bool int, vector float);
15940 vector bool int vec_or (vector bool int, vector bool int);
15941 vector signed int vec_or (vector bool int, vector signed int);
15942 vector signed int vec_or (vector signed int, vector bool int);
15943 vector signed int vec_or (vector signed int, vector signed int);
15944 vector unsigned int vec_or (vector bool int, vector unsigned int);
15945 vector unsigned int vec_or (vector unsigned int, vector bool int);
15946 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
15947 vector bool short vec_or (vector bool short, vector bool short);
15948 vector signed short vec_or (vector bool short, vector signed short);
15949 vector signed short vec_or (vector signed short, vector bool short);
15950 vector signed short vec_or (vector signed short, vector signed short);
15951 vector unsigned short vec_or (vector bool short, vector unsigned short);
15952 vector unsigned short vec_or (vector unsigned short, vector bool short);
15953 vector unsigned short vec_or (vector unsigned short,
15954 vector unsigned short);
15955 vector signed char vec_or (vector bool char, vector signed char);
15956 vector bool char vec_or (vector bool char, vector bool char);
15957 vector signed char vec_or (vector signed char, vector bool char);
15958 vector signed char vec_or (vector signed char, vector signed char);
15959 vector unsigned char vec_or (vector bool char, vector unsigned char);
15960 vector unsigned char vec_or (vector unsigned char, vector bool char);
15961 vector unsigned char vec_or (vector unsigned char,
15962 vector unsigned char);
15963
15964 vector signed char vec_pack (vector signed short, vector signed short);
15965 vector unsigned char vec_pack (vector unsigned short,
15966 vector unsigned short);
15967 vector bool char vec_pack (vector bool short, vector bool short);
15968 vector signed short vec_pack (vector signed int, vector signed int);
15969 vector unsigned short vec_pack (vector unsigned int,
15970 vector unsigned int);
15971 vector bool short vec_pack (vector bool int, vector bool int);
15972
15973 vector bool short vec_vpkuwum (vector bool int, vector bool int);
15974 vector signed short vec_vpkuwum (vector signed int, vector signed int);
15975 vector unsigned short vec_vpkuwum (vector unsigned int,
15976 vector unsigned int);
15977
15978 vector bool char vec_vpkuhum (vector bool short, vector bool short);
15979 vector signed char vec_vpkuhum (vector signed short,
15980 vector signed short);
15981 vector unsigned char vec_vpkuhum (vector unsigned short,
15982 vector unsigned short);
15983
15984 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
15985
15986 vector unsigned char vec_packs (vector unsigned short,
15987 vector unsigned short);
15988 vector signed char vec_packs (vector signed short, vector signed short);
15989 vector unsigned short vec_packs (vector unsigned int,
15990 vector unsigned int);
15991 vector signed short vec_packs (vector signed int, vector signed int);
15992
15993 vector signed short vec_vpkswss (vector signed int, vector signed int);
15994
15995 vector unsigned short vec_vpkuwus (vector unsigned int,
15996 vector unsigned int);
15997
15998 vector signed char vec_vpkshss (vector signed short,
15999 vector signed short);
16000
16001 vector unsigned char vec_vpkuhus (vector unsigned short,
16002 vector unsigned short);
16003
16004 vector unsigned char vec_packsu (vector unsigned short,
16005 vector unsigned short);
16006 vector unsigned char vec_packsu (vector signed short,
16007 vector signed short);
16008 vector unsigned short vec_packsu (vector unsigned int,
16009 vector unsigned int);
16010 vector unsigned short vec_packsu (vector signed int, vector signed int);
16011
16012 vector unsigned short vec_vpkswus (vector signed int,
16013 vector signed int);
16014
16015 vector unsigned char vec_vpkshus (vector signed short,
16016 vector signed short);
16017
16018 vector float vec_perm (vector float,
16019 vector float,
16020 vector unsigned char);
16021 vector signed int vec_perm (vector signed int,
16022 vector signed int,
16023 vector unsigned char);
16024 vector unsigned int vec_perm (vector unsigned int,
16025 vector unsigned int,
16026 vector unsigned char);
16027 vector bool int vec_perm (vector bool int,
16028 vector bool int,
16029 vector unsigned char);
16030 vector signed short vec_perm (vector signed short,
16031 vector signed short,
16032 vector unsigned char);
16033 vector unsigned short vec_perm (vector unsigned short,
16034 vector unsigned short,
16035 vector unsigned char);
16036 vector bool short vec_perm (vector bool short,
16037 vector bool short,
16038 vector unsigned char);
16039 vector pixel vec_perm (vector pixel,
16040 vector pixel,
16041 vector unsigned char);
16042 vector signed char vec_perm (vector signed char,
16043 vector signed char,
16044 vector unsigned char);
16045 vector unsigned char vec_perm (vector unsigned char,
16046 vector unsigned char,
16047 vector unsigned char);
16048 vector bool char vec_perm (vector bool char,
16049 vector bool char,
16050 vector unsigned char);
16051
16052 vector float vec_re (vector float);
16053
16054 vector signed char vec_rl (vector signed char,
16055 vector unsigned char);
16056 vector unsigned char vec_rl (vector unsigned char,
16057 vector unsigned char);
16058 vector signed short vec_rl (vector signed short, vector unsigned short);
16059 vector unsigned short vec_rl (vector unsigned short,
16060 vector unsigned short);
16061 vector signed int vec_rl (vector signed int, vector unsigned int);
16062 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
16063
16064 vector signed int vec_vrlw (vector signed int, vector unsigned int);
16065 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
16066
16067 vector signed short vec_vrlh (vector signed short,
16068 vector unsigned short);
16069 vector unsigned short vec_vrlh (vector unsigned short,
16070 vector unsigned short);
16071
16072 vector signed char vec_vrlb (vector signed char, vector unsigned char);
16073 vector unsigned char vec_vrlb (vector unsigned char,
16074 vector unsigned char);
16075
16076 vector float vec_round (vector float);
16077
16078 vector float vec_recip (vector float, vector float);
16079
16080 vector float vec_rsqrt (vector float);
16081
16082 vector float vec_rsqrte (vector float);
16083
16084 vector float vec_sel (vector float, vector float, vector bool int);
16085 vector float vec_sel (vector float, vector float, vector unsigned int);
16086 vector signed int vec_sel (vector signed int,
16087 vector signed int,
16088 vector bool int);
16089 vector signed int vec_sel (vector signed int,
16090 vector signed int,
16091 vector unsigned int);
16092 vector unsigned int vec_sel (vector unsigned int,
16093 vector unsigned int,
16094 vector bool int);
16095 vector unsigned int vec_sel (vector unsigned int,
16096 vector unsigned int,
16097 vector unsigned int);
16098 vector bool int vec_sel (vector bool int,
16099 vector bool int,
16100 vector bool int);
16101 vector bool int vec_sel (vector bool int,
16102 vector bool int,
16103 vector unsigned int);
16104 vector signed short vec_sel (vector signed short,
16105 vector signed short,
16106 vector bool short);
16107 vector signed short vec_sel (vector signed short,
16108 vector signed short,
16109 vector unsigned short);
16110 vector unsigned short vec_sel (vector unsigned short,
16111 vector unsigned short,
16112 vector bool short);
16113 vector unsigned short vec_sel (vector unsigned short,
16114 vector unsigned short,
16115 vector unsigned short);
16116 vector bool short vec_sel (vector bool short,
16117 vector bool short,
16118 vector bool short);
16119 vector bool short vec_sel (vector bool short,
16120 vector bool short,
16121 vector unsigned short);
16122 vector signed char vec_sel (vector signed char,
16123 vector signed char,
16124 vector bool char);
16125 vector signed char vec_sel (vector signed char,
16126 vector signed char,
16127 vector unsigned char);
16128 vector unsigned char vec_sel (vector unsigned char,
16129 vector unsigned char,
16130 vector bool char);
16131 vector unsigned char vec_sel (vector unsigned char,
16132 vector unsigned char,
16133 vector unsigned char);
16134 vector bool char vec_sel (vector bool char,
16135 vector bool char,
16136 vector bool char);
16137 vector bool char vec_sel (vector bool char,
16138 vector bool char,
16139 vector unsigned char);
16140
16141 vector signed char vec_sl (vector signed char,
16142 vector unsigned char);
16143 vector unsigned char vec_sl (vector unsigned char,
16144 vector unsigned char);
16145 vector signed short vec_sl (vector signed short, vector unsigned short);
16146 vector unsigned short vec_sl (vector unsigned short,
16147 vector unsigned short);
16148 vector signed int vec_sl (vector signed int, vector unsigned int);
16149 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
16150
16151 vector signed int vec_vslw (vector signed int, vector unsigned int);
16152 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
16153
16154 vector signed short vec_vslh (vector signed short,
16155 vector unsigned short);
16156 vector unsigned short vec_vslh (vector unsigned short,
16157 vector unsigned short);
16158
16159 vector signed char vec_vslb (vector signed char, vector unsigned char);
16160 vector unsigned char vec_vslb (vector unsigned char,
16161 vector unsigned char);
16162
16163 vector float vec_sld (vector float, vector float, const int);
16164 vector signed int vec_sld (vector signed int,
16165 vector signed int,
16166 const int);
16167 vector unsigned int vec_sld (vector unsigned int,
16168 vector unsigned int,
16169 const int);
16170 vector bool int vec_sld (vector bool int,
16171 vector bool int,
16172 const int);
16173 vector signed short vec_sld (vector signed short,
16174 vector signed short,
16175 const int);
16176 vector unsigned short vec_sld (vector unsigned short,
16177 vector unsigned short,
16178 const int);
16179 vector bool short vec_sld (vector bool short,
16180 vector bool short,
16181 const int);
16182 vector pixel vec_sld (vector pixel,
16183 vector pixel,
16184 const int);
16185 vector signed char vec_sld (vector signed char,
16186 vector signed char,
16187 const int);
16188 vector unsigned char vec_sld (vector unsigned char,
16189 vector unsigned char,
16190 const int);
16191 vector bool char vec_sld (vector bool char,
16192 vector bool char,
16193 const int);
16194
16195 vector signed int vec_sll (vector signed int,
16196 vector unsigned int);
16197 vector signed int vec_sll (vector signed int,
16198 vector unsigned short);
16199 vector signed int vec_sll (vector signed int,
16200 vector unsigned char);
16201 vector unsigned int vec_sll (vector unsigned int,
16202 vector unsigned int);
16203 vector unsigned int vec_sll (vector unsigned int,
16204 vector unsigned short);
16205 vector unsigned int vec_sll (vector unsigned int,
16206 vector unsigned char);
16207 vector bool int vec_sll (vector bool int,
16208 vector unsigned int);
16209 vector bool int vec_sll (vector bool int,
16210 vector unsigned short);
16211 vector bool int vec_sll (vector bool int,
16212 vector unsigned char);
16213 vector signed short vec_sll (vector signed short,
16214 vector unsigned int);
16215 vector signed short vec_sll (vector signed short,
16216 vector unsigned short);
16217 vector signed short vec_sll (vector signed short,
16218 vector unsigned char);
16219 vector unsigned short vec_sll (vector unsigned short,
16220 vector unsigned int);
16221 vector unsigned short vec_sll (vector unsigned short,
16222 vector unsigned short);
16223 vector unsigned short vec_sll (vector unsigned short,
16224 vector unsigned char);
16225 vector bool short vec_sll (vector bool short, vector unsigned int);
16226 vector bool short vec_sll (vector bool short, vector unsigned short);
16227 vector bool short vec_sll (vector bool short, vector unsigned char);
16228 vector pixel vec_sll (vector pixel, vector unsigned int);
16229 vector pixel vec_sll (vector pixel, vector unsigned short);
16230 vector pixel vec_sll (vector pixel, vector unsigned char);
16231 vector signed char vec_sll (vector signed char, vector unsigned int);
16232 vector signed char vec_sll (vector signed char, vector unsigned short);
16233 vector signed char vec_sll (vector signed char, vector unsigned char);
16234 vector unsigned char vec_sll (vector unsigned char,
16235 vector unsigned int);
16236 vector unsigned char vec_sll (vector unsigned char,
16237 vector unsigned short);
16238 vector unsigned char vec_sll (vector unsigned char,
16239 vector unsigned char);
16240 vector bool char vec_sll (vector bool char, vector unsigned int);
16241 vector bool char vec_sll (vector bool char, vector unsigned short);
16242 vector bool char vec_sll (vector bool char, vector unsigned char);
16243
16244 vector float vec_slo (vector float, vector signed char);
16245 vector float vec_slo (vector float, vector unsigned char);
16246 vector signed int vec_slo (vector signed int, vector signed char);
16247 vector signed int vec_slo (vector signed int, vector unsigned char);
16248 vector unsigned int vec_slo (vector unsigned int, vector signed char);
16249 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
16250 vector signed short vec_slo (vector signed short, vector signed char);
16251 vector signed short vec_slo (vector signed short, vector unsigned char);
16252 vector unsigned short vec_slo (vector unsigned short,
16253 vector signed char);
16254 vector unsigned short vec_slo (vector unsigned short,
16255 vector unsigned char);
16256 vector pixel vec_slo (vector pixel, vector signed char);
16257 vector pixel vec_slo (vector pixel, vector unsigned char);
16258 vector signed char vec_slo (vector signed char, vector signed char);
16259 vector signed char vec_slo (vector signed char, vector unsigned char);
16260 vector unsigned char vec_slo (vector unsigned char, vector signed char);
16261 vector unsigned char vec_slo (vector unsigned char,
16262 vector unsigned char);
16263
16264 vector signed char vec_splat (vector signed char, const int);
16265 vector unsigned char vec_splat (vector unsigned char, const int);
16266 vector bool char vec_splat (vector bool char, const int);
16267 vector signed short vec_splat (vector signed short, const int);
16268 vector unsigned short vec_splat (vector unsigned short, const int);
16269 vector bool short vec_splat (vector bool short, const int);
16270 vector pixel vec_splat (vector pixel, const int);
16271 vector float vec_splat (vector float, const int);
16272 vector signed int vec_splat (vector signed int, const int);
16273 vector unsigned int vec_splat (vector unsigned int, const int);
16274 vector bool int vec_splat (vector bool int, const int);
16275 vector signed long vec_splat (vector signed long, const int);
16276 vector unsigned long vec_splat (vector unsigned long, const int);
16277
16278 vector signed char vec_splats (signed char);
16279 vector unsigned char vec_splats (unsigned char);
16280 vector signed short vec_splats (signed short);
16281 vector unsigned short vec_splats (unsigned short);
16282 vector signed int vec_splats (signed int);
16283 vector unsigned int vec_splats (unsigned int);
16284 vector float vec_splats (float);
16285
16286 vector float vec_vspltw (vector float, const int);
16287 vector signed int vec_vspltw (vector signed int, const int);
16288 vector unsigned int vec_vspltw (vector unsigned int, const int);
16289 vector bool int vec_vspltw (vector bool int, const int);
16290
16291 vector bool short vec_vsplth (vector bool short, const int);
16292 vector signed short vec_vsplth (vector signed short, const int);
16293 vector unsigned short vec_vsplth (vector unsigned short, const int);
16294 vector pixel vec_vsplth (vector pixel, const int);
16295
16296 vector signed char vec_vspltb (vector signed char, const int);
16297 vector unsigned char vec_vspltb (vector unsigned char, const int);
16298 vector bool char vec_vspltb (vector bool char, const int);
16299
16300 vector signed char vec_splat_s8 (const int);
16301
16302 vector signed short vec_splat_s16 (const int);
16303
16304 vector signed int vec_splat_s32 (const int);
16305
16306 vector unsigned char vec_splat_u8 (const int);
16307
16308 vector unsigned short vec_splat_u16 (const int);
16309
16310 vector unsigned int vec_splat_u32 (const int);
16311
16312 vector signed char vec_sr (vector signed char, vector unsigned char);
16313 vector unsigned char vec_sr (vector unsigned char,
16314 vector unsigned char);
16315 vector signed short vec_sr (vector signed short,
16316 vector unsigned short);
16317 vector unsigned short vec_sr (vector unsigned short,
16318 vector unsigned short);
16319 vector signed int vec_sr (vector signed int, vector unsigned int);
16320 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
16321
16322 vector signed int vec_vsrw (vector signed int, vector unsigned int);
16323 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
16324
16325 vector signed short vec_vsrh (vector signed short,
16326 vector unsigned short);
16327 vector unsigned short vec_vsrh (vector unsigned short,
16328 vector unsigned short);
16329
16330 vector signed char vec_vsrb (vector signed char, vector unsigned char);
16331 vector unsigned char vec_vsrb (vector unsigned char,
16332 vector unsigned char);
16333
16334 vector signed char vec_sra (vector signed char, vector unsigned char);
16335 vector unsigned char vec_sra (vector unsigned char,
16336 vector unsigned char);
16337 vector signed short vec_sra (vector signed short,
16338 vector unsigned short);
16339 vector unsigned short vec_sra (vector unsigned short,
16340 vector unsigned short);
16341 vector signed int vec_sra (vector signed int, vector unsigned int);
16342 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
16343
16344 vector signed int vec_vsraw (vector signed int, vector unsigned int);
16345 vector unsigned int vec_vsraw (vector unsigned int,
16346 vector unsigned int);
16347
16348 vector signed short vec_vsrah (vector signed short,
16349 vector unsigned short);
16350 vector unsigned short vec_vsrah (vector unsigned short,
16351 vector unsigned short);
16352
16353 vector signed char vec_vsrab (vector signed char, vector unsigned char);
16354 vector unsigned char vec_vsrab (vector unsigned char,
16355 vector unsigned char);
16356
16357 vector signed int vec_srl (vector signed int, vector unsigned int);
16358 vector signed int vec_srl (vector signed int, vector unsigned short);
16359 vector signed int vec_srl (vector signed int, vector unsigned char);
16360 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
16361 vector unsigned int vec_srl (vector unsigned int,
16362 vector unsigned short);
16363 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
16364 vector bool int vec_srl (vector bool int, vector unsigned int);
16365 vector bool int vec_srl (vector bool int, vector unsigned short);
16366 vector bool int vec_srl (vector bool int, vector unsigned char);
16367 vector signed short vec_srl (vector signed short, vector unsigned int);
16368 vector signed short vec_srl (vector signed short,
16369 vector unsigned short);
16370 vector signed short vec_srl (vector signed short, vector unsigned char);
16371 vector unsigned short vec_srl (vector unsigned short,
16372 vector unsigned int);
16373 vector unsigned short vec_srl (vector unsigned short,
16374 vector unsigned short);
16375 vector unsigned short vec_srl (vector unsigned short,
16376 vector unsigned char);
16377 vector bool short vec_srl (vector bool short, vector unsigned int);
16378 vector bool short vec_srl (vector bool short, vector unsigned short);
16379 vector bool short vec_srl (vector bool short, vector unsigned char);
16380 vector pixel vec_srl (vector pixel, vector unsigned int);
16381 vector pixel vec_srl (vector pixel, vector unsigned short);
16382 vector pixel vec_srl (vector pixel, vector unsigned char);
16383 vector signed char vec_srl (vector signed char, vector unsigned int);
16384 vector signed char vec_srl (vector signed char, vector unsigned short);
16385 vector signed char vec_srl (vector signed char, vector unsigned char);
16386 vector unsigned char vec_srl (vector unsigned char,
16387 vector unsigned int);
16388 vector unsigned char vec_srl (vector unsigned char,
16389 vector unsigned short);
16390 vector unsigned char vec_srl (vector unsigned char,
16391 vector unsigned char);
16392 vector bool char vec_srl (vector bool char, vector unsigned int);
16393 vector bool char vec_srl (vector bool char, vector unsigned short);
16394 vector bool char vec_srl (vector bool char, vector unsigned char);
16395
16396 vector float vec_sro (vector float, vector signed char);
16397 vector float vec_sro (vector float, vector unsigned char);
16398 vector signed int vec_sro (vector signed int, vector signed char);
16399 vector signed int vec_sro (vector signed int, vector unsigned char);
16400 vector unsigned int vec_sro (vector unsigned int, vector signed char);
16401 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
16402 vector signed short vec_sro (vector signed short, vector signed char);
16403 vector signed short vec_sro (vector signed short, vector unsigned char);
16404 vector unsigned short vec_sro (vector unsigned short,
16405 vector signed char);
16406 vector unsigned short vec_sro (vector unsigned short,
16407 vector unsigned char);
16408 vector pixel vec_sro (vector pixel, vector signed char);
16409 vector pixel vec_sro (vector pixel, vector unsigned char);
16410 vector signed char vec_sro (vector signed char, vector signed char);
16411 vector signed char vec_sro (vector signed char, vector unsigned char);
16412 vector unsigned char vec_sro (vector unsigned char, vector signed char);
16413 vector unsigned char vec_sro (vector unsigned char,
16414 vector unsigned char);
16415
16416 void vec_st (vector float, int, vector float *);
16417 void vec_st (vector float, int, float *);
16418 void vec_st (vector signed int, int, vector signed int *);
16419 void vec_st (vector signed int, int, int *);
16420 void vec_st (vector unsigned int, int, vector unsigned int *);
16421 void vec_st (vector unsigned int, int, unsigned int *);
16422 void vec_st (vector bool int, int, vector bool int *);
16423 void vec_st (vector bool int, int, unsigned int *);
16424 void vec_st (vector bool int, int, int *);
16425 void vec_st (vector signed short, int, vector signed short *);
16426 void vec_st (vector signed short, int, short *);
16427 void vec_st (vector unsigned short, int, vector unsigned short *);
16428 void vec_st (vector unsigned short, int, unsigned short *);
16429 void vec_st (vector bool short, int, vector bool short *);
16430 void vec_st (vector bool short, int, unsigned short *);
16431 void vec_st (vector pixel, int, vector pixel *);
16432 void vec_st (vector pixel, int, unsigned short *);
16433 void vec_st (vector pixel, int, short *);
16434 void vec_st (vector bool short, int, short *);
16435 void vec_st (vector signed char, int, vector signed char *);
16436 void vec_st (vector signed char, int, signed char *);
16437 void vec_st (vector unsigned char, int, vector unsigned char *);
16438 void vec_st (vector unsigned char, int, unsigned char *);
16439 void vec_st (vector bool char, int, vector bool char *);
16440 void vec_st (vector bool char, int, unsigned char *);
16441 void vec_st (vector bool char, int, signed char *);
16442
16443 void vec_ste (vector signed char, int, signed char *);
16444 void vec_ste (vector unsigned char, int, unsigned char *);
16445 void vec_ste (vector bool char, int, signed char *);
16446 void vec_ste (vector bool char, int, unsigned char *);
16447 void vec_ste (vector signed short, int, short *);
16448 void vec_ste (vector unsigned short, int, unsigned short *);
16449 void vec_ste (vector bool short, int, short *);
16450 void vec_ste (vector bool short, int, unsigned short *);
16451 void vec_ste (vector pixel, int, short *);
16452 void vec_ste (vector pixel, int, unsigned short *);
16453 void vec_ste (vector float, int, float *);
16454 void vec_ste (vector signed int, int, int *);
16455 void vec_ste (vector unsigned int, int, unsigned int *);
16456 void vec_ste (vector bool int, int, int *);
16457 void vec_ste (vector bool int, int, unsigned int *);
16458
16459 void vec_stvewx (vector float, int, float *);
16460 void vec_stvewx (vector signed int, int, int *);
16461 void vec_stvewx (vector unsigned int, int, unsigned int *);
16462 void vec_stvewx (vector bool int, int, int *);
16463 void vec_stvewx (vector bool int, int, unsigned int *);
16464
16465 void vec_stvehx (vector signed short, int, short *);
16466 void vec_stvehx (vector unsigned short, int, unsigned short *);
16467 void vec_stvehx (vector bool short, int, short *);
16468 void vec_stvehx (vector bool short, int, unsigned short *);
16469 void vec_stvehx (vector pixel, int, short *);
16470 void vec_stvehx (vector pixel, int, unsigned short *);
16471
16472 void vec_stvebx (vector signed char, int, signed char *);
16473 void vec_stvebx (vector unsigned char, int, unsigned char *);
16474 void vec_stvebx (vector bool char, int, signed char *);
16475 void vec_stvebx (vector bool char, int, unsigned char *);
16476
16477 void vec_stl (vector float, int, vector float *);
16478 void vec_stl (vector float, int, float *);
16479 void vec_stl (vector signed int, int, vector signed int *);
16480 void vec_stl (vector signed int, int, int *);
16481 void vec_stl (vector unsigned int, int, vector unsigned int *);
16482 void vec_stl (vector unsigned int, int, unsigned int *);
16483 void vec_stl (vector bool int, int, vector bool int *);
16484 void vec_stl (vector bool int, int, unsigned int *);
16485 void vec_stl (vector bool int, int, int *);
16486 void vec_stl (vector signed short, int, vector signed short *);
16487 void vec_stl (vector signed short, int, short *);
16488 void vec_stl (vector unsigned short, int, vector unsigned short *);
16489 void vec_stl (vector unsigned short, int, unsigned short *);
16490 void vec_stl (vector bool short, int, vector bool short *);
16491 void vec_stl (vector bool short, int, unsigned short *);
16492 void vec_stl (vector bool short, int, short *);
16493 void vec_stl (vector pixel, int, vector pixel *);
16494 void vec_stl (vector pixel, int, unsigned short *);
16495 void vec_stl (vector pixel, int, short *);
16496 void vec_stl (vector signed char, int, vector signed char *);
16497 void vec_stl (vector signed char, int, signed char *);
16498 void vec_stl (vector unsigned char, int, vector unsigned char *);
16499 void vec_stl (vector unsigned char, int, unsigned char *);
16500 void vec_stl (vector bool char, int, vector bool char *);
16501 void vec_stl (vector bool char, int, unsigned char *);
16502 void vec_stl (vector bool char, int, signed char *);
16503
16504 vector signed char vec_sub (vector bool char, vector signed char);
16505 vector signed char vec_sub (vector signed char, vector bool char);
16506 vector signed char vec_sub (vector signed char, vector signed char);
16507 vector unsigned char vec_sub (vector bool char, vector unsigned char);
16508 vector unsigned char vec_sub (vector unsigned char, vector bool char);
16509 vector unsigned char vec_sub (vector unsigned char,
16510 vector unsigned char);
16511 vector signed short vec_sub (vector bool short, vector signed short);
16512 vector signed short vec_sub (vector signed short, vector bool short);
16513 vector signed short vec_sub (vector signed short, vector signed short);
16514 vector unsigned short vec_sub (vector bool short,
16515 vector unsigned short);
16516 vector unsigned short vec_sub (vector unsigned short,
16517 vector bool short);
16518 vector unsigned short vec_sub (vector unsigned short,
16519 vector unsigned short);
16520 vector signed int vec_sub (vector bool int, vector signed int);
16521 vector signed int vec_sub (vector signed int, vector bool int);
16522 vector signed int vec_sub (vector signed int, vector signed int);
16523 vector unsigned int vec_sub (vector bool int, vector unsigned int);
16524 vector unsigned int vec_sub (vector unsigned int, vector bool int);
16525 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
16526 vector float vec_sub (vector float, vector float);
16527
16528 vector float vec_vsubfp (vector float, vector float);
16529
16530 vector signed int vec_vsubuwm (vector bool int, vector signed int);
16531 vector signed int vec_vsubuwm (vector signed int, vector bool int);
16532 vector signed int vec_vsubuwm (vector signed int, vector signed int);
16533 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
16534 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
16535 vector unsigned int vec_vsubuwm (vector unsigned int,
16536 vector unsigned int);
16537
16538 vector signed short vec_vsubuhm (vector bool short,
16539 vector signed short);
16540 vector signed short vec_vsubuhm (vector signed short,
16541 vector bool short);
16542 vector signed short vec_vsubuhm (vector signed short,
16543 vector signed short);
16544 vector unsigned short vec_vsubuhm (vector bool short,
16545 vector unsigned short);
16546 vector unsigned short vec_vsubuhm (vector unsigned short,
16547 vector bool short);
16548 vector unsigned short vec_vsubuhm (vector unsigned short,
16549 vector unsigned short);
16550
16551 vector signed char vec_vsububm (vector bool char, vector signed char);
16552 vector signed char vec_vsububm (vector signed char, vector bool char);
16553 vector signed char vec_vsububm (vector signed char, vector signed char);
16554 vector unsigned char vec_vsububm (vector bool char,
16555 vector unsigned char);
16556 vector unsigned char vec_vsububm (vector unsigned char,
16557 vector bool char);
16558 vector unsigned char vec_vsububm (vector unsigned char,
16559 vector unsigned char);
16560
16561 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
16562
16563 vector unsigned char vec_subs (vector bool char, vector unsigned char);
16564 vector unsigned char vec_subs (vector unsigned char, vector bool char);
16565 vector unsigned char vec_subs (vector unsigned char,
16566 vector unsigned char);
16567 vector signed char vec_subs (vector bool char, vector signed char);
16568 vector signed char vec_subs (vector signed char, vector bool char);
16569 vector signed char vec_subs (vector signed char, vector signed char);
16570 vector unsigned short vec_subs (vector bool short,
16571 vector unsigned short);
16572 vector unsigned short vec_subs (vector unsigned short,
16573 vector bool short);
16574 vector unsigned short vec_subs (vector unsigned short,
16575 vector unsigned short);
16576 vector signed short vec_subs (vector bool short, vector signed short);
16577 vector signed short vec_subs (vector signed short, vector bool short);
16578 vector signed short vec_subs (vector signed short, vector signed short);
16579 vector unsigned int vec_subs (vector bool int, vector unsigned int);
16580 vector unsigned int vec_subs (vector unsigned int, vector bool int);
16581 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
16582 vector signed int vec_subs (vector bool int, vector signed int);
16583 vector signed int vec_subs (vector signed int, vector bool int);
16584 vector signed int vec_subs (vector signed int, vector signed int);
16585
16586 vector signed int vec_vsubsws (vector bool int, vector signed int);
16587 vector signed int vec_vsubsws (vector signed int, vector bool int);
16588 vector signed int vec_vsubsws (vector signed int, vector signed int);
16589
16590 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
16591 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
16592 vector unsigned int vec_vsubuws (vector unsigned int,
16593 vector unsigned int);
16594
16595 vector signed short vec_vsubshs (vector bool short,
16596 vector signed short);
16597 vector signed short vec_vsubshs (vector signed short,
16598 vector bool short);
16599 vector signed short vec_vsubshs (vector signed short,
16600 vector signed short);
16601
16602 vector unsigned short vec_vsubuhs (vector bool short,
16603 vector unsigned short);
16604 vector unsigned short vec_vsubuhs (vector unsigned short,
16605 vector bool short);
16606 vector unsigned short vec_vsubuhs (vector unsigned short,
16607 vector unsigned short);
16608
16609 vector signed char vec_vsubsbs (vector bool char, vector signed char);
16610 vector signed char vec_vsubsbs (vector signed char, vector bool char);
16611 vector signed char vec_vsubsbs (vector signed char, vector signed char);
16612
16613 vector unsigned char vec_vsububs (vector bool char,
16614 vector unsigned char);
16615 vector unsigned char vec_vsububs (vector unsigned char,
16616 vector bool char);
16617 vector unsigned char vec_vsububs (vector unsigned char,
16618 vector unsigned char);
16619
16620 vector unsigned int vec_sum4s (vector unsigned char,
16621 vector unsigned int);
16622 vector signed int vec_sum4s (vector signed char, vector signed int);
16623 vector signed int vec_sum4s (vector signed short, vector signed int);
16624
16625 vector signed int vec_vsum4shs (vector signed short, vector signed int);
16626
16627 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
16628
16629 vector unsigned int vec_vsum4ubs (vector unsigned char,
16630 vector unsigned int);
16631
16632 vector signed int vec_sum2s (vector signed int, vector signed int);
16633
16634 vector signed int vec_sums (vector signed int, vector signed int);
16635
16636 vector float vec_trunc (vector float);
16637
16638 vector signed short vec_unpackh (vector signed char);
16639 vector bool short vec_unpackh (vector bool char);
16640 vector signed int vec_unpackh (vector signed short);
16641 vector bool int vec_unpackh (vector bool short);
16642 vector unsigned int vec_unpackh (vector pixel);
16643
16644 vector bool int vec_vupkhsh (vector bool short);
16645 vector signed int vec_vupkhsh (vector signed short);
16646
16647 vector unsigned int vec_vupkhpx (vector pixel);
16648
16649 vector bool short vec_vupkhsb (vector bool char);
16650 vector signed short vec_vupkhsb (vector signed char);
16651
16652 vector signed short vec_unpackl (vector signed char);
16653 vector bool short vec_unpackl (vector bool char);
16654 vector unsigned int vec_unpackl (vector pixel);
16655 vector signed int vec_unpackl (vector signed short);
16656 vector bool int vec_unpackl (vector bool short);
16657
16658 vector unsigned int vec_vupklpx (vector pixel);
16659
16660 vector bool int vec_vupklsh (vector bool short);
16661 vector signed int vec_vupklsh (vector signed short);
16662
16663 vector bool short vec_vupklsb (vector bool char);
16664 vector signed short vec_vupklsb (vector signed char);
16665
16666 vector float vec_xor (vector float, vector float);
16667 vector float vec_xor (vector float, vector bool int);
16668 vector float vec_xor (vector bool int, vector float);
16669 vector bool int vec_xor (vector bool int, vector bool int);
16670 vector signed int vec_xor (vector bool int, vector signed int);
16671 vector signed int vec_xor (vector signed int, vector bool int);
16672 vector signed int vec_xor (vector signed int, vector signed int);
16673 vector unsigned int vec_xor (vector bool int, vector unsigned int);
16674 vector unsigned int vec_xor (vector unsigned int, vector bool int);
16675 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
16676 vector bool short vec_xor (vector bool short, vector bool short);
16677 vector signed short vec_xor (vector bool short, vector signed short);
16678 vector signed short vec_xor (vector signed short, vector bool short);
16679 vector signed short vec_xor (vector signed short, vector signed short);
16680 vector unsigned short vec_xor (vector bool short,
16681 vector unsigned short);
16682 vector unsigned short vec_xor (vector unsigned short,
16683 vector bool short);
16684 vector unsigned short vec_xor (vector unsigned short,
16685 vector unsigned short);
16686 vector signed char vec_xor (vector bool char, vector signed char);
16687 vector bool char vec_xor (vector bool char, vector bool char);
16688 vector signed char vec_xor (vector signed char, vector bool char);
16689 vector signed char vec_xor (vector signed char, vector signed char);
16690 vector unsigned char vec_xor (vector bool char, vector unsigned char);
16691 vector unsigned char vec_xor (vector unsigned char, vector bool char);
16692 vector unsigned char vec_xor (vector unsigned char,
16693 vector unsigned char);
16694
16695 int vec_all_eq (vector signed char, vector bool char);
16696 int vec_all_eq (vector signed char, vector signed char);
16697 int vec_all_eq (vector unsigned char, vector bool char);
16698 int vec_all_eq (vector unsigned char, vector unsigned char);
16699 int vec_all_eq (vector bool char, vector bool char);
16700 int vec_all_eq (vector bool char, vector unsigned char);
16701 int vec_all_eq (vector bool char, vector signed char);
16702 int vec_all_eq (vector signed short, vector bool short);
16703 int vec_all_eq (vector signed short, vector signed short);
16704 int vec_all_eq (vector unsigned short, vector bool short);
16705 int vec_all_eq (vector unsigned short, vector unsigned short);
16706 int vec_all_eq (vector bool short, vector bool short);
16707 int vec_all_eq (vector bool short, vector unsigned short);
16708 int vec_all_eq (vector bool short, vector signed short);
16709 int vec_all_eq (vector pixel, vector pixel);
16710 int vec_all_eq (vector signed int, vector bool int);
16711 int vec_all_eq (vector signed int, vector signed int);
16712 int vec_all_eq (vector unsigned int, vector bool int);
16713 int vec_all_eq (vector unsigned int, vector unsigned int);
16714 int vec_all_eq (vector bool int, vector bool int);
16715 int vec_all_eq (vector bool int, vector unsigned int);
16716 int vec_all_eq (vector bool int, vector signed int);
16717 int vec_all_eq (vector float, vector float);
16718
16719 int vec_all_ge (vector bool char, vector unsigned char);
16720 int vec_all_ge (vector unsigned char, vector bool char);
16721 int vec_all_ge (vector unsigned char, vector unsigned char);
16722 int vec_all_ge (vector bool char, vector signed char);
16723 int vec_all_ge (vector signed char, vector bool char);
16724 int vec_all_ge (vector signed char, vector signed char);
16725 int vec_all_ge (vector bool short, vector unsigned short);
16726 int vec_all_ge (vector unsigned short, vector bool short);
16727 int vec_all_ge (vector unsigned short, vector unsigned short);
16728 int vec_all_ge (vector signed short, vector signed short);
16729 int vec_all_ge (vector bool short, vector signed short);
16730 int vec_all_ge (vector signed short, vector bool short);
16731 int vec_all_ge (vector bool int, vector unsigned int);
16732 int vec_all_ge (vector unsigned int, vector bool int);
16733 int vec_all_ge (vector unsigned int, vector unsigned int);
16734 int vec_all_ge (vector bool int, vector signed int);
16735 int vec_all_ge (vector signed int, vector bool int);
16736 int vec_all_ge (vector signed int, vector signed int);
16737 int vec_all_ge (vector float, vector float);
16738
16739 int vec_all_gt (vector bool char, vector unsigned char);
16740 int vec_all_gt (vector unsigned char, vector bool char);
16741 int vec_all_gt (vector unsigned char, vector unsigned char);
16742 int vec_all_gt (vector bool char, vector signed char);
16743 int vec_all_gt (vector signed char, vector bool char);
16744 int vec_all_gt (vector signed char, vector signed char);
16745 int vec_all_gt (vector bool short, vector unsigned short);
16746 int vec_all_gt (vector unsigned short, vector bool short);
16747 int vec_all_gt (vector unsigned short, vector unsigned short);
16748 int vec_all_gt (vector bool short, vector signed short);
16749 int vec_all_gt (vector signed short, vector bool short);
16750 int vec_all_gt (vector signed short, vector signed short);
16751 int vec_all_gt (vector bool int, vector unsigned int);
16752 int vec_all_gt (vector unsigned int, vector bool int);
16753 int vec_all_gt (vector unsigned int, vector unsigned int);
16754 int vec_all_gt (vector bool int, vector signed int);
16755 int vec_all_gt (vector signed int, vector bool int);
16756 int vec_all_gt (vector signed int, vector signed int);
16757 int vec_all_gt (vector float, vector float);
16758
16759 int vec_all_in (vector float, vector float);
16760
16761 int vec_all_le (vector bool char, vector unsigned char);
16762 int vec_all_le (vector unsigned char, vector bool char);
16763 int vec_all_le (vector unsigned char, vector unsigned char);
16764 int vec_all_le (vector bool char, vector signed char);
16765 int vec_all_le (vector signed char, vector bool char);
16766 int vec_all_le (vector signed char, vector signed char);
16767 int vec_all_le (vector bool short, vector unsigned short);
16768 int vec_all_le (vector unsigned short, vector bool short);
16769 int vec_all_le (vector unsigned short, vector unsigned short);
16770 int vec_all_le (vector bool short, vector signed short);
16771 int vec_all_le (vector signed short, vector bool short);
16772 int vec_all_le (vector signed short, vector signed short);
16773 int vec_all_le (vector bool int, vector unsigned int);
16774 int vec_all_le (vector unsigned int, vector bool int);
16775 int vec_all_le (vector unsigned int, vector unsigned int);
16776 int vec_all_le (vector bool int, vector signed int);
16777 int vec_all_le (vector signed int, vector bool int);
16778 int vec_all_le (vector signed int, vector signed int);
16779 int vec_all_le (vector float, vector float);
16780
16781 int vec_all_lt (vector bool char, vector unsigned char);
16782 int vec_all_lt (vector unsigned char, vector bool char);
16783 int vec_all_lt (vector unsigned char, vector unsigned char);
16784 int vec_all_lt (vector bool char, vector signed char);
16785 int vec_all_lt (vector signed char, vector bool char);
16786 int vec_all_lt (vector signed char, vector signed char);
16787 int vec_all_lt (vector bool short, vector unsigned short);
16788 int vec_all_lt (vector unsigned short, vector bool short);
16789 int vec_all_lt (vector unsigned short, vector unsigned short);
16790 int vec_all_lt (vector bool short, vector signed short);
16791 int vec_all_lt (vector signed short, vector bool short);
16792 int vec_all_lt (vector signed short, vector signed short);
16793 int vec_all_lt (vector bool int, vector unsigned int);
16794 int vec_all_lt (vector unsigned int, vector bool int);
16795 int vec_all_lt (vector unsigned int, vector unsigned int);
16796 int vec_all_lt (vector bool int, vector signed int);
16797 int vec_all_lt (vector signed int, vector bool int);
16798 int vec_all_lt (vector signed int, vector signed int);
16799 int vec_all_lt (vector float, vector float);
16800
16801 int vec_all_nan (vector float);
16802
16803 int vec_all_ne (vector signed char, vector bool char);
16804 int vec_all_ne (vector signed char, vector signed char);
16805 int vec_all_ne (vector unsigned char, vector bool char);
16806 int vec_all_ne (vector unsigned char, vector unsigned char);
16807 int vec_all_ne (vector bool char, vector bool char);
16808 int vec_all_ne (vector bool char, vector unsigned char);
16809 int vec_all_ne (vector bool char, vector signed char);
16810 int vec_all_ne (vector signed short, vector bool short);
16811 int vec_all_ne (vector signed short, vector signed short);
16812 int vec_all_ne (vector unsigned short, vector bool short);
16813 int vec_all_ne (vector unsigned short, vector unsigned short);
16814 int vec_all_ne (vector bool short, vector bool short);
16815 int vec_all_ne (vector bool short, vector unsigned short);
16816 int vec_all_ne (vector bool short, vector signed short);
16817 int vec_all_ne (vector pixel, vector pixel);
16818 int vec_all_ne (vector signed int, vector bool int);
16819 int vec_all_ne (vector signed int, vector signed int);
16820 int vec_all_ne (vector unsigned int, vector bool int);
16821 int vec_all_ne (vector unsigned int, vector unsigned int);
16822 int vec_all_ne (vector bool int, vector bool int);
16823 int vec_all_ne (vector bool int, vector unsigned int);
16824 int vec_all_ne (vector bool int, vector signed int);
16825 int vec_all_ne (vector float, vector float);
16826
16827 int vec_all_nge (vector float, vector float);
16828
16829 int vec_all_ngt (vector float, vector float);
16830
16831 int vec_all_nle (vector float, vector float);
16832
16833 int vec_all_nlt (vector float, vector float);
16834
16835 int vec_all_numeric (vector float);
16836
16837 int vec_any_eq (vector signed char, vector bool char);
16838 int vec_any_eq (vector signed char, vector signed char);
16839 int vec_any_eq (vector unsigned char, vector bool char);
16840 int vec_any_eq (vector unsigned char, vector unsigned char);
16841 int vec_any_eq (vector bool char, vector bool char);
16842 int vec_any_eq (vector bool char, vector unsigned char);
16843 int vec_any_eq (vector bool char, vector signed char);
16844 int vec_any_eq (vector signed short, vector bool short);
16845 int vec_any_eq (vector signed short, vector signed short);
16846 int vec_any_eq (vector unsigned short, vector bool short);
16847 int vec_any_eq (vector unsigned short, vector unsigned short);
16848 int vec_any_eq (vector bool short, vector bool short);
16849 int vec_any_eq (vector bool short, vector unsigned short);
16850 int vec_any_eq (vector bool short, vector signed short);
16851 int vec_any_eq (vector pixel, vector pixel);
16852 int vec_any_eq (vector signed int, vector bool int);
16853 int vec_any_eq (vector signed int, vector signed int);
16854 int vec_any_eq (vector unsigned int, vector bool int);
16855 int vec_any_eq (vector unsigned int, vector unsigned int);
16856 int vec_any_eq (vector bool int, vector bool int);
16857 int vec_any_eq (vector bool int, vector unsigned int);
16858 int vec_any_eq (vector bool int, vector signed int);
16859 int vec_any_eq (vector float, vector float);
16860
16861 int vec_any_ge (vector signed char, vector bool char);
16862 int vec_any_ge (vector unsigned char, vector bool char);
16863 int vec_any_ge (vector unsigned char, vector unsigned char);
16864 int vec_any_ge (vector signed char, vector signed char);
16865 int vec_any_ge (vector bool char, vector unsigned char);
16866 int vec_any_ge (vector bool char, vector signed char);
16867 int vec_any_ge (vector unsigned short, vector bool short);
16868 int vec_any_ge (vector unsigned short, vector unsigned short);
16869 int vec_any_ge (vector signed short, vector signed short);
16870 int vec_any_ge (vector signed short, vector bool short);
16871 int vec_any_ge (vector bool short, vector unsigned short);
16872 int vec_any_ge (vector bool short, vector signed short);
16873 int vec_any_ge (vector signed int, vector bool int);
16874 int vec_any_ge (vector unsigned int, vector bool int);
16875 int vec_any_ge (vector unsigned int, vector unsigned int);
16876 int vec_any_ge (vector signed int, vector signed int);
16877 int vec_any_ge (vector bool int, vector unsigned int);
16878 int vec_any_ge (vector bool int, vector signed int);
16879 int vec_any_ge (vector float, vector float);
16880
16881 int vec_any_gt (vector bool char, vector unsigned char);
16882 int vec_any_gt (vector unsigned char, vector bool char);
16883 int vec_any_gt (vector unsigned char, vector unsigned char);
16884 int vec_any_gt (vector bool char, vector signed char);
16885 int vec_any_gt (vector signed char, vector bool char);
16886 int vec_any_gt (vector signed char, vector signed char);
16887 int vec_any_gt (vector bool short, vector unsigned short);
16888 int vec_any_gt (vector unsigned short, vector bool short);
16889 int vec_any_gt (vector unsigned short, vector unsigned short);
16890 int vec_any_gt (vector bool short, vector signed short);
16891 int vec_any_gt (vector signed short, vector bool short);
16892 int vec_any_gt (vector signed short, vector signed short);
16893 int vec_any_gt (vector bool int, vector unsigned int);
16894 int vec_any_gt (vector unsigned int, vector bool int);
16895 int vec_any_gt (vector unsigned int, vector unsigned int);
16896 int vec_any_gt (vector bool int, vector signed int);
16897 int vec_any_gt (vector signed int, vector bool int);
16898 int vec_any_gt (vector signed int, vector signed int);
16899 int vec_any_gt (vector float, vector float);
16900
16901 int vec_any_le (vector bool char, vector unsigned char);
16902 int vec_any_le (vector unsigned char, vector bool char);
16903 int vec_any_le (vector unsigned char, vector unsigned char);
16904 int vec_any_le (vector bool char, vector signed char);
16905 int vec_any_le (vector signed char, vector bool char);
16906 int vec_any_le (vector signed char, vector signed char);
16907 int vec_any_le (vector bool short, vector unsigned short);
16908 int vec_any_le (vector unsigned short, vector bool short);
16909 int vec_any_le (vector unsigned short, vector unsigned short);
16910 int vec_any_le (vector bool short, vector signed short);
16911 int vec_any_le (vector signed short, vector bool short);
16912 int vec_any_le (vector signed short, vector signed short);
16913 int vec_any_le (vector bool int, vector unsigned int);
16914 int vec_any_le (vector unsigned int, vector bool int);
16915 int vec_any_le (vector unsigned int, vector unsigned int);
16916 int vec_any_le (vector bool int, vector signed int);
16917 int vec_any_le (vector signed int, vector bool int);
16918 int vec_any_le (vector signed int, vector signed int);
16919 int vec_any_le (vector float, vector float);
16920
16921 int vec_any_lt (vector bool char, vector unsigned char);
16922 int vec_any_lt (vector unsigned char, vector bool char);
16923 int vec_any_lt (vector unsigned char, vector unsigned char);
16924 int vec_any_lt (vector bool char, vector signed char);
16925 int vec_any_lt (vector signed char, vector bool char);
16926 int vec_any_lt (vector signed char, vector signed char);
16927 int vec_any_lt (vector bool short, vector unsigned short);
16928 int vec_any_lt (vector unsigned short, vector bool short);
16929 int vec_any_lt (vector unsigned short, vector unsigned short);
16930 int vec_any_lt (vector bool short, vector signed short);
16931 int vec_any_lt (vector signed short, vector bool short);
16932 int vec_any_lt (vector signed short, vector signed short);
16933 int vec_any_lt (vector bool int, vector unsigned int);
16934 int vec_any_lt (vector unsigned int, vector bool int);
16935 int vec_any_lt (vector unsigned int, vector unsigned int);
16936 int vec_any_lt (vector bool int, vector signed int);
16937 int vec_any_lt (vector signed int, vector bool int);
16938 int vec_any_lt (vector signed int, vector signed int);
16939 int vec_any_lt (vector float, vector float);
16940
16941 int vec_any_nan (vector float);
16942
16943 int vec_any_ne (vector signed char, vector bool char);
16944 int vec_any_ne (vector signed char, vector signed char);
16945 int vec_any_ne (vector unsigned char, vector bool char);
16946 int vec_any_ne (vector unsigned char, vector unsigned char);
16947 int vec_any_ne (vector bool char, vector bool char);
16948 int vec_any_ne (vector bool char, vector unsigned char);
16949 int vec_any_ne (vector bool char, vector signed char);
16950 int vec_any_ne (vector signed short, vector bool short);
16951 int vec_any_ne (vector signed short, vector signed short);
16952 int vec_any_ne (vector unsigned short, vector bool short);
16953 int vec_any_ne (vector unsigned short, vector unsigned short);
16954 int vec_any_ne (vector bool short, vector bool short);
16955 int vec_any_ne (vector bool short, vector unsigned short);
16956 int vec_any_ne (vector bool short, vector signed short);
16957 int vec_any_ne (vector pixel, vector pixel);
16958 int vec_any_ne (vector signed int, vector bool int);
16959 int vec_any_ne (vector signed int, vector signed int);
16960 int vec_any_ne (vector unsigned int, vector bool int);
16961 int vec_any_ne (vector unsigned int, vector unsigned int);
16962 int vec_any_ne (vector bool int, vector bool int);
16963 int vec_any_ne (vector bool int, vector unsigned int);
16964 int vec_any_ne (vector bool int, vector signed int);
16965 int vec_any_ne (vector float, vector float);
16966
16967 int vec_any_nge (vector float, vector float);
16968
16969 int vec_any_ngt (vector float, vector float);
16970
16971 int vec_any_nle (vector float, vector float);
16972
16973 int vec_any_nlt (vector float, vector float);
16974
16975 int vec_any_numeric (vector float);
16976
16977 int vec_any_out (vector float, vector float);
16978 @end smallexample
16979
16980 If the vector/scalar (VSX) instruction set is available, the following
16981 additional functions are available:
16982
16983 @smallexample
16984 vector double vec_abs (vector double);
16985 vector double vec_add (vector double, vector double);
16986 vector double vec_and (vector double, vector double);
16987 vector double vec_and (vector double, vector bool long);
16988 vector double vec_and (vector bool long, vector double);
16989 vector long vec_and (vector long, vector long);
16990 vector long vec_and (vector long, vector bool long);
16991 vector long vec_and (vector bool long, vector long);
16992 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
16993 vector unsigned long vec_and (vector unsigned long, vector bool long);
16994 vector unsigned long vec_and (vector bool long, vector unsigned long);
16995 vector double vec_andc (vector double, vector double);
16996 vector double vec_andc (vector double, vector bool long);
16997 vector double vec_andc (vector bool long, vector double);
16998 vector long vec_andc (vector long, vector long);
16999 vector long vec_andc (vector long, vector bool long);
17000 vector long vec_andc (vector bool long, vector long);
17001 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
17002 vector unsigned long vec_andc (vector unsigned long, vector bool long);
17003 vector unsigned long vec_andc (vector bool long, vector unsigned long);
17004 vector double vec_ceil (vector double);
17005 vector bool long vec_cmpeq (vector double, vector double);
17006 vector bool long vec_cmpge (vector double, vector double);
17007 vector bool long vec_cmpgt (vector double, vector double);
17008 vector bool long vec_cmple (vector double, vector double);
17009 vector bool long vec_cmplt (vector double, vector double);
17010 vector double vec_cpsgn (vector double, vector double);
17011 vector float vec_div (vector float, vector float);
17012 vector double vec_div (vector double, vector double);
17013 vector long vec_div (vector long, vector long);
17014 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
17015 vector double vec_floor (vector double);
17016 vector double vec_ld (int, const vector double *);
17017 vector double vec_ld (int, const double *);
17018 vector double vec_ldl (int, const vector double *);
17019 vector double vec_ldl (int, const double *);
17020 vector unsigned char vec_lvsl (int, const volatile double *);
17021 vector unsigned char vec_lvsr (int, const volatile double *);
17022 vector double vec_madd (vector double, vector double, vector double);
17023 vector double vec_max (vector double, vector double);
17024 vector signed long vec_mergeh (vector signed long, vector signed long);
17025 vector signed long vec_mergeh (vector signed long, vector bool long);
17026 vector signed long vec_mergeh (vector bool long, vector signed long);
17027 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
17028 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
17029 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
17030 vector signed long vec_mergel (vector signed long, vector signed long);
17031 vector signed long vec_mergel (vector signed long, vector bool long);
17032 vector signed long vec_mergel (vector bool long, vector signed long);
17033 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
17034 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
17035 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
17036 vector double vec_min (vector double, vector double);
17037 vector float vec_msub (vector float, vector float, vector float);
17038 vector double vec_msub (vector double, vector double, vector double);
17039 vector float vec_mul (vector float, vector float);
17040 vector double vec_mul (vector double, vector double);
17041 vector long vec_mul (vector long, vector long);
17042 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
17043 vector float vec_nearbyint (vector float);
17044 vector double vec_nearbyint (vector double);
17045 vector float vec_nmadd (vector float, vector float, vector float);
17046 vector double vec_nmadd (vector double, vector double, vector double);
17047 vector double vec_nmsub (vector double, vector double, vector double);
17048 vector double vec_nor (vector double, vector double);
17049 vector long vec_nor (vector long, vector long);
17050 vector long vec_nor (vector long, vector bool long);
17051 vector long vec_nor (vector bool long, vector long);
17052 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
17053 vector unsigned long vec_nor (vector unsigned long, vector bool long);
17054 vector unsigned long vec_nor (vector bool long, vector unsigned long);
17055 vector double vec_or (vector double, vector double);
17056 vector double vec_or (vector double, vector bool long);
17057 vector double vec_or (vector bool long, vector double);
17058 vector long vec_or (vector long, vector long);
17059 vector long vec_or (vector long, vector bool long);
17060 vector long vec_or (vector bool long, vector long);
17061 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
17062 vector unsigned long vec_or (vector unsigned long, vector bool long);
17063 vector unsigned long vec_or (vector bool long, vector unsigned long);
17064 vector double vec_perm (vector double, vector double, vector unsigned char);
17065 vector long vec_perm (vector long, vector long, vector unsigned char);
17066 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
17067 vector unsigned char);
17068 vector double vec_rint (vector double);
17069 vector double vec_recip (vector double, vector double);
17070 vector double vec_rsqrt (vector double);
17071 vector double vec_rsqrte (vector double);
17072 vector double vec_sel (vector double, vector double, vector bool long);
17073 vector double vec_sel (vector double, vector double, vector unsigned long);
17074 vector long vec_sel (vector long, vector long, vector long);
17075 vector long vec_sel (vector long, vector long, vector unsigned long);
17076 vector long vec_sel (vector long, vector long, vector bool long);
17077 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17078 vector long);
17079 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17080 vector unsigned long);
17081 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17082 vector bool long);
17083 vector double vec_splats (double);
17084 vector signed long vec_splats (signed long);
17085 vector unsigned long vec_splats (unsigned long);
17086 vector float vec_sqrt (vector float);
17087 vector double vec_sqrt (vector double);
17088 void vec_st (vector double, int, vector double *);
17089 void vec_st (vector double, int, double *);
17090 vector double vec_sub (vector double, vector double);
17091 vector double vec_trunc (vector double);
17092 vector double vec_xl (int, vector double *);
17093 vector double vec_xl (int, double *);
17094 vector long long vec_xl (int, vector long long *);
17095 vector long long vec_xl (int, long long *);
17096 vector unsigned long long vec_xl (int, vector unsigned long long *);
17097 vector unsigned long long vec_xl (int, unsigned long long *);
17098 vector float vec_xl (int, vector float *);
17099 vector float vec_xl (int, float *);
17100 vector int vec_xl (int, vector int *);
17101 vector int vec_xl (int, int *);
17102 vector unsigned int vec_xl (int, vector unsigned int *);
17103 vector unsigned int vec_xl (int, unsigned int *);
17104 vector double vec_xor (vector double, vector double);
17105 vector double vec_xor (vector double, vector bool long);
17106 vector double vec_xor (vector bool long, vector double);
17107 vector long vec_xor (vector long, vector long);
17108 vector long vec_xor (vector long, vector bool long);
17109 vector long vec_xor (vector bool long, vector long);
17110 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
17111 vector unsigned long vec_xor (vector unsigned long, vector bool long);
17112 vector unsigned long vec_xor (vector bool long, vector unsigned long);
17113 void vec_xst (vector double, int, vector double *);
17114 void vec_xst (vector double, int, double *);
17115 void vec_xst (vector long long, int, vector long long *);
17116 void vec_xst (vector long long, int, long long *);
17117 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
17118 void vec_xst (vector unsigned long long, int, unsigned long long *);
17119 void vec_xst (vector float, int, vector float *);
17120 void vec_xst (vector float, int, float *);
17121 void vec_xst (vector int, int, vector int *);
17122 void vec_xst (vector int, int, int *);
17123 void vec_xst (vector unsigned int, int, vector unsigned int *);
17124 void vec_xst (vector unsigned int, int, unsigned int *);
17125 int vec_all_eq (vector double, vector double);
17126 int vec_all_ge (vector double, vector double);
17127 int vec_all_gt (vector double, vector double);
17128 int vec_all_le (vector double, vector double);
17129 int vec_all_lt (vector double, vector double);
17130 int vec_all_nan (vector double);
17131 int vec_all_ne (vector double, vector double);
17132 int vec_all_nge (vector double, vector double);
17133 int vec_all_ngt (vector double, vector double);
17134 int vec_all_nle (vector double, vector double);
17135 int vec_all_nlt (vector double, vector double);
17136 int vec_all_numeric (vector double);
17137 int vec_any_eq (vector double, vector double);
17138 int vec_any_ge (vector double, vector double);
17139 int vec_any_gt (vector double, vector double);
17140 int vec_any_le (vector double, vector double);
17141 int vec_any_lt (vector double, vector double);
17142 int vec_any_nan (vector double);
17143 int vec_any_ne (vector double, vector double);
17144 int vec_any_nge (vector double, vector double);
17145 int vec_any_ngt (vector double, vector double);
17146 int vec_any_nle (vector double, vector double);
17147 int vec_any_nlt (vector double, vector double);
17148 int vec_any_numeric (vector double);
17149
17150 vector double vec_vsx_ld (int, const vector double *);
17151 vector double vec_vsx_ld (int, const double *);
17152 vector float vec_vsx_ld (int, const vector float *);
17153 vector float vec_vsx_ld (int, const float *);
17154 vector bool int vec_vsx_ld (int, const vector bool int *);
17155 vector signed int vec_vsx_ld (int, const vector signed int *);
17156 vector signed int vec_vsx_ld (int, const int *);
17157 vector signed int vec_vsx_ld (int, const long *);
17158 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
17159 vector unsigned int vec_vsx_ld (int, const unsigned int *);
17160 vector unsigned int vec_vsx_ld (int, const unsigned long *);
17161 vector bool short vec_vsx_ld (int, const vector bool short *);
17162 vector pixel vec_vsx_ld (int, const vector pixel *);
17163 vector signed short vec_vsx_ld (int, const vector signed short *);
17164 vector signed short vec_vsx_ld (int, const short *);
17165 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
17166 vector unsigned short vec_vsx_ld (int, const unsigned short *);
17167 vector bool char vec_vsx_ld (int, const vector bool char *);
17168 vector signed char vec_vsx_ld (int, const vector signed char *);
17169 vector signed char vec_vsx_ld (int, const signed char *);
17170 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
17171 vector unsigned char vec_vsx_ld (int, const unsigned char *);
17172
17173 void vec_vsx_st (vector double, int, vector double *);
17174 void vec_vsx_st (vector double, int, double *);
17175 void vec_vsx_st (vector float, int, vector float *);
17176 void vec_vsx_st (vector float, int, float *);
17177 void vec_vsx_st (vector signed int, int, vector signed int *);
17178 void vec_vsx_st (vector signed int, int, int *);
17179 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
17180 void vec_vsx_st (vector unsigned int, int, unsigned int *);
17181 void vec_vsx_st (vector bool int, int, vector bool int *);
17182 void vec_vsx_st (vector bool int, int, unsigned int *);
17183 void vec_vsx_st (vector bool int, int, int *);
17184 void vec_vsx_st (vector signed short, int, vector signed short *);
17185 void vec_vsx_st (vector signed short, int, short *);
17186 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
17187 void vec_vsx_st (vector unsigned short, int, unsigned short *);
17188 void vec_vsx_st (vector bool short, int, vector bool short *);
17189 void vec_vsx_st (vector bool short, int, unsigned short *);
17190 void vec_vsx_st (vector pixel, int, vector pixel *);
17191 void vec_vsx_st (vector pixel, int, unsigned short *);
17192 void vec_vsx_st (vector pixel, int, short *);
17193 void vec_vsx_st (vector bool short, int, short *);
17194 void vec_vsx_st (vector signed char, int, vector signed char *);
17195 void vec_vsx_st (vector signed char, int, signed char *);
17196 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
17197 void vec_vsx_st (vector unsigned char, int, unsigned char *);
17198 void vec_vsx_st (vector bool char, int, vector bool char *);
17199 void vec_vsx_st (vector bool char, int, unsigned char *);
17200 void vec_vsx_st (vector bool char, int, signed char *);
17201
17202 vector double vec_xxpermdi (vector double, vector double, int);
17203 vector float vec_xxpermdi (vector float, vector float, int);
17204 vector long long vec_xxpermdi (vector long long, vector long long, int);
17205 vector unsigned long long vec_xxpermdi (vector unsigned long long,
17206 vector unsigned long long, int);
17207 vector int vec_xxpermdi (vector int, vector int, int);
17208 vector unsigned int vec_xxpermdi (vector unsigned int,
17209 vector unsigned int, int);
17210 vector short vec_xxpermdi (vector short, vector short, int);
17211 vector unsigned short vec_xxpermdi (vector unsigned short,
17212 vector unsigned short, int);
17213 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
17214 vector unsigned char vec_xxpermdi (vector unsigned char,
17215 vector unsigned char, int);
17216
17217 vector double vec_xxsldi (vector double, vector double, int);
17218 vector float vec_xxsldi (vector float, vector float, int);
17219 vector long long vec_xxsldi (vector long long, vector long long, int);
17220 vector unsigned long long vec_xxsldi (vector unsigned long long,
17221 vector unsigned long long, int);
17222 vector int vec_xxsldi (vector int, vector int, int);
17223 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
17224 vector short vec_xxsldi (vector short, vector short, int);
17225 vector unsigned short vec_xxsldi (vector unsigned short,
17226 vector unsigned short, int);
17227 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
17228 vector unsigned char vec_xxsldi (vector unsigned char,
17229 vector unsigned char, int);
17230 @end smallexample
17231
17232 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
17233 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
17234 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
17235 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
17236 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
17237
17238 If the ISA 2.07 additions to the vector/scalar (power8-vector)
17239 instruction set are available, the following additional functions are
17240 available for both 32-bit and 64-bit targets. For 64-bit targets, you
17241 can use @var{vector long} instead of @var{vector long long},
17242 @var{vector bool long} instead of @var{vector bool long long}, and
17243 @var{vector unsigned long} instead of @var{vector unsigned long long}.
17244
17245 @smallexample
17246 vector long long vec_abs (vector long long);
17247
17248 vector long long vec_add (vector long long, vector long long);
17249 vector unsigned long long vec_add (vector unsigned long long,
17250 vector unsigned long long);
17251
17252 int vec_all_eq (vector long long, vector long long);
17253 int vec_all_eq (vector unsigned long long, vector unsigned long long);
17254 int vec_all_ge (vector long long, vector long long);
17255 int vec_all_ge (vector unsigned long long, vector unsigned long long);
17256 int vec_all_gt (vector long long, vector long long);
17257 int vec_all_gt (vector unsigned long long, vector unsigned long long);
17258 int vec_all_le (vector long long, vector long long);
17259 int vec_all_le (vector unsigned long long, vector unsigned long long);
17260 int vec_all_lt (vector long long, vector long long);
17261 int vec_all_lt (vector unsigned long long, vector unsigned long long);
17262 int vec_all_ne (vector long long, vector long long);
17263 int vec_all_ne (vector unsigned long long, vector unsigned long long);
17264
17265 int vec_any_eq (vector long long, vector long long);
17266 int vec_any_eq (vector unsigned long long, vector unsigned long long);
17267 int vec_any_ge (vector long long, vector long long);
17268 int vec_any_ge (vector unsigned long long, vector unsigned long long);
17269 int vec_any_gt (vector long long, vector long long);
17270 int vec_any_gt (vector unsigned long long, vector unsigned long long);
17271 int vec_any_le (vector long long, vector long long);
17272 int vec_any_le (vector unsigned long long, vector unsigned long long);
17273 int vec_any_lt (vector long long, vector long long);
17274 int vec_any_lt (vector unsigned long long, vector unsigned long long);
17275 int vec_any_ne (vector long long, vector long long);
17276 int vec_any_ne (vector unsigned long long, vector unsigned long long);
17277
17278 vector long long vec_eqv (vector long long, vector long long);
17279 vector long long vec_eqv (vector bool long long, vector long long);
17280 vector long long vec_eqv (vector long long, vector bool long long);
17281 vector unsigned long long vec_eqv (vector unsigned long long,
17282 vector unsigned long long);
17283 vector unsigned long long vec_eqv (vector bool long long,
17284 vector unsigned long long);
17285 vector unsigned long long vec_eqv (vector unsigned long long,
17286 vector bool long long);
17287 vector int vec_eqv (vector int, vector int);
17288 vector int vec_eqv (vector bool int, vector int);
17289 vector int vec_eqv (vector int, vector bool int);
17290 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
17291 vector unsigned int vec_eqv (vector bool unsigned int,
17292 vector unsigned int);
17293 vector unsigned int vec_eqv (vector unsigned int,
17294 vector bool unsigned int);
17295 vector short vec_eqv (vector short, vector short);
17296 vector short vec_eqv (vector bool short, vector short);
17297 vector short vec_eqv (vector short, vector bool short);
17298 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
17299 vector unsigned short vec_eqv (vector bool unsigned short,
17300 vector unsigned short);
17301 vector unsigned short vec_eqv (vector unsigned short,
17302 vector bool unsigned short);
17303 vector signed char vec_eqv (vector signed char, vector signed char);
17304 vector signed char vec_eqv (vector bool signed char, vector signed char);
17305 vector signed char vec_eqv (vector signed char, vector bool signed char);
17306 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
17307 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
17308 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
17309
17310 vector long long vec_max (vector long long, vector long long);
17311 vector unsigned long long vec_max (vector unsigned long long,
17312 vector unsigned long long);
17313
17314 vector signed int vec_mergee (vector signed int, vector signed int);
17315 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
17316 vector bool int vec_mergee (vector bool int, vector bool int);
17317
17318 vector signed int vec_mergeo (vector signed int, vector signed int);
17319 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
17320 vector bool int vec_mergeo (vector bool int, vector bool int);
17321
17322 vector long long vec_min (vector long long, vector long long);
17323 vector unsigned long long vec_min (vector unsigned long long,
17324 vector unsigned long long);
17325
17326 vector long long vec_nand (vector long long, vector long long);
17327 vector long long vec_nand (vector bool long long, vector long long);
17328 vector long long vec_nand (vector long long, vector bool long long);
17329 vector unsigned long long vec_nand (vector unsigned long long,
17330 vector unsigned long long);
17331 vector unsigned long long vec_nand (vector bool long long,
17332 vector unsigned long long);
17333 vector unsigned long long vec_nand (vector unsigned long long,
17334 vector bool long long);
17335 vector int vec_nand (vector int, vector int);
17336 vector int vec_nand (vector bool int, vector int);
17337 vector int vec_nand (vector int, vector bool int);
17338 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
17339 vector unsigned int vec_nand (vector bool unsigned int,
17340 vector unsigned int);
17341 vector unsigned int vec_nand (vector unsigned int,
17342 vector bool unsigned int);
17343 vector short vec_nand (vector short, vector short);
17344 vector short vec_nand (vector bool short, vector short);
17345 vector short vec_nand (vector short, vector bool short);
17346 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
17347 vector unsigned short vec_nand (vector bool unsigned short,
17348 vector unsigned short);
17349 vector unsigned short vec_nand (vector unsigned short,
17350 vector bool unsigned short);
17351 vector signed char vec_nand (vector signed char, vector signed char);
17352 vector signed char vec_nand (vector bool signed char, vector signed char);
17353 vector signed char vec_nand (vector signed char, vector bool signed char);
17354 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
17355 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
17356 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
17357
17358 vector long long vec_orc (vector long long, vector long long);
17359 vector long long vec_orc (vector bool long long, vector long long);
17360 vector long long vec_orc (vector long long, vector bool long long);
17361 vector unsigned long long vec_orc (vector unsigned long long,
17362 vector unsigned long long);
17363 vector unsigned long long vec_orc (vector bool long long,
17364 vector unsigned long long);
17365 vector unsigned long long vec_orc (vector unsigned long long,
17366 vector bool long long);
17367 vector int vec_orc (vector int, vector int);
17368 vector int vec_orc (vector bool int, vector int);
17369 vector int vec_orc (vector int, vector bool int);
17370 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
17371 vector unsigned int vec_orc (vector bool unsigned int,
17372 vector unsigned int);
17373 vector unsigned int vec_orc (vector unsigned int,
17374 vector bool unsigned int);
17375 vector short vec_orc (vector short, vector short);
17376 vector short vec_orc (vector bool short, vector short);
17377 vector short vec_orc (vector short, vector bool short);
17378 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
17379 vector unsigned short vec_orc (vector bool unsigned short,
17380 vector unsigned short);
17381 vector unsigned short vec_orc (vector unsigned short,
17382 vector bool unsigned short);
17383 vector signed char vec_orc (vector signed char, vector signed char);
17384 vector signed char vec_orc (vector bool signed char, vector signed char);
17385 vector signed char vec_orc (vector signed char, vector bool signed char);
17386 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
17387 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
17388 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
17389
17390 vector int vec_pack (vector long long, vector long long);
17391 vector unsigned int vec_pack (vector unsigned long long,
17392 vector unsigned long long);
17393 vector bool int vec_pack (vector bool long long, vector bool long long);
17394
17395 vector int vec_packs (vector long long, vector long long);
17396 vector unsigned int vec_packs (vector unsigned long long,
17397 vector unsigned long long);
17398
17399 vector unsigned int vec_packsu (vector long long, vector long long);
17400 vector unsigned int vec_packsu (vector unsigned long long,
17401 vector unsigned long long);
17402
17403 vector long long vec_rl (vector long long,
17404 vector unsigned long long);
17405 vector long long vec_rl (vector unsigned long long,
17406 vector unsigned long long);
17407
17408 vector long long vec_sl (vector long long, vector unsigned long long);
17409 vector long long vec_sl (vector unsigned long long,
17410 vector unsigned long long);
17411
17412 vector long long vec_sr (vector long long, vector unsigned long long);
17413 vector unsigned long long char vec_sr (vector unsigned long long,
17414 vector unsigned long long);
17415
17416 vector long long vec_sra (vector long long, vector unsigned long long);
17417 vector unsigned long long vec_sra (vector unsigned long long,
17418 vector unsigned long long);
17419
17420 vector long long vec_sub (vector long long, vector long long);
17421 vector unsigned long long vec_sub (vector unsigned long long,
17422 vector unsigned long long);
17423
17424 vector long long vec_unpackh (vector int);
17425 vector unsigned long long vec_unpackh (vector unsigned int);
17426
17427 vector long long vec_unpackl (vector int);
17428 vector unsigned long long vec_unpackl (vector unsigned int);
17429
17430 vector long long vec_vaddudm (vector long long, vector long long);
17431 vector long long vec_vaddudm (vector bool long long, vector long long);
17432 vector long long vec_vaddudm (vector long long, vector bool long long);
17433 vector unsigned long long vec_vaddudm (vector unsigned long long,
17434 vector unsigned long long);
17435 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
17436 vector unsigned long long);
17437 vector unsigned long long vec_vaddudm (vector unsigned long long,
17438 vector bool unsigned long long);
17439
17440 vector long long vec_vbpermq (vector signed char, vector signed char);
17441 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
17442
17443 vector long long vec_cntlz (vector long long);
17444 vector unsigned long long vec_cntlz (vector unsigned long long);
17445 vector int vec_cntlz (vector int);
17446 vector unsigned int vec_cntlz (vector int);
17447 vector short vec_cntlz (vector short);
17448 vector unsigned short vec_cntlz (vector unsigned short);
17449 vector signed char vec_cntlz (vector signed char);
17450 vector unsigned char vec_cntlz (vector unsigned char);
17451
17452 vector long long vec_vclz (vector long long);
17453 vector unsigned long long vec_vclz (vector unsigned long long);
17454 vector int vec_vclz (vector int);
17455 vector unsigned int vec_vclz (vector int);
17456 vector short vec_vclz (vector short);
17457 vector unsigned short vec_vclz (vector unsigned short);
17458 vector signed char vec_vclz (vector signed char);
17459 vector unsigned char vec_vclz (vector unsigned char);
17460
17461 vector signed char vec_vclzb (vector signed char);
17462 vector unsigned char vec_vclzb (vector unsigned char);
17463
17464 vector long long vec_vclzd (vector long long);
17465 vector unsigned long long vec_vclzd (vector unsigned long long);
17466
17467 vector short vec_vclzh (vector short);
17468 vector unsigned short vec_vclzh (vector unsigned short);
17469
17470 vector int vec_vclzw (vector int);
17471 vector unsigned int vec_vclzw (vector int);
17472
17473 vector signed char vec_vgbbd (vector signed char);
17474 vector unsigned char vec_vgbbd (vector unsigned char);
17475
17476 vector long long vec_vmaxsd (vector long long, vector long long);
17477
17478 vector unsigned long long vec_vmaxud (vector unsigned long long,
17479 unsigned vector long long);
17480
17481 vector long long vec_vminsd (vector long long, vector long long);
17482
17483 vector unsigned long long vec_vminud (vector long long,
17484 vector long long);
17485
17486 vector int vec_vpksdss (vector long long, vector long long);
17487 vector unsigned int vec_vpksdss (vector long long, vector long long);
17488
17489 vector unsigned int vec_vpkudus (vector unsigned long long,
17490 vector unsigned long long);
17491
17492 vector int vec_vpkudum (vector long long, vector long long);
17493 vector unsigned int vec_vpkudum (vector unsigned long long,
17494 vector unsigned long long);
17495 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
17496
17497 vector long long vec_vpopcnt (vector long long);
17498 vector unsigned long long vec_vpopcnt (vector unsigned long long);
17499 vector int vec_vpopcnt (vector int);
17500 vector unsigned int vec_vpopcnt (vector int);
17501 vector short vec_vpopcnt (vector short);
17502 vector unsigned short vec_vpopcnt (vector unsigned short);
17503 vector signed char vec_vpopcnt (vector signed char);
17504 vector unsigned char vec_vpopcnt (vector unsigned char);
17505
17506 vector signed char vec_vpopcntb (vector signed char);
17507 vector unsigned char vec_vpopcntb (vector unsigned char);
17508
17509 vector long long vec_vpopcntd (vector long long);
17510 vector unsigned long long vec_vpopcntd (vector unsigned long long);
17511
17512 vector short vec_vpopcnth (vector short);
17513 vector unsigned short vec_vpopcnth (vector unsigned short);
17514
17515 vector int vec_vpopcntw (vector int);
17516 vector unsigned int vec_vpopcntw (vector int);
17517
17518 vector long long vec_vrld (vector long long, vector unsigned long long);
17519 vector unsigned long long vec_vrld (vector unsigned long long,
17520 vector unsigned long long);
17521
17522 vector long long vec_vsld (vector long long, vector unsigned long long);
17523 vector long long vec_vsld (vector unsigned long long,
17524 vector unsigned long long);
17525
17526 vector long long vec_vsrad (vector long long, vector unsigned long long);
17527 vector unsigned long long vec_vsrad (vector unsigned long long,
17528 vector unsigned long long);
17529
17530 vector long long vec_vsrd (vector long long, vector unsigned long long);
17531 vector unsigned long long char vec_vsrd (vector unsigned long long,
17532 vector unsigned long long);
17533
17534 vector long long vec_vsubudm (vector long long, vector long long);
17535 vector long long vec_vsubudm (vector bool long long, vector long long);
17536 vector long long vec_vsubudm (vector long long, vector bool long long);
17537 vector unsigned long long vec_vsubudm (vector unsigned long long,
17538 vector unsigned long long);
17539 vector unsigned long long vec_vsubudm (vector bool long long,
17540 vector unsigned long long);
17541 vector unsigned long long vec_vsubudm (vector unsigned long long,
17542 vector bool long long);
17543
17544 vector long long vec_vupkhsw (vector int);
17545 vector unsigned long long vec_vupkhsw (vector unsigned int);
17546
17547 vector long long vec_vupklsw (vector int);
17548 vector unsigned long long vec_vupklsw (vector int);
17549 @end smallexample
17550
17551 If the ISA 2.07 additions to the vector/scalar (power8-vector)
17552 instruction set are available, the following additional functions are
17553 available for 64-bit targets. New vector types
17554 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
17555 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
17556 builtins.
17557
17558 The normal vector extract, and set operations work on
17559 @var{vector __int128_t} and @var{vector __uint128_t} types,
17560 but the index value must be 0.
17561
17562 @smallexample
17563 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
17564 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
17565
17566 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
17567 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
17568
17569 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
17570 vector __int128_t);
17571 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
17572 vector __uint128_t);
17573
17574 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
17575 vector __int128_t);
17576 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
17577 vector __uint128_t);
17578
17579 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
17580 vector __int128_t);
17581 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
17582 vector __uint128_t);
17583
17584 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
17585 vector __int128_t);
17586 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
17587 vector __uint128_t);
17588
17589 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
17590 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
17591
17592 __int128_t vec_vsubuqm (__int128_t, __int128_t);
17593 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
17594
17595 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
17596 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
17597 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
17598 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
17599 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
17600 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
17601 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
17602 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
17603 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
17604 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
17605 @end smallexample
17606
17607 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
17608 are available:
17609
17610 @smallexample
17611 vector long long vec_vctz (vector long long);
17612 vector unsigned long long vec_vctz (vector unsigned long long);
17613 vector int vec_vctz (vector int);
17614 vector unsigned int vec_vctz (vector int);
17615 vector short vec_vctz (vector short);
17616 vector unsigned short vec_vctz (vector unsigned short);
17617 vector signed char vec_vctz (vector signed char);
17618 vector unsigned char vec_vctz (vector unsigned char);
17619
17620 vector signed char vec_vctzb (vector signed char);
17621 vector unsigned char vec_vctzb (vector unsigned char);
17622
17623 vector long long vec_vctzd (vector long long);
17624 vector unsigned long long vec_vctzd (vector unsigned long long);
17625
17626 vector short vec_vctzh (vector short);
17627 vector unsigned short vec_vctzh (vector unsigned short);
17628
17629 vector int vec_vctzw (vector int);
17630 vector unsigned int vec_vctzw (vector int);
17631
17632 vector int vec_vprtyb (vector int);
17633 vector unsigned int vec_vprtyb (vector unsigned int);
17634 vector long long vec_vprtyb (vector long long);
17635 vector unsigned long long vec_vprtyb (vector unsigned long long);
17636
17637 vector int vec_vprtybw (vector int);
17638 vector unsigned int vec_vprtybw (vector unsigned int);
17639
17640 vector long long vec_vprtybd (vector long long);
17641 vector unsigned long long vec_vprtybd (vector unsigned long long);
17642 @end smallexample
17643
17644 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
17645 are available:
17646
17647 @smallexample
17648 vector long vec_vprtyb (vector long);
17649 vector unsigned long vec_vprtyb (vector unsigned long);
17650 vector __int128_t vec_vprtyb (vector __int128_t);
17651 vector __uint128_t vec_vprtyb (vector __uint128_t);
17652
17653 vector long vec_vprtybd (vector long);
17654 vector unsigned long vec_vprtybd (vector unsigned long);
17655
17656 vector __int128_t vec_vprtybq (vector __int128_t);
17657 vector __uint128_t vec_vprtybd (vector __uint128_t);
17658 @end smallexample
17659
17660 The following built-in vector functions are available for the PowerPC family
17661 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
17662 @smallexample
17663 __vector unsigned char
17664 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
17665 __vector unsigned char
17666 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
17667 @end smallexample
17668
17669 The @code{vec_slv} and @code{vec_srv} functions operate on
17670 all of the bytes of their @code{src} and @code{shift_distance}
17671 arguments in parallel. The behavior of the @code{vec_slv} is as if
17672 there existed a temporary array of 17 unsigned characters
17673 @code{slv_array} within which elements 0 through 15 are the same as
17674 the entries in the @code{src} array and element 16 equals 0. The
17675 result returned from the @code{vec_slv} function is a
17676 @code{__vector} of 16 unsigned characters within which element
17677 @code{i} is computed using the C expression
17678 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
17679 shift_distance[i]))},
17680 with this resulting value coerced to the @code{unsigned char} type.
17681 The behavior of the @code{vec_srv} is as if
17682 there existed a temporary array of 17 unsigned characters
17683 @code{srv_array} within which element 0 equals zero and
17684 elements 1 through 16 equal the elements 0 through 15 of
17685 the @code{src} array. The
17686 result returned from the @code{vec_srv} function is a
17687 @code{__vector} of 16 unsigned characters within which element
17688 @code{i} is computed using the C expression
17689 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
17690 (0x07 & shift_distance[i]))},
17691 with this resulting value coerced to the @code{unsigned char} type.
17692
17693 The following built-in functions are available for the PowerPC family
17694 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
17695 @smallexample
17696 __vector unsigned char
17697 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
17698 __vector unsigned short
17699 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
17700 __vector unsigned int
17701 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
17702
17703 __vector unsigned char
17704 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
17705 __vector unsigned short
17706 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
17707 __vector unsigned int
17708 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
17709 @end smallexample
17710
17711 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
17712 @code{vec_absdw} built-in functions each computes the absolute
17713 differences of the pairs of vector elements supplied in its two vector
17714 arguments, placing the absolute differences into the corresponding
17715 elements of the vector result.
17716
17717 The following built-in functions are available for the PowerPC family
17718 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
17719 @smallexample
17720 __vector int
17721 vec_extract_exp (__vector float source);
17722 __vector long long int
17723 vec_extract_exp (__vector double source);
17724
17725 __vector int
17726 vec_extract_sig (__vector float source);
17727 __vector long long int
17728 vec_extract_sig (__vector double source);
17729
17730 __vector float
17731 vec_insert_exp (__vector unsigned int significands, __vector unsigned int exponents);
17732 __vector double
17733 vec_insert_exp (__vector unsigned long long int significands,
17734 __vector unsigned long long int exponents);
17735
17736 __vector int vec_test_data_class (__vector float source, unsigned int condition);
17737 __vector long long int vec_test_data_class (__vector double source, unsigned int condition);
17738 @end smallexample
17739
17740 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
17741 functions return vectors representing the significands and exponents
17742 of their @code{source} arguments respectively. The
17743 @code{vec_insert_exp} built-in functions return a vector of single- or
17744 double-precision floating
17745 point values constructed by assembling the values of their
17746 @code{significands} and @code{exponents} arguments into the
17747 corresponding elements of the returned vector. The sign of each
17748 element of the result is copied from the most significant bit of the
17749 corresponding entry within the @code{significands} argument. The
17750 significand and exponent components of each element of the result are
17751 composed of the least significant bits of the corresponding
17752 @code{significands} element and the least significant bits of the
17753 corresponding @code{exponents} element.
17754
17755 The @code{vec_test_data_class} built-in function returns a vector
17756 representing the results of testing the @code{source} vector for the
17757 condition selected by the @code{condition} argument. The
17758 @code{condition} argument must be an unsigned integer with value not
17759 exceeding 127. The
17760 @code{condition} argument is encoded as a bitmask with each bit
17761 enabling the testing of a different condition, as characterized by the
17762 following:
17763 @smallexample
17764 0x40 Test for NaN
17765 0x20 Test for +Infinity
17766 0x10 Test for -Infinity
17767 0x08 Test for +Zero
17768 0x04 Test for -Zero
17769 0x02 Test for +Denormal
17770 0x01 Test for -Denormal
17771 @end smallexample
17772
17773 If any of the enabled test conditions is true, the corresponding entry
17774 in the result vector is -1. Otherwise (all of the enabled test
17775 conditions are false), the corresponding entry of the result vector is 0.
17776
17777 If the cryptographic instructions are enabled (@option{-mcrypto} or
17778 @option{-mcpu=power8}), the following builtins are enabled.
17779
17780 @smallexample
17781 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
17782
17783 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
17784 vector unsigned long long);
17785
17786 vector unsigned long long __builtin_crypto_vcipherlast
17787 (vector unsigned long long,
17788 vector unsigned long long);
17789
17790 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
17791 vector unsigned long long);
17792
17793 vector unsigned long long __builtin_crypto_vncipherlast
17794 (vector unsigned long long,
17795 vector unsigned long long);
17796
17797 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
17798 vector unsigned char,
17799 vector unsigned char);
17800
17801 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
17802 vector unsigned short,
17803 vector unsigned short);
17804
17805 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
17806 vector unsigned int,
17807 vector unsigned int);
17808
17809 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
17810 vector unsigned long long,
17811 vector unsigned long long);
17812
17813 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
17814 vector unsigned char);
17815
17816 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
17817 vector unsigned short);
17818
17819 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
17820 vector unsigned int);
17821
17822 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
17823 vector unsigned long long);
17824
17825 vector unsigned long long __builtin_crypto_vshasigmad
17826 (vector unsigned long long, int, int);
17827
17828 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
17829 int, int);
17830 @end smallexample
17831
17832 The second argument to the @var{__builtin_crypto_vshasigmad} and
17833 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
17834 integer that is 0 or 1. The third argument to these builtin functions
17835 must be a constant integer in the range of 0 to 15.
17836
17837 If the ISA 3.0 instruction set additions
17838 are enabled (@option{-mcpu=power9}), the following additional
17839 functions are available for both 32-bit and 64-bit targets.
17840
17841 vector short vec_xl (int, vector short *);
17842 vector short vec_xl (int, short *);
17843 vector unsigned short vec_xl (int, vector unsigned short *);
17844 vector unsigned short vec_xl (int, unsigned short *);
17845 vector char vec_xl (int, vector char *);
17846 vector char vec_xl (int, char *);
17847 vector unsigned char vec_xl (int, vector unsigned char *);
17848 vector unsigned char vec_xl (int, unsigned char *);
17849
17850 void vec_xst (vector short, int, vector short *);
17851 void vec_xst (vector short, int, short *);
17852 void vec_xst (vector unsigned short, int, vector unsigned short *);
17853 void vec_xst (vector unsigned short, int, unsigned short *);
17854 void vec_xst (vector char, int, vector char *);
17855 void vec_xst (vector char, int, char *);
17856 void vec_xst (vector unsigned char, int, vector unsigned char *);
17857 void vec_xst (vector unsigned char, int, unsigned char *);
17858
17859 @node PowerPC Hardware Transactional Memory Built-in Functions
17860 @subsection PowerPC Hardware Transactional Memory Built-in Functions
17861 GCC provides two interfaces for accessing the Hardware Transactional
17862 Memory (HTM) instructions available on some of the PowerPC family
17863 of processors (eg, POWER8). The two interfaces come in a low level
17864 interface, consisting of built-in functions specific to PowerPC and a
17865 higher level interface consisting of inline functions that are common
17866 between PowerPC and S/390.
17867
17868 @subsubsection PowerPC HTM Low Level Built-in Functions
17869
17870 The following low level built-in functions are available with
17871 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
17872 They all generate the machine instruction that is part of the name.
17873
17874 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
17875 the full 4-bit condition register value set by their associated hardware
17876 instruction. The header file @code{htmintrin.h} defines some macros that can
17877 be used to decipher the return value. The @code{__builtin_tbegin} builtin
17878 returns a simple true or false value depending on whether a transaction was
17879 successfully started or not. The arguments of the builtins match exactly the
17880 type and order of the associated hardware instruction's operands, except for
17881 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
17882 Refer to the ISA manual for a description of each instruction's operands.
17883
17884 @smallexample
17885 unsigned int __builtin_tbegin (unsigned int)
17886 unsigned int __builtin_tend (unsigned int)
17887
17888 unsigned int __builtin_tabort (unsigned int)
17889 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
17890 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
17891 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
17892 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
17893
17894 unsigned int __builtin_tcheck (void)
17895 unsigned int __builtin_treclaim (unsigned int)
17896 unsigned int __builtin_trechkpt (void)
17897 unsigned int __builtin_tsr (unsigned int)
17898 @end smallexample
17899
17900 In addition to the above HTM built-ins, we have added built-ins for
17901 some common extended mnemonics of the HTM instructions:
17902
17903 @smallexample
17904 unsigned int __builtin_tendall (void)
17905 unsigned int __builtin_tresume (void)
17906 unsigned int __builtin_tsuspend (void)
17907 @end smallexample
17908
17909 Note that the semantics of the above HTM builtins are required to mimic
17910 the locking semantics used for critical sections. Builtins that are used
17911 to create a new transaction or restart a suspended transaction must have
17912 lock acquisition like semantics while those builtins that end or suspend a
17913 transaction must have lock release like semantics. Specifically, this must
17914 mimic lock semantics as specified by C++11, for example: Lock acquisition is
17915 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
17916 that returns 0, and lock release is as-if an execution of
17917 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
17918 implicit implementation-defined lock used for all transactions. The HTM
17919 instructions associated with with the builtins inherently provide the
17920 correct acquisition and release hardware barriers required. However,
17921 the compiler must also be prohibited from moving loads and stores across
17922 the builtins in a way that would violate their semantics. This has been
17923 accomplished by adding memory barriers to the associated HTM instructions
17924 (which is a conservative approach to provide acquire and release semantics).
17925 Earlier versions of the compiler did not treat the HTM instructions as
17926 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
17927 be used to determine whether the current compiler treats HTM instructions
17928 as memory barriers or not. This allows the user to explicitly add memory
17929 barriers to their code when using an older version of the compiler.
17930
17931 The following set of built-in functions are available to gain access
17932 to the HTM specific special purpose registers.
17933
17934 @smallexample
17935 unsigned long __builtin_get_texasr (void)
17936 unsigned long __builtin_get_texasru (void)
17937 unsigned long __builtin_get_tfhar (void)
17938 unsigned long __builtin_get_tfiar (void)
17939
17940 void __builtin_set_texasr (unsigned long);
17941 void __builtin_set_texasru (unsigned long);
17942 void __builtin_set_tfhar (unsigned long);
17943 void __builtin_set_tfiar (unsigned long);
17944 @end smallexample
17945
17946 Example usage of these low level built-in functions may look like:
17947
17948 @smallexample
17949 #include <htmintrin.h>
17950
17951 int num_retries = 10;
17952
17953 while (1)
17954 @{
17955 if (__builtin_tbegin (0))
17956 @{
17957 /* Transaction State Initiated. */
17958 if (is_locked (lock))
17959 __builtin_tabort (0);
17960 ... transaction code...
17961 __builtin_tend (0);
17962 break;
17963 @}
17964 else
17965 @{
17966 /* Transaction State Failed. Use locks if the transaction
17967 failure is "persistent" or we've tried too many times. */
17968 if (num_retries-- <= 0
17969 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
17970 @{
17971 acquire_lock (lock);
17972 ... non transactional fallback path...
17973 release_lock (lock);
17974 break;
17975 @}
17976 @}
17977 @}
17978 @end smallexample
17979
17980 One final built-in function has been added that returns the value of
17981 the 2-bit Transaction State field of the Machine Status Register (MSR)
17982 as stored in @code{CR0}.
17983
17984 @smallexample
17985 unsigned long __builtin_ttest (void)
17986 @end smallexample
17987
17988 This built-in can be used to determine the current transaction state
17989 using the following code example:
17990
17991 @smallexample
17992 #include <htmintrin.h>
17993
17994 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
17995
17996 if (tx_state == _HTM_TRANSACTIONAL)
17997 @{
17998 /* Code to use in transactional state. */
17999 @}
18000 else if (tx_state == _HTM_NONTRANSACTIONAL)
18001 @{
18002 /* Code to use in non-transactional state. */
18003 @}
18004 else if (tx_state == _HTM_SUSPENDED)
18005 @{
18006 /* Code to use in transaction suspended state. */
18007 @}
18008 @end smallexample
18009
18010 @subsubsection PowerPC HTM High Level Inline Functions
18011
18012 The following high level HTM interface is made available by including
18013 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
18014 where CPU is `power8' or later. This interface is common between PowerPC
18015 and S/390, allowing users to write one HTM source implementation that
18016 can be compiled and executed on either system.
18017
18018 @smallexample
18019 long __TM_simple_begin (void)
18020 long __TM_begin (void* const TM_buff)
18021 long __TM_end (void)
18022 void __TM_abort (void)
18023 void __TM_named_abort (unsigned char const code)
18024 void __TM_resume (void)
18025 void __TM_suspend (void)
18026
18027 long __TM_is_user_abort (void* const TM_buff)
18028 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
18029 long __TM_is_illegal (void* const TM_buff)
18030 long __TM_is_footprint_exceeded (void* const TM_buff)
18031 long __TM_nesting_depth (void* const TM_buff)
18032 long __TM_is_nested_too_deep(void* const TM_buff)
18033 long __TM_is_conflict(void* const TM_buff)
18034 long __TM_is_failure_persistent(void* const TM_buff)
18035 long __TM_failure_address(void* const TM_buff)
18036 long long __TM_failure_code(void* const TM_buff)
18037 @end smallexample
18038
18039 Using these common set of HTM inline functions, we can create
18040 a more portable version of the HTM example in the previous
18041 section that will work on either PowerPC or S/390:
18042
18043 @smallexample
18044 #include <htmxlintrin.h>
18045
18046 int num_retries = 10;
18047 TM_buff_type TM_buff;
18048
18049 while (1)
18050 @{
18051 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
18052 @{
18053 /* Transaction State Initiated. */
18054 if (is_locked (lock))
18055 __TM_abort ();
18056 ... transaction code...
18057 __TM_end ();
18058 break;
18059 @}
18060 else
18061 @{
18062 /* Transaction State Failed. Use locks if the transaction
18063 failure is "persistent" or we've tried too many times. */
18064 if (num_retries-- <= 0
18065 || __TM_is_failure_persistent (TM_buff))
18066 @{
18067 acquire_lock (lock);
18068 ... non transactional fallback path...
18069 release_lock (lock);
18070 break;
18071 @}
18072 @}
18073 @}
18074 @end smallexample
18075
18076 @node RX Built-in Functions
18077 @subsection RX Built-in Functions
18078 GCC supports some of the RX instructions which cannot be expressed in
18079 the C programming language via the use of built-in functions. The
18080 following functions are supported:
18081
18082 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
18083 Generates the @code{brk} machine instruction.
18084 @end deftypefn
18085
18086 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
18087 Generates the @code{clrpsw} machine instruction to clear the specified
18088 bit in the processor status word.
18089 @end deftypefn
18090
18091 @deftypefn {Built-in Function} void __builtin_rx_int (int)
18092 Generates the @code{int} machine instruction to generate an interrupt
18093 with the specified value.
18094 @end deftypefn
18095
18096 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
18097 Generates the @code{machi} machine instruction to add the result of
18098 multiplying the top 16 bits of the two arguments into the
18099 accumulator.
18100 @end deftypefn
18101
18102 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
18103 Generates the @code{maclo} machine instruction to add the result of
18104 multiplying the bottom 16 bits of the two arguments into the
18105 accumulator.
18106 @end deftypefn
18107
18108 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
18109 Generates the @code{mulhi} machine instruction to place the result of
18110 multiplying the top 16 bits of the two arguments into the
18111 accumulator.
18112 @end deftypefn
18113
18114 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
18115 Generates the @code{mullo} machine instruction to place the result of
18116 multiplying the bottom 16 bits of the two arguments into the
18117 accumulator.
18118 @end deftypefn
18119
18120 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
18121 Generates the @code{mvfachi} machine instruction to read the top
18122 32 bits of the accumulator.
18123 @end deftypefn
18124
18125 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
18126 Generates the @code{mvfacmi} machine instruction to read the middle
18127 32 bits of the accumulator.
18128 @end deftypefn
18129
18130 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
18131 Generates the @code{mvfc} machine instruction which reads the control
18132 register specified in its argument and returns its value.
18133 @end deftypefn
18134
18135 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
18136 Generates the @code{mvtachi} machine instruction to set the top
18137 32 bits of the accumulator.
18138 @end deftypefn
18139
18140 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
18141 Generates the @code{mvtaclo} machine instruction to set the bottom
18142 32 bits of the accumulator.
18143 @end deftypefn
18144
18145 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
18146 Generates the @code{mvtc} machine instruction which sets control
18147 register number @code{reg} to @code{val}.
18148 @end deftypefn
18149
18150 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
18151 Generates the @code{mvtipl} machine instruction set the interrupt
18152 priority level.
18153 @end deftypefn
18154
18155 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
18156 Generates the @code{racw} machine instruction to round the accumulator
18157 according to the specified mode.
18158 @end deftypefn
18159
18160 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
18161 Generates the @code{revw} machine instruction which swaps the bytes in
18162 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
18163 and also bits 16--23 occupy bits 24--31 and vice versa.
18164 @end deftypefn
18165
18166 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
18167 Generates the @code{rmpa} machine instruction which initiates a
18168 repeated multiply and accumulate sequence.
18169 @end deftypefn
18170
18171 @deftypefn {Built-in Function} void __builtin_rx_round (float)
18172 Generates the @code{round} machine instruction which returns the
18173 floating-point argument rounded according to the current rounding mode
18174 set in the floating-point status word register.
18175 @end deftypefn
18176
18177 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
18178 Generates the @code{sat} machine instruction which returns the
18179 saturated value of the argument.
18180 @end deftypefn
18181
18182 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
18183 Generates the @code{setpsw} machine instruction to set the specified
18184 bit in the processor status word.
18185 @end deftypefn
18186
18187 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
18188 Generates the @code{wait} machine instruction.
18189 @end deftypefn
18190
18191 @node S/390 System z Built-in Functions
18192 @subsection S/390 System z Built-in Functions
18193 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
18194 Generates the @code{tbegin} machine instruction starting a
18195 non-constrained hardware transaction. If the parameter is non-NULL the
18196 memory area is used to store the transaction diagnostic buffer and
18197 will be passed as first operand to @code{tbegin}. This buffer can be
18198 defined using the @code{struct __htm_tdb} C struct defined in
18199 @code{htmintrin.h} and must reside on a double-word boundary. The
18200 second tbegin operand is set to @code{0xff0c}. This enables
18201 save/restore of all GPRs and disables aborts for FPR and AR
18202 manipulations inside the transaction body. The condition code set by
18203 the tbegin instruction is returned as integer value. The tbegin
18204 instruction by definition overwrites the content of all FPRs. The
18205 compiler will generate code which saves and restores the FPRs. For
18206 soft-float code it is recommended to used the @code{*_nofloat}
18207 variant. In order to prevent a TDB from being written it is required
18208 to pass a constant zero value as parameter. Passing a zero value
18209 through a variable is not sufficient. Although modifications of
18210 access registers inside the transaction will not trigger an
18211 transaction abort it is not supported to actually modify them. Access
18212 registers do not get saved when entering a transaction. They will have
18213 undefined state when reaching the abort code.
18214 @end deftypefn
18215
18216 Macros for the possible return codes of tbegin are defined in the
18217 @code{htmintrin.h} header file:
18218
18219 @table @code
18220 @item _HTM_TBEGIN_STARTED
18221 @code{tbegin} has been executed as part of normal processing. The
18222 transaction body is supposed to be executed.
18223 @item _HTM_TBEGIN_INDETERMINATE
18224 The transaction was aborted due to an indeterminate condition which
18225 might be persistent.
18226 @item _HTM_TBEGIN_TRANSIENT
18227 The transaction aborted due to a transient failure. The transaction
18228 should be re-executed in that case.
18229 @item _HTM_TBEGIN_PERSISTENT
18230 The transaction aborted due to a persistent failure. Re-execution
18231 under same circumstances will not be productive.
18232 @end table
18233
18234 @defmac _HTM_FIRST_USER_ABORT_CODE
18235 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
18236 specifies the first abort code which can be used for
18237 @code{__builtin_tabort}. Values below this threshold are reserved for
18238 machine use.
18239 @end defmac
18240
18241 @deftp {Data type} {struct __htm_tdb}
18242 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
18243 the structure of the transaction diagnostic block as specified in the
18244 Principles of Operation manual chapter 5-91.
18245 @end deftp
18246
18247 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
18248 Same as @code{__builtin_tbegin} but without FPR saves and restores.
18249 Using this variant in code making use of FPRs will leave the FPRs in
18250 undefined state when entering the transaction abort handler code.
18251 @end deftypefn
18252
18253 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
18254 In addition to @code{__builtin_tbegin} a loop for transient failures
18255 is generated. If tbegin returns a condition code of 2 the transaction
18256 will be retried as often as specified in the second argument. The
18257 perform processor assist instruction is used to tell the CPU about the
18258 number of fails so far.
18259 @end deftypefn
18260
18261 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
18262 Same as @code{__builtin_tbegin_retry} but without FPR saves and
18263 restores. Using this variant in code making use of FPRs will leave
18264 the FPRs in undefined state when entering the transaction abort
18265 handler code.
18266 @end deftypefn
18267
18268 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
18269 Generates the @code{tbeginc} machine instruction starting a constrained
18270 hardware transaction. The second operand is set to @code{0xff08}.
18271 @end deftypefn
18272
18273 @deftypefn {Built-in Function} int __builtin_tend (void)
18274 Generates the @code{tend} machine instruction finishing a transaction
18275 and making the changes visible to other threads. The condition code
18276 generated by tend is returned as integer value.
18277 @end deftypefn
18278
18279 @deftypefn {Built-in Function} void __builtin_tabort (int)
18280 Generates the @code{tabort} machine instruction with the specified
18281 abort code. Abort codes from 0 through 255 are reserved and will
18282 result in an error message.
18283 @end deftypefn
18284
18285 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
18286 Generates the @code{ppa rX,rY,1} machine instruction. Where the
18287 integer parameter is loaded into rX and a value of zero is loaded into
18288 rY. The integer parameter specifies the number of times the
18289 transaction repeatedly aborted.
18290 @end deftypefn
18291
18292 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
18293 Generates the @code{etnd} machine instruction. The current nesting
18294 depth is returned as integer value. For a nesting depth of 0 the code
18295 is not executed as part of an transaction.
18296 @end deftypefn
18297
18298 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
18299
18300 Generates the @code{ntstg} machine instruction. The second argument
18301 is written to the first arguments location. The store operation will
18302 not be rolled-back in case of an transaction abort.
18303 @end deftypefn
18304
18305 @node SH Built-in Functions
18306 @subsection SH Built-in Functions
18307 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
18308 families of processors:
18309
18310 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
18311 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
18312 used by system code that manages threads and execution contexts. The compiler
18313 normally does not generate code that modifies the contents of @samp{GBR} and
18314 thus the value is preserved across function calls. Changing the @samp{GBR}
18315 value in user code must be done with caution, since the compiler might use
18316 @samp{GBR} in order to access thread local variables.
18317
18318 @end deftypefn
18319
18320 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
18321 Returns the value that is currently set in the @samp{GBR} register.
18322 Memory loads and stores that use the thread pointer as a base address are
18323 turned into @samp{GBR} based displacement loads and stores, if possible.
18324 For example:
18325 @smallexample
18326 struct my_tcb
18327 @{
18328 int a, b, c, d, e;
18329 @};
18330
18331 int get_tcb_value (void)
18332 @{
18333 // Generate @samp{mov.l @@(8,gbr),r0} instruction
18334 return ((my_tcb*)__builtin_thread_pointer ())->c;
18335 @}
18336
18337 @end smallexample
18338 @end deftypefn
18339
18340 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
18341 Returns the value that is currently set in the @samp{FPSCR} register.
18342 @end deftypefn
18343
18344 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
18345 Sets the @samp{FPSCR} register to the specified value @var{val}, while
18346 preserving the current values of the FR, SZ and PR bits.
18347 @end deftypefn
18348
18349 @node SPARC VIS Built-in Functions
18350 @subsection SPARC VIS Built-in Functions
18351
18352 GCC supports SIMD operations on the SPARC using both the generic vector
18353 extensions (@pxref{Vector Extensions}) as well as built-in functions for
18354 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
18355 switch, the VIS extension is exposed as the following built-in functions:
18356
18357 @smallexample
18358 typedef int v1si __attribute__ ((vector_size (4)));
18359 typedef int v2si __attribute__ ((vector_size (8)));
18360 typedef short v4hi __attribute__ ((vector_size (8)));
18361 typedef short v2hi __attribute__ ((vector_size (4)));
18362 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
18363 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
18364
18365 void __builtin_vis_write_gsr (int64_t);
18366 int64_t __builtin_vis_read_gsr (void);
18367
18368 void * __builtin_vis_alignaddr (void *, long);
18369 void * __builtin_vis_alignaddrl (void *, long);
18370 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
18371 v2si __builtin_vis_faligndatav2si (v2si, v2si);
18372 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
18373 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
18374
18375 v4hi __builtin_vis_fexpand (v4qi);
18376
18377 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
18378 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
18379 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
18380 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
18381 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
18382 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
18383 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
18384
18385 v4qi __builtin_vis_fpack16 (v4hi);
18386 v8qi __builtin_vis_fpack32 (v2si, v8qi);
18387 v2hi __builtin_vis_fpackfix (v2si);
18388 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
18389
18390 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
18391
18392 long __builtin_vis_edge8 (void *, void *);
18393 long __builtin_vis_edge8l (void *, void *);
18394 long __builtin_vis_edge16 (void *, void *);
18395 long __builtin_vis_edge16l (void *, void *);
18396 long __builtin_vis_edge32 (void *, void *);
18397 long __builtin_vis_edge32l (void *, void *);
18398
18399 long __builtin_vis_fcmple16 (v4hi, v4hi);
18400 long __builtin_vis_fcmple32 (v2si, v2si);
18401 long __builtin_vis_fcmpne16 (v4hi, v4hi);
18402 long __builtin_vis_fcmpne32 (v2si, v2si);
18403 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
18404 long __builtin_vis_fcmpgt32 (v2si, v2si);
18405 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
18406 long __builtin_vis_fcmpeq32 (v2si, v2si);
18407
18408 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
18409 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
18410 v2si __builtin_vis_fpadd32 (v2si, v2si);
18411 v1si __builtin_vis_fpadd32s (v1si, v1si);
18412 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
18413 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
18414 v2si __builtin_vis_fpsub32 (v2si, v2si);
18415 v1si __builtin_vis_fpsub32s (v1si, v1si);
18416
18417 long __builtin_vis_array8 (long, long);
18418 long __builtin_vis_array16 (long, long);
18419 long __builtin_vis_array32 (long, long);
18420 @end smallexample
18421
18422 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
18423 functions also become available:
18424
18425 @smallexample
18426 long __builtin_vis_bmask (long, long);
18427 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
18428 v2si __builtin_vis_bshufflev2si (v2si, v2si);
18429 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
18430 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
18431
18432 long __builtin_vis_edge8n (void *, void *);
18433 long __builtin_vis_edge8ln (void *, void *);
18434 long __builtin_vis_edge16n (void *, void *);
18435 long __builtin_vis_edge16ln (void *, void *);
18436 long __builtin_vis_edge32n (void *, void *);
18437 long __builtin_vis_edge32ln (void *, void *);
18438 @end smallexample
18439
18440 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
18441 functions also become available:
18442
18443 @smallexample
18444 void __builtin_vis_cmask8 (long);
18445 void __builtin_vis_cmask16 (long);
18446 void __builtin_vis_cmask32 (long);
18447
18448 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
18449
18450 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
18451 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
18452 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
18453 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
18454 v2si __builtin_vis_fsll16 (v2si, v2si);
18455 v2si __builtin_vis_fslas16 (v2si, v2si);
18456 v2si __builtin_vis_fsrl16 (v2si, v2si);
18457 v2si __builtin_vis_fsra16 (v2si, v2si);
18458
18459 long __builtin_vis_pdistn (v8qi, v8qi);
18460
18461 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
18462
18463 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
18464 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
18465
18466 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
18467 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
18468 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
18469 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
18470 v2si __builtin_vis_fpadds32 (v2si, v2si);
18471 v1si __builtin_vis_fpadds32s (v1si, v1si);
18472 v2si __builtin_vis_fpsubs32 (v2si, v2si);
18473 v1si __builtin_vis_fpsubs32s (v1si, v1si);
18474
18475 long __builtin_vis_fucmple8 (v8qi, v8qi);
18476 long __builtin_vis_fucmpne8 (v8qi, v8qi);
18477 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
18478 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
18479
18480 float __builtin_vis_fhadds (float, float);
18481 double __builtin_vis_fhaddd (double, double);
18482 float __builtin_vis_fhsubs (float, float);
18483 double __builtin_vis_fhsubd (double, double);
18484 float __builtin_vis_fnhadds (float, float);
18485 double __builtin_vis_fnhaddd (double, double);
18486
18487 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
18488 int64_t __builtin_vis_xmulx (int64_t, int64_t);
18489 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
18490 @end smallexample
18491
18492 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
18493 functions also become available:
18494
18495 @smallexample
18496 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
18497 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
18498 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
18499 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
18500
18501 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
18502 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
18503 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
18504 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
18505
18506 long __builtin_vis_fpcmple8 (v8qi, v8qi);
18507 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
18508 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
18509 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
18510 long __builtin_vis_fpcmpule32 (v2si, v2si);
18511 long __builtin_vis_fpcmpugt32 (v2si, v2si);
18512
18513 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
18514 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
18515 v2si __builtin_vis_fpmax32 (v2si, v2si);
18516
18517 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
18518 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
18519 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
18520
18521
18522 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
18523 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
18524 v2si __builtin_vis_fpmin32 (v2si, v2si);
18525
18526 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
18527 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
18528 v2si __builtin_vis_fpminu32 (v2si, v2si);
18529 @end smallexample
18530
18531 @node SPU Built-in Functions
18532 @subsection SPU Built-in Functions
18533
18534 GCC provides extensions for the SPU processor as described in the
18535 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
18536 found at @uref{http://cell.scei.co.jp/} or
18537 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
18538 implementation differs in several ways.
18539
18540 @itemize @bullet
18541
18542 @item
18543 The optional extension of specifying vector constants in parentheses is
18544 not supported.
18545
18546 @item
18547 A vector initializer requires no cast if the vector constant is of the
18548 same type as the variable it is initializing.
18549
18550 @item
18551 If @code{signed} or @code{unsigned} is omitted, the signedness of the
18552 vector type is the default signedness of the base type. The default
18553 varies depending on the operating system, so a portable program should
18554 always specify the signedness.
18555
18556 @item
18557 By default, the keyword @code{__vector} is added. The macro
18558 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
18559 undefined.
18560
18561 @item
18562 GCC allows using a @code{typedef} name as the type specifier for a
18563 vector type.
18564
18565 @item
18566 For C, overloaded functions are implemented with macros so the following
18567 does not work:
18568
18569 @smallexample
18570 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
18571 @end smallexample
18572
18573 @noindent
18574 Since @code{spu_add} is a macro, the vector constant in the example
18575 is treated as four separate arguments. Wrap the entire argument in
18576 parentheses for this to work.
18577
18578 @item
18579 The extended version of @code{__builtin_expect} is not supported.
18580
18581 @end itemize
18582
18583 @emph{Note:} Only the interface described in the aforementioned
18584 specification is supported. Internally, GCC uses built-in functions to
18585 implement the required functionality, but these are not supported and
18586 are subject to change without notice.
18587
18588 @node TI C6X Built-in Functions
18589 @subsection TI C6X Built-in Functions
18590
18591 GCC provides intrinsics to access certain instructions of the TI C6X
18592 processors. These intrinsics, listed below, are available after
18593 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
18594 to C6X instructions.
18595
18596 @smallexample
18597
18598 int _sadd (int, int)
18599 int _ssub (int, int)
18600 int _sadd2 (int, int)
18601 int _ssub2 (int, int)
18602 long long _mpy2 (int, int)
18603 long long _smpy2 (int, int)
18604 int _add4 (int, int)
18605 int _sub4 (int, int)
18606 int _saddu4 (int, int)
18607
18608 int _smpy (int, int)
18609 int _smpyh (int, int)
18610 int _smpyhl (int, int)
18611 int _smpylh (int, int)
18612
18613 int _sshl (int, int)
18614 int _subc (int, int)
18615
18616 int _avg2 (int, int)
18617 int _avgu4 (int, int)
18618
18619 int _clrr (int, int)
18620 int _extr (int, int)
18621 int _extru (int, int)
18622 int _abs (int)
18623 int _abs2 (int)
18624
18625 @end smallexample
18626
18627 @node TILE-Gx Built-in Functions
18628 @subsection TILE-Gx Built-in Functions
18629
18630 GCC provides intrinsics to access every instruction of the TILE-Gx
18631 processor. The intrinsics are of the form:
18632
18633 @smallexample
18634
18635 unsigned long long __insn_@var{op} (...)
18636
18637 @end smallexample
18638
18639 Where @var{op} is the name of the instruction. Refer to the ISA manual
18640 for the complete list of instructions.
18641
18642 GCC also provides intrinsics to directly access the network registers.
18643 The intrinsics are:
18644
18645 @smallexample
18646
18647 unsigned long long __tile_idn0_receive (void)
18648 unsigned long long __tile_idn1_receive (void)
18649 unsigned long long __tile_udn0_receive (void)
18650 unsigned long long __tile_udn1_receive (void)
18651 unsigned long long __tile_udn2_receive (void)
18652 unsigned long long __tile_udn3_receive (void)
18653 void __tile_idn_send (unsigned long long)
18654 void __tile_udn_send (unsigned long long)
18655
18656 @end smallexample
18657
18658 The intrinsic @code{void __tile_network_barrier (void)} is used to
18659 guarantee that no network operations before it are reordered with
18660 those after it.
18661
18662 @node TILEPro Built-in Functions
18663 @subsection TILEPro Built-in Functions
18664
18665 GCC provides intrinsics to access every instruction of the TILEPro
18666 processor. The intrinsics are of the form:
18667
18668 @smallexample
18669
18670 unsigned __insn_@var{op} (...)
18671
18672 @end smallexample
18673
18674 @noindent
18675 where @var{op} is the name of the instruction. Refer to the ISA manual
18676 for the complete list of instructions.
18677
18678 GCC also provides intrinsics to directly access the network registers.
18679 The intrinsics are:
18680
18681 @smallexample
18682
18683 unsigned __tile_idn0_receive (void)
18684 unsigned __tile_idn1_receive (void)
18685 unsigned __tile_sn_receive (void)
18686 unsigned __tile_udn0_receive (void)
18687 unsigned __tile_udn1_receive (void)
18688 unsigned __tile_udn2_receive (void)
18689 unsigned __tile_udn3_receive (void)
18690 void __tile_idn_send (unsigned)
18691 void __tile_sn_send (unsigned)
18692 void __tile_udn_send (unsigned)
18693
18694 @end smallexample
18695
18696 The intrinsic @code{void __tile_network_barrier (void)} is used to
18697 guarantee that no network operations before it are reordered with
18698 those after it.
18699
18700 @node x86 Built-in Functions
18701 @subsection x86 Built-in Functions
18702
18703 These built-in functions are available for the x86-32 and x86-64 family
18704 of computers, depending on the command-line switches used.
18705
18706 If you specify command-line switches such as @option{-msse},
18707 the compiler could use the extended instruction sets even if the built-ins
18708 are not used explicitly in the program. For this reason, applications
18709 that perform run-time CPU detection must compile separate files for each
18710 supported architecture, using the appropriate flags. In particular,
18711 the file containing the CPU detection code should be compiled without
18712 these options.
18713
18714 The following machine modes are available for use with MMX built-in functions
18715 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
18716 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
18717 vector of eight 8-bit integers. Some of the built-in functions operate on
18718 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
18719
18720 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
18721 of two 32-bit floating-point values.
18722
18723 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
18724 floating-point values. Some instructions use a vector of four 32-bit
18725 integers, these use @code{V4SI}. Finally, some instructions operate on an
18726 entire vector register, interpreting it as a 128-bit integer, these use mode
18727 @code{TI}.
18728
18729 The x86-32 and x86-64 family of processors use additional built-in
18730 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
18731 floating point and @code{TC} 128-bit complex floating-point values.
18732
18733 The following floating-point built-in functions are always available. All
18734 of them implement the function that is part of the name.
18735
18736 @smallexample
18737 __float128 __builtin_fabsq (__float128)
18738 __float128 __builtin_copysignq (__float128, __float128)
18739 @end smallexample
18740
18741 The following built-in functions are always available.
18742
18743 @table @code
18744 @item __float128 __builtin_infq (void)
18745 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
18746 @findex __builtin_infq
18747
18748 @item __float128 __builtin_huge_valq (void)
18749 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
18750 @findex __builtin_huge_valq
18751
18752 @item __float128 __builtin_nanq (void)
18753 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
18754 @findex __builtin_nanq
18755
18756 @item __float128 __builtin_nansq (void)
18757 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
18758 @findex __builtin_nansq
18759 @end table
18760
18761 The following built-in function is always available.
18762
18763 @table @code
18764 @item void __builtin_ia32_pause (void)
18765 Generates the @code{pause} machine instruction with a compiler memory
18766 barrier.
18767 @end table
18768
18769 The following built-in functions are always available and can be used to
18770 check the target platform type.
18771
18772 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
18773 This function runs the CPU detection code to check the type of CPU and the
18774 features supported. This built-in function needs to be invoked along with the built-in functions
18775 to check CPU type and features, @code{__builtin_cpu_is} and
18776 @code{__builtin_cpu_supports}, only when used in a function that is
18777 executed before any constructors are called. The CPU detection code is
18778 automatically executed in a very high priority constructor.
18779
18780 For example, this function has to be used in @code{ifunc} resolvers that
18781 check for CPU type using the built-in functions @code{__builtin_cpu_is}
18782 and @code{__builtin_cpu_supports}, or in constructors on targets that
18783 don't support constructor priority.
18784 @smallexample
18785
18786 static void (*resolve_memcpy (void)) (void)
18787 @{
18788 // ifunc resolvers fire before constructors, explicitly call the init
18789 // function.
18790 __builtin_cpu_init ();
18791 if (__builtin_cpu_supports ("ssse3"))
18792 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
18793 else
18794 return default_memcpy;
18795 @}
18796
18797 void *memcpy (void *, const void *, size_t)
18798 __attribute__ ((ifunc ("resolve_memcpy")));
18799 @end smallexample
18800
18801 @end deftypefn
18802
18803 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
18804 This function returns a positive integer if the run-time CPU
18805 is of type @var{cpuname}
18806 and returns @code{0} otherwise. The following CPU names can be detected:
18807
18808 @table @samp
18809 @item intel
18810 Intel CPU.
18811
18812 @item atom
18813 Intel Atom CPU.
18814
18815 @item core2
18816 Intel Core 2 CPU.
18817
18818 @item corei7
18819 Intel Core i7 CPU.
18820
18821 @item nehalem
18822 Intel Core i7 Nehalem CPU.
18823
18824 @item westmere
18825 Intel Core i7 Westmere CPU.
18826
18827 @item sandybridge
18828 Intel Core i7 Sandy Bridge CPU.
18829
18830 @item amd
18831 AMD CPU.
18832
18833 @item amdfam10h
18834 AMD Family 10h CPU.
18835
18836 @item barcelona
18837 AMD Family 10h Barcelona CPU.
18838
18839 @item shanghai
18840 AMD Family 10h Shanghai CPU.
18841
18842 @item istanbul
18843 AMD Family 10h Istanbul CPU.
18844
18845 @item btver1
18846 AMD Family 14h CPU.
18847
18848 @item amdfam15h
18849 AMD Family 15h CPU.
18850
18851 @item bdver1
18852 AMD Family 15h Bulldozer version 1.
18853
18854 @item bdver2
18855 AMD Family 15h Bulldozer version 2.
18856
18857 @item bdver3
18858 AMD Family 15h Bulldozer version 3.
18859
18860 @item bdver4
18861 AMD Family 15h Bulldozer version 4.
18862
18863 @item btver2
18864 AMD Family 16h CPU.
18865
18866 @item znver1
18867 AMD Family 17h CPU.
18868 @end table
18869
18870 Here is an example:
18871 @smallexample
18872 if (__builtin_cpu_is ("corei7"))
18873 @{
18874 do_corei7 (); // Core i7 specific implementation.
18875 @}
18876 else
18877 @{
18878 do_generic (); // Generic implementation.
18879 @}
18880 @end smallexample
18881 @end deftypefn
18882
18883 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
18884 This function returns a positive integer if the run-time CPU
18885 supports @var{feature}
18886 and returns @code{0} otherwise. The following features can be detected:
18887
18888 @table @samp
18889 @item cmov
18890 CMOV instruction.
18891 @item mmx
18892 MMX instructions.
18893 @item popcnt
18894 POPCNT instruction.
18895 @item sse
18896 SSE instructions.
18897 @item sse2
18898 SSE2 instructions.
18899 @item sse3
18900 SSE3 instructions.
18901 @item ssse3
18902 SSSE3 instructions.
18903 @item sse4.1
18904 SSE4.1 instructions.
18905 @item sse4.2
18906 SSE4.2 instructions.
18907 @item avx
18908 AVX instructions.
18909 @item avx2
18910 AVX2 instructions.
18911 @item avx512f
18912 AVX512F instructions.
18913 @end table
18914
18915 Here is an example:
18916 @smallexample
18917 if (__builtin_cpu_supports ("popcnt"))
18918 @{
18919 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
18920 @}
18921 else
18922 @{
18923 count = generic_countbits (n); //generic implementation.
18924 @}
18925 @end smallexample
18926 @end deftypefn
18927
18928
18929 The following built-in functions are made available by @option{-mmmx}.
18930 All of them generate the machine instruction that is part of the name.
18931
18932 @smallexample
18933 v8qi __builtin_ia32_paddb (v8qi, v8qi)
18934 v4hi __builtin_ia32_paddw (v4hi, v4hi)
18935 v2si __builtin_ia32_paddd (v2si, v2si)
18936 v8qi __builtin_ia32_psubb (v8qi, v8qi)
18937 v4hi __builtin_ia32_psubw (v4hi, v4hi)
18938 v2si __builtin_ia32_psubd (v2si, v2si)
18939 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
18940 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
18941 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
18942 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
18943 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
18944 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
18945 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
18946 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
18947 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
18948 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
18949 di __builtin_ia32_pand (di, di)
18950 di __builtin_ia32_pandn (di,di)
18951 di __builtin_ia32_por (di, di)
18952 di __builtin_ia32_pxor (di, di)
18953 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
18954 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
18955 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
18956 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
18957 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
18958 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
18959 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
18960 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
18961 v2si __builtin_ia32_punpckhdq (v2si, v2si)
18962 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
18963 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
18964 v2si __builtin_ia32_punpckldq (v2si, v2si)
18965 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
18966 v4hi __builtin_ia32_packssdw (v2si, v2si)
18967 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
18968
18969 v4hi __builtin_ia32_psllw (v4hi, v4hi)
18970 v2si __builtin_ia32_pslld (v2si, v2si)
18971 v1di __builtin_ia32_psllq (v1di, v1di)
18972 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
18973 v2si __builtin_ia32_psrld (v2si, v2si)
18974 v1di __builtin_ia32_psrlq (v1di, v1di)
18975 v4hi __builtin_ia32_psraw (v4hi, v4hi)
18976 v2si __builtin_ia32_psrad (v2si, v2si)
18977 v4hi __builtin_ia32_psllwi (v4hi, int)
18978 v2si __builtin_ia32_pslldi (v2si, int)
18979 v1di __builtin_ia32_psllqi (v1di, int)
18980 v4hi __builtin_ia32_psrlwi (v4hi, int)
18981 v2si __builtin_ia32_psrldi (v2si, int)
18982 v1di __builtin_ia32_psrlqi (v1di, int)
18983 v4hi __builtin_ia32_psrawi (v4hi, int)
18984 v2si __builtin_ia32_psradi (v2si, int)
18985
18986 @end smallexample
18987
18988 The following built-in functions are made available either with
18989 @option{-msse}, or with a combination of @option{-m3dnow} and
18990 @option{-march=athlon}. All of them generate the machine
18991 instruction that is part of the name.
18992
18993 @smallexample
18994 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
18995 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
18996 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
18997 v1di __builtin_ia32_psadbw (v8qi, v8qi)
18998 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
18999 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
19000 v8qi __builtin_ia32_pminub (v8qi, v8qi)
19001 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
19002 int __builtin_ia32_pmovmskb (v8qi)
19003 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
19004 void __builtin_ia32_movntq (di *, di)
19005 void __builtin_ia32_sfence (void)
19006 @end smallexample
19007
19008 The following built-in functions are available when @option{-msse} is used.
19009 All of them generate the machine instruction that is part of the name.
19010
19011 @smallexample
19012 int __builtin_ia32_comieq (v4sf, v4sf)
19013 int __builtin_ia32_comineq (v4sf, v4sf)
19014 int __builtin_ia32_comilt (v4sf, v4sf)
19015 int __builtin_ia32_comile (v4sf, v4sf)
19016 int __builtin_ia32_comigt (v4sf, v4sf)
19017 int __builtin_ia32_comige (v4sf, v4sf)
19018 int __builtin_ia32_ucomieq (v4sf, v4sf)
19019 int __builtin_ia32_ucomineq (v4sf, v4sf)
19020 int __builtin_ia32_ucomilt (v4sf, v4sf)
19021 int __builtin_ia32_ucomile (v4sf, v4sf)
19022 int __builtin_ia32_ucomigt (v4sf, v4sf)
19023 int __builtin_ia32_ucomige (v4sf, v4sf)
19024 v4sf __builtin_ia32_addps (v4sf, v4sf)
19025 v4sf __builtin_ia32_subps (v4sf, v4sf)
19026 v4sf __builtin_ia32_mulps (v4sf, v4sf)
19027 v4sf __builtin_ia32_divps (v4sf, v4sf)
19028 v4sf __builtin_ia32_addss (v4sf, v4sf)
19029 v4sf __builtin_ia32_subss (v4sf, v4sf)
19030 v4sf __builtin_ia32_mulss (v4sf, v4sf)
19031 v4sf __builtin_ia32_divss (v4sf, v4sf)
19032 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
19033 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
19034 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
19035 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
19036 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
19037 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
19038 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
19039 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
19040 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
19041 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
19042 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
19043 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
19044 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
19045 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
19046 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
19047 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
19048 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
19049 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
19050 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
19051 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
19052 v4sf __builtin_ia32_maxps (v4sf, v4sf)
19053 v4sf __builtin_ia32_maxss (v4sf, v4sf)
19054 v4sf __builtin_ia32_minps (v4sf, v4sf)
19055 v4sf __builtin_ia32_minss (v4sf, v4sf)
19056 v4sf __builtin_ia32_andps (v4sf, v4sf)
19057 v4sf __builtin_ia32_andnps (v4sf, v4sf)
19058 v4sf __builtin_ia32_orps (v4sf, v4sf)
19059 v4sf __builtin_ia32_xorps (v4sf, v4sf)
19060 v4sf __builtin_ia32_movss (v4sf, v4sf)
19061 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
19062 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
19063 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
19064 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
19065 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
19066 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
19067 v2si __builtin_ia32_cvtps2pi (v4sf)
19068 int __builtin_ia32_cvtss2si (v4sf)
19069 v2si __builtin_ia32_cvttps2pi (v4sf)
19070 int __builtin_ia32_cvttss2si (v4sf)
19071 v4sf __builtin_ia32_rcpps (v4sf)
19072 v4sf __builtin_ia32_rsqrtps (v4sf)
19073 v4sf __builtin_ia32_sqrtps (v4sf)
19074 v4sf __builtin_ia32_rcpss (v4sf)
19075 v4sf __builtin_ia32_rsqrtss (v4sf)
19076 v4sf __builtin_ia32_sqrtss (v4sf)
19077 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
19078 void __builtin_ia32_movntps (float *, v4sf)
19079 int __builtin_ia32_movmskps (v4sf)
19080 @end smallexample
19081
19082 The following built-in functions are available when @option{-msse} is used.
19083
19084 @table @code
19085 @item v4sf __builtin_ia32_loadups (float *)
19086 Generates the @code{movups} machine instruction as a load from memory.
19087 @item void __builtin_ia32_storeups (float *, v4sf)
19088 Generates the @code{movups} machine instruction as a store to memory.
19089 @item v4sf __builtin_ia32_loadss (float *)
19090 Generates the @code{movss} machine instruction as a load from memory.
19091 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
19092 Generates the @code{movhps} machine instruction as a load from memory.
19093 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
19094 Generates the @code{movlps} machine instruction as a load from memory
19095 @item void __builtin_ia32_storehps (v2sf *, v4sf)
19096 Generates the @code{movhps} machine instruction as a store to memory.
19097 @item void __builtin_ia32_storelps (v2sf *, v4sf)
19098 Generates the @code{movlps} machine instruction as a store to memory.
19099 @end table
19100
19101 The following built-in functions are available when @option{-msse2} is used.
19102 All of them generate the machine instruction that is part of the name.
19103
19104 @smallexample
19105 int __builtin_ia32_comisdeq (v2df, v2df)
19106 int __builtin_ia32_comisdlt (v2df, v2df)
19107 int __builtin_ia32_comisdle (v2df, v2df)
19108 int __builtin_ia32_comisdgt (v2df, v2df)
19109 int __builtin_ia32_comisdge (v2df, v2df)
19110 int __builtin_ia32_comisdneq (v2df, v2df)
19111 int __builtin_ia32_ucomisdeq (v2df, v2df)
19112 int __builtin_ia32_ucomisdlt (v2df, v2df)
19113 int __builtin_ia32_ucomisdle (v2df, v2df)
19114 int __builtin_ia32_ucomisdgt (v2df, v2df)
19115 int __builtin_ia32_ucomisdge (v2df, v2df)
19116 int __builtin_ia32_ucomisdneq (v2df, v2df)
19117 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
19118 v2df __builtin_ia32_cmpltpd (v2df, v2df)
19119 v2df __builtin_ia32_cmplepd (v2df, v2df)
19120 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
19121 v2df __builtin_ia32_cmpgepd (v2df, v2df)
19122 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
19123 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
19124 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
19125 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
19126 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
19127 v2df __builtin_ia32_cmpngepd (v2df, v2df)
19128 v2df __builtin_ia32_cmpordpd (v2df, v2df)
19129 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
19130 v2df __builtin_ia32_cmpltsd (v2df, v2df)
19131 v2df __builtin_ia32_cmplesd (v2df, v2df)
19132 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
19133 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
19134 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
19135 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
19136 v2df __builtin_ia32_cmpordsd (v2df, v2df)
19137 v2di __builtin_ia32_paddq (v2di, v2di)
19138 v2di __builtin_ia32_psubq (v2di, v2di)
19139 v2df __builtin_ia32_addpd (v2df, v2df)
19140 v2df __builtin_ia32_subpd (v2df, v2df)
19141 v2df __builtin_ia32_mulpd (v2df, v2df)
19142 v2df __builtin_ia32_divpd (v2df, v2df)
19143 v2df __builtin_ia32_addsd (v2df, v2df)
19144 v2df __builtin_ia32_subsd (v2df, v2df)
19145 v2df __builtin_ia32_mulsd (v2df, v2df)
19146 v2df __builtin_ia32_divsd (v2df, v2df)
19147 v2df __builtin_ia32_minpd (v2df, v2df)
19148 v2df __builtin_ia32_maxpd (v2df, v2df)
19149 v2df __builtin_ia32_minsd (v2df, v2df)
19150 v2df __builtin_ia32_maxsd (v2df, v2df)
19151 v2df __builtin_ia32_andpd (v2df, v2df)
19152 v2df __builtin_ia32_andnpd (v2df, v2df)
19153 v2df __builtin_ia32_orpd (v2df, v2df)
19154 v2df __builtin_ia32_xorpd (v2df, v2df)
19155 v2df __builtin_ia32_movsd (v2df, v2df)
19156 v2df __builtin_ia32_unpckhpd (v2df, v2df)
19157 v2df __builtin_ia32_unpcklpd (v2df, v2df)
19158 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
19159 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
19160 v4si __builtin_ia32_paddd128 (v4si, v4si)
19161 v2di __builtin_ia32_paddq128 (v2di, v2di)
19162 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
19163 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
19164 v4si __builtin_ia32_psubd128 (v4si, v4si)
19165 v2di __builtin_ia32_psubq128 (v2di, v2di)
19166 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
19167 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
19168 v2di __builtin_ia32_pand128 (v2di, v2di)
19169 v2di __builtin_ia32_pandn128 (v2di, v2di)
19170 v2di __builtin_ia32_por128 (v2di, v2di)
19171 v2di __builtin_ia32_pxor128 (v2di, v2di)
19172 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
19173 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
19174 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
19175 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
19176 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
19177 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
19178 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
19179 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
19180 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
19181 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
19182 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
19183 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
19184 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
19185 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
19186 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
19187 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
19188 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
19189 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
19190 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
19191 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
19192 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
19193 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
19194 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
19195 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
19196 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
19197 v2df __builtin_ia32_loadupd (double *)
19198 void __builtin_ia32_storeupd (double *, v2df)
19199 v2df __builtin_ia32_loadhpd (v2df, double const *)
19200 v2df __builtin_ia32_loadlpd (v2df, double const *)
19201 int __builtin_ia32_movmskpd (v2df)
19202 int __builtin_ia32_pmovmskb128 (v16qi)
19203 void __builtin_ia32_movnti (int *, int)
19204 void __builtin_ia32_movnti64 (long long int *, long long int)
19205 void __builtin_ia32_movntpd (double *, v2df)
19206 void __builtin_ia32_movntdq (v2df *, v2df)
19207 v4si __builtin_ia32_pshufd (v4si, int)
19208 v8hi __builtin_ia32_pshuflw (v8hi, int)
19209 v8hi __builtin_ia32_pshufhw (v8hi, int)
19210 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
19211 v2df __builtin_ia32_sqrtpd (v2df)
19212 v2df __builtin_ia32_sqrtsd (v2df)
19213 v2df __builtin_ia32_shufpd (v2df, v2df, int)
19214 v2df __builtin_ia32_cvtdq2pd (v4si)
19215 v4sf __builtin_ia32_cvtdq2ps (v4si)
19216 v4si __builtin_ia32_cvtpd2dq (v2df)
19217 v2si __builtin_ia32_cvtpd2pi (v2df)
19218 v4sf __builtin_ia32_cvtpd2ps (v2df)
19219 v4si __builtin_ia32_cvttpd2dq (v2df)
19220 v2si __builtin_ia32_cvttpd2pi (v2df)
19221 v2df __builtin_ia32_cvtpi2pd (v2si)
19222 int __builtin_ia32_cvtsd2si (v2df)
19223 int __builtin_ia32_cvttsd2si (v2df)
19224 long long __builtin_ia32_cvtsd2si64 (v2df)
19225 long long __builtin_ia32_cvttsd2si64 (v2df)
19226 v4si __builtin_ia32_cvtps2dq (v4sf)
19227 v2df __builtin_ia32_cvtps2pd (v4sf)
19228 v4si __builtin_ia32_cvttps2dq (v4sf)
19229 v2df __builtin_ia32_cvtsi2sd (v2df, int)
19230 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
19231 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
19232 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
19233 void __builtin_ia32_clflush (const void *)
19234 void __builtin_ia32_lfence (void)
19235 void __builtin_ia32_mfence (void)
19236 v16qi __builtin_ia32_loaddqu (const char *)
19237 void __builtin_ia32_storedqu (char *, v16qi)
19238 v1di __builtin_ia32_pmuludq (v2si, v2si)
19239 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
19240 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
19241 v4si __builtin_ia32_pslld128 (v4si, v4si)
19242 v2di __builtin_ia32_psllq128 (v2di, v2di)
19243 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
19244 v4si __builtin_ia32_psrld128 (v4si, v4si)
19245 v2di __builtin_ia32_psrlq128 (v2di, v2di)
19246 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
19247 v4si __builtin_ia32_psrad128 (v4si, v4si)
19248 v2di __builtin_ia32_pslldqi128 (v2di, int)
19249 v8hi __builtin_ia32_psllwi128 (v8hi, int)
19250 v4si __builtin_ia32_pslldi128 (v4si, int)
19251 v2di __builtin_ia32_psllqi128 (v2di, int)
19252 v2di __builtin_ia32_psrldqi128 (v2di, int)
19253 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
19254 v4si __builtin_ia32_psrldi128 (v4si, int)
19255 v2di __builtin_ia32_psrlqi128 (v2di, int)
19256 v8hi __builtin_ia32_psrawi128 (v8hi, int)
19257 v4si __builtin_ia32_psradi128 (v4si, int)
19258 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
19259 v2di __builtin_ia32_movq128 (v2di)
19260 @end smallexample
19261
19262 The following built-in functions are available when @option{-msse3} is used.
19263 All of them generate the machine instruction that is part of the name.
19264
19265 @smallexample
19266 v2df __builtin_ia32_addsubpd (v2df, v2df)
19267 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
19268 v2df __builtin_ia32_haddpd (v2df, v2df)
19269 v4sf __builtin_ia32_haddps (v4sf, v4sf)
19270 v2df __builtin_ia32_hsubpd (v2df, v2df)
19271 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
19272 v16qi __builtin_ia32_lddqu (char const *)
19273 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
19274 v4sf __builtin_ia32_movshdup (v4sf)
19275 v4sf __builtin_ia32_movsldup (v4sf)
19276 void __builtin_ia32_mwait (unsigned int, unsigned int)
19277 @end smallexample
19278
19279 The following built-in functions are available when @option{-mssse3} is used.
19280 All of them generate the machine instruction that is part of the name.
19281
19282 @smallexample
19283 v2si __builtin_ia32_phaddd (v2si, v2si)
19284 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
19285 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
19286 v2si __builtin_ia32_phsubd (v2si, v2si)
19287 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
19288 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
19289 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
19290 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
19291 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
19292 v8qi __builtin_ia32_psignb (v8qi, v8qi)
19293 v2si __builtin_ia32_psignd (v2si, v2si)
19294 v4hi __builtin_ia32_psignw (v4hi, v4hi)
19295 v1di __builtin_ia32_palignr (v1di, v1di, int)
19296 v8qi __builtin_ia32_pabsb (v8qi)
19297 v2si __builtin_ia32_pabsd (v2si)
19298 v4hi __builtin_ia32_pabsw (v4hi)
19299 @end smallexample
19300
19301 The following built-in functions are available when @option{-mssse3} is used.
19302 All of them generate the machine instruction that is part of the name.
19303
19304 @smallexample
19305 v4si __builtin_ia32_phaddd128 (v4si, v4si)
19306 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
19307 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
19308 v4si __builtin_ia32_phsubd128 (v4si, v4si)
19309 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
19310 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
19311 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
19312 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
19313 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
19314 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
19315 v4si __builtin_ia32_psignd128 (v4si, v4si)
19316 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
19317 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
19318 v16qi __builtin_ia32_pabsb128 (v16qi)
19319 v4si __builtin_ia32_pabsd128 (v4si)
19320 v8hi __builtin_ia32_pabsw128 (v8hi)
19321 @end smallexample
19322
19323 The following built-in functions are available when @option{-msse4.1} is
19324 used. All of them generate the machine instruction that is part of the
19325 name.
19326
19327 @smallexample
19328 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
19329 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
19330 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
19331 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
19332 v2df __builtin_ia32_dppd (v2df, v2df, const int)
19333 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
19334 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
19335 v2di __builtin_ia32_movntdqa (v2di *);
19336 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
19337 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
19338 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
19339 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
19340 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
19341 v8hi __builtin_ia32_phminposuw128 (v8hi)
19342 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
19343 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
19344 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
19345 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
19346 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
19347 v4si __builtin_ia32_pminsd128 (v4si, v4si)
19348 v4si __builtin_ia32_pminud128 (v4si, v4si)
19349 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
19350 v4si __builtin_ia32_pmovsxbd128 (v16qi)
19351 v2di __builtin_ia32_pmovsxbq128 (v16qi)
19352 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
19353 v2di __builtin_ia32_pmovsxdq128 (v4si)
19354 v4si __builtin_ia32_pmovsxwd128 (v8hi)
19355 v2di __builtin_ia32_pmovsxwq128 (v8hi)
19356 v4si __builtin_ia32_pmovzxbd128 (v16qi)
19357 v2di __builtin_ia32_pmovzxbq128 (v16qi)
19358 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
19359 v2di __builtin_ia32_pmovzxdq128 (v4si)
19360 v4si __builtin_ia32_pmovzxwd128 (v8hi)
19361 v2di __builtin_ia32_pmovzxwq128 (v8hi)
19362 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
19363 v4si __builtin_ia32_pmulld128 (v4si, v4si)
19364 int __builtin_ia32_ptestc128 (v2di, v2di)
19365 int __builtin_ia32_ptestnzc128 (v2di, v2di)
19366 int __builtin_ia32_ptestz128 (v2di, v2di)
19367 v2df __builtin_ia32_roundpd (v2df, const int)
19368 v4sf __builtin_ia32_roundps (v4sf, const int)
19369 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
19370 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
19371 @end smallexample
19372
19373 The following built-in functions are available when @option{-msse4.1} is
19374 used.
19375
19376 @table @code
19377 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
19378 Generates the @code{insertps} machine instruction.
19379 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
19380 Generates the @code{pextrb} machine instruction.
19381 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
19382 Generates the @code{pinsrb} machine instruction.
19383 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
19384 Generates the @code{pinsrd} machine instruction.
19385 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
19386 Generates the @code{pinsrq} machine instruction in 64bit mode.
19387 @end table
19388
19389 The following built-in functions are changed to generate new SSE4.1
19390 instructions when @option{-msse4.1} is used.
19391
19392 @table @code
19393 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
19394 Generates the @code{extractps} machine instruction.
19395 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
19396 Generates the @code{pextrd} machine instruction.
19397 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
19398 Generates the @code{pextrq} machine instruction in 64bit mode.
19399 @end table
19400
19401 The following built-in functions are available when @option{-msse4.2} is
19402 used. All of them generate the machine instruction that is part of the
19403 name.
19404
19405 @smallexample
19406 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
19407 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
19408 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
19409 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
19410 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
19411 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
19412 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
19413 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
19414 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
19415 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
19416 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
19417 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
19418 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
19419 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
19420 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
19421 @end smallexample
19422
19423 The following built-in functions are available when @option{-msse4.2} is
19424 used.
19425
19426 @table @code
19427 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
19428 Generates the @code{crc32b} machine instruction.
19429 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
19430 Generates the @code{crc32w} machine instruction.
19431 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
19432 Generates the @code{crc32l} machine instruction.
19433 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
19434 Generates the @code{crc32q} machine instruction.
19435 @end table
19436
19437 The following built-in functions are changed to generate new SSE4.2
19438 instructions when @option{-msse4.2} is used.
19439
19440 @table @code
19441 @item int __builtin_popcount (unsigned int)
19442 Generates the @code{popcntl} machine instruction.
19443 @item int __builtin_popcountl (unsigned long)
19444 Generates the @code{popcntl} or @code{popcntq} machine instruction,
19445 depending on the size of @code{unsigned long}.
19446 @item int __builtin_popcountll (unsigned long long)
19447 Generates the @code{popcntq} machine instruction.
19448 @end table
19449
19450 The following built-in functions are available when @option{-mavx} is
19451 used. All of them generate the machine instruction that is part of the
19452 name.
19453
19454 @smallexample
19455 v4df __builtin_ia32_addpd256 (v4df,v4df)
19456 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
19457 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
19458 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
19459 v4df __builtin_ia32_andnpd256 (v4df,v4df)
19460 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
19461 v4df __builtin_ia32_andpd256 (v4df,v4df)
19462 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
19463 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
19464 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
19465 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
19466 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
19467 v2df __builtin_ia32_cmppd (v2df,v2df,int)
19468 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
19469 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
19470 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
19471 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
19472 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
19473 v4df __builtin_ia32_cvtdq2pd256 (v4si)
19474 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
19475 v4si __builtin_ia32_cvtpd2dq256 (v4df)
19476 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
19477 v8si __builtin_ia32_cvtps2dq256 (v8sf)
19478 v4df __builtin_ia32_cvtps2pd256 (v4sf)
19479 v4si __builtin_ia32_cvttpd2dq256 (v4df)
19480 v8si __builtin_ia32_cvttps2dq256 (v8sf)
19481 v4df __builtin_ia32_divpd256 (v4df,v4df)
19482 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
19483 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
19484 v4df __builtin_ia32_haddpd256 (v4df,v4df)
19485 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
19486 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
19487 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
19488 v32qi __builtin_ia32_lddqu256 (pcchar)
19489 v32qi __builtin_ia32_loaddqu256 (pcchar)
19490 v4df __builtin_ia32_loadupd256 (pcdouble)
19491 v8sf __builtin_ia32_loadups256 (pcfloat)
19492 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
19493 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
19494 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
19495 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
19496 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
19497 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
19498 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
19499 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
19500 v4df __builtin_ia32_maxpd256 (v4df,v4df)
19501 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
19502 v4df __builtin_ia32_minpd256 (v4df,v4df)
19503 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
19504 v4df __builtin_ia32_movddup256 (v4df)
19505 int __builtin_ia32_movmskpd256 (v4df)
19506 int __builtin_ia32_movmskps256 (v8sf)
19507 v8sf __builtin_ia32_movshdup256 (v8sf)
19508 v8sf __builtin_ia32_movsldup256 (v8sf)
19509 v4df __builtin_ia32_mulpd256 (v4df,v4df)
19510 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
19511 v4df __builtin_ia32_orpd256 (v4df,v4df)
19512 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
19513 v2df __builtin_ia32_pd_pd256 (v4df)
19514 v4df __builtin_ia32_pd256_pd (v2df)
19515 v4sf __builtin_ia32_ps_ps256 (v8sf)
19516 v8sf __builtin_ia32_ps256_ps (v4sf)
19517 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
19518 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
19519 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
19520 v8sf __builtin_ia32_rcpps256 (v8sf)
19521 v4df __builtin_ia32_roundpd256 (v4df,int)
19522 v8sf __builtin_ia32_roundps256 (v8sf,int)
19523 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
19524 v8sf __builtin_ia32_rsqrtps256 (v8sf)
19525 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
19526 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
19527 v4si __builtin_ia32_si_si256 (v8si)
19528 v8si __builtin_ia32_si256_si (v4si)
19529 v4df __builtin_ia32_sqrtpd256 (v4df)
19530 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
19531 v8sf __builtin_ia32_sqrtps256 (v8sf)
19532 void __builtin_ia32_storedqu256 (pchar,v32qi)
19533 void __builtin_ia32_storeupd256 (pdouble,v4df)
19534 void __builtin_ia32_storeups256 (pfloat,v8sf)
19535 v4df __builtin_ia32_subpd256 (v4df,v4df)
19536 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
19537 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
19538 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
19539 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
19540 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
19541 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
19542 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
19543 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
19544 v4sf __builtin_ia32_vbroadcastss (pcfloat)
19545 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
19546 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
19547 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
19548 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
19549 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
19550 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
19551 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
19552 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
19553 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
19554 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
19555 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
19556 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
19557 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
19558 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
19559 v2df __builtin_ia32_vpermilpd (v2df,int)
19560 v4df __builtin_ia32_vpermilpd256 (v4df,int)
19561 v4sf __builtin_ia32_vpermilps (v4sf,int)
19562 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
19563 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
19564 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
19565 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
19566 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
19567 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
19568 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
19569 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
19570 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
19571 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
19572 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
19573 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
19574 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
19575 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
19576 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
19577 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
19578 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
19579 void __builtin_ia32_vzeroall (void)
19580 void __builtin_ia32_vzeroupper (void)
19581 v4df __builtin_ia32_xorpd256 (v4df,v4df)
19582 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
19583 @end smallexample
19584
19585 The following built-in functions are available when @option{-mavx2} is
19586 used. All of them generate the machine instruction that is part of the
19587 name.
19588
19589 @smallexample
19590 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
19591 v32qi __builtin_ia32_pabsb256 (v32qi)
19592 v16hi __builtin_ia32_pabsw256 (v16hi)
19593 v8si __builtin_ia32_pabsd256 (v8si)
19594 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
19595 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
19596 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
19597 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
19598 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
19599 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
19600 v8si __builtin_ia32_paddd256 (v8si,v8si)
19601 v4di __builtin_ia32_paddq256 (v4di,v4di)
19602 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
19603 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
19604 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
19605 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
19606 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
19607 v4di __builtin_ia32_andsi256 (v4di,v4di)
19608 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
19609 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
19610 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
19611 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
19612 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
19613 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
19614 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
19615 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
19616 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
19617 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
19618 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
19619 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
19620 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
19621 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
19622 v8si __builtin_ia32_phaddd256 (v8si,v8si)
19623 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
19624 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
19625 v8si __builtin_ia32_phsubd256 (v8si,v8si)
19626 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
19627 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
19628 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
19629 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
19630 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
19631 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
19632 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
19633 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
19634 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
19635 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
19636 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
19637 v8si __builtin_ia32_pminsd256 (v8si,v8si)
19638 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
19639 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
19640 v8si __builtin_ia32_pminud256 (v8si,v8si)
19641 int __builtin_ia32_pmovmskb256 (v32qi)
19642 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
19643 v8si __builtin_ia32_pmovsxbd256 (v16qi)
19644 v4di __builtin_ia32_pmovsxbq256 (v16qi)
19645 v8si __builtin_ia32_pmovsxwd256 (v8hi)
19646 v4di __builtin_ia32_pmovsxwq256 (v8hi)
19647 v4di __builtin_ia32_pmovsxdq256 (v4si)
19648 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
19649 v8si __builtin_ia32_pmovzxbd256 (v16qi)
19650 v4di __builtin_ia32_pmovzxbq256 (v16qi)
19651 v8si __builtin_ia32_pmovzxwd256 (v8hi)
19652 v4di __builtin_ia32_pmovzxwq256 (v8hi)
19653 v4di __builtin_ia32_pmovzxdq256 (v4si)
19654 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
19655 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
19656 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
19657 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
19658 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
19659 v8si __builtin_ia32_pmulld256 (v8si,v8si)
19660 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
19661 v4di __builtin_ia32_por256 (v4di,v4di)
19662 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
19663 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
19664 v8si __builtin_ia32_pshufd256 (v8si,int)
19665 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
19666 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
19667 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
19668 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
19669 v8si __builtin_ia32_psignd256 (v8si,v8si)
19670 v4di __builtin_ia32_pslldqi256 (v4di,int)
19671 v16hi __builtin_ia32_psllwi256 (16hi,int)
19672 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
19673 v8si __builtin_ia32_pslldi256 (v8si,int)
19674 v8si __builtin_ia32_pslld256(v8si,v4si)
19675 v4di __builtin_ia32_psllqi256 (v4di,int)
19676 v4di __builtin_ia32_psllq256(v4di,v2di)
19677 v16hi __builtin_ia32_psrawi256 (v16hi,int)
19678 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
19679 v8si __builtin_ia32_psradi256 (v8si,int)
19680 v8si __builtin_ia32_psrad256 (v8si,v4si)
19681 v4di __builtin_ia32_psrldqi256 (v4di, int)
19682 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
19683 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
19684 v8si __builtin_ia32_psrldi256 (v8si,int)
19685 v8si __builtin_ia32_psrld256 (v8si,v4si)
19686 v4di __builtin_ia32_psrlqi256 (v4di,int)
19687 v4di __builtin_ia32_psrlq256(v4di,v2di)
19688 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
19689 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
19690 v8si __builtin_ia32_psubd256 (v8si,v8si)
19691 v4di __builtin_ia32_psubq256 (v4di,v4di)
19692 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
19693 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
19694 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
19695 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
19696 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
19697 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
19698 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
19699 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
19700 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
19701 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
19702 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
19703 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
19704 v4di __builtin_ia32_pxor256 (v4di,v4di)
19705 v4di __builtin_ia32_movntdqa256 (pv4di)
19706 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
19707 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
19708 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
19709 v4di __builtin_ia32_vbroadcastsi256 (v2di)
19710 v4si __builtin_ia32_pblendd128 (v4si,v4si)
19711 v8si __builtin_ia32_pblendd256 (v8si,v8si)
19712 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
19713 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
19714 v8si __builtin_ia32_pbroadcastd256 (v4si)
19715 v4di __builtin_ia32_pbroadcastq256 (v2di)
19716 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
19717 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
19718 v4si __builtin_ia32_pbroadcastd128 (v4si)
19719 v2di __builtin_ia32_pbroadcastq128 (v2di)
19720 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
19721 v4df __builtin_ia32_permdf256 (v4df,int)
19722 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
19723 v4di __builtin_ia32_permdi256 (v4di,int)
19724 v4di __builtin_ia32_permti256 (v4di,v4di,int)
19725 v4di __builtin_ia32_extract128i256 (v4di,int)
19726 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
19727 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
19728 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
19729 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
19730 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
19731 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
19732 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
19733 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
19734 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
19735 v8si __builtin_ia32_psllv8si (v8si,v8si)
19736 v4si __builtin_ia32_psllv4si (v4si,v4si)
19737 v4di __builtin_ia32_psllv4di (v4di,v4di)
19738 v2di __builtin_ia32_psllv2di (v2di,v2di)
19739 v8si __builtin_ia32_psrav8si (v8si,v8si)
19740 v4si __builtin_ia32_psrav4si (v4si,v4si)
19741 v8si __builtin_ia32_psrlv8si (v8si,v8si)
19742 v4si __builtin_ia32_psrlv4si (v4si,v4si)
19743 v4di __builtin_ia32_psrlv4di (v4di,v4di)
19744 v2di __builtin_ia32_psrlv2di (v2di,v2di)
19745 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
19746 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
19747 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
19748 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
19749 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
19750 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
19751 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
19752 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
19753 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
19754 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
19755 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
19756 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
19757 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
19758 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
19759 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
19760 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
19761 @end smallexample
19762
19763 The following built-in functions are available when @option{-maes} is
19764 used. All of them generate the machine instruction that is part of the
19765 name.
19766
19767 @smallexample
19768 v2di __builtin_ia32_aesenc128 (v2di, v2di)
19769 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
19770 v2di __builtin_ia32_aesdec128 (v2di, v2di)
19771 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
19772 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
19773 v2di __builtin_ia32_aesimc128 (v2di)
19774 @end smallexample
19775
19776 The following built-in function is available when @option{-mpclmul} is
19777 used.
19778
19779 @table @code
19780 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
19781 Generates the @code{pclmulqdq} machine instruction.
19782 @end table
19783
19784 The following built-in function is available when @option{-mfsgsbase} is
19785 used. All of them generate the machine instruction that is part of the
19786 name.
19787
19788 @smallexample
19789 unsigned int __builtin_ia32_rdfsbase32 (void)
19790 unsigned long long __builtin_ia32_rdfsbase64 (void)
19791 unsigned int __builtin_ia32_rdgsbase32 (void)
19792 unsigned long long __builtin_ia32_rdgsbase64 (void)
19793 void _writefsbase_u32 (unsigned int)
19794 void _writefsbase_u64 (unsigned long long)
19795 void _writegsbase_u32 (unsigned int)
19796 void _writegsbase_u64 (unsigned long long)
19797 @end smallexample
19798
19799 The following built-in function is available when @option{-mrdrnd} is
19800 used. All of them generate the machine instruction that is part of the
19801 name.
19802
19803 @smallexample
19804 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
19805 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
19806 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
19807 @end smallexample
19808
19809 The following built-in functions are available when @option{-msse4a} is used.
19810 All of them generate the machine instruction that is part of the name.
19811
19812 @smallexample
19813 void __builtin_ia32_movntsd (double *, v2df)
19814 void __builtin_ia32_movntss (float *, v4sf)
19815 v2di __builtin_ia32_extrq (v2di, v16qi)
19816 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
19817 v2di __builtin_ia32_insertq (v2di, v2di)
19818 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
19819 @end smallexample
19820
19821 The following built-in functions are available when @option{-mxop} is used.
19822 @smallexample
19823 v2df __builtin_ia32_vfrczpd (v2df)
19824 v4sf __builtin_ia32_vfrczps (v4sf)
19825 v2df __builtin_ia32_vfrczsd (v2df)
19826 v4sf __builtin_ia32_vfrczss (v4sf)
19827 v4df __builtin_ia32_vfrczpd256 (v4df)
19828 v8sf __builtin_ia32_vfrczps256 (v8sf)
19829 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
19830 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
19831 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
19832 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
19833 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
19834 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
19835 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
19836 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
19837 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
19838 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
19839 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
19840 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
19841 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
19842 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
19843 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
19844 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
19845 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
19846 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
19847 v4si __builtin_ia32_vpcomequd (v4si, v4si)
19848 v2di __builtin_ia32_vpcomequq (v2di, v2di)
19849 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
19850 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
19851 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
19852 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
19853 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
19854 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
19855 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
19856 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
19857 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
19858 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
19859 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
19860 v4si __builtin_ia32_vpcomged (v4si, v4si)
19861 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
19862 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
19863 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
19864 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
19865 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
19866 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
19867 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
19868 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
19869 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
19870 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
19871 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
19872 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
19873 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
19874 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
19875 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
19876 v4si __builtin_ia32_vpcomled (v4si, v4si)
19877 v2di __builtin_ia32_vpcomleq (v2di, v2di)
19878 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
19879 v4si __builtin_ia32_vpcomleud (v4si, v4si)
19880 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
19881 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
19882 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
19883 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
19884 v4si __builtin_ia32_vpcomltd (v4si, v4si)
19885 v2di __builtin_ia32_vpcomltq (v2di, v2di)
19886 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
19887 v4si __builtin_ia32_vpcomltud (v4si, v4si)
19888 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
19889 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
19890 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
19891 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
19892 v4si __builtin_ia32_vpcomned (v4si, v4si)
19893 v2di __builtin_ia32_vpcomneq (v2di, v2di)
19894 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
19895 v4si __builtin_ia32_vpcomneud (v4si, v4si)
19896 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
19897 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
19898 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
19899 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
19900 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
19901 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
19902 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
19903 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
19904 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
19905 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
19906 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
19907 v4si __builtin_ia32_vphaddbd (v16qi)
19908 v2di __builtin_ia32_vphaddbq (v16qi)
19909 v8hi __builtin_ia32_vphaddbw (v16qi)
19910 v2di __builtin_ia32_vphadddq (v4si)
19911 v4si __builtin_ia32_vphaddubd (v16qi)
19912 v2di __builtin_ia32_vphaddubq (v16qi)
19913 v8hi __builtin_ia32_vphaddubw (v16qi)
19914 v2di __builtin_ia32_vphaddudq (v4si)
19915 v4si __builtin_ia32_vphadduwd (v8hi)
19916 v2di __builtin_ia32_vphadduwq (v8hi)
19917 v4si __builtin_ia32_vphaddwd (v8hi)
19918 v2di __builtin_ia32_vphaddwq (v8hi)
19919 v8hi __builtin_ia32_vphsubbw (v16qi)
19920 v2di __builtin_ia32_vphsubdq (v4si)
19921 v4si __builtin_ia32_vphsubwd (v8hi)
19922 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
19923 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
19924 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
19925 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
19926 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
19927 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
19928 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
19929 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
19930 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
19931 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
19932 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
19933 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
19934 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
19935 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
19936 v4si __builtin_ia32_vprotd (v4si, v4si)
19937 v2di __builtin_ia32_vprotq (v2di, v2di)
19938 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
19939 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
19940 v4si __builtin_ia32_vpshad (v4si, v4si)
19941 v2di __builtin_ia32_vpshaq (v2di, v2di)
19942 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
19943 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
19944 v4si __builtin_ia32_vpshld (v4si, v4si)
19945 v2di __builtin_ia32_vpshlq (v2di, v2di)
19946 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
19947 @end smallexample
19948
19949 The following built-in functions are available when @option{-mfma4} is used.
19950 All of them generate the machine instruction that is part of the name.
19951
19952 @smallexample
19953 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
19954 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
19955 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
19956 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
19957 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
19958 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
19959 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
19960 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
19961 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
19962 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
19963 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
19964 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
19965 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
19966 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
19967 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
19968 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
19969 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
19970 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
19971 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
19972 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
19973 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
19974 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
19975 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
19976 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
19977 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
19978 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
19979 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
19980 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
19981 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
19982 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
19983 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
19984 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
19985
19986 @end smallexample
19987
19988 The following built-in functions are available when @option{-mlwp} is used.
19989
19990 @smallexample
19991 void __builtin_ia32_llwpcb16 (void *);
19992 void __builtin_ia32_llwpcb32 (void *);
19993 void __builtin_ia32_llwpcb64 (void *);
19994 void * __builtin_ia32_llwpcb16 (void);
19995 void * __builtin_ia32_llwpcb32 (void);
19996 void * __builtin_ia32_llwpcb64 (void);
19997 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
19998 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
19999 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
20000 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
20001 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
20002 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
20003 @end smallexample
20004
20005 The following built-in functions are available when @option{-mbmi} is used.
20006 All of them generate the machine instruction that is part of the name.
20007 @smallexample
20008 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
20009 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
20010 @end smallexample
20011
20012 The following built-in functions are available when @option{-mbmi2} is used.
20013 All of them generate the machine instruction that is part of the name.
20014 @smallexample
20015 unsigned int _bzhi_u32 (unsigned int, unsigned int)
20016 unsigned int _pdep_u32 (unsigned int, unsigned int)
20017 unsigned int _pext_u32 (unsigned int, unsigned int)
20018 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
20019 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
20020 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
20021 @end smallexample
20022
20023 The following built-in functions are available when @option{-mlzcnt} is used.
20024 All of them generate the machine instruction that is part of the name.
20025 @smallexample
20026 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
20027 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
20028 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
20029 @end smallexample
20030
20031 The following built-in functions are available when @option{-mfxsr} is used.
20032 All of them generate the machine instruction that is part of the name.
20033 @smallexample
20034 void __builtin_ia32_fxsave (void *)
20035 void __builtin_ia32_fxrstor (void *)
20036 void __builtin_ia32_fxsave64 (void *)
20037 void __builtin_ia32_fxrstor64 (void *)
20038 @end smallexample
20039
20040 The following built-in functions are available when @option{-mxsave} is used.
20041 All of them generate the machine instruction that is part of the name.
20042 @smallexample
20043 void __builtin_ia32_xsave (void *, long long)
20044 void __builtin_ia32_xrstor (void *, long long)
20045 void __builtin_ia32_xsave64 (void *, long long)
20046 void __builtin_ia32_xrstor64 (void *, long long)
20047 @end smallexample
20048
20049 The following built-in functions are available when @option{-mxsaveopt} is used.
20050 All of them generate the machine instruction that is part of the name.
20051 @smallexample
20052 void __builtin_ia32_xsaveopt (void *, long long)
20053 void __builtin_ia32_xsaveopt64 (void *, long long)
20054 @end smallexample
20055
20056 The following built-in functions are available when @option{-mtbm} is used.
20057 Both of them generate the immediate form of the bextr machine instruction.
20058 @smallexample
20059 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
20060 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
20061 @end smallexample
20062
20063
20064 The following built-in functions are available when @option{-m3dnow} is used.
20065 All of them generate the machine instruction that is part of the name.
20066
20067 @smallexample
20068 void __builtin_ia32_femms (void)
20069 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
20070 v2si __builtin_ia32_pf2id (v2sf)
20071 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
20072 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
20073 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
20074 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
20075 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
20076 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
20077 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
20078 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
20079 v2sf __builtin_ia32_pfrcp (v2sf)
20080 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
20081 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
20082 v2sf __builtin_ia32_pfrsqrt (v2sf)
20083 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
20084 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
20085 v2sf __builtin_ia32_pi2fd (v2si)
20086 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
20087 @end smallexample
20088
20089 The following built-in functions are available when both @option{-m3dnow}
20090 and @option{-march=athlon} are used. All of them generate the machine
20091 instruction that is part of the name.
20092
20093 @smallexample
20094 v2si __builtin_ia32_pf2iw (v2sf)
20095 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
20096 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
20097 v2sf __builtin_ia32_pi2fw (v2si)
20098 v2sf __builtin_ia32_pswapdsf (v2sf)
20099 v2si __builtin_ia32_pswapdsi (v2si)
20100 @end smallexample
20101
20102 The following built-in functions are available when @option{-mrtm} is used
20103 They are used for restricted transactional memory. These are the internal
20104 low level functions. Normally the functions in
20105 @ref{x86 transactional memory intrinsics} should be used instead.
20106
20107 @smallexample
20108 int __builtin_ia32_xbegin ()
20109 void __builtin_ia32_xend ()
20110 void __builtin_ia32_xabort (status)
20111 int __builtin_ia32_xtest ()
20112 @end smallexample
20113
20114 The following built-in functions are available when @option{-mmwaitx} is used.
20115 All of them generate the machine instruction that is part of the name.
20116 @smallexample
20117 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
20118 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
20119 @end smallexample
20120
20121 The following built-in functions are available when @option{-mclzero} is used.
20122 All of them generate the machine instruction that is part of the name.
20123 @smallexample
20124 void __builtin_i32_clzero (void *)
20125 @end smallexample
20126
20127 The following built-in functions are available when @option{-mpku} is used.
20128 They generate reads and writes to PKRU.
20129 @smallexample
20130 void __builtin_ia32_wrpkru (unsigned int)
20131 unsigned int __builtin_ia32_rdpkru ()
20132 @end smallexample
20133
20134 @node x86 transactional memory intrinsics
20135 @subsection x86 Transactional Memory Intrinsics
20136
20137 These hardware transactional memory intrinsics for x86 allow you to use
20138 memory transactions with RTM (Restricted Transactional Memory).
20139 This support is enabled with the @option{-mrtm} option.
20140 For using HLE (Hardware Lock Elision) see
20141 @ref{x86 specific memory model extensions for transactional memory} instead.
20142
20143 A memory transaction commits all changes to memory in an atomic way,
20144 as visible to other threads. If the transaction fails it is rolled back
20145 and all side effects discarded.
20146
20147 Generally there is no guarantee that a memory transaction ever succeeds
20148 and suitable fallback code always needs to be supplied.
20149
20150 @deftypefn {RTM Function} {unsigned} _xbegin ()
20151 Start a RTM (Restricted Transactional Memory) transaction.
20152 Returns @code{_XBEGIN_STARTED} when the transaction
20153 started successfully (note this is not 0, so the constant has to be
20154 explicitly tested).
20155
20156 If the transaction aborts, all side-effects
20157 are undone and an abort code encoded as a bit mask is returned.
20158 The following macros are defined:
20159
20160 @table @code
20161 @item _XABORT_EXPLICIT
20162 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
20163 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
20164 @item _XABORT_RETRY
20165 Transaction retry is possible.
20166 @item _XABORT_CONFLICT
20167 Transaction abort due to a memory conflict with another thread.
20168 @item _XABORT_CAPACITY
20169 Transaction abort due to the transaction using too much memory.
20170 @item _XABORT_DEBUG
20171 Transaction abort due to a debug trap.
20172 @item _XABORT_NESTED
20173 Transaction abort in an inner nested transaction.
20174 @end table
20175
20176 There is no guarantee
20177 any transaction ever succeeds, so there always needs to be a valid
20178 fallback path.
20179 @end deftypefn
20180
20181 @deftypefn {RTM Function} {void} _xend ()
20182 Commit the current transaction. When no transaction is active this faults.
20183 All memory side-effects of the transaction become visible
20184 to other threads in an atomic manner.
20185 @end deftypefn
20186
20187 @deftypefn {RTM Function} {int} _xtest ()
20188 Return a nonzero value if a transaction is currently active, otherwise 0.
20189 @end deftypefn
20190
20191 @deftypefn {RTM Function} {void} _xabort (status)
20192 Abort the current transaction. When no transaction is active this is a no-op.
20193 The @var{status} is an 8-bit constant; its value is encoded in the return
20194 value from @code{_xbegin}.
20195 @end deftypefn
20196
20197 Here is an example showing handling for @code{_XABORT_RETRY}
20198 and a fallback path for other failures:
20199
20200 @smallexample
20201 #include <immintrin.h>
20202
20203 int n_tries, max_tries;
20204 unsigned status = _XABORT_EXPLICIT;
20205 ...
20206
20207 for (n_tries = 0; n_tries < max_tries; n_tries++)
20208 @{
20209 status = _xbegin ();
20210 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
20211 break;
20212 @}
20213 if (status == _XBEGIN_STARTED)
20214 @{
20215 ... transaction code...
20216 _xend ();
20217 @}
20218 else
20219 @{
20220 ... non-transactional fallback path...
20221 @}
20222 @end smallexample
20223
20224 @noindent
20225 Note that, in most cases, the transactional and non-transactional code
20226 must synchronize together to ensure consistency.
20227
20228 @node Target Format Checks
20229 @section Format Checks Specific to Particular Target Machines
20230
20231 For some target machines, GCC supports additional options to the
20232 format attribute
20233 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
20234
20235 @menu
20236 * Solaris Format Checks::
20237 * Darwin Format Checks::
20238 @end menu
20239
20240 @node Solaris Format Checks
20241 @subsection Solaris Format Checks
20242
20243 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
20244 check. @code{cmn_err} accepts a subset of the standard @code{printf}
20245 conversions, and the two-argument @code{%b} conversion for displaying
20246 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
20247
20248 @node Darwin Format Checks
20249 @subsection Darwin Format Checks
20250
20251 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
20252 attribute context. Declarations made with such attribution are parsed for correct syntax
20253 and format argument types. However, parsing of the format string itself is currently undefined
20254 and is not carried out by this version of the compiler.
20255
20256 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
20257 also be used as format arguments. Note that the relevant headers are only likely to be
20258 available on Darwin (OSX) installations. On such installations, the XCode and system
20259 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
20260 associated functions.
20261
20262 @node Pragmas
20263 @section Pragmas Accepted by GCC
20264 @cindex pragmas
20265 @cindex @code{#pragma}
20266
20267 GCC supports several types of pragmas, primarily in order to compile
20268 code originally written for other compilers. Note that in general
20269 we do not recommend the use of pragmas; @xref{Function Attributes},
20270 for further explanation.
20271
20272 @menu
20273 * AArch64 Pragmas::
20274 * ARM Pragmas::
20275 * M32C Pragmas::
20276 * MeP Pragmas::
20277 * RS/6000 and PowerPC Pragmas::
20278 * S/390 Pragmas::
20279 * Darwin Pragmas::
20280 * Solaris Pragmas::
20281 * Symbol-Renaming Pragmas::
20282 * Structure-Layout Pragmas::
20283 * Weak Pragmas::
20284 * Diagnostic Pragmas::
20285 * Visibility Pragmas::
20286 * Push/Pop Macro Pragmas::
20287 * Function Specific Option Pragmas::
20288 * Loop-Specific Pragmas::
20289 @end menu
20290
20291 @node AArch64 Pragmas
20292 @subsection AArch64 Pragmas
20293
20294 The pragmas defined by the AArch64 target correspond to the AArch64
20295 target function attributes. They can be specified as below:
20296 @smallexample
20297 #pragma GCC target("string")
20298 @end smallexample
20299
20300 where @code{@var{string}} can be any string accepted as an AArch64 target
20301 attribute. @xref{AArch64 Function Attributes}, for more details
20302 on the permissible values of @code{string}.
20303
20304 @node ARM Pragmas
20305 @subsection ARM Pragmas
20306
20307 The ARM target defines pragmas for controlling the default addition of
20308 @code{long_call} and @code{short_call} attributes to functions.
20309 @xref{Function Attributes}, for information about the effects of these
20310 attributes.
20311
20312 @table @code
20313 @item long_calls
20314 @cindex pragma, long_calls
20315 Set all subsequent functions to have the @code{long_call} attribute.
20316
20317 @item no_long_calls
20318 @cindex pragma, no_long_calls
20319 Set all subsequent functions to have the @code{short_call} attribute.
20320
20321 @item long_calls_off
20322 @cindex pragma, long_calls_off
20323 Do not affect the @code{long_call} or @code{short_call} attributes of
20324 subsequent functions.
20325 @end table
20326
20327 @node M32C Pragmas
20328 @subsection M32C Pragmas
20329
20330 @table @code
20331 @item GCC memregs @var{number}
20332 @cindex pragma, memregs
20333 Overrides the command-line option @code{-memregs=} for the current
20334 file. Use with care! This pragma must be before any function in the
20335 file, and mixing different memregs values in different objects may
20336 make them incompatible. This pragma is useful when a
20337 performance-critical function uses a memreg for temporary values,
20338 as it may allow you to reduce the number of memregs used.
20339
20340 @item ADDRESS @var{name} @var{address}
20341 @cindex pragma, address
20342 For any declared symbols matching @var{name}, this does three things
20343 to that symbol: it forces the symbol to be located at the given
20344 address (a number), it forces the symbol to be volatile, and it
20345 changes the symbol's scope to be static. This pragma exists for
20346 compatibility with other compilers, but note that the common
20347 @code{1234H} numeric syntax is not supported (use @code{0x1234}
20348 instead). Example:
20349
20350 @smallexample
20351 #pragma ADDRESS port3 0x103
20352 char port3;
20353 @end smallexample
20354
20355 @end table
20356
20357 @node MeP Pragmas
20358 @subsection MeP Pragmas
20359
20360 @table @code
20361
20362 @item custom io_volatile (on|off)
20363 @cindex pragma, custom io_volatile
20364 Overrides the command-line option @code{-mio-volatile} for the current
20365 file. Note that for compatibility with future GCC releases, this
20366 option should only be used once before any @code{io} variables in each
20367 file.
20368
20369 @item GCC coprocessor available @var{registers}
20370 @cindex pragma, coprocessor available
20371 Specifies which coprocessor registers are available to the register
20372 allocator. @var{registers} may be a single register, register range
20373 separated by ellipses, or comma-separated list of those. Example:
20374
20375 @smallexample
20376 #pragma GCC coprocessor available $c0...$c10, $c28
20377 @end smallexample
20378
20379 @item GCC coprocessor call_saved @var{registers}
20380 @cindex pragma, coprocessor call_saved
20381 Specifies which coprocessor registers are to be saved and restored by
20382 any function using them. @var{registers} may be a single register,
20383 register range separated by ellipses, or comma-separated list of
20384 those. Example:
20385
20386 @smallexample
20387 #pragma GCC coprocessor call_saved $c4...$c6, $c31
20388 @end smallexample
20389
20390 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
20391 @cindex pragma, coprocessor subclass
20392 Creates and defines a register class. These register classes can be
20393 used by inline @code{asm} constructs. @var{registers} may be a single
20394 register, register range separated by ellipses, or comma-separated
20395 list of those. Example:
20396
20397 @smallexample
20398 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
20399
20400 asm ("cpfoo %0" : "=B" (x));
20401 @end smallexample
20402
20403 @item GCC disinterrupt @var{name} , @var{name} @dots{}
20404 @cindex pragma, disinterrupt
20405 For the named functions, the compiler adds code to disable interrupts
20406 for the duration of those functions. If any functions so named
20407 are not encountered in the source, a warning is emitted that the pragma is
20408 not used. Examples:
20409
20410 @smallexample
20411 #pragma disinterrupt foo
20412 #pragma disinterrupt bar, grill
20413 int foo () @{ @dots{} @}
20414 @end smallexample
20415
20416 @item GCC call @var{name} , @var{name} @dots{}
20417 @cindex pragma, call
20418 For the named functions, the compiler always uses a register-indirect
20419 call model when calling the named functions. Examples:
20420
20421 @smallexample
20422 extern int foo ();
20423 #pragma call foo
20424 @end smallexample
20425
20426 @end table
20427
20428 @node RS/6000 and PowerPC Pragmas
20429 @subsection RS/6000 and PowerPC Pragmas
20430
20431 The RS/6000 and PowerPC targets define one pragma for controlling
20432 whether or not the @code{longcall} attribute is added to function
20433 declarations by default. This pragma overrides the @option{-mlongcall}
20434 option, but not the @code{longcall} and @code{shortcall} attributes.
20435 @xref{RS/6000 and PowerPC Options}, for more information about when long
20436 calls are and are not necessary.
20437
20438 @table @code
20439 @item longcall (1)
20440 @cindex pragma, longcall
20441 Apply the @code{longcall} attribute to all subsequent function
20442 declarations.
20443
20444 @item longcall (0)
20445 Do not apply the @code{longcall} attribute to subsequent function
20446 declarations.
20447 @end table
20448
20449 @c Describe h8300 pragmas here.
20450 @c Describe sh pragmas here.
20451 @c Describe v850 pragmas here.
20452
20453 @node S/390 Pragmas
20454 @subsection S/390 Pragmas
20455
20456 The pragmas defined by the S/390 target correspond to the S/390
20457 target function attributes and some the additional options:
20458
20459 @table @samp
20460 @item zvector
20461 @itemx no-zvector
20462 @end table
20463
20464 Note that options of the pragma, unlike options of the target
20465 attribute, do change the value of preprocessor macros like
20466 @code{__VEC__}. They can be specified as below:
20467
20468 @smallexample
20469 #pragma GCC target("string[,string]...")
20470 #pragma GCC target("string"[,"string"]...)
20471 @end smallexample
20472
20473 @node Darwin Pragmas
20474 @subsection Darwin Pragmas
20475
20476 The following pragmas are available for all architectures running the
20477 Darwin operating system. These are useful for compatibility with other
20478 Mac OS compilers.
20479
20480 @table @code
20481 @item mark @var{tokens}@dots{}
20482 @cindex pragma, mark
20483 This pragma is accepted, but has no effect.
20484
20485 @item options align=@var{alignment}
20486 @cindex pragma, options align
20487 This pragma sets the alignment of fields in structures. The values of
20488 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
20489 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
20490 properly; to restore the previous setting, use @code{reset} for the
20491 @var{alignment}.
20492
20493 @item segment @var{tokens}@dots{}
20494 @cindex pragma, segment
20495 This pragma is accepted, but has no effect.
20496
20497 @item unused (@var{var} [, @var{var}]@dots{})
20498 @cindex pragma, unused
20499 This pragma declares variables to be possibly unused. GCC does not
20500 produce warnings for the listed variables. The effect is similar to
20501 that of the @code{unused} attribute, except that this pragma may appear
20502 anywhere within the variables' scopes.
20503 @end table
20504
20505 @node Solaris Pragmas
20506 @subsection Solaris Pragmas
20507
20508 The Solaris target supports @code{#pragma redefine_extname}
20509 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
20510 @code{#pragma} directives for compatibility with the system compiler.
20511
20512 @table @code
20513 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
20514 @cindex pragma, align
20515
20516 Increase the minimum alignment of each @var{variable} to @var{alignment}.
20517 This is the same as GCC's @code{aligned} attribute @pxref{Variable
20518 Attributes}). Macro expansion occurs on the arguments to this pragma
20519 when compiling C and Objective-C@. It does not currently occur when
20520 compiling C++, but this is a bug which may be fixed in a future
20521 release.
20522
20523 @item fini (@var{function} [, @var{function}]...)
20524 @cindex pragma, fini
20525
20526 This pragma causes each listed @var{function} to be called after
20527 main, or during shared module unloading, by adding a call to the
20528 @code{.fini} section.
20529
20530 @item init (@var{function} [, @var{function}]...)
20531 @cindex pragma, init
20532
20533 This pragma causes each listed @var{function} to be called during
20534 initialization (before @code{main}) or during shared module loading, by
20535 adding a call to the @code{.init} section.
20536
20537 @end table
20538
20539 @node Symbol-Renaming Pragmas
20540 @subsection Symbol-Renaming Pragmas
20541
20542 GCC supports a @code{#pragma} directive that changes the name used in
20543 assembly for a given declaration. While this pragma is supported on all
20544 platforms, it is intended primarily to provide compatibility with the
20545 Solaris system headers. This effect can also be achieved using the asm
20546 labels extension (@pxref{Asm Labels}).
20547
20548 @table @code
20549 @item redefine_extname @var{oldname} @var{newname}
20550 @cindex pragma, redefine_extname
20551
20552 This pragma gives the C function @var{oldname} the assembly symbol
20553 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
20554 is defined if this pragma is available (currently on all platforms).
20555 @end table
20556
20557 This pragma and the asm labels extension interact in a complicated
20558 manner. Here are some corner cases you may want to be aware of:
20559
20560 @enumerate
20561 @item This pragma silently applies only to declarations with external
20562 linkage. Asm labels do not have this restriction.
20563
20564 @item In C++, this pragma silently applies only to declarations with
20565 ``C'' linkage. Again, asm labels do not have this restriction.
20566
20567 @item If either of the ways of changing the assembly name of a
20568 declaration are applied to a declaration whose assembly name has
20569 already been determined (either by a previous use of one of these
20570 features, or because the compiler needed the assembly name in order to
20571 generate code), and the new name is different, a warning issues and
20572 the name does not change.
20573
20574 @item The @var{oldname} used by @code{#pragma redefine_extname} is
20575 always the C-language name.
20576 @end enumerate
20577
20578 @node Structure-Layout Pragmas
20579 @subsection Structure-Layout Pragmas
20580
20581 For compatibility with Microsoft Windows compilers, GCC supports a
20582 set of @code{#pragma} directives that change the maximum alignment of
20583 members of structures (other than zero-width bit-fields), unions, and
20584 classes subsequently defined. The @var{n} value below always is required
20585 to be a small power of two and specifies the new alignment in bytes.
20586
20587 @enumerate
20588 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
20589 @item @code{#pragma pack()} sets the alignment to the one that was in
20590 effect when compilation started (see also command-line option
20591 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
20592 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
20593 setting on an internal stack and then optionally sets the new alignment.
20594 @item @code{#pragma pack(pop)} restores the alignment setting to the one
20595 saved at the top of the internal stack (and removes that stack entry).
20596 Note that @code{#pragma pack([@var{n}])} does not influence this internal
20597 stack; thus it is possible to have @code{#pragma pack(push)} followed by
20598 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
20599 @code{#pragma pack(pop)}.
20600 @end enumerate
20601
20602 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
20603 directive which lays out structures and unions subsequently defined as the
20604 documented @code{__attribute__ ((ms_struct))}.
20605
20606 @enumerate
20607 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
20608 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
20609 @item @code{#pragma ms_struct reset} goes back to the default layout.
20610 @end enumerate
20611
20612 Most targets also support the @code{#pragma scalar_storage_order} directive
20613 which lays out structures and unions subsequently defined as the documented
20614 @code{__attribute__ ((scalar_storage_order))}.
20615
20616 @enumerate
20617 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
20618 of the scalar fields to big-endian.
20619 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
20620 of the scalar fields to little-endian.
20621 @item @code{#pragma scalar_storage_order default} goes back to the endianness
20622 that was in effect when compilation started (see also command-line option
20623 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
20624 @end enumerate
20625
20626 @node Weak Pragmas
20627 @subsection Weak Pragmas
20628
20629 For compatibility with SVR4, GCC supports a set of @code{#pragma}
20630 directives for declaring symbols to be weak, and defining weak
20631 aliases.
20632
20633 @table @code
20634 @item #pragma weak @var{symbol}
20635 @cindex pragma, weak
20636 This pragma declares @var{symbol} to be weak, as if the declaration
20637 had the attribute of the same name. The pragma may appear before
20638 or after the declaration of @var{symbol}. It is not an error for
20639 @var{symbol} to never be defined at all.
20640
20641 @item #pragma weak @var{symbol1} = @var{symbol2}
20642 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
20643 It is an error if @var{symbol2} is not defined in the current
20644 translation unit.
20645 @end table
20646
20647 @node Diagnostic Pragmas
20648 @subsection Diagnostic Pragmas
20649
20650 GCC allows the user to selectively enable or disable certain types of
20651 diagnostics, and change the kind of the diagnostic. For example, a
20652 project's policy might require that all sources compile with
20653 @option{-Werror} but certain files might have exceptions allowing
20654 specific types of warnings. Or, a project might selectively enable
20655 diagnostics and treat them as errors depending on which preprocessor
20656 macros are defined.
20657
20658 @table @code
20659 @item #pragma GCC diagnostic @var{kind} @var{option}
20660 @cindex pragma, diagnostic
20661
20662 Modifies the disposition of a diagnostic. Note that not all
20663 diagnostics are modifiable; at the moment only warnings (normally
20664 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
20665 Use @option{-fdiagnostics-show-option} to determine which diagnostics
20666 are controllable and which option controls them.
20667
20668 @var{kind} is @samp{error} to treat this diagnostic as an error,
20669 @samp{warning} to treat it like a warning (even if @option{-Werror} is
20670 in effect), or @samp{ignored} if the diagnostic is to be ignored.
20671 @var{option} is a double quoted string that matches the command-line
20672 option.
20673
20674 @smallexample
20675 #pragma GCC diagnostic warning "-Wformat"
20676 #pragma GCC diagnostic error "-Wformat"
20677 #pragma GCC diagnostic ignored "-Wformat"
20678 @end smallexample
20679
20680 Note that these pragmas override any command-line options. GCC keeps
20681 track of the location of each pragma, and issues diagnostics according
20682 to the state as of that point in the source file. Thus, pragmas occurring
20683 after a line do not affect diagnostics caused by that line.
20684
20685 @item #pragma GCC diagnostic push
20686 @itemx #pragma GCC diagnostic pop
20687
20688 Causes GCC to remember the state of the diagnostics as of each
20689 @code{push}, and restore to that point at each @code{pop}. If a
20690 @code{pop} has no matching @code{push}, the command-line options are
20691 restored.
20692
20693 @smallexample
20694 #pragma GCC diagnostic error "-Wuninitialized"
20695 foo(a); /* error is given for this one */
20696 #pragma GCC diagnostic push
20697 #pragma GCC diagnostic ignored "-Wuninitialized"
20698 foo(b); /* no diagnostic for this one */
20699 #pragma GCC diagnostic pop
20700 foo(c); /* error is given for this one */
20701 #pragma GCC diagnostic pop
20702 foo(d); /* depends on command-line options */
20703 @end smallexample
20704
20705 @end table
20706
20707 GCC also offers a simple mechanism for printing messages during
20708 compilation.
20709
20710 @table @code
20711 @item #pragma message @var{string}
20712 @cindex pragma, diagnostic
20713
20714 Prints @var{string} as a compiler message on compilation. The message
20715 is informational only, and is neither a compilation warning nor an error.
20716
20717 @smallexample
20718 #pragma message "Compiling " __FILE__ "..."
20719 @end smallexample
20720
20721 @var{string} may be parenthesized, and is printed with location
20722 information. For example,
20723
20724 @smallexample
20725 #define DO_PRAGMA(x) _Pragma (#x)
20726 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
20727
20728 TODO(Remember to fix this)
20729 @end smallexample
20730
20731 @noindent
20732 prints @samp{/tmp/file.c:4: note: #pragma message:
20733 TODO - Remember to fix this}.
20734
20735 @end table
20736
20737 @node Visibility Pragmas
20738 @subsection Visibility Pragmas
20739
20740 @table @code
20741 @item #pragma GCC visibility push(@var{visibility})
20742 @itemx #pragma GCC visibility pop
20743 @cindex pragma, visibility
20744
20745 This pragma allows the user to set the visibility for multiple
20746 declarations without having to give each a visibility attribute
20747 (@pxref{Function Attributes}).
20748
20749 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
20750 declarations. Class members and template specializations are not
20751 affected; if you want to override the visibility for a particular
20752 member or instantiation, you must use an attribute.
20753
20754 @end table
20755
20756
20757 @node Push/Pop Macro Pragmas
20758 @subsection Push/Pop Macro Pragmas
20759
20760 For compatibility with Microsoft Windows compilers, GCC supports
20761 @samp{#pragma push_macro(@var{"macro_name"})}
20762 and @samp{#pragma pop_macro(@var{"macro_name"})}.
20763
20764 @table @code
20765 @item #pragma push_macro(@var{"macro_name"})
20766 @cindex pragma, push_macro
20767 This pragma saves the value of the macro named as @var{macro_name} to
20768 the top of the stack for this macro.
20769
20770 @item #pragma pop_macro(@var{"macro_name"})
20771 @cindex pragma, pop_macro
20772 This pragma sets the value of the macro named as @var{macro_name} to
20773 the value on top of the stack for this macro. If the stack for
20774 @var{macro_name} is empty, the value of the macro remains unchanged.
20775 @end table
20776
20777 For example:
20778
20779 @smallexample
20780 #define X 1
20781 #pragma push_macro("X")
20782 #undef X
20783 #define X -1
20784 #pragma pop_macro("X")
20785 int x [X];
20786 @end smallexample
20787
20788 @noindent
20789 In this example, the definition of X as 1 is saved by @code{#pragma
20790 push_macro} and restored by @code{#pragma pop_macro}.
20791
20792 @node Function Specific Option Pragmas
20793 @subsection Function Specific Option Pragmas
20794
20795 @table @code
20796 @item #pragma GCC target (@var{"string"}...)
20797 @cindex pragma GCC target
20798
20799 This pragma allows you to set target specific options for functions
20800 defined later in the source file. One or more strings can be
20801 specified. Each function that is defined after this point is as
20802 if @code{attribute((target("STRING")))} was specified for that
20803 function. The parenthesis around the options is optional.
20804 @xref{Function Attributes}, for more information about the
20805 @code{target} attribute and the attribute syntax.
20806
20807 The @code{#pragma GCC target} pragma is presently implemented for
20808 x86, PowerPC, and Nios II targets only.
20809 @end table
20810
20811 @table @code
20812 @item #pragma GCC optimize (@var{"string"}...)
20813 @cindex pragma GCC optimize
20814
20815 This pragma allows you to set global optimization options for functions
20816 defined later in the source file. One or more strings can be
20817 specified. Each function that is defined after this point is as
20818 if @code{attribute((optimize("STRING")))} was specified for that
20819 function. The parenthesis around the options is optional.
20820 @xref{Function Attributes}, for more information about the
20821 @code{optimize} attribute and the attribute syntax.
20822 @end table
20823
20824 @table @code
20825 @item #pragma GCC push_options
20826 @itemx #pragma GCC pop_options
20827 @cindex pragma GCC push_options
20828 @cindex pragma GCC pop_options
20829
20830 These pragmas maintain a stack of the current target and optimization
20831 options. It is intended for include files where you temporarily want
20832 to switch to using a different @samp{#pragma GCC target} or
20833 @samp{#pragma GCC optimize} and then to pop back to the previous
20834 options.
20835 @end table
20836
20837 @table @code
20838 @item #pragma GCC reset_options
20839 @cindex pragma GCC reset_options
20840
20841 This pragma clears the current @code{#pragma GCC target} and
20842 @code{#pragma GCC optimize} to use the default switches as specified
20843 on the command line.
20844 @end table
20845
20846 @node Loop-Specific Pragmas
20847 @subsection Loop-Specific Pragmas
20848
20849 @table @code
20850 @item #pragma GCC ivdep
20851 @cindex pragma GCC ivdep
20852 @end table
20853
20854 With this pragma, the programmer asserts that there are no loop-carried
20855 dependencies which would prevent consecutive iterations of
20856 the following loop from executing concurrently with SIMD
20857 (single instruction multiple data) instructions.
20858
20859 For example, the compiler can only unconditionally vectorize the following
20860 loop with the pragma:
20861
20862 @smallexample
20863 void foo (int n, int *a, int *b, int *c)
20864 @{
20865 int i, j;
20866 #pragma GCC ivdep
20867 for (i = 0; i < n; ++i)
20868 a[i] = b[i] + c[i];
20869 @}
20870 @end smallexample
20871
20872 @noindent
20873 In this example, using the @code{restrict} qualifier had the same
20874 effect. In the following example, that would not be possible. Assume
20875 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
20876 that it can unconditionally vectorize the following loop:
20877
20878 @smallexample
20879 void ignore_vec_dep (int *a, int k, int c, int m)
20880 @{
20881 #pragma GCC ivdep
20882 for (int i = 0; i < m; i++)
20883 a[i] = a[i + k] * c;
20884 @}
20885 @end smallexample
20886
20887
20888 @node Unnamed Fields
20889 @section Unnamed Structure and Union Fields
20890 @cindex @code{struct}
20891 @cindex @code{union}
20892
20893 As permitted by ISO C11 and for compatibility with other compilers,
20894 GCC allows you to define
20895 a structure or union that contains, as fields, structures and unions
20896 without names. For example:
20897
20898 @smallexample
20899 struct @{
20900 int a;
20901 union @{
20902 int b;
20903 float c;
20904 @};
20905 int d;
20906 @} foo;
20907 @end smallexample
20908
20909 @noindent
20910 In this example, you are able to access members of the unnamed
20911 union with code like @samp{foo.b}. Note that only unnamed structs and
20912 unions are allowed, you may not have, for example, an unnamed
20913 @code{int}.
20914
20915 You must never create such structures that cause ambiguous field definitions.
20916 For example, in this structure:
20917
20918 @smallexample
20919 struct @{
20920 int a;
20921 struct @{
20922 int a;
20923 @};
20924 @} foo;
20925 @end smallexample
20926
20927 @noindent
20928 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
20929 The compiler gives errors for such constructs.
20930
20931 @opindex fms-extensions
20932 Unless @option{-fms-extensions} is used, the unnamed field must be a
20933 structure or union definition without a tag (for example, @samp{struct
20934 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
20935 also be a definition with a tag such as @samp{struct foo @{ int a;
20936 @};}, a reference to a previously defined structure or union such as
20937 @samp{struct foo;}, or a reference to a @code{typedef} name for a
20938 previously defined structure or union type.
20939
20940 @opindex fplan9-extensions
20941 The option @option{-fplan9-extensions} enables
20942 @option{-fms-extensions} as well as two other extensions. First, a
20943 pointer to a structure is automatically converted to a pointer to an
20944 anonymous field for assignments and function calls. For example:
20945
20946 @smallexample
20947 struct s1 @{ int a; @};
20948 struct s2 @{ struct s1; @};
20949 extern void f1 (struct s1 *);
20950 void f2 (struct s2 *p) @{ f1 (p); @}
20951 @end smallexample
20952
20953 @noindent
20954 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
20955 converted into a pointer to the anonymous field.
20956
20957 Second, when the type of an anonymous field is a @code{typedef} for a
20958 @code{struct} or @code{union}, code may refer to the field using the
20959 name of the @code{typedef}.
20960
20961 @smallexample
20962 typedef struct @{ int a; @} s1;
20963 struct s2 @{ s1; @};
20964 s1 f1 (struct s2 *p) @{ return p->s1; @}
20965 @end smallexample
20966
20967 These usages are only permitted when they are not ambiguous.
20968
20969 @node Thread-Local
20970 @section Thread-Local Storage
20971 @cindex Thread-Local Storage
20972 @cindex @acronym{TLS}
20973 @cindex @code{__thread}
20974
20975 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
20976 are allocated such that there is one instance of the variable per extant
20977 thread. The runtime model GCC uses to implement this originates
20978 in the IA-64 processor-specific ABI, but has since been migrated
20979 to other processors as well. It requires significant support from
20980 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
20981 system libraries (@file{libc.so} and @file{libpthread.so}), so it
20982 is not available everywhere.
20983
20984 At the user level, the extension is visible with a new storage
20985 class keyword: @code{__thread}. For example:
20986
20987 @smallexample
20988 __thread int i;
20989 extern __thread struct state s;
20990 static __thread char *p;
20991 @end smallexample
20992
20993 The @code{__thread} specifier may be used alone, with the @code{extern}
20994 or @code{static} specifiers, but with no other storage class specifier.
20995 When used with @code{extern} or @code{static}, @code{__thread} must appear
20996 immediately after the other storage class specifier.
20997
20998 The @code{__thread} specifier may be applied to any global, file-scoped
20999 static, function-scoped static, or static data member of a class. It may
21000 not be applied to block-scoped automatic or non-static data member.
21001
21002 When the address-of operator is applied to a thread-local variable, it is
21003 evaluated at run time and returns the address of the current thread's
21004 instance of that variable. An address so obtained may be used by any
21005 thread. When a thread terminates, any pointers to thread-local variables
21006 in that thread become invalid.
21007
21008 No static initialization may refer to the address of a thread-local variable.
21009
21010 In C++, if an initializer is present for a thread-local variable, it must
21011 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
21012 standard.
21013
21014 See @uref{http://www.akkadia.org/drepper/tls.pdf,
21015 ELF Handling For Thread-Local Storage} for a detailed explanation of
21016 the four thread-local storage addressing models, and how the runtime
21017 is expected to function.
21018
21019 @menu
21020 * C99 Thread-Local Edits::
21021 * C++98 Thread-Local Edits::
21022 @end menu
21023
21024 @node C99 Thread-Local Edits
21025 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
21026
21027 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
21028 that document the exact semantics of the language extension.
21029
21030 @itemize @bullet
21031 @item
21032 @cite{5.1.2 Execution environments}
21033
21034 Add new text after paragraph 1
21035
21036 @quotation
21037 Within either execution environment, a @dfn{thread} is a flow of
21038 control within a program. It is implementation defined whether
21039 or not there may be more than one thread associated with a program.
21040 It is implementation defined how threads beyond the first are
21041 created, the name and type of the function called at thread
21042 startup, and how threads may be terminated. However, objects
21043 with thread storage duration shall be initialized before thread
21044 startup.
21045 @end quotation
21046
21047 @item
21048 @cite{6.2.4 Storage durations of objects}
21049
21050 Add new text before paragraph 3
21051
21052 @quotation
21053 An object whose identifier is declared with the storage-class
21054 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
21055 Its lifetime is the entire execution of the thread, and its
21056 stored value is initialized only once, prior to thread startup.
21057 @end quotation
21058
21059 @item
21060 @cite{6.4.1 Keywords}
21061
21062 Add @code{__thread}.
21063
21064 @item
21065 @cite{6.7.1 Storage-class specifiers}
21066
21067 Add @code{__thread} to the list of storage class specifiers in
21068 paragraph 1.
21069
21070 Change paragraph 2 to
21071
21072 @quotation
21073 With the exception of @code{__thread}, at most one storage-class
21074 specifier may be given [@dots{}]. The @code{__thread} specifier may
21075 be used alone, or immediately following @code{extern} or
21076 @code{static}.
21077 @end quotation
21078
21079 Add new text after paragraph 6
21080
21081 @quotation
21082 The declaration of an identifier for a variable that has
21083 block scope that specifies @code{__thread} shall also
21084 specify either @code{extern} or @code{static}.
21085
21086 The @code{__thread} specifier shall be used only with
21087 variables.
21088 @end quotation
21089 @end itemize
21090
21091 @node C++98 Thread-Local Edits
21092 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
21093
21094 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
21095 that document the exact semantics of the language extension.
21096
21097 @itemize @bullet
21098 @item
21099 @b{[intro.execution]}
21100
21101 New text after paragraph 4
21102
21103 @quotation
21104 A @dfn{thread} is a flow of control within the abstract machine.
21105 It is implementation defined whether or not there may be more than
21106 one thread.
21107 @end quotation
21108
21109 New text after paragraph 7
21110
21111 @quotation
21112 It is unspecified whether additional action must be taken to
21113 ensure when and whether side effects are visible to other threads.
21114 @end quotation
21115
21116 @item
21117 @b{[lex.key]}
21118
21119 Add @code{__thread}.
21120
21121 @item
21122 @b{[basic.start.main]}
21123
21124 Add after paragraph 5
21125
21126 @quotation
21127 The thread that begins execution at the @code{main} function is called
21128 the @dfn{main thread}. It is implementation defined how functions
21129 beginning threads other than the main thread are designated or typed.
21130 A function so designated, as well as the @code{main} function, is called
21131 a @dfn{thread startup function}. It is implementation defined what
21132 happens if a thread startup function returns. It is implementation
21133 defined what happens to other threads when any thread calls @code{exit}.
21134 @end quotation
21135
21136 @item
21137 @b{[basic.start.init]}
21138
21139 Add after paragraph 4
21140
21141 @quotation
21142 The storage for an object of thread storage duration shall be
21143 statically initialized before the first statement of the thread startup
21144 function. An object of thread storage duration shall not require
21145 dynamic initialization.
21146 @end quotation
21147
21148 @item
21149 @b{[basic.start.term]}
21150
21151 Add after paragraph 3
21152
21153 @quotation
21154 The type of an object with thread storage duration shall not have a
21155 non-trivial destructor, nor shall it be an array type whose elements
21156 (directly or indirectly) have non-trivial destructors.
21157 @end quotation
21158
21159 @item
21160 @b{[basic.stc]}
21161
21162 Add ``thread storage duration'' to the list in paragraph 1.
21163
21164 Change paragraph 2
21165
21166 @quotation
21167 Thread, static, and automatic storage durations are associated with
21168 objects introduced by declarations [@dots{}].
21169 @end quotation
21170
21171 Add @code{__thread} to the list of specifiers in paragraph 3.
21172
21173 @item
21174 @b{[basic.stc.thread]}
21175
21176 New section before @b{[basic.stc.static]}
21177
21178 @quotation
21179 The keyword @code{__thread} applied to a non-local object gives the
21180 object thread storage duration.
21181
21182 A local variable or class data member declared both @code{static}
21183 and @code{__thread} gives the variable or member thread storage
21184 duration.
21185 @end quotation
21186
21187 @item
21188 @b{[basic.stc.static]}
21189
21190 Change paragraph 1
21191
21192 @quotation
21193 All objects that have neither thread storage duration, dynamic
21194 storage duration nor are local [@dots{}].
21195 @end quotation
21196
21197 @item
21198 @b{[dcl.stc]}
21199
21200 Add @code{__thread} to the list in paragraph 1.
21201
21202 Change paragraph 1
21203
21204 @quotation
21205 With the exception of @code{__thread}, at most one
21206 @var{storage-class-specifier} shall appear in a given
21207 @var{decl-specifier-seq}. The @code{__thread} specifier may
21208 be used alone, or immediately following the @code{extern} or
21209 @code{static} specifiers. [@dots{}]
21210 @end quotation
21211
21212 Add after paragraph 5
21213
21214 @quotation
21215 The @code{__thread} specifier can be applied only to the names of objects
21216 and to anonymous unions.
21217 @end quotation
21218
21219 @item
21220 @b{[class.mem]}
21221
21222 Add after paragraph 6
21223
21224 @quotation
21225 Non-@code{static} members shall not be @code{__thread}.
21226 @end quotation
21227 @end itemize
21228
21229 @node Binary constants
21230 @section Binary Constants using the @samp{0b} Prefix
21231 @cindex Binary constants using the @samp{0b} prefix
21232
21233 Integer constants can be written as binary constants, consisting of a
21234 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
21235 @samp{0B}. This is particularly useful in environments that operate a
21236 lot on the bit level (like microcontrollers).
21237
21238 The following statements are identical:
21239
21240 @smallexample
21241 i = 42;
21242 i = 0x2a;
21243 i = 052;
21244 i = 0b101010;
21245 @end smallexample
21246
21247 The type of these constants follows the same rules as for octal or
21248 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
21249 can be applied.
21250
21251 @node C++ Extensions
21252 @chapter Extensions to the C++ Language
21253 @cindex extensions, C++ language
21254 @cindex C++ language extensions
21255
21256 The GNU compiler provides these extensions to the C++ language (and you
21257 can also use most of the C language extensions in your C++ programs). If you
21258 want to write code that checks whether these features are available, you can
21259 test for the GNU compiler the same way as for C programs: check for a
21260 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
21261 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
21262 Predefined Macros,cpp,The GNU C Preprocessor}).
21263
21264 @menu
21265 * C++ Volatiles:: What constitutes an access to a volatile object.
21266 * Restricted Pointers:: C99 restricted pointers and references.
21267 * Vague Linkage:: Where G++ puts inlines, vtables and such.
21268 * C++ Interface:: You can use a single C++ header file for both
21269 declarations and definitions.
21270 * Template Instantiation:: Methods for ensuring that exactly one copy of
21271 each needed template instantiation is emitted.
21272 * Bound member functions:: You can extract a function pointer to the
21273 method denoted by a @samp{->*} or @samp{.*} expression.
21274 * C++ Attributes:: Variable, function, and type attributes for C++ only.
21275 * Function Multiversioning:: Declaring multiple function versions.
21276 * Namespace Association:: Strong using-directives for namespace association.
21277 * Type Traits:: Compiler support for type traits.
21278 * C++ Concepts:: Improved support for generic programming.
21279 * Java Exceptions:: Tweaking exception handling to work with Java.
21280 * Deprecated Features:: Things will disappear from G++.
21281 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
21282 @end menu
21283
21284 @node C++ Volatiles
21285 @section When is a Volatile C++ Object Accessed?
21286 @cindex accessing volatiles
21287 @cindex volatile read
21288 @cindex volatile write
21289 @cindex volatile access
21290
21291 The C++ standard differs from the C standard in its treatment of
21292 volatile objects. It fails to specify what constitutes a volatile
21293 access, except to say that C++ should behave in a similar manner to C
21294 with respect to volatiles, where possible. However, the different
21295 lvalueness of expressions between C and C++ complicate the behavior.
21296 G++ behaves the same as GCC for volatile access, @xref{C
21297 Extensions,,Volatiles}, for a description of GCC's behavior.
21298
21299 The C and C++ language specifications differ when an object is
21300 accessed in a void context:
21301
21302 @smallexample
21303 volatile int *src = @var{somevalue};
21304 *src;
21305 @end smallexample
21306
21307 The C++ standard specifies that such expressions do not undergo lvalue
21308 to rvalue conversion, and that the type of the dereferenced object may
21309 be incomplete. The C++ standard does not specify explicitly that it
21310 is lvalue to rvalue conversion that is responsible for causing an
21311 access. There is reason to believe that it is, because otherwise
21312 certain simple expressions become undefined. However, because it
21313 would surprise most programmers, G++ treats dereferencing a pointer to
21314 volatile object of complete type as GCC would do for an equivalent
21315 type in C@. When the object has incomplete type, G++ issues a
21316 warning; if you wish to force an error, you must force a conversion to
21317 rvalue with, for instance, a static cast.
21318
21319 When using a reference to volatile, G++ does not treat equivalent
21320 expressions as accesses to volatiles, but instead issues a warning that
21321 no volatile is accessed. The rationale for this is that otherwise it
21322 becomes difficult to determine where volatile access occur, and not
21323 possible to ignore the return value from functions returning volatile
21324 references. Again, if you wish to force a read, cast the reference to
21325 an rvalue.
21326
21327 G++ implements the same behavior as GCC does when assigning to a
21328 volatile object---there is no reread of the assigned-to object, the
21329 assigned rvalue is reused. Note that in C++ assignment expressions
21330 are lvalues, and if used as an lvalue, the volatile object is
21331 referred to. For instance, @var{vref} refers to @var{vobj}, as
21332 expected, in the following example:
21333
21334 @smallexample
21335 volatile int vobj;
21336 volatile int &vref = vobj = @var{something};
21337 @end smallexample
21338
21339 @node Restricted Pointers
21340 @section Restricting Pointer Aliasing
21341 @cindex restricted pointers
21342 @cindex restricted references
21343 @cindex restricted this pointer
21344
21345 As with the C front end, G++ understands the C99 feature of restricted pointers,
21346 specified with the @code{__restrict__}, or @code{__restrict} type
21347 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
21348 language flag, @code{restrict} is not a keyword in C++.
21349
21350 In addition to allowing restricted pointers, you can specify restricted
21351 references, which indicate that the reference is not aliased in the local
21352 context.
21353
21354 @smallexample
21355 void fn (int *__restrict__ rptr, int &__restrict__ rref)
21356 @{
21357 /* @r{@dots{}} */
21358 @}
21359 @end smallexample
21360
21361 @noindent
21362 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
21363 @var{rref} refers to a (different) unaliased integer.
21364
21365 You may also specify whether a member function's @var{this} pointer is
21366 unaliased by using @code{__restrict__} as a member function qualifier.
21367
21368 @smallexample
21369 void T::fn () __restrict__
21370 @{
21371 /* @r{@dots{}} */
21372 @}
21373 @end smallexample
21374
21375 @noindent
21376 Within the body of @code{T::fn}, @var{this} has the effective
21377 definition @code{T *__restrict__ const this}. Notice that the
21378 interpretation of a @code{__restrict__} member function qualifier is
21379 different to that of @code{const} or @code{volatile} qualifier, in that it
21380 is applied to the pointer rather than the object. This is consistent with
21381 other compilers that implement restricted pointers.
21382
21383 As with all outermost parameter qualifiers, @code{__restrict__} is
21384 ignored in function definition matching. This means you only need to
21385 specify @code{__restrict__} in a function definition, rather than
21386 in a function prototype as well.
21387
21388 @node Vague Linkage
21389 @section Vague Linkage
21390 @cindex vague linkage
21391
21392 There are several constructs in C++ that require space in the object
21393 file but are not clearly tied to a single translation unit. We say that
21394 these constructs have ``vague linkage''. Typically such constructs are
21395 emitted wherever they are needed, though sometimes we can be more
21396 clever.
21397
21398 @table @asis
21399 @item Inline Functions
21400 Inline functions are typically defined in a header file which can be
21401 included in many different compilations. Hopefully they can usually be
21402 inlined, but sometimes an out-of-line copy is necessary, if the address
21403 of the function is taken or if inlining fails. In general, we emit an
21404 out-of-line copy in all translation units where one is needed. As an
21405 exception, we only emit inline virtual functions with the vtable, since
21406 it always requires a copy.
21407
21408 Local static variables and string constants used in an inline function
21409 are also considered to have vague linkage, since they must be shared
21410 between all inlined and out-of-line instances of the function.
21411
21412 @item VTables
21413 @cindex vtable
21414 C++ virtual functions are implemented in most compilers using a lookup
21415 table, known as a vtable. The vtable contains pointers to the virtual
21416 functions provided by a class, and each object of the class contains a
21417 pointer to its vtable (or vtables, in some multiple-inheritance
21418 situations). If the class declares any non-inline, non-pure virtual
21419 functions, the first one is chosen as the ``key method'' for the class,
21420 and the vtable is only emitted in the translation unit where the key
21421 method is defined.
21422
21423 @emph{Note:} If the chosen key method is later defined as inline, the
21424 vtable is still emitted in every translation unit that defines it.
21425 Make sure that any inline virtuals are declared inline in the class
21426 body, even if they are not defined there.
21427
21428 @item @code{type_info} objects
21429 @cindex @code{type_info}
21430 @cindex RTTI
21431 C++ requires information about types to be written out in order to
21432 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
21433 For polymorphic classes (classes with virtual functions), the @samp{type_info}
21434 object is written out along with the vtable so that @samp{dynamic_cast}
21435 can determine the dynamic type of a class object at run time. For all
21436 other types, we write out the @samp{type_info} object when it is used: when
21437 applying @samp{typeid} to an expression, throwing an object, or
21438 referring to a type in a catch clause or exception specification.
21439
21440 @item Template Instantiations
21441 Most everything in this section also applies to template instantiations,
21442 but there are other options as well.
21443 @xref{Template Instantiation,,Where's the Template?}.
21444
21445 @end table
21446
21447 When used with GNU ld version 2.8 or later on an ELF system such as
21448 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
21449 these constructs will be discarded at link time. This is known as
21450 COMDAT support.
21451
21452 On targets that don't support COMDAT, but do support weak symbols, GCC
21453 uses them. This way one copy overrides all the others, but
21454 the unused copies still take up space in the executable.
21455
21456 For targets that do not support either COMDAT or weak symbols,
21457 most entities with vague linkage are emitted as local symbols to
21458 avoid duplicate definition errors from the linker. This does not happen
21459 for local statics in inlines, however, as having multiple copies
21460 almost certainly breaks things.
21461
21462 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
21463 another way to control placement of these constructs.
21464
21465 @node C++ Interface
21466 @section C++ Interface and Implementation Pragmas
21467
21468 @cindex interface and implementation headers, C++
21469 @cindex C++ interface and implementation headers
21470 @cindex pragmas, interface and implementation
21471
21472 @code{#pragma interface} and @code{#pragma implementation} provide the
21473 user with a way of explicitly directing the compiler to emit entities
21474 with vague linkage (and debugging information) in a particular
21475 translation unit.
21476
21477 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
21478 by COMDAT support and the ``key method'' heuristic
21479 mentioned in @ref{Vague Linkage}. Using them can actually cause your
21480 program to grow due to unnecessary out-of-line copies of inline
21481 functions.
21482
21483 @table @code
21484 @item #pragma interface
21485 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
21486 @kindex #pragma interface
21487 Use this directive in @emph{header files} that define object classes, to save
21488 space in most of the object files that use those classes. Normally,
21489 local copies of certain information (backup copies of inline member
21490 functions, debugging information, and the internal tables that implement
21491 virtual functions) must be kept in each object file that includes class
21492 definitions. You can use this pragma to avoid such duplication. When a
21493 header file containing @samp{#pragma interface} is included in a
21494 compilation, this auxiliary information is not generated (unless
21495 the main input source file itself uses @samp{#pragma implementation}).
21496 Instead, the object files contain references to be resolved at link
21497 time.
21498
21499 The second form of this directive is useful for the case where you have
21500 multiple headers with the same name in different directories. If you
21501 use this form, you must specify the same string to @samp{#pragma
21502 implementation}.
21503
21504 @item #pragma implementation
21505 @itemx #pragma implementation "@var{objects}.h"
21506 @kindex #pragma implementation
21507 Use this pragma in a @emph{main input file}, when you want full output from
21508 included header files to be generated (and made globally visible). The
21509 included header file, in turn, should use @samp{#pragma interface}.
21510 Backup copies of inline member functions, debugging information, and the
21511 internal tables used to implement virtual functions are all generated in
21512 implementation files.
21513
21514 @cindex implied @code{#pragma implementation}
21515 @cindex @code{#pragma implementation}, implied
21516 @cindex naming convention, implementation headers
21517 If you use @samp{#pragma implementation} with no argument, it applies to
21518 an include file with the same basename@footnote{A file's @dfn{basename}
21519 is the name stripped of all leading path information and of trailing
21520 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
21521 file. For example, in @file{allclass.cc}, giving just
21522 @samp{#pragma implementation}
21523 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
21524
21525 Use the string argument if you want a single implementation file to
21526 include code from multiple header files. (You must also use
21527 @samp{#include} to include the header file; @samp{#pragma
21528 implementation} only specifies how to use the file---it doesn't actually
21529 include it.)
21530
21531 There is no way to split up the contents of a single header file into
21532 multiple implementation files.
21533 @end table
21534
21535 @cindex inlining and C++ pragmas
21536 @cindex C++ pragmas, effect on inlining
21537 @cindex pragmas in C++, effect on inlining
21538 @samp{#pragma implementation} and @samp{#pragma interface} also have an
21539 effect on function inlining.
21540
21541 If you define a class in a header file marked with @samp{#pragma
21542 interface}, the effect on an inline function defined in that class is
21543 similar to an explicit @code{extern} declaration---the compiler emits
21544 no code at all to define an independent version of the function. Its
21545 definition is used only for inlining with its callers.
21546
21547 @opindex fno-implement-inlines
21548 Conversely, when you include the same header file in a main source file
21549 that declares it as @samp{#pragma implementation}, the compiler emits
21550 code for the function itself; this defines a version of the function
21551 that can be found via pointers (or by callers compiled without
21552 inlining). If all calls to the function can be inlined, you can avoid
21553 emitting the function by compiling with @option{-fno-implement-inlines}.
21554 If any calls are not inlined, you will get linker errors.
21555
21556 @node Template Instantiation
21557 @section Where's the Template?
21558 @cindex template instantiation
21559
21560 C++ templates were the first language feature to require more
21561 intelligence from the environment than was traditionally found on a UNIX
21562 system. Somehow the compiler and linker have to make sure that each
21563 template instance occurs exactly once in the executable if it is needed,
21564 and not at all otherwise. There are two basic approaches to this
21565 problem, which are referred to as the Borland model and the Cfront model.
21566
21567 @table @asis
21568 @item Borland model
21569 Borland C++ solved the template instantiation problem by adding the code
21570 equivalent of common blocks to their linker; the compiler emits template
21571 instances in each translation unit that uses them, and the linker
21572 collapses them together. The advantage of this model is that the linker
21573 only has to consider the object files themselves; there is no external
21574 complexity to worry about. The disadvantage is that compilation time
21575 is increased because the template code is being compiled repeatedly.
21576 Code written for this model tends to include definitions of all
21577 templates in the header file, since they must be seen to be
21578 instantiated.
21579
21580 @item Cfront model
21581 The AT&T C++ translator, Cfront, solved the template instantiation
21582 problem by creating the notion of a template repository, an
21583 automatically maintained place where template instances are stored. A
21584 more modern version of the repository works as follows: As individual
21585 object files are built, the compiler places any template definitions and
21586 instantiations encountered in the repository. At link time, the link
21587 wrapper adds in the objects in the repository and compiles any needed
21588 instances that were not previously emitted. The advantages of this
21589 model are more optimal compilation speed and the ability to use the
21590 system linker; to implement the Borland model a compiler vendor also
21591 needs to replace the linker. The disadvantages are vastly increased
21592 complexity, and thus potential for error; for some code this can be
21593 just as transparent, but in practice it can been very difficult to build
21594 multiple programs in one directory and one program in multiple
21595 directories. Code written for this model tends to separate definitions
21596 of non-inline member templates into a separate file, which should be
21597 compiled separately.
21598 @end table
21599
21600 G++ implements the Borland model on targets where the linker supports it,
21601 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
21602 Otherwise G++ implements neither automatic model.
21603
21604 You have the following options for dealing with template instantiations:
21605
21606 @enumerate
21607 @item
21608 Do nothing. Code written for the Borland model works fine, but
21609 each translation unit contains instances of each of the templates it
21610 uses. The duplicate instances will be discarded by the linker, but in
21611 a large program, this can lead to an unacceptable amount of code
21612 duplication in object files or shared libraries.
21613
21614 Duplicate instances of a template can be avoided by defining an explicit
21615 instantiation in one object file, and preventing the compiler from doing
21616 implicit instantiations in any other object files by using an explicit
21617 instantiation declaration, using the @code{extern template} syntax:
21618
21619 @smallexample
21620 extern template int max (int, int);
21621 @end smallexample
21622
21623 This syntax is defined in the C++ 2011 standard, but has been supported by
21624 G++ and other compilers since well before 2011.
21625
21626 Explicit instantiations can be used for the largest or most frequently
21627 duplicated instances, without having to know exactly which other instances
21628 are used in the rest of the program. You can scatter the explicit
21629 instantiations throughout your program, perhaps putting them in the
21630 translation units where the instances are used or the translation units
21631 that define the templates themselves; you can put all of the explicit
21632 instantiations you need into one big file; or you can create small files
21633 like
21634
21635 @smallexample
21636 #include "Foo.h"
21637 #include "Foo.cc"
21638
21639 template class Foo<int>;
21640 template ostream& operator <<
21641 (ostream&, const Foo<int>&);
21642 @end smallexample
21643
21644 @noindent
21645 for each of the instances you need, and create a template instantiation
21646 library from those.
21647
21648 This is the simplest option, but also offers flexibility and
21649 fine-grained control when necessary. It is also the most portable
21650 alternative and programs using this approach will work with most modern
21651 compilers.
21652
21653 @item
21654 @opindex frepo
21655 Compile your template-using code with @option{-frepo}. The compiler
21656 generates files with the extension @samp{.rpo} listing all of the
21657 template instantiations used in the corresponding object files that
21658 could be instantiated there; the link wrapper, @samp{collect2},
21659 then updates the @samp{.rpo} files to tell the compiler where to place
21660 those instantiations and rebuild any affected object files. The
21661 link-time overhead is negligible after the first pass, as the compiler
21662 continues to place the instantiations in the same files.
21663
21664 This can be a suitable option for application code written for the Borland
21665 model, as it usually just works. Code written for the Cfront model
21666 needs to be modified so that the template definitions are available at
21667 one or more points of instantiation; usually this is as simple as adding
21668 @code{#include <tmethods.cc>} to the end of each template header.
21669
21670 For library code, if you want the library to provide all of the template
21671 instantiations it needs, just try to link all of its object files
21672 together; the link will fail, but cause the instantiations to be
21673 generated as a side effect. Be warned, however, that this may cause
21674 conflicts if multiple libraries try to provide the same instantiations.
21675 For greater control, use explicit instantiation as described in the next
21676 option.
21677
21678 @item
21679 @opindex fno-implicit-templates
21680 Compile your code with @option{-fno-implicit-templates} to disable the
21681 implicit generation of template instances, and explicitly instantiate
21682 all the ones you use. This approach requires more knowledge of exactly
21683 which instances you need than do the others, but it's less
21684 mysterious and allows greater control if you want to ensure that only
21685 the intended instances are used.
21686
21687 If you are using Cfront-model code, you can probably get away with not
21688 using @option{-fno-implicit-templates} when compiling files that don't
21689 @samp{#include} the member template definitions.
21690
21691 If you use one big file to do the instantiations, you may want to
21692 compile it without @option{-fno-implicit-templates} so you get all of the
21693 instances required by your explicit instantiations (but not by any
21694 other files) without having to specify them as well.
21695
21696 In addition to forward declaration of explicit instantiations
21697 (with @code{extern}), G++ has extended the template instantiation
21698 syntax to support instantiation of the compiler support data for a
21699 template class (i.e.@: the vtable) without instantiating any of its
21700 members (with @code{inline}), and instantiation of only the static data
21701 members of a template class, without the support data or member
21702 functions (with @code{static}):
21703
21704 @smallexample
21705 inline template class Foo<int>;
21706 static template class Foo<int>;
21707 @end smallexample
21708 @end enumerate
21709
21710 @node Bound member functions
21711 @section Extracting the Function Pointer from a Bound Pointer to Member Function
21712 @cindex pmf
21713 @cindex pointer to member function
21714 @cindex bound pointer to member function
21715
21716 In C++, pointer to member functions (PMFs) are implemented using a wide
21717 pointer of sorts to handle all the possible call mechanisms; the PMF
21718 needs to store information about how to adjust the @samp{this} pointer,
21719 and if the function pointed to is virtual, where to find the vtable, and
21720 where in the vtable to look for the member function. If you are using
21721 PMFs in an inner loop, you should really reconsider that decision. If
21722 that is not an option, you can extract the pointer to the function that
21723 would be called for a given object/PMF pair and call it directly inside
21724 the inner loop, to save a bit of time.
21725
21726 Note that you still pay the penalty for the call through a
21727 function pointer; on most modern architectures, such a call defeats the
21728 branch prediction features of the CPU@. This is also true of normal
21729 virtual function calls.
21730
21731 The syntax for this extension is
21732
21733 @smallexample
21734 extern A a;
21735 extern int (A::*fp)();
21736 typedef int (*fptr)(A *);
21737
21738 fptr p = (fptr)(a.*fp);
21739 @end smallexample
21740
21741 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
21742 no object is needed to obtain the address of the function. They can be
21743 converted to function pointers directly:
21744
21745 @smallexample
21746 fptr p1 = (fptr)(&A::foo);
21747 @end smallexample
21748
21749 @opindex Wno-pmf-conversions
21750 You must specify @option{-Wno-pmf-conversions} to use this extension.
21751
21752 @node C++ Attributes
21753 @section C++-Specific Variable, Function, and Type Attributes
21754
21755 Some attributes only make sense for C++ programs.
21756
21757 @table @code
21758 @item abi_tag ("@var{tag}", ...)
21759 @cindex @code{abi_tag} function attribute
21760 @cindex @code{abi_tag} variable attribute
21761 @cindex @code{abi_tag} type attribute
21762 The @code{abi_tag} attribute can be applied to a function, variable, or class
21763 declaration. It modifies the mangled name of the entity to
21764 incorporate the tag name, in order to distinguish the function or
21765 class from an earlier version with a different ABI; perhaps the class
21766 has changed size, or the function has a different return type that is
21767 not encoded in the mangled name.
21768
21769 The attribute can also be applied to an inline namespace, but does not
21770 affect the mangled name of the namespace; in this case it is only used
21771 for @option{-Wabi-tag} warnings and automatic tagging of functions and
21772 variables. Tagging inline namespaces is generally preferable to
21773 tagging individual declarations, but the latter is sometimes
21774 necessary, such as when only certain members of a class need to be
21775 tagged.
21776
21777 The argument can be a list of strings of arbitrary length. The
21778 strings are sorted on output, so the order of the list is
21779 unimportant.
21780
21781 A redeclaration of an entity must not add new ABI tags,
21782 since doing so would change the mangled name.
21783
21784 The ABI tags apply to a name, so all instantiations and
21785 specializations of a template have the same tags. The attribute will
21786 be ignored if applied to an explicit specialization or instantiation.
21787
21788 The @option{-Wabi-tag} flag enables a warning about a class which does
21789 not have all the ABI tags used by its subobjects and virtual functions; for users with code
21790 that needs to coexist with an earlier ABI, using this option can help
21791 to find all affected types that need to be tagged.
21792
21793 When a type involving an ABI tag is used as the type of a variable or
21794 return type of a function where that tag is not already present in the
21795 signature of the function, the tag is automatically applied to the
21796 variable or function. @option{-Wabi-tag} also warns about this
21797 situation; this warning can be avoided by explicitly tagging the
21798 variable or function or moving it into a tagged inline namespace.
21799
21800 @item init_priority (@var{priority})
21801 @cindex @code{init_priority} variable attribute
21802
21803 In Standard C++, objects defined at namespace scope are guaranteed to be
21804 initialized in an order in strict accordance with that of their definitions
21805 @emph{in a given translation unit}. No guarantee is made for initializations
21806 across translation units. However, GNU C++ allows users to control the
21807 order of initialization of objects defined at namespace scope with the
21808 @code{init_priority} attribute by specifying a relative @var{priority},
21809 a constant integral expression currently bounded between 101 and 65535
21810 inclusive. Lower numbers indicate a higher priority.
21811
21812 In the following example, @code{A} would normally be created before
21813 @code{B}, but the @code{init_priority} attribute reverses that order:
21814
21815 @smallexample
21816 Some_Class A __attribute__ ((init_priority (2000)));
21817 Some_Class B __attribute__ ((init_priority (543)));
21818 @end smallexample
21819
21820 @noindent
21821 Note that the particular values of @var{priority} do not matter; only their
21822 relative ordering.
21823
21824 @item java_interface
21825 @cindex @code{java_interface} type attribute
21826
21827 This type attribute informs C++ that the class is a Java interface. It may
21828 only be applied to classes declared within an @code{extern "Java"} block.
21829 Calls to methods declared in this interface are dispatched using GCJ's
21830 interface table mechanism, instead of regular virtual table dispatch.
21831
21832 @item warn_unused
21833 @cindex @code{warn_unused} type attribute
21834
21835 For C++ types with non-trivial constructors and/or destructors it is
21836 impossible for the compiler to determine whether a variable of this
21837 type is truly unused if it is not referenced. This type attribute
21838 informs the compiler that variables of this type should be warned
21839 about if they appear to be unused, just like variables of fundamental
21840 types.
21841
21842 This attribute is appropriate for types which just represent a value,
21843 such as @code{std::string}; it is not appropriate for types which
21844 control a resource, such as @code{std::lock_guard}.
21845
21846 This attribute is also accepted in C, but it is unnecessary because C
21847 does not have constructors or destructors.
21848
21849 @end table
21850
21851 See also @ref{Namespace Association}.
21852
21853 @node Function Multiversioning
21854 @section Function Multiversioning
21855 @cindex function versions
21856
21857 With the GNU C++ front end, for x86 targets, you may specify multiple
21858 versions of a function, where each function is specialized for a
21859 specific target feature. At runtime, the appropriate version of the
21860 function is automatically executed depending on the characteristics of
21861 the execution platform. Here is an example.
21862
21863 @smallexample
21864 __attribute__ ((target ("default")))
21865 int foo ()
21866 @{
21867 // The default version of foo.
21868 return 0;
21869 @}
21870
21871 __attribute__ ((target ("sse4.2")))
21872 int foo ()
21873 @{
21874 // foo version for SSE4.2
21875 return 1;
21876 @}
21877
21878 __attribute__ ((target ("arch=atom")))
21879 int foo ()
21880 @{
21881 // foo version for the Intel ATOM processor
21882 return 2;
21883 @}
21884
21885 __attribute__ ((target ("arch=amdfam10")))
21886 int foo ()
21887 @{
21888 // foo version for the AMD Family 0x10 processors.
21889 return 3;
21890 @}
21891
21892 int main ()
21893 @{
21894 int (*p)() = &foo;
21895 assert ((*p) () == foo ());
21896 return 0;
21897 @}
21898 @end smallexample
21899
21900 In the above example, four versions of function foo are created. The
21901 first version of foo with the target attribute "default" is the default
21902 version. This version gets executed when no other target specific
21903 version qualifies for execution on a particular platform. A new version
21904 of foo is created by using the same function signature but with a
21905 different target string. Function foo is called or a pointer to it is
21906 taken just like a regular function. GCC takes care of doing the
21907 dispatching to call the right version at runtime. Refer to the
21908 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
21909 Function Multiversioning} for more details.
21910
21911 @node Namespace Association
21912 @section Namespace Association
21913
21914 @strong{Caution:} The semantics of this extension are equivalent
21915 to C++ 2011 inline namespaces. Users should use inline namespaces
21916 instead as this extension will be removed in future versions of G++.
21917
21918 A using-directive with @code{__attribute ((strong))} is stronger
21919 than a normal using-directive in two ways:
21920
21921 @itemize @bullet
21922 @item
21923 Templates from the used namespace can be specialized and explicitly
21924 instantiated as though they were members of the using namespace.
21925
21926 @item
21927 The using namespace is considered an associated namespace of all
21928 templates in the used namespace for purposes of argument-dependent
21929 name lookup.
21930 @end itemize
21931
21932 The used namespace must be nested within the using namespace so that
21933 normal unqualified lookup works properly.
21934
21935 This is useful for composing a namespace transparently from
21936 implementation namespaces. For example:
21937
21938 @smallexample
21939 namespace std @{
21940 namespace debug @{
21941 template <class T> struct A @{ @};
21942 @}
21943 using namespace debug __attribute ((__strong__));
21944 template <> struct A<int> @{ @}; // @r{OK to specialize}
21945
21946 template <class T> void f (A<T>);
21947 @}
21948
21949 int main()
21950 @{
21951 f (std::A<float>()); // @r{lookup finds} std::f
21952 f (std::A<int>());
21953 @}
21954 @end smallexample
21955
21956 @node Type Traits
21957 @section Type Traits
21958
21959 The C++ front end implements syntactic extensions that allow
21960 compile-time determination of
21961 various characteristics of a type (or of a
21962 pair of types).
21963
21964 @table @code
21965 @item __has_nothrow_assign (type)
21966 If @code{type} is const qualified or is a reference type then the trait is
21967 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
21968 is true, else if @code{type} is a cv class or union type with copy assignment
21969 operators that are known not to throw an exception then the trait is true,
21970 else it is false. Requires: @code{type} shall be a complete type,
21971 (possibly cv-qualified) @code{void}, or an array of unknown bound.
21972
21973 @item __has_nothrow_copy (type)
21974 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
21975 @code{type} is a cv class or union type with copy constructors that
21976 are known not to throw an exception then the trait is true, else it is false.
21977 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
21978 @code{void}, or an array of unknown bound.
21979
21980 @item __has_nothrow_constructor (type)
21981 If @code{__has_trivial_constructor (type)} is true then the trait is
21982 true, else if @code{type} is a cv class or union type (or array
21983 thereof) with a default constructor that is known not to throw an
21984 exception then the trait is true, else it is false. Requires:
21985 @code{type} shall be a complete type, (possibly cv-qualified)
21986 @code{void}, or an array of unknown bound.
21987
21988 @item __has_trivial_assign (type)
21989 If @code{type} is const qualified or is a reference type then the trait is
21990 false. Otherwise if @code{__is_pod (type)} is true then the trait is
21991 true, else if @code{type} is a cv class or union type with a trivial
21992 copy assignment ([class.copy]) then the trait is true, else it is
21993 false. Requires: @code{type} shall be a complete type, (possibly
21994 cv-qualified) @code{void}, or an array of unknown bound.
21995
21996 @item __has_trivial_copy (type)
21997 If @code{__is_pod (type)} is true or @code{type} is a reference type
21998 then the trait is true, else if @code{type} is a cv class or union type
21999 with a trivial copy constructor ([class.copy]) then the trait
22000 is true, else it is false. Requires: @code{type} shall be a complete
22001 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22002
22003 @item __has_trivial_constructor (type)
22004 If @code{__is_pod (type)} is true then the trait is true, else if
22005 @code{type} is a cv class or union type (or array thereof) with a
22006 trivial default constructor ([class.ctor]) then the trait is true,
22007 else it is false. Requires: @code{type} shall be a complete
22008 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22009
22010 @item __has_trivial_destructor (type)
22011 If @code{__is_pod (type)} is true or @code{type} is a reference type then
22012 the trait is true, else if @code{type} is a cv class or union type (or
22013 array thereof) with a trivial destructor ([class.dtor]) then the trait
22014 is true, else it is false. Requires: @code{type} shall be a complete
22015 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22016
22017 @item __has_virtual_destructor (type)
22018 If @code{type} is a class type with a virtual destructor
22019 ([class.dtor]) then the trait is true, else it is false. Requires:
22020 @code{type} shall be a complete type, (possibly cv-qualified)
22021 @code{void}, or an array of unknown bound.
22022
22023 @item __is_abstract (type)
22024 If @code{type} is an abstract class ([class.abstract]) then the trait
22025 is true, else it is false. Requires: @code{type} shall be a complete
22026 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22027
22028 @item __is_base_of (base_type, derived_type)
22029 If @code{base_type} is a base class of @code{derived_type}
22030 ([class.derived]) then the trait is true, otherwise it is false.
22031 Top-level cv qualifications of @code{base_type} and
22032 @code{derived_type} are ignored. For the purposes of this trait, a
22033 class type is considered is own base. Requires: if @code{__is_class
22034 (base_type)} and @code{__is_class (derived_type)} are true and
22035 @code{base_type} and @code{derived_type} are not the same type
22036 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
22037 type. A diagnostic is produced if this requirement is not met.
22038
22039 @item __is_class (type)
22040 If @code{type} is a cv class type, and not a union type
22041 ([basic.compound]) the trait is true, else it is false.
22042
22043 @item __is_empty (type)
22044 If @code{__is_class (type)} is false then the trait is false.
22045 Otherwise @code{type} is considered empty if and only if: @code{type}
22046 has no non-static data members, or all non-static data members, if
22047 any, are bit-fields of length 0, and @code{type} has no virtual
22048 members, and @code{type} has no virtual base classes, and @code{type}
22049 has no base classes @code{base_type} for which
22050 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
22051 be a complete type, (possibly cv-qualified) @code{void}, or an array
22052 of unknown bound.
22053
22054 @item __is_enum (type)
22055 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
22056 true, else it is false.
22057
22058 @item __is_literal_type (type)
22059 If @code{type} is a literal type ([basic.types]) the trait is
22060 true, else it is false. Requires: @code{type} shall be a complete type,
22061 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22062
22063 @item __is_pod (type)
22064 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
22065 else it is false. Requires: @code{type} shall be a complete type,
22066 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22067
22068 @item __is_polymorphic (type)
22069 If @code{type} is a polymorphic class ([class.virtual]) then the trait
22070 is true, else it is false. Requires: @code{type} shall be a complete
22071 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22072
22073 @item __is_standard_layout (type)
22074 If @code{type} is a standard-layout type ([basic.types]) the trait is
22075 true, else it is false. Requires: @code{type} shall be a complete
22076 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22077
22078 @item __is_trivial (type)
22079 If @code{type} is a trivial type ([basic.types]) the trait is
22080 true, else it is false. Requires: @code{type} shall be a complete
22081 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22082
22083 @item __is_union (type)
22084 If @code{type} is a cv union type ([basic.compound]) the trait is
22085 true, else it is false.
22086
22087 @item __underlying_type (type)
22088 The underlying type of @code{type}. Requires: @code{type} shall be
22089 an enumeration type ([dcl.enum]).
22090
22091 @end table
22092
22093
22094 @node C++ Concepts
22095 @section C++ Concepts
22096
22097 C++ concepts provide much-improved support for generic programming. In
22098 particular, they allow the specification of constraints on template arguments.
22099 The constraints are used to extend the usual overloading and partial
22100 specialization capabilities of the language, allowing generic data structures
22101 and algorithms to be ``refined'' based on their properties rather than their
22102 type names.
22103
22104 The following keywords are reserved for concepts.
22105
22106 @table @code
22107 @item assumes
22108 States an expression as an assumption, and if possible, verifies that the
22109 assumption is valid. For example, @code{assume(n > 0)}.
22110
22111 @item axiom
22112 Introduces an axiom definition. Axioms introduce requirements on values.
22113
22114 @item forall
22115 Introduces a universally quantified object in an axiom. For example,
22116 @code{forall (int n) n + 0 == n}).
22117
22118 @item concept
22119 Introduces a concept definition. Concepts are sets of syntactic and semantic
22120 requirements on types and their values.
22121
22122 @item requires
22123 Introduces constraints on template arguments or requirements for a member
22124 function of a class template.
22125
22126 @end table
22127
22128 The front end also exposes a number of internal mechanism that can be used
22129 to simplify the writing of type traits. Note that some of these traits are
22130 likely to be removed in the future.
22131
22132 @table @code
22133 @item __is_same (type1, type2)
22134 A binary type trait: true whenever the type arguments are the same.
22135
22136 @end table
22137
22138
22139 @node Java Exceptions
22140 @section Java Exceptions
22141
22142 The Java language uses a slightly different exception handling model
22143 from C++. Normally, GNU C++ automatically detects when you are
22144 writing C++ code that uses Java exceptions, and handle them
22145 appropriately. However, if C++ code only needs to execute destructors
22146 when Java exceptions are thrown through it, GCC guesses incorrectly.
22147 Sample problematic code is:
22148
22149 @smallexample
22150 struct S @{ ~S(); @};
22151 extern void bar(); // @r{is written in Java, and may throw exceptions}
22152 void foo()
22153 @{
22154 S s;
22155 bar();
22156 @}
22157 @end smallexample
22158
22159 @noindent
22160 The usual effect of an incorrect guess is a link failure, complaining of
22161 a missing routine called @samp{__gxx_personality_v0}.
22162
22163 You can inform the compiler that Java exceptions are to be used in a
22164 translation unit, irrespective of what it might think, by writing
22165 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
22166 @samp{#pragma} must appear before any functions that throw or catch
22167 exceptions, or run destructors when exceptions are thrown through them.
22168
22169 You cannot mix Java and C++ exceptions in the same translation unit. It
22170 is believed to be safe to throw a C++ exception from one file through
22171 another file compiled for the Java exception model, or vice versa, but
22172 there may be bugs in this area.
22173
22174 @node Deprecated Features
22175 @section Deprecated Features
22176
22177 In the past, the GNU C++ compiler was extended to experiment with new
22178 features, at a time when the C++ language was still evolving. Now that
22179 the C++ standard is complete, some of those features are superseded by
22180 superior alternatives. Using the old features might cause a warning in
22181 some cases that the feature will be dropped in the future. In other
22182 cases, the feature might be gone already.
22183
22184 While the list below is not exhaustive, it documents some of the options
22185 that are now deprecated:
22186
22187 @table @code
22188 @item -fexternal-templates
22189 @itemx -falt-external-templates
22190 These are two of the many ways for G++ to implement template
22191 instantiation. @xref{Template Instantiation}. The C++ standard clearly
22192 defines how template definitions have to be organized across
22193 implementation units. G++ has an implicit instantiation mechanism that
22194 should work just fine for standard-conforming code.
22195
22196 @item -fstrict-prototype
22197 @itemx -fno-strict-prototype
22198 Previously it was possible to use an empty prototype parameter list to
22199 indicate an unspecified number of parameters (like C), rather than no
22200 parameters, as C++ demands. This feature has been removed, except where
22201 it is required for backwards compatibility. @xref{Backwards Compatibility}.
22202 @end table
22203
22204 G++ allows a virtual function returning @samp{void *} to be overridden
22205 by one returning a different pointer type. This extension to the
22206 covariant return type rules is now deprecated and will be removed from a
22207 future version.
22208
22209 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
22210 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
22211 and are now removed from G++. Code using these operators should be
22212 modified to use @code{std::min} and @code{std::max} instead.
22213
22214 The named return value extension has been deprecated, and is now
22215 removed from G++.
22216
22217 The use of initializer lists with new expressions has been deprecated,
22218 and is now removed from G++.
22219
22220 Floating and complex non-type template parameters have been deprecated,
22221 and are now removed from G++.
22222
22223 The implicit typename extension has been deprecated and is now
22224 removed from G++.
22225
22226 The use of default arguments in function pointers, function typedefs
22227 and other places where they are not permitted by the standard is
22228 deprecated and will be removed from a future version of G++.
22229
22230 G++ allows floating-point literals to appear in integral constant expressions,
22231 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
22232 This extension is deprecated and will be removed from a future version.
22233
22234 G++ allows static data members of const floating-point type to be declared
22235 with an initializer in a class definition. The standard only allows
22236 initializers for static members of const integral types and const
22237 enumeration types so this extension has been deprecated and will be removed
22238 from a future version.
22239
22240 @node Backwards Compatibility
22241 @section Backwards Compatibility
22242 @cindex Backwards Compatibility
22243 @cindex ARM [Annotated C++ Reference Manual]
22244
22245 Now that there is a definitive ISO standard C++, G++ has a specification
22246 to adhere to. The C++ language evolved over time, and features that
22247 used to be acceptable in previous drafts of the standard, such as the ARM
22248 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
22249 compilation of C++ written to such drafts, G++ contains some backwards
22250 compatibilities. @emph{All such backwards compatibility features are
22251 liable to disappear in future versions of G++.} They should be considered
22252 deprecated. @xref{Deprecated Features}.
22253
22254 @table @code
22255 @item For scope
22256 If a variable is declared at for scope, it used to remain in scope until
22257 the end of the scope that contained the for statement (rather than just
22258 within the for scope). G++ retains this, but issues a warning, if such a
22259 variable is accessed outside the for scope.
22260
22261 @item Implicit C language
22262 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
22263 scope to set the language. On such systems, all header files are
22264 implicitly scoped inside a C language scope. Also, an empty prototype
22265 @code{()} is treated as an unspecified number of arguments, rather
22266 than no arguments, as C++ demands.
22267 @end table
22268
22269 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
22270 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr