]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/extend.texi
Add new nds32 port, including machine description, libgcc, and documentation.
[thirdparty/gcc.git] / gcc / doc / extend.texi
1 @c Copyright (C) 1988-2013 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 * Initializers:: Non-constant initializers.
50 * Compound Literals:: Compound literals give structures, unions
51 or arrays as values.
52 * Designated Inits:: Labeling elements of initializers.
53 * Case Ranges:: `case 1 ... 9' and such.
54 * Cast to Union:: Casting to union type from any member of the union.
55 * Mixed Declarations:: Mixing declarations and code.
56 * Function Attributes:: Declaring that functions have no side effects,
57 or that they can never return.
58 * Attribute Syntax:: Formal syntax for attributes.
59 * Function Prototypes:: Prototype declarations and old-style definitions.
60 * C++ Comments:: C++ comments are recognized.
61 * Dollar Signs:: Dollar sign is allowed in identifiers.
62 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
63 * Variable Attributes:: Specifying attributes of variables.
64 * Type Attributes:: Specifying attributes of types.
65 * Alignment:: Inquiring about the alignment of a type or variable.
66 * Inline:: Defining inline functions (as fast as macros).
67 * Volatiles:: What constitutes an access to a volatile object.
68 * Extended Asm:: Assembler instructions with C expressions as operands.
69 (With them you can define ``built-in'' functions.)
70 * Constraints:: Constraints for asm operands
71 * Asm Labels:: Specifying the assembler name to use for a C symbol.
72 * Explicit Reg Vars:: Defining variables residing in specified registers.
73 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums:: @code{enum foo;}, with details to follow.
75 * Function Names:: Printable strings which are the name of the current
76 function.
77 * Return Address:: Getting the return or frame address of a function.
78 * Vector Extensions:: Using vector instructions through built-in functions.
79 * Offsetof:: Special syntax for implementing @code{offsetof}.
80 * __sync Builtins:: Legacy built-in functions for atomic memory access.
81 * __atomic Builtins:: Atomic built-in functions with memory model.
82 * x86 specific memory model extensions for transactional memory:: x86 memory models.
83 * Object Size Checking:: Built-in functions for limited buffer overflow
84 checking.
85 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
86 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
87 * Other Builtins:: Other built-in functions.
88 * Target Builtins:: Built-in functions specific to particular targets.
89 * Target Format Checks:: Format checks specific to particular targets.
90 * Pragmas:: Pragmas accepted by GCC.
91 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
92 * Thread-Local:: Per-thread variables.
93 * Binary constants:: Binary constants using the @samp{0b} prefix.
94 @end menu
95
96 @node Statement Exprs
97 @section Statements and Declarations in Expressions
98 @cindex statements inside expressions
99 @cindex declarations inside expressions
100 @cindex expressions containing statements
101 @cindex macros, statements in expressions
102
103 @c the above section title wrapped and causes an underfull hbox.. i
104 @c changed it from "within" to "in". --mew 4feb93
105 A compound statement enclosed in parentheses may appear as an expression
106 in GNU C@. This allows you to use loops, switches, and local variables
107 within an expression.
108
109 Recall that a compound statement is a sequence of statements surrounded
110 by braces; in this construct, parentheses go around the braces. For
111 example:
112
113 @smallexample
114 (@{ int y = foo (); int z;
115 if (y > 0) z = y;
116 else z = - y;
117 z; @})
118 @end smallexample
119
120 @noindent
121 is a valid (though slightly more complex than necessary) expression
122 for the absolute value of @code{foo ()}.
123
124 The last thing in the compound statement should be an expression
125 followed by a semicolon; the value of this subexpression serves as the
126 value of the entire construct. (If you use some other kind of statement
127 last within the braces, the construct has type @code{void}, and thus
128 effectively no value.)
129
130 This feature is especially useful in making macro definitions ``safe'' (so
131 that they evaluate each operand exactly once). For example, the
132 ``maximum'' function is commonly defined as a macro in standard C as
133 follows:
134
135 @smallexample
136 #define max(a,b) ((a) > (b) ? (a) : (b))
137 @end smallexample
138
139 @noindent
140 @cindex side effects, macro argument
141 But this definition computes either @var{a} or @var{b} twice, with bad
142 results if the operand has side effects. In GNU C, if you know the
143 type of the operands (here taken as @code{int}), you can define
144 the macro safely as follows:
145
146 @smallexample
147 #define maxint(a,b) \
148 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
149 @end smallexample
150
151 Embedded statements are not allowed in constant expressions, such as
152 the value of an enumeration constant, the width of a bit-field, or
153 the initial value of a static variable.
154
155 If you don't know the type of the operand, you can still do this, but you
156 must use @code{typeof} (@pxref{Typeof}).
157
158 In G++, the result value of a statement expression undergoes array and
159 function pointer decay, and is returned by value to the enclosing
160 expression. For instance, if @code{A} is a class, then
161
162 @smallexample
163 A a;
164
165 (@{a;@}).Foo ()
166 @end smallexample
167
168 @noindent
169 constructs a temporary @code{A} object to hold the result of the
170 statement expression, and that is used to invoke @code{Foo}.
171 Therefore the @code{this} pointer observed by @code{Foo} is not the
172 address of @code{a}.
173
174 In a statement expression, any temporaries created within a statement
175 are destroyed at that statement's end. This makes statement
176 expressions inside macros slightly different from function calls. In
177 the latter case temporaries introduced during argument evaluation are
178 destroyed at the end of the statement that includes the function
179 call. In the statement expression case they are destroyed during
180 the statement expression. For instance,
181
182 @smallexample
183 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
184 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
185
186 void foo ()
187 @{
188 macro (X ());
189 function (X ());
190 @}
191 @end smallexample
192
193 @noindent
194 has different places where temporaries are destroyed. For the
195 @code{macro} case, the temporary @code{X} is destroyed just after
196 the initialization of @code{b}. In the @code{function} case that
197 temporary is destroyed when the function returns.
198
199 These considerations mean that it is probably a bad idea to use
200 statement expressions of this form in header files that are designed to
201 work with C++. (Note that some versions of the GNU C Library contained
202 header files using statement expressions that lead to precisely this
203 bug.)
204
205 Jumping into a statement expression with @code{goto} or using a
206 @code{switch} statement outside the statement expression with a
207 @code{case} or @code{default} label inside the statement expression is
208 not permitted. Jumping into a statement expression with a computed
209 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
210 Jumping out of a statement expression is permitted, but if the
211 statement expression is part of a larger expression then it is
212 unspecified which other subexpressions of that expression have been
213 evaluated except where the language definition requires certain
214 subexpressions to be evaluated before or after the statement
215 expression. In any case, as with a function call, the evaluation of a
216 statement expression is not interleaved with the evaluation of other
217 parts of the containing expression. For example,
218
219 @smallexample
220 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
221 @end smallexample
222
223 @noindent
224 calls @code{foo} and @code{bar1} and does not call @code{baz} but
225 may or may not call @code{bar2}. If @code{bar2} is called, it is
226 called after @code{foo} and before @code{bar1}.
227
228 @node Local Labels
229 @section Locally Declared Labels
230 @cindex local labels
231 @cindex macros, local labels
232
233 GCC allows you to declare @dfn{local labels} in any nested block
234 scope. A local label is just like an ordinary label, but you can
235 only reference it (with a @code{goto} statement, or by taking its
236 address) within the block in which it is declared.
237
238 A local label declaration looks like this:
239
240 @smallexample
241 __label__ @var{label};
242 @end smallexample
243
244 @noindent
245 or
246
247 @smallexample
248 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
249 @end smallexample
250
251 Local label declarations must come at the beginning of the block,
252 before any ordinary declarations or statements.
253
254 The label declaration defines the label @emph{name}, but does not define
255 the label itself. You must do this in the usual way, with
256 @code{@var{label}:}, within the statements of the statement expression.
257
258 The local label feature is useful for complex macros. If a macro
259 contains nested loops, a @code{goto} can be useful for breaking out of
260 them. However, an ordinary label whose scope is the whole function
261 cannot be used: if the macro can be expanded several times in one
262 function, the label is multiply defined in that function. A
263 local label avoids this problem. For example:
264
265 @smallexample
266 #define SEARCH(value, array, target) \
267 do @{ \
268 __label__ found; \
269 typeof (target) _SEARCH_target = (target); \
270 typeof (*(array)) *_SEARCH_array = (array); \
271 int i, j; \
272 int value; \
273 for (i = 0; i < max; i++) \
274 for (j = 0; j < max; j++) \
275 if (_SEARCH_array[i][j] == _SEARCH_target) \
276 @{ (value) = i; goto found; @} \
277 (value) = -1; \
278 found:; \
279 @} while (0)
280 @end smallexample
281
282 This could also be written using a statement expression:
283
284 @smallexample
285 #define SEARCH(array, target) \
286 (@{ \
287 __label__ found; \
288 typeof (target) _SEARCH_target = (target); \
289 typeof (*(array)) *_SEARCH_array = (array); \
290 int i, j; \
291 int value; \
292 for (i = 0; i < max; i++) \
293 for (j = 0; j < max; j++) \
294 if (_SEARCH_array[i][j] == _SEARCH_target) \
295 @{ value = i; goto found; @} \
296 value = -1; \
297 found: \
298 value; \
299 @})
300 @end smallexample
301
302 Local label declarations also make the labels they declare visible to
303 nested functions, if there are any. @xref{Nested Functions}, for details.
304
305 @node Labels as Values
306 @section Labels as Values
307 @cindex labels as values
308 @cindex computed gotos
309 @cindex goto with computed label
310 @cindex address of a label
311
312 You can get the address of a label defined in the current function
313 (or a containing function) with the unary operator @samp{&&}. The
314 value has type @code{void *}. This value is a constant and can be used
315 wherever a constant of that type is valid. For example:
316
317 @smallexample
318 void *ptr;
319 /* @r{@dots{}} */
320 ptr = &&foo;
321 @end smallexample
322
323 To use these values, you need to be able to jump to one. This is done
324 with the computed goto statement@footnote{The analogous feature in
325 Fortran is called an assigned goto, but that name seems inappropriate in
326 C, where one can do more than simply store label addresses in label
327 variables.}, @code{goto *@var{exp};}. For example,
328
329 @smallexample
330 goto *ptr;
331 @end smallexample
332
333 @noindent
334 Any expression of type @code{void *} is allowed.
335
336 One way of using these constants is in initializing a static array that
337 serves as a jump table:
338
339 @smallexample
340 static void *array[] = @{ &&foo, &&bar, &&hack @};
341 @end smallexample
342
343 @noindent
344 Then you can select a label with indexing, like this:
345
346 @smallexample
347 goto *array[i];
348 @end smallexample
349
350 @noindent
351 Note that this does not check whether the subscript is in bounds---array
352 indexing in C never does that.
353
354 Such an array of label values serves a purpose much like that of the
355 @code{switch} statement. The @code{switch} statement is cleaner, so
356 use that rather than an array unless the problem does not fit a
357 @code{switch} statement very well.
358
359 Another use of label values is in an interpreter for threaded code.
360 The labels within the interpreter function can be stored in the
361 threaded code for super-fast dispatching.
362
363 You may not use this mechanism to jump to code in a different function.
364 If you do that, totally unpredictable things happen. The best way to
365 avoid this is to store the label address only in automatic variables and
366 never pass it as an argument.
367
368 An alternate way to write the above example is
369
370 @smallexample
371 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
372 &&hack - &&foo @};
373 goto *(&&foo + array[i]);
374 @end smallexample
375
376 @noindent
377 This is more friendly to code living in shared libraries, as it reduces
378 the number of dynamic relocations that are needed, and by consequence,
379 allows the data to be read-only.
380
381 The @code{&&foo} expressions for the same label might have different
382 values if the containing function is inlined or cloned. If a program
383 relies on them being always the same,
384 @code{__attribute__((__noinline__,__noclone__))} should be used to
385 prevent inlining and cloning. If @code{&&foo} is used in a static
386 variable initializer, inlining and cloning is forbidden.
387
388 @node Nested Functions
389 @section Nested Functions
390 @cindex nested functions
391 @cindex downward funargs
392 @cindex thunks
393
394 A @dfn{nested function} is a function defined inside another function.
395 Nested functions are supported as an extension in GNU C, but are not
396 supported by GNU C++.
397
398 The nested function's name is local to the block where it is defined.
399 For example, here we define a nested function named @code{square}, and
400 call it twice:
401
402 @smallexample
403 @group
404 foo (double a, double b)
405 @{
406 double square (double z) @{ return z * z; @}
407
408 return square (a) + square (b);
409 @}
410 @end group
411 @end smallexample
412
413 The nested function can access all the variables of the containing
414 function that are visible at the point of its definition. This is
415 called @dfn{lexical scoping}. For example, here we show a nested
416 function which uses an inherited variable named @code{offset}:
417
418 @smallexample
419 @group
420 bar (int *array, int offset, int size)
421 @{
422 int access (int *array, int index)
423 @{ return array[index + offset]; @}
424 int i;
425 /* @r{@dots{}} */
426 for (i = 0; i < size; i++)
427 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
428 @}
429 @end group
430 @end smallexample
431
432 Nested function definitions are permitted within functions in the places
433 where variable definitions are allowed; that is, in any block, mixed
434 with the other declarations and statements in the block.
435
436 It is possible to call the nested function from outside the scope of its
437 name by storing its address or passing the address to another function:
438
439 @smallexample
440 hack (int *array, int size)
441 @{
442 void store (int index, int value)
443 @{ array[index] = value; @}
444
445 intermediate (store, size);
446 @}
447 @end smallexample
448
449 Here, the function @code{intermediate} receives the address of
450 @code{store} as an argument. If @code{intermediate} calls @code{store},
451 the arguments given to @code{store} are used to store into @code{array}.
452 But this technique works only so long as the containing function
453 (@code{hack}, in this example) does not exit.
454
455 If you try to call the nested function through its address after the
456 containing function exits, all hell breaks loose. If you try
457 to call it after a containing scope level exits, and if it refers
458 to some of the variables that are no longer in scope, you may be lucky,
459 but it's not wise to take the risk. If, however, the nested function
460 does not refer to anything that has gone out of scope, you should be
461 safe.
462
463 GCC implements taking the address of a nested function using a technique
464 called @dfn{trampolines}. This technique was described in
465 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
466 C++ Conference Proceedings, October 17-21, 1988).
467
468 A nested function can jump to a label inherited from a containing
469 function, provided the label is explicitly declared in the containing
470 function (@pxref{Local Labels}). Such a jump returns instantly to the
471 containing function, exiting the nested function that did the
472 @code{goto} and any intermediate functions as well. Here is an example:
473
474 @smallexample
475 @group
476 bar (int *array, int offset, int size)
477 @{
478 __label__ failure;
479 int access (int *array, int index)
480 @{
481 if (index > size)
482 goto failure;
483 return array[index + offset];
484 @}
485 int i;
486 /* @r{@dots{}} */
487 for (i = 0; i < size; i++)
488 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
489 /* @r{@dots{}} */
490 return 0;
491
492 /* @r{Control comes here from @code{access}
493 if it detects an error.} */
494 failure:
495 return -1;
496 @}
497 @end group
498 @end smallexample
499
500 A nested function always has no linkage. Declaring one with
501 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
502 before its definition, use @code{auto} (which is otherwise meaningless
503 for function declarations).
504
505 @smallexample
506 bar (int *array, int offset, int size)
507 @{
508 __label__ failure;
509 auto int access (int *, int);
510 /* @r{@dots{}} */
511 int access (int *array, int index)
512 @{
513 if (index > size)
514 goto failure;
515 return array[index + offset];
516 @}
517 /* @r{@dots{}} */
518 @}
519 @end smallexample
520
521 @node Constructing Calls
522 @section Constructing Function Calls
523 @cindex constructing calls
524 @cindex forwarding calls
525
526 Using the built-in functions described below, you can record
527 the arguments a function received, and call another function
528 with the same arguments, without knowing the number or types
529 of the arguments.
530
531 You can also record the return value of that function call,
532 and later return that value, without knowing what data type
533 the function tried to return (as long as your caller expects
534 that data type).
535
536 However, these built-in functions may interact badly with some
537 sophisticated features or other extensions of the language. It
538 is, therefore, not recommended to use them outside very simple
539 functions acting as mere forwarders for their arguments.
540
541 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
542 This built-in function returns a pointer to data
543 describing how to perform a call with the same arguments as are passed
544 to the current function.
545
546 The function saves the arg pointer register, structure value address,
547 and all registers that might be used to pass arguments to a function
548 into a block of memory allocated on the stack. Then it returns the
549 address of that block.
550 @end deftypefn
551
552 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
553 This built-in function invokes @var{function}
554 with a copy of the parameters described by @var{arguments}
555 and @var{size}.
556
557 The value of @var{arguments} should be the value returned by
558 @code{__builtin_apply_args}. The argument @var{size} specifies the size
559 of the stack argument data, in bytes.
560
561 This function returns a pointer to data describing
562 how to return whatever value is returned by @var{function}. The data
563 is saved in a block of memory allocated on the stack.
564
565 It is not always simple to compute the proper value for @var{size}. The
566 value is used by @code{__builtin_apply} to compute the amount of data
567 that should be pushed on the stack and copied from the incoming argument
568 area.
569 @end deftypefn
570
571 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
572 This built-in function returns the value described by @var{result} from
573 the containing function. You should specify, for @var{result}, a value
574 returned by @code{__builtin_apply}.
575 @end deftypefn
576
577 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
578 This built-in function represents all anonymous arguments of an inline
579 function. It can be used only in inline functions that are always
580 inlined, never compiled as a separate function, such as those using
581 @code{__attribute__ ((__always_inline__))} or
582 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
583 It must be only passed as last argument to some other function
584 with variable arguments. This is useful for writing small wrapper
585 inlines for variable argument functions, when using preprocessor
586 macros is undesirable. For example:
587 @smallexample
588 extern int myprintf (FILE *f, const char *format, ...);
589 extern inline __attribute__ ((__gnu_inline__)) int
590 myprintf (FILE *f, const char *format, ...)
591 @{
592 int r = fprintf (f, "myprintf: ");
593 if (r < 0)
594 return r;
595 int s = fprintf (f, format, __builtin_va_arg_pack ());
596 if (s < 0)
597 return s;
598 return r + s;
599 @}
600 @end smallexample
601 @end deftypefn
602
603 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
604 This built-in function returns the number of anonymous arguments of
605 an inline function. It can be used only in inline functions that
606 are always inlined, never compiled as a separate function, such
607 as those using @code{__attribute__ ((__always_inline__))} or
608 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
609 For example following does link- or run-time checking of open
610 arguments for optimized code:
611 @smallexample
612 #ifdef __OPTIMIZE__
613 extern inline __attribute__((__gnu_inline__)) int
614 myopen (const char *path, int oflag, ...)
615 @{
616 if (__builtin_va_arg_pack_len () > 1)
617 warn_open_too_many_arguments ();
618
619 if (__builtin_constant_p (oflag))
620 @{
621 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
622 @{
623 warn_open_missing_mode ();
624 return __open_2 (path, oflag);
625 @}
626 return open (path, oflag, __builtin_va_arg_pack ());
627 @}
628
629 if (__builtin_va_arg_pack_len () < 1)
630 return __open_2 (path, oflag);
631
632 return open (path, oflag, __builtin_va_arg_pack ());
633 @}
634 #endif
635 @end smallexample
636 @end deftypefn
637
638 @node Typeof
639 @section Referring to a Type with @code{typeof}
640 @findex typeof
641 @findex sizeof
642 @cindex macros, types of arguments
643
644 Another way to refer to the type of an expression is with @code{typeof}.
645 The syntax of using of this keyword looks like @code{sizeof}, but the
646 construct acts semantically like a type name defined with @code{typedef}.
647
648 There are two ways of writing the argument to @code{typeof}: with an
649 expression or with a type. Here is an example with an expression:
650
651 @smallexample
652 typeof (x[0](1))
653 @end smallexample
654
655 @noindent
656 This assumes that @code{x} is an array of pointers to functions;
657 the type described is that of the values of the functions.
658
659 Here is an example with a typename as the argument:
660
661 @smallexample
662 typeof (int *)
663 @end smallexample
664
665 @noindent
666 Here the type described is that of pointers to @code{int}.
667
668 If you are writing a header file that must work when included in ISO C
669 programs, write @code{__typeof__} instead of @code{typeof}.
670 @xref{Alternate Keywords}.
671
672 A @code{typeof} construct can be used anywhere a typedef name can be
673 used. For example, you can use it in a declaration, in a cast, or inside
674 of @code{sizeof} or @code{typeof}.
675
676 The operand of @code{typeof} is evaluated for its side effects if and
677 only if it is an expression of variably modified type or the name of
678 such a type.
679
680 @code{typeof} is often useful in conjunction with
681 statement expressions (@pxref{Statement Exprs}).
682 Here is how the two together can
683 be used to define a safe ``maximum'' macro which operates on any
684 arithmetic type and evaluates each of its arguments exactly once:
685
686 @smallexample
687 #define max(a,b) \
688 (@{ typeof (a) _a = (a); \
689 typeof (b) _b = (b); \
690 _a > _b ? _a : _b; @})
691 @end smallexample
692
693 @cindex underscores in variables in macros
694 @cindex @samp{_} in variables in macros
695 @cindex local variables in macros
696 @cindex variables, local, in macros
697 @cindex macros, local variables in
698
699 The reason for using names that start with underscores for the local
700 variables is to avoid conflicts with variable names that occur within the
701 expressions that are substituted for @code{a} and @code{b}. Eventually we
702 hope to design a new form of declaration syntax that allows you to declare
703 variables whose scopes start only after their initializers; this will be a
704 more reliable way to prevent such conflicts.
705
706 @noindent
707 Some more examples of the use of @code{typeof}:
708
709 @itemize @bullet
710 @item
711 This declares @code{y} with the type of what @code{x} points to.
712
713 @smallexample
714 typeof (*x) y;
715 @end smallexample
716
717 @item
718 This declares @code{y} as an array of such values.
719
720 @smallexample
721 typeof (*x) y[4];
722 @end smallexample
723
724 @item
725 This declares @code{y} as an array of pointers to characters:
726
727 @smallexample
728 typeof (typeof (char *)[4]) y;
729 @end smallexample
730
731 @noindent
732 It is equivalent to the following traditional C declaration:
733
734 @smallexample
735 char *y[4];
736 @end smallexample
737
738 To see the meaning of the declaration using @code{typeof}, and why it
739 might be a useful way to write, rewrite it with these macros:
740
741 @smallexample
742 #define pointer(T) typeof(T *)
743 #define array(T, N) typeof(T [N])
744 @end smallexample
745
746 @noindent
747 Now the declaration can be rewritten this way:
748
749 @smallexample
750 array (pointer (char), 4) y;
751 @end smallexample
752
753 @noindent
754 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
755 pointers to @code{char}.
756 @end itemize
757
758 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
759 a more limited extension that permitted one to write
760
761 @smallexample
762 typedef @var{T} = @var{expr};
763 @end smallexample
764
765 @noindent
766 with the effect of declaring @var{T} to have the type of the expression
767 @var{expr}. This extension does not work with GCC 3 (versions between
768 3.0 and 3.2 crash; 3.2.1 and later give an error). Code that
769 relies on it should be rewritten to use @code{typeof}:
770
771 @smallexample
772 typedef typeof(@var{expr}) @var{T};
773 @end smallexample
774
775 @noindent
776 This works with all versions of GCC@.
777
778 @node Conditionals
779 @section Conditionals with Omitted Operands
780 @cindex conditional expressions, extensions
781 @cindex omitted middle-operands
782 @cindex middle-operands, omitted
783 @cindex extensions, @code{?:}
784 @cindex @code{?:} extensions
785
786 The middle operand in a conditional expression may be omitted. Then
787 if the first operand is nonzero, its value is the value of the conditional
788 expression.
789
790 Therefore, the expression
791
792 @smallexample
793 x ? : y
794 @end smallexample
795
796 @noindent
797 has the value of @code{x} if that is nonzero; otherwise, the value of
798 @code{y}.
799
800 This example is perfectly equivalent to
801
802 @smallexample
803 x ? x : y
804 @end smallexample
805
806 @cindex side effect in @code{?:}
807 @cindex @code{?:} side effect
808 @noindent
809 In this simple case, the ability to omit the middle operand is not
810 especially useful. When it becomes useful is when the first operand does,
811 or may (if it is a macro argument), contain a side effect. Then repeating
812 the operand in the middle would perform the side effect twice. Omitting
813 the middle operand uses the value already computed without the undesirable
814 effects of recomputing it.
815
816 @node __int128
817 @section 128-bit integers
818 @cindex @code{__int128} data types
819
820 As an extension the integer scalar type @code{__int128} is supported for
821 targets which have an integer mode wide enough to hold 128 bits.
822 Simply write @code{__int128} for a signed 128-bit integer, or
823 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
824 support in GCC for expressing an integer constant of type @code{__int128}
825 for targets with @code{long long} integer less than 128 bits wide.
826
827 @node Long Long
828 @section Double-Word Integers
829 @cindex @code{long long} data types
830 @cindex double-word arithmetic
831 @cindex multiprecision arithmetic
832 @cindex @code{LL} integer suffix
833 @cindex @code{ULL} integer suffix
834
835 ISO C99 supports data types for integers that are at least 64 bits wide,
836 and as an extension GCC supports them in C90 mode and in C++.
837 Simply write @code{long long int} for a signed integer, or
838 @code{unsigned long long int} for an unsigned integer. To make an
839 integer constant of type @code{long long int}, add the suffix @samp{LL}
840 to the integer. To make an integer constant of type @code{unsigned long
841 long int}, add the suffix @samp{ULL} to the integer.
842
843 You can use these types in arithmetic like any other integer types.
844 Addition, subtraction, and bitwise boolean operations on these types
845 are open-coded on all types of machines. Multiplication is open-coded
846 if the machine supports a fullword-to-doubleword widening multiply
847 instruction. Division and shifts are open-coded only on machines that
848 provide special support. The operations that are not open-coded use
849 special library routines that come with GCC@.
850
851 There may be pitfalls when you use @code{long long} types for function
852 arguments without function prototypes. If a function
853 expects type @code{int} for its argument, and you pass a value of type
854 @code{long long int}, confusion results because the caller and the
855 subroutine disagree about the number of bytes for the argument.
856 Likewise, if the function expects @code{long long int} and you pass
857 @code{int}. The best way to avoid such problems is to use prototypes.
858
859 @node Complex
860 @section Complex Numbers
861 @cindex complex numbers
862 @cindex @code{_Complex} keyword
863 @cindex @code{__complex__} keyword
864
865 ISO C99 supports complex floating data types, and as an extension GCC
866 supports them in C90 mode and in C++. GCC also supports complex integer data
867 types which are not part of ISO C99. You can declare complex types
868 using the keyword @code{_Complex}. As an extension, the older GNU
869 keyword @code{__complex__} is also supported.
870
871 For example, @samp{_Complex double x;} declares @code{x} as a
872 variable whose real part and imaginary part are both of type
873 @code{double}. @samp{_Complex short int y;} declares @code{y} to
874 have real and imaginary parts of type @code{short int}; this is not
875 likely to be useful, but it shows that the set of complex types is
876 complete.
877
878 To write a constant with a complex data type, use the suffix @samp{i} or
879 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
880 has type @code{_Complex float} and @code{3i} has type
881 @code{_Complex int}. Such a constant always has a pure imaginary
882 value, but you can form any complex value you like by adding one to a
883 real constant. This is a GNU extension; if you have an ISO C99
884 conforming C library (such as the GNU C Library), and want to construct complex
885 constants of floating type, you should include @code{<complex.h>} and
886 use the macros @code{I} or @code{_Complex_I} instead.
887
888 @cindex @code{__real__} keyword
889 @cindex @code{__imag__} keyword
890 To extract the real part of a complex-valued expression @var{exp}, write
891 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
892 extract the imaginary part. This is a GNU extension; for values of
893 floating type, you should use the ISO C99 functions @code{crealf},
894 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
895 @code{cimagl}, declared in @code{<complex.h>} and also provided as
896 built-in functions by GCC@.
897
898 @cindex complex conjugation
899 The operator @samp{~} performs complex conjugation when used on a value
900 with a complex type. This is a GNU extension; for values of
901 floating type, you should use the ISO C99 functions @code{conjf},
902 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
903 provided as built-in functions by GCC@.
904
905 GCC can allocate complex automatic variables in a noncontiguous
906 fashion; it's even possible for the real part to be in a register while
907 the imaginary part is on the stack (or vice versa). Only the DWARF 2
908 debug info format can represent this, so use of DWARF 2 is recommended.
909 If you are using the stabs debug info format, GCC describes a noncontiguous
910 complex variable as if it were two separate variables of noncomplex type.
911 If the variable's actual name is @code{foo}, the two fictitious
912 variables are named @code{foo$real} and @code{foo$imag}. You can
913 examine and set these two fictitious variables with your debugger.
914
915 @node Floating Types
916 @section Additional Floating Types
917 @cindex additional floating types
918 @cindex @code{__float80} data type
919 @cindex @code{__float128} data type
920 @cindex @code{w} floating point suffix
921 @cindex @code{q} floating point suffix
922 @cindex @code{W} floating point suffix
923 @cindex @code{Q} floating point suffix
924
925 As an extension, GNU C supports additional floating
926 types, @code{__float80} and @code{__float128} to support 80-bit
927 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
928 Support for additional types includes the arithmetic operators:
929 add, subtract, multiply, divide; unary arithmetic operators;
930 relational operators; equality operators; and conversions to and from
931 integer and other floating types. Use a suffix @samp{w} or @samp{W}
932 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
933 for @code{_float128}. You can declare complex types using the
934 corresponding internal complex type, @code{XCmode} for @code{__float80}
935 type and @code{TCmode} for @code{__float128} type:
936
937 @smallexample
938 typedef _Complex float __attribute__((mode(TC))) _Complex128;
939 typedef _Complex float __attribute__((mode(XC))) _Complex80;
940 @end smallexample
941
942 Not all targets support additional floating-point types. @code{__float80}
943 and @code{__float128} types are supported on i386, x86_64 and IA-64 targets.
944 The @code{__float128} type is supported on hppa HP-UX targets.
945
946 @node Half-Precision
947 @section Half-Precision Floating Point
948 @cindex half-precision floating point
949 @cindex @code{__fp16} data type
950
951 On ARM targets, GCC supports half-precision (16-bit) floating point via
952 the @code{__fp16} type. You must enable this type explicitly
953 with the @option{-mfp16-format} command-line option in order to use it.
954
955 ARM supports two incompatible representations for half-precision
956 floating-point values. You must choose one of the representations and
957 use it consistently in your program.
958
959 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
960 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
961 There are 11 bits of significand precision, approximately 3
962 decimal digits.
963
964 Specifying @option{-mfp16-format=alternative} selects the ARM
965 alternative format. This representation is similar to the IEEE
966 format, but does not support infinities or NaNs. Instead, the range
967 of exponents is extended, so that this format can represent normalized
968 values in the range of @math{2^{-14}} to 131008.
969
970 The @code{__fp16} type is a storage format only. For purposes
971 of arithmetic and other operations, @code{__fp16} values in C or C++
972 expressions are automatically promoted to @code{float}. In addition,
973 you cannot declare a function with a return value or parameters
974 of type @code{__fp16}.
975
976 Note that conversions from @code{double} to @code{__fp16}
977 involve an intermediate conversion to @code{float}. Because
978 of rounding, this can sometimes produce a different result than a
979 direct conversion.
980
981 ARM provides hardware support for conversions between
982 @code{__fp16} and @code{float} values
983 as an extension to VFP and NEON (Advanced SIMD). GCC generates
984 code using these hardware instructions if you compile with
985 options to select an FPU that provides them;
986 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
987 in addition to the @option{-mfp16-format} option to select
988 a half-precision format.
989
990 Language-level support for the @code{__fp16} data type is
991 independent of whether GCC generates code using hardware floating-point
992 instructions. In cases where hardware support is not specified, GCC
993 implements conversions between @code{__fp16} and @code{float} values
994 as library calls.
995
996 @node Decimal Float
997 @section Decimal Floating Types
998 @cindex decimal floating types
999 @cindex @code{_Decimal32} data type
1000 @cindex @code{_Decimal64} data type
1001 @cindex @code{_Decimal128} data type
1002 @cindex @code{df} integer suffix
1003 @cindex @code{dd} integer suffix
1004 @cindex @code{dl} integer suffix
1005 @cindex @code{DF} integer suffix
1006 @cindex @code{DD} integer suffix
1007 @cindex @code{DL} integer suffix
1008
1009 As an extension, GNU C supports decimal floating types as
1010 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1011 floating types in GCC will evolve as the draft technical report changes.
1012 Calling conventions for any target might also change. Not all targets
1013 support decimal floating types.
1014
1015 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1016 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1017 @code{float}, @code{double}, and @code{long double} whose radix is not
1018 specified by the C standard but is usually two.
1019
1020 Support for decimal floating types includes the arithmetic operators
1021 add, subtract, multiply, divide; unary arithmetic operators;
1022 relational operators; equality operators; and conversions to and from
1023 integer and other floating types. Use a suffix @samp{df} or
1024 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1025 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1026 @code{_Decimal128}.
1027
1028 GCC support of decimal float as specified by the draft technical report
1029 is incomplete:
1030
1031 @itemize @bullet
1032 @item
1033 When the value of a decimal floating type cannot be represented in the
1034 integer type to which it is being converted, the result is undefined
1035 rather than the result value specified by the draft technical report.
1036
1037 @item
1038 GCC does not provide the C library functionality associated with
1039 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1040 @file{wchar.h}, which must come from a separate C library implementation.
1041 Because of this the GNU C compiler does not define macro
1042 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1043 the technical report.
1044 @end itemize
1045
1046 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1047 are supported by the DWARF 2 debug information format.
1048
1049 @node Hex Floats
1050 @section Hex Floats
1051 @cindex hex floats
1052
1053 ISO C99 supports floating-point numbers written not only in the usual
1054 decimal notation, such as @code{1.55e1}, but also numbers such as
1055 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1056 supports this in C90 mode (except in some cases when strictly
1057 conforming) and in C++. In that format the
1058 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1059 mandatory. The exponent is a decimal number that indicates the power of
1060 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1061 @tex
1062 $1 {15\over16}$,
1063 @end tex
1064 @ifnottex
1065 1 15/16,
1066 @end ifnottex
1067 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1068 is the same as @code{1.55e1}.
1069
1070 Unlike for floating-point numbers in the decimal notation the exponent
1071 is always required in the hexadecimal notation. Otherwise the compiler
1072 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1073 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1074 extension for floating-point constants of type @code{float}.
1075
1076 @node Fixed-Point
1077 @section Fixed-Point Types
1078 @cindex fixed-point types
1079 @cindex @code{_Fract} data type
1080 @cindex @code{_Accum} data type
1081 @cindex @code{_Sat} data type
1082 @cindex @code{hr} fixed-suffix
1083 @cindex @code{r} fixed-suffix
1084 @cindex @code{lr} fixed-suffix
1085 @cindex @code{llr} fixed-suffix
1086 @cindex @code{uhr} fixed-suffix
1087 @cindex @code{ur} fixed-suffix
1088 @cindex @code{ulr} fixed-suffix
1089 @cindex @code{ullr} fixed-suffix
1090 @cindex @code{hk} fixed-suffix
1091 @cindex @code{k} fixed-suffix
1092 @cindex @code{lk} fixed-suffix
1093 @cindex @code{llk} fixed-suffix
1094 @cindex @code{uhk} fixed-suffix
1095 @cindex @code{uk} fixed-suffix
1096 @cindex @code{ulk} fixed-suffix
1097 @cindex @code{ullk} fixed-suffix
1098 @cindex @code{HR} fixed-suffix
1099 @cindex @code{R} fixed-suffix
1100 @cindex @code{LR} fixed-suffix
1101 @cindex @code{LLR} fixed-suffix
1102 @cindex @code{UHR} fixed-suffix
1103 @cindex @code{UR} fixed-suffix
1104 @cindex @code{ULR} fixed-suffix
1105 @cindex @code{ULLR} fixed-suffix
1106 @cindex @code{HK} fixed-suffix
1107 @cindex @code{K} fixed-suffix
1108 @cindex @code{LK} fixed-suffix
1109 @cindex @code{LLK} fixed-suffix
1110 @cindex @code{UHK} fixed-suffix
1111 @cindex @code{UK} fixed-suffix
1112 @cindex @code{ULK} fixed-suffix
1113 @cindex @code{ULLK} fixed-suffix
1114
1115 As an extension, GNU C supports fixed-point types as
1116 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1117 types in GCC will evolve as the draft technical report changes.
1118 Calling conventions for any target might also change. Not all targets
1119 support fixed-point types.
1120
1121 The fixed-point types are
1122 @code{short _Fract},
1123 @code{_Fract},
1124 @code{long _Fract},
1125 @code{long long _Fract},
1126 @code{unsigned short _Fract},
1127 @code{unsigned _Fract},
1128 @code{unsigned long _Fract},
1129 @code{unsigned long long _Fract},
1130 @code{_Sat short _Fract},
1131 @code{_Sat _Fract},
1132 @code{_Sat long _Fract},
1133 @code{_Sat long long _Fract},
1134 @code{_Sat unsigned short _Fract},
1135 @code{_Sat unsigned _Fract},
1136 @code{_Sat unsigned long _Fract},
1137 @code{_Sat unsigned long long _Fract},
1138 @code{short _Accum},
1139 @code{_Accum},
1140 @code{long _Accum},
1141 @code{long long _Accum},
1142 @code{unsigned short _Accum},
1143 @code{unsigned _Accum},
1144 @code{unsigned long _Accum},
1145 @code{unsigned long long _Accum},
1146 @code{_Sat short _Accum},
1147 @code{_Sat _Accum},
1148 @code{_Sat long _Accum},
1149 @code{_Sat long long _Accum},
1150 @code{_Sat unsigned short _Accum},
1151 @code{_Sat unsigned _Accum},
1152 @code{_Sat unsigned long _Accum},
1153 @code{_Sat unsigned long long _Accum}.
1154
1155 Fixed-point data values contain fractional and optional integral parts.
1156 The format of fixed-point data varies and depends on the target machine.
1157
1158 Support for fixed-point types includes:
1159 @itemize @bullet
1160 @item
1161 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1162 @item
1163 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1164 @item
1165 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1166 @item
1167 binary shift operators (@code{<<}, @code{>>})
1168 @item
1169 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1170 @item
1171 equality operators (@code{==}, @code{!=})
1172 @item
1173 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1174 @code{<<=}, @code{>>=})
1175 @item
1176 conversions to and from integer, floating-point, or fixed-point types
1177 @end itemize
1178
1179 Use a suffix in a fixed-point literal constant:
1180 @itemize
1181 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1182 @code{_Sat short _Fract}
1183 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1184 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1185 @code{_Sat long _Fract}
1186 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1187 @code{_Sat long long _Fract}
1188 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1189 @code{_Sat unsigned short _Fract}
1190 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1191 @code{_Sat unsigned _Fract}
1192 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1193 @code{_Sat unsigned long _Fract}
1194 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1195 and @code{_Sat unsigned long long _Fract}
1196 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1197 @code{_Sat short _Accum}
1198 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1199 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1200 @code{_Sat long _Accum}
1201 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1202 @code{_Sat long long _Accum}
1203 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1204 @code{_Sat unsigned short _Accum}
1205 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1206 @code{_Sat unsigned _Accum}
1207 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1208 @code{_Sat unsigned long _Accum}
1209 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1210 and @code{_Sat unsigned long long _Accum}
1211 @end itemize
1212
1213 GCC support of fixed-point types as specified by the draft technical report
1214 is incomplete:
1215
1216 @itemize @bullet
1217 @item
1218 Pragmas to control overflow and rounding behaviors are not implemented.
1219 @end itemize
1220
1221 Fixed-point types are supported by the DWARF 2 debug information format.
1222
1223 @node Named Address Spaces
1224 @section Named Address Spaces
1225 @cindex Named Address Spaces
1226
1227 As an extension, GNU C supports named address spaces as
1228 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1229 address spaces in GCC will evolve as the draft technical report
1230 changes. Calling conventions for any target might also change. At
1231 present, only the AVR, SPU, M32C, and RL78 targets support address
1232 spaces other than the generic address space.
1233
1234 Address space identifiers may be used exactly like any other C type
1235 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1236 document for more details.
1237
1238 @anchor{AVR Named Address Spaces}
1239 @subsection AVR Named Address Spaces
1240
1241 On the AVR target, there are several address spaces that can be used
1242 in order to put read-only data into the flash memory and access that
1243 data by means of the special instructions @code{LPM} or @code{ELPM}
1244 needed to read from flash.
1245
1246 Per default, any data including read-only data is located in RAM
1247 (the generic address space) so that non-generic address spaces are
1248 needed to locate read-only data in flash memory
1249 @emph{and} to generate the right instructions to access this data
1250 without using (inline) assembler code.
1251
1252 @table @code
1253 @item __flash
1254 @cindex @code{__flash} AVR Named Address Spaces
1255 The @code{__flash} qualifier locates data in the
1256 @code{.progmem.data} section. Data is read using the @code{LPM}
1257 instruction. Pointers to this address space are 16 bits wide.
1258
1259 @item __flash1
1260 @itemx __flash2
1261 @itemx __flash3
1262 @itemx __flash4
1263 @itemx __flash5
1264 @cindex @code{__flash1} AVR Named Address Spaces
1265 @cindex @code{__flash2} AVR Named Address Spaces
1266 @cindex @code{__flash3} AVR Named Address Spaces
1267 @cindex @code{__flash4} AVR Named Address Spaces
1268 @cindex @code{__flash5} AVR Named Address Spaces
1269 These are 16-bit address spaces locating data in section
1270 @code{.progmem@var{N}.data} where @var{N} refers to
1271 address space @code{__flash@var{N}}.
1272 The compiler sets the @code{RAMPZ} segment register appropriately
1273 before reading data by means of the @code{ELPM} instruction.
1274
1275 @item __memx
1276 @cindex @code{__memx} AVR Named Address Spaces
1277 This is a 24-bit address space that linearizes flash and RAM:
1278 If the high bit of the address is set, data is read from
1279 RAM using the lower two bytes as RAM address.
1280 If the high bit of the address is clear, data is read from flash
1281 with @code{RAMPZ} set according to the high byte of the address.
1282 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1283
1284 Objects in this address space are located in @code{.progmemx.data}.
1285 @end table
1286
1287 @b{Example}
1288
1289 @smallexample
1290 char my_read (const __flash char ** p)
1291 @{
1292 /* p is a pointer to RAM that points to a pointer to flash.
1293 The first indirection of p reads that flash pointer
1294 from RAM and the second indirection reads a char from this
1295 flash address. */
1296
1297 return **p;
1298 @}
1299
1300 /* Locate array[] in flash memory */
1301 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1302
1303 int i = 1;
1304
1305 int main (void)
1306 @{
1307 /* Return 17 by reading from flash memory */
1308 return array[array[i]];
1309 @}
1310 @end smallexample
1311
1312 @noindent
1313 For each named address space supported by avr-gcc there is an equally
1314 named but uppercase built-in macro defined.
1315 The purpose is to facilitate testing if respective address space
1316 support is available or not:
1317
1318 @smallexample
1319 #ifdef __FLASH
1320 const __flash int var = 1;
1321
1322 int read_var (void)
1323 @{
1324 return var;
1325 @}
1326 #else
1327 #include <avr/pgmspace.h> /* From AVR-LibC */
1328
1329 const int var PROGMEM = 1;
1330
1331 int read_var (void)
1332 @{
1333 return (int) pgm_read_word (&var);
1334 @}
1335 #endif /* __FLASH */
1336 @end smallexample
1337
1338 @noindent
1339 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1340 locates data in flash but
1341 accesses to these data read from generic address space, i.e.@:
1342 from RAM,
1343 so that you need special accessors like @code{pgm_read_byte}
1344 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1345 together with attribute @code{progmem}.
1346
1347 @noindent
1348 @b{Limitations and caveats}
1349
1350 @itemize
1351 @item
1352 Reading across the 64@tie{}KiB section boundary of
1353 the @code{__flash} or @code{__flash@var{N}} address spaces
1354 shows undefined behavior. The only address space that
1355 supports reading across the 64@tie{}KiB flash segment boundaries is
1356 @code{__memx}.
1357
1358 @item
1359 If you use one of the @code{__flash@var{N}} address spaces
1360 you must arrange your linker script to locate the
1361 @code{.progmem@var{N}.data} sections according to your needs.
1362
1363 @item
1364 Any data or pointers to the non-generic address spaces must
1365 be qualified as @code{const}, i.e.@: as read-only data.
1366 This still applies if the data in one of these address
1367 spaces like software version number or calibration lookup table are intended to
1368 be changed after load time by, say, a boot loader. In this case
1369 the right qualification is @code{const} @code{volatile} so that the compiler
1370 must not optimize away known values or insert them
1371 as immediates into operands of instructions.
1372
1373 @item
1374 The following code initializes a variable @code{pfoo}
1375 located in static storage with a 24-bit address:
1376 @smallexample
1377 extern const __memx char foo;
1378 const __memx void *pfoo = &foo;
1379 @end smallexample
1380
1381 @noindent
1382 Such code requires at least binutils 2.23, see
1383 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1384
1385 @end itemize
1386
1387 @subsection M32C Named Address Spaces
1388 @cindex @code{__far} M32C Named Address Spaces
1389
1390 On the M32C target, with the R8C and M16C CPU variants, variables
1391 qualified with @code{__far} are accessed using 32-bit addresses in
1392 order to access memory beyond the first 64@tie{}Ki bytes. If
1393 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1394 effect.
1395
1396 @subsection RL78 Named Address Spaces
1397 @cindex @code{__far} RL78 Named Address Spaces
1398
1399 On the RL78 target, variables qualified with @code{__far} are accessed
1400 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1401 addresses. Non-far variables are assumed to appear in the topmost
1402 64@tie{}KiB of the address space.
1403
1404 @subsection SPU Named Address Spaces
1405 @cindex @code{__ea} SPU Named Address Spaces
1406
1407 On the SPU target variables may be declared as
1408 belonging to another address space by qualifying the type with the
1409 @code{__ea} address space identifier:
1410
1411 @smallexample
1412 extern int __ea i;
1413 @end smallexample
1414
1415 @noindent
1416 The compiler generates special code to access the variable @code{i}.
1417 It may use runtime library
1418 support, or generate special machine instructions to access that address
1419 space.
1420
1421 @node Zero Length
1422 @section Arrays of Length Zero
1423 @cindex arrays of length zero
1424 @cindex zero-length arrays
1425 @cindex length-zero arrays
1426 @cindex flexible array members
1427
1428 Zero-length arrays are allowed in GNU C@. They are very useful as the
1429 last element of a structure that is really a header for a variable-length
1430 object:
1431
1432 @smallexample
1433 struct line @{
1434 int length;
1435 char contents[0];
1436 @};
1437
1438 struct line *thisline = (struct line *)
1439 malloc (sizeof (struct line) + this_length);
1440 thisline->length = this_length;
1441 @end smallexample
1442
1443 In ISO C90, you would have to give @code{contents} a length of 1, which
1444 means either you waste space or complicate the argument to @code{malloc}.
1445
1446 In ISO C99, you would use a @dfn{flexible array member}, which is
1447 slightly different in syntax and semantics:
1448
1449 @itemize @bullet
1450 @item
1451 Flexible array members are written as @code{contents[]} without
1452 the @code{0}.
1453
1454 @item
1455 Flexible array members have incomplete type, and so the @code{sizeof}
1456 operator may not be applied. As a quirk of the original implementation
1457 of zero-length arrays, @code{sizeof} evaluates to zero.
1458
1459 @item
1460 Flexible array members may only appear as the last member of a
1461 @code{struct} that is otherwise non-empty.
1462
1463 @item
1464 A structure containing a flexible array member, or a union containing
1465 such a structure (possibly recursively), may not be a member of a
1466 structure or an element of an array. (However, these uses are
1467 permitted by GCC as extensions.)
1468 @end itemize
1469
1470 GCC versions before 3.0 allowed zero-length arrays to be statically
1471 initialized, as if they were flexible arrays. In addition to those
1472 cases that were useful, it also allowed initializations in situations
1473 that would corrupt later data. Non-empty initialization of zero-length
1474 arrays is now treated like any case where there are more initializer
1475 elements than the array holds, in that a suitable warning about ``excess
1476 elements in array'' is given, and the excess elements (all of them, in
1477 this case) are ignored.
1478
1479 Instead GCC allows static initialization of flexible array members.
1480 This is equivalent to defining a new structure containing the original
1481 structure followed by an array of sufficient size to contain the data.
1482 E.g.@: in the following, @code{f1} is constructed as if it were declared
1483 like @code{f2}.
1484
1485 @smallexample
1486 struct f1 @{
1487 int x; int y[];
1488 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1489
1490 struct f2 @{
1491 struct f1 f1; int data[3];
1492 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1493 @end smallexample
1494
1495 @noindent
1496 The convenience of this extension is that @code{f1} has the desired
1497 type, eliminating the need to consistently refer to @code{f2.f1}.
1498
1499 This has symmetry with normal static arrays, in that an array of
1500 unknown size is also written with @code{[]}.
1501
1502 Of course, this extension only makes sense if the extra data comes at
1503 the end of a top-level object, as otherwise we would be overwriting
1504 data at subsequent offsets. To avoid undue complication and confusion
1505 with initialization of deeply nested arrays, we simply disallow any
1506 non-empty initialization except when the structure is the top-level
1507 object. For example:
1508
1509 @smallexample
1510 struct foo @{ int x; int y[]; @};
1511 struct bar @{ struct foo z; @};
1512
1513 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1514 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1515 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1516 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1517 @end smallexample
1518
1519 @node Empty Structures
1520 @section Structures With No Members
1521 @cindex empty structures
1522 @cindex zero-size structures
1523
1524 GCC permits a C structure to have no members:
1525
1526 @smallexample
1527 struct empty @{
1528 @};
1529 @end smallexample
1530
1531 The structure has size zero. In C++, empty structures are part
1532 of the language. G++ treats empty structures as if they had a single
1533 member of type @code{char}.
1534
1535 @node Variable Length
1536 @section Arrays of Variable Length
1537 @cindex variable-length arrays
1538 @cindex arrays of variable length
1539 @cindex VLAs
1540
1541 Variable-length automatic arrays are allowed in ISO C99, and as an
1542 extension GCC accepts them in C90 mode and in C++. These arrays are
1543 declared like any other automatic arrays, but with a length that is not
1544 a constant expression. The storage is allocated at the point of
1545 declaration and deallocated when the block scope containing the declaration
1546 exits. For
1547 example:
1548
1549 @smallexample
1550 FILE *
1551 concat_fopen (char *s1, char *s2, char *mode)
1552 @{
1553 char str[strlen (s1) + strlen (s2) + 1];
1554 strcpy (str, s1);
1555 strcat (str, s2);
1556 return fopen (str, mode);
1557 @}
1558 @end smallexample
1559
1560 @cindex scope of a variable length array
1561 @cindex variable-length array scope
1562 @cindex deallocating variable length arrays
1563 Jumping or breaking out of the scope of the array name deallocates the
1564 storage. Jumping into the scope is not allowed; you get an error
1565 message for it.
1566
1567 @cindex @code{alloca} vs variable-length arrays
1568 You can use the function @code{alloca} to get an effect much like
1569 variable-length arrays. The function @code{alloca} is available in
1570 many other C implementations (but not in all). On the other hand,
1571 variable-length arrays are more elegant.
1572
1573 There are other differences between these two methods. Space allocated
1574 with @code{alloca} exists until the containing @emph{function} returns.
1575 The space for a variable-length array is deallocated as soon as the array
1576 name's scope ends. (If you use both variable-length arrays and
1577 @code{alloca} in the same function, deallocation of a variable-length array
1578 also deallocates anything more recently allocated with @code{alloca}.)
1579
1580 You can also use variable-length arrays as arguments to functions:
1581
1582 @smallexample
1583 struct entry
1584 tester (int len, char data[len][len])
1585 @{
1586 /* @r{@dots{}} */
1587 @}
1588 @end smallexample
1589
1590 The length of an array is computed once when the storage is allocated
1591 and is remembered for the scope of the array in case you access it with
1592 @code{sizeof}.
1593
1594 If you want to pass the array first and the length afterward, you can
1595 use a forward declaration in the parameter list---another GNU extension.
1596
1597 @smallexample
1598 struct entry
1599 tester (int len; char data[len][len], int len)
1600 @{
1601 /* @r{@dots{}} */
1602 @}
1603 @end smallexample
1604
1605 @cindex parameter forward declaration
1606 The @samp{int len} before the semicolon is a @dfn{parameter forward
1607 declaration}, and it serves the purpose of making the name @code{len}
1608 known when the declaration of @code{data} is parsed.
1609
1610 You can write any number of such parameter forward declarations in the
1611 parameter list. They can be separated by commas or semicolons, but the
1612 last one must end with a semicolon, which is followed by the ``real''
1613 parameter declarations. Each forward declaration must match a ``real''
1614 declaration in parameter name and data type. ISO C99 does not support
1615 parameter forward declarations.
1616
1617 @node Variadic Macros
1618 @section Macros with a Variable Number of Arguments.
1619 @cindex variable number of arguments
1620 @cindex macro with variable arguments
1621 @cindex rest argument (in macro)
1622 @cindex variadic macros
1623
1624 In the ISO C standard of 1999, a macro can be declared to accept a
1625 variable number of arguments much as a function can. The syntax for
1626 defining the macro is similar to that of a function. Here is an
1627 example:
1628
1629 @smallexample
1630 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1631 @end smallexample
1632
1633 @noindent
1634 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1635 such a macro, it represents the zero or more tokens until the closing
1636 parenthesis that ends the invocation, including any commas. This set of
1637 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1638 wherever it appears. See the CPP manual for more information.
1639
1640 GCC has long supported variadic macros, and used a different syntax that
1641 allowed you to give a name to the variable arguments just like any other
1642 argument. Here is an example:
1643
1644 @smallexample
1645 #define debug(format, args...) fprintf (stderr, format, args)
1646 @end smallexample
1647
1648 @noindent
1649 This is in all ways equivalent to the ISO C example above, but arguably
1650 more readable and descriptive.
1651
1652 GNU CPP has two further variadic macro extensions, and permits them to
1653 be used with either of the above forms of macro definition.
1654
1655 In standard C, you are not allowed to leave the variable argument out
1656 entirely; but you are allowed to pass an empty argument. For example,
1657 this invocation is invalid in ISO C, because there is no comma after
1658 the string:
1659
1660 @smallexample
1661 debug ("A message")
1662 @end smallexample
1663
1664 GNU CPP permits you to completely omit the variable arguments in this
1665 way. In the above examples, the compiler would complain, though since
1666 the expansion of the macro still has the extra comma after the format
1667 string.
1668
1669 To help solve this problem, CPP behaves specially for variable arguments
1670 used with the token paste operator, @samp{##}. If instead you write
1671
1672 @smallexample
1673 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1674 @end smallexample
1675
1676 @noindent
1677 and if the variable arguments are omitted or empty, the @samp{##}
1678 operator causes the preprocessor to remove the comma before it. If you
1679 do provide some variable arguments in your macro invocation, GNU CPP
1680 does not complain about the paste operation and instead places the
1681 variable arguments after the comma. Just like any other pasted macro
1682 argument, these arguments are not macro expanded.
1683
1684 @node Escaped Newlines
1685 @section Slightly Looser Rules for Escaped Newlines
1686 @cindex escaped newlines
1687 @cindex newlines (escaped)
1688
1689 Recently, the preprocessor has relaxed its treatment of escaped
1690 newlines. Previously, the newline had to immediately follow a
1691 backslash. The current implementation allows whitespace in the form
1692 of spaces, horizontal and vertical tabs, and form feeds between the
1693 backslash and the subsequent newline. The preprocessor issues a
1694 warning, but treats it as a valid escaped newline and combines the two
1695 lines to form a single logical line. This works within comments and
1696 tokens, as well as between tokens. Comments are @emph{not} treated as
1697 whitespace for the purposes of this relaxation, since they have not
1698 yet been replaced with spaces.
1699
1700 @node Subscripting
1701 @section Non-Lvalue Arrays May Have Subscripts
1702 @cindex subscripting
1703 @cindex arrays, non-lvalue
1704
1705 @cindex subscripting and function values
1706 In ISO C99, arrays that are not lvalues still decay to pointers, and
1707 may be subscripted, although they may not be modified or used after
1708 the next sequence point and the unary @samp{&} operator may not be
1709 applied to them. As an extension, GNU C allows such arrays to be
1710 subscripted in C90 mode, though otherwise they do not decay to
1711 pointers outside C99 mode. For example,
1712 this is valid in GNU C though not valid in C90:
1713
1714 @smallexample
1715 @group
1716 struct foo @{int a[4];@};
1717
1718 struct foo f();
1719
1720 bar (int index)
1721 @{
1722 return f().a[index];
1723 @}
1724 @end group
1725 @end smallexample
1726
1727 @node Pointer Arith
1728 @section Arithmetic on @code{void}- and Function-Pointers
1729 @cindex void pointers, arithmetic
1730 @cindex void, size of pointer to
1731 @cindex function pointers, arithmetic
1732 @cindex function, size of pointer to
1733
1734 In GNU C, addition and subtraction operations are supported on pointers to
1735 @code{void} and on pointers to functions. This is done by treating the
1736 size of a @code{void} or of a function as 1.
1737
1738 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1739 and on function types, and returns 1.
1740
1741 @opindex Wpointer-arith
1742 The option @option{-Wpointer-arith} requests a warning if these extensions
1743 are used.
1744
1745 @node Initializers
1746 @section Non-Constant Initializers
1747 @cindex initializers, non-constant
1748 @cindex non-constant initializers
1749
1750 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1751 automatic variable are not required to be constant expressions in GNU C@.
1752 Here is an example of an initializer with run-time varying elements:
1753
1754 @smallexample
1755 foo (float f, float g)
1756 @{
1757 float beat_freqs[2] = @{ f-g, f+g @};
1758 /* @r{@dots{}} */
1759 @}
1760 @end smallexample
1761
1762 @node Compound Literals
1763 @section Compound Literals
1764 @cindex constructor expressions
1765 @cindex initializations in expressions
1766 @cindex structures, constructor expression
1767 @cindex expressions, constructor
1768 @cindex compound literals
1769 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1770
1771 ISO C99 supports compound literals. A compound literal looks like
1772 a cast containing an initializer. Its value is an object of the
1773 type specified in the cast, containing the elements specified in
1774 the initializer; it is an lvalue. As an extension, GCC supports
1775 compound literals in C90 mode and in C++, though the semantics are
1776 somewhat different in C++.
1777
1778 Usually, the specified type is a structure. Assume that
1779 @code{struct foo} and @code{structure} are declared as shown:
1780
1781 @smallexample
1782 struct foo @{int a; char b[2];@} structure;
1783 @end smallexample
1784
1785 @noindent
1786 Here is an example of constructing a @code{struct foo} with a compound literal:
1787
1788 @smallexample
1789 structure = ((struct foo) @{x + y, 'a', 0@});
1790 @end smallexample
1791
1792 @noindent
1793 This is equivalent to writing the following:
1794
1795 @smallexample
1796 @{
1797 struct foo temp = @{x + y, 'a', 0@};
1798 structure = temp;
1799 @}
1800 @end smallexample
1801
1802 You can also construct an array, though this is dangerous in C++, as
1803 explained below. If all the elements of the compound literal are
1804 (made up of) simple constant expressions, suitable for use in
1805 initializers of objects of static storage duration, then the compound
1806 literal can be coerced to a pointer to its first element and used in
1807 such an initializer, as shown here:
1808
1809 @smallexample
1810 char **foo = (char *[]) @{ "x", "y", "z" @};
1811 @end smallexample
1812
1813 Compound literals for scalar types and union types are
1814 also allowed, but then the compound literal is equivalent
1815 to a cast.
1816
1817 As a GNU extension, GCC allows initialization of objects with static storage
1818 duration by compound literals (which is not possible in ISO C99, because
1819 the initializer is not a constant).
1820 It is handled as if the object is initialized only with the bracket
1821 enclosed list if the types of the compound literal and the object match.
1822 The initializer list of the compound literal must be constant.
1823 If the object being initialized has array type of unknown size, the size is
1824 determined by compound literal size.
1825
1826 @smallexample
1827 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1828 static int y[] = (int []) @{1, 2, 3@};
1829 static int z[] = (int [3]) @{1@};
1830 @end smallexample
1831
1832 @noindent
1833 The above lines are equivalent to the following:
1834 @smallexample
1835 static struct foo x = @{1, 'a', 'b'@};
1836 static int y[] = @{1, 2, 3@};
1837 static int z[] = @{1, 0, 0@};
1838 @end smallexample
1839
1840 In C, a compound literal designates an unnamed object with static or
1841 automatic storage duration. In C++, a compound literal designates a
1842 temporary object, which only lives until the end of its
1843 full-expression. As a result, well-defined C code that takes the
1844 address of a subobject of a compound literal can be undefined in C++.
1845 For instance, if the array compound literal example above appeared
1846 inside a function, any subsequent use of @samp{foo} in C++ has
1847 undefined behavior because the lifetime of the array ends after the
1848 declaration of @samp{foo}. As a result, the C++ compiler now rejects
1849 the conversion of a temporary array to a pointer.
1850
1851 As an optimization, the C++ compiler sometimes gives array compound
1852 literals longer lifetimes: when the array either appears outside a
1853 function or has const-qualified type. If @samp{foo} and its
1854 initializer had elements of @samp{char *const} type rather than
1855 @samp{char *}, or if @samp{foo} were a global variable, the array
1856 would have static storage duration. But it is probably safest just to
1857 avoid the use of array compound literals in code compiled as C++.
1858
1859 @node Designated Inits
1860 @section Designated Initializers
1861 @cindex initializers with labeled elements
1862 @cindex labeled elements in initializers
1863 @cindex case labels in initializers
1864 @cindex designated initializers
1865
1866 Standard C90 requires the elements of an initializer to appear in a fixed
1867 order, the same as the order of the elements in the array or structure
1868 being initialized.
1869
1870 In ISO C99 you can give the elements in any order, specifying the array
1871 indices or structure field names they apply to, and GNU C allows this as
1872 an extension in C90 mode as well. This extension is not
1873 implemented in GNU C++.
1874
1875 To specify an array index, write
1876 @samp{[@var{index}] =} before the element value. For example,
1877
1878 @smallexample
1879 int a[6] = @{ [4] = 29, [2] = 15 @};
1880 @end smallexample
1881
1882 @noindent
1883 is equivalent to
1884
1885 @smallexample
1886 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1887 @end smallexample
1888
1889 @noindent
1890 The index values must be constant expressions, even if the array being
1891 initialized is automatic.
1892
1893 An alternative syntax for this that has been obsolete since GCC 2.5 but
1894 GCC still accepts is to write @samp{[@var{index}]} before the element
1895 value, with no @samp{=}.
1896
1897 To initialize a range of elements to the same value, write
1898 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
1899 extension. For example,
1900
1901 @smallexample
1902 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1903 @end smallexample
1904
1905 @noindent
1906 If the value in it has side-effects, the side-effects happen only once,
1907 not for each initialized field by the range initializer.
1908
1909 @noindent
1910 Note that the length of the array is the highest value specified
1911 plus one.
1912
1913 In a structure initializer, specify the name of a field to initialize
1914 with @samp{.@var{fieldname} =} before the element value. For example,
1915 given the following structure,
1916
1917 @smallexample
1918 struct point @{ int x, y; @};
1919 @end smallexample
1920
1921 @noindent
1922 the following initialization
1923
1924 @smallexample
1925 struct point p = @{ .y = yvalue, .x = xvalue @};
1926 @end smallexample
1927
1928 @noindent
1929 is equivalent to
1930
1931 @smallexample
1932 struct point p = @{ xvalue, yvalue @};
1933 @end smallexample
1934
1935 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1936 @samp{@var{fieldname}:}, as shown here:
1937
1938 @smallexample
1939 struct point p = @{ y: yvalue, x: xvalue @};
1940 @end smallexample
1941
1942 @cindex designators
1943 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1944 @dfn{designator}. You can also use a designator (or the obsolete colon
1945 syntax) when initializing a union, to specify which element of the union
1946 should be used. For example,
1947
1948 @smallexample
1949 union foo @{ int i; double d; @};
1950
1951 union foo f = @{ .d = 4 @};
1952 @end smallexample
1953
1954 @noindent
1955 converts 4 to a @code{double} to store it in the union using
1956 the second element. By contrast, casting 4 to type @code{union foo}
1957 stores it into the union as the integer @code{i}, since it is
1958 an integer. (@xref{Cast to Union}.)
1959
1960 You can combine this technique of naming elements with ordinary C
1961 initialization of successive elements. Each initializer element that
1962 does not have a designator applies to the next consecutive element of the
1963 array or structure. For example,
1964
1965 @smallexample
1966 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
1967 @end smallexample
1968
1969 @noindent
1970 is equivalent to
1971
1972 @smallexample
1973 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
1974 @end smallexample
1975
1976 Labeling the elements of an array initializer is especially useful
1977 when the indices are characters or belong to an @code{enum} type.
1978 For example:
1979
1980 @smallexample
1981 int whitespace[256]
1982 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
1983 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
1984 @end smallexample
1985
1986 @cindex designator lists
1987 You can also write a series of @samp{.@var{fieldname}} and
1988 @samp{[@var{index}]} designators before an @samp{=} to specify a
1989 nested subobject to initialize; the list is taken relative to the
1990 subobject corresponding to the closest surrounding brace pair. For
1991 example, with the @samp{struct point} declaration above:
1992
1993 @smallexample
1994 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
1995 @end smallexample
1996
1997 @noindent
1998 If the same field is initialized multiple times, it has the value from
1999 the last initialization. If any such overridden initialization has
2000 side-effect, it is unspecified whether the side-effect happens or not.
2001 Currently, GCC discards them and issues a warning.
2002
2003 @node Case Ranges
2004 @section Case Ranges
2005 @cindex case ranges
2006 @cindex ranges in case statements
2007
2008 You can specify a range of consecutive values in a single @code{case} label,
2009 like this:
2010
2011 @smallexample
2012 case @var{low} ... @var{high}:
2013 @end smallexample
2014
2015 @noindent
2016 This has the same effect as the proper number of individual @code{case}
2017 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2018
2019 This feature is especially useful for ranges of ASCII character codes:
2020
2021 @smallexample
2022 case 'A' ... 'Z':
2023 @end smallexample
2024
2025 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2026 it may be parsed wrong when you use it with integer values. For example,
2027 write this:
2028
2029 @smallexample
2030 case 1 ... 5:
2031 @end smallexample
2032
2033 @noindent
2034 rather than this:
2035
2036 @smallexample
2037 case 1...5:
2038 @end smallexample
2039
2040 @node Cast to Union
2041 @section Cast to a Union Type
2042 @cindex cast to a union
2043 @cindex union, casting to a
2044
2045 A cast to union type is similar to other casts, except that the type
2046 specified is a union type. You can specify the type either with
2047 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2048 a constructor, not a cast, and hence does not yield an lvalue like
2049 normal casts. (@xref{Compound Literals}.)
2050
2051 The types that may be cast to the union type are those of the members
2052 of the union. Thus, given the following union and variables:
2053
2054 @smallexample
2055 union foo @{ int i; double d; @};
2056 int x;
2057 double y;
2058 @end smallexample
2059
2060 @noindent
2061 both @code{x} and @code{y} can be cast to type @code{union foo}.
2062
2063 Using the cast as the right-hand side of an assignment to a variable of
2064 union type is equivalent to storing in a member of the union:
2065
2066 @smallexample
2067 union foo u;
2068 /* @r{@dots{}} */
2069 u = (union foo) x @equiv{} u.i = x
2070 u = (union foo) y @equiv{} u.d = y
2071 @end smallexample
2072
2073 You can also use the union cast as a function argument:
2074
2075 @smallexample
2076 void hack (union foo);
2077 /* @r{@dots{}} */
2078 hack ((union foo) x);
2079 @end smallexample
2080
2081 @node Mixed Declarations
2082 @section Mixed Declarations and Code
2083 @cindex mixed declarations and code
2084 @cindex declarations, mixed with code
2085 @cindex code, mixed with declarations
2086
2087 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2088 within compound statements. As an extension, GNU C also allows this in
2089 C90 mode. For example, you could do:
2090
2091 @smallexample
2092 int i;
2093 /* @r{@dots{}} */
2094 i++;
2095 int j = i + 2;
2096 @end smallexample
2097
2098 Each identifier is visible from where it is declared until the end of
2099 the enclosing block.
2100
2101 @node Function Attributes
2102 @section Declaring Attributes of Functions
2103 @cindex function attributes
2104 @cindex declaring attributes of functions
2105 @cindex functions that never return
2106 @cindex functions that return more than once
2107 @cindex functions that have no side effects
2108 @cindex functions in arbitrary sections
2109 @cindex functions that behave like malloc
2110 @cindex @code{volatile} applied to function
2111 @cindex @code{const} applied to function
2112 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2113 @cindex functions with non-null pointer arguments
2114 @cindex functions that are passed arguments in registers on the 386
2115 @cindex functions that pop the argument stack on the 386
2116 @cindex functions that do not pop the argument stack on the 386
2117 @cindex functions that have different compilation options on the 386
2118 @cindex functions that have different optimization options
2119 @cindex functions that are dynamically resolved
2120
2121 In GNU C, you declare certain things about functions called in your program
2122 which help the compiler optimize function calls and check your code more
2123 carefully.
2124
2125 The keyword @code{__attribute__} allows you to specify special
2126 attributes when making a declaration. This keyword is followed by an
2127 attribute specification inside double parentheses. The following
2128 attributes are currently defined for functions on all targets:
2129 @code{aligned}, @code{alloc_size}, @code{noreturn},
2130 @code{returns_twice}, @code{noinline}, @code{noclone},
2131 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2132 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2133 @code{no_instrument_function}, @code{no_split_stack},
2134 @code{section}, @code{constructor},
2135 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2136 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2137 @code{warn_unused_result}, @code{nonnull},
2138 @code{returns_nonnull}, @code{gnu_inline},
2139 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2140 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2141 @code{no_sanitize_undefined}, @code{bnd_legacy},
2142 @code{error} and @code{warning}.
2143 Several other attributes are defined for functions on particular
2144 target systems. Other attributes, including @code{section} are
2145 supported for variables declarations (@pxref{Variable Attributes})
2146 and for types (@pxref{Type Attributes}).
2147
2148 GCC plugins may provide their own attributes.
2149
2150 You may also specify attributes with @samp{__} preceding and following
2151 each keyword. This allows you to use them in header files without
2152 being concerned about a possible macro of the same name. For example,
2153 you may use @code{__noreturn__} instead of @code{noreturn}.
2154
2155 @xref{Attribute Syntax}, for details of the exact syntax for using
2156 attributes.
2157
2158 @table @code
2159 @c Keep this table alphabetized by attribute name. Treat _ as space.
2160
2161 @item alias ("@var{target}")
2162 @cindex @code{alias} attribute
2163 The @code{alias} attribute causes the declaration to be emitted as an
2164 alias for another symbol, which must be specified. For instance,
2165
2166 @smallexample
2167 void __f () @{ /* @r{Do something.} */; @}
2168 void f () __attribute__ ((weak, alias ("__f")));
2169 @end smallexample
2170
2171 @noindent
2172 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2173 mangled name for the target must be used. It is an error if @samp{__f}
2174 is not defined in the same translation unit.
2175
2176 Not all target machines support this attribute.
2177
2178 @item aligned (@var{alignment})
2179 @cindex @code{aligned} attribute
2180 This attribute specifies a minimum alignment for the function,
2181 measured in bytes.
2182
2183 You cannot use this attribute to decrease the alignment of a function,
2184 only to increase it. However, when you explicitly specify a function
2185 alignment this overrides the effect of the
2186 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2187 function.
2188
2189 Note that the effectiveness of @code{aligned} attributes may be
2190 limited by inherent limitations in your linker. On many systems, the
2191 linker is only able to arrange for functions to be aligned up to a
2192 certain maximum alignment. (For some linkers, the maximum supported
2193 alignment may be very very small.) See your linker documentation for
2194 further information.
2195
2196 The @code{aligned} attribute can also be used for variables and fields
2197 (@pxref{Variable Attributes}.)
2198
2199 @item alloc_size
2200 @cindex @code{alloc_size} attribute
2201 The @code{alloc_size} attribute is used to tell the compiler that the
2202 function return value points to memory, where the size is given by
2203 one or two of the functions parameters. GCC uses this
2204 information to improve the correctness of @code{__builtin_object_size}.
2205
2206 The function parameter(s) denoting the allocated size are specified by
2207 one or two integer arguments supplied to the attribute. The allocated size
2208 is either the value of the single function argument specified or the product
2209 of the two function arguments specified. Argument numbering starts at
2210 one.
2211
2212 For instance,
2213
2214 @smallexample
2215 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2216 void my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2217 @end smallexample
2218
2219 @noindent
2220 declares that @code{my_calloc} returns memory of the size given by
2221 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2222 of the size given by parameter 2.
2223
2224 @item always_inline
2225 @cindex @code{always_inline} function attribute
2226 Generally, functions are not inlined unless optimization is specified.
2227 For functions declared inline, this attribute inlines the function even
2228 if no optimization level is specified.
2229
2230 @item gnu_inline
2231 @cindex @code{gnu_inline} function attribute
2232 This attribute should be used with a function that is also declared
2233 with the @code{inline} keyword. It directs GCC to treat the function
2234 as if it were defined in gnu90 mode even when compiling in C99 or
2235 gnu99 mode.
2236
2237 If the function is declared @code{extern}, then this definition of the
2238 function is used only for inlining. In no case is the function
2239 compiled as a standalone function, not even if you take its address
2240 explicitly. Such an address becomes an external reference, as if you
2241 had only declared the function, and had not defined it. This has
2242 almost the effect of a macro. The way to use this is to put a
2243 function definition in a header file with this attribute, and put
2244 another copy of the function, without @code{extern}, in a library
2245 file. The definition in the header file causes most calls to the
2246 function to be inlined. If any uses of the function remain, they
2247 refer to the single copy in the library. Note that the two
2248 definitions of the functions need not be precisely the same, although
2249 if they do not have the same effect your program may behave oddly.
2250
2251 In C, if the function is neither @code{extern} nor @code{static}, then
2252 the function is compiled as a standalone function, as well as being
2253 inlined where possible.
2254
2255 This is how GCC traditionally handled functions declared
2256 @code{inline}. Since ISO C99 specifies a different semantics for
2257 @code{inline}, this function attribute is provided as a transition
2258 measure and as a useful feature in its own right. This attribute is
2259 available in GCC 4.1.3 and later. It is available if either of the
2260 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2261 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2262 Function is As Fast As a Macro}.
2263
2264 In C++, this attribute does not depend on @code{extern} in any way,
2265 but it still requires the @code{inline} keyword to enable its special
2266 behavior.
2267
2268 @item artificial
2269 @cindex @code{artificial} function attribute
2270 This attribute is useful for small inline wrappers that if possible
2271 should appear during debugging as a unit. Depending on the debug
2272 info format it either means marking the function as artificial
2273 or using the caller location for all instructions within the inlined
2274 body.
2275
2276 @item bank_switch
2277 @cindex interrupt handler functions
2278 When added to an interrupt handler with the M32C port, causes the
2279 prologue and epilogue to use bank switching to preserve the registers
2280 rather than saving them on the stack.
2281
2282 @item flatten
2283 @cindex @code{flatten} function attribute
2284 Generally, inlining into a function is limited. For a function marked with
2285 this attribute, every call inside this function is inlined, if possible.
2286 Whether the function itself is considered for inlining depends on its size and
2287 the current inlining parameters.
2288
2289 @item error ("@var{message}")
2290 @cindex @code{error} function attribute
2291 If this attribute is used on a function declaration and a call to such a function
2292 is not eliminated through dead code elimination or other optimizations, an error
2293 that includes @var{message} is diagnosed. This is useful
2294 for compile-time checking, especially together with @code{__builtin_constant_p}
2295 and inline functions where checking the inline function arguments is not
2296 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2297 While it is possible to leave the function undefined and thus invoke
2298 a link failure, when using this attribute the problem is diagnosed
2299 earlier and with exact location of the call even in presence of inline
2300 functions or when not emitting debugging information.
2301
2302 @item warning ("@var{message}")
2303 @cindex @code{warning} function attribute
2304 If this attribute is used on a function declaration and a call to such a function
2305 is not eliminated through dead code elimination or other optimizations, a warning
2306 that includes @var{message} is diagnosed. This is useful
2307 for compile-time checking, especially together with @code{__builtin_constant_p}
2308 and inline functions. While it is possible to define the function with
2309 a message in @code{.gnu.warning*} section, when using this attribute the problem
2310 is diagnosed earlier and with exact location of the call even in presence
2311 of inline functions or when not emitting debugging information.
2312
2313 @item cdecl
2314 @cindex functions that do pop the argument stack on the 386
2315 @opindex mrtd
2316 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2317 assume that the calling function pops off the stack space used to
2318 pass arguments. This is
2319 useful to override the effects of the @option{-mrtd} switch.
2320
2321 @item const
2322 @cindex @code{const} function attribute
2323 Many functions do not examine any values except their arguments, and
2324 have no effects except the return value. Basically this is just slightly
2325 more strict class than the @code{pure} attribute below, since function is not
2326 allowed to read global memory.
2327
2328 @cindex pointer arguments
2329 Note that a function that has pointer arguments and examines the data
2330 pointed to must @emph{not} be declared @code{const}. Likewise, a
2331 function that calls a non-@code{const} function usually must not be
2332 @code{const}. It does not make sense for a @code{const} function to
2333 return @code{void}.
2334
2335 The attribute @code{const} is not implemented in GCC versions earlier
2336 than 2.5. An alternative way to declare that a function has no side
2337 effects, which works in the current version and in some older versions,
2338 is as follows:
2339
2340 @smallexample
2341 typedef int intfn ();
2342
2343 extern const intfn square;
2344 @end smallexample
2345
2346 @noindent
2347 This approach does not work in GNU C++ from 2.6.0 on, since the language
2348 specifies that the @samp{const} must be attached to the return value.
2349
2350 @item constructor
2351 @itemx destructor
2352 @itemx constructor (@var{priority})
2353 @itemx destructor (@var{priority})
2354 @cindex @code{constructor} function attribute
2355 @cindex @code{destructor} function attribute
2356 The @code{constructor} attribute causes the function to be called
2357 automatically before execution enters @code{main ()}. Similarly, the
2358 @code{destructor} attribute causes the function to be called
2359 automatically after @code{main ()} completes or @code{exit ()} is
2360 called. Functions with these attributes are useful for
2361 initializing data that is used implicitly during the execution of
2362 the program.
2363
2364 You may provide an optional integer priority to control the order in
2365 which constructor and destructor functions are run. A constructor
2366 with a smaller priority number runs before a constructor with a larger
2367 priority number; the opposite relationship holds for destructors. So,
2368 if you have a constructor that allocates a resource and a destructor
2369 that deallocates the same resource, both functions typically have the
2370 same priority. The priorities for constructor and destructor
2371 functions are the same as those specified for namespace-scope C++
2372 objects (@pxref{C++ Attributes}).
2373
2374 These attributes are not currently implemented for Objective-C@.
2375
2376 @item deprecated
2377 @itemx deprecated (@var{msg})
2378 @cindex @code{deprecated} attribute.
2379 The @code{deprecated} attribute results in a warning if the function
2380 is used anywhere in the source file. This is useful when identifying
2381 functions that are expected to be removed in a future version of a
2382 program. The warning also includes the location of the declaration
2383 of the deprecated function, to enable users to easily find further
2384 information about why the function is deprecated, or what they should
2385 do instead. Note that the warnings only occurs for uses:
2386
2387 @smallexample
2388 int old_fn () __attribute__ ((deprecated));
2389 int old_fn ();
2390 int (*fn_ptr)() = old_fn;
2391 @end smallexample
2392
2393 @noindent
2394 results in a warning on line 3 but not line 2. The optional @var{msg}
2395 argument, which must be a string, is printed in the warning if
2396 present.
2397
2398 The @code{deprecated} attribute can also be used for variables and
2399 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2400
2401 @item disinterrupt
2402 @cindex @code{disinterrupt} attribute
2403 On Epiphany and MeP targets, this attribute causes the compiler to emit
2404 instructions to disable interrupts for the duration of the given
2405 function.
2406
2407 @item dllexport
2408 @cindex @code{__declspec(dllexport)}
2409 On Microsoft Windows targets and Symbian OS targets the
2410 @code{dllexport} attribute causes the compiler to provide a global
2411 pointer to a pointer in a DLL, so that it can be referenced with the
2412 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
2413 name is formed by combining @code{_imp__} and the function or variable
2414 name.
2415
2416 You can use @code{__declspec(dllexport)} as a synonym for
2417 @code{__attribute__ ((dllexport))} for compatibility with other
2418 compilers.
2419
2420 On systems that support the @code{visibility} attribute, this
2421 attribute also implies ``default'' visibility. It is an error to
2422 explicitly specify any other visibility.
2423
2424 In previous versions of GCC, the @code{dllexport} attribute was ignored
2425 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2426 had been used. The default behavior now is to emit all dllexported
2427 inline functions; however, this can cause object file-size bloat, in
2428 which case the old behavior can be restored by using
2429 @option{-fno-keep-inline-dllexport}.
2430
2431 The attribute is also ignored for undefined symbols.
2432
2433 When applied to C++ classes, the attribute marks defined non-inlined
2434 member functions and static data members as exports. Static consts
2435 initialized in-class are not marked unless they are also defined
2436 out-of-class.
2437
2438 For Microsoft Windows targets there are alternative methods for
2439 including the symbol in the DLL's export table such as using a
2440 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2441 the @option{--export-all} linker flag.
2442
2443 @item dllimport
2444 @cindex @code{__declspec(dllimport)}
2445 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2446 attribute causes the compiler to reference a function or variable via
2447 a global pointer to a pointer that is set up by the DLL exporting the
2448 symbol. The attribute implies @code{extern}. On Microsoft Windows
2449 targets, the pointer name is formed by combining @code{_imp__} and the
2450 function or variable name.
2451
2452 You can use @code{__declspec(dllimport)} as a synonym for
2453 @code{__attribute__ ((dllimport))} for compatibility with other
2454 compilers.
2455
2456 On systems that support the @code{visibility} attribute, this
2457 attribute also implies ``default'' visibility. It is an error to
2458 explicitly specify any other visibility.
2459
2460 Currently, the attribute is ignored for inlined functions. If the
2461 attribute is applied to a symbol @emph{definition}, an error is reported.
2462 If a symbol previously declared @code{dllimport} is later defined, the
2463 attribute is ignored in subsequent references, and a warning is emitted.
2464 The attribute is also overridden by a subsequent declaration as
2465 @code{dllexport}.
2466
2467 When applied to C++ classes, the attribute marks non-inlined
2468 member functions and static data members as imports. However, the
2469 attribute is ignored for virtual methods to allow creation of vtables
2470 using thunks.
2471
2472 On the SH Symbian OS target the @code{dllimport} attribute also has
2473 another affect---it can cause the vtable and run-time type information
2474 for a class to be exported. This happens when the class has a
2475 dllimported constructor or a non-inline, non-pure virtual function
2476 and, for either of those two conditions, the class also has an inline
2477 constructor or destructor and has a key function that is defined in
2478 the current translation unit.
2479
2480 For Microsoft Windows targets the use of the @code{dllimport}
2481 attribute on functions is not necessary, but provides a small
2482 performance benefit by eliminating a thunk in the DLL@. The use of the
2483 @code{dllimport} attribute on imported variables was required on older
2484 versions of the GNU linker, but can now be avoided by passing the
2485 @option{--enable-auto-import} switch to the GNU linker. As with
2486 functions, using the attribute for a variable eliminates a thunk in
2487 the DLL@.
2488
2489 One drawback to using this attribute is that a pointer to a
2490 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2491 address. However, a pointer to a @emph{function} with the
2492 @code{dllimport} attribute can be used as a constant initializer; in
2493 this case, the address of a stub function in the import lib is
2494 referenced. On Microsoft Windows targets, the attribute can be disabled
2495 for functions by setting the @option{-mnop-fun-dllimport} flag.
2496
2497 @item eightbit_data
2498 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2499 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2500 variable should be placed into the eight-bit data section.
2501 The compiler generates more efficient code for certain operations
2502 on data in the eight-bit data area. Note the eight-bit data area is limited to
2503 256 bytes of data.
2504
2505 You must use GAS and GLD from GNU binutils version 2.7 or later for
2506 this attribute to work correctly.
2507
2508 @item exception
2509 @cindex exception handler functions
2510 Use this attribute on the NDS32 target to indicate that the specified function
2511 is an exception handler. The compiler will generate corresponding sections
2512 for use in an exception handler.
2513
2514 @item exception_handler
2515 @cindex exception handler functions on the Blackfin processor
2516 Use this attribute on the Blackfin to indicate that the specified function
2517 is an exception handler. The compiler generates function entry and
2518 exit sequences suitable for use in an exception handler when this
2519 attribute is present.
2520
2521 @item externally_visible
2522 @cindex @code{externally_visible} attribute.
2523 This attribute, attached to a global variable or function, nullifies
2524 the effect of the @option{-fwhole-program} command-line option, so the
2525 object remains visible outside the current compilation unit.
2526
2527 If @option{-fwhole-program} is used together with @option{-flto} and
2528 @command{gold} is used as the linker plugin,
2529 @code{externally_visible} attributes are automatically added to functions
2530 (not variable yet due to a current @command{gold} issue)
2531 that are accessed outside of LTO objects according to resolution file
2532 produced by @command{gold}.
2533 For other linkers that cannot generate resolution file,
2534 explicit @code{externally_visible} attributes are still necessary.
2535
2536 @item far
2537 @cindex functions that handle memory bank switching
2538 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2539 use a calling convention that takes care of switching memory banks when
2540 entering and leaving a function. This calling convention is also the
2541 default when using the @option{-mlong-calls} option.
2542
2543 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2544 to call and return from a function.
2545
2546 On 68HC11 the compiler generates a sequence of instructions
2547 to invoke a board-specific routine to switch the memory bank and call the
2548 real function. The board-specific routine simulates a @code{call}.
2549 At the end of a function, it jumps to a board-specific routine
2550 instead of using @code{rts}. The board-specific return routine simulates
2551 the @code{rtc}.
2552
2553 On MeP targets this causes the compiler to use a calling convention
2554 that assumes the called function is too far away for the built-in
2555 addressing modes.
2556
2557 @item fast_interrupt
2558 @cindex interrupt handler functions
2559 Use this attribute on the M32C and RX ports to indicate that the specified
2560 function is a fast interrupt handler. This is just like the
2561 @code{interrupt} attribute, except that @code{freit} is used to return
2562 instead of @code{reit}.
2563
2564 @item fastcall
2565 @cindex functions that pop the argument stack on the 386
2566 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2567 pass the first argument (if of integral type) in the register ECX and
2568 the second argument (if of integral type) in the register EDX@. Subsequent
2569 and other typed arguments are passed on the stack. The called function
2570 pops the arguments off the stack. If the number of arguments is variable all
2571 arguments are pushed on the stack.
2572
2573 @item thiscall
2574 @cindex functions that pop the argument stack on the 386
2575 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2576 pass the first argument (if of integral type) in the register ECX.
2577 Subsequent and other typed arguments are passed on the stack. The called
2578 function pops the arguments off the stack.
2579 If the number of arguments is variable all arguments are pushed on the
2580 stack.
2581 The @code{thiscall} attribute is intended for C++ non-static member functions.
2582 As a GCC extension, this calling convention can be used for C functions
2583 and for static member methods.
2584
2585 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2586 @cindex @code{format} function attribute
2587 @opindex Wformat
2588 The @code{format} attribute specifies that a function takes @code{printf},
2589 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2590 should be type-checked against a format string. For example, the
2591 declaration:
2592
2593 @smallexample
2594 extern int
2595 my_printf (void *my_object, const char *my_format, ...)
2596 __attribute__ ((format (printf, 2, 3)));
2597 @end smallexample
2598
2599 @noindent
2600 causes the compiler to check the arguments in calls to @code{my_printf}
2601 for consistency with the @code{printf} style format string argument
2602 @code{my_format}.
2603
2604 The parameter @var{archetype} determines how the format string is
2605 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2606 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2607 @code{strfmon}. (You can also use @code{__printf__},
2608 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2609 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2610 @code{ms_strftime} are also present.
2611 @var{archetype} values such as @code{printf} refer to the formats accepted
2612 by the system's C runtime library,
2613 while values prefixed with @samp{gnu_} always refer
2614 to the formats accepted by the GNU C Library. On Microsoft Windows
2615 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2616 @file{msvcrt.dll} library.
2617 The parameter @var{string-index}
2618 specifies which argument is the format string argument (starting
2619 from 1), while @var{first-to-check} is the number of the first
2620 argument to check against the format string. For functions
2621 where the arguments are not available to be checked (such as
2622 @code{vprintf}), specify the third parameter as zero. In this case the
2623 compiler only checks the format string for consistency. For
2624 @code{strftime} formats, the third parameter is required to be zero.
2625 Since non-static C++ methods have an implicit @code{this} argument, the
2626 arguments of such methods should be counted from two, not one, when
2627 giving values for @var{string-index} and @var{first-to-check}.
2628
2629 In the example above, the format string (@code{my_format}) is the second
2630 argument of the function @code{my_print}, and the arguments to check
2631 start with the third argument, so the correct parameters for the format
2632 attribute are 2 and 3.
2633
2634 @opindex ffreestanding
2635 @opindex fno-builtin
2636 The @code{format} attribute allows you to identify your own functions
2637 that take format strings as arguments, so that GCC can check the
2638 calls to these functions for errors. The compiler always (unless
2639 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2640 for the standard library functions @code{printf}, @code{fprintf},
2641 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2642 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2643 warnings are requested (using @option{-Wformat}), so there is no need to
2644 modify the header file @file{stdio.h}. In C99 mode, the functions
2645 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2646 @code{vsscanf} are also checked. Except in strictly conforming C
2647 standard modes, the X/Open function @code{strfmon} is also checked as
2648 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2649 @xref{C Dialect Options,,Options Controlling C Dialect}.
2650
2651 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2652 recognized in the same context. Declarations including these format attributes
2653 are parsed for correct syntax, however the result of checking of such format
2654 strings is not yet defined, and is not carried out by this version of the
2655 compiler.
2656
2657 The target may also provide additional types of format checks.
2658 @xref{Target Format Checks,,Format Checks Specific to Particular
2659 Target Machines}.
2660
2661 @item format_arg (@var{string-index})
2662 @cindex @code{format_arg} function attribute
2663 @opindex Wformat-nonliteral
2664 The @code{format_arg} attribute specifies that a function takes a format
2665 string for a @code{printf}, @code{scanf}, @code{strftime} or
2666 @code{strfmon} style function and modifies it (for example, to translate
2667 it into another language), so the result can be passed to a
2668 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2669 function (with the remaining arguments to the format function the same
2670 as they would have been for the unmodified string). For example, the
2671 declaration:
2672
2673 @smallexample
2674 extern char *
2675 my_dgettext (char *my_domain, const char *my_format)
2676 __attribute__ ((format_arg (2)));
2677 @end smallexample
2678
2679 @noindent
2680 causes the compiler to check the arguments in calls to a @code{printf},
2681 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2682 format string argument is a call to the @code{my_dgettext} function, for
2683 consistency with the format string argument @code{my_format}. If the
2684 @code{format_arg} attribute had not been specified, all the compiler
2685 could tell in such calls to format functions would be that the format
2686 string argument is not constant; this would generate a warning when
2687 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2688 without the attribute.
2689
2690 The parameter @var{string-index} specifies which argument is the format
2691 string argument (starting from one). Since non-static C++ methods have
2692 an implicit @code{this} argument, the arguments of such methods should
2693 be counted from two.
2694
2695 The @code{format_arg} attribute allows you to identify your own
2696 functions that modify format strings, so that GCC can check the
2697 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2698 type function whose operands are a call to one of your own function.
2699 The compiler always treats @code{gettext}, @code{dgettext}, and
2700 @code{dcgettext} in this manner except when strict ISO C support is
2701 requested by @option{-ansi} or an appropriate @option{-std} option, or
2702 @option{-ffreestanding} or @option{-fno-builtin}
2703 is used. @xref{C Dialect Options,,Options
2704 Controlling C Dialect}.
2705
2706 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2707 @code{NSString} reference for compatibility with the @code{format} attribute
2708 above.
2709
2710 The target may also allow additional types in @code{format-arg} attributes.
2711 @xref{Target Format Checks,,Format Checks Specific to Particular
2712 Target Machines}.
2713
2714 @item function_vector
2715 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2716 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2717 function should be called through the function vector. Calling a
2718 function through the function vector reduces code size, however;
2719 the function vector has a limited size (maximum 128 entries on the H8/300
2720 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2721
2722 On SH2A targets, this attribute declares a function to be called using the
2723 TBR relative addressing mode. The argument to this attribute is the entry
2724 number of the same function in a vector table containing all the TBR
2725 relative addressable functions. For correct operation the TBR must be setup
2726 accordingly to point to the start of the vector table before any functions with
2727 this attribute are invoked. Usually a good place to do the initialization is
2728 the startup routine. The TBR relative vector table can have at max 256 function
2729 entries. The jumps to these functions are generated using a SH2A specific,
2730 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
2731 from GNU binutils version 2.7 or later for this attribute to work correctly.
2732
2733 Please refer the example of M16C target, to see the use of this
2734 attribute while declaring a function,
2735
2736 In an application, for a function being called once, this attribute
2737 saves at least 8 bytes of code; and if other successive calls are being
2738 made to the same function, it saves 2 bytes of code per each of these
2739 calls.
2740
2741 On M16C/M32C targets, the @code{function_vector} attribute declares a
2742 special page subroutine call function. Use of this attribute reduces
2743 the code size by 2 bytes for each call generated to the
2744 subroutine. The argument to the attribute is the vector number entry
2745 from the special page vector table which contains the 16 low-order
2746 bits of the subroutine's entry address. Each vector table has special
2747 page number (18 to 255) that is used in @code{jsrs} instructions.
2748 Jump addresses of the routines are generated by adding 0x0F0000 (in
2749 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2750 2-byte addresses set in the vector table. Therefore you need to ensure
2751 that all the special page vector routines should get mapped within the
2752 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2753 (for M32C).
2754
2755 In the following example 2 bytes are saved for each call to
2756 function @code{foo}.
2757
2758 @smallexample
2759 void foo (void) __attribute__((function_vector(0x18)));
2760 void foo (void)
2761 @{
2762 @}
2763
2764 void bar (void)
2765 @{
2766 foo();
2767 @}
2768 @end smallexample
2769
2770 If functions are defined in one file and are called in another file,
2771 then be sure to write this declaration in both files.
2772
2773 This attribute is ignored for R8C target.
2774
2775 @item ifunc ("@var{resolver}")
2776 @cindex @code{ifunc} attribute
2777 The @code{ifunc} attribute is used to mark a function as an indirect
2778 function using the STT_GNU_IFUNC symbol type extension to the ELF
2779 standard. This allows the resolution of the symbol value to be
2780 determined dynamically at load time, and an optimized version of the
2781 routine can be selected for the particular processor or other system
2782 characteristics determined then. To use this attribute, first define
2783 the implementation functions available, and a resolver function that
2784 returns a pointer to the selected implementation function. The
2785 implementation functions' declarations must match the API of the
2786 function being implemented, the resolver's declaration is be a
2787 function returning pointer to void function returning void:
2788
2789 @smallexample
2790 void *my_memcpy (void *dst, const void *src, size_t len)
2791 @{
2792 @dots{}
2793 @}
2794
2795 static void (*resolve_memcpy (void)) (void)
2796 @{
2797 return my_memcpy; // we'll just always select this routine
2798 @}
2799 @end smallexample
2800
2801 @noindent
2802 The exported header file declaring the function the user calls would
2803 contain:
2804
2805 @smallexample
2806 extern void *memcpy (void *, const void *, size_t);
2807 @end smallexample
2808
2809 @noindent
2810 allowing the user to call this as a regular function, unaware of the
2811 implementation. Finally, the indirect function needs to be defined in
2812 the same translation unit as the resolver function:
2813
2814 @smallexample
2815 void *memcpy (void *, const void *, size_t)
2816 __attribute__ ((ifunc ("resolve_memcpy")));
2817 @end smallexample
2818
2819 Indirect functions cannot be weak, and require a recent binutils (at
2820 least version 2.20.1), and GNU C library (at least version 2.11.1).
2821
2822 @item interrupt
2823 @cindex interrupt handler functions
2824 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2825 m68k, MeP, MIPS, MSP430, RL78, RX and Xstormy16 ports to indicate that
2826 the specified function is an
2827 interrupt handler. The compiler generates function entry and exit
2828 sequences suitable for use in an interrupt handler when this attribute
2829 is present. With Epiphany targets it may also generate a special section with
2830 code to initialize the interrupt vector table.
2831
2832 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2833 and SH processors can be specified via the @code{interrupt_handler} attribute.
2834
2835 Note, on the ARC, you must specify the kind of interrupt to be handled
2836 in a parameter to the interrupt attribute like this:
2837
2838 @smallexample
2839 void f () __attribute__ ((interrupt ("ilink1")));
2840 @end smallexample
2841
2842 Permissible values for this parameter are: @w{@code{ilink1}} and
2843 @w{@code{ilink2}}.
2844
2845 Note, on the AVR, the hardware globally disables interrupts when an
2846 interrupt is executed. The first instruction of an interrupt handler
2847 declared with this attribute is a @code{SEI} instruction to
2848 re-enable interrupts. See also the @code{signal} function attribute
2849 that does not insert a @code{SEI} instruction. If both @code{signal} and
2850 @code{interrupt} are specified for the same function, @code{signal}
2851 is silently ignored.
2852
2853 Note, for the ARM, you can specify the kind of interrupt to be handled by
2854 adding an optional parameter to the interrupt attribute like this:
2855
2856 @smallexample
2857 void f () __attribute__ ((interrupt ("IRQ")));
2858 @end smallexample
2859
2860 @noindent
2861 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2862 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2863
2864 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2865 may be called with a word-aligned stack pointer.
2866
2867 Note, for the MSP430 you can provide an argument to the interrupt
2868 attribute which specifies a name or number. If the argument is a
2869 number it indicates the slot in the interrupt vector table (0 - 31) to
2870 which this handler should be assigned. If the argument is a name it
2871 is treated as a symbolic name for the vector slot. These names should
2872 match up with appropriate entries in the linker script. By default
2873 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2874 @code{reset} for vector 31 are recognised.
2875
2876 You can also use the following function attributes to modify how
2877 normal functions interact with interrupt functions:
2878
2879 @table @code
2880 @item critical
2881 @cindex @code{critical} attribute
2882 Critical functions disable interrupts upon entry and restore the
2883 previous interrupt state upon exit. Critical functions cannot also
2884 have the @code{naked} or @code{reentrant} attributes. They can have
2885 the @code{interrupt} attribute.
2886
2887 @item reentrant
2888 @cindex @code{reentrant} attribute
2889 Reentrant functions disable interrupts upon entry and enable them
2890 upon exit. Reentrant functions cannot also have the @code{naked}
2891 or @code{critical} attributes. They can have the @code{interrupt}
2892 attribute.
2893
2894 @end table
2895
2896 On Epiphany targets one or more optional parameters can be added like this:
2897
2898 @smallexample
2899 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2900 @end smallexample
2901
2902 Permissible values for these parameters are: @w{@code{reset}},
2903 @w{@code{software_exception}}, @w{@code{page_miss}},
2904 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
2905 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
2906 Multiple parameters indicate that multiple entries in the interrupt
2907 vector table should be initialized for this function, i.e.@: for each
2908 parameter @w{@var{name}}, a jump to the function is emitted in
2909 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
2910 entirely, in which case no interrupt vector table entry is provided.
2911
2912 Note, on Epiphany targets, interrupts are enabled inside the function
2913 unless the @code{disinterrupt} attribute is also specified.
2914
2915 On Epiphany targets, you can also use the following attribute to
2916 modify the behavior of an interrupt handler:
2917 @table @code
2918 @item forwarder_section
2919 @cindex @code{forwarder_section} attribute
2920 The interrupt handler may be in external memory which cannot be
2921 reached by a branch instruction, so generate a local memory trampoline
2922 to transfer control. The single parameter identifies the section where
2923 the trampoline is placed.
2924 @end table
2925
2926 The following examples are all valid uses of these attributes on
2927 Epiphany targets:
2928 @smallexample
2929 void __attribute__ ((interrupt)) universal_handler ();
2930 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
2931 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2932 void __attribute__ ((interrupt ("timer0"), disinterrupt))
2933 fast_timer_handler ();
2934 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
2935 external_dma_handler ();
2936 @end smallexample
2937
2938 On MIPS targets, you can use the following attributes to modify the behavior
2939 of an interrupt handler:
2940 @table @code
2941 @item use_shadow_register_set
2942 @cindex @code{use_shadow_register_set} attribute
2943 Assume that the handler uses a shadow register set, instead of
2944 the main general-purpose registers.
2945
2946 @item keep_interrupts_masked
2947 @cindex @code{keep_interrupts_masked} attribute
2948 Keep interrupts masked for the whole function. Without this attribute,
2949 GCC tries to reenable interrupts for as much of the function as it can.
2950
2951 @item use_debug_exception_return
2952 @cindex @code{use_debug_exception_return} attribute
2953 Return using the @code{deret} instruction. Interrupt handlers that don't
2954 have this attribute return using @code{eret} instead.
2955 @end table
2956
2957 You can use any combination of these attributes, as shown below:
2958 @smallexample
2959 void __attribute__ ((interrupt)) v0 ();
2960 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
2961 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
2962 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
2963 void __attribute__ ((interrupt, use_shadow_register_set,
2964 keep_interrupts_masked)) v4 ();
2965 void __attribute__ ((interrupt, use_shadow_register_set,
2966 use_debug_exception_return)) v5 ();
2967 void __attribute__ ((interrupt, keep_interrupts_masked,
2968 use_debug_exception_return)) v6 ();
2969 void __attribute__ ((interrupt, use_shadow_register_set,
2970 keep_interrupts_masked,
2971 use_debug_exception_return)) v7 ();
2972 @end smallexample
2973
2974 On NDS32 target, this attribute is to indicate that the specified function
2975 is an interrupt handler. The compiler will generate corresponding sections
2976 for use in an interrupt handler. You can use the following attributes
2977 to modify the behavior:
2978 @table @code
2979 @item nested
2980 @cindex @code{nested} attribute
2981 This interrupt service routine is interruptible.
2982 @item not_nested
2983 @cindex @code{not_nested} attribute
2984 This interrupt service routine is not interruptible.
2985 @item nested_ready
2986 @cindex @code{nested_ready} attribute
2987 This interrupt service routine is interruptible after @code{PSW.GIE}
2988 (global interrupt enable) is set. This allows interrupt service routine to
2989 finish some short critical code before enabling interrupts.
2990 @item save_all
2991 @cindex @code{save_all} attribute
2992 The system will help save all registers into stack before entering
2993 interrupt handler.
2994 @item partial_save
2995 @cindex @code{partial_save} attribute
2996 The system will help save caller registers into stack before entering
2997 interrupt handler.
2998 @end table
2999
3000 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3001 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3002 that must end with @code{RETB} instead of @code{RETI}).
3003
3004 @item interrupt_handler
3005 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
3006 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3007 indicate that the specified function is an interrupt handler. The compiler
3008 generates function entry and exit sequences suitable for use in an
3009 interrupt handler when this attribute is present.
3010
3011 @item interrupt_thread
3012 @cindex interrupt thread functions on fido
3013 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3014 that the specified function is an interrupt handler that is designed
3015 to run as a thread. The compiler omits generate prologue/epilogue
3016 sequences and replaces the return instruction with a @code{sleep}
3017 instruction. This attribute is available only on fido.
3018
3019 @item isr
3020 @cindex interrupt service routines on ARM
3021 Use this attribute on ARM to write Interrupt Service Routines. This is an
3022 alias to the @code{interrupt} attribute above.
3023
3024 @item kspisusp
3025 @cindex User stack pointer in interrupts on the Blackfin
3026 When used together with @code{interrupt_handler}, @code{exception_handler}
3027 or @code{nmi_handler}, code is generated to load the stack pointer
3028 from the USP register in the function prologue.
3029
3030 @item l1_text
3031 @cindex @code{l1_text} function attribute
3032 This attribute specifies a function to be placed into L1 Instruction
3033 SRAM@. The function is put into a specific section named @code{.l1.text}.
3034 With @option{-mfdpic}, function calls with a such function as the callee
3035 or caller uses inlined PLT.
3036
3037 @item l2
3038 @cindex @code{l2} function attribute
3039 On the Blackfin, this attribute specifies a function to be placed into L2
3040 SRAM. The function is put into a specific section named
3041 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3042 an inlined PLT.
3043
3044 @item leaf
3045 @cindex @code{leaf} function attribute
3046 Calls to external functions with this attribute must return to the current
3047 compilation unit only by return or by exception handling. In particular, leaf
3048 functions are not allowed to call callback function passed to it from the current
3049 compilation unit or directly call functions exported by the unit or longjmp
3050 into the unit. Leaf function might still call functions from other compilation
3051 units and thus they are not necessarily leaf in the sense that they contain no
3052 function calls at all.
3053
3054 The attribute is intended for library functions to improve dataflow analysis.
3055 The compiler takes the hint that any data not escaping the current compilation unit can
3056 not be used or modified by the leaf function. For example, the @code{sin} function
3057 is a leaf function, but @code{qsort} is not.
3058
3059 Note that leaf functions might invoke signals and signal handlers might be
3060 defined in the current compilation unit and use static variables. The only
3061 compliant way to write such a signal handler is to declare such variables
3062 @code{volatile}.
3063
3064 The attribute has no effect on functions defined within the current compilation
3065 unit. This is to allow easy merging of multiple compilation units into one,
3066 for example, by using the link-time optimization. For this reason the
3067 attribute is not allowed on types to annotate indirect calls.
3068
3069 @item long_call/medium_call/short_call
3070 @cindex indirect calls on ARC
3071 @cindex indirect calls on ARM
3072 @cindex indirect calls on Epiphany
3073 These attributes specify how a particular function is called on
3074 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3075 These attributes override the
3076 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3077 and @option{-mmedium-calls} (@pxref{ARC Options})
3078 command-line switches and @code{#pragma long_calls} settings. For ARM, the
3079 @code{long_call} attribute indicates that the function might be far
3080 away from the call site and require a different (more expensive)
3081 calling sequence. The @code{short_call} attribute always places
3082 the offset to the function from the call site into the @samp{BL}
3083 instruction directly.
3084
3085 For ARC, a function marked with the @code{long_call} attribute is
3086 always called using register-indirect jump-and-link instructions,
3087 thereby enabling the called function to be placed anywhere within the
3088 32-bit address space. A function marked with the @code{medium_call}
3089 attribute will always be close enough to be called with an unconditional
3090 branch-and-link instruction, which has a 25-bit offset from
3091 the call site. A function marked with the @code{short_call}
3092 attribute will always be close enough to be called with a conditional
3093 branch-and-link instruction, which has a 21-bit offset from
3094 the call site.
3095
3096 @item longcall/shortcall
3097 @cindex functions called via pointer on the RS/6000 and PowerPC
3098 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3099 indicates that the function might be far away from the call site and
3100 require a different (more expensive) calling sequence. The
3101 @code{shortcall} attribute indicates that the function is always close
3102 enough for the shorter calling sequence to be used. These attributes
3103 override both the @option{-mlongcall} switch and, on the RS/6000 and
3104 PowerPC, the @code{#pragma longcall} setting.
3105
3106 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3107 calls are necessary.
3108
3109 @item long_call/near/far
3110 @cindex indirect calls on MIPS
3111 These attributes specify how a particular function is called on MIPS@.
3112 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3113 command-line switch. The @code{long_call} and @code{far} attributes are
3114 synonyms, and cause the compiler to always call
3115 the function by first loading its address into a register, and then using
3116 the contents of that register. The @code{near} attribute has the opposite
3117 effect; it specifies that non-PIC calls should be made using the more
3118 efficient @code{jal} instruction.
3119
3120 @item malloc
3121 @cindex @code{malloc} attribute
3122 The @code{malloc} attribute is used to tell the compiler that a function
3123 may be treated as if any non-@code{NULL} pointer it returns cannot
3124 alias any other pointer valid when the function returns and that the memory
3125 has undefined content.
3126 This often improves optimization.
3127 Standard functions with this property include @code{malloc} and
3128 @code{calloc}. @code{realloc}-like functions do not have this
3129 property as the memory pointed to does not have undefined content.
3130
3131 @item mips16/nomips16
3132 @cindex @code{mips16} attribute
3133 @cindex @code{nomips16} attribute
3134
3135 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3136 function attributes to locally select or turn off MIPS16 code generation.
3137 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3138 while MIPS16 code generation is disabled for functions with the
3139 @code{nomips16} attribute. These attributes override the
3140 @option{-mips16} and @option{-mno-mips16} options on the command line
3141 (@pxref{MIPS Options}).
3142
3143 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3144 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3145 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
3146 may interact badly with some GCC extensions such as @code{__builtin_apply}
3147 (@pxref{Constructing Calls}).
3148
3149 @item micromips/nomicromips
3150 @cindex @code{micromips} attribute
3151 @cindex @code{nomicromips} attribute
3152
3153 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3154 function attributes to locally select or turn off microMIPS code generation.
3155 A function with the @code{micromips} attribute is emitted as microMIPS code,
3156 while microMIPS code generation is disabled for functions with the
3157 @code{nomicromips} attribute. These attributes override the
3158 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3159 (@pxref{MIPS Options}).
3160
3161 When compiling files containing mixed microMIPS and non-microMIPS code, the
3162 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3163 command line,
3164 not that within individual functions. Mixed microMIPS and non-microMIPS code
3165 may interact badly with some GCC extensions such as @code{__builtin_apply}
3166 (@pxref{Constructing Calls}).
3167
3168 @item model (@var{model-name})
3169 @cindex function addressability on the M32R/D
3170 @cindex variable addressability on the IA-64
3171
3172 On the M32R/D, use this attribute to set the addressability of an
3173 object, and of the code generated for a function. The identifier
3174 @var{model-name} is one of @code{small}, @code{medium}, or
3175 @code{large}, representing each of the code models.
3176
3177 Small model objects live in the lower 16MB of memory (so that their
3178 addresses can be loaded with the @code{ld24} instruction), and are
3179 callable with the @code{bl} instruction.
3180
3181 Medium model objects may live anywhere in the 32-bit address space (the
3182 compiler generates @code{seth/add3} instructions to load their addresses),
3183 and are callable with the @code{bl} instruction.
3184
3185 Large model objects may live anywhere in the 32-bit address space (the
3186 compiler generates @code{seth/add3} instructions to load their addresses),
3187 and may not be reachable with the @code{bl} instruction (the compiler
3188 generates the much slower @code{seth/add3/jl} instruction sequence).
3189
3190 On IA-64, use this attribute to set the addressability of an object.
3191 At present, the only supported identifier for @var{model-name} is
3192 @code{small}, indicating addressability via ``small'' (22-bit)
3193 addresses (so that their addresses can be loaded with the @code{addl}
3194 instruction). Caveat: such addressing is by definition not position
3195 independent and hence this attribute must not be used for objects
3196 defined by shared libraries.
3197
3198 @item ms_abi/sysv_abi
3199 @cindex @code{ms_abi} attribute
3200 @cindex @code{sysv_abi} attribute
3201
3202 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3203 to indicate which calling convention should be used for a function. The
3204 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3205 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3206 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
3207 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
3208
3209 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3210 requires the @option{-maccumulate-outgoing-args} option.
3211
3212 @item callee_pop_aggregate_return (@var{number})
3213 @cindex @code{callee_pop_aggregate_return} attribute
3214
3215 On 32-bit i?86-*-* targets, you can use this attribute to control how
3216 aggregates are returned in memory. If the caller is responsible for
3217 popping the hidden pointer together with the rest of the arguments, specify
3218 @var{number} equal to zero. If callee is responsible for popping the
3219 hidden pointer, specify @var{number} equal to one.
3220
3221 The default i386 ABI assumes that the callee pops the
3222 stack for hidden pointer. However, on 32-bit i386 Microsoft Windows targets,
3223 the compiler assumes that the
3224 caller pops the stack for hidden pointer.
3225
3226 @item ms_hook_prologue
3227 @cindex @code{ms_hook_prologue} attribute
3228
3229 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3230 this function attribute to make GCC generate the ``hot-patching'' function
3231 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3232 and newer.
3233
3234 @item naked
3235 @cindex function without a prologue/epilogue code
3236 Use this attribute on the ARM, AVR, MCORE, MSP430, NDS32, RL78, RX and SPU
3237 ports to indicate that the specified function does not need prologue/epilogue
3238 sequences generated by the compiler.
3239 It is up to the programmer to provide these sequences. The
3240 only statements that can be safely included in naked functions are
3241 @code{asm} statements that do not have operands. All other statements,
3242 including declarations of local variables, @code{if} statements, and so
3243 forth, should be avoided. Naked functions should be used to implement the
3244 body of an assembly function, while allowing the compiler to construct
3245 the requisite function declaration for the assembler.
3246
3247 @item near
3248 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3249 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3250 use the normal calling convention based on @code{jsr} and @code{rts}.
3251 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3252 option.
3253
3254 On MeP targets this attribute causes the compiler to assume the called
3255 function is close enough to use the normal calling convention,
3256 overriding the @option{-mtf} command-line option.
3257
3258 @item nesting
3259 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3260 Use this attribute together with @code{interrupt_handler},
3261 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3262 entry code should enable nested interrupts or exceptions.
3263
3264 @item nmi_handler
3265 @cindex NMI handler functions on the Blackfin processor
3266 Use this attribute on the Blackfin to indicate that the specified function
3267 is an NMI handler. The compiler generates function entry and
3268 exit sequences suitable for use in an NMI handler when this
3269 attribute is present.
3270
3271 @item nocompression
3272 @cindex @code{nocompression} attribute
3273 On MIPS targets, you can use the @code{nocompression} function attribute
3274 to locally turn off MIPS16 and microMIPS code generation. This attribute
3275 overrides the @option{-mips16} and @option{-mmicromips} options on the
3276 command line (@pxref{MIPS Options}).
3277
3278 @item no_instrument_function
3279 @cindex @code{no_instrument_function} function attribute
3280 @opindex finstrument-functions
3281 If @option{-finstrument-functions} is given, profiling function calls are
3282 generated at entry and exit of most user-compiled functions.
3283 Functions with this attribute are not so instrumented.
3284
3285 @item no_split_stack
3286 @cindex @code{no_split_stack} function attribute
3287 @opindex fsplit-stack
3288 If @option{-fsplit-stack} is given, functions have a small
3289 prologue which decides whether to split the stack. Functions with the
3290 @code{no_split_stack} attribute do not have that prologue, and thus
3291 may run with only a small amount of stack space available.
3292
3293 @item noinline
3294 @cindex @code{noinline} function attribute
3295 This function attribute prevents a function from being considered for
3296 inlining.
3297 @c Don't enumerate the optimizations by name here; we try to be
3298 @c future-compatible with this mechanism.
3299 If the function does not have side-effects, there are optimizations
3300 other than inlining that cause function calls to be optimized away,
3301 although the function call is live. To keep such calls from being
3302 optimized away, put
3303 @smallexample
3304 asm ("");
3305 @end smallexample
3306
3307 @noindent
3308 (@pxref{Extended Asm}) in the called function, to serve as a special
3309 side-effect.
3310
3311 @item noclone
3312 @cindex @code{noclone} function attribute
3313 This function attribute prevents a function from being considered for
3314 cloning---a mechanism that produces specialized copies of functions
3315 and which is (currently) performed by interprocedural constant
3316 propagation.
3317
3318 @item nonnull (@var{arg-index}, @dots{})
3319 @cindex @code{nonnull} function attribute
3320 The @code{nonnull} attribute specifies that some function parameters should
3321 be non-null pointers. For instance, the declaration:
3322
3323 @smallexample
3324 extern void *
3325 my_memcpy (void *dest, const void *src, size_t len)
3326 __attribute__((nonnull (1, 2)));
3327 @end smallexample
3328
3329 @noindent
3330 causes the compiler to check that, in calls to @code{my_memcpy},
3331 arguments @var{dest} and @var{src} are non-null. If the compiler
3332 determines that a null pointer is passed in an argument slot marked
3333 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3334 is issued. The compiler may also choose to make optimizations based
3335 on the knowledge that certain function arguments will never be null.
3336
3337 If no argument index list is given to the @code{nonnull} attribute,
3338 all pointer arguments are marked as non-null. To illustrate, the
3339 following declaration is equivalent to the previous example:
3340
3341 @smallexample
3342 extern void *
3343 my_memcpy (void *dest, const void *src, size_t len)
3344 __attribute__((nonnull));
3345 @end smallexample
3346
3347 @item returns_nonnull
3348 @cindex @code{returns_nonnull} function attribute
3349 The @code{returns_nonnull} attribute specifies that the function
3350 return value should be a non-null pointer. For instance, the declaration:
3351
3352 @smallexample
3353 extern void *
3354 mymalloc (size_t len) __attribute__((returns_nonnull));
3355 @end smallexample
3356
3357 @noindent
3358 lets the compiler optimize callers based on the knowledge
3359 that the return value will never be null.
3360
3361 @item noreturn
3362 @cindex @code{noreturn} function attribute
3363 A few standard library functions, such as @code{abort} and @code{exit},
3364 cannot return. GCC knows this automatically. Some programs define
3365 their own functions that never return. You can declare them
3366 @code{noreturn} to tell the compiler this fact. For example,
3367
3368 @smallexample
3369 @group
3370 void fatal () __attribute__ ((noreturn));
3371
3372 void
3373 fatal (/* @r{@dots{}} */)
3374 @{
3375 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3376 exit (1);
3377 @}
3378 @end group
3379 @end smallexample
3380
3381 The @code{noreturn} keyword tells the compiler to assume that
3382 @code{fatal} cannot return. It can then optimize without regard to what
3383 would happen if @code{fatal} ever did return. This makes slightly
3384 better code. More importantly, it helps avoid spurious warnings of
3385 uninitialized variables.
3386
3387 The @code{noreturn} keyword does not affect the exceptional path when that
3388 applies: a @code{noreturn}-marked function may still return to the caller
3389 by throwing an exception or calling @code{longjmp}.
3390
3391 Do not assume that registers saved by the calling function are
3392 restored before calling the @code{noreturn} function.
3393
3394 It does not make sense for a @code{noreturn} function to have a return
3395 type other than @code{void}.
3396
3397 The attribute @code{noreturn} is not implemented in GCC versions
3398 earlier than 2.5. An alternative way to declare that a function does
3399 not return, which works in the current version and in some older
3400 versions, is as follows:
3401
3402 @smallexample
3403 typedef void voidfn ();
3404
3405 volatile voidfn fatal;
3406 @end smallexample
3407
3408 @noindent
3409 This approach does not work in GNU C++.
3410
3411 @item nothrow
3412 @cindex @code{nothrow} function attribute
3413 The @code{nothrow} attribute is used to inform the compiler that a
3414 function cannot throw an exception. For example, most functions in
3415 the standard C library can be guaranteed not to throw an exception
3416 with the notable exceptions of @code{qsort} and @code{bsearch} that
3417 take function pointer arguments. The @code{nothrow} attribute is not
3418 implemented in GCC versions earlier than 3.3.
3419
3420 @item nosave_low_regs
3421 @cindex @code{nosave_low_regs} attribute
3422 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3423 function should not save and restore registers R0..R7. This can be used on SH3*
3424 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3425 interrupt handlers.
3426
3427 @item optimize
3428 @cindex @code{optimize} function attribute
3429 The @code{optimize} attribute is used to specify that a function is to
3430 be compiled with different optimization options than specified on the
3431 command line. Arguments can either be numbers or strings. Numbers
3432 are assumed to be an optimization level. Strings that begin with
3433 @code{O} are assumed to be an optimization option, while other options
3434 are assumed to be used with a @code{-f} prefix. You can also use the
3435 @samp{#pragma GCC optimize} pragma to set the optimization options
3436 that affect more than one function.
3437 @xref{Function Specific Option Pragmas}, for details about the
3438 @samp{#pragma GCC optimize} pragma.
3439
3440 This can be used for instance to have frequently-executed functions
3441 compiled with more aggressive optimization options that produce faster
3442 and larger code, while other functions can be compiled with less
3443 aggressive options.
3444
3445 @item OS_main/OS_task
3446 @cindex @code{OS_main} AVR function attribute
3447 @cindex @code{OS_task} AVR function attribute
3448 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3449 do not save/restore any call-saved register in their prologue/epilogue.
3450
3451 The @code{OS_main} attribute can be used when there @emph{is
3452 guarantee} that interrupts are disabled at the time when the function
3453 is entered. This saves resources when the stack pointer has to be
3454 changed to set up a frame for local variables.
3455
3456 The @code{OS_task} attribute can be used when there is @emph{no
3457 guarantee} that interrupts are disabled at that time when the function
3458 is entered like for, e@.g@. task functions in a multi-threading operating
3459 system. In that case, changing the stack pointer register is
3460 guarded by save/clear/restore of the global interrupt enable flag.
3461
3462 The differences to the @code{naked} function attribute are:
3463 @itemize @bullet
3464 @item @code{naked} functions do not have a return instruction whereas
3465 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3466 @code{RETI} return instruction.
3467 @item @code{naked} functions do not set up a frame for local variables
3468 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3469 as needed.
3470 @end itemize
3471
3472 @item pcs
3473 @cindex @code{pcs} function attribute
3474
3475 The @code{pcs} attribute can be used to control the calling convention
3476 used for a function on ARM. The attribute takes an argument that specifies
3477 the calling convention to use.
3478
3479 When compiling using the AAPCS ABI (or a variant of it) then valid
3480 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3481 order to use a variant other than @code{"aapcs"} then the compiler must
3482 be permitted to use the appropriate co-processor registers (i.e., the
3483 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3484 For example,
3485
3486 @smallexample
3487 /* Argument passed in r0, and result returned in r0+r1. */
3488 double f2d (float) __attribute__((pcs("aapcs")));
3489 @end smallexample
3490
3491 Variadic functions always use the @code{"aapcs"} calling convention and
3492 the compiler rejects attempts to specify an alternative.
3493
3494 @item pure
3495 @cindex @code{pure} function attribute
3496 Many functions have no effects except the return value and their
3497 return value depends only on the parameters and/or global variables.
3498 Such a function can be subject
3499 to common subexpression elimination and loop optimization just as an
3500 arithmetic operator would be. These functions should be declared
3501 with the attribute @code{pure}. For example,
3502
3503 @smallexample
3504 int square (int) __attribute__ ((pure));
3505 @end smallexample
3506
3507 @noindent
3508 says that the hypothetical function @code{square} is safe to call
3509 fewer times than the program says.
3510
3511 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3512 Interesting non-pure functions are functions with infinite loops or those
3513 depending on volatile memory or other system resource, that may change between
3514 two consecutive calls (such as @code{feof} in a multithreading environment).
3515
3516 The attribute @code{pure} is not implemented in GCC versions earlier
3517 than 2.96.
3518
3519 @item hot
3520 @cindex @code{hot} function attribute
3521 The @code{hot} attribute on a function is used to inform the compiler that
3522 the function is a hot spot of the compiled program. The function is
3523 optimized more aggressively and on many target it is placed into special
3524 subsection of the text section so all hot functions appears close together
3525 improving locality.
3526
3527 When profile feedback is available, via @option{-fprofile-use}, hot functions
3528 are automatically detected and this attribute is ignored.
3529
3530 The @code{hot} attribute on functions is not implemented in GCC versions
3531 earlier than 4.3.
3532
3533 @cindex @code{hot} label attribute
3534 The @code{hot} attribute on a label is used to inform the compiler that
3535 path following the label are more likely than paths that are not so
3536 annotated. This attribute is used in cases where @code{__builtin_expect}
3537 cannot be used, for instance with computed goto or @code{asm goto}.
3538
3539 The @code{hot} attribute on labels is not implemented in GCC versions
3540 earlier than 4.8.
3541
3542 @item cold
3543 @cindex @code{cold} function attribute
3544 The @code{cold} attribute on functions is used to inform the compiler that
3545 the function is unlikely to be executed. The function is optimized for
3546 size rather than speed and on many targets it is placed into special
3547 subsection of the text section so all cold functions appears close together
3548 improving code locality of non-cold parts of program. The paths leading
3549 to call of cold functions within code are marked as unlikely by the branch
3550 prediction mechanism. It is thus useful to mark functions used to handle
3551 unlikely conditions, such as @code{perror}, as cold to improve optimization
3552 of hot functions that do call marked functions in rare occasions.
3553
3554 When profile feedback is available, via @option{-fprofile-use}, cold functions
3555 are automatically detected and this attribute is ignored.
3556
3557 The @code{cold} attribute on functions is not implemented in GCC versions
3558 earlier than 4.3.
3559
3560 @cindex @code{cold} label attribute
3561 The @code{cold} attribute on labels is used to inform the compiler that
3562 the path following the label is unlikely to be executed. This attribute
3563 is used in cases where @code{__builtin_expect} cannot be used, for instance
3564 with computed goto or @code{asm goto}.
3565
3566 The @code{cold} attribute on labels is not implemented in GCC versions
3567 earlier than 4.8.
3568
3569 @item no_sanitize_address
3570 @itemx no_address_safety_analysis
3571 @cindex @code{no_sanitize_address} function attribute
3572 The @code{no_sanitize_address} attribute on functions is used
3573 to inform the compiler that it should not instrument memory accesses
3574 in the function when compiling with the @option{-fsanitize=address} option.
3575 The @code{no_address_safety_analysis} is a deprecated alias of the
3576 @code{no_sanitize_address} attribute, new code should use
3577 @code{no_sanitize_address}.
3578
3579 @item no_sanitize_undefined
3580 @cindex @code{no_sanitize_undefined} function attribute
3581 The @code{no_sanitize_undefined} attribute on functions is used
3582 to inform the compiler that it should not check for undefined behavior
3583 in the function when compiling with the @option{-fsanitize=undefined} option.
3584
3585 @item bnd_legacy
3586 @cindex @code{bnd_legacy} function attribute
3587 The @code{bnd_legacy} attribute on functions is used to inform
3588 compiler that function should not be instrumented when compiled
3589 with @option{-fcheck-pointers} option.
3590
3591 @item regparm (@var{number})
3592 @cindex @code{regparm} attribute
3593 @cindex functions that are passed arguments in registers on the 386
3594 On the Intel 386, the @code{regparm} attribute causes the compiler to
3595 pass arguments number one to @var{number} if they are of integral type
3596 in registers EAX, EDX, and ECX instead of on the stack. Functions that
3597 take a variable number of arguments continue to be passed all of their
3598 arguments on the stack.
3599
3600 Beware that on some ELF systems this attribute is unsuitable for
3601 global functions in shared libraries with lazy binding (which is the
3602 default). Lazy binding sends the first call via resolving code in
3603 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3604 per the standard calling conventions. Solaris 8 is affected by this.
3605 Systems with the GNU C Library version 2.1 or higher
3606 and FreeBSD are believed to be
3607 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
3608 disabled with the linker or the loader if desired, to avoid the
3609 problem.)
3610
3611 @item reset
3612 @cindex reset handler functions
3613 Use this attribute on the NDS32 target to indicate that the specified function
3614 is a reset handler. The compiler will generate corresponding sections
3615 for use in a reset handler. You can use the following attributes
3616 to provide extra exception handling:
3617 @table @code
3618 @item nmi
3619 @cindex @code{nmi} attribute
3620 Provide a user-defined function to handle NMI exception.
3621 @item warm
3622 @cindex @code{warm} attribute
3623 Provide a user-defined function to handle warm reset exception.
3624 @end table
3625
3626 @item sseregparm
3627 @cindex @code{sseregparm} attribute
3628 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3629 causes the compiler to pass up to 3 floating-point arguments in
3630 SSE registers instead of on the stack. Functions that take a
3631 variable number of arguments continue to pass all of their
3632 floating-point arguments on the stack.
3633
3634 @item force_align_arg_pointer
3635 @cindex @code{force_align_arg_pointer} attribute
3636 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3637 applied to individual function definitions, generating an alternate
3638 prologue and epilogue that realigns the run-time stack if necessary.
3639 This supports mixing legacy codes that run with a 4-byte aligned stack
3640 with modern codes that keep a 16-byte stack for SSE compatibility.
3641
3642 @item renesas
3643 @cindex @code{renesas} attribute
3644 On SH targets this attribute specifies that the function or struct follows the
3645 Renesas ABI.
3646
3647 @item resbank
3648 @cindex @code{resbank} attribute
3649 On the SH2A target, this attribute enables the high-speed register
3650 saving and restoration using a register bank for @code{interrupt_handler}
3651 routines. Saving to the bank is performed automatically after the CPU
3652 accepts an interrupt that uses a register bank.
3653
3654 The nineteen 32-bit registers comprising general register R0 to R14,
3655 control register GBR, and system registers MACH, MACL, and PR and the
3656 vector table address offset are saved into a register bank. Register
3657 banks are stacked in first-in last-out (FILO) sequence. Restoration
3658 from the bank is executed by issuing a RESBANK instruction.
3659
3660 @item returns_twice
3661 @cindex @code{returns_twice} attribute
3662 The @code{returns_twice} attribute tells the compiler that a function may
3663 return more than one time. The compiler ensures that all registers
3664 are dead before calling such a function and emits a warning about
3665 the variables that may be clobbered after the second return from the
3666 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3667 The @code{longjmp}-like counterpart of such function, if any, might need
3668 to be marked with the @code{noreturn} attribute.
3669
3670 @item saveall
3671 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3672 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3673 all registers except the stack pointer should be saved in the prologue
3674 regardless of whether they are used or not.
3675
3676 @item save_volatiles
3677 @cindex save volatile registers on the MicroBlaze
3678 Use this attribute on the MicroBlaze to indicate that the function is
3679 an interrupt handler. All volatile registers (in addition to non-volatile
3680 registers) are saved in the function prologue. If the function is a leaf
3681 function, only volatiles used by the function are saved. A normal function
3682 return is generated instead of a return from interrupt.
3683
3684 @item section ("@var{section-name}")
3685 @cindex @code{section} function attribute
3686 Normally, the compiler places the code it generates in the @code{text} section.
3687 Sometimes, however, you need additional sections, or you need certain
3688 particular functions to appear in special sections. The @code{section}
3689 attribute specifies that a function lives in a particular section.
3690 For example, the declaration:
3691
3692 @smallexample
3693 extern void foobar (void) __attribute__ ((section ("bar")));
3694 @end smallexample
3695
3696 @noindent
3697 puts the function @code{foobar} in the @code{bar} section.
3698
3699 Some file formats do not support arbitrary sections so the @code{section}
3700 attribute is not available on all platforms.
3701 If you need to map the entire contents of a module to a particular
3702 section, consider using the facilities of the linker instead.
3703
3704 @item sentinel
3705 @cindex @code{sentinel} function attribute
3706 This function attribute ensures that a parameter in a function call is
3707 an explicit @code{NULL}. The attribute is only valid on variadic
3708 functions. By default, the sentinel is located at position zero, the
3709 last parameter of the function call. If an optional integer position
3710 argument P is supplied to the attribute, the sentinel must be located at
3711 position P counting backwards from the end of the argument list.
3712
3713 @smallexample
3714 __attribute__ ((sentinel))
3715 is equivalent to
3716 __attribute__ ((sentinel(0)))
3717 @end smallexample
3718
3719 The attribute is automatically set with a position of 0 for the built-in
3720 functions @code{execl} and @code{execlp}. The built-in function
3721 @code{execle} has the attribute set with a position of 1.
3722
3723 A valid @code{NULL} in this context is defined as zero with any pointer
3724 type. If your system defines the @code{NULL} macro with an integer type
3725 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3726 with a copy that redefines NULL appropriately.
3727
3728 The warnings for missing or incorrect sentinels are enabled with
3729 @option{-Wformat}.
3730
3731 @item short_call
3732 See @code{long_call/short_call}.
3733
3734 @item shortcall
3735 See @code{longcall/shortcall}.
3736
3737 @item signal
3738 @cindex interrupt handler functions on the AVR processors
3739 Use this attribute on the AVR to indicate that the specified
3740 function is an interrupt handler. The compiler generates function
3741 entry and exit sequences suitable for use in an interrupt handler when this
3742 attribute is present.
3743
3744 See also the @code{interrupt} function attribute.
3745
3746 The AVR hardware globally disables interrupts when an interrupt is executed.
3747 Interrupt handler functions defined with the @code{signal} attribute
3748 do not re-enable interrupts. It is save to enable interrupts in a
3749 @code{signal} handler. This ``save'' only applies to the code
3750 generated by the compiler and not to the IRQ layout of the
3751 application which is responsibility of the application.
3752
3753 If both @code{signal} and @code{interrupt} are specified for the same
3754 function, @code{signal} is silently ignored.
3755
3756 @item sp_switch
3757 @cindex @code{sp_switch} attribute
3758 Use this attribute on the SH to indicate an @code{interrupt_handler}
3759 function should switch to an alternate stack. It expects a string
3760 argument that names a global variable holding the address of the
3761 alternate stack.
3762
3763 @smallexample
3764 void *alt_stack;
3765 void f () __attribute__ ((interrupt_handler,
3766 sp_switch ("alt_stack")));
3767 @end smallexample
3768
3769 @item stdcall
3770 @cindex functions that pop the argument stack on the 386
3771 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3772 assume that the called function pops off the stack space used to
3773 pass arguments, unless it takes a variable number of arguments.
3774
3775 @item syscall_linkage
3776 @cindex @code{syscall_linkage} attribute
3777 This attribute is used to modify the IA-64 calling convention by marking
3778 all input registers as live at all function exits. This makes it possible
3779 to restart a system call after an interrupt without having to save/restore
3780 the input registers. This also prevents kernel data from leaking into
3781 application code.
3782
3783 @item target
3784 @cindex @code{target} function attribute
3785 The @code{target} attribute is used to specify that a function is to
3786 be compiled with different target options than specified on the
3787 command line. This can be used for instance to have functions
3788 compiled with a different ISA (instruction set architecture) than the
3789 default. You can also use the @samp{#pragma GCC target} pragma to set
3790 more than one function to be compiled with specific target options.
3791 @xref{Function Specific Option Pragmas}, for details about the
3792 @samp{#pragma GCC target} pragma.
3793
3794 For instance on a 386, you could compile one function with
3795 @code{target("sse4.1,arch=core2")} and another with
3796 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3797 compiling the first function with @option{-msse4.1} and
3798 @option{-march=core2} options, and the second function with
3799 @option{-msse4a} and @option{-march=amdfam10} options. It is up to the
3800 user to make sure that a function is only invoked on a machine that
3801 supports the particular ISA it is compiled for (for example by using
3802 @code{cpuid} on 386 to determine what feature bits and architecture
3803 family are used).
3804
3805 @smallexample
3806 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3807 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3808 @end smallexample
3809
3810 On the 386, the following options are allowed:
3811
3812 @table @samp
3813 @item abm
3814 @itemx no-abm
3815 @cindex @code{target("abm")} attribute
3816 Enable/disable the generation of the advanced bit instructions.
3817
3818 @item aes
3819 @itemx no-aes
3820 @cindex @code{target("aes")} attribute
3821 Enable/disable the generation of the AES instructions.
3822
3823 @item default
3824 @cindex @code{target("default")} attribute
3825 @xref{Function Multiversioning}, where it is used to specify the
3826 default function version.
3827
3828 @item mmx
3829 @itemx no-mmx
3830 @cindex @code{target("mmx")} attribute
3831 Enable/disable the generation of the MMX instructions.
3832
3833 @item pclmul
3834 @itemx no-pclmul
3835 @cindex @code{target("pclmul")} attribute
3836 Enable/disable the generation of the PCLMUL instructions.
3837
3838 @item popcnt
3839 @itemx no-popcnt
3840 @cindex @code{target("popcnt")} attribute
3841 Enable/disable the generation of the POPCNT instruction.
3842
3843 @item sse
3844 @itemx no-sse
3845 @cindex @code{target("sse")} attribute
3846 Enable/disable the generation of the SSE instructions.
3847
3848 @item sse2
3849 @itemx no-sse2
3850 @cindex @code{target("sse2")} attribute
3851 Enable/disable the generation of the SSE2 instructions.
3852
3853 @item sse3
3854 @itemx no-sse3
3855 @cindex @code{target("sse3")} attribute
3856 Enable/disable the generation of the SSE3 instructions.
3857
3858 @item sse4
3859 @itemx no-sse4
3860 @cindex @code{target("sse4")} attribute
3861 Enable/disable the generation of the SSE4 instructions (both SSE4.1
3862 and SSE4.2).
3863
3864 @item sse4.1
3865 @itemx no-sse4.1
3866 @cindex @code{target("sse4.1")} attribute
3867 Enable/disable the generation of the sse4.1 instructions.
3868
3869 @item sse4.2
3870 @itemx no-sse4.2
3871 @cindex @code{target("sse4.2")} attribute
3872 Enable/disable the generation of the sse4.2 instructions.
3873
3874 @item sse4a
3875 @itemx no-sse4a
3876 @cindex @code{target("sse4a")} attribute
3877 Enable/disable the generation of the SSE4A instructions.
3878
3879 @item fma4
3880 @itemx no-fma4
3881 @cindex @code{target("fma4")} attribute
3882 Enable/disable the generation of the FMA4 instructions.
3883
3884 @item xop
3885 @itemx no-xop
3886 @cindex @code{target("xop")} attribute
3887 Enable/disable the generation of the XOP instructions.
3888
3889 @item lwp
3890 @itemx no-lwp
3891 @cindex @code{target("lwp")} attribute
3892 Enable/disable the generation of the LWP instructions.
3893
3894 @item ssse3
3895 @itemx no-ssse3
3896 @cindex @code{target("ssse3")} attribute
3897 Enable/disable the generation of the SSSE3 instructions.
3898
3899 @item cld
3900 @itemx no-cld
3901 @cindex @code{target("cld")} attribute
3902 Enable/disable the generation of the CLD before string moves.
3903
3904 @item fancy-math-387
3905 @itemx no-fancy-math-387
3906 @cindex @code{target("fancy-math-387")} attribute
3907 Enable/disable the generation of the @code{sin}, @code{cos}, and
3908 @code{sqrt} instructions on the 387 floating-point unit.
3909
3910 @item fused-madd
3911 @itemx no-fused-madd
3912 @cindex @code{target("fused-madd")} attribute
3913 Enable/disable the generation of the fused multiply/add instructions.
3914
3915 @item ieee-fp
3916 @itemx no-ieee-fp
3917 @cindex @code{target("ieee-fp")} attribute
3918 Enable/disable the generation of floating point that depends on IEEE arithmetic.
3919
3920 @item inline-all-stringops
3921 @itemx no-inline-all-stringops
3922 @cindex @code{target("inline-all-stringops")} attribute
3923 Enable/disable inlining of string operations.
3924
3925 @item inline-stringops-dynamically
3926 @itemx no-inline-stringops-dynamically
3927 @cindex @code{target("inline-stringops-dynamically")} attribute
3928 Enable/disable the generation of the inline code to do small string
3929 operations and calling the library routines for large operations.
3930
3931 @item align-stringops
3932 @itemx no-align-stringops
3933 @cindex @code{target("align-stringops")} attribute
3934 Do/do not align destination of inlined string operations.
3935
3936 @item recip
3937 @itemx no-recip
3938 @cindex @code{target("recip")} attribute
3939 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
3940 instructions followed an additional Newton-Raphson step instead of
3941 doing a floating-point division.
3942
3943 @item arch=@var{ARCH}
3944 @cindex @code{target("arch=@var{ARCH}")} attribute
3945 Specify the architecture to generate code for in compiling the function.
3946
3947 @item tune=@var{TUNE}
3948 @cindex @code{target("tune=@var{TUNE}")} attribute
3949 Specify the architecture to tune for in compiling the function.
3950
3951 @item fpmath=@var{FPMATH}
3952 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
3953 Specify which floating-point unit to use. The
3954 @code{target("fpmath=sse,387")} option must be specified as
3955 @code{target("fpmath=sse+387")} because the comma would separate
3956 different options.
3957 @end table
3958
3959 On the PowerPC, the following options are allowed:
3960
3961 @table @samp
3962 @item altivec
3963 @itemx no-altivec
3964 @cindex @code{target("altivec")} attribute
3965 Generate code that uses (does not use) AltiVec instructions. In
3966 32-bit code, you cannot enable AltiVec instructions unless
3967 @option{-mabi=altivec} is used on the command line.
3968
3969 @item cmpb
3970 @itemx no-cmpb
3971 @cindex @code{target("cmpb")} attribute
3972 Generate code that uses (does not use) the compare bytes instruction
3973 implemented on the POWER6 processor and other processors that support
3974 the PowerPC V2.05 architecture.
3975
3976 @item dlmzb
3977 @itemx no-dlmzb
3978 @cindex @code{target("dlmzb")} attribute
3979 Generate code that uses (does not use) the string-search @samp{dlmzb}
3980 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
3981 generated by default when targeting those processors.
3982
3983 @item fprnd
3984 @itemx no-fprnd
3985 @cindex @code{target("fprnd")} attribute
3986 Generate code that uses (does not use) the FP round to integer
3987 instructions implemented on the POWER5+ processor and other processors
3988 that support the PowerPC V2.03 architecture.
3989
3990 @item hard-dfp
3991 @itemx no-hard-dfp
3992 @cindex @code{target("hard-dfp")} attribute
3993 Generate code that uses (does not use) the decimal floating-point
3994 instructions implemented on some POWER processors.
3995
3996 @item isel
3997 @itemx no-isel
3998 @cindex @code{target("isel")} attribute
3999 Generate code that uses (does not use) ISEL instruction.
4000
4001 @item mfcrf
4002 @itemx no-mfcrf
4003 @cindex @code{target("mfcrf")} attribute
4004 Generate code that uses (does not use) the move from condition
4005 register field instruction implemented on the POWER4 processor and
4006 other processors that support the PowerPC V2.01 architecture.
4007
4008 @item mfpgpr
4009 @itemx no-mfpgpr
4010 @cindex @code{target("mfpgpr")} attribute
4011 Generate code that uses (does not use) the FP move to/from general
4012 purpose register instructions implemented on the POWER6X processor and
4013 other processors that support the extended PowerPC V2.05 architecture.
4014
4015 @item mulhw
4016 @itemx no-mulhw
4017 @cindex @code{target("mulhw")} attribute
4018 Generate code that uses (does not use) the half-word multiply and
4019 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4020 These instructions are generated by default when targeting those
4021 processors.
4022
4023 @item multiple
4024 @itemx no-multiple
4025 @cindex @code{target("multiple")} attribute
4026 Generate code that uses (does not use) the load multiple word
4027 instructions and the store multiple word instructions.
4028
4029 @item update
4030 @itemx no-update
4031 @cindex @code{target("update")} attribute
4032 Generate code that uses (does not use) the load or store instructions
4033 that update the base register to the address of the calculated memory
4034 location.
4035
4036 @item popcntb
4037 @itemx no-popcntb
4038 @cindex @code{target("popcntb")} attribute
4039 Generate code that uses (does not use) the popcount and double-precision
4040 FP reciprocal estimate instruction implemented on the POWER5
4041 processor and other processors that support the PowerPC V2.02
4042 architecture.
4043
4044 @item popcntd
4045 @itemx no-popcntd
4046 @cindex @code{target("popcntd")} attribute
4047 Generate code that uses (does not use) the popcount instruction
4048 implemented on the POWER7 processor and other processors that support
4049 the PowerPC V2.06 architecture.
4050
4051 @item powerpc-gfxopt
4052 @itemx no-powerpc-gfxopt
4053 @cindex @code{target("powerpc-gfxopt")} attribute
4054 Generate code that uses (does not use) the optional PowerPC
4055 architecture instructions in the Graphics group, including
4056 floating-point select.
4057
4058 @item powerpc-gpopt
4059 @itemx no-powerpc-gpopt
4060 @cindex @code{target("powerpc-gpopt")} attribute
4061 Generate code that uses (does not use) the optional PowerPC
4062 architecture instructions in the General Purpose group, including
4063 floating-point square root.
4064
4065 @item recip-precision
4066 @itemx no-recip-precision
4067 @cindex @code{target("recip-precision")} attribute
4068 Assume (do not assume) that the reciprocal estimate instructions
4069 provide higher-precision estimates than is mandated by the powerpc
4070 ABI.
4071
4072 @item string
4073 @itemx no-string
4074 @cindex @code{target("string")} attribute
4075 Generate code that uses (does not use) the load string instructions
4076 and the store string word instructions to save multiple registers and
4077 do small block moves.
4078
4079 @item vsx
4080 @itemx no-vsx
4081 @cindex @code{target("vsx")} attribute
4082 Generate code that uses (does not use) vector/scalar (VSX)
4083 instructions, and also enable the use of built-in functions that allow
4084 more direct access to the VSX instruction set. In 32-bit code, you
4085 cannot enable VSX or AltiVec instructions unless
4086 @option{-mabi=altivec} is used on the command line.
4087
4088 @item friz
4089 @itemx no-friz
4090 @cindex @code{target("friz")} attribute
4091 Generate (do not generate) the @code{friz} instruction when the
4092 @option{-funsafe-math-optimizations} option is used to optimize
4093 rounding a floating-point value to 64-bit integer and back to floating
4094 point. The @code{friz} instruction does not return the same value if
4095 the floating-point number is too large to fit in an integer.
4096
4097 @item avoid-indexed-addresses
4098 @itemx no-avoid-indexed-addresses
4099 @cindex @code{target("avoid-indexed-addresses")} attribute
4100 Generate code that tries to avoid (not avoid) the use of indexed load
4101 or store instructions.
4102
4103 @item paired
4104 @itemx no-paired
4105 @cindex @code{target("paired")} attribute
4106 Generate code that uses (does not use) the generation of PAIRED simd
4107 instructions.
4108
4109 @item longcall
4110 @itemx no-longcall
4111 @cindex @code{target("longcall")} attribute
4112 Generate code that assumes (does not assume) that all calls are far
4113 away so that a longer more expensive calling sequence is required.
4114
4115 @item cpu=@var{CPU}
4116 @cindex @code{target("cpu=@var{CPU}")} attribute
4117 Specify the architecture to generate code for when compiling the
4118 function. If you select the @code{target("cpu=power7")} attribute when
4119 generating 32-bit code, VSX and AltiVec instructions are not generated
4120 unless you use the @option{-mabi=altivec} option on the command line.
4121
4122 @item tune=@var{TUNE}
4123 @cindex @code{target("tune=@var{TUNE}")} attribute
4124 Specify the architecture to tune for when compiling the function. If
4125 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4126 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4127 compilation tunes for the @var{CPU} architecture, and not the
4128 default tuning specified on the command line.
4129 @end table
4130
4131 On the 386/x86_64 and PowerPC back ends, you can use either multiple
4132 strings to specify multiple options, or you can separate the option
4133 with a comma (@code{,}).
4134
4135 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
4136 function that has different target options than the caller, unless the
4137 callee has a subset of the target options of the caller. For example
4138 a function declared with @code{target("sse3")} can inline a function
4139 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4140
4141 The @code{target} attribute is not implemented in GCC versions earlier
4142 than 4.4 for the i386/x86_64 and 4.6 for the PowerPC back ends. It is
4143 not currently implemented for other back ends.
4144
4145 @item tiny_data
4146 @cindex tiny data section on the H8/300H and H8S
4147 Use this attribute on the H8/300H and H8S to indicate that the specified
4148 variable should be placed into the tiny data section.
4149 The compiler generates more efficient code for loads and stores
4150 on data in the tiny data section. Note the tiny data area is limited to
4151 slightly under 32KB of data.
4152
4153 @item trap_exit
4154 @cindex @code{trap_exit} attribute
4155 Use this attribute on the SH for an @code{interrupt_handler} to return using
4156 @code{trapa} instead of @code{rte}. This attribute expects an integer
4157 argument specifying the trap number to be used.
4158
4159 @item trapa_handler
4160 @cindex @code{trapa_handler} attribute
4161 On SH targets this function attribute is similar to @code{interrupt_handler}
4162 but it does not save and restore all registers.
4163
4164 @item unused
4165 @cindex @code{unused} attribute.
4166 This attribute, attached to a function, means that the function is meant
4167 to be possibly unused. GCC does not produce a warning for this
4168 function.
4169
4170 @item used
4171 @cindex @code{used} attribute.
4172 This attribute, attached to a function, means that code must be emitted
4173 for the function even if it appears that the function is not referenced.
4174 This is useful, for example, when the function is referenced only in
4175 inline assembly.
4176
4177 When applied to a member function of a C++ class template, the
4178 attribute also means that the function is instantiated if the
4179 class itself is instantiated.
4180
4181 @item version_id
4182 @cindex @code{version_id} attribute
4183 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4184 symbol to contain a version string, thus allowing for function level
4185 versioning. HP-UX system header files may use function level versioning
4186 for some system calls.
4187
4188 @smallexample
4189 extern int foo () __attribute__((version_id ("20040821")));
4190 @end smallexample
4191
4192 @noindent
4193 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4194
4195 @item visibility ("@var{visibility_type}")
4196 @cindex @code{visibility} attribute
4197 This attribute affects the linkage of the declaration to which it is attached.
4198 There are four supported @var{visibility_type} values: default,
4199 hidden, protected or internal visibility.
4200
4201 @smallexample
4202 void __attribute__ ((visibility ("protected")))
4203 f () @{ /* @r{Do something.} */; @}
4204 int i __attribute__ ((visibility ("hidden")));
4205 @end smallexample
4206
4207 The possible values of @var{visibility_type} correspond to the
4208 visibility settings in the ELF gABI.
4209
4210 @table @dfn
4211 @c keep this list of visibilities in alphabetical order.
4212
4213 @item default
4214 Default visibility is the normal case for the object file format.
4215 This value is available for the visibility attribute to override other
4216 options that may change the assumed visibility of entities.
4217
4218 On ELF, default visibility means that the declaration is visible to other
4219 modules and, in shared libraries, means that the declared entity may be
4220 overridden.
4221
4222 On Darwin, default visibility means that the declaration is visible to
4223 other modules.
4224
4225 Default visibility corresponds to ``external linkage'' in the language.
4226
4227 @item hidden
4228 Hidden visibility indicates that the entity declared has a new
4229 form of linkage, which we call ``hidden linkage''. Two
4230 declarations of an object with hidden linkage refer to the same object
4231 if they are in the same shared object.
4232
4233 @item internal
4234 Internal visibility is like hidden visibility, but with additional
4235 processor specific semantics. Unless otherwise specified by the
4236 psABI, GCC defines internal visibility to mean that a function is
4237 @emph{never} called from another module. Compare this with hidden
4238 functions which, while they cannot be referenced directly by other
4239 modules, can be referenced indirectly via function pointers. By
4240 indicating that a function cannot be called from outside the module,
4241 GCC may for instance omit the load of a PIC register since it is known
4242 that the calling function loaded the correct value.
4243
4244 @item protected
4245 Protected visibility is like default visibility except that it
4246 indicates that references within the defining module bind to the
4247 definition in that module. That is, the declared entity cannot be
4248 overridden by another module.
4249
4250 @end table
4251
4252 All visibilities are supported on many, but not all, ELF targets
4253 (supported when the assembler supports the @samp{.visibility}
4254 pseudo-op). Default visibility is supported everywhere. Hidden
4255 visibility is supported on Darwin targets.
4256
4257 The visibility attribute should be applied only to declarations that
4258 would otherwise have external linkage. The attribute should be applied
4259 consistently, so that the same entity should not be declared with
4260 different settings of the attribute.
4261
4262 In C++, the visibility attribute applies to types as well as functions
4263 and objects, because in C++ types have linkage. A class must not have
4264 greater visibility than its non-static data member types and bases,
4265 and class members default to the visibility of their class. Also, a
4266 declaration without explicit visibility is limited to the visibility
4267 of its type.
4268
4269 In C++, you can mark member functions and static member variables of a
4270 class with the visibility attribute. This is useful if you know a
4271 particular method or static member variable should only be used from
4272 one shared object; then you can mark it hidden while the rest of the
4273 class has default visibility. Care must be taken to avoid breaking
4274 the One Definition Rule; for example, it is usually not useful to mark
4275 an inline method as hidden without marking the whole class as hidden.
4276
4277 A C++ namespace declaration can also have the visibility attribute.
4278 This attribute applies only to the particular namespace body, not to
4279 other definitions of the same namespace; it is equivalent to using
4280 @samp{#pragma GCC visibility} before and after the namespace
4281 definition (@pxref{Visibility Pragmas}).
4282
4283 In C++, if a template argument has limited visibility, this
4284 restriction is implicitly propagated to the template instantiation.
4285 Otherwise, template instantiations and specializations default to the
4286 visibility of their template.
4287
4288 If both the template and enclosing class have explicit visibility, the
4289 visibility from the template is used.
4290
4291 @item vliw
4292 @cindex @code{vliw} attribute
4293 On MeP, the @code{vliw} attribute tells the compiler to emit
4294 instructions in VLIW mode instead of core mode. Note that this
4295 attribute is not allowed unless a VLIW coprocessor has been configured
4296 and enabled through command-line options.
4297
4298 @item warn_unused_result
4299 @cindex @code{warn_unused_result} attribute
4300 The @code{warn_unused_result} attribute causes a warning to be emitted
4301 if a caller of the function with this attribute does not use its
4302 return value. This is useful for functions where not checking
4303 the result is either a security problem or always a bug, such as
4304 @code{realloc}.
4305
4306 @smallexample
4307 int fn () __attribute__ ((warn_unused_result));
4308 int foo ()
4309 @{
4310 if (fn () < 0) return -1;
4311 fn ();
4312 return 0;
4313 @}
4314 @end smallexample
4315
4316 @noindent
4317 results in warning on line 5.
4318
4319 @item weak
4320 @cindex @code{weak} attribute
4321 The @code{weak} attribute causes the declaration to be emitted as a weak
4322 symbol rather than a global. This is primarily useful in defining
4323 library functions that can be overridden in user code, though it can
4324 also be used with non-function declarations. Weak symbols are supported
4325 for ELF targets, and also for a.out targets when using the GNU assembler
4326 and linker.
4327
4328 @item weakref
4329 @itemx weakref ("@var{target}")
4330 @cindex @code{weakref} attribute
4331 The @code{weakref} attribute marks a declaration as a weak reference.
4332 Without arguments, it should be accompanied by an @code{alias} attribute
4333 naming the target symbol. Optionally, the @var{target} may be given as
4334 an argument to @code{weakref} itself. In either case, @code{weakref}
4335 implicitly marks the declaration as @code{weak}. Without a
4336 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4337 @code{weakref} is equivalent to @code{weak}.
4338
4339 @smallexample
4340 static int x() __attribute__ ((weakref ("y")));
4341 /* is equivalent to... */
4342 static int x() __attribute__ ((weak, weakref, alias ("y")));
4343 /* and to... */
4344 static int x() __attribute__ ((weakref));
4345 static int x() __attribute__ ((alias ("y")));
4346 @end smallexample
4347
4348 A weak reference is an alias that does not by itself require a
4349 definition to be given for the target symbol. If the target symbol is
4350 only referenced through weak references, then it becomes a @code{weak}
4351 undefined symbol. If it is directly referenced, however, then such
4352 strong references prevail, and a definition is required for the
4353 symbol, not necessarily in the same translation unit.
4354
4355 The effect is equivalent to moving all references to the alias to a
4356 separate translation unit, renaming the alias to the aliased symbol,
4357 declaring it as weak, compiling the two separate translation units and
4358 performing a reloadable link on them.
4359
4360 At present, a declaration to which @code{weakref} is attached can
4361 only be @code{static}.
4362
4363 @end table
4364
4365 You can specify multiple attributes in a declaration by separating them
4366 by commas within the double parentheses or by immediately following an
4367 attribute declaration with another attribute declaration.
4368
4369 @cindex @code{#pragma}, reason for not using
4370 @cindex pragma, reason for not using
4371 Some people object to the @code{__attribute__} feature, suggesting that
4372 ISO C's @code{#pragma} should be used instead. At the time
4373 @code{__attribute__} was designed, there were two reasons for not doing
4374 this.
4375
4376 @enumerate
4377 @item
4378 It is impossible to generate @code{#pragma} commands from a macro.
4379
4380 @item
4381 There is no telling what the same @code{#pragma} might mean in another
4382 compiler.
4383 @end enumerate
4384
4385 These two reasons applied to almost any application that might have been
4386 proposed for @code{#pragma}. It was basically a mistake to use
4387 @code{#pragma} for @emph{anything}.
4388
4389 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4390 to be generated from macros. In addition, a @code{#pragma GCC}
4391 namespace is now in use for GCC-specific pragmas. However, it has been
4392 found convenient to use @code{__attribute__} to achieve a natural
4393 attachment of attributes to their corresponding declarations, whereas
4394 @code{#pragma GCC} is of use for constructs that do not naturally form
4395 part of the grammar. @xref{Pragmas,,Pragmas Accepted by GCC}.
4396
4397 @node Attribute Syntax
4398 @section Attribute Syntax
4399 @cindex attribute syntax
4400
4401 This section describes the syntax with which @code{__attribute__} may be
4402 used, and the constructs to which attribute specifiers bind, for the C
4403 language. Some details may vary for C++ and Objective-C@. Because of
4404 infelicities in the grammar for attributes, some forms described here
4405 may not be successfully parsed in all cases.
4406
4407 There are some problems with the semantics of attributes in C++. For
4408 example, there are no manglings for attributes, although they may affect
4409 code generation, so problems may arise when attributed types are used in
4410 conjunction with templates or overloading. Similarly, @code{typeid}
4411 does not distinguish between types with different attributes. Support
4412 for attributes in C++ may be restricted in future to attributes on
4413 declarations only, but not on nested declarators.
4414
4415 @xref{Function Attributes}, for details of the semantics of attributes
4416 applying to functions. @xref{Variable Attributes}, for details of the
4417 semantics of attributes applying to variables. @xref{Type Attributes},
4418 for details of the semantics of attributes applying to structure, union
4419 and enumerated types.
4420
4421 An @dfn{attribute specifier} is of the form
4422 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
4423 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4424 each attribute is one of the following:
4425
4426 @itemize @bullet
4427 @item
4428 Empty. Empty attributes are ignored.
4429
4430 @item
4431 A word (which may be an identifier such as @code{unused}, or a reserved
4432 word such as @code{const}).
4433
4434 @item
4435 A word, followed by, in parentheses, parameters for the attribute.
4436 These parameters take one of the following forms:
4437
4438 @itemize @bullet
4439 @item
4440 An identifier. For example, @code{mode} attributes use this form.
4441
4442 @item
4443 An identifier followed by a comma and a non-empty comma-separated list
4444 of expressions. For example, @code{format} attributes use this form.
4445
4446 @item
4447 A possibly empty comma-separated list of expressions. For example,
4448 @code{format_arg} attributes use this form with the list being a single
4449 integer constant expression, and @code{alias} attributes use this form
4450 with the list being a single string constant.
4451 @end itemize
4452 @end itemize
4453
4454 An @dfn{attribute specifier list} is a sequence of one or more attribute
4455 specifiers, not separated by any other tokens.
4456
4457 In GNU C, an attribute specifier list may appear after the colon following a
4458 label, other than a @code{case} or @code{default} label. The only
4459 attribute it makes sense to use after a label is @code{unused}. This
4460 feature is intended for program-generated code that may contain unused labels,
4461 but which is compiled with @option{-Wall}. It is
4462 not normally appropriate to use in it human-written code, though it
4463 could be useful in cases where the code that jumps to the label is
4464 contained within an @code{#ifdef} conditional. GNU C++ only permits
4465 attributes on labels if the attribute specifier is immediately
4466 followed by a semicolon (i.e., the label applies to an empty
4467 statement). If the semicolon is missing, C++ label attributes are
4468 ambiguous, as it is permissible for a declaration, which could begin
4469 with an attribute list, to be labelled in C++. Declarations cannot be
4470 labelled in C90 or C99, so the ambiguity does not arise there.
4471
4472 An attribute specifier list may appear as part of a @code{struct},
4473 @code{union} or @code{enum} specifier. It may go either immediately
4474 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4475 the closing brace. The former syntax is preferred.
4476 Where attribute specifiers follow the closing brace, they are considered
4477 to relate to the structure, union or enumerated type defined, not to any
4478 enclosing declaration the type specifier appears in, and the type
4479 defined is not complete until after the attribute specifiers.
4480 @c Otherwise, there would be the following problems: a shift/reduce
4481 @c conflict between attributes binding the struct/union/enum and
4482 @c binding to the list of specifiers/qualifiers; and "aligned"
4483 @c attributes could use sizeof for the structure, but the size could be
4484 @c changed later by "packed" attributes.
4485
4486 Otherwise, an attribute specifier appears as part of a declaration,
4487 counting declarations of unnamed parameters and type names, and relates
4488 to that declaration (which may be nested in another declaration, for
4489 example in the case of a parameter declaration), or to a particular declarator
4490 within a declaration. Where an
4491 attribute specifier is applied to a parameter declared as a function or
4492 an array, it should apply to the function or array rather than the
4493 pointer to which the parameter is implicitly converted, but this is not
4494 yet correctly implemented.
4495
4496 Any list of specifiers and qualifiers at the start of a declaration may
4497 contain attribute specifiers, whether or not such a list may in that
4498 context contain storage class specifiers. (Some attributes, however,
4499 are essentially in the nature of storage class specifiers, and only make
4500 sense where storage class specifiers may be used; for example,
4501 @code{section}.) There is one necessary limitation to this syntax: the
4502 first old-style parameter declaration in a function definition cannot
4503 begin with an attribute specifier, because such an attribute applies to
4504 the function instead by syntax described below (which, however, is not
4505 yet implemented in this case). In some other cases, attribute
4506 specifiers are permitted by this grammar but not yet supported by the
4507 compiler. All attribute specifiers in this place relate to the
4508 declaration as a whole. In the obsolescent usage where a type of
4509 @code{int} is implied by the absence of type specifiers, such a list of
4510 specifiers and qualifiers may be an attribute specifier list with no
4511 other specifiers or qualifiers.
4512
4513 At present, the first parameter in a function prototype must have some
4514 type specifier that is not an attribute specifier; this resolves an
4515 ambiguity in the interpretation of @code{void f(int
4516 (__attribute__((foo)) x))}, but is subject to change. At present, if
4517 the parentheses of a function declarator contain only attributes then
4518 those attributes are ignored, rather than yielding an error or warning
4519 or implying a single parameter of type int, but this is subject to
4520 change.
4521
4522 An attribute specifier list may appear immediately before a declarator
4523 (other than the first) in a comma-separated list of declarators in a
4524 declaration of more than one identifier using a single list of
4525 specifiers and qualifiers. Such attribute specifiers apply
4526 only to the identifier before whose declarator they appear. For
4527 example, in
4528
4529 @smallexample
4530 __attribute__((noreturn)) void d0 (void),
4531 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4532 d2 (void)
4533 @end smallexample
4534
4535 @noindent
4536 the @code{noreturn} attribute applies to all the functions
4537 declared; the @code{format} attribute only applies to @code{d1}.
4538
4539 An attribute specifier list may appear immediately before the comma,
4540 @code{=} or semicolon terminating the declaration of an identifier other
4541 than a function definition. Such attribute specifiers apply
4542 to the declared object or function. Where an
4543 assembler name for an object or function is specified (@pxref{Asm
4544 Labels}), the attribute must follow the @code{asm}
4545 specification.
4546
4547 An attribute specifier list may, in future, be permitted to appear after
4548 the declarator in a function definition (before any old-style parameter
4549 declarations or the function body).
4550
4551 Attribute specifiers may be mixed with type qualifiers appearing inside
4552 the @code{[]} of a parameter array declarator, in the C99 construct by
4553 which such qualifiers are applied to the pointer to which the array is
4554 implicitly converted. Such attribute specifiers apply to the pointer,
4555 not to the array, but at present this is not implemented and they are
4556 ignored.
4557
4558 An attribute specifier list may appear at the start of a nested
4559 declarator. At present, there are some limitations in this usage: the
4560 attributes correctly apply to the declarator, but for most individual
4561 attributes the semantics this implies are not implemented.
4562 When attribute specifiers follow the @code{*} of a pointer
4563 declarator, they may be mixed with any type qualifiers present.
4564 The following describes the formal semantics of this syntax. It makes the
4565 most sense if you are familiar with the formal specification of
4566 declarators in the ISO C standard.
4567
4568 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4569 D1}, where @code{T} contains declaration specifiers that specify a type
4570 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4571 contains an identifier @var{ident}. The type specified for @var{ident}
4572 for derived declarators whose type does not include an attribute
4573 specifier is as in the ISO C standard.
4574
4575 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4576 and the declaration @code{T D} specifies the type
4577 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4578 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4579 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4580
4581 If @code{D1} has the form @code{*
4582 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4583 declaration @code{T D} specifies the type
4584 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4585 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4586 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4587 @var{ident}.
4588
4589 For example,
4590
4591 @smallexample
4592 void (__attribute__((noreturn)) ****f) (void);
4593 @end smallexample
4594
4595 @noindent
4596 specifies the type ``pointer to pointer to pointer to pointer to
4597 non-returning function returning @code{void}''. As another example,
4598
4599 @smallexample
4600 char *__attribute__((aligned(8))) *f;
4601 @end smallexample
4602
4603 @noindent
4604 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4605 Note again that this does not work with most attributes; for example,
4606 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4607 is not yet supported.
4608
4609 For compatibility with existing code written for compiler versions that
4610 did not implement attributes on nested declarators, some laxity is
4611 allowed in the placing of attributes. If an attribute that only applies
4612 to types is applied to a declaration, it is treated as applying to
4613 the type of that declaration. If an attribute that only applies to
4614 declarations is applied to the type of a declaration, it is treated
4615 as applying to that declaration; and, for compatibility with code
4616 placing the attributes immediately before the identifier declared, such
4617 an attribute applied to a function return type is treated as
4618 applying to the function type, and such an attribute applied to an array
4619 element type is treated as applying to the array type. If an
4620 attribute that only applies to function types is applied to a
4621 pointer-to-function type, it is treated as applying to the pointer
4622 target type; if such an attribute is applied to a function return type
4623 that is not a pointer-to-function type, it is treated as applying
4624 to the function type.
4625
4626 @node Function Prototypes
4627 @section Prototypes and Old-Style Function Definitions
4628 @cindex function prototype declarations
4629 @cindex old-style function definitions
4630 @cindex promotion of formal parameters
4631
4632 GNU C extends ISO C to allow a function prototype to override a later
4633 old-style non-prototype definition. Consider the following example:
4634
4635 @smallexample
4636 /* @r{Use prototypes unless the compiler is old-fashioned.} */
4637 #ifdef __STDC__
4638 #define P(x) x
4639 #else
4640 #define P(x) ()
4641 #endif
4642
4643 /* @r{Prototype function declaration.} */
4644 int isroot P((uid_t));
4645
4646 /* @r{Old-style function definition.} */
4647 int
4648 isroot (x) /* @r{??? lossage here ???} */
4649 uid_t x;
4650 @{
4651 return x == 0;
4652 @}
4653 @end smallexample
4654
4655 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
4656 not allow this example, because subword arguments in old-style
4657 non-prototype definitions are promoted. Therefore in this example the
4658 function definition's argument is really an @code{int}, which does not
4659 match the prototype argument type of @code{short}.
4660
4661 This restriction of ISO C makes it hard to write code that is portable
4662 to traditional C compilers, because the programmer does not know
4663 whether the @code{uid_t} type is @code{short}, @code{int}, or
4664 @code{long}. Therefore, in cases like these GNU C allows a prototype
4665 to override a later old-style definition. More precisely, in GNU C, a
4666 function prototype argument type overrides the argument type specified
4667 by a later old-style definition if the former type is the same as the
4668 latter type before promotion. Thus in GNU C the above example is
4669 equivalent to the following:
4670
4671 @smallexample
4672 int isroot (uid_t);
4673
4674 int
4675 isroot (uid_t x)
4676 @{
4677 return x == 0;
4678 @}
4679 @end smallexample
4680
4681 @noindent
4682 GNU C++ does not support old-style function definitions, so this
4683 extension is irrelevant.
4684
4685 @node C++ Comments
4686 @section C++ Style Comments
4687 @cindex @code{//}
4688 @cindex C++ comments
4689 @cindex comments, C++ style
4690
4691 In GNU C, you may use C++ style comments, which start with @samp{//} and
4692 continue until the end of the line. Many other C implementations allow
4693 such comments, and they are included in the 1999 C standard. However,
4694 C++ style comments are not recognized if you specify an @option{-std}
4695 option specifying a version of ISO C before C99, or @option{-ansi}
4696 (equivalent to @option{-std=c90}).
4697
4698 @node Dollar Signs
4699 @section Dollar Signs in Identifier Names
4700 @cindex $
4701 @cindex dollar signs in identifier names
4702 @cindex identifier names, dollar signs in
4703
4704 In GNU C, you may normally use dollar signs in identifier names.
4705 This is because many traditional C implementations allow such identifiers.
4706 However, dollar signs in identifiers are not supported on a few target
4707 machines, typically because the target assembler does not allow them.
4708
4709 @node Character Escapes
4710 @section The Character @key{ESC} in Constants
4711
4712 You can use the sequence @samp{\e} in a string or character constant to
4713 stand for the ASCII character @key{ESC}.
4714
4715 @node Variable Attributes
4716 @section Specifying Attributes of Variables
4717 @cindex attribute of variables
4718 @cindex variable attributes
4719
4720 The keyword @code{__attribute__} allows you to specify special
4721 attributes of variables or structure fields. This keyword is followed
4722 by an attribute specification inside double parentheses. Some
4723 attributes are currently defined generically for variables.
4724 Other attributes are defined for variables on particular target
4725 systems. Other attributes are available for functions
4726 (@pxref{Function Attributes}) and for types (@pxref{Type Attributes}).
4727 Other front ends might define more attributes
4728 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4729
4730 You may also specify attributes with @samp{__} preceding and following
4731 each keyword. This allows you to use them in header files without
4732 being concerned about a possible macro of the same name. For example,
4733 you may use @code{__aligned__} instead of @code{aligned}.
4734
4735 @xref{Attribute Syntax}, for details of the exact syntax for using
4736 attributes.
4737
4738 @table @code
4739 @cindex @code{aligned} attribute
4740 @item aligned (@var{alignment})
4741 This attribute specifies a minimum alignment for the variable or
4742 structure field, measured in bytes. For example, the declaration:
4743
4744 @smallexample
4745 int x __attribute__ ((aligned (16))) = 0;
4746 @end smallexample
4747
4748 @noindent
4749 causes the compiler to allocate the global variable @code{x} on a
4750 16-byte boundary. On a 68040, this could be used in conjunction with
4751 an @code{asm} expression to access the @code{move16} instruction which
4752 requires 16-byte aligned operands.
4753
4754 You can also specify the alignment of structure fields. For example, to
4755 create a double-word aligned @code{int} pair, you could write:
4756
4757 @smallexample
4758 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
4759 @end smallexample
4760
4761 @noindent
4762 This is an alternative to creating a union with a @code{double} member,
4763 which forces the union to be double-word aligned.
4764
4765 As in the preceding examples, you can explicitly specify the alignment
4766 (in bytes) that you wish the compiler to use for a given variable or
4767 structure field. Alternatively, you can leave out the alignment factor
4768 and just ask the compiler to align a variable or field to the
4769 default alignment for the target architecture you are compiling for.
4770 The default alignment is sufficient for all scalar types, but may not be
4771 enough for all vector types on a target that supports vector operations.
4772 The default alignment is fixed for a particular target ABI.
4773
4774 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
4775 which is the largest alignment ever used for any data type on the
4776 target machine you are compiling for. For example, you could write:
4777
4778 @smallexample
4779 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
4780 @end smallexample
4781
4782 The compiler automatically sets the alignment for the declared
4783 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
4784 often make copy operations more efficient, because the compiler can
4785 use whatever instructions copy the biggest chunks of memory when
4786 performing copies to or from the variables or fields that you have
4787 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
4788 may change depending on command-line options.
4789
4790 When used on a struct, or struct member, the @code{aligned} attribute can
4791 only increase the alignment; in order to decrease it, the @code{packed}
4792 attribute must be specified as well. When used as part of a typedef, the
4793 @code{aligned} attribute can both increase and decrease alignment, and
4794 specifying the @code{packed} attribute generates a warning.
4795
4796 Note that the effectiveness of @code{aligned} attributes may be limited
4797 by inherent limitations in your linker. On many systems, the linker is
4798 only able to arrange for variables to be aligned up to a certain maximum
4799 alignment. (For some linkers, the maximum supported alignment may
4800 be very very small.) If your linker is only able to align variables
4801 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
4802 in an @code{__attribute__} still only provides you with 8-byte
4803 alignment. See your linker documentation for further information.
4804
4805 The @code{aligned} attribute can also be used for functions
4806 (@pxref{Function Attributes}.)
4807
4808 @item cleanup (@var{cleanup_function})
4809 @cindex @code{cleanup} attribute
4810 The @code{cleanup} attribute runs a function when the variable goes
4811 out of scope. This attribute can only be applied to auto function
4812 scope variables; it may not be applied to parameters or variables
4813 with static storage duration. The function must take one parameter,
4814 a pointer to a type compatible with the variable. The return value
4815 of the function (if any) is ignored.
4816
4817 If @option{-fexceptions} is enabled, then @var{cleanup_function}
4818 is run during the stack unwinding that happens during the
4819 processing of the exception. Note that the @code{cleanup} attribute
4820 does not allow the exception to be caught, only to perform an action.
4821 It is undefined what happens if @var{cleanup_function} does not
4822 return normally.
4823
4824 @item common
4825 @itemx nocommon
4826 @cindex @code{common} attribute
4827 @cindex @code{nocommon} attribute
4828 @opindex fcommon
4829 @opindex fno-common
4830 The @code{common} attribute requests GCC to place a variable in
4831 ``common'' storage. The @code{nocommon} attribute requests the
4832 opposite---to allocate space for it directly.
4833
4834 These attributes override the default chosen by the
4835 @option{-fno-common} and @option{-fcommon} flags respectively.
4836
4837 @item deprecated
4838 @itemx deprecated (@var{msg})
4839 @cindex @code{deprecated} attribute
4840 The @code{deprecated} attribute results in a warning if the variable
4841 is used anywhere in the source file. This is useful when identifying
4842 variables that are expected to be removed in a future version of a
4843 program. The warning also includes the location of the declaration
4844 of the deprecated variable, to enable users to easily find further
4845 information about why the variable is deprecated, or what they should
4846 do instead. Note that the warning only occurs for uses:
4847
4848 @smallexample
4849 extern int old_var __attribute__ ((deprecated));
4850 extern int old_var;
4851 int new_fn () @{ return old_var; @}
4852 @end smallexample
4853
4854 @noindent
4855 results in a warning on line 3 but not line 2. The optional @var{msg}
4856 argument, which must be a string, is printed in the warning if
4857 present.
4858
4859 The @code{deprecated} attribute can also be used for functions and
4860 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
4861
4862 @item mode (@var{mode})
4863 @cindex @code{mode} attribute
4864 This attribute specifies the data type for the declaration---whichever
4865 type corresponds to the mode @var{mode}. This in effect lets you
4866 request an integer or floating-point type according to its width.
4867
4868 You may also specify a mode of @code{byte} or @code{__byte__} to
4869 indicate the mode corresponding to a one-byte integer, @code{word} or
4870 @code{__word__} for the mode of a one-word integer, and @code{pointer}
4871 or @code{__pointer__} for the mode used to represent pointers.
4872
4873 @item packed
4874 @cindex @code{packed} attribute
4875 The @code{packed} attribute specifies that a variable or structure field
4876 should have the smallest possible alignment---one byte for a variable,
4877 and one bit for a field, unless you specify a larger value with the
4878 @code{aligned} attribute.
4879
4880 Here is a structure in which the field @code{x} is packed, so that it
4881 immediately follows @code{a}:
4882
4883 @smallexample
4884 struct foo
4885 @{
4886 char a;
4887 int x[2] __attribute__ ((packed));
4888 @};
4889 @end smallexample
4890
4891 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
4892 @code{packed} attribute on bit-fields of type @code{char}. This has
4893 been fixed in GCC 4.4 but the change can lead to differences in the
4894 structure layout. See the documentation of
4895 @option{-Wpacked-bitfield-compat} for more information.
4896
4897 @item section ("@var{section-name}")
4898 @cindex @code{section} variable attribute
4899 Normally, the compiler places the objects it generates in sections like
4900 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
4901 or you need certain particular variables to appear in special sections,
4902 for example to map to special hardware. The @code{section}
4903 attribute specifies that a variable (or function) lives in a particular
4904 section. For example, this small program uses several specific section names:
4905
4906 @smallexample
4907 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
4908 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
4909 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
4910 int init_data __attribute__ ((section ("INITDATA")));
4911
4912 main()
4913 @{
4914 /* @r{Initialize stack pointer} */
4915 init_sp (stack + sizeof (stack));
4916
4917 /* @r{Initialize initialized data} */
4918 memcpy (&init_data, &data, &edata - &data);
4919
4920 /* @r{Turn on the serial ports} */
4921 init_duart (&a);
4922 init_duart (&b);
4923 @}
4924 @end smallexample
4925
4926 @noindent
4927 Use the @code{section} attribute with
4928 @emph{global} variables and not @emph{local} variables,
4929 as shown in the example.
4930
4931 You may use the @code{section} attribute with initialized or
4932 uninitialized global variables but the linker requires
4933 each object be defined once, with the exception that uninitialized
4934 variables tentatively go in the @code{common} (or @code{bss}) section
4935 and can be multiply ``defined''. Using the @code{section} attribute
4936 changes what section the variable goes into and may cause the
4937 linker to issue an error if an uninitialized variable has multiple
4938 definitions. You can force a variable to be initialized with the
4939 @option{-fno-common} flag or the @code{nocommon} attribute.
4940
4941 Some file formats do not support arbitrary sections so the @code{section}
4942 attribute is not available on all platforms.
4943 If you need to map the entire contents of a module to a particular
4944 section, consider using the facilities of the linker instead.
4945
4946 @item shared
4947 @cindex @code{shared} variable attribute
4948 On Microsoft Windows, in addition to putting variable definitions in a named
4949 section, the section can also be shared among all running copies of an
4950 executable or DLL@. For example, this small program defines shared data
4951 by putting it in a named section @code{shared} and marking the section
4952 shareable:
4953
4954 @smallexample
4955 int foo __attribute__((section ("shared"), shared)) = 0;
4956
4957 int
4958 main()
4959 @{
4960 /* @r{Read and write foo. All running
4961 copies see the same value.} */
4962 return 0;
4963 @}
4964 @end smallexample
4965
4966 @noindent
4967 You may only use the @code{shared} attribute along with @code{section}
4968 attribute with a fully-initialized global definition because of the way
4969 linkers work. See @code{section} attribute for more information.
4970
4971 The @code{shared} attribute is only available on Microsoft Windows@.
4972
4973 @item tls_model ("@var{tls_model}")
4974 @cindex @code{tls_model} attribute
4975 The @code{tls_model} attribute sets thread-local storage model
4976 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
4977 overriding @option{-ftls-model=} command-line switch on a per-variable
4978 basis.
4979 The @var{tls_model} argument should be one of @code{global-dynamic},
4980 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
4981
4982 Not all targets support this attribute.
4983
4984 @item unused
4985 This attribute, attached to a variable, means that the variable is meant
4986 to be possibly unused. GCC does not produce a warning for this
4987 variable.
4988
4989 @item used
4990 This attribute, attached to a variable with the static storage, means that
4991 the variable must be emitted even if it appears that the variable is not
4992 referenced.
4993
4994 When applied to a static data member of a C++ class template, the
4995 attribute also means that the member is instantiated if the
4996 class itself is instantiated.
4997
4998 @item vector_size (@var{bytes})
4999 This attribute specifies the vector size for the variable, measured in
5000 bytes. For example, the declaration:
5001
5002 @smallexample
5003 int foo __attribute__ ((vector_size (16)));
5004 @end smallexample
5005
5006 @noindent
5007 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5008 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5009 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5010
5011 This attribute is only applicable to integral and float scalars,
5012 although arrays, pointers, and function return values are allowed in
5013 conjunction with this construct.
5014
5015 Aggregates with this attribute are invalid, even if they are of the same
5016 size as a corresponding scalar. For example, the declaration:
5017
5018 @smallexample
5019 struct S @{ int a; @};
5020 struct S __attribute__ ((vector_size (16))) foo;
5021 @end smallexample
5022
5023 @noindent
5024 is invalid even if the size of the structure is the same as the size of
5025 the @code{int}.
5026
5027 @item selectany
5028 The @code{selectany} attribute causes an initialized global variable to
5029 have link-once semantics. When multiple definitions of the variable are
5030 encountered by the linker, the first is selected and the remainder are
5031 discarded. Following usage by the Microsoft compiler, the linker is told
5032 @emph{not} to warn about size or content differences of the multiple
5033 definitions.
5034
5035 Although the primary usage of this attribute is for POD types, the
5036 attribute can also be applied to global C++ objects that are initialized
5037 by a constructor. In this case, the static initialization and destruction
5038 code for the object is emitted in each translation defining the object,
5039 but the calls to the constructor and destructor are protected by a
5040 link-once guard variable.
5041
5042 The @code{selectany} attribute is only available on Microsoft Windows
5043 targets. You can use @code{__declspec (selectany)} as a synonym for
5044 @code{__attribute__ ((selectany))} for compatibility with other
5045 compilers.
5046
5047 @item weak
5048 The @code{weak} attribute is described in @ref{Function Attributes}.
5049
5050 @item dllimport
5051 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5052
5053 @item dllexport
5054 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5055
5056 @end table
5057
5058 @anchor{AVR Variable Attributes}
5059 @subsection AVR Variable Attributes
5060
5061 @table @code
5062 @item progmem
5063 @cindex @code{progmem} AVR variable attribute
5064 The @code{progmem} attribute is used on the AVR to place read-only
5065 data in the non-volatile program memory (flash). The @code{progmem}
5066 attribute accomplishes this by putting respective variables into a
5067 section whose name starts with @code{.progmem}.
5068
5069 This attribute works similar to the @code{section} attribute
5070 but adds additional checking. Notice that just like the
5071 @code{section} attribute, @code{progmem} affects the location
5072 of the data but not how this data is accessed.
5073
5074 In order to read data located with the @code{progmem} attribute
5075 (inline) assembler must be used.
5076 @smallexample
5077 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5078 #include <avr/pgmspace.h>
5079
5080 /* Locate var in flash memory */
5081 const int var[2] PROGMEM = @{ 1, 2 @};
5082
5083 int read_var (int i)
5084 @{
5085 /* Access var[] by accessor macro from avr/pgmspace.h */
5086 return (int) pgm_read_word (& var[i]);
5087 @}
5088 @end smallexample
5089
5090 AVR is a Harvard architecture processor and data and read-only data
5091 normally resides in the data memory (RAM).
5092
5093 See also the @ref{AVR Named Address Spaces} section for
5094 an alternate way to locate and access data in flash memory.
5095 @end table
5096
5097 @subsection Blackfin Variable Attributes
5098
5099 Three attributes are currently defined for the Blackfin.
5100
5101 @table @code
5102 @item l1_data
5103 @itemx l1_data_A
5104 @itemx l1_data_B
5105 @cindex @code{l1_data} variable attribute
5106 @cindex @code{l1_data_A} variable attribute
5107 @cindex @code{l1_data_B} variable attribute
5108 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5109 Variables with @code{l1_data} attribute are put into the specific section
5110 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5111 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5112 attribute are put into the specific section named @code{.l1.data.B}.
5113
5114 @item l2
5115 @cindex @code{l2} variable attribute
5116 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5117 Variables with @code{l2} attribute are put into the specific section
5118 named @code{.l2.data}.
5119 @end table
5120
5121 @subsection M32R/D Variable Attributes
5122
5123 One attribute is currently defined for the M32R/D@.
5124
5125 @table @code
5126 @item model (@var{model-name})
5127 @cindex variable addressability on the M32R/D
5128 Use this attribute on the M32R/D to set the addressability of an object.
5129 The identifier @var{model-name} is one of @code{small}, @code{medium},
5130 or @code{large}, representing each of the code models.
5131
5132 Small model objects live in the lower 16MB of memory (so that their
5133 addresses can be loaded with the @code{ld24} instruction).
5134
5135 Medium and large model objects may live anywhere in the 32-bit address space
5136 (the compiler generates @code{seth/add3} instructions to load their
5137 addresses).
5138 @end table
5139
5140 @anchor{MeP Variable Attributes}
5141 @subsection MeP Variable Attributes
5142
5143 The MeP target has a number of addressing modes and busses. The
5144 @code{near} space spans the standard memory space's first 16 megabytes
5145 (24 bits). The @code{far} space spans the entire 32-bit memory space.
5146 The @code{based} space is a 128-byte region in the memory space that
5147 is addressed relative to the @code{$tp} register. The @code{tiny}
5148 space is a 65536-byte region relative to the @code{$gp} register. In
5149 addition to these memory regions, the MeP target has a separate 16-bit
5150 control bus which is specified with @code{cb} attributes.
5151
5152 @table @code
5153
5154 @item based
5155 Any variable with the @code{based} attribute is assigned to the
5156 @code{.based} section, and is accessed with relative to the
5157 @code{$tp} register.
5158
5159 @item tiny
5160 Likewise, the @code{tiny} attribute assigned variables to the
5161 @code{.tiny} section, relative to the @code{$gp} register.
5162
5163 @item near
5164 Variables with the @code{near} attribute are assumed to have addresses
5165 that fit in a 24-bit addressing mode. This is the default for large
5166 variables (@code{-mtiny=4} is the default) but this attribute can
5167 override @code{-mtiny=} for small variables, or override @code{-ml}.
5168
5169 @item far
5170 Variables with the @code{far} attribute are addressed using a full
5171 32-bit address. Since this covers the entire memory space, this
5172 allows modules to make no assumptions about where variables might be
5173 stored.
5174
5175 @item io
5176 @itemx io (@var{addr})
5177 Variables with the @code{io} attribute are used to address
5178 memory-mapped peripherals. If an address is specified, the variable
5179 is assigned that address, else it is not assigned an address (it is
5180 assumed some other module assigns an address). Example:
5181
5182 @smallexample
5183 int timer_count __attribute__((io(0x123)));
5184 @end smallexample
5185
5186 @item cb
5187 @itemx cb (@var{addr})
5188 Variables with the @code{cb} attribute are used to access the control
5189 bus, using special instructions. @code{addr} indicates the control bus
5190 address. Example:
5191
5192 @smallexample
5193 int cpu_clock __attribute__((cb(0x123)));
5194 @end smallexample
5195
5196 @end table
5197
5198 @anchor{i386 Variable Attributes}
5199 @subsection i386 Variable Attributes
5200
5201 Two attributes are currently defined for i386 configurations:
5202 @code{ms_struct} and @code{gcc_struct}
5203
5204 @table @code
5205 @item ms_struct
5206 @itemx gcc_struct
5207 @cindex @code{ms_struct} attribute
5208 @cindex @code{gcc_struct} attribute
5209
5210 If @code{packed} is used on a structure, or if bit-fields are used,
5211 it may be that the Microsoft ABI lays out the structure differently
5212 than the way GCC normally does. Particularly when moving packed
5213 data between functions compiled with GCC and the native Microsoft compiler
5214 (either via function call or as data in a file), it may be necessary to access
5215 either format.
5216
5217 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5218 compilers to match the native Microsoft compiler.
5219
5220 The Microsoft structure layout algorithm is fairly simple with the exception
5221 of the bit-field packing.
5222 The padding and alignment of members of structures and whether a bit-field
5223 can straddle a storage-unit boundary are determine by these rules:
5224
5225 @enumerate
5226 @item Structure members are stored sequentially in the order in which they are
5227 declared: the first member has the lowest memory address and the last member
5228 the highest.
5229
5230 @item Every data object has an alignment requirement. The alignment requirement
5231 for all data except structures, unions, and arrays is either the size of the
5232 object or the current packing size (specified with either the
5233 @code{aligned} attribute or the @code{pack} pragma),
5234 whichever is less. For structures, unions, and arrays,
5235 the alignment requirement is the largest alignment requirement of its members.
5236 Every object is allocated an offset so that:
5237
5238 @smallexample
5239 offset % alignment_requirement == 0
5240 @end smallexample
5241
5242 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5243 unit if the integral types are the same size and if the next bit-field fits
5244 into the current allocation unit without crossing the boundary imposed by the
5245 common alignment requirements of the bit-fields.
5246 @end enumerate
5247
5248 MSVC interprets zero-length bit-fields in the following ways:
5249
5250 @enumerate
5251 @item If a zero-length bit-field is inserted between two bit-fields that
5252 are normally coalesced, the bit-fields are not coalesced.
5253
5254 For example:
5255
5256 @smallexample
5257 struct
5258 @{
5259 unsigned long bf_1 : 12;
5260 unsigned long : 0;
5261 unsigned long bf_2 : 12;
5262 @} t1;
5263 @end smallexample
5264
5265 @noindent
5266 The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
5267 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5268
5269 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5270 alignment of the zero-length bit-field is greater than the member that follows it,
5271 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5272
5273 For example:
5274
5275 @smallexample
5276 struct
5277 @{
5278 char foo : 4;
5279 short : 0;
5280 char bar;
5281 @} t2;
5282
5283 struct
5284 @{
5285 char foo : 4;
5286 short : 0;
5287 double bar;
5288 @} t3;
5289 @end smallexample
5290
5291 @noindent
5292 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5293 Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
5294 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5295 of the structure.
5296
5297 Taking this into account, it is important to note the following:
5298
5299 @enumerate
5300 @item If a zero-length bit-field follows a normal bit-field, the type of the
5301 zero-length bit-field may affect the alignment of the structure as whole. For
5302 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5303 normal bit-field, and is of type short.
5304
5305 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5306 still affect the alignment of the structure:
5307
5308 @smallexample
5309 struct
5310 @{
5311 char foo : 6;
5312 long : 0;
5313 @} t4;
5314 @end smallexample
5315
5316 @noindent
5317 Here, @code{t4} takes up 4 bytes.
5318 @end enumerate
5319
5320 @item Zero-length bit-fields following non-bit-field members are ignored:
5321
5322 @smallexample
5323 struct
5324 @{
5325 char foo;
5326 long : 0;
5327 char bar;
5328 @} t5;
5329 @end smallexample
5330
5331 @noindent
5332 Here, @code{t5} takes up 2 bytes.
5333 @end enumerate
5334 @end table
5335
5336 @subsection PowerPC Variable Attributes
5337
5338 Three attributes currently are defined for PowerPC configurations:
5339 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5340
5341 For full documentation of the struct attributes please see the
5342 documentation in @ref{i386 Variable Attributes}.
5343
5344 For documentation of @code{altivec} attribute please see the
5345 documentation in @ref{PowerPC Type Attributes}.
5346
5347 @subsection SPU Variable Attributes
5348
5349 The SPU supports the @code{spu_vector} attribute for variables. For
5350 documentation of this attribute please see the documentation in
5351 @ref{SPU Type Attributes}.
5352
5353 @subsection Xstormy16 Variable Attributes
5354
5355 One attribute is currently defined for xstormy16 configurations:
5356 @code{below100}.
5357
5358 @table @code
5359 @item below100
5360 @cindex @code{below100} attribute
5361
5362 If a variable has the @code{below100} attribute (@code{BELOW100} is
5363 allowed also), GCC places the variable in the first 0x100 bytes of
5364 memory and use special opcodes to access it. Such variables are
5365 placed in either the @code{.bss_below100} section or the
5366 @code{.data_below100} section.
5367
5368 @end table
5369
5370 @node Type Attributes
5371 @section Specifying Attributes of Types
5372 @cindex attribute of types
5373 @cindex type attributes
5374
5375 The keyword @code{__attribute__} allows you to specify special
5376 attributes of @code{struct} and @code{union} types when you define
5377 such types. This keyword is followed by an attribute specification
5378 inside double parentheses. Eight attributes are currently defined for
5379 types: @code{aligned}, @code{packed}, @code{transparent_union},
5380 @code{unused}, @code{deprecated}, @code{visibility}, @code{may_alias}
5381 and @code{bnd_variable_size}. Other attributes are defined for
5382 functions (@pxref{Function Attributes}) and for variables
5383 (@pxref{Variable Attributes}).
5384
5385 You may also specify any one of these attributes with @samp{__}
5386 preceding and following its keyword. This allows you to use these
5387 attributes in header files without being concerned about a possible
5388 macro of the same name. For example, you may use @code{__aligned__}
5389 instead of @code{aligned}.
5390
5391 You may specify type attributes in an enum, struct or union type
5392 declaration or definition, or for other types in a @code{typedef}
5393 declaration.
5394
5395 For an enum, struct or union type, you may specify attributes either
5396 between the enum, struct or union tag and the name of the type, or
5397 just past the closing curly brace of the @emph{definition}. The
5398 former syntax is preferred.
5399
5400 @xref{Attribute Syntax}, for details of the exact syntax for using
5401 attributes.
5402
5403 @table @code
5404 @cindex @code{aligned} attribute
5405 @item aligned (@var{alignment})
5406 This attribute specifies a minimum alignment (in bytes) for variables
5407 of the specified type. For example, the declarations:
5408
5409 @smallexample
5410 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5411 typedef int more_aligned_int __attribute__ ((aligned (8)));
5412 @end smallexample
5413
5414 @noindent
5415 force the compiler to ensure (as far as it can) that each variable whose
5416 type is @code{struct S} or @code{more_aligned_int} is allocated and
5417 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
5418 variables of type @code{struct S} aligned to 8-byte boundaries allows
5419 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5420 store) instructions when copying one variable of type @code{struct S} to
5421 another, thus improving run-time efficiency.
5422
5423 Note that the alignment of any given @code{struct} or @code{union} type
5424 is required by the ISO C standard to be at least a perfect multiple of
5425 the lowest common multiple of the alignments of all of the members of
5426 the @code{struct} or @code{union} in question. This means that you @emph{can}
5427 effectively adjust the alignment of a @code{struct} or @code{union}
5428 type by attaching an @code{aligned} attribute to any one of the members
5429 of such a type, but the notation illustrated in the example above is a
5430 more obvious, intuitive, and readable way to request the compiler to
5431 adjust the alignment of an entire @code{struct} or @code{union} type.
5432
5433 As in the preceding example, you can explicitly specify the alignment
5434 (in bytes) that you wish the compiler to use for a given @code{struct}
5435 or @code{union} type. Alternatively, you can leave out the alignment factor
5436 and just ask the compiler to align a type to the maximum
5437 useful alignment for the target machine you are compiling for. For
5438 example, you could write:
5439
5440 @smallexample
5441 struct S @{ short f[3]; @} __attribute__ ((aligned));
5442 @end smallexample
5443
5444 Whenever you leave out the alignment factor in an @code{aligned}
5445 attribute specification, the compiler automatically sets the alignment
5446 for the type to the largest alignment that is ever used for any data
5447 type on the target machine you are compiling for. Doing this can often
5448 make copy operations more efficient, because the compiler can use
5449 whatever instructions copy the biggest chunks of memory when performing
5450 copies to or from the variables that have types that you have aligned
5451 this way.
5452
5453 In the example above, if the size of each @code{short} is 2 bytes, then
5454 the size of the entire @code{struct S} type is 6 bytes. The smallest
5455 power of two that is greater than or equal to that is 8, so the
5456 compiler sets the alignment for the entire @code{struct S} type to 8
5457 bytes.
5458
5459 Note that although you can ask the compiler to select a time-efficient
5460 alignment for a given type and then declare only individual stand-alone
5461 objects of that type, the compiler's ability to select a time-efficient
5462 alignment is primarily useful only when you plan to create arrays of
5463 variables having the relevant (efficiently aligned) type. If you
5464 declare or use arrays of variables of an efficiently-aligned type, then
5465 it is likely that your program also does pointer arithmetic (or
5466 subscripting, which amounts to the same thing) on pointers to the
5467 relevant type, and the code that the compiler generates for these
5468 pointer arithmetic operations is often more efficient for
5469 efficiently-aligned types than for other types.
5470
5471 The @code{aligned} attribute can only increase the alignment; but you
5472 can decrease it by specifying @code{packed} as well. See below.
5473
5474 Note that the effectiveness of @code{aligned} attributes may be limited
5475 by inherent limitations in your linker. On many systems, the linker is
5476 only able to arrange for variables to be aligned up to a certain maximum
5477 alignment. (For some linkers, the maximum supported alignment may
5478 be very very small.) If your linker is only able to align variables
5479 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5480 in an @code{__attribute__} still only provides you with 8-byte
5481 alignment. See your linker documentation for further information.
5482
5483 @item packed
5484 This attribute, attached to @code{struct} or @code{union} type
5485 definition, specifies that each member (other than zero-width bit-fields)
5486 of the structure or union is placed to minimize the memory required. When
5487 attached to an @code{enum} definition, it indicates that the smallest
5488 integral type should be used.
5489
5490 @opindex fshort-enums
5491 Specifying this attribute for @code{struct} and @code{union} types is
5492 equivalent to specifying the @code{packed} attribute on each of the
5493 structure or union members. Specifying the @option{-fshort-enums}
5494 flag on the line is equivalent to specifying the @code{packed}
5495 attribute on all @code{enum} definitions.
5496
5497 In the following example @code{struct my_packed_struct}'s members are
5498 packed closely together, but the internal layout of its @code{s} member
5499 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5500 be packed too.
5501
5502 @smallexample
5503 struct my_unpacked_struct
5504 @{
5505 char c;
5506 int i;
5507 @};
5508
5509 struct __attribute__ ((__packed__)) my_packed_struct
5510 @{
5511 char c;
5512 int i;
5513 struct my_unpacked_struct s;
5514 @};
5515 @end smallexample
5516
5517 You may only specify this attribute on the definition of an @code{enum},
5518 @code{struct} or @code{union}, not on a @code{typedef} that does not
5519 also define the enumerated type, structure or union.
5520
5521 @item transparent_union
5522 This attribute, attached to a @code{union} type definition, indicates
5523 that any function parameter having that union type causes calls to that
5524 function to be treated in a special way.
5525
5526 First, the argument corresponding to a transparent union type can be of
5527 any type in the union; no cast is required. Also, if the union contains
5528 a pointer type, the corresponding argument can be a null pointer
5529 constant or a void pointer expression; and if the union contains a void
5530 pointer type, the corresponding argument can be any pointer expression.
5531 If the union member type is a pointer, qualifiers like @code{const} on
5532 the referenced type must be respected, just as with normal pointer
5533 conversions.
5534
5535 Second, the argument is passed to the function using the calling
5536 conventions of the first member of the transparent union, not the calling
5537 conventions of the union itself. All members of the union must have the
5538 same machine representation; this is necessary for this argument passing
5539 to work properly.
5540
5541 Transparent unions are designed for library functions that have multiple
5542 interfaces for compatibility reasons. For example, suppose the
5543 @code{wait} function must accept either a value of type @code{int *} to
5544 comply with POSIX, or a value of type @code{union wait *} to comply with
5545 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
5546 @code{wait} would accept both kinds of arguments, but it would also
5547 accept any other pointer type and this would make argument type checking
5548 less useful. Instead, @code{<sys/wait.h>} might define the interface
5549 as follows:
5550
5551 @smallexample
5552 typedef union __attribute__ ((__transparent_union__))
5553 @{
5554 int *__ip;
5555 union wait *__up;
5556 @} wait_status_ptr_t;
5557
5558 pid_t wait (wait_status_ptr_t);
5559 @end smallexample
5560
5561 @noindent
5562 This interface allows either @code{int *} or @code{union wait *}
5563 arguments to be passed, using the @code{int *} calling convention.
5564 The program can call @code{wait} with arguments of either type:
5565
5566 @smallexample
5567 int w1 () @{ int w; return wait (&w); @}
5568 int w2 () @{ union wait w; return wait (&w); @}
5569 @end smallexample
5570
5571 @noindent
5572 With this interface, @code{wait}'s implementation might look like this:
5573
5574 @smallexample
5575 pid_t wait (wait_status_ptr_t p)
5576 @{
5577 return waitpid (-1, p.__ip, 0);
5578 @}
5579 @end smallexample
5580
5581 @item unused
5582 When attached to a type (including a @code{union} or a @code{struct}),
5583 this attribute means that variables of that type are meant to appear
5584 possibly unused. GCC does not produce a warning for any variables of
5585 that type, even if the variable appears to do nothing. This is often
5586 the case with lock or thread classes, which are usually defined and then
5587 not referenced, but contain constructors and destructors that have
5588 nontrivial bookkeeping functions.
5589
5590 @item deprecated
5591 @itemx deprecated (@var{msg})
5592 The @code{deprecated} attribute results in a warning if the type
5593 is used anywhere in the source file. This is useful when identifying
5594 types that are expected to be removed in a future version of a program.
5595 If possible, the warning also includes the location of the declaration
5596 of the deprecated type, to enable users to easily find further
5597 information about why the type is deprecated, or what they should do
5598 instead. Note that the warnings only occur for uses and then only
5599 if the type is being applied to an identifier that itself is not being
5600 declared as deprecated.
5601
5602 @smallexample
5603 typedef int T1 __attribute__ ((deprecated));
5604 T1 x;
5605 typedef T1 T2;
5606 T2 y;
5607 typedef T1 T3 __attribute__ ((deprecated));
5608 T3 z __attribute__ ((deprecated));
5609 @end smallexample
5610
5611 @noindent
5612 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
5613 warning is issued for line 4 because T2 is not explicitly
5614 deprecated. Line 5 has no warning because T3 is explicitly
5615 deprecated. Similarly for line 6. The optional @var{msg}
5616 argument, which must be a string, is printed in the warning if
5617 present.
5618
5619 The @code{deprecated} attribute can also be used for functions and
5620 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5621
5622 @item may_alias
5623 Accesses through pointers to types with this attribute are not subject
5624 to type-based alias analysis, but are instead assumed to be able to alias
5625 any other type of objects.
5626 In the context of section 6.5 paragraph 7 of the C99 standard,
5627 an lvalue expression
5628 dereferencing such a pointer is treated like having a character type.
5629 See @option{-fstrict-aliasing} for more information on aliasing issues.
5630 This extension exists to support some vector APIs, in which pointers to
5631 one vector type are permitted to alias pointers to a different vector type.
5632
5633 Note that an object of a type with this attribute does not have any
5634 special semantics.
5635
5636 Example of use:
5637
5638 @smallexample
5639 typedef short __attribute__((__may_alias__)) short_a;
5640
5641 int
5642 main (void)
5643 @{
5644 int a = 0x12345678;
5645 short_a *b = (short_a *) &a;
5646
5647 b[1] = 0;
5648
5649 if (a == 0x12345678)
5650 abort();
5651
5652 exit(0);
5653 @}
5654 @end smallexample
5655
5656 @noindent
5657 If you replaced @code{short_a} with @code{short} in the variable
5658 declaration, the above program would abort when compiled with
5659 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5660 above in recent GCC versions.
5661
5662 @item visibility
5663 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5664 applied to class, struct, union and enum types. Unlike other type
5665 attributes, the attribute must appear between the initial keyword and
5666 the name of the type; it cannot appear after the body of the type.
5667
5668 Note that the type visibility is applied to vague linkage entities
5669 associated with the class (vtable, typeinfo node, etc.). In
5670 particular, if a class is thrown as an exception in one shared object
5671 and caught in another, the class must have default visibility.
5672 Otherwise the two shared objects are unable to use the same
5673 typeinfo node and exception handling will break.
5674
5675 @item bnd_variable_size
5676 When applied to a structure field, this attribute tells Pointer
5677 Bounds Checker that the size of this field should not be computed
5678 using static type information. It may be used to mark variable
5679 sized static array fields placed at the end of a structure.
5680
5681 @smallexample
5682 struct S
5683 @{
5684 int size;
5685 char data[1];
5686 @}
5687 S *p = (S *)malloc (sizeof(S) + 100);
5688 p->data[10] = 0; //Bounds violation
5689 @end smallexample
5690
5691 By using an attribute for a field we may avoid bound violation
5692 we most probably do not want to see:
5693
5694 @smallexample
5695 struct S
5696 @{
5697 int size;
5698 char data[1] __attribute__((bnd_variable_size));
5699 @}
5700 S *p = (S *)malloc (sizeof(S) + 100);
5701 p->data[10] = 0; //OK
5702 @end smallexample
5703
5704 @end table
5705
5706 To specify multiple attributes, separate them by commas within the
5707 double parentheses: for example, @samp{__attribute__ ((aligned (16),
5708 packed))}.
5709
5710 @subsection ARM Type Attributes
5711
5712 On those ARM targets that support @code{dllimport} (such as Symbian
5713 OS), you can use the @code{notshared} attribute to indicate that the
5714 virtual table and other similar data for a class should not be
5715 exported from a DLL@. For example:
5716
5717 @smallexample
5718 class __declspec(notshared) C @{
5719 public:
5720 __declspec(dllimport) C();
5721 virtual void f();
5722 @}
5723
5724 __declspec(dllexport)
5725 C::C() @{@}
5726 @end smallexample
5727
5728 @noindent
5729 In this code, @code{C::C} is exported from the current DLL, but the
5730 virtual table for @code{C} is not exported. (You can use
5731 @code{__attribute__} instead of @code{__declspec} if you prefer, but
5732 most Symbian OS code uses @code{__declspec}.)
5733
5734 @anchor{MeP Type Attributes}
5735 @subsection MeP Type Attributes
5736
5737 Many of the MeP variable attributes may be applied to types as well.
5738 Specifically, the @code{based}, @code{tiny}, @code{near}, and
5739 @code{far} attributes may be applied to either. The @code{io} and
5740 @code{cb} attributes may not be applied to types.
5741
5742 @anchor{i386 Type Attributes}
5743 @subsection i386 Type Attributes
5744
5745 Two attributes are currently defined for i386 configurations:
5746 @code{ms_struct} and @code{gcc_struct}.
5747
5748 @table @code
5749
5750 @item ms_struct
5751 @itemx gcc_struct
5752 @cindex @code{ms_struct}
5753 @cindex @code{gcc_struct}
5754
5755 If @code{packed} is used on a structure, or if bit-fields are used
5756 it may be that the Microsoft ABI packs them differently
5757 than GCC normally packs them. Particularly when moving packed
5758 data between functions compiled with GCC and the native Microsoft compiler
5759 (either via function call or as data in a file), it may be necessary to access
5760 either format.
5761
5762 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5763 compilers to match the native Microsoft compiler.
5764 @end table
5765
5766 @anchor{PowerPC Type Attributes}
5767 @subsection PowerPC Type Attributes
5768
5769 Three attributes currently are defined for PowerPC configurations:
5770 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5771
5772 For full documentation of the @code{ms_struct} and @code{gcc_struct}
5773 attributes please see the documentation in @ref{i386 Type Attributes}.
5774
5775 The @code{altivec} attribute allows one to declare AltiVec vector data
5776 types supported by the AltiVec Programming Interface Manual. The
5777 attribute requires an argument to specify one of three vector types:
5778 @code{vector__}, @code{pixel__} (always followed by unsigned short),
5779 and @code{bool__} (always followed by unsigned).
5780
5781 @smallexample
5782 __attribute__((altivec(vector__)))
5783 __attribute__((altivec(pixel__))) unsigned short
5784 __attribute__((altivec(bool__))) unsigned
5785 @end smallexample
5786
5787 These attributes mainly are intended to support the @code{__vector},
5788 @code{__pixel}, and @code{__bool} AltiVec keywords.
5789
5790 @anchor{SPU Type Attributes}
5791 @subsection SPU Type Attributes
5792
5793 The SPU supports the @code{spu_vector} attribute for types. This attribute
5794 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
5795 Language Extensions Specification. It is intended to support the
5796 @code{__vector} keyword.
5797
5798 @node Alignment
5799 @section Inquiring on Alignment of Types or Variables
5800 @cindex alignment
5801 @cindex type alignment
5802 @cindex variable alignment
5803
5804 The keyword @code{__alignof__} allows you to inquire about how an object
5805 is aligned, or the minimum alignment usually required by a type. Its
5806 syntax is just like @code{sizeof}.
5807
5808 For example, if the target machine requires a @code{double} value to be
5809 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
5810 This is true on many RISC machines. On more traditional machine
5811 designs, @code{__alignof__ (double)} is 4 or even 2.
5812
5813 Some machines never actually require alignment; they allow reference to any
5814 data type even at an odd address. For these machines, @code{__alignof__}
5815 reports the smallest alignment that GCC gives the data type, usually as
5816 mandated by the target ABI.
5817
5818 If the operand of @code{__alignof__} is an lvalue rather than a type,
5819 its value is the required alignment for its type, taking into account
5820 any minimum alignment specified with GCC's @code{__attribute__}
5821 extension (@pxref{Variable Attributes}). For example, after this
5822 declaration:
5823
5824 @smallexample
5825 struct foo @{ int x; char y; @} foo1;
5826 @end smallexample
5827
5828 @noindent
5829 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
5830 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
5831
5832 It is an error to ask for the alignment of an incomplete type.
5833
5834
5835 @node Inline
5836 @section An Inline Function is As Fast As a Macro
5837 @cindex inline functions
5838 @cindex integrating function code
5839 @cindex open coding
5840 @cindex macros, inline alternative
5841
5842 By declaring a function inline, you can direct GCC to make
5843 calls to that function faster. One way GCC can achieve this is to
5844 integrate that function's code into the code for its callers. This
5845 makes execution faster by eliminating the function-call overhead; in
5846 addition, if any of the actual argument values are constant, their
5847 known values may permit simplifications at compile time so that not
5848 all of the inline function's code needs to be included. The effect on
5849 code size is less predictable; object code may be larger or smaller
5850 with function inlining, depending on the particular case. You can
5851 also direct GCC to try to integrate all ``simple enough'' functions
5852 into their callers with the option @option{-finline-functions}.
5853
5854 GCC implements three different semantics of declaring a function
5855 inline. One is available with @option{-std=gnu89} or
5856 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
5857 on all inline declarations, another when
5858 @option{-std=c99}, @option{-std=c11},
5859 @option{-std=gnu99} or @option{-std=gnu11}
5860 (without @option{-fgnu89-inline}), and the third
5861 is used when compiling C++.
5862
5863 To declare a function inline, use the @code{inline} keyword in its
5864 declaration, like this:
5865
5866 @smallexample
5867 static inline int
5868 inc (int *a)
5869 @{
5870 return (*a)++;
5871 @}
5872 @end smallexample
5873
5874 If you are writing a header file to be included in ISO C90 programs, write
5875 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
5876
5877 The three types of inlining behave similarly in two important cases:
5878 when the @code{inline} keyword is used on a @code{static} function,
5879 like the example above, and when a function is first declared without
5880 using the @code{inline} keyword and then is defined with
5881 @code{inline}, like this:
5882
5883 @smallexample
5884 extern int inc (int *a);
5885 inline int
5886 inc (int *a)
5887 @{
5888 return (*a)++;
5889 @}
5890 @end smallexample
5891
5892 In both of these common cases, the program behaves the same as if you
5893 had not used the @code{inline} keyword, except for its speed.
5894
5895 @cindex inline functions, omission of
5896 @opindex fkeep-inline-functions
5897 When a function is both inline and @code{static}, if all calls to the
5898 function are integrated into the caller, and the function's address is
5899 never used, then the function's own assembler code is never referenced.
5900 In this case, GCC does not actually output assembler code for the
5901 function, unless you specify the option @option{-fkeep-inline-functions}.
5902 Some calls cannot be integrated for various reasons (in particular,
5903 calls that precede the function's definition cannot be integrated, and
5904 neither can recursive calls within the definition). If there is a
5905 nonintegrated call, then the function is compiled to assembler code as
5906 usual. The function must also be compiled as usual if the program
5907 refers to its address, because that can't be inlined.
5908
5909 @opindex Winline
5910 Note that certain usages in a function definition can make it unsuitable
5911 for inline substitution. Among these usages are: variadic functions, use of
5912 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
5913 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
5914 and nested functions (@pxref{Nested Functions}). Using @option{-Winline}
5915 warns when a function marked @code{inline} could not be substituted,
5916 and gives the reason for the failure.
5917
5918 @cindex automatic @code{inline} for C++ member fns
5919 @cindex @code{inline} automatic for C++ member fns
5920 @cindex member fns, automatically @code{inline}
5921 @cindex C++ member fns, automatically @code{inline}
5922 @opindex fno-default-inline
5923 As required by ISO C++, GCC considers member functions defined within
5924 the body of a class to be marked inline even if they are
5925 not explicitly declared with the @code{inline} keyword. You can
5926 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
5927 Options,,Options Controlling C++ Dialect}.
5928
5929 GCC does not inline any functions when not optimizing unless you specify
5930 the @samp{always_inline} attribute for the function, like this:
5931
5932 @smallexample
5933 /* @r{Prototype.} */
5934 inline void foo (const char) __attribute__((always_inline));
5935 @end smallexample
5936
5937 The remainder of this section is specific to GNU C90 inlining.
5938
5939 @cindex non-static inline function
5940 When an inline function is not @code{static}, then the compiler must assume
5941 that there may be calls from other source files; since a global symbol can
5942 be defined only once in any program, the function must not be defined in
5943 the other source files, so the calls therein cannot be integrated.
5944 Therefore, a non-@code{static} inline function is always compiled on its
5945 own in the usual fashion.
5946
5947 If you specify both @code{inline} and @code{extern} in the function
5948 definition, then the definition is used only for inlining. In no case
5949 is the function compiled on its own, not even if you refer to its
5950 address explicitly. Such an address becomes an external reference, as
5951 if you had only declared the function, and had not defined it.
5952
5953 This combination of @code{inline} and @code{extern} has almost the
5954 effect of a macro. The way to use it is to put a function definition in
5955 a header file with these keywords, and put another copy of the
5956 definition (lacking @code{inline} and @code{extern}) in a library file.
5957 The definition in the header file causes most calls to the function
5958 to be inlined. If any uses of the function remain, they refer to
5959 the single copy in the library.
5960
5961 @node Volatiles
5962 @section When is a Volatile Object Accessed?
5963 @cindex accessing volatiles
5964 @cindex volatile read
5965 @cindex volatile write
5966 @cindex volatile access
5967
5968 C has the concept of volatile objects. These are normally accessed by
5969 pointers and used for accessing hardware or inter-thread
5970 communication. The standard encourages compilers to refrain from
5971 optimizations concerning accesses to volatile objects, but leaves it
5972 implementation defined as to what constitutes a volatile access. The
5973 minimum requirement is that at a sequence point all previous accesses
5974 to volatile objects have stabilized and no subsequent accesses have
5975 occurred. Thus an implementation is free to reorder and combine
5976 volatile accesses that occur between sequence points, but cannot do
5977 so for accesses across a sequence point. The use of volatile does
5978 not allow you to violate the restriction on updating objects multiple
5979 times between two sequence points.
5980
5981 Accesses to non-volatile objects are not ordered with respect to
5982 volatile accesses. You cannot use a volatile object as a memory
5983 barrier to order a sequence of writes to non-volatile memory. For
5984 instance:
5985
5986 @smallexample
5987 int *ptr = @var{something};
5988 volatile int vobj;
5989 *ptr = @var{something};
5990 vobj = 1;
5991 @end smallexample
5992
5993 @noindent
5994 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
5995 that the write to @var{*ptr} occurs by the time the update
5996 of @var{vobj} happens. If you need this guarantee, you must use
5997 a stronger memory barrier such as:
5998
5999 @smallexample
6000 int *ptr = @var{something};
6001 volatile int vobj;
6002 *ptr = @var{something};
6003 asm volatile ("" : : : "memory");
6004 vobj = 1;
6005 @end smallexample
6006
6007 A scalar volatile object is read when it is accessed in a void context:
6008
6009 @smallexample
6010 volatile int *src = @var{somevalue};
6011 *src;
6012 @end smallexample
6013
6014 Such expressions are rvalues, and GCC implements this as a
6015 read of the volatile object being pointed to.
6016
6017 Assignments are also expressions and have an rvalue. However when
6018 assigning to a scalar volatile, the volatile object is not reread,
6019 regardless of whether the assignment expression's rvalue is used or
6020 not. If the assignment's rvalue is used, the value is that assigned
6021 to the volatile object. For instance, there is no read of @var{vobj}
6022 in all the following cases:
6023
6024 @smallexample
6025 int obj;
6026 volatile int vobj;
6027 vobj = @var{something};
6028 obj = vobj = @var{something};
6029 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6030 obj = (@var{something}, vobj = @var{anotherthing});
6031 @end smallexample
6032
6033 If you need to read the volatile object after an assignment has
6034 occurred, you must use a separate expression with an intervening
6035 sequence point.
6036
6037 As bit-fields are not individually addressable, volatile bit-fields may
6038 be implicitly read when written to, or when adjacent bit-fields are
6039 accessed. Bit-field operations may be optimized such that adjacent
6040 bit-fields are only partially accessed, if they straddle a storage unit
6041 boundary. For these reasons it is unwise to use volatile bit-fields to
6042 access hardware.
6043
6044 @node Extended Asm
6045 @section Assembler Instructions with C Expression Operands
6046 @cindex extended @code{asm}
6047 @cindex @code{asm} expressions
6048 @cindex assembler instructions
6049 @cindex registers
6050
6051 In an assembler instruction using @code{asm}, you can specify the
6052 operands of the instruction using C expressions. This means you need not
6053 guess which registers or memory locations contain the data you want
6054 to use.
6055
6056 You must specify an assembler instruction template much like what
6057 appears in a machine description, plus an operand constraint string for
6058 each operand.
6059
6060 For example, here is how to use the 68881's @code{fsinx} instruction:
6061
6062 @smallexample
6063 asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
6064 @end smallexample
6065
6066 @noindent
6067 Here @code{angle} is the C expression for the input operand while
6068 @code{result} is that of the output operand. Each has @samp{"f"} as its
6069 operand constraint, saying that a floating-point register is required.
6070 The @samp{=} in @samp{=f} indicates that the operand is an output; all
6071 output operands' constraints must use @samp{=}. The constraints use the
6072 same language used in the machine description (@pxref{Constraints}).
6073
6074 Each operand is described by an operand-constraint string followed by
6075 the C expression in parentheses. A colon separates the assembler
6076 template from the first output operand and another separates the last
6077 output operand from the first input, if any. Commas separate the
6078 operands within each group. The total number of operands is currently
6079 limited to 30; this limitation may be lifted in some future version of
6080 GCC@.
6081
6082 If there are no output operands but there are input operands, you must
6083 place two consecutive colons surrounding the place where the output
6084 operands would go.
6085
6086 As of GCC version 3.1, it is also possible to specify input and output
6087 operands using symbolic names which can be referenced within the
6088 assembler code. These names are specified inside square brackets
6089 preceding the constraint string, and can be referenced inside the
6090 assembler code using @code{%[@var{name}]} instead of a percentage sign
6091 followed by the operand number. Using named operands the above example
6092 could look like:
6093
6094 @smallexample
6095 asm ("fsinx %[angle],%[output]"
6096 : [output] "=f" (result)
6097 : [angle] "f" (angle));
6098 @end smallexample
6099
6100 @noindent
6101 Note that the symbolic operand names have no relation whatsoever to
6102 other C identifiers. You may use any name you like, even those of
6103 existing C symbols, but you must ensure that no two operands within the same
6104 assembler construct use the same symbolic name.
6105
6106 Output operand expressions must be lvalues; the compiler can check this.
6107 The input operands need not be lvalues. The compiler cannot check
6108 whether the operands have data types that are reasonable for the
6109 instruction being executed. It does not parse the assembler instruction
6110 template and does not know what it means or even whether it is valid
6111 assembler input. The extended @code{asm} feature is most often used for
6112 machine instructions the compiler itself does not know exist. If
6113 the output expression cannot be directly addressed (for example, it is a
6114 bit-field), your constraint must allow a register. In that case, GCC
6115 uses the register as the output of the @code{asm}, and then stores
6116 that register into the output.
6117
6118 The ordinary output operands must be write-only; GCC assumes that
6119 the values in these operands before the instruction are dead and need
6120 not be generated. Extended asm supports input-output or read-write
6121 operands. Use the constraint character @samp{+} to indicate such an
6122 operand and list it with the output operands.
6123
6124 You may, as an alternative, logically split its function into two
6125 separate operands, one input operand and one write-only output
6126 operand. The connection between them is expressed by constraints
6127 that say they need to be in the same location when the instruction
6128 executes. You can use the same C expression for both operands, or
6129 different expressions. For example, here we write the (fictitious)
6130 @samp{combine} instruction with @code{bar} as its read-only source
6131 operand and @code{foo} as its read-write destination:
6132
6133 @smallexample
6134 asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar));
6135 @end smallexample
6136
6137 @noindent
6138 The constraint @samp{"0"} for operand 1 says that it must occupy the
6139 same location as operand 0. A number in constraint is allowed only in
6140 an input operand and it must refer to an output operand.
6141
6142 Only a number in the constraint can guarantee that one operand is in
6143 the same place as another. The mere fact that @code{foo} is the value
6144 of both operands is not enough to guarantee that they are in the
6145 same place in the generated assembler code. The following does not
6146 work reliably:
6147
6148 @smallexample
6149 asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar));
6150 @end smallexample
6151
6152 Various optimizations or reloading could cause operands 0 and 1 to be in
6153 different registers; GCC knows no reason not to do so. For example, the
6154 compiler might find a copy of the value of @code{foo} in one register and
6155 use it for operand 1, but generate the output operand 0 in a different
6156 register (copying it afterward to @code{foo}'s own address). Of course,
6157 since the register for operand 1 is not even mentioned in the assembler
6158 code, the result will not work, but GCC can't tell that.
6159
6160 As of GCC version 3.1, one may write @code{[@var{name}]} instead of
6161 the operand number for a matching constraint. For example:
6162
6163 @smallexample
6164 asm ("cmoveq %1,%2,%[result]"
6165 : [result] "=r"(result)
6166 : "r" (test), "r"(new), "[result]"(old));
6167 @end smallexample
6168
6169 Sometimes you need to make an @code{asm} operand be a specific register,
6170 but there's no matching constraint letter for that register @emph{by
6171 itself}. To force the operand into that register, use a local variable
6172 for the operand and specify the register in the variable declaration.
6173 @xref{Explicit Reg Vars}. Then for the @code{asm} operand, use any
6174 register constraint letter that matches the register:
6175
6176 @smallexample
6177 register int *p1 asm ("r0") = @dots{};
6178 register int *p2 asm ("r1") = @dots{};
6179 register int *result asm ("r0");
6180 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
6181 @end smallexample
6182
6183 @anchor{Example of asm with clobbered asm reg}
6184 In the above example, beware that a register that is call-clobbered by
6185 the target ABI will be overwritten by any function call in the
6186 assignment, including library calls for arithmetic operators.
6187 Also a register may be clobbered when generating some operations,
6188 like variable shift, memory copy or memory move on x86.
6189 Assuming it is a call-clobbered register, this may happen to @code{r0}
6190 above by the assignment to @code{p2}. If you have to use such a
6191 register, use temporary variables for expressions between the register
6192 assignment and use:
6193
6194 @smallexample
6195 int t1 = @dots{};
6196 register int *p1 asm ("r0") = @dots{};
6197 register int *p2 asm ("r1") = t1;
6198 register int *result asm ("r0");
6199 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
6200 @end smallexample
6201
6202 Some instructions clobber specific hard registers. To describe this,
6203 write a third colon after the input operands, followed by the names of
6204 the clobbered hard registers (given as strings). Here is a realistic
6205 example for the VAX:
6206
6207 @smallexample
6208 asm volatile ("movc3 %0,%1,%2"
6209 : /* @r{no outputs} */
6210 : "g" (from), "g" (to), "g" (count)
6211 : "r0", "r1", "r2", "r3", "r4", "r5");
6212 @end smallexample
6213
6214 You may not write a clobber description in a way that overlaps with an
6215 input or output operand. For example, you may not have an operand
6216 describing a register class with one member if you mention that register
6217 in the clobber list. Variables declared to live in specific registers
6218 (@pxref{Explicit Reg Vars}), and used as asm input or output operands must
6219 have no part mentioned in the clobber description.
6220 There is no way for you to specify that an input
6221 operand is modified without also specifying it as an output
6222 operand. Note that if all the output operands you specify are for this
6223 purpose (and hence unused), you then also need to specify
6224 @code{volatile} for the @code{asm} construct, as described below, to
6225 prevent GCC from deleting the @code{asm} statement as unused.
6226
6227 If you refer to a particular hardware register from the assembler code,
6228 you probably have to list the register after the third colon to
6229 tell the compiler the register's value is modified. In some assemblers,
6230 the register names begin with @samp{%}; to produce one @samp{%} in the
6231 assembler code, you must write @samp{%%} in the input.
6232
6233 If your assembler instruction can alter the condition code register, add
6234 @samp{cc} to the list of clobbered registers. GCC on some machines
6235 represents the condition codes as a specific hardware register;
6236 @samp{cc} serves to name this register. On other machines, the
6237 condition code is handled differently, and specifying @samp{cc} has no
6238 effect. But it is valid no matter what the machine.
6239
6240 If your assembler instructions access memory in an unpredictable
6241 fashion, add @samp{memory} to the list of clobbered registers. This
6242 causes GCC to not keep memory values cached in registers across the
6243 assembler instruction and not optimize stores or loads to that memory.
6244 You also should add the @code{volatile} keyword if the memory
6245 affected is not listed in the inputs or outputs of the @code{asm}, as
6246 the @samp{memory} clobber does not count as a side-effect of the
6247 @code{asm}. If you know how large the accessed memory is, you can add
6248 it as input or output but if this is not known, you should add
6249 @samp{memory}. As an example, if you access ten bytes of a string, you
6250 can use a memory input like:
6251
6252 @smallexample
6253 @{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}.
6254 @end smallexample
6255
6256 Note that in the following example the memory input is necessary,
6257 otherwise GCC might optimize the store to @code{x} away:
6258 @smallexample
6259 int foo ()
6260 @{
6261 int x = 42;
6262 int *y = &x;
6263 int result;
6264 asm ("magic stuff accessing an 'int' pointed to by '%1'"
6265 : "=&d" (r) : "a" (y), "m" (*y));
6266 return result;
6267 @}
6268 @end smallexample
6269
6270 You can put multiple assembler instructions together in a single
6271 @code{asm} template, separated by the characters normally used in assembly
6272 code for the system. A combination that works in most places is a newline
6273 to break the line, plus a tab character to move to the instruction field
6274 (written as @samp{\n\t}). Sometimes semicolons can be used, if the
6275 assembler allows semicolons as a line-breaking character. Note that some
6276 assembler dialects use semicolons to start a comment.
6277 The input operands are guaranteed not to use any of the clobbered
6278 registers, and neither do the output operands' addresses, so you can
6279 read and write the clobbered registers as many times as you like. Here
6280 is an example of multiple instructions in a template; it assumes the
6281 subroutine @code{_foo} accepts arguments in registers 9 and 10:
6282
6283 @smallexample
6284 asm ("movl %0,r9\n\tmovl %1,r10\n\tcall _foo"
6285 : /* no outputs */
6286 : "g" (from), "g" (to)
6287 : "r9", "r10");
6288 @end smallexample
6289
6290 Unless an output operand has the @samp{&} constraint modifier, GCC
6291 may allocate it in the same register as an unrelated input operand, on
6292 the assumption the inputs are consumed before the outputs are produced.
6293 This assumption may be false if the assembler code actually consists of
6294 more than one instruction. In such a case, use @samp{&} for each output
6295 operand that may not overlap an input. @xref{Modifiers}.
6296
6297 If you want to test the condition code produced by an assembler
6298 instruction, you must include a branch and a label in the @code{asm}
6299 construct, as follows:
6300
6301 @smallexample
6302 asm ("clr %0\n\tfrob %1\n\tbeq 0f\n\tmov #1,%0\n0:"
6303 : "g" (result)
6304 : "g" (input));
6305 @end smallexample
6306
6307 @noindent
6308 This assumes your assembler supports local labels, as the GNU assembler
6309 and most Unix assemblers do.
6310
6311 Speaking of labels, jumps from one @code{asm} to another are not
6312 supported. The compiler's optimizers do not know about these jumps, and
6313 therefore they cannot take account of them when deciding how to
6314 optimize. @xref{Extended asm with goto}.
6315
6316 @cindex macros containing @code{asm}
6317 Usually the most convenient way to use these @code{asm} instructions is to
6318 encapsulate them in macros that look like functions. For example,
6319
6320 @smallexample
6321 #define sin(x) \
6322 (@{ double __value, __arg = (x); \
6323 asm ("fsinx %1,%0": "=f" (__value): "f" (__arg)); \
6324 __value; @})
6325 @end smallexample
6326
6327 @noindent
6328 Here the variable @code{__arg} is used to make sure that the instruction
6329 operates on a proper @code{double} value, and to accept only those
6330 arguments @code{x} that can convert automatically to a @code{double}.
6331
6332 Another way to make sure the instruction operates on the correct data
6333 type is to use a cast in the @code{asm}. This is different from using a
6334 variable @code{__arg} in that it converts more different types. For
6335 example, if the desired type is @code{int}, casting the argument to
6336 @code{int} accepts a pointer with no complaint, while assigning the
6337 argument to an @code{int} variable named @code{__arg} warns about
6338 using a pointer unless the caller explicitly casts it.
6339
6340 If an @code{asm} has output operands, GCC assumes for optimization
6341 purposes the instruction has no side effects except to change the output
6342 operands. This does not mean instructions with a side effect cannot be
6343 used, but you must be careful, because the compiler may eliminate them
6344 if the output operands aren't used, or move them out of loops, or
6345 replace two with one if they constitute a common subexpression. Also,
6346 if your instruction does have a side effect on a variable that otherwise
6347 appears not to change, the old value of the variable may be reused later
6348 if it happens to be found in a register.
6349
6350 You can prevent an @code{asm} instruction from being deleted
6351 by writing the keyword @code{volatile} after
6352 the @code{asm}. For example:
6353
6354 @smallexample
6355 #define get_and_set_priority(new) \
6356 (@{ int __old; \
6357 asm volatile ("get_and_set_priority %0, %1" \
6358 : "=g" (__old) : "g" (new)); \
6359 __old; @})
6360 @end smallexample
6361
6362 @noindent
6363 The @code{volatile} keyword indicates that the instruction has
6364 important side-effects. GCC does not delete a volatile @code{asm} if
6365 it is reachable. (The instruction can still be deleted if GCC can
6366 prove that control flow never reaches the location of the
6367 instruction.) Note that even a volatile @code{asm} instruction
6368 can be moved relative to other code, including across jump
6369 instructions. For example, on many targets there is a system
6370 register that can be set to control the rounding mode of
6371 floating-point operations. You might try
6372 setting it with a volatile @code{asm}, like this PowerPC example:
6373
6374 @smallexample
6375 asm volatile("mtfsf 255,%0" : : "f" (fpenv));
6376 sum = x + y;
6377 @end smallexample
6378
6379 @noindent
6380 This does not work reliably, as the compiler may move the addition back
6381 before the volatile @code{asm}. To make it work you need to add an
6382 artificial dependency to the @code{asm} referencing a variable in the code
6383 you don't want moved, for example:
6384
6385 @smallexample
6386 asm volatile ("mtfsf 255,%1" : "=X"(sum): "f"(fpenv));
6387 sum = x + y;
6388 @end smallexample
6389
6390 Similarly, you can't expect a
6391 sequence of volatile @code{asm} instructions to remain perfectly
6392 consecutive. If you want consecutive output, use a single @code{asm}.
6393 Also, GCC performs some optimizations across a volatile @code{asm}
6394 instruction; GCC does not ``forget everything'' when it encounters
6395 a volatile @code{asm} instruction the way some other compilers do.
6396
6397 An @code{asm} instruction without any output operands is treated
6398 identically to a volatile @code{asm} instruction.
6399
6400 It is a natural idea to look for a way to give access to the condition
6401 code left by the assembler instruction. However, when we attempted to
6402 implement this, we found no way to make it work reliably. The problem
6403 is that output operands might need reloading, which result in
6404 additional following ``store'' instructions. On most machines, these
6405 instructions alter the condition code before there is time to
6406 test it. This problem doesn't arise for ordinary ``test'' and
6407 ``compare'' instructions because they don't have any output operands.
6408
6409 For reasons similar to those described above, it is not possible to give
6410 an assembler instruction access to the condition code left by previous
6411 instructions.
6412
6413 @anchor{Extended asm with goto}
6414 As of GCC version 4.5, @code{asm goto} may be used to have the assembly
6415 jump to one or more C labels. In this form, a fifth section after the
6416 clobber list contains a list of all C labels to which the assembly may jump.
6417 Each label operand is implicitly self-named. The @code{asm} is also assumed
6418 to fall through to the next statement.
6419
6420 This form of @code{asm} is restricted to not have outputs. This is due
6421 to a internal restriction in the compiler that control transfer instructions
6422 cannot have outputs. This restriction on @code{asm goto} may be lifted
6423 in some future version of the compiler. In the meantime, @code{asm goto}
6424 may include a memory clobber, and so leave outputs in memory.
6425
6426 @smallexample
6427 int frob(int x)
6428 @{
6429 int y;
6430 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
6431 : : "r"(x), "r"(&y) : "r5", "memory" : error);
6432 return y;
6433 error:
6434 return -1;
6435 @}
6436 @end smallexample
6437
6438 @noindent
6439 In this (inefficient) example, the @code{frob} instruction sets the
6440 carry bit to indicate an error. The @code{jc} instruction detects
6441 this and branches to the @code{error} label. Finally, the output
6442 of the @code{frob} instruction (@code{%r5}) is stored into the memory
6443 for variable @code{y}, which is later read by the @code{return} statement.
6444
6445 @smallexample
6446 void doit(void)
6447 @{
6448 int i = 0;
6449 asm goto ("mfsr %%r1, 123; jmp %%r1;"
6450 ".pushsection doit_table;"
6451 ".long %l0, %l1, %l2, %l3;"
6452 ".popsection"
6453 : : : "r1" : label1, label2, label3, label4);
6454 __builtin_unreachable ();
6455
6456 label1:
6457 f1();
6458 return;
6459 label2:
6460 f2();
6461 return;
6462 label3:
6463 i = 1;
6464 label4:
6465 f3(i);
6466 @}
6467 @end smallexample
6468
6469 @noindent
6470 In this (also inefficient) example, the @code{mfsr} instruction reads
6471 an address from some out-of-band machine register, and the following
6472 @code{jmp} instruction branches to that address. The address read by
6473 the @code{mfsr} instruction is assumed to have been previously set via
6474 some application-specific mechanism to be one of the four values stored
6475 in the @code{doit_table} section. Finally, the @code{asm} is followed
6476 by a call to @code{__builtin_unreachable} to indicate that the @code{asm}
6477 does not in fact fall through.
6478
6479 @smallexample
6480 #define TRACE1(NUM) \
6481 do @{ \
6482 asm goto ("0: nop;" \
6483 ".pushsection trace_table;" \
6484 ".long 0b, %l0;" \
6485 ".popsection" \
6486 : : : : trace#NUM); \
6487 if (0) @{ trace#NUM: trace(); @} \
6488 @} while (0)
6489 #define TRACE TRACE1(__COUNTER__)
6490 @end smallexample
6491
6492 @noindent
6493 In this example (which in fact inspired the @code{asm goto} feature)
6494 we want on rare occasions to call the @code{trace} function; on other
6495 occasions we'd like to keep the overhead to the absolute minimum.
6496 The normal code path consists of a single @code{nop} instruction.
6497 However, we record the address of this @code{nop} together with the
6498 address of a label that calls the @code{trace} function. This allows
6499 the @code{nop} instruction to be patched at run time to be an
6500 unconditional branch to the stored label. It is assumed that an
6501 optimizing compiler moves the labeled block out of line, to
6502 optimize the fall through path from the @code{asm}.
6503
6504 If you are writing a header file that should be includable in ISO C
6505 programs, write @code{__asm__} instead of @code{asm}. @xref{Alternate
6506 Keywords}.
6507
6508 @subsection Size of an @code{asm}
6509
6510 Some targets require that GCC track the size of each instruction used in
6511 order to generate correct code. Because the final length of an
6512 @code{asm} is only known by the assembler, GCC must make an estimate as
6513 to how big it will be. The estimate is formed by counting the number of
6514 statements in the pattern of the @code{asm} and multiplying that by the
6515 length of the longest instruction on that processor. Statements in the
6516 @code{asm} are identified by newline characters and whatever statement
6517 separator characters are supported by the assembler; on most processors
6518 this is the @samp{;} character.
6519
6520 Normally, GCC's estimate is perfectly adequate to ensure that correct
6521 code is generated, but it is possible to confuse the compiler if you use
6522 pseudo instructions or assembler macros that expand into multiple real
6523 instructions or if you use assembler directives that expand to more
6524 space in the object file than is needed for a single instruction.
6525 If this happens then the assembler produces a diagnostic saying that
6526 a label is unreachable.
6527
6528 @subsection i386 floating-point asm operands
6529
6530 On i386 targets, there are several rules on the usage of stack-like registers
6531 in the operands of an @code{asm}. These rules apply only to the operands
6532 that are stack-like registers:
6533
6534 @enumerate
6535 @item
6536 Given a set of input registers that die in an @code{asm}, it is
6537 necessary to know which are implicitly popped by the @code{asm}, and
6538 which must be explicitly popped by GCC@.
6539
6540 An input register that is implicitly popped by the @code{asm} must be
6541 explicitly clobbered, unless it is constrained to match an
6542 output operand.
6543
6544 @item
6545 For any input register that is implicitly popped by an @code{asm}, it is
6546 necessary to know how to adjust the stack to compensate for the pop.
6547 If any non-popped input is closer to the top of the reg-stack than
6548 the implicitly popped register, it would not be possible to know what the
6549 stack looked like---it's not clear how the rest of the stack ``slides
6550 up''.
6551
6552 All implicitly popped input registers must be closer to the top of
6553 the reg-stack than any input that is not implicitly popped.
6554
6555 It is possible that if an input dies in an @code{asm}, the compiler might
6556 use the input register for an output reload. Consider this example:
6557
6558 @smallexample
6559 asm ("foo" : "=t" (a) : "f" (b));
6560 @end smallexample
6561
6562 @noindent
6563 This code says that input @code{b} is not popped by the @code{asm}, and that
6564 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
6565 deeper after the @code{asm} than it was before. But, it is possible that
6566 reload may think that it can use the same register for both the input and
6567 the output.
6568
6569 To prevent this from happening,
6570 if any input operand uses the @code{f} constraint, all output register
6571 constraints must use the @code{&} early-clobber modifier.
6572
6573 The example above would be correctly written as:
6574
6575 @smallexample
6576 asm ("foo" : "=&t" (a) : "f" (b));
6577 @end smallexample
6578
6579 @item
6580 Some operands need to be in particular places on the stack. All
6581 output operands fall in this category---GCC has no other way to
6582 know which registers the outputs appear in unless you indicate
6583 this in the constraints.
6584
6585 Output operands must specifically indicate which register an output
6586 appears in after an @code{asm}. @code{=f} is not allowed: the operand
6587 constraints must select a class with a single register.
6588
6589 @item
6590 Output operands may not be ``inserted'' between existing stack registers.
6591 Since no 387 opcode uses a read/write operand, all output operands
6592 are dead before the @code{asm}, and are pushed by the @code{asm}.
6593 It makes no sense to push anywhere but the top of the reg-stack.
6594
6595 Output operands must start at the top of the reg-stack: output
6596 operands may not ``skip'' a register.
6597
6598 @item
6599 Some @code{asm} statements may need extra stack space for internal
6600 calculations. This can be guaranteed by clobbering stack registers
6601 unrelated to the inputs and outputs.
6602
6603 @end enumerate
6604
6605 Here are a couple of reasonable @code{asm}s to want to write. This
6606 @code{asm}
6607 takes one input, which is internally popped, and produces two outputs.
6608
6609 @smallexample
6610 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
6611 @end smallexample
6612
6613 @noindent
6614 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
6615 and replaces them with one output. The @code{st(1)} clobber is necessary
6616 for the compiler to know that @code{fyl2xp1} pops both inputs.
6617
6618 @smallexample
6619 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
6620 @end smallexample
6621
6622 @include md.texi
6623
6624 @node Asm Labels
6625 @section Controlling Names Used in Assembler Code
6626 @cindex assembler names for identifiers
6627 @cindex names used in assembler code
6628 @cindex identifiers, names in assembler code
6629
6630 You can specify the name to be used in the assembler code for a C
6631 function or variable by writing the @code{asm} (or @code{__asm__})
6632 keyword after the declarator as follows:
6633
6634 @smallexample
6635 int foo asm ("myfoo") = 2;
6636 @end smallexample
6637
6638 @noindent
6639 This specifies that the name to be used for the variable @code{foo} in
6640 the assembler code should be @samp{myfoo} rather than the usual
6641 @samp{_foo}.
6642
6643 On systems where an underscore is normally prepended to the name of a C
6644 function or variable, this feature allows you to define names for the
6645 linker that do not start with an underscore.
6646
6647 It does not make sense to use this feature with a non-static local
6648 variable since such variables do not have assembler names. If you are
6649 trying to put the variable in a particular register, see @ref{Explicit
6650 Reg Vars}. GCC presently accepts such code with a warning, but will
6651 probably be changed to issue an error, rather than a warning, in the
6652 future.
6653
6654 You cannot use @code{asm} in this way in a function @emph{definition}; but
6655 you can get the same effect by writing a declaration for the function
6656 before its definition and putting @code{asm} there, like this:
6657
6658 @smallexample
6659 extern func () asm ("FUNC");
6660
6661 func (x, y)
6662 int x, y;
6663 /* @r{@dots{}} */
6664 @end smallexample
6665
6666 It is up to you to make sure that the assembler names you choose do not
6667 conflict with any other assembler symbols. Also, you must not use a
6668 register name; that would produce completely invalid assembler code. GCC
6669 does not as yet have the ability to store static variables in registers.
6670 Perhaps that will be added.
6671
6672 @node Explicit Reg Vars
6673 @section Variables in Specified Registers
6674 @cindex explicit register variables
6675 @cindex variables in specified registers
6676 @cindex specified registers
6677 @cindex registers, global allocation
6678
6679 GNU C allows you to put a few global variables into specified hardware
6680 registers. You can also specify the register in which an ordinary
6681 register variable should be allocated.
6682
6683 @itemize @bullet
6684 @item
6685 Global register variables reserve registers throughout the program.
6686 This may be useful in programs such as programming language
6687 interpreters that have a couple of global variables that are accessed
6688 very often.
6689
6690 @item
6691 Local register variables in specific registers do not reserve the
6692 registers, except at the point where they are used as input or output
6693 operands in an @code{asm} statement and the @code{asm} statement itself is
6694 not deleted. The compiler's data flow analysis is capable of determining
6695 where the specified registers contain live values, and where they are
6696 available for other uses. Stores into local register variables may be deleted
6697 when they appear to be dead according to dataflow analysis. References
6698 to local register variables may be deleted or moved or simplified.
6699
6700 These local variables are sometimes convenient for use with the extended
6701 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
6702 output of the assembler instruction directly into a particular register.
6703 (This works provided the register you specify fits the constraints
6704 specified for that operand in the @code{asm}.)
6705 @end itemize
6706
6707 @menu
6708 * Global Reg Vars::
6709 * Local Reg Vars::
6710 @end menu
6711
6712 @node Global Reg Vars
6713 @subsection Defining Global Register Variables
6714 @cindex global register variables
6715 @cindex registers, global variables in
6716
6717 You can define a global register variable in GNU C like this:
6718
6719 @smallexample
6720 register int *foo asm ("a5");
6721 @end smallexample
6722
6723 @noindent
6724 Here @code{a5} is the name of the register that should be used. Choose a
6725 register that is normally saved and restored by function calls on your
6726 machine, so that library routines will not clobber it.
6727
6728 Naturally the register name is cpu-dependent, so you need to
6729 conditionalize your program according to cpu type. The register
6730 @code{a5} is a good choice on a 68000 for a variable of pointer
6731 type. On machines with register windows, be sure to choose a ``global''
6732 register that is not affected magically by the function call mechanism.
6733
6734 In addition, different operating systems on the same CPU may differ in how they
6735 name the registers; then you need additional conditionals. For
6736 example, some 68000 operating systems call this register @code{%a5}.
6737
6738 Eventually there may be a way of asking the compiler to choose a register
6739 automatically, but first we need to figure out how it should choose and
6740 how to enable you to guide the choice. No solution is evident.
6741
6742 Defining a global register variable in a certain register reserves that
6743 register entirely for this use, at least within the current compilation.
6744 The register is not allocated for any other purpose in the functions
6745 in the current compilation, and is not saved and restored by
6746 these functions. Stores into this register are never deleted even if they
6747 appear to be dead, but references may be deleted or moved or
6748 simplified.
6749
6750 It is not safe to access the global register variables from signal
6751 handlers, or from more than one thread of control, because the system
6752 library routines may temporarily use the register for other things (unless
6753 you recompile them specially for the task at hand).
6754
6755 @cindex @code{qsort}, and global register variables
6756 It is not safe for one function that uses a global register variable to
6757 call another such function @code{foo} by way of a third function
6758 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
6759 different source file in which the variable isn't declared). This is
6760 because @code{lose} might save the register and put some other value there.
6761 For example, you can't expect a global register variable to be available in
6762 the comparison-function that you pass to @code{qsort}, since @code{qsort}
6763 might have put something else in that register. (If you are prepared to
6764 recompile @code{qsort} with the same global register variable, you can
6765 solve this problem.)
6766
6767 If you want to recompile @code{qsort} or other source files that do not
6768 actually use your global register variable, so that they do not use that
6769 register for any other purpose, then it suffices to specify the compiler
6770 option @option{-ffixed-@var{reg}}. You need not actually add a global
6771 register declaration to their source code.
6772
6773 A function that can alter the value of a global register variable cannot
6774 safely be called from a function compiled without this variable, because it
6775 could clobber the value the caller expects to find there on return.
6776 Therefore, the function that is the entry point into the part of the
6777 program that uses the global register variable must explicitly save and
6778 restore the value that belongs to its caller.
6779
6780 @cindex register variable after @code{longjmp}
6781 @cindex global register after @code{longjmp}
6782 @cindex value after @code{longjmp}
6783 @findex longjmp
6784 @findex setjmp
6785 On most machines, @code{longjmp} restores to each global register
6786 variable the value it had at the time of the @code{setjmp}. On some
6787 machines, however, @code{longjmp} does not change the value of global
6788 register variables. To be portable, the function that called @code{setjmp}
6789 should make other arrangements to save the values of the global register
6790 variables, and to restore them in a @code{longjmp}. This way, the same
6791 thing happens regardless of what @code{longjmp} does.
6792
6793 All global register variable declarations must precede all function
6794 definitions. If such a declaration could appear after function
6795 definitions, the declaration would be too late to prevent the register from
6796 being used for other purposes in the preceding functions.
6797
6798 Global register variables may not have initial values, because an
6799 executable file has no means to supply initial contents for a register.
6800
6801 On the SPARC, there are reports that g3 @dots{} g7 are suitable
6802 registers, but certain library functions, such as @code{getwd}, as well
6803 as the subroutines for division and remainder, modify g3 and g4. g1 and
6804 g2 are local temporaries.
6805
6806 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
6807 Of course, it does not do to use more than a few of those.
6808
6809 @node Local Reg Vars
6810 @subsection Specifying Registers for Local Variables
6811 @cindex local variables, specifying registers
6812 @cindex specifying registers for local variables
6813 @cindex registers for local variables
6814
6815 You can define a local register variable with a specified register
6816 like this:
6817
6818 @smallexample
6819 register int *foo asm ("a5");
6820 @end smallexample
6821
6822 @noindent
6823 Here @code{a5} is the name of the register that should be used. Note
6824 that this is the same syntax used for defining global register
6825 variables, but for a local variable it appears within a function.
6826
6827 Naturally the register name is cpu-dependent, but this is not a
6828 problem, since specific registers are most often useful with explicit
6829 assembler instructions (@pxref{Extended Asm}). Both of these things
6830 generally require that you conditionalize your program according to
6831 cpu type.
6832
6833 In addition, operating systems on one type of cpu may differ in how they
6834 name the registers; then you need additional conditionals. For
6835 example, some 68000 operating systems call this register @code{%a5}.
6836
6837 Defining such a register variable does not reserve the register; it
6838 remains available for other uses in places where flow control determines
6839 the variable's value is not live.
6840
6841 This option does not guarantee that GCC generates code that has
6842 this variable in the register you specify at all times. You may not
6843 code an explicit reference to this register in the @emph{assembler
6844 instruction template} part of an @code{asm} statement and assume it
6845 always refers to this variable. However, using the variable as an
6846 @code{asm} @emph{operand} guarantees that the specified register is used
6847 for the operand.
6848
6849 Stores into local register variables may be deleted when they appear to be dead
6850 according to dataflow analysis. References to local register variables may
6851 be deleted or moved or simplified.
6852
6853 As for global register variables, it's recommended that you choose a
6854 register that is normally saved and restored by function calls on
6855 your machine, so that library routines will not clobber it. A common
6856 pitfall is to initialize multiple call-clobbered registers with
6857 arbitrary expressions, where a function call or library call for an
6858 arithmetic operator overwrites a register value from a previous
6859 assignment, for example @code{r0} below:
6860 @smallexample
6861 register int *p1 asm ("r0") = @dots{};
6862 register int *p2 asm ("r1") = @dots{};
6863 @end smallexample
6864
6865 @noindent
6866 In those cases, a solution is to use a temporary variable for
6867 each arbitrary expression. @xref{Example of asm with clobbered asm reg}.
6868
6869 @node Alternate Keywords
6870 @section Alternate Keywords
6871 @cindex alternate keywords
6872 @cindex keywords, alternate
6873
6874 @option{-ansi} and the various @option{-std} options disable certain
6875 keywords. This causes trouble when you want to use GNU C extensions, or
6876 a general-purpose header file that should be usable by all programs,
6877 including ISO C programs. The keywords @code{asm}, @code{typeof} and
6878 @code{inline} are not available in programs compiled with
6879 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
6880 program compiled with @option{-std=c99} or @option{-std=c11}). The
6881 ISO C99 keyword
6882 @code{restrict} is only available when @option{-std=gnu99} (which will
6883 eventually be the default) or @option{-std=c99} (or the equivalent
6884 @option{-std=iso9899:1999}), or an option for a later standard
6885 version, is used.
6886
6887 The way to solve these problems is to put @samp{__} at the beginning and
6888 end of each problematical keyword. For example, use @code{__asm__}
6889 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
6890
6891 Other C compilers won't accept these alternative keywords; if you want to
6892 compile with another compiler, you can define the alternate keywords as
6893 macros to replace them with the customary keywords. It looks like this:
6894
6895 @smallexample
6896 #ifndef __GNUC__
6897 #define __asm__ asm
6898 #endif
6899 @end smallexample
6900
6901 @findex __extension__
6902 @opindex pedantic
6903 @option{-pedantic} and other options cause warnings for many GNU C extensions.
6904 You can
6905 prevent such warnings within one expression by writing
6906 @code{__extension__} before the expression. @code{__extension__} has no
6907 effect aside from this.
6908
6909 @node Incomplete Enums
6910 @section Incomplete @code{enum} Types
6911
6912 You can define an @code{enum} tag without specifying its possible values.
6913 This results in an incomplete type, much like what you get if you write
6914 @code{struct foo} without describing the elements. A later declaration
6915 that does specify the possible values completes the type.
6916
6917 You can't allocate variables or storage using the type while it is
6918 incomplete. However, you can work with pointers to that type.
6919
6920 This extension may not be very useful, but it makes the handling of
6921 @code{enum} more consistent with the way @code{struct} and @code{union}
6922 are handled.
6923
6924 This extension is not supported by GNU C++.
6925
6926 @node Function Names
6927 @section Function Names as Strings
6928 @cindex @code{__func__} identifier
6929 @cindex @code{__FUNCTION__} identifier
6930 @cindex @code{__PRETTY_FUNCTION__} identifier
6931
6932 GCC provides three magic variables that hold the name of the current
6933 function, as a string. The first of these is @code{__func__}, which
6934 is part of the C99 standard:
6935
6936 The identifier @code{__func__} is implicitly declared by the translator
6937 as if, immediately following the opening brace of each function
6938 definition, the declaration
6939
6940 @smallexample
6941 static const char __func__[] = "function-name";
6942 @end smallexample
6943
6944 @noindent
6945 appeared, where function-name is the name of the lexically-enclosing
6946 function. This name is the unadorned name of the function.
6947
6948 @code{__FUNCTION__} is another name for @code{__func__}. Older
6949 versions of GCC recognize only this name. However, it is not
6950 standardized. For maximum portability, we recommend you use
6951 @code{__func__}, but provide a fallback definition with the
6952 preprocessor:
6953
6954 @smallexample
6955 #if __STDC_VERSION__ < 199901L
6956 # if __GNUC__ >= 2
6957 # define __func__ __FUNCTION__
6958 # else
6959 # define __func__ "<unknown>"
6960 # endif
6961 #endif
6962 @end smallexample
6963
6964 In C, @code{__PRETTY_FUNCTION__} is yet another name for
6965 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
6966 the type signature of the function as well as its bare name. For
6967 example, this program:
6968
6969 @smallexample
6970 extern "C" @{
6971 extern int printf (char *, ...);
6972 @}
6973
6974 class a @{
6975 public:
6976 void sub (int i)
6977 @{
6978 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
6979 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
6980 @}
6981 @};
6982
6983 int
6984 main (void)
6985 @{
6986 a ax;
6987 ax.sub (0);
6988 return 0;
6989 @}
6990 @end smallexample
6991
6992 @noindent
6993 gives this output:
6994
6995 @smallexample
6996 __FUNCTION__ = sub
6997 __PRETTY_FUNCTION__ = void a::sub(int)
6998 @end smallexample
6999
7000 These identifiers are not preprocessor macros. In GCC 3.3 and
7001 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
7002 were treated as string literals; they could be used to initialize
7003 @code{char} arrays, and they could be concatenated with other string
7004 literals. GCC 3.4 and later treat them as variables, like
7005 @code{__func__}. In C++, @code{__FUNCTION__} and
7006 @code{__PRETTY_FUNCTION__} have always been variables.
7007
7008 @node Return Address
7009 @section Getting the Return or Frame Address of a Function
7010
7011 These functions may be used to get information about the callers of a
7012 function.
7013
7014 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7015 This function returns the return address of the current function, or of
7016 one of its callers. The @var{level} argument is number of frames to
7017 scan up the call stack. A value of @code{0} yields the return address
7018 of the current function, a value of @code{1} yields the return address
7019 of the caller of the current function, and so forth. When inlining
7020 the expected behavior is that the function returns the address of
7021 the function that is returned to. To work around this behavior use
7022 the @code{noinline} function attribute.
7023
7024 The @var{level} argument must be a constant integer.
7025
7026 On some machines it may be impossible to determine the return address of
7027 any function other than the current one; in such cases, or when the top
7028 of the stack has been reached, this function returns @code{0} or a
7029 random value. In addition, @code{__builtin_frame_address} may be used
7030 to determine if the top of the stack has been reached.
7031
7032 Additional post-processing of the returned value may be needed, see
7033 @code{__builtin_extract_return_addr}.
7034
7035 This function should only be used with a nonzero argument for debugging
7036 purposes.
7037 @end deftypefn
7038
7039 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7040 The address as returned by @code{__builtin_return_address} may have to be fed
7041 through this function to get the actual encoded address. For example, on the
7042 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7043 platforms an offset has to be added for the true next instruction to be
7044 executed.
7045
7046 If no fixup is needed, this function simply passes through @var{addr}.
7047 @end deftypefn
7048
7049 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7050 This function does the reverse of @code{__builtin_extract_return_addr}.
7051 @end deftypefn
7052
7053 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7054 This function is similar to @code{__builtin_return_address}, but it
7055 returns the address of the function frame rather than the return address
7056 of the function. Calling @code{__builtin_frame_address} with a value of
7057 @code{0} yields the frame address of the current function, a value of
7058 @code{1} yields the frame address of the caller of the current function,
7059 and so forth.
7060
7061 The frame is the area on the stack that holds local variables and saved
7062 registers. The frame address is normally the address of the first word
7063 pushed on to the stack by the function. However, the exact definition
7064 depends upon the processor and the calling convention. If the processor
7065 has a dedicated frame pointer register, and the function has a frame,
7066 then @code{__builtin_frame_address} returns the value of the frame
7067 pointer register.
7068
7069 On some machines it may be impossible to determine the frame address of
7070 any function other than the current one; in such cases, or when the top
7071 of the stack has been reached, this function returns @code{0} if
7072 the first frame pointer is properly initialized by the startup code.
7073
7074 This function should only be used with a nonzero argument for debugging
7075 purposes.
7076 @end deftypefn
7077
7078 @node Vector Extensions
7079 @section Using Vector Instructions through Built-in Functions
7080
7081 On some targets, the instruction set contains SIMD vector instructions which
7082 operate on multiple values contained in one large register at the same time.
7083 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
7084 this way.
7085
7086 The first step in using these extensions is to provide the necessary data
7087 types. This should be done using an appropriate @code{typedef}:
7088
7089 @smallexample
7090 typedef int v4si __attribute__ ((vector_size (16)));
7091 @end smallexample
7092
7093 @noindent
7094 The @code{int} type specifies the base type, while the attribute specifies
7095 the vector size for the variable, measured in bytes. For example, the
7096 declaration above causes the compiler to set the mode for the @code{v4si}
7097 type to be 16 bytes wide and divided into @code{int} sized units. For
7098 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7099 corresponding mode of @code{foo} is @acronym{V4SI}.
7100
7101 The @code{vector_size} attribute is only applicable to integral and
7102 float scalars, although arrays, pointers, and function return values
7103 are allowed in conjunction with this construct. Only sizes that are
7104 a power of two are currently allowed.
7105
7106 All the basic integer types can be used as base types, both as signed
7107 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7108 @code{long long}. In addition, @code{float} and @code{double} can be
7109 used to build floating-point vector types.
7110
7111 Specifying a combination that is not valid for the current architecture
7112 causes GCC to synthesize the instructions using a narrower mode.
7113 For example, if you specify a variable of type @code{V4SI} and your
7114 architecture does not allow for this specific SIMD type, GCC
7115 produces code that uses 4 @code{SIs}.
7116
7117 The types defined in this manner can be used with a subset of normal C
7118 operations. Currently, GCC allows using the following operators
7119 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7120
7121 The operations behave like C++ @code{valarrays}. Addition is defined as
7122 the addition of the corresponding elements of the operands. For
7123 example, in the code below, each of the 4 elements in @var{a} is
7124 added to the corresponding 4 elements in @var{b} and the resulting
7125 vector is stored in @var{c}.
7126
7127 @smallexample
7128 typedef int v4si __attribute__ ((vector_size (16)));
7129
7130 v4si a, b, c;
7131
7132 c = a + b;
7133 @end smallexample
7134
7135 Subtraction, multiplication, division, and the logical operations
7136 operate in a similar manner. Likewise, the result of using the unary
7137 minus or complement operators on a vector type is a vector whose
7138 elements are the negative or complemented values of the corresponding
7139 elements in the operand.
7140
7141 It is possible to use shifting operators @code{<<}, @code{>>} on
7142 integer-type vectors. The operation is defined as following: @code{@{a0,
7143 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7144 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7145 elements.
7146
7147 For convenience, it is allowed to use a binary vector operation
7148 where one operand is a scalar. In that case the compiler transforms
7149 the scalar operand into a vector where each element is the scalar from
7150 the operation. The transformation happens only if the scalar could be
7151 safely converted to the vector-element type.
7152 Consider the following code.
7153
7154 @smallexample
7155 typedef int v4si __attribute__ ((vector_size (16)));
7156
7157 v4si a, b, c;
7158 long l;
7159
7160 a = b + 1; /* a = b + @{1,1,1,1@}; */
7161 a = 2 * b; /* a = @{2,2,2,2@} * b; */
7162
7163 a = l + a; /* Error, cannot convert long to int. */
7164 @end smallexample
7165
7166 Vectors can be subscripted as if the vector were an array with
7167 the same number of elements and base type. Out of bound accesses
7168 invoke undefined behavior at run time. Warnings for out of bound
7169 accesses for vector subscription can be enabled with
7170 @option{-Warray-bounds}.
7171
7172 Vector comparison is supported with standard comparison
7173 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
7174 vector expressions of integer-type or real-type. Comparison between
7175 integer-type vectors and real-type vectors are not supported. The
7176 result of the comparison is a vector of the same width and number of
7177 elements as the comparison operands with a signed integral element
7178 type.
7179
7180 Vectors are compared element-wise producing 0 when comparison is false
7181 and -1 (constant of the appropriate type where all bits are set)
7182 otherwise. Consider the following example.
7183
7184 @smallexample
7185 typedef int v4si __attribute__ ((vector_size (16)));
7186
7187 v4si a = @{1,2,3,4@};
7188 v4si b = @{3,2,1,4@};
7189 v4si c;
7190
7191 c = a > b; /* The result would be @{0, 0,-1, 0@} */
7192 c = a == b; /* The result would be @{0,-1, 0,-1@} */
7193 @end smallexample
7194
7195 Vector shuffling is available using functions
7196 @code{__builtin_shuffle (vec, mask)} and
7197 @code{__builtin_shuffle (vec0, vec1, mask)}.
7198 Both functions construct a permutation of elements from one or two
7199 vectors and return a vector of the same type as the input vector(s).
7200 The @var{mask} is an integral vector with the same width (@var{W})
7201 and element count (@var{N}) as the output vector.
7202
7203 The elements of the input vectors are numbered in memory ordering of
7204 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
7205 elements of @var{mask} are considered modulo @var{N} in the single-operand
7206 case and modulo @math{2*@var{N}} in the two-operand case.
7207
7208 Consider the following example,
7209
7210 @smallexample
7211 typedef int v4si __attribute__ ((vector_size (16)));
7212
7213 v4si a = @{1,2,3,4@};
7214 v4si b = @{5,6,7,8@};
7215 v4si mask1 = @{0,1,1,3@};
7216 v4si mask2 = @{0,4,2,5@};
7217 v4si res;
7218
7219 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
7220 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
7221 @end smallexample
7222
7223 Note that @code{__builtin_shuffle} is intentionally semantically
7224 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
7225
7226 You can declare variables and use them in function calls and returns, as
7227 well as in assignments and some casts. You can specify a vector type as
7228 a return type for a function. Vector types can also be used as function
7229 arguments. It is possible to cast from one vector type to another,
7230 provided they are of the same size (in fact, you can also cast vectors
7231 to and from other datatypes of the same size).
7232
7233 You cannot operate between vectors of different lengths or different
7234 signedness without a cast.
7235
7236 @node Offsetof
7237 @section Offsetof
7238 @findex __builtin_offsetof
7239
7240 GCC implements for both C and C++ a syntactic extension to implement
7241 the @code{offsetof} macro.
7242
7243 @smallexample
7244 primary:
7245 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
7246
7247 offsetof_member_designator:
7248 @code{identifier}
7249 | offsetof_member_designator "." @code{identifier}
7250 | offsetof_member_designator "[" @code{expr} "]"
7251 @end smallexample
7252
7253 This extension is sufficient such that
7254
7255 @smallexample
7256 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
7257 @end smallexample
7258
7259 @noindent
7260 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
7261 may be dependent. In either case, @var{member} may consist of a single
7262 identifier, or a sequence of member accesses and array references.
7263
7264 @node __sync Builtins
7265 @section Legacy __sync Built-in Functions for Atomic Memory Access
7266
7267 The following built-in functions
7268 are intended to be compatible with those described
7269 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
7270 section 7.4. As such, they depart from the normal GCC practice of using
7271 the @samp{__builtin_} prefix, and further that they are overloaded such that
7272 they work on multiple types.
7273
7274 The definition given in the Intel documentation allows only for the use of
7275 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
7276 counterparts. GCC allows any integral scalar or pointer type that is
7277 1, 2, 4 or 8 bytes in length.
7278
7279 Not all operations are supported by all target processors. If a particular
7280 operation cannot be implemented on the target processor, a warning is
7281 generated and a call an external function is generated. The external
7282 function carries the same name as the built-in version,
7283 with an additional suffix
7284 @samp{_@var{n}} where @var{n} is the size of the data type.
7285
7286 @c ??? Should we have a mechanism to suppress this warning? This is almost
7287 @c useful for implementing the operation under the control of an external
7288 @c mutex.
7289
7290 In most cases, these built-in functions are considered a @dfn{full barrier}.
7291 That is,
7292 no memory operand is moved across the operation, either forward or
7293 backward. Further, instructions are issued as necessary to prevent the
7294 processor from speculating loads across the operation and from queuing stores
7295 after the operation.
7296
7297 All of the routines are described in the Intel documentation to take
7298 ``an optional list of variables protected by the memory barrier''. It's
7299 not clear what is meant by that; it could mean that @emph{only} the
7300 following variables are protected, or it could mean that these variables
7301 should in addition be protected. At present GCC ignores this list and
7302 protects all variables that are globally accessible. If in the future
7303 we make some use of this list, an empty list will continue to mean all
7304 globally accessible variables.
7305
7306 @table @code
7307 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
7308 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
7309 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
7310 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
7311 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
7312 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
7313 @findex __sync_fetch_and_add
7314 @findex __sync_fetch_and_sub
7315 @findex __sync_fetch_and_or
7316 @findex __sync_fetch_and_and
7317 @findex __sync_fetch_and_xor
7318 @findex __sync_fetch_and_nand
7319 These built-in functions perform the operation suggested by the name, and
7320 returns the value that had previously been in memory. That is,
7321
7322 @smallexample
7323 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
7324 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
7325 @end smallexample
7326
7327 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
7328 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
7329
7330 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
7331 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
7332 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
7333 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
7334 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
7335 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
7336 @findex __sync_add_and_fetch
7337 @findex __sync_sub_and_fetch
7338 @findex __sync_or_and_fetch
7339 @findex __sync_and_and_fetch
7340 @findex __sync_xor_and_fetch
7341 @findex __sync_nand_and_fetch
7342 These built-in functions perform the operation suggested by the name, and
7343 return the new value. That is,
7344
7345 @smallexample
7346 @{ *ptr @var{op}= value; return *ptr; @}
7347 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
7348 @end smallexample
7349
7350 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
7351 as @code{*ptr = ~(*ptr & value)} instead of
7352 @code{*ptr = ~*ptr & value}.
7353
7354 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7355 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7356 @findex __sync_bool_compare_and_swap
7357 @findex __sync_val_compare_and_swap
7358 These built-in functions perform an atomic compare and swap.
7359 That is, if the current
7360 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
7361 @code{*@var{ptr}}.
7362
7363 The ``bool'' version returns true if the comparison is successful and
7364 @var{newval} is written. The ``val'' version returns the contents
7365 of @code{*@var{ptr}} before the operation.
7366
7367 @item __sync_synchronize (...)
7368 @findex __sync_synchronize
7369 This built-in function issues a full memory barrier.
7370
7371 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
7372 @findex __sync_lock_test_and_set
7373 This built-in function, as described by Intel, is not a traditional test-and-set
7374 operation, but rather an atomic exchange operation. It writes @var{value}
7375 into @code{*@var{ptr}}, and returns the previous contents of
7376 @code{*@var{ptr}}.
7377
7378 Many targets have only minimal support for such locks, and do not support
7379 a full exchange operation. In this case, a target may support reduced
7380 functionality here by which the @emph{only} valid value to store is the
7381 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
7382 is implementation defined.
7383
7384 This built-in function is not a full barrier,
7385 but rather an @dfn{acquire barrier}.
7386 This means that references after the operation cannot move to (or be
7387 speculated to) before the operation, but previous memory stores may not
7388 be globally visible yet, and previous memory loads may not yet be
7389 satisfied.
7390
7391 @item void __sync_lock_release (@var{type} *ptr, ...)
7392 @findex __sync_lock_release
7393 This built-in function releases the lock acquired by
7394 @code{__sync_lock_test_and_set}.
7395 Normally this means writing the constant 0 to @code{*@var{ptr}}.
7396
7397 This built-in function is not a full barrier,
7398 but rather a @dfn{release barrier}.
7399 This means that all previous memory stores are globally visible, and all
7400 previous memory loads have been satisfied, but following memory reads
7401 are not prevented from being speculated to before the barrier.
7402 @end table
7403
7404 @node __atomic Builtins
7405 @section Built-in functions for memory model aware atomic operations
7406
7407 The following built-in functions approximately match the requirements for
7408 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
7409 functions, but all also have a memory model parameter. These are all
7410 identified by being prefixed with @samp{__atomic}, and most are overloaded
7411 such that they work with multiple types.
7412
7413 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
7414 bytes in length. 16-byte integral types are also allowed if
7415 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
7416
7417 Target architectures are encouraged to provide their own patterns for
7418 each of these built-in functions. If no target is provided, the original
7419 non-memory model set of @samp{__sync} atomic built-in functions are
7420 utilized, along with any required synchronization fences surrounding it in
7421 order to achieve the proper behavior. Execution in this case is subject
7422 to the same restrictions as those built-in functions.
7423
7424 If there is no pattern or mechanism to provide a lock free instruction
7425 sequence, a call is made to an external routine with the same parameters
7426 to be resolved at run time.
7427
7428 The four non-arithmetic functions (load, store, exchange, and
7429 compare_exchange) all have a generic version as well. This generic
7430 version works on any data type. If the data type size maps to one
7431 of the integral sizes that may have lock free support, the generic
7432 version utilizes the lock free built-in function. Otherwise an
7433 external call is left to be resolved at run time. This external call is
7434 the same format with the addition of a @samp{size_t} parameter inserted
7435 as the first parameter indicating the size of the object being pointed to.
7436 All objects must be the same size.
7437
7438 There are 6 different memory models that can be specified. These map
7439 to the same names in the C++11 standard. Refer there or to the
7440 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
7441 atomic synchronization} for more detailed definitions. These memory
7442 models integrate both barriers to code motion as well as synchronization
7443 requirements with other threads. These are listed in approximately
7444 ascending order of strength. It is also possible to use target specific
7445 flags for memory model flags, like Hardware Lock Elision.
7446
7447 @table @code
7448 @item __ATOMIC_RELAXED
7449 No barriers or synchronization.
7450 @item __ATOMIC_CONSUME
7451 Data dependency only for both barrier and synchronization with another
7452 thread.
7453 @item __ATOMIC_ACQUIRE
7454 Barrier to hoisting of code and synchronizes with release (or stronger)
7455 semantic stores from another thread.
7456 @item __ATOMIC_RELEASE
7457 Barrier to sinking of code and synchronizes with acquire (or stronger)
7458 semantic loads from another thread.
7459 @item __ATOMIC_ACQ_REL
7460 Full barrier in both directions and synchronizes with acquire loads and
7461 release stores in another thread.
7462 @item __ATOMIC_SEQ_CST
7463 Full barrier in both directions and synchronizes with acquire loads and
7464 release stores in all threads.
7465 @end table
7466
7467 When implementing patterns for these built-in functions, the memory model
7468 parameter can be ignored as long as the pattern implements the most
7469 restrictive @code{__ATOMIC_SEQ_CST} model. Any of the other memory models
7470 execute correctly with this memory model but they may not execute as
7471 efficiently as they could with a more appropriate implementation of the
7472 relaxed requirements.
7473
7474 Note that the C++11 standard allows for the memory model parameter to be
7475 determined at run time rather than at compile time. These built-in
7476 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
7477 than invoke a runtime library call or inline a switch statement. This is
7478 standard compliant, safe, and the simplest approach for now.
7479
7480 The memory model parameter is a signed int, but only the lower 8 bits are
7481 reserved for the memory model. The remainder of the signed int is reserved
7482 for future use and should be 0. Use of the predefined atomic values
7483 ensures proper usage.
7484
7485 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
7486 This built-in function implements an atomic load operation. It returns the
7487 contents of @code{*@var{ptr}}.
7488
7489 The valid memory model variants are
7490 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
7491 and @code{__ATOMIC_CONSUME}.
7492
7493 @end deftypefn
7494
7495 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
7496 This is the generic version of an atomic load. It returns the
7497 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
7498
7499 @end deftypefn
7500
7501 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
7502 This built-in function implements an atomic store operation. It writes
7503 @code{@var{val}} into @code{*@var{ptr}}.
7504
7505 The valid memory model variants are
7506 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
7507
7508 @end deftypefn
7509
7510 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
7511 This is the generic version of an atomic store. It stores the value
7512 of @code{*@var{val}} into @code{*@var{ptr}}.
7513
7514 @end deftypefn
7515
7516 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
7517 This built-in function implements an atomic exchange operation. It writes
7518 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
7519 @code{*@var{ptr}}.
7520
7521 The valid memory model variants are
7522 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
7523 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
7524
7525 @end deftypefn
7526
7527 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
7528 This is the generic version of an atomic exchange. It stores the
7529 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
7530 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
7531
7532 @end deftypefn
7533
7534 @deftypefn {Built-in Function} bool __atomic_compare_exchange_n (@var{type} *ptr, @var{type} *expected, @var{type} desired, bool weak, int success_memmodel, int failure_memmodel)
7535 This built-in function implements an atomic compare and exchange operation.
7536 This compares the contents of @code{*@var{ptr}} with the contents of
7537 @code{*@var{expected}} and if equal, writes @var{desired} into
7538 @code{*@var{ptr}}. If they are not equal, the current contents of
7539 @code{*@var{ptr}} is written into @code{*@var{expected}}. @var{weak} is true
7540 for weak compare_exchange, and false for the strong variation. Many targets
7541 only offer the strong variation and ignore the parameter. When in doubt, use
7542 the strong variation.
7543
7544 True is returned if @var{desired} is written into
7545 @code{*@var{ptr}} and the execution is considered to conform to the
7546 memory model specified by @var{success_memmodel}. There are no
7547 restrictions on what memory model can be used here.
7548
7549 False is returned otherwise, and the execution is considered to conform
7550 to @var{failure_memmodel}. This memory model cannot be
7551 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
7552 stronger model than that specified by @var{success_memmodel}.
7553
7554 @end deftypefn
7555
7556 @deftypefn {Built-in Function} bool __atomic_compare_exchange (@var{type} *ptr, @var{type} *expected, @var{type} *desired, bool weak, int success_memmodel, int failure_memmodel)
7557 This built-in function implements the generic version of
7558 @code{__atomic_compare_exchange}. The function is virtually identical to
7559 @code{__atomic_compare_exchange_n}, except the desired value is also a
7560 pointer.
7561
7562 @end deftypefn
7563
7564 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7565 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7566 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7567 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7568 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7569 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7570 These built-in functions perform the operation suggested by the name, and
7571 return the result of the operation. That is,
7572
7573 @smallexample
7574 @{ *ptr @var{op}= val; return *ptr; @}
7575 @end smallexample
7576
7577 All memory models are valid.
7578
7579 @end deftypefn
7580
7581 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
7582 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
7583 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
7584 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
7585 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
7586 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
7587 These built-in functions perform the operation suggested by the name, and
7588 return the value that had previously been in @code{*@var{ptr}}. That is,
7589
7590 @smallexample
7591 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
7592 @end smallexample
7593
7594 All memory models are valid.
7595
7596 @end deftypefn
7597
7598 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
7599
7600 This built-in function performs an atomic test-and-set operation on
7601 the byte at @code{*@var{ptr}}. The byte is set to some implementation
7602 defined nonzero ``set'' value and the return value is @code{true} if and only
7603 if the previous contents were ``set''.
7604 It should be only used for operands of type @code{bool} or @code{char}. For
7605 other types only part of the value may be set.
7606
7607 All memory models are valid.
7608
7609 @end deftypefn
7610
7611 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
7612
7613 This built-in function performs an atomic clear operation on
7614 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
7615 It should be only used for operands of type @code{bool} or @code{char} and
7616 in conjunction with @code{__atomic_test_and_set}.
7617 For other types it may only clear partially. If the type is not @code{bool}
7618 prefer using @code{__atomic_store}.
7619
7620 The valid memory model variants are
7621 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
7622 @code{__ATOMIC_RELEASE}.
7623
7624 @end deftypefn
7625
7626 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
7627
7628 This built-in function acts as a synchronization fence between threads
7629 based on the specified memory model.
7630
7631 All memory orders are valid.
7632
7633 @end deftypefn
7634
7635 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
7636
7637 This built-in function acts as a synchronization fence between a thread
7638 and signal handlers based in the same thread.
7639
7640 All memory orders are valid.
7641
7642 @end deftypefn
7643
7644 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
7645
7646 This built-in function returns true if objects of @var{size} bytes always
7647 generate lock free atomic instructions for the target architecture.
7648 @var{size} must resolve to a compile-time constant and the result also
7649 resolves to a compile-time constant.
7650
7651 @var{ptr} is an optional pointer to the object that may be used to determine
7652 alignment. A value of 0 indicates typical alignment should be used. The
7653 compiler may also ignore this parameter.
7654
7655 @smallexample
7656 if (_atomic_always_lock_free (sizeof (long long), 0))
7657 @end smallexample
7658
7659 @end deftypefn
7660
7661 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
7662
7663 This built-in function returns true if objects of @var{size} bytes always
7664 generate lock free atomic instructions for the target architecture. If
7665 it is not known to be lock free a call is made to a runtime routine named
7666 @code{__atomic_is_lock_free}.
7667
7668 @var{ptr} is an optional pointer to the object that may be used to determine
7669 alignment. A value of 0 indicates typical alignment should be used. The
7670 compiler may also ignore this parameter.
7671 @end deftypefn
7672
7673 @node x86 specific memory model extensions for transactional memory
7674 @section x86 specific memory model extensions for transactional memory
7675
7676 The i386 architecture supports additional memory ordering flags
7677 to mark lock critical sections for hardware lock elision.
7678 These must be specified in addition to an existing memory model to
7679 atomic intrinsics.
7680
7681 @table @code
7682 @item __ATOMIC_HLE_ACQUIRE
7683 Start lock elision on a lock variable.
7684 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
7685 @item __ATOMIC_HLE_RELEASE
7686 End lock elision on a lock variable.
7687 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
7688 @end table
7689
7690 When a lock acquire fails it is required for good performance to abort
7691 the transaction quickly. This can be done with a @code{_mm_pause}
7692
7693 @smallexample
7694 #include <immintrin.h> // For _mm_pause
7695
7696 int lockvar;
7697
7698 /* Acquire lock with lock elision */
7699 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
7700 _mm_pause(); /* Abort failed transaction */
7701 ...
7702 /* Free lock with lock elision */
7703 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
7704 @end smallexample
7705
7706 @node Object Size Checking
7707 @section Object Size Checking Built-in Functions
7708 @findex __builtin_object_size
7709 @findex __builtin___memcpy_chk
7710 @findex __builtin___mempcpy_chk
7711 @findex __builtin___memmove_chk
7712 @findex __builtin___memset_chk
7713 @findex __builtin___strcpy_chk
7714 @findex __builtin___stpcpy_chk
7715 @findex __builtin___strncpy_chk
7716 @findex __builtin___strcat_chk
7717 @findex __builtin___strncat_chk
7718 @findex __builtin___sprintf_chk
7719 @findex __builtin___snprintf_chk
7720 @findex __builtin___vsprintf_chk
7721 @findex __builtin___vsnprintf_chk
7722 @findex __builtin___printf_chk
7723 @findex __builtin___vprintf_chk
7724 @findex __builtin___fprintf_chk
7725 @findex __builtin___vfprintf_chk
7726
7727 GCC implements a limited buffer overflow protection mechanism
7728 that can prevent some buffer overflow attacks.
7729
7730 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
7731 is a built-in construct that returns a constant number of bytes from
7732 @var{ptr} to the end of the object @var{ptr} pointer points to
7733 (if known at compile time). @code{__builtin_object_size} never evaluates
7734 its arguments for side-effects. If there are any side-effects in them, it
7735 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
7736 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
7737 point to and all of them are known at compile time, the returned number
7738 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
7739 0 and minimum if nonzero. If it is not possible to determine which objects
7740 @var{ptr} points to at compile time, @code{__builtin_object_size} should
7741 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
7742 for @var{type} 2 or 3.
7743
7744 @var{type} is an integer constant from 0 to 3. If the least significant
7745 bit is clear, objects are whole variables, if it is set, a closest
7746 surrounding subobject is considered the object a pointer points to.
7747 The second bit determines if maximum or minimum of remaining bytes
7748 is computed.
7749
7750 @smallexample
7751 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
7752 char *p = &var.buf1[1], *q = &var.b;
7753
7754 /* Here the object p points to is var. */
7755 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
7756 /* The subobject p points to is var.buf1. */
7757 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
7758 /* The object q points to is var. */
7759 assert (__builtin_object_size (q, 0)
7760 == (char *) (&var + 1) - (char *) &var.b);
7761 /* The subobject q points to is var.b. */
7762 assert (__builtin_object_size (q, 1) == sizeof (var.b));
7763 @end smallexample
7764 @end deftypefn
7765
7766 There are built-in functions added for many common string operation
7767 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
7768 built-in is provided. This built-in has an additional last argument,
7769 which is the number of bytes remaining in object the @var{dest}
7770 argument points to or @code{(size_t) -1} if the size is not known.
7771
7772 The built-in functions are optimized into the normal string functions
7773 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
7774 it is known at compile time that the destination object will not
7775 be overflown. If the compiler can determine at compile time the
7776 object will be always overflown, it issues a warning.
7777
7778 The intended use can be e.g.@:
7779
7780 @smallexample
7781 #undef memcpy
7782 #define bos0(dest) __builtin_object_size (dest, 0)
7783 #define memcpy(dest, src, n) \
7784 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
7785
7786 char *volatile p;
7787 char buf[10];
7788 /* It is unknown what object p points to, so this is optimized
7789 into plain memcpy - no checking is possible. */
7790 memcpy (p, "abcde", n);
7791 /* Destination is known and length too. It is known at compile
7792 time there will be no overflow. */
7793 memcpy (&buf[5], "abcde", 5);
7794 /* Destination is known, but the length is not known at compile time.
7795 This will result in __memcpy_chk call that can check for overflow
7796 at run time. */
7797 memcpy (&buf[5], "abcde", n);
7798 /* Destination is known and it is known at compile time there will
7799 be overflow. There will be a warning and __memcpy_chk call that
7800 will abort the program at run time. */
7801 memcpy (&buf[6], "abcde", 5);
7802 @end smallexample
7803
7804 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
7805 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
7806 @code{strcat} and @code{strncat}.
7807
7808 There are also checking built-in functions for formatted output functions.
7809 @smallexample
7810 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
7811 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
7812 const char *fmt, ...);
7813 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
7814 va_list ap);
7815 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
7816 const char *fmt, va_list ap);
7817 @end smallexample
7818
7819 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
7820 etc.@: functions and can contain implementation specific flags on what
7821 additional security measures the checking function might take, such as
7822 handling @code{%n} differently.
7823
7824 The @var{os} argument is the object size @var{s} points to, like in the
7825 other built-in functions. There is a small difference in the behavior
7826 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
7827 optimized into the non-checking functions only if @var{flag} is 0, otherwise
7828 the checking function is called with @var{os} argument set to
7829 @code{(size_t) -1}.
7830
7831 In addition to this, there are checking built-in functions
7832 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
7833 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
7834 These have just one additional argument, @var{flag}, right before
7835 format string @var{fmt}. If the compiler is able to optimize them to
7836 @code{fputc} etc.@: functions, it does, otherwise the checking function
7837 is called and the @var{flag} argument passed to it.
7838
7839 @node Pointer Bounds Checker builtins
7840 @section Pointer Bounds Checker Built-in Functions
7841 @findex __builtin___bnd_set_ptr_bounds
7842 @findex __builtin___bnd_narrow_ptr_bounds
7843 @findex __builtin___bnd_copy_ptr_bounds
7844 @findex __builtin___bnd_init_ptr_bounds
7845 @findex __builtin___bnd_null_ptr_bounds
7846 @findex __builtin___bnd_store_ptr_bounds
7847 @findex __builtin___bnd_chk_ptr_lbounds
7848 @findex __builtin___bnd_chk_ptr_ubounds
7849 @findex __builtin___bnd_chk_ptr_bounds
7850 @findex __builtin___bnd_get_ptr_lbound
7851 @findex __builtin___bnd_get_ptr_ubound
7852
7853 GCC provides a set of built-in functions to control Pointer Bounds Checker
7854 instrumentation. Note that all Pointer Bounds Checker builtins are allowed
7855 to use even if you compile with Pointer Bounds Checker off. But functions
7856 behavior may differ in such case.
7857
7858 @deftypefn {Built-in Function} void * __builtin___bnd_set_ptr_bounds (const void * @var{q}, size_t @var{size})
7859
7860 This built-in function returns a new pointer with the value of @var{q}, and
7861 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
7862 Bounds Checker off built-in function just returns the first argument.
7863
7864 @smallexample
7865 extern void *__wrap_malloc (size_t n)
7866 @{
7867 void *p = (void *)__real_malloc (n);
7868 if (!p) return __builtin___bnd_null_ptr_bounds (p);
7869 return __builtin___bnd_set_ptr_bounds (p, n);
7870 @}
7871 @end smallexample
7872
7873 @end deftypefn
7874
7875 @deftypefn {Built-in Function} void * __builtin___bnd_narrow_ptr_bounds (const void * @var{p}, const void * @var{q}, size_t @var{size})
7876
7877 This built-in function returns a new pointer with the value of @var{p}
7878 and associate it with the narrowed bounds formed by the intersection
7879 of bounds associated with @var{q} and the [@var{p}, @var{p} + @var{size} - 1].
7880 With Pointer Bounds Checker off built-in function just returns the first
7881 argument.
7882
7883 @smallexample
7884 void init_objects (object *objs, size_t size)
7885 @{
7886 size_t i;
7887 /* Initialize objects one-by-one passing pointers with bounds of an object,
7888 not the full array of objects. */
7889 for (i = 0; i < size; i++)
7890 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs, sizeof(object)));
7891 @}
7892 @end smallexample
7893
7894 @end deftypefn
7895
7896 @deftypefn {Built-in Function} void * __builtin___bnd_copy_ptr_bounds (const void * @var{q}, const void * @var{r})
7897
7898 This built-in function returns a new pointer with the value of @var{q},
7899 and associate it with the bounds already associated with pointer @var{r}.
7900 With Pointer Bounds Checker off built-in function just returns the first
7901 argument.
7902
7903 @smallexample
7904 /* Here is a way to get pointer to object's field but
7905 still with the full object's bounds. */
7906 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_filed, objptr);
7907 @end smallexample
7908
7909 @end deftypefn
7910
7911 @deftypefn {Built-in Function} void * __builtin___bnd_init_ptr_bounds (const void * @var{q})
7912
7913 This built-in function returns a new pointer with the value of @var{q}, and
7914 associate it with INIT (allowing full memory access) bounds. With Pointer
7915 Bounds Checker off built-in function just returns the first argument.
7916
7917 @end deftypefn
7918
7919 @deftypefn {Built-in Function} void * __builtin___bnd_null_ptr_bounds (const void * @var{q})
7920
7921 This built-in function returns a new pointer with the value of @var{q}, and
7922 associate it with NULL (allowing no memory access) bounds. With Pointer
7923 Bounds Checker off built-in function just returns the first argument.
7924
7925 @end deftypefn
7926
7927 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void ** @var{ptr_addr}, const void * @var{ptr_val})
7928
7929 This built-in function stores the bounds associated with pointer @var{ptr_val}
7930 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
7931 bounds from legacy code without touching the associated pointer's memory when
7932 pointers were copied as integers. With Pointer Bounds Checker off built-in
7933 function call is ignored.
7934
7935 @end deftypefn
7936
7937 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void * @var{q})
7938
7939 This built-in function checks if the pointer @var{q} is within the lower
7940 bound of its associated bounds. With Pointer Bounds Checker off built-in
7941 function call is ignored.
7942
7943 @smallexample
7944 extern void *__wrap_memset (void *dst, int c, size_t len)
7945 @{
7946 if (len > 0)
7947 @{
7948 __builtin___bnd_chk_ptr_lbounds (dst);
7949 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
7950 __real_memset (dst, c, len);
7951 @}
7952 return dst;
7953 @}
7954 @end smallexample
7955
7956 @end deftypefn
7957
7958 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void * @var{q})
7959
7960 This built-in function checks if the pointer @var{q} is within the upper
7961 bound of its associated bounds. With Pointer Bounds Checker off built-in
7962 function call is ignored.
7963
7964 @end deftypefn
7965
7966 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void * @var{q}, size_t @var{size})
7967
7968 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
7969 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
7970 off built-in function call is ignored.
7971
7972 @smallexample
7973 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
7974 @{
7975 if (n > 0)
7976 @{
7977 __bnd_chk_ptr_bounds (dst, n);
7978 __bnd_chk_ptr_bounds (src, n);
7979 __real_memcpy (dst, src, n);
7980 @}
7981 return dst;
7982 @}
7983 @end smallexample
7984
7985 @end deftypefn
7986
7987 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_lbound (const void * @var{q})
7988
7989 This built-in function returns the lower bound (which is a pointer) associated
7990 with the pointer @var{q}. This is at least useful for debugging using printf.
7991 With Pointer Bounds Checker off built-in function returns 0.
7992
7993 @smallexample
7994 void *lb = __builtin___bnd_get_ptr_lbound (q);
7995 void *ub = __builtin___bnd_get_ptr_ubound (q);
7996 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
7997 @end smallexample
7998
7999 @end deftypefn
8000
8001 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_ubound (const void * @var{q})
8002
8003 This built-in function returns the upper bound (which is a pointer) associated
8004 with the pointer @var{q}. With Pointer Bounds Checker off built-in function
8005 returns -1.
8006
8007 @end deftypefn
8008
8009 @node Other Builtins
8010 @section Other Built-in Functions Provided by GCC
8011 @cindex built-in functions
8012 @findex __builtin_fpclassify
8013 @findex __builtin_isfinite
8014 @findex __builtin_isnormal
8015 @findex __builtin_isgreater
8016 @findex __builtin_isgreaterequal
8017 @findex __builtin_isinf_sign
8018 @findex __builtin_isless
8019 @findex __builtin_islessequal
8020 @findex __builtin_islessgreater
8021 @findex __builtin_isunordered
8022 @findex __builtin_powi
8023 @findex __builtin_powif
8024 @findex __builtin_powil
8025 @findex _Exit
8026 @findex _exit
8027 @findex abort
8028 @findex abs
8029 @findex acos
8030 @findex acosf
8031 @findex acosh
8032 @findex acoshf
8033 @findex acoshl
8034 @findex acosl
8035 @findex alloca
8036 @findex asin
8037 @findex asinf
8038 @findex asinh
8039 @findex asinhf
8040 @findex asinhl
8041 @findex asinl
8042 @findex atan
8043 @findex atan2
8044 @findex atan2f
8045 @findex atan2l
8046 @findex atanf
8047 @findex atanh
8048 @findex atanhf
8049 @findex atanhl
8050 @findex atanl
8051 @findex bcmp
8052 @findex bzero
8053 @findex cabs
8054 @findex cabsf
8055 @findex cabsl
8056 @findex cacos
8057 @findex cacosf
8058 @findex cacosh
8059 @findex cacoshf
8060 @findex cacoshl
8061 @findex cacosl
8062 @findex calloc
8063 @findex carg
8064 @findex cargf
8065 @findex cargl
8066 @findex casin
8067 @findex casinf
8068 @findex casinh
8069 @findex casinhf
8070 @findex casinhl
8071 @findex casinl
8072 @findex catan
8073 @findex catanf
8074 @findex catanh
8075 @findex catanhf
8076 @findex catanhl
8077 @findex catanl
8078 @findex cbrt
8079 @findex cbrtf
8080 @findex cbrtl
8081 @findex ccos
8082 @findex ccosf
8083 @findex ccosh
8084 @findex ccoshf
8085 @findex ccoshl
8086 @findex ccosl
8087 @findex ceil
8088 @findex ceilf
8089 @findex ceill
8090 @findex cexp
8091 @findex cexpf
8092 @findex cexpl
8093 @findex cimag
8094 @findex cimagf
8095 @findex cimagl
8096 @findex clog
8097 @findex clogf
8098 @findex clogl
8099 @findex conj
8100 @findex conjf
8101 @findex conjl
8102 @findex copysign
8103 @findex copysignf
8104 @findex copysignl
8105 @findex cos
8106 @findex cosf
8107 @findex cosh
8108 @findex coshf
8109 @findex coshl
8110 @findex cosl
8111 @findex cpow
8112 @findex cpowf
8113 @findex cpowl
8114 @findex cproj
8115 @findex cprojf
8116 @findex cprojl
8117 @findex creal
8118 @findex crealf
8119 @findex creall
8120 @findex csin
8121 @findex csinf
8122 @findex csinh
8123 @findex csinhf
8124 @findex csinhl
8125 @findex csinl
8126 @findex csqrt
8127 @findex csqrtf
8128 @findex csqrtl
8129 @findex ctan
8130 @findex ctanf
8131 @findex ctanh
8132 @findex ctanhf
8133 @findex ctanhl
8134 @findex ctanl
8135 @findex dcgettext
8136 @findex dgettext
8137 @findex drem
8138 @findex dremf
8139 @findex dreml
8140 @findex erf
8141 @findex erfc
8142 @findex erfcf
8143 @findex erfcl
8144 @findex erff
8145 @findex erfl
8146 @findex exit
8147 @findex exp
8148 @findex exp10
8149 @findex exp10f
8150 @findex exp10l
8151 @findex exp2
8152 @findex exp2f
8153 @findex exp2l
8154 @findex expf
8155 @findex expl
8156 @findex expm1
8157 @findex expm1f
8158 @findex expm1l
8159 @findex fabs
8160 @findex fabsf
8161 @findex fabsl
8162 @findex fdim
8163 @findex fdimf
8164 @findex fdiml
8165 @findex ffs
8166 @findex floor
8167 @findex floorf
8168 @findex floorl
8169 @findex fma
8170 @findex fmaf
8171 @findex fmal
8172 @findex fmax
8173 @findex fmaxf
8174 @findex fmaxl
8175 @findex fmin
8176 @findex fminf
8177 @findex fminl
8178 @findex fmod
8179 @findex fmodf
8180 @findex fmodl
8181 @findex fprintf
8182 @findex fprintf_unlocked
8183 @findex fputs
8184 @findex fputs_unlocked
8185 @findex frexp
8186 @findex frexpf
8187 @findex frexpl
8188 @findex fscanf
8189 @findex gamma
8190 @findex gammaf
8191 @findex gammal
8192 @findex gamma_r
8193 @findex gammaf_r
8194 @findex gammal_r
8195 @findex gettext
8196 @findex hypot
8197 @findex hypotf
8198 @findex hypotl
8199 @findex ilogb
8200 @findex ilogbf
8201 @findex ilogbl
8202 @findex imaxabs
8203 @findex index
8204 @findex isalnum
8205 @findex isalpha
8206 @findex isascii
8207 @findex isblank
8208 @findex iscntrl
8209 @findex isdigit
8210 @findex isgraph
8211 @findex islower
8212 @findex isprint
8213 @findex ispunct
8214 @findex isspace
8215 @findex isupper
8216 @findex iswalnum
8217 @findex iswalpha
8218 @findex iswblank
8219 @findex iswcntrl
8220 @findex iswdigit
8221 @findex iswgraph
8222 @findex iswlower
8223 @findex iswprint
8224 @findex iswpunct
8225 @findex iswspace
8226 @findex iswupper
8227 @findex iswxdigit
8228 @findex isxdigit
8229 @findex j0
8230 @findex j0f
8231 @findex j0l
8232 @findex j1
8233 @findex j1f
8234 @findex j1l
8235 @findex jn
8236 @findex jnf
8237 @findex jnl
8238 @findex labs
8239 @findex ldexp
8240 @findex ldexpf
8241 @findex ldexpl
8242 @findex lgamma
8243 @findex lgammaf
8244 @findex lgammal
8245 @findex lgamma_r
8246 @findex lgammaf_r
8247 @findex lgammal_r
8248 @findex llabs
8249 @findex llrint
8250 @findex llrintf
8251 @findex llrintl
8252 @findex llround
8253 @findex llroundf
8254 @findex llroundl
8255 @findex log
8256 @findex log10
8257 @findex log10f
8258 @findex log10l
8259 @findex log1p
8260 @findex log1pf
8261 @findex log1pl
8262 @findex log2
8263 @findex log2f
8264 @findex log2l
8265 @findex logb
8266 @findex logbf
8267 @findex logbl
8268 @findex logf
8269 @findex logl
8270 @findex lrint
8271 @findex lrintf
8272 @findex lrintl
8273 @findex lround
8274 @findex lroundf
8275 @findex lroundl
8276 @findex malloc
8277 @findex memchr
8278 @findex memcmp
8279 @findex memcpy
8280 @findex mempcpy
8281 @findex memset
8282 @findex modf
8283 @findex modff
8284 @findex modfl
8285 @findex nearbyint
8286 @findex nearbyintf
8287 @findex nearbyintl
8288 @findex nextafter
8289 @findex nextafterf
8290 @findex nextafterl
8291 @findex nexttoward
8292 @findex nexttowardf
8293 @findex nexttowardl
8294 @findex pow
8295 @findex pow10
8296 @findex pow10f
8297 @findex pow10l
8298 @findex powf
8299 @findex powl
8300 @findex printf
8301 @findex printf_unlocked
8302 @findex putchar
8303 @findex puts
8304 @findex remainder
8305 @findex remainderf
8306 @findex remainderl
8307 @findex remquo
8308 @findex remquof
8309 @findex remquol
8310 @findex rindex
8311 @findex rint
8312 @findex rintf
8313 @findex rintl
8314 @findex round
8315 @findex roundf
8316 @findex roundl
8317 @findex scalb
8318 @findex scalbf
8319 @findex scalbl
8320 @findex scalbln
8321 @findex scalblnf
8322 @findex scalblnf
8323 @findex scalbn
8324 @findex scalbnf
8325 @findex scanfnl
8326 @findex signbit
8327 @findex signbitf
8328 @findex signbitl
8329 @findex signbitd32
8330 @findex signbitd64
8331 @findex signbitd128
8332 @findex significand
8333 @findex significandf
8334 @findex significandl
8335 @findex sin
8336 @findex sincos
8337 @findex sincosf
8338 @findex sincosl
8339 @findex sinf
8340 @findex sinh
8341 @findex sinhf
8342 @findex sinhl
8343 @findex sinl
8344 @findex snprintf
8345 @findex sprintf
8346 @findex sqrt
8347 @findex sqrtf
8348 @findex sqrtl
8349 @findex sscanf
8350 @findex stpcpy
8351 @findex stpncpy
8352 @findex strcasecmp
8353 @findex strcat
8354 @findex strchr
8355 @findex strcmp
8356 @findex strcpy
8357 @findex strcspn
8358 @findex strdup
8359 @findex strfmon
8360 @findex strftime
8361 @findex strlen
8362 @findex strncasecmp
8363 @findex strncat
8364 @findex strncmp
8365 @findex strncpy
8366 @findex strndup
8367 @findex strpbrk
8368 @findex strrchr
8369 @findex strspn
8370 @findex strstr
8371 @findex tan
8372 @findex tanf
8373 @findex tanh
8374 @findex tanhf
8375 @findex tanhl
8376 @findex tanl
8377 @findex tgamma
8378 @findex tgammaf
8379 @findex tgammal
8380 @findex toascii
8381 @findex tolower
8382 @findex toupper
8383 @findex towlower
8384 @findex towupper
8385 @findex trunc
8386 @findex truncf
8387 @findex truncl
8388 @findex vfprintf
8389 @findex vfscanf
8390 @findex vprintf
8391 @findex vscanf
8392 @findex vsnprintf
8393 @findex vsprintf
8394 @findex vsscanf
8395 @findex y0
8396 @findex y0f
8397 @findex y0l
8398 @findex y1
8399 @findex y1f
8400 @findex y1l
8401 @findex yn
8402 @findex ynf
8403 @findex ynl
8404
8405 GCC provides a large number of built-in functions other than the ones
8406 mentioned above. Some of these are for internal use in the processing
8407 of exceptions or variable-length argument lists and are not
8408 documented here because they may change from time to time; we do not
8409 recommend general use of these functions.
8410
8411 The remaining functions are provided for optimization purposes.
8412
8413 @opindex fno-builtin
8414 GCC includes built-in versions of many of the functions in the standard
8415 C library. The versions prefixed with @code{__builtin_} are always
8416 treated as having the same meaning as the C library function even if you
8417 specify the @option{-fno-builtin} option. (@pxref{C Dialect Options})
8418 Many of these functions are only optimized in certain cases; if they are
8419 not optimized in a particular case, a call to the library function is
8420 emitted.
8421
8422 @opindex ansi
8423 @opindex std
8424 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
8425 @option{-std=c99} or @option{-std=c11}), the functions
8426 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
8427 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
8428 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
8429 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
8430 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
8431 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
8432 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
8433 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
8434 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
8435 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
8436 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
8437 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
8438 @code{signbitd64}, @code{signbitd128}, @code{significandf},
8439 @code{significandl}, @code{significand}, @code{sincosf},
8440 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
8441 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
8442 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
8443 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
8444 @code{yn}
8445 may be handled as built-in functions.
8446 All these functions have corresponding versions
8447 prefixed with @code{__builtin_}, which may be used even in strict C90
8448 mode.
8449
8450 The ISO C99 functions
8451 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
8452 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
8453 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
8454 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
8455 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
8456 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
8457 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
8458 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
8459 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
8460 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
8461 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
8462 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
8463 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
8464 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
8465 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
8466 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
8467 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
8468 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
8469 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
8470 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
8471 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
8472 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
8473 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
8474 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
8475 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
8476 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
8477 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
8478 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
8479 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
8480 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
8481 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
8482 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
8483 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
8484 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
8485 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
8486 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
8487 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
8488 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
8489 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
8490 are handled as built-in functions
8491 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8492
8493 There are also built-in versions of the ISO C99 functions
8494 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
8495 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
8496 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
8497 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
8498 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
8499 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
8500 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
8501 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
8502 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
8503 that are recognized in any mode since ISO C90 reserves these names for
8504 the purpose to which ISO C99 puts them. All these functions have
8505 corresponding versions prefixed with @code{__builtin_}.
8506
8507 The ISO C94 functions
8508 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
8509 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
8510 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
8511 @code{towupper}
8512 are handled as built-in functions
8513 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8514
8515 The ISO C90 functions
8516 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
8517 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
8518 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
8519 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
8520 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
8521 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
8522 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
8523 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
8524 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
8525 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
8526 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
8527 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
8528 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
8529 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
8530 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
8531 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
8532 are all recognized as built-in functions unless
8533 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
8534 is specified for an individual function). All of these functions have
8535 corresponding versions prefixed with @code{__builtin_}.
8536
8537 GCC provides built-in versions of the ISO C99 floating-point comparison
8538 macros that avoid raising exceptions for unordered operands. They have
8539 the same names as the standard macros ( @code{isgreater},
8540 @code{isgreaterequal}, @code{isless}, @code{islessequal},
8541 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
8542 prefixed. We intend for a library implementor to be able to simply
8543 @code{#define} each standard macro to its built-in equivalent.
8544 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
8545 @code{isinf_sign} and @code{isnormal} built-ins used with
8546 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
8547 built-in functions appear both with and without the @code{__builtin_} prefix.
8548
8549 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
8550
8551 You can use the built-in function @code{__builtin_types_compatible_p} to
8552 determine whether two types are the same.
8553
8554 This built-in function returns 1 if the unqualified versions of the
8555 types @var{type1} and @var{type2} (which are types, not expressions) are
8556 compatible, 0 otherwise. The result of this built-in function can be
8557 used in integer constant expressions.
8558
8559 This built-in function ignores top level qualifiers (e.g., @code{const},
8560 @code{volatile}). For example, @code{int} is equivalent to @code{const
8561 int}.
8562
8563 The type @code{int[]} and @code{int[5]} are compatible. On the other
8564 hand, @code{int} and @code{char *} are not compatible, even if the size
8565 of their types, on the particular architecture are the same. Also, the
8566 amount of pointer indirection is taken into account when determining
8567 similarity. Consequently, @code{short *} is not similar to
8568 @code{short **}. Furthermore, two types that are typedefed are
8569 considered compatible if their underlying types are compatible.
8570
8571 An @code{enum} type is not considered to be compatible with another
8572 @code{enum} type even if both are compatible with the same integer
8573 type; this is what the C standard specifies.
8574 For example, @code{enum @{foo, bar@}} is not similar to
8575 @code{enum @{hot, dog@}}.
8576
8577 You typically use this function in code whose execution varies
8578 depending on the arguments' types. For example:
8579
8580 @smallexample
8581 #define foo(x) \
8582 (@{ \
8583 typeof (x) tmp = (x); \
8584 if (__builtin_types_compatible_p (typeof (x), long double)) \
8585 tmp = foo_long_double (tmp); \
8586 else if (__builtin_types_compatible_p (typeof (x), double)) \
8587 tmp = foo_double (tmp); \
8588 else if (__builtin_types_compatible_p (typeof (x), float)) \
8589 tmp = foo_float (tmp); \
8590 else \
8591 abort (); \
8592 tmp; \
8593 @})
8594 @end smallexample
8595
8596 @emph{Note:} This construct is only available for C@.
8597
8598 @end deftypefn
8599
8600 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
8601
8602 You can use the built-in function @code{__builtin_choose_expr} to
8603 evaluate code depending on the value of a constant expression. This
8604 built-in function returns @var{exp1} if @var{const_exp}, which is an
8605 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
8606
8607 This built-in function is analogous to the @samp{? :} operator in C,
8608 except that the expression returned has its type unaltered by promotion
8609 rules. Also, the built-in function does not evaluate the expression
8610 that is not chosen. For example, if @var{const_exp} evaluates to true,
8611 @var{exp2} is not evaluated even if it has side-effects.
8612
8613 This built-in function can return an lvalue if the chosen argument is an
8614 lvalue.
8615
8616 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
8617 type. Similarly, if @var{exp2} is returned, its return type is the same
8618 as @var{exp2}.
8619
8620 Example:
8621
8622 @smallexample
8623 #define foo(x) \
8624 __builtin_choose_expr ( \
8625 __builtin_types_compatible_p (typeof (x), double), \
8626 foo_double (x), \
8627 __builtin_choose_expr ( \
8628 __builtin_types_compatible_p (typeof (x), float), \
8629 foo_float (x), \
8630 /* @r{The void expression results in a compile-time error} \
8631 @r{when assigning the result to something.} */ \
8632 (void)0))
8633 @end smallexample
8634
8635 @emph{Note:} This construct is only available for C@. Furthermore, the
8636 unused expression (@var{exp1} or @var{exp2} depending on the value of
8637 @var{const_exp}) may still generate syntax errors. This may change in
8638 future revisions.
8639
8640 @end deftypefn
8641
8642 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
8643
8644 The built-in function @code{__builtin_complex} is provided for use in
8645 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
8646 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
8647 real binary floating-point type, and the result has the corresponding
8648 complex type with real and imaginary parts @var{real} and @var{imag}.
8649 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
8650 infinities, NaNs and negative zeros are involved.
8651
8652 @end deftypefn
8653
8654 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
8655 You can use the built-in function @code{__builtin_constant_p} to
8656 determine if a value is known to be constant at compile time and hence
8657 that GCC can perform constant-folding on expressions involving that
8658 value. The argument of the function is the value to test. The function
8659 returns the integer 1 if the argument is known to be a compile-time
8660 constant and 0 if it is not known to be a compile-time constant. A
8661 return of 0 does not indicate that the value is @emph{not} a constant,
8662 but merely that GCC cannot prove it is a constant with the specified
8663 value of the @option{-O} option.
8664
8665 You typically use this function in an embedded application where
8666 memory is a critical resource. If you have some complex calculation,
8667 you may want it to be folded if it involves constants, but need to call
8668 a function if it does not. For example:
8669
8670 @smallexample
8671 #define Scale_Value(X) \
8672 (__builtin_constant_p (X) \
8673 ? ((X) * SCALE + OFFSET) : Scale (X))
8674 @end smallexample
8675
8676 You may use this built-in function in either a macro or an inline
8677 function. However, if you use it in an inlined function and pass an
8678 argument of the function as the argument to the built-in, GCC
8679 never returns 1 when you call the inline function with a string constant
8680 or compound literal (@pxref{Compound Literals}) and does not return 1
8681 when you pass a constant numeric value to the inline function unless you
8682 specify the @option{-O} option.
8683
8684 You may also use @code{__builtin_constant_p} in initializers for static
8685 data. For instance, you can write
8686
8687 @smallexample
8688 static const int table[] = @{
8689 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
8690 /* @r{@dots{}} */
8691 @};
8692 @end smallexample
8693
8694 @noindent
8695 This is an acceptable initializer even if @var{EXPRESSION} is not a
8696 constant expression, including the case where
8697 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
8698 folded to a constant but @var{EXPRESSION} contains operands that are
8699 not otherwise permitted in a static initializer (for example,
8700 @code{0 && foo ()}). GCC must be more conservative about evaluating the
8701 built-in in this case, because it has no opportunity to perform
8702 optimization.
8703
8704 Previous versions of GCC did not accept this built-in in data
8705 initializers. The earliest version where it is completely safe is
8706 3.0.1.
8707 @end deftypefn
8708
8709 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
8710 @opindex fprofile-arcs
8711 You may use @code{__builtin_expect} to provide the compiler with
8712 branch prediction information. In general, you should prefer to
8713 use actual profile feedback for this (@option{-fprofile-arcs}), as
8714 programmers are notoriously bad at predicting how their programs
8715 actually perform. However, there are applications in which this
8716 data is hard to collect.
8717
8718 The return value is the value of @var{exp}, which should be an integral
8719 expression. The semantics of the built-in are that it is expected that
8720 @var{exp} == @var{c}. For example:
8721
8722 @smallexample
8723 if (__builtin_expect (x, 0))
8724 foo ();
8725 @end smallexample
8726
8727 @noindent
8728 indicates that we do not expect to call @code{foo}, since
8729 we expect @code{x} to be zero. Since you are limited to integral
8730 expressions for @var{exp}, you should use constructions such as
8731
8732 @smallexample
8733 if (__builtin_expect (ptr != NULL, 1))
8734 foo (*ptr);
8735 @end smallexample
8736
8737 @noindent
8738 when testing pointer or floating-point values.
8739 @end deftypefn
8740
8741 @deftypefn {Built-in Function} void __builtin_trap (void)
8742 This function causes the program to exit abnormally. GCC implements
8743 this function by using a target-dependent mechanism (such as
8744 intentionally executing an illegal instruction) or by calling
8745 @code{abort}. The mechanism used may vary from release to release so
8746 you should not rely on any particular implementation.
8747 @end deftypefn
8748
8749 @deftypefn {Built-in Function} void __builtin_unreachable (void)
8750 If control flow reaches the point of the @code{__builtin_unreachable},
8751 the program is undefined. It is useful in situations where the
8752 compiler cannot deduce the unreachability of the code.
8753
8754 One such case is immediately following an @code{asm} statement that
8755 either never terminates, or one that transfers control elsewhere
8756 and never returns. In this example, without the
8757 @code{__builtin_unreachable}, GCC issues a warning that control
8758 reaches the end of a non-void function. It also generates code
8759 to return after the @code{asm}.
8760
8761 @smallexample
8762 int f (int c, int v)
8763 @{
8764 if (c)
8765 @{
8766 return v;
8767 @}
8768 else
8769 @{
8770 asm("jmp error_handler");
8771 __builtin_unreachable ();
8772 @}
8773 @}
8774 @end smallexample
8775
8776 @noindent
8777 Because the @code{asm} statement unconditionally transfers control out
8778 of the function, control never reaches the end of the function
8779 body. The @code{__builtin_unreachable} is in fact unreachable and
8780 communicates this fact to the compiler.
8781
8782 Another use for @code{__builtin_unreachable} is following a call a
8783 function that never returns but that is not declared
8784 @code{__attribute__((noreturn))}, as in this example:
8785
8786 @smallexample
8787 void function_that_never_returns (void);
8788
8789 int g (int c)
8790 @{
8791 if (c)
8792 @{
8793 return 1;
8794 @}
8795 else
8796 @{
8797 function_that_never_returns ();
8798 __builtin_unreachable ();
8799 @}
8800 @}
8801 @end smallexample
8802
8803 @end deftypefn
8804
8805 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
8806 This function returns its first argument, and allows the compiler
8807 to assume that the returned pointer is at least @var{align} bytes
8808 aligned. This built-in can have either two or three arguments,
8809 if it has three, the third argument should have integer type, and
8810 if it is nonzero means misalignment offset. For example:
8811
8812 @smallexample
8813 void *x = __builtin_assume_aligned (arg, 16);
8814 @end smallexample
8815
8816 @noindent
8817 means that the compiler can assume @code{x}, set to @code{arg}, is at least
8818 16-byte aligned, while:
8819
8820 @smallexample
8821 void *x = __builtin_assume_aligned (arg, 32, 8);
8822 @end smallexample
8823
8824 @noindent
8825 means that the compiler can assume for @code{x}, set to @code{arg}, that
8826 @code{(char *) x - 8} is 32-byte aligned.
8827 @end deftypefn
8828
8829 @deftypefn {Built-in Function} int __builtin_LINE ()
8830 This function is the equivalent to the preprocessor @code{__LINE__}
8831 macro and returns the line number of the invocation of the built-in.
8832 @end deftypefn
8833
8834 @deftypefn {Built-in Function} int __builtin_FUNCTION ()
8835 This function is the equivalent to the preprocessor @code{__FUNCTION__}
8836 macro and returns the function name the invocation of the built-in is in.
8837 @end deftypefn
8838
8839 @deftypefn {Built-in Function} int __builtin_FILE ()
8840 This function is the equivalent to the preprocessor @code{__FILE__}
8841 macro and returns the file name the invocation of the built-in is in.
8842 @end deftypefn
8843
8844 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
8845 This function is used to flush the processor's instruction cache for
8846 the region of memory between @var{begin} inclusive and @var{end}
8847 exclusive. Some targets require that the instruction cache be
8848 flushed, after modifying memory containing code, in order to obtain
8849 deterministic behavior.
8850
8851 If the target does not require instruction cache flushes,
8852 @code{__builtin___clear_cache} has no effect. Otherwise either
8853 instructions are emitted in-line to clear the instruction cache or a
8854 call to the @code{__clear_cache} function in libgcc is made.
8855 @end deftypefn
8856
8857 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
8858 This function is used to minimize cache-miss latency by moving data into
8859 a cache before it is accessed.
8860 You can insert calls to @code{__builtin_prefetch} into code for which
8861 you know addresses of data in memory that is likely to be accessed soon.
8862 If the target supports them, data prefetch instructions are generated.
8863 If the prefetch is done early enough before the access then the data will
8864 be in the cache by the time it is accessed.
8865
8866 The value of @var{addr} is the address of the memory to prefetch.
8867 There are two optional arguments, @var{rw} and @var{locality}.
8868 The value of @var{rw} is a compile-time constant one or zero; one
8869 means that the prefetch is preparing for a write to the memory address
8870 and zero, the default, means that the prefetch is preparing for a read.
8871 The value @var{locality} must be a compile-time constant integer between
8872 zero and three. A value of zero means that the data has no temporal
8873 locality, so it need not be left in the cache after the access. A value
8874 of three means that the data has a high degree of temporal locality and
8875 should be left in all levels of cache possible. Values of one and two
8876 mean, respectively, a low or moderate degree of temporal locality. The
8877 default is three.
8878
8879 @smallexample
8880 for (i = 0; i < n; i++)
8881 @{
8882 a[i] = a[i] + b[i];
8883 __builtin_prefetch (&a[i+j], 1, 1);
8884 __builtin_prefetch (&b[i+j], 0, 1);
8885 /* @r{@dots{}} */
8886 @}
8887 @end smallexample
8888
8889 Data prefetch does not generate faults if @var{addr} is invalid, but
8890 the address expression itself must be valid. For example, a prefetch
8891 of @code{p->next} does not fault if @code{p->next} is not a valid
8892 address, but evaluation faults if @code{p} is not a valid address.
8893
8894 If the target does not support data prefetch, the address expression
8895 is evaluated if it includes side effects but no other code is generated
8896 and GCC does not issue a warning.
8897 @end deftypefn
8898
8899 @deftypefn {Built-in Function} double __builtin_huge_val (void)
8900 Returns a positive infinity, if supported by the floating-point format,
8901 else @code{DBL_MAX}. This function is suitable for implementing the
8902 ISO C macro @code{HUGE_VAL}.
8903 @end deftypefn
8904
8905 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
8906 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
8907 @end deftypefn
8908
8909 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
8910 Similar to @code{__builtin_huge_val}, except the return
8911 type is @code{long double}.
8912 @end deftypefn
8913
8914 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
8915 This built-in implements the C99 fpclassify functionality. The first
8916 five int arguments should be the target library's notion of the
8917 possible FP classes and are used for return values. They must be
8918 constant values and they must appear in this order: @code{FP_NAN},
8919 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
8920 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
8921 to classify. GCC treats the last argument as type-generic, which
8922 means it does not do default promotion from float to double.
8923 @end deftypefn
8924
8925 @deftypefn {Built-in Function} double __builtin_inf (void)
8926 Similar to @code{__builtin_huge_val}, except a warning is generated
8927 if the target floating-point format does not support infinities.
8928 @end deftypefn
8929
8930 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
8931 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
8932 @end deftypefn
8933
8934 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
8935 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
8936 @end deftypefn
8937
8938 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
8939 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
8940 @end deftypefn
8941
8942 @deftypefn {Built-in Function} float __builtin_inff (void)
8943 Similar to @code{__builtin_inf}, except the return type is @code{float}.
8944 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
8945 @end deftypefn
8946
8947 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
8948 Similar to @code{__builtin_inf}, except the return
8949 type is @code{long double}.
8950 @end deftypefn
8951
8952 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
8953 Similar to @code{isinf}, except the return value is -1 for
8954 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
8955 Note while the parameter list is an
8956 ellipsis, this function only accepts exactly one floating-point
8957 argument. GCC treats this parameter as type-generic, which means it
8958 does not do default promotion from float to double.
8959 @end deftypefn
8960
8961 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
8962 This is an implementation of the ISO C99 function @code{nan}.
8963
8964 Since ISO C99 defines this function in terms of @code{strtod}, which we
8965 do not implement, a description of the parsing is in order. The string
8966 is parsed as by @code{strtol}; that is, the base is recognized by
8967 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
8968 in the significand such that the least significant bit of the number
8969 is at the least significant bit of the significand. The number is
8970 truncated to fit the significand field provided. The significand is
8971 forced to be a quiet NaN@.
8972
8973 This function, if given a string literal all of which would have been
8974 consumed by @code{strtol}, is evaluated early enough that it is considered a
8975 compile-time constant.
8976 @end deftypefn
8977
8978 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
8979 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
8980 @end deftypefn
8981
8982 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
8983 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
8984 @end deftypefn
8985
8986 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
8987 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
8988 @end deftypefn
8989
8990 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
8991 Similar to @code{__builtin_nan}, except the return type is @code{float}.
8992 @end deftypefn
8993
8994 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
8995 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
8996 @end deftypefn
8997
8998 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
8999 Similar to @code{__builtin_nan}, except the significand is forced
9000 to be a signaling NaN@. The @code{nans} function is proposed by
9001 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
9002 @end deftypefn
9003
9004 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
9005 Similar to @code{__builtin_nans}, except the return type is @code{float}.
9006 @end deftypefn
9007
9008 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
9009 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
9010 @end deftypefn
9011
9012 @deftypefn {Built-in Function} int __builtin_ffs (unsigned int x)
9013 Returns one plus the index of the least significant 1-bit of @var{x}, or
9014 if @var{x} is zero, returns zero.
9015 @end deftypefn
9016
9017 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
9018 Returns the number of leading 0-bits in @var{x}, starting at the most
9019 significant bit position. If @var{x} is 0, the result is undefined.
9020 @end deftypefn
9021
9022 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
9023 Returns the number of trailing 0-bits in @var{x}, starting at the least
9024 significant bit position. If @var{x} is 0, the result is undefined.
9025 @end deftypefn
9026
9027 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
9028 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
9029 number of bits following the most significant bit that are identical
9030 to it. There are no special cases for 0 or other values.
9031 @end deftypefn
9032
9033 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
9034 Returns the number of 1-bits in @var{x}.
9035 @end deftypefn
9036
9037 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
9038 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
9039 modulo 2.
9040 @end deftypefn
9041
9042 @deftypefn {Built-in Function} int __builtin_ffsl (unsigned long)
9043 Similar to @code{__builtin_ffs}, except the argument type is
9044 @code{unsigned long}.
9045 @end deftypefn
9046
9047 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
9048 Similar to @code{__builtin_clz}, except the argument type is
9049 @code{unsigned long}.
9050 @end deftypefn
9051
9052 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
9053 Similar to @code{__builtin_ctz}, except the argument type is
9054 @code{unsigned long}.
9055 @end deftypefn
9056
9057 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
9058 Similar to @code{__builtin_clrsb}, except the argument type is
9059 @code{long}.
9060 @end deftypefn
9061
9062 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
9063 Similar to @code{__builtin_popcount}, except the argument type is
9064 @code{unsigned long}.
9065 @end deftypefn
9066
9067 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
9068 Similar to @code{__builtin_parity}, except the argument type is
9069 @code{unsigned long}.
9070 @end deftypefn
9071
9072 @deftypefn {Built-in Function} int __builtin_ffsll (unsigned long long)
9073 Similar to @code{__builtin_ffs}, except the argument type is
9074 @code{unsigned long long}.
9075 @end deftypefn
9076
9077 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
9078 Similar to @code{__builtin_clz}, except the argument type is
9079 @code{unsigned long long}.
9080 @end deftypefn
9081
9082 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
9083 Similar to @code{__builtin_ctz}, except the argument type is
9084 @code{unsigned long long}.
9085 @end deftypefn
9086
9087 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
9088 Similar to @code{__builtin_clrsb}, except the argument type is
9089 @code{long long}.
9090 @end deftypefn
9091
9092 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
9093 Similar to @code{__builtin_popcount}, except the argument type is
9094 @code{unsigned long long}.
9095 @end deftypefn
9096
9097 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
9098 Similar to @code{__builtin_parity}, except the argument type is
9099 @code{unsigned long long}.
9100 @end deftypefn
9101
9102 @deftypefn {Built-in Function} double __builtin_powi (double, int)
9103 Returns the first argument raised to the power of the second. Unlike the
9104 @code{pow} function no guarantees about precision and rounding are made.
9105 @end deftypefn
9106
9107 @deftypefn {Built-in Function} float __builtin_powif (float, int)
9108 Similar to @code{__builtin_powi}, except the argument and return types
9109 are @code{float}.
9110 @end deftypefn
9111
9112 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
9113 Similar to @code{__builtin_powi}, except the argument and return types
9114 are @code{long double}.
9115 @end deftypefn
9116
9117 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
9118 Returns @var{x} with the order of the bytes reversed; for example,
9119 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
9120 exactly 8 bits.
9121 @end deftypefn
9122
9123 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
9124 Similar to @code{__builtin_bswap16}, except the argument and return types
9125 are 32 bit.
9126 @end deftypefn
9127
9128 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
9129 Similar to @code{__builtin_bswap32}, except the argument and return types
9130 are 64 bit.
9131 @end deftypefn
9132
9133 @node Cilk Plus Builtins
9134 @section Cilk Plus C/C++ language extension Built-in Functions.
9135
9136 GCC provides support for the following built-in reduction funtions if Cilk Plus
9137 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
9138
9139 @itemize @bullet
9140 @item __sec_implicit_index
9141 @item __sec_reduce
9142 @item __sec_reduce_add
9143 @item __sec_reduce_all_nonzero
9144 @item __sec_reduce_all_zero
9145 @item __sec_reduce_any_nonzero
9146 @item __sec_reduce_any_zero
9147 @item __sec_reduce_max
9148 @item __sec_reduce_min
9149 @item __sec_reduce_max_ind
9150 @item __sec_reduce_min_ind
9151 @item __sec_reduce_mul
9152 @item __sec_reduce_mutating
9153 @end itemize
9154
9155 Further details and examples about these built-in functions are described
9156 in the Cilk Plus language manual which can be found at
9157 @uref{http://www.cilkplus.org}.
9158
9159 @node Target Builtins
9160 @section Built-in Functions Specific to Particular Target Machines
9161
9162 On some target machines, GCC supports many built-in functions specific
9163 to those machines. Generally these generate calls to specific machine
9164 instructions, but allow the compiler to schedule those calls.
9165
9166 @menu
9167 * Alpha Built-in Functions::
9168 * ARC Built-in Functions::
9169 * ARC SIMD Built-in Functions::
9170 * ARM iWMMXt Built-in Functions::
9171 * ARM NEON Intrinsics::
9172 * AVR Built-in Functions::
9173 * Blackfin Built-in Functions::
9174 * FR-V Built-in Functions::
9175 * X86 Built-in Functions::
9176 * X86 transactional memory intrinsics::
9177 * MIPS DSP Built-in Functions::
9178 * MIPS Paired-Single Support::
9179 * MIPS Loongson Built-in Functions::
9180 * Other MIPS Built-in Functions::
9181 * MSP430 Built-in Functions::
9182 * NDS32 Built-in Functions::
9183 * picoChip Built-in Functions::
9184 * PowerPC Built-in Functions::
9185 * PowerPC AltiVec/VSX Built-in Functions::
9186 * RX Built-in Functions::
9187 * S/390 System z Built-in Functions::
9188 * SH Built-in Functions::
9189 * SPARC VIS Built-in Functions::
9190 * SPU Built-in Functions::
9191 * TI C6X Built-in Functions::
9192 * TILE-Gx Built-in Functions::
9193 * TILEPro Built-in Functions::
9194 @end menu
9195
9196 @node Alpha Built-in Functions
9197 @subsection Alpha Built-in Functions
9198
9199 These built-in functions are available for the Alpha family of
9200 processors, depending on the command-line switches used.
9201
9202 The following built-in functions are always available. They
9203 all generate the machine instruction that is part of the name.
9204
9205 @smallexample
9206 long __builtin_alpha_implver (void)
9207 long __builtin_alpha_rpcc (void)
9208 long __builtin_alpha_amask (long)
9209 long __builtin_alpha_cmpbge (long, long)
9210 long __builtin_alpha_extbl (long, long)
9211 long __builtin_alpha_extwl (long, long)
9212 long __builtin_alpha_extll (long, long)
9213 long __builtin_alpha_extql (long, long)
9214 long __builtin_alpha_extwh (long, long)
9215 long __builtin_alpha_extlh (long, long)
9216 long __builtin_alpha_extqh (long, long)
9217 long __builtin_alpha_insbl (long, long)
9218 long __builtin_alpha_inswl (long, long)
9219 long __builtin_alpha_insll (long, long)
9220 long __builtin_alpha_insql (long, long)
9221 long __builtin_alpha_inswh (long, long)
9222 long __builtin_alpha_inslh (long, long)
9223 long __builtin_alpha_insqh (long, long)
9224 long __builtin_alpha_mskbl (long, long)
9225 long __builtin_alpha_mskwl (long, long)
9226 long __builtin_alpha_mskll (long, long)
9227 long __builtin_alpha_mskql (long, long)
9228 long __builtin_alpha_mskwh (long, long)
9229 long __builtin_alpha_msklh (long, long)
9230 long __builtin_alpha_mskqh (long, long)
9231 long __builtin_alpha_umulh (long, long)
9232 long __builtin_alpha_zap (long, long)
9233 long __builtin_alpha_zapnot (long, long)
9234 @end smallexample
9235
9236 The following built-in functions are always with @option{-mmax}
9237 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
9238 later. They all generate the machine instruction that is part
9239 of the name.
9240
9241 @smallexample
9242 long __builtin_alpha_pklb (long)
9243 long __builtin_alpha_pkwb (long)
9244 long __builtin_alpha_unpkbl (long)
9245 long __builtin_alpha_unpkbw (long)
9246 long __builtin_alpha_minub8 (long, long)
9247 long __builtin_alpha_minsb8 (long, long)
9248 long __builtin_alpha_minuw4 (long, long)
9249 long __builtin_alpha_minsw4 (long, long)
9250 long __builtin_alpha_maxub8 (long, long)
9251 long __builtin_alpha_maxsb8 (long, long)
9252 long __builtin_alpha_maxuw4 (long, long)
9253 long __builtin_alpha_maxsw4 (long, long)
9254 long __builtin_alpha_perr (long, long)
9255 @end smallexample
9256
9257 The following built-in functions are always with @option{-mcix}
9258 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
9259 later. They all generate the machine instruction that is part
9260 of the name.
9261
9262 @smallexample
9263 long __builtin_alpha_cttz (long)
9264 long __builtin_alpha_ctlz (long)
9265 long __builtin_alpha_ctpop (long)
9266 @end smallexample
9267
9268 The following built-in functions are available on systems that use the OSF/1
9269 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
9270 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
9271 @code{rdval} and @code{wrval}.
9272
9273 @smallexample
9274 void *__builtin_thread_pointer (void)
9275 void __builtin_set_thread_pointer (void *)
9276 @end smallexample
9277
9278 @node ARC Built-in Functions
9279 @subsection ARC Built-in Functions
9280
9281 The following built-in functions are provided for ARC targets. The
9282 built-ins generate the corresponding assembly instructions. In the
9283 examples given below, the generated code often requires an operand or
9284 result to be in a register. Where necessary further code will be
9285 generated to ensure this is true, but for brevity this is not
9286 described in each case.
9287
9288 @emph{Note:} Using a built-in to generate an instruction not supported
9289 by a target may cause problems. At present the compiler is not
9290 guaranteed to detect such misuse, and as a result an internal compiler
9291 error may be generated.
9292
9293 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
9294 Return 1 if @var{val} is known to have the byte alignment given
9295 by @var{alignval}, otherwise return 0.
9296 Note that this is different from
9297 @smallexample
9298 __alignof__(*(char *)@var{val}) >= alignval
9299 @end smallexample
9300 because __alignof__ sees only the type of the dereference, whereas
9301 __builtin_arc_align uses alignment information from the pointer
9302 as well as from the pointed-to type.
9303 The information available will depend on optimization level.
9304 @end deftypefn
9305
9306 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
9307 Generates
9308 @example
9309 brk
9310 @end example
9311 @end deftypefn
9312
9313 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
9314 The operand is the number of a register to be read. Generates:
9315 @example
9316 mov @var{dest}, r@var{regno}
9317 @end example
9318 where the value in @var{dest} will be the result returned from the
9319 built-in.
9320 @end deftypefn
9321
9322 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
9323 The first operand is the number of a register to be written, the
9324 second operand is a compile time constant to write into that
9325 register. Generates:
9326 @example
9327 mov r@var{regno}, @var{val}
9328 @end example
9329 @end deftypefn
9330
9331 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
9332 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
9333 Generates:
9334 @example
9335 divaw @var{dest}, @var{a}, @var{b}
9336 @end example
9337 where the value in @var{dest} will be the result returned from the
9338 built-in.
9339 @end deftypefn
9340
9341 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
9342 Generates
9343 @example
9344 flag @var{a}
9345 @end example
9346 @end deftypefn
9347
9348 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
9349 The operand, @var{auxv}, is the address of an auxiliary register and
9350 must be a compile time constant. Generates:
9351 @example
9352 lr @var{dest}, [@var{auxr}]
9353 @end example
9354 Where the value in @var{dest} will be the result returned from the
9355 built-in.
9356 @end deftypefn
9357
9358 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
9359 Only available with @option{-mmul64}. Generates:
9360 @example
9361 mul64 @var{a}, @var{b}
9362 @end example
9363 @end deftypefn
9364
9365 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
9366 Only available with @option{-mmul64}. Generates:
9367 @example
9368 mulu64 @var{a}, @var{b}
9369 @end example
9370 @end deftypefn
9371
9372 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
9373 Generates:
9374 @example
9375 nop
9376 @end example
9377 @end deftypefn
9378
9379 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
9380 Only valid if the @samp{norm} instruction is available through the
9381 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
9382 Generates:
9383 @example
9384 norm @var{dest}, @var{src}
9385 @end example
9386 Where the value in @var{dest} will be the result returned from the
9387 built-in.
9388 @end deftypefn
9389
9390 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
9391 Only valid if the @samp{normw} instruction is available through the
9392 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
9393 Generates:
9394 @example
9395 normw @var{dest}, @var{src}
9396 @end example
9397 Where the value in @var{dest} will be the result returned from the
9398 built-in.
9399 @end deftypefn
9400
9401 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
9402 Generates:
9403 @example
9404 rtie
9405 @end example
9406 @end deftypefn
9407
9408 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
9409 Generates:
9410 @example
9411 sleep @var{a}
9412 @end example
9413 @end deftypefn
9414
9415 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
9416 The first argument, @var{auxv}, is the address of an auxiliary
9417 register, the second argument, @var{val}, is a compile time constant
9418 to be written to the register. Generates:
9419 @example
9420 sr @var{auxr}, [@var{val}]
9421 @end example
9422 @end deftypefn
9423
9424 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
9425 Only valid with @option{-mswap}. Generates:
9426 @example
9427 swap @var{dest}, @var{src}
9428 @end example
9429 Where the value in @var{dest} will be the result returned from the
9430 built-in.
9431 @end deftypefn
9432
9433 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
9434 Generates:
9435 @example
9436 swi
9437 @end example
9438 @end deftypefn
9439
9440 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
9441 Only available with @option{-mcpu=ARC700}. Generates:
9442 @example
9443 sync
9444 @end example
9445 @end deftypefn
9446
9447 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
9448 Only available with @option{-mcpu=ARC700}. Generates:
9449 @example
9450 trap_s @var{c}
9451 @end example
9452 @end deftypefn
9453
9454 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
9455 Only available with @option{-mcpu=ARC700}. Generates:
9456 @example
9457 unimp_s
9458 @end example
9459 @end deftypefn
9460
9461 The instructions generated by the following builtins are not
9462 considered as candidates for scheduling. They are not moved around by
9463 the compiler during scheduling, and thus can be expected to appear
9464 where they are put in the C code:
9465 @example
9466 __builtin_arc_brk()
9467 __builtin_arc_core_read()
9468 __builtin_arc_core_write()
9469 __builtin_arc_flag()
9470 __builtin_arc_lr()
9471 __builtin_arc_sleep()
9472 __builtin_arc_sr()
9473 __builtin_arc_swi()
9474 @end example
9475
9476 @node ARC SIMD Built-in Functions
9477 @subsection ARC SIMD Built-in Functions
9478
9479 SIMD builtins provided by the compiler can be used to generate the
9480 vector instructions. This section describes the available builtins
9481 and their usage in programs. With the @option{-msimd} option, the
9482 compiler provides 128-bit vector types, which can be specified using
9483 the @code{vector_size} attribute. The header file @file{arc-simd.h}
9484 can be included to use the following predefined types:
9485 @example
9486 typedef int __v4si __attribute__((vector_size(16)));
9487 typedef short __v8hi __attribute__((vector_size(16)));
9488 @end example
9489
9490 These types can be used to define 128-bit variables. The built-in
9491 functions listed in the following section can be used on these
9492 variables to generate the vector operations.
9493
9494 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
9495 @file{arc-simd.h} also provides equivalent macros called
9496 @code{_@var{someinsn}} that can be used for programming ease and
9497 improved readability. The following macros for DMA control are also
9498 provided:
9499 @example
9500 #define _setup_dma_in_channel_reg _vdiwr
9501 #define _setup_dma_out_channel_reg _vdowr
9502 @end example
9503
9504 The following is a complete list of all the SIMD built-ins provided
9505 for ARC, grouped by calling signature.
9506
9507 The following take two @code{__v8hi} arguments and return a
9508 @code{__v8hi} result:
9509 @example
9510 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
9511 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
9512 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
9513 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
9514 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
9515 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
9516 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
9517 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
9518 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
9519 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
9520 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
9521 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
9522 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
9523 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
9524 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
9525 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
9526 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
9527 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
9528 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
9529 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
9530 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
9531 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
9532 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
9533 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
9534 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
9535 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
9536 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
9537 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
9538 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
9539 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
9540 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
9541 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
9542 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
9543 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
9544 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
9545 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
9546 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
9547 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
9548 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
9549 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
9550 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
9551 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
9552 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
9553 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
9554 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
9555 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
9556 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
9557 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
9558 @end example
9559
9560 The following take one @code{__v8hi} and one @code{int} argument and return a
9561 @code{__v8hi} result:
9562
9563 @example
9564 __v8hi __builtin_arc_vbaddw (__v8hi, int)
9565 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
9566 __v8hi __builtin_arc_vbminw (__v8hi, int)
9567 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
9568 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
9569 __v8hi __builtin_arc_vbmulw (__v8hi, int)
9570 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
9571 __v8hi __builtin_arc_vbsubw (__v8hi, int)
9572 @end example
9573
9574 The following take one @code{__v8hi} argument and one @code{int} argument which
9575 must be a 3-bit compile time constant indicating a register number
9576 I0-I7. They return a @code{__v8hi} result.
9577 @example
9578 __v8hi __builtin_arc_vasrw (__v8hi, const int)
9579 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
9580 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
9581 @end example
9582
9583 The following take one @code{__v8hi} argument and one @code{int}
9584 argument which must be a 6-bit compile time constant. They return a
9585 @code{__v8hi} result.
9586 @example
9587 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
9588 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
9589 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
9590 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
9591 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
9592 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
9593 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
9594 @end example
9595
9596 The following take one @code{__v8hi} argument and one @code{int} argument which
9597 must be a 8-bit compile time constant. They return a @code{__v8hi}
9598 result.
9599 @example
9600 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
9601 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
9602 __v8hi __builtin_arc_vmvw (__v8hi, const int)
9603 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
9604 @end example
9605
9606 The following take two @code{int} arguments, the second of which which
9607 must be a 8-bit compile time constant. They return a @code{__v8hi}
9608 result:
9609 @example
9610 __v8hi __builtin_arc_vmovaw (int, const int)
9611 __v8hi __builtin_arc_vmovw (int, const int)
9612 __v8hi __builtin_arc_vmovzw (int, const int)
9613 @end example
9614
9615 The following take a single @code{__v8hi} argument and return a
9616 @code{__v8hi} result:
9617 @example
9618 __v8hi __builtin_arc_vabsaw (__v8hi)
9619 __v8hi __builtin_arc_vabsw (__v8hi)
9620 __v8hi __builtin_arc_vaddsuw (__v8hi)
9621 __v8hi __builtin_arc_vexch1 (__v8hi)
9622 __v8hi __builtin_arc_vexch2 (__v8hi)
9623 __v8hi __builtin_arc_vexch4 (__v8hi)
9624 __v8hi __builtin_arc_vsignw (__v8hi)
9625 __v8hi __builtin_arc_vupbaw (__v8hi)
9626 __v8hi __builtin_arc_vupbw (__v8hi)
9627 __v8hi __builtin_arc_vupsbaw (__v8hi)
9628 __v8hi __builtin_arc_vupsbw (__v8hi)
9629 @end example
9630
9631 The followign take two @code{int} arguments and return no result:
9632 @example
9633 void __builtin_arc_vdirun (int, int)
9634 void __builtin_arc_vdorun (int, int)
9635 @end example
9636
9637 The following take two @code{int} arguments and return no result. The
9638 first argument must a 3-bit compile time constant indicating one of
9639 the DR0-DR7 DMA setup channels:
9640 @example
9641 void __builtin_arc_vdiwr (const int, int)
9642 void __builtin_arc_vdowr (const int, int)
9643 @end example
9644
9645 The following take an @code{int} argument and return no result:
9646 @example
9647 void __builtin_arc_vendrec (int)
9648 void __builtin_arc_vrec (int)
9649 void __builtin_arc_vrecrun (int)
9650 void __builtin_arc_vrun (int)
9651 @end example
9652
9653 The following take a @code{__v8hi} argument and two @code{int}
9654 arguments and return a @code{__v8hi} result. The second argument must
9655 be a 3-bit compile time constants, indicating one the registers I0-I7,
9656 and the third argument must be an 8-bit compile time constant.
9657
9658 @emph{Note:} Although the equivalent hardware instructions do not take
9659 an SIMD register as an operand, these builtins overwrite the relevant
9660 bits of the @code{__v8hi} register provided as the first argument with
9661 the value loaded from the @code{[Ib, u8]} location in the SDM.
9662
9663 @example
9664 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
9665 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
9666 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
9667 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
9668 @end example
9669
9670 The following take two @code{int} arguments and return a @code{__v8hi}
9671 result. The first argument must be a 3-bit compile time constants,
9672 indicating one the registers I0-I7, and the second argument must be an
9673 8-bit compile time constant.
9674
9675 @example
9676 __v8hi __builtin_arc_vld128 (const int, const int)
9677 __v8hi __builtin_arc_vld64w (const int, const int)
9678 @end example
9679
9680 The following take a @code{__v8hi} argument and two @code{int}
9681 arguments and return no result. The second argument must be a 3-bit
9682 compile time constants, indicating one the registers I0-I7, and the
9683 third argument must be an 8-bit compile time constant.
9684
9685 @example
9686 void __builtin_arc_vst128 (__v8hi, const int, const int)
9687 void __builtin_arc_vst64 (__v8hi, const int, const int)
9688 @end example
9689
9690 The following take a @code{__v8hi} argument and three @code{int}
9691 arguments and return no result. The second argument must be a 3-bit
9692 compile-time constant, identifying the 16-bit sub-register to be
9693 stored, the third argument must be a 3-bit compile time constants,
9694 indicating one the registers I0-I7, and the fourth argument must be an
9695 8-bit compile time constant.
9696
9697 @example
9698 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
9699 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
9700 @end example
9701
9702 @node ARM iWMMXt Built-in Functions
9703 @subsection ARM iWMMXt Built-in Functions
9704
9705 These built-in functions are available for the ARM family of
9706 processors when the @option{-mcpu=iwmmxt} switch is used:
9707
9708 @smallexample
9709 typedef int v2si __attribute__ ((vector_size (8)));
9710 typedef short v4hi __attribute__ ((vector_size (8)));
9711 typedef char v8qi __attribute__ ((vector_size (8)));
9712
9713 int __builtin_arm_getwcgr0 (void)
9714 void __builtin_arm_setwcgr0 (int)
9715 int __builtin_arm_getwcgr1 (void)
9716 void __builtin_arm_setwcgr1 (int)
9717 int __builtin_arm_getwcgr2 (void)
9718 void __builtin_arm_setwcgr2 (int)
9719 int __builtin_arm_getwcgr3 (void)
9720 void __builtin_arm_setwcgr3 (int)
9721 int __builtin_arm_textrmsb (v8qi, int)
9722 int __builtin_arm_textrmsh (v4hi, int)
9723 int __builtin_arm_textrmsw (v2si, int)
9724 int __builtin_arm_textrmub (v8qi, int)
9725 int __builtin_arm_textrmuh (v4hi, int)
9726 int __builtin_arm_textrmuw (v2si, int)
9727 v8qi __builtin_arm_tinsrb (v8qi, int, int)
9728 v4hi __builtin_arm_tinsrh (v4hi, int, int)
9729 v2si __builtin_arm_tinsrw (v2si, int, int)
9730 long long __builtin_arm_tmia (long long, int, int)
9731 long long __builtin_arm_tmiabb (long long, int, int)
9732 long long __builtin_arm_tmiabt (long long, int, int)
9733 long long __builtin_arm_tmiaph (long long, int, int)
9734 long long __builtin_arm_tmiatb (long long, int, int)
9735 long long __builtin_arm_tmiatt (long long, int, int)
9736 int __builtin_arm_tmovmskb (v8qi)
9737 int __builtin_arm_tmovmskh (v4hi)
9738 int __builtin_arm_tmovmskw (v2si)
9739 long long __builtin_arm_waccb (v8qi)
9740 long long __builtin_arm_wacch (v4hi)
9741 long long __builtin_arm_waccw (v2si)
9742 v8qi __builtin_arm_waddb (v8qi, v8qi)
9743 v8qi __builtin_arm_waddbss (v8qi, v8qi)
9744 v8qi __builtin_arm_waddbus (v8qi, v8qi)
9745 v4hi __builtin_arm_waddh (v4hi, v4hi)
9746 v4hi __builtin_arm_waddhss (v4hi, v4hi)
9747 v4hi __builtin_arm_waddhus (v4hi, v4hi)
9748 v2si __builtin_arm_waddw (v2si, v2si)
9749 v2si __builtin_arm_waddwss (v2si, v2si)
9750 v2si __builtin_arm_waddwus (v2si, v2si)
9751 v8qi __builtin_arm_walign (v8qi, v8qi, int)
9752 long long __builtin_arm_wand(long long, long long)
9753 long long __builtin_arm_wandn (long long, long long)
9754 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
9755 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
9756 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
9757 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
9758 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
9759 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
9760 v2si __builtin_arm_wcmpeqw (v2si, v2si)
9761 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
9762 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
9763 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
9764 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
9765 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
9766 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
9767 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
9768 long long __builtin_arm_wmacsz (v4hi, v4hi)
9769 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
9770 long long __builtin_arm_wmacuz (v4hi, v4hi)
9771 v4hi __builtin_arm_wmadds (v4hi, v4hi)
9772 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
9773 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
9774 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
9775 v2si __builtin_arm_wmaxsw (v2si, v2si)
9776 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
9777 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
9778 v2si __builtin_arm_wmaxuw (v2si, v2si)
9779 v8qi __builtin_arm_wminsb (v8qi, v8qi)
9780 v4hi __builtin_arm_wminsh (v4hi, v4hi)
9781 v2si __builtin_arm_wminsw (v2si, v2si)
9782 v8qi __builtin_arm_wminub (v8qi, v8qi)
9783 v4hi __builtin_arm_wminuh (v4hi, v4hi)
9784 v2si __builtin_arm_wminuw (v2si, v2si)
9785 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
9786 v4hi __builtin_arm_wmulul (v4hi, v4hi)
9787 v4hi __builtin_arm_wmulum (v4hi, v4hi)
9788 long long __builtin_arm_wor (long long, long long)
9789 v2si __builtin_arm_wpackdss (long long, long long)
9790 v2si __builtin_arm_wpackdus (long long, long long)
9791 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
9792 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
9793 v4hi __builtin_arm_wpackwss (v2si, v2si)
9794 v4hi __builtin_arm_wpackwus (v2si, v2si)
9795 long long __builtin_arm_wrord (long long, long long)
9796 long long __builtin_arm_wrordi (long long, int)
9797 v4hi __builtin_arm_wrorh (v4hi, long long)
9798 v4hi __builtin_arm_wrorhi (v4hi, int)
9799 v2si __builtin_arm_wrorw (v2si, long long)
9800 v2si __builtin_arm_wrorwi (v2si, int)
9801 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
9802 v2si __builtin_arm_wsadbz (v8qi, v8qi)
9803 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
9804 v2si __builtin_arm_wsadhz (v4hi, v4hi)
9805 v4hi __builtin_arm_wshufh (v4hi, int)
9806 long long __builtin_arm_wslld (long long, long long)
9807 long long __builtin_arm_wslldi (long long, int)
9808 v4hi __builtin_arm_wsllh (v4hi, long long)
9809 v4hi __builtin_arm_wsllhi (v4hi, int)
9810 v2si __builtin_arm_wsllw (v2si, long long)
9811 v2si __builtin_arm_wsllwi (v2si, int)
9812 long long __builtin_arm_wsrad (long long, long long)
9813 long long __builtin_arm_wsradi (long long, int)
9814 v4hi __builtin_arm_wsrah (v4hi, long long)
9815 v4hi __builtin_arm_wsrahi (v4hi, int)
9816 v2si __builtin_arm_wsraw (v2si, long long)
9817 v2si __builtin_arm_wsrawi (v2si, int)
9818 long long __builtin_arm_wsrld (long long, long long)
9819 long long __builtin_arm_wsrldi (long long, int)
9820 v4hi __builtin_arm_wsrlh (v4hi, long long)
9821 v4hi __builtin_arm_wsrlhi (v4hi, int)
9822 v2si __builtin_arm_wsrlw (v2si, long long)
9823 v2si __builtin_arm_wsrlwi (v2si, int)
9824 v8qi __builtin_arm_wsubb (v8qi, v8qi)
9825 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
9826 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
9827 v4hi __builtin_arm_wsubh (v4hi, v4hi)
9828 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
9829 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
9830 v2si __builtin_arm_wsubw (v2si, v2si)
9831 v2si __builtin_arm_wsubwss (v2si, v2si)
9832 v2si __builtin_arm_wsubwus (v2si, v2si)
9833 v4hi __builtin_arm_wunpckehsb (v8qi)
9834 v2si __builtin_arm_wunpckehsh (v4hi)
9835 long long __builtin_arm_wunpckehsw (v2si)
9836 v4hi __builtin_arm_wunpckehub (v8qi)
9837 v2si __builtin_arm_wunpckehuh (v4hi)
9838 long long __builtin_arm_wunpckehuw (v2si)
9839 v4hi __builtin_arm_wunpckelsb (v8qi)
9840 v2si __builtin_arm_wunpckelsh (v4hi)
9841 long long __builtin_arm_wunpckelsw (v2si)
9842 v4hi __builtin_arm_wunpckelub (v8qi)
9843 v2si __builtin_arm_wunpckeluh (v4hi)
9844 long long __builtin_arm_wunpckeluw (v2si)
9845 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
9846 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
9847 v2si __builtin_arm_wunpckihw (v2si, v2si)
9848 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
9849 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
9850 v2si __builtin_arm_wunpckilw (v2si, v2si)
9851 long long __builtin_arm_wxor (long long, long long)
9852 long long __builtin_arm_wzero ()
9853 @end smallexample
9854
9855 @node ARM NEON Intrinsics
9856 @subsection ARM NEON Intrinsics
9857
9858 These built-in intrinsics for the ARM Advanced SIMD extension are available
9859 when the @option{-mfpu=neon} switch is used:
9860
9861 @include arm-neon-intrinsics.texi
9862
9863 @node AVR Built-in Functions
9864 @subsection AVR Built-in Functions
9865
9866 For each built-in function for AVR, there is an equally named,
9867 uppercase built-in macro defined. That way users can easily query if
9868 or if not a specific built-in is implemented or not. For example, if
9869 @code{__builtin_avr_nop} is available the macro
9870 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
9871
9872 The following built-in functions map to the respective machine
9873 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
9874 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
9875 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
9876 as library call if no hardware multiplier is available.
9877
9878 @smallexample
9879 void __builtin_avr_nop (void)
9880 void __builtin_avr_sei (void)
9881 void __builtin_avr_cli (void)
9882 void __builtin_avr_sleep (void)
9883 void __builtin_avr_wdr (void)
9884 unsigned char __builtin_avr_swap (unsigned char)
9885 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
9886 int __builtin_avr_fmuls (char, char)
9887 int __builtin_avr_fmulsu (char, unsigned char)
9888 @end smallexample
9889
9890 In order to delay execution for a specific number of cycles, GCC
9891 implements
9892 @smallexample
9893 void __builtin_avr_delay_cycles (unsigned long ticks)
9894 @end smallexample
9895
9896 @noindent
9897 @code{ticks} is the number of ticks to delay execution. Note that this
9898 built-in does not take into account the effect of interrupts that
9899 might increase delay time. @code{ticks} must be a compile-time
9900 integer constant; delays with a variable number of cycles are not supported.
9901
9902 @smallexample
9903 char __builtin_avr_flash_segment (const __memx void*)
9904 @end smallexample
9905
9906 @noindent
9907 This built-in takes a byte address to the 24-bit
9908 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
9909 the number of the flash segment (the 64 KiB chunk) where the address
9910 points to. Counting starts at @code{0}.
9911 If the address does not point to flash memory, return @code{-1}.
9912
9913 @smallexample
9914 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
9915 @end smallexample
9916
9917 @noindent
9918 Insert bits from @var{bits} into @var{val} and return the resulting
9919 value. The nibbles of @var{map} determine how the insertion is
9920 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
9921 @enumerate
9922 @item If @var{X} is @code{0xf},
9923 then the @var{n}-th bit of @var{val} is returned unaltered.
9924
9925 @item If X is in the range 0@dots{}7,
9926 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
9927
9928 @item If X is in the range 8@dots{}@code{0xe},
9929 then the @var{n}-th result bit is undefined.
9930 @end enumerate
9931
9932 @noindent
9933 One typical use case for this built-in is adjusting input and
9934 output values to non-contiguous port layouts. Some examples:
9935
9936 @smallexample
9937 // same as val, bits is unused
9938 __builtin_avr_insert_bits (0xffffffff, bits, val)
9939 @end smallexample
9940
9941 @smallexample
9942 // same as bits, val is unused
9943 __builtin_avr_insert_bits (0x76543210, bits, val)
9944 @end smallexample
9945
9946 @smallexample
9947 // same as rotating bits by 4
9948 __builtin_avr_insert_bits (0x32107654, bits, 0)
9949 @end smallexample
9950
9951 @smallexample
9952 // high nibble of result is the high nibble of val
9953 // low nibble of result is the low nibble of bits
9954 __builtin_avr_insert_bits (0xffff3210, bits, val)
9955 @end smallexample
9956
9957 @smallexample
9958 // reverse the bit order of bits
9959 __builtin_avr_insert_bits (0x01234567, bits, 0)
9960 @end smallexample
9961
9962 @node Blackfin Built-in Functions
9963 @subsection Blackfin Built-in Functions
9964
9965 Currently, there are two Blackfin-specific built-in functions. These are
9966 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
9967 using inline assembly; by using these built-in functions the compiler can
9968 automatically add workarounds for hardware errata involving these
9969 instructions. These functions are named as follows:
9970
9971 @smallexample
9972 void __builtin_bfin_csync (void)
9973 void __builtin_bfin_ssync (void)
9974 @end smallexample
9975
9976 @node FR-V Built-in Functions
9977 @subsection FR-V Built-in Functions
9978
9979 GCC provides many FR-V-specific built-in functions. In general,
9980 these functions are intended to be compatible with those described
9981 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
9982 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
9983 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
9984 pointer rather than by value.
9985
9986 Most of the functions are named after specific FR-V instructions.
9987 Such functions are said to be ``directly mapped'' and are summarized
9988 here in tabular form.
9989
9990 @menu
9991 * Argument Types::
9992 * Directly-mapped Integer Functions::
9993 * Directly-mapped Media Functions::
9994 * Raw read/write Functions::
9995 * Other Built-in Functions::
9996 @end menu
9997
9998 @node Argument Types
9999 @subsubsection Argument Types
10000
10001 The arguments to the built-in functions can be divided into three groups:
10002 register numbers, compile-time constants and run-time values. In order
10003 to make this classification clear at a glance, the arguments and return
10004 values are given the following pseudo types:
10005
10006 @multitable @columnfractions .20 .30 .15 .35
10007 @item Pseudo type @tab Real C type @tab Constant? @tab Description
10008 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
10009 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
10010 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
10011 @item @code{uw2} @tab @code{unsigned long long} @tab No
10012 @tab an unsigned doubleword
10013 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
10014 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
10015 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
10016 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
10017 @end multitable
10018
10019 These pseudo types are not defined by GCC, they are simply a notational
10020 convenience used in this manual.
10021
10022 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
10023 and @code{sw2} are evaluated at run time. They correspond to
10024 register operands in the underlying FR-V instructions.
10025
10026 @code{const} arguments represent immediate operands in the underlying
10027 FR-V instructions. They must be compile-time constants.
10028
10029 @code{acc} arguments are evaluated at compile time and specify the number
10030 of an accumulator register. For example, an @code{acc} argument of 2
10031 selects the ACC2 register.
10032
10033 @code{iacc} arguments are similar to @code{acc} arguments but specify the
10034 number of an IACC register. See @pxref{Other Built-in Functions}
10035 for more details.
10036
10037 @node Directly-mapped Integer Functions
10038 @subsubsection Directly-mapped Integer Functions
10039
10040 The functions listed below map directly to FR-V I-type instructions.
10041
10042 @multitable @columnfractions .45 .32 .23
10043 @item Function prototype @tab Example usage @tab Assembly output
10044 @item @code{sw1 __ADDSS (sw1, sw1)}
10045 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
10046 @tab @code{ADDSS @var{a},@var{b},@var{c}}
10047 @item @code{sw1 __SCAN (sw1, sw1)}
10048 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
10049 @tab @code{SCAN @var{a},@var{b},@var{c}}
10050 @item @code{sw1 __SCUTSS (sw1)}
10051 @tab @code{@var{b} = __SCUTSS (@var{a})}
10052 @tab @code{SCUTSS @var{a},@var{b}}
10053 @item @code{sw1 __SLASS (sw1, sw1)}
10054 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
10055 @tab @code{SLASS @var{a},@var{b},@var{c}}
10056 @item @code{void __SMASS (sw1, sw1)}
10057 @tab @code{__SMASS (@var{a}, @var{b})}
10058 @tab @code{SMASS @var{a},@var{b}}
10059 @item @code{void __SMSSS (sw1, sw1)}
10060 @tab @code{__SMSSS (@var{a}, @var{b})}
10061 @tab @code{SMSSS @var{a},@var{b}}
10062 @item @code{void __SMU (sw1, sw1)}
10063 @tab @code{__SMU (@var{a}, @var{b})}
10064 @tab @code{SMU @var{a},@var{b}}
10065 @item @code{sw2 __SMUL (sw1, sw1)}
10066 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
10067 @tab @code{SMUL @var{a},@var{b},@var{c}}
10068 @item @code{sw1 __SUBSS (sw1, sw1)}
10069 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
10070 @tab @code{SUBSS @var{a},@var{b},@var{c}}
10071 @item @code{uw2 __UMUL (uw1, uw1)}
10072 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
10073 @tab @code{UMUL @var{a},@var{b},@var{c}}
10074 @end multitable
10075
10076 @node Directly-mapped Media Functions
10077 @subsubsection Directly-mapped Media Functions
10078
10079 The functions listed below map directly to FR-V M-type instructions.
10080
10081 @multitable @columnfractions .45 .32 .23
10082 @item Function prototype @tab Example usage @tab Assembly output
10083 @item @code{uw1 __MABSHS (sw1)}
10084 @tab @code{@var{b} = __MABSHS (@var{a})}
10085 @tab @code{MABSHS @var{a},@var{b}}
10086 @item @code{void __MADDACCS (acc, acc)}
10087 @tab @code{__MADDACCS (@var{b}, @var{a})}
10088 @tab @code{MADDACCS @var{a},@var{b}}
10089 @item @code{sw1 __MADDHSS (sw1, sw1)}
10090 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
10091 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
10092 @item @code{uw1 __MADDHUS (uw1, uw1)}
10093 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
10094 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
10095 @item @code{uw1 __MAND (uw1, uw1)}
10096 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
10097 @tab @code{MAND @var{a},@var{b},@var{c}}
10098 @item @code{void __MASACCS (acc, acc)}
10099 @tab @code{__MASACCS (@var{b}, @var{a})}
10100 @tab @code{MASACCS @var{a},@var{b}}
10101 @item @code{uw1 __MAVEH (uw1, uw1)}
10102 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
10103 @tab @code{MAVEH @var{a},@var{b},@var{c}}
10104 @item @code{uw2 __MBTOH (uw1)}
10105 @tab @code{@var{b} = __MBTOH (@var{a})}
10106 @tab @code{MBTOH @var{a},@var{b}}
10107 @item @code{void __MBTOHE (uw1 *, uw1)}
10108 @tab @code{__MBTOHE (&@var{b}, @var{a})}
10109 @tab @code{MBTOHE @var{a},@var{b}}
10110 @item @code{void __MCLRACC (acc)}
10111 @tab @code{__MCLRACC (@var{a})}
10112 @tab @code{MCLRACC @var{a}}
10113 @item @code{void __MCLRACCA (void)}
10114 @tab @code{__MCLRACCA ()}
10115 @tab @code{MCLRACCA}
10116 @item @code{uw1 __Mcop1 (uw1, uw1)}
10117 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
10118 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
10119 @item @code{uw1 __Mcop2 (uw1, uw1)}
10120 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
10121 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
10122 @item @code{uw1 __MCPLHI (uw2, const)}
10123 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
10124 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
10125 @item @code{uw1 __MCPLI (uw2, const)}
10126 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
10127 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
10128 @item @code{void __MCPXIS (acc, sw1, sw1)}
10129 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
10130 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
10131 @item @code{void __MCPXIU (acc, uw1, uw1)}
10132 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
10133 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
10134 @item @code{void __MCPXRS (acc, sw1, sw1)}
10135 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
10136 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
10137 @item @code{void __MCPXRU (acc, uw1, uw1)}
10138 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
10139 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
10140 @item @code{uw1 __MCUT (acc, uw1)}
10141 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
10142 @tab @code{MCUT @var{a},@var{b},@var{c}}
10143 @item @code{uw1 __MCUTSS (acc, sw1)}
10144 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
10145 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
10146 @item @code{void __MDADDACCS (acc, acc)}
10147 @tab @code{__MDADDACCS (@var{b}, @var{a})}
10148 @tab @code{MDADDACCS @var{a},@var{b}}
10149 @item @code{void __MDASACCS (acc, acc)}
10150 @tab @code{__MDASACCS (@var{b}, @var{a})}
10151 @tab @code{MDASACCS @var{a},@var{b}}
10152 @item @code{uw2 __MDCUTSSI (acc, const)}
10153 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
10154 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
10155 @item @code{uw2 __MDPACKH (uw2, uw2)}
10156 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
10157 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
10158 @item @code{uw2 __MDROTLI (uw2, const)}
10159 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
10160 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
10161 @item @code{void __MDSUBACCS (acc, acc)}
10162 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
10163 @tab @code{MDSUBACCS @var{a},@var{b}}
10164 @item @code{void __MDUNPACKH (uw1 *, uw2)}
10165 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
10166 @tab @code{MDUNPACKH @var{a},@var{b}}
10167 @item @code{uw2 __MEXPDHD (uw1, const)}
10168 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
10169 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
10170 @item @code{uw1 __MEXPDHW (uw1, const)}
10171 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
10172 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
10173 @item @code{uw1 __MHDSETH (uw1, const)}
10174 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
10175 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
10176 @item @code{sw1 __MHDSETS (const)}
10177 @tab @code{@var{b} = __MHDSETS (@var{a})}
10178 @tab @code{MHDSETS #@var{a},@var{b}}
10179 @item @code{uw1 __MHSETHIH (uw1, const)}
10180 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
10181 @tab @code{MHSETHIH #@var{a},@var{b}}
10182 @item @code{sw1 __MHSETHIS (sw1, const)}
10183 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
10184 @tab @code{MHSETHIS #@var{a},@var{b}}
10185 @item @code{uw1 __MHSETLOH (uw1, const)}
10186 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
10187 @tab @code{MHSETLOH #@var{a},@var{b}}
10188 @item @code{sw1 __MHSETLOS (sw1, const)}
10189 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
10190 @tab @code{MHSETLOS #@var{a},@var{b}}
10191 @item @code{uw1 __MHTOB (uw2)}
10192 @tab @code{@var{b} = __MHTOB (@var{a})}
10193 @tab @code{MHTOB @var{a},@var{b}}
10194 @item @code{void __MMACHS (acc, sw1, sw1)}
10195 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
10196 @tab @code{MMACHS @var{a},@var{b},@var{c}}
10197 @item @code{void __MMACHU (acc, uw1, uw1)}
10198 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
10199 @tab @code{MMACHU @var{a},@var{b},@var{c}}
10200 @item @code{void __MMRDHS (acc, sw1, sw1)}
10201 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
10202 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
10203 @item @code{void __MMRDHU (acc, uw1, uw1)}
10204 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
10205 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
10206 @item @code{void __MMULHS (acc, sw1, sw1)}
10207 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
10208 @tab @code{MMULHS @var{a},@var{b},@var{c}}
10209 @item @code{void __MMULHU (acc, uw1, uw1)}
10210 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
10211 @tab @code{MMULHU @var{a},@var{b},@var{c}}
10212 @item @code{void __MMULXHS (acc, sw1, sw1)}
10213 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
10214 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
10215 @item @code{void __MMULXHU (acc, uw1, uw1)}
10216 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
10217 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
10218 @item @code{uw1 __MNOT (uw1)}
10219 @tab @code{@var{b} = __MNOT (@var{a})}
10220 @tab @code{MNOT @var{a},@var{b}}
10221 @item @code{uw1 __MOR (uw1, uw1)}
10222 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
10223 @tab @code{MOR @var{a},@var{b},@var{c}}
10224 @item @code{uw1 __MPACKH (uh, uh)}
10225 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
10226 @tab @code{MPACKH @var{a},@var{b},@var{c}}
10227 @item @code{sw2 __MQADDHSS (sw2, sw2)}
10228 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
10229 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
10230 @item @code{uw2 __MQADDHUS (uw2, uw2)}
10231 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
10232 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
10233 @item @code{void __MQCPXIS (acc, sw2, sw2)}
10234 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
10235 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
10236 @item @code{void __MQCPXIU (acc, uw2, uw2)}
10237 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
10238 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
10239 @item @code{void __MQCPXRS (acc, sw2, sw2)}
10240 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
10241 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
10242 @item @code{void __MQCPXRU (acc, uw2, uw2)}
10243 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
10244 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
10245 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
10246 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
10247 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
10248 @item @code{sw2 __MQLMTHS (sw2, sw2)}
10249 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
10250 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
10251 @item @code{void __MQMACHS (acc, sw2, sw2)}
10252 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
10253 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
10254 @item @code{void __MQMACHU (acc, uw2, uw2)}
10255 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
10256 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
10257 @item @code{void __MQMACXHS (acc, sw2, sw2)}
10258 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
10259 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
10260 @item @code{void __MQMULHS (acc, sw2, sw2)}
10261 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
10262 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
10263 @item @code{void __MQMULHU (acc, uw2, uw2)}
10264 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
10265 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
10266 @item @code{void __MQMULXHS (acc, sw2, sw2)}
10267 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
10268 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
10269 @item @code{void __MQMULXHU (acc, uw2, uw2)}
10270 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
10271 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
10272 @item @code{sw2 __MQSATHS (sw2, sw2)}
10273 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
10274 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
10275 @item @code{uw2 __MQSLLHI (uw2, int)}
10276 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
10277 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
10278 @item @code{sw2 __MQSRAHI (sw2, int)}
10279 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
10280 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
10281 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
10282 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
10283 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
10284 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
10285 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
10286 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
10287 @item @code{void __MQXMACHS (acc, sw2, sw2)}
10288 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
10289 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
10290 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
10291 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
10292 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
10293 @item @code{uw1 __MRDACC (acc)}
10294 @tab @code{@var{b} = __MRDACC (@var{a})}
10295 @tab @code{MRDACC @var{a},@var{b}}
10296 @item @code{uw1 __MRDACCG (acc)}
10297 @tab @code{@var{b} = __MRDACCG (@var{a})}
10298 @tab @code{MRDACCG @var{a},@var{b}}
10299 @item @code{uw1 __MROTLI (uw1, const)}
10300 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
10301 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
10302 @item @code{uw1 __MROTRI (uw1, const)}
10303 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
10304 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
10305 @item @code{sw1 __MSATHS (sw1, sw1)}
10306 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
10307 @tab @code{MSATHS @var{a},@var{b},@var{c}}
10308 @item @code{uw1 __MSATHU (uw1, uw1)}
10309 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
10310 @tab @code{MSATHU @var{a},@var{b},@var{c}}
10311 @item @code{uw1 __MSLLHI (uw1, const)}
10312 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
10313 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
10314 @item @code{sw1 __MSRAHI (sw1, const)}
10315 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
10316 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
10317 @item @code{uw1 __MSRLHI (uw1, const)}
10318 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
10319 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
10320 @item @code{void __MSUBACCS (acc, acc)}
10321 @tab @code{__MSUBACCS (@var{b}, @var{a})}
10322 @tab @code{MSUBACCS @var{a},@var{b}}
10323 @item @code{sw1 __MSUBHSS (sw1, sw1)}
10324 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
10325 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
10326 @item @code{uw1 __MSUBHUS (uw1, uw1)}
10327 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
10328 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
10329 @item @code{void __MTRAP (void)}
10330 @tab @code{__MTRAP ()}
10331 @tab @code{MTRAP}
10332 @item @code{uw2 __MUNPACKH (uw1)}
10333 @tab @code{@var{b} = __MUNPACKH (@var{a})}
10334 @tab @code{MUNPACKH @var{a},@var{b}}
10335 @item @code{uw1 __MWCUT (uw2, uw1)}
10336 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
10337 @tab @code{MWCUT @var{a},@var{b},@var{c}}
10338 @item @code{void __MWTACC (acc, uw1)}
10339 @tab @code{__MWTACC (@var{b}, @var{a})}
10340 @tab @code{MWTACC @var{a},@var{b}}
10341 @item @code{void __MWTACCG (acc, uw1)}
10342 @tab @code{__MWTACCG (@var{b}, @var{a})}
10343 @tab @code{MWTACCG @var{a},@var{b}}
10344 @item @code{uw1 __MXOR (uw1, uw1)}
10345 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
10346 @tab @code{MXOR @var{a},@var{b},@var{c}}
10347 @end multitable
10348
10349 @node Raw read/write Functions
10350 @subsubsection Raw read/write Functions
10351
10352 This sections describes built-in functions related to read and write
10353 instructions to access memory. These functions generate
10354 @code{membar} instructions to flush the I/O load and stores where
10355 appropriate, as described in Fujitsu's manual described above.
10356
10357 @table @code
10358
10359 @item unsigned char __builtin_read8 (void *@var{data})
10360 @item unsigned short __builtin_read16 (void *@var{data})
10361 @item unsigned long __builtin_read32 (void *@var{data})
10362 @item unsigned long long __builtin_read64 (void *@var{data})
10363
10364 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
10365 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
10366 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
10367 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
10368 @end table
10369
10370 @node Other Built-in Functions
10371 @subsubsection Other Built-in Functions
10372
10373 This section describes built-in functions that are not named after
10374 a specific FR-V instruction.
10375
10376 @table @code
10377 @item sw2 __IACCreadll (iacc @var{reg})
10378 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
10379 for future expansion and must be 0.
10380
10381 @item sw1 __IACCreadl (iacc @var{reg})
10382 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
10383 Other values of @var{reg} are rejected as invalid.
10384
10385 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
10386 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
10387 is reserved for future expansion and must be 0.
10388
10389 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
10390 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
10391 is 1. Other values of @var{reg} are rejected as invalid.
10392
10393 @item void __data_prefetch0 (const void *@var{x})
10394 Use the @code{dcpl} instruction to load the contents of address @var{x}
10395 into the data cache.
10396
10397 @item void __data_prefetch (const void *@var{x})
10398 Use the @code{nldub} instruction to load the contents of address @var{x}
10399 into the data cache. The instruction is issued in slot I1@.
10400 @end table
10401
10402 @node X86 Built-in Functions
10403 @subsection X86 Built-in Functions
10404
10405 These built-in functions are available for the i386 and x86-64 family
10406 of computers, depending on the command-line switches used.
10407
10408 If you specify command-line switches such as @option{-msse},
10409 the compiler could use the extended instruction sets even if the built-ins
10410 are not used explicitly in the program. For this reason, applications
10411 that perform run-time CPU detection must compile separate files for each
10412 supported architecture, using the appropriate flags. In particular,
10413 the file containing the CPU detection code should be compiled without
10414 these options.
10415
10416 The following machine modes are available for use with MMX built-in functions
10417 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
10418 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
10419 vector of eight 8-bit integers. Some of the built-in functions operate on
10420 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
10421
10422 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
10423 of two 32-bit floating-point values.
10424
10425 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
10426 floating-point values. Some instructions use a vector of four 32-bit
10427 integers, these use @code{V4SI}. Finally, some instructions operate on an
10428 entire vector register, interpreting it as a 128-bit integer, these use mode
10429 @code{TI}.
10430
10431 In 64-bit mode, the x86-64 family of processors uses additional built-in
10432 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
10433 floating point and @code{TC} 128-bit complex floating-point values.
10434
10435 The following floating-point built-in functions are available in 64-bit
10436 mode. All of them implement the function that is part of the name.
10437
10438 @smallexample
10439 __float128 __builtin_fabsq (__float128)
10440 __float128 __builtin_copysignq (__float128, __float128)
10441 @end smallexample
10442
10443 The following built-in function is always available.
10444
10445 @table @code
10446 @item void __builtin_ia32_pause (void)
10447 Generates the @code{pause} machine instruction with a compiler memory
10448 barrier.
10449 @end table
10450
10451 The following floating-point built-in functions are made available in the
10452 64-bit mode.
10453
10454 @table @code
10455 @item __float128 __builtin_infq (void)
10456 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
10457 @findex __builtin_infq
10458
10459 @item __float128 __builtin_huge_valq (void)
10460 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
10461 @findex __builtin_huge_valq
10462 @end table
10463
10464 The following built-in functions are always available and can be used to
10465 check the target platform type.
10466
10467 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
10468 This function runs the CPU detection code to check the type of CPU and the
10469 features supported. This built-in function needs to be invoked along with the built-in functions
10470 to check CPU type and features, @code{__builtin_cpu_is} and
10471 @code{__builtin_cpu_supports}, only when used in a function that is
10472 executed before any constructors are called. The CPU detection code is
10473 automatically executed in a very high priority constructor.
10474
10475 For example, this function has to be used in @code{ifunc} resolvers that
10476 check for CPU type using the built-in functions @code{__builtin_cpu_is}
10477 and @code{__builtin_cpu_supports}, or in constructors on targets that
10478 don't support constructor priority.
10479 @smallexample
10480
10481 static void (*resolve_memcpy (void)) (void)
10482 @{
10483 // ifunc resolvers fire before constructors, explicitly call the init
10484 // function.
10485 __builtin_cpu_init ();
10486 if (__builtin_cpu_supports ("ssse3"))
10487 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
10488 else
10489 return default_memcpy;
10490 @}
10491
10492 void *memcpy (void *, const void *, size_t)
10493 __attribute__ ((ifunc ("resolve_memcpy")));
10494 @end smallexample
10495
10496 @end deftypefn
10497
10498 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
10499 This function returns a positive integer if the run-time CPU
10500 is of type @var{cpuname}
10501 and returns @code{0} otherwise. The following CPU names can be detected:
10502
10503 @table @samp
10504 @item intel
10505 Intel CPU.
10506
10507 @item atom
10508 Intel Atom CPU.
10509
10510 @item core2
10511 Intel Core 2 CPU.
10512
10513 @item corei7
10514 Intel Core i7 CPU.
10515
10516 @item nehalem
10517 Intel Core i7 Nehalem CPU.
10518
10519 @item westmere
10520 Intel Core i7 Westmere CPU.
10521
10522 @item sandybridge
10523 Intel Core i7 Sandy Bridge CPU.
10524
10525 @item amd
10526 AMD CPU.
10527
10528 @item amdfam10h
10529 AMD Family 10h CPU.
10530
10531 @item barcelona
10532 AMD Family 10h Barcelona CPU.
10533
10534 @item shanghai
10535 AMD Family 10h Shanghai CPU.
10536
10537 @item istanbul
10538 AMD Family 10h Istanbul CPU.
10539
10540 @item btver1
10541 AMD Family 14h CPU.
10542
10543 @item amdfam15h
10544 AMD Family 15h CPU.
10545
10546 @item bdver1
10547 AMD Family 15h Bulldozer version 1.
10548
10549 @item bdver2
10550 AMD Family 15h Bulldozer version 2.
10551
10552 @item bdver3
10553 AMD Family 15h Bulldozer version 3.
10554
10555 @item btver2
10556 AMD Family 16h CPU.
10557 @end table
10558
10559 Here is an example:
10560 @smallexample
10561 if (__builtin_cpu_is ("corei7"))
10562 @{
10563 do_corei7 (); // Core i7 specific implementation.
10564 @}
10565 else
10566 @{
10567 do_generic (); // Generic implementation.
10568 @}
10569 @end smallexample
10570 @end deftypefn
10571
10572 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
10573 This function returns a positive integer if the run-time CPU
10574 supports @var{feature}
10575 and returns @code{0} otherwise. The following features can be detected:
10576
10577 @table @samp
10578 @item cmov
10579 CMOV instruction.
10580 @item mmx
10581 MMX instructions.
10582 @item popcnt
10583 POPCNT instruction.
10584 @item sse
10585 SSE instructions.
10586 @item sse2
10587 SSE2 instructions.
10588 @item sse3
10589 SSE3 instructions.
10590 @item ssse3
10591 SSSE3 instructions.
10592 @item sse4.1
10593 SSE4.1 instructions.
10594 @item sse4.2
10595 SSE4.2 instructions.
10596 @item avx
10597 AVX instructions.
10598 @item avx2
10599 AVX2 instructions.
10600 @end table
10601
10602 Here is an example:
10603 @smallexample
10604 if (__builtin_cpu_supports ("popcnt"))
10605 @{
10606 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
10607 @}
10608 else
10609 @{
10610 count = generic_countbits (n); //generic implementation.
10611 @}
10612 @end smallexample
10613 @end deftypefn
10614
10615
10616 The following built-in functions are made available by @option{-mmmx}.
10617 All of them generate the machine instruction that is part of the name.
10618
10619 @smallexample
10620 v8qi __builtin_ia32_paddb (v8qi, v8qi)
10621 v4hi __builtin_ia32_paddw (v4hi, v4hi)
10622 v2si __builtin_ia32_paddd (v2si, v2si)
10623 v8qi __builtin_ia32_psubb (v8qi, v8qi)
10624 v4hi __builtin_ia32_psubw (v4hi, v4hi)
10625 v2si __builtin_ia32_psubd (v2si, v2si)
10626 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
10627 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
10628 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
10629 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
10630 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
10631 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
10632 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
10633 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
10634 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
10635 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
10636 di __builtin_ia32_pand (di, di)
10637 di __builtin_ia32_pandn (di,di)
10638 di __builtin_ia32_por (di, di)
10639 di __builtin_ia32_pxor (di, di)
10640 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
10641 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
10642 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
10643 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
10644 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
10645 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
10646 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
10647 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
10648 v2si __builtin_ia32_punpckhdq (v2si, v2si)
10649 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
10650 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
10651 v2si __builtin_ia32_punpckldq (v2si, v2si)
10652 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
10653 v4hi __builtin_ia32_packssdw (v2si, v2si)
10654 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
10655
10656 v4hi __builtin_ia32_psllw (v4hi, v4hi)
10657 v2si __builtin_ia32_pslld (v2si, v2si)
10658 v1di __builtin_ia32_psllq (v1di, v1di)
10659 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
10660 v2si __builtin_ia32_psrld (v2si, v2si)
10661 v1di __builtin_ia32_psrlq (v1di, v1di)
10662 v4hi __builtin_ia32_psraw (v4hi, v4hi)
10663 v2si __builtin_ia32_psrad (v2si, v2si)
10664 v4hi __builtin_ia32_psllwi (v4hi, int)
10665 v2si __builtin_ia32_pslldi (v2si, int)
10666 v1di __builtin_ia32_psllqi (v1di, int)
10667 v4hi __builtin_ia32_psrlwi (v4hi, int)
10668 v2si __builtin_ia32_psrldi (v2si, int)
10669 v1di __builtin_ia32_psrlqi (v1di, int)
10670 v4hi __builtin_ia32_psrawi (v4hi, int)
10671 v2si __builtin_ia32_psradi (v2si, int)
10672
10673 @end smallexample
10674
10675 The following built-in functions are made available either with
10676 @option{-msse}, or with a combination of @option{-m3dnow} and
10677 @option{-march=athlon}. All of them generate the machine
10678 instruction that is part of the name.
10679
10680 @smallexample
10681 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
10682 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
10683 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
10684 v1di __builtin_ia32_psadbw (v8qi, v8qi)
10685 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
10686 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
10687 v8qi __builtin_ia32_pminub (v8qi, v8qi)
10688 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
10689 int __builtin_ia32_pmovmskb (v8qi)
10690 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
10691 void __builtin_ia32_movntq (di *, di)
10692 void __builtin_ia32_sfence (void)
10693 @end smallexample
10694
10695 The following built-in functions are available when @option{-msse} is used.
10696 All of them generate the machine instruction that is part of the name.
10697
10698 @smallexample
10699 int __builtin_ia32_comieq (v4sf, v4sf)
10700 int __builtin_ia32_comineq (v4sf, v4sf)
10701 int __builtin_ia32_comilt (v4sf, v4sf)
10702 int __builtin_ia32_comile (v4sf, v4sf)
10703 int __builtin_ia32_comigt (v4sf, v4sf)
10704 int __builtin_ia32_comige (v4sf, v4sf)
10705 int __builtin_ia32_ucomieq (v4sf, v4sf)
10706 int __builtin_ia32_ucomineq (v4sf, v4sf)
10707 int __builtin_ia32_ucomilt (v4sf, v4sf)
10708 int __builtin_ia32_ucomile (v4sf, v4sf)
10709 int __builtin_ia32_ucomigt (v4sf, v4sf)
10710 int __builtin_ia32_ucomige (v4sf, v4sf)
10711 v4sf __builtin_ia32_addps (v4sf, v4sf)
10712 v4sf __builtin_ia32_subps (v4sf, v4sf)
10713 v4sf __builtin_ia32_mulps (v4sf, v4sf)
10714 v4sf __builtin_ia32_divps (v4sf, v4sf)
10715 v4sf __builtin_ia32_addss (v4sf, v4sf)
10716 v4sf __builtin_ia32_subss (v4sf, v4sf)
10717 v4sf __builtin_ia32_mulss (v4sf, v4sf)
10718 v4sf __builtin_ia32_divss (v4sf, v4sf)
10719 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
10720 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
10721 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
10722 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
10723 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
10724 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
10725 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
10726 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
10727 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
10728 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
10729 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
10730 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
10731 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
10732 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
10733 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
10734 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
10735 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
10736 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
10737 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
10738 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
10739 v4sf __builtin_ia32_maxps (v4sf, v4sf)
10740 v4sf __builtin_ia32_maxss (v4sf, v4sf)
10741 v4sf __builtin_ia32_minps (v4sf, v4sf)
10742 v4sf __builtin_ia32_minss (v4sf, v4sf)
10743 v4sf __builtin_ia32_andps (v4sf, v4sf)
10744 v4sf __builtin_ia32_andnps (v4sf, v4sf)
10745 v4sf __builtin_ia32_orps (v4sf, v4sf)
10746 v4sf __builtin_ia32_xorps (v4sf, v4sf)
10747 v4sf __builtin_ia32_movss (v4sf, v4sf)
10748 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
10749 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
10750 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
10751 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
10752 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
10753 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
10754 v2si __builtin_ia32_cvtps2pi (v4sf)
10755 int __builtin_ia32_cvtss2si (v4sf)
10756 v2si __builtin_ia32_cvttps2pi (v4sf)
10757 int __builtin_ia32_cvttss2si (v4sf)
10758 v4sf __builtin_ia32_rcpps (v4sf)
10759 v4sf __builtin_ia32_rsqrtps (v4sf)
10760 v4sf __builtin_ia32_sqrtps (v4sf)
10761 v4sf __builtin_ia32_rcpss (v4sf)
10762 v4sf __builtin_ia32_rsqrtss (v4sf)
10763 v4sf __builtin_ia32_sqrtss (v4sf)
10764 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
10765 void __builtin_ia32_movntps (float *, v4sf)
10766 int __builtin_ia32_movmskps (v4sf)
10767 @end smallexample
10768
10769 The following built-in functions are available when @option{-msse} is used.
10770
10771 @table @code
10772 @item v4sf __builtin_ia32_loadups (float *)
10773 Generates the @code{movups} machine instruction as a load from memory.
10774 @item void __builtin_ia32_storeups (float *, v4sf)
10775 Generates the @code{movups} machine instruction as a store to memory.
10776 @item v4sf __builtin_ia32_loadss (float *)
10777 Generates the @code{movss} machine instruction as a load from memory.
10778 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
10779 Generates the @code{movhps} machine instruction as a load from memory.
10780 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
10781 Generates the @code{movlps} machine instruction as a load from memory
10782 @item void __builtin_ia32_storehps (v2sf *, v4sf)
10783 Generates the @code{movhps} machine instruction as a store to memory.
10784 @item void __builtin_ia32_storelps (v2sf *, v4sf)
10785 Generates the @code{movlps} machine instruction as a store to memory.
10786 @end table
10787
10788 The following built-in functions are available when @option{-msse2} is used.
10789 All of them generate the machine instruction that is part of the name.
10790
10791 @smallexample
10792 int __builtin_ia32_comisdeq (v2df, v2df)
10793 int __builtin_ia32_comisdlt (v2df, v2df)
10794 int __builtin_ia32_comisdle (v2df, v2df)
10795 int __builtin_ia32_comisdgt (v2df, v2df)
10796 int __builtin_ia32_comisdge (v2df, v2df)
10797 int __builtin_ia32_comisdneq (v2df, v2df)
10798 int __builtin_ia32_ucomisdeq (v2df, v2df)
10799 int __builtin_ia32_ucomisdlt (v2df, v2df)
10800 int __builtin_ia32_ucomisdle (v2df, v2df)
10801 int __builtin_ia32_ucomisdgt (v2df, v2df)
10802 int __builtin_ia32_ucomisdge (v2df, v2df)
10803 int __builtin_ia32_ucomisdneq (v2df, v2df)
10804 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
10805 v2df __builtin_ia32_cmpltpd (v2df, v2df)
10806 v2df __builtin_ia32_cmplepd (v2df, v2df)
10807 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
10808 v2df __builtin_ia32_cmpgepd (v2df, v2df)
10809 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
10810 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
10811 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
10812 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
10813 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
10814 v2df __builtin_ia32_cmpngepd (v2df, v2df)
10815 v2df __builtin_ia32_cmpordpd (v2df, v2df)
10816 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
10817 v2df __builtin_ia32_cmpltsd (v2df, v2df)
10818 v2df __builtin_ia32_cmplesd (v2df, v2df)
10819 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
10820 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
10821 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
10822 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
10823 v2df __builtin_ia32_cmpordsd (v2df, v2df)
10824 v2di __builtin_ia32_paddq (v2di, v2di)
10825 v2di __builtin_ia32_psubq (v2di, v2di)
10826 v2df __builtin_ia32_addpd (v2df, v2df)
10827 v2df __builtin_ia32_subpd (v2df, v2df)
10828 v2df __builtin_ia32_mulpd (v2df, v2df)
10829 v2df __builtin_ia32_divpd (v2df, v2df)
10830 v2df __builtin_ia32_addsd (v2df, v2df)
10831 v2df __builtin_ia32_subsd (v2df, v2df)
10832 v2df __builtin_ia32_mulsd (v2df, v2df)
10833 v2df __builtin_ia32_divsd (v2df, v2df)
10834 v2df __builtin_ia32_minpd (v2df, v2df)
10835 v2df __builtin_ia32_maxpd (v2df, v2df)
10836 v2df __builtin_ia32_minsd (v2df, v2df)
10837 v2df __builtin_ia32_maxsd (v2df, v2df)
10838 v2df __builtin_ia32_andpd (v2df, v2df)
10839 v2df __builtin_ia32_andnpd (v2df, v2df)
10840 v2df __builtin_ia32_orpd (v2df, v2df)
10841 v2df __builtin_ia32_xorpd (v2df, v2df)
10842 v2df __builtin_ia32_movsd (v2df, v2df)
10843 v2df __builtin_ia32_unpckhpd (v2df, v2df)
10844 v2df __builtin_ia32_unpcklpd (v2df, v2df)
10845 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
10846 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
10847 v4si __builtin_ia32_paddd128 (v4si, v4si)
10848 v2di __builtin_ia32_paddq128 (v2di, v2di)
10849 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
10850 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
10851 v4si __builtin_ia32_psubd128 (v4si, v4si)
10852 v2di __builtin_ia32_psubq128 (v2di, v2di)
10853 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
10854 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
10855 v2di __builtin_ia32_pand128 (v2di, v2di)
10856 v2di __builtin_ia32_pandn128 (v2di, v2di)
10857 v2di __builtin_ia32_por128 (v2di, v2di)
10858 v2di __builtin_ia32_pxor128 (v2di, v2di)
10859 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
10860 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
10861 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
10862 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
10863 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
10864 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
10865 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
10866 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
10867 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
10868 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
10869 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
10870 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
10871 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
10872 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
10873 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
10874 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
10875 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
10876 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
10877 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
10878 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
10879 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
10880 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
10881 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
10882 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
10883 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
10884 v2df __builtin_ia32_loadupd (double *)
10885 void __builtin_ia32_storeupd (double *, v2df)
10886 v2df __builtin_ia32_loadhpd (v2df, double const *)
10887 v2df __builtin_ia32_loadlpd (v2df, double const *)
10888 int __builtin_ia32_movmskpd (v2df)
10889 int __builtin_ia32_pmovmskb128 (v16qi)
10890 void __builtin_ia32_movnti (int *, int)
10891 void __builtin_ia32_movnti64 (long long int *, long long int)
10892 void __builtin_ia32_movntpd (double *, v2df)
10893 void __builtin_ia32_movntdq (v2df *, v2df)
10894 v4si __builtin_ia32_pshufd (v4si, int)
10895 v8hi __builtin_ia32_pshuflw (v8hi, int)
10896 v8hi __builtin_ia32_pshufhw (v8hi, int)
10897 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
10898 v2df __builtin_ia32_sqrtpd (v2df)
10899 v2df __builtin_ia32_sqrtsd (v2df)
10900 v2df __builtin_ia32_shufpd (v2df, v2df, int)
10901 v2df __builtin_ia32_cvtdq2pd (v4si)
10902 v4sf __builtin_ia32_cvtdq2ps (v4si)
10903 v4si __builtin_ia32_cvtpd2dq (v2df)
10904 v2si __builtin_ia32_cvtpd2pi (v2df)
10905 v4sf __builtin_ia32_cvtpd2ps (v2df)
10906 v4si __builtin_ia32_cvttpd2dq (v2df)
10907 v2si __builtin_ia32_cvttpd2pi (v2df)
10908 v2df __builtin_ia32_cvtpi2pd (v2si)
10909 int __builtin_ia32_cvtsd2si (v2df)
10910 int __builtin_ia32_cvttsd2si (v2df)
10911 long long __builtin_ia32_cvtsd2si64 (v2df)
10912 long long __builtin_ia32_cvttsd2si64 (v2df)
10913 v4si __builtin_ia32_cvtps2dq (v4sf)
10914 v2df __builtin_ia32_cvtps2pd (v4sf)
10915 v4si __builtin_ia32_cvttps2dq (v4sf)
10916 v2df __builtin_ia32_cvtsi2sd (v2df, int)
10917 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
10918 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
10919 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
10920 void __builtin_ia32_clflush (const void *)
10921 void __builtin_ia32_lfence (void)
10922 void __builtin_ia32_mfence (void)
10923 v16qi __builtin_ia32_loaddqu (const char *)
10924 void __builtin_ia32_storedqu (char *, v16qi)
10925 v1di __builtin_ia32_pmuludq (v2si, v2si)
10926 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
10927 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
10928 v4si __builtin_ia32_pslld128 (v4si, v4si)
10929 v2di __builtin_ia32_psllq128 (v2di, v2di)
10930 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
10931 v4si __builtin_ia32_psrld128 (v4si, v4si)
10932 v2di __builtin_ia32_psrlq128 (v2di, v2di)
10933 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
10934 v4si __builtin_ia32_psrad128 (v4si, v4si)
10935 v2di __builtin_ia32_pslldqi128 (v2di, int)
10936 v8hi __builtin_ia32_psllwi128 (v8hi, int)
10937 v4si __builtin_ia32_pslldi128 (v4si, int)
10938 v2di __builtin_ia32_psllqi128 (v2di, int)
10939 v2di __builtin_ia32_psrldqi128 (v2di, int)
10940 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
10941 v4si __builtin_ia32_psrldi128 (v4si, int)
10942 v2di __builtin_ia32_psrlqi128 (v2di, int)
10943 v8hi __builtin_ia32_psrawi128 (v8hi, int)
10944 v4si __builtin_ia32_psradi128 (v4si, int)
10945 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
10946 v2di __builtin_ia32_movq128 (v2di)
10947 @end smallexample
10948
10949 The following built-in functions are available when @option{-msse3} is used.
10950 All of them generate the machine instruction that is part of the name.
10951
10952 @smallexample
10953 v2df __builtin_ia32_addsubpd (v2df, v2df)
10954 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
10955 v2df __builtin_ia32_haddpd (v2df, v2df)
10956 v4sf __builtin_ia32_haddps (v4sf, v4sf)
10957 v2df __builtin_ia32_hsubpd (v2df, v2df)
10958 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
10959 v16qi __builtin_ia32_lddqu (char const *)
10960 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
10961 v4sf __builtin_ia32_movshdup (v4sf)
10962 v4sf __builtin_ia32_movsldup (v4sf)
10963 void __builtin_ia32_mwait (unsigned int, unsigned int)
10964 @end smallexample
10965
10966 The following built-in functions are available when @option{-mssse3} is used.
10967 All of them generate the machine instruction that is part of the name.
10968
10969 @smallexample
10970 v2si __builtin_ia32_phaddd (v2si, v2si)
10971 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
10972 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
10973 v2si __builtin_ia32_phsubd (v2si, v2si)
10974 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
10975 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
10976 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
10977 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
10978 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
10979 v8qi __builtin_ia32_psignb (v8qi, v8qi)
10980 v2si __builtin_ia32_psignd (v2si, v2si)
10981 v4hi __builtin_ia32_psignw (v4hi, v4hi)
10982 v1di __builtin_ia32_palignr (v1di, v1di, int)
10983 v8qi __builtin_ia32_pabsb (v8qi)
10984 v2si __builtin_ia32_pabsd (v2si)
10985 v4hi __builtin_ia32_pabsw (v4hi)
10986 @end smallexample
10987
10988 The following built-in functions are available when @option{-mssse3} is used.
10989 All of them generate the machine instruction that is part of the name.
10990
10991 @smallexample
10992 v4si __builtin_ia32_phaddd128 (v4si, v4si)
10993 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
10994 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
10995 v4si __builtin_ia32_phsubd128 (v4si, v4si)
10996 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
10997 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
10998 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
10999 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
11000 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
11001 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
11002 v4si __builtin_ia32_psignd128 (v4si, v4si)
11003 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
11004 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
11005 v16qi __builtin_ia32_pabsb128 (v16qi)
11006 v4si __builtin_ia32_pabsd128 (v4si)
11007 v8hi __builtin_ia32_pabsw128 (v8hi)
11008 @end smallexample
11009
11010 The following built-in functions are available when @option{-msse4.1} is
11011 used. All of them generate the machine instruction that is part of the
11012 name.
11013
11014 @smallexample
11015 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
11016 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
11017 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
11018 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
11019 v2df __builtin_ia32_dppd (v2df, v2df, const int)
11020 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
11021 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
11022 v2di __builtin_ia32_movntdqa (v2di *);
11023 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
11024 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
11025 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
11026 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
11027 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
11028 v8hi __builtin_ia32_phminposuw128 (v8hi)
11029 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
11030 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
11031 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
11032 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
11033 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
11034 v4si __builtin_ia32_pminsd128 (v4si, v4si)
11035 v4si __builtin_ia32_pminud128 (v4si, v4si)
11036 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
11037 v4si __builtin_ia32_pmovsxbd128 (v16qi)
11038 v2di __builtin_ia32_pmovsxbq128 (v16qi)
11039 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
11040 v2di __builtin_ia32_pmovsxdq128 (v4si)
11041 v4si __builtin_ia32_pmovsxwd128 (v8hi)
11042 v2di __builtin_ia32_pmovsxwq128 (v8hi)
11043 v4si __builtin_ia32_pmovzxbd128 (v16qi)
11044 v2di __builtin_ia32_pmovzxbq128 (v16qi)
11045 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
11046 v2di __builtin_ia32_pmovzxdq128 (v4si)
11047 v4si __builtin_ia32_pmovzxwd128 (v8hi)
11048 v2di __builtin_ia32_pmovzxwq128 (v8hi)
11049 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
11050 v4si __builtin_ia32_pmulld128 (v4si, v4si)
11051 int __builtin_ia32_ptestc128 (v2di, v2di)
11052 int __builtin_ia32_ptestnzc128 (v2di, v2di)
11053 int __builtin_ia32_ptestz128 (v2di, v2di)
11054 v2df __builtin_ia32_roundpd (v2df, const int)
11055 v4sf __builtin_ia32_roundps (v4sf, const int)
11056 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
11057 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
11058 @end smallexample
11059
11060 The following built-in functions are available when @option{-msse4.1} is
11061 used.
11062
11063 @table @code
11064 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
11065 Generates the @code{insertps} machine instruction.
11066 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
11067 Generates the @code{pextrb} machine instruction.
11068 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
11069 Generates the @code{pinsrb} machine instruction.
11070 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
11071 Generates the @code{pinsrd} machine instruction.
11072 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
11073 Generates the @code{pinsrq} machine instruction in 64bit mode.
11074 @end table
11075
11076 The following built-in functions are changed to generate new SSE4.1
11077 instructions when @option{-msse4.1} is used.
11078
11079 @table @code
11080 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
11081 Generates the @code{extractps} machine instruction.
11082 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
11083 Generates the @code{pextrd} machine instruction.
11084 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
11085 Generates the @code{pextrq} machine instruction in 64bit mode.
11086 @end table
11087
11088 The following built-in functions are available when @option{-msse4.2} is
11089 used. All of them generate the machine instruction that is part of the
11090 name.
11091
11092 @smallexample
11093 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
11094 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
11095 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
11096 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
11097 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
11098 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
11099 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
11100 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
11101 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
11102 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
11103 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
11104 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
11105 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
11106 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
11107 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
11108 @end smallexample
11109
11110 The following built-in functions are available when @option{-msse4.2} is
11111 used.
11112
11113 @table @code
11114 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
11115 Generates the @code{crc32b} machine instruction.
11116 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
11117 Generates the @code{crc32w} machine instruction.
11118 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
11119 Generates the @code{crc32l} machine instruction.
11120 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
11121 Generates the @code{crc32q} machine instruction.
11122 @end table
11123
11124 The following built-in functions are changed to generate new SSE4.2
11125 instructions when @option{-msse4.2} is used.
11126
11127 @table @code
11128 @item int __builtin_popcount (unsigned int)
11129 Generates the @code{popcntl} machine instruction.
11130 @item int __builtin_popcountl (unsigned long)
11131 Generates the @code{popcntl} or @code{popcntq} machine instruction,
11132 depending on the size of @code{unsigned long}.
11133 @item int __builtin_popcountll (unsigned long long)
11134 Generates the @code{popcntq} machine instruction.
11135 @end table
11136
11137 The following built-in functions are available when @option{-mavx} is
11138 used. All of them generate the machine instruction that is part of the
11139 name.
11140
11141 @smallexample
11142 v4df __builtin_ia32_addpd256 (v4df,v4df)
11143 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
11144 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
11145 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
11146 v4df __builtin_ia32_andnpd256 (v4df,v4df)
11147 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
11148 v4df __builtin_ia32_andpd256 (v4df,v4df)
11149 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
11150 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
11151 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
11152 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
11153 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
11154 v2df __builtin_ia32_cmppd (v2df,v2df,int)
11155 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
11156 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
11157 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
11158 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
11159 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
11160 v4df __builtin_ia32_cvtdq2pd256 (v4si)
11161 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
11162 v4si __builtin_ia32_cvtpd2dq256 (v4df)
11163 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
11164 v8si __builtin_ia32_cvtps2dq256 (v8sf)
11165 v4df __builtin_ia32_cvtps2pd256 (v4sf)
11166 v4si __builtin_ia32_cvttpd2dq256 (v4df)
11167 v8si __builtin_ia32_cvttps2dq256 (v8sf)
11168 v4df __builtin_ia32_divpd256 (v4df,v4df)
11169 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
11170 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
11171 v4df __builtin_ia32_haddpd256 (v4df,v4df)
11172 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
11173 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
11174 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
11175 v32qi __builtin_ia32_lddqu256 (pcchar)
11176 v32qi __builtin_ia32_loaddqu256 (pcchar)
11177 v4df __builtin_ia32_loadupd256 (pcdouble)
11178 v8sf __builtin_ia32_loadups256 (pcfloat)
11179 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
11180 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
11181 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
11182 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
11183 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
11184 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
11185 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
11186 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
11187 v4df __builtin_ia32_maxpd256 (v4df,v4df)
11188 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
11189 v4df __builtin_ia32_minpd256 (v4df,v4df)
11190 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
11191 v4df __builtin_ia32_movddup256 (v4df)
11192 int __builtin_ia32_movmskpd256 (v4df)
11193 int __builtin_ia32_movmskps256 (v8sf)
11194 v8sf __builtin_ia32_movshdup256 (v8sf)
11195 v8sf __builtin_ia32_movsldup256 (v8sf)
11196 v4df __builtin_ia32_mulpd256 (v4df,v4df)
11197 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
11198 v4df __builtin_ia32_orpd256 (v4df,v4df)
11199 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
11200 v2df __builtin_ia32_pd_pd256 (v4df)
11201 v4df __builtin_ia32_pd256_pd (v2df)
11202 v4sf __builtin_ia32_ps_ps256 (v8sf)
11203 v8sf __builtin_ia32_ps256_ps (v4sf)
11204 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
11205 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
11206 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
11207 v8sf __builtin_ia32_rcpps256 (v8sf)
11208 v4df __builtin_ia32_roundpd256 (v4df,int)
11209 v8sf __builtin_ia32_roundps256 (v8sf,int)
11210 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
11211 v8sf __builtin_ia32_rsqrtps256 (v8sf)
11212 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
11213 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
11214 v4si __builtin_ia32_si_si256 (v8si)
11215 v8si __builtin_ia32_si256_si (v4si)
11216 v4df __builtin_ia32_sqrtpd256 (v4df)
11217 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
11218 v8sf __builtin_ia32_sqrtps256 (v8sf)
11219 void __builtin_ia32_storedqu256 (pchar,v32qi)
11220 void __builtin_ia32_storeupd256 (pdouble,v4df)
11221 void __builtin_ia32_storeups256 (pfloat,v8sf)
11222 v4df __builtin_ia32_subpd256 (v4df,v4df)
11223 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
11224 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
11225 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
11226 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
11227 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
11228 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
11229 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
11230 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
11231 v4sf __builtin_ia32_vbroadcastss (pcfloat)
11232 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
11233 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
11234 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
11235 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
11236 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
11237 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
11238 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
11239 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
11240 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
11241 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
11242 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
11243 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
11244 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
11245 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
11246 v2df __builtin_ia32_vpermilpd (v2df,int)
11247 v4df __builtin_ia32_vpermilpd256 (v4df,int)
11248 v4sf __builtin_ia32_vpermilps (v4sf,int)
11249 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
11250 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
11251 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
11252 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
11253 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
11254 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
11255 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
11256 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
11257 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
11258 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
11259 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
11260 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
11261 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
11262 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
11263 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
11264 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
11265 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
11266 void __builtin_ia32_vzeroall (void)
11267 void __builtin_ia32_vzeroupper (void)
11268 v4df __builtin_ia32_xorpd256 (v4df,v4df)
11269 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
11270 @end smallexample
11271
11272 The following built-in functions are available when @option{-mavx2} is
11273 used. All of them generate the machine instruction that is part of the
11274 name.
11275
11276 @smallexample
11277 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,v32qi,int)
11278 v32qi __builtin_ia32_pabsb256 (v32qi)
11279 v16hi __builtin_ia32_pabsw256 (v16hi)
11280 v8si __builtin_ia32_pabsd256 (v8si)
11281 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
11282 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
11283 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
11284 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
11285 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
11286 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
11287 v8si __builtin_ia32_paddd256 (v8si,v8si)
11288 v4di __builtin_ia32_paddq256 (v4di,v4di)
11289 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
11290 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
11291 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
11292 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
11293 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
11294 v4di __builtin_ia32_andsi256 (v4di,v4di)
11295 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
11296 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
11297 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
11298 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
11299 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
11300 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
11301 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
11302 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
11303 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
11304 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
11305 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
11306 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
11307 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
11308 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
11309 v8si __builtin_ia32_phaddd256 (v8si,v8si)
11310 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
11311 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
11312 v8si __builtin_ia32_phsubd256 (v8si,v8si)
11313 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
11314 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
11315 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
11316 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
11317 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
11318 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
11319 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
11320 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
11321 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
11322 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
11323 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
11324 v8si __builtin_ia32_pminsd256 (v8si,v8si)
11325 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
11326 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
11327 v8si __builtin_ia32_pminud256 (v8si,v8si)
11328 int __builtin_ia32_pmovmskb256 (v32qi)
11329 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
11330 v8si __builtin_ia32_pmovsxbd256 (v16qi)
11331 v4di __builtin_ia32_pmovsxbq256 (v16qi)
11332 v8si __builtin_ia32_pmovsxwd256 (v8hi)
11333 v4di __builtin_ia32_pmovsxwq256 (v8hi)
11334 v4di __builtin_ia32_pmovsxdq256 (v4si)
11335 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
11336 v8si __builtin_ia32_pmovzxbd256 (v16qi)
11337 v4di __builtin_ia32_pmovzxbq256 (v16qi)
11338 v8si __builtin_ia32_pmovzxwd256 (v8hi)
11339 v4di __builtin_ia32_pmovzxwq256 (v8hi)
11340 v4di __builtin_ia32_pmovzxdq256 (v4si)
11341 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
11342 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
11343 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
11344 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
11345 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
11346 v8si __builtin_ia32_pmulld256 (v8si,v8si)
11347 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
11348 v4di __builtin_ia32_por256 (v4di,v4di)
11349 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
11350 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
11351 v8si __builtin_ia32_pshufd256 (v8si,int)
11352 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
11353 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
11354 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
11355 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
11356 v8si __builtin_ia32_psignd256 (v8si,v8si)
11357 v4di __builtin_ia32_pslldqi256 (v4di,int)
11358 v16hi __builtin_ia32_psllwi256 (16hi,int)
11359 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
11360 v8si __builtin_ia32_pslldi256 (v8si,int)
11361 v8si __builtin_ia32_pslld256(v8si,v4si)
11362 v4di __builtin_ia32_psllqi256 (v4di,int)
11363 v4di __builtin_ia32_psllq256(v4di,v2di)
11364 v16hi __builtin_ia32_psrawi256 (v16hi,int)
11365 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
11366 v8si __builtin_ia32_psradi256 (v8si,int)
11367 v8si __builtin_ia32_psrad256 (v8si,v4si)
11368 v4di __builtin_ia32_psrldqi256 (v4di, int)
11369 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
11370 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
11371 v8si __builtin_ia32_psrldi256 (v8si,int)
11372 v8si __builtin_ia32_psrld256 (v8si,v4si)
11373 v4di __builtin_ia32_psrlqi256 (v4di,int)
11374 v4di __builtin_ia32_psrlq256(v4di,v2di)
11375 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
11376 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
11377 v8si __builtin_ia32_psubd256 (v8si,v8si)
11378 v4di __builtin_ia32_psubq256 (v4di,v4di)
11379 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
11380 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
11381 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
11382 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
11383 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
11384 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
11385 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
11386 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
11387 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
11388 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
11389 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
11390 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
11391 v4di __builtin_ia32_pxor256 (v4di,v4di)
11392 v4di __builtin_ia32_movntdqa256 (pv4di)
11393 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
11394 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
11395 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
11396 v4di __builtin_ia32_vbroadcastsi256 (v2di)
11397 v4si __builtin_ia32_pblendd128 (v4si,v4si)
11398 v8si __builtin_ia32_pblendd256 (v8si,v8si)
11399 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
11400 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
11401 v8si __builtin_ia32_pbroadcastd256 (v4si)
11402 v4di __builtin_ia32_pbroadcastq256 (v2di)
11403 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
11404 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
11405 v4si __builtin_ia32_pbroadcastd128 (v4si)
11406 v2di __builtin_ia32_pbroadcastq128 (v2di)
11407 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
11408 v4df __builtin_ia32_permdf256 (v4df,int)
11409 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
11410 v4di __builtin_ia32_permdi256 (v4di,int)
11411 v4di __builtin_ia32_permti256 (v4di,v4di,int)
11412 v4di __builtin_ia32_extract128i256 (v4di,int)
11413 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
11414 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
11415 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
11416 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
11417 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
11418 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
11419 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
11420 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
11421 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
11422 v8si __builtin_ia32_psllv8si (v8si,v8si)
11423 v4si __builtin_ia32_psllv4si (v4si,v4si)
11424 v4di __builtin_ia32_psllv4di (v4di,v4di)
11425 v2di __builtin_ia32_psllv2di (v2di,v2di)
11426 v8si __builtin_ia32_psrav8si (v8si,v8si)
11427 v4si __builtin_ia32_psrav4si (v4si,v4si)
11428 v8si __builtin_ia32_psrlv8si (v8si,v8si)
11429 v4si __builtin_ia32_psrlv4si (v4si,v4si)
11430 v4di __builtin_ia32_psrlv4di (v4di,v4di)
11431 v2di __builtin_ia32_psrlv2di (v2di,v2di)
11432 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
11433 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
11434 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
11435 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
11436 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
11437 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
11438 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
11439 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
11440 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
11441 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
11442 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
11443 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
11444 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
11445 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
11446 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
11447 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
11448 @end smallexample
11449
11450 The following built-in functions are available when @option{-maes} is
11451 used. All of them generate the machine instruction that is part of the
11452 name.
11453
11454 @smallexample
11455 v2di __builtin_ia32_aesenc128 (v2di, v2di)
11456 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
11457 v2di __builtin_ia32_aesdec128 (v2di, v2di)
11458 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
11459 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
11460 v2di __builtin_ia32_aesimc128 (v2di)
11461 @end smallexample
11462
11463 The following built-in function is available when @option{-mpclmul} is
11464 used.
11465
11466 @table @code
11467 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
11468 Generates the @code{pclmulqdq} machine instruction.
11469 @end table
11470
11471 The following built-in function is available when @option{-mfsgsbase} is
11472 used. All of them generate the machine instruction that is part of the
11473 name.
11474
11475 @smallexample
11476 unsigned int __builtin_ia32_rdfsbase32 (void)
11477 unsigned long long __builtin_ia32_rdfsbase64 (void)
11478 unsigned int __builtin_ia32_rdgsbase32 (void)
11479 unsigned long long __builtin_ia32_rdgsbase64 (void)
11480 void _writefsbase_u32 (unsigned int)
11481 void _writefsbase_u64 (unsigned long long)
11482 void _writegsbase_u32 (unsigned int)
11483 void _writegsbase_u64 (unsigned long long)
11484 @end smallexample
11485
11486 The following built-in function is available when @option{-mrdrnd} is
11487 used. All of them generate the machine instruction that is part of the
11488 name.
11489
11490 @smallexample
11491 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
11492 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
11493 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
11494 @end smallexample
11495
11496 The following built-in functions are available when @option{-msse4a} is used.
11497 All of them generate the machine instruction that is part of the name.
11498
11499 @smallexample
11500 void __builtin_ia32_movntsd (double *, v2df)
11501 void __builtin_ia32_movntss (float *, v4sf)
11502 v2di __builtin_ia32_extrq (v2di, v16qi)
11503 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
11504 v2di __builtin_ia32_insertq (v2di, v2di)
11505 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
11506 @end smallexample
11507
11508 The following built-in functions are available when @option{-mxop} is used.
11509 @smallexample
11510 v2df __builtin_ia32_vfrczpd (v2df)
11511 v4sf __builtin_ia32_vfrczps (v4sf)
11512 v2df __builtin_ia32_vfrczsd (v2df, v2df)
11513 v4sf __builtin_ia32_vfrczss (v4sf, v4sf)
11514 v4df __builtin_ia32_vfrczpd256 (v4df)
11515 v8sf __builtin_ia32_vfrczps256 (v8sf)
11516 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
11517 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
11518 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
11519 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
11520 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
11521 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
11522 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
11523 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
11524 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
11525 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
11526 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
11527 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
11528 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
11529 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
11530 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
11531 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
11532 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
11533 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
11534 v4si __builtin_ia32_vpcomequd (v4si, v4si)
11535 v2di __builtin_ia32_vpcomequq (v2di, v2di)
11536 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
11537 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
11538 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
11539 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
11540 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
11541 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
11542 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
11543 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
11544 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
11545 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
11546 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
11547 v4si __builtin_ia32_vpcomged (v4si, v4si)
11548 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
11549 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
11550 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
11551 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
11552 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
11553 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
11554 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
11555 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
11556 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
11557 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
11558 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
11559 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
11560 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
11561 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
11562 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
11563 v4si __builtin_ia32_vpcomled (v4si, v4si)
11564 v2di __builtin_ia32_vpcomleq (v2di, v2di)
11565 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
11566 v4si __builtin_ia32_vpcomleud (v4si, v4si)
11567 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
11568 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
11569 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
11570 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
11571 v4si __builtin_ia32_vpcomltd (v4si, v4si)
11572 v2di __builtin_ia32_vpcomltq (v2di, v2di)
11573 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
11574 v4si __builtin_ia32_vpcomltud (v4si, v4si)
11575 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
11576 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
11577 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
11578 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
11579 v4si __builtin_ia32_vpcomned (v4si, v4si)
11580 v2di __builtin_ia32_vpcomneq (v2di, v2di)
11581 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
11582 v4si __builtin_ia32_vpcomneud (v4si, v4si)
11583 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
11584 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
11585 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
11586 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
11587 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
11588 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
11589 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
11590 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
11591 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
11592 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
11593 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
11594 v4si __builtin_ia32_vphaddbd (v16qi)
11595 v2di __builtin_ia32_vphaddbq (v16qi)
11596 v8hi __builtin_ia32_vphaddbw (v16qi)
11597 v2di __builtin_ia32_vphadddq (v4si)
11598 v4si __builtin_ia32_vphaddubd (v16qi)
11599 v2di __builtin_ia32_vphaddubq (v16qi)
11600 v8hi __builtin_ia32_vphaddubw (v16qi)
11601 v2di __builtin_ia32_vphaddudq (v4si)
11602 v4si __builtin_ia32_vphadduwd (v8hi)
11603 v2di __builtin_ia32_vphadduwq (v8hi)
11604 v4si __builtin_ia32_vphaddwd (v8hi)
11605 v2di __builtin_ia32_vphaddwq (v8hi)
11606 v8hi __builtin_ia32_vphsubbw (v16qi)
11607 v2di __builtin_ia32_vphsubdq (v4si)
11608 v4si __builtin_ia32_vphsubwd (v8hi)
11609 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
11610 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
11611 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
11612 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
11613 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
11614 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
11615 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
11616 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
11617 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
11618 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
11619 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
11620 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
11621 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
11622 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
11623 v4si __builtin_ia32_vprotd (v4si, v4si)
11624 v2di __builtin_ia32_vprotq (v2di, v2di)
11625 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
11626 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
11627 v4si __builtin_ia32_vpshad (v4si, v4si)
11628 v2di __builtin_ia32_vpshaq (v2di, v2di)
11629 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
11630 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
11631 v4si __builtin_ia32_vpshld (v4si, v4si)
11632 v2di __builtin_ia32_vpshlq (v2di, v2di)
11633 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
11634 @end smallexample
11635
11636 The following built-in functions are available when @option{-mfma4} is used.
11637 All of them generate the machine instruction that is part of the name.
11638
11639 @smallexample
11640 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
11641 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
11642 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
11643 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
11644 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
11645 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
11646 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
11647 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
11648 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
11649 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
11650 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
11651 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
11652 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
11653 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
11654 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
11655 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
11656 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
11657 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
11658 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
11659 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
11660 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
11661 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
11662 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
11663 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
11664 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
11665 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
11666 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
11667 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
11668 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
11669 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
11670 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
11671 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
11672
11673 @end smallexample
11674
11675 The following built-in functions are available when @option{-mlwp} is used.
11676
11677 @smallexample
11678 void __builtin_ia32_llwpcb16 (void *);
11679 void __builtin_ia32_llwpcb32 (void *);
11680 void __builtin_ia32_llwpcb64 (void *);
11681 void * __builtin_ia32_llwpcb16 (void);
11682 void * __builtin_ia32_llwpcb32 (void);
11683 void * __builtin_ia32_llwpcb64 (void);
11684 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
11685 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
11686 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
11687 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
11688 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
11689 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
11690 @end smallexample
11691
11692 The following built-in functions are available when @option{-mbmi} is used.
11693 All of them generate the machine instruction that is part of the name.
11694 @smallexample
11695 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
11696 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
11697 @end smallexample
11698
11699 The following built-in functions are available when @option{-mbmi2} is used.
11700 All of them generate the machine instruction that is part of the name.
11701 @smallexample
11702 unsigned int _bzhi_u32 (unsigned int, unsigned int)
11703 unsigned int _pdep_u32 (unsigned int, unsigned int)
11704 unsigned int _pext_u32 (unsigned int, unsigned int)
11705 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
11706 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
11707 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
11708 @end smallexample
11709
11710 The following built-in functions are available when @option{-mlzcnt} is used.
11711 All of them generate the machine instruction that is part of the name.
11712 @smallexample
11713 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
11714 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
11715 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
11716 @end smallexample
11717
11718 The following built-in functions are available when @option{-mfxsr} is used.
11719 All of them generate the machine instruction that is part of the name.
11720 @smallexample
11721 void __builtin_ia32_fxsave (void *)
11722 void __builtin_ia32_fxrstor (void *)
11723 void __builtin_ia32_fxsave64 (void *)
11724 void __builtin_ia32_fxrstor64 (void *)
11725 @end smallexample
11726
11727 The following built-in functions are available when @option{-mxsave} is used.
11728 All of them generate the machine instruction that is part of the name.
11729 @smallexample
11730 void __builtin_ia32_xsave (void *, long long)
11731 void __builtin_ia32_xrstor (void *, long long)
11732 void __builtin_ia32_xsave64 (void *, long long)
11733 void __builtin_ia32_xrstor64 (void *, long long)
11734 @end smallexample
11735
11736 The following built-in functions are available when @option{-mxsaveopt} is used.
11737 All of them generate the machine instruction that is part of the name.
11738 @smallexample
11739 void __builtin_ia32_xsaveopt (void *, long long)
11740 void __builtin_ia32_xsaveopt64 (void *, long long)
11741 @end smallexample
11742
11743 The following built-in functions are available when @option{-mtbm} is used.
11744 Both of them generate the immediate form of the bextr machine instruction.
11745 @smallexample
11746 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
11747 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
11748 @end smallexample
11749
11750
11751 The following built-in functions are available when @option{-m3dnow} is used.
11752 All of them generate the machine instruction that is part of the name.
11753
11754 @smallexample
11755 void __builtin_ia32_femms (void)
11756 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
11757 v2si __builtin_ia32_pf2id (v2sf)
11758 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
11759 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
11760 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
11761 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
11762 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
11763 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
11764 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
11765 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
11766 v2sf __builtin_ia32_pfrcp (v2sf)
11767 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
11768 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
11769 v2sf __builtin_ia32_pfrsqrt (v2sf)
11770 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
11771 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
11772 v2sf __builtin_ia32_pi2fd (v2si)
11773 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
11774 @end smallexample
11775
11776 The following built-in functions are available when both @option{-m3dnow}
11777 and @option{-march=athlon} are used. All of them generate the machine
11778 instruction that is part of the name.
11779
11780 @smallexample
11781 v2si __builtin_ia32_pf2iw (v2sf)
11782 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
11783 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
11784 v2sf __builtin_ia32_pi2fw (v2si)
11785 v2sf __builtin_ia32_pswapdsf (v2sf)
11786 v2si __builtin_ia32_pswapdsi (v2si)
11787 @end smallexample
11788
11789 The following built-in functions are available when @option{-mrtm} is used
11790 They are used for restricted transactional memory. These are the internal
11791 low level functions. Normally the functions in
11792 @ref{X86 transactional memory intrinsics} should be used instead.
11793
11794 @smallexample
11795 int __builtin_ia32_xbegin ()
11796 void __builtin_ia32_xend ()
11797 void __builtin_ia32_xabort (status)
11798 int __builtin_ia32_xtest ()
11799 @end smallexample
11800
11801 @node X86 transactional memory intrinsics
11802 @subsection X86 transaction memory intrinsics
11803
11804 Hardware transactional memory intrinsics for i386. These allow to use
11805 memory transactions with RTM (Restricted Transactional Memory).
11806 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
11807 This support is enabled with the @option{-mrtm} option.
11808
11809 A memory transaction commits all changes to memory in an atomic way,
11810 as visible to other threads. If the transaction fails it is rolled back
11811 and all side effects discarded.
11812
11813 Generally there is no guarantee that a memory transaction ever succeeds
11814 and suitable fallback code always needs to be supplied.
11815
11816 @deftypefn {RTM Function} {unsigned} _xbegin ()
11817 Start a RTM (Restricted Transactional Memory) transaction.
11818 Returns _XBEGIN_STARTED when the transaction
11819 started successfully (note this is not 0, so the constant has to be
11820 explicitely tested). When the transaction aborts all side effects
11821 are undone and an abort code is returned. There is no guarantee
11822 any transaction ever succeeds, so there always needs to be a valid
11823 tested fallback path.
11824 @end deftypefn
11825
11826 @smallexample
11827 #include <immintrin.h>
11828
11829 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
11830 ... transaction code...
11831 _xend ();
11832 @} else @{
11833 ... non transactional fallback path...
11834 @}
11835 @end smallexample
11836
11837 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
11838
11839 @table @code
11840 @item _XABORT_EXPLICIT
11841 Transaction explicitely aborted with @code{_xabort}. The parameter passed
11842 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
11843 @item _XABORT_RETRY
11844 Transaction retry is possible.
11845 @item _XABORT_CONFLICT
11846 Transaction abort due to a memory conflict with another thread
11847 @item _XABORT_CAPACITY
11848 Transaction abort due to the transaction using too much memory
11849 @item _XABORT_DEBUG
11850 Transaction abort due to a debug trap
11851 @item _XABORT_NESTED
11852 Transaction abort in a inner nested transaction
11853 @end table
11854
11855 @deftypefn {RTM Function} {void} _xend ()
11856 Commit the current transaction. When no transaction is active this will
11857 fault. All memory side effects of the transactions will become visible
11858 to other threads in an atomic matter.
11859 @end deftypefn
11860
11861 @deftypefn {RTM Function} {int} _xtest ()
11862 Return a value not zero when a transaction is currently active, otherwise 0.
11863 @end deftypefn
11864
11865 @deftypefn {RTM Function} {void} _xabort (status)
11866 Abort the current transaction. When no transaction is active this is a no-op.
11867 status must be a 8bit constant, that is included in the status code returned
11868 by @code{_xbegin}
11869 @end deftypefn
11870
11871 @node MIPS DSP Built-in Functions
11872 @subsection MIPS DSP Built-in Functions
11873
11874 The MIPS DSP Application-Specific Extension (ASE) includes new
11875 instructions that are designed to improve the performance of DSP and
11876 media applications. It provides instructions that operate on packed
11877 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
11878
11879 GCC supports MIPS DSP operations using both the generic
11880 vector extensions (@pxref{Vector Extensions}) and a collection of
11881 MIPS-specific built-in functions. Both kinds of support are
11882 enabled by the @option{-mdsp} command-line option.
11883
11884 Revision 2 of the ASE was introduced in the second half of 2006.
11885 This revision adds extra instructions to the original ASE, but is
11886 otherwise backwards-compatible with it. You can select revision 2
11887 using the command-line option @option{-mdspr2}; this option implies
11888 @option{-mdsp}.
11889
11890 The SCOUNT and POS bits of the DSP control register are global. The
11891 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
11892 POS bits. During optimization, the compiler does not delete these
11893 instructions and it does not delete calls to functions containing
11894 these instructions.
11895
11896 At present, GCC only provides support for operations on 32-bit
11897 vectors. The vector type associated with 8-bit integer data is
11898 usually called @code{v4i8}, the vector type associated with Q7
11899 is usually called @code{v4q7}, the vector type associated with 16-bit
11900 integer data is usually called @code{v2i16}, and the vector type
11901 associated with Q15 is usually called @code{v2q15}. They can be
11902 defined in C as follows:
11903
11904 @smallexample
11905 typedef signed char v4i8 __attribute__ ((vector_size(4)));
11906 typedef signed char v4q7 __attribute__ ((vector_size(4)));
11907 typedef short v2i16 __attribute__ ((vector_size(4)));
11908 typedef short v2q15 __attribute__ ((vector_size(4)));
11909 @end smallexample
11910
11911 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
11912 initialized in the same way as aggregates. For example:
11913
11914 @smallexample
11915 v4i8 a = @{1, 2, 3, 4@};
11916 v4i8 b;
11917 b = (v4i8) @{5, 6, 7, 8@};
11918
11919 v2q15 c = @{0x0fcb, 0x3a75@};
11920 v2q15 d;
11921 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
11922 @end smallexample
11923
11924 @emph{Note:} The CPU's endianness determines the order in which values
11925 are packed. On little-endian targets, the first value is the least
11926 significant and the last value is the most significant. The opposite
11927 order applies to big-endian targets. For example, the code above
11928 sets the lowest byte of @code{a} to @code{1} on little-endian targets
11929 and @code{4} on big-endian targets.
11930
11931 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
11932 representation. As shown in this example, the integer representation
11933 of a Q7 value can be obtained by multiplying the fractional value by
11934 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
11935 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
11936 @code{0x1.0p31}.
11937
11938 The table below lists the @code{v4i8} and @code{v2q15} operations for which
11939 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
11940 and @code{c} and @code{d} are @code{v2q15} values.
11941
11942 @multitable @columnfractions .50 .50
11943 @item C code @tab MIPS instruction
11944 @item @code{a + b} @tab @code{addu.qb}
11945 @item @code{c + d} @tab @code{addq.ph}
11946 @item @code{a - b} @tab @code{subu.qb}
11947 @item @code{c - d} @tab @code{subq.ph}
11948 @end multitable
11949
11950 The table below lists the @code{v2i16} operation for which
11951 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
11952 @code{v2i16} values.
11953
11954 @multitable @columnfractions .50 .50
11955 @item C code @tab MIPS instruction
11956 @item @code{e * f} @tab @code{mul.ph}
11957 @end multitable
11958
11959 It is easier to describe the DSP built-in functions if we first define
11960 the following types:
11961
11962 @smallexample
11963 typedef int q31;
11964 typedef int i32;
11965 typedef unsigned int ui32;
11966 typedef long long a64;
11967 @end smallexample
11968
11969 @code{q31} and @code{i32} are actually the same as @code{int}, but we
11970 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
11971 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
11972 @code{long long}, but we use @code{a64} to indicate values that are
11973 placed in one of the four DSP accumulators (@code{$ac0},
11974 @code{$ac1}, @code{$ac2} or @code{$ac3}).
11975
11976 Also, some built-in functions prefer or require immediate numbers as
11977 parameters, because the corresponding DSP instructions accept both immediate
11978 numbers and register operands, or accept immediate numbers only. The
11979 immediate parameters are listed as follows.
11980
11981 @smallexample
11982 imm0_3: 0 to 3.
11983 imm0_7: 0 to 7.
11984 imm0_15: 0 to 15.
11985 imm0_31: 0 to 31.
11986 imm0_63: 0 to 63.
11987 imm0_255: 0 to 255.
11988 imm_n32_31: -32 to 31.
11989 imm_n512_511: -512 to 511.
11990 @end smallexample
11991
11992 The following built-in functions map directly to a particular MIPS DSP
11993 instruction. Please refer to the architecture specification
11994 for details on what each instruction does.
11995
11996 @smallexample
11997 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
11998 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
11999 q31 __builtin_mips_addq_s_w (q31, q31)
12000 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12001 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12002 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12003 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12004 q31 __builtin_mips_subq_s_w (q31, q31)
12005 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12006 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12007 i32 __builtin_mips_addsc (i32, i32)
12008 i32 __builtin_mips_addwc (i32, i32)
12009 i32 __builtin_mips_modsub (i32, i32)
12010 i32 __builtin_mips_raddu_w_qb (v4i8)
12011 v2q15 __builtin_mips_absq_s_ph (v2q15)
12012 q31 __builtin_mips_absq_s_w (q31)
12013 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12014 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12015 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12016 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12017 q31 __builtin_mips_preceq_w_phl (v2q15)
12018 q31 __builtin_mips_preceq_w_phr (v2q15)
12019 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12020 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12021 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12022 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12023 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12024 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12025 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12026 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12027 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12028 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12029 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12030 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12031 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12032 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12033 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12034 q31 __builtin_mips_shll_s_w (q31, i32)
12035 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12036 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12037 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12038 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12039 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12040 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12041 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12042 q31 __builtin_mips_shra_r_w (q31, i32)
12043 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12044 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12045 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12046 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12047 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12048 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12049 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12050 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12051 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12052 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12053 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12054 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12055 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12056 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12057 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12058 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12059 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12060 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12061 i32 __builtin_mips_bitrev (i32)
12062 i32 __builtin_mips_insv (i32, i32)
12063 v4i8 __builtin_mips_repl_qb (imm0_255)
12064 v4i8 __builtin_mips_repl_qb (i32)
12065 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12066 v2q15 __builtin_mips_repl_ph (i32)
12067 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12068 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12069 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12070 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12071 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12072 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12073 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
12074 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
12075 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
12076 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
12077 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
12078 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
12079 i32 __builtin_mips_extr_w (a64, imm0_31)
12080 i32 __builtin_mips_extr_w (a64, i32)
12081 i32 __builtin_mips_extr_r_w (a64, imm0_31)
12082 i32 __builtin_mips_extr_s_h (a64, i32)
12083 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
12084 i32 __builtin_mips_extr_rs_w (a64, i32)
12085 i32 __builtin_mips_extr_s_h (a64, imm0_31)
12086 i32 __builtin_mips_extr_r_w (a64, i32)
12087 i32 __builtin_mips_extp (a64, imm0_31)
12088 i32 __builtin_mips_extp (a64, i32)
12089 i32 __builtin_mips_extpdp (a64, imm0_31)
12090 i32 __builtin_mips_extpdp (a64, i32)
12091 a64 __builtin_mips_shilo (a64, imm_n32_31)
12092 a64 __builtin_mips_shilo (a64, i32)
12093 a64 __builtin_mips_mthlip (a64, i32)
12094 void __builtin_mips_wrdsp (i32, imm0_63)
12095 i32 __builtin_mips_rddsp (imm0_63)
12096 i32 __builtin_mips_lbux (void *, i32)
12097 i32 __builtin_mips_lhx (void *, i32)
12098 i32 __builtin_mips_lwx (void *, i32)
12099 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
12100 i32 __builtin_mips_bposge32 (void)
12101 a64 __builtin_mips_madd (a64, i32, i32);
12102 a64 __builtin_mips_maddu (a64, ui32, ui32);
12103 a64 __builtin_mips_msub (a64, i32, i32);
12104 a64 __builtin_mips_msubu (a64, ui32, ui32);
12105 a64 __builtin_mips_mult (i32, i32);
12106 a64 __builtin_mips_multu (ui32, ui32);
12107 @end smallexample
12108
12109 The following built-in functions map directly to a particular MIPS DSP REV 2
12110 instruction. Please refer to the architecture specification
12111 for details on what each instruction does.
12112
12113 @smallexample
12114 v4q7 __builtin_mips_absq_s_qb (v4q7);
12115 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
12116 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
12117 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
12118 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
12119 i32 __builtin_mips_append (i32, i32, imm0_31);
12120 i32 __builtin_mips_balign (i32, i32, imm0_3);
12121 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
12122 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
12123 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
12124 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
12125 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
12126 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
12127 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
12128 q31 __builtin_mips_mulq_rs_w (q31, q31);
12129 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
12130 q31 __builtin_mips_mulq_s_w (q31, q31);
12131 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
12132 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
12133 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
12134 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
12135 i32 __builtin_mips_prepend (i32, i32, imm0_31);
12136 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
12137 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
12138 v4i8 __builtin_mips_shra_qb (v4i8, i32);
12139 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
12140 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
12141 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
12142 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
12143 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
12144 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
12145 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
12146 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
12147 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
12148 q31 __builtin_mips_addqh_w (q31, q31);
12149 q31 __builtin_mips_addqh_r_w (q31, q31);
12150 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
12151 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
12152 q31 __builtin_mips_subqh_w (q31, q31);
12153 q31 __builtin_mips_subqh_r_w (q31, q31);
12154 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
12155 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
12156 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
12157 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
12158 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
12159 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
12160 @end smallexample
12161
12162
12163 @node MIPS Paired-Single Support
12164 @subsection MIPS Paired-Single Support
12165
12166 The MIPS64 architecture includes a number of instructions that
12167 operate on pairs of single-precision floating-point values.
12168 Each pair is packed into a 64-bit floating-point register,
12169 with one element being designated the ``upper half'' and
12170 the other being designated the ``lower half''.
12171
12172 GCC supports paired-single operations using both the generic
12173 vector extensions (@pxref{Vector Extensions}) and a collection of
12174 MIPS-specific built-in functions. Both kinds of support are
12175 enabled by the @option{-mpaired-single} command-line option.
12176
12177 The vector type associated with paired-single values is usually
12178 called @code{v2sf}. It can be defined in C as follows:
12179
12180 @smallexample
12181 typedef float v2sf __attribute__ ((vector_size (8)));
12182 @end smallexample
12183
12184 @code{v2sf} values are initialized in the same way as aggregates.
12185 For example:
12186
12187 @smallexample
12188 v2sf a = @{1.5, 9.1@};
12189 v2sf b;
12190 float e, f;
12191 b = (v2sf) @{e, f@};
12192 @end smallexample
12193
12194 @emph{Note:} The CPU's endianness determines which value is stored in
12195 the upper half of a register and which value is stored in the lower half.
12196 On little-endian targets, the first value is the lower one and the second
12197 value is the upper one. The opposite order applies to big-endian targets.
12198 For example, the code above sets the lower half of @code{a} to
12199 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
12200
12201 @node MIPS Loongson Built-in Functions
12202 @subsection MIPS Loongson Built-in Functions
12203
12204 GCC provides intrinsics to access the SIMD instructions provided by the
12205 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
12206 available after inclusion of the @code{loongson.h} header file,
12207 operate on the following 64-bit vector types:
12208
12209 @itemize
12210 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
12211 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
12212 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
12213 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
12214 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
12215 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
12216 @end itemize
12217
12218 The intrinsics provided are listed below; each is named after the
12219 machine instruction to which it corresponds, with suffixes added as
12220 appropriate to distinguish intrinsics that expand to the same machine
12221 instruction yet have different argument types. Refer to the architecture
12222 documentation for a description of the functionality of each
12223 instruction.
12224
12225 @smallexample
12226 int16x4_t packsswh (int32x2_t s, int32x2_t t);
12227 int8x8_t packsshb (int16x4_t s, int16x4_t t);
12228 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
12229 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
12230 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
12231 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
12232 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
12233 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
12234 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
12235 uint64_t paddd_u (uint64_t s, uint64_t t);
12236 int64_t paddd_s (int64_t s, int64_t t);
12237 int16x4_t paddsh (int16x4_t s, int16x4_t t);
12238 int8x8_t paddsb (int8x8_t s, int8x8_t t);
12239 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
12240 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
12241 uint64_t pandn_ud (uint64_t s, uint64_t t);
12242 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
12243 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
12244 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
12245 int64_t pandn_sd (int64_t s, int64_t t);
12246 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
12247 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
12248 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
12249 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
12250 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
12251 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
12252 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
12253 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
12254 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
12255 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
12256 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
12257 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
12258 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
12259 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
12260 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
12261 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
12262 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
12263 uint16x4_t pextrh_u (uint16x4_t s, int field);
12264 int16x4_t pextrh_s (int16x4_t s, int field);
12265 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
12266 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
12267 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
12268 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
12269 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
12270 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
12271 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
12272 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
12273 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
12274 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
12275 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
12276 int16x4_t pminsh (int16x4_t s, int16x4_t t);
12277 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
12278 uint8x8_t pmovmskb_u (uint8x8_t s);
12279 int8x8_t pmovmskb_s (int8x8_t s);
12280 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
12281 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
12282 int16x4_t pmullh (int16x4_t s, int16x4_t t);
12283 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
12284 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
12285 uint16x4_t biadd (uint8x8_t s);
12286 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
12287 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
12288 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
12289 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
12290 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
12291 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
12292 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
12293 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
12294 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
12295 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
12296 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
12297 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
12298 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
12299 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
12300 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
12301 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
12302 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
12303 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
12304 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
12305 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
12306 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
12307 uint64_t psubd_u (uint64_t s, uint64_t t);
12308 int64_t psubd_s (int64_t s, int64_t t);
12309 int16x4_t psubsh (int16x4_t s, int16x4_t t);
12310 int8x8_t psubsb (int8x8_t s, int8x8_t t);
12311 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
12312 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
12313 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
12314 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
12315 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
12316 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
12317 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
12318 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
12319 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
12320 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
12321 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
12322 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
12323 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
12324 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
12325 @end smallexample
12326
12327 @menu
12328 * Paired-Single Arithmetic::
12329 * Paired-Single Built-in Functions::
12330 * MIPS-3D Built-in Functions::
12331 @end menu
12332
12333 @node Paired-Single Arithmetic
12334 @subsubsection Paired-Single Arithmetic
12335
12336 The table below lists the @code{v2sf} operations for which hardware
12337 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
12338 values and @code{x} is an integral value.
12339
12340 @multitable @columnfractions .50 .50
12341 @item C code @tab MIPS instruction
12342 @item @code{a + b} @tab @code{add.ps}
12343 @item @code{a - b} @tab @code{sub.ps}
12344 @item @code{-a} @tab @code{neg.ps}
12345 @item @code{a * b} @tab @code{mul.ps}
12346 @item @code{a * b + c} @tab @code{madd.ps}
12347 @item @code{a * b - c} @tab @code{msub.ps}
12348 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
12349 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
12350 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
12351 @end multitable
12352
12353 Note that the multiply-accumulate instructions can be disabled
12354 using the command-line option @code{-mno-fused-madd}.
12355
12356 @node Paired-Single Built-in Functions
12357 @subsubsection Paired-Single Built-in Functions
12358
12359 The following paired-single functions map directly to a particular
12360 MIPS instruction. Please refer to the architecture specification
12361 for details on what each instruction does.
12362
12363 @table @code
12364 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
12365 Pair lower lower (@code{pll.ps}).
12366
12367 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
12368 Pair upper lower (@code{pul.ps}).
12369
12370 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
12371 Pair lower upper (@code{plu.ps}).
12372
12373 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
12374 Pair upper upper (@code{puu.ps}).
12375
12376 @item v2sf __builtin_mips_cvt_ps_s (float, float)
12377 Convert pair to paired single (@code{cvt.ps.s}).
12378
12379 @item float __builtin_mips_cvt_s_pl (v2sf)
12380 Convert pair lower to single (@code{cvt.s.pl}).
12381
12382 @item float __builtin_mips_cvt_s_pu (v2sf)
12383 Convert pair upper to single (@code{cvt.s.pu}).
12384
12385 @item v2sf __builtin_mips_abs_ps (v2sf)
12386 Absolute value (@code{abs.ps}).
12387
12388 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
12389 Align variable (@code{alnv.ps}).
12390
12391 @emph{Note:} The value of the third parameter must be 0 or 4
12392 modulo 8, otherwise the result is unpredictable. Please read the
12393 instruction description for details.
12394 @end table
12395
12396 The following multi-instruction functions are also available.
12397 In each case, @var{cond} can be any of the 16 floating-point conditions:
12398 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12399 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
12400 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12401
12402 @table @code
12403 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12404 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12405 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
12406 @code{movt.ps}/@code{movf.ps}).
12407
12408 The @code{movt} functions return the value @var{x} computed by:
12409
12410 @smallexample
12411 c.@var{cond}.ps @var{cc},@var{a},@var{b}
12412 mov.ps @var{x},@var{c}
12413 movt.ps @var{x},@var{d},@var{cc}
12414 @end smallexample
12415
12416 The @code{movf} functions are similar but use @code{movf.ps} instead
12417 of @code{movt.ps}.
12418
12419 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12420 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12421 Comparison of two paired-single values (@code{c.@var{cond}.ps},
12422 @code{bc1t}/@code{bc1f}).
12423
12424 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12425 and return either the upper or lower half of the result. For example:
12426
12427 @smallexample
12428 v2sf a, b;
12429 if (__builtin_mips_upper_c_eq_ps (a, b))
12430 upper_halves_are_equal ();
12431 else
12432 upper_halves_are_unequal ();
12433
12434 if (__builtin_mips_lower_c_eq_ps (a, b))
12435 lower_halves_are_equal ();
12436 else
12437 lower_halves_are_unequal ();
12438 @end smallexample
12439 @end table
12440
12441 @node MIPS-3D Built-in Functions
12442 @subsubsection MIPS-3D Built-in Functions
12443
12444 The MIPS-3D Application-Specific Extension (ASE) includes additional
12445 paired-single instructions that are designed to improve the performance
12446 of 3D graphics operations. Support for these instructions is controlled
12447 by the @option{-mips3d} command-line option.
12448
12449 The functions listed below map directly to a particular MIPS-3D
12450 instruction. Please refer to the architecture specification for
12451 more details on what each instruction does.
12452
12453 @table @code
12454 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
12455 Reduction add (@code{addr.ps}).
12456
12457 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
12458 Reduction multiply (@code{mulr.ps}).
12459
12460 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
12461 Convert paired single to paired word (@code{cvt.pw.ps}).
12462
12463 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
12464 Convert paired word to paired single (@code{cvt.ps.pw}).
12465
12466 @item float __builtin_mips_recip1_s (float)
12467 @itemx double __builtin_mips_recip1_d (double)
12468 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
12469 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
12470
12471 @item float __builtin_mips_recip2_s (float, float)
12472 @itemx double __builtin_mips_recip2_d (double, double)
12473 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
12474 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
12475
12476 @item float __builtin_mips_rsqrt1_s (float)
12477 @itemx double __builtin_mips_rsqrt1_d (double)
12478 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
12479 Reduced-precision reciprocal square root (sequence step 1)
12480 (@code{rsqrt1.@var{fmt}}).
12481
12482 @item float __builtin_mips_rsqrt2_s (float, float)
12483 @itemx double __builtin_mips_rsqrt2_d (double, double)
12484 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
12485 Reduced-precision reciprocal square root (sequence step 2)
12486 (@code{rsqrt2.@var{fmt}}).
12487 @end table
12488
12489 The following multi-instruction functions are also available.
12490 In each case, @var{cond} can be any of the 16 floating-point conditions:
12491 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12492 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
12493 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12494
12495 @table @code
12496 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
12497 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
12498 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
12499 @code{bc1t}/@code{bc1f}).
12500
12501 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
12502 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
12503 For example:
12504
12505 @smallexample
12506 float a, b;
12507 if (__builtin_mips_cabs_eq_s (a, b))
12508 true ();
12509 else
12510 false ();
12511 @end smallexample
12512
12513 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12514 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12515 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
12516 @code{bc1t}/@code{bc1f}).
12517
12518 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
12519 and return either the upper or lower half of the result. For example:
12520
12521 @smallexample
12522 v2sf a, b;
12523 if (__builtin_mips_upper_cabs_eq_ps (a, b))
12524 upper_halves_are_equal ();
12525 else
12526 upper_halves_are_unequal ();
12527
12528 if (__builtin_mips_lower_cabs_eq_ps (a, b))
12529 lower_halves_are_equal ();
12530 else
12531 lower_halves_are_unequal ();
12532 @end smallexample
12533
12534 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12535 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12536 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
12537 @code{movt.ps}/@code{movf.ps}).
12538
12539 The @code{movt} functions return the value @var{x} computed by:
12540
12541 @smallexample
12542 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
12543 mov.ps @var{x},@var{c}
12544 movt.ps @var{x},@var{d},@var{cc}
12545 @end smallexample
12546
12547 The @code{movf} functions are similar but use @code{movf.ps} instead
12548 of @code{movt.ps}.
12549
12550 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12551 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12552 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12553 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12554 Comparison of two paired-single values
12555 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12556 @code{bc1any2t}/@code{bc1any2f}).
12557
12558 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12559 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
12560 result is true and the @code{all} forms return true if both results are true.
12561 For example:
12562
12563 @smallexample
12564 v2sf a, b;
12565 if (__builtin_mips_any_c_eq_ps (a, b))
12566 one_is_true ();
12567 else
12568 both_are_false ();
12569
12570 if (__builtin_mips_all_c_eq_ps (a, b))
12571 both_are_true ();
12572 else
12573 one_is_false ();
12574 @end smallexample
12575
12576 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12577 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12578 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12579 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12580 Comparison of four paired-single values
12581 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12582 @code{bc1any4t}/@code{bc1any4f}).
12583
12584 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
12585 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
12586 The @code{any} forms return true if any of the four results are true
12587 and the @code{all} forms return true if all four results are true.
12588 For example:
12589
12590 @smallexample
12591 v2sf a, b, c, d;
12592 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
12593 some_are_true ();
12594 else
12595 all_are_false ();
12596
12597 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
12598 all_are_true ();
12599 else
12600 some_are_false ();
12601 @end smallexample
12602 @end table
12603
12604 @node Other MIPS Built-in Functions
12605 @subsection Other MIPS Built-in Functions
12606
12607 GCC provides other MIPS-specific built-in functions:
12608
12609 @table @code
12610 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
12611 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
12612 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
12613 when this function is available.
12614 @end table
12615
12616 @node MSP430 Built-in Functions
12617 @subsection MSP430 Built-in Functions
12618
12619 GCC provides a couple of special builtin functions to aid in the
12620 writing of interrupt handlers in C.
12621
12622 @table @code
12623 @item __bic_SR_register_on_exit (int @var{mask})
12624 This clears the indicated bits in the saved copy of the status register
12625 currently residing on the stack. This only works inside interrupt
12626 handlers and the changes to the status register will only take affect
12627 once the handler returns.
12628
12629 @item __bis_SR_register_on_exit (int @var{mask})
12630 This sets the indicated bits in the saved copy of the status register
12631 currently residing on the stack. This only works inside interrupt
12632 handlers and the changes to the status register will only take affect
12633 once the handler returns.
12634 @end table
12635
12636 @node NDS32 Built-in Functions
12637 @subsection NDS32 Built-in Functions
12638
12639 These built-in functions are available for the NDS32 target:
12640
12641 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
12642 Insert an ISYNC instruction into the instruction stream where
12643 @var{addr} is an instruction address for serialization.
12644 @end deftypefn
12645
12646 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
12647 Insert an ISB instruction into the instruction stream.
12648 @end deftypefn
12649
12650 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
12651 Return the content of a system register which is mapped by @var{sr}.
12652 @end deftypefn
12653
12654 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
12655 Return the content of a user space register which is mapped by @var{usr}.
12656 @end deftypefn
12657
12658 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
12659 Move the @var{value} to a system register which is mapped by @var{sr}.
12660 @end deftypefn
12661
12662 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
12663 Move the @var{value} to a user space register which is mapped by @var{usr}.
12664 @end deftypefn
12665
12666 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
12667 Enable global interrupt.
12668 @end deftypefn
12669
12670 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
12671 Disable global interrupt.
12672 @end deftypefn
12673
12674 @node picoChip Built-in Functions
12675 @subsection picoChip Built-in Functions
12676
12677 GCC provides an interface to selected machine instructions from the
12678 picoChip instruction set.
12679
12680 @table @code
12681 @item int __builtin_sbc (int @var{value})
12682 Sign bit count. Return the number of consecutive bits in @var{value}
12683 that have the same value as the sign bit. The result is the number of
12684 leading sign bits minus one, giving the number of redundant sign bits in
12685 @var{value}.
12686
12687 @item int __builtin_byteswap (int @var{value})
12688 Byte swap. Return the result of swapping the upper and lower bytes of
12689 @var{value}.
12690
12691 @item int __builtin_brev (int @var{value})
12692 Bit reversal. Return the result of reversing the bits in
12693 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
12694 and so on.
12695
12696 @item int __builtin_adds (int @var{x}, int @var{y})
12697 Saturating addition. Return the result of adding @var{x} and @var{y},
12698 storing the value 32767 if the result overflows.
12699
12700 @item int __builtin_subs (int @var{x}, int @var{y})
12701 Saturating subtraction. Return the result of subtracting @var{y} from
12702 @var{x}, storing the value @minus{}32768 if the result overflows.
12703
12704 @item void __builtin_halt (void)
12705 Halt. The processor stops execution. This built-in is useful for
12706 implementing assertions.
12707
12708 @end table
12709
12710 @node PowerPC Built-in Functions
12711 @subsection PowerPC Built-in Functions
12712
12713 These built-in functions are available for the PowerPC family of
12714 processors:
12715 @smallexample
12716 float __builtin_recipdivf (float, float);
12717 float __builtin_rsqrtf (float);
12718 double __builtin_recipdiv (double, double);
12719 double __builtin_rsqrt (double);
12720 long __builtin_bpermd (long, long);
12721 uint64_t __builtin_ppc_get_timebase ();
12722 unsigned long __builtin_ppc_mftb ();
12723 @end smallexample
12724
12725 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
12726 @code{__builtin_rsqrtf} functions generate multiple instructions to
12727 implement the reciprocal sqrt functionality using reciprocal sqrt
12728 estimate instructions.
12729
12730 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
12731 functions generate multiple instructions to implement division using
12732 the reciprocal estimate instructions.
12733
12734 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
12735 functions generate instructions to read the Time Base Register. The
12736 @code{__builtin_ppc_get_timebase} function may generate multiple
12737 instructions and always returns the 64 bits of the Time Base Register.
12738 The @code{__builtin_ppc_mftb} function always generates one instruction and
12739 returns the Time Base Register value as an unsigned long, throwing away
12740 the most significant word on 32-bit environments.
12741
12742 @node PowerPC AltiVec/VSX Built-in Functions
12743 @subsection PowerPC AltiVec Built-in Functions
12744
12745 GCC provides an interface for the PowerPC family of processors to access
12746 the AltiVec operations described in Motorola's AltiVec Programming
12747 Interface Manual. The interface is made available by including
12748 @code{<altivec.h>} and using @option{-maltivec} and
12749 @option{-mabi=altivec}. The interface supports the following vector
12750 types.
12751
12752 @smallexample
12753 vector unsigned char
12754 vector signed char
12755 vector bool char
12756
12757 vector unsigned short
12758 vector signed short
12759 vector bool short
12760 vector pixel
12761
12762 vector unsigned int
12763 vector signed int
12764 vector bool int
12765 vector float
12766 @end smallexample
12767
12768 If @option{-mvsx} is used the following additional vector types are
12769 implemented.
12770
12771 @smallexample
12772 vector unsigned long
12773 vector signed long
12774 vector double
12775 @end smallexample
12776
12777 The long types are only implemented for 64-bit code generation, and
12778 the long type is only used in the floating point/integer conversion
12779 instructions.
12780
12781 GCC's implementation of the high-level language interface available from
12782 C and C++ code differs from Motorola's documentation in several ways.
12783
12784 @itemize @bullet
12785
12786 @item
12787 A vector constant is a list of constant expressions within curly braces.
12788
12789 @item
12790 A vector initializer requires no cast if the vector constant is of the
12791 same type as the variable it is initializing.
12792
12793 @item
12794 If @code{signed} or @code{unsigned} is omitted, the signedness of the
12795 vector type is the default signedness of the base type. The default
12796 varies depending on the operating system, so a portable program should
12797 always specify the signedness.
12798
12799 @item
12800 Compiling with @option{-maltivec} adds keywords @code{__vector},
12801 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
12802 @code{bool}. When compiling ISO C, the context-sensitive substitution
12803 of the keywords @code{vector}, @code{pixel} and @code{bool} is
12804 disabled. To use them, you must include @code{<altivec.h>} instead.
12805
12806 @item
12807 GCC allows using a @code{typedef} name as the type specifier for a
12808 vector type.
12809
12810 @item
12811 For C, overloaded functions are implemented with macros so the following
12812 does not work:
12813
12814 @smallexample
12815 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
12816 @end smallexample
12817
12818 @noindent
12819 Since @code{vec_add} is a macro, the vector constant in the example
12820 is treated as four separate arguments. Wrap the entire argument in
12821 parentheses for this to work.
12822 @end itemize
12823
12824 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
12825 Internally, GCC uses built-in functions to achieve the functionality in
12826 the aforementioned header file, but they are not supported and are
12827 subject to change without notice.
12828
12829 The following interfaces are supported for the generic and specific
12830 AltiVec operations and the AltiVec predicates. In cases where there
12831 is a direct mapping between generic and specific operations, only the
12832 generic names are shown here, although the specific operations can also
12833 be used.
12834
12835 Arguments that are documented as @code{const int} require literal
12836 integral values within the range required for that operation.
12837
12838 @smallexample
12839 vector signed char vec_abs (vector signed char);
12840 vector signed short vec_abs (vector signed short);
12841 vector signed int vec_abs (vector signed int);
12842 vector float vec_abs (vector float);
12843
12844 vector signed char vec_abss (vector signed char);
12845 vector signed short vec_abss (vector signed short);
12846 vector signed int vec_abss (vector signed int);
12847
12848 vector signed char vec_add (vector bool char, vector signed char);
12849 vector signed char vec_add (vector signed char, vector bool char);
12850 vector signed char vec_add (vector signed char, vector signed char);
12851 vector unsigned char vec_add (vector bool char, vector unsigned char);
12852 vector unsigned char vec_add (vector unsigned char, vector bool char);
12853 vector unsigned char vec_add (vector unsigned char,
12854 vector unsigned char);
12855 vector signed short vec_add (vector bool short, vector signed short);
12856 vector signed short vec_add (vector signed short, vector bool short);
12857 vector signed short vec_add (vector signed short, vector signed short);
12858 vector unsigned short vec_add (vector bool short,
12859 vector unsigned short);
12860 vector unsigned short vec_add (vector unsigned short,
12861 vector bool short);
12862 vector unsigned short vec_add (vector unsigned short,
12863 vector unsigned short);
12864 vector signed int vec_add (vector bool int, vector signed int);
12865 vector signed int vec_add (vector signed int, vector bool int);
12866 vector signed int vec_add (vector signed int, vector signed int);
12867 vector unsigned int vec_add (vector bool int, vector unsigned int);
12868 vector unsigned int vec_add (vector unsigned int, vector bool int);
12869 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
12870 vector float vec_add (vector float, vector float);
12871
12872 vector float vec_vaddfp (vector float, vector float);
12873
12874 vector signed int vec_vadduwm (vector bool int, vector signed int);
12875 vector signed int vec_vadduwm (vector signed int, vector bool int);
12876 vector signed int vec_vadduwm (vector signed int, vector signed int);
12877 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
12878 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
12879 vector unsigned int vec_vadduwm (vector unsigned int,
12880 vector unsigned int);
12881
12882 vector signed short vec_vadduhm (vector bool short,
12883 vector signed short);
12884 vector signed short vec_vadduhm (vector signed short,
12885 vector bool short);
12886 vector signed short vec_vadduhm (vector signed short,
12887 vector signed short);
12888 vector unsigned short vec_vadduhm (vector bool short,
12889 vector unsigned short);
12890 vector unsigned short vec_vadduhm (vector unsigned short,
12891 vector bool short);
12892 vector unsigned short vec_vadduhm (vector unsigned short,
12893 vector unsigned short);
12894
12895 vector signed char vec_vaddubm (vector bool char, vector signed char);
12896 vector signed char vec_vaddubm (vector signed char, vector bool char);
12897 vector signed char vec_vaddubm (vector signed char, vector signed char);
12898 vector unsigned char vec_vaddubm (vector bool char,
12899 vector unsigned char);
12900 vector unsigned char vec_vaddubm (vector unsigned char,
12901 vector bool char);
12902 vector unsigned char vec_vaddubm (vector unsigned char,
12903 vector unsigned char);
12904
12905 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
12906
12907 vector unsigned char vec_adds (vector bool char, vector unsigned char);
12908 vector unsigned char vec_adds (vector unsigned char, vector bool char);
12909 vector unsigned char vec_adds (vector unsigned char,
12910 vector unsigned char);
12911 vector signed char vec_adds (vector bool char, vector signed char);
12912 vector signed char vec_adds (vector signed char, vector bool char);
12913 vector signed char vec_adds (vector signed char, vector signed char);
12914 vector unsigned short vec_adds (vector bool short,
12915 vector unsigned short);
12916 vector unsigned short vec_adds (vector unsigned short,
12917 vector bool short);
12918 vector unsigned short vec_adds (vector unsigned short,
12919 vector unsigned short);
12920 vector signed short vec_adds (vector bool short, vector signed short);
12921 vector signed short vec_adds (vector signed short, vector bool short);
12922 vector signed short vec_adds (vector signed short, vector signed short);
12923 vector unsigned int vec_adds (vector bool int, vector unsigned int);
12924 vector unsigned int vec_adds (vector unsigned int, vector bool int);
12925 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
12926 vector signed int vec_adds (vector bool int, vector signed int);
12927 vector signed int vec_adds (vector signed int, vector bool int);
12928 vector signed int vec_adds (vector signed int, vector signed int);
12929
12930 vector signed int vec_vaddsws (vector bool int, vector signed int);
12931 vector signed int vec_vaddsws (vector signed int, vector bool int);
12932 vector signed int vec_vaddsws (vector signed int, vector signed int);
12933
12934 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
12935 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
12936 vector unsigned int vec_vadduws (vector unsigned int,
12937 vector unsigned int);
12938
12939 vector signed short vec_vaddshs (vector bool short,
12940 vector signed short);
12941 vector signed short vec_vaddshs (vector signed short,
12942 vector bool short);
12943 vector signed short vec_vaddshs (vector signed short,
12944 vector signed short);
12945
12946 vector unsigned short vec_vadduhs (vector bool short,
12947 vector unsigned short);
12948 vector unsigned short vec_vadduhs (vector unsigned short,
12949 vector bool short);
12950 vector unsigned short vec_vadduhs (vector unsigned short,
12951 vector unsigned short);
12952
12953 vector signed char vec_vaddsbs (vector bool char, vector signed char);
12954 vector signed char vec_vaddsbs (vector signed char, vector bool char);
12955 vector signed char vec_vaddsbs (vector signed char, vector signed char);
12956
12957 vector unsigned char vec_vaddubs (vector bool char,
12958 vector unsigned char);
12959 vector unsigned char vec_vaddubs (vector unsigned char,
12960 vector bool char);
12961 vector unsigned char vec_vaddubs (vector unsigned char,
12962 vector unsigned char);
12963
12964 vector float vec_and (vector float, vector float);
12965 vector float vec_and (vector float, vector bool int);
12966 vector float vec_and (vector bool int, vector float);
12967 vector bool int vec_and (vector bool int, vector bool int);
12968 vector signed int vec_and (vector bool int, vector signed int);
12969 vector signed int vec_and (vector signed int, vector bool int);
12970 vector signed int vec_and (vector signed int, vector signed int);
12971 vector unsigned int vec_and (vector bool int, vector unsigned int);
12972 vector unsigned int vec_and (vector unsigned int, vector bool int);
12973 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
12974 vector bool short vec_and (vector bool short, vector bool short);
12975 vector signed short vec_and (vector bool short, vector signed short);
12976 vector signed short vec_and (vector signed short, vector bool short);
12977 vector signed short vec_and (vector signed short, vector signed short);
12978 vector unsigned short vec_and (vector bool short,
12979 vector unsigned short);
12980 vector unsigned short vec_and (vector unsigned short,
12981 vector bool short);
12982 vector unsigned short vec_and (vector unsigned short,
12983 vector unsigned short);
12984 vector signed char vec_and (vector bool char, vector signed char);
12985 vector bool char vec_and (vector bool char, vector bool char);
12986 vector signed char vec_and (vector signed char, vector bool char);
12987 vector signed char vec_and (vector signed char, vector signed char);
12988 vector unsigned char vec_and (vector bool char, vector unsigned char);
12989 vector unsigned char vec_and (vector unsigned char, vector bool char);
12990 vector unsigned char vec_and (vector unsigned char,
12991 vector unsigned char);
12992
12993 vector float vec_andc (vector float, vector float);
12994 vector float vec_andc (vector float, vector bool int);
12995 vector float vec_andc (vector bool int, vector float);
12996 vector bool int vec_andc (vector bool int, vector bool int);
12997 vector signed int vec_andc (vector bool int, vector signed int);
12998 vector signed int vec_andc (vector signed int, vector bool int);
12999 vector signed int vec_andc (vector signed int, vector signed int);
13000 vector unsigned int vec_andc (vector bool int, vector unsigned int);
13001 vector unsigned int vec_andc (vector unsigned int, vector bool int);
13002 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
13003 vector bool short vec_andc (vector bool short, vector bool short);
13004 vector signed short vec_andc (vector bool short, vector signed short);
13005 vector signed short vec_andc (vector signed short, vector bool short);
13006 vector signed short vec_andc (vector signed short, vector signed short);
13007 vector unsigned short vec_andc (vector bool short,
13008 vector unsigned short);
13009 vector unsigned short vec_andc (vector unsigned short,
13010 vector bool short);
13011 vector unsigned short vec_andc (vector unsigned short,
13012 vector unsigned short);
13013 vector signed char vec_andc (vector bool char, vector signed char);
13014 vector bool char vec_andc (vector bool char, vector bool char);
13015 vector signed char vec_andc (vector signed char, vector bool char);
13016 vector signed char vec_andc (vector signed char, vector signed char);
13017 vector unsigned char vec_andc (vector bool char, vector unsigned char);
13018 vector unsigned char vec_andc (vector unsigned char, vector bool char);
13019 vector unsigned char vec_andc (vector unsigned char,
13020 vector unsigned char);
13021
13022 vector unsigned char vec_avg (vector unsigned char,
13023 vector unsigned char);
13024 vector signed char vec_avg (vector signed char, vector signed char);
13025 vector unsigned short vec_avg (vector unsigned short,
13026 vector unsigned short);
13027 vector signed short vec_avg (vector signed short, vector signed short);
13028 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
13029 vector signed int vec_avg (vector signed int, vector signed int);
13030
13031 vector signed int vec_vavgsw (vector signed int, vector signed int);
13032
13033 vector unsigned int vec_vavguw (vector unsigned int,
13034 vector unsigned int);
13035
13036 vector signed short vec_vavgsh (vector signed short,
13037 vector signed short);
13038
13039 vector unsigned short vec_vavguh (vector unsigned short,
13040 vector unsigned short);
13041
13042 vector signed char vec_vavgsb (vector signed char, vector signed char);
13043
13044 vector unsigned char vec_vavgub (vector unsigned char,
13045 vector unsigned char);
13046
13047 vector float vec_copysign (vector float);
13048
13049 vector float vec_ceil (vector float);
13050
13051 vector signed int vec_cmpb (vector float, vector float);
13052
13053 vector bool char vec_cmpeq (vector signed char, vector signed char);
13054 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
13055 vector bool short vec_cmpeq (vector signed short, vector signed short);
13056 vector bool short vec_cmpeq (vector unsigned short,
13057 vector unsigned short);
13058 vector bool int vec_cmpeq (vector signed int, vector signed int);
13059 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
13060 vector bool int vec_cmpeq (vector float, vector float);
13061
13062 vector bool int vec_vcmpeqfp (vector float, vector float);
13063
13064 vector bool int vec_vcmpequw (vector signed int, vector signed int);
13065 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
13066
13067 vector bool short vec_vcmpequh (vector signed short,
13068 vector signed short);
13069 vector bool short vec_vcmpequh (vector unsigned short,
13070 vector unsigned short);
13071
13072 vector bool char vec_vcmpequb (vector signed char, vector signed char);
13073 vector bool char vec_vcmpequb (vector unsigned char,
13074 vector unsigned char);
13075
13076 vector bool int vec_cmpge (vector float, vector float);
13077
13078 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
13079 vector bool char vec_cmpgt (vector signed char, vector signed char);
13080 vector bool short vec_cmpgt (vector unsigned short,
13081 vector unsigned short);
13082 vector bool short vec_cmpgt (vector signed short, vector signed short);
13083 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
13084 vector bool int vec_cmpgt (vector signed int, vector signed int);
13085 vector bool int vec_cmpgt (vector float, vector float);
13086
13087 vector bool int vec_vcmpgtfp (vector float, vector float);
13088
13089 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
13090
13091 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
13092
13093 vector bool short vec_vcmpgtsh (vector signed short,
13094 vector signed short);
13095
13096 vector bool short vec_vcmpgtuh (vector unsigned short,
13097 vector unsigned short);
13098
13099 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
13100
13101 vector bool char vec_vcmpgtub (vector unsigned char,
13102 vector unsigned char);
13103
13104 vector bool int vec_cmple (vector float, vector float);
13105
13106 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
13107 vector bool char vec_cmplt (vector signed char, vector signed char);
13108 vector bool short vec_cmplt (vector unsigned short,
13109 vector unsigned short);
13110 vector bool short vec_cmplt (vector signed short, vector signed short);
13111 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
13112 vector bool int vec_cmplt (vector signed int, vector signed int);
13113 vector bool int vec_cmplt (vector float, vector float);
13114
13115 vector float vec_ctf (vector unsigned int, const int);
13116 vector float vec_ctf (vector signed int, const int);
13117
13118 vector float vec_vcfsx (vector signed int, const int);
13119
13120 vector float vec_vcfux (vector unsigned int, const int);
13121
13122 vector signed int vec_cts (vector float, const int);
13123
13124 vector unsigned int vec_ctu (vector float, const int);
13125
13126 void vec_dss (const int);
13127
13128 void vec_dssall (void);
13129
13130 void vec_dst (const vector unsigned char *, int, const int);
13131 void vec_dst (const vector signed char *, int, const int);
13132 void vec_dst (const vector bool char *, int, const int);
13133 void vec_dst (const vector unsigned short *, int, const int);
13134 void vec_dst (const vector signed short *, int, const int);
13135 void vec_dst (const vector bool short *, int, const int);
13136 void vec_dst (const vector pixel *, int, const int);
13137 void vec_dst (const vector unsigned int *, int, const int);
13138 void vec_dst (const vector signed int *, int, const int);
13139 void vec_dst (const vector bool int *, int, const int);
13140 void vec_dst (const vector float *, int, const int);
13141 void vec_dst (const unsigned char *, int, const int);
13142 void vec_dst (const signed char *, int, const int);
13143 void vec_dst (const unsigned short *, int, const int);
13144 void vec_dst (const short *, int, const int);
13145 void vec_dst (const unsigned int *, int, const int);
13146 void vec_dst (const int *, int, const int);
13147 void vec_dst (const unsigned long *, int, const int);
13148 void vec_dst (const long *, int, const int);
13149 void vec_dst (const float *, int, const int);
13150
13151 void vec_dstst (const vector unsigned char *, int, const int);
13152 void vec_dstst (const vector signed char *, int, const int);
13153 void vec_dstst (const vector bool char *, int, const int);
13154 void vec_dstst (const vector unsigned short *, int, const int);
13155 void vec_dstst (const vector signed short *, int, const int);
13156 void vec_dstst (const vector bool short *, int, const int);
13157 void vec_dstst (const vector pixel *, int, const int);
13158 void vec_dstst (const vector unsigned int *, int, const int);
13159 void vec_dstst (const vector signed int *, int, const int);
13160 void vec_dstst (const vector bool int *, int, const int);
13161 void vec_dstst (const vector float *, int, const int);
13162 void vec_dstst (const unsigned char *, int, const int);
13163 void vec_dstst (const signed char *, int, const int);
13164 void vec_dstst (const unsigned short *, int, const int);
13165 void vec_dstst (const short *, int, const int);
13166 void vec_dstst (const unsigned int *, int, const int);
13167 void vec_dstst (const int *, int, const int);
13168 void vec_dstst (const unsigned long *, int, const int);
13169 void vec_dstst (const long *, int, const int);
13170 void vec_dstst (const float *, int, const int);
13171
13172 void vec_dststt (const vector unsigned char *, int, const int);
13173 void vec_dststt (const vector signed char *, int, const int);
13174 void vec_dststt (const vector bool char *, int, const int);
13175 void vec_dststt (const vector unsigned short *, int, const int);
13176 void vec_dststt (const vector signed short *, int, const int);
13177 void vec_dststt (const vector bool short *, int, const int);
13178 void vec_dststt (const vector pixel *, int, const int);
13179 void vec_dststt (const vector unsigned int *, int, const int);
13180 void vec_dststt (const vector signed int *, int, const int);
13181 void vec_dststt (const vector bool int *, int, const int);
13182 void vec_dststt (const vector float *, int, const int);
13183 void vec_dststt (const unsigned char *, int, const int);
13184 void vec_dststt (const signed char *, int, const int);
13185 void vec_dststt (const unsigned short *, int, const int);
13186 void vec_dststt (const short *, int, const int);
13187 void vec_dststt (const unsigned int *, int, const int);
13188 void vec_dststt (const int *, int, const int);
13189 void vec_dststt (const unsigned long *, int, const int);
13190 void vec_dststt (const long *, int, const int);
13191 void vec_dststt (const float *, int, const int);
13192
13193 void vec_dstt (const vector unsigned char *, int, const int);
13194 void vec_dstt (const vector signed char *, int, const int);
13195 void vec_dstt (const vector bool char *, int, const int);
13196 void vec_dstt (const vector unsigned short *, int, const int);
13197 void vec_dstt (const vector signed short *, int, const int);
13198 void vec_dstt (const vector bool short *, int, const int);
13199 void vec_dstt (const vector pixel *, int, const int);
13200 void vec_dstt (const vector unsigned int *, int, const int);
13201 void vec_dstt (const vector signed int *, int, const int);
13202 void vec_dstt (const vector bool int *, int, const int);
13203 void vec_dstt (const vector float *, int, const int);
13204 void vec_dstt (const unsigned char *, int, const int);
13205 void vec_dstt (const signed char *, int, const int);
13206 void vec_dstt (const unsigned short *, int, const int);
13207 void vec_dstt (const short *, int, const int);
13208 void vec_dstt (const unsigned int *, int, const int);
13209 void vec_dstt (const int *, int, const int);
13210 void vec_dstt (const unsigned long *, int, const int);
13211 void vec_dstt (const long *, int, const int);
13212 void vec_dstt (const float *, int, const int);
13213
13214 vector float vec_expte (vector float);
13215
13216 vector float vec_floor (vector float);
13217
13218 vector float vec_ld (int, const vector float *);
13219 vector float vec_ld (int, const float *);
13220 vector bool int vec_ld (int, const vector bool int *);
13221 vector signed int vec_ld (int, const vector signed int *);
13222 vector signed int vec_ld (int, const int *);
13223 vector signed int vec_ld (int, const long *);
13224 vector unsigned int vec_ld (int, const vector unsigned int *);
13225 vector unsigned int vec_ld (int, const unsigned int *);
13226 vector unsigned int vec_ld (int, const unsigned long *);
13227 vector bool short vec_ld (int, const vector bool short *);
13228 vector pixel vec_ld (int, const vector pixel *);
13229 vector signed short vec_ld (int, const vector signed short *);
13230 vector signed short vec_ld (int, const short *);
13231 vector unsigned short vec_ld (int, const vector unsigned short *);
13232 vector unsigned short vec_ld (int, const unsigned short *);
13233 vector bool char vec_ld (int, const vector bool char *);
13234 vector signed char vec_ld (int, const vector signed char *);
13235 vector signed char vec_ld (int, const signed char *);
13236 vector unsigned char vec_ld (int, const vector unsigned char *);
13237 vector unsigned char vec_ld (int, const unsigned char *);
13238
13239 vector signed char vec_lde (int, const signed char *);
13240 vector unsigned char vec_lde (int, const unsigned char *);
13241 vector signed short vec_lde (int, const short *);
13242 vector unsigned short vec_lde (int, const unsigned short *);
13243 vector float vec_lde (int, const float *);
13244 vector signed int vec_lde (int, const int *);
13245 vector unsigned int vec_lde (int, const unsigned int *);
13246 vector signed int vec_lde (int, const long *);
13247 vector unsigned int vec_lde (int, const unsigned long *);
13248
13249 vector float vec_lvewx (int, float *);
13250 vector signed int vec_lvewx (int, int *);
13251 vector unsigned int vec_lvewx (int, unsigned int *);
13252 vector signed int vec_lvewx (int, long *);
13253 vector unsigned int vec_lvewx (int, unsigned long *);
13254
13255 vector signed short vec_lvehx (int, short *);
13256 vector unsigned short vec_lvehx (int, unsigned short *);
13257
13258 vector signed char vec_lvebx (int, char *);
13259 vector unsigned char vec_lvebx (int, unsigned char *);
13260
13261 vector float vec_ldl (int, const vector float *);
13262 vector float vec_ldl (int, const float *);
13263 vector bool int vec_ldl (int, const vector bool int *);
13264 vector signed int vec_ldl (int, const vector signed int *);
13265 vector signed int vec_ldl (int, const int *);
13266 vector signed int vec_ldl (int, const long *);
13267 vector unsigned int vec_ldl (int, const vector unsigned int *);
13268 vector unsigned int vec_ldl (int, const unsigned int *);
13269 vector unsigned int vec_ldl (int, const unsigned long *);
13270 vector bool short vec_ldl (int, const vector bool short *);
13271 vector pixel vec_ldl (int, const vector pixel *);
13272 vector signed short vec_ldl (int, const vector signed short *);
13273 vector signed short vec_ldl (int, const short *);
13274 vector unsigned short vec_ldl (int, const vector unsigned short *);
13275 vector unsigned short vec_ldl (int, const unsigned short *);
13276 vector bool char vec_ldl (int, const vector bool char *);
13277 vector signed char vec_ldl (int, const vector signed char *);
13278 vector signed char vec_ldl (int, const signed char *);
13279 vector unsigned char vec_ldl (int, const vector unsigned char *);
13280 vector unsigned char vec_ldl (int, const unsigned char *);
13281
13282 vector float vec_loge (vector float);
13283
13284 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
13285 vector unsigned char vec_lvsl (int, const volatile signed char *);
13286 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
13287 vector unsigned char vec_lvsl (int, const volatile short *);
13288 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
13289 vector unsigned char vec_lvsl (int, const volatile int *);
13290 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
13291 vector unsigned char vec_lvsl (int, const volatile long *);
13292 vector unsigned char vec_lvsl (int, const volatile float *);
13293
13294 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
13295 vector unsigned char vec_lvsr (int, const volatile signed char *);
13296 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
13297 vector unsigned char vec_lvsr (int, const volatile short *);
13298 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
13299 vector unsigned char vec_lvsr (int, const volatile int *);
13300 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
13301 vector unsigned char vec_lvsr (int, const volatile long *);
13302 vector unsigned char vec_lvsr (int, const volatile float *);
13303
13304 vector float vec_madd (vector float, vector float, vector float);
13305
13306 vector signed short vec_madds (vector signed short,
13307 vector signed short,
13308 vector signed short);
13309
13310 vector unsigned char vec_max (vector bool char, vector unsigned char);
13311 vector unsigned char vec_max (vector unsigned char, vector bool char);
13312 vector unsigned char vec_max (vector unsigned char,
13313 vector unsigned char);
13314 vector signed char vec_max (vector bool char, vector signed char);
13315 vector signed char vec_max (vector signed char, vector bool char);
13316 vector signed char vec_max (vector signed char, vector signed char);
13317 vector unsigned short vec_max (vector bool short,
13318 vector unsigned short);
13319 vector unsigned short vec_max (vector unsigned short,
13320 vector bool short);
13321 vector unsigned short vec_max (vector unsigned short,
13322 vector unsigned short);
13323 vector signed short vec_max (vector bool short, vector signed short);
13324 vector signed short vec_max (vector signed short, vector bool short);
13325 vector signed short vec_max (vector signed short, vector signed short);
13326 vector unsigned int vec_max (vector bool int, vector unsigned int);
13327 vector unsigned int vec_max (vector unsigned int, vector bool int);
13328 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
13329 vector signed int vec_max (vector bool int, vector signed int);
13330 vector signed int vec_max (vector signed int, vector bool int);
13331 vector signed int vec_max (vector signed int, vector signed int);
13332 vector float vec_max (vector float, vector float);
13333
13334 vector float vec_vmaxfp (vector float, vector float);
13335
13336 vector signed int vec_vmaxsw (vector bool int, vector signed int);
13337 vector signed int vec_vmaxsw (vector signed int, vector bool int);
13338 vector signed int vec_vmaxsw (vector signed int, vector signed int);
13339
13340 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
13341 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
13342 vector unsigned int vec_vmaxuw (vector unsigned int,
13343 vector unsigned int);
13344
13345 vector signed short vec_vmaxsh (vector bool short, vector signed short);
13346 vector signed short vec_vmaxsh (vector signed short, vector bool short);
13347 vector signed short vec_vmaxsh (vector signed short,
13348 vector signed short);
13349
13350 vector unsigned short vec_vmaxuh (vector bool short,
13351 vector unsigned short);
13352 vector unsigned short vec_vmaxuh (vector unsigned short,
13353 vector bool short);
13354 vector unsigned short vec_vmaxuh (vector unsigned short,
13355 vector unsigned short);
13356
13357 vector signed char vec_vmaxsb (vector bool char, vector signed char);
13358 vector signed char vec_vmaxsb (vector signed char, vector bool char);
13359 vector signed char vec_vmaxsb (vector signed char, vector signed char);
13360
13361 vector unsigned char vec_vmaxub (vector bool char,
13362 vector unsigned char);
13363 vector unsigned char vec_vmaxub (vector unsigned char,
13364 vector bool char);
13365 vector unsigned char vec_vmaxub (vector unsigned char,
13366 vector unsigned char);
13367
13368 vector bool char vec_mergeh (vector bool char, vector bool char);
13369 vector signed char vec_mergeh (vector signed char, vector signed char);
13370 vector unsigned char vec_mergeh (vector unsigned char,
13371 vector unsigned char);
13372 vector bool short vec_mergeh (vector bool short, vector bool short);
13373 vector pixel vec_mergeh (vector pixel, vector pixel);
13374 vector signed short vec_mergeh (vector signed short,
13375 vector signed short);
13376 vector unsigned short vec_mergeh (vector unsigned short,
13377 vector unsigned short);
13378 vector float vec_mergeh (vector float, vector float);
13379 vector bool int vec_mergeh (vector bool int, vector bool int);
13380 vector signed int vec_mergeh (vector signed int, vector signed int);
13381 vector unsigned int vec_mergeh (vector unsigned int,
13382 vector unsigned int);
13383
13384 vector float vec_vmrghw (vector float, vector float);
13385 vector bool int vec_vmrghw (vector bool int, vector bool int);
13386 vector signed int vec_vmrghw (vector signed int, vector signed int);
13387 vector unsigned int vec_vmrghw (vector unsigned int,
13388 vector unsigned int);
13389
13390 vector bool short vec_vmrghh (vector bool short, vector bool short);
13391 vector signed short vec_vmrghh (vector signed short,
13392 vector signed short);
13393 vector unsigned short vec_vmrghh (vector unsigned short,
13394 vector unsigned short);
13395 vector pixel vec_vmrghh (vector pixel, vector pixel);
13396
13397 vector bool char vec_vmrghb (vector bool char, vector bool char);
13398 vector signed char vec_vmrghb (vector signed char, vector signed char);
13399 vector unsigned char vec_vmrghb (vector unsigned char,
13400 vector unsigned char);
13401
13402 vector bool char vec_mergel (vector bool char, vector bool char);
13403 vector signed char vec_mergel (vector signed char, vector signed char);
13404 vector unsigned char vec_mergel (vector unsigned char,
13405 vector unsigned char);
13406 vector bool short vec_mergel (vector bool short, vector bool short);
13407 vector pixel vec_mergel (vector pixel, vector pixel);
13408 vector signed short vec_mergel (vector signed short,
13409 vector signed short);
13410 vector unsigned short vec_mergel (vector unsigned short,
13411 vector unsigned short);
13412 vector float vec_mergel (vector float, vector float);
13413 vector bool int vec_mergel (vector bool int, vector bool int);
13414 vector signed int vec_mergel (vector signed int, vector signed int);
13415 vector unsigned int vec_mergel (vector unsigned int,
13416 vector unsigned int);
13417
13418 vector float vec_vmrglw (vector float, vector float);
13419 vector signed int vec_vmrglw (vector signed int, vector signed int);
13420 vector unsigned int vec_vmrglw (vector unsigned int,
13421 vector unsigned int);
13422 vector bool int vec_vmrglw (vector bool int, vector bool int);
13423
13424 vector bool short vec_vmrglh (vector bool short, vector bool short);
13425 vector signed short vec_vmrglh (vector signed short,
13426 vector signed short);
13427 vector unsigned short vec_vmrglh (vector unsigned short,
13428 vector unsigned short);
13429 vector pixel vec_vmrglh (vector pixel, vector pixel);
13430
13431 vector bool char vec_vmrglb (vector bool char, vector bool char);
13432 vector signed char vec_vmrglb (vector signed char, vector signed char);
13433 vector unsigned char vec_vmrglb (vector unsigned char,
13434 vector unsigned char);
13435
13436 vector unsigned short vec_mfvscr (void);
13437
13438 vector unsigned char vec_min (vector bool char, vector unsigned char);
13439 vector unsigned char vec_min (vector unsigned char, vector bool char);
13440 vector unsigned char vec_min (vector unsigned char,
13441 vector unsigned char);
13442 vector signed char vec_min (vector bool char, vector signed char);
13443 vector signed char vec_min (vector signed char, vector bool char);
13444 vector signed char vec_min (vector signed char, vector signed char);
13445 vector unsigned short vec_min (vector bool short,
13446 vector unsigned short);
13447 vector unsigned short vec_min (vector unsigned short,
13448 vector bool short);
13449 vector unsigned short vec_min (vector unsigned short,
13450 vector unsigned short);
13451 vector signed short vec_min (vector bool short, vector signed short);
13452 vector signed short vec_min (vector signed short, vector bool short);
13453 vector signed short vec_min (vector signed short, vector signed short);
13454 vector unsigned int vec_min (vector bool int, vector unsigned int);
13455 vector unsigned int vec_min (vector unsigned int, vector bool int);
13456 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
13457 vector signed int vec_min (vector bool int, vector signed int);
13458 vector signed int vec_min (vector signed int, vector bool int);
13459 vector signed int vec_min (vector signed int, vector signed int);
13460 vector float vec_min (vector float, vector float);
13461
13462 vector float vec_vminfp (vector float, vector float);
13463
13464 vector signed int vec_vminsw (vector bool int, vector signed int);
13465 vector signed int vec_vminsw (vector signed int, vector bool int);
13466 vector signed int vec_vminsw (vector signed int, vector signed int);
13467
13468 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
13469 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
13470 vector unsigned int vec_vminuw (vector unsigned int,
13471 vector unsigned int);
13472
13473 vector signed short vec_vminsh (vector bool short, vector signed short);
13474 vector signed short vec_vminsh (vector signed short, vector bool short);
13475 vector signed short vec_vminsh (vector signed short,
13476 vector signed short);
13477
13478 vector unsigned short vec_vminuh (vector bool short,
13479 vector unsigned short);
13480 vector unsigned short vec_vminuh (vector unsigned short,
13481 vector bool short);
13482 vector unsigned short vec_vminuh (vector unsigned short,
13483 vector unsigned short);
13484
13485 vector signed char vec_vminsb (vector bool char, vector signed char);
13486 vector signed char vec_vminsb (vector signed char, vector bool char);
13487 vector signed char vec_vminsb (vector signed char, vector signed char);
13488
13489 vector unsigned char vec_vminub (vector bool char,
13490 vector unsigned char);
13491 vector unsigned char vec_vminub (vector unsigned char,
13492 vector bool char);
13493 vector unsigned char vec_vminub (vector unsigned char,
13494 vector unsigned char);
13495
13496 vector signed short vec_mladd (vector signed short,
13497 vector signed short,
13498 vector signed short);
13499 vector signed short vec_mladd (vector signed short,
13500 vector unsigned short,
13501 vector unsigned short);
13502 vector signed short vec_mladd (vector unsigned short,
13503 vector signed short,
13504 vector signed short);
13505 vector unsigned short vec_mladd (vector unsigned short,
13506 vector unsigned short,
13507 vector unsigned short);
13508
13509 vector signed short vec_mradds (vector signed short,
13510 vector signed short,
13511 vector signed short);
13512
13513 vector unsigned int vec_msum (vector unsigned char,
13514 vector unsigned char,
13515 vector unsigned int);
13516 vector signed int vec_msum (vector signed char,
13517 vector unsigned char,
13518 vector signed int);
13519 vector unsigned int vec_msum (vector unsigned short,
13520 vector unsigned short,
13521 vector unsigned int);
13522 vector signed int vec_msum (vector signed short,
13523 vector signed short,
13524 vector signed int);
13525
13526 vector signed int vec_vmsumshm (vector signed short,
13527 vector signed short,
13528 vector signed int);
13529
13530 vector unsigned int vec_vmsumuhm (vector unsigned short,
13531 vector unsigned short,
13532 vector unsigned int);
13533
13534 vector signed int vec_vmsummbm (vector signed char,
13535 vector unsigned char,
13536 vector signed int);
13537
13538 vector unsigned int vec_vmsumubm (vector unsigned char,
13539 vector unsigned char,
13540 vector unsigned int);
13541
13542 vector unsigned int vec_msums (vector unsigned short,
13543 vector unsigned short,
13544 vector unsigned int);
13545 vector signed int vec_msums (vector signed short,
13546 vector signed short,
13547 vector signed int);
13548
13549 vector signed int vec_vmsumshs (vector signed short,
13550 vector signed short,
13551 vector signed int);
13552
13553 vector unsigned int vec_vmsumuhs (vector unsigned short,
13554 vector unsigned short,
13555 vector unsigned int);
13556
13557 void vec_mtvscr (vector signed int);
13558 void vec_mtvscr (vector unsigned int);
13559 void vec_mtvscr (vector bool int);
13560 void vec_mtvscr (vector signed short);
13561 void vec_mtvscr (vector unsigned short);
13562 void vec_mtvscr (vector bool short);
13563 void vec_mtvscr (vector pixel);
13564 void vec_mtvscr (vector signed char);
13565 void vec_mtvscr (vector unsigned char);
13566 void vec_mtvscr (vector bool char);
13567
13568 vector unsigned short vec_mule (vector unsigned char,
13569 vector unsigned char);
13570 vector signed short vec_mule (vector signed char,
13571 vector signed char);
13572 vector unsigned int vec_mule (vector unsigned short,
13573 vector unsigned short);
13574 vector signed int vec_mule (vector signed short, vector signed short);
13575
13576 vector signed int vec_vmulesh (vector signed short,
13577 vector signed short);
13578
13579 vector unsigned int vec_vmuleuh (vector unsigned short,
13580 vector unsigned short);
13581
13582 vector signed short vec_vmulesb (vector signed char,
13583 vector signed char);
13584
13585 vector unsigned short vec_vmuleub (vector unsigned char,
13586 vector unsigned char);
13587
13588 vector unsigned short vec_mulo (vector unsigned char,
13589 vector unsigned char);
13590 vector signed short vec_mulo (vector signed char, vector signed char);
13591 vector unsigned int vec_mulo (vector unsigned short,
13592 vector unsigned short);
13593 vector signed int vec_mulo (vector signed short, vector signed short);
13594
13595 vector signed int vec_vmulosh (vector signed short,
13596 vector signed short);
13597
13598 vector unsigned int vec_vmulouh (vector unsigned short,
13599 vector unsigned short);
13600
13601 vector signed short vec_vmulosb (vector signed char,
13602 vector signed char);
13603
13604 vector unsigned short vec_vmuloub (vector unsigned char,
13605 vector unsigned char);
13606
13607 vector float vec_nmsub (vector float, vector float, vector float);
13608
13609 vector float vec_nor (vector float, vector float);
13610 vector signed int vec_nor (vector signed int, vector signed int);
13611 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
13612 vector bool int vec_nor (vector bool int, vector bool int);
13613 vector signed short vec_nor (vector signed short, vector signed short);
13614 vector unsigned short vec_nor (vector unsigned short,
13615 vector unsigned short);
13616 vector bool short vec_nor (vector bool short, vector bool short);
13617 vector signed char vec_nor (vector signed char, vector signed char);
13618 vector unsigned char vec_nor (vector unsigned char,
13619 vector unsigned char);
13620 vector bool char vec_nor (vector bool char, vector bool char);
13621
13622 vector float vec_or (vector float, vector float);
13623 vector float vec_or (vector float, vector bool int);
13624 vector float vec_or (vector bool int, vector float);
13625 vector bool int vec_or (vector bool int, vector bool int);
13626 vector signed int vec_or (vector bool int, vector signed int);
13627 vector signed int vec_or (vector signed int, vector bool int);
13628 vector signed int vec_or (vector signed int, vector signed int);
13629 vector unsigned int vec_or (vector bool int, vector unsigned int);
13630 vector unsigned int vec_or (vector unsigned int, vector bool int);
13631 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
13632 vector bool short vec_or (vector bool short, vector bool short);
13633 vector signed short vec_or (vector bool short, vector signed short);
13634 vector signed short vec_or (vector signed short, vector bool short);
13635 vector signed short vec_or (vector signed short, vector signed short);
13636 vector unsigned short vec_or (vector bool short, vector unsigned short);
13637 vector unsigned short vec_or (vector unsigned short, vector bool short);
13638 vector unsigned short vec_or (vector unsigned short,
13639 vector unsigned short);
13640 vector signed char vec_or (vector bool char, vector signed char);
13641 vector bool char vec_or (vector bool char, vector bool char);
13642 vector signed char vec_or (vector signed char, vector bool char);
13643 vector signed char vec_or (vector signed char, vector signed char);
13644 vector unsigned char vec_or (vector bool char, vector unsigned char);
13645 vector unsigned char vec_or (vector unsigned char, vector bool char);
13646 vector unsigned char vec_or (vector unsigned char,
13647 vector unsigned char);
13648
13649 vector signed char vec_pack (vector signed short, vector signed short);
13650 vector unsigned char vec_pack (vector unsigned short,
13651 vector unsigned short);
13652 vector bool char vec_pack (vector bool short, vector bool short);
13653 vector signed short vec_pack (vector signed int, vector signed int);
13654 vector unsigned short vec_pack (vector unsigned int,
13655 vector unsigned int);
13656 vector bool short vec_pack (vector bool int, vector bool int);
13657
13658 vector bool short vec_vpkuwum (vector bool int, vector bool int);
13659 vector signed short vec_vpkuwum (vector signed int, vector signed int);
13660 vector unsigned short vec_vpkuwum (vector unsigned int,
13661 vector unsigned int);
13662
13663 vector bool char vec_vpkuhum (vector bool short, vector bool short);
13664 vector signed char vec_vpkuhum (vector signed short,
13665 vector signed short);
13666 vector unsigned char vec_vpkuhum (vector unsigned short,
13667 vector unsigned short);
13668
13669 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
13670
13671 vector unsigned char vec_packs (vector unsigned short,
13672 vector unsigned short);
13673 vector signed char vec_packs (vector signed short, vector signed short);
13674 vector unsigned short vec_packs (vector unsigned int,
13675 vector unsigned int);
13676 vector signed short vec_packs (vector signed int, vector signed int);
13677
13678 vector signed short vec_vpkswss (vector signed int, vector signed int);
13679
13680 vector unsigned short vec_vpkuwus (vector unsigned int,
13681 vector unsigned int);
13682
13683 vector signed char vec_vpkshss (vector signed short,
13684 vector signed short);
13685
13686 vector unsigned char vec_vpkuhus (vector unsigned short,
13687 vector unsigned short);
13688
13689 vector unsigned char vec_packsu (vector unsigned short,
13690 vector unsigned short);
13691 vector unsigned char vec_packsu (vector signed short,
13692 vector signed short);
13693 vector unsigned short vec_packsu (vector unsigned int,
13694 vector unsigned int);
13695 vector unsigned short vec_packsu (vector signed int, vector signed int);
13696
13697 vector unsigned short vec_vpkswus (vector signed int,
13698 vector signed int);
13699
13700 vector unsigned char vec_vpkshus (vector signed short,
13701 vector signed short);
13702
13703 vector float vec_perm (vector float,
13704 vector float,
13705 vector unsigned char);
13706 vector signed int vec_perm (vector signed int,
13707 vector signed int,
13708 vector unsigned char);
13709 vector unsigned int vec_perm (vector unsigned int,
13710 vector unsigned int,
13711 vector unsigned char);
13712 vector bool int vec_perm (vector bool int,
13713 vector bool int,
13714 vector unsigned char);
13715 vector signed short vec_perm (vector signed short,
13716 vector signed short,
13717 vector unsigned char);
13718 vector unsigned short vec_perm (vector unsigned short,
13719 vector unsigned short,
13720 vector unsigned char);
13721 vector bool short vec_perm (vector bool short,
13722 vector bool short,
13723 vector unsigned char);
13724 vector pixel vec_perm (vector pixel,
13725 vector pixel,
13726 vector unsigned char);
13727 vector signed char vec_perm (vector signed char,
13728 vector signed char,
13729 vector unsigned char);
13730 vector unsigned char vec_perm (vector unsigned char,
13731 vector unsigned char,
13732 vector unsigned char);
13733 vector bool char vec_perm (vector bool char,
13734 vector bool char,
13735 vector unsigned char);
13736
13737 vector float vec_re (vector float);
13738
13739 vector signed char vec_rl (vector signed char,
13740 vector unsigned char);
13741 vector unsigned char vec_rl (vector unsigned char,
13742 vector unsigned char);
13743 vector signed short vec_rl (vector signed short, vector unsigned short);
13744 vector unsigned short vec_rl (vector unsigned short,
13745 vector unsigned short);
13746 vector signed int vec_rl (vector signed int, vector unsigned int);
13747 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
13748
13749 vector signed int vec_vrlw (vector signed int, vector unsigned int);
13750 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
13751
13752 vector signed short vec_vrlh (vector signed short,
13753 vector unsigned short);
13754 vector unsigned short vec_vrlh (vector unsigned short,
13755 vector unsigned short);
13756
13757 vector signed char vec_vrlb (vector signed char, vector unsigned char);
13758 vector unsigned char vec_vrlb (vector unsigned char,
13759 vector unsigned char);
13760
13761 vector float vec_round (vector float);
13762
13763 vector float vec_recip (vector float, vector float);
13764
13765 vector float vec_rsqrt (vector float);
13766
13767 vector float vec_rsqrte (vector float);
13768
13769 vector float vec_sel (vector float, vector float, vector bool int);
13770 vector float vec_sel (vector float, vector float, vector unsigned int);
13771 vector signed int vec_sel (vector signed int,
13772 vector signed int,
13773 vector bool int);
13774 vector signed int vec_sel (vector signed int,
13775 vector signed int,
13776 vector unsigned int);
13777 vector unsigned int vec_sel (vector unsigned int,
13778 vector unsigned int,
13779 vector bool int);
13780 vector unsigned int vec_sel (vector unsigned int,
13781 vector unsigned int,
13782 vector unsigned int);
13783 vector bool int vec_sel (vector bool int,
13784 vector bool int,
13785 vector bool int);
13786 vector bool int vec_sel (vector bool int,
13787 vector bool int,
13788 vector unsigned int);
13789 vector signed short vec_sel (vector signed short,
13790 vector signed short,
13791 vector bool short);
13792 vector signed short vec_sel (vector signed short,
13793 vector signed short,
13794 vector unsigned short);
13795 vector unsigned short vec_sel (vector unsigned short,
13796 vector unsigned short,
13797 vector bool short);
13798 vector unsigned short vec_sel (vector unsigned short,
13799 vector unsigned short,
13800 vector unsigned short);
13801 vector bool short vec_sel (vector bool short,
13802 vector bool short,
13803 vector bool short);
13804 vector bool short vec_sel (vector bool short,
13805 vector bool short,
13806 vector unsigned short);
13807 vector signed char vec_sel (vector signed char,
13808 vector signed char,
13809 vector bool char);
13810 vector signed char vec_sel (vector signed char,
13811 vector signed char,
13812 vector unsigned char);
13813 vector unsigned char vec_sel (vector unsigned char,
13814 vector unsigned char,
13815 vector bool char);
13816 vector unsigned char vec_sel (vector unsigned char,
13817 vector unsigned char,
13818 vector unsigned char);
13819 vector bool char vec_sel (vector bool char,
13820 vector bool char,
13821 vector bool char);
13822 vector bool char vec_sel (vector bool char,
13823 vector bool char,
13824 vector unsigned char);
13825
13826 vector signed char vec_sl (vector signed char,
13827 vector unsigned char);
13828 vector unsigned char vec_sl (vector unsigned char,
13829 vector unsigned char);
13830 vector signed short vec_sl (vector signed short, vector unsigned short);
13831 vector unsigned short vec_sl (vector unsigned short,
13832 vector unsigned short);
13833 vector signed int vec_sl (vector signed int, vector unsigned int);
13834 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
13835
13836 vector signed int vec_vslw (vector signed int, vector unsigned int);
13837 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
13838
13839 vector signed short vec_vslh (vector signed short,
13840 vector unsigned short);
13841 vector unsigned short vec_vslh (vector unsigned short,
13842 vector unsigned short);
13843
13844 vector signed char vec_vslb (vector signed char, vector unsigned char);
13845 vector unsigned char vec_vslb (vector unsigned char,
13846 vector unsigned char);
13847
13848 vector float vec_sld (vector float, vector float, const int);
13849 vector signed int vec_sld (vector signed int,
13850 vector signed int,
13851 const int);
13852 vector unsigned int vec_sld (vector unsigned int,
13853 vector unsigned int,
13854 const int);
13855 vector bool int vec_sld (vector bool int,
13856 vector bool int,
13857 const int);
13858 vector signed short vec_sld (vector signed short,
13859 vector signed short,
13860 const int);
13861 vector unsigned short vec_sld (vector unsigned short,
13862 vector unsigned short,
13863 const int);
13864 vector bool short vec_sld (vector bool short,
13865 vector bool short,
13866 const int);
13867 vector pixel vec_sld (vector pixel,
13868 vector pixel,
13869 const int);
13870 vector signed char vec_sld (vector signed char,
13871 vector signed char,
13872 const int);
13873 vector unsigned char vec_sld (vector unsigned char,
13874 vector unsigned char,
13875 const int);
13876 vector bool char vec_sld (vector bool char,
13877 vector bool char,
13878 const int);
13879
13880 vector signed int vec_sll (vector signed int,
13881 vector unsigned int);
13882 vector signed int vec_sll (vector signed int,
13883 vector unsigned short);
13884 vector signed int vec_sll (vector signed int,
13885 vector unsigned char);
13886 vector unsigned int vec_sll (vector unsigned int,
13887 vector unsigned int);
13888 vector unsigned int vec_sll (vector unsigned int,
13889 vector unsigned short);
13890 vector unsigned int vec_sll (vector unsigned int,
13891 vector unsigned char);
13892 vector bool int vec_sll (vector bool int,
13893 vector unsigned int);
13894 vector bool int vec_sll (vector bool int,
13895 vector unsigned short);
13896 vector bool int vec_sll (vector bool int,
13897 vector unsigned char);
13898 vector signed short vec_sll (vector signed short,
13899 vector unsigned int);
13900 vector signed short vec_sll (vector signed short,
13901 vector unsigned short);
13902 vector signed short vec_sll (vector signed short,
13903 vector unsigned char);
13904 vector unsigned short vec_sll (vector unsigned short,
13905 vector unsigned int);
13906 vector unsigned short vec_sll (vector unsigned short,
13907 vector unsigned short);
13908 vector unsigned short vec_sll (vector unsigned short,
13909 vector unsigned char);
13910 vector bool short vec_sll (vector bool short, vector unsigned int);
13911 vector bool short vec_sll (vector bool short, vector unsigned short);
13912 vector bool short vec_sll (vector bool short, vector unsigned char);
13913 vector pixel vec_sll (vector pixel, vector unsigned int);
13914 vector pixel vec_sll (vector pixel, vector unsigned short);
13915 vector pixel vec_sll (vector pixel, vector unsigned char);
13916 vector signed char vec_sll (vector signed char, vector unsigned int);
13917 vector signed char vec_sll (vector signed char, vector unsigned short);
13918 vector signed char vec_sll (vector signed char, vector unsigned char);
13919 vector unsigned char vec_sll (vector unsigned char,
13920 vector unsigned int);
13921 vector unsigned char vec_sll (vector unsigned char,
13922 vector unsigned short);
13923 vector unsigned char vec_sll (vector unsigned char,
13924 vector unsigned char);
13925 vector bool char vec_sll (vector bool char, vector unsigned int);
13926 vector bool char vec_sll (vector bool char, vector unsigned short);
13927 vector bool char vec_sll (vector bool char, vector unsigned char);
13928
13929 vector float vec_slo (vector float, vector signed char);
13930 vector float vec_slo (vector float, vector unsigned char);
13931 vector signed int vec_slo (vector signed int, vector signed char);
13932 vector signed int vec_slo (vector signed int, vector unsigned char);
13933 vector unsigned int vec_slo (vector unsigned int, vector signed char);
13934 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
13935 vector signed short vec_slo (vector signed short, vector signed char);
13936 vector signed short vec_slo (vector signed short, vector unsigned char);
13937 vector unsigned short vec_slo (vector unsigned short,
13938 vector signed char);
13939 vector unsigned short vec_slo (vector unsigned short,
13940 vector unsigned char);
13941 vector pixel vec_slo (vector pixel, vector signed char);
13942 vector pixel vec_slo (vector pixel, vector unsigned char);
13943 vector signed char vec_slo (vector signed char, vector signed char);
13944 vector signed char vec_slo (vector signed char, vector unsigned char);
13945 vector unsigned char vec_slo (vector unsigned char, vector signed char);
13946 vector unsigned char vec_slo (vector unsigned char,
13947 vector unsigned char);
13948
13949 vector signed char vec_splat (vector signed char, const int);
13950 vector unsigned char vec_splat (vector unsigned char, const int);
13951 vector bool char vec_splat (vector bool char, const int);
13952 vector signed short vec_splat (vector signed short, const int);
13953 vector unsigned short vec_splat (vector unsigned short, const int);
13954 vector bool short vec_splat (vector bool short, const int);
13955 vector pixel vec_splat (vector pixel, const int);
13956 vector float vec_splat (vector float, const int);
13957 vector signed int vec_splat (vector signed int, const int);
13958 vector unsigned int vec_splat (vector unsigned int, const int);
13959 vector bool int vec_splat (vector bool int, const int);
13960
13961 vector float vec_vspltw (vector float, const int);
13962 vector signed int vec_vspltw (vector signed int, const int);
13963 vector unsigned int vec_vspltw (vector unsigned int, const int);
13964 vector bool int vec_vspltw (vector bool int, const int);
13965
13966 vector bool short vec_vsplth (vector bool short, const int);
13967 vector signed short vec_vsplth (vector signed short, const int);
13968 vector unsigned short vec_vsplth (vector unsigned short, const int);
13969 vector pixel vec_vsplth (vector pixel, const int);
13970
13971 vector signed char vec_vspltb (vector signed char, const int);
13972 vector unsigned char vec_vspltb (vector unsigned char, const int);
13973 vector bool char vec_vspltb (vector bool char, const int);
13974
13975 vector signed char vec_splat_s8 (const int);
13976
13977 vector signed short vec_splat_s16 (const int);
13978
13979 vector signed int vec_splat_s32 (const int);
13980
13981 vector unsigned char vec_splat_u8 (const int);
13982
13983 vector unsigned short vec_splat_u16 (const int);
13984
13985 vector unsigned int vec_splat_u32 (const int);
13986
13987 vector signed char vec_sr (vector signed char, vector unsigned char);
13988 vector unsigned char vec_sr (vector unsigned char,
13989 vector unsigned char);
13990 vector signed short vec_sr (vector signed short,
13991 vector unsigned short);
13992 vector unsigned short vec_sr (vector unsigned short,
13993 vector unsigned short);
13994 vector signed int vec_sr (vector signed int, vector unsigned int);
13995 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
13996
13997 vector signed int vec_vsrw (vector signed int, vector unsigned int);
13998 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
13999
14000 vector signed short vec_vsrh (vector signed short,
14001 vector unsigned short);
14002 vector unsigned short vec_vsrh (vector unsigned short,
14003 vector unsigned short);
14004
14005 vector signed char vec_vsrb (vector signed char, vector unsigned char);
14006 vector unsigned char vec_vsrb (vector unsigned char,
14007 vector unsigned char);
14008
14009 vector signed char vec_sra (vector signed char, vector unsigned char);
14010 vector unsigned char vec_sra (vector unsigned char,
14011 vector unsigned char);
14012 vector signed short vec_sra (vector signed short,
14013 vector unsigned short);
14014 vector unsigned short vec_sra (vector unsigned short,
14015 vector unsigned short);
14016 vector signed int vec_sra (vector signed int, vector unsigned int);
14017 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
14018
14019 vector signed int vec_vsraw (vector signed int, vector unsigned int);
14020 vector unsigned int vec_vsraw (vector unsigned int,
14021 vector unsigned int);
14022
14023 vector signed short vec_vsrah (vector signed short,
14024 vector unsigned short);
14025 vector unsigned short vec_vsrah (vector unsigned short,
14026 vector unsigned short);
14027
14028 vector signed char vec_vsrab (vector signed char, vector unsigned char);
14029 vector unsigned char vec_vsrab (vector unsigned char,
14030 vector unsigned char);
14031
14032 vector signed int vec_srl (vector signed int, vector unsigned int);
14033 vector signed int vec_srl (vector signed int, vector unsigned short);
14034 vector signed int vec_srl (vector signed int, vector unsigned char);
14035 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
14036 vector unsigned int vec_srl (vector unsigned int,
14037 vector unsigned short);
14038 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
14039 vector bool int vec_srl (vector bool int, vector unsigned int);
14040 vector bool int vec_srl (vector bool int, vector unsigned short);
14041 vector bool int vec_srl (vector bool int, vector unsigned char);
14042 vector signed short vec_srl (vector signed short, vector unsigned int);
14043 vector signed short vec_srl (vector signed short,
14044 vector unsigned short);
14045 vector signed short vec_srl (vector signed short, vector unsigned char);
14046 vector unsigned short vec_srl (vector unsigned short,
14047 vector unsigned int);
14048 vector unsigned short vec_srl (vector unsigned short,
14049 vector unsigned short);
14050 vector unsigned short vec_srl (vector unsigned short,
14051 vector unsigned char);
14052 vector bool short vec_srl (vector bool short, vector unsigned int);
14053 vector bool short vec_srl (vector bool short, vector unsigned short);
14054 vector bool short vec_srl (vector bool short, vector unsigned char);
14055 vector pixel vec_srl (vector pixel, vector unsigned int);
14056 vector pixel vec_srl (vector pixel, vector unsigned short);
14057 vector pixel vec_srl (vector pixel, vector unsigned char);
14058 vector signed char vec_srl (vector signed char, vector unsigned int);
14059 vector signed char vec_srl (vector signed char, vector unsigned short);
14060 vector signed char vec_srl (vector signed char, vector unsigned char);
14061 vector unsigned char vec_srl (vector unsigned char,
14062 vector unsigned int);
14063 vector unsigned char vec_srl (vector unsigned char,
14064 vector unsigned short);
14065 vector unsigned char vec_srl (vector unsigned char,
14066 vector unsigned char);
14067 vector bool char vec_srl (vector bool char, vector unsigned int);
14068 vector bool char vec_srl (vector bool char, vector unsigned short);
14069 vector bool char vec_srl (vector bool char, vector unsigned char);
14070
14071 vector float vec_sro (vector float, vector signed char);
14072 vector float vec_sro (vector float, vector unsigned char);
14073 vector signed int vec_sro (vector signed int, vector signed char);
14074 vector signed int vec_sro (vector signed int, vector unsigned char);
14075 vector unsigned int vec_sro (vector unsigned int, vector signed char);
14076 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
14077 vector signed short vec_sro (vector signed short, vector signed char);
14078 vector signed short vec_sro (vector signed short, vector unsigned char);
14079 vector unsigned short vec_sro (vector unsigned short,
14080 vector signed char);
14081 vector unsigned short vec_sro (vector unsigned short,
14082 vector unsigned char);
14083 vector pixel vec_sro (vector pixel, vector signed char);
14084 vector pixel vec_sro (vector pixel, vector unsigned char);
14085 vector signed char vec_sro (vector signed char, vector signed char);
14086 vector signed char vec_sro (vector signed char, vector unsigned char);
14087 vector unsigned char vec_sro (vector unsigned char, vector signed char);
14088 vector unsigned char vec_sro (vector unsigned char,
14089 vector unsigned char);
14090
14091 void vec_st (vector float, int, vector float *);
14092 void vec_st (vector float, int, float *);
14093 void vec_st (vector signed int, int, vector signed int *);
14094 void vec_st (vector signed int, int, int *);
14095 void vec_st (vector unsigned int, int, vector unsigned int *);
14096 void vec_st (vector unsigned int, int, unsigned int *);
14097 void vec_st (vector bool int, int, vector bool int *);
14098 void vec_st (vector bool int, int, unsigned int *);
14099 void vec_st (vector bool int, int, int *);
14100 void vec_st (vector signed short, int, vector signed short *);
14101 void vec_st (vector signed short, int, short *);
14102 void vec_st (vector unsigned short, int, vector unsigned short *);
14103 void vec_st (vector unsigned short, int, unsigned short *);
14104 void vec_st (vector bool short, int, vector bool short *);
14105 void vec_st (vector bool short, int, unsigned short *);
14106 void vec_st (vector pixel, int, vector pixel *);
14107 void vec_st (vector pixel, int, unsigned short *);
14108 void vec_st (vector pixel, int, short *);
14109 void vec_st (vector bool short, int, short *);
14110 void vec_st (vector signed char, int, vector signed char *);
14111 void vec_st (vector signed char, int, signed char *);
14112 void vec_st (vector unsigned char, int, vector unsigned char *);
14113 void vec_st (vector unsigned char, int, unsigned char *);
14114 void vec_st (vector bool char, int, vector bool char *);
14115 void vec_st (vector bool char, int, unsigned char *);
14116 void vec_st (vector bool char, int, signed char *);
14117
14118 void vec_ste (vector signed char, int, signed char *);
14119 void vec_ste (vector unsigned char, int, unsigned char *);
14120 void vec_ste (vector bool char, int, signed char *);
14121 void vec_ste (vector bool char, int, unsigned char *);
14122 void vec_ste (vector signed short, int, short *);
14123 void vec_ste (vector unsigned short, int, unsigned short *);
14124 void vec_ste (vector bool short, int, short *);
14125 void vec_ste (vector bool short, int, unsigned short *);
14126 void vec_ste (vector pixel, int, short *);
14127 void vec_ste (vector pixel, int, unsigned short *);
14128 void vec_ste (vector float, int, float *);
14129 void vec_ste (vector signed int, int, int *);
14130 void vec_ste (vector unsigned int, int, unsigned int *);
14131 void vec_ste (vector bool int, int, int *);
14132 void vec_ste (vector bool int, int, unsigned int *);
14133
14134 void vec_stvewx (vector float, int, float *);
14135 void vec_stvewx (vector signed int, int, int *);
14136 void vec_stvewx (vector unsigned int, int, unsigned int *);
14137 void vec_stvewx (vector bool int, int, int *);
14138 void vec_stvewx (vector bool int, int, unsigned int *);
14139
14140 void vec_stvehx (vector signed short, int, short *);
14141 void vec_stvehx (vector unsigned short, int, unsigned short *);
14142 void vec_stvehx (vector bool short, int, short *);
14143 void vec_stvehx (vector bool short, int, unsigned short *);
14144 void vec_stvehx (vector pixel, int, short *);
14145 void vec_stvehx (vector pixel, int, unsigned short *);
14146
14147 void vec_stvebx (vector signed char, int, signed char *);
14148 void vec_stvebx (vector unsigned char, int, unsigned char *);
14149 void vec_stvebx (vector bool char, int, signed char *);
14150 void vec_stvebx (vector bool char, int, unsigned char *);
14151
14152 void vec_stl (vector float, int, vector float *);
14153 void vec_stl (vector float, int, float *);
14154 void vec_stl (vector signed int, int, vector signed int *);
14155 void vec_stl (vector signed int, int, int *);
14156 void vec_stl (vector unsigned int, int, vector unsigned int *);
14157 void vec_stl (vector unsigned int, int, unsigned int *);
14158 void vec_stl (vector bool int, int, vector bool int *);
14159 void vec_stl (vector bool int, int, unsigned int *);
14160 void vec_stl (vector bool int, int, int *);
14161 void vec_stl (vector signed short, int, vector signed short *);
14162 void vec_stl (vector signed short, int, short *);
14163 void vec_stl (vector unsigned short, int, vector unsigned short *);
14164 void vec_stl (vector unsigned short, int, unsigned short *);
14165 void vec_stl (vector bool short, int, vector bool short *);
14166 void vec_stl (vector bool short, int, unsigned short *);
14167 void vec_stl (vector bool short, int, short *);
14168 void vec_stl (vector pixel, int, vector pixel *);
14169 void vec_stl (vector pixel, int, unsigned short *);
14170 void vec_stl (vector pixel, int, short *);
14171 void vec_stl (vector signed char, int, vector signed char *);
14172 void vec_stl (vector signed char, int, signed char *);
14173 void vec_stl (vector unsigned char, int, vector unsigned char *);
14174 void vec_stl (vector unsigned char, int, unsigned char *);
14175 void vec_stl (vector bool char, int, vector bool char *);
14176 void vec_stl (vector bool char, int, unsigned char *);
14177 void vec_stl (vector bool char, int, signed char *);
14178
14179 vector signed char vec_sub (vector bool char, vector signed char);
14180 vector signed char vec_sub (vector signed char, vector bool char);
14181 vector signed char vec_sub (vector signed char, vector signed char);
14182 vector unsigned char vec_sub (vector bool char, vector unsigned char);
14183 vector unsigned char vec_sub (vector unsigned char, vector bool char);
14184 vector unsigned char vec_sub (vector unsigned char,
14185 vector unsigned char);
14186 vector signed short vec_sub (vector bool short, vector signed short);
14187 vector signed short vec_sub (vector signed short, vector bool short);
14188 vector signed short vec_sub (vector signed short, vector signed short);
14189 vector unsigned short vec_sub (vector bool short,
14190 vector unsigned short);
14191 vector unsigned short vec_sub (vector unsigned short,
14192 vector bool short);
14193 vector unsigned short vec_sub (vector unsigned short,
14194 vector unsigned short);
14195 vector signed int vec_sub (vector bool int, vector signed int);
14196 vector signed int vec_sub (vector signed int, vector bool int);
14197 vector signed int vec_sub (vector signed int, vector signed int);
14198 vector unsigned int vec_sub (vector bool int, vector unsigned int);
14199 vector unsigned int vec_sub (vector unsigned int, vector bool int);
14200 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
14201 vector float vec_sub (vector float, vector float);
14202
14203 vector float vec_vsubfp (vector float, vector float);
14204
14205 vector signed int vec_vsubuwm (vector bool int, vector signed int);
14206 vector signed int vec_vsubuwm (vector signed int, vector bool int);
14207 vector signed int vec_vsubuwm (vector signed int, vector signed int);
14208 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
14209 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
14210 vector unsigned int vec_vsubuwm (vector unsigned int,
14211 vector unsigned int);
14212
14213 vector signed short vec_vsubuhm (vector bool short,
14214 vector signed short);
14215 vector signed short vec_vsubuhm (vector signed short,
14216 vector bool short);
14217 vector signed short vec_vsubuhm (vector signed short,
14218 vector signed short);
14219 vector unsigned short vec_vsubuhm (vector bool short,
14220 vector unsigned short);
14221 vector unsigned short vec_vsubuhm (vector unsigned short,
14222 vector bool short);
14223 vector unsigned short vec_vsubuhm (vector unsigned short,
14224 vector unsigned short);
14225
14226 vector signed char vec_vsububm (vector bool char, vector signed char);
14227 vector signed char vec_vsububm (vector signed char, vector bool char);
14228 vector signed char vec_vsububm (vector signed char, vector signed char);
14229 vector unsigned char vec_vsububm (vector bool char,
14230 vector unsigned char);
14231 vector unsigned char vec_vsububm (vector unsigned char,
14232 vector bool char);
14233 vector unsigned char vec_vsububm (vector unsigned char,
14234 vector unsigned char);
14235
14236 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
14237
14238 vector unsigned char vec_subs (vector bool char, vector unsigned char);
14239 vector unsigned char vec_subs (vector unsigned char, vector bool char);
14240 vector unsigned char vec_subs (vector unsigned char,
14241 vector unsigned char);
14242 vector signed char vec_subs (vector bool char, vector signed char);
14243 vector signed char vec_subs (vector signed char, vector bool char);
14244 vector signed char vec_subs (vector signed char, vector signed char);
14245 vector unsigned short vec_subs (vector bool short,
14246 vector unsigned short);
14247 vector unsigned short vec_subs (vector unsigned short,
14248 vector bool short);
14249 vector unsigned short vec_subs (vector unsigned short,
14250 vector unsigned short);
14251 vector signed short vec_subs (vector bool short, vector signed short);
14252 vector signed short vec_subs (vector signed short, vector bool short);
14253 vector signed short vec_subs (vector signed short, vector signed short);
14254 vector unsigned int vec_subs (vector bool int, vector unsigned int);
14255 vector unsigned int vec_subs (vector unsigned int, vector bool int);
14256 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
14257 vector signed int vec_subs (vector bool int, vector signed int);
14258 vector signed int vec_subs (vector signed int, vector bool int);
14259 vector signed int vec_subs (vector signed int, vector signed int);
14260
14261 vector signed int vec_vsubsws (vector bool int, vector signed int);
14262 vector signed int vec_vsubsws (vector signed int, vector bool int);
14263 vector signed int vec_vsubsws (vector signed int, vector signed int);
14264
14265 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
14266 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
14267 vector unsigned int vec_vsubuws (vector unsigned int,
14268 vector unsigned int);
14269
14270 vector signed short vec_vsubshs (vector bool short,
14271 vector signed short);
14272 vector signed short vec_vsubshs (vector signed short,
14273 vector bool short);
14274 vector signed short vec_vsubshs (vector signed short,
14275 vector signed short);
14276
14277 vector unsigned short vec_vsubuhs (vector bool short,
14278 vector unsigned short);
14279 vector unsigned short vec_vsubuhs (vector unsigned short,
14280 vector bool short);
14281 vector unsigned short vec_vsubuhs (vector unsigned short,
14282 vector unsigned short);
14283
14284 vector signed char vec_vsubsbs (vector bool char, vector signed char);
14285 vector signed char vec_vsubsbs (vector signed char, vector bool char);
14286 vector signed char vec_vsubsbs (vector signed char, vector signed char);
14287
14288 vector unsigned char vec_vsububs (vector bool char,
14289 vector unsigned char);
14290 vector unsigned char vec_vsububs (vector unsigned char,
14291 vector bool char);
14292 vector unsigned char vec_vsububs (vector unsigned char,
14293 vector unsigned char);
14294
14295 vector unsigned int vec_sum4s (vector unsigned char,
14296 vector unsigned int);
14297 vector signed int vec_sum4s (vector signed char, vector signed int);
14298 vector signed int vec_sum4s (vector signed short, vector signed int);
14299
14300 vector signed int vec_vsum4shs (vector signed short, vector signed int);
14301
14302 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
14303
14304 vector unsigned int vec_vsum4ubs (vector unsigned char,
14305 vector unsigned int);
14306
14307 vector signed int vec_sum2s (vector signed int, vector signed int);
14308
14309 vector signed int vec_sums (vector signed int, vector signed int);
14310
14311 vector float vec_trunc (vector float);
14312
14313 vector signed short vec_unpackh (vector signed char);
14314 vector bool short vec_unpackh (vector bool char);
14315 vector signed int vec_unpackh (vector signed short);
14316 vector bool int vec_unpackh (vector bool short);
14317 vector unsigned int vec_unpackh (vector pixel);
14318
14319 vector bool int vec_vupkhsh (vector bool short);
14320 vector signed int vec_vupkhsh (vector signed short);
14321
14322 vector unsigned int vec_vupkhpx (vector pixel);
14323
14324 vector bool short vec_vupkhsb (vector bool char);
14325 vector signed short vec_vupkhsb (vector signed char);
14326
14327 vector signed short vec_unpackl (vector signed char);
14328 vector bool short vec_unpackl (vector bool char);
14329 vector unsigned int vec_unpackl (vector pixel);
14330 vector signed int vec_unpackl (vector signed short);
14331 vector bool int vec_unpackl (vector bool short);
14332
14333 vector unsigned int vec_vupklpx (vector pixel);
14334
14335 vector bool int vec_vupklsh (vector bool short);
14336 vector signed int vec_vupklsh (vector signed short);
14337
14338 vector bool short vec_vupklsb (vector bool char);
14339 vector signed short vec_vupklsb (vector signed char);
14340
14341 vector float vec_xor (vector float, vector float);
14342 vector float vec_xor (vector float, vector bool int);
14343 vector float vec_xor (vector bool int, vector float);
14344 vector bool int vec_xor (vector bool int, vector bool int);
14345 vector signed int vec_xor (vector bool int, vector signed int);
14346 vector signed int vec_xor (vector signed int, vector bool int);
14347 vector signed int vec_xor (vector signed int, vector signed int);
14348 vector unsigned int vec_xor (vector bool int, vector unsigned int);
14349 vector unsigned int vec_xor (vector unsigned int, vector bool int);
14350 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
14351 vector bool short vec_xor (vector bool short, vector bool short);
14352 vector signed short vec_xor (vector bool short, vector signed short);
14353 vector signed short vec_xor (vector signed short, vector bool short);
14354 vector signed short vec_xor (vector signed short, vector signed short);
14355 vector unsigned short vec_xor (vector bool short,
14356 vector unsigned short);
14357 vector unsigned short vec_xor (vector unsigned short,
14358 vector bool short);
14359 vector unsigned short vec_xor (vector unsigned short,
14360 vector unsigned short);
14361 vector signed char vec_xor (vector bool char, vector signed char);
14362 vector bool char vec_xor (vector bool char, vector bool char);
14363 vector signed char vec_xor (vector signed char, vector bool char);
14364 vector signed char vec_xor (vector signed char, vector signed char);
14365 vector unsigned char vec_xor (vector bool char, vector unsigned char);
14366 vector unsigned char vec_xor (vector unsigned char, vector bool char);
14367 vector unsigned char vec_xor (vector unsigned char,
14368 vector unsigned char);
14369
14370 int vec_all_eq (vector signed char, vector bool char);
14371 int vec_all_eq (vector signed char, vector signed char);
14372 int vec_all_eq (vector unsigned char, vector bool char);
14373 int vec_all_eq (vector unsigned char, vector unsigned char);
14374 int vec_all_eq (vector bool char, vector bool char);
14375 int vec_all_eq (vector bool char, vector unsigned char);
14376 int vec_all_eq (vector bool char, vector signed char);
14377 int vec_all_eq (vector signed short, vector bool short);
14378 int vec_all_eq (vector signed short, vector signed short);
14379 int vec_all_eq (vector unsigned short, vector bool short);
14380 int vec_all_eq (vector unsigned short, vector unsigned short);
14381 int vec_all_eq (vector bool short, vector bool short);
14382 int vec_all_eq (vector bool short, vector unsigned short);
14383 int vec_all_eq (vector bool short, vector signed short);
14384 int vec_all_eq (vector pixel, vector pixel);
14385 int vec_all_eq (vector signed int, vector bool int);
14386 int vec_all_eq (vector signed int, vector signed int);
14387 int vec_all_eq (vector unsigned int, vector bool int);
14388 int vec_all_eq (vector unsigned int, vector unsigned int);
14389 int vec_all_eq (vector bool int, vector bool int);
14390 int vec_all_eq (vector bool int, vector unsigned int);
14391 int vec_all_eq (vector bool int, vector signed int);
14392 int vec_all_eq (vector float, vector float);
14393
14394 int vec_all_ge (vector bool char, vector unsigned char);
14395 int vec_all_ge (vector unsigned char, vector bool char);
14396 int vec_all_ge (vector unsigned char, vector unsigned char);
14397 int vec_all_ge (vector bool char, vector signed char);
14398 int vec_all_ge (vector signed char, vector bool char);
14399 int vec_all_ge (vector signed char, vector signed char);
14400 int vec_all_ge (vector bool short, vector unsigned short);
14401 int vec_all_ge (vector unsigned short, vector bool short);
14402 int vec_all_ge (vector unsigned short, vector unsigned short);
14403 int vec_all_ge (vector signed short, vector signed short);
14404 int vec_all_ge (vector bool short, vector signed short);
14405 int vec_all_ge (vector signed short, vector bool short);
14406 int vec_all_ge (vector bool int, vector unsigned int);
14407 int vec_all_ge (vector unsigned int, vector bool int);
14408 int vec_all_ge (vector unsigned int, vector unsigned int);
14409 int vec_all_ge (vector bool int, vector signed int);
14410 int vec_all_ge (vector signed int, vector bool int);
14411 int vec_all_ge (vector signed int, vector signed int);
14412 int vec_all_ge (vector float, vector float);
14413
14414 int vec_all_gt (vector bool char, vector unsigned char);
14415 int vec_all_gt (vector unsigned char, vector bool char);
14416 int vec_all_gt (vector unsigned char, vector unsigned char);
14417 int vec_all_gt (vector bool char, vector signed char);
14418 int vec_all_gt (vector signed char, vector bool char);
14419 int vec_all_gt (vector signed char, vector signed char);
14420 int vec_all_gt (vector bool short, vector unsigned short);
14421 int vec_all_gt (vector unsigned short, vector bool short);
14422 int vec_all_gt (vector unsigned short, vector unsigned short);
14423 int vec_all_gt (vector bool short, vector signed short);
14424 int vec_all_gt (vector signed short, vector bool short);
14425 int vec_all_gt (vector signed short, vector signed short);
14426 int vec_all_gt (vector bool int, vector unsigned int);
14427 int vec_all_gt (vector unsigned int, vector bool int);
14428 int vec_all_gt (vector unsigned int, vector unsigned int);
14429 int vec_all_gt (vector bool int, vector signed int);
14430 int vec_all_gt (vector signed int, vector bool int);
14431 int vec_all_gt (vector signed int, vector signed int);
14432 int vec_all_gt (vector float, vector float);
14433
14434 int vec_all_in (vector float, vector float);
14435
14436 int vec_all_le (vector bool char, vector unsigned char);
14437 int vec_all_le (vector unsigned char, vector bool char);
14438 int vec_all_le (vector unsigned char, vector unsigned char);
14439 int vec_all_le (vector bool char, vector signed char);
14440 int vec_all_le (vector signed char, vector bool char);
14441 int vec_all_le (vector signed char, vector signed char);
14442 int vec_all_le (vector bool short, vector unsigned short);
14443 int vec_all_le (vector unsigned short, vector bool short);
14444 int vec_all_le (vector unsigned short, vector unsigned short);
14445 int vec_all_le (vector bool short, vector signed short);
14446 int vec_all_le (vector signed short, vector bool short);
14447 int vec_all_le (vector signed short, vector signed short);
14448 int vec_all_le (vector bool int, vector unsigned int);
14449 int vec_all_le (vector unsigned int, vector bool int);
14450 int vec_all_le (vector unsigned int, vector unsigned int);
14451 int vec_all_le (vector bool int, vector signed int);
14452 int vec_all_le (vector signed int, vector bool int);
14453 int vec_all_le (vector signed int, vector signed int);
14454 int vec_all_le (vector float, vector float);
14455
14456 int vec_all_lt (vector bool char, vector unsigned char);
14457 int vec_all_lt (vector unsigned char, vector bool char);
14458 int vec_all_lt (vector unsigned char, vector unsigned char);
14459 int vec_all_lt (vector bool char, vector signed char);
14460 int vec_all_lt (vector signed char, vector bool char);
14461 int vec_all_lt (vector signed char, vector signed char);
14462 int vec_all_lt (vector bool short, vector unsigned short);
14463 int vec_all_lt (vector unsigned short, vector bool short);
14464 int vec_all_lt (vector unsigned short, vector unsigned short);
14465 int vec_all_lt (vector bool short, vector signed short);
14466 int vec_all_lt (vector signed short, vector bool short);
14467 int vec_all_lt (vector signed short, vector signed short);
14468 int vec_all_lt (vector bool int, vector unsigned int);
14469 int vec_all_lt (vector unsigned int, vector bool int);
14470 int vec_all_lt (vector unsigned int, vector unsigned int);
14471 int vec_all_lt (vector bool int, vector signed int);
14472 int vec_all_lt (vector signed int, vector bool int);
14473 int vec_all_lt (vector signed int, vector signed int);
14474 int vec_all_lt (vector float, vector float);
14475
14476 int vec_all_nan (vector float);
14477
14478 int vec_all_ne (vector signed char, vector bool char);
14479 int vec_all_ne (vector signed char, vector signed char);
14480 int vec_all_ne (vector unsigned char, vector bool char);
14481 int vec_all_ne (vector unsigned char, vector unsigned char);
14482 int vec_all_ne (vector bool char, vector bool char);
14483 int vec_all_ne (vector bool char, vector unsigned char);
14484 int vec_all_ne (vector bool char, vector signed char);
14485 int vec_all_ne (vector signed short, vector bool short);
14486 int vec_all_ne (vector signed short, vector signed short);
14487 int vec_all_ne (vector unsigned short, vector bool short);
14488 int vec_all_ne (vector unsigned short, vector unsigned short);
14489 int vec_all_ne (vector bool short, vector bool short);
14490 int vec_all_ne (vector bool short, vector unsigned short);
14491 int vec_all_ne (vector bool short, vector signed short);
14492 int vec_all_ne (vector pixel, vector pixel);
14493 int vec_all_ne (vector signed int, vector bool int);
14494 int vec_all_ne (vector signed int, vector signed int);
14495 int vec_all_ne (vector unsigned int, vector bool int);
14496 int vec_all_ne (vector unsigned int, vector unsigned int);
14497 int vec_all_ne (vector bool int, vector bool int);
14498 int vec_all_ne (vector bool int, vector unsigned int);
14499 int vec_all_ne (vector bool int, vector signed int);
14500 int vec_all_ne (vector float, vector float);
14501
14502 int vec_all_nge (vector float, vector float);
14503
14504 int vec_all_ngt (vector float, vector float);
14505
14506 int vec_all_nle (vector float, vector float);
14507
14508 int vec_all_nlt (vector float, vector float);
14509
14510 int vec_all_numeric (vector float);
14511
14512 int vec_any_eq (vector signed char, vector bool char);
14513 int vec_any_eq (vector signed char, vector signed char);
14514 int vec_any_eq (vector unsigned char, vector bool char);
14515 int vec_any_eq (vector unsigned char, vector unsigned char);
14516 int vec_any_eq (vector bool char, vector bool char);
14517 int vec_any_eq (vector bool char, vector unsigned char);
14518 int vec_any_eq (vector bool char, vector signed char);
14519 int vec_any_eq (vector signed short, vector bool short);
14520 int vec_any_eq (vector signed short, vector signed short);
14521 int vec_any_eq (vector unsigned short, vector bool short);
14522 int vec_any_eq (vector unsigned short, vector unsigned short);
14523 int vec_any_eq (vector bool short, vector bool short);
14524 int vec_any_eq (vector bool short, vector unsigned short);
14525 int vec_any_eq (vector bool short, vector signed short);
14526 int vec_any_eq (vector pixel, vector pixel);
14527 int vec_any_eq (vector signed int, vector bool int);
14528 int vec_any_eq (vector signed int, vector signed int);
14529 int vec_any_eq (vector unsigned int, vector bool int);
14530 int vec_any_eq (vector unsigned int, vector unsigned int);
14531 int vec_any_eq (vector bool int, vector bool int);
14532 int vec_any_eq (vector bool int, vector unsigned int);
14533 int vec_any_eq (vector bool int, vector signed int);
14534 int vec_any_eq (vector float, vector float);
14535
14536 int vec_any_ge (vector signed char, vector bool char);
14537 int vec_any_ge (vector unsigned char, vector bool char);
14538 int vec_any_ge (vector unsigned char, vector unsigned char);
14539 int vec_any_ge (vector signed char, vector signed char);
14540 int vec_any_ge (vector bool char, vector unsigned char);
14541 int vec_any_ge (vector bool char, vector signed char);
14542 int vec_any_ge (vector unsigned short, vector bool short);
14543 int vec_any_ge (vector unsigned short, vector unsigned short);
14544 int vec_any_ge (vector signed short, vector signed short);
14545 int vec_any_ge (vector signed short, vector bool short);
14546 int vec_any_ge (vector bool short, vector unsigned short);
14547 int vec_any_ge (vector bool short, vector signed short);
14548 int vec_any_ge (vector signed int, vector bool int);
14549 int vec_any_ge (vector unsigned int, vector bool int);
14550 int vec_any_ge (vector unsigned int, vector unsigned int);
14551 int vec_any_ge (vector signed int, vector signed int);
14552 int vec_any_ge (vector bool int, vector unsigned int);
14553 int vec_any_ge (vector bool int, vector signed int);
14554 int vec_any_ge (vector float, vector float);
14555
14556 int vec_any_gt (vector bool char, vector unsigned char);
14557 int vec_any_gt (vector unsigned char, vector bool char);
14558 int vec_any_gt (vector unsigned char, vector unsigned char);
14559 int vec_any_gt (vector bool char, vector signed char);
14560 int vec_any_gt (vector signed char, vector bool char);
14561 int vec_any_gt (vector signed char, vector signed char);
14562 int vec_any_gt (vector bool short, vector unsigned short);
14563 int vec_any_gt (vector unsigned short, vector bool short);
14564 int vec_any_gt (vector unsigned short, vector unsigned short);
14565 int vec_any_gt (vector bool short, vector signed short);
14566 int vec_any_gt (vector signed short, vector bool short);
14567 int vec_any_gt (vector signed short, vector signed short);
14568 int vec_any_gt (vector bool int, vector unsigned int);
14569 int vec_any_gt (vector unsigned int, vector bool int);
14570 int vec_any_gt (vector unsigned int, vector unsigned int);
14571 int vec_any_gt (vector bool int, vector signed int);
14572 int vec_any_gt (vector signed int, vector bool int);
14573 int vec_any_gt (vector signed int, vector signed int);
14574 int vec_any_gt (vector float, vector float);
14575
14576 int vec_any_le (vector bool char, vector unsigned char);
14577 int vec_any_le (vector unsigned char, vector bool char);
14578 int vec_any_le (vector unsigned char, vector unsigned char);
14579 int vec_any_le (vector bool char, vector signed char);
14580 int vec_any_le (vector signed char, vector bool char);
14581 int vec_any_le (vector signed char, vector signed char);
14582 int vec_any_le (vector bool short, vector unsigned short);
14583 int vec_any_le (vector unsigned short, vector bool short);
14584 int vec_any_le (vector unsigned short, vector unsigned short);
14585 int vec_any_le (vector bool short, vector signed short);
14586 int vec_any_le (vector signed short, vector bool short);
14587 int vec_any_le (vector signed short, vector signed short);
14588 int vec_any_le (vector bool int, vector unsigned int);
14589 int vec_any_le (vector unsigned int, vector bool int);
14590 int vec_any_le (vector unsigned int, vector unsigned int);
14591 int vec_any_le (vector bool int, vector signed int);
14592 int vec_any_le (vector signed int, vector bool int);
14593 int vec_any_le (vector signed int, vector signed int);
14594 int vec_any_le (vector float, vector float);
14595
14596 int vec_any_lt (vector bool char, vector unsigned char);
14597 int vec_any_lt (vector unsigned char, vector bool char);
14598 int vec_any_lt (vector unsigned char, vector unsigned char);
14599 int vec_any_lt (vector bool char, vector signed char);
14600 int vec_any_lt (vector signed char, vector bool char);
14601 int vec_any_lt (vector signed char, vector signed char);
14602 int vec_any_lt (vector bool short, vector unsigned short);
14603 int vec_any_lt (vector unsigned short, vector bool short);
14604 int vec_any_lt (vector unsigned short, vector unsigned short);
14605 int vec_any_lt (vector bool short, vector signed short);
14606 int vec_any_lt (vector signed short, vector bool short);
14607 int vec_any_lt (vector signed short, vector signed short);
14608 int vec_any_lt (vector bool int, vector unsigned int);
14609 int vec_any_lt (vector unsigned int, vector bool int);
14610 int vec_any_lt (vector unsigned int, vector unsigned int);
14611 int vec_any_lt (vector bool int, vector signed int);
14612 int vec_any_lt (vector signed int, vector bool int);
14613 int vec_any_lt (vector signed int, vector signed int);
14614 int vec_any_lt (vector float, vector float);
14615
14616 int vec_any_nan (vector float);
14617
14618 int vec_any_ne (vector signed char, vector bool char);
14619 int vec_any_ne (vector signed char, vector signed char);
14620 int vec_any_ne (vector unsigned char, vector bool char);
14621 int vec_any_ne (vector unsigned char, vector unsigned char);
14622 int vec_any_ne (vector bool char, vector bool char);
14623 int vec_any_ne (vector bool char, vector unsigned char);
14624 int vec_any_ne (vector bool char, vector signed char);
14625 int vec_any_ne (vector signed short, vector bool short);
14626 int vec_any_ne (vector signed short, vector signed short);
14627 int vec_any_ne (vector unsigned short, vector bool short);
14628 int vec_any_ne (vector unsigned short, vector unsigned short);
14629 int vec_any_ne (vector bool short, vector bool short);
14630 int vec_any_ne (vector bool short, vector unsigned short);
14631 int vec_any_ne (vector bool short, vector signed short);
14632 int vec_any_ne (vector pixel, vector pixel);
14633 int vec_any_ne (vector signed int, vector bool int);
14634 int vec_any_ne (vector signed int, vector signed int);
14635 int vec_any_ne (vector unsigned int, vector bool int);
14636 int vec_any_ne (vector unsigned int, vector unsigned int);
14637 int vec_any_ne (vector bool int, vector bool int);
14638 int vec_any_ne (vector bool int, vector unsigned int);
14639 int vec_any_ne (vector bool int, vector signed int);
14640 int vec_any_ne (vector float, vector float);
14641
14642 int vec_any_nge (vector float, vector float);
14643
14644 int vec_any_ngt (vector float, vector float);
14645
14646 int vec_any_nle (vector float, vector float);
14647
14648 int vec_any_nlt (vector float, vector float);
14649
14650 int vec_any_numeric (vector float);
14651
14652 int vec_any_out (vector float, vector float);
14653 @end smallexample
14654
14655 If the vector/scalar (VSX) instruction set is available, the following
14656 additional functions are available:
14657
14658 @smallexample
14659 vector double vec_abs (vector double);
14660 vector double vec_add (vector double, vector double);
14661 vector double vec_and (vector double, vector double);
14662 vector double vec_and (vector double, vector bool long);
14663 vector double vec_and (vector bool long, vector double);
14664 vector double vec_andc (vector double, vector double);
14665 vector double vec_andc (vector double, vector bool long);
14666 vector double vec_andc (vector bool long, vector double);
14667 vector double vec_ceil (vector double);
14668 vector bool long vec_cmpeq (vector double, vector double);
14669 vector bool long vec_cmpge (vector double, vector double);
14670 vector bool long vec_cmpgt (vector double, vector double);
14671 vector bool long vec_cmple (vector double, vector double);
14672 vector bool long vec_cmplt (vector double, vector double);
14673 vector float vec_div (vector float, vector float);
14674 vector double vec_div (vector double, vector double);
14675 vector double vec_floor (vector double);
14676 vector double vec_ld (int, const vector double *);
14677 vector double vec_ld (int, const double *);
14678 vector double vec_ldl (int, const vector double *);
14679 vector double vec_ldl (int, const double *);
14680 vector unsigned char vec_lvsl (int, const volatile double *);
14681 vector unsigned char vec_lvsr (int, const volatile double *);
14682 vector double vec_madd (vector double, vector double, vector double);
14683 vector double vec_max (vector double, vector double);
14684 vector double vec_min (vector double, vector double);
14685 vector float vec_msub (vector float, vector float, vector float);
14686 vector double vec_msub (vector double, vector double, vector double);
14687 vector float vec_mul (vector float, vector float);
14688 vector double vec_mul (vector double, vector double);
14689 vector float vec_nearbyint (vector float);
14690 vector double vec_nearbyint (vector double);
14691 vector float vec_nmadd (vector float, vector float, vector float);
14692 vector double vec_nmadd (vector double, vector double, vector double);
14693 vector double vec_nmsub (vector double, vector double, vector double);
14694 vector double vec_nor (vector double, vector double);
14695 vector double vec_or (vector double, vector double);
14696 vector double vec_or (vector double, vector bool long);
14697 vector double vec_or (vector bool long, vector double);
14698 vector double vec_perm (vector double,
14699 vector double,
14700 vector unsigned char);
14701 vector double vec_rint (vector double);
14702 vector double vec_recip (vector double, vector double);
14703 vector double vec_rsqrt (vector double);
14704 vector double vec_rsqrte (vector double);
14705 vector double vec_sel (vector double, vector double, vector bool long);
14706 vector double vec_sel (vector double, vector double, vector unsigned long);
14707 vector double vec_sub (vector double, vector double);
14708 vector float vec_sqrt (vector float);
14709 vector double vec_sqrt (vector double);
14710 void vec_st (vector double, int, vector double *);
14711 void vec_st (vector double, int, double *);
14712 vector double vec_trunc (vector double);
14713 vector double vec_xor (vector double, vector double);
14714 vector double vec_xor (vector double, vector bool long);
14715 vector double vec_xor (vector bool long, vector double);
14716 int vec_all_eq (vector double, vector double);
14717 int vec_all_ge (vector double, vector double);
14718 int vec_all_gt (vector double, vector double);
14719 int vec_all_le (vector double, vector double);
14720 int vec_all_lt (vector double, vector double);
14721 int vec_all_nan (vector double);
14722 int vec_all_ne (vector double, vector double);
14723 int vec_all_nge (vector double, vector double);
14724 int vec_all_ngt (vector double, vector double);
14725 int vec_all_nle (vector double, vector double);
14726 int vec_all_nlt (vector double, vector double);
14727 int vec_all_numeric (vector double);
14728 int vec_any_eq (vector double, vector double);
14729 int vec_any_ge (vector double, vector double);
14730 int vec_any_gt (vector double, vector double);
14731 int vec_any_le (vector double, vector double);
14732 int vec_any_lt (vector double, vector double);
14733 int vec_any_nan (vector double);
14734 int vec_any_ne (vector double, vector double);
14735 int vec_any_nge (vector double, vector double);
14736 int vec_any_ngt (vector double, vector double);
14737 int vec_any_nle (vector double, vector double);
14738 int vec_any_nlt (vector double, vector double);
14739 int vec_any_numeric (vector double);
14740
14741 vector double vec_vsx_ld (int, const vector double *);
14742 vector double vec_vsx_ld (int, const double *);
14743 vector float vec_vsx_ld (int, const vector float *);
14744 vector float vec_vsx_ld (int, const float *);
14745 vector bool int vec_vsx_ld (int, const vector bool int *);
14746 vector signed int vec_vsx_ld (int, const vector signed int *);
14747 vector signed int vec_vsx_ld (int, const int *);
14748 vector signed int vec_vsx_ld (int, const long *);
14749 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
14750 vector unsigned int vec_vsx_ld (int, const unsigned int *);
14751 vector unsigned int vec_vsx_ld (int, const unsigned long *);
14752 vector bool short vec_vsx_ld (int, const vector bool short *);
14753 vector pixel vec_vsx_ld (int, const vector pixel *);
14754 vector signed short vec_vsx_ld (int, const vector signed short *);
14755 vector signed short vec_vsx_ld (int, const short *);
14756 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
14757 vector unsigned short vec_vsx_ld (int, const unsigned short *);
14758 vector bool char vec_vsx_ld (int, const vector bool char *);
14759 vector signed char vec_vsx_ld (int, const vector signed char *);
14760 vector signed char vec_vsx_ld (int, const signed char *);
14761 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
14762 vector unsigned char vec_vsx_ld (int, const unsigned char *);
14763
14764 void vec_vsx_st (vector double, int, vector double *);
14765 void vec_vsx_st (vector double, int, double *);
14766 void vec_vsx_st (vector float, int, vector float *);
14767 void vec_vsx_st (vector float, int, float *);
14768 void vec_vsx_st (vector signed int, int, vector signed int *);
14769 void vec_vsx_st (vector signed int, int, int *);
14770 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
14771 void vec_vsx_st (vector unsigned int, int, unsigned int *);
14772 void vec_vsx_st (vector bool int, int, vector bool int *);
14773 void vec_vsx_st (vector bool int, int, unsigned int *);
14774 void vec_vsx_st (vector bool int, int, int *);
14775 void vec_vsx_st (vector signed short, int, vector signed short *);
14776 void vec_vsx_st (vector signed short, int, short *);
14777 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
14778 void vec_vsx_st (vector unsigned short, int, unsigned short *);
14779 void vec_vsx_st (vector bool short, int, vector bool short *);
14780 void vec_vsx_st (vector bool short, int, unsigned short *);
14781 void vec_vsx_st (vector pixel, int, vector pixel *);
14782 void vec_vsx_st (vector pixel, int, unsigned short *);
14783 void vec_vsx_st (vector pixel, int, short *);
14784 void vec_vsx_st (vector bool short, int, short *);
14785 void vec_vsx_st (vector signed char, int, vector signed char *);
14786 void vec_vsx_st (vector signed char, int, signed char *);
14787 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
14788 void vec_vsx_st (vector unsigned char, int, unsigned char *);
14789 void vec_vsx_st (vector bool char, int, vector bool char *);
14790 void vec_vsx_st (vector bool char, int, unsigned char *);
14791 void vec_vsx_st (vector bool char, int, signed char *);
14792 @end smallexample
14793
14794 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
14795 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
14796 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
14797 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
14798 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
14799
14800 If the ISA 2.07 additions to the vector/scalar (power8-vector)
14801 instruction set is available, the following additional functions are
14802 available for both 32-bit and 64-bit targets. For 64-bit targets, you
14803 can use @var{vector long} instead of @var{vector long long},
14804 @var{vector bool long} instead of @var{vector bool long long}, and
14805 @var{vector unsigned long} instead of @var{vector unsigned long long}.
14806
14807 @smallexample
14808 vector long long vec_abs (vector long long);
14809
14810 vector long long vec_add (vector long long, vector long long);
14811 vector unsigned long long vec_add (vector unsigned long long,
14812 vector unsigned long long);
14813
14814 int vec_all_eq (vector long long, vector long long);
14815 int vec_all_ge (vector long long, vector long long);
14816 int vec_all_gt (vector long long, vector long long);
14817 int vec_all_le (vector long long, vector long long);
14818 int vec_all_lt (vector long long, vector long long);
14819 int vec_all_ne (vector long long, vector long long);
14820 int vec_any_eq (vector long long, vector long long);
14821 int vec_any_ge (vector long long, vector long long);
14822 int vec_any_gt (vector long long, vector long long);
14823 int vec_any_le (vector long long, vector long long);
14824 int vec_any_lt (vector long long, vector long long);
14825 int vec_any_ne (vector long long, vector long long);
14826
14827 vector long long vec_eqv (vector long long, vector long long);
14828 vector long long vec_eqv (vector bool long long, vector long long);
14829 vector long long vec_eqv (vector long long, vector bool long long);
14830 vector unsigned long long vec_eqv (vector unsigned long long,
14831 vector unsigned long long);
14832 vector unsigned long long vec_eqv (vector bool long long,
14833 vector unsigned long long);
14834 vector unsigned long long vec_eqv (vector unsigned long long,
14835 vector bool long long);
14836 vector int vec_eqv (vector int, vector int);
14837 vector int vec_eqv (vector bool int, vector int);
14838 vector int vec_eqv (vector int, vector bool int);
14839 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
14840 vector unsigned int vec_eqv (vector bool unsigned int,
14841 vector unsigned int);
14842 vector unsigned int vec_eqv (vector unsigned int,
14843 vector bool unsigned int);
14844 vector short vec_eqv (vector short, vector short);
14845 vector short vec_eqv (vector bool short, vector short);
14846 vector short vec_eqv (vector short, vector bool short);
14847 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
14848 vector unsigned short vec_eqv (vector bool unsigned short,
14849 vector unsigned short);
14850 vector unsigned short vec_eqv (vector unsigned short,
14851 vector bool unsigned short);
14852 vector signed char vec_eqv (vector signed char, vector signed char);
14853 vector signed char vec_eqv (vector bool signed char, vector signed char);
14854 vector signed char vec_eqv (vector signed char, vector bool signed char);
14855 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
14856 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
14857 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
14858
14859 vector long long vec_max (vector long long, vector long long);
14860 vector unsigned long long vec_max (vector unsigned long long,
14861 vector unsigned long long);
14862
14863 vector long long vec_min (vector long long, vector long long);
14864 vector unsigned long long vec_min (vector unsigned long long,
14865 vector unsigned long long);
14866
14867 vector long long vec_nand (vector long long, vector long long);
14868 vector long long vec_nand (vector bool long long, vector long long);
14869 vector long long vec_nand (vector long long, vector bool long long);
14870 vector unsigned long long vec_nand (vector unsigned long long,
14871 vector unsigned long long);
14872 vector unsigned long long vec_nand (vector bool long long,
14873 vector unsigned long long);
14874 vector unsigned long long vec_nand (vector unsigned long long,
14875 vector bool long long);
14876 vector int vec_nand (vector int, vector int);
14877 vector int vec_nand (vector bool int, vector int);
14878 vector int vec_nand (vector int, vector bool int);
14879 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
14880 vector unsigned int vec_nand (vector bool unsigned int,
14881 vector unsigned int);
14882 vector unsigned int vec_nand (vector unsigned int,
14883 vector bool unsigned int);
14884 vector short vec_nand (vector short, vector short);
14885 vector short vec_nand (vector bool short, vector short);
14886 vector short vec_nand (vector short, vector bool short);
14887 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
14888 vector unsigned short vec_nand (vector bool unsigned short,
14889 vector unsigned short);
14890 vector unsigned short vec_nand (vector unsigned short,
14891 vector bool unsigned short);
14892 vector signed char vec_nand (vector signed char, vector signed char);
14893 vector signed char vec_nand (vector bool signed char, vector signed char);
14894 vector signed char vec_nand (vector signed char, vector bool signed char);
14895 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
14896 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
14897 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
14898
14899 vector long long vec_orc (vector long long, vector long long);
14900 vector long long vec_orc (vector bool long long, vector long long);
14901 vector long long vec_orc (vector long long, vector bool long long);
14902 vector unsigned long long vec_orc (vector unsigned long long,
14903 vector unsigned long long);
14904 vector unsigned long long vec_orc (vector bool long long,
14905 vector unsigned long long);
14906 vector unsigned long long vec_orc (vector unsigned long long,
14907 vector bool long long);
14908 vector int vec_orc (vector int, vector int);
14909 vector int vec_orc (vector bool int, vector int);
14910 vector int vec_orc (vector int, vector bool int);
14911 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
14912 vector unsigned int vec_orc (vector bool unsigned int,
14913 vector unsigned int);
14914 vector unsigned int vec_orc (vector unsigned int,
14915 vector bool unsigned int);
14916 vector short vec_orc (vector short, vector short);
14917 vector short vec_orc (vector bool short, vector short);
14918 vector short vec_orc (vector short, vector bool short);
14919 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
14920 vector unsigned short vec_orc (vector bool unsigned short,
14921 vector unsigned short);
14922 vector unsigned short vec_orc (vector unsigned short,
14923 vector bool unsigned short);
14924 vector signed char vec_orc (vector signed char, vector signed char);
14925 vector signed char vec_orc (vector bool signed char, vector signed char);
14926 vector signed char vec_orc (vector signed char, vector bool signed char);
14927 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
14928 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
14929 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
14930
14931 vector int vec_pack (vector long long, vector long long);
14932 vector unsigned int vec_pack (vector unsigned long long,
14933 vector unsigned long long);
14934 vector bool int vec_pack (vector bool long long, vector bool long long);
14935
14936 vector int vec_packs (vector long long, vector long long);
14937 vector unsigned int vec_packs (vector unsigned long long,
14938 vector unsigned long long);
14939
14940 vector unsigned int vec_packsu (vector long long, vector long long);
14941
14942 vector long long vec_rl (vector long long,
14943 vector unsigned long long);
14944 vector long long vec_rl (vector unsigned long long,
14945 vector unsigned long long);
14946
14947 vector long long vec_sl (vector long long, vector unsigned long long);
14948 vector long long vec_sl (vector unsigned long long,
14949 vector unsigned long long);
14950
14951 vector long long vec_sr (vector long long, vector unsigned long long);
14952 vector unsigned long long char vec_sr (vector unsigned long long,
14953 vector unsigned long long);
14954
14955 vector long long vec_sra (vector long long, vector unsigned long long);
14956 vector unsigned long long vec_sra (vector unsigned long long,
14957 vector unsigned long long);
14958
14959 vector long long vec_sub (vector long long, vector long long);
14960 vector unsigned long long vec_sub (vector unsigned long long,
14961 vector unsigned long long);
14962
14963 vector long long vec_unpackh (vector int);
14964 vector unsigned long long vec_unpackh (vector unsigned int);
14965
14966 vector long long vec_unpackl (vector int);
14967 vector unsigned long long vec_unpackl (vector unsigned int);
14968
14969 vector long long vec_vaddudm (vector long long, vector long long);
14970 vector long long vec_vaddudm (vector bool long long, vector long long);
14971 vector long long vec_vaddudm (vector long long, vector bool long long);
14972 vector unsigned long long vec_vaddudm (vector unsigned long long,
14973 vector unsigned long long);
14974 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
14975 vector unsigned long long);
14976 vector unsigned long long vec_vaddudm (vector unsigned long long,
14977 vector bool unsigned long long);
14978
14979 vector long long vec_vclz (vector long long);
14980 vector unsigned long long vec_vclz (vector unsigned long long);
14981 vector int vec_vclz (vector int);
14982 vector unsigned int vec_vclz (vector int);
14983 vector short vec_vclz (vector short);
14984 vector unsigned short vec_vclz (vector unsigned short);
14985 vector signed char vec_vclz (vector signed char);
14986 vector unsigned char vec_vclz (vector unsigned char);
14987
14988 vector signed char vec_vclzb (vector signed char);
14989 vector unsigned char vec_vclzb (vector unsigned char);
14990
14991 vector long long vec_vclzd (vector long long);
14992 vector unsigned long long vec_vclzd (vector unsigned long long);
14993
14994 vector short vec_vclzh (vector short);
14995 vector unsigned short vec_vclzh (vector unsigned short);
14996
14997 vector int vec_vclzw (vector int);
14998 vector unsigned int vec_vclzw (vector int);
14999
15000 vector long long vec_vmaxsd (vector long long, vector long long);
15001
15002 vector unsigned long long vec_vmaxud (vector unsigned long long,
15003 unsigned vector long long);
15004
15005 vector long long vec_vminsd (vector long long, vector long long);
15006
15007 vector unsigned long long vec_vminud (vector long long,
15008 vector long long);
15009
15010 vector int vec_vpksdss (vector long long, vector long long);
15011 vector unsigned int vec_vpksdss (vector long long, vector long long);
15012
15013 vector unsigned int vec_vpkudus (vector unsigned long long,
15014 vector unsigned long long);
15015
15016 vector int vec_vpkudum (vector long long, vector long long);
15017 vector unsigned int vec_vpkudum (vector unsigned long long,
15018 vector unsigned long long);
15019 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
15020
15021 vector long long vec_vpopcnt (vector long long);
15022 vector unsigned long long vec_vpopcnt (vector unsigned long long);
15023 vector int vec_vpopcnt (vector int);
15024 vector unsigned int vec_vpopcnt (vector int);
15025 vector short vec_vpopcnt (vector short);
15026 vector unsigned short vec_vpopcnt (vector unsigned short);
15027 vector signed char vec_vpopcnt (vector signed char);
15028 vector unsigned char vec_vpopcnt (vector unsigned char);
15029
15030 vector signed char vec_vpopcntb (vector signed char);
15031 vector unsigned char vec_vpopcntb (vector unsigned char);
15032
15033 vector long long vec_vpopcntd (vector long long);
15034 vector unsigned long long vec_vpopcntd (vector unsigned long long);
15035
15036 vector short vec_vpopcnth (vector short);
15037 vector unsigned short vec_vpopcnth (vector unsigned short);
15038
15039 vector int vec_vpopcntw (vector int);
15040 vector unsigned int vec_vpopcntw (vector int);
15041
15042 vector long long vec_vrld (vector long long, vector unsigned long long);
15043 vector unsigned long long vec_vrld (vector unsigned long long,
15044 vector unsigned long long);
15045
15046 vector long long vec_vsld (vector long long, vector unsigned long long);
15047 vector long long vec_vsld (vector unsigned long long,
15048 vector unsigned long long);
15049
15050 vector long long vec_vsrad (vector long long, vector unsigned long long);
15051 vector unsigned long long vec_vsrad (vector unsigned long long,
15052 vector unsigned long long);
15053
15054 vector long long vec_vsrd (vector long long, vector unsigned long long);
15055 vector unsigned long long char vec_vsrd (vector unsigned long long,
15056 vector unsigned long long);
15057
15058 vector long long vec_vsubudm (vector long long, vector long long);
15059 vector long long vec_vsubudm (vector bool long long, vector long long);
15060 vector long long vec_vsubudm (vector long long, vector bool long long);
15061 vector unsigned long long vec_vsubudm (vector unsigned long long,
15062 vector unsigned long long);
15063 vector unsigned long long vec_vsubudm (vector bool long long,
15064 vector unsigned long long);
15065 vector unsigned long long vec_vsubudm (vector unsigned long long,
15066 vector bool long long);
15067
15068 vector long long vec_vupkhsw (vector int);
15069 vector unsigned long long vec_vupkhsw (vector unsigned int);
15070
15071 vector long long vec_vupklsw (vector int);
15072 vector unsigned long long vec_vupklsw (vector int);
15073 @end smallexample
15074
15075 If the cryptographic instructions are enabled (@option{-mcrypto} or
15076 @option{-mcpu=power8}), the following builtins are enabled.
15077
15078 @smallexample
15079 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
15080
15081 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
15082 vector unsigned long long);
15083
15084 vector unsigned long long __builtin_crypto_vcipherlast
15085 (vector unsigned long long,
15086 vector unsigned long long);
15087
15088 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
15089 vector unsigned long long);
15090
15091 vector unsigned long long __builtin_crypto_vncipherlast
15092 (vector unsigned long long,
15093 vector unsigned long long);
15094
15095 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
15096 vector unsigned char,
15097 vector unsigned char);
15098
15099 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
15100 vector unsigned short,
15101 vector unsigned short);
15102
15103 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
15104 vector unsigned int,
15105 vector unsigned int);
15106
15107 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
15108 vector unsigned long long,
15109 vector unsigned long long);
15110
15111 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
15112 vector unsigned char);
15113
15114 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
15115 vector unsigned short);
15116
15117 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
15118 vector unsigned int);
15119
15120 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
15121 vector unsigned long long);
15122
15123 vector unsigned long long __builtin_crypto_vshasigmad
15124 (vector unsigned long long, int, int);
15125
15126 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
15127 int, int);
15128 @end smallexample
15129
15130 The second argument to the @var{__builtin_crypto_vshasigmad} and
15131 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
15132 integer that is 0 or 1. The third argument to these builtin functions
15133 must be a constant integer in the range of 0 to 15.
15134
15135 @node RX Built-in Functions
15136 @subsection RX Built-in Functions
15137 GCC supports some of the RX instructions which cannot be expressed in
15138 the C programming language via the use of built-in functions. The
15139 following functions are supported:
15140
15141 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
15142 Generates the @code{brk} machine instruction.
15143 @end deftypefn
15144
15145 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
15146 Generates the @code{clrpsw} machine instruction to clear the specified
15147 bit in the processor status word.
15148 @end deftypefn
15149
15150 @deftypefn {Built-in Function} void __builtin_rx_int (int)
15151 Generates the @code{int} machine instruction to generate an interrupt
15152 with the specified value.
15153 @end deftypefn
15154
15155 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
15156 Generates the @code{machi} machine instruction to add the result of
15157 multiplying the top 16 bits of the two arguments into the
15158 accumulator.
15159 @end deftypefn
15160
15161 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
15162 Generates the @code{maclo} machine instruction to add the result of
15163 multiplying the bottom 16 bits of the two arguments into the
15164 accumulator.
15165 @end deftypefn
15166
15167 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
15168 Generates the @code{mulhi} machine instruction to place the result of
15169 multiplying the top 16 bits of the two arguments into the
15170 accumulator.
15171 @end deftypefn
15172
15173 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
15174 Generates the @code{mullo} machine instruction to place the result of
15175 multiplying the bottom 16 bits of the two arguments into the
15176 accumulator.
15177 @end deftypefn
15178
15179 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
15180 Generates the @code{mvfachi} machine instruction to read the top
15181 32 bits of the accumulator.
15182 @end deftypefn
15183
15184 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
15185 Generates the @code{mvfacmi} machine instruction to read the middle
15186 32 bits of the accumulator.
15187 @end deftypefn
15188
15189 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
15190 Generates the @code{mvfc} machine instruction which reads the control
15191 register specified in its argument and returns its value.
15192 @end deftypefn
15193
15194 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
15195 Generates the @code{mvtachi} machine instruction to set the top
15196 32 bits of the accumulator.
15197 @end deftypefn
15198
15199 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
15200 Generates the @code{mvtaclo} machine instruction to set the bottom
15201 32 bits of the accumulator.
15202 @end deftypefn
15203
15204 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
15205 Generates the @code{mvtc} machine instruction which sets control
15206 register number @code{reg} to @code{val}.
15207 @end deftypefn
15208
15209 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
15210 Generates the @code{mvtipl} machine instruction set the interrupt
15211 priority level.
15212 @end deftypefn
15213
15214 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
15215 Generates the @code{racw} machine instruction to round the accumulator
15216 according to the specified mode.
15217 @end deftypefn
15218
15219 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
15220 Generates the @code{revw} machine instruction which swaps the bytes in
15221 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
15222 and also bits 16--23 occupy bits 24--31 and vice versa.
15223 @end deftypefn
15224
15225 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
15226 Generates the @code{rmpa} machine instruction which initiates a
15227 repeated multiply and accumulate sequence.
15228 @end deftypefn
15229
15230 @deftypefn {Built-in Function} void __builtin_rx_round (float)
15231 Generates the @code{round} machine instruction which returns the
15232 floating-point argument rounded according to the current rounding mode
15233 set in the floating-point status word register.
15234 @end deftypefn
15235
15236 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
15237 Generates the @code{sat} machine instruction which returns the
15238 saturated value of the argument.
15239 @end deftypefn
15240
15241 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
15242 Generates the @code{setpsw} machine instruction to set the specified
15243 bit in the processor status word.
15244 @end deftypefn
15245
15246 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
15247 Generates the @code{wait} machine instruction.
15248 @end deftypefn
15249
15250 @node S/390 System z Built-in Functions
15251 @subsection S/390 System z Built-in Functions
15252 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
15253 Generates the @code{tbegin} machine instruction starting a
15254 non-constraint hardware transaction. If the parameter is non-NULL the
15255 memory area is used to store the transaction diagnostic buffer and
15256 will be passed as first operand to @code{tbegin}. This buffer can be
15257 defined using the @code{struct __htm_tdb} C struct defined in
15258 @code{htmintrin.h} and must reside on a double-word boundary. The
15259 second tbegin operand is set to @code{0xff0c}. This enables
15260 save/restore of all GPRs and disables aborts for FPR and AR
15261 manipulations inside the transaction body. The condition code set by
15262 the tbegin instruction is returned as integer value. The tbegin
15263 instruction by definition overwrites the content of all FPRs. The
15264 compiler will generate code which saves and restores the FPRs. For
15265 soft-float code it is recommended to used the @code{*_nofloat}
15266 variant. In order to prevent a TDB from being written it is required
15267 to pass an constant zero value as parameter. Passing the zero value
15268 through a variable is not sufficient. Although modifications of
15269 access registers inside the transaction will not trigger an
15270 transaction abort it is not supported to actually modify them. Access
15271 registers do not get saved when entering a transaction. They will have
15272 undefined state when reaching the abort code.
15273 @end deftypefn
15274
15275 Macros for the possible return codes of tbegin are defined in the
15276 @code{htmintrin.h} header file:
15277
15278 @table @code
15279 @item _HTM_TBEGIN_STARTED
15280 @code{tbegin} has been executed as part of normal processing. The
15281 transaction body is supposed to be executed.
15282 @item _HTM_TBEGIN_INDETERMINATE
15283 The transaction was aborted due to an indeterminate condition which
15284 might be persistent.
15285 @item _HTM_TBEGIN_TRANSIENT
15286 The transaction aborted due to a transient failure. The transaction
15287 should be re-executed in that case.
15288 @item _HTM_TBEGIN_PERSISTENT
15289 The transaction aborted due to a persistent failure. Re-execution
15290 under same circumstances will not be productive.
15291 @end table
15292
15293 @defmac _HTM_FIRST_USER_ABORT_CODE
15294 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
15295 specifies the first abort code which can be used for
15296 @code{__builtin_tabort}. Values below this threshold are reserved for
15297 machine use.
15298 @end defmac
15299
15300 @deftp {Data type} {struct __htm_tdb}
15301 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
15302 the structure of the transaction diagnostic block as specified in the
15303 Principles of Operation manual chapter 5-91.
15304 @end deftp
15305
15306 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
15307 Same as @code{__builtin_tbegin} but without FPR saves and restores.
15308 Using this variant in code making use of FPRs will leave the FPRs in
15309 undefined state when entering the transaction abort handler code.
15310 @end deftypefn
15311
15312 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
15313 In addition to @code{__builtin_tbegin} a loop for transient failures
15314 is generated. If tbegin returns a condition code of 2 the transaction
15315 will be retried as often as specified in the second argument. The
15316 perform processor assist instruction is used to tell the CPU about the
15317 number of fails so far.
15318 @end deftypefn
15319
15320 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
15321 Same as @code{__builtin_tbegin_retry} but without FPR saves and
15322 restores. Using this variant in code making use of FPRs will leave
15323 the FPRs in undefined state when entering the transaction abort
15324 handler code.
15325 @end deftypefn
15326
15327 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
15328 Generates the @code{tbeginc} machine instruction starting a constraint
15329 hardware transaction. The second operand is set to @code{0xff08}.
15330 @end deftypefn
15331
15332 @deftypefn {Built-in Function} int __builtin_tend (void)
15333 Generates the @code{tend} machine instruction finishing a transaction
15334 and making the changes visible to other threads. The condition code
15335 generated by tend is returned as integer value.
15336 @end deftypefn
15337
15338 @deftypefn {Built-in Function} void __builtin_tabort (int)
15339 Generates the @code{tabort} machine instruction with the specified
15340 abort code. Abort codes from 0 through 255 are reserved and will
15341 result in an error message.
15342 @end deftypefn
15343
15344 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
15345 Generates the @code{ppa rX,rY,1} machine instruction. Where the
15346 integer parameter is loaded into rX and a value of zero is loaded into
15347 rY. The integer parameter specifies the number of times the
15348 transaction repeatedly aborted.
15349 @end deftypefn
15350
15351 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
15352 Generates the @code{etnd} machine instruction. The current nesting
15353 depth is returned as integer value. For a nesting depth of 0 the code
15354 is not executed as part of an transaction.
15355 @end deftypefn
15356
15357 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
15358
15359 Generates the @code{ntstg} machine instruction. The second argument
15360 is written to the first arguments location. The store operation will
15361 not be rolled-back in case of an transaction abort.
15362 @end deftypefn
15363
15364 @node SH Built-in Functions
15365 @subsection SH Built-in Functions
15366 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
15367 families of processors:
15368
15369 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
15370 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
15371 used by system code that manages threads and execution contexts. The compiler
15372 normally does not generate code that modifies the contents of @samp{GBR} and
15373 thus the value is preserved across function calls. Changing the @samp{GBR}
15374 value in user code must be done with caution, since the compiler might use
15375 @samp{GBR} in order to access thread local variables.
15376
15377 @end deftypefn
15378
15379 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
15380 Returns the value that is currently set in the @samp{GBR} register.
15381 Memory loads and stores that use the thread pointer as a base address are
15382 turned into @samp{GBR} based displacement loads and stores, if possible.
15383 For example:
15384 @smallexample
15385 struct my_tcb
15386 @{
15387 int a, b, c, d, e;
15388 @};
15389
15390 int get_tcb_value (void)
15391 @{
15392 // Generate @samp{mov.l @@(8,gbr),r0} instruction
15393 return ((my_tcb*)__builtin_thread_pointer ())->c;
15394 @}
15395
15396 @end smallexample
15397 @end deftypefn
15398
15399 @node SPARC VIS Built-in Functions
15400 @subsection SPARC VIS Built-in Functions
15401
15402 GCC supports SIMD operations on the SPARC using both the generic vector
15403 extensions (@pxref{Vector Extensions}) as well as built-in functions for
15404 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
15405 switch, the VIS extension is exposed as the following built-in functions:
15406
15407 @smallexample
15408 typedef int v1si __attribute__ ((vector_size (4)));
15409 typedef int v2si __attribute__ ((vector_size (8)));
15410 typedef short v4hi __attribute__ ((vector_size (8)));
15411 typedef short v2hi __attribute__ ((vector_size (4)));
15412 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
15413 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
15414
15415 void __builtin_vis_write_gsr (int64_t);
15416 int64_t __builtin_vis_read_gsr (void);
15417
15418 void * __builtin_vis_alignaddr (void *, long);
15419 void * __builtin_vis_alignaddrl (void *, long);
15420 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
15421 v2si __builtin_vis_faligndatav2si (v2si, v2si);
15422 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
15423 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
15424
15425 v4hi __builtin_vis_fexpand (v4qi);
15426
15427 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
15428 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
15429 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
15430 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
15431 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
15432 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
15433 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
15434
15435 v4qi __builtin_vis_fpack16 (v4hi);
15436 v8qi __builtin_vis_fpack32 (v2si, v8qi);
15437 v2hi __builtin_vis_fpackfix (v2si);
15438 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
15439
15440 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
15441
15442 long __builtin_vis_edge8 (void *, void *);
15443 long __builtin_vis_edge8l (void *, void *);
15444 long __builtin_vis_edge16 (void *, void *);
15445 long __builtin_vis_edge16l (void *, void *);
15446 long __builtin_vis_edge32 (void *, void *);
15447 long __builtin_vis_edge32l (void *, void *);
15448
15449 long __builtin_vis_fcmple16 (v4hi, v4hi);
15450 long __builtin_vis_fcmple32 (v2si, v2si);
15451 long __builtin_vis_fcmpne16 (v4hi, v4hi);
15452 long __builtin_vis_fcmpne32 (v2si, v2si);
15453 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
15454 long __builtin_vis_fcmpgt32 (v2si, v2si);
15455 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
15456 long __builtin_vis_fcmpeq32 (v2si, v2si);
15457
15458 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
15459 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
15460 v2si __builtin_vis_fpadd32 (v2si, v2si);
15461 v1si __builtin_vis_fpadd32s (v1si, v1si);
15462 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
15463 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
15464 v2si __builtin_vis_fpsub32 (v2si, v2si);
15465 v1si __builtin_vis_fpsub32s (v1si, v1si);
15466
15467 long __builtin_vis_array8 (long, long);
15468 long __builtin_vis_array16 (long, long);
15469 long __builtin_vis_array32 (long, long);
15470 @end smallexample
15471
15472 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
15473 functions also become available:
15474
15475 @smallexample
15476 long __builtin_vis_bmask (long, long);
15477 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
15478 v2si __builtin_vis_bshufflev2si (v2si, v2si);
15479 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
15480 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
15481
15482 long __builtin_vis_edge8n (void *, void *);
15483 long __builtin_vis_edge8ln (void *, void *);
15484 long __builtin_vis_edge16n (void *, void *);
15485 long __builtin_vis_edge16ln (void *, void *);
15486 long __builtin_vis_edge32n (void *, void *);
15487 long __builtin_vis_edge32ln (void *, void *);
15488 @end smallexample
15489
15490 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
15491 functions also become available:
15492
15493 @smallexample
15494 void __builtin_vis_cmask8 (long);
15495 void __builtin_vis_cmask16 (long);
15496 void __builtin_vis_cmask32 (long);
15497
15498 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
15499
15500 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
15501 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
15502 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
15503 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
15504 v2si __builtin_vis_fsll16 (v2si, v2si);
15505 v2si __builtin_vis_fslas16 (v2si, v2si);
15506 v2si __builtin_vis_fsrl16 (v2si, v2si);
15507 v2si __builtin_vis_fsra16 (v2si, v2si);
15508
15509 long __builtin_vis_pdistn (v8qi, v8qi);
15510
15511 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
15512
15513 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
15514 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
15515
15516 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
15517 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
15518 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
15519 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
15520 v2si __builtin_vis_fpadds32 (v2si, v2si);
15521 v1si __builtin_vis_fpadds32s (v1si, v1si);
15522 v2si __builtin_vis_fpsubs32 (v2si, v2si);
15523 v1si __builtin_vis_fpsubs32s (v1si, v1si);
15524
15525 long __builtin_vis_fucmple8 (v8qi, v8qi);
15526 long __builtin_vis_fucmpne8 (v8qi, v8qi);
15527 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
15528 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
15529
15530 float __builtin_vis_fhadds (float, float);
15531 double __builtin_vis_fhaddd (double, double);
15532 float __builtin_vis_fhsubs (float, float);
15533 double __builtin_vis_fhsubd (double, double);
15534 float __builtin_vis_fnhadds (float, float);
15535 double __builtin_vis_fnhaddd (double, double);
15536
15537 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
15538 int64_t __builtin_vis_xmulx (int64_t, int64_t);
15539 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
15540 @end smallexample
15541
15542 @node SPU Built-in Functions
15543 @subsection SPU Built-in Functions
15544
15545 GCC provides extensions for the SPU processor as described in the
15546 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
15547 found at @uref{http://cell.scei.co.jp/} or
15548 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
15549 implementation differs in several ways.
15550
15551 @itemize @bullet
15552
15553 @item
15554 The optional extension of specifying vector constants in parentheses is
15555 not supported.
15556
15557 @item
15558 A vector initializer requires no cast if the vector constant is of the
15559 same type as the variable it is initializing.
15560
15561 @item
15562 If @code{signed} or @code{unsigned} is omitted, the signedness of the
15563 vector type is the default signedness of the base type. The default
15564 varies depending on the operating system, so a portable program should
15565 always specify the signedness.
15566
15567 @item
15568 By default, the keyword @code{__vector} is added. The macro
15569 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
15570 undefined.
15571
15572 @item
15573 GCC allows using a @code{typedef} name as the type specifier for a
15574 vector type.
15575
15576 @item
15577 For C, overloaded functions are implemented with macros so the following
15578 does not work:
15579
15580 @smallexample
15581 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
15582 @end smallexample
15583
15584 @noindent
15585 Since @code{spu_add} is a macro, the vector constant in the example
15586 is treated as four separate arguments. Wrap the entire argument in
15587 parentheses for this to work.
15588
15589 @item
15590 The extended version of @code{__builtin_expect} is not supported.
15591
15592 @end itemize
15593
15594 @emph{Note:} Only the interface described in the aforementioned
15595 specification is supported. Internally, GCC uses built-in functions to
15596 implement the required functionality, but these are not supported and
15597 are subject to change without notice.
15598
15599 @node TI C6X Built-in Functions
15600 @subsection TI C6X Built-in Functions
15601
15602 GCC provides intrinsics to access certain instructions of the TI C6X
15603 processors. These intrinsics, listed below, are available after
15604 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
15605 to C6X instructions.
15606
15607 @smallexample
15608
15609 int _sadd (int, int)
15610 int _ssub (int, int)
15611 int _sadd2 (int, int)
15612 int _ssub2 (int, int)
15613 long long _mpy2 (int, int)
15614 long long _smpy2 (int, int)
15615 int _add4 (int, int)
15616 int _sub4 (int, int)
15617 int _saddu4 (int, int)
15618
15619 int _smpy (int, int)
15620 int _smpyh (int, int)
15621 int _smpyhl (int, int)
15622 int _smpylh (int, int)
15623
15624 int _sshl (int, int)
15625 int _subc (int, int)
15626
15627 int _avg2 (int, int)
15628 int _avgu4 (int, int)
15629
15630 int _clrr (int, int)
15631 int _extr (int, int)
15632 int _extru (int, int)
15633 int _abs (int)
15634 int _abs2 (int)
15635
15636 @end smallexample
15637
15638 @node TILE-Gx Built-in Functions
15639 @subsection TILE-Gx Built-in Functions
15640
15641 GCC provides intrinsics to access every instruction of the TILE-Gx
15642 processor. The intrinsics are of the form:
15643
15644 @smallexample
15645
15646 unsigned long long __insn_@var{op} (...)
15647
15648 @end smallexample
15649
15650 Where @var{op} is the name of the instruction. Refer to the ISA manual
15651 for the complete list of instructions.
15652
15653 GCC also provides intrinsics to directly access the network registers.
15654 The intrinsics are:
15655
15656 @smallexample
15657
15658 unsigned long long __tile_idn0_receive (void)
15659 unsigned long long __tile_idn1_receive (void)
15660 unsigned long long __tile_udn0_receive (void)
15661 unsigned long long __tile_udn1_receive (void)
15662 unsigned long long __tile_udn2_receive (void)
15663 unsigned long long __tile_udn3_receive (void)
15664 void __tile_idn_send (unsigned long long)
15665 void __tile_udn_send (unsigned long long)
15666
15667 @end smallexample
15668
15669 The intrinsic @code{void __tile_network_barrier (void)} is used to
15670 guarantee that no network operations before it are reordered with
15671 those after it.
15672
15673 @node TILEPro Built-in Functions
15674 @subsection TILEPro Built-in Functions
15675
15676 GCC provides intrinsics to access every instruction of the TILEPro
15677 processor. The intrinsics are of the form:
15678
15679 @smallexample
15680
15681 unsigned __insn_@var{op} (...)
15682
15683 @end smallexample
15684
15685 @noindent
15686 where @var{op} is the name of the instruction. Refer to the ISA manual
15687 for the complete list of instructions.
15688
15689 GCC also provides intrinsics to directly access the network registers.
15690 The intrinsics are:
15691
15692 @smallexample
15693
15694 unsigned __tile_idn0_receive (void)
15695 unsigned __tile_idn1_receive (void)
15696 unsigned __tile_sn_receive (void)
15697 unsigned __tile_udn0_receive (void)
15698 unsigned __tile_udn1_receive (void)
15699 unsigned __tile_udn2_receive (void)
15700 unsigned __tile_udn3_receive (void)
15701 void __tile_idn_send (unsigned)
15702 void __tile_sn_send (unsigned)
15703 void __tile_udn_send (unsigned)
15704
15705 @end smallexample
15706
15707 The intrinsic @code{void __tile_network_barrier (void)} is used to
15708 guarantee that no network operations before it are reordered with
15709 those after it.
15710
15711 @node Target Format Checks
15712 @section Format Checks Specific to Particular Target Machines
15713
15714 For some target machines, GCC supports additional options to the
15715 format attribute
15716 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
15717
15718 @menu
15719 * Solaris Format Checks::
15720 * Darwin Format Checks::
15721 @end menu
15722
15723 @node Solaris Format Checks
15724 @subsection Solaris Format Checks
15725
15726 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
15727 check. @code{cmn_err} accepts a subset of the standard @code{printf}
15728 conversions, and the two-argument @code{%b} conversion for displaying
15729 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
15730
15731 @node Darwin Format Checks
15732 @subsection Darwin Format Checks
15733
15734 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
15735 attribute context. Declarations made with such attribution are parsed for correct syntax
15736 and format argument types. However, parsing of the format string itself is currently undefined
15737 and is not carried out by this version of the compiler.
15738
15739 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
15740 also be used as format arguments. Note that the relevant headers are only likely to be
15741 available on Darwin (OSX) installations. On such installations, the XCode and system
15742 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
15743 associated functions.
15744
15745 @node Pragmas
15746 @section Pragmas Accepted by GCC
15747 @cindex pragmas
15748 @cindex @code{#pragma}
15749
15750 GCC supports several types of pragmas, primarily in order to compile
15751 code originally written for other compilers. Note that in general
15752 we do not recommend the use of pragmas; @xref{Function Attributes},
15753 for further explanation.
15754
15755 @menu
15756 * ARM Pragmas::
15757 * M32C Pragmas::
15758 * MeP Pragmas::
15759 * RS/6000 and PowerPC Pragmas::
15760 * Darwin Pragmas::
15761 * Solaris Pragmas::
15762 * Symbol-Renaming Pragmas::
15763 * Structure-Packing Pragmas::
15764 * Weak Pragmas::
15765 * Diagnostic Pragmas::
15766 * Visibility Pragmas::
15767 * Push/Pop Macro Pragmas::
15768 * Function Specific Option Pragmas::
15769 * Loop-Specific Pragmas::
15770 @end menu
15771
15772 @node ARM Pragmas
15773 @subsection ARM Pragmas
15774
15775 The ARM target defines pragmas for controlling the default addition of
15776 @code{long_call} and @code{short_call} attributes to functions.
15777 @xref{Function Attributes}, for information about the effects of these
15778 attributes.
15779
15780 @table @code
15781 @item long_calls
15782 @cindex pragma, long_calls
15783 Set all subsequent functions to have the @code{long_call} attribute.
15784
15785 @item no_long_calls
15786 @cindex pragma, no_long_calls
15787 Set all subsequent functions to have the @code{short_call} attribute.
15788
15789 @item long_calls_off
15790 @cindex pragma, long_calls_off
15791 Do not affect the @code{long_call} or @code{short_call} attributes of
15792 subsequent functions.
15793 @end table
15794
15795 @node M32C Pragmas
15796 @subsection M32C Pragmas
15797
15798 @table @code
15799 @item GCC memregs @var{number}
15800 @cindex pragma, memregs
15801 Overrides the command-line option @code{-memregs=} for the current
15802 file. Use with care! This pragma must be before any function in the
15803 file, and mixing different memregs values in different objects may
15804 make them incompatible. This pragma is useful when a
15805 performance-critical function uses a memreg for temporary values,
15806 as it may allow you to reduce the number of memregs used.
15807
15808 @item ADDRESS @var{name} @var{address}
15809 @cindex pragma, address
15810 For any declared symbols matching @var{name}, this does three things
15811 to that symbol: it forces the symbol to be located at the given
15812 address (a number), it forces the symbol to be volatile, and it
15813 changes the symbol's scope to be static. This pragma exists for
15814 compatibility with other compilers, but note that the common
15815 @code{1234H} numeric syntax is not supported (use @code{0x1234}
15816 instead). Example:
15817
15818 @smallexample
15819 #pragma ADDRESS port3 0x103
15820 char port3;
15821 @end smallexample
15822
15823 @end table
15824
15825 @node MeP Pragmas
15826 @subsection MeP Pragmas
15827
15828 @table @code
15829
15830 @item custom io_volatile (on|off)
15831 @cindex pragma, custom io_volatile
15832 Overrides the command-line option @code{-mio-volatile} for the current
15833 file. Note that for compatibility with future GCC releases, this
15834 option should only be used once before any @code{io} variables in each
15835 file.
15836
15837 @item GCC coprocessor available @var{registers}
15838 @cindex pragma, coprocessor available
15839 Specifies which coprocessor registers are available to the register
15840 allocator. @var{registers} may be a single register, register range
15841 separated by ellipses, or comma-separated list of those. Example:
15842
15843 @smallexample
15844 #pragma GCC coprocessor available $c0...$c10, $c28
15845 @end smallexample
15846
15847 @item GCC coprocessor call_saved @var{registers}
15848 @cindex pragma, coprocessor call_saved
15849 Specifies which coprocessor registers are to be saved and restored by
15850 any function using them. @var{registers} may be a single register,
15851 register range separated by ellipses, or comma-separated list of
15852 those. Example:
15853
15854 @smallexample
15855 #pragma GCC coprocessor call_saved $c4...$c6, $c31
15856 @end smallexample
15857
15858 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
15859 @cindex pragma, coprocessor subclass
15860 Creates and defines a register class. These register classes can be
15861 used by inline @code{asm} constructs. @var{registers} may be a single
15862 register, register range separated by ellipses, or comma-separated
15863 list of those. Example:
15864
15865 @smallexample
15866 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
15867
15868 asm ("cpfoo %0" : "=B" (x));
15869 @end smallexample
15870
15871 @item GCC disinterrupt @var{name} , @var{name} @dots{}
15872 @cindex pragma, disinterrupt
15873 For the named functions, the compiler adds code to disable interrupts
15874 for the duration of those functions. If any functions so named
15875 are not encountered in the source, a warning is emitted that the pragma is
15876 not used. Examples:
15877
15878 @smallexample
15879 #pragma disinterrupt foo
15880 #pragma disinterrupt bar, grill
15881 int foo () @{ @dots{} @}
15882 @end smallexample
15883
15884 @item GCC call @var{name} , @var{name} @dots{}
15885 @cindex pragma, call
15886 For the named functions, the compiler always uses a register-indirect
15887 call model when calling the named functions. Examples:
15888
15889 @smallexample
15890 extern int foo ();
15891 #pragma call foo
15892 @end smallexample
15893
15894 @end table
15895
15896 @node RS/6000 and PowerPC Pragmas
15897 @subsection RS/6000 and PowerPC Pragmas
15898
15899 The RS/6000 and PowerPC targets define one pragma for controlling
15900 whether or not the @code{longcall} attribute is added to function
15901 declarations by default. This pragma overrides the @option{-mlongcall}
15902 option, but not the @code{longcall} and @code{shortcall} attributes.
15903 @xref{RS/6000 and PowerPC Options}, for more information about when long
15904 calls are and are not necessary.
15905
15906 @table @code
15907 @item longcall (1)
15908 @cindex pragma, longcall
15909 Apply the @code{longcall} attribute to all subsequent function
15910 declarations.
15911
15912 @item longcall (0)
15913 Do not apply the @code{longcall} attribute to subsequent function
15914 declarations.
15915 @end table
15916
15917 @c Describe h8300 pragmas here.
15918 @c Describe sh pragmas here.
15919 @c Describe v850 pragmas here.
15920
15921 @node Darwin Pragmas
15922 @subsection Darwin Pragmas
15923
15924 The following pragmas are available for all architectures running the
15925 Darwin operating system. These are useful for compatibility with other
15926 Mac OS compilers.
15927
15928 @table @code
15929 @item mark @var{tokens}@dots{}
15930 @cindex pragma, mark
15931 This pragma is accepted, but has no effect.
15932
15933 @item options align=@var{alignment}
15934 @cindex pragma, options align
15935 This pragma sets the alignment of fields in structures. The values of
15936 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
15937 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
15938 properly; to restore the previous setting, use @code{reset} for the
15939 @var{alignment}.
15940
15941 @item segment @var{tokens}@dots{}
15942 @cindex pragma, segment
15943 This pragma is accepted, but has no effect.
15944
15945 @item unused (@var{var} [, @var{var}]@dots{})
15946 @cindex pragma, unused
15947 This pragma declares variables to be possibly unused. GCC does not
15948 produce warnings for the listed variables. The effect is similar to
15949 that of the @code{unused} attribute, except that this pragma may appear
15950 anywhere within the variables' scopes.
15951 @end table
15952
15953 @node Solaris Pragmas
15954 @subsection Solaris Pragmas
15955
15956 The Solaris target supports @code{#pragma redefine_extname}
15957 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
15958 @code{#pragma} directives for compatibility with the system compiler.
15959
15960 @table @code
15961 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
15962 @cindex pragma, align
15963
15964 Increase the minimum alignment of each @var{variable} to @var{alignment}.
15965 This is the same as GCC's @code{aligned} attribute @pxref{Variable
15966 Attributes}). Macro expansion occurs on the arguments to this pragma
15967 when compiling C and Objective-C@. It does not currently occur when
15968 compiling C++, but this is a bug which may be fixed in a future
15969 release.
15970
15971 @item fini (@var{function} [, @var{function}]...)
15972 @cindex pragma, fini
15973
15974 This pragma causes each listed @var{function} to be called after
15975 main, or during shared module unloading, by adding a call to the
15976 @code{.fini} section.
15977
15978 @item init (@var{function} [, @var{function}]...)
15979 @cindex pragma, init
15980
15981 This pragma causes each listed @var{function} to be called during
15982 initialization (before @code{main}) or during shared module loading, by
15983 adding a call to the @code{.init} section.
15984
15985 @end table
15986
15987 @node Symbol-Renaming Pragmas
15988 @subsection Symbol-Renaming Pragmas
15989
15990 For compatibility with the Solaris system headers, GCC
15991 supports two @code{#pragma} directives that change the name used in
15992 assembly for a given declaration. To get this effect
15993 on all platforms supported by GCC, use the asm labels extension (@pxref{Asm
15994 Labels}).
15995
15996 @table @code
15997 @item redefine_extname @var{oldname} @var{newname}
15998 @cindex pragma, redefine_extname
15999
16000 This pragma gives the C function @var{oldname} the assembly symbol
16001 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
16002 is defined if this pragma is available (currently on all platforms).
16003 @end table
16004
16005 This pragma and the asm labels extension interact in a complicated
16006 manner. Here are some corner cases you may want to be aware of.
16007
16008 @enumerate
16009 @item Both pragmas silently apply only to declarations with external
16010 linkage. Asm labels do not have this restriction.
16011
16012 @item In C++, both pragmas silently apply only to declarations with
16013 ``C'' linkage. Again, asm labels do not have this restriction.
16014
16015 @item If any of the three ways of changing the assembly name of a
16016 declaration is applied to a declaration whose assembly name has
16017 already been determined (either by a previous use of one of these
16018 features, or because the compiler needed the assembly name in order to
16019 generate code), and the new name is different, a warning issues and
16020 the name does not change.
16021
16022 @item The @var{oldname} used by @code{#pragma redefine_extname} is
16023 always the C-language name.
16024 @end enumerate
16025
16026 @node Structure-Packing Pragmas
16027 @subsection Structure-Packing Pragmas
16028
16029 For compatibility with Microsoft Windows compilers, GCC supports a
16030 set of @code{#pragma} directives that change the maximum alignment of
16031 members of structures (other than zero-width bit-fields), unions, and
16032 classes subsequently defined. The @var{n} value below always is required
16033 to be a small power of two and specifies the new alignment in bytes.
16034
16035 @enumerate
16036 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
16037 @item @code{#pragma pack()} sets the alignment to the one that was in
16038 effect when compilation started (see also command-line option
16039 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
16040 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
16041 setting on an internal stack and then optionally sets the new alignment.
16042 @item @code{#pragma pack(pop)} restores the alignment setting to the one
16043 saved at the top of the internal stack (and removes that stack entry).
16044 Note that @code{#pragma pack([@var{n}])} does not influence this internal
16045 stack; thus it is possible to have @code{#pragma pack(push)} followed by
16046 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
16047 @code{#pragma pack(pop)}.
16048 @end enumerate
16049
16050 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
16051 @code{#pragma} which lays out a structure as the documented
16052 @code{__attribute__ ((ms_struct))}.
16053 @enumerate
16054 @item @code{#pragma ms_struct on} turns on the layout for structures
16055 declared.
16056 @item @code{#pragma ms_struct off} turns off the layout for structures
16057 declared.
16058 @item @code{#pragma ms_struct reset} goes back to the default layout.
16059 @end enumerate
16060
16061 @node Weak Pragmas
16062 @subsection Weak Pragmas
16063
16064 For compatibility with SVR4, GCC supports a set of @code{#pragma}
16065 directives for declaring symbols to be weak, and defining weak
16066 aliases.
16067
16068 @table @code
16069 @item #pragma weak @var{symbol}
16070 @cindex pragma, weak
16071 This pragma declares @var{symbol} to be weak, as if the declaration
16072 had the attribute of the same name. The pragma may appear before
16073 or after the declaration of @var{symbol}. It is not an error for
16074 @var{symbol} to never be defined at all.
16075
16076 @item #pragma weak @var{symbol1} = @var{symbol2}
16077 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
16078 It is an error if @var{symbol2} is not defined in the current
16079 translation unit.
16080 @end table
16081
16082 @node Diagnostic Pragmas
16083 @subsection Diagnostic Pragmas
16084
16085 GCC allows the user to selectively enable or disable certain types of
16086 diagnostics, and change the kind of the diagnostic. For example, a
16087 project's policy might require that all sources compile with
16088 @option{-Werror} but certain files might have exceptions allowing
16089 specific types of warnings. Or, a project might selectively enable
16090 diagnostics and treat them as errors depending on which preprocessor
16091 macros are defined.
16092
16093 @table @code
16094 @item #pragma GCC diagnostic @var{kind} @var{option}
16095 @cindex pragma, diagnostic
16096
16097 Modifies the disposition of a diagnostic. Note that not all
16098 diagnostics are modifiable; at the moment only warnings (normally
16099 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
16100 Use @option{-fdiagnostics-show-option} to determine which diagnostics
16101 are controllable and which option controls them.
16102
16103 @var{kind} is @samp{error} to treat this diagnostic as an error,
16104 @samp{warning} to treat it like a warning (even if @option{-Werror} is
16105 in effect), or @samp{ignored} if the diagnostic is to be ignored.
16106 @var{option} is a double quoted string that matches the command-line
16107 option.
16108
16109 @smallexample
16110 #pragma GCC diagnostic warning "-Wformat"
16111 #pragma GCC diagnostic error "-Wformat"
16112 #pragma GCC diagnostic ignored "-Wformat"
16113 @end smallexample
16114
16115 Note that these pragmas override any command-line options. GCC keeps
16116 track of the location of each pragma, and issues diagnostics according
16117 to the state as of that point in the source file. Thus, pragmas occurring
16118 after a line do not affect diagnostics caused by that line.
16119
16120 @item #pragma GCC diagnostic push
16121 @itemx #pragma GCC diagnostic pop
16122
16123 Causes GCC to remember the state of the diagnostics as of each
16124 @code{push}, and restore to that point at each @code{pop}. If a
16125 @code{pop} has no matching @code{push}, the command-line options are
16126 restored.
16127
16128 @smallexample
16129 #pragma GCC diagnostic error "-Wuninitialized"
16130 foo(a); /* error is given for this one */
16131 #pragma GCC diagnostic push
16132 #pragma GCC diagnostic ignored "-Wuninitialized"
16133 foo(b); /* no diagnostic for this one */
16134 #pragma GCC diagnostic pop
16135 foo(c); /* error is given for this one */
16136 #pragma GCC diagnostic pop
16137 foo(d); /* depends on command-line options */
16138 @end smallexample
16139
16140 @end table
16141
16142 GCC also offers a simple mechanism for printing messages during
16143 compilation.
16144
16145 @table @code
16146 @item #pragma message @var{string}
16147 @cindex pragma, diagnostic
16148
16149 Prints @var{string} as a compiler message on compilation. The message
16150 is informational only, and is neither a compilation warning nor an error.
16151
16152 @smallexample
16153 #pragma message "Compiling " __FILE__ "..."
16154 @end smallexample
16155
16156 @var{string} may be parenthesized, and is printed with location
16157 information. For example,
16158
16159 @smallexample
16160 #define DO_PRAGMA(x) _Pragma (#x)
16161 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
16162
16163 TODO(Remember to fix this)
16164 @end smallexample
16165
16166 @noindent
16167 prints @samp{/tmp/file.c:4: note: #pragma message:
16168 TODO - Remember to fix this}.
16169
16170 @end table
16171
16172 @node Visibility Pragmas
16173 @subsection Visibility Pragmas
16174
16175 @table @code
16176 @item #pragma GCC visibility push(@var{visibility})
16177 @itemx #pragma GCC visibility pop
16178 @cindex pragma, visibility
16179
16180 This pragma allows the user to set the visibility for multiple
16181 declarations without having to give each a visibility attribute
16182 @xref{Function Attributes}, for more information about visibility and
16183 the attribute syntax.
16184
16185 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
16186 declarations. Class members and template specializations are not
16187 affected; if you want to override the visibility for a particular
16188 member or instantiation, you must use an attribute.
16189
16190 @end table
16191
16192
16193 @node Push/Pop Macro Pragmas
16194 @subsection Push/Pop Macro Pragmas
16195
16196 For compatibility with Microsoft Windows compilers, GCC supports
16197 @samp{#pragma push_macro(@var{"macro_name"})}
16198 and @samp{#pragma pop_macro(@var{"macro_name"})}.
16199
16200 @table @code
16201 @item #pragma push_macro(@var{"macro_name"})
16202 @cindex pragma, push_macro
16203 This pragma saves the value of the macro named as @var{macro_name} to
16204 the top of the stack for this macro.
16205
16206 @item #pragma pop_macro(@var{"macro_name"})
16207 @cindex pragma, pop_macro
16208 This pragma sets the value of the macro named as @var{macro_name} to
16209 the value on top of the stack for this macro. If the stack for
16210 @var{macro_name} is empty, the value of the macro remains unchanged.
16211 @end table
16212
16213 For example:
16214
16215 @smallexample
16216 #define X 1
16217 #pragma push_macro("X")
16218 #undef X
16219 #define X -1
16220 #pragma pop_macro("X")
16221 int x [X];
16222 @end smallexample
16223
16224 @noindent
16225 In this example, the definition of X as 1 is saved by @code{#pragma
16226 push_macro} and restored by @code{#pragma pop_macro}.
16227
16228 @node Function Specific Option Pragmas
16229 @subsection Function Specific Option Pragmas
16230
16231 @table @code
16232 @item #pragma GCC target (@var{"string"}...)
16233 @cindex pragma GCC target
16234
16235 This pragma allows you to set target specific options for functions
16236 defined later in the source file. One or more strings can be
16237 specified. Each function that is defined after this point is as
16238 if @code{attribute((target("STRING")))} was specified for that
16239 function. The parenthesis around the options is optional.
16240 @xref{Function Attributes}, for more information about the
16241 @code{target} attribute and the attribute syntax.
16242
16243 The @code{#pragma GCC target} attribute is not implemented in GCC versions earlier
16244 than 4.4 for the i386/x86_64 and 4.6 for the PowerPC back ends. At
16245 present, it is not implemented for other back ends.
16246 @end table
16247
16248 @table @code
16249 @item #pragma GCC optimize (@var{"string"}...)
16250 @cindex pragma GCC optimize
16251
16252 This pragma allows you to set global optimization options for functions
16253 defined later in the source file. One or more strings can be
16254 specified. Each function that is defined after this point is as
16255 if @code{attribute((optimize("STRING")))} was specified for that
16256 function. The parenthesis around the options is optional.
16257 @xref{Function Attributes}, for more information about the
16258 @code{optimize} attribute and the attribute syntax.
16259
16260 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
16261 versions earlier than 4.4.
16262 @end table
16263
16264 @table @code
16265 @item #pragma GCC push_options
16266 @itemx #pragma GCC pop_options
16267 @cindex pragma GCC push_options
16268 @cindex pragma GCC pop_options
16269
16270 These pragmas maintain a stack of the current target and optimization
16271 options. It is intended for include files where you temporarily want
16272 to switch to using a different @samp{#pragma GCC target} or
16273 @samp{#pragma GCC optimize} and then to pop back to the previous
16274 options.
16275
16276 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
16277 pragmas are not implemented in GCC versions earlier than 4.4.
16278 @end table
16279
16280 @table @code
16281 @item #pragma GCC reset_options
16282 @cindex pragma GCC reset_options
16283
16284 This pragma clears the current @code{#pragma GCC target} and
16285 @code{#pragma GCC optimize} to use the default switches as specified
16286 on the command line.
16287
16288 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
16289 versions earlier than 4.4.
16290 @end table
16291
16292 @node Loop-Specific Pragmas
16293 @subsection Loop-Specific Pragmas
16294
16295 @table @code
16296 @item #pragma GCC ivdep
16297 @cindex pragma GCC ivdep
16298 @end table
16299
16300 With this pragma, the programmer asserts that there are no loop-carried
16301 dependencies which would prevent that consecutive iterations of
16302 the following loop can be executed concurrently with SIMD
16303 (single instruction multiple data) instructions.
16304
16305 For example, the compiler can only unconditionally vectorize the following
16306 loop with the pragma:
16307
16308 @smallexample
16309 void foo (int n, int *a, int *b, int *c)
16310 @{
16311 int i, j;
16312 #pragma GCC ivdep
16313 for (i = 0; i < n; ++i)
16314 a[i] = b[i] + c[i];
16315 @}
16316 @end smallexample
16317
16318 @noindent
16319 In this example, using the @code{restrict} qualifier had the same
16320 effect. In the following example, that would not be possible. Assume
16321 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
16322 that it can unconditionally vectorize the following loop:
16323
16324 @smallexample
16325 void ignore_vec_dep (int *a, int k, int c, int m)
16326 @{
16327 #pragma GCC ivdep
16328 for (int i = 0; i < m; i++)
16329 a[i] = a[i + k] * c;
16330 @}
16331 @end smallexample
16332
16333
16334 @node Unnamed Fields
16335 @section Unnamed struct/union fields within structs/unions
16336 @cindex @code{struct}
16337 @cindex @code{union}
16338
16339 As permitted by ISO C11 and for compatibility with other compilers,
16340 GCC allows you to define
16341 a structure or union that contains, as fields, structures and unions
16342 without names. For example:
16343
16344 @smallexample
16345 struct @{
16346 int a;
16347 union @{
16348 int b;
16349 float c;
16350 @};
16351 int d;
16352 @} foo;
16353 @end smallexample
16354
16355 @noindent
16356 In this example, you are able to access members of the unnamed
16357 union with code like @samp{foo.b}. Note that only unnamed structs and
16358 unions are allowed, you may not have, for example, an unnamed
16359 @code{int}.
16360
16361 You must never create such structures that cause ambiguous field definitions.
16362 For example, in this structure:
16363
16364 @smallexample
16365 struct @{
16366 int a;
16367 struct @{
16368 int a;
16369 @};
16370 @} foo;
16371 @end smallexample
16372
16373 @noindent
16374 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
16375 The compiler gives errors for such constructs.
16376
16377 @opindex fms-extensions
16378 Unless @option{-fms-extensions} is used, the unnamed field must be a
16379 structure or union definition without a tag (for example, @samp{struct
16380 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
16381 also be a definition with a tag such as @samp{struct foo @{ int a;
16382 @};}, a reference to a previously defined structure or union such as
16383 @samp{struct foo;}, or a reference to a @code{typedef} name for a
16384 previously defined structure or union type.
16385
16386 @opindex fplan9-extensions
16387 The option @option{-fplan9-extensions} enables
16388 @option{-fms-extensions} as well as two other extensions. First, a
16389 pointer to a structure is automatically converted to a pointer to an
16390 anonymous field for assignments and function calls. For example:
16391
16392 @smallexample
16393 struct s1 @{ int a; @};
16394 struct s2 @{ struct s1; @};
16395 extern void f1 (struct s1 *);
16396 void f2 (struct s2 *p) @{ f1 (p); @}
16397 @end smallexample
16398
16399 @noindent
16400 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
16401 converted into a pointer to the anonymous field.
16402
16403 Second, when the type of an anonymous field is a @code{typedef} for a
16404 @code{struct} or @code{union}, code may refer to the field using the
16405 name of the @code{typedef}.
16406
16407 @smallexample
16408 typedef struct @{ int a; @} s1;
16409 struct s2 @{ s1; @};
16410 s1 f1 (struct s2 *p) @{ return p->s1; @}
16411 @end smallexample
16412
16413 These usages are only permitted when they are not ambiguous.
16414
16415 @node Thread-Local
16416 @section Thread-Local Storage
16417 @cindex Thread-Local Storage
16418 @cindex @acronym{TLS}
16419 @cindex @code{__thread}
16420
16421 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
16422 are allocated such that there is one instance of the variable per extant
16423 thread. The runtime model GCC uses to implement this originates
16424 in the IA-64 processor-specific ABI, but has since been migrated
16425 to other processors as well. It requires significant support from
16426 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
16427 system libraries (@file{libc.so} and @file{libpthread.so}), so it
16428 is not available everywhere.
16429
16430 At the user level, the extension is visible with a new storage
16431 class keyword: @code{__thread}. For example:
16432
16433 @smallexample
16434 __thread int i;
16435 extern __thread struct state s;
16436 static __thread char *p;
16437 @end smallexample
16438
16439 The @code{__thread} specifier may be used alone, with the @code{extern}
16440 or @code{static} specifiers, but with no other storage class specifier.
16441 When used with @code{extern} or @code{static}, @code{__thread} must appear
16442 immediately after the other storage class specifier.
16443
16444 The @code{__thread} specifier may be applied to any global, file-scoped
16445 static, function-scoped static, or static data member of a class. It may
16446 not be applied to block-scoped automatic or non-static data member.
16447
16448 When the address-of operator is applied to a thread-local variable, it is
16449 evaluated at run time and returns the address of the current thread's
16450 instance of that variable. An address so obtained may be used by any
16451 thread. When a thread terminates, any pointers to thread-local variables
16452 in that thread become invalid.
16453
16454 No static initialization may refer to the address of a thread-local variable.
16455
16456 In C++, if an initializer is present for a thread-local variable, it must
16457 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
16458 standard.
16459
16460 See @uref{http://www.akkadia.org/drepper/tls.pdf,
16461 ELF Handling For Thread-Local Storage} for a detailed explanation of
16462 the four thread-local storage addressing models, and how the runtime
16463 is expected to function.
16464
16465 @menu
16466 * C99 Thread-Local Edits::
16467 * C++98 Thread-Local Edits::
16468 @end menu
16469
16470 @node C99 Thread-Local Edits
16471 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
16472
16473 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
16474 that document the exact semantics of the language extension.
16475
16476 @itemize @bullet
16477 @item
16478 @cite{5.1.2 Execution environments}
16479
16480 Add new text after paragraph 1
16481
16482 @quotation
16483 Within either execution environment, a @dfn{thread} is a flow of
16484 control within a program. It is implementation defined whether
16485 or not there may be more than one thread associated with a program.
16486 It is implementation defined how threads beyond the first are
16487 created, the name and type of the function called at thread
16488 startup, and how threads may be terminated. However, objects
16489 with thread storage duration shall be initialized before thread
16490 startup.
16491 @end quotation
16492
16493 @item
16494 @cite{6.2.4 Storage durations of objects}
16495
16496 Add new text before paragraph 3
16497
16498 @quotation
16499 An object whose identifier is declared with the storage-class
16500 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
16501 Its lifetime is the entire execution of the thread, and its
16502 stored value is initialized only once, prior to thread startup.
16503 @end quotation
16504
16505 @item
16506 @cite{6.4.1 Keywords}
16507
16508 Add @code{__thread}.
16509
16510 @item
16511 @cite{6.7.1 Storage-class specifiers}
16512
16513 Add @code{__thread} to the list of storage class specifiers in
16514 paragraph 1.
16515
16516 Change paragraph 2 to
16517
16518 @quotation
16519 With the exception of @code{__thread}, at most one storage-class
16520 specifier may be given [@dots{}]. The @code{__thread} specifier may
16521 be used alone, or immediately following @code{extern} or
16522 @code{static}.
16523 @end quotation
16524
16525 Add new text after paragraph 6
16526
16527 @quotation
16528 The declaration of an identifier for a variable that has
16529 block scope that specifies @code{__thread} shall also
16530 specify either @code{extern} or @code{static}.
16531
16532 The @code{__thread} specifier shall be used only with
16533 variables.
16534 @end quotation
16535 @end itemize
16536
16537 @node C++98 Thread-Local Edits
16538 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
16539
16540 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
16541 that document the exact semantics of the language extension.
16542
16543 @itemize @bullet
16544 @item
16545 @b{[intro.execution]}
16546
16547 New text after paragraph 4
16548
16549 @quotation
16550 A @dfn{thread} is a flow of control within the abstract machine.
16551 It is implementation defined whether or not there may be more than
16552 one thread.
16553 @end quotation
16554
16555 New text after paragraph 7
16556
16557 @quotation
16558 It is unspecified whether additional action must be taken to
16559 ensure when and whether side effects are visible to other threads.
16560 @end quotation
16561
16562 @item
16563 @b{[lex.key]}
16564
16565 Add @code{__thread}.
16566
16567 @item
16568 @b{[basic.start.main]}
16569
16570 Add after paragraph 5
16571
16572 @quotation
16573 The thread that begins execution at the @code{main} function is called
16574 the @dfn{main thread}. It is implementation defined how functions
16575 beginning threads other than the main thread are designated or typed.
16576 A function so designated, as well as the @code{main} function, is called
16577 a @dfn{thread startup function}. It is implementation defined what
16578 happens if a thread startup function returns. It is implementation
16579 defined what happens to other threads when any thread calls @code{exit}.
16580 @end quotation
16581
16582 @item
16583 @b{[basic.start.init]}
16584
16585 Add after paragraph 4
16586
16587 @quotation
16588 The storage for an object of thread storage duration shall be
16589 statically initialized before the first statement of the thread startup
16590 function. An object of thread storage duration shall not require
16591 dynamic initialization.
16592 @end quotation
16593
16594 @item
16595 @b{[basic.start.term]}
16596
16597 Add after paragraph 3
16598
16599 @quotation
16600 The type of an object with thread storage duration shall not have a
16601 non-trivial destructor, nor shall it be an array type whose elements
16602 (directly or indirectly) have non-trivial destructors.
16603 @end quotation
16604
16605 @item
16606 @b{[basic.stc]}
16607
16608 Add ``thread storage duration'' to the list in paragraph 1.
16609
16610 Change paragraph 2
16611
16612 @quotation
16613 Thread, static, and automatic storage durations are associated with
16614 objects introduced by declarations [@dots{}].
16615 @end quotation
16616
16617 Add @code{__thread} to the list of specifiers in paragraph 3.
16618
16619 @item
16620 @b{[basic.stc.thread]}
16621
16622 New section before @b{[basic.stc.static]}
16623
16624 @quotation
16625 The keyword @code{__thread} applied to a non-local object gives the
16626 object thread storage duration.
16627
16628 A local variable or class data member declared both @code{static}
16629 and @code{__thread} gives the variable or member thread storage
16630 duration.
16631 @end quotation
16632
16633 @item
16634 @b{[basic.stc.static]}
16635
16636 Change paragraph 1
16637
16638 @quotation
16639 All objects that have neither thread storage duration, dynamic
16640 storage duration nor are local [@dots{}].
16641 @end quotation
16642
16643 @item
16644 @b{[dcl.stc]}
16645
16646 Add @code{__thread} to the list in paragraph 1.
16647
16648 Change paragraph 1
16649
16650 @quotation
16651 With the exception of @code{__thread}, at most one
16652 @var{storage-class-specifier} shall appear in a given
16653 @var{decl-specifier-seq}. The @code{__thread} specifier may
16654 be used alone, or immediately following the @code{extern} or
16655 @code{static} specifiers. [@dots{}]
16656 @end quotation
16657
16658 Add after paragraph 5
16659
16660 @quotation
16661 The @code{__thread} specifier can be applied only to the names of objects
16662 and to anonymous unions.
16663 @end quotation
16664
16665 @item
16666 @b{[class.mem]}
16667
16668 Add after paragraph 6
16669
16670 @quotation
16671 Non-@code{static} members shall not be @code{__thread}.
16672 @end quotation
16673 @end itemize
16674
16675 @node Binary constants
16676 @section Binary constants using the @samp{0b} prefix
16677 @cindex Binary constants using the @samp{0b} prefix
16678
16679 Integer constants can be written as binary constants, consisting of a
16680 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
16681 @samp{0B}. This is particularly useful in environments that operate a
16682 lot on the bit level (like microcontrollers).
16683
16684 The following statements are identical:
16685
16686 @smallexample
16687 i = 42;
16688 i = 0x2a;
16689 i = 052;
16690 i = 0b101010;
16691 @end smallexample
16692
16693 The type of these constants follows the same rules as for octal or
16694 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
16695 can be applied.
16696
16697 @node C++ Extensions
16698 @chapter Extensions to the C++ Language
16699 @cindex extensions, C++ language
16700 @cindex C++ language extensions
16701
16702 The GNU compiler provides these extensions to the C++ language (and you
16703 can also use most of the C language extensions in your C++ programs). If you
16704 want to write code that checks whether these features are available, you can
16705 test for the GNU compiler the same way as for C programs: check for a
16706 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
16707 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
16708 Predefined Macros,cpp,The GNU C Preprocessor}).
16709
16710 @menu
16711 * C++ Volatiles:: What constitutes an access to a volatile object.
16712 * Restricted Pointers:: C99 restricted pointers and references.
16713 * Vague Linkage:: Where G++ puts inlines, vtables and such.
16714 * C++ Interface:: You can use a single C++ header file for both
16715 declarations and definitions.
16716 * Template Instantiation:: Methods for ensuring that exactly one copy of
16717 each needed template instantiation is emitted.
16718 * Bound member functions:: You can extract a function pointer to the
16719 method denoted by a @samp{->*} or @samp{.*} expression.
16720 * C++ Attributes:: Variable, function, and type attributes for C++ only.
16721 * Function Multiversioning:: Declaring multiple function versions.
16722 * Namespace Association:: Strong using-directives for namespace association.
16723 * Type Traits:: Compiler support for type traits
16724 * Java Exceptions:: Tweaking exception handling to work with Java.
16725 * Deprecated Features:: Things will disappear from G++.
16726 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
16727 @end menu
16728
16729 @node C++ Volatiles
16730 @section When is a Volatile C++ Object Accessed?
16731 @cindex accessing volatiles
16732 @cindex volatile read
16733 @cindex volatile write
16734 @cindex volatile access
16735
16736 The C++ standard differs from the C standard in its treatment of
16737 volatile objects. It fails to specify what constitutes a volatile
16738 access, except to say that C++ should behave in a similar manner to C
16739 with respect to volatiles, where possible. However, the different
16740 lvalueness of expressions between C and C++ complicate the behavior.
16741 G++ behaves the same as GCC for volatile access, @xref{C
16742 Extensions,,Volatiles}, for a description of GCC's behavior.
16743
16744 The C and C++ language specifications differ when an object is
16745 accessed in a void context:
16746
16747 @smallexample
16748 volatile int *src = @var{somevalue};
16749 *src;
16750 @end smallexample
16751
16752 The C++ standard specifies that such expressions do not undergo lvalue
16753 to rvalue conversion, and that the type of the dereferenced object may
16754 be incomplete. The C++ standard does not specify explicitly that it
16755 is lvalue to rvalue conversion that is responsible for causing an
16756 access. There is reason to believe that it is, because otherwise
16757 certain simple expressions become undefined. However, because it
16758 would surprise most programmers, G++ treats dereferencing a pointer to
16759 volatile object of complete type as GCC would do for an equivalent
16760 type in C@. When the object has incomplete type, G++ issues a
16761 warning; if you wish to force an error, you must force a conversion to
16762 rvalue with, for instance, a static cast.
16763
16764 When using a reference to volatile, G++ does not treat equivalent
16765 expressions as accesses to volatiles, but instead issues a warning that
16766 no volatile is accessed. The rationale for this is that otherwise it
16767 becomes difficult to determine where volatile access occur, and not
16768 possible to ignore the return value from functions returning volatile
16769 references. Again, if you wish to force a read, cast the reference to
16770 an rvalue.
16771
16772 G++ implements the same behavior as GCC does when assigning to a
16773 volatile object---there is no reread of the assigned-to object, the
16774 assigned rvalue is reused. Note that in C++ assignment expressions
16775 are lvalues, and if used as an lvalue, the volatile object is
16776 referred to. For instance, @var{vref} refers to @var{vobj}, as
16777 expected, in the following example:
16778
16779 @smallexample
16780 volatile int vobj;
16781 volatile int &vref = vobj = @var{something};
16782 @end smallexample
16783
16784 @node Restricted Pointers
16785 @section Restricting Pointer Aliasing
16786 @cindex restricted pointers
16787 @cindex restricted references
16788 @cindex restricted this pointer
16789
16790 As with the C front end, G++ understands the C99 feature of restricted pointers,
16791 specified with the @code{__restrict__}, or @code{__restrict} type
16792 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
16793 language flag, @code{restrict} is not a keyword in C++.
16794
16795 In addition to allowing restricted pointers, you can specify restricted
16796 references, which indicate that the reference is not aliased in the local
16797 context.
16798
16799 @smallexample
16800 void fn (int *__restrict__ rptr, int &__restrict__ rref)
16801 @{
16802 /* @r{@dots{}} */
16803 @}
16804 @end smallexample
16805
16806 @noindent
16807 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
16808 @var{rref} refers to a (different) unaliased integer.
16809
16810 You may also specify whether a member function's @var{this} pointer is
16811 unaliased by using @code{__restrict__} as a member function qualifier.
16812
16813 @smallexample
16814 void T::fn () __restrict__
16815 @{
16816 /* @r{@dots{}} */
16817 @}
16818 @end smallexample
16819
16820 @noindent
16821 Within the body of @code{T::fn}, @var{this} has the effective
16822 definition @code{T *__restrict__ const this}. Notice that the
16823 interpretation of a @code{__restrict__} member function qualifier is
16824 different to that of @code{const} or @code{volatile} qualifier, in that it
16825 is applied to the pointer rather than the object. This is consistent with
16826 other compilers that implement restricted pointers.
16827
16828 As with all outermost parameter qualifiers, @code{__restrict__} is
16829 ignored in function definition matching. This means you only need to
16830 specify @code{__restrict__} in a function definition, rather than
16831 in a function prototype as well.
16832
16833 @node Vague Linkage
16834 @section Vague Linkage
16835 @cindex vague linkage
16836
16837 There are several constructs in C++ that require space in the object
16838 file but are not clearly tied to a single translation unit. We say that
16839 these constructs have ``vague linkage''. Typically such constructs are
16840 emitted wherever they are needed, though sometimes we can be more
16841 clever.
16842
16843 @table @asis
16844 @item Inline Functions
16845 Inline functions are typically defined in a header file which can be
16846 included in many different compilations. Hopefully they can usually be
16847 inlined, but sometimes an out-of-line copy is necessary, if the address
16848 of the function is taken or if inlining fails. In general, we emit an
16849 out-of-line copy in all translation units where one is needed. As an
16850 exception, we only emit inline virtual functions with the vtable, since
16851 it always requires a copy.
16852
16853 Local static variables and string constants used in an inline function
16854 are also considered to have vague linkage, since they must be shared
16855 between all inlined and out-of-line instances of the function.
16856
16857 @item VTables
16858 @cindex vtable
16859 C++ virtual functions are implemented in most compilers using a lookup
16860 table, known as a vtable. The vtable contains pointers to the virtual
16861 functions provided by a class, and each object of the class contains a
16862 pointer to its vtable (or vtables, in some multiple-inheritance
16863 situations). If the class declares any non-inline, non-pure virtual
16864 functions, the first one is chosen as the ``key method'' for the class,
16865 and the vtable is only emitted in the translation unit where the key
16866 method is defined.
16867
16868 @emph{Note:} If the chosen key method is later defined as inline, the
16869 vtable is still emitted in every translation unit that defines it.
16870 Make sure that any inline virtuals are declared inline in the class
16871 body, even if they are not defined there.
16872
16873 @item @code{type_info} objects
16874 @cindex @code{type_info}
16875 @cindex RTTI
16876 C++ requires information about types to be written out in order to
16877 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
16878 For polymorphic classes (classes with virtual functions), the @samp{type_info}
16879 object is written out along with the vtable so that @samp{dynamic_cast}
16880 can determine the dynamic type of a class object at run time. For all
16881 other types, we write out the @samp{type_info} object when it is used: when
16882 applying @samp{typeid} to an expression, throwing an object, or
16883 referring to a type in a catch clause or exception specification.
16884
16885 @item Template Instantiations
16886 Most everything in this section also applies to template instantiations,
16887 but there are other options as well.
16888 @xref{Template Instantiation,,Where's the Template?}.
16889
16890 @end table
16891
16892 When used with GNU ld version 2.8 or later on an ELF system such as
16893 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
16894 these constructs will be discarded at link time. This is known as
16895 COMDAT support.
16896
16897 On targets that don't support COMDAT, but do support weak symbols, GCC
16898 uses them. This way one copy overrides all the others, but
16899 the unused copies still take up space in the executable.
16900
16901 For targets that do not support either COMDAT or weak symbols,
16902 most entities with vague linkage are emitted as local symbols to
16903 avoid duplicate definition errors from the linker. This does not happen
16904 for local statics in inlines, however, as having multiple copies
16905 almost certainly breaks things.
16906
16907 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
16908 another way to control placement of these constructs.
16909
16910 @node C++ Interface
16911 @section #pragma interface and implementation
16912
16913 @cindex interface and implementation headers, C++
16914 @cindex C++ interface and implementation headers
16915 @cindex pragmas, interface and implementation
16916
16917 @code{#pragma interface} and @code{#pragma implementation} provide the
16918 user with a way of explicitly directing the compiler to emit entities
16919 with vague linkage (and debugging information) in a particular
16920 translation unit.
16921
16922 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
16923 most cases, because of COMDAT support and the ``key method'' heuristic
16924 mentioned in @ref{Vague Linkage}. Using them can actually cause your
16925 program to grow due to unnecessary out-of-line copies of inline
16926 functions. Currently (3.4) the only benefit of these
16927 @code{#pragma}s is reduced duplication of debugging information, and
16928 that should be addressed soon on DWARF 2 targets with the use of
16929 COMDAT groups.
16930
16931 @table @code
16932 @item #pragma interface
16933 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
16934 @kindex #pragma interface
16935 Use this directive in @emph{header files} that define object classes, to save
16936 space in most of the object files that use those classes. Normally,
16937 local copies of certain information (backup copies of inline member
16938 functions, debugging information, and the internal tables that implement
16939 virtual functions) must be kept in each object file that includes class
16940 definitions. You can use this pragma to avoid such duplication. When a
16941 header file containing @samp{#pragma interface} is included in a
16942 compilation, this auxiliary information is not generated (unless
16943 the main input source file itself uses @samp{#pragma implementation}).
16944 Instead, the object files contain references to be resolved at link
16945 time.
16946
16947 The second form of this directive is useful for the case where you have
16948 multiple headers with the same name in different directories. If you
16949 use this form, you must specify the same string to @samp{#pragma
16950 implementation}.
16951
16952 @item #pragma implementation
16953 @itemx #pragma implementation "@var{objects}.h"
16954 @kindex #pragma implementation
16955 Use this pragma in a @emph{main input file}, when you want full output from
16956 included header files to be generated (and made globally visible). The
16957 included header file, in turn, should use @samp{#pragma interface}.
16958 Backup copies of inline member functions, debugging information, and the
16959 internal tables used to implement virtual functions are all generated in
16960 implementation files.
16961
16962 @cindex implied @code{#pragma implementation}
16963 @cindex @code{#pragma implementation}, implied
16964 @cindex naming convention, implementation headers
16965 If you use @samp{#pragma implementation} with no argument, it applies to
16966 an include file with the same basename@footnote{A file's @dfn{basename}
16967 is the name stripped of all leading path information and of trailing
16968 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
16969 file. For example, in @file{allclass.cc}, giving just
16970 @samp{#pragma implementation}
16971 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
16972
16973 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
16974 an implementation file whenever you would include it from
16975 @file{allclass.cc} even if you never specified @samp{#pragma
16976 implementation}. This was deemed to be more trouble than it was worth,
16977 however, and disabled.
16978
16979 Use the string argument if you want a single implementation file to
16980 include code from multiple header files. (You must also use
16981 @samp{#include} to include the header file; @samp{#pragma
16982 implementation} only specifies how to use the file---it doesn't actually
16983 include it.)
16984
16985 There is no way to split up the contents of a single header file into
16986 multiple implementation files.
16987 @end table
16988
16989 @cindex inlining and C++ pragmas
16990 @cindex C++ pragmas, effect on inlining
16991 @cindex pragmas in C++, effect on inlining
16992 @samp{#pragma implementation} and @samp{#pragma interface} also have an
16993 effect on function inlining.
16994
16995 If you define a class in a header file marked with @samp{#pragma
16996 interface}, the effect on an inline function defined in that class is
16997 similar to an explicit @code{extern} declaration---the compiler emits
16998 no code at all to define an independent version of the function. Its
16999 definition is used only for inlining with its callers.
17000
17001 @opindex fno-implement-inlines
17002 Conversely, when you include the same header file in a main source file
17003 that declares it as @samp{#pragma implementation}, the compiler emits
17004 code for the function itself; this defines a version of the function
17005 that can be found via pointers (or by callers compiled without
17006 inlining). If all calls to the function can be inlined, you can avoid
17007 emitting the function by compiling with @option{-fno-implement-inlines}.
17008 If any calls are not inlined, you will get linker errors.
17009
17010 @node Template Instantiation
17011 @section Where's the Template?
17012 @cindex template instantiation
17013
17014 C++ templates are the first language feature to require more
17015 intelligence from the environment than one usually finds on a UNIX
17016 system. Somehow the compiler and linker have to make sure that each
17017 template instance occurs exactly once in the executable if it is needed,
17018 and not at all otherwise. There are two basic approaches to this
17019 problem, which are referred to as the Borland model and the Cfront model.
17020
17021 @table @asis
17022 @item Borland model
17023 Borland C++ solved the template instantiation problem by adding the code
17024 equivalent of common blocks to their linker; the compiler emits template
17025 instances in each translation unit that uses them, and the linker
17026 collapses them together. The advantage of this model is that the linker
17027 only has to consider the object files themselves; there is no external
17028 complexity to worry about. This disadvantage is that compilation time
17029 is increased because the template code is being compiled repeatedly.
17030 Code written for this model tends to include definitions of all
17031 templates in the header file, since they must be seen to be
17032 instantiated.
17033
17034 @item Cfront model
17035 The AT&T C++ translator, Cfront, solved the template instantiation
17036 problem by creating the notion of a template repository, an
17037 automatically maintained place where template instances are stored. A
17038 more modern version of the repository works as follows: As individual
17039 object files are built, the compiler places any template definitions and
17040 instantiations encountered in the repository. At link time, the link
17041 wrapper adds in the objects in the repository and compiles any needed
17042 instances that were not previously emitted. The advantages of this
17043 model are more optimal compilation speed and the ability to use the
17044 system linker; to implement the Borland model a compiler vendor also
17045 needs to replace the linker. The disadvantages are vastly increased
17046 complexity, and thus potential for error; for some code this can be
17047 just as transparent, but in practice it can been very difficult to build
17048 multiple programs in one directory and one program in multiple
17049 directories. Code written for this model tends to separate definitions
17050 of non-inline member templates into a separate file, which should be
17051 compiled separately.
17052 @end table
17053
17054 When used with GNU ld version 2.8 or later on an ELF system such as
17055 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
17056 Borland model. On other systems, G++ implements neither automatic
17057 model.
17058
17059 You have the following options for dealing with template instantiations:
17060
17061 @enumerate
17062 @item
17063 @opindex frepo
17064 Compile your template-using code with @option{-frepo}. The compiler
17065 generates files with the extension @samp{.rpo} listing all of the
17066 template instantiations used in the corresponding object files that
17067 could be instantiated there; the link wrapper, @samp{collect2},
17068 then updates the @samp{.rpo} files to tell the compiler where to place
17069 those instantiations and rebuild any affected object files. The
17070 link-time overhead is negligible after the first pass, as the compiler
17071 continues to place the instantiations in the same files.
17072
17073 This is your best option for application code written for the Borland
17074 model, as it just works. Code written for the Cfront model
17075 needs to be modified so that the template definitions are available at
17076 one or more points of instantiation; usually this is as simple as adding
17077 @code{#include <tmethods.cc>} to the end of each template header.
17078
17079 For library code, if you want the library to provide all of the template
17080 instantiations it needs, just try to link all of its object files
17081 together; the link will fail, but cause the instantiations to be
17082 generated as a side effect. Be warned, however, that this may cause
17083 conflicts if multiple libraries try to provide the same instantiations.
17084 For greater control, use explicit instantiation as described in the next
17085 option.
17086
17087 @item
17088 @opindex fno-implicit-templates
17089 Compile your code with @option{-fno-implicit-templates} to disable the
17090 implicit generation of template instances, and explicitly instantiate
17091 all the ones you use. This approach requires more knowledge of exactly
17092 which instances you need than do the others, but it's less
17093 mysterious and allows greater control. You can scatter the explicit
17094 instantiations throughout your program, perhaps putting them in the
17095 translation units where the instances are used or the translation units
17096 that define the templates themselves; you can put all of the explicit
17097 instantiations you need into one big file; or you can create small files
17098 like
17099
17100 @smallexample
17101 #include "Foo.h"
17102 #include "Foo.cc"
17103
17104 template class Foo<int>;
17105 template ostream& operator <<
17106 (ostream&, const Foo<int>&);
17107 @end smallexample
17108
17109 @noindent
17110 for each of the instances you need, and create a template instantiation
17111 library from those.
17112
17113 If you are using Cfront-model code, you can probably get away with not
17114 using @option{-fno-implicit-templates} when compiling files that don't
17115 @samp{#include} the member template definitions.
17116
17117 If you use one big file to do the instantiations, you may want to
17118 compile it without @option{-fno-implicit-templates} so you get all of the
17119 instances required by your explicit instantiations (but not by any
17120 other files) without having to specify them as well.
17121
17122 The ISO C++ 2011 standard allows forward declaration of explicit
17123 instantiations (with @code{extern}). G++ supports explicit instantiation
17124 declarations in C++98 mode and has extended the template instantiation
17125 syntax to support instantiation of the compiler support data for a
17126 template class (i.e.@: the vtable) without instantiating any of its
17127 members (with @code{inline}), and instantiation of only the static data
17128 members of a template class, without the support data or member
17129 functions (with (@code{static}):
17130
17131 @smallexample
17132 extern template int max (int, int);
17133 inline template class Foo<int>;
17134 static template class Foo<int>;
17135 @end smallexample
17136
17137 @item
17138 Do nothing. Pretend G++ does implement automatic instantiation
17139 management. Code written for the Borland model works fine, but
17140 each translation unit contains instances of each of the templates it
17141 uses. In a large program, this can lead to an unacceptable amount of code
17142 duplication.
17143 @end enumerate
17144
17145 @node Bound member functions
17146 @section Extracting the function pointer from a bound pointer to member function
17147 @cindex pmf
17148 @cindex pointer to member function
17149 @cindex bound pointer to member function
17150
17151 In C++, pointer to member functions (PMFs) are implemented using a wide
17152 pointer of sorts to handle all the possible call mechanisms; the PMF
17153 needs to store information about how to adjust the @samp{this} pointer,
17154 and if the function pointed to is virtual, where to find the vtable, and
17155 where in the vtable to look for the member function. If you are using
17156 PMFs in an inner loop, you should really reconsider that decision. If
17157 that is not an option, you can extract the pointer to the function that
17158 would be called for a given object/PMF pair and call it directly inside
17159 the inner loop, to save a bit of time.
17160
17161 Note that you still pay the penalty for the call through a
17162 function pointer; on most modern architectures, such a call defeats the
17163 branch prediction features of the CPU@. This is also true of normal
17164 virtual function calls.
17165
17166 The syntax for this extension is
17167
17168 @smallexample
17169 extern A a;
17170 extern int (A::*fp)();
17171 typedef int (*fptr)(A *);
17172
17173 fptr p = (fptr)(a.*fp);
17174 @end smallexample
17175
17176 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
17177 no object is needed to obtain the address of the function. They can be
17178 converted to function pointers directly:
17179
17180 @smallexample
17181 fptr p1 = (fptr)(&A::foo);
17182 @end smallexample
17183
17184 @opindex Wno-pmf-conversions
17185 You must specify @option{-Wno-pmf-conversions} to use this extension.
17186
17187 @node C++ Attributes
17188 @section C++-Specific Variable, Function, and Type Attributes
17189
17190 Some attributes only make sense for C++ programs.
17191
17192 @table @code
17193 @item abi_tag ("@var{tag}", ...)
17194 @cindex @code{abi_tag} attribute
17195 The @code{abi_tag} attribute can be applied to a function or class
17196 declaration. It modifies the mangled name of the function or class to
17197 incorporate the tag name, in order to distinguish the function or
17198 class from an earlier version with a different ABI; perhaps the class
17199 has changed size, or the function has a different return type that is
17200 not encoded in the mangled name.
17201
17202 The argument can be a list of strings of arbitrary length. The
17203 strings are sorted on output, so the order of the list is
17204 unimportant.
17205
17206 A redeclaration of a function or class must not add new ABI tags,
17207 since doing so would change the mangled name.
17208
17209 The @option{-Wabi-tag} flag enables a warning about a class which does
17210 not have all the ABI tags used by its subobjects and virtual functions; for users with code
17211 that needs to coexist with an earlier ABI, using this option can help
17212 to find all affected types that need to be tagged.
17213
17214 @item init_priority (@var{priority})
17215 @cindex @code{init_priority} attribute
17216
17217
17218 In Standard C++, objects defined at namespace scope are guaranteed to be
17219 initialized in an order in strict accordance with that of their definitions
17220 @emph{in a given translation unit}. No guarantee is made for initializations
17221 across translation units. However, GNU C++ allows users to control the
17222 order of initialization of objects defined at namespace scope with the
17223 @code{init_priority} attribute by specifying a relative @var{priority},
17224 a constant integral expression currently bounded between 101 and 65535
17225 inclusive. Lower numbers indicate a higher priority.
17226
17227 In the following example, @code{A} would normally be created before
17228 @code{B}, but the @code{init_priority} attribute reverses that order:
17229
17230 @smallexample
17231 Some_Class A __attribute__ ((init_priority (2000)));
17232 Some_Class B __attribute__ ((init_priority (543)));
17233 @end smallexample
17234
17235 @noindent
17236 Note that the particular values of @var{priority} do not matter; only their
17237 relative ordering.
17238
17239 @item java_interface
17240 @cindex @code{java_interface} attribute
17241
17242 This type attribute informs C++ that the class is a Java interface. It may
17243 only be applied to classes declared within an @code{extern "Java"} block.
17244 Calls to methods declared in this interface are dispatched using GCJ's
17245 interface table mechanism, instead of regular virtual table dispatch.
17246
17247 @item warn_unused
17248 @cindex @code{warn_unused} attribute
17249
17250 For C++ types with non-trivial constructors and/or destructors it is
17251 impossible for the compiler to determine whether a variable of this
17252 type is truly unused if it is not referenced. This type attribute
17253 informs the compiler that variables of this type should be warned
17254 about if they appear to be unused, just like variables of fundamental
17255 types.
17256
17257 This attribute is appropriate for types which just represent a value,
17258 such as @code{std::string}; it is not appropriate for types which
17259 control a resource, such as @code{std::mutex}.
17260
17261 This attribute is also accepted in C, but it is unnecessary because C
17262 does not have constructors or destructors.
17263
17264 @end table
17265
17266 See also @ref{Namespace Association}.
17267
17268 @node Function Multiversioning
17269 @section Function Multiversioning
17270 @cindex function versions
17271
17272 With the GNU C++ front end, for target i386, you may specify multiple
17273 versions of a function, where each function is specialized for a
17274 specific target feature. At runtime, the appropriate version of the
17275 function is automatically executed depending on the characteristics of
17276 the execution platform. Here is an example.
17277
17278 @smallexample
17279 __attribute__ ((target ("default")))
17280 int foo ()
17281 @{
17282 // The default version of foo.
17283 return 0;
17284 @}
17285
17286 __attribute__ ((target ("sse4.2")))
17287 int foo ()
17288 @{
17289 // foo version for SSE4.2
17290 return 1;
17291 @}
17292
17293 __attribute__ ((target ("arch=atom")))
17294 int foo ()
17295 @{
17296 // foo version for the Intel ATOM processor
17297 return 2;
17298 @}
17299
17300 __attribute__ ((target ("arch=amdfam10")))
17301 int foo ()
17302 @{
17303 // foo version for the AMD Family 0x10 processors.
17304 return 3;
17305 @}
17306
17307 int main ()
17308 @{
17309 int (*p)() = &foo;
17310 assert ((*p) () == foo ());
17311 return 0;
17312 @}
17313 @end smallexample
17314
17315 In the above example, four versions of function foo are created. The
17316 first version of foo with the target attribute "default" is the default
17317 version. This version gets executed when no other target specific
17318 version qualifies for execution on a particular platform. A new version
17319 of foo is created by using the same function signature but with a
17320 different target string. Function foo is called or a pointer to it is
17321 taken just like a regular function. GCC takes care of doing the
17322 dispatching to call the right version at runtime. Refer to the
17323 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
17324 Function Multiversioning} for more details.
17325
17326 @node Namespace Association
17327 @section Namespace Association
17328
17329 @strong{Caution:} The semantics of this extension are equivalent
17330 to C++ 2011 inline namespaces. Users should use inline namespaces
17331 instead as this extension will be removed in future versions of G++.
17332
17333 A using-directive with @code{__attribute ((strong))} is stronger
17334 than a normal using-directive in two ways:
17335
17336 @itemize @bullet
17337 @item
17338 Templates from the used namespace can be specialized and explicitly
17339 instantiated as though they were members of the using namespace.
17340
17341 @item
17342 The using namespace is considered an associated namespace of all
17343 templates in the used namespace for purposes of argument-dependent
17344 name lookup.
17345 @end itemize
17346
17347 The used namespace must be nested within the using namespace so that
17348 normal unqualified lookup works properly.
17349
17350 This is useful for composing a namespace transparently from
17351 implementation namespaces. For example:
17352
17353 @smallexample
17354 namespace std @{
17355 namespace debug @{
17356 template <class T> struct A @{ @};
17357 @}
17358 using namespace debug __attribute ((__strong__));
17359 template <> struct A<int> @{ @}; // @r{OK to specialize}
17360
17361 template <class T> void f (A<T>);
17362 @}
17363
17364 int main()
17365 @{
17366 f (std::A<float>()); // @r{lookup finds} std::f
17367 f (std::A<int>());
17368 @}
17369 @end smallexample
17370
17371 @node Type Traits
17372 @section Type Traits
17373
17374 The C++ front end implements syntactic extensions that allow
17375 compile-time determination of
17376 various characteristics of a type (or of a
17377 pair of types).
17378
17379 @table @code
17380 @item __has_nothrow_assign (type)
17381 If @code{type} is const qualified or is a reference type then the trait is
17382 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
17383 is true, else if @code{type} is a cv class or union type with copy assignment
17384 operators that are known not to throw an exception then the trait is true,
17385 else it is false. Requires: @code{type} shall be a complete type,
17386 (possibly cv-qualified) @code{void}, or an array of unknown bound.
17387
17388 @item __has_nothrow_copy (type)
17389 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
17390 @code{type} is a cv class or union type with copy constructors that
17391 are known not to throw an exception then the trait is true, else it is false.
17392 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
17393 @code{void}, or an array of unknown bound.
17394
17395 @item __has_nothrow_constructor (type)
17396 If @code{__has_trivial_constructor (type)} is true then the trait is
17397 true, else if @code{type} is a cv class or union type (or array
17398 thereof) with a default constructor that is known not to throw an
17399 exception then the trait is true, else it is false. Requires:
17400 @code{type} shall be a complete type, (possibly cv-qualified)
17401 @code{void}, or an array of unknown bound.
17402
17403 @item __has_trivial_assign (type)
17404 If @code{type} is const qualified or is a reference type then the trait is
17405 false. Otherwise if @code{__is_pod (type)} is true then the trait is
17406 true, else if @code{type} is a cv class or union type with a trivial
17407 copy assignment ([class.copy]) then the trait is true, else it is
17408 false. Requires: @code{type} shall be a complete type, (possibly
17409 cv-qualified) @code{void}, or an array of unknown bound.
17410
17411 @item __has_trivial_copy (type)
17412 If @code{__is_pod (type)} is true or @code{type} is a reference type
17413 then the trait is true, else if @code{type} is a cv class or union type
17414 with a trivial copy constructor ([class.copy]) then the trait
17415 is true, else it is false. Requires: @code{type} shall be a complete
17416 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17417
17418 @item __has_trivial_constructor (type)
17419 If @code{__is_pod (type)} is true then the trait is true, else if
17420 @code{type} is a cv class or union type (or array thereof) with a
17421 trivial default constructor ([class.ctor]) then the trait is true,
17422 else it is false. Requires: @code{type} shall be a complete
17423 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17424
17425 @item __has_trivial_destructor (type)
17426 If @code{__is_pod (type)} is true or @code{type} is a reference type then
17427 the trait is true, else if @code{type} is a cv class or union type (or
17428 array thereof) with a trivial destructor ([class.dtor]) then the trait
17429 is true, else it is false. Requires: @code{type} shall be a complete
17430 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17431
17432 @item __has_virtual_destructor (type)
17433 If @code{type} is a class type with a virtual destructor
17434 ([class.dtor]) then the trait is true, else it is false. Requires:
17435 @code{type} shall be a complete type, (possibly cv-qualified)
17436 @code{void}, or an array of unknown bound.
17437
17438 @item __is_abstract (type)
17439 If @code{type} is an abstract class ([class.abstract]) then the trait
17440 is true, else it is false. Requires: @code{type} shall be a complete
17441 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17442
17443 @item __is_base_of (base_type, derived_type)
17444 If @code{base_type} is a base class of @code{derived_type}
17445 ([class.derived]) then the trait is true, otherwise it is false.
17446 Top-level cv qualifications of @code{base_type} and
17447 @code{derived_type} are ignored. For the purposes of this trait, a
17448 class type is considered is own base. Requires: if @code{__is_class
17449 (base_type)} and @code{__is_class (derived_type)} are true and
17450 @code{base_type} and @code{derived_type} are not the same type
17451 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
17452 type. Diagnostic is produced if this requirement is not met.
17453
17454 @item __is_class (type)
17455 If @code{type} is a cv class type, and not a union type
17456 ([basic.compound]) the trait is true, else it is false.
17457
17458 @item __is_empty (type)
17459 If @code{__is_class (type)} is false then the trait is false.
17460 Otherwise @code{type} is considered empty if and only if: @code{type}
17461 has no non-static data members, or all non-static data members, if
17462 any, are bit-fields of length 0, and @code{type} has no virtual
17463 members, and @code{type} has no virtual base classes, and @code{type}
17464 has no base classes @code{base_type} for which
17465 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
17466 be a complete type, (possibly cv-qualified) @code{void}, or an array
17467 of unknown bound.
17468
17469 @item __is_enum (type)
17470 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
17471 true, else it is false.
17472
17473 @item __is_literal_type (type)
17474 If @code{type} is a literal type ([basic.types]) the trait is
17475 true, else it is false. Requires: @code{type} shall be a complete type,
17476 (possibly cv-qualified) @code{void}, or an array of unknown bound.
17477
17478 @item __is_pod (type)
17479 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
17480 else it is false. Requires: @code{type} shall be a complete type,
17481 (possibly cv-qualified) @code{void}, or an array of unknown bound.
17482
17483 @item __is_polymorphic (type)
17484 If @code{type} is a polymorphic class ([class.virtual]) then the trait
17485 is true, else it is false. Requires: @code{type} shall be a complete
17486 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17487
17488 @item __is_standard_layout (type)
17489 If @code{type} is a standard-layout type ([basic.types]) the trait is
17490 true, else it is false. Requires: @code{type} shall be a complete
17491 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17492
17493 @item __is_trivial (type)
17494 If @code{type} is a trivial type ([basic.types]) the trait is
17495 true, else it is false. Requires: @code{type} shall be a complete
17496 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17497
17498 @item __is_union (type)
17499 If @code{type} is a cv union type ([basic.compound]) the trait is
17500 true, else it is false.
17501
17502 @item __underlying_type (type)
17503 The underlying type of @code{type}. Requires: @code{type} shall be
17504 an enumeration type ([dcl.enum]).
17505
17506 @end table
17507
17508 @node Java Exceptions
17509 @section Java Exceptions
17510
17511 The Java language uses a slightly different exception handling model
17512 from C++. Normally, GNU C++ automatically detects when you are
17513 writing C++ code that uses Java exceptions, and handle them
17514 appropriately. However, if C++ code only needs to execute destructors
17515 when Java exceptions are thrown through it, GCC guesses incorrectly.
17516 Sample problematic code is:
17517
17518 @smallexample
17519 struct S @{ ~S(); @};
17520 extern void bar(); // @r{is written in Java, and may throw exceptions}
17521 void foo()
17522 @{
17523 S s;
17524 bar();
17525 @}
17526 @end smallexample
17527
17528 @noindent
17529 The usual effect of an incorrect guess is a link failure, complaining of
17530 a missing routine called @samp{__gxx_personality_v0}.
17531
17532 You can inform the compiler that Java exceptions are to be used in a
17533 translation unit, irrespective of what it might think, by writing
17534 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
17535 @samp{#pragma} must appear before any functions that throw or catch
17536 exceptions, or run destructors when exceptions are thrown through them.
17537
17538 You cannot mix Java and C++ exceptions in the same translation unit. It
17539 is believed to be safe to throw a C++ exception from one file through
17540 another file compiled for the Java exception model, or vice versa, but
17541 there may be bugs in this area.
17542
17543 @node Deprecated Features
17544 @section Deprecated Features
17545
17546 In the past, the GNU C++ compiler was extended to experiment with new
17547 features, at a time when the C++ language was still evolving. Now that
17548 the C++ standard is complete, some of those features are superseded by
17549 superior alternatives. Using the old features might cause a warning in
17550 some cases that the feature will be dropped in the future. In other
17551 cases, the feature might be gone already.
17552
17553 While the list below is not exhaustive, it documents some of the options
17554 that are now deprecated:
17555
17556 @table @code
17557 @item -fexternal-templates
17558 @itemx -falt-external-templates
17559 These are two of the many ways for G++ to implement template
17560 instantiation. @xref{Template Instantiation}. The C++ standard clearly
17561 defines how template definitions have to be organized across
17562 implementation units. G++ has an implicit instantiation mechanism that
17563 should work just fine for standard-conforming code.
17564
17565 @item -fstrict-prototype
17566 @itemx -fno-strict-prototype
17567 Previously it was possible to use an empty prototype parameter list to
17568 indicate an unspecified number of parameters (like C), rather than no
17569 parameters, as C++ demands. This feature has been removed, except where
17570 it is required for backwards compatibility. @xref{Backwards Compatibility}.
17571 @end table
17572
17573 G++ allows a virtual function returning @samp{void *} to be overridden
17574 by one returning a different pointer type. This extension to the
17575 covariant return type rules is now deprecated and will be removed from a
17576 future version.
17577
17578 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
17579 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
17580 and are now removed from G++. Code using these operators should be
17581 modified to use @code{std::min} and @code{std::max} instead.
17582
17583 The named return value extension has been deprecated, and is now
17584 removed from G++.
17585
17586 The use of initializer lists with new expressions has been deprecated,
17587 and is now removed from G++.
17588
17589 Floating and complex non-type template parameters have been deprecated,
17590 and are now removed from G++.
17591
17592 The implicit typename extension has been deprecated and is now
17593 removed from G++.
17594
17595 The use of default arguments in function pointers, function typedefs
17596 and other places where they are not permitted by the standard is
17597 deprecated and will be removed from a future version of G++.
17598
17599 G++ allows floating-point literals to appear in integral constant expressions,
17600 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
17601 This extension is deprecated and will be removed from a future version.
17602
17603 G++ allows static data members of const floating-point type to be declared
17604 with an initializer in a class definition. The standard only allows
17605 initializers for static members of const integral types and const
17606 enumeration types so this extension has been deprecated and will be removed
17607 from a future version.
17608
17609 @node Backwards Compatibility
17610 @section Backwards Compatibility
17611 @cindex Backwards Compatibility
17612 @cindex ARM [Annotated C++ Reference Manual]
17613
17614 Now that there is a definitive ISO standard C++, G++ has a specification
17615 to adhere to. The C++ language evolved over time, and features that
17616 used to be acceptable in previous drafts of the standard, such as the ARM
17617 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
17618 compilation of C++ written to such drafts, G++ contains some backwards
17619 compatibilities. @emph{All such backwards compatibility features are
17620 liable to disappear in future versions of G++.} They should be considered
17621 deprecated. @xref{Deprecated Features}.
17622
17623 @table @code
17624 @item For scope
17625 If a variable is declared at for scope, it used to remain in scope until
17626 the end of the scope that contained the for statement (rather than just
17627 within the for scope). G++ retains this, but issues a warning, if such a
17628 variable is accessed outside the for scope.
17629
17630 @item Implicit C language
17631 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
17632 scope to set the language. On such systems, all header files are
17633 implicitly scoped inside a C language scope. Also, an empty prototype
17634 @code{()} is treated as an unspecified number of arguments, rather
17635 than no arguments, as C++ demands.
17636 @end table
17637
17638 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
17639 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr followign