]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/extend.texi
Document HLE / RTM intrinsics
[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 * Other Builtins:: Other built-in functions.
86 * Target Builtins:: Built-in functions specific to particular targets.
87 * Target Format Checks:: Format checks specific to particular targets.
88 * Pragmas:: Pragmas accepted by GCC.
89 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
90 * Thread-Local:: Per-thread variables.
91 * Binary constants:: Binary constants using the @samp{0b} prefix.
92 @end menu
93
94 @node Statement Exprs
95 @section Statements and Declarations in Expressions
96 @cindex statements inside expressions
97 @cindex declarations inside expressions
98 @cindex expressions containing statements
99 @cindex macros, statements in expressions
100
101 @c the above section title wrapped and causes an underfull hbox.. i
102 @c changed it from "within" to "in". --mew 4feb93
103 A compound statement enclosed in parentheses may appear as an expression
104 in GNU C@. This allows you to use loops, switches, and local variables
105 within an expression.
106
107 Recall that a compound statement is a sequence of statements surrounded
108 by braces; in this construct, parentheses go around the braces. For
109 example:
110
111 @smallexample
112 (@{ int y = foo (); int z;
113 if (y > 0) z = y;
114 else z = - y;
115 z; @})
116 @end smallexample
117
118 @noindent
119 is a valid (though slightly more complex than necessary) expression
120 for the absolute value of @code{foo ()}.
121
122 The last thing in the compound statement should be an expression
123 followed by a semicolon; the value of this subexpression serves as the
124 value of the entire construct. (If you use some other kind of statement
125 last within the braces, the construct has type @code{void}, and thus
126 effectively no value.)
127
128 This feature is especially useful in making macro definitions ``safe'' (so
129 that they evaluate each operand exactly once). For example, the
130 ``maximum'' function is commonly defined as a macro in standard C as
131 follows:
132
133 @smallexample
134 #define max(a,b) ((a) > (b) ? (a) : (b))
135 @end smallexample
136
137 @noindent
138 @cindex side effects, macro argument
139 But this definition computes either @var{a} or @var{b} twice, with bad
140 results if the operand has side effects. In GNU C, if you know the
141 type of the operands (here taken as @code{int}), you can define
142 the macro safely as follows:
143
144 @smallexample
145 #define maxint(a,b) \
146 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
147 @end smallexample
148
149 Embedded statements are not allowed in constant expressions, such as
150 the value of an enumeration constant, the width of a bit-field, or
151 the initial value of a static variable.
152
153 If you don't know the type of the operand, you can still do this, but you
154 must use @code{typeof} (@pxref{Typeof}).
155
156 In G++, the result value of a statement expression undergoes array and
157 function pointer decay, and is returned by value to the enclosing
158 expression. For instance, if @code{A} is a class, then
159
160 @smallexample
161 A a;
162
163 (@{a;@}).Foo ()
164 @end smallexample
165
166 @noindent
167 constructs a temporary @code{A} object to hold the result of the
168 statement expression, and that is used to invoke @code{Foo}.
169 Therefore the @code{this} pointer observed by @code{Foo} is not the
170 address of @code{a}.
171
172 In a statement expression, any temporaries created within a statement
173 are destroyed at that statement's end. This makes statement
174 expressions inside macros slightly different from function calls. In
175 the latter case temporaries introduced during argument evaluation are
176 destroyed at the end of the statement that includes the function
177 call. In the statement expression case they are destroyed during
178 the statement expression. For instance,
179
180 @smallexample
181 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
182 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
183
184 void foo ()
185 @{
186 macro (X ());
187 function (X ());
188 @}
189 @end smallexample
190
191 @noindent
192 has different places where temporaries are destroyed. For the
193 @code{macro} case, the temporary @code{X} is destroyed just after
194 the initialization of @code{b}. In the @code{function} case that
195 temporary is destroyed when the function returns.
196
197 These considerations mean that it is probably a bad idea to use
198 statement expressions of this form in header files that are designed to
199 work with C++. (Note that some versions of the GNU C Library contained
200 header files using statement expressions that lead to precisely this
201 bug.)
202
203 Jumping into a statement expression with @code{goto} or using a
204 @code{switch} statement outside the statement expression with a
205 @code{case} or @code{default} label inside the statement expression is
206 not permitted. Jumping into a statement expression with a computed
207 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
208 Jumping out of a statement expression is permitted, but if the
209 statement expression is part of a larger expression then it is
210 unspecified which other subexpressions of that expression have been
211 evaluated except where the language definition requires certain
212 subexpressions to be evaluated before or after the statement
213 expression. In any case, as with a function call, the evaluation of a
214 statement expression is not interleaved with the evaluation of other
215 parts of the containing expression. For example,
216
217 @smallexample
218 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
219 @end smallexample
220
221 @noindent
222 calls @code{foo} and @code{bar1} and does not call @code{baz} but
223 may or may not call @code{bar2}. If @code{bar2} is called, it is
224 called after @code{foo} and before @code{bar1}.
225
226 @node Local Labels
227 @section Locally Declared Labels
228 @cindex local labels
229 @cindex macros, local labels
230
231 GCC allows you to declare @dfn{local labels} in any nested block
232 scope. A local label is just like an ordinary label, but you can
233 only reference it (with a @code{goto} statement, or by taking its
234 address) within the block in which it is declared.
235
236 A local label declaration looks like this:
237
238 @smallexample
239 __label__ @var{label};
240 @end smallexample
241
242 @noindent
243 or
244
245 @smallexample
246 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
247 @end smallexample
248
249 Local label declarations must come at the beginning of the block,
250 before any ordinary declarations or statements.
251
252 The label declaration defines the label @emph{name}, but does not define
253 the label itself. You must do this in the usual way, with
254 @code{@var{label}:}, within the statements of the statement expression.
255
256 The local label feature is useful for complex macros. If a macro
257 contains nested loops, a @code{goto} can be useful for breaking out of
258 them. However, an ordinary label whose scope is the whole function
259 cannot be used: if the macro can be expanded several times in one
260 function, the label is multiply defined in that function. A
261 local label avoids this problem. For example:
262
263 @smallexample
264 #define SEARCH(value, array, target) \
265 do @{ \
266 __label__ found; \
267 typeof (target) _SEARCH_target = (target); \
268 typeof (*(array)) *_SEARCH_array = (array); \
269 int i, j; \
270 int value; \
271 for (i = 0; i < max; i++) \
272 for (j = 0; j < max; j++) \
273 if (_SEARCH_array[i][j] == _SEARCH_target) \
274 @{ (value) = i; goto found; @} \
275 (value) = -1; \
276 found:; \
277 @} while (0)
278 @end smallexample
279
280 This could also be written using a statement expression:
281
282 @smallexample
283 #define SEARCH(array, target) \
284 (@{ \
285 __label__ found; \
286 typeof (target) _SEARCH_target = (target); \
287 typeof (*(array)) *_SEARCH_array = (array); \
288 int i, j; \
289 int value; \
290 for (i = 0; i < max; i++) \
291 for (j = 0; j < max; j++) \
292 if (_SEARCH_array[i][j] == _SEARCH_target) \
293 @{ value = i; goto found; @} \
294 value = -1; \
295 found: \
296 value; \
297 @})
298 @end smallexample
299
300 Local label declarations also make the labels they declare visible to
301 nested functions, if there are any. @xref{Nested Functions}, for details.
302
303 @node Labels as Values
304 @section Labels as Values
305 @cindex labels as values
306 @cindex computed gotos
307 @cindex goto with computed label
308 @cindex address of a label
309
310 You can get the address of a label defined in the current function
311 (or a containing function) with the unary operator @samp{&&}. The
312 value has type @code{void *}. This value is a constant and can be used
313 wherever a constant of that type is valid. For example:
314
315 @smallexample
316 void *ptr;
317 /* @r{@dots{}} */
318 ptr = &&foo;
319 @end smallexample
320
321 To use these values, you need to be able to jump to one. This is done
322 with the computed goto statement@footnote{The analogous feature in
323 Fortran is called an assigned goto, but that name seems inappropriate in
324 C, where one can do more than simply store label addresses in label
325 variables.}, @code{goto *@var{exp};}. For example,
326
327 @smallexample
328 goto *ptr;
329 @end smallexample
330
331 @noindent
332 Any expression of type @code{void *} is allowed.
333
334 One way of using these constants is in initializing a static array that
335 serves as a jump table:
336
337 @smallexample
338 static void *array[] = @{ &&foo, &&bar, &&hack @};
339 @end smallexample
340
341 @noindent
342 Then you can select a label with indexing, like this:
343
344 @smallexample
345 goto *array[i];
346 @end smallexample
347
348 @noindent
349 Note that this does not check whether the subscript is in bounds---array
350 indexing in C never does that.
351
352 Such an array of label values serves a purpose much like that of the
353 @code{switch} statement. The @code{switch} statement is cleaner, so
354 use that rather than an array unless the problem does not fit a
355 @code{switch} statement very well.
356
357 Another use of label values is in an interpreter for threaded code.
358 The labels within the interpreter function can be stored in the
359 threaded code for super-fast dispatching.
360
361 You may not use this mechanism to jump to code in a different function.
362 If you do that, totally unpredictable things happen. The best way to
363 avoid this is to store the label address only in automatic variables and
364 never pass it as an argument.
365
366 An alternate way to write the above example is
367
368 @smallexample
369 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
370 &&hack - &&foo @};
371 goto *(&&foo + array[i]);
372 @end smallexample
373
374 @noindent
375 This is more friendly to code living in shared libraries, as it reduces
376 the number of dynamic relocations that are needed, and by consequence,
377 allows the data to be read-only.
378
379 The @code{&&foo} expressions for the same label might have different
380 values if the containing function is inlined or cloned. If a program
381 relies on them being always the same,
382 @code{__attribute__((__noinline__,__noclone__))} should be used to
383 prevent inlining and cloning. If @code{&&foo} is used in a static
384 variable initializer, inlining and cloning is forbidden.
385
386 @node Nested Functions
387 @section Nested Functions
388 @cindex nested functions
389 @cindex downward funargs
390 @cindex thunks
391
392 A @dfn{nested function} is a function defined inside another function.
393 Nested functions are supported as an extension in GNU C, but are not
394 supported by GNU C++.
395
396 The nested function's name is local to the block where it is defined.
397 For example, here we define a nested function named @code{square}, and
398 call it twice:
399
400 @smallexample
401 @group
402 foo (double a, double b)
403 @{
404 double square (double z) @{ return z * z; @}
405
406 return square (a) + square (b);
407 @}
408 @end group
409 @end smallexample
410
411 The nested function can access all the variables of the containing
412 function that are visible at the point of its definition. This is
413 called @dfn{lexical scoping}. For example, here we show a nested
414 function which uses an inherited variable named @code{offset}:
415
416 @smallexample
417 @group
418 bar (int *array, int offset, int size)
419 @{
420 int access (int *array, int index)
421 @{ return array[index + offset]; @}
422 int i;
423 /* @r{@dots{}} */
424 for (i = 0; i < size; i++)
425 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
426 @}
427 @end group
428 @end smallexample
429
430 Nested function definitions are permitted within functions in the places
431 where variable definitions are allowed; that is, in any block, mixed
432 with the other declarations and statements in the block.
433
434 It is possible to call the nested function from outside the scope of its
435 name by storing its address or passing the address to another function:
436
437 @smallexample
438 hack (int *array, int size)
439 @{
440 void store (int index, int value)
441 @{ array[index] = value; @}
442
443 intermediate (store, size);
444 @}
445 @end smallexample
446
447 Here, the function @code{intermediate} receives the address of
448 @code{store} as an argument. If @code{intermediate} calls @code{store},
449 the arguments given to @code{store} are used to store into @code{array}.
450 But this technique works only so long as the containing function
451 (@code{hack}, in this example) does not exit.
452
453 If you try to call the nested function through its address after the
454 containing function exits, all hell breaks loose. If you try
455 to call it after a containing scope level exits, and if it refers
456 to some of the variables that are no longer in scope, you may be lucky,
457 but it's not wise to take the risk. If, however, the nested function
458 does not refer to anything that has gone out of scope, you should be
459 safe.
460
461 GCC implements taking the address of a nested function using a technique
462 called @dfn{trampolines}. This technique was described in
463 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
464 C++ Conference Proceedings, October 17-21, 1988).
465
466 A nested function can jump to a label inherited from a containing
467 function, provided the label is explicitly declared in the containing
468 function (@pxref{Local Labels}). Such a jump returns instantly to the
469 containing function, exiting the nested function that did the
470 @code{goto} and any intermediate functions as well. Here is an example:
471
472 @smallexample
473 @group
474 bar (int *array, int offset, int size)
475 @{
476 __label__ failure;
477 int access (int *array, int index)
478 @{
479 if (index > size)
480 goto failure;
481 return array[index + offset];
482 @}
483 int i;
484 /* @r{@dots{}} */
485 for (i = 0; i < size; i++)
486 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
487 /* @r{@dots{}} */
488 return 0;
489
490 /* @r{Control comes here from @code{access}
491 if it detects an error.} */
492 failure:
493 return -1;
494 @}
495 @end group
496 @end smallexample
497
498 A nested function always has no linkage. Declaring one with
499 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
500 before its definition, use @code{auto} (which is otherwise meaningless
501 for function declarations).
502
503 @smallexample
504 bar (int *array, int offset, int size)
505 @{
506 __label__ failure;
507 auto int access (int *, int);
508 /* @r{@dots{}} */
509 int access (int *array, int index)
510 @{
511 if (index > size)
512 goto failure;
513 return array[index + offset];
514 @}
515 /* @r{@dots{}} */
516 @}
517 @end smallexample
518
519 @node Constructing Calls
520 @section Constructing Function Calls
521 @cindex constructing calls
522 @cindex forwarding calls
523
524 Using the built-in functions described below, you can record
525 the arguments a function received, and call another function
526 with the same arguments, without knowing the number or types
527 of the arguments.
528
529 You can also record the return value of that function call,
530 and later return that value, without knowing what data type
531 the function tried to return (as long as your caller expects
532 that data type).
533
534 However, these built-in functions may interact badly with some
535 sophisticated features or other extensions of the language. It
536 is, therefore, not recommended to use them outside very simple
537 functions acting as mere forwarders for their arguments.
538
539 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
540 This built-in function returns a pointer to data
541 describing how to perform a call with the same arguments as are passed
542 to the current function.
543
544 The function saves the arg pointer register, structure value address,
545 and all registers that might be used to pass arguments to a function
546 into a block of memory allocated on the stack. Then it returns the
547 address of that block.
548 @end deftypefn
549
550 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
551 This built-in function invokes @var{function}
552 with a copy of the parameters described by @var{arguments}
553 and @var{size}.
554
555 The value of @var{arguments} should be the value returned by
556 @code{__builtin_apply_args}. The argument @var{size} specifies the size
557 of the stack argument data, in bytes.
558
559 This function returns a pointer to data describing
560 how to return whatever value is returned by @var{function}. The data
561 is saved in a block of memory allocated on the stack.
562
563 It is not always simple to compute the proper value for @var{size}. The
564 value is used by @code{__builtin_apply} to compute the amount of data
565 that should be pushed on the stack and copied from the incoming argument
566 area.
567 @end deftypefn
568
569 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
570 This built-in function returns the value described by @var{result} from
571 the containing function. You should specify, for @var{result}, a value
572 returned by @code{__builtin_apply}.
573 @end deftypefn
574
575 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
576 This built-in function represents all anonymous arguments of an inline
577 function. It can be used only in inline functions that are always
578 inlined, never compiled as a separate function, such as those using
579 @code{__attribute__ ((__always_inline__))} or
580 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
581 It must be only passed as last argument to some other function
582 with variable arguments. This is useful for writing small wrapper
583 inlines for variable argument functions, when using preprocessor
584 macros is undesirable. For example:
585 @smallexample
586 extern int myprintf (FILE *f, const char *format, ...);
587 extern inline __attribute__ ((__gnu_inline__)) int
588 myprintf (FILE *f, const char *format, ...)
589 @{
590 int r = fprintf (f, "myprintf: ");
591 if (r < 0)
592 return r;
593 int s = fprintf (f, format, __builtin_va_arg_pack ());
594 if (s < 0)
595 return s;
596 return r + s;
597 @}
598 @end smallexample
599 @end deftypefn
600
601 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
602 This built-in function returns the number of anonymous arguments of
603 an inline function. It can be used only in inline functions that
604 are always inlined, never compiled as a separate function, such
605 as those using @code{__attribute__ ((__always_inline__))} or
606 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
607 For example following does link- or run-time checking of open
608 arguments for optimized code:
609 @smallexample
610 #ifdef __OPTIMIZE__
611 extern inline __attribute__((__gnu_inline__)) int
612 myopen (const char *path, int oflag, ...)
613 @{
614 if (__builtin_va_arg_pack_len () > 1)
615 warn_open_too_many_arguments ();
616
617 if (__builtin_constant_p (oflag))
618 @{
619 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
620 @{
621 warn_open_missing_mode ();
622 return __open_2 (path, oflag);
623 @}
624 return open (path, oflag, __builtin_va_arg_pack ());
625 @}
626
627 if (__builtin_va_arg_pack_len () < 1)
628 return __open_2 (path, oflag);
629
630 return open (path, oflag, __builtin_va_arg_pack ());
631 @}
632 #endif
633 @end smallexample
634 @end deftypefn
635
636 @node Typeof
637 @section Referring to a Type with @code{typeof}
638 @findex typeof
639 @findex sizeof
640 @cindex macros, types of arguments
641
642 Another way to refer to the type of an expression is with @code{typeof}.
643 The syntax of using of this keyword looks like @code{sizeof}, but the
644 construct acts semantically like a type name defined with @code{typedef}.
645
646 There are two ways of writing the argument to @code{typeof}: with an
647 expression or with a type. Here is an example with an expression:
648
649 @smallexample
650 typeof (x[0](1))
651 @end smallexample
652
653 @noindent
654 This assumes that @code{x} is an array of pointers to functions;
655 the type described is that of the values of the functions.
656
657 Here is an example with a typename as the argument:
658
659 @smallexample
660 typeof (int *)
661 @end smallexample
662
663 @noindent
664 Here the type described is that of pointers to @code{int}.
665
666 If you are writing a header file that must work when included in ISO C
667 programs, write @code{__typeof__} instead of @code{typeof}.
668 @xref{Alternate Keywords}.
669
670 A @code{typeof} construct can be used anywhere a typedef name can be
671 used. For example, you can use it in a declaration, in a cast, or inside
672 of @code{sizeof} or @code{typeof}.
673
674 The operand of @code{typeof} is evaluated for its side effects if and
675 only if it is an expression of variably modified type or the name of
676 such a type.
677
678 @code{typeof} is often useful in conjunction with
679 statement expressions (@pxref{Statement Exprs}).
680 Here is how the two together can
681 be used to define a safe ``maximum'' macro which operates on any
682 arithmetic type and evaluates each of its arguments exactly once:
683
684 @smallexample
685 #define max(a,b) \
686 (@{ typeof (a) _a = (a); \
687 typeof (b) _b = (b); \
688 _a > _b ? _a : _b; @})
689 @end smallexample
690
691 @cindex underscores in variables in macros
692 @cindex @samp{_} in variables in macros
693 @cindex local variables in macros
694 @cindex variables, local, in macros
695 @cindex macros, local variables in
696
697 The reason for using names that start with underscores for the local
698 variables is to avoid conflicts with variable names that occur within the
699 expressions that are substituted for @code{a} and @code{b}. Eventually we
700 hope to design a new form of declaration syntax that allows you to declare
701 variables whose scopes start only after their initializers; this will be a
702 more reliable way to prevent such conflicts.
703
704 @noindent
705 Some more examples of the use of @code{typeof}:
706
707 @itemize @bullet
708 @item
709 This declares @code{y} with the type of what @code{x} points to.
710
711 @smallexample
712 typeof (*x) y;
713 @end smallexample
714
715 @item
716 This declares @code{y} as an array of such values.
717
718 @smallexample
719 typeof (*x) y[4];
720 @end smallexample
721
722 @item
723 This declares @code{y} as an array of pointers to characters:
724
725 @smallexample
726 typeof (typeof (char *)[4]) y;
727 @end smallexample
728
729 @noindent
730 It is equivalent to the following traditional C declaration:
731
732 @smallexample
733 char *y[4];
734 @end smallexample
735
736 To see the meaning of the declaration using @code{typeof}, and why it
737 might be a useful way to write, rewrite it with these macros:
738
739 @smallexample
740 #define pointer(T) typeof(T *)
741 #define array(T, N) typeof(T [N])
742 @end smallexample
743
744 @noindent
745 Now the declaration can be rewritten this way:
746
747 @smallexample
748 array (pointer (char), 4) y;
749 @end smallexample
750
751 @noindent
752 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
753 pointers to @code{char}.
754 @end itemize
755
756 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
757 a more limited extension that permitted one to write
758
759 @smallexample
760 typedef @var{T} = @var{expr};
761 @end smallexample
762
763 @noindent
764 with the effect of declaring @var{T} to have the type of the expression
765 @var{expr}. This extension does not work with GCC 3 (versions between
766 3.0 and 3.2 crash; 3.2.1 and later give an error). Code that
767 relies on it should be rewritten to use @code{typeof}:
768
769 @smallexample
770 typedef typeof(@var{expr}) @var{T};
771 @end smallexample
772
773 @noindent
774 This works with all versions of GCC@.
775
776 @node Conditionals
777 @section Conditionals with Omitted Operands
778 @cindex conditional expressions, extensions
779 @cindex omitted middle-operands
780 @cindex middle-operands, omitted
781 @cindex extensions, @code{?:}
782 @cindex @code{?:} extensions
783
784 The middle operand in a conditional expression may be omitted. Then
785 if the first operand is nonzero, its value is the value of the conditional
786 expression.
787
788 Therefore, the expression
789
790 @smallexample
791 x ? : y
792 @end smallexample
793
794 @noindent
795 has the value of @code{x} if that is nonzero; otherwise, the value of
796 @code{y}.
797
798 This example is perfectly equivalent to
799
800 @smallexample
801 x ? x : y
802 @end smallexample
803
804 @cindex side effect in @code{?:}
805 @cindex @code{?:} side effect
806 @noindent
807 In this simple case, the ability to omit the middle operand is not
808 especially useful. When it becomes useful is when the first operand does,
809 or may (if it is a macro argument), contain a side effect. Then repeating
810 the operand in the middle would perform the side effect twice. Omitting
811 the middle operand uses the value already computed without the undesirable
812 effects of recomputing it.
813
814 @node __int128
815 @section 128-bit integers
816 @cindex @code{__int128} data types
817
818 As an extension the integer scalar type @code{__int128} is supported for
819 targets which have an integer mode wide enough to hold 128 bits.
820 Simply write @code{__int128} for a signed 128-bit integer, or
821 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
822 support in GCC for expressing an integer constant of type @code{__int128}
823 for targets with @code{long long} integer less than 128 bits wide.
824
825 @node Long Long
826 @section Double-Word Integers
827 @cindex @code{long long} data types
828 @cindex double-word arithmetic
829 @cindex multiprecision arithmetic
830 @cindex @code{LL} integer suffix
831 @cindex @code{ULL} integer suffix
832
833 ISO C99 supports data types for integers that are at least 64 bits wide,
834 and as an extension GCC supports them in C90 mode and in C++.
835 Simply write @code{long long int} for a signed integer, or
836 @code{unsigned long long int} for an unsigned integer. To make an
837 integer constant of type @code{long long int}, add the suffix @samp{LL}
838 to the integer. To make an integer constant of type @code{unsigned long
839 long int}, add the suffix @samp{ULL} to the integer.
840
841 You can use these types in arithmetic like any other integer types.
842 Addition, subtraction, and bitwise boolean operations on these types
843 are open-coded on all types of machines. Multiplication is open-coded
844 if the machine supports a fullword-to-doubleword widening multiply
845 instruction. Division and shifts are open-coded only on machines that
846 provide special support. The operations that are not open-coded use
847 special library routines that come with GCC@.
848
849 There may be pitfalls when you use @code{long long} types for function
850 arguments without function prototypes. If a function
851 expects type @code{int} for its argument, and you pass a value of type
852 @code{long long int}, confusion results because the caller and the
853 subroutine disagree about the number of bytes for the argument.
854 Likewise, if the function expects @code{long long int} and you pass
855 @code{int}. The best way to avoid such problems is to use prototypes.
856
857 @node Complex
858 @section Complex Numbers
859 @cindex complex numbers
860 @cindex @code{_Complex} keyword
861 @cindex @code{__complex__} keyword
862
863 ISO C99 supports complex floating data types, and as an extension GCC
864 supports them in C90 mode and in C++. GCC also supports complex integer data
865 types which are not part of ISO C99. You can declare complex types
866 using the keyword @code{_Complex}. As an extension, the older GNU
867 keyword @code{__complex__} is also supported.
868
869 For example, @samp{_Complex double x;} declares @code{x} as a
870 variable whose real part and imaginary part are both of type
871 @code{double}. @samp{_Complex short int y;} declares @code{y} to
872 have real and imaginary parts of type @code{short int}; this is not
873 likely to be useful, but it shows that the set of complex types is
874 complete.
875
876 To write a constant with a complex data type, use the suffix @samp{i} or
877 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
878 has type @code{_Complex float} and @code{3i} has type
879 @code{_Complex int}. Such a constant always has a pure imaginary
880 value, but you can form any complex value you like by adding one to a
881 real constant. This is a GNU extension; if you have an ISO C99
882 conforming C library (such as the GNU C Library), and want to construct complex
883 constants of floating type, you should include @code{<complex.h>} and
884 use the macros @code{I} or @code{_Complex_I} instead.
885
886 @cindex @code{__real__} keyword
887 @cindex @code{__imag__} keyword
888 To extract the real part of a complex-valued expression @var{exp}, write
889 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
890 extract the imaginary part. This is a GNU extension; for values of
891 floating type, you should use the ISO C99 functions @code{crealf},
892 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
893 @code{cimagl}, declared in @code{<complex.h>} and also provided as
894 built-in functions by GCC@.
895
896 @cindex complex conjugation
897 The operator @samp{~} performs complex conjugation when used on a value
898 with a complex type. This is a GNU extension; for values of
899 floating type, you should use the ISO C99 functions @code{conjf},
900 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
901 provided as built-in functions by GCC@.
902
903 GCC can allocate complex automatic variables in a noncontiguous
904 fashion; it's even possible for the real part to be in a register while
905 the imaginary part is on the stack (or vice versa). Only the DWARF 2
906 debug info format can represent this, so use of DWARF 2 is recommended.
907 If you are using the stabs debug info format, GCC describes a noncontiguous
908 complex variable as if it were two separate variables of noncomplex type.
909 If the variable's actual name is @code{foo}, the two fictitious
910 variables are named @code{foo$real} and @code{foo$imag}. You can
911 examine and set these two fictitious variables with your debugger.
912
913 @node Floating Types
914 @section Additional Floating Types
915 @cindex additional floating types
916 @cindex @code{__float80} data type
917 @cindex @code{__float128} data type
918 @cindex @code{w} floating point suffix
919 @cindex @code{q} floating point suffix
920 @cindex @code{W} floating point suffix
921 @cindex @code{Q} floating point suffix
922
923 As an extension, GNU C supports additional floating
924 types, @code{__float80} and @code{__float128} to support 80-bit
925 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
926 Support for additional types includes the arithmetic operators:
927 add, subtract, multiply, divide; unary arithmetic operators;
928 relational operators; equality operators; and conversions to and from
929 integer and other floating types. Use a suffix @samp{w} or @samp{W}
930 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
931 for @code{_float128}. You can declare complex types using the
932 corresponding internal complex type, @code{XCmode} for @code{__float80}
933 type and @code{TCmode} for @code{__float128} type:
934
935 @smallexample
936 typedef _Complex float __attribute__((mode(TC))) _Complex128;
937 typedef _Complex float __attribute__((mode(XC))) _Complex80;
938 @end smallexample
939
940 Not all targets support additional floating-point types. @code{__float80}
941 and @code{__float128} types are supported on i386, x86_64 and IA-64 targets.
942 The @code{__float128} type is supported on hppa HP-UX targets.
943
944 @node Half-Precision
945 @section Half-Precision Floating Point
946 @cindex half-precision floating point
947 @cindex @code{__fp16} data type
948
949 On ARM targets, GCC supports half-precision (16-bit) floating point via
950 the @code{__fp16} type. You must enable this type explicitly
951 with the @option{-mfp16-format} command-line option in order to use it.
952
953 ARM supports two incompatible representations for half-precision
954 floating-point values. You must choose one of the representations and
955 use it consistently in your program.
956
957 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
958 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
959 There are 11 bits of significand precision, approximately 3
960 decimal digits.
961
962 Specifying @option{-mfp16-format=alternative} selects the ARM
963 alternative format. This representation is similar to the IEEE
964 format, but does not support infinities or NaNs. Instead, the range
965 of exponents is extended, so that this format can represent normalized
966 values in the range of @math{2^{-14}} to 131008.
967
968 The @code{__fp16} type is a storage format only. For purposes
969 of arithmetic and other operations, @code{__fp16} values in C or C++
970 expressions are automatically promoted to @code{float}. In addition,
971 you cannot declare a function with a return value or parameters
972 of type @code{__fp16}.
973
974 Note that conversions from @code{double} to @code{__fp16}
975 involve an intermediate conversion to @code{float}. Because
976 of rounding, this can sometimes produce a different result than a
977 direct conversion.
978
979 ARM provides hardware support for conversions between
980 @code{__fp16} and @code{float} values
981 as an extension to VFP and NEON (Advanced SIMD). GCC generates
982 code using these hardware instructions if you compile with
983 options to select an FPU that provides them;
984 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
985 in addition to the @option{-mfp16-format} option to select
986 a half-precision format.
987
988 Language-level support for the @code{__fp16} data type is
989 independent of whether GCC generates code using hardware floating-point
990 instructions. In cases where hardware support is not specified, GCC
991 implements conversions between @code{__fp16} and @code{float} values
992 as library calls.
993
994 @node Decimal Float
995 @section Decimal Floating Types
996 @cindex decimal floating types
997 @cindex @code{_Decimal32} data type
998 @cindex @code{_Decimal64} data type
999 @cindex @code{_Decimal128} data type
1000 @cindex @code{df} integer suffix
1001 @cindex @code{dd} integer suffix
1002 @cindex @code{dl} integer suffix
1003 @cindex @code{DF} integer suffix
1004 @cindex @code{DD} integer suffix
1005 @cindex @code{DL} integer suffix
1006
1007 As an extension, GNU C supports decimal floating types as
1008 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1009 floating types in GCC will evolve as the draft technical report changes.
1010 Calling conventions for any target might also change. Not all targets
1011 support decimal floating types.
1012
1013 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1014 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1015 @code{float}, @code{double}, and @code{long double} whose radix is not
1016 specified by the C standard but is usually two.
1017
1018 Support for decimal floating types includes the arithmetic operators
1019 add, subtract, multiply, divide; unary arithmetic operators;
1020 relational operators; equality operators; and conversions to and from
1021 integer and other floating types. Use a suffix @samp{df} or
1022 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1023 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1024 @code{_Decimal128}.
1025
1026 GCC support of decimal float as specified by the draft technical report
1027 is incomplete:
1028
1029 @itemize @bullet
1030 @item
1031 When the value of a decimal floating type cannot be represented in the
1032 integer type to which it is being converted, the result is undefined
1033 rather than the result value specified by the draft technical report.
1034
1035 @item
1036 GCC does not provide the C library functionality associated with
1037 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1038 @file{wchar.h}, which must come from a separate C library implementation.
1039 Because of this the GNU C compiler does not define macro
1040 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1041 the technical report.
1042 @end itemize
1043
1044 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1045 are supported by the DWARF 2 debug information format.
1046
1047 @node Hex Floats
1048 @section Hex Floats
1049 @cindex hex floats
1050
1051 ISO C99 supports floating-point numbers written not only in the usual
1052 decimal notation, such as @code{1.55e1}, but also numbers such as
1053 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1054 supports this in C90 mode (except in some cases when strictly
1055 conforming) and in C++. In that format the
1056 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1057 mandatory. The exponent is a decimal number that indicates the power of
1058 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1059 @tex
1060 $1 {15\over16}$,
1061 @end tex
1062 @ifnottex
1063 1 15/16,
1064 @end ifnottex
1065 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1066 is the same as @code{1.55e1}.
1067
1068 Unlike for floating-point numbers in the decimal notation the exponent
1069 is always required in the hexadecimal notation. Otherwise the compiler
1070 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1071 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1072 extension for floating-point constants of type @code{float}.
1073
1074 @node Fixed-Point
1075 @section Fixed-Point Types
1076 @cindex fixed-point types
1077 @cindex @code{_Fract} data type
1078 @cindex @code{_Accum} data type
1079 @cindex @code{_Sat} data type
1080 @cindex @code{hr} fixed-suffix
1081 @cindex @code{r} fixed-suffix
1082 @cindex @code{lr} fixed-suffix
1083 @cindex @code{llr} fixed-suffix
1084 @cindex @code{uhr} fixed-suffix
1085 @cindex @code{ur} fixed-suffix
1086 @cindex @code{ulr} fixed-suffix
1087 @cindex @code{ullr} fixed-suffix
1088 @cindex @code{hk} fixed-suffix
1089 @cindex @code{k} fixed-suffix
1090 @cindex @code{lk} fixed-suffix
1091 @cindex @code{llk} fixed-suffix
1092 @cindex @code{uhk} fixed-suffix
1093 @cindex @code{uk} fixed-suffix
1094 @cindex @code{ulk} fixed-suffix
1095 @cindex @code{ullk} fixed-suffix
1096 @cindex @code{HR} fixed-suffix
1097 @cindex @code{R} fixed-suffix
1098 @cindex @code{LR} fixed-suffix
1099 @cindex @code{LLR} fixed-suffix
1100 @cindex @code{UHR} fixed-suffix
1101 @cindex @code{UR} fixed-suffix
1102 @cindex @code{ULR} fixed-suffix
1103 @cindex @code{ULLR} fixed-suffix
1104 @cindex @code{HK} fixed-suffix
1105 @cindex @code{K} fixed-suffix
1106 @cindex @code{LK} fixed-suffix
1107 @cindex @code{LLK} fixed-suffix
1108 @cindex @code{UHK} fixed-suffix
1109 @cindex @code{UK} fixed-suffix
1110 @cindex @code{ULK} fixed-suffix
1111 @cindex @code{ULLK} fixed-suffix
1112
1113 As an extension, GNU C supports fixed-point types as
1114 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1115 types in GCC will evolve as the draft technical report changes.
1116 Calling conventions for any target might also change. Not all targets
1117 support fixed-point types.
1118
1119 The fixed-point types are
1120 @code{short _Fract},
1121 @code{_Fract},
1122 @code{long _Fract},
1123 @code{long long _Fract},
1124 @code{unsigned short _Fract},
1125 @code{unsigned _Fract},
1126 @code{unsigned long _Fract},
1127 @code{unsigned long long _Fract},
1128 @code{_Sat short _Fract},
1129 @code{_Sat _Fract},
1130 @code{_Sat long _Fract},
1131 @code{_Sat long long _Fract},
1132 @code{_Sat unsigned short _Fract},
1133 @code{_Sat unsigned _Fract},
1134 @code{_Sat unsigned long _Fract},
1135 @code{_Sat unsigned long long _Fract},
1136 @code{short _Accum},
1137 @code{_Accum},
1138 @code{long _Accum},
1139 @code{long long _Accum},
1140 @code{unsigned short _Accum},
1141 @code{unsigned _Accum},
1142 @code{unsigned long _Accum},
1143 @code{unsigned long long _Accum},
1144 @code{_Sat short _Accum},
1145 @code{_Sat _Accum},
1146 @code{_Sat long _Accum},
1147 @code{_Sat long long _Accum},
1148 @code{_Sat unsigned short _Accum},
1149 @code{_Sat unsigned _Accum},
1150 @code{_Sat unsigned long _Accum},
1151 @code{_Sat unsigned long long _Accum}.
1152
1153 Fixed-point data values contain fractional and optional integral parts.
1154 The format of fixed-point data varies and depends on the target machine.
1155
1156 Support for fixed-point types includes:
1157 @itemize @bullet
1158 @item
1159 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1160 @item
1161 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1162 @item
1163 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1164 @item
1165 binary shift operators (@code{<<}, @code{>>})
1166 @item
1167 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1168 @item
1169 equality operators (@code{==}, @code{!=})
1170 @item
1171 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1172 @code{<<=}, @code{>>=})
1173 @item
1174 conversions to and from integer, floating-point, or fixed-point types
1175 @end itemize
1176
1177 Use a suffix in a fixed-point literal constant:
1178 @itemize
1179 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1180 @code{_Sat short _Fract}
1181 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1182 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1183 @code{_Sat long _Fract}
1184 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1185 @code{_Sat long long _Fract}
1186 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1187 @code{_Sat unsigned short _Fract}
1188 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1189 @code{_Sat unsigned _Fract}
1190 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1191 @code{_Sat unsigned long _Fract}
1192 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1193 and @code{_Sat unsigned long long _Fract}
1194 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1195 @code{_Sat short _Accum}
1196 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1197 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1198 @code{_Sat long _Accum}
1199 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1200 @code{_Sat long long _Accum}
1201 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1202 @code{_Sat unsigned short _Accum}
1203 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1204 @code{_Sat unsigned _Accum}
1205 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1206 @code{_Sat unsigned long _Accum}
1207 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1208 and @code{_Sat unsigned long long _Accum}
1209 @end itemize
1210
1211 GCC support of fixed-point types as specified by the draft technical report
1212 is incomplete:
1213
1214 @itemize @bullet
1215 @item
1216 Pragmas to control overflow and rounding behaviors are not implemented.
1217 @end itemize
1218
1219 Fixed-point types are supported by the DWARF 2 debug information format.
1220
1221 @node Named Address Spaces
1222 @section Named Address Spaces
1223 @cindex Named Address Spaces
1224
1225 As an extension, GNU C supports named address spaces as
1226 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1227 address spaces in GCC will evolve as the draft technical report
1228 changes. Calling conventions for any target might also change. At
1229 present, only the AVR, SPU, M32C, and RL78 targets support address
1230 spaces other than the generic address space.
1231
1232 Address space identifiers may be used exactly like any other C type
1233 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1234 document for more details.
1235
1236 @anchor{AVR Named Address Spaces}
1237 @subsection AVR Named Address Spaces
1238
1239 On the AVR target, there are several address spaces that can be used
1240 in order to put read-only data into the flash memory and access that
1241 data by means of the special instructions @code{LPM} or @code{ELPM}
1242 needed to read from flash.
1243
1244 Per default, any data including read-only data is located in RAM
1245 (the generic address space) so that non-generic address spaces are
1246 needed to locate read-only data in flash memory
1247 @emph{and} to generate the right instructions to access this data
1248 without using (inline) assembler code.
1249
1250 @table @code
1251 @item __flash
1252 @cindex @code{__flash} AVR Named Address Spaces
1253 The @code{__flash} qualifier locates data in the
1254 @code{.progmem.data} section. Data is read using the @code{LPM}
1255 instruction. Pointers to this address space are 16 bits wide.
1256
1257 @item __flash1
1258 @itemx __flash2
1259 @itemx __flash3
1260 @itemx __flash4
1261 @itemx __flash5
1262 @cindex @code{__flash1} AVR Named Address Spaces
1263 @cindex @code{__flash2} AVR Named Address Spaces
1264 @cindex @code{__flash3} AVR Named Address Spaces
1265 @cindex @code{__flash4} AVR Named Address Spaces
1266 @cindex @code{__flash5} AVR Named Address Spaces
1267 These are 16-bit address spaces locating data in section
1268 @code{.progmem@var{N}.data} where @var{N} refers to
1269 address space @code{__flash@var{N}}.
1270 The compiler sets the @code{RAMPZ} segment register appropriately
1271 before reading data by means of the @code{ELPM} instruction.
1272
1273 @item __memx
1274 @cindex @code{__memx} AVR Named Address Spaces
1275 This is a 24-bit address space that linearizes flash and RAM:
1276 If the high bit of the address is set, data is read from
1277 RAM using the lower two bytes as RAM address.
1278 If the high bit of the address is clear, data is read from flash
1279 with @code{RAMPZ} set according to the high byte of the address.
1280 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1281
1282 Objects in this address space are located in @code{.progmemx.data}.
1283 @end table
1284
1285 @b{Example}
1286
1287 @smallexample
1288 char my_read (const __flash char ** p)
1289 @{
1290 /* p is a pointer to RAM that points to a pointer to flash.
1291 The first indirection of p reads that flash pointer
1292 from RAM and the second indirection reads a char from this
1293 flash address. */
1294
1295 return **p;
1296 @}
1297
1298 /* Locate array[] in flash memory */
1299 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1300
1301 int i = 1;
1302
1303 int main (void)
1304 @{
1305 /* Return 17 by reading from flash memory */
1306 return array[array[i]];
1307 @}
1308 @end smallexample
1309
1310 @noindent
1311 For each named address space supported by avr-gcc there is an equally
1312 named but uppercase built-in macro defined.
1313 The purpose is to facilitate testing if respective address space
1314 support is available or not:
1315
1316 @smallexample
1317 #ifdef __FLASH
1318 const __flash int var = 1;
1319
1320 int read_var (void)
1321 @{
1322 return var;
1323 @}
1324 #else
1325 #include <avr/pgmspace.h> /* From AVR-LibC */
1326
1327 const int var PROGMEM = 1;
1328
1329 int read_var (void)
1330 @{
1331 return (int) pgm_read_word (&var);
1332 @}
1333 #endif /* __FLASH */
1334 @end smallexample
1335
1336 @noindent
1337 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1338 locates data in flash but
1339 accesses to these data read from generic address space, i.e.@:
1340 from RAM,
1341 so that you need special accessors like @code{pgm_read_byte}
1342 from @w{@uref{http://nongnu.org/avr-libc/user-manual,AVR-LibC}}
1343 together with attribute @code{progmem}.
1344
1345 @noindent
1346 @b{Limitations and caveats}
1347
1348 @itemize
1349 @item
1350 Reading across the 64@tie{}KiB section boundary of
1351 the @code{__flash} or @code{__flash@var{N}} address spaces
1352 shows undefined behavior. The only address space that
1353 supports reading across the 64@tie{}KiB flash segment boundaries is
1354 @code{__memx}.
1355
1356 @item
1357 If you use one of the @code{__flash@var{N}} address spaces
1358 you must arrange your linker script to locate the
1359 @code{.progmem@var{N}.data} sections according to your needs.
1360
1361 @item
1362 Any data or pointers to the non-generic address spaces must
1363 be qualified as @code{const}, i.e.@: as read-only data.
1364 This still applies if the data in one of these address
1365 spaces like software version number or calibration lookup table are intended to
1366 be changed after load time by, say, a boot loader. In this case
1367 the right qualification is @code{const} @code{volatile} so that the compiler
1368 must not optimize away known values or insert them
1369 as immediates into operands of instructions.
1370
1371 @item
1372 The following code initializes a variable @code{pfoo}
1373 located in static storage with a 24-bit address:
1374 @smallexample
1375 extern const __memx char foo;
1376 const __memx void *pfoo = &foo;
1377 @end smallexample
1378
1379 @noindent
1380 Such code requires at least binutils 2.23, see
1381 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1382
1383 @end itemize
1384
1385 @subsection M32C Named Address Spaces
1386 @cindex @code{__far} M32C Named Address Spaces
1387
1388 On the M32C target, with the R8C and M16C CPU variants, variables
1389 qualified with @code{__far} are accessed using 32-bit addresses in
1390 order to access memory beyond the first 64@tie{}Ki bytes. If
1391 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1392 effect.
1393
1394 @subsection RL78 Named Address Spaces
1395 @cindex @code{__far} RL78 Named Address Spaces
1396
1397 On the RL78 target, variables qualified with @code{__far} are accessed
1398 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1399 addresses. Non-far variables are assumed to appear in the topmost
1400 64@tie{}KiB of the address space.
1401
1402 @subsection SPU Named Address Spaces
1403 @cindex @code{__ea} SPU Named Address Spaces
1404
1405 On the SPU target variables may be declared as
1406 belonging to another address space by qualifying the type with the
1407 @code{__ea} address space identifier:
1408
1409 @smallexample
1410 extern int __ea i;
1411 @end smallexample
1412
1413 @noindent
1414 The compiler generates special code to access the variable @code{i}.
1415 It may use runtime library
1416 support, or generate special machine instructions to access that address
1417 space.
1418
1419 @node Zero Length
1420 @section Arrays of Length Zero
1421 @cindex arrays of length zero
1422 @cindex zero-length arrays
1423 @cindex length-zero arrays
1424 @cindex flexible array members
1425
1426 Zero-length arrays are allowed in GNU C@. They are very useful as the
1427 last element of a structure that is really a header for a variable-length
1428 object:
1429
1430 @smallexample
1431 struct line @{
1432 int length;
1433 char contents[0];
1434 @};
1435
1436 struct line *thisline = (struct line *)
1437 malloc (sizeof (struct line) + this_length);
1438 thisline->length = this_length;
1439 @end smallexample
1440
1441 In ISO C90, you would have to give @code{contents} a length of 1, which
1442 means either you waste space or complicate the argument to @code{malloc}.
1443
1444 In ISO C99, you would use a @dfn{flexible array member}, which is
1445 slightly different in syntax and semantics:
1446
1447 @itemize @bullet
1448 @item
1449 Flexible array members are written as @code{contents[]} without
1450 the @code{0}.
1451
1452 @item
1453 Flexible array members have incomplete type, and so the @code{sizeof}
1454 operator may not be applied. As a quirk of the original implementation
1455 of zero-length arrays, @code{sizeof} evaluates to zero.
1456
1457 @item
1458 Flexible array members may only appear as the last member of a
1459 @code{struct} that is otherwise non-empty.
1460
1461 @item
1462 A structure containing a flexible array member, or a union containing
1463 such a structure (possibly recursively), may not be a member of a
1464 structure or an element of an array. (However, these uses are
1465 permitted by GCC as extensions.)
1466 @end itemize
1467
1468 GCC versions before 3.0 allowed zero-length arrays to be statically
1469 initialized, as if they were flexible arrays. In addition to those
1470 cases that were useful, it also allowed initializations in situations
1471 that would corrupt later data. Non-empty initialization of zero-length
1472 arrays is now treated like any case where there are more initializer
1473 elements than the array holds, in that a suitable warning about ``excess
1474 elements in array'' is given, and the excess elements (all of them, in
1475 this case) are ignored.
1476
1477 Instead GCC allows static initialization of flexible array members.
1478 This is equivalent to defining a new structure containing the original
1479 structure followed by an array of sufficient size to contain the data.
1480 E.g.@: in the following, @code{f1} is constructed as if it were declared
1481 like @code{f2}.
1482
1483 @smallexample
1484 struct f1 @{
1485 int x; int y[];
1486 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1487
1488 struct f2 @{
1489 struct f1 f1; int data[3];
1490 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1491 @end smallexample
1492
1493 @noindent
1494 The convenience of this extension is that @code{f1} has the desired
1495 type, eliminating the need to consistently refer to @code{f2.f1}.
1496
1497 This has symmetry with normal static arrays, in that an array of
1498 unknown size is also written with @code{[]}.
1499
1500 Of course, this extension only makes sense if the extra data comes at
1501 the end of a top-level object, as otherwise we would be overwriting
1502 data at subsequent offsets. To avoid undue complication and confusion
1503 with initialization of deeply nested arrays, we simply disallow any
1504 non-empty initialization except when the structure is the top-level
1505 object. For example:
1506
1507 @smallexample
1508 struct foo @{ int x; int y[]; @};
1509 struct bar @{ struct foo z; @};
1510
1511 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1512 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1513 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1514 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1515 @end smallexample
1516
1517 @node Empty Structures
1518 @section Structures With No Members
1519 @cindex empty structures
1520 @cindex zero-size structures
1521
1522 GCC permits a C structure to have no members:
1523
1524 @smallexample
1525 struct empty @{
1526 @};
1527 @end smallexample
1528
1529 The structure has size zero. In C++, empty structures are part
1530 of the language. G++ treats empty structures as if they had a single
1531 member of type @code{char}.
1532
1533 @node Variable Length
1534 @section Arrays of Variable Length
1535 @cindex variable-length arrays
1536 @cindex arrays of variable length
1537 @cindex VLAs
1538
1539 Variable-length automatic arrays are allowed in ISO C99, and as an
1540 extension GCC accepts them in C90 mode and in C++. These arrays are
1541 declared like any other automatic arrays, but with a length that is not
1542 a constant expression. The storage is allocated at the point of
1543 declaration and deallocated when the block scope containing the declaration
1544 exits. For
1545 example:
1546
1547 @smallexample
1548 FILE *
1549 concat_fopen (char *s1, char *s2, char *mode)
1550 @{
1551 char str[strlen (s1) + strlen (s2) + 1];
1552 strcpy (str, s1);
1553 strcat (str, s2);
1554 return fopen (str, mode);
1555 @}
1556 @end smallexample
1557
1558 @cindex scope of a variable length array
1559 @cindex variable-length array scope
1560 @cindex deallocating variable length arrays
1561 Jumping or breaking out of the scope of the array name deallocates the
1562 storage. Jumping into the scope is not allowed; you get an error
1563 message for it.
1564
1565 @cindex @code{alloca} vs variable-length arrays
1566 You can use the function @code{alloca} to get an effect much like
1567 variable-length arrays. The function @code{alloca} is available in
1568 many other C implementations (but not in all). On the other hand,
1569 variable-length arrays are more elegant.
1570
1571 There are other differences between these two methods. Space allocated
1572 with @code{alloca} exists until the containing @emph{function} returns.
1573 The space for a variable-length array is deallocated as soon as the array
1574 name's scope ends. (If you use both variable-length arrays and
1575 @code{alloca} in the same function, deallocation of a variable-length array
1576 also deallocates anything more recently allocated with @code{alloca}.)
1577
1578 You can also use variable-length arrays as arguments to functions:
1579
1580 @smallexample
1581 struct entry
1582 tester (int len, char data[len][len])
1583 @{
1584 /* @r{@dots{}} */
1585 @}
1586 @end smallexample
1587
1588 The length of an array is computed once when the storage is allocated
1589 and is remembered for the scope of the array in case you access it with
1590 @code{sizeof}.
1591
1592 If you want to pass the array first and the length afterward, you can
1593 use a forward declaration in the parameter list---another GNU extension.
1594
1595 @smallexample
1596 struct entry
1597 tester (int len; char data[len][len], int len)
1598 @{
1599 /* @r{@dots{}} */
1600 @}
1601 @end smallexample
1602
1603 @cindex parameter forward declaration
1604 The @samp{int len} before the semicolon is a @dfn{parameter forward
1605 declaration}, and it serves the purpose of making the name @code{len}
1606 known when the declaration of @code{data} is parsed.
1607
1608 You can write any number of such parameter forward declarations in the
1609 parameter list. They can be separated by commas or semicolons, but the
1610 last one must end with a semicolon, which is followed by the ``real''
1611 parameter declarations. Each forward declaration must match a ``real''
1612 declaration in parameter name and data type. ISO C99 does not support
1613 parameter forward declarations.
1614
1615 @node Variadic Macros
1616 @section Macros with a Variable Number of Arguments.
1617 @cindex variable number of arguments
1618 @cindex macro with variable arguments
1619 @cindex rest argument (in macro)
1620 @cindex variadic macros
1621
1622 In the ISO C standard of 1999, a macro can be declared to accept a
1623 variable number of arguments much as a function can. The syntax for
1624 defining the macro is similar to that of a function. Here is an
1625 example:
1626
1627 @smallexample
1628 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1629 @end smallexample
1630
1631 @noindent
1632 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1633 such a macro, it represents the zero or more tokens until the closing
1634 parenthesis that ends the invocation, including any commas. This set of
1635 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1636 wherever it appears. See the CPP manual for more information.
1637
1638 GCC has long supported variadic macros, and used a different syntax that
1639 allowed you to give a name to the variable arguments just like any other
1640 argument. Here is an example:
1641
1642 @smallexample
1643 #define debug(format, args...) fprintf (stderr, format, args)
1644 @end smallexample
1645
1646 @noindent
1647 This is in all ways equivalent to the ISO C example above, but arguably
1648 more readable and descriptive.
1649
1650 GNU CPP has two further variadic macro extensions, and permits them to
1651 be used with either of the above forms of macro definition.
1652
1653 In standard C, you are not allowed to leave the variable argument out
1654 entirely; but you are allowed to pass an empty argument. For example,
1655 this invocation is invalid in ISO C, because there is no comma after
1656 the string:
1657
1658 @smallexample
1659 debug ("A message")
1660 @end smallexample
1661
1662 GNU CPP permits you to completely omit the variable arguments in this
1663 way. In the above examples, the compiler would complain, though since
1664 the expansion of the macro still has the extra comma after the format
1665 string.
1666
1667 To help solve this problem, CPP behaves specially for variable arguments
1668 used with the token paste operator, @samp{##}. If instead you write
1669
1670 @smallexample
1671 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1672 @end smallexample
1673
1674 @noindent
1675 and if the variable arguments are omitted or empty, the @samp{##}
1676 operator causes the preprocessor to remove the comma before it. If you
1677 do provide some variable arguments in your macro invocation, GNU CPP
1678 does not complain about the paste operation and instead places the
1679 variable arguments after the comma. Just like any other pasted macro
1680 argument, these arguments are not macro expanded.
1681
1682 @node Escaped Newlines
1683 @section Slightly Looser Rules for Escaped Newlines
1684 @cindex escaped newlines
1685 @cindex newlines (escaped)
1686
1687 Recently, the preprocessor has relaxed its treatment of escaped
1688 newlines. Previously, the newline had to immediately follow a
1689 backslash. The current implementation allows whitespace in the form
1690 of spaces, horizontal and vertical tabs, and form feeds between the
1691 backslash and the subsequent newline. The preprocessor issues a
1692 warning, but treats it as a valid escaped newline and combines the two
1693 lines to form a single logical line. This works within comments and
1694 tokens, as well as between tokens. Comments are @emph{not} treated as
1695 whitespace for the purposes of this relaxation, since they have not
1696 yet been replaced with spaces.
1697
1698 @node Subscripting
1699 @section Non-Lvalue Arrays May Have Subscripts
1700 @cindex subscripting
1701 @cindex arrays, non-lvalue
1702
1703 @cindex subscripting and function values
1704 In ISO C99, arrays that are not lvalues still decay to pointers, and
1705 may be subscripted, although they may not be modified or used after
1706 the next sequence point and the unary @samp{&} operator may not be
1707 applied to them. As an extension, GNU C allows such arrays to be
1708 subscripted in C90 mode, though otherwise they do not decay to
1709 pointers outside C99 mode. For example,
1710 this is valid in GNU C though not valid in C90:
1711
1712 @smallexample
1713 @group
1714 struct foo @{int a[4];@};
1715
1716 struct foo f();
1717
1718 bar (int index)
1719 @{
1720 return f().a[index];
1721 @}
1722 @end group
1723 @end smallexample
1724
1725 @node Pointer Arith
1726 @section Arithmetic on @code{void}- and Function-Pointers
1727 @cindex void pointers, arithmetic
1728 @cindex void, size of pointer to
1729 @cindex function pointers, arithmetic
1730 @cindex function, size of pointer to
1731
1732 In GNU C, addition and subtraction operations are supported on pointers to
1733 @code{void} and on pointers to functions. This is done by treating the
1734 size of a @code{void} or of a function as 1.
1735
1736 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1737 and on function types, and returns 1.
1738
1739 @opindex Wpointer-arith
1740 The option @option{-Wpointer-arith} requests a warning if these extensions
1741 are used.
1742
1743 @node Initializers
1744 @section Non-Constant Initializers
1745 @cindex initializers, non-constant
1746 @cindex non-constant initializers
1747
1748 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1749 automatic variable are not required to be constant expressions in GNU C@.
1750 Here is an example of an initializer with run-time varying elements:
1751
1752 @smallexample
1753 foo (float f, float g)
1754 @{
1755 float beat_freqs[2] = @{ f-g, f+g @};
1756 /* @r{@dots{}} */
1757 @}
1758 @end smallexample
1759
1760 @node Compound Literals
1761 @section Compound Literals
1762 @cindex constructor expressions
1763 @cindex initializations in expressions
1764 @cindex structures, constructor expression
1765 @cindex expressions, constructor
1766 @cindex compound literals
1767 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1768
1769 ISO C99 supports compound literals. A compound literal looks like
1770 a cast containing an initializer. Its value is an object of the
1771 type specified in the cast, containing the elements specified in
1772 the initializer; it is an lvalue. As an extension, GCC supports
1773 compound literals in C90 mode and in C++, though the semantics are
1774 somewhat different in C++.
1775
1776 Usually, the specified type is a structure. Assume that
1777 @code{struct foo} and @code{structure} are declared as shown:
1778
1779 @smallexample
1780 struct foo @{int a; char b[2];@} structure;
1781 @end smallexample
1782
1783 @noindent
1784 Here is an example of constructing a @code{struct foo} with a compound literal:
1785
1786 @smallexample
1787 structure = ((struct foo) @{x + y, 'a', 0@});
1788 @end smallexample
1789
1790 @noindent
1791 This is equivalent to writing the following:
1792
1793 @smallexample
1794 @{
1795 struct foo temp = @{x + y, 'a', 0@};
1796 structure = temp;
1797 @}
1798 @end smallexample
1799
1800 You can also construct an array, though this is dangerous in C++, as
1801 explained below. If all the elements of the compound literal are
1802 (made up of) simple constant expressions, suitable for use in
1803 initializers of objects of static storage duration, then the compound
1804 literal can be coerced to a pointer to its first element and used in
1805 such an initializer, as shown here:
1806
1807 @smallexample
1808 char **foo = (char *[]) @{ "x", "y", "z" @};
1809 @end smallexample
1810
1811 Compound literals for scalar types and union types are
1812 also allowed, but then the compound literal is equivalent
1813 to a cast.
1814
1815 As a GNU extension, GCC allows initialization of objects with static storage
1816 duration by compound literals (which is not possible in ISO C99, because
1817 the initializer is not a constant).
1818 It is handled as if the object is initialized only with the bracket
1819 enclosed list if the types of the compound literal and the object match.
1820 The initializer list of the compound literal must be constant.
1821 If the object being initialized has array type of unknown size, the size is
1822 determined by compound literal size.
1823
1824 @smallexample
1825 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1826 static int y[] = (int []) @{1, 2, 3@};
1827 static int z[] = (int [3]) @{1@};
1828 @end smallexample
1829
1830 @noindent
1831 The above lines are equivalent to the following:
1832 @smallexample
1833 static struct foo x = @{1, 'a', 'b'@};
1834 static int y[] = @{1, 2, 3@};
1835 static int z[] = @{1, 0, 0@};
1836 @end smallexample
1837
1838 In C, a compound literal designates an unnamed object with static or
1839 automatic storage duration. In C++, a compound literal designates a
1840 temporary object, which only lives until the end of its
1841 full-expression. As a result, well-defined C code that takes the
1842 address of a subobject of a compound literal can be undefined in C++.
1843 For instance, if the array compound literal example above appeared
1844 inside a function, any subsequent use of @samp{foo} in C++ has
1845 undefined behavior because the lifetime of the array ends after the
1846 declaration of @samp{foo}. As a result, the C++ compiler now rejects
1847 the conversion of a temporary array to a pointer.
1848
1849 As an optimization, the C++ compiler sometimes gives array compound
1850 literals longer lifetimes: when the array either appears outside a
1851 function or has const-qualified type. If @samp{foo} and its
1852 initializer had elements of @samp{char *const} type rather than
1853 @samp{char *}, or if @samp{foo} were a global variable, the array
1854 would have static storage duration. But it is probably safest just to
1855 avoid the use of array compound literals in code compiled as C++.
1856
1857 @node Designated Inits
1858 @section Designated Initializers
1859 @cindex initializers with labeled elements
1860 @cindex labeled elements in initializers
1861 @cindex case labels in initializers
1862 @cindex designated initializers
1863
1864 Standard C90 requires the elements of an initializer to appear in a fixed
1865 order, the same as the order of the elements in the array or structure
1866 being initialized.
1867
1868 In ISO C99 you can give the elements in any order, specifying the array
1869 indices or structure field names they apply to, and GNU C allows this as
1870 an extension in C90 mode as well. This extension is not
1871 implemented in GNU C++.
1872
1873 To specify an array index, write
1874 @samp{[@var{index}] =} before the element value. For example,
1875
1876 @smallexample
1877 int a[6] = @{ [4] = 29, [2] = 15 @};
1878 @end smallexample
1879
1880 @noindent
1881 is equivalent to
1882
1883 @smallexample
1884 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1885 @end smallexample
1886
1887 @noindent
1888 The index values must be constant expressions, even if the array being
1889 initialized is automatic.
1890
1891 An alternative syntax for this that has been obsolete since GCC 2.5 but
1892 GCC still accepts is to write @samp{[@var{index}]} before the element
1893 value, with no @samp{=}.
1894
1895 To initialize a range of elements to the same value, write
1896 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
1897 extension. For example,
1898
1899 @smallexample
1900 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1901 @end smallexample
1902
1903 @noindent
1904 If the value in it has side-effects, the side-effects happen only once,
1905 not for each initialized field by the range initializer.
1906
1907 @noindent
1908 Note that the length of the array is the highest value specified
1909 plus one.
1910
1911 In a structure initializer, specify the name of a field to initialize
1912 with @samp{.@var{fieldname} =} before the element value. For example,
1913 given the following structure,
1914
1915 @smallexample
1916 struct point @{ int x, y; @};
1917 @end smallexample
1918
1919 @noindent
1920 the following initialization
1921
1922 @smallexample
1923 struct point p = @{ .y = yvalue, .x = xvalue @};
1924 @end smallexample
1925
1926 @noindent
1927 is equivalent to
1928
1929 @smallexample
1930 struct point p = @{ xvalue, yvalue @};
1931 @end smallexample
1932
1933 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1934 @samp{@var{fieldname}:}, as shown here:
1935
1936 @smallexample
1937 struct point p = @{ y: yvalue, x: xvalue @};
1938 @end smallexample
1939
1940 @cindex designators
1941 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1942 @dfn{designator}. You can also use a designator (or the obsolete colon
1943 syntax) when initializing a union, to specify which element of the union
1944 should be used. For example,
1945
1946 @smallexample
1947 union foo @{ int i; double d; @};
1948
1949 union foo f = @{ .d = 4 @};
1950 @end smallexample
1951
1952 @noindent
1953 converts 4 to a @code{double} to store it in the union using
1954 the second element. By contrast, casting 4 to type @code{union foo}
1955 stores it into the union as the integer @code{i}, since it is
1956 an integer. (@xref{Cast to Union}.)
1957
1958 You can combine this technique of naming elements with ordinary C
1959 initialization of successive elements. Each initializer element that
1960 does not have a designator applies to the next consecutive element of the
1961 array or structure. For example,
1962
1963 @smallexample
1964 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
1965 @end smallexample
1966
1967 @noindent
1968 is equivalent to
1969
1970 @smallexample
1971 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
1972 @end smallexample
1973
1974 Labeling the elements of an array initializer is especially useful
1975 when the indices are characters or belong to an @code{enum} type.
1976 For example:
1977
1978 @smallexample
1979 int whitespace[256]
1980 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
1981 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
1982 @end smallexample
1983
1984 @cindex designator lists
1985 You can also write a series of @samp{.@var{fieldname}} and
1986 @samp{[@var{index}]} designators before an @samp{=} to specify a
1987 nested subobject to initialize; the list is taken relative to the
1988 subobject corresponding to the closest surrounding brace pair. For
1989 example, with the @samp{struct point} declaration above:
1990
1991 @smallexample
1992 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
1993 @end smallexample
1994
1995 @noindent
1996 If the same field is initialized multiple times, it has the value from
1997 the last initialization. If any such overridden initialization has
1998 side-effect, it is unspecified whether the side-effect happens or not.
1999 Currently, GCC discards them and issues a warning.
2000
2001 @node Case Ranges
2002 @section Case Ranges
2003 @cindex case ranges
2004 @cindex ranges in case statements
2005
2006 You can specify a range of consecutive values in a single @code{case} label,
2007 like this:
2008
2009 @smallexample
2010 case @var{low} ... @var{high}:
2011 @end smallexample
2012
2013 @noindent
2014 This has the same effect as the proper number of individual @code{case}
2015 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2016
2017 This feature is especially useful for ranges of ASCII character codes:
2018
2019 @smallexample
2020 case 'A' ... 'Z':
2021 @end smallexample
2022
2023 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2024 it may be parsed wrong when you use it with integer values. For example,
2025 write this:
2026
2027 @smallexample
2028 case 1 ... 5:
2029 @end smallexample
2030
2031 @noindent
2032 rather than this:
2033
2034 @smallexample
2035 case 1...5:
2036 @end smallexample
2037
2038 @node Cast to Union
2039 @section Cast to a Union Type
2040 @cindex cast to a union
2041 @cindex union, casting to a
2042
2043 A cast to union type is similar to other casts, except that the type
2044 specified is a union type. You can specify the type either with
2045 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2046 a constructor, not a cast, and hence does not yield an lvalue like
2047 normal casts. (@xref{Compound Literals}.)
2048
2049 The types that may be cast to the union type are those of the members
2050 of the union. Thus, given the following union and variables:
2051
2052 @smallexample
2053 union foo @{ int i; double d; @};
2054 int x;
2055 double y;
2056 @end smallexample
2057
2058 @noindent
2059 both @code{x} and @code{y} can be cast to type @code{union foo}.
2060
2061 Using the cast as the right-hand side of an assignment to a variable of
2062 union type is equivalent to storing in a member of the union:
2063
2064 @smallexample
2065 union foo u;
2066 /* @r{@dots{}} */
2067 u = (union foo) x @equiv{} u.i = x
2068 u = (union foo) y @equiv{} u.d = y
2069 @end smallexample
2070
2071 You can also use the union cast as a function argument:
2072
2073 @smallexample
2074 void hack (union foo);
2075 /* @r{@dots{}} */
2076 hack ((union foo) x);
2077 @end smallexample
2078
2079 @node Mixed Declarations
2080 @section Mixed Declarations and Code
2081 @cindex mixed declarations and code
2082 @cindex declarations, mixed with code
2083 @cindex code, mixed with declarations
2084
2085 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2086 within compound statements. As an extension, GNU C also allows this in
2087 C90 mode. For example, you could do:
2088
2089 @smallexample
2090 int i;
2091 /* @r{@dots{}} */
2092 i++;
2093 int j = i + 2;
2094 @end smallexample
2095
2096 Each identifier is visible from where it is declared until the end of
2097 the enclosing block.
2098
2099 @node Function Attributes
2100 @section Declaring Attributes of Functions
2101 @cindex function attributes
2102 @cindex declaring attributes of functions
2103 @cindex functions that never return
2104 @cindex functions that return more than once
2105 @cindex functions that have no side effects
2106 @cindex functions in arbitrary sections
2107 @cindex functions that behave like malloc
2108 @cindex @code{volatile} applied to function
2109 @cindex @code{const} applied to function
2110 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2111 @cindex functions with non-null pointer arguments
2112 @cindex functions that are passed arguments in registers on the 386
2113 @cindex functions that pop the argument stack on the 386
2114 @cindex functions that do not pop the argument stack on the 386
2115 @cindex functions that have different compilation options on the 386
2116 @cindex functions that have different optimization options
2117 @cindex functions that are dynamically resolved
2118
2119 In GNU C, you declare certain things about functions called in your program
2120 which help the compiler optimize function calls and check your code more
2121 carefully.
2122
2123 The keyword @code{__attribute__} allows you to specify special
2124 attributes when making a declaration. This keyword is followed by an
2125 attribute specification inside double parentheses. The following
2126 attributes are currently defined for functions on all targets:
2127 @code{aligned}, @code{alloc_size}, @code{noreturn},
2128 @code{returns_twice}, @code{noinline}, @code{noclone},
2129 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2130 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2131 @code{no_instrument_function}, @code{no_split_stack},
2132 @code{section}, @code{constructor},
2133 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2134 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2135 @code{warn_unused_result}, @code{nonnull}, @code{gnu_inline},
2136 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2137 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2138 @code{error} and @code{warning}.
2139 Several other attributes are defined for functions on particular
2140 target systems. Other attributes, including @code{section} are
2141 supported for variables declarations (@pxref{Variable Attributes})
2142 and for types (@pxref{Type Attributes}).
2143
2144 GCC plugins may provide their own attributes.
2145
2146 You may also specify attributes with @samp{__} preceding and following
2147 each keyword. This allows you to use them in header files without
2148 being concerned about a possible macro of the same name. For example,
2149 you may use @code{__noreturn__} instead of @code{noreturn}.
2150
2151 @xref{Attribute Syntax}, for details of the exact syntax for using
2152 attributes.
2153
2154 @table @code
2155 @c Keep this table alphabetized by attribute name. Treat _ as space.
2156
2157 @item alias ("@var{target}")
2158 @cindex @code{alias} attribute
2159 The @code{alias} attribute causes the declaration to be emitted as an
2160 alias for another symbol, which must be specified. For instance,
2161
2162 @smallexample
2163 void __f () @{ /* @r{Do something.} */; @}
2164 void f () __attribute__ ((weak, alias ("__f")));
2165 @end smallexample
2166
2167 @noindent
2168 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2169 mangled name for the target must be used. It is an error if @samp{__f}
2170 is not defined in the same translation unit.
2171
2172 Not all target machines support this attribute.
2173
2174 @item aligned (@var{alignment})
2175 @cindex @code{aligned} attribute
2176 This attribute specifies a minimum alignment for the function,
2177 measured in bytes.
2178
2179 You cannot use this attribute to decrease the alignment of a function,
2180 only to increase it. However, when you explicitly specify a function
2181 alignment this overrides the effect of the
2182 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2183 function.
2184
2185 Note that the effectiveness of @code{aligned} attributes may be
2186 limited by inherent limitations in your linker. On many systems, the
2187 linker is only able to arrange for functions to be aligned up to a
2188 certain maximum alignment. (For some linkers, the maximum supported
2189 alignment may be very very small.) See your linker documentation for
2190 further information.
2191
2192 The @code{aligned} attribute can also be used for variables and fields
2193 (@pxref{Variable Attributes}.)
2194
2195 @item alloc_size
2196 @cindex @code{alloc_size} attribute
2197 The @code{alloc_size} attribute is used to tell the compiler that the
2198 function return value points to memory, where the size is given by
2199 one or two of the functions parameters. GCC uses this
2200 information to improve the correctness of @code{__builtin_object_size}.
2201
2202 The function parameter(s) denoting the allocated size are specified by
2203 one or two integer arguments supplied to the attribute. The allocated size
2204 is either the value of the single function argument specified or the product
2205 of the two function arguments specified. Argument numbering starts at
2206 one.
2207
2208 For instance,
2209
2210 @smallexample
2211 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2212 void my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2213 @end smallexample
2214
2215 @noindent
2216 declares that @code{my_calloc} returns memory of the size given by
2217 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2218 of the size given by parameter 2.
2219
2220 @item always_inline
2221 @cindex @code{always_inline} function attribute
2222 Generally, functions are not inlined unless optimization is specified.
2223 For functions declared inline, this attribute inlines the function even
2224 if no optimization level is specified.
2225
2226 @item gnu_inline
2227 @cindex @code{gnu_inline} function attribute
2228 This attribute should be used with a function that is also declared
2229 with the @code{inline} keyword. It directs GCC to treat the function
2230 as if it were defined in gnu90 mode even when compiling in C99 or
2231 gnu99 mode.
2232
2233 If the function is declared @code{extern}, then this definition of the
2234 function is used only for inlining. In no case is the function
2235 compiled as a standalone function, not even if you take its address
2236 explicitly. Such an address becomes an external reference, as if you
2237 had only declared the function, and had not defined it. This has
2238 almost the effect of a macro. The way to use this is to put a
2239 function definition in a header file with this attribute, and put
2240 another copy of the function, without @code{extern}, in a library
2241 file. The definition in the header file causes most calls to the
2242 function to be inlined. If any uses of the function remain, they
2243 refer to the single copy in the library. Note that the two
2244 definitions of the functions need not be precisely the same, although
2245 if they do not have the same effect your program may behave oddly.
2246
2247 In C, if the function is neither @code{extern} nor @code{static}, then
2248 the function is compiled as a standalone function, as well as being
2249 inlined where possible.
2250
2251 This is how GCC traditionally handled functions declared
2252 @code{inline}. Since ISO C99 specifies a different semantics for
2253 @code{inline}, this function attribute is provided as a transition
2254 measure and as a useful feature in its own right. This attribute is
2255 available in GCC 4.1.3 and later. It is available if either of the
2256 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2257 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2258 Function is As Fast As a Macro}.
2259
2260 In C++, this attribute does not depend on @code{extern} in any way,
2261 but it still requires the @code{inline} keyword to enable its special
2262 behavior.
2263
2264 @item artificial
2265 @cindex @code{artificial} function attribute
2266 This attribute is useful for small inline wrappers that if possible
2267 should appear during debugging as a unit. Depending on the debug
2268 info format it either means marking the function as artificial
2269 or using the caller location for all instructions within the inlined
2270 body.
2271
2272 @item bank_switch
2273 @cindex interrupt handler functions
2274 When added to an interrupt handler with the M32C port, causes the
2275 prologue and epilogue to use bank switching to preserve the registers
2276 rather than saving them on the stack.
2277
2278 @item flatten
2279 @cindex @code{flatten} function attribute
2280 Generally, inlining into a function is limited. For a function marked with
2281 this attribute, every call inside this function is inlined, if possible.
2282 Whether the function itself is considered for inlining depends on its size and
2283 the current inlining parameters.
2284
2285 @item error ("@var{message}")
2286 @cindex @code{error} function attribute
2287 If this attribute is used on a function declaration and a call to such a function
2288 is not eliminated through dead code elimination or other optimizations, an error
2289 that includes @var{message} is diagnosed. This is useful
2290 for compile-time checking, especially together with @code{__builtin_constant_p}
2291 and inline functions where checking the inline function arguments is not
2292 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2293 While it is possible to leave the function undefined and thus invoke
2294 a link failure, when using this attribute the problem is diagnosed
2295 earlier and with exact location of the call even in presence of inline
2296 functions or when not emitting debugging information.
2297
2298 @item warning ("@var{message}")
2299 @cindex @code{warning} function attribute
2300 If this attribute is used on a function declaration and a call to such a function
2301 is not eliminated through dead code elimination or other optimizations, a warning
2302 that includes @var{message} is diagnosed. This is useful
2303 for compile-time checking, especially together with @code{__builtin_constant_p}
2304 and inline functions. While it is possible to define the function with
2305 a message in @code{.gnu.warning*} section, when using this attribute the problem
2306 is diagnosed earlier and with exact location of the call even in presence
2307 of inline functions or when not emitting debugging information.
2308
2309 @item cdecl
2310 @cindex functions that do pop the argument stack on the 386
2311 @opindex mrtd
2312 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2313 assume that the calling function pops off the stack space used to
2314 pass arguments. This is
2315 useful to override the effects of the @option{-mrtd} switch.
2316
2317 @item const
2318 @cindex @code{const} function attribute
2319 Many functions do not examine any values except their arguments, and
2320 have no effects except the return value. Basically this is just slightly
2321 more strict class than the @code{pure} attribute below, since function is not
2322 allowed to read global memory.
2323
2324 @cindex pointer arguments
2325 Note that a function that has pointer arguments and examines the data
2326 pointed to must @emph{not} be declared @code{const}. Likewise, a
2327 function that calls a non-@code{const} function usually must not be
2328 @code{const}. It does not make sense for a @code{const} function to
2329 return @code{void}.
2330
2331 The attribute @code{const} is not implemented in GCC versions earlier
2332 than 2.5. An alternative way to declare that a function has no side
2333 effects, which works in the current version and in some older versions,
2334 is as follows:
2335
2336 @smallexample
2337 typedef int intfn ();
2338
2339 extern const intfn square;
2340 @end smallexample
2341
2342 @noindent
2343 This approach does not work in GNU C++ from 2.6.0 on, since the language
2344 specifies that the @samp{const} must be attached to the return value.
2345
2346 @item constructor
2347 @itemx destructor
2348 @itemx constructor (@var{priority})
2349 @itemx destructor (@var{priority})
2350 @cindex @code{constructor} function attribute
2351 @cindex @code{destructor} function attribute
2352 The @code{constructor} attribute causes the function to be called
2353 automatically before execution enters @code{main ()}. Similarly, the
2354 @code{destructor} attribute causes the function to be called
2355 automatically after @code{main ()} completes or @code{exit ()} is
2356 called. Functions with these attributes are useful for
2357 initializing data that is used implicitly during the execution of
2358 the program.
2359
2360 You may provide an optional integer priority to control the order in
2361 which constructor and destructor functions are run. A constructor
2362 with a smaller priority number runs before a constructor with a larger
2363 priority number; the opposite relationship holds for destructors. So,
2364 if you have a constructor that allocates a resource and a destructor
2365 that deallocates the same resource, both functions typically have the
2366 same priority. The priorities for constructor and destructor
2367 functions are the same as those specified for namespace-scope C++
2368 objects (@pxref{C++ Attributes}).
2369
2370 These attributes are not currently implemented for Objective-C@.
2371
2372 @item deprecated
2373 @itemx deprecated (@var{msg})
2374 @cindex @code{deprecated} attribute.
2375 The @code{deprecated} attribute results in a warning if the function
2376 is used anywhere in the source file. This is useful when identifying
2377 functions that are expected to be removed in a future version of a
2378 program. The warning also includes the location of the declaration
2379 of the deprecated function, to enable users to easily find further
2380 information about why the function is deprecated, or what they should
2381 do instead. Note that the warnings only occurs for uses:
2382
2383 @smallexample
2384 int old_fn () __attribute__ ((deprecated));
2385 int old_fn ();
2386 int (*fn_ptr)() = old_fn;
2387 @end smallexample
2388
2389 @noindent
2390 results in a warning on line 3 but not line 2. The optional @var{msg}
2391 argument, which must be a string, is printed in the warning if
2392 present.
2393
2394 The @code{deprecated} attribute can also be used for variables and
2395 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2396
2397 @item disinterrupt
2398 @cindex @code{disinterrupt} attribute
2399 On Epiphany and MeP targets, this attribute causes the compiler to emit
2400 instructions to disable interrupts for the duration of the given
2401 function.
2402
2403 @item dllexport
2404 @cindex @code{__declspec(dllexport)}
2405 On Microsoft Windows targets and Symbian OS targets the
2406 @code{dllexport} attribute causes the compiler to provide a global
2407 pointer to a pointer in a DLL, so that it can be referenced with the
2408 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
2409 name is formed by combining @code{_imp__} and the function or variable
2410 name.
2411
2412 You can use @code{__declspec(dllexport)} as a synonym for
2413 @code{__attribute__ ((dllexport))} for compatibility with other
2414 compilers.
2415
2416 On systems that support the @code{visibility} attribute, this
2417 attribute also implies ``default'' visibility. It is an error to
2418 explicitly specify any other visibility.
2419
2420 In previous versions of GCC, the @code{dllexport} attribute was ignored
2421 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2422 had been used. The default behavior now is to emit all dllexported
2423 inline functions; however, this can cause object file-size bloat, in
2424 which case the old behavior can be restored by using
2425 @option{-fno-keep-inline-dllexport}.
2426
2427 The attribute is also ignored for undefined symbols.
2428
2429 When applied to C++ classes, the attribute marks defined non-inlined
2430 member functions and static data members as exports. Static consts
2431 initialized in-class are not marked unless they are also defined
2432 out-of-class.
2433
2434 For Microsoft Windows targets there are alternative methods for
2435 including the symbol in the DLL's export table such as using a
2436 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2437 the @option{--export-all} linker flag.
2438
2439 @item dllimport
2440 @cindex @code{__declspec(dllimport)}
2441 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2442 attribute causes the compiler to reference a function or variable via
2443 a global pointer to a pointer that is set up by the DLL exporting the
2444 symbol. The attribute implies @code{extern}. On Microsoft Windows
2445 targets, the pointer name is formed by combining @code{_imp__} and the
2446 function or variable name.
2447
2448 You can use @code{__declspec(dllimport)} as a synonym for
2449 @code{__attribute__ ((dllimport))} for compatibility with other
2450 compilers.
2451
2452 On systems that support the @code{visibility} attribute, this
2453 attribute also implies ``default'' visibility. It is an error to
2454 explicitly specify any other visibility.
2455
2456 Currently, the attribute is ignored for inlined functions. If the
2457 attribute is applied to a symbol @emph{definition}, an error is reported.
2458 If a symbol previously declared @code{dllimport} is later defined, the
2459 attribute is ignored in subsequent references, and a warning is emitted.
2460 The attribute is also overridden by a subsequent declaration as
2461 @code{dllexport}.
2462
2463 When applied to C++ classes, the attribute marks non-inlined
2464 member functions and static data members as imports. However, the
2465 attribute is ignored for virtual methods to allow creation of vtables
2466 using thunks.
2467
2468 On the SH Symbian OS target the @code{dllimport} attribute also has
2469 another affect---it can cause the vtable and run-time type information
2470 for a class to be exported. This happens when the class has a
2471 dllimported constructor or a non-inline, non-pure virtual function
2472 and, for either of those two conditions, the class also has an inline
2473 constructor or destructor and has a key function that is defined in
2474 the current translation unit.
2475
2476 For Microsoft Windows targets the use of the @code{dllimport}
2477 attribute on functions is not necessary, but provides a small
2478 performance benefit by eliminating a thunk in the DLL@. The use of the
2479 @code{dllimport} attribute on imported variables was required on older
2480 versions of the GNU linker, but can now be avoided by passing the
2481 @option{--enable-auto-import} switch to the GNU linker. As with
2482 functions, using the attribute for a variable eliminates a thunk in
2483 the DLL@.
2484
2485 One drawback to using this attribute is that a pointer to a
2486 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2487 address. However, a pointer to a @emph{function} with the
2488 @code{dllimport} attribute can be used as a constant initializer; in
2489 this case, the address of a stub function in the import lib is
2490 referenced. On Microsoft Windows targets, the attribute can be disabled
2491 for functions by setting the @option{-mnop-fun-dllimport} flag.
2492
2493 @item eightbit_data
2494 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2495 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2496 variable should be placed into the eight-bit data section.
2497 The compiler generates more efficient code for certain operations
2498 on data in the eight-bit data area. Note the eight-bit data area is limited to
2499 256 bytes of data.
2500
2501 You must use GAS and GLD from GNU binutils version 2.7 or later for
2502 this attribute to work correctly.
2503
2504 @item exception_handler
2505 @cindex exception handler functions on the Blackfin processor
2506 Use this attribute on the Blackfin to indicate that the specified function
2507 is an exception handler. The compiler generates function entry and
2508 exit sequences suitable for use in an exception handler when this
2509 attribute is present.
2510
2511 @item externally_visible
2512 @cindex @code{externally_visible} attribute.
2513 This attribute, attached to a global variable or function, nullifies
2514 the effect of the @option{-fwhole-program} command-line option, so the
2515 object remains visible outside the current compilation unit.
2516
2517 If @option{-fwhole-program} is used together with @option{-flto} and
2518 @command{gold} is used as the linker plugin,
2519 @code{externally_visible} attributes are automatically added to functions
2520 (not variable yet due to a current @command{gold} issue)
2521 that are accessed outside of LTO objects according to resolution file
2522 produced by @command{gold}.
2523 For other linkers that cannot generate resolution file,
2524 explicit @code{externally_visible} attributes are still necessary.
2525
2526 @item far
2527 @cindex functions that handle memory bank switching
2528 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2529 use a calling convention that takes care of switching memory banks when
2530 entering and leaving a function. This calling convention is also the
2531 default when using the @option{-mlong-calls} option.
2532
2533 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2534 to call and return from a function.
2535
2536 On 68HC11 the compiler generates a sequence of instructions
2537 to invoke a board-specific routine to switch the memory bank and call the
2538 real function. The board-specific routine simulates a @code{call}.
2539 At the end of a function, it jumps to a board-specific routine
2540 instead of using @code{rts}. The board-specific return routine simulates
2541 the @code{rtc}.
2542
2543 On MeP targets this causes the compiler to use a calling convention
2544 that assumes the called function is too far away for the built-in
2545 addressing modes.
2546
2547 @item fast_interrupt
2548 @cindex interrupt handler functions
2549 Use this attribute on the M32C and RX ports to indicate that the specified
2550 function is a fast interrupt handler. This is just like the
2551 @code{interrupt} attribute, except that @code{freit} is used to return
2552 instead of @code{reit}.
2553
2554 @item fastcall
2555 @cindex functions that pop the argument stack on the 386
2556 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2557 pass the first argument (if of integral type) in the register ECX and
2558 the second argument (if of integral type) in the register EDX@. Subsequent
2559 and other typed arguments are passed on the stack. The called function
2560 pops the arguments off the stack. If the number of arguments is variable all
2561 arguments are pushed on the stack.
2562
2563 @item thiscall
2564 @cindex functions that pop the argument stack on the 386
2565 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2566 pass the first argument (if of integral type) in the register ECX.
2567 Subsequent and other typed arguments are passed on the stack. The called
2568 function pops the arguments off the stack.
2569 If the number of arguments is variable all arguments are pushed on the
2570 stack.
2571 The @code{thiscall} attribute is intended for C++ non-static member functions.
2572 As a GCC extension, this calling convention can be used for C functions
2573 and for static member methods.
2574
2575 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2576 @cindex @code{format} function attribute
2577 @opindex Wformat
2578 The @code{format} attribute specifies that a function takes @code{printf},
2579 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2580 should be type-checked against a format string. For example, the
2581 declaration:
2582
2583 @smallexample
2584 extern int
2585 my_printf (void *my_object, const char *my_format, ...)
2586 __attribute__ ((format (printf, 2, 3)));
2587 @end smallexample
2588
2589 @noindent
2590 causes the compiler to check the arguments in calls to @code{my_printf}
2591 for consistency with the @code{printf} style format string argument
2592 @code{my_format}.
2593
2594 The parameter @var{archetype} determines how the format string is
2595 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2596 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2597 @code{strfmon}. (You can also use @code{__printf__},
2598 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2599 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2600 @code{ms_strftime} are also present.
2601 @var{archetype} values such as @code{printf} refer to the formats accepted
2602 by the system's C runtime library,
2603 while values prefixed with @samp{gnu_} always refer
2604 to the formats accepted by the GNU C Library. On Microsoft Windows
2605 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2606 @file{msvcrt.dll} library.
2607 The parameter @var{string-index}
2608 specifies which argument is the format string argument (starting
2609 from 1), while @var{first-to-check} is the number of the first
2610 argument to check against the format string. For functions
2611 where the arguments are not available to be checked (such as
2612 @code{vprintf}), specify the third parameter as zero. In this case the
2613 compiler only checks the format string for consistency. For
2614 @code{strftime} formats, the third parameter is required to be zero.
2615 Since non-static C++ methods have an implicit @code{this} argument, the
2616 arguments of such methods should be counted from two, not one, when
2617 giving values for @var{string-index} and @var{first-to-check}.
2618
2619 In the example above, the format string (@code{my_format}) is the second
2620 argument of the function @code{my_print}, and the arguments to check
2621 start with the third argument, so the correct parameters for the format
2622 attribute are 2 and 3.
2623
2624 @opindex ffreestanding
2625 @opindex fno-builtin
2626 The @code{format} attribute allows you to identify your own functions
2627 that take format strings as arguments, so that GCC can check the
2628 calls to these functions for errors. The compiler always (unless
2629 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2630 for the standard library functions @code{printf}, @code{fprintf},
2631 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2632 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2633 warnings are requested (using @option{-Wformat}), so there is no need to
2634 modify the header file @file{stdio.h}. In C99 mode, the functions
2635 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2636 @code{vsscanf} are also checked. Except in strictly conforming C
2637 standard modes, the X/Open function @code{strfmon} is also checked as
2638 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2639 @xref{C Dialect Options,,Options Controlling C Dialect}.
2640
2641 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2642 recognized in the same context. Declarations including these format attributes
2643 are parsed for correct syntax, however the result of checking of such format
2644 strings is not yet defined, and is not carried out by this version of the
2645 compiler.
2646
2647 The target may also provide additional types of format checks.
2648 @xref{Target Format Checks,,Format Checks Specific to Particular
2649 Target Machines}.
2650
2651 @item format_arg (@var{string-index})
2652 @cindex @code{format_arg} function attribute
2653 @opindex Wformat-nonliteral
2654 The @code{format_arg} attribute specifies that a function takes a format
2655 string for a @code{printf}, @code{scanf}, @code{strftime} or
2656 @code{strfmon} style function and modifies it (for example, to translate
2657 it into another language), so the result can be passed to a
2658 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2659 function (with the remaining arguments to the format function the same
2660 as they would have been for the unmodified string). For example, the
2661 declaration:
2662
2663 @smallexample
2664 extern char *
2665 my_dgettext (char *my_domain, const char *my_format)
2666 __attribute__ ((format_arg (2)));
2667 @end smallexample
2668
2669 @noindent
2670 causes the compiler to check the arguments in calls to a @code{printf},
2671 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2672 format string argument is a call to the @code{my_dgettext} function, for
2673 consistency with the format string argument @code{my_format}. If the
2674 @code{format_arg} attribute had not been specified, all the compiler
2675 could tell in such calls to format functions would be that the format
2676 string argument is not constant; this would generate a warning when
2677 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2678 without the attribute.
2679
2680 The parameter @var{string-index} specifies which argument is the format
2681 string argument (starting from one). Since non-static C++ methods have
2682 an implicit @code{this} argument, the arguments of such methods should
2683 be counted from two.
2684
2685 The @code{format_arg} attribute allows you to identify your own
2686 functions that modify format strings, so that GCC can check the
2687 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2688 type function whose operands are a call to one of your own function.
2689 The compiler always treats @code{gettext}, @code{dgettext}, and
2690 @code{dcgettext} in this manner except when strict ISO C support is
2691 requested by @option{-ansi} or an appropriate @option{-std} option, or
2692 @option{-ffreestanding} or @option{-fno-builtin}
2693 is used. @xref{C Dialect Options,,Options
2694 Controlling C Dialect}.
2695
2696 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2697 @code{NSString} reference for compatibility with the @code{format} attribute
2698 above.
2699
2700 The target may also allow additional types in @code{format-arg} attributes.
2701 @xref{Target Format Checks,,Format Checks Specific to Particular
2702 Target Machines}.
2703
2704 @item function_vector
2705 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2706 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2707 function should be called through the function vector. Calling a
2708 function through the function vector reduces code size, however;
2709 the function vector has a limited size (maximum 128 entries on the H8/300
2710 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2711
2712 On SH2A targets, this attribute declares a function to be called using the
2713 TBR relative addressing mode. The argument to this attribute is the entry
2714 number of the same function in a vector table containing all the TBR
2715 relative addressable functions. For correct operation the TBR must be setup
2716 accordingly to point to the start of the vector table before any functions with
2717 this attribute are invoked. Usually a good place to do the initialization is
2718 the startup routine. The TBR relative vector table can have at max 256 function
2719 entries. The jumps to these functions are generated using a SH2A specific,
2720 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
2721 from GNU binutils version 2.7 or later for this attribute to work correctly.
2722
2723 Please refer the example of M16C target, to see the use of this
2724 attribute while declaring a function,
2725
2726 In an application, for a function being called once, this attribute
2727 saves at least 8 bytes of code; and if other successive calls are being
2728 made to the same function, it saves 2 bytes of code per each of these
2729 calls.
2730
2731 On M16C/M32C targets, the @code{function_vector} attribute declares a
2732 special page subroutine call function. Use of this attribute reduces
2733 the code size by 2 bytes for each call generated to the
2734 subroutine. The argument to the attribute is the vector number entry
2735 from the special page vector table which contains the 16 low-order
2736 bits of the subroutine's entry address. Each vector table has special
2737 page number (18 to 255) that is used in @code{jsrs} instructions.
2738 Jump addresses of the routines are generated by adding 0x0F0000 (in
2739 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2740 2-byte addresses set in the vector table. Therefore you need to ensure
2741 that all the special page vector routines should get mapped within the
2742 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2743 (for M32C).
2744
2745 In the following example 2 bytes are saved for each call to
2746 function @code{foo}.
2747
2748 @smallexample
2749 void foo (void) __attribute__((function_vector(0x18)));
2750 void foo (void)
2751 @{
2752 @}
2753
2754 void bar (void)
2755 @{
2756 foo();
2757 @}
2758 @end smallexample
2759
2760 If functions are defined in one file and are called in another file,
2761 then be sure to write this declaration in both files.
2762
2763 This attribute is ignored for R8C target.
2764
2765 @item ifunc ("@var{resolver}")
2766 @cindex @code{ifunc} attribute
2767 The @code{ifunc} attribute is used to mark a function as an indirect
2768 function using the STT_GNU_IFUNC symbol type extension to the ELF
2769 standard. This allows the resolution of the symbol value to be
2770 determined dynamically at load time, and an optimized version of the
2771 routine can be selected for the particular processor or other system
2772 characteristics determined then. To use this attribute, first define
2773 the implementation functions available, and a resolver function that
2774 returns a pointer to the selected implementation function. The
2775 implementation functions' declarations must match the API of the
2776 function being implemented, the resolver's declaration is be a
2777 function returning pointer to void function returning void:
2778
2779 @smallexample
2780 void *my_memcpy (void *dst, const void *src, size_t len)
2781 @{
2782 @dots{}
2783 @}
2784
2785 static void (*resolve_memcpy (void)) (void)
2786 @{
2787 return my_memcpy; // we'll just always select this routine
2788 @}
2789 @end smallexample
2790
2791 @noindent
2792 The exported header file declaring the function the user calls would
2793 contain:
2794
2795 @smallexample
2796 extern void *memcpy (void *, const void *, size_t);
2797 @end smallexample
2798
2799 @noindent
2800 allowing the user to call this as a regular function, unaware of the
2801 implementation. Finally, the indirect function needs to be defined in
2802 the same translation unit as the resolver function:
2803
2804 @smallexample
2805 void *memcpy (void *, const void *, size_t)
2806 __attribute__ ((ifunc ("resolve_memcpy")));
2807 @end smallexample
2808
2809 Indirect functions cannot be weak, and require a recent binutils (at
2810 least version 2.20.1), and GNU C library (at least version 2.11.1).
2811
2812 @item interrupt
2813 @cindex interrupt handler functions
2814 Use this attribute on the ARM, AVR, CR16, Epiphany, M32C, M32R/D, m68k, MeP, MIPS,
2815 RL78, RX and Xstormy16 ports to indicate that the specified function is an
2816 interrupt handler. The compiler generates function entry and exit
2817 sequences suitable for use in an interrupt handler when this attribute
2818 is present. With Epiphany targets it may also generate a special section with
2819 code to initialize the interrupt vector table.
2820
2821 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2822 and SH processors can be specified via the @code{interrupt_handler} attribute.
2823
2824 Note, on the AVR, the hardware globally disables interrupts when an
2825 interrupt is executed. The first instruction of an interrupt handler
2826 declared with this attribute is a @code{SEI} instruction to
2827 re-enable interrupts. See also the @code{signal} function attribute
2828 that does not insert a @code{SEI} instruction. If both @code{signal} and
2829 @code{interrupt} are specified for the same function, @code{signal}
2830 is silently ignored.
2831
2832 Note, for the ARM, you can specify the kind of interrupt to be handled by
2833 adding an optional parameter to the interrupt attribute like this:
2834
2835 @smallexample
2836 void f () __attribute__ ((interrupt ("IRQ")));
2837 @end smallexample
2838
2839 @noindent
2840 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2841 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2842
2843 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2844 may be called with a word-aligned stack pointer.
2845
2846 On Epiphany targets one or more optional parameters can be added like this:
2847
2848 @smallexample
2849 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2850 @end smallexample
2851
2852 Permissible values for these parameters are: @w{@code{reset}},
2853 @w{@code{software_exception}}, @w{@code{page_miss}},
2854 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
2855 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
2856 Multiple parameters indicate that multiple entries in the interrupt
2857 vector table should be initialized for this function, i.e.@: for each
2858 parameter @w{@var{name}}, a jump to the function is emitted in
2859 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
2860 entirely, in which case no interrupt vector table entry is provided.
2861
2862 Note, on Epiphany targets, interrupts are enabled inside the function
2863 unless the @code{disinterrupt} attribute is also specified.
2864
2865 On Epiphany targets, you can also use the following attribute to
2866 modify the behavior of an interrupt handler:
2867 @table @code
2868 @item forwarder_section
2869 @cindex @code{forwarder_section} attribute
2870 The interrupt handler may be in external memory which cannot be
2871 reached by a branch instruction, so generate a local memory trampoline
2872 to transfer control. The single parameter identifies the section where
2873 the trampoline is placed.
2874 @end table
2875
2876 The following examples are all valid uses of these attributes on
2877 Epiphany targets:
2878 @smallexample
2879 void __attribute__ ((interrupt)) universal_handler ();
2880 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
2881 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2882 void __attribute__ ((interrupt ("timer0"), disinterrupt))
2883 fast_timer_handler ();
2884 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
2885 external_dma_handler ();
2886 @end smallexample
2887
2888 On MIPS targets, you can use the following attributes to modify the behavior
2889 of an interrupt handler:
2890 @table @code
2891 @item use_shadow_register_set
2892 @cindex @code{use_shadow_register_set} attribute
2893 Assume that the handler uses a shadow register set, instead of
2894 the main general-purpose registers.
2895
2896 @item keep_interrupts_masked
2897 @cindex @code{keep_interrupts_masked} attribute
2898 Keep interrupts masked for the whole function. Without this attribute,
2899 GCC tries to reenable interrupts for as much of the function as it can.
2900
2901 @item use_debug_exception_return
2902 @cindex @code{use_debug_exception_return} attribute
2903 Return using the @code{deret} instruction. Interrupt handlers that don't
2904 have this attribute return using @code{eret} instead.
2905 @end table
2906
2907 You can use any combination of these attributes, as shown below:
2908 @smallexample
2909 void __attribute__ ((interrupt)) v0 ();
2910 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
2911 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
2912 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
2913 void __attribute__ ((interrupt, use_shadow_register_set,
2914 keep_interrupts_masked)) v4 ();
2915 void __attribute__ ((interrupt, use_shadow_register_set,
2916 use_debug_exception_return)) v5 ();
2917 void __attribute__ ((interrupt, keep_interrupts_masked,
2918 use_debug_exception_return)) v6 ();
2919 void __attribute__ ((interrupt, use_shadow_register_set,
2920 keep_interrupts_masked,
2921 use_debug_exception_return)) v7 ();
2922 @end smallexample
2923
2924 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
2925 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
2926 that must end with @code{RETB} instead of @code{RETI}).
2927
2928 @item interrupt_handler
2929 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
2930 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
2931 indicate that the specified function is an interrupt handler. The compiler
2932 generates function entry and exit sequences suitable for use in an
2933 interrupt handler when this attribute is present.
2934
2935 @item interrupt_thread
2936 @cindex interrupt thread functions on fido
2937 Use this attribute on fido, a subarchitecture of the m68k, to indicate
2938 that the specified function is an interrupt handler that is designed
2939 to run as a thread. The compiler omits generate prologue/epilogue
2940 sequences and replaces the return instruction with a @code{sleep}
2941 instruction. This attribute is available only on fido.
2942
2943 @item isr
2944 @cindex interrupt service routines on ARM
2945 Use this attribute on ARM to write Interrupt Service Routines. This is an
2946 alias to the @code{interrupt} attribute above.
2947
2948 @item kspisusp
2949 @cindex User stack pointer in interrupts on the Blackfin
2950 When used together with @code{interrupt_handler}, @code{exception_handler}
2951 or @code{nmi_handler}, code is generated to load the stack pointer
2952 from the USP register in the function prologue.
2953
2954 @item l1_text
2955 @cindex @code{l1_text} function attribute
2956 This attribute specifies a function to be placed into L1 Instruction
2957 SRAM@. The function is put into a specific section named @code{.l1.text}.
2958 With @option{-mfdpic}, function calls with a such function as the callee
2959 or caller uses inlined PLT.
2960
2961 @item l2
2962 @cindex @code{l2} function attribute
2963 On the Blackfin, this attribute specifies a function to be placed into L2
2964 SRAM. The function is put into a specific section named
2965 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
2966 an inlined PLT.
2967
2968 @item leaf
2969 @cindex @code{leaf} function attribute
2970 Calls to external functions with this attribute must return to the current
2971 compilation unit only by return or by exception handling. In particular, leaf
2972 functions are not allowed to call callback function passed to it from the current
2973 compilation unit or directly call functions exported by the unit or longjmp
2974 into the unit. Leaf function might still call functions from other compilation
2975 units and thus they are not necessarily leaf in the sense that they contain no
2976 function calls at all.
2977
2978 The attribute is intended for library functions to improve dataflow analysis.
2979 The compiler takes the hint that any data not escaping the current compilation unit can
2980 not be used or modified by the leaf function. For example, the @code{sin} function
2981 is a leaf function, but @code{qsort} is not.
2982
2983 Note that leaf functions might invoke signals and signal handlers might be
2984 defined in the current compilation unit and use static variables. The only
2985 compliant way to write such a signal handler is to declare such variables
2986 @code{volatile}.
2987
2988 The attribute has no effect on functions defined within the current compilation
2989 unit. This is to allow easy merging of multiple compilation units into one,
2990 for example, by using the link-time optimization. For this reason the
2991 attribute is not allowed on types to annotate indirect calls.
2992
2993 @item long_call/short_call
2994 @cindex indirect calls on ARM
2995 This attribute specifies how a particular function is called on
2996 ARM and Epiphany. Both attributes override the
2997 @option{-mlong-calls} (@pxref{ARM Options})
2998 command-line switch and @code{#pragma long_calls} settings. The
2999 @code{long_call} attribute indicates that the function might be far
3000 away from the call site and require a different (more expensive)
3001 calling sequence. The @code{short_call} attribute always places
3002 the offset to the function from the call site into the @samp{BL}
3003 instruction directly.
3004
3005 @item longcall/shortcall
3006 @cindex functions called via pointer on the RS/6000 and PowerPC
3007 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3008 indicates that the function might be far away from the call site and
3009 require a different (more expensive) calling sequence. The
3010 @code{shortcall} attribute indicates that the function is always close
3011 enough for the shorter calling sequence to be used. These attributes
3012 override both the @option{-mlongcall} switch and, on the RS/6000 and
3013 PowerPC, the @code{#pragma longcall} setting.
3014
3015 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3016 calls are necessary.
3017
3018 @item long_call/near/far
3019 @cindex indirect calls on MIPS
3020 These attributes specify how a particular function is called on MIPS@.
3021 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3022 command-line switch. The @code{long_call} and @code{far} attributes are
3023 synonyms, and cause the compiler to always call
3024 the function by first loading its address into a register, and then using
3025 the contents of that register. The @code{near} attribute has the opposite
3026 effect; it specifies that non-PIC calls should be made using the more
3027 efficient @code{jal} instruction.
3028
3029 @item malloc
3030 @cindex @code{malloc} attribute
3031 The @code{malloc} attribute is used to tell the compiler that a function
3032 may be treated as if any non-@code{NULL} pointer it returns cannot
3033 alias any other pointer valid when the function returns and that the memory
3034 has undefined content.
3035 This often improves optimization.
3036 Standard functions with this property include @code{malloc} and
3037 @code{calloc}. @code{realloc}-like functions do not have this
3038 property as the memory pointed to does not have undefined content.
3039
3040 @item mips16/nomips16
3041 @cindex @code{mips16} attribute
3042 @cindex @code{nomips16} attribute
3043
3044 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3045 function attributes to locally select or turn off MIPS16 code generation.
3046 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3047 while MIPS16 code generation is disabled for functions with the
3048 @code{nomips16} attribute. These attributes override the
3049 @option{-mips16} and @option{-mno-mips16} options on the command line
3050 (@pxref{MIPS Options}).
3051
3052 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3053 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3054 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
3055 may interact badly with some GCC extensions such as @code{__builtin_apply}
3056 (@pxref{Constructing Calls}).
3057
3058 @item model (@var{model-name})
3059 @cindex function addressability on the M32R/D
3060 @cindex variable addressability on the IA-64
3061
3062 On the M32R/D, use this attribute to set the addressability of an
3063 object, and of the code generated for a function. The identifier
3064 @var{model-name} is one of @code{small}, @code{medium}, or
3065 @code{large}, representing each of the code models.
3066
3067 Small model objects live in the lower 16MB of memory (so that their
3068 addresses can be loaded with the @code{ld24} instruction), and are
3069 callable with the @code{bl} instruction.
3070
3071 Medium model objects may live anywhere in the 32-bit address space (the
3072 compiler generates @code{seth/add3} instructions to load their addresses),
3073 and are callable with the @code{bl} instruction.
3074
3075 Large model objects may live anywhere in the 32-bit address space (the
3076 compiler generates @code{seth/add3} instructions to load their addresses),
3077 and may not be reachable with the @code{bl} instruction (the compiler
3078 generates the much slower @code{seth/add3/jl} instruction sequence).
3079
3080 On IA-64, use this attribute to set the addressability of an object.
3081 At present, the only supported identifier for @var{model-name} is
3082 @code{small}, indicating addressability via ``small'' (22-bit)
3083 addresses (so that their addresses can be loaded with the @code{addl}
3084 instruction). Caveat: such addressing is by definition not position
3085 independent and hence this attribute must not be used for objects
3086 defined by shared libraries.
3087
3088 @item ms_abi/sysv_abi
3089 @cindex @code{ms_abi} attribute
3090 @cindex @code{sysv_abi} attribute
3091
3092 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3093 to indicate which calling convention should be used for a function. The
3094 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3095 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3096 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
3097 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
3098
3099 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3100 requires the @option{-maccumulate-outgoing-args} option.
3101
3102 @item callee_pop_aggregate_return (@var{number})
3103 @cindex @code{callee_pop_aggregate_return} attribute
3104
3105 On 32-bit i?86-*-* targets, you can use this attribute to control how
3106 aggregates are returned in memory. If the caller is responsible for
3107 popping the hidden pointer together with the rest of the arguments, specify
3108 @var{number} equal to zero. If callee is responsible for popping the
3109 hidden pointer, specify @var{number} equal to one.
3110
3111 The default i386 ABI assumes that the callee pops the
3112 stack for hidden pointer. However, on 32-bit i386 Microsoft Windows targets,
3113 the compiler assumes that the
3114 caller pops the stack for hidden pointer.
3115
3116 @item ms_hook_prologue
3117 @cindex @code{ms_hook_prologue} attribute
3118
3119 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3120 this function attribute to make GCC generate the ``hot-patching'' function
3121 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3122 and newer.
3123
3124 @item naked
3125 @cindex function without a prologue/epilogue code
3126 Use this attribute on the ARM, AVR, MCORE, RX and SPU ports to indicate that
3127 the specified function does not need prologue/epilogue sequences generated by
3128 the compiler. It is up to the programmer to provide these sequences. The
3129 only statements that can be safely included in naked functions are
3130 @code{asm} statements that do not have operands. All other statements,
3131 including declarations of local variables, @code{if} statements, and so
3132 forth, should be avoided. Naked functions should be used to implement the
3133 body of an assembly function, while allowing the compiler to construct
3134 the requisite function declaration for the assembler.
3135
3136 @item near
3137 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3138 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3139 use the normal calling convention based on @code{jsr} and @code{rts}.
3140 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3141 option.
3142
3143 On MeP targets this attribute causes the compiler to assume the called
3144 function is close enough to use the normal calling convention,
3145 overriding the @option{-mtf} command-line option.
3146
3147 @item nesting
3148 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3149 Use this attribute together with @code{interrupt_handler},
3150 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3151 entry code should enable nested interrupts or exceptions.
3152
3153 @item nmi_handler
3154 @cindex NMI handler functions on the Blackfin processor
3155 Use this attribute on the Blackfin to indicate that the specified function
3156 is an NMI handler. The compiler generates function entry and
3157 exit sequences suitable for use in an NMI handler when this
3158 attribute is present.
3159
3160 @item no_instrument_function
3161 @cindex @code{no_instrument_function} function attribute
3162 @opindex finstrument-functions
3163 If @option{-finstrument-functions} is given, profiling function calls are
3164 generated at entry and exit of most user-compiled functions.
3165 Functions with this attribute are not so instrumented.
3166
3167 @item no_split_stack
3168 @cindex @code{no_split_stack} function attribute
3169 @opindex fsplit-stack
3170 If @option{-fsplit-stack} is given, functions have a small
3171 prologue which decides whether to split the stack. Functions with the
3172 @code{no_split_stack} attribute do not have that prologue, and thus
3173 may run with only a small amount of stack space available.
3174
3175 @item noinline
3176 @cindex @code{noinline} function attribute
3177 This function attribute prevents a function from being considered for
3178 inlining.
3179 @c Don't enumerate the optimizations by name here; we try to be
3180 @c future-compatible with this mechanism.
3181 If the function does not have side-effects, there are optimizations
3182 other than inlining that cause function calls to be optimized away,
3183 although the function call is live. To keep such calls from being
3184 optimized away, put
3185 @smallexample
3186 asm ("");
3187 @end smallexample
3188
3189 @noindent
3190 (@pxref{Extended Asm}) in the called function, to serve as a special
3191 side-effect.
3192
3193 @item noclone
3194 @cindex @code{noclone} function attribute
3195 This function attribute prevents a function from being considered for
3196 cloning---a mechanism that produces specialized copies of functions
3197 and which is (currently) performed by interprocedural constant
3198 propagation.
3199
3200 @item nonnull (@var{arg-index}, @dots{})
3201 @cindex @code{nonnull} function attribute
3202 The @code{nonnull} attribute specifies that some function parameters should
3203 be non-null pointers. For instance, the declaration:
3204
3205 @smallexample
3206 extern void *
3207 my_memcpy (void *dest, const void *src, size_t len)
3208 __attribute__((nonnull (1, 2)));
3209 @end smallexample
3210
3211 @noindent
3212 causes the compiler to check that, in calls to @code{my_memcpy},
3213 arguments @var{dest} and @var{src} are non-null. If the compiler
3214 determines that a null pointer is passed in an argument slot marked
3215 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3216 is issued. The compiler may also choose to make optimizations based
3217 on the knowledge that certain function arguments will never be null.
3218
3219 If no argument index list is given to the @code{nonnull} attribute,
3220 all pointer arguments are marked as non-null. To illustrate, the
3221 following declaration is equivalent to the previous example:
3222
3223 @smallexample
3224 extern void *
3225 my_memcpy (void *dest, const void *src, size_t len)
3226 __attribute__((nonnull));
3227 @end smallexample
3228
3229 @item noreturn
3230 @cindex @code{noreturn} function attribute
3231 A few standard library functions, such as @code{abort} and @code{exit},
3232 cannot return. GCC knows this automatically. Some programs define
3233 their own functions that never return. You can declare them
3234 @code{noreturn} to tell the compiler this fact. For example,
3235
3236 @smallexample
3237 @group
3238 void fatal () __attribute__ ((noreturn));
3239
3240 void
3241 fatal (/* @r{@dots{}} */)
3242 @{
3243 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3244 exit (1);
3245 @}
3246 @end group
3247 @end smallexample
3248
3249 The @code{noreturn} keyword tells the compiler to assume that
3250 @code{fatal} cannot return. It can then optimize without regard to what
3251 would happen if @code{fatal} ever did return. This makes slightly
3252 better code. More importantly, it helps avoid spurious warnings of
3253 uninitialized variables.
3254
3255 The @code{noreturn} keyword does not affect the exceptional path when that
3256 applies: a @code{noreturn}-marked function may still return to the caller
3257 by throwing an exception or calling @code{longjmp}.
3258
3259 Do not assume that registers saved by the calling function are
3260 restored before calling the @code{noreturn} function.
3261
3262 It does not make sense for a @code{noreturn} function to have a return
3263 type other than @code{void}.
3264
3265 The attribute @code{noreturn} is not implemented in GCC versions
3266 earlier than 2.5. An alternative way to declare that a function does
3267 not return, which works in the current version and in some older
3268 versions, is as follows:
3269
3270 @smallexample
3271 typedef void voidfn ();
3272
3273 volatile voidfn fatal;
3274 @end smallexample
3275
3276 @noindent
3277 This approach does not work in GNU C++.
3278
3279 @item nothrow
3280 @cindex @code{nothrow} function attribute
3281 The @code{nothrow} attribute is used to inform the compiler that a
3282 function cannot throw an exception. For example, most functions in
3283 the standard C library can be guaranteed not to throw an exception
3284 with the notable exceptions of @code{qsort} and @code{bsearch} that
3285 take function pointer arguments. The @code{nothrow} attribute is not
3286 implemented in GCC versions earlier than 3.3.
3287
3288 @item nosave_low_regs
3289 @cindex @code{nosave_low_regs} attribute
3290 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3291 function should not save and restore registers R0..R7. This can be used on SH3*
3292 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3293 interrupt handlers.
3294
3295 @item optimize
3296 @cindex @code{optimize} function attribute
3297 The @code{optimize} attribute is used to specify that a function is to
3298 be compiled with different optimization options than specified on the
3299 command line. Arguments can either be numbers or strings. Numbers
3300 are assumed to be an optimization level. Strings that begin with
3301 @code{O} are assumed to be an optimization option, while other options
3302 are assumed to be used with a @code{-f} prefix. You can also use the
3303 @samp{#pragma GCC optimize} pragma to set the optimization options
3304 that affect more than one function.
3305 @xref{Function Specific Option Pragmas}, for details about the
3306 @samp{#pragma GCC optimize} pragma.
3307
3308 This can be used for instance to have frequently-executed functions
3309 compiled with more aggressive optimization options that produce faster
3310 and larger code, while other functions can be compiled with less
3311 aggressive options.
3312
3313 @item OS_main/OS_task
3314 @cindex @code{OS_main} AVR function attribute
3315 @cindex @code{OS_task} AVR function attribute
3316 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3317 do not save/restore any call-saved register in their prologue/epilogue.
3318
3319 The @code{OS_main} attribute can be used when there @emph{is
3320 guarantee} that interrupts are disabled at the time when the function
3321 is entered. This saves resources when the stack pointer has to be
3322 changed to set up a frame for local variables.
3323
3324 The @code{OS_task} attribute can be used when there is @emph{no
3325 guarantee} that interrupts are disabled at that time when the function
3326 is entered like for, e@.g@. task functions in a multi-threading operating
3327 system. In that case, changing the stack pointer register is
3328 guarded by save/clear/restore of the global interrupt enable flag.
3329
3330 The differences to the @code{naked} function attribute are:
3331 @itemize @bullet
3332 @item @code{naked} functions do not have a return instruction whereas
3333 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3334 @code{RETI} return instruction.
3335 @item @code{naked} functions do not set up a frame for local variables
3336 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3337 as needed.
3338 @end itemize
3339
3340 @item pcs
3341 @cindex @code{pcs} function attribute
3342
3343 The @code{pcs} attribute can be used to control the calling convention
3344 used for a function on ARM. The attribute takes an argument that specifies
3345 the calling convention to use.
3346
3347 When compiling using the AAPCS ABI (or a variant of it) then valid
3348 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3349 order to use a variant other than @code{"aapcs"} then the compiler must
3350 be permitted to use the appropriate co-processor registers (i.e., the
3351 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3352 For example,
3353
3354 @smallexample
3355 /* Argument passed in r0, and result returned in r0+r1. */
3356 double f2d (float) __attribute__((pcs("aapcs")));
3357 @end smallexample
3358
3359 Variadic functions always use the @code{"aapcs"} calling convention and
3360 the compiler rejects attempts to specify an alternative.
3361
3362 @item pure
3363 @cindex @code{pure} function attribute
3364 Many functions have no effects except the return value and their
3365 return value depends only on the parameters and/or global variables.
3366 Such a function can be subject
3367 to common subexpression elimination and loop optimization just as an
3368 arithmetic operator would be. These functions should be declared
3369 with the attribute @code{pure}. For example,
3370
3371 @smallexample
3372 int square (int) __attribute__ ((pure));
3373 @end smallexample
3374
3375 @noindent
3376 says that the hypothetical function @code{square} is safe to call
3377 fewer times than the program says.
3378
3379 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3380 Interesting non-pure functions are functions with infinite loops or those
3381 depending on volatile memory or other system resource, that may change between
3382 two consecutive calls (such as @code{feof} in a multithreading environment).
3383
3384 The attribute @code{pure} is not implemented in GCC versions earlier
3385 than 2.96.
3386
3387 @item hot
3388 @cindex @code{hot} function attribute
3389 The @code{hot} attribute on a function is used to inform the compiler that
3390 the function is a hot spot of the compiled program. The function is
3391 optimized more aggressively and on many target it is placed into special
3392 subsection of the text section so all hot functions appears close together
3393 improving locality.
3394
3395 When profile feedback is available, via @option{-fprofile-use}, hot functions
3396 are automatically detected and this attribute is ignored.
3397
3398 The @code{hot} attribute on functions is not implemented in GCC versions
3399 earlier than 4.3.
3400
3401 @cindex @code{hot} label attribute
3402 The @code{hot} attribute on a label is used to inform the compiler that
3403 path following the label are more likely than paths that are not so
3404 annotated. This attribute is used in cases where @code{__builtin_expect}
3405 cannot be used, for instance with computed goto or @code{asm goto}.
3406
3407 The @code{hot} attribute on labels is not implemented in GCC versions
3408 earlier than 4.8.
3409
3410 @item cold
3411 @cindex @code{cold} function attribute
3412 The @code{cold} attribute on functions is used to inform the compiler that
3413 the function is unlikely to be executed. The function is optimized for
3414 size rather than speed and on many targets it is placed into special
3415 subsection of the text section so all cold functions appears close together
3416 improving code locality of non-cold parts of program. The paths leading
3417 to call of cold functions within code are marked as unlikely by the branch
3418 prediction mechanism. It is thus useful to mark functions used to handle
3419 unlikely conditions, such as @code{perror}, as cold to improve optimization
3420 of hot functions that do call marked functions in rare occasions.
3421
3422 When profile feedback is available, via @option{-fprofile-use}, cold functions
3423 are automatically detected and this attribute is ignored.
3424
3425 The @code{cold} attribute on functions is not implemented in GCC versions
3426 earlier than 4.3.
3427
3428 @cindex @code{cold} label attribute
3429 The @code{cold} attribute on labels is used to inform the compiler that
3430 the path following the label is unlikely to be executed. This attribute
3431 is used in cases where @code{__builtin_expect} cannot be used, for instance
3432 with computed goto or @code{asm goto}.
3433
3434 The @code{cold} attribute on labels is not implemented in GCC versions
3435 earlier than 4.8.
3436
3437 @item no_sanitize_address
3438 @itemx no_address_safety_analysis
3439 @cindex @code{no_sanitize_address} function attribute
3440 The @code{no_sanitize_address} attribute on functions is used
3441 to inform the compiler that it should not instrument memory accesses
3442 in the function when compiling with the @option{-fsanitize=address} option.
3443 The @code{no_address_safety_analysis} is a deprecated alias of the
3444 @code{no_sanitize_address} attribute, new code should use
3445 @code{no_sanitize_address}.
3446
3447 @item regparm (@var{number})
3448 @cindex @code{regparm} attribute
3449 @cindex functions that are passed arguments in registers on the 386
3450 On the Intel 386, the @code{regparm} attribute causes the compiler to
3451 pass arguments number one to @var{number} if they are of integral type
3452 in registers EAX, EDX, and ECX instead of on the stack. Functions that
3453 take a variable number of arguments continue to be passed all of their
3454 arguments on the stack.
3455
3456 Beware that on some ELF systems this attribute is unsuitable for
3457 global functions in shared libraries with lazy binding (which is the
3458 default). Lazy binding sends the first call via resolving code in
3459 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3460 per the standard calling conventions. Solaris 8 is affected by this.
3461 Systems with the GNU C Library version 2.1 or higher
3462 and FreeBSD are believed to be
3463 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
3464 disabled with the linker or the loader if desired, to avoid the
3465 problem.)
3466
3467 @item sseregparm
3468 @cindex @code{sseregparm} attribute
3469 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3470 causes the compiler to pass up to 3 floating-point arguments in
3471 SSE registers instead of on the stack. Functions that take a
3472 variable number of arguments continue to pass all of their
3473 floating-point arguments on the stack.
3474
3475 @item force_align_arg_pointer
3476 @cindex @code{force_align_arg_pointer} attribute
3477 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3478 applied to individual function definitions, generating an alternate
3479 prologue and epilogue that realigns the run-time stack if necessary.
3480 This supports mixing legacy codes that run with a 4-byte aligned stack
3481 with modern codes that keep a 16-byte stack for SSE compatibility.
3482
3483 @item renesas
3484 @cindex @code{renesas} attribute
3485 On SH targets this attribute specifies that the function or struct follows the
3486 Renesas ABI.
3487
3488 @item resbank
3489 @cindex @code{resbank} attribute
3490 On the SH2A target, this attribute enables the high-speed register
3491 saving and restoration using a register bank for @code{interrupt_handler}
3492 routines. Saving to the bank is performed automatically after the CPU
3493 accepts an interrupt that uses a register bank.
3494
3495 The nineteen 32-bit registers comprising general register R0 to R14,
3496 control register GBR, and system registers MACH, MACL, and PR and the
3497 vector table address offset are saved into a register bank. Register
3498 banks are stacked in first-in last-out (FILO) sequence. Restoration
3499 from the bank is executed by issuing a RESBANK instruction.
3500
3501 @item returns_twice
3502 @cindex @code{returns_twice} attribute
3503 The @code{returns_twice} attribute tells the compiler that a function may
3504 return more than one time. The compiler ensures that all registers
3505 are dead before calling such a function and emits a warning about
3506 the variables that may be clobbered after the second return from the
3507 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3508 The @code{longjmp}-like counterpart of such function, if any, might need
3509 to be marked with the @code{noreturn} attribute.
3510
3511 @item saveall
3512 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3513 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3514 all registers except the stack pointer should be saved in the prologue
3515 regardless of whether they are used or not.
3516
3517 @item save_volatiles
3518 @cindex save volatile registers on the MicroBlaze
3519 Use this attribute on the MicroBlaze to indicate that the function is
3520 an interrupt handler. All volatile registers (in addition to non-volatile
3521 registers) are saved in the function prologue. If the function is a leaf
3522 function, only volatiles used by the function are saved. A normal function
3523 return is generated instead of a return from interrupt.
3524
3525 @item section ("@var{section-name}")
3526 @cindex @code{section} function attribute
3527 Normally, the compiler places the code it generates in the @code{text} section.
3528 Sometimes, however, you need additional sections, or you need certain
3529 particular functions to appear in special sections. The @code{section}
3530 attribute specifies that a function lives in a particular section.
3531 For example, the declaration:
3532
3533 @smallexample
3534 extern void foobar (void) __attribute__ ((section ("bar")));
3535 @end smallexample
3536
3537 @noindent
3538 puts the function @code{foobar} in the @code{bar} section.
3539
3540 Some file formats do not support arbitrary sections so the @code{section}
3541 attribute is not available on all platforms.
3542 If you need to map the entire contents of a module to a particular
3543 section, consider using the facilities of the linker instead.
3544
3545 @item sentinel
3546 @cindex @code{sentinel} function attribute
3547 This function attribute ensures that a parameter in a function call is
3548 an explicit @code{NULL}. The attribute is only valid on variadic
3549 functions. By default, the sentinel is located at position zero, the
3550 last parameter of the function call. If an optional integer position
3551 argument P is supplied to the attribute, the sentinel must be located at
3552 position P counting backwards from the end of the argument list.
3553
3554 @smallexample
3555 __attribute__ ((sentinel))
3556 is equivalent to
3557 __attribute__ ((sentinel(0)))
3558 @end smallexample
3559
3560 The attribute is automatically set with a position of 0 for the built-in
3561 functions @code{execl} and @code{execlp}. The built-in function
3562 @code{execle} has the attribute set with a position of 1.
3563
3564 A valid @code{NULL} in this context is defined as zero with any pointer
3565 type. If your system defines the @code{NULL} macro with an integer type
3566 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3567 with a copy that redefines NULL appropriately.
3568
3569 The warnings for missing or incorrect sentinels are enabled with
3570 @option{-Wformat}.
3571
3572 @item short_call
3573 See @code{long_call/short_call}.
3574
3575 @item shortcall
3576 See @code{longcall/shortcall}.
3577
3578 @item signal
3579 @cindex interrupt handler functions on the AVR processors
3580 Use this attribute on the AVR to indicate that the specified
3581 function is an interrupt handler. The compiler generates function
3582 entry and exit sequences suitable for use in an interrupt handler when this
3583 attribute is present.
3584
3585 See also the @code{interrupt} function attribute.
3586
3587 The AVR hardware globally disables interrupts when an interrupt is executed.
3588 Interrupt handler functions defined with the @code{signal} attribute
3589 do not re-enable interrupts. It is save to enable interrupts in a
3590 @code{signal} handler. This ``save'' only applies to the code
3591 generated by the compiler and not to the IRQ layout of the
3592 application which is responsibility of the application.
3593
3594 If both @code{signal} and @code{interrupt} are specified for the same
3595 function, @code{signal} is silently ignored.
3596
3597 @item sp_switch
3598 @cindex @code{sp_switch} attribute
3599 Use this attribute on the SH to indicate an @code{interrupt_handler}
3600 function should switch to an alternate stack. It expects a string
3601 argument that names a global variable holding the address of the
3602 alternate stack.
3603
3604 @smallexample
3605 void *alt_stack;
3606 void f () __attribute__ ((interrupt_handler,
3607 sp_switch ("alt_stack")));
3608 @end smallexample
3609
3610 @item stdcall
3611 @cindex functions that pop the argument stack on the 386
3612 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3613 assume that the called function pops off the stack space used to
3614 pass arguments, unless it takes a variable number of arguments.
3615
3616 @item syscall_linkage
3617 @cindex @code{syscall_linkage} attribute
3618 This attribute is used to modify the IA-64 calling convention by marking
3619 all input registers as live at all function exits. This makes it possible
3620 to restart a system call after an interrupt without having to save/restore
3621 the input registers. This also prevents kernel data from leaking into
3622 application code.
3623
3624 @item target
3625 @cindex @code{target} function attribute
3626 The @code{target} attribute is used to specify that a function is to
3627 be compiled with different target options than specified on the
3628 command line. This can be used for instance to have functions
3629 compiled with a different ISA (instruction set architecture) than the
3630 default. You can also use the @samp{#pragma GCC target} pragma to set
3631 more than one function to be compiled with specific target options.
3632 @xref{Function Specific Option Pragmas}, for details about the
3633 @samp{#pragma GCC target} pragma.
3634
3635 For instance on a 386, you could compile one function with
3636 @code{target("sse4.1,arch=core2")} and another with
3637 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3638 compiling the first function with @option{-msse4.1} and
3639 @option{-march=core2} options, and the second function with
3640 @option{-msse4a} and @option{-march=amdfam10} options. It is up to the
3641 user to make sure that a function is only invoked on a machine that
3642 supports the particular ISA it is compiled for (for example by using
3643 @code{cpuid} on 386 to determine what feature bits and architecture
3644 family are used).
3645
3646 @smallexample
3647 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3648 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3649 @end smallexample
3650
3651 On the 386, the following options are allowed:
3652
3653 @table @samp
3654 @item abm
3655 @itemx no-abm
3656 @cindex @code{target("abm")} attribute
3657 Enable/disable the generation of the advanced bit instructions.
3658
3659 @item aes
3660 @itemx no-aes
3661 @cindex @code{target("aes")} attribute
3662 Enable/disable the generation of the AES instructions.
3663
3664 @item default
3665 @cindex @code{target("default")} attribute
3666 @xref{Function Multiversioning}, where it is used to specify the
3667 default function version.
3668
3669 @item mmx
3670 @itemx no-mmx
3671 @cindex @code{target("mmx")} attribute
3672 Enable/disable the generation of the MMX instructions.
3673
3674 @item pclmul
3675 @itemx no-pclmul
3676 @cindex @code{target("pclmul")} attribute
3677 Enable/disable the generation of the PCLMUL instructions.
3678
3679 @item popcnt
3680 @itemx no-popcnt
3681 @cindex @code{target("popcnt")} attribute
3682 Enable/disable the generation of the POPCNT instruction.
3683
3684 @item sse
3685 @itemx no-sse
3686 @cindex @code{target("sse")} attribute
3687 Enable/disable the generation of the SSE instructions.
3688
3689 @item sse2
3690 @itemx no-sse2
3691 @cindex @code{target("sse2")} attribute
3692 Enable/disable the generation of the SSE2 instructions.
3693
3694 @item sse3
3695 @itemx no-sse3
3696 @cindex @code{target("sse3")} attribute
3697 Enable/disable the generation of the SSE3 instructions.
3698
3699 @item sse4
3700 @itemx no-sse4
3701 @cindex @code{target("sse4")} attribute
3702 Enable/disable the generation of the SSE4 instructions (both SSE4.1
3703 and SSE4.2).
3704
3705 @item sse4.1
3706 @itemx no-sse4.1
3707 @cindex @code{target("sse4.1")} attribute
3708 Enable/disable the generation of the sse4.1 instructions.
3709
3710 @item sse4.2
3711 @itemx no-sse4.2
3712 @cindex @code{target("sse4.2")} attribute
3713 Enable/disable the generation of the sse4.2 instructions.
3714
3715 @item sse4a
3716 @itemx no-sse4a
3717 @cindex @code{target("sse4a")} attribute
3718 Enable/disable the generation of the SSE4A instructions.
3719
3720 @item fma4
3721 @itemx no-fma4
3722 @cindex @code{target("fma4")} attribute
3723 Enable/disable the generation of the FMA4 instructions.
3724
3725 @item xop
3726 @itemx no-xop
3727 @cindex @code{target("xop")} attribute
3728 Enable/disable the generation of the XOP instructions.
3729
3730 @item lwp
3731 @itemx no-lwp
3732 @cindex @code{target("lwp")} attribute
3733 Enable/disable the generation of the LWP instructions.
3734
3735 @item ssse3
3736 @itemx no-ssse3
3737 @cindex @code{target("ssse3")} attribute
3738 Enable/disable the generation of the SSSE3 instructions.
3739
3740 @item cld
3741 @itemx no-cld
3742 @cindex @code{target("cld")} attribute
3743 Enable/disable the generation of the CLD before string moves.
3744
3745 @item fancy-math-387
3746 @itemx no-fancy-math-387
3747 @cindex @code{target("fancy-math-387")} attribute
3748 Enable/disable the generation of the @code{sin}, @code{cos}, and
3749 @code{sqrt} instructions on the 387 floating-point unit.
3750
3751 @item fused-madd
3752 @itemx no-fused-madd
3753 @cindex @code{target("fused-madd")} attribute
3754 Enable/disable the generation of the fused multiply/add instructions.
3755
3756 @item ieee-fp
3757 @itemx no-ieee-fp
3758 @cindex @code{target("ieee-fp")} attribute
3759 Enable/disable the generation of floating point that depends on IEEE arithmetic.
3760
3761 @item inline-all-stringops
3762 @itemx no-inline-all-stringops
3763 @cindex @code{target("inline-all-stringops")} attribute
3764 Enable/disable inlining of string operations.
3765
3766 @item inline-stringops-dynamically
3767 @itemx no-inline-stringops-dynamically
3768 @cindex @code{target("inline-stringops-dynamically")} attribute
3769 Enable/disable the generation of the inline code to do small string
3770 operations and calling the library routines for large operations.
3771
3772 @item align-stringops
3773 @itemx no-align-stringops
3774 @cindex @code{target("align-stringops")} attribute
3775 Do/do not align destination of inlined string operations.
3776
3777 @item recip
3778 @itemx no-recip
3779 @cindex @code{target("recip")} attribute
3780 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
3781 instructions followed an additional Newton-Raphson step instead of
3782 doing a floating-point division.
3783
3784 @item arch=@var{ARCH}
3785 @cindex @code{target("arch=@var{ARCH}")} attribute
3786 Specify the architecture to generate code for in compiling the function.
3787
3788 @item tune=@var{TUNE}
3789 @cindex @code{target("tune=@var{TUNE}")} attribute
3790 Specify the architecture to tune for in compiling the function.
3791
3792 @item fpmath=@var{FPMATH}
3793 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
3794 Specify which floating-point unit to use. The
3795 @code{target("fpmath=sse,387")} option must be specified as
3796 @code{target("fpmath=sse+387")} because the comma would separate
3797 different options.
3798 @end table
3799
3800 On the PowerPC, the following options are allowed:
3801
3802 @table @samp
3803 @item altivec
3804 @itemx no-altivec
3805 @cindex @code{target("altivec")} attribute
3806 Generate code that uses (does not use) AltiVec instructions. In
3807 32-bit code, you cannot enable AltiVec instructions unless
3808 @option{-mabi=altivec} is used on the command line.
3809
3810 @item cmpb
3811 @itemx no-cmpb
3812 @cindex @code{target("cmpb")} attribute
3813 Generate code that uses (does not use) the compare bytes instruction
3814 implemented on the POWER6 processor and other processors that support
3815 the PowerPC V2.05 architecture.
3816
3817 @item dlmzb
3818 @itemx no-dlmzb
3819 @cindex @code{target("dlmzb")} attribute
3820 Generate code that uses (does not use) the string-search @samp{dlmzb}
3821 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
3822 generated by default when targeting those processors.
3823
3824 @item fprnd
3825 @itemx no-fprnd
3826 @cindex @code{target("fprnd")} attribute
3827 Generate code that uses (does not use) the FP round to integer
3828 instructions implemented on the POWER5+ processor and other processors
3829 that support the PowerPC V2.03 architecture.
3830
3831 @item hard-dfp
3832 @itemx no-hard-dfp
3833 @cindex @code{target("hard-dfp")} attribute
3834 Generate code that uses (does not use) the decimal floating-point
3835 instructions implemented on some POWER processors.
3836
3837 @item isel
3838 @itemx no-isel
3839 @cindex @code{target("isel")} attribute
3840 Generate code that uses (does not use) ISEL instruction.
3841
3842 @item mfcrf
3843 @itemx no-mfcrf
3844 @cindex @code{target("mfcrf")} attribute
3845 Generate code that uses (does not use) the move from condition
3846 register field instruction implemented on the POWER4 processor and
3847 other processors that support the PowerPC V2.01 architecture.
3848
3849 @item mfpgpr
3850 @itemx no-mfpgpr
3851 @cindex @code{target("mfpgpr")} attribute
3852 Generate code that uses (does not use) the FP move to/from general
3853 purpose register instructions implemented on the POWER6X processor and
3854 other processors that support the extended PowerPC V2.05 architecture.
3855
3856 @item mulhw
3857 @itemx no-mulhw
3858 @cindex @code{target("mulhw")} attribute
3859 Generate code that uses (does not use) the half-word multiply and
3860 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
3861 These instructions are generated by default when targeting those
3862 processors.
3863
3864 @item multiple
3865 @itemx no-multiple
3866 @cindex @code{target("multiple")} attribute
3867 Generate code that uses (does not use) the load multiple word
3868 instructions and the store multiple word instructions.
3869
3870 @item update
3871 @itemx no-update
3872 @cindex @code{target("update")} attribute
3873 Generate code that uses (does not use) the load or store instructions
3874 that update the base register to the address of the calculated memory
3875 location.
3876
3877 @item popcntb
3878 @itemx no-popcntb
3879 @cindex @code{target("popcntb")} attribute
3880 Generate code that uses (does not use) the popcount and double-precision
3881 FP reciprocal estimate instruction implemented on the POWER5
3882 processor and other processors that support the PowerPC V2.02
3883 architecture.
3884
3885 @item popcntd
3886 @itemx no-popcntd
3887 @cindex @code{target("popcntd")} attribute
3888 Generate code that uses (does not use) the popcount instruction
3889 implemented on the POWER7 processor and other processors that support
3890 the PowerPC V2.06 architecture.
3891
3892 @item powerpc-gfxopt
3893 @itemx no-powerpc-gfxopt
3894 @cindex @code{target("powerpc-gfxopt")} attribute
3895 Generate code that uses (does not use) the optional PowerPC
3896 architecture instructions in the Graphics group, including
3897 floating-point select.
3898
3899 @item powerpc-gpopt
3900 @itemx no-powerpc-gpopt
3901 @cindex @code{target("powerpc-gpopt")} attribute
3902 Generate code that uses (does not use) the optional PowerPC
3903 architecture instructions in the General Purpose group, including
3904 floating-point square root.
3905
3906 @item recip-precision
3907 @itemx no-recip-precision
3908 @cindex @code{target("recip-precision")} attribute
3909 Assume (do not assume) that the reciprocal estimate instructions
3910 provide higher-precision estimates than is mandated by the powerpc
3911 ABI.
3912
3913 @item string
3914 @itemx no-string
3915 @cindex @code{target("string")} attribute
3916 Generate code that uses (does not use) the load string instructions
3917 and the store string word instructions to save multiple registers and
3918 do small block moves.
3919
3920 @item vsx
3921 @itemx no-vsx
3922 @cindex @code{target("vsx")} attribute
3923 Generate code that uses (does not use) vector/scalar (VSX)
3924 instructions, and also enable the use of built-in functions that allow
3925 more direct access to the VSX instruction set. In 32-bit code, you
3926 cannot enable VSX or AltiVec instructions unless
3927 @option{-mabi=altivec} is used on the command line.
3928
3929 @item friz
3930 @itemx no-friz
3931 @cindex @code{target("friz")} attribute
3932 Generate (do not generate) the @code{friz} instruction when the
3933 @option{-funsafe-math-optimizations} option is used to optimize
3934 rounding a floating-point value to 64-bit integer and back to floating
3935 point. The @code{friz} instruction does not return the same value if
3936 the floating-point number is too large to fit in an integer.
3937
3938 @item avoid-indexed-addresses
3939 @itemx no-avoid-indexed-addresses
3940 @cindex @code{target("avoid-indexed-addresses")} attribute
3941 Generate code that tries to avoid (not avoid) the use of indexed load
3942 or store instructions.
3943
3944 @item paired
3945 @itemx no-paired
3946 @cindex @code{target("paired")} attribute
3947 Generate code that uses (does not use) the generation of PAIRED simd
3948 instructions.
3949
3950 @item longcall
3951 @itemx no-longcall
3952 @cindex @code{target("longcall")} attribute
3953 Generate code that assumes (does not assume) that all calls are far
3954 away so that a longer more expensive calling sequence is required.
3955
3956 @item cpu=@var{CPU}
3957 @cindex @code{target("cpu=@var{CPU}")} attribute
3958 Specify the architecture to generate code for when compiling the
3959 function. If you select the @code{target("cpu=power7")} attribute when
3960 generating 32-bit code, VSX and AltiVec instructions are not generated
3961 unless you use the @option{-mabi=altivec} option on the command line.
3962
3963 @item tune=@var{TUNE}
3964 @cindex @code{target("tune=@var{TUNE}")} attribute
3965 Specify the architecture to tune for when compiling the function. If
3966 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
3967 you do specify the @code{target("cpu=@var{CPU}")} attribute,
3968 compilation tunes for the @var{CPU} architecture, and not the
3969 default tuning specified on the command line.
3970 @end table
3971
3972 On the 386/x86_64 and PowerPC back ends, you can use either multiple
3973 strings to specify multiple options, or you can separate the option
3974 with a comma (@code{,}).
3975
3976 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
3977 function that has different target options than the caller, unless the
3978 callee has a subset of the target options of the caller. For example
3979 a function declared with @code{target("sse3")} can inline a function
3980 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
3981
3982 The @code{target} attribute is not implemented in GCC versions earlier
3983 than 4.4 for the i386/x86_64 and 4.6 for the PowerPC back ends. It is
3984 not currently implemented for other back ends.
3985
3986 @item tiny_data
3987 @cindex tiny data section on the H8/300H and H8S
3988 Use this attribute on the H8/300H and H8S to indicate that the specified
3989 variable should be placed into the tiny data section.
3990 The compiler generates more efficient code for loads and stores
3991 on data in the tiny data section. Note the tiny data area is limited to
3992 slightly under 32KB of data.
3993
3994 @item trap_exit
3995 @cindex @code{trap_exit} attribute
3996 Use this attribute on the SH for an @code{interrupt_handler} to return using
3997 @code{trapa} instead of @code{rte}. This attribute expects an integer
3998 argument specifying the trap number to be used.
3999
4000 @item trapa_handler
4001 @cindex @code{trapa_handler} attribute
4002 On SH targets this function attribute is similar to @code{interrupt_handler}
4003 but it does not save and restore all registers.
4004
4005 @item unused
4006 @cindex @code{unused} attribute.
4007 This attribute, attached to a function, means that the function is meant
4008 to be possibly unused. GCC does not produce a warning for this
4009 function.
4010
4011 @item used
4012 @cindex @code{used} attribute.
4013 This attribute, attached to a function, means that code must be emitted
4014 for the function even if it appears that the function is not referenced.
4015 This is useful, for example, when the function is referenced only in
4016 inline assembly.
4017
4018 When applied to a member function of a C++ class template, the
4019 attribute also means that the function is instantiated if the
4020 class itself is instantiated.
4021
4022 @item version_id
4023 @cindex @code{version_id} attribute
4024 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4025 symbol to contain a version string, thus allowing for function level
4026 versioning. HP-UX system header files may use version level functioning
4027 for some system calls.
4028
4029 @smallexample
4030 extern int foo () __attribute__((version_id ("20040821")));
4031 @end smallexample
4032
4033 @noindent
4034 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4035
4036 @item visibility ("@var{visibility_type}")
4037 @cindex @code{visibility} attribute
4038 This attribute affects the linkage of the declaration to which it is attached.
4039 There are four supported @var{visibility_type} values: default,
4040 hidden, protected or internal visibility.
4041
4042 @smallexample
4043 void __attribute__ ((visibility ("protected")))
4044 f () @{ /* @r{Do something.} */; @}
4045 int i __attribute__ ((visibility ("hidden")));
4046 @end smallexample
4047
4048 The possible values of @var{visibility_type} correspond to the
4049 visibility settings in the ELF gABI.
4050
4051 @table @dfn
4052 @c keep this list of visibilities in alphabetical order.
4053
4054 @item default
4055 Default visibility is the normal case for the object file format.
4056 This value is available for the visibility attribute to override other
4057 options that may change the assumed visibility of entities.
4058
4059 On ELF, default visibility means that the declaration is visible to other
4060 modules and, in shared libraries, means that the declared entity may be
4061 overridden.
4062
4063 On Darwin, default visibility means that the declaration is visible to
4064 other modules.
4065
4066 Default visibility corresponds to ``external linkage'' in the language.
4067
4068 @item hidden
4069 Hidden visibility indicates that the entity declared has a new
4070 form of linkage, which we call ``hidden linkage''. Two
4071 declarations of an object with hidden linkage refer to the same object
4072 if they are in the same shared object.
4073
4074 @item internal
4075 Internal visibility is like hidden visibility, but with additional
4076 processor specific semantics. Unless otherwise specified by the
4077 psABI, GCC defines internal visibility to mean that a function is
4078 @emph{never} called from another module. Compare this with hidden
4079 functions which, while they cannot be referenced directly by other
4080 modules, can be referenced indirectly via function pointers. By
4081 indicating that a function cannot be called from outside the module,
4082 GCC may for instance omit the load of a PIC register since it is known
4083 that the calling function loaded the correct value.
4084
4085 @item protected
4086 Protected visibility is like default visibility except that it
4087 indicates that references within the defining module bind to the
4088 definition in that module. That is, the declared entity cannot be
4089 overridden by another module.
4090
4091 @end table
4092
4093 All visibilities are supported on many, but not all, ELF targets
4094 (supported when the assembler supports the @samp{.visibility}
4095 pseudo-op). Default visibility is supported everywhere. Hidden
4096 visibility is supported on Darwin targets.
4097
4098 The visibility attribute should be applied only to declarations that
4099 would otherwise have external linkage. The attribute should be applied
4100 consistently, so that the same entity should not be declared with
4101 different settings of the attribute.
4102
4103 In C++, the visibility attribute applies to types as well as functions
4104 and objects, because in C++ types have linkage. A class must not have
4105 greater visibility than its non-static data member types and bases,
4106 and class members default to the visibility of their class. Also, a
4107 declaration without explicit visibility is limited to the visibility
4108 of its type.
4109
4110 In C++, you can mark member functions and static member variables of a
4111 class with the visibility attribute. This is useful if you know a
4112 particular method or static member variable should only be used from
4113 one shared object; then you can mark it hidden while the rest of the
4114 class has default visibility. Care must be taken to avoid breaking
4115 the One Definition Rule; for example, it is usually not useful to mark
4116 an inline method as hidden without marking the whole class as hidden.
4117
4118 A C++ namespace declaration can also have the visibility attribute.
4119 This attribute applies only to the particular namespace body, not to
4120 other definitions of the same namespace; it is equivalent to using
4121 @samp{#pragma GCC visibility} before and after the namespace
4122 definition (@pxref{Visibility Pragmas}).
4123
4124 In C++, if a template argument has limited visibility, this
4125 restriction is implicitly propagated to the template instantiation.
4126 Otherwise, template instantiations and specializations default to the
4127 visibility of their template.
4128
4129 If both the template and enclosing class have explicit visibility, the
4130 visibility from the template is used.
4131
4132 @item vliw
4133 @cindex @code{vliw} attribute
4134 On MeP, the @code{vliw} attribute tells the compiler to emit
4135 instructions in VLIW mode instead of core mode. Note that this
4136 attribute is not allowed unless a VLIW coprocessor has been configured
4137 and enabled through command-line options.
4138
4139 @item warn_unused_result
4140 @cindex @code{warn_unused_result} attribute
4141 The @code{warn_unused_result} attribute causes a warning to be emitted
4142 if a caller of the function with this attribute does not use its
4143 return value. This is useful for functions where not checking
4144 the result is either a security problem or always a bug, such as
4145 @code{realloc}.
4146
4147 @smallexample
4148 int fn () __attribute__ ((warn_unused_result));
4149 int foo ()
4150 @{
4151 if (fn () < 0) return -1;
4152 fn ();
4153 return 0;
4154 @}
4155 @end smallexample
4156
4157 @noindent
4158 results in warning on line 5.
4159
4160 @item weak
4161 @cindex @code{weak} attribute
4162 The @code{weak} attribute causes the declaration to be emitted as a weak
4163 symbol rather than a global. This is primarily useful in defining
4164 library functions that can be overridden in user code, though it can
4165 also be used with non-function declarations. Weak symbols are supported
4166 for ELF targets, and also for a.out targets when using the GNU assembler
4167 and linker.
4168
4169 @item weakref
4170 @itemx weakref ("@var{target}")
4171 @cindex @code{weakref} attribute
4172 The @code{weakref} attribute marks a declaration as a weak reference.
4173 Without arguments, it should be accompanied by an @code{alias} attribute
4174 naming the target symbol. Optionally, the @var{target} may be given as
4175 an argument to @code{weakref} itself. In either case, @code{weakref}
4176 implicitly marks the declaration as @code{weak}. Without a
4177 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4178 @code{weakref} is equivalent to @code{weak}.
4179
4180 @smallexample
4181 static int x() __attribute__ ((weakref ("y")));
4182 /* is equivalent to... */
4183 static int x() __attribute__ ((weak, weakref, alias ("y")));
4184 /* and to... */
4185 static int x() __attribute__ ((weakref));
4186 static int x() __attribute__ ((alias ("y")));
4187 @end smallexample
4188
4189 A weak reference is an alias that does not by itself require a
4190 definition to be given for the target symbol. If the target symbol is
4191 only referenced through weak references, then it becomes a @code{weak}
4192 undefined symbol. If it is directly referenced, however, then such
4193 strong references prevail, and a definition is required for the
4194 symbol, not necessarily in the same translation unit.
4195
4196 The effect is equivalent to moving all references to the alias to a
4197 separate translation unit, renaming the alias to the aliased symbol,
4198 declaring it as weak, compiling the two separate translation units and
4199 performing a reloadable link on them.
4200
4201 At present, a declaration to which @code{weakref} is attached can
4202 only be @code{static}.
4203
4204 @end table
4205
4206 You can specify multiple attributes in a declaration by separating them
4207 by commas within the double parentheses or by immediately following an
4208 attribute declaration with another attribute declaration.
4209
4210 @cindex @code{#pragma}, reason for not using
4211 @cindex pragma, reason for not using
4212 Some people object to the @code{__attribute__} feature, suggesting that
4213 ISO C's @code{#pragma} should be used instead. At the time
4214 @code{__attribute__} was designed, there were two reasons for not doing
4215 this.
4216
4217 @enumerate
4218 @item
4219 It is impossible to generate @code{#pragma} commands from a macro.
4220
4221 @item
4222 There is no telling what the same @code{#pragma} might mean in another
4223 compiler.
4224 @end enumerate
4225
4226 These two reasons applied to almost any application that might have been
4227 proposed for @code{#pragma}. It was basically a mistake to use
4228 @code{#pragma} for @emph{anything}.
4229
4230 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4231 to be generated from macros. In addition, a @code{#pragma GCC}
4232 namespace is now in use for GCC-specific pragmas. However, it has been
4233 found convenient to use @code{__attribute__} to achieve a natural
4234 attachment of attributes to their corresponding declarations, whereas
4235 @code{#pragma GCC} is of use for constructs that do not naturally form
4236 part of the grammar. @xref{Pragmas,,Pragmas Accepted by GCC}.
4237
4238 @node Attribute Syntax
4239 @section Attribute Syntax
4240 @cindex attribute syntax
4241
4242 This section describes the syntax with which @code{__attribute__} may be
4243 used, and the constructs to which attribute specifiers bind, for the C
4244 language. Some details may vary for C++ and Objective-C@. Because of
4245 infelicities in the grammar for attributes, some forms described here
4246 may not be successfully parsed in all cases.
4247
4248 There are some problems with the semantics of attributes in C++. For
4249 example, there are no manglings for attributes, although they may affect
4250 code generation, so problems may arise when attributed types are used in
4251 conjunction with templates or overloading. Similarly, @code{typeid}
4252 does not distinguish between types with different attributes. Support
4253 for attributes in C++ may be restricted in future to attributes on
4254 declarations only, but not on nested declarators.
4255
4256 @xref{Function Attributes}, for details of the semantics of attributes
4257 applying to functions. @xref{Variable Attributes}, for details of the
4258 semantics of attributes applying to variables. @xref{Type Attributes},
4259 for details of the semantics of attributes applying to structure, union
4260 and enumerated types.
4261
4262 An @dfn{attribute specifier} is of the form
4263 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
4264 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4265 each attribute is one of the following:
4266
4267 @itemize @bullet
4268 @item
4269 Empty. Empty attributes are ignored.
4270
4271 @item
4272 A word (which may be an identifier such as @code{unused}, or a reserved
4273 word such as @code{const}).
4274
4275 @item
4276 A word, followed by, in parentheses, parameters for the attribute.
4277 These parameters take one of the following forms:
4278
4279 @itemize @bullet
4280 @item
4281 An identifier. For example, @code{mode} attributes use this form.
4282
4283 @item
4284 An identifier followed by a comma and a non-empty comma-separated list
4285 of expressions. For example, @code{format} attributes use this form.
4286
4287 @item
4288 A possibly empty comma-separated list of expressions. For example,
4289 @code{format_arg} attributes use this form with the list being a single
4290 integer constant expression, and @code{alias} attributes use this form
4291 with the list being a single string constant.
4292 @end itemize
4293 @end itemize
4294
4295 An @dfn{attribute specifier list} is a sequence of one or more attribute
4296 specifiers, not separated by any other tokens.
4297
4298 In GNU C, an attribute specifier list may appear after the colon following a
4299 label, other than a @code{case} or @code{default} label. The only
4300 attribute it makes sense to use after a label is @code{unused}. This
4301 feature is intended for program-generated code that may contain unused labels,
4302 but which is compiled with @option{-Wall}. It is
4303 not normally appropriate to use in it human-written code, though it
4304 could be useful in cases where the code that jumps to the label is
4305 contained within an @code{#ifdef} conditional. GNU C++ only permits
4306 attributes on labels if the attribute specifier is immediately
4307 followed by a semicolon (i.e., the label applies to an empty
4308 statement). If the semicolon is missing, C++ label attributes are
4309 ambiguous, as it is permissible for a declaration, which could begin
4310 with an attribute list, to be labelled in C++. Declarations cannot be
4311 labelled in C90 or C99, so the ambiguity does not arise there.
4312
4313 An attribute specifier list may appear as part of a @code{struct},
4314 @code{union} or @code{enum} specifier. It may go either immediately
4315 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4316 the closing brace. The former syntax is preferred.
4317 Where attribute specifiers follow the closing brace, they are considered
4318 to relate to the structure, union or enumerated type defined, not to any
4319 enclosing declaration the type specifier appears in, and the type
4320 defined is not complete until after the attribute specifiers.
4321 @c Otherwise, there would be the following problems: a shift/reduce
4322 @c conflict between attributes binding the struct/union/enum and
4323 @c binding to the list of specifiers/qualifiers; and "aligned"
4324 @c attributes could use sizeof for the structure, but the size could be
4325 @c changed later by "packed" attributes.
4326
4327 Otherwise, an attribute specifier appears as part of a declaration,
4328 counting declarations of unnamed parameters and type names, and relates
4329 to that declaration (which may be nested in another declaration, for
4330 example in the case of a parameter declaration), or to a particular declarator
4331 within a declaration. Where an
4332 attribute specifier is applied to a parameter declared as a function or
4333 an array, it should apply to the function or array rather than the
4334 pointer to which the parameter is implicitly converted, but this is not
4335 yet correctly implemented.
4336
4337 Any list of specifiers and qualifiers at the start of a declaration may
4338 contain attribute specifiers, whether or not such a list may in that
4339 context contain storage class specifiers. (Some attributes, however,
4340 are essentially in the nature of storage class specifiers, and only make
4341 sense where storage class specifiers may be used; for example,
4342 @code{section}.) There is one necessary limitation to this syntax: the
4343 first old-style parameter declaration in a function definition cannot
4344 begin with an attribute specifier, because such an attribute applies to
4345 the function instead by syntax described below (which, however, is not
4346 yet implemented in this case). In some other cases, attribute
4347 specifiers are permitted by this grammar but not yet supported by the
4348 compiler. All attribute specifiers in this place relate to the
4349 declaration as a whole. In the obsolescent usage where a type of
4350 @code{int} is implied by the absence of type specifiers, such a list of
4351 specifiers and qualifiers may be an attribute specifier list with no
4352 other specifiers or qualifiers.
4353
4354 At present, the first parameter in a function prototype must have some
4355 type specifier that is not an attribute specifier; this resolves an
4356 ambiguity in the interpretation of @code{void f(int
4357 (__attribute__((foo)) x))}, but is subject to change. At present, if
4358 the parentheses of a function declarator contain only attributes then
4359 those attributes are ignored, rather than yielding an error or warning
4360 or implying a single parameter of type int, but this is subject to
4361 change.
4362
4363 An attribute specifier list may appear immediately before a declarator
4364 (other than the first) in a comma-separated list of declarators in a
4365 declaration of more than one identifier using a single list of
4366 specifiers and qualifiers. Such attribute specifiers apply
4367 only to the identifier before whose declarator they appear. For
4368 example, in
4369
4370 @smallexample
4371 __attribute__((noreturn)) void d0 (void),
4372 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4373 d2 (void)
4374 @end smallexample
4375
4376 @noindent
4377 the @code{noreturn} attribute applies to all the functions
4378 declared; the @code{format} attribute only applies to @code{d1}.
4379
4380 An attribute specifier list may appear immediately before the comma,
4381 @code{=} or semicolon terminating the declaration of an identifier other
4382 than a function definition. Such attribute specifiers apply
4383 to the declared object or function. Where an
4384 assembler name for an object or function is specified (@pxref{Asm
4385 Labels}), the attribute must follow the @code{asm}
4386 specification.
4387
4388 An attribute specifier list may, in future, be permitted to appear after
4389 the declarator in a function definition (before any old-style parameter
4390 declarations or the function body).
4391
4392 Attribute specifiers may be mixed with type qualifiers appearing inside
4393 the @code{[]} of a parameter array declarator, in the C99 construct by
4394 which such qualifiers are applied to the pointer to which the array is
4395 implicitly converted. Such attribute specifiers apply to the pointer,
4396 not to the array, but at present this is not implemented and they are
4397 ignored.
4398
4399 An attribute specifier list may appear at the start of a nested
4400 declarator. At present, there are some limitations in this usage: the
4401 attributes correctly apply to the declarator, but for most individual
4402 attributes the semantics this implies are not implemented.
4403 When attribute specifiers follow the @code{*} of a pointer
4404 declarator, they may be mixed with any type qualifiers present.
4405 The following describes the formal semantics of this syntax. It makes the
4406 most sense if you are familiar with the formal specification of
4407 declarators in the ISO C standard.
4408
4409 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4410 D1}, where @code{T} contains declaration specifiers that specify a type
4411 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4412 contains an identifier @var{ident}. The type specified for @var{ident}
4413 for derived declarators whose type does not include an attribute
4414 specifier is as in the ISO C standard.
4415
4416 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4417 and the declaration @code{T D} specifies the type
4418 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4419 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4420 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4421
4422 If @code{D1} has the form @code{*
4423 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4424 declaration @code{T D} specifies the type
4425 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4426 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4427 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4428 @var{ident}.
4429
4430 For example,
4431
4432 @smallexample
4433 void (__attribute__((noreturn)) ****f) (void);
4434 @end smallexample
4435
4436 @noindent
4437 specifies the type ``pointer to pointer to pointer to pointer to
4438 non-returning function returning @code{void}''. As another example,
4439
4440 @smallexample
4441 char *__attribute__((aligned(8))) *f;
4442 @end smallexample
4443
4444 @noindent
4445 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4446 Note again that this does not work with most attributes; for example,
4447 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4448 is not yet supported.
4449
4450 For compatibility with existing code written for compiler versions that
4451 did not implement attributes on nested declarators, some laxity is
4452 allowed in the placing of attributes. If an attribute that only applies
4453 to types is applied to a declaration, it is treated as applying to
4454 the type of that declaration. If an attribute that only applies to
4455 declarations is applied to the type of a declaration, it is treated
4456 as applying to that declaration; and, for compatibility with code
4457 placing the attributes immediately before the identifier declared, such
4458 an attribute applied to a function return type is treated as
4459 applying to the function type, and such an attribute applied to an array
4460 element type is treated as applying to the array type. If an
4461 attribute that only applies to function types is applied to a
4462 pointer-to-function type, it is treated as applying to the pointer
4463 target type; if such an attribute is applied to a function return type
4464 that is not a pointer-to-function type, it is treated as applying
4465 to the function type.
4466
4467 @node Function Prototypes
4468 @section Prototypes and Old-Style Function Definitions
4469 @cindex function prototype declarations
4470 @cindex old-style function definitions
4471 @cindex promotion of formal parameters
4472
4473 GNU C extends ISO C to allow a function prototype to override a later
4474 old-style non-prototype definition. Consider the following example:
4475
4476 @smallexample
4477 /* @r{Use prototypes unless the compiler is old-fashioned.} */
4478 #ifdef __STDC__
4479 #define P(x) x
4480 #else
4481 #define P(x) ()
4482 #endif
4483
4484 /* @r{Prototype function declaration.} */
4485 int isroot P((uid_t));
4486
4487 /* @r{Old-style function definition.} */
4488 int
4489 isroot (x) /* @r{??? lossage here ???} */
4490 uid_t x;
4491 @{
4492 return x == 0;
4493 @}
4494 @end smallexample
4495
4496 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
4497 not allow this example, because subword arguments in old-style
4498 non-prototype definitions are promoted. Therefore in this example the
4499 function definition's argument is really an @code{int}, which does not
4500 match the prototype argument type of @code{short}.
4501
4502 This restriction of ISO C makes it hard to write code that is portable
4503 to traditional C compilers, because the programmer does not know
4504 whether the @code{uid_t} type is @code{short}, @code{int}, or
4505 @code{long}. Therefore, in cases like these GNU C allows a prototype
4506 to override a later old-style definition. More precisely, in GNU C, a
4507 function prototype argument type overrides the argument type specified
4508 by a later old-style definition if the former type is the same as the
4509 latter type before promotion. Thus in GNU C the above example is
4510 equivalent to the following:
4511
4512 @smallexample
4513 int isroot (uid_t);
4514
4515 int
4516 isroot (uid_t x)
4517 @{
4518 return x == 0;
4519 @}
4520 @end smallexample
4521
4522 @noindent
4523 GNU C++ does not support old-style function definitions, so this
4524 extension is irrelevant.
4525
4526 @node C++ Comments
4527 @section C++ Style Comments
4528 @cindex @code{//}
4529 @cindex C++ comments
4530 @cindex comments, C++ style
4531
4532 In GNU C, you may use C++ style comments, which start with @samp{//} and
4533 continue until the end of the line. Many other C implementations allow
4534 such comments, and they are included in the 1999 C standard. However,
4535 C++ style comments are not recognized if you specify an @option{-std}
4536 option specifying a version of ISO C before C99, or @option{-ansi}
4537 (equivalent to @option{-std=c90}).
4538
4539 @node Dollar Signs
4540 @section Dollar Signs in Identifier Names
4541 @cindex $
4542 @cindex dollar signs in identifier names
4543 @cindex identifier names, dollar signs in
4544
4545 In GNU C, you may normally use dollar signs in identifier names.
4546 This is because many traditional C implementations allow such identifiers.
4547 However, dollar signs in identifiers are not supported on a few target
4548 machines, typically because the target assembler does not allow them.
4549
4550 @node Character Escapes
4551 @section The Character @key{ESC} in Constants
4552
4553 You can use the sequence @samp{\e} in a string or character constant to
4554 stand for the ASCII character @key{ESC}.
4555
4556 @node Variable Attributes
4557 @section Specifying Attributes of Variables
4558 @cindex attribute of variables
4559 @cindex variable attributes
4560
4561 The keyword @code{__attribute__} allows you to specify special
4562 attributes of variables or structure fields. This keyword is followed
4563 by an attribute specification inside double parentheses. Some
4564 attributes are currently defined generically for variables.
4565 Other attributes are defined for variables on particular target
4566 systems. Other attributes are available for functions
4567 (@pxref{Function Attributes}) and for types (@pxref{Type Attributes}).
4568 Other front ends might define more attributes
4569 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4570
4571 You may also specify attributes with @samp{__} preceding and following
4572 each keyword. This allows you to use them in header files without
4573 being concerned about a possible macro of the same name. For example,
4574 you may use @code{__aligned__} instead of @code{aligned}.
4575
4576 @xref{Attribute Syntax}, for details of the exact syntax for using
4577 attributes.
4578
4579 @table @code
4580 @cindex @code{aligned} attribute
4581 @item aligned (@var{alignment})
4582 This attribute specifies a minimum alignment for the variable or
4583 structure field, measured in bytes. For example, the declaration:
4584
4585 @smallexample
4586 int x __attribute__ ((aligned (16))) = 0;
4587 @end smallexample
4588
4589 @noindent
4590 causes the compiler to allocate the global variable @code{x} on a
4591 16-byte boundary. On a 68040, this could be used in conjunction with
4592 an @code{asm} expression to access the @code{move16} instruction which
4593 requires 16-byte aligned operands.
4594
4595 You can also specify the alignment of structure fields. For example, to
4596 create a double-word aligned @code{int} pair, you could write:
4597
4598 @smallexample
4599 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
4600 @end smallexample
4601
4602 @noindent
4603 This is an alternative to creating a union with a @code{double} member,
4604 which forces the union to be double-word aligned.
4605
4606 As in the preceding examples, you can explicitly specify the alignment
4607 (in bytes) that you wish the compiler to use for a given variable or
4608 structure field. Alternatively, you can leave out the alignment factor
4609 and just ask the compiler to align a variable or field to the
4610 default alignment for the target architecture you are compiling for.
4611 The default alignment is sufficient for all scalar types, but may not be
4612 enough for all vector types on a target that supports vector operations.
4613 The default alignment is fixed for a particular target ABI.
4614
4615 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
4616 which is the largest alignment ever used for any data type on the
4617 target machine you are compiling for. For example, you could write:
4618
4619 @smallexample
4620 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
4621 @end smallexample
4622
4623 The compiler automatically sets the alignment for the declared
4624 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
4625 often make copy operations more efficient, because the compiler can
4626 use whatever instructions copy the biggest chunks of memory when
4627 performing copies to or from the variables or fields that you have
4628 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
4629 may change depending on command-line options.
4630
4631 When used on a struct, or struct member, the @code{aligned} attribute can
4632 only increase the alignment; in order to decrease it, the @code{packed}
4633 attribute must be specified as well. When used as part of a typedef, the
4634 @code{aligned} attribute can both increase and decrease alignment, and
4635 specifying the @code{packed} attribute generates a warning.
4636
4637 Note that the effectiveness of @code{aligned} attributes may be limited
4638 by inherent limitations in your linker. On many systems, the linker is
4639 only able to arrange for variables to be aligned up to a certain maximum
4640 alignment. (For some linkers, the maximum supported alignment may
4641 be very very small.) If your linker is only able to align variables
4642 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
4643 in an @code{__attribute__} still only provides you with 8-byte
4644 alignment. See your linker documentation for further information.
4645
4646 The @code{aligned} attribute can also be used for functions
4647 (@pxref{Function Attributes}.)
4648
4649 @item cleanup (@var{cleanup_function})
4650 @cindex @code{cleanup} attribute
4651 The @code{cleanup} attribute runs a function when the variable goes
4652 out of scope. This attribute can only be applied to auto function
4653 scope variables; it may not be applied to parameters or variables
4654 with static storage duration. The function must take one parameter,
4655 a pointer to a type compatible with the variable. The return value
4656 of the function (if any) is ignored.
4657
4658 If @option{-fexceptions} is enabled, then @var{cleanup_function}
4659 is run during the stack unwinding that happens during the
4660 processing of the exception. Note that the @code{cleanup} attribute
4661 does not allow the exception to be caught, only to perform an action.
4662 It is undefined what happens if @var{cleanup_function} does not
4663 return normally.
4664
4665 @item common
4666 @itemx nocommon
4667 @cindex @code{common} attribute
4668 @cindex @code{nocommon} attribute
4669 @opindex fcommon
4670 @opindex fno-common
4671 The @code{common} attribute requests GCC to place a variable in
4672 ``common'' storage. The @code{nocommon} attribute requests the
4673 opposite---to allocate space for it directly.
4674
4675 These attributes override the default chosen by the
4676 @option{-fno-common} and @option{-fcommon} flags respectively.
4677
4678 @item deprecated
4679 @itemx deprecated (@var{msg})
4680 @cindex @code{deprecated} attribute
4681 The @code{deprecated} attribute results in a warning if the variable
4682 is used anywhere in the source file. This is useful when identifying
4683 variables that are expected to be removed in a future version of a
4684 program. The warning also includes the location of the declaration
4685 of the deprecated variable, to enable users to easily find further
4686 information about why the variable is deprecated, or what they should
4687 do instead. Note that the warning only occurs for uses:
4688
4689 @smallexample
4690 extern int old_var __attribute__ ((deprecated));
4691 extern int old_var;
4692 int new_fn () @{ return old_var; @}
4693 @end smallexample
4694
4695 @noindent
4696 results in a warning on line 3 but not line 2. The optional @var{msg}
4697 argument, which must be a string, is printed in the warning if
4698 present.
4699
4700 The @code{deprecated} attribute can also be used for functions and
4701 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
4702
4703 @item mode (@var{mode})
4704 @cindex @code{mode} attribute
4705 This attribute specifies the data type for the declaration---whichever
4706 type corresponds to the mode @var{mode}. This in effect lets you
4707 request an integer or floating-point type according to its width.
4708
4709 You may also specify a mode of @code{byte} or @code{__byte__} to
4710 indicate the mode corresponding to a one-byte integer, @code{word} or
4711 @code{__word__} for the mode of a one-word integer, and @code{pointer}
4712 or @code{__pointer__} for the mode used to represent pointers.
4713
4714 @item packed
4715 @cindex @code{packed} attribute
4716 The @code{packed} attribute specifies that a variable or structure field
4717 should have the smallest possible alignment---one byte for a variable,
4718 and one bit for a field, unless you specify a larger value with the
4719 @code{aligned} attribute.
4720
4721 Here is a structure in which the field @code{x} is packed, so that it
4722 immediately follows @code{a}:
4723
4724 @smallexample
4725 struct foo
4726 @{
4727 char a;
4728 int x[2] __attribute__ ((packed));
4729 @};
4730 @end smallexample
4731
4732 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
4733 @code{packed} attribute on bit-fields of type @code{char}. This has
4734 been fixed in GCC 4.4 but the change can lead to differences in the
4735 structure layout. See the documentation of
4736 @option{-Wpacked-bitfield-compat} for more information.
4737
4738 @item section ("@var{section-name}")
4739 @cindex @code{section} variable attribute
4740 Normally, the compiler places the objects it generates in sections like
4741 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
4742 or you need certain particular variables to appear in special sections,
4743 for example to map to special hardware. The @code{section}
4744 attribute specifies that a variable (or function) lives in a particular
4745 section. For example, this small program uses several specific section names:
4746
4747 @smallexample
4748 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
4749 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
4750 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
4751 int init_data __attribute__ ((section ("INITDATA")));
4752
4753 main()
4754 @{
4755 /* @r{Initialize stack pointer} */
4756 init_sp (stack + sizeof (stack));
4757
4758 /* @r{Initialize initialized data} */
4759 memcpy (&init_data, &data, &edata - &data);
4760
4761 /* @r{Turn on the serial ports} */
4762 init_duart (&a);
4763 init_duart (&b);
4764 @}
4765 @end smallexample
4766
4767 @noindent
4768 Use the @code{section} attribute with
4769 @emph{global} variables and not @emph{local} variables,
4770 as shown in the example.
4771
4772 You may use the @code{section} attribute with initialized or
4773 uninitialized global variables but the linker requires
4774 each object be defined once, with the exception that uninitialized
4775 variables tentatively go in the @code{common} (or @code{bss}) section
4776 and can be multiply ``defined''. Using the @code{section} attribute
4777 changes what section the variable goes into and may cause the
4778 linker to issue an error if an uninitialized variable has multiple
4779 definitions. You can force a variable to be initialized with the
4780 @option{-fno-common} flag or the @code{nocommon} attribute.
4781
4782 Some file formats do not support arbitrary sections so the @code{section}
4783 attribute is not available on all platforms.
4784 If you need to map the entire contents of a module to a particular
4785 section, consider using the facilities of the linker instead.
4786
4787 @item shared
4788 @cindex @code{shared} variable attribute
4789 On Microsoft Windows, in addition to putting variable definitions in a named
4790 section, the section can also be shared among all running copies of an
4791 executable or DLL@. For example, this small program defines shared data
4792 by putting it in a named section @code{shared} and marking the section
4793 shareable:
4794
4795 @smallexample
4796 int foo __attribute__((section ("shared"), shared)) = 0;
4797
4798 int
4799 main()
4800 @{
4801 /* @r{Read and write foo. All running
4802 copies see the same value.} */
4803 return 0;
4804 @}
4805 @end smallexample
4806
4807 @noindent
4808 You may only use the @code{shared} attribute along with @code{section}
4809 attribute with a fully-initialized global definition because of the way
4810 linkers work. See @code{section} attribute for more information.
4811
4812 The @code{shared} attribute is only available on Microsoft Windows@.
4813
4814 @item tls_model ("@var{tls_model}")
4815 @cindex @code{tls_model} attribute
4816 The @code{tls_model} attribute sets thread-local storage model
4817 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
4818 overriding @option{-ftls-model=} command-line switch on a per-variable
4819 basis.
4820 The @var{tls_model} argument should be one of @code{global-dynamic},
4821 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
4822
4823 Not all targets support this attribute.
4824
4825 @item unused
4826 This attribute, attached to a variable, means that the variable is meant
4827 to be possibly unused. GCC does not produce a warning for this
4828 variable.
4829
4830 @item used
4831 This attribute, attached to a variable, means that the variable must be
4832 emitted even if it appears that the variable is not referenced.
4833
4834 When applied to a static data member of a C++ class template, the
4835 attribute also means that the member is instantiated if the
4836 class itself is instantiated.
4837
4838 @item vector_size (@var{bytes})
4839 This attribute specifies the vector size for the variable, measured in
4840 bytes. For example, the declaration:
4841
4842 @smallexample
4843 int foo __attribute__ ((vector_size (16)));
4844 @end smallexample
4845
4846 @noindent
4847 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
4848 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
4849 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
4850
4851 This attribute is only applicable to integral and float scalars,
4852 although arrays, pointers, and function return values are allowed in
4853 conjunction with this construct.
4854
4855 Aggregates with this attribute are invalid, even if they are of the same
4856 size as a corresponding scalar. For example, the declaration:
4857
4858 @smallexample
4859 struct S @{ int a; @};
4860 struct S __attribute__ ((vector_size (16))) foo;
4861 @end smallexample
4862
4863 @noindent
4864 is invalid even if the size of the structure is the same as the size of
4865 the @code{int}.
4866
4867 @item selectany
4868 The @code{selectany} attribute causes an initialized global variable to
4869 have link-once semantics. When multiple definitions of the variable are
4870 encountered by the linker, the first is selected and the remainder are
4871 discarded. Following usage by the Microsoft compiler, the linker is told
4872 @emph{not} to warn about size or content differences of the multiple
4873 definitions.
4874
4875 Although the primary usage of this attribute is for POD types, the
4876 attribute can also be applied to global C++ objects that are initialized
4877 by a constructor. In this case, the static initialization and destruction
4878 code for the object is emitted in each translation defining the object,
4879 but the calls to the constructor and destructor are protected by a
4880 link-once guard variable.
4881
4882 The @code{selectany} attribute is only available on Microsoft Windows
4883 targets. You can use @code{__declspec (selectany)} as a synonym for
4884 @code{__attribute__ ((selectany))} for compatibility with other
4885 compilers.
4886
4887 @item weak
4888 The @code{weak} attribute is described in @ref{Function Attributes}.
4889
4890 @item dllimport
4891 The @code{dllimport} attribute is described in @ref{Function Attributes}.
4892
4893 @item dllexport
4894 The @code{dllexport} attribute is described in @ref{Function Attributes}.
4895
4896 @end table
4897
4898 @anchor{AVR Variable Attributes}
4899 @subsection AVR Variable Attributes
4900
4901 @table @code
4902 @item progmem
4903 @cindex @code{progmem} AVR variable attribute
4904 The @code{progmem} attribute is used on the AVR to place read-only
4905 data in the non-volatile program memory (flash). The @code{progmem}
4906 attribute accomplishes this by putting respective variables into a
4907 section whose name starts with @code{.progmem}.
4908
4909 This attribute works similar to the @code{section} attribute
4910 but adds additional checking. Notice that just like the
4911 @code{section} attribute, @code{progmem} affects the location
4912 of the data but not how this data is accessed.
4913
4914 In order to read data located with the @code{progmem} attribute
4915 (inline) assembler must be used.
4916 @smallexample
4917 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual,AVR-LibC}} */
4918 #include <avr/pgmspace.h>
4919
4920 /* Locate var in flash memory */
4921 const int var[2] PROGMEM = @{ 1, 2 @};
4922
4923 int read_var (int i)
4924 @{
4925 /* Access var[] by accessor macro from avr/pgmspace.h */
4926 return (int) pgm_read_word (& var[i]);
4927 @}
4928 @end smallexample
4929
4930 AVR is a Harvard architecture processor and data and read-only data
4931 normally resides in the data memory (RAM).
4932
4933 See also the @ref{AVR Named Address Spaces} section for
4934 an alternate way to locate and access data in flash memory.
4935 @end table
4936
4937 @subsection Blackfin Variable Attributes
4938
4939 Three attributes are currently defined for the Blackfin.
4940
4941 @table @code
4942 @item l1_data
4943 @itemx l1_data_A
4944 @itemx l1_data_B
4945 @cindex @code{l1_data} variable attribute
4946 @cindex @code{l1_data_A} variable attribute
4947 @cindex @code{l1_data_B} variable attribute
4948 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
4949 Variables with @code{l1_data} attribute are put into the specific section
4950 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
4951 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
4952 attribute are put into the specific section named @code{.l1.data.B}.
4953
4954 @item l2
4955 @cindex @code{l2} variable attribute
4956 Use this attribute on the Blackfin to place the variable into L2 SRAM.
4957 Variables with @code{l2} attribute are put into the specific section
4958 named @code{.l2.data}.
4959 @end table
4960
4961 @subsection M32R/D Variable Attributes
4962
4963 One attribute is currently defined for the M32R/D@.
4964
4965 @table @code
4966 @item model (@var{model-name})
4967 @cindex variable addressability on the M32R/D
4968 Use this attribute on the M32R/D to set the addressability of an object.
4969 The identifier @var{model-name} is one of @code{small}, @code{medium},
4970 or @code{large}, representing each of the code models.
4971
4972 Small model objects live in the lower 16MB of memory (so that their
4973 addresses can be loaded with the @code{ld24} instruction).
4974
4975 Medium and large model objects may live anywhere in the 32-bit address space
4976 (the compiler generates @code{seth/add3} instructions to load their
4977 addresses).
4978 @end table
4979
4980 @anchor{MeP Variable Attributes}
4981 @subsection MeP Variable Attributes
4982
4983 The MeP target has a number of addressing modes and busses. The
4984 @code{near} space spans the standard memory space's first 16 megabytes
4985 (24 bits). The @code{far} space spans the entire 32-bit memory space.
4986 The @code{based} space is a 128-byte region in the memory space that
4987 is addressed relative to the @code{$tp} register. The @code{tiny}
4988 space is a 65536-byte region relative to the @code{$gp} register. In
4989 addition to these memory regions, the MeP target has a separate 16-bit
4990 control bus which is specified with @code{cb} attributes.
4991
4992 @table @code
4993
4994 @item based
4995 Any variable with the @code{based} attribute is assigned to the
4996 @code{.based} section, and is accessed with relative to the
4997 @code{$tp} register.
4998
4999 @item tiny
5000 Likewise, the @code{tiny} attribute assigned variables to the
5001 @code{.tiny} section, relative to the @code{$gp} register.
5002
5003 @item near
5004 Variables with the @code{near} attribute are assumed to have addresses
5005 that fit in a 24-bit addressing mode. This is the default for large
5006 variables (@code{-mtiny=4} is the default) but this attribute can
5007 override @code{-mtiny=} for small variables, or override @code{-ml}.
5008
5009 @item far
5010 Variables with the @code{far} attribute are addressed using a full
5011 32-bit address. Since this covers the entire memory space, this
5012 allows modules to make no assumptions about where variables might be
5013 stored.
5014
5015 @item io
5016 @itemx io (@var{addr})
5017 Variables with the @code{io} attribute are used to address
5018 memory-mapped peripherals. If an address is specified, the variable
5019 is assigned that address, else it is not assigned an address (it is
5020 assumed some other module assigns an address). Example:
5021
5022 @smallexample
5023 int timer_count __attribute__((io(0x123)));
5024 @end smallexample
5025
5026 @item cb
5027 @itemx cb (@var{addr})
5028 Variables with the @code{cb} attribute are used to access the control
5029 bus, using special instructions. @code{addr} indicates the control bus
5030 address. Example:
5031
5032 @smallexample
5033 int cpu_clock __attribute__((cb(0x123)));
5034 @end smallexample
5035
5036 @end table
5037
5038 @anchor{i386 Variable Attributes}
5039 @subsection i386 Variable Attributes
5040
5041 Two attributes are currently defined for i386 configurations:
5042 @code{ms_struct} and @code{gcc_struct}
5043
5044 @table @code
5045 @item ms_struct
5046 @itemx gcc_struct
5047 @cindex @code{ms_struct} attribute
5048 @cindex @code{gcc_struct} attribute
5049
5050 If @code{packed} is used on a structure, or if bit-fields are used,
5051 it may be that the Microsoft ABI lays out the structure differently
5052 than the way GCC normally does. Particularly when moving packed
5053 data between functions compiled with GCC and the native Microsoft compiler
5054 (either via function call or as data in a file), it may be necessary to access
5055 either format.
5056
5057 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5058 compilers to match the native Microsoft compiler.
5059
5060 The Microsoft structure layout algorithm is fairly simple with the exception
5061 of the bit-field packing.
5062 The padding and alignment of members of structures and whether a bit-field
5063 can straddle a storage-unit boundary are determine by these rules:
5064
5065 @enumerate
5066 @item Structure members are stored sequentially in the order in which they are
5067 declared: the first member has the lowest memory address and the last member
5068 the highest.
5069
5070 @item Every data object has an alignment requirement. The alignment requirement
5071 for all data except structures, unions, and arrays is either the size of the
5072 object or the current packing size (specified with either the
5073 @code{aligned} attribute or the @code{pack} pragma),
5074 whichever is less. For structures, unions, and arrays,
5075 the alignment requirement is the largest alignment requirement of its members.
5076 Every object is allocated an offset so that:
5077
5078 @smallexample
5079 offset % alignment_requirement == 0
5080 @end smallexample
5081
5082 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5083 unit if the integral types are the same size and if the next bit-field fits
5084 into the current allocation unit without crossing the boundary imposed by the
5085 common alignment requirements of the bit-fields.
5086 @end enumerate
5087
5088 MSVC interprets zero-length bit-fields in the following ways:
5089
5090 @enumerate
5091 @item If a zero-length bit-field is inserted between two bit-fields that
5092 are normally coalesced, the bit-fields are not coalesced.
5093
5094 For example:
5095
5096 @smallexample
5097 struct
5098 @{
5099 unsigned long bf_1 : 12;
5100 unsigned long : 0;
5101 unsigned long bf_2 : 12;
5102 @} t1;
5103 @end smallexample
5104
5105 @noindent
5106 The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
5107 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5108
5109 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5110 alignment of the zero-length bit-field is greater than the member that follows it,
5111 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5112
5113 For example:
5114
5115 @smallexample
5116 struct
5117 @{
5118 char foo : 4;
5119 short : 0;
5120 char bar;
5121 @} t2;
5122
5123 struct
5124 @{
5125 char foo : 4;
5126 short : 0;
5127 double bar;
5128 @} t3;
5129 @end smallexample
5130
5131 @noindent
5132 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5133 Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
5134 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5135 of the structure.
5136
5137 Taking this into account, it is important to note the following:
5138
5139 @enumerate
5140 @item If a zero-length bit-field follows a normal bit-field, the type of the
5141 zero-length bit-field may affect the alignment of the structure as whole. For
5142 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5143 normal bit-field, and is of type short.
5144
5145 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5146 still affect the alignment of the structure:
5147
5148 @smallexample
5149 struct
5150 @{
5151 char foo : 6;
5152 long : 0;
5153 @} t4;
5154 @end smallexample
5155
5156 @noindent
5157 Here, @code{t4} takes up 4 bytes.
5158 @end enumerate
5159
5160 @item Zero-length bit-fields following non-bit-field members are ignored:
5161
5162 @smallexample
5163 struct
5164 @{
5165 char foo;
5166 long : 0;
5167 char bar;
5168 @} t5;
5169 @end smallexample
5170
5171 @noindent
5172 Here, @code{t5} takes up 2 bytes.
5173 @end enumerate
5174 @end table
5175
5176 @subsection PowerPC Variable Attributes
5177
5178 Three attributes currently are defined for PowerPC configurations:
5179 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5180
5181 For full documentation of the struct attributes please see the
5182 documentation in @ref{i386 Variable Attributes}.
5183
5184 For documentation of @code{altivec} attribute please see the
5185 documentation in @ref{PowerPC Type Attributes}.
5186
5187 @subsection SPU Variable Attributes
5188
5189 The SPU supports the @code{spu_vector} attribute for variables. For
5190 documentation of this attribute please see the documentation in
5191 @ref{SPU Type Attributes}.
5192
5193 @subsection Xstormy16 Variable Attributes
5194
5195 One attribute is currently defined for xstormy16 configurations:
5196 @code{below100}.
5197
5198 @table @code
5199 @item below100
5200 @cindex @code{below100} attribute
5201
5202 If a variable has the @code{below100} attribute (@code{BELOW100} is
5203 allowed also), GCC places the variable in the first 0x100 bytes of
5204 memory and use special opcodes to access it. Such variables are
5205 placed in either the @code{.bss_below100} section or the
5206 @code{.data_below100} section.
5207
5208 @end table
5209
5210 @node Type Attributes
5211 @section Specifying Attributes of Types
5212 @cindex attribute of types
5213 @cindex type attributes
5214
5215 The keyword @code{__attribute__} allows you to specify special
5216 attributes of @code{struct} and @code{union} types when you define
5217 such types. This keyword is followed by an attribute specification
5218 inside double parentheses. Seven attributes are currently defined for
5219 types: @code{aligned}, @code{packed}, @code{transparent_union},
5220 @code{unused}, @code{deprecated}, @code{visibility}, and
5221 @code{may_alias}. Other attributes are defined for functions
5222 (@pxref{Function Attributes}) and for variables (@pxref{Variable
5223 Attributes}).
5224
5225 You may also specify any one of these attributes with @samp{__}
5226 preceding and following its keyword. This allows you to use these
5227 attributes in header files without being concerned about a possible
5228 macro of the same name. For example, you may use @code{__aligned__}
5229 instead of @code{aligned}.
5230
5231 You may specify type attributes in an enum, struct or union type
5232 declaration or definition, or for other types in a @code{typedef}
5233 declaration.
5234
5235 For an enum, struct or union type, you may specify attributes either
5236 between the enum, struct or union tag and the name of the type, or
5237 just past the closing curly brace of the @emph{definition}. The
5238 former syntax is preferred.
5239
5240 @xref{Attribute Syntax}, for details of the exact syntax for using
5241 attributes.
5242
5243 @table @code
5244 @cindex @code{aligned} attribute
5245 @item aligned (@var{alignment})
5246 This attribute specifies a minimum alignment (in bytes) for variables
5247 of the specified type. For example, the declarations:
5248
5249 @smallexample
5250 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5251 typedef int more_aligned_int __attribute__ ((aligned (8)));
5252 @end smallexample
5253
5254 @noindent
5255 force the compiler to ensure (as far as it can) that each variable whose
5256 type is @code{struct S} or @code{more_aligned_int} is allocated and
5257 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
5258 variables of type @code{struct S} aligned to 8-byte boundaries allows
5259 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5260 store) instructions when copying one variable of type @code{struct S} to
5261 another, thus improving run-time efficiency.
5262
5263 Note that the alignment of any given @code{struct} or @code{union} type
5264 is required by the ISO C standard to be at least a perfect multiple of
5265 the lowest common multiple of the alignments of all of the members of
5266 the @code{struct} or @code{union} in question. This means that you @emph{can}
5267 effectively adjust the alignment of a @code{struct} or @code{union}
5268 type by attaching an @code{aligned} attribute to any one of the members
5269 of such a type, but the notation illustrated in the example above is a
5270 more obvious, intuitive, and readable way to request the compiler to
5271 adjust the alignment of an entire @code{struct} or @code{union} type.
5272
5273 As in the preceding example, you can explicitly specify the alignment
5274 (in bytes) that you wish the compiler to use for a given @code{struct}
5275 or @code{union} type. Alternatively, you can leave out the alignment factor
5276 and just ask the compiler to align a type to the maximum
5277 useful alignment for the target machine you are compiling for. For
5278 example, you could write:
5279
5280 @smallexample
5281 struct S @{ short f[3]; @} __attribute__ ((aligned));
5282 @end smallexample
5283
5284 Whenever you leave out the alignment factor in an @code{aligned}
5285 attribute specification, the compiler automatically sets the alignment
5286 for the type to the largest alignment that is ever used for any data
5287 type on the target machine you are compiling for. Doing this can often
5288 make copy operations more efficient, because the compiler can use
5289 whatever instructions copy the biggest chunks of memory when performing
5290 copies to or from the variables that have types that you have aligned
5291 this way.
5292
5293 In the example above, if the size of each @code{short} is 2 bytes, then
5294 the size of the entire @code{struct S} type is 6 bytes. The smallest
5295 power of two that is greater than or equal to that is 8, so the
5296 compiler sets the alignment for the entire @code{struct S} type to 8
5297 bytes.
5298
5299 Note that although you can ask the compiler to select a time-efficient
5300 alignment for a given type and then declare only individual stand-alone
5301 objects of that type, the compiler's ability to select a time-efficient
5302 alignment is primarily useful only when you plan to create arrays of
5303 variables having the relevant (efficiently aligned) type. If you
5304 declare or use arrays of variables of an efficiently-aligned type, then
5305 it is likely that your program also does pointer arithmetic (or
5306 subscripting, which amounts to the same thing) on pointers to the
5307 relevant type, and the code that the compiler generates for these
5308 pointer arithmetic operations is often more efficient for
5309 efficiently-aligned types than for other types.
5310
5311 The @code{aligned} attribute can only increase the alignment; but you
5312 can decrease it by specifying @code{packed} as well. See below.
5313
5314 Note that the effectiveness of @code{aligned} attributes may be limited
5315 by inherent limitations in your linker. On many systems, the linker is
5316 only able to arrange for variables to be aligned up to a certain maximum
5317 alignment. (For some linkers, the maximum supported alignment may
5318 be very very small.) If your linker is only able to align variables
5319 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5320 in an @code{__attribute__} still only provides you with 8-byte
5321 alignment. See your linker documentation for further information.
5322
5323 @item packed
5324 This attribute, attached to @code{struct} or @code{union} type
5325 definition, specifies that each member (other than zero-width bit-fields)
5326 of the structure or union is placed to minimize the memory required. When
5327 attached to an @code{enum} definition, it indicates that the smallest
5328 integral type should be used.
5329
5330 @opindex fshort-enums
5331 Specifying this attribute for @code{struct} and @code{union} types is
5332 equivalent to specifying the @code{packed} attribute on each of the
5333 structure or union members. Specifying the @option{-fshort-enums}
5334 flag on the line is equivalent to specifying the @code{packed}
5335 attribute on all @code{enum} definitions.
5336
5337 In the following example @code{struct my_packed_struct}'s members are
5338 packed closely together, but the internal layout of its @code{s} member
5339 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5340 be packed too.
5341
5342 @smallexample
5343 struct my_unpacked_struct
5344 @{
5345 char c;
5346 int i;
5347 @};
5348
5349 struct __attribute__ ((__packed__)) my_packed_struct
5350 @{
5351 char c;
5352 int i;
5353 struct my_unpacked_struct s;
5354 @};
5355 @end smallexample
5356
5357 You may only specify this attribute on the definition of an @code{enum},
5358 @code{struct} or @code{union}, not on a @code{typedef} that does not
5359 also define the enumerated type, structure or union.
5360
5361 @item transparent_union
5362 This attribute, attached to a @code{union} type definition, indicates
5363 that any function parameter having that union type causes calls to that
5364 function to be treated in a special way.
5365
5366 First, the argument corresponding to a transparent union type can be of
5367 any type in the union; no cast is required. Also, if the union contains
5368 a pointer type, the corresponding argument can be a null pointer
5369 constant or a void pointer expression; and if the union contains a void
5370 pointer type, the corresponding argument can be any pointer expression.
5371 If the union member type is a pointer, qualifiers like @code{const} on
5372 the referenced type must be respected, just as with normal pointer
5373 conversions.
5374
5375 Second, the argument is passed to the function using the calling
5376 conventions of the first member of the transparent union, not the calling
5377 conventions of the union itself. All members of the union must have the
5378 same machine representation; this is necessary for this argument passing
5379 to work properly.
5380
5381 Transparent unions are designed for library functions that have multiple
5382 interfaces for compatibility reasons. For example, suppose the
5383 @code{wait} function must accept either a value of type @code{int *} to
5384 comply with POSIX, or a value of type @code{union wait *} to comply with
5385 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
5386 @code{wait} would accept both kinds of arguments, but it would also
5387 accept any other pointer type and this would make argument type checking
5388 less useful. Instead, @code{<sys/wait.h>} might define the interface
5389 as follows:
5390
5391 @smallexample
5392 typedef union __attribute__ ((__transparent_union__))
5393 @{
5394 int *__ip;
5395 union wait *__up;
5396 @} wait_status_ptr_t;
5397
5398 pid_t wait (wait_status_ptr_t);
5399 @end smallexample
5400
5401 @noindent
5402 This interface allows either @code{int *} or @code{union wait *}
5403 arguments to be passed, using the @code{int *} calling convention.
5404 The program can call @code{wait} with arguments of either type:
5405
5406 @smallexample
5407 int w1 () @{ int w; return wait (&w); @}
5408 int w2 () @{ union wait w; return wait (&w); @}
5409 @end smallexample
5410
5411 @noindent
5412 With this interface, @code{wait}'s implementation might look like this:
5413
5414 @smallexample
5415 pid_t wait (wait_status_ptr_t p)
5416 @{
5417 return waitpid (-1, p.__ip, 0);
5418 @}
5419 @end smallexample
5420
5421 @item unused
5422 When attached to a type (including a @code{union} or a @code{struct}),
5423 this attribute means that variables of that type are meant to appear
5424 possibly unused. GCC does not produce a warning for any variables of
5425 that type, even if the variable appears to do nothing. This is often
5426 the case with lock or thread classes, which are usually defined and then
5427 not referenced, but contain constructors and destructors that have
5428 nontrivial bookkeeping functions.
5429
5430 @item deprecated
5431 @itemx deprecated (@var{msg})
5432 The @code{deprecated} attribute results in a warning if the type
5433 is used anywhere in the source file. This is useful when identifying
5434 types that are expected to be removed in a future version of a program.
5435 If possible, the warning also includes the location of the declaration
5436 of the deprecated type, to enable users to easily find further
5437 information about why the type is deprecated, or what they should do
5438 instead. Note that the warnings only occur for uses and then only
5439 if the type is being applied to an identifier that itself is not being
5440 declared as deprecated.
5441
5442 @smallexample
5443 typedef int T1 __attribute__ ((deprecated));
5444 T1 x;
5445 typedef T1 T2;
5446 T2 y;
5447 typedef T1 T3 __attribute__ ((deprecated));
5448 T3 z __attribute__ ((deprecated));
5449 @end smallexample
5450
5451 @noindent
5452 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
5453 warning is issued for line 4 because T2 is not explicitly
5454 deprecated. Line 5 has no warning because T3 is explicitly
5455 deprecated. Similarly for line 6. The optional @var{msg}
5456 argument, which must be a string, is printed in the warning if
5457 present.
5458
5459 The @code{deprecated} attribute can also be used for functions and
5460 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5461
5462 @item may_alias
5463 Accesses through pointers to types with this attribute are not subject
5464 to type-based alias analysis, but are instead assumed to be able to alias
5465 any other type of objects.
5466 In the context of section 6.5 paragraph 7 of the C99 standard,
5467 an lvalue expression
5468 dereferencing such a pointer is treated like having a character type.
5469 See @option{-fstrict-aliasing} for more information on aliasing issues.
5470 This extension exists to support some vector APIs, in which pointers to
5471 one vector type are permitted to alias pointers to a different vector type.
5472
5473 Note that an object of a type with this attribute does not have any
5474 special semantics.
5475
5476 Example of use:
5477
5478 @smallexample
5479 typedef short __attribute__((__may_alias__)) short_a;
5480
5481 int
5482 main (void)
5483 @{
5484 int a = 0x12345678;
5485 short_a *b = (short_a *) &a;
5486
5487 b[1] = 0;
5488
5489 if (a == 0x12345678)
5490 abort();
5491
5492 exit(0);
5493 @}
5494 @end smallexample
5495
5496 @noindent
5497 If you replaced @code{short_a} with @code{short} in the variable
5498 declaration, the above program would abort when compiled with
5499 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5500 above in recent GCC versions.
5501
5502 @item visibility
5503 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5504 applied to class, struct, union and enum types. Unlike other type
5505 attributes, the attribute must appear between the initial keyword and
5506 the name of the type; it cannot appear after the body of the type.
5507
5508 Note that the type visibility is applied to vague linkage entities
5509 associated with the class (vtable, typeinfo node, etc.). In
5510 particular, if a class is thrown as an exception in one shared object
5511 and caught in another, the class must have default visibility.
5512 Otherwise the two shared objects are unable to use the same
5513 typeinfo node and exception handling will break.
5514
5515 @end table
5516
5517 To specify multiple attributes, separate them by commas within the
5518 double parentheses: for example, @samp{__attribute__ ((aligned (16),
5519 packed))}.
5520
5521 @subsection ARM Type Attributes
5522
5523 On those ARM targets that support @code{dllimport} (such as Symbian
5524 OS), you can use the @code{notshared} attribute to indicate that the
5525 virtual table and other similar data for a class should not be
5526 exported from a DLL@. For example:
5527
5528 @smallexample
5529 class __declspec(notshared) C @{
5530 public:
5531 __declspec(dllimport) C();
5532 virtual void f();
5533 @}
5534
5535 __declspec(dllexport)
5536 C::C() @{@}
5537 @end smallexample
5538
5539 @noindent
5540 In this code, @code{C::C} is exported from the current DLL, but the
5541 virtual table for @code{C} is not exported. (You can use
5542 @code{__attribute__} instead of @code{__declspec} if you prefer, but
5543 most Symbian OS code uses @code{__declspec}.)
5544
5545 @anchor{MeP Type Attributes}
5546 @subsection MeP Type Attributes
5547
5548 Many of the MeP variable attributes may be applied to types as well.
5549 Specifically, the @code{based}, @code{tiny}, @code{near}, and
5550 @code{far} attributes may be applied to either. The @code{io} and
5551 @code{cb} attributes may not be applied to types.
5552
5553 @anchor{i386 Type Attributes}
5554 @subsection i386 Type Attributes
5555
5556 Two attributes are currently defined for i386 configurations:
5557 @code{ms_struct} and @code{gcc_struct}.
5558
5559 @table @code
5560
5561 @item ms_struct
5562 @itemx gcc_struct
5563 @cindex @code{ms_struct}
5564 @cindex @code{gcc_struct}
5565
5566 If @code{packed} is used on a structure, or if bit-fields are used
5567 it may be that the Microsoft ABI packs them differently
5568 than GCC normally packs them. Particularly when moving packed
5569 data between functions compiled with GCC and the native Microsoft compiler
5570 (either via function call or as data in a file), it may be necessary to access
5571 either format.
5572
5573 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5574 compilers to match the native Microsoft compiler.
5575 @end table
5576
5577 @anchor{PowerPC Type Attributes}
5578 @subsection PowerPC Type Attributes
5579
5580 Three attributes currently are defined for PowerPC configurations:
5581 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5582
5583 For full documentation of the @code{ms_struct} and @code{gcc_struct}
5584 attributes please see the documentation in @ref{i386 Type Attributes}.
5585
5586 The @code{altivec} attribute allows one to declare AltiVec vector data
5587 types supported by the AltiVec Programming Interface Manual. The
5588 attribute requires an argument to specify one of three vector types:
5589 @code{vector__}, @code{pixel__} (always followed by unsigned short),
5590 and @code{bool__} (always followed by unsigned).
5591
5592 @smallexample
5593 __attribute__((altivec(vector__)))
5594 __attribute__((altivec(pixel__))) unsigned short
5595 __attribute__((altivec(bool__))) unsigned
5596 @end smallexample
5597
5598 These attributes mainly are intended to support the @code{__vector},
5599 @code{__pixel}, and @code{__bool} AltiVec keywords.
5600
5601 @anchor{SPU Type Attributes}
5602 @subsection SPU Type Attributes
5603
5604 The SPU supports the @code{spu_vector} attribute for types. This attribute
5605 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
5606 Language Extensions Specification. It is intended to support the
5607 @code{__vector} keyword.
5608
5609 @node Alignment
5610 @section Inquiring on Alignment of Types or Variables
5611 @cindex alignment
5612 @cindex type alignment
5613 @cindex variable alignment
5614
5615 The keyword @code{__alignof__} allows you to inquire about how an object
5616 is aligned, or the minimum alignment usually required by a type. Its
5617 syntax is just like @code{sizeof}.
5618
5619 For example, if the target machine requires a @code{double} value to be
5620 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
5621 This is true on many RISC machines. On more traditional machine
5622 designs, @code{__alignof__ (double)} is 4 or even 2.
5623
5624 Some machines never actually require alignment; they allow reference to any
5625 data type even at an odd address. For these machines, @code{__alignof__}
5626 reports the smallest alignment that GCC gives the data type, usually as
5627 mandated by the target ABI.
5628
5629 If the operand of @code{__alignof__} is an lvalue rather than a type,
5630 its value is the required alignment for its type, taking into account
5631 any minimum alignment specified with GCC's @code{__attribute__}
5632 extension (@pxref{Variable Attributes}). For example, after this
5633 declaration:
5634
5635 @smallexample
5636 struct foo @{ int x; char y; @} foo1;
5637 @end smallexample
5638
5639 @noindent
5640 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
5641 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
5642
5643 It is an error to ask for the alignment of an incomplete type.
5644
5645
5646 @node Inline
5647 @section An Inline Function is As Fast As a Macro
5648 @cindex inline functions
5649 @cindex integrating function code
5650 @cindex open coding
5651 @cindex macros, inline alternative
5652
5653 By declaring a function inline, you can direct GCC to make
5654 calls to that function faster. One way GCC can achieve this is to
5655 integrate that function's code into the code for its callers. This
5656 makes execution faster by eliminating the function-call overhead; in
5657 addition, if any of the actual argument values are constant, their
5658 known values may permit simplifications at compile time so that not
5659 all of the inline function's code needs to be included. The effect on
5660 code size is less predictable; object code may be larger or smaller
5661 with function inlining, depending on the particular case. You can
5662 also direct GCC to try to integrate all ``simple enough'' functions
5663 into their callers with the option @option{-finline-functions}.
5664
5665 GCC implements three different semantics of declaring a function
5666 inline. One is available with @option{-std=gnu89} or
5667 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
5668 on all inline declarations, another when
5669 @option{-std=c99}, @option{-std=c11},
5670 @option{-std=gnu99} or @option{-std=gnu11}
5671 (without @option{-fgnu89-inline}), and the third
5672 is used when compiling C++.
5673
5674 To declare a function inline, use the @code{inline} keyword in its
5675 declaration, like this:
5676
5677 @smallexample
5678 static inline int
5679 inc (int *a)
5680 @{
5681 return (*a)++;
5682 @}
5683 @end smallexample
5684
5685 If you are writing a header file to be included in ISO C90 programs, write
5686 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
5687
5688 The three types of inlining behave similarly in two important cases:
5689 when the @code{inline} keyword is used on a @code{static} function,
5690 like the example above, and when a function is first declared without
5691 using the @code{inline} keyword and then is defined with
5692 @code{inline}, like this:
5693
5694 @smallexample
5695 extern int inc (int *a);
5696 inline int
5697 inc (int *a)
5698 @{
5699 return (*a)++;
5700 @}
5701 @end smallexample
5702
5703 In both of these common cases, the program behaves the same as if you
5704 had not used the @code{inline} keyword, except for its speed.
5705
5706 @cindex inline functions, omission of
5707 @opindex fkeep-inline-functions
5708 When a function is both inline and @code{static}, if all calls to the
5709 function are integrated into the caller, and the function's address is
5710 never used, then the function's own assembler code is never referenced.
5711 In this case, GCC does not actually output assembler code for the
5712 function, unless you specify the option @option{-fkeep-inline-functions}.
5713 Some calls cannot be integrated for various reasons (in particular,
5714 calls that precede the function's definition cannot be integrated, and
5715 neither can recursive calls within the definition). If there is a
5716 nonintegrated call, then the function is compiled to assembler code as
5717 usual. The function must also be compiled as usual if the program
5718 refers to its address, because that can't be inlined.
5719
5720 @opindex Winline
5721 Note that certain usages in a function definition can make it unsuitable
5722 for inline substitution. Among these usages are: variadic functions, use of
5723 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
5724 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
5725 and nested functions (@pxref{Nested Functions}). Using @option{-Winline}
5726 warns when a function marked @code{inline} could not be substituted,
5727 and gives the reason for the failure.
5728
5729 @cindex automatic @code{inline} for C++ member fns
5730 @cindex @code{inline} automatic for C++ member fns
5731 @cindex member fns, automatically @code{inline}
5732 @cindex C++ member fns, automatically @code{inline}
5733 @opindex fno-default-inline
5734 As required by ISO C++, GCC considers member functions defined within
5735 the body of a class to be marked inline even if they are
5736 not explicitly declared with the @code{inline} keyword. You can
5737 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
5738 Options,,Options Controlling C++ Dialect}.
5739
5740 GCC does not inline any functions when not optimizing unless you specify
5741 the @samp{always_inline} attribute for the function, like this:
5742
5743 @smallexample
5744 /* @r{Prototype.} */
5745 inline void foo (const char) __attribute__((always_inline));
5746 @end smallexample
5747
5748 The remainder of this section is specific to GNU C90 inlining.
5749
5750 @cindex non-static inline function
5751 When an inline function is not @code{static}, then the compiler must assume
5752 that there may be calls from other source files; since a global symbol can
5753 be defined only once in any program, the function must not be defined in
5754 the other source files, so the calls therein cannot be integrated.
5755 Therefore, a non-@code{static} inline function is always compiled on its
5756 own in the usual fashion.
5757
5758 If you specify both @code{inline} and @code{extern} in the function
5759 definition, then the definition is used only for inlining. In no case
5760 is the function compiled on its own, not even if you refer to its
5761 address explicitly. Such an address becomes an external reference, as
5762 if you had only declared the function, and had not defined it.
5763
5764 This combination of @code{inline} and @code{extern} has almost the
5765 effect of a macro. The way to use it is to put a function definition in
5766 a header file with these keywords, and put another copy of the
5767 definition (lacking @code{inline} and @code{extern}) in a library file.
5768 The definition in the header file causes most calls to the function
5769 to be inlined. If any uses of the function remain, they refer to
5770 the single copy in the library.
5771
5772 @node Volatiles
5773 @section When is a Volatile Object Accessed?
5774 @cindex accessing volatiles
5775 @cindex volatile read
5776 @cindex volatile write
5777 @cindex volatile access
5778
5779 C has the concept of volatile objects. These are normally accessed by
5780 pointers and used for accessing hardware or inter-thread
5781 communication. The standard encourages compilers to refrain from
5782 optimizations concerning accesses to volatile objects, but leaves it
5783 implementation defined as to what constitutes a volatile access. The
5784 minimum requirement is that at a sequence point all previous accesses
5785 to volatile objects have stabilized and no subsequent accesses have
5786 occurred. Thus an implementation is free to reorder and combine
5787 volatile accesses that occur between sequence points, but cannot do
5788 so for accesses across a sequence point. The use of volatile does
5789 not allow you to violate the restriction on updating objects multiple
5790 times between two sequence points.
5791
5792 Accesses to non-volatile objects are not ordered with respect to
5793 volatile accesses. You cannot use a volatile object as a memory
5794 barrier to order a sequence of writes to non-volatile memory. For
5795 instance:
5796
5797 @smallexample
5798 int *ptr = @var{something};
5799 volatile int vobj;
5800 *ptr = @var{something};
5801 vobj = 1;
5802 @end smallexample
5803
5804 @noindent
5805 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
5806 that the write to @var{*ptr} occurs by the time the update
5807 of @var{vobj} happens. If you need this guarantee, you must use
5808 a stronger memory barrier such as:
5809
5810 @smallexample
5811 int *ptr = @var{something};
5812 volatile int vobj;
5813 *ptr = @var{something};
5814 asm volatile ("" : : : "memory");
5815 vobj = 1;
5816 @end smallexample
5817
5818 A scalar volatile object is read when it is accessed in a void context:
5819
5820 @smallexample
5821 volatile int *src = @var{somevalue};
5822 *src;
5823 @end smallexample
5824
5825 Such expressions are rvalues, and GCC implements this as a
5826 read of the volatile object being pointed to.
5827
5828 Assignments are also expressions and have an rvalue. However when
5829 assigning to a scalar volatile, the volatile object is not reread,
5830 regardless of whether the assignment expression's rvalue is used or
5831 not. If the assignment's rvalue is used, the value is that assigned
5832 to the volatile object. For instance, there is no read of @var{vobj}
5833 in all the following cases:
5834
5835 @smallexample
5836 int obj;
5837 volatile int vobj;
5838 vobj = @var{something};
5839 obj = vobj = @var{something};
5840 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
5841 obj = (@var{something}, vobj = @var{anotherthing});
5842 @end smallexample
5843
5844 If you need to read the volatile object after an assignment has
5845 occurred, you must use a separate expression with an intervening
5846 sequence point.
5847
5848 As bit-fields are not individually addressable, volatile bit-fields may
5849 be implicitly read when written to, or when adjacent bit-fields are
5850 accessed. Bit-field operations may be optimized such that adjacent
5851 bit-fields are only partially accessed, if they straddle a storage unit
5852 boundary. For these reasons it is unwise to use volatile bit-fields to
5853 access hardware.
5854
5855 @node Extended Asm
5856 @section Assembler Instructions with C Expression Operands
5857 @cindex extended @code{asm}
5858 @cindex @code{asm} expressions
5859 @cindex assembler instructions
5860 @cindex registers
5861
5862 In an assembler instruction using @code{asm}, you can specify the
5863 operands of the instruction using C expressions. This means you need not
5864 guess which registers or memory locations contain the data you want
5865 to use.
5866
5867 You must specify an assembler instruction template much like what
5868 appears in a machine description, plus an operand constraint string for
5869 each operand.
5870
5871 For example, here is how to use the 68881's @code{fsinx} instruction:
5872
5873 @smallexample
5874 asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
5875 @end smallexample
5876
5877 @noindent
5878 Here @code{angle} is the C expression for the input operand while
5879 @code{result} is that of the output operand. Each has @samp{"f"} as its
5880 operand constraint, saying that a floating-point register is required.
5881 The @samp{=} in @samp{=f} indicates that the operand is an output; all
5882 output operands' constraints must use @samp{=}. The constraints use the
5883 same language used in the machine description (@pxref{Constraints}).
5884
5885 Each operand is described by an operand-constraint string followed by
5886 the C expression in parentheses. A colon separates the assembler
5887 template from the first output operand and another separates the last
5888 output operand from the first input, if any. Commas separate the
5889 operands within each group. The total number of operands is currently
5890 limited to 30; this limitation may be lifted in some future version of
5891 GCC@.
5892
5893 If there are no output operands but there are input operands, you must
5894 place two consecutive colons surrounding the place where the output
5895 operands would go.
5896
5897 As of GCC version 3.1, it is also possible to specify input and output
5898 operands using symbolic names which can be referenced within the
5899 assembler code. These names are specified inside square brackets
5900 preceding the constraint string, and can be referenced inside the
5901 assembler code using @code{%[@var{name}]} instead of a percentage sign
5902 followed by the operand number. Using named operands the above example
5903 could look like:
5904
5905 @smallexample
5906 asm ("fsinx %[angle],%[output]"
5907 : [output] "=f" (result)
5908 : [angle] "f" (angle));
5909 @end smallexample
5910
5911 @noindent
5912 Note that the symbolic operand names have no relation whatsoever to
5913 other C identifiers. You may use any name you like, even those of
5914 existing C symbols, but you must ensure that no two operands within the same
5915 assembler construct use the same symbolic name.
5916
5917 Output operand expressions must be lvalues; the compiler can check this.
5918 The input operands need not be lvalues. The compiler cannot check
5919 whether the operands have data types that are reasonable for the
5920 instruction being executed. It does not parse the assembler instruction
5921 template and does not know what it means or even whether it is valid
5922 assembler input. The extended @code{asm} feature is most often used for
5923 machine instructions the compiler itself does not know exist. If
5924 the output expression cannot be directly addressed (for example, it is a
5925 bit-field), your constraint must allow a register. In that case, GCC
5926 uses the register as the output of the @code{asm}, and then stores
5927 that register into the output.
5928
5929 The ordinary output operands must be write-only; GCC assumes that
5930 the values in these operands before the instruction are dead and need
5931 not be generated. Extended asm supports input-output or read-write
5932 operands. Use the constraint character @samp{+} to indicate such an
5933 operand and list it with the output operands.
5934
5935 You may, as an alternative, logically split its function into two
5936 separate operands, one input operand and one write-only output
5937 operand. The connection between them is expressed by constraints
5938 that say they need to be in the same location when the instruction
5939 executes. You can use the same C expression for both operands, or
5940 different expressions. For example, here we write the (fictitious)
5941 @samp{combine} instruction with @code{bar} as its read-only source
5942 operand and @code{foo} as its read-write destination:
5943
5944 @smallexample
5945 asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar));
5946 @end smallexample
5947
5948 @noindent
5949 The constraint @samp{"0"} for operand 1 says that it must occupy the
5950 same location as operand 0. A number in constraint is allowed only in
5951 an input operand and it must refer to an output operand.
5952
5953 Only a number in the constraint can guarantee that one operand is in
5954 the same place as another. The mere fact that @code{foo} is the value
5955 of both operands is not enough to guarantee that they are in the
5956 same place in the generated assembler code. The following does not
5957 work reliably:
5958
5959 @smallexample
5960 asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar));
5961 @end smallexample
5962
5963 Various optimizations or reloading could cause operands 0 and 1 to be in
5964 different registers; GCC knows no reason not to do so. For example, the
5965 compiler might find a copy of the value of @code{foo} in one register and
5966 use it for operand 1, but generate the output operand 0 in a different
5967 register (copying it afterward to @code{foo}'s own address). Of course,
5968 since the register for operand 1 is not even mentioned in the assembler
5969 code, the result will not work, but GCC can't tell that.
5970
5971 As of GCC version 3.1, one may write @code{[@var{name}]} instead of
5972 the operand number for a matching constraint. For example:
5973
5974 @smallexample
5975 asm ("cmoveq %1,%2,%[result]"
5976 : [result] "=r"(result)
5977 : "r" (test), "r"(new), "[result]"(old));
5978 @end smallexample
5979
5980 Sometimes you need to make an @code{asm} operand be a specific register,
5981 but there's no matching constraint letter for that register @emph{by
5982 itself}. To force the operand into that register, use a local variable
5983 for the operand and specify the register in the variable declaration.
5984 @xref{Explicit Reg Vars}. Then for the @code{asm} operand, use any
5985 register constraint letter that matches the register:
5986
5987 @smallexample
5988 register int *p1 asm ("r0") = @dots{};
5989 register int *p2 asm ("r1") = @dots{};
5990 register int *result asm ("r0");
5991 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
5992 @end smallexample
5993
5994 @anchor{Example of asm with clobbered asm reg}
5995 In the above example, beware that a register that is call-clobbered by
5996 the target ABI will be overwritten by any function call in the
5997 assignment, including library calls for arithmetic operators.
5998 Also a register may be clobbered when generating some operations,
5999 like variable shift, memory copy or memory move on x86.
6000 Assuming it is a call-clobbered register, this may happen to @code{r0}
6001 above by the assignment to @code{p2}. If you have to use such a
6002 register, use temporary variables for expressions between the register
6003 assignment and use:
6004
6005 @smallexample
6006 int t1 = @dots{};
6007 register int *p1 asm ("r0") = @dots{};
6008 register int *p2 asm ("r1") = t1;
6009 register int *result asm ("r0");
6010 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
6011 @end smallexample
6012
6013 Some instructions clobber specific hard registers. To describe this,
6014 write a third colon after the input operands, followed by the names of
6015 the clobbered hard registers (given as strings). Here is a realistic
6016 example for the VAX:
6017
6018 @smallexample
6019 asm volatile ("movc3 %0,%1,%2"
6020 : /* @r{no outputs} */
6021 : "g" (from), "g" (to), "g" (count)
6022 : "r0", "r1", "r2", "r3", "r4", "r5");
6023 @end smallexample
6024
6025 You may not write a clobber description in a way that overlaps with an
6026 input or output operand. For example, you may not have an operand
6027 describing a register class with one member if you mention that register
6028 in the clobber list. Variables declared to live in specific registers
6029 (@pxref{Explicit Reg Vars}), and used as asm input or output operands must
6030 have no part mentioned in the clobber description.
6031 There is no way for you to specify that an input
6032 operand is modified without also specifying it as an output
6033 operand. Note that if all the output operands you specify are for this
6034 purpose (and hence unused), you then also need to specify
6035 @code{volatile} for the @code{asm} construct, as described below, to
6036 prevent GCC from deleting the @code{asm} statement as unused.
6037
6038 If you refer to a particular hardware register from the assembler code,
6039 you probably have to list the register after the third colon to
6040 tell the compiler the register's value is modified. In some assemblers,
6041 the register names begin with @samp{%}; to produce one @samp{%} in the
6042 assembler code, you must write @samp{%%} in the input.
6043
6044 If your assembler instruction can alter the condition code register, add
6045 @samp{cc} to the list of clobbered registers. GCC on some machines
6046 represents the condition codes as a specific hardware register;
6047 @samp{cc} serves to name this register. On other machines, the
6048 condition code is handled differently, and specifying @samp{cc} has no
6049 effect. But it is valid no matter what the machine.
6050
6051 If your assembler instructions access memory in an unpredictable
6052 fashion, add @samp{memory} to the list of clobbered registers. This
6053 causes GCC to not keep memory values cached in registers across the
6054 assembler instruction and not optimize stores or loads to that memory.
6055 You also should add the @code{volatile} keyword if the memory
6056 affected is not listed in the inputs or outputs of the @code{asm}, as
6057 the @samp{memory} clobber does not count as a side-effect of the
6058 @code{asm}. If you know how large the accessed memory is, you can add
6059 it as input or output but if this is not known, you should add
6060 @samp{memory}. As an example, if you access ten bytes of a string, you
6061 can use a memory input like:
6062
6063 @smallexample
6064 @{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}.
6065 @end smallexample
6066
6067 Note that in the following example the memory input is necessary,
6068 otherwise GCC might optimize the store to @code{x} away:
6069 @smallexample
6070 int foo ()
6071 @{
6072 int x = 42;
6073 int *y = &x;
6074 int result;
6075 asm ("magic stuff accessing an 'int' pointed to by '%1'"
6076 : "=&d" (r) : "a" (y), "m" (*y));
6077 return result;
6078 @}
6079 @end smallexample
6080
6081 You can put multiple assembler instructions together in a single
6082 @code{asm} template, separated by the characters normally used in assembly
6083 code for the system. A combination that works in most places is a newline
6084 to break the line, plus a tab character to move to the instruction field
6085 (written as @samp{\n\t}). Sometimes semicolons can be used, if the
6086 assembler allows semicolons as a line-breaking character. Note that some
6087 assembler dialects use semicolons to start a comment.
6088 The input operands are guaranteed not to use any of the clobbered
6089 registers, and neither do the output operands' addresses, so you can
6090 read and write the clobbered registers as many times as you like. Here
6091 is an example of multiple instructions in a template; it assumes the
6092 subroutine @code{_foo} accepts arguments in registers 9 and 10:
6093
6094 @smallexample
6095 asm ("movl %0,r9\n\tmovl %1,r10\n\tcall _foo"
6096 : /* no outputs */
6097 : "g" (from), "g" (to)
6098 : "r9", "r10");
6099 @end smallexample
6100
6101 Unless an output operand has the @samp{&} constraint modifier, GCC
6102 may allocate it in the same register as an unrelated input operand, on
6103 the assumption the inputs are consumed before the outputs are produced.
6104 This assumption may be false if the assembler code actually consists of
6105 more than one instruction. In such a case, use @samp{&} for each output
6106 operand that may not overlap an input. @xref{Modifiers}.
6107
6108 If you want to test the condition code produced by an assembler
6109 instruction, you must include a branch and a label in the @code{asm}
6110 construct, as follows:
6111
6112 @smallexample
6113 asm ("clr %0\n\tfrob %1\n\tbeq 0f\n\tmov #1,%0\n0:"
6114 : "g" (result)
6115 : "g" (input));
6116 @end smallexample
6117
6118 @noindent
6119 This assumes your assembler supports local labels, as the GNU assembler
6120 and most Unix assemblers do.
6121
6122 Speaking of labels, jumps from one @code{asm} to another are not
6123 supported. The compiler's optimizers do not know about these jumps, and
6124 therefore they cannot take account of them when deciding how to
6125 optimize. @xref{Extended asm with goto}.
6126
6127 @cindex macros containing @code{asm}
6128 Usually the most convenient way to use these @code{asm} instructions is to
6129 encapsulate them in macros that look like functions. For example,
6130
6131 @smallexample
6132 #define sin(x) \
6133 (@{ double __value, __arg = (x); \
6134 asm ("fsinx %1,%0": "=f" (__value): "f" (__arg)); \
6135 __value; @})
6136 @end smallexample
6137
6138 @noindent
6139 Here the variable @code{__arg} is used to make sure that the instruction
6140 operates on a proper @code{double} value, and to accept only those
6141 arguments @code{x} that can convert automatically to a @code{double}.
6142
6143 Another way to make sure the instruction operates on the correct data
6144 type is to use a cast in the @code{asm}. This is different from using a
6145 variable @code{__arg} in that it converts more different types. For
6146 example, if the desired type is @code{int}, casting the argument to
6147 @code{int} accepts a pointer with no complaint, while assigning the
6148 argument to an @code{int} variable named @code{__arg} warns about
6149 using a pointer unless the caller explicitly casts it.
6150
6151 If an @code{asm} has output operands, GCC assumes for optimization
6152 purposes the instruction has no side effects except to change the output
6153 operands. This does not mean instructions with a side effect cannot be
6154 used, but you must be careful, because the compiler may eliminate them
6155 if the output operands aren't used, or move them out of loops, or
6156 replace two with one if they constitute a common subexpression. Also,
6157 if your instruction does have a side effect on a variable that otherwise
6158 appears not to change, the old value of the variable may be reused later
6159 if it happens to be found in a register.
6160
6161 You can prevent an @code{asm} instruction from being deleted
6162 by writing the keyword @code{volatile} after
6163 the @code{asm}. For example:
6164
6165 @smallexample
6166 #define get_and_set_priority(new) \
6167 (@{ int __old; \
6168 asm volatile ("get_and_set_priority %0, %1" \
6169 : "=g" (__old) : "g" (new)); \
6170 __old; @})
6171 @end smallexample
6172
6173 @noindent
6174 The @code{volatile} keyword indicates that the instruction has
6175 important side-effects. GCC does not delete a volatile @code{asm} if
6176 it is reachable. (The instruction can still be deleted if GCC can
6177 prove that control flow never reaches the location of the
6178 instruction.) Note that even a volatile @code{asm} instruction
6179 can be moved relative to other code, including across jump
6180 instructions. For example, on many targets there is a system
6181 register that can be set to control the rounding mode of
6182 floating-point operations. You might try
6183 setting it with a volatile @code{asm}, like this PowerPC example:
6184
6185 @smallexample
6186 asm volatile("mtfsf 255,%0" : : "f" (fpenv));
6187 sum = x + y;
6188 @end smallexample
6189
6190 @noindent
6191 This does not work reliably, as the compiler may move the addition back
6192 before the volatile @code{asm}. To make it work you need to add an
6193 artificial dependency to the @code{asm} referencing a variable in the code
6194 you don't want moved, for example:
6195
6196 @smallexample
6197 asm volatile ("mtfsf 255,%1" : "=X"(sum): "f"(fpenv));
6198 sum = x + y;
6199 @end smallexample
6200
6201 Similarly, you can't expect a
6202 sequence of volatile @code{asm} instructions to remain perfectly
6203 consecutive. If you want consecutive output, use a single @code{asm}.
6204 Also, GCC performs some optimizations across a volatile @code{asm}
6205 instruction; GCC does not ``forget everything'' when it encounters
6206 a volatile @code{asm} instruction the way some other compilers do.
6207
6208 An @code{asm} instruction without any output operands is treated
6209 identically to a volatile @code{asm} instruction.
6210
6211 It is a natural idea to look for a way to give access to the condition
6212 code left by the assembler instruction. However, when we attempted to
6213 implement this, we found no way to make it work reliably. The problem
6214 is that output operands might need reloading, which result in
6215 additional following ``store'' instructions. On most machines, these
6216 instructions alter the condition code before there is time to
6217 test it. This problem doesn't arise for ordinary ``test'' and
6218 ``compare'' instructions because they don't have any output operands.
6219
6220 For reasons similar to those described above, it is not possible to give
6221 an assembler instruction access to the condition code left by previous
6222 instructions.
6223
6224 @anchor{Extended asm with goto}
6225 As of GCC version 4.5, @code{asm goto} may be used to have the assembly
6226 jump to one or more C labels. In this form, a fifth section after the
6227 clobber list contains a list of all C labels to which the assembly may jump.
6228 Each label operand is implicitly self-named. The @code{asm} is also assumed
6229 to fall through to the next statement.
6230
6231 This form of @code{asm} is restricted to not have outputs. This is due
6232 to a internal restriction in the compiler that control transfer instructions
6233 cannot have outputs. This restriction on @code{asm goto} may be lifted
6234 in some future version of the compiler. In the meantime, @code{asm goto}
6235 may include a memory clobber, and so leave outputs in memory.
6236
6237 @smallexample
6238 int frob(int x)
6239 @{
6240 int y;
6241 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
6242 : : "r"(x), "r"(&y) : "r5", "memory" : error);
6243 return y;
6244 error:
6245 return -1;
6246 @}
6247 @end smallexample
6248
6249 @noindent
6250 In this (inefficient) example, the @code{frob} instruction sets the
6251 carry bit to indicate an error. The @code{jc} instruction detects
6252 this and branches to the @code{error} label. Finally, the output
6253 of the @code{frob} instruction (@code{%r5}) is stored into the memory
6254 for variable @code{y}, which is later read by the @code{return} statement.
6255
6256 @smallexample
6257 void doit(void)
6258 @{
6259 int i = 0;
6260 asm goto ("mfsr %%r1, 123; jmp %%r1;"
6261 ".pushsection doit_table;"
6262 ".long %l0, %l1, %l2, %l3;"
6263 ".popsection"
6264 : : : "r1" : label1, label2, label3, label4);
6265 __builtin_unreachable ();
6266
6267 label1:
6268 f1();
6269 return;
6270 label2:
6271 f2();
6272 return;
6273 label3:
6274 i = 1;
6275 label4:
6276 f3(i);
6277 @}
6278 @end smallexample
6279
6280 @noindent
6281 In this (also inefficient) example, the @code{mfsr} instruction reads
6282 an address from some out-of-band machine register, and the following
6283 @code{jmp} instruction branches to that address. The address read by
6284 the @code{mfsr} instruction is assumed to have been previously set via
6285 some application-specific mechanism to be one of the four values stored
6286 in the @code{doit_table} section. Finally, the @code{asm} is followed
6287 by a call to @code{__builtin_unreachable} to indicate that the @code{asm}
6288 does not in fact fall through.
6289
6290 @smallexample
6291 #define TRACE1(NUM) \
6292 do @{ \
6293 asm goto ("0: nop;" \
6294 ".pushsection trace_table;" \
6295 ".long 0b, %l0;" \
6296 ".popsection" \
6297 : : : : trace#NUM); \
6298 if (0) @{ trace#NUM: trace(); @} \
6299 @} while (0)
6300 #define TRACE TRACE1(__COUNTER__)
6301 @end smallexample
6302
6303 @noindent
6304 In this example (which in fact inspired the @code{asm goto} feature)
6305 we want on rare occasions to call the @code{trace} function; on other
6306 occasions we'd like to keep the overhead to the absolute minimum.
6307 The normal code path consists of a single @code{nop} instruction.
6308 However, we record the address of this @code{nop} together with the
6309 address of a label that calls the @code{trace} function. This allows
6310 the @code{nop} instruction to be patched at run time to be an
6311 unconditional branch to the stored label. It is assumed that an
6312 optimizing compiler moves the labeled block out of line, to
6313 optimize the fall through path from the @code{asm}.
6314
6315 If you are writing a header file that should be includable in ISO C
6316 programs, write @code{__asm__} instead of @code{asm}. @xref{Alternate
6317 Keywords}.
6318
6319 @subsection Size of an @code{asm}
6320
6321 Some targets require that GCC track the size of each instruction used in
6322 order to generate correct code. Because the final length of an
6323 @code{asm} is only known by the assembler, GCC must make an estimate as
6324 to how big it will be. The estimate is formed by counting the number of
6325 statements in the pattern of the @code{asm} and multiplying that by the
6326 length of the longest instruction on that processor. Statements in the
6327 @code{asm} are identified by newline characters and whatever statement
6328 separator characters are supported by the assembler; on most processors
6329 this is the @samp{;} character.
6330
6331 Normally, GCC's estimate is perfectly adequate to ensure that correct
6332 code is generated, but it is possible to confuse the compiler if you use
6333 pseudo instructions or assembler macros that expand into multiple real
6334 instructions or if you use assembler directives that expand to more
6335 space in the object file than is needed for a single instruction.
6336 If this happens then the assembler produces a diagnostic saying that
6337 a label is unreachable.
6338
6339 @subsection i386 floating-point asm operands
6340
6341 On i386 targets, there are several rules on the usage of stack-like registers
6342 in the operands of an @code{asm}. These rules apply only to the operands
6343 that are stack-like registers:
6344
6345 @enumerate
6346 @item
6347 Given a set of input registers that die in an @code{asm}, it is
6348 necessary to know which are implicitly popped by the @code{asm}, and
6349 which must be explicitly popped by GCC@.
6350
6351 An input register that is implicitly popped by the @code{asm} must be
6352 explicitly clobbered, unless it is constrained to match an
6353 output operand.
6354
6355 @item
6356 For any input register that is implicitly popped by an @code{asm}, it is
6357 necessary to know how to adjust the stack to compensate for the pop.
6358 If any non-popped input is closer to the top of the reg-stack than
6359 the implicitly popped register, it would not be possible to know what the
6360 stack looked like---it's not clear how the rest of the stack ``slides
6361 up''.
6362
6363 All implicitly popped input registers must be closer to the top of
6364 the reg-stack than any input that is not implicitly popped.
6365
6366 It is possible that if an input dies in an @code{asm}, the compiler might
6367 use the input register for an output reload. Consider this example:
6368
6369 @smallexample
6370 asm ("foo" : "=t" (a) : "f" (b));
6371 @end smallexample
6372
6373 @noindent
6374 This code says that input @code{b} is not popped by the @code{asm}, and that
6375 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
6376 deeper after the @code{asm} than it was before. But, it is possible that
6377 reload may think that it can use the same register for both the input and
6378 the output.
6379
6380 To prevent this from happening,
6381 if any input operand uses the @code{f} constraint, all output register
6382 constraints must use the @code{&} early-clobber modifier.
6383
6384 The example above would be correctly written as:
6385
6386 @smallexample
6387 asm ("foo" : "=&t" (a) : "f" (b));
6388 @end smallexample
6389
6390 @item
6391 Some operands need to be in particular places on the stack. All
6392 output operands fall in this category---GCC has no other way to
6393 know which registers the outputs appear in unless you indicate
6394 this in the constraints.
6395
6396 Output operands must specifically indicate which register an output
6397 appears in after an @code{asm}. @code{=f} is not allowed: the operand
6398 constraints must select a class with a single register.
6399
6400 @item
6401 Output operands may not be ``inserted'' between existing stack registers.
6402 Since no 387 opcode uses a read/write operand, all output operands
6403 are dead before the @code{asm}, and are pushed by the @code{asm}.
6404 It makes no sense to push anywhere but the top of the reg-stack.
6405
6406 Output operands must start at the top of the reg-stack: output
6407 operands may not ``skip'' a register.
6408
6409 @item
6410 Some @code{asm} statements may need extra stack space for internal
6411 calculations. This can be guaranteed by clobbering stack registers
6412 unrelated to the inputs and outputs.
6413
6414 @end enumerate
6415
6416 Here are a couple of reasonable @code{asm}s to want to write. This
6417 @code{asm}
6418 takes one input, which is internally popped, and produces two outputs.
6419
6420 @smallexample
6421 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
6422 @end smallexample
6423
6424 @noindent
6425 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
6426 and replaces them with one output. The @code{st(1)} clobber is necessary
6427 for the compiler to know that @code{fyl2xp1} pops both inputs.
6428
6429 @smallexample
6430 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
6431 @end smallexample
6432
6433 @include md.texi
6434
6435 @node Asm Labels
6436 @section Controlling Names Used in Assembler Code
6437 @cindex assembler names for identifiers
6438 @cindex names used in assembler code
6439 @cindex identifiers, names in assembler code
6440
6441 You can specify the name to be used in the assembler code for a C
6442 function or variable by writing the @code{asm} (or @code{__asm__})
6443 keyword after the declarator as follows:
6444
6445 @smallexample
6446 int foo asm ("myfoo") = 2;
6447 @end smallexample
6448
6449 @noindent
6450 This specifies that the name to be used for the variable @code{foo} in
6451 the assembler code should be @samp{myfoo} rather than the usual
6452 @samp{_foo}.
6453
6454 On systems where an underscore is normally prepended to the name of a C
6455 function or variable, this feature allows you to define names for the
6456 linker that do not start with an underscore.
6457
6458 It does not make sense to use this feature with a non-static local
6459 variable since such variables do not have assembler names. If you are
6460 trying to put the variable in a particular register, see @ref{Explicit
6461 Reg Vars}. GCC presently accepts such code with a warning, but will
6462 probably be changed to issue an error, rather than a warning, in the
6463 future.
6464
6465 You cannot use @code{asm} in this way in a function @emph{definition}; but
6466 you can get the same effect by writing a declaration for the function
6467 before its definition and putting @code{asm} there, like this:
6468
6469 @smallexample
6470 extern func () asm ("FUNC");
6471
6472 func (x, y)
6473 int x, y;
6474 /* @r{@dots{}} */
6475 @end smallexample
6476
6477 It is up to you to make sure that the assembler names you choose do not
6478 conflict with any other assembler symbols. Also, you must not use a
6479 register name; that would produce completely invalid assembler code. GCC
6480 does not as yet have the ability to store static variables in registers.
6481 Perhaps that will be added.
6482
6483 @node Explicit Reg Vars
6484 @section Variables in Specified Registers
6485 @cindex explicit register variables
6486 @cindex variables in specified registers
6487 @cindex specified registers
6488 @cindex registers, global allocation
6489
6490 GNU C allows you to put a few global variables into specified hardware
6491 registers. You can also specify the register in which an ordinary
6492 register variable should be allocated.
6493
6494 @itemize @bullet
6495 @item
6496 Global register variables reserve registers throughout the program.
6497 This may be useful in programs such as programming language
6498 interpreters that have a couple of global variables that are accessed
6499 very often.
6500
6501 @item
6502 Local register variables in specific registers do not reserve the
6503 registers, except at the point where they are used as input or output
6504 operands in an @code{asm} statement and the @code{asm} statement itself is
6505 not deleted. The compiler's data flow analysis is capable of determining
6506 where the specified registers contain live values, and where they are
6507 available for other uses. Stores into local register variables may be deleted
6508 when they appear to be dead according to dataflow analysis. References
6509 to local register variables may be deleted or moved or simplified.
6510
6511 These local variables are sometimes convenient for use with the extended
6512 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
6513 output of the assembler instruction directly into a particular register.
6514 (This works provided the register you specify fits the constraints
6515 specified for that operand in the @code{asm}.)
6516 @end itemize
6517
6518 @menu
6519 * Global Reg Vars::
6520 * Local Reg Vars::
6521 @end menu
6522
6523 @node Global Reg Vars
6524 @subsection Defining Global Register Variables
6525 @cindex global register variables
6526 @cindex registers, global variables in
6527
6528 You can define a global register variable in GNU C like this:
6529
6530 @smallexample
6531 register int *foo asm ("a5");
6532 @end smallexample
6533
6534 @noindent
6535 Here @code{a5} is the name of the register that should be used. Choose a
6536 register that is normally saved and restored by function calls on your
6537 machine, so that library routines will not clobber it.
6538
6539 Naturally the register name is cpu-dependent, so you need to
6540 conditionalize your program according to cpu type. The register
6541 @code{a5} is a good choice on a 68000 for a variable of pointer
6542 type. On machines with register windows, be sure to choose a ``global''
6543 register that is not affected magically by the function call mechanism.
6544
6545 In addition, different operating systems on the same CPU may differ in how they
6546 name the registers; then you need additional conditionals. For
6547 example, some 68000 operating systems call this register @code{%a5}.
6548
6549 Eventually there may be a way of asking the compiler to choose a register
6550 automatically, but first we need to figure out how it should choose and
6551 how to enable you to guide the choice. No solution is evident.
6552
6553 Defining a global register variable in a certain register reserves that
6554 register entirely for this use, at least within the current compilation.
6555 The register is not allocated for any other purpose in the functions
6556 in the current compilation, and is not saved and restored by
6557 these functions. Stores into this register are never deleted even if they
6558 appear to be dead, but references may be deleted or moved or
6559 simplified.
6560
6561 It is not safe to access the global register variables from signal
6562 handlers, or from more than one thread of control, because the system
6563 library routines may temporarily use the register for other things (unless
6564 you recompile them specially for the task at hand).
6565
6566 @cindex @code{qsort}, and global register variables
6567 It is not safe for one function that uses a global register variable to
6568 call another such function @code{foo} by way of a third function
6569 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
6570 different source file in which the variable isn't declared). This is
6571 because @code{lose} might save the register and put some other value there.
6572 For example, you can't expect a global register variable to be available in
6573 the comparison-function that you pass to @code{qsort}, since @code{qsort}
6574 might have put something else in that register. (If you are prepared to
6575 recompile @code{qsort} with the same global register variable, you can
6576 solve this problem.)
6577
6578 If you want to recompile @code{qsort} or other source files that do not
6579 actually use your global register variable, so that they do not use that
6580 register for any other purpose, then it suffices to specify the compiler
6581 option @option{-ffixed-@var{reg}}. You need not actually add a global
6582 register declaration to their source code.
6583
6584 A function that can alter the value of a global register variable cannot
6585 safely be called from a function compiled without this variable, because it
6586 could clobber the value the caller expects to find there on return.
6587 Therefore, the function that is the entry point into the part of the
6588 program that uses the global register variable must explicitly save and
6589 restore the value that belongs to its caller.
6590
6591 @cindex register variable after @code{longjmp}
6592 @cindex global register after @code{longjmp}
6593 @cindex value after @code{longjmp}
6594 @findex longjmp
6595 @findex setjmp
6596 On most machines, @code{longjmp} restores to each global register
6597 variable the value it had at the time of the @code{setjmp}. On some
6598 machines, however, @code{longjmp} does not change the value of global
6599 register variables. To be portable, the function that called @code{setjmp}
6600 should make other arrangements to save the values of the global register
6601 variables, and to restore them in a @code{longjmp}. This way, the same
6602 thing happens regardless of what @code{longjmp} does.
6603
6604 All global register variable declarations must precede all function
6605 definitions. If such a declaration could appear after function
6606 definitions, the declaration would be too late to prevent the register from
6607 being used for other purposes in the preceding functions.
6608
6609 Global register variables may not have initial values, because an
6610 executable file has no means to supply initial contents for a register.
6611
6612 On the SPARC, there are reports that g3 @dots{} g7 are suitable
6613 registers, but certain library functions, such as @code{getwd}, as well
6614 as the subroutines for division and remainder, modify g3 and g4. g1 and
6615 g2 are local temporaries.
6616
6617 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
6618 Of course, it does not do to use more than a few of those.
6619
6620 @node Local Reg Vars
6621 @subsection Specifying Registers for Local Variables
6622 @cindex local variables, specifying registers
6623 @cindex specifying registers for local variables
6624 @cindex registers for local variables
6625
6626 You can define a local register variable with a specified register
6627 like this:
6628
6629 @smallexample
6630 register int *foo asm ("a5");
6631 @end smallexample
6632
6633 @noindent
6634 Here @code{a5} is the name of the register that should be used. Note
6635 that this is the same syntax used for defining global register
6636 variables, but for a local variable it appears within a function.
6637
6638 Naturally the register name is cpu-dependent, but this is not a
6639 problem, since specific registers are most often useful with explicit
6640 assembler instructions (@pxref{Extended Asm}). Both of these things
6641 generally require that you conditionalize your program according to
6642 cpu type.
6643
6644 In addition, operating systems on one type of cpu may differ in how they
6645 name the registers; then you need additional conditionals. For
6646 example, some 68000 operating systems call this register @code{%a5}.
6647
6648 Defining such a register variable does not reserve the register; it
6649 remains available for other uses in places where flow control determines
6650 the variable's value is not live.
6651
6652 This option does not guarantee that GCC generates code that has
6653 this variable in the register you specify at all times. You may not
6654 code an explicit reference to this register in the @emph{assembler
6655 instruction template} part of an @code{asm} statement and assume it
6656 always refers to this variable. However, using the variable as an
6657 @code{asm} @emph{operand} guarantees that the specified register is used
6658 for the operand.
6659
6660 Stores into local register variables may be deleted when they appear to be dead
6661 according to dataflow analysis. References to local register variables may
6662 be deleted or moved or simplified.
6663
6664 As for global register variables, it's recommended that you choose a
6665 register that is normally saved and restored by function calls on
6666 your machine, so that library routines will not clobber it. A common
6667 pitfall is to initialize multiple call-clobbered registers with
6668 arbitrary expressions, where a function call or library call for an
6669 arithmetic operator overwrites a register value from a previous
6670 assignment, for example @code{r0} below:
6671 @smallexample
6672 register int *p1 asm ("r0") = @dots{};
6673 register int *p2 asm ("r1") = @dots{};
6674 @end smallexample
6675
6676 @noindent
6677 In those cases, a solution is to use a temporary variable for
6678 each arbitrary expression. @xref{Example of asm with clobbered asm reg}.
6679
6680 @node Alternate Keywords
6681 @section Alternate Keywords
6682 @cindex alternate keywords
6683 @cindex keywords, alternate
6684
6685 @option{-ansi} and the various @option{-std} options disable certain
6686 keywords. This causes trouble when you want to use GNU C extensions, or
6687 a general-purpose header file that should be usable by all programs,
6688 including ISO C programs. The keywords @code{asm}, @code{typeof} and
6689 @code{inline} are not available in programs compiled with
6690 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
6691 program compiled with @option{-std=c99} or @option{-std=c11}). The
6692 ISO C99 keyword
6693 @code{restrict} is only available when @option{-std=gnu99} (which will
6694 eventually be the default) or @option{-std=c99} (or the equivalent
6695 @option{-std=iso9899:1999}), or an option for a later standard
6696 version, is used.
6697
6698 The way to solve these problems is to put @samp{__} at the beginning and
6699 end of each problematical keyword. For example, use @code{__asm__}
6700 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
6701
6702 Other C compilers won't accept these alternative keywords; if you want to
6703 compile with another compiler, you can define the alternate keywords as
6704 macros to replace them with the customary keywords. It looks like this:
6705
6706 @smallexample
6707 #ifndef __GNUC__
6708 #define __asm__ asm
6709 #endif
6710 @end smallexample
6711
6712 @findex __extension__
6713 @opindex pedantic
6714 @option{-pedantic} and other options cause warnings for many GNU C extensions.
6715 You can
6716 prevent such warnings within one expression by writing
6717 @code{__extension__} before the expression. @code{__extension__} has no
6718 effect aside from this.
6719
6720 @node Incomplete Enums
6721 @section Incomplete @code{enum} Types
6722
6723 You can define an @code{enum} tag without specifying its possible values.
6724 This results in an incomplete type, much like what you get if you write
6725 @code{struct foo} without describing the elements. A later declaration
6726 that does specify the possible values completes the type.
6727
6728 You can't allocate variables or storage using the type while it is
6729 incomplete. However, you can work with pointers to that type.
6730
6731 This extension may not be very useful, but it makes the handling of
6732 @code{enum} more consistent with the way @code{struct} and @code{union}
6733 are handled.
6734
6735 This extension is not supported by GNU C++.
6736
6737 @node Function Names
6738 @section Function Names as Strings
6739 @cindex @code{__func__} identifier
6740 @cindex @code{__FUNCTION__} identifier
6741 @cindex @code{__PRETTY_FUNCTION__} identifier
6742
6743 GCC provides three magic variables that hold the name of the current
6744 function, as a string. The first of these is @code{__func__}, which
6745 is part of the C99 standard:
6746
6747 The identifier @code{__func__} is implicitly declared by the translator
6748 as if, immediately following the opening brace of each function
6749 definition, the declaration
6750
6751 @smallexample
6752 static const char __func__[] = "function-name";
6753 @end smallexample
6754
6755 @noindent
6756 appeared, where function-name is the name of the lexically-enclosing
6757 function. This name is the unadorned name of the function.
6758
6759 @code{__FUNCTION__} is another name for @code{__func__}. Older
6760 versions of GCC recognize only this name. However, it is not
6761 standardized. For maximum portability, we recommend you use
6762 @code{__func__}, but provide a fallback definition with the
6763 preprocessor:
6764
6765 @smallexample
6766 #if __STDC_VERSION__ < 199901L
6767 # if __GNUC__ >= 2
6768 # define __func__ __FUNCTION__
6769 # else
6770 # define __func__ "<unknown>"
6771 # endif
6772 #endif
6773 @end smallexample
6774
6775 In C, @code{__PRETTY_FUNCTION__} is yet another name for
6776 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
6777 the type signature of the function as well as its bare name. For
6778 example, this program:
6779
6780 @smallexample
6781 extern "C" @{
6782 extern int printf (char *, ...);
6783 @}
6784
6785 class a @{
6786 public:
6787 void sub (int i)
6788 @{
6789 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
6790 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
6791 @}
6792 @};
6793
6794 int
6795 main (void)
6796 @{
6797 a ax;
6798 ax.sub (0);
6799 return 0;
6800 @}
6801 @end smallexample
6802
6803 @noindent
6804 gives this output:
6805
6806 @smallexample
6807 __FUNCTION__ = sub
6808 __PRETTY_FUNCTION__ = void a::sub(int)
6809 @end smallexample
6810
6811 These identifiers are not preprocessor macros. In GCC 3.3 and
6812 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
6813 were treated as string literals; they could be used to initialize
6814 @code{char} arrays, and they could be concatenated with other string
6815 literals. GCC 3.4 and later treat them as variables, like
6816 @code{__func__}. In C++, @code{__FUNCTION__} and
6817 @code{__PRETTY_FUNCTION__} have always been variables.
6818
6819 @node Return Address
6820 @section Getting the Return or Frame Address of a Function
6821
6822 These functions may be used to get information about the callers of a
6823 function.
6824
6825 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
6826 This function returns the return address of the current function, or of
6827 one of its callers. The @var{level} argument is number of frames to
6828 scan up the call stack. A value of @code{0} yields the return address
6829 of the current function, a value of @code{1} yields the return address
6830 of the caller of the current function, and so forth. When inlining
6831 the expected behavior is that the function returns the address of
6832 the function that is returned to. To work around this behavior use
6833 the @code{noinline} function attribute.
6834
6835 The @var{level} argument must be a constant integer.
6836
6837 On some machines it may be impossible to determine the return address of
6838 any function other than the current one; in such cases, or when the top
6839 of the stack has been reached, this function returns @code{0} or a
6840 random value. In addition, @code{__builtin_frame_address} may be used
6841 to determine if the top of the stack has been reached.
6842
6843 Additional post-processing of the returned value may be needed, see
6844 @code{__builtin_extract_return_addr}.
6845
6846 This function should only be used with a nonzero argument for debugging
6847 purposes.
6848 @end deftypefn
6849
6850 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
6851 The address as returned by @code{__builtin_return_address} may have to be fed
6852 through this function to get the actual encoded address. For example, on the
6853 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
6854 platforms an offset has to be added for the true next instruction to be
6855 executed.
6856
6857 If no fixup is needed, this function simply passes through @var{addr}.
6858 @end deftypefn
6859
6860 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
6861 This function does the reverse of @code{__builtin_extract_return_addr}.
6862 @end deftypefn
6863
6864 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
6865 This function is similar to @code{__builtin_return_address}, but it
6866 returns the address of the function frame rather than the return address
6867 of the function. Calling @code{__builtin_frame_address} with a value of
6868 @code{0} yields the frame address of the current function, a value of
6869 @code{1} yields the frame address of the caller of the current function,
6870 and so forth.
6871
6872 The frame is the area on the stack that holds local variables and saved
6873 registers. The frame address is normally the address of the first word
6874 pushed on to the stack by the function. However, the exact definition
6875 depends upon the processor and the calling convention. If the processor
6876 has a dedicated frame pointer register, and the function has a frame,
6877 then @code{__builtin_frame_address} returns the value of the frame
6878 pointer register.
6879
6880 On some machines it may be impossible to determine the frame address of
6881 any function other than the current one; in such cases, or when the top
6882 of the stack has been reached, this function returns @code{0} if
6883 the first frame pointer is properly initialized by the startup code.
6884
6885 This function should only be used with a nonzero argument for debugging
6886 purposes.
6887 @end deftypefn
6888
6889 @node Vector Extensions
6890 @section Using Vector Instructions through Built-in Functions
6891
6892 On some targets, the instruction set contains SIMD vector instructions which
6893 operate on multiple values contained in one large register at the same time.
6894 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
6895 this way.
6896
6897 The first step in using these extensions is to provide the necessary data
6898 types. This should be done using an appropriate @code{typedef}:
6899
6900 @smallexample
6901 typedef int v4si __attribute__ ((vector_size (16)));
6902 @end smallexample
6903
6904 @noindent
6905 The @code{int} type specifies the base type, while the attribute specifies
6906 the vector size for the variable, measured in bytes. For example, the
6907 declaration above causes the compiler to set the mode for the @code{v4si}
6908 type to be 16 bytes wide and divided into @code{int} sized units. For
6909 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
6910 corresponding mode of @code{foo} is @acronym{V4SI}.
6911
6912 The @code{vector_size} attribute is only applicable to integral and
6913 float scalars, although arrays, pointers, and function return values
6914 are allowed in conjunction with this construct. Only sizes that are
6915 a power of two are currently allowed.
6916
6917 All the basic integer types can be used as base types, both as signed
6918 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
6919 @code{long long}. In addition, @code{float} and @code{double} can be
6920 used to build floating-point vector types.
6921
6922 Specifying a combination that is not valid for the current architecture
6923 causes GCC to synthesize the instructions using a narrower mode.
6924 For example, if you specify a variable of type @code{V4SI} and your
6925 architecture does not allow for this specific SIMD type, GCC
6926 produces code that uses 4 @code{SIs}.
6927
6928 The types defined in this manner can be used with a subset of normal C
6929 operations. Currently, GCC allows using the following operators
6930 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
6931
6932 The operations behave like C++ @code{valarrays}. Addition is defined as
6933 the addition of the corresponding elements of the operands. For
6934 example, in the code below, each of the 4 elements in @var{a} is
6935 added to the corresponding 4 elements in @var{b} and the resulting
6936 vector is stored in @var{c}.
6937
6938 @smallexample
6939 typedef int v4si __attribute__ ((vector_size (16)));
6940
6941 v4si a, b, c;
6942
6943 c = a + b;
6944 @end smallexample
6945
6946 Subtraction, multiplication, division, and the logical operations
6947 operate in a similar manner. Likewise, the result of using the unary
6948 minus or complement operators on a vector type is a vector whose
6949 elements are the negative or complemented values of the corresponding
6950 elements in the operand.
6951
6952 It is possible to use shifting operators @code{<<}, @code{>>} on
6953 integer-type vectors. The operation is defined as following: @code{@{a0,
6954 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
6955 @dots{}, an >> bn@}}@. Vector operands must have the same number of
6956 elements.
6957
6958 For convenience, it is allowed to use a binary vector operation
6959 where one operand is a scalar. In that case the compiler transforms
6960 the scalar operand into a vector where each element is the scalar from
6961 the operation. The transformation happens only if the scalar could be
6962 safely converted to the vector-element type.
6963 Consider the following code.
6964
6965 @smallexample
6966 typedef int v4si __attribute__ ((vector_size (16)));
6967
6968 v4si a, b, c;
6969 long l;
6970
6971 a = b + 1; /* a = b + @{1,1,1,1@}; */
6972 a = 2 * b; /* a = @{2,2,2,2@} * b; */
6973
6974 a = l + a; /* Error, cannot convert long to int. */
6975 @end smallexample
6976
6977 Vectors can be subscripted as if the vector were an array with
6978 the same number of elements and base type. Out of bound accesses
6979 invoke undefined behavior at run time. Warnings for out of bound
6980 accesses for vector subscription can be enabled with
6981 @option{-Warray-bounds}.
6982
6983 Vector comparison is supported with standard comparison
6984 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
6985 vector expressions of integer-type or real-type. Comparison between
6986 integer-type vectors and real-type vectors are not supported. The
6987 result of the comparison is a vector of the same width and number of
6988 elements as the comparison operands with a signed integral element
6989 type.
6990
6991 Vectors are compared element-wise producing 0 when comparison is false
6992 and -1 (constant of the appropriate type where all bits are set)
6993 otherwise. Consider the following example.
6994
6995 @smallexample
6996 typedef int v4si __attribute__ ((vector_size (16)));
6997
6998 v4si a = @{1,2,3,4@};
6999 v4si b = @{3,2,1,4@};
7000 v4si c;
7001
7002 c = a > b; /* The result would be @{0, 0,-1, 0@} */
7003 c = a == b; /* The result would be @{0,-1, 0,-1@} */
7004 @end smallexample
7005
7006 Vector shuffling is available using functions
7007 @code{__builtin_shuffle (vec, mask)} and
7008 @code{__builtin_shuffle (vec0, vec1, mask)}.
7009 Both functions construct a permutation of elements from one or two
7010 vectors and return a vector of the same type as the input vector(s).
7011 The @var{mask} is an integral vector with the same width (@var{W})
7012 and element count (@var{N}) as the output vector.
7013
7014 The elements of the input vectors are numbered in memory ordering of
7015 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
7016 elements of @var{mask} are considered modulo @var{N} in the single-operand
7017 case and modulo @math{2*@var{N}} in the two-operand case.
7018
7019 Consider the following example,
7020
7021 @smallexample
7022 typedef int v4si __attribute__ ((vector_size (16)));
7023
7024 v4si a = @{1,2,3,4@};
7025 v4si b = @{5,6,7,8@};
7026 v4si mask1 = @{0,1,1,3@};
7027 v4si mask2 = @{0,4,2,5@};
7028 v4si res;
7029
7030 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
7031 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
7032 @end smallexample
7033
7034 Note that @code{__builtin_shuffle} is intentionally semantically
7035 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
7036
7037 You can declare variables and use them in function calls and returns, as
7038 well as in assignments and some casts. You can specify a vector type as
7039 a return type for a function. Vector types can also be used as function
7040 arguments. It is possible to cast from one vector type to another,
7041 provided they are of the same size (in fact, you can also cast vectors
7042 to and from other datatypes of the same size).
7043
7044 You cannot operate between vectors of different lengths or different
7045 signedness without a cast.
7046
7047 @node Offsetof
7048 @section Offsetof
7049 @findex __builtin_offsetof
7050
7051 GCC implements for both C and C++ a syntactic extension to implement
7052 the @code{offsetof} macro.
7053
7054 @smallexample
7055 primary:
7056 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
7057
7058 offsetof_member_designator:
7059 @code{identifier}
7060 | offsetof_member_designator "." @code{identifier}
7061 | offsetof_member_designator "[" @code{expr} "]"
7062 @end smallexample
7063
7064 This extension is sufficient such that
7065
7066 @smallexample
7067 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
7068 @end smallexample
7069
7070 @noindent
7071 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
7072 may be dependent. In either case, @var{member} may consist of a single
7073 identifier, or a sequence of member accesses and array references.
7074
7075 @node __sync Builtins
7076 @section Legacy __sync Built-in Functions for Atomic Memory Access
7077
7078 The following built-in functions
7079 are intended to be compatible with those described
7080 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
7081 section 7.4. As such, they depart from the normal GCC practice of using
7082 the @samp{__builtin_} prefix, and further that they are overloaded such that
7083 they work on multiple types.
7084
7085 The definition given in the Intel documentation allows only for the use of
7086 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
7087 counterparts. GCC allows any integral scalar or pointer type that is
7088 1, 2, 4 or 8 bytes in length.
7089
7090 Not all operations are supported by all target processors. If a particular
7091 operation cannot be implemented on the target processor, a warning is
7092 generated and a call an external function is generated. The external
7093 function carries the same name as the built-in version,
7094 with an additional suffix
7095 @samp{_@var{n}} where @var{n} is the size of the data type.
7096
7097 @c ??? Should we have a mechanism to suppress this warning? This is almost
7098 @c useful for implementing the operation under the control of an external
7099 @c mutex.
7100
7101 In most cases, these built-in functions are considered a @dfn{full barrier}.
7102 That is,
7103 no memory operand is moved across the operation, either forward or
7104 backward. Further, instructions are issued as necessary to prevent the
7105 processor from speculating loads across the operation and from queuing stores
7106 after the operation.
7107
7108 All of the routines are described in the Intel documentation to take
7109 ``an optional list of variables protected by the memory barrier''. It's
7110 not clear what is meant by that; it could mean that @emph{only} the
7111 following variables are protected, or it could mean that these variables
7112 should in addition be protected. At present GCC ignores this list and
7113 protects all variables that are globally accessible. If in the future
7114 we make some use of this list, an empty list will continue to mean all
7115 globally accessible variables.
7116
7117 @table @code
7118 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
7119 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
7120 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
7121 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
7122 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
7123 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
7124 @findex __sync_fetch_and_add
7125 @findex __sync_fetch_and_sub
7126 @findex __sync_fetch_and_or
7127 @findex __sync_fetch_and_and
7128 @findex __sync_fetch_and_xor
7129 @findex __sync_fetch_and_nand
7130 These built-in functions perform the operation suggested by the name, and
7131 returns the value that had previously been in memory. That is,
7132
7133 @smallexample
7134 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
7135 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
7136 @end smallexample
7137
7138 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
7139 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
7140
7141 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
7142 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
7143 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
7144 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
7145 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
7146 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
7147 @findex __sync_add_and_fetch
7148 @findex __sync_sub_and_fetch
7149 @findex __sync_or_and_fetch
7150 @findex __sync_and_and_fetch
7151 @findex __sync_xor_and_fetch
7152 @findex __sync_nand_and_fetch
7153 These built-in functions perform the operation suggested by the name, and
7154 return the new value. That is,
7155
7156 @smallexample
7157 @{ *ptr @var{op}= value; return *ptr; @}
7158 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
7159 @end smallexample
7160
7161 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
7162 as @code{*ptr = ~(*ptr & value)} instead of
7163 @code{*ptr = ~*ptr & value}.
7164
7165 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7166 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7167 @findex __sync_bool_compare_and_swap
7168 @findex __sync_val_compare_and_swap
7169 These built-in functions perform an atomic compare and swap.
7170 That is, if the current
7171 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
7172 @code{*@var{ptr}}.
7173
7174 The ``bool'' version returns true if the comparison is successful and
7175 @var{newval} is written. The ``val'' version returns the contents
7176 of @code{*@var{ptr}} before the operation.
7177
7178 @item __sync_synchronize (...)
7179 @findex __sync_synchronize
7180 This built-in function issues a full memory barrier.
7181
7182 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
7183 @findex __sync_lock_test_and_set
7184 This built-in function, as described by Intel, is not a traditional test-and-set
7185 operation, but rather an atomic exchange operation. It writes @var{value}
7186 into @code{*@var{ptr}}, and returns the previous contents of
7187 @code{*@var{ptr}}.
7188
7189 Many targets have only minimal support for such locks, and do not support
7190 a full exchange operation. In this case, a target may support reduced
7191 functionality here by which the @emph{only} valid value to store is the
7192 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
7193 is implementation defined.
7194
7195 This built-in function is not a full barrier,
7196 but rather an @dfn{acquire barrier}.
7197 This means that references after the operation cannot move to (or be
7198 speculated to) before the operation, but previous memory stores may not
7199 be globally visible yet, and previous memory loads may not yet be
7200 satisfied.
7201
7202 @item void __sync_lock_release (@var{type} *ptr, ...)
7203 @findex __sync_lock_release
7204 This built-in function releases the lock acquired by
7205 @code{__sync_lock_test_and_set}.
7206 Normally this means writing the constant 0 to @code{*@var{ptr}}.
7207
7208 This built-in function is not a full barrier,
7209 but rather a @dfn{release barrier}.
7210 This means that all previous memory stores are globally visible, and all
7211 previous memory loads have been satisfied, but following memory reads
7212 are not prevented from being speculated to before the barrier.
7213 @end table
7214
7215 @node __atomic Builtins
7216 @section Built-in functions for memory model aware atomic operations
7217
7218 The following built-in functions approximately match the requirements for
7219 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
7220 functions, but all also have a memory model parameter. These are all
7221 identified by being prefixed with @samp{__atomic}, and most are overloaded
7222 such that they work with multiple types.
7223
7224 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
7225 bytes in length. 16-byte integral types are also allowed if
7226 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
7227
7228 Target architectures are encouraged to provide their own patterns for
7229 each of these built-in functions. If no target is provided, the original
7230 non-memory model set of @samp{__sync} atomic built-in functions are
7231 utilized, along with any required synchronization fences surrounding it in
7232 order to achieve the proper behavior. Execution in this case is subject
7233 to the same restrictions as those built-in functions.
7234
7235 If there is no pattern or mechanism to provide a lock free instruction
7236 sequence, a call is made to an external routine with the same parameters
7237 to be resolved at run time.
7238
7239 The four non-arithmetic functions (load, store, exchange, and
7240 compare_exchange) all have a generic version as well. This generic
7241 version works on any data type. If the data type size maps to one
7242 of the integral sizes that may have lock free support, the generic
7243 version utilizes the lock free built-in function. Otherwise an
7244 external call is left to be resolved at run time. This external call is
7245 the same format with the addition of a @samp{size_t} parameter inserted
7246 as the first parameter indicating the size of the object being pointed to.
7247 All objects must be the same size.
7248
7249 There are 6 different memory models that can be specified. These map
7250 to the same names in the C++11 standard. Refer there or to the
7251 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
7252 atomic synchronization} for more detailed definitions. These memory
7253 models integrate both barriers to code motion as well as synchronization
7254 requirements with other threads. These are listed in approximately
7255 ascending order of strength. It is also possible to use target specific
7256 flags for memory model flags, like Hardware Lock Elision.
7257
7258 @table @code
7259 @item __ATOMIC_RELAXED
7260 No barriers or synchronization.
7261 @item __ATOMIC_CONSUME
7262 Data dependency only for both barrier and synchronization with another
7263 thread.
7264 @item __ATOMIC_ACQUIRE
7265 Barrier to hoisting of code and synchronizes with release (or stronger)
7266 semantic stores from another thread.
7267 @item __ATOMIC_RELEASE
7268 Barrier to sinking of code and synchronizes with acquire (or stronger)
7269 semantic loads from another thread.
7270 @item __ATOMIC_ACQ_REL
7271 Full barrier in both directions and synchronizes with acquire loads and
7272 release stores in another thread.
7273 @item __ATOMIC_SEQ_CST
7274 Full barrier in both directions and synchronizes with acquire loads and
7275 release stores in all threads.
7276 @end table
7277
7278 When implementing patterns for these built-in functions, the memory model
7279 parameter can be ignored as long as the pattern implements the most
7280 restrictive @code{__ATOMIC_SEQ_CST} model. Any of the other memory models
7281 execute correctly with this memory model but they may not execute as
7282 efficiently as they could with a more appropriate implementation of the
7283 relaxed requirements.
7284
7285 Note that the C++11 standard allows for the memory model parameter to be
7286 determined at run time rather than at compile time. These built-in
7287 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
7288 than invoke a runtime library call or inline a switch statement. This is
7289 standard compliant, safe, and the simplest approach for now.
7290
7291 The memory model parameter is a signed int, but only the lower 8 bits are
7292 reserved for the memory model. The remainder of the signed int is reserved
7293 for future use and should be 0. Use of the predefined atomic values
7294 ensures proper usage.
7295
7296 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
7297 This built-in function implements an atomic load operation. It returns the
7298 contents of @code{*@var{ptr}}.
7299
7300 The valid memory model variants are
7301 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
7302 and @code{__ATOMIC_CONSUME}.
7303
7304 @end deftypefn
7305
7306 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
7307 This is the generic version of an atomic load. It returns the
7308 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
7309
7310 @end deftypefn
7311
7312 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
7313 This built-in function implements an atomic store operation. It writes
7314 @code{@var{val}} into @code{*@var{ptr}}.
7315
7316 The valid memory model variants are
7317 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
7318
7319 @end deftypefn
7320
7321 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
7322 This is the generic version of an atomic store. It stores the value
7323 of @code{*@var{val}} into @code{*@var{ptr}}.
7324
7325 @end deftypefn
7326
7327 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
7328 This built-in function implements an atomic exchange operation. It writes
7329 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
7330 @code{*@var{ptr}}.
7331
7332 The valid memory model variants are
7333 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
7334 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
7335
7336 @end deftypefn
7337
7338 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
7339 This is the generic version of an atomic exchange. It stores the
7340 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
7341 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
7342
7343 @end deftypefn
7344
7345 @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)
7346 This built-in function implements an atomic compare and exchange operation.
7347 This compares the contents of @code{*@var{ptr}} with the contents of
7348 @code{*@var{expected}} and if equal, writes @var{desired} into
7349 @code{*@var{ptr}}. If they are not equal, the current contents of
7350 @code{*@var{ptr}} is written into @code{*@var{expected}}. @var{weak} is true
7351 for weak compare_exchange, and false for the strong variation. Many targets
7352 only offer the strong variation and ignore the parameter. When in doubt, use
7353 the strong variation.
7354
7355 True is returned if @var{desired} is written into
7356 @code{*@var{ptr}} and the execution is considered to conform to the
7357 memory model specified by @var{success_memmodel}. There are no
7358 restrictions on what memory model can be used here.
7359
7360 False is returned otherwise, and the execution is considered to conform
7361 to @var{failure_memmodel}. This memory model cannot be
7362 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
7363 stronger model than that specified by @var{success_memmodel}.
7364
7365 @end deftypefn
7366
7367 @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)
7368 This built-in function implements the generic version of
7369 @code{__atomic_compare_exchange}. The function is virtually identical to
7370 @code{__atomic_compare_exchange_n}, except the desired value is also a
7371 pointer.
7372
7373 @end deftypefn
7374
7375 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7376 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7377 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7378 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7379 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7380 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7381 These built-in functions perform the operation suggested by the name, and
7382 return the result of the operation. That is,
7383
7384 @smallexample
7385 @{ *ptr @var{op}= val; return *ptr; @}
7386 @end smallexample
7387
7388 All memory models are valid.
7389
7390 @end deftypefn
7391
7392 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
7393 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
7394 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
7395 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
7396 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
7397 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
7398 These built-in functions perform the operation suggested by the name, and
7399 return the value that had previously been in @code{*@var{ptr}}. That is,
7400
7401 @smallexample
7402 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
7403 @end smallexample
7404
7405 All memory models are valid.
7406
7407 @end deftypefn
7408
7409 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
7410
7411 This built-in function performs an atomic test-and-set operation on
7412 the byte at @code{*@var{ptr}}. The byte is set to some implementation
7413 defined nonzero ``set'' value and the return value is @code{true} if and only
7414 if the previous contents were ``set''.
7415
7416 All memory models are valid.
7417
7418 @end deftypefn
7419
7420 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
7421
7422 This built-in function performs an atomic clear operation on
7423 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
7424
7425 The valid memory model variants are
7426 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
7427 @code{__ATOMIC_RELEASE}.
7428
7429 @end deftypefn
7430
7431 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
7432
7433 This built-in function acts as a synchronization fence between threads
7434 based on the specified memory model.
7435
7436 All memory orders are valid.
7437
7438 @end deftypefn
7439
7440 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
7441
7442 This built-in function acts as a synchronization fence between a thread
7443 and signal handlers based in the same thread.
7444
7445 All memory orders are valid.
7446
7447 @end deftypefn
7448
7449 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
7450
7451 This built-in function returns true if objects of @var{size} bytes always
7452 generate lock free atomic instructions for the target architecture.
7453 @var{size} must resolve to a compile-time constant and the result also
7454 resolves to a compile-time constant.
7455
7456 @var{ptr} is an optional pointer to the object that may be used to determine
7457 alignment. A value of 0 indicates typical alignment should be used. The
7458 compiler may also ignore this parameter.
7459
7460 @smallexample
7461 if (_atomic_always_lock_free (sizeof (long long), 0))
7462 @end smallexample
7463
7464 @end deftypefn
7465
7466 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
7467
7468 This built-in function returns true if objects of @var{size} bytes always
7469 generate lock free atomic instructions for the target architecture. If
7470 it is not known to be lock free a call is made to a runtime routine named
7471 @code{__atomic_is_lock_free}.
7472
7473 @var{ptr} is an optional pointer to the object that may be used to determine
7474 alignment. A value of 0 indicates typical alignment should be used. The
7475 compiler may also ignore this parameter.
7476 @end deftypefn
7477
7478 @node x86 specific memory model extensions for transactional memory
7479 @section x86 specific memory model extensions for transactional memory
7480
7481 The i386 architecture supports additional memory ordering flags
7482 to mark lock critical sections for hardware lock elision.
7483 These must be specified in addition to an existing memory model to
7484 atomic intrinsics.
7485
7486 @table @code
7487 @item __ATOMIC_HLE_ACQUIRE
7488 Start lock elision on a lock variable.
7489 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
7490 @item __ATOMIC_HLE_RELEASE
7491 End lock elision on a lock variable.
7492 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
7493 @end table
7494
7495 When a lock acquire fails it's required for good performance to abort
7496 the transaction quickly. This can be done with a @code{_mm_pause}
7497
7498 @smallexample
7499 #include <immintrin.h> // For _mm_pause
7500
7501 /* Acquire lock with lock elision */
7502 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
7503 _mm_pause(); /* Abort failed transaction */
7504 ...
7505 /* Free lock with lock elision */
7506 __atomic_clear(&lockvar, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
7507 @end smallexample
7508
7509 @node Object Size Checking
7510 @section Object Size Checking Built-in Functions
7511 @findex __builtin_object_size
7512 @findex __builtin___memcpy_chk
7513 @findex __builtin___mempcpy_chk
7514 @findex __builtin___memmove_chk
7515 @findex __builtin___memset_chk
7516 @findex __builtin___strcpy_chk
7517 @findex __builtin___stpcpy_chk
7518 @findex __builtin___strncpy_chk
7519 @findex __builtin___strcat_chk
7520 @findex __builtin___strncat_chk
7521 @findex __builtin___sprintf_chk
7522 @findex __builtin___snprintf_chk
7523 @findex __builtin___vsprintf_chk
7524 @findex __builtin___vsnprintf_chk
7525 @findex __builtin___printf_chk
7526 @findex __builtin___vprintf_chk
7527 @findex __builtin___fprintf_chk
7528 @findex __builtin___vfprintf_chk
7529
7530 GCC implements a limited buffer overflow protection mechanism
7531 that can prevent some buffer overflow attacks.
7532
7533 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
7534 is a built-in construct that returns a constant number of bytes from
7535 @var{ptr} to the end of the object @var{ptr} pointer points to
7536 (if known at compile time). @code{__builtin_object_size} never evaluates
7537 its arguments for side-effects. If there are any side-effects in them, it
7538 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
7539 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
7540 point to and all of them are known at compile time, the returned number
7541 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
7542 0 and minimum if nonzero. If it is not possible to determine which objects
7543 @var{ptr} points to at compile time, @code{__builtin_object_size} should
7544 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
7545 for @var{type} 2 or 3.
7546
7547 @var{type} is an integer constant from 0 to 3. If the least significant
7548 bit is clear, objects are whole variables, if it is set, a closest
7549 surrounding subobject is considered the object a pointer points to.
7550 The second bit determines if maximum or minimum of remaining bytes
7551 is computed.
7552
7553 @smallexample
7554 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
7555 char *p = &var.buf1[1], *q = &var.b;
7556
7557 /* Here the object p points to is var. */
7558 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
7559 /* The subobject p points to is var.buf1. */
7560 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
7561 /* The object q points to is var. */
7562 assert (__builtin_object_size (q, 0)
7563 == (char *) (&var + 1) - (char *) &var.b);
7564 /* The subobject q points to is var.b. */
7565 assert (__builtin_object_size (q, 1) == sizeof (var.b));
7566 @end smallexample
7567 @end deftypefn
7568
7569 There are built-in functions added for many common string operation
7570 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
7571 built-in is provided. This built-in has an additional last argument,
7572 which is the number of bytes remaining in object the @var{dest}
7573 argument points to or @code{(size_t) -1} if the size is not known.
7574
7575 The built-in functions are optimized into the normal string functions
7576 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
7577 it is known at compile time that the destination object will not
7578 be overflown. If the compiler can determine at compile time the
7579 object will be always overflown, it issues a warning.
7580
7581 The intended use can be e.g.@:
7582
7583 @smallexample
7584 #undef memcpy
7585 #define bos0(dest) __builtin_object_size (dest, 0)
7586 #define memcpy(dest, src, n) \
7587 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
7588
7589 char *volatile p;
7590 char buf[10];
7591 /* It is unknown what object p points to, so this is optimized
7592 into plain memcpy - no checking is possible. */
7593 memcpy (p, "abcde", n);
7594 /* Destination is known and length too. It is known at compile
7595 time there will be no overflow. */
7596 memcpy (&buf[5], "abcde", 5);
7597 /* Destination is known, but the length is not known at compile time.
7598 This will result in __memcpy_chk call that can check for overflow
7599 at run time. */
7600 memcpy (&buf[5], "abcde", n);
7601 /* Destination is known and it is known at compile time there will
7602 be overflow. There will be a warning and __memcpy_chk call that
7603 will abort the program at run time. */
7604 memcpy (&buf[6], "abcde", 5);
7605 @end smallexample
7606
7607 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
7608 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
7609 @code{strcat} and @code{strncat}.
7610
7611 There are also checking built-in functions for formatted output functions.
7612 @smallexample
7613 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
7614 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
7615 const char *fmt, ...);
7616 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
7617 va_list ap);
7618 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
7619 const char *fmt, va_list ap);
7620 @end smallexample
7621
7622 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
7623 etc.@: functions and can contain implementation specific flags on what
7624 additional security measures the checking function might take, such as
7625 handling @code{%n} differently.
7626
7627 The @var{os} argument is the object size @var{s} points to, like in the
7628 other built-in functions. There is a small difference in the behavior
7629 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
7630 optimized into the non-checking functions only if @var{flag} is 0, otherwise
7631 the checking function is called with @var{os} argument set to
7632 @code{(size_t) -1}.
7633
7634 In addition to this, there are checking built-in functions
7635 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
7636 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
7637 These have just one additional argument, @var{flag}, right before
7638 format string @var{fmt}. If the compiler is able to optimize them to
7639 @code{fputc} etc.@: functions, it does, otherwise the checking function
7640 is called and the @var{flag} argument passed to it.
7641
7642 @node Other Builtins
7643 @section Other Built-in Functions Provided by GCC
7644 @cindex built-in functions
7645 @findex __builtin_fpclassify
7646 @findex __builtin_isfinite
7647 @findex __builtin_isnormal
7648 @findex __builtin_isgreater
7649 @findex __builtin_isgreaterequal
7650 @findex __builtin_isinf_sign
7651 @findex __builtin_isless
7652 @findex __builtin_islessequal
7653 @findex __builtin_islessgreater
7654 @findex __builtin_isunordered
7655 @findex __builtin_powi
7656 @findex __builtin_powif
7657 @findex __builtin_powil
7658 @findex _Exit
7659 @findex _exit
7660 @findex abort
7661 @findex abs
7662 @findex acos
7663 @findex acosf
7664 @findex acosh
7665 @findex acoshf
7666 @findex acoshl
7667 @findex acosl
7668 @findex alloca
7669 @findex asin
7670 @findex asinf
7671 @findex asinh
7672 @findex asinhf
7673 @findex asinhl
7674 @findex asinl
7675 @findex atan
7676 @findex atan2
7677 @findex atan2f
7678 @findex atan2l
7679 @findex atanf
7680 @findex atanh
7681 @findex atanhf
7682 @findex atanhl
7683 @findex atanl
7684 @findex bcmp
7685 @findex bzero
7686 @findex cabs
7687 @findex cabsf
7688 @findex cabsl
7689 @findex cacos
7690 @findex cacosf
7691 @findex cacosh
7692 @findex cacoshf
7693 @findex cacoshl
7694 @findex cacosl
7695 @findex calloc
7696 @findex carg
7697 @findex cargf
7698 @findex cargl
7699 @findex casin
7700 @findex casinf
7701 @findex casinh
7702 @findex casinhf
7703 @findex casinhl
7704 @findex casinl
7705 @findex catan
7706 @findex catanf
7707 @findex catanh
7708 @findex catanhf
7709 @findex catanhl
7710 @findex catanl
7711 @findex cbrt
7712 @findex cbrtf
7713 @findex cbrtl
7714 @findex ccos
7715 @findex ccosf
7716 @findex ccosh
7717 @findex ccoshf
7718 @findex ccoshl
7719 @findex ccosl
7720 @findex ceil
7721 @findex ceilf
7722 @findex ceill
7723 @findex cexp
7724 @findex cexpf
7725 @findex cexpl
7726 @findex cimag
7727 @findex cimagf
7728 @findex cimagl
7729 @findex clog
7730 @findex clogf
7731 @findex clogl
7732 @findex conj
7733 @findex conjf
7734 @findex conjl
7735 @findex copysign
7736 @findex copysignf
7737 @findex copysignl
7738 @findex cos
7739 @findex cosf
7740 @findex cosh
7741 @findex coshf
7742 @findex coshl
7743 @findex cosl
7744 @findex cpow
7745 @findex cpowf
7746 @findex cpowl
7747 @findex cproj
7748 @findex cprojf
7749 @findex cprojl
7750 @findex creal
7751 @findex crealf
7752 @findex creall
7753 @findex csin
7754 @findex csinf
7755 @findex csinh
7756 @findex csinhf
7757 @findex csinhl
7758 @findex csinl
7759 @findex csqrt
7760 @findex csqrtf
7761 @findex csqrtl
7762 @findex ctan
7763 @findex ctanf
7764 @findex ctanh
7765 @findex ctanhf
7766 @findex ctanhl
7767 @findex ctanl
7768 @findex dcgettext
7769 @findex dgettext
7770 @findex drem
7771 @findex dremf
7772 @findex dreml
7773 @findex erf
7774 @findex erfc
7775 @findex erfcf
7776 @findex erfcl
7777 @findex erff
7778 @findex erfl
7779 @findex exit
7780 @findex exp
7781 @findex exp10
7782 @findex exp10f
7783 @findex exp10l
7784 @findex exp2
7785 @findex exp2f
7786 @findex exp2l
7787 @findex expf
7788 @findex expl
7789 @findex expm1
7790 @findex expm1f
7791 @findex expm1l
7792 @findex fabs
7793 @findex fabsf
7794 @findex fabsl
7795 @findex fdim
7796 @findex fdimf
7797 @findex fdiml
7798 @findex ffs
7799 @findex floor
7800 @findex floorf
7801 @findex floorl
7802 @findex fma
7803 @findex fmaf
7804 @findex fmal
7805 @findex fmax
7806 @findex fmaxf
7807 @findex fmaxl
7808 @findex fmin
7809 @findex fminf
7810 @findex fminl
7811 @findex fmod
7812 @findex fmodf
7813 @findex fmodl
7814 @findex fprintf
7815 @findex fprintf_unlocked
7816 @findex fputs
7817 @findex fputs_unlocked
7818 @findex frexp
7819 @findex frexpf
7820 @findex frexpl
7821 @findex fscanf
7822 @findex gamma
7823 @findex gammaf
7824 @findex gammal
7825 @findex gamma_r
7826 @findex gammaf_r
7827 @findex gammal_r
7828 @findex gettext
7829 @findex hypot
7830 @findex hypotf
7831 @findex hypotl
7832 @findex ilogb
7833 @findex ilogbf
7834 @findex ilogbl
7835 @findex imaxabs
7836 @findex index
7837 @findex isalnum
7838 @findex isalpha
7839 @findex isascii
7840 @findex isblank
7841 @findex iscntrl
7842 @findex isdigit
7843 @findex isgraph
7844 @findex islower
7845 @findex isprint
7846 @findex ispunct
7847 @findex isspace
7848 @findex isupper
7849 @findex iswalnum
7850 @findex iswalpha
7851 @findex iswblank
7852 @findex iswcntrl
7853 @findex iswdigit
7854 @findex iswgraph
7855 @findex iswlower
7856 @findex iswprint
7857 @findex iswpunct
7858 @findex iswspace
7859 @findex iswupper
7860 @findex iswxdigit
7861 @findex isxdigit
7862 @findex j0
7863 @findex j0f
7864 @findex j0l
7865 @findex j1
7866 @findex j1f
7867 @findex j1l
7868 @findex jn
7869 @findex jnf
7870 @findex jnl
7871 @findex labs
7872 @findex ldexp
7873 @findex ldexpf
7874 @findex ldexpl
7875 @findex lgamma
7876 @findex lgammaf
7877 @findex lgammal
7878 @findex lgamma_r
7879 @findex lgammaf_r
7880 @findex lgammal_r
7881 @findex llabs
7882 @findex llrint
7883 @findex llrintf
7884 @findex llrintl
7885 @findex llround
7886 @findex llroundf
7887 @findex llroundl
7888 @findex log
7889 @findex log10
7890 @findex log10f
7891 @findex log10l
7892 @findex log1p
7893 @findex log1pf
7894 @findex log1pl
7895 @findex log2
7896 @findex log2f
7897 @findex log2l
7898 @findex logb
7899 @findex logbf
7900 @findex logbl
7901 @findex logf
7902 @findex logl
7903 @findex lrint
7904 @findex lrintf
7905 @findex lrintl
7906 @findex lround
7907 @findex lroundf
7908 @findex lroundl
7909 @findex malloc
7910 @findex memchr
7911 @findex memcmp
7912 @findex memcpy
7913 @findex mempcpy
7914 @findex memset
7915 @findex modf
7916 @findex modff
7917 @findex modfl
7918 @findex nearbyint
7919 @findex nearbyintf
7920 @findex nearbyintl
7921 @findex nextafter
7922 @findex nextafterf
7923 @findex nextafterl
7924 @findex nexttoward
7925 @findex nexttowardf
7926 @findex nexttowardl
7927 @findex pow
7928 @findex pow10
7929 @findex pow10f
7930 @findex pow10l
7931 @findex powf
7932 @findex powl
7933 @findex printf
7934 @findex printf_unlocked
7935 @findex putchar
7936 @findex puts
7937 @findex remainder
7938 @findex remainderf
7939 @findex remainderl
7940 @findex remquo
7941 @findex remquof
7942 @findex remquol
7943 @findex rindex
7944 @findex rint
7945 @findex rintf
7946 @findex rintl
7947 @findex round
7948 @findex roundf
7949 @findex roundl
7950 @findex scalb
7951 @findex scalbf
7952 @findex scalbl
7953 @findex scalbln
7954 @findex scalblnf
7955 @findex scalblnf
7956 @findex scalbn
7957 @findex scalbnf
7958 @findex scanfnl
7959 @findex signbit
7960 @findex signbitf
7961 @findex signbitl
7962 @findex signbitd32
7963 @findex signbitd64
7964 @findex signbitd128
7965 @findex significand
7966 @findex significandf
7967 @findex significandl
7968 @findex sin
7969 @findex sincos
7970 @findex sincosf
7971 @findex sincosl
7972 @findex sinf
7973 @findex sinh
7974 @findex sinhf
7975 @findex sinhl
7976 @findex sinl
7977 @findex snprintf
7978 @findex sprintf
7979 @findex sqrt
7980 @findex sqrtf
7981 @findex sqrtl
7982 @findex sscanf
7983 @findex stpcpy
7984 @findex stpncpy
7985 @findex strcasecmp
7986 @findex strcat
7987 @findex strchr
7988 @findex strcmp
7989 @findex strcpy
7990 @findex strcspn
7991 @findex strdup
7992 @findex strfmon
7993 @findex strftime
7994 @findex strlen
7995 @findex strncasecmp
7996 @findex strncat
7997 @findex strncmp
7998 @findex strncpy
7999 @findex strndup
8000 @findex strpbrk
8001 @findex strrchr
8002 @findex strspn
8003 @findex strstr
8004 @findex tan
8005 @findex tanf
8006 @findex tanh
8007 @findex tanhf
8008 @findex tanhl
8009 @findex tanl
8010 @findex tgamma
8011 @findex tgammaf
8012 @findex tgammal
8013 @findex toascii
8014 @findex tolower
8015 @findex toupper
8016 @findex towlower
8017 @findex towupper
8018 @findex trunc
8019 @findex truncf
8020 @findex truncl
8021 @findex vfprintf
8022 @findex vfscanf
8023 @findex vprintf
8024 @findex vscanf
8025 @findex vsnprintf
8026 @findex vsprintf
8027 @findex vsscanf
8028 @findex y0
8029 @findex y0f
8030 @findex y0l
8031 @findex y1
8032 @findex y1f
8033 @findex y1l
8034 @findex yn
8035 @findex ynf
8036 @findex ynl
8037
8038 GCC provides a large number of built-in functions other than the ones
8039 mentioned above. Some of these are for internal use in the processing
8040 of exceptions or variable-length argument lists and are not
8041 documented here because they may change from time to time; we do not
8042 recommend general use of these functions.
8043
8044 The remaining functions are provided for optimization purposes.
8045
8046 @opindex fno-builtin
8047 GCC includes built-in versions of many of the functions in the standard
8048 C library. The versions prefixed with @code{__builtin_} are always
8049 treated as having the same meaning as the C library function even if you
8050 specify the @option{-fno-builtin} option. (@pxref{C Dialect Options})
8051 Many of these functions are only optimized in certain cases; if they are
8052 not optimized in a particular case, a call to the library function is
8053 emitted.
8054
8055 @opindex ansi
8056 @opindex std
8057 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
8058 @option{-std=c99} or @option{-std=c11}), the functions
8059 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
8060 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
8061 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
8062 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
8063 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
8064 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
8065 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
8066 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
8067 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
8068 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
8069 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
8070 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
8071 @code{signbitd64}, @code{signbitd128}, @code{significandf},
8072 @code{significandl}, @code{significand}, @code{sincosf},
8073 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
8074 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
8075 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
8076 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
8077 @code{yn}
8078 may be handled as built-in functions.
8079 All these functions have corresponding versions
8080 prefixed with @code{__builtin_}, which may be used even in strict C90
8081 mode.
8082
8083 The ISO C99 functions
8084 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
8085 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
8086 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
8087 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
8088 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
8089 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
8090 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
8091 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
8092 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
8093 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
8094 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
8095 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
8096 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
8097 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
8098 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
8099 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
8100 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
8101 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
8102 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
8103 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
8104 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
8105 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
8106 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
8107 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
8108 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
8109 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
8110 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
8111 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
8112 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
8113 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
8114 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
8115 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
8116 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
8117 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
8118 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
8119 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
8120 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
8121 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
8122 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
8123 are handled as built-in functions
8124 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8125
8126 There are also built-in versions of the ISO C99 functions
8127 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
8128 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
8129 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
8130 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
8131 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
8132 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
8133 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
8134 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
8135 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
8136 that are recognized in any mode since ISO C90 reserves these names for
8137 the purpose to which ISO C99 puts them. All these functions have
8138 corresponding versions prefixed with @code{__builtin_}.
8139
8140 The ISO C94 functions
8141 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
8142 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
8143 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
8144 @code{towupper}
8145 are handled as built-in functions
8146 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8147
8148 The ISO C90 functions
8149 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
8150 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
8151 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
8152 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
8153 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
8154 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
8155 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
8156 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
8157 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
8158 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
8159 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
8160 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
8161 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
8162 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
8163 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
8164 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
8165 are all recognized as built-in functions unless
8166 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
8167 is specified for an individual function). All of these functions have
8168 corresponding versions prefixed with @code{__builtin_}.
8169
8170 GCC provides built-in versions of the ISO C99 floating-point comparison
8171 macros that avoid raising exceptions for unordered operands. They have
8172 the same names as the standard macros ( @code{isgreater},
8173 @code{isgreaterequal}, @code{isless}, @code{islessequal},
8174 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
8175 prefixed. We intend for a library implementor to be able to simply
8176 @code{#define} each standard macro to its built-in equivalent.
8177 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
8178 @code{isinf_sign} and @code{isnormal} built-ins used with
8179 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
8180 built-in functions appear both with and without the @code{__builtin_} prefix.
8181
8182 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
8183
8184 You can use the built-in function @code{__builtin_types_compatible_p} to
8185 determine whether two types are the same.
8186
8187 This built-in function returns 1 if the unqualified versions of the
8188 types @var{type1} and @var{type2} (which are types, not expressions) are
8189 compatible, 0 otherwise. The result of this built-in function can be
8190 used in integer constant expressions.
8191
8192 This built-in function ignores top level qualifiers (e.g., @code{const},
8193 @code{volatile}). For example, @code{int} is equivalent to @code{const
8194 int}.
8195
8196 The type @code{int[]} and @code{int[5]} are compatible. On the other
8197 hand, @code{int} and @code{char *} are not compatible, even if the size
8198 of their types, on the particular architecture are the same. Also, the
8199 amount of pointer indirection is taken into account when determining
8200 similarity. Consequently, @code{short *} is not similar to
8201 @code{short **}. Furthermore, two types that are typedefed are
8202 considered compatible if their underlying types are compatible.
8203
8204 An @code{enum} type is not considered to be compatible with another
8205 @code{enum} type even if both are compatible with the same integer
8206 type; this is what the C standard specifies.
8207 For example, @code{enum @{foo, bar@}} is not similar to
8208 @code{enum @{hot, dog@}}.
8209
8210 You typically use this function in code whose execution varies
8211 depending on the arguments' types. For example:
8212
8213 @smallexample
8214 #define foo(x) \
8215 (@{ \
8216 typeof (x) tmp = (x); \
8217 if (__builtin_types_compatible_p (typeof (x), long double)) \
8218 tmp = foo_long_double (tmp); \
8219 else if (__builtin_types_compatible_p (typeof (x), double)) \
8220 tmp = foo_double (tmp); \
8221 else if (__builtin_types_compatible_p (typeof (x), float)) \
8222 tmp = foo_float (tmp); \
8223 else \
8224 abort (); \
8225 tmp; \
8226 @})
8227 @end smallexample
8228
8229 @emph{Note:} This construct is only available for C@.
8230
8231 @end deftypefn
8232
8233 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
8234
8235 You can use the built-in function @code{__builtin_choose_expr} to
8236 evaluate code depending on the value of a constant expression. This
8237 built-in function returns @var{exp1} if @var{const_exp}, which is an
8238 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
8239
8240 This built-in function is analogous to the @samp{? :} operator in C,
8241 except that the expression returned has its type unaltered by promotion
8242 rules. Also, the built-in function does not evaluate the expression
8243 that is not chosen. For example, if @var{const_exp} evaluates to true,
8244 @var{exp2} is not evaluated even if it has side-effects.
8245
8246 This built-in function can return an lvalue if the chosen argument is an
8247 lvalue.
8248
8249 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
8250 type. Similarly, if @var{exp2} is returned, its return type is the same
8251 as @var{exp2}.
8252
8253 Example:
8254
8255 @smallexample
8256 #define foo(x) \
8257 __builtin_choose_expr ( \
8258 __builtin_types_compatible_p (typeof (x), double), \
8259 foo_double (x), \
8260 __builtin_choose_expr ( \
8261 __builtin_types_compatible_p (typeof (x), float), \
8262 foo_float (x), \
8263 /* @r{The void expression results in a compile-time error} \
8264 @r{when assigning the result to something.} */ \
8265 (void)0))
8266 @end smallexample
8267
8268 @emph{Note:} This construct is only available for C@. Furthermore, the
8269 unused expression (@var{exp1} or @var{exp2} depending on the value of
8270 @var{const_exp}) may still generate syntax errors. This may change in
8271 future revisions.
8272
8273 @end deftypefn
8274
8275 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
8276
8277 The built-in function @code{__builtin_complex} is provided for use in
8278 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
8279 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
8280 real binary floating-point type, and the result has the corresponding
8281 complex type with real and imaginary parts @var{real} and @var{imag}.
8282 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
8283 infinities, NaNs and negative zeros are involved.
8284
8285 @end deftypefn
8286
8287 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
8288 You can use the built-in function @code{__builtin_constant_p} to
8289 determine if a value is known to be constant at compile time and hence
8290 that GCC can perform constant-folding on expressions involving that
8291 value. The argument of the function is the value to test. The function
8292 returns the integer 1 if the argument is known to be a compile-time
8293 constant and 0 if it is not known to be a compile-time constant. A
8294 return of 0 does not indicate that the value is @emph{not} a constant,
8295 but merely that GCC cannot prove it is a constant with the specified
8296 value of the @option{-O} option.
8297
8298 You typically use this function in an embedded application where
8299 memory is a critical resource. If you have some complex calculation,
8300 you may want it to be folded if it involves constants, but need to call
8301 a function if it does not. For example:
8302
8303 @smallexample
8304 #define Scale_Value(X) \
8305 (__builtin_constant_p (X) \
8306 ? ((X) * SCALE + OFFSET) : Scale (X))
8307 @end smallexample
8308
8309 You may use this built-in function in either a macro or an inline
8310 function. However, if you use it in an inlined function and pass an
8311 argument of the function as the argument to the built-in, GCC
8312 never returns 1 when you call the inline function with a string constant
8313 or compound literal (@pxref{Compound Literals}) and does not return 1
8314 when you pass a constant numeric value to the inline function unless you
8315 specify the @option{-O} option.
8316
8317 You may also use @code{__builtin_constant_p} in initializers for static
8318 data. For instance, you can write
8319
8320 @smallexample
8321 static const int table[] = @{
8322 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
8323 /* @r{@dots{}} */
8324 @};
8325 @end smallexample
8326
8327 @noindent
8328 This is an acceptable initializer even if @var{EXPRESSION} is not a
8329 constant expression, including the case where
8330 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
8331 folded to a constant but @var{EXPRESSION} contains operands that are
8332 not otherwise permitted in a static initializer (for example,
8333 @code{0 && foo ()}). GCC must be more conservative about evaluating the
8334 built-in in this case, because it has no opportunity to perform
8335 optimization.
8336
8337 Previous versions of GCC did not accept this built-in in data
8338 initializers. The earliest version where it is completely safe is
8339 3.0.1.
8340 @end deftypefn
8341
8342 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
8343 @opindex fprofile-arcs
8344 You may use @code{__builtin_expect} to provide the compiler with
8345 branch prediction information. In general, you should prefer to
8346 use actual profile feedback for this (@option{-fprofile-arcs}), as
8347 programmers are notoriously bad at predicting how their programs
8348 actually perform. However, there are applications in which this
8349 data is hard to collect.
8350
8351 The return value is the value of @var{exp}, which should be an integral
8352 expression. The semantics of the built-in are that it is expected that
8353 @var{exp} == @var{c}. For example:
8354
8355 @smallexample
8356 if (__builtin_expect (x, 0))
8357 foo ();
8358 @end smallexample
8359
8360 @noindent
8361 indicates that we do not expect to call @code{foo}, since
8362 we expect @code{x} to be zero. Since you are limited to integral
8363 expressions for @var{exp}, you should use constructions such as
8364
8365 @smallexample
8366 if (__builtin_expect (ptr != NULL, 1))
8367 foo (*ptr);
8368 @end smallexample
8369
8370 @noindent
8371 when testing pointer or floating-point values.
8372 @end deftypefn
8373
8374 @deftypefn {Built-in Function} void __builtin_trap (void)
8375 This function causes the program to exit abnormally. GCC implements
8376 this function by using a target-dependent mechanism (such as
8377 intentionally executing an illegal instruction) or by calling
8378 @code{abort}. The mechanism used may vary from release to release so
8379 you should not rely on any particular implementation.
8380 @end deftypefn
8381
8382 @deftypefn {Built-in Function} void __builtin_unreachable (void)
8383 If control flow reaches the point of the @code{__builtin_unreachable},
8384 the program is undefined. It is useful in situations where the
8385 compiler cannot deduce the unreachability of the code.
8386
8387 One such case is immediately following an @code{asm} statement that
8388 either never terminates, or one that transfers control elsewhere
8389 and never returns. In this example, without the
8390 @code{__builtin_unreachable}, GCC issues a warning that control
8391 reaches the end of a non-void function. It also generates code
8392 to return after the @code{asm}.
8393
8394 @smallexample
8395 int f (int c, int v)
8396 @{
8397 if (c)
8398 @{
8399 return v;
8400 @}
8401 else
8402 @{
8403 asm("jmp error_handler");
8404 __builtin_unreachable ();
8405 @}
8406 @}
8407 @end smallexample
8408
8409 @noindent
8410 Because the @code{asm} statement unconditionally transfers control out
8411 of the function, control never reaches the end of the function
8412 body. The @code{__builtin_unreachable} is in fact unreachable and
8413 communicates this fact to the compiler.
8414
8415 Another use for @code{__builtin_unreachable} is following a call a
8416 function that never returns but that is not declared
8417 @code{__attribute__((noreturn))}, as in this example:
8418
8419 @smallexample
8420 void function_that_never_returns (void);
8421
8422 int g (int c)
8423 @{
8424 if (c)
8425 @{
8426 return 1;
8427 @}
8428 else
8429 @{
8430 function_that_never_returns ();
8431 __builtin_unreachable ();
8432 @}
8433 @}
8434 @end smallexample
8435
8436 @end deftypefn
8437
8438 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
8439 This function returns its first argument, and allows the compiler
8440 to assume that the returned pointer is at least @var{align} bytes
8441 aligned. This built-in can have either two or three arguments,
8442 if it has three, the third argument should have integer type, and
8443 if it is nonzero means misalignment offset. For example:
8444
8445 @smallexample
8446 void *x = __builtin_assume_aligned (arg, 16);
8447 @end smallexample
8448
8449 @noindent
8450 means that the compiler can assume @code{x}, set to @code{arg}, is at least
8451 16-byte aligned, while:
8452
8453 @smallexample
8454 void *x = __builtin_assume_aligned (arg, 32, 8);
8455 @end smallexample
8456
8457 @noindent
8458 means that the compiler can assume for @code{x}, set to @code{arg}, that
8459 @code{(char *) x - 8} is 32-byte aligned.
8460 @end deftypefn
8461
8462 @deftypefn {Built-in Function} int __builtin_LINE ()
8463 This function is the equivalent to the preprocessor @code{__LINE__}
8464 macro and returns the line number of the invocation of the built-in.
8465 @end deftypefn
8466
8467 @deftypefn {Built-in Function} int __builtin_FUNCTION ()
8468 This function is the equivalent to the preprocessor @code{__FUNCTION__}
8469 macro and returns the function name the invocation of the built-in is in.
8470 @end deftypefn
8471
8472 @deftypefn {Built-in Function} int __builtin_FILE ()
8473 This function is the equivalent to the preprocessor @code{__FILE__}
8474 macro and returns the file name the invocation of the built-in is in.
8475 @end deftypefn
8476
8477 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
8478 This function is used to flush the processor's instruction cache for
8479 the region of memory between @var{begin} inclusive and @var{end}
8480 exclusive. Some targets require that the instruction cache be
8481 flushed, after modifying memory containing code, in order to obtain
8482 deterministic behavior.
8483
8484 If the target does not require instruction cache flushes,
8485 @code{__builtin___clear_cache} has no effect. Otherwise either
8486 instructions are emitted in-line to clear the instruction cache or a
8487 call to the @code{__clear_cache} function in libgcc is made.
8488 @end deftypefn
8489
8490 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
8491 This function is used to minimize cache-miss latency by moving data into
8492 a cache before it is accessed.
8493 You can insert calls to @code{__builtin_prefetch} into code for which
8494 you know addresses of data in memory that is likely to be accessed soon.
8495 If the target supports them, data prefetch instructions are generated.
8496 If the prefetch is done early enough before the access then the data will
8497 be in the cache by the time it is accessed.
8498
8499 The value of @var{addr} is the address of the memory to prefetch.
8500 There are two optional arguments, @var{rw} and @var{locality}.
8501 The value of @var{rw} is a compile-time constant one or zero; one
8502 means that the prefetch is preparing for a write to the memory address
8503 and zero, the default, means that the prefetch is preparing for a read.
8504 The value @var{locality} must be a compile-time constant integer between
8505 zero and three. A value of zero means that the data has no temporal
8506 locality, so it need not be left in the cache after the access. A value
8507 of three means that the data has a high degree of temporal locality and
8508 should be left in all levels of cache possible. Values of one and two
8509 mean, respectively, a low or moderate degree of temporal locality. The
8510 default is three.
8511
8512 @smallexample
8513 for (i = 0; i < n; i++)
8514 @{
8515 a[i] = a[i] + b[i];
8516 __builtin_prefetch (&a[i+j], 1, 1);
8517 __builtin_prefetch (&b[i+j], 0, 1);
8518 /* @r{@dots{}} */
8519 @}
8520 @end smallexample
8521
8522 Data prefetch does not generate faults if @var{addr} is invalid, but
8523 the address expression itself must be valid. For example, a prefetch
8524 of @code{p->next} does not fault if @code{p->next} is not a valid
8525 address, but evaluation faults if @code{p} is not a valid address.
8526
8527 If the target does not support data prefetch, the address expression
8528 is evaluated if it includes side effects but no other code is generated
8529 and GCC does not issue a warning.
8530 @end deftypefn
8531
8532 @deftypefn {Built-in Function} double __builtin_huge_val (void)
8533 Returns a positive infinity, if supported by the floating-point format,
8534 else @code{DBL_MAX}. This function is suitable for implementing the
8535 ISO C macro @code{HUGE_VAL}.
8536 @end deftypefn
8537
8538 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
8539 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
8540 @end deftypefn
8541
8542 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
8543 Similar to @code{__builtin_huge_val}, except the return
8544 type is @code{long double}.
8545 @end deftypefn
8546
8547 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
8548 This built-in implements the C99 fpclassify functionality. The first
8549 five int arguments should be the target library's notion of the
8550 possible FP classes and are used for return values. They must be
8551 constant values and they must appear in this order: @code{FP_NAN},
8552 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
8553 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
8554 to classify. GCC treats the last argument as type-generic, which
8555 means it does not do default promotion from float to double.
8556 @end deftypefn
8557
8558 @deftypefn {Built-in Function} double __builtin_inf (void)
8559 Similar to @code{__builtin_huge_val}, except a warning is generated
8560 if the target floating-point format does not support infinities.
8561 @end deftypefn
8562
8563 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
8564 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
8565 @end deftypefn
8566
8567 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
8568 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
8569 @end deftypefn
8570
8571 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
8572 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
8573 @end deftypefn
8574
8575 @deftypefn {Built-in Function} float __builtin_inff (void)
8576 Similar to @code{__builtin_inf}, except the return type is @code{float}.
8577 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
8578 @end deftypefn
8579
8580 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
8581 Similar to @code{__builtin_inf}, except the return
8582 type is @code{long double}.
8583 @end deftypefn
8584
8585 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
8586 Similar to @code{isinf}, except the return value is negative for
8587 an argument of @code{-Inf}. Note while the parameter list is an
8588 ellipsis, this function only accepts exactly one floating-point
8589 argument. GCC treats this parameter as type-generic, which means it
8590 does not do default promotion from float to double.
8591 @end deftypefn
8592
8593 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
8594 This is an implementation of the ISO C99 function @code{nan}.
8595
8596 Since ISO C99 defines this function in terms of @code{strtod}, which we
8597 do not implement, a description of the parsing is in order. The string
8598 is parsed as by @code{strtol}; that is, the base is recognized by
8599 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
8600 in the significand such that the least significant bit of the number
8601 is at the least significant bit of the significand. The number is
8602 truncated to fit the significand field provided. The significand is
8603 forced to be a quiet NaN@.
8604
8605 This function, if given a string literal all of which would have been
8606 consumed by @code{strtol}, is evaluated early enough that it is considered a
8607 compile-time constant.
8608 @end deftypefn
8609
8610 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
8611 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
8612 @end deftypefn
8613
8614 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
8615 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
8616 @end deftypefn
8617
8618 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
8619 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
8620 @end deftypefn
8621
8622 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
8623 Similar to @code{__builtin_nan}, except the return type is @code{float}.
8624 @end deftypefn
8625
8626 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
8627 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
8628 @end deftypefn
8629
8630 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
8631 Similar to @code{__builtin_nan}, except the significand is forced
8632 to be a signaling NaN@. The @code{nans} function is proposed by
8633 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
8634 @end deftypefn
8635
8636 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
8637 Similar to @code{__builtin_nans}, except the return type is @code{float}.
8638 @end deftypefn
8639
8640 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
8641 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
8642 @end deftypefn
8643
8644 @deftypefn {Built-in Function} int __builtin_ffs (unsigned int x)
8645 Returns one plus the index of the least significant 1-bit of @var{x}, or
8646 if @var{x} is zero, returns zero.
8647 @end deftypefn
8648
8649 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
8650 Returns the number of leading 0-bits in @var{x}, starting at the most
8651 significant bit position. If @var{x} is 0, the result is undefined.
8652 @end deftypefn
8653
8654 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
8655 Returns the number of trailing 0-bits in @var{x}, starting at the least
8656 significant bit position. If @var{x} is 0, the result is undefined.
8657 @end deftypefn
8658
8659 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
8660 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
8661 number of bits following the most significant bit that are identical
8662 to it. There are no special cases for 0 or other values.
8663 @end deftypefn
8664
8665 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
8666 Returns the number of 1-bits in @var{x}.
8667 @end deftypefn
8668
8669 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
8670 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
8671 modulo 2.
8672 @end deftypefn
8673
8674 @deftypefn {Built-in Function} int __builtin_ffsl (unsigned long)
8675 Similar to @code{__builtin_ffs}, except the argument type is
8676 @code{unsigned long}.
8677 @end deftypefn
8678
8679 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
8680 Similar to @code{__builtin_clz}, except the argument type is
8681 @code{unsigned long}.
8682 @end deftypefn
8683
8684 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
8685 Similar to @code{__builtin_ctz}, except the argument type is
8686 @code{unsigned long}.
8687 @end deftypefn
8688
8689 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
8690 Similar to @code{__builtin_clrsb}, except the argument type is
8691 @code{long}.
8692 @end deftypefn
8693
8694 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
8695 Similar to @code{__builtin_popcount}, except the argument type is
8696 @code{unsigned long}.
8697 @end deftypefn
8698
8699 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
8700 Similar to @code{__builtin_parity}, except the argument type is
8701 @code{unsigned long}.
8702 @end deftypefn
8703
8704 @deftypefn {Built-in Function} int __builtin_ffsll (unsigned long long)
8705 Similar to @code{__builtin_ffs}, except the argument type is
8706 @code{unsigned long long}.
8707 @end deftypefn
8708
8709 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
8710 Similar to @code{__builtin_clz}, except the argument type is
8711 @code{unsigned long long}.
8712 @end deftypefn
8713
8714 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
8715 Similar to @code{__builtin_ctz}, except the argument type is
8716 @code{unsigned long long}.
8717 @end deftypefn
8718
8719 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
8720 Similar to @code{__builtin_clrsb}, except the argument type is
8721 @code{long long}.
8722 @end deftypefn
8723
8724 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
8725 Similar to @code{__builtin_popcount}, except the argument type is
8726 @code{unsigned long long}.
8727 @end deftypefn
8728
8729 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
8730 Similar to @code{__builtin_parity}, except the argument type is
8731 @code{unsigned long long}.
8732 @end deftypefn
8733
8734 @deftypefn {Built-in Function} double __builtin_powi (double, int)
8735 Returns the first argument raised to the power of the second. Unlike the
8736 @code{pow} function no guarantees about precision and rounding are made.
8737 @end deftypefn
8738
8739 @deftypefn {Built-in Function} float __builtin_powif (float, int)
8740 Similar to @code{__builtin_powi}, except the argument and return types
8741 are @code{float}.
8742 @end deftypefn
8743
8744 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
8745 Similar to @code{__builtin_powi}, except the argument and return types
8746 are @code{long double}.
8747 @end deftypefn
8748
8749 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
8750 Returns @var{x} with the order of the bytes reversed; for example,
8751 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
8752 exactly 8 bits.
8753 @end deftypefn
8754
8755 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
8756 Similar to @code{__builtin_bswap16}, except the argument and return types
8757 are 32 bit.
8758 @end deftypefn
8759
8760 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
8761 Similar to @code{__builtin_bswap32}, except the argument and return types
8762 are 64 bit.
8763 @end deftypefn
8764
8765 @node Target Builtins
8766 @section Built-in Functions Specific to Particular Target Machines
8767
8768 On some target machines, GCC supports many built-in functions specific
8769 to those machines. Generally these generate calls to specific machine
8770 instructions, but allow the compiler to schedule those calls.
8771
8772 @menu
8773 * Alpha Built-in Functions::
8774 * ARM iWMMXt Built-in Functions::
8775 * ARM NEON Intrinsics::
8776 * AVR Built-in Functions::
8777 * Blackfin Built-in Functions::
8778 * FR-V Built-in Functions::
8779 * X86 Built-in Functions::
8780 * X86 transactional memory intrinsics::
8781 * MIPS DSP Built-in Functions::
8782 * MIPS Paired-Single Support::
8783 * MIPS Loongson Built-in Functions::
8784 * Other MIPS Built-in Functions::
8785 * picoChip Built-in Functions::
8786 * PowerPC Built-in Functions::
8787 * PowerPC AltiVec/VSX Built-in Functions::
8788 * RX Built-in Functions::
8789 * SH Built-in Functions::
8790 * SPARC VIS Built-in Functions::
8791 * SPU Built-in Functions::
8792 * TI C6X Built-in Functions::
8793 * TILE-Gx Built-in Functions::
8794 * TILEPro Built-in Functions::
8795 @end menu
8796
8797 @node Alpha Built-in Functions
8798 @subsection Alpha Built-in Functions
8799
8800 These built-in functions are available for the Alpha family of
8801 processors, depending on the command-line switches used.
8802
8803 The following built-in functions are always available. They
8804 all generate the machine instruction that is part of the name.
8805
8806 @smallexample
8807 long __builtin_alpha_implver (void)
8808 long __builtin_alpha_rpcc (void)
8809 long __builtin_alpha_amask (long)
8810 long __builtin_alpha_cmpbge (long, long)
8811 long __builtin_alpha_extbl (long, long)
8812 long __builtin_alpha_extwl (long, long)
8813 long __builtin_alpha_extll (long, long)
8814 long __builtin_alpha_extql (long, long)
8815 long __builtin_alpha_extwh (long, long)
8816 long __builtin_alpha_extlh (long, long)
8817 long __builtin_alpha_extqh (long, long)
8818 long __builtin_alpha_insbl (long, long)
8819 long __builtin_alpha_inswl (long, long)
8820 long __builtin_alpha_insll (long, long)
8821 long __builtin_alpha_insql (long, long)
8822 long __builtin_alpha_inswh (long, long)
8823 long __builtin_alpha_inslh (long, long)
8824 long __builtin_alpha_insqh (long, long)
8825 long __builtin_alpha_mskbl (long, long)
8826 long __builtin_alpha_mskwl (long, long)
8827 long __builtin_alpha_mskll (long, long)
8828 long __builtin_alpha_mskql (long, long)
8829 long __builtin_alpha_mskwh (long, long)
8830 long __builtin_alpha_msklh (long, long)
8831 long __builtin_alpha_mskqh (long, long)
8832 long __builtin_alpha_umulh (long, long)
8833 long __builtin_alpha_zap (long, long)
8834 long __builtin_alpha_zapnot (long, long)
8835 @end smallexample
8836
8837 The following built-in functions are always with @option{-mmax}
8838 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
8839 later. They all generate the machine instruction that is part
8840 of the name.
8841
8842 @smallexample
8843 long __builtin_alpha_pklb (long)
8844 long __builtin_alpha_pkwb (long)
8845 long __builtin_alpha_unpkbl (long)
8846 long __builtin_alpha_unpkbw (long)
8847 long __builtin_alpha_minub8 (long, long)
8848 long __builtin_alpha_minsb8 (long, long)
8849 long __builtin_alpha_minuw4 (long, long)
8850 long __builtin_alpha_minsw4 (long, long)
8851 long __builtin_alpha_maxub8 (long, long)
8852 long __builtin_alpha_maxsb8 (long, long)
8853 long __builtin_alpha_maxuw4 (long, long)
8854 long __builtin_alpha_maxsw4 (long, long)
8855 long __builtin_alpha_perr (long, long)
8856 @end smallexample
8857
8858 The following built-in functions are always with @option{-mcix}
8859 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
8860 later. They all generate the machine instruction that is part
8861 of the name.
8862
8863 @smallexample
8864 long __builtin_alpha_cttz (long)
8865 long __builtin_alpha_ctlz (long)
8866 long __builtin_alpha_ctpop (long)
8867 @end smallexample
8868
8869 The following built-in functions are available on systems that use the OSF/1
8870 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
8871 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
8872 @code{rdval} and @code{wrval}.
8873
8874 @smallexample
8875 void *__builtin_thread_pointer (void)
8876 void __builtin_set_thread_pointer (void *)
8877 @end smallexample
8878
8879 @node ARM iWMMXt Built-in Functions
8880 @subsection ARM iWMMXt Built-in Functions
8881
8882 These built-in functions are available for the ARM family of
8883 processors when the @option{-mcpu=iwmmxt} switch is used:
8884
8885 @smallexample
8886 typedef int v2si __attribute__ ((vector_size (8)));
8887 typedef short v4hi __attribute__ ((vector_size (8)));
8888 typedef char v8qi __attribute__ ((vector_size (8)));
8889
8890 int __builtin_arm_getwcgr0 (void)
8891 void __builtin_arm_setwcgr0 (int)
8892 int __builtin_arm_getwcgr1 (void)
8893 void __builtin_arm_setwcgr1 (int)
8894 int __builtin_arm_getwcgr2 (void)
8895 void __builtin_arm_setwcgr2 (int)
8896 int __builtin_arm_getwcgr3 (void)
8897 void __builtin_arm_setwcgr3 (int)
8898 int __builtin_arm_textrmsb (v8qi, int)
8899 int __builtin_arm_textrmsh (v4hi, int)
8900 int __builtin_arm_textrmsw (v2si, int)
8901 int __builtin_arm_textrmub (v8qi, int)
8902 int __builtin_arm_textrmuh (v4hi, int)
8903 int __builtin_arm_textrmuw (v2si, int)
8904 v8qi __builtin_arm_tinsrb (v8qi, int, int)
8905 v4hi __builtin_arm_tinsrh (v4hi, int, int)
8906 v2si __builtin_arm_tinsrw (v2si, int, int)
8907 long long __builtin_arm_tmia (long long, int, int)
8908 long long __builtin_arm_tmiabb (long long, int, int)
8909 long long __builtin_arm_tmiabt (long long, int, int)
8910 long long __builtin_arm_tmiaph (long long, int, int)
8911 long long __builtin_arm_tmiatb (long long, int, int)
8912 long long __builtin_arm_tmiatt (long long, int, int)
8913 int __builtin_arm_tmovmskb (v8qi)
8914 int __builtin_arm_tmovmskh (v4hi)
8915 int __builtin_arm_tmovmskw (v2si)
8916 long long __builtin_arm_waccb (v8qi)
8917 long long __builtin_arm_wacch (v4hi)
8918 long long __builtin_arm_waccw (v2si)
8919 v8qi __builtin_arm_waddb (v8qi, v8qi)
8920 v8qi __builtin_arm_waddbss (v8qi, v8qi)
8921 v8qi __builtin_arm_waddbus (v8qi, v8qi)
8922 v4hi __builtin_arm_waddh (v4hi, v4hi)
8923 v4hi __builtin_arm_waddhss (v4hi, v4hi)
8924 v4hi __builtin_arm_waddhus (v4hi, v4hi)
8925 v2si __builtin_arm_waddw (v2si, v2si)
8926 v2si __builtin_arm_waddwss (v2si, v2si)
8927 v2si __builtin_arm_waddwus (v2si, v2si)
8928 v8qi __builtin_arm_walign (v8qi, v8qi, int)
8929 long long __builtin_arm_wand(long long, long long)
8930 long long __builtin_arm_wandn (long long, long long)
8931 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
8932 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
8933 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
8934 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
8935 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
8936 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
8937 v2si __builtin_arm_wcmpeqw (v2si, v2si)
8938 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
8939 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
8940 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
8941 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
8942 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
8943 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
8944 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
8945 long long __builtin_arm_wmacsz (v4hi, v4hi)
8946 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
8947 long long __builtin_arm_wmacuz (v4hi, v4hi)
8948 v4hi __builtin_arm_wmadds (v4hi, v4hi)
8949 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
8950 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
8951 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
8952 v2si __builtin_arm_wmaxsw (v2si, v2si)
8953 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
8954 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
8955 v2si __builtin_arm_wmaxuw (v2si, v2si)
8956 v8qi __builtin_arm_wminsb (v8qi, v8qi)
8957 v4hi __builtin_arm_wminsh (v4hi, v4hi)
8958 v2si __builtin_arm_wminsw (v2si, v2si)
8959 v8qi __builtin_arm_wminub (v8qi, v8qi)
8960 v4hi __builtin_arm_wminuh (v4hi, v4hi)
8961 v2si __builtin_arm_wminuw (v2si, v2si)
8962 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
8963 v4hi __builtin_arm_wmulul (v4hi, v4hi)
8964 v4hi __builtin_arm_wmulum (v4hi, v4hi)
8965 long long __builtin_arm_wor (long long, long long)
8966 v2si __builtin_arm_wpackdss (long long, long long)
8967 v2si __builtin_arm_wpackdus (long long, long long)
8968 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
8969 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
8970 v4hi __builtin_arm_wpackwss (v2si, v2si)
8971 v4hi __builtin_arm_wpackwus (v2si, v2si)
8972 long long __builtin_arm_wrord (long long, long long)
8973 long long __builtin_arm_wrordi (long long, int)
8974 v4hi __builtin_arm_wrorh (v4hi, long long)
8975 v4hi __builtin_arm_wrorhi (v4hi, int)
8976 v2si __builtin_arm_wrorw (v2si, long long)
8977 v2si __builtin_arm_wrorwi (v2si, int)
8978 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
8979 v2si __builtin_arm_wsadbz (v8qi, v8qi)
8980 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
8981 v2si __builtin_arm_wsadhz (v4hi, v4hi)
8982 v4hi __builtin_arm_wshufh (v4hi, int)
8983 long long __builtin_arm_wslld (long long, long long)
8984 long long __builtin_arm_wslldi (long long, int)
8985 v4hi __builtin_arm_wsllh (v4hi, long long)
8986 v4hi __builtin_arm_wsllhi (v4hi, int)
8987 v2si __builtin_arm_wsllw (v2si, long long)
8988 v2si __builtin_arm_wsllwi (v2si, int)
8989 long long __builtin_arm_wsrad (long long, long long)
8990 long long __builtin_arm_wsradi (long long, int)
8991 v4hi __builtin_arm_wsrah (v4hi, long long)
8992 v4hi __builtin_arm_wsrahi (v4hi, int)
8993 v2si __builtin_arm_wsraw (v2si, long long)
8994 v2si __builtin_arm_wsrawi (v2si, int)
8995 long long __builtin_arm_wsrld (long long, long long)
8996 long long __builtin_arm_wsrldi (long long, int)
8997 v4hi __builtin_arm_wsrlh (v4hi, long long)
8998 v4hi __builtin_arm_wsrlhi (v4hi, int)
8999 v2si __builtin_arm_wsrlw (v2si, long long)
9000 v2si __builtin_arm_wsrlwi (v2si, int)
9001 v8qi __builtin_arm_wsubb (v8qi, v8qi)
9002 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
9003 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
9004 v4hi __builtin_arm_wsubh (v4hi, v4hi)
9005 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
9006 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
9007 v2si __builtin_arm_wsubw (v2si, v2si)
9008 v2si __builtin_arm_wsubwss (v2si, v2si)
9009 v2si __builtin_arm_wsubwus (v2si, v2si)
9010 v4hi __builtin_arm_wunpckehsb (v8qi)
9011 v2si __builtin_arm_wunpckehsh (v4hi)
9012 long long __builtin_arm_wunpckehsw (v2si)
9013 v4hi __builtin_arm_wunpckehub (v8qi)
9014 v2si __builtin_arm_wunpckehuh (v4hi)
9015 long long __builtin_arm_wunpckehuw (v2si)
9016 v4hi __builtin_arm_wunpckelsb (v8qi)
9017 v2si __builtin_arm_wunpckelsh (v4hi)
9018 long long __builtin_arm_wunpckelsw (v2si)
9019 v4hi __builtin_arm_wunpckelub (v8qi)
9020 v2si __builtin_arm_wunpckeluh (v4hi)
9021 long long __builtin_arm_wunpckeluw (v2si)
9022 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
9023 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
9024 v2si __builtin_arm_wunpckihw (v2si, v2si)
9025 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
9026 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
9027 v2si __builtin_arm_wunpckilw (v2si, v2si)
9028 long long __builtin_arm_wxor (long long, long long)
9029 long long __builtin_arm_wzero ()
9030 @end smallexample
9031
9032 @node ARM NEON Intrinsics
9033 @subsection ARM NEON Intrinsics
9034
9035 These built-in intrinsics for the ARM Advanced SIMD extension are available
9036 when the @option{-mfpu=neon} switch is used:
9037
9038 @include arm-neon-intrinsics.texi
9039
9040 @node AVR Built-in Functions
9041 @subsection AVR Built-in Functions
9042
9043 For each built-in function for AVR, there is an equally named,
9044 uppercase built-in macro defined. That way users can easily query if
9045 or if not a specific built-in is implemented or not. For example, if
9046 @code{__builtin_avr_nop} is available the macro
9047 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
9048
9049 The following built-in functions map to the respective machine
9050 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
9051 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
9052 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
9053 as library call if no hardware multiplier is available.
9054
9055 @smallexample
9056 void __builtin_avr_nop (void)
9057 void __builtin_avr_sei (void)
9058 void __builtin_avr_cli (void)
9059 void __builtin_avr_sleep (void)
9060 void __builtin_avr_wdr (void)
9061 unsigned char __builtin_avr_swap (unsigned char)
9062 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
9063 int __builtin_avr_fmuls (char, char)
9064 int __builtin_avr_fmulsu (char, unsigned char)
9065 @end smallexample
9066
9067 In order to delay execution for a specific number of cycles, GCC
9068 implements
9069 @smallexample
9070 void __builtin_avr_delay_cycles (unsigned long ticks)
9071 @end smallexample
9072
9073 @noindent
9074 @code{ticks} is the number of ticks to delay execution. Note that this
9075 built-in does not take into account the effect of interrupts that
9076 might increase delay time. @code{ticks} must be a compile-time
9077 integer constant; delays with a variable number of cycles are not supported.
9078
9079 @smallexample
9080 char __builtin_avr_flash_segment (const __memx void*)
9081 @end smallexample
9082
9083 @noindent
9084 This built-in takes a byte address to the 24-bit
9085 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
9086 the number of the flash segment (the 64 KiB chunk) where the address
9087 points to. Counting starts at @code{0}.
9088 If the address does not point to flash memory, return @code{-1}.
9089
9090 @smallexample
9091 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
9092 @end smallexample
9093
9094 @noindent
9095 Insert bits from @var{bits} into @var{val} and return the resulting
9096 value. The nibbles of @var{map} determine how the insertion is
9097 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
9098 @enumerate
9099 @item If @var{X} is @code{0xf},
9100 then the @var{n}-th bit of @var{val} is returned unaltered.
9101
9102 @item If X is in the range 0@dots{}7,
9103 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
9104
9105 @item If X is in the range 8@dots{}@code{0xe},
9106 then the @var{n}-th result bit is undefined.
9107 @end enumerate
9108
9109 @noindent
9110 One typical use case for this built-in is adjusting input and
9111 output values to non-contiguous port layouts. Some examples:
9112
9113 @smallexample
9114 // same as val, bits is unused
9115 __builtin_avr_insert_bits (0xffffffff, bits, val)
9116 @end smallexample
9117
9118 @smallexample
9119 // same as bits, val is unused
9120 __builtin_avr_insert_bits (0x76543210, bits, val)
9121 @end smallexample
9122
9123 @smallexample
9124 // same as rotating bits by 4
9125 __builtin_avr_insert_bits (0x32107654, bits, 0)
9126 @end smallexample
9127
9128 @smallexample
9129 // high nibble of result is the high nibble of val
9130 // low nibble of result is the low nibble of bits
9131 __builtin_avr_insert_bits (0xffff3210, bits, val)
9132 @end smallexample
9133
9134 @smallexample
9135 // reverse the bit order of bits
9136 __builtin_avr_insert_bits (0x01234567, bits, 0)
9137 @end smallexample
9138
9139 @node Blackfin Built-in Functions
9140 @subsection Blackfin Built-in Functions
9141
9142 Currently, there are two Blackfin-specific built-in functions. These are
9143 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
9144 using inline assembly; by using these built-in functions the compiler can
9145 automatically add workarounds for hardware errata involving these
9146 instructions. These functions are named as follows:
9147
9148 @smallexample
9149 void __builtin_bfin_csync (void)
9150 void __builtin_bfin_ssync (void)
9151 @end smallexample
9152
9153 @node FR-V Built-in Functions
9154 @subsection FR-V Built-in Functions
9155
9156 GCC provides many FR-V-specific built-in functions. In general,
9157 these functions are intended to be compatible with those described
9158 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
9159 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
9160 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
9161 pointer rather than by value.
9162
9163 Most of the functions are named after specific FR-V instructions.
9164 Such functions are said to be ``directly mapped'' and are summarized
9165 here in tabular form.
9166
9167 @menu
9168 * Argument Types::
9169 * Directly-mapped Integer Functions::
9170 * Directly-mapped Media Functions::
9171 * Raw read/write Functions::
9172 * Other Built-in Functions::
9173 @end menu
9174
9175 @node Argument Types
9176 @subsubsection Argument Types
9177
9178 The arguments to the built-in functions can be divided into three groups:
9179 register numbers, compile-time constants and run-time values. In order
9180 to make this classification clear at a glance, the arguments and return
9181 values are given the following pseudo types:
9182
9183 @multitable @columnfractions .20 .30 .15 .35
9184 @item Pseudo type @tab Real C type @tab Constant? @tab Description
9185 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
9186 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
9187 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
9188 @item @code{uw2} @tab @code{unsigned long long} @tab No
9189 @tab an unsigned doubleword
9190 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
9191 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
9192 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
9193 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
9194 @end multitable
9195
9196 These pseudo types are not defined by GCC, they are simply a notational
9197 convenience used in this manual.
9198
9199 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
9200 and @code{sw2} are evaluated at run time. They correspond to
9201 register operands in the underlying FR-V instructions.
9202
9203 @code{const} arguments represent immediate operands in the underlying
9204 FR-V instructions. They must be compile-time constants.
9205
9206 @code{acc} arguments are evaluated at compile time and specify the number
9207 of an accumulator register. For example, an @code{acc} argument of 2
9208 selects the ACC2 register.
9209
9210 @code{iacc} arguments are similar to @code{acc} arguments but specify the
9211 number of an IACC register. See @pxref{Other Built-in Functions}
9212 for more details.
9213
9214 @node Directly-mapped Integer Functions
9215 @subsubsection Directly-mapped Integer Functions
9216
9217 The functions listed below map directly to FR-V I-type instructions.
9218
9219 @multitable @columnfractions .45 .32 .23
9220 @item Function prototype @tab Example usage @tab Assembly output
9221 @item @code{sw1 __ADDSS (sw1, sw1)}
9222 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
9223 @tab @code{ADDSS @var{a},@var{b},@var{c}}
9224 @item @code{sw1 __SCAN (sw1, sw1)}
9225 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
9226 @tab @code{SCAN @var{a},@var{b},@var{c}}
9227 @item @code{sw1 __SCUTSS (sw1)}
9228 @tab @code{@var{b} = __SCUTSS (@var{a})}
9229 @tab @code{SCUTSS @var{a},@var{b}}
9230 @item @code{sw1 __SLASS (sw1, sw1)}
9231 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
9232 @tab @code{SLASS @var{a},@var{b},@var{c}}
9233 @item @code{void __SMASS (sw1, sw1)}
9234 @tab @code{__SMASS (@var{a}, @var{b})}
9235 @tab @code{SMASS @var{a},@var{b}}
9236 @item @code{void __SMSSS (sw1, sw1)}
9237 @tab @code{__SMSSS (@var{a}, @var{b})}
9238 @tab @code{SMSSS @var{a},@var{b}}
9239 @item @code{void __SMU (sw1, sw1)}
9240 @tab @code{__SMU (@var{a}, @var{b})}
9241 @tab @code{SMU @var{a},@var{b}}
9242 @item @code{sw2 __SMUL (sw1, sw1)}
9243 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
9244 @tab @code{SMUL @var{a},@var{b},@var{c}}
9245 @item @code{sw1 __SUBSS (sw1, sw1)}
9246 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
9247 @tab @code{SUBSS @var{a},@var{b},@var{c}}
9248 @item @code{uw2 __UMUL (uw1, uw1)}
9249 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
9250 @tab @code{UMUL @var{a},@var{b},@var{c}}
9251 @end multitable
9252
9253 @node Directly-mapped Media Functions
9254 @subsubsection Directly-mapped Media Functions
9255
9256 The functions listed below map directly to FR-V M-type instructions.
9257
9258 @multitable @columnfractions .45 .32 .23
9259 @item Function prototype @tab Example usage @tab Assembly output
9260 @item @code{uw1 __MABSHS (sw1)}
9261 @tab @code{@var{b} = __MABSHS (@var{a})}
9262 @tab @code{MABSHS @var{a},@var{b}}
9263 @item @code{void __MADDACCS (acc, acc)}
9264 @tab @code{__MADDACCS (@var{b}, @var{a})}
9265 @tab @code{MADDACCS @var{a},@var{b}}
9266 @item @code{sw1 __MADDHSS (sw1, sw1)}
9267 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
9268 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
9269 @item @code{uw1 __MADDHUS (uw1, uw1)}
9270 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
9271 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
9272 @item @code{uw1 __MAND (uw1, uw1)}
9273 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
9274 @tab @code{MAND @var{a},@var{b},@var{c}}
9275 @item @code{void __MASACCS (acc, acc)}
9276 @tab @code{__MASACCS (@var{b}, @var{a})}
9277 @tab @code{MASACCS @var{a},@var{b}}
9278 @item @code{uw1 __MAVEH (uw1, uw1)}
9279 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
9280 @tab @code{MAVEH @var{a},@var{b},@var{c}}
9281 @item @code{uw2 __MBTOH (uw1)}
9282 @tab @code{@var{b} = __MBTOH (@var{a})}
9283 @tab @code{MBTOH @var{a},@var{b}}
9284 @item @code{void __MBTOHE (uw1 *, uw1)}
9285 @tab @code{__MBTOHE (&@var{b}, @var{a})}
9286 @tab @code{MBTOHE @var{a},@var{b}}
9287 @item @code{void __MCLRACC (acc)}
9288 @tab @code{__MCLRACC (@var{a})}
9289 @tab @code{MCLRACC @var{a}}
9290 @item @code{void __MCLRACCA (void)}
9291 @tab @code{__MCLRACCA ()}
9292 @tab @code{MCLRACCA}
9293 @item @code{uw1 __Mcop1 (uw1, uw1)}
9294 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
9295 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
9296 @item @code{uw1 __Mcop2 (uw1, uw1)}
9297 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
9298 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
9299 @item @code{uw1 __MCPLHI (uw2, const)}
9300 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
9301 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
9302 @item @code{uw1 __MCPLI (uw2, const)}
9303 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
9304 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
9305 @item @code{void __MCPXIS (acc, sw1, sw1)}
9306 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
9307 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
9308 @item @code{void __MCPXIU (acc, uw1, uw1)}
9309 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
9310 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
9311 @item @code{void __MCPXRS (acc, sw1, sw1)}
9312 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
9313 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
9314 @item @code{void __MCPXRU (acc, uw1, uw1)}
9315 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
9316 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
9317 @item @code{uw1 __MCUT (acc, uw1)}
9318 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
9319 @tab @code{MCUT @var{a},@var{b},@var{c}}
9320 @item @code{uw1 __MCUTSS (acc, sw1)}
9321 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
9322 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
9323 @item @code{void __MDADDACCS (acc, acc)}
9324 @tab @code{__MDADDACCS (@var{b}, @var{a})}
9325 @tab @code{MDADDACCS @var{a},@var{b}}
9326 @item @code{void __MDASACCS (acc, acc)}
9327 @tab @code{__MDASACCS (@var{b}, @var{a})}
9328 @tab @code{MDASACCS @var{a},@var{b}}
9329 @item @code{uw2 __MDCUTSSI (acc, const)}
9330 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
9331 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
9332 @item @code{uw2 __MDPACKH (uw2, uw2)}
9333 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
9334 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
9335 @item @code{uw2 __MDROTLI (uw2, const)}
9336 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
9337 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
9338 @item @code{void __MDSUBACCS (acc, acc)}
9339 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
9340 @tab @code{MDSUBACCS @var{a},@var{b}}
9341 @item @code{void __MDUNPACKH (uw1 *, uw2)}
9342 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
9343 @tab @code{MDUNPACKH @var{a},@var{b}}
9344 @item @code{uw2 __MEXPDHD (uw1, const)}
9345 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
9346 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
9347 @item @code{uw1 __MEXPDHW (uw1, const)}
9348 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
9349 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
9350 @item @code{uw1 __MHDSETH (uw1, const)}
9351 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
9352 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
9353 @item @code{sw1 __MHDSETS (const)}
9354 @tab @code{@var{b} = __MHDSETS (@var{a})}
9355 @tab @code{MHDSETS #@var{a},@var{b}}
9356 @item @code{uw1 __MHSETHIH (uw1, const)}
9357 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
9358 @tab @code{MHSETHIH #@var{a},@var{b}}
9359 @item @code{sw1 __MHSETHIS (sw1, const)}
9360 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
9361 @tab @code{MHSETHIS #@var{a},@var{b}}
9362 @item @code{uw1 __MHSETLOH (uw1, const)}
9363 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
9364 @tab @code{MHSETLOH #@var{a},@var{b}}
9365 @item @code{sw1 __MHSETLOS (sw1, const)}
9366 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
9367 @tab @code{MHSETLOS #@var{a},@var{b}}
9368 @item @code{uw1 __MHTOB (uw2)}
9369 @tab @code{@var{b} = __MHTOB (@var{a})}
9370 @tab @code{MHTOB @var{a},@var{b}}
9371 @item @code{void __MMACHS (acc, sw1, sw1)}
9372 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
9373 @tab @code{MMACHS @var{a},@var{b},@var{c}}
9374 @item @code{void __MMACHU (acc, uw1, uw1)}
9375 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
9376 @tab @code{MMACHU @var{a},@var{b},@var{c}}
9377 @item @code{void __MMRDHS (acc, sw1, sw1)}
9378 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
9379 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
9380 @item @code{void __MMRDHU (acc, uw1, uw1)}
9381 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
9382 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
9383 @item @code{void __MMULHS (acc, sw1, sw1)}
9384 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
9385 @tab @code{MMULHS @var{a},@var{b},@var{c}}
9386 @item @code{void __MMULHU (acc, uw1, uw1)}
9387 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
9388 @tab @code{MMULHU @var{a},@var{b},@var{c}}
9389 @item @code{void __MMULXHS (acc, sw1, sw1)}
9390 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
9391 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
9392 @item @code{void __MMULXHU (acc, uw1, uw1)}
9393 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
9394 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
9395 @item @code{uw1 __MNOT (uw1)}
9396 @tab @code{@var{b} = __MNOT (@var{a})}
9397 @tab @code{MNOT @var{a},@var{b}}
9398 @item @code{uw1 __MOR (uw1, uw1)}
9399 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
9400 @tab @code{MOR @var{a},@var{b},@var{c}}
9401 @item @code{uw1 __MPACKH (uh, uh)}
9402 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
9403 @tab @code{MPACKH @var{a},@var{b},@var{c}}
9404 @item @code{sw2 __MQADDHSS (sw2, sw2)}
9405 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
9406 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
9407 @item @code{uw2 __MQADDHUS (uw2, uw2)}
9408 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
9409 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
9410 @item @code{void __MQCPXIS (acc, sw2, sw2)}
9411 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
9412 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
9413 @item @code{void __MQCPXIU (acc, uw2, uw2)}
9414 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
9415 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
9416 @item @code{void __MQCPXRS (acc, sw2, sw2)}
9417 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
9418 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
9419 @item @code{void __MQCPXRU (acc, uw2, uw2)}
9420 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
9421 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
9422 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
9423 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
9424 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
9425 @item @code{sw2 __MQLMTHS (sw2, sw2)}
9426 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
9427 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
9428 @item @code{void __MQMACHS (acc, sw2, sw2)}
9429 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
9430 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
9431 @item @code{void __MQMACHU (acc, uw2, uw2)}
9432 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
9433 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
9434 @item @code{void __MQMACXHS (acc, sw2, sw2)}
9435 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
9436 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
9437 @item @code{void __MQMULHS (acc, sw2, sw2)}
9438 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
9439 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
9440 @item @code{void __MQMULHU (acc, uw2, uw2)}
9441 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
9442 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
9443 @item @code{void __MQMULXHS (acc, sw2, sw2)}
9444 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
9445 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
9446 @item @code{void __MQMULXHU (acc, uw2, uw2)}
9447 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
9448 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
9449 @item @code{sw2 __MQSATHS (sw2, sw2)}
9450 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
9451 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
9452 @item @code{uw2 __MQSLLHI (uw2, int)}
9453 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
9454 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
9455 @item @code{sw2 __MQSRAHI (sw2, int)}
9456 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
9457 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
9458 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
9459 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
9460 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
9461 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
9462 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
9463 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
9464 @item @code{void __MQXMACHS (acc, sw2, sw2)}
9465 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
9466 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
9467 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
9468 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
9469 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
9470 @item @code{uw1 __MRDACC (acc)}
9471 @tab @code{@var{b} = __MRDACC (@var{a})}
9472 @tab @code{MRDACC @var{a},@var{b}}
9473 @item @code{uw1 __MRDACCG (acc)}
9474 @tab @code{@var{b} = __MRDACCG (@var{a})}
9475 @tab @code{MRDACCG @var{a},@var{b}}
9476 @item @code{uw1 __MROTLI (uw1, const)}
9477 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
9478 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
9479 @item @code{uw1 __MROTRI (uw1, const)}
9480 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
9481 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
9482 @item @code{sw1 __MSATHS (sw1, sw1)}
9483 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
9484 @tab @code{MSATHS @var{a},@var{b},@var{c}}
9485 @item @code{uw1 __MSATHU (uw1, uw1)}
9486 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
9487 @tab @code{MSATHU @var{a},@var{b},@var{c}}
9488 @item @code{uw1 __MSLLHI (uw1, const)}
9489 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
9490 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
9491 @item @code{sw1 __MSRAHI (sw1, const)}
9492 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
9493 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
9494 @item @code{uw1 __MSRLHI (uw1, const)}
9495 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
9496 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
9497 @item @code{void __MSUBACCS (acc, acc)}
9498 @tab @code{__MSUBACCS (@var{b}, @var{a})}
9499 @tab @code{MSUBACCS @var{a},@var{b}}
9500 @item @code{sw1 __MSUBHSS (sw1, sw1)}
9501 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
9502 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
9503 @item @code{uw1 __MSUBHUS (uw1, uw1)}
9504 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
9505 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
9506 @item @code{void __MTRAP (void)}
9507 @tab @code{__MTRAP ()}
9508 @tab @code{MTRAP}
9509 @item @code{uw2 __MUNPACKH (uw1)}
9510 @tab @code{@var{b} = __MUNPACKH (@var{a})}
9511 @tab @code{MUNPACKH @var{a},@var{b}}
9512 @item @code{uw1 __MWCUT (uw2, uw1)}
9513 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
9514 @tab @code{MWCUT @var{a},@var{b},@var{c}}
9515 @item @code{void __MWTACC (acc, uw1)}
9516 @tab @code{__MWTACC (@var{b}, @var{a})}
9517 @tab @code{MWTACC @var{a},@var{b}}
9518 @item @code{void __MWTACCG (acc, uw1)}
9519 @tab @code{__MWTACCG (@var{b}, @var{a})}
9520 @tab @code{MWTACCG @var{a},@var{b}}
9521 @item @code{uw1 __MXOR (uw1, uw1)}
9522 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
9523 @tab @code{MXOR @var{a},@var{b},@var{c}}
9524 @end multitable
9525
9526 @node Raw read/write Functions
9527 @subsubsection Raw read/write Functions
9528
9529 This sections describes built-in functions related to read and write
9530 instructions to access memory. These functions generate
9531 @code{membar} instructions to flush the I/O load and stores where
9532 appropriate, as described in Fujitsu's manual described above.
9533
9534 @table @code
9535
9536 @item unsigned char __builtin_read8 (void *@var{data})
9537 @item unsigned short __builtin_read16 (void *@var{data})
9538 @item unsigned long __builtin_read32 (void *@var{data})
9539 @item unsigned long long __builtin_read64 (void *@var{data})
9540
9541 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
9542 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
9543 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
9544 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
9545 @end table
9546
9547 @node Other Built-in Functions
9548 @subsubsection Other Built-in Functions
9549
9550 This section describes built-in functions that are not named after
9551 a specific FR-V instruction.
9552
9553 @table @code
9554 @item sw2 __IACCreadll (iacc @var{reg})
9555 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
9556 for future expansion and must be 0.
9557
9558 @item sw1 __IACCreadl (iacc @var{reg})
9559 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
9560 Other values of @var{reg} are rejected as invalid.
9561
9562 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
9563 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
9564 is reserved for future expansion and must be 0.
9565
9566 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
9567 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
9568 is 1. Other values of @var{reg} are rejected as invalid.
9569
9570 @item void __data_prefetch0 (const void *@var{x})
9571 Use the @code{dcpl} instruction to load the contents of address @var{x}
9572 into the data cache.
9573
9574 @item void __data_prefetch (const void *@var{x})
9575 Use the @code{nldub} instruction to load the contents of address @var{x}
9576 into the data cache. The instruction is issued in slot I1@.
9577 @end table
9578
9579 @node X86 Built-in Functions
9580 @subsection X86 Built-in Functions
9581
9582 These built-in functions are available for the i386 and x86-64 family
9583 of computers, depending on the command-line switches used.
9584
9585 If you specify command-line switches such as @option{-msse},
9586 the compiler could use the extended instruction sets even if the built-ins
9587 are not used explicitly in the program. For this reason, applications
9588 that perform run-time CPU detection must compile separate files for each
9589 supported architecture, using the appropriate flags. In particular,
9590 the file containing the CPU detection code should be compiled without
9591 these options.
9592
9593 The following machine modes are available for use with MMX built-in functions
9594 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
9595 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
9596 vector of eight 8-bit integers. Some of the built-in functions operate on
9597 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
9598
9599 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
9600 of two 32-bit floating-point values.
9601
9602 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
9603 floating-point values. Some instructions use a vector of four 32-bit
9604 integers, these use @code{V4SI}. Finally, some instructions operate on an
9605 entire vector register, interpreting it as a 128-bit integer, these use mode
9606 @code{TI}.
9607
9608 In 64-bit mode, the x86-64 family of processors uses additional built-in
9609 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
9610 floating point and @code{TC} 128-bit complex floating-point values.
9611
9612 The following floating-point built-in functions are available in 64-bit
9613 mode. All of them implement the function that is part of the name.
9614
9615 @smallexample
9616 __float128 __builtin_fabsq (__float128)
9617 __float128 __builtin_copysignq (__float128, __float128)
9618 @end smallexample
9619
9620 The following built-in function is always available.
9621
9622 @table @code
9623 @item void __builtin_ia32_pause (void)
9624 Generates the @code{pause} machine instruction with a compiler memory
9625 barrier.
9626 @end table
9627
9628 The following floating-point built-in functions are made available in the
9629 64-bit mode.
9630
9631 @table @code
9632 @item __float128 __builtin_infq (void)
9633 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
9634 @findex __builtin_infq
9635
9636 @item __float128 __builtin_huge_valq (void)
9637 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
9638 @findex __builtin_huge_valq
9639 @end table
9640
9641 The following built-in functions are always available and can be used to
9642 check the target platform type.
9643
9644 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
9645 This function runs the CPU detection code to check the type of CPU and the
9646 features supported. This built-in function needs to be invoked along with the built-in functions
9647 to check CPU type and features, @code{__builtin_cpu_is} and
9648 @code{__builtin_cpu_supports}, only when used in a function that is
9649 executed before any constructors are called. The CPU detection code is
9650 automatically executed in a very high priority constructor.
9651
9652 For example, this function has to be used in @code{ifunc} resolvers that
9653 check for CPU type using the built-in functions @code{__builtin_cpu_is}
9654 and @code{__builtin_cpu_supports}, or in constructors on targets that
9655 don't support constructor priority.
9656 @smallexample
9657
9658 static void (*resolve_memcpy (void)) (void)
9659 @{
9660 // ifunc resolvers fire before constructors, explicitly call the init
9661 // function.
9662 __builtin_cpu_init ();
9663 if (__builtin_cpu_supports ("ssse3"))
9664 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
9665 else
9666 return default_memcpy;
9667 @}
9668
9669 void *memcpy (void *, const void *, size_t)
9670 __attribute__ ((ifunc ("resolve_memcpy")));
9671 @end smallexample
9672
9673 @end deftypefn
9674
9675 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
9676 This function returns a positive integer if the run-time CPU
9677 is of type @var{cpuname}
9678 and returns @code{0} otherwise. The following CPU names can be detected:
9679
9680 @table @samp
9681 @item intel
9682 Intel CPU.
9683
9684 @item atom
9685 Intel Atom CPU.
9686
9687 @item core2
9688 Intel Core 2 CPU.
9689
9690 @item corei7
9691 Intel Core i7 CPU.
9692
9693 @item nehalem
9694 Intel Core i7 Nehalem CPU.
9695
9696 @item westmere
9697 Intel Core i7 Westmere CPU.
9698
9699 @item sandybridge
9700 Intel Core i7 Sandy Bridge CPU.
9701
9702 @item amd
9703 AMD CPU.
9704
9705 @item amdfam10h
9706 AMD Family 10h CPU.
9707
9708 @item barcelona
9709 AMD Family 10h Barcelona CPU.
9710
9711 @item shanghai
9712 AMD Family 10h Shanghai CPU.
9713
9714 @item istanbul
9715 AMD Family 10h Istanbul CPU.
9716
9717 @item btver1
9718 AMD Family 14h CPU.
9719
9720 @item amdfam15h
9721 AMD Family 15h CPU.
9722
9723 @item bdver1
9724 AMD Family 15h Bulldozer version 1.
9725
9726 @item bdver2
9727 AMD Family 15h Bulldozer version 2.
9728
9729 @item bdver3
9730 AMD Family 15h Bulldozer version 3.
9731
9732 @item btver2
9733 AMD Family 16h CPU.
9734 @end table
9735
9736 Here is an example:
9737 @smallexample
9738 if (__builtin_cpu_is ("corei7"))
9739 @{
9740 do_corei7 (); // Core i7 specific implementation.
9741 @}
9742 else
9743 @{
9744 do_generic (); // Generic implementation.
9745 @}
9746 @end smallexample
9747 @end deftypefn
9748
9749 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
9750 This function returns a positive integer if the run-time CPU
9751 supports @var{feature}
9752 and returns @code{0} otherwise. The following features can be detected:
9753
9754 @table @samp
9755 @item cmov
9756 CMOV instruction.
9757 @item mmx
9758 MMX instructions.
9759 @item popcnt
9760 POPCNT instruction.
9761 @item sse
9762 SSE instructions.
9763 @item sse2
9764 SSE2 instructions.
9765 @item sse3
9766 SSE3 instructions.
9767 @item ssse3
9768 SSSE3 instructions.
9769 @item sse4.1
9770 SSE4.1 instructions.
9771 @item sse4.2
9772 SSE4.2 instructions.
9773 @item avx
9774 AVX instructions.
9775 @item avx2
9776 AVX2 instructions.
9777 @end table
9778
9779 Here is an example:
9780 @smallexample
9781 if (__builtin_cpu_supports ("popcnt"))
9782 @{
9783 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
9784 @}
9785 else
9786 @{
9787 count = generic_countbits (n); //generic implementation.
9788 @}
9789 @end smallexample
9790 @end deftypefn
9791
9792
9793 The following built-in functions are made available by @option{-mmmx}.
9794 All of them generate the machine instruction that is part of the name.
9795
9796 @smallexample
9797 v8qi __builtin_ia32_paddb (v8qi, v8qi)
9798 v4hi __builtin_ia32_paddw (v4hi, v4hi)
9799 v2si __builtin_ia32_paddd (v2si, v2si)
9800 v8qi __builtin_ia32_psubb (v8qi, v8qi)
9801 v4hi __builtin_ia32_psubw (v4hi, v4hi)
9802 v2si __builtin_ia32_psubd (v2si, v2si)
9803 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
9804 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
9805 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
9806 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
9807 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
9808 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
9809 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
9810 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
9811 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
9812 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
9813 di __builtin_ia32_pand (di, di)
9814 di __builtin_ia32_pandn (di,di)
9815 di __builtin_ia32_por (di, di)
9816 di __builtin_ia32_pxor (di, di)
9817 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
9818 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
9819 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
9820 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
9821 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
9822 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
9823 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
9824 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
9825 v2si __builtin_ia32_punpckhdq (v2si, v2si)
9826 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
9827 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
9828 v2si __builtin_ia32_punpckldq (v2si, v2si)
9829 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
9830 v4hi __builtin_ia32_packssdw (v2si, v2si)
9831 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
9832
9833 v4hi __builtin_ia32_psllw (v4hi, v4hi)
9834 v2si __builtin_ia32_pslld (v2si, v2si)
9835 v1di __builtin_ia32_psllq (v1di, v1di)
9836 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
9837 v2si __builtin_ia32_psrld (v2si, v2si)
9838 v1di __builtin_ia32_psrlq (v1di, v1di)
9839 v4hi __builtin_ia32_psraw (v4hi, v4hi)
9840 v2si __builtin_ia32_psrad (v2si, v2si)
9841 v4hi __builtin_ia32_psllwi (v4hi, int)
9842 v2si __builtin_ia32_pslldi (v2si, int)
9843 v1di __builtin_ia32_psllqi (v1di, int)
9844 v4hi __builtin_ia32_psrlwi (v4hi, int)
9845 v2si __builtin_ia32_psrldi (v2si, int)
9846 v1di __builtin_ia32_psrlqi (v1di, int)
9847 v4hi __builtin_ia32_psrawi (v4hi, int)
9848 v2si __builtin_ia32_psradi (v2si, int)
9849
9850 @end smallexample
9851
9852 The following built-in functions are made available either with
9853 @option{-msse}, or with a combination of @option{-m3dnow} and
9854 @option{-march=athlon}. All of them generate the machine
9855 instruction that is part of the name.
9856
9857 @smallexample
9858 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
9859 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
9860 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
9861 v1di __builtin_ia32_psadbw (v8qi, v8qi)
9862 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
9863 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
9864 v8qi __builtin_ia32_pminub (v8qi, v8qi)
9865 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
9866 int __builtin_ia32_pextrw (v4hi, int)
9867 v4hi __builtin_ia32_pinsrw (v4hi, int, int)
9868 int __builtin_ia32_pmovmskb (v8qi)
9869 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
9870 void __builtin_ia32_movntq (di *, di)
9871 void __builtin_ia32_sfence (void)
9872 @end smallexample
9873
9874 The following built-in functions are available when @option{-msse} is used.
9875 All of them generate the machine instruction that is part of the name.
9876
9877 @smallexample
9878 int __builtin_ia32_comieq (v4sf, v4sf)
9879 int __builtin_ia32_comineq (v4sf, v4sf)
9880 int __builtin_ia32_comilt (v4sf, v4sf)
9881 int __builtin_ia32_comile (v4sf, v4sf)
9882 int __builtin_ia32_comigt (v4sf, v4sf)
9883 int __builtin_ia32_comige (v4sf, v4sf)
9884 int __builtin_ia32_ucomieq (v4sf, v4sf)
9885 int __builtin_ia32_ucomineq (v4sf, v4sf)
9886 int __builtin_ia32_ucomilt (v4sf, v4sf)
9887 int __builtin_ia32_ucomile (v4sf, v4sf)
9888 int __builtin_ia32_ucomigt (v4sf, v4sf)
9889 int __builtin_ia32_ucomige (v4sf, v4sf)
9890 v4sf __builtin_ia32_addps (v4sf, v4sf)
9891 v4sf __builtin_ia32_subps (v4sf, v4sf)
9892 v4sf __builtin_ia32_mulps (v4sf, v4sf)
9893 v4sf __builtin_ia32_divps (v4sf, v4sf)
9894 v4sf __builtin_ia32_addss (v4sf, v4sf)
9895 v4sf __builtin_ia32_subss (v4sf, v4sf)
9896 v4sf __builtin_ia32_mulss (v4sf, v4sf)
9897 v4sf __builtin_ia32_divss (v4sf, v4sf)
9898 v4si __builtin_ia32_cmpeqps (v4sf, v4sf)
9899 v4si __builtin_ia32_cmpltps (v4sf, v4sf)
9900 v4si __builtin_ia32_cmpleps (v4sf, v4sf)
9901 v4si __builtin_ia32_cmpgtps (v4sf, v4sf)
9902 v4si __builtin_ia32_cmpgeps (v4sf, v4sf)
9903 v4si __builtin_ia32_cmpunordps (v4sf, v4sf)
9904 v4si __builtin_ia32_cmpneqps (v4sf, v4sf)
9905 v4si __builtin_ia32_cmpnltps (v4sf, v4sf)
9906 v4si __builtin_ia32_cmpnleps (v4sf, v4sf)
9907 v4si __builtin_ia32_cmpngtps (v4sf, v4sf)
9908 v4si __builtin_ia32_cmpngeps (v4sf, v4sf)
9909 v4si __builtin_ia32_cmpordps (v4sf, v4sf)
9910 v4si __builtin_ia32_cmpeqss (v4sf, v4sf)
9911 v4si __builtin_ia32_cmpltss (v4sf, v4sf)
9912 v4si __builtin_ia32_cmpless (v4sf, v4sf)
9913 v4si __builtin_ia32_cmpunordss (v4sf, v4sf)
9914 v4si __builtin_ia32_cmpneqss (v4sf, v4sf)
9915 v4si __builtin_ia32_cmpnlts (v4sf, v4sf)
9916 v4si __builtin_ia32_cmpnless (v4sf, v4sf)
9917 v4si __builtin_ia32_cmpordss (v4sf, v4sf)
9918 v4sf __builtin_ia32_maxps (v4sf, v4sf)
9919 v4sf __builtin_ia32_maxss (v4sf, v4sf)
9920 v4sf __builtin_ia32_minps (v4sf, v4sf)
9921 v4sf __builtin_ia32_minss (v4sf, v4sf)
9922 v4sf __builtin_ia32_andps (v4sf, v4sf)
9923 v4sf __builtin_ia32_andnps (v4sf, v4sf)
9924 v4sf __builtin_ia32_orps (v4sf, v4sf)
9925 v4sf __builtin_ia32_xorps (v4sf, v4sf)
9926 v4sf __builtin_ia32_movss (v4sf, v4sf)
9927 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
9928 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
9929 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
9930 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
9931 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
9932 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
9933 v2si __builtin_ia32_cvtps2pi (v4sf)
9934 int __builtin_ia32_cvtss2si (v4sf)
9935 v2si __builtin_ia32_cvttps2pi (v4sf)
9936 int __builtin_ia32_cvttss2si (v4sf)
9937 v4sf __builtin_ia32_rcpps (v4sf)
9938 v4sf __builtin_ia32_rsqrtps (v4sf)
9939 v4sf __builtin_ia32_sqrtps (v4sf)
9940 v4sf __builtin_ia32_rcpss (v4sf)
9941 v4sf __builtin_ia32_rsqrtss (v4sf)
9942 v4sf __builtin_ia32_sqrtss (v4sf)
9943 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
9944 void __builtin_ia32_movntps (float *, v4sf)
9945 int __builtin_ia32_movmskps (v4sf)
9946 @end smallexample
9947
9948 The following built-in functions are available when @option{-msse} is used.
9949
9950 @table @code
9951 @item v4sf __builtin_ia32_loadaps (float *)
9952 Generates the @code{movaps} machine instruction as a load from memory.
9953 @item void __builtin_ia32_storeaps (float *, v4sf)
9954 Generates the @code{movaps} machine instruction as a store to memory.
9955 @item v4sf __builtin_ia32_loadups (float *)
9956 Generates the @code{movups} machine instruction as a load from memory.
9957 @item void __builtin_ia32_storeups (float *, v4sf)
9958 Generates the @code{movups} machine instruction as a store to memory.
9959 @item v4sf __builtin_ia32_loadsss (float *)
9960 Generates the @code{movss} machine instruction as a load from memory.
9961 @item void __builtin_ia32_storess (float *, v4sf)
9962 Generates the @code{movss} machine instruction as a store to memory.
9963 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
9964 Generates the @code{movhps} machine instruction as a load from memory.
9965 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
9966 Generates the @code{movlps} machine instruction as a load from memory
9967 @item void __builtin_ia32_storehps (v2sf *, v4sf)
9968 Generates the @code{movhps} machine instruction as a store to memory.
9969 @item void __builtin_ia32_storelps (v2sf *, v4sf)
9970 Generates the @code{movlps} machine instruction as a store to memory.
9971 @end table
9972
9973 The following built-in functions are available when @option{-msse2} is used.
9974 All of them generate the machine instruction that is part of the name.
9975
9976 @smallexample
9977 int __builtin_ia32_comisdeq (v2df, v2df)
9978 int __builtin_ia32_comisdlt (v2df, v2df)
9979 int __builtin_ia32_comisdle (v2df, v2df)
9980 int __builtin_ia32_comisdgt (v2df, v2df)
9981 int __builtin_ia32_comisdge (v2df, v2df)
9982 int __builtin_ia32_comisdneq (v2df, v2df)
9983 int __builtin_ia32_ucomisdeq (v2df, v2df)
9984 int __builtin_ia32_ucomisdlt (v2df, v2df)
9985 int __builtin_ia32_ucomisdle (v2df, v2df)
9986 int __builtin_ia32_ucomisdgt (v2df, v2df)
9987 int __builtin_ia32_ucomisdge (v2df, v2df)
9988 int __builtin_ia32_ucomisdneq (v2df, v2df)
9989 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
9990 v2df __builtin_ia32_cmpltpd (v2df, v2df)
9991 v2df __builtin_ia32_cmplepd (v2df, v2df)
9992 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
9993 v2df __builtin_ia32_cmpgepd (v2df, v2df)
9994 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
9995 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
9996 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
9997 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
9998 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
9999 v2df __builtin_ia32_cmpngepd (v2df, v2df)
10000 v2df __builtin_ia32_cmpordpd (v2df, v2df)
10001 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
10002 v2df __builtin_ia32_cmpltsd (v2df, v2df)
10003 v2df __builtin_ia32_cmplesd (v2df, v2df)
10004 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
10005 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
10006 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
10007 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
10008 v2df __builtin_ia32_cmpordsd (v2df, v2df)
10009 v2di __builtin_ia32_paddq (v2di, v2di)
10010 v2di __builtin_ia32_psubq (v2di, v2di)
10011 v2df __builtin_ia32_addpd (v2df, v2df)
10012 v2df __builtin_ia32_subpd (v2df, v2df)
10013 v2df __builtin_ia32_mulpd (v2df, v2df)
10014 v2df __builtin_ia32_divpd (v2df, v2df)
10015 v2df __builtin_ia32_addsd (v2df, v2df)
10016 v2df __builtin_ia32_subsd (v2df, v2df)
10017 v2df __builtin_ia32_mulsd (v2df, v2df)
10018 v2df __builtin_ia32_divsd (v2df, v2df)
10019 v2df __builtin_ia32_minpd (v2df, v2df)
10020 v2df __builtin_ia32_maxpd (v2df, v2df)
10021 v2df __builtin_ia32_minsd (v2df, v2df)
10022 v2df __builtin_ia32_maxsd (v2df, v2df)
10023 v2df __builtin_ia32_andpd (v2df, v2df)
10024 v2df __builtin_ia32_andnpd (v2df, v2df)
10025 v2df __builtin_ia32_orpd (v2df, v2df)
10026 v2df __builtin_ia32_xorpd (v2df, v2df)
10027 v2df __builtin_ia32_movsd (v2df, v2df)
10028 v2df __builtin_ia32_unpckhpd (v2df, v2df)
10029 v2df __builtin_ia32_unpcklpd (v2df, v2df)
10030 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
10031 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
10032 v4si __builtin_ia32_paddd128 (v4si, v4si)
10033 v2di __builtin_ia32_paddq128 (v2di, v2di)
10034 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
10035 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
10036 v4si __builtin_ia32_psubd128 (v4si, v4si)
10037 v2di __builtin_ia32_psubq128 (v2di, v2di)
10038 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
10039 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
10040 v2di __builtin_ia32_pand128 (v2di, v2di)
10041 v2di __builtin_ia32_pandn128 (v2di, v2di)
10042 v2di __builtin_ia32_por128 (v2di, v2di)
10043 v2di __builtin_ia32_pxor128 (v2di, v2di)
10044 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
10045 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
10046 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
10047 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
10048 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
10049 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
10050 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
10051 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
10052 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
10053 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
10054 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
10055 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
10056 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
10057 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
10058 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
10059 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
10060 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
10061 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
10062 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
10063 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
10064 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
10065 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
10066 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
10067 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
10068 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
10069 v2df __builtin_ia32_loadupd (double *)
10070 void __builtin_ia32_storeupd (double *, v2df)
10071 v2df __builtin_ia32_loadhpd (v2df, double const *)
10072 v2df __builtin_ia32_loadlpd (v2df, double const *)
10073 int __builtin_ia32_movmskpd (v2df)
10074 int __builtin_ia32_pmovmskb128 (v16qi)
10075 void __builtin_ia32_movnti (int *, int)
10076 void __builtin_ia32_movnti64 (long long int *, long long int)
10077 void __builtin_ia32_movntpd (double *, v2df)
10078 void __builtin_ia32_movntdq (v2df *, v2df)
10079 v4si __builtin_ia32_pshufd (v4si, int)
10080 v8hi __builtin_ia32_pshuflw (v8hi, int)
10081 v8hi __builtin_ia32_pshufhw (v8hi, int)
10082 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
10083 v2df __builtin_ia32_sqrtpd (v2df)
10084 v2df __builtin_ia32_sqrtsd (v2df)
10085 v2df __builtin_ia32_shufpd (v2df, v2df, int)
10086 v2df __builtin_ia32_cvtdq2pd (v4si)
10087 v4sf __builtin_ia32_cvtdq2ps (v4si)
10088 v4si __builtin_ia32_cvtpd2dq (v2df)
10089 v2si __builtin_ia32_cvtpd2pi (v2df)
10090 v4sf __builtin_ia32_cvtpd2ps (v2df)
10091 v4si __builtin_ia32_cvttpd2dq (v2df)
10092 v2si __builtin_ia32_cvttpd2pi (v2df)
10093 v2df __builtin_ia32_cvtpi2pd (v2si)
10094 int __builtin_ia32_cvtsd2si (v2df)
10095 int __builtin_ia32_cvttsd2si (v2df)
10096 long long __builtin_ia32_cvtsd2si64 (v2df)
10097 long long __builtin_ia32_cvttsd2si64 (v2df)
10098 v4si __builtin_ia32_cvtps2dq (v4sf)
10099 v2df __builtin_ia32_cvtps2pd (v4sf)
10100 v4si __builtin_ia32_cvttps2dq (v4sf)
10101 v2df __builtin_ia32_cvtsi2sd (v2df, int)
10102 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
10103 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
10104 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
10105 void __builtin_ia32_clflush (const void *)
10106 void __builtin_ia32_lfence (void)
10107 void __builtin_ia32_mfence (void)
10108 v16qi __builtin_ia32_loaddqu (const char *)
10109 void __builtin_ia32_storedqu (char *, v16qi)
10110 v1di __builtin_ia32_pmuludq (v2si, v2si)
10111 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
10112 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
10113 v4si __builtin_ia32_pslld128 (v4si, v4si)
10114 v2di __builtin_ia32_psllq128 (v2di, v2di)
10115 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
10116 v4si __builtin_ia32_psrld128 (v4si, v4si)
10117 v2di __builtin_ia32_psrlq128 (v2di, v2di)
10118 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
10119 v4si __builtin_ia32_psrad128 (v4si, v4si)
10120 v2di __builtin_ia32_pslldqi128 (v2di, int)
10121 v8hi __builtin_ia32_psllwi128 (v8hi, int)
10122 v4si __builtin_ia32_pslldi128 (v4si, int)
10123 v2di __builtin_ia32_psllqi128 (v2di, int)
10124 v2di __builtin_ia32_psrldqi128 (v2di, int)
10125 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
10126 v4si __builtin_ia32_psrldi128 (v4si, int)
10127 v2di __builtin_ia32_psrlqi128 (v2di, int)
10128 v8hi __builtin_ia32_psrawi128 (v8hi, int)
10129 v4si __builtin_ia32_psradi128 (v4si, int)
10130 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
10131 v2di __builtin_ia32_movq128 (v2di)
10132 @end smallexample
10133
10134 The following built-in functions are available when @option{-msse3} is used.
10135 All of them generate the machine instruction that is part of the name.
10136
10137 @smallexample
10138 v2df __builtin_ia32_addsubpd (v2df, v2df)
10139 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
10140 v2df __builtin_ia32_haddpd (v2df, v2df)
10141 v4sf __builtin_ia32_haddps (v4sf, v4sf)
10142 v2df __builtin_ia32_hsubpd (v2df, v2df)
10143 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
10144 v16qi __builtin_ia32_lddqu (char const *)
10145 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
10146 v2df __builtin_ia32_movddup (v2df)
10147 v4sf __builtin_ia32_movshdup (v4sf)
10148 v4sf __builtin_ia32_movsldup (v4sf)
10149 void __builtin_ia32_mwait (unsigned int, unsigned int)
10150 @end smallexample
10151
10152 The following built-in functions are available when @option{-msse3} is used.
10153
10154 @table @code
10155 @item v2df __builtin_ia32_loadddup (double const *)
10156 Generates the @code{movddup} machine instruction as a load from memory.
10157 @end table
10158
10159 The following built-in functions are available when @option{-mssse3} is used.
10160 All of them generate the machine instruction that is part of the name
10161 with MMX registers.
10162
10163 @smallexample
10164 v2si __builtin_ia32_phaddd (v2si, v2si)
10165 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
10166 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
10167 v2si __builtin_ia32_phsubd (v2si, v2si)
10168 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
10169 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
10170 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
10171 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
10172 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
10173 v8qi __builtin_ia32_psignb (v8qi, v8qi)
10174 v2si __builtin_ia32_psignd (v2si, v2si)
10175 v4hi __builtin_ia32_psignw (v4hi, v4hi)
10176 v1di __builtin_ia32_palignr (v1di, v1di, int)
10177 v8qi __builtin_ia32_pabsb (v8qi)
10178 v2si __builtin_ia32_pabsd (v2si)
10179 v4hi __builtin_ia32_pabsw (v4hi)
10180 @end smallexample
10181
10182 The following built-in functions are available when @option{-mssse3} is used.
10183 All of them generate the machine instruction that is part of the name
10184 with SSE registers.
10185
10186 @smallexample
10187 v4si __builtin_ia32_phaddd128 (v4si, v4si)
10188 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
10189 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
10190 v4si __builtin_ia32_phsubd128 (v4si, v4si)
10191 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
10192 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
10193 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
10194 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
10195 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
10196 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
10197 v4si __builtin_ia32_psignd128 (v4si, v4si)
10198 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
10199 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
10200 v16qi __builtin_ia32_pabsb128 (v16qi)
10201 v4si __builtin_ia32_pabsd128 (v4si)
10202 v8hi __builtin_ia32_pabsw128 (v8hi)
10203 @end smallexample
10204
10205 The following built-in functions are available when @option{-msse4.1} is
10206 used. All of them generate the machine instruction that is part of the
10207 name.
10208
10209 @smallexample
10210 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
10211 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
10212 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
10213 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
10214 v2df __builtin_ia32_dppd (v2df, v2df, const int)
10215 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
10216 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
10217 v2di __builtin_ia32_movntdqa (v2di *);
10218 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
10219 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
10220 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
10221 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
10222 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
10223 v8hi __builtin_ia32_phminposuw128 (v8hi)
10224 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
10225 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
10226 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
10227 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
10228 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
10229 v4si __builtin_ia32_pminsd128 (v4si, v4si)
10230 v4si __builtin_ia32_pminud128 (v4si, v4si)
10231 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
10232 v4si __builtin_ia32_pmovsxbd128 (v16qi)
10233 v2di __builtin_ia32_pmovsxbq128 (v16qi)
10234 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
10235 v2di __builtin_ia32_pmovsxdq128 (v4si)
10236 v4si __builtin_ia32_pmovsxwd128 (v8hi)
10237 v2di __builtin_ia32_pmovsxwq128 (v8hi)
10238 v4si __builtin_ia32_pmovzxbd128 (v16qi)
10239 v2di __builtin_ia32_pmovzxbq128 (v16qi)
10240 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
10241 v2di __builtin_ia32_pmovzxdq128 (v4si)
10242 v4si __builtin_ia32_pmovzxwd128 (v8hi)
10243 v2di __builtin_ia32_pmovzxwq128 (v8hi)
10244 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
10245 v4si __builtin_ia32_pmulld128 (v4si, v4si)
10246 int __builtin_ia32_ptestc128 (v2di, v2di)
10247 int __builtin_ia32_ptestnzc128 (v2di, v2di)
10248 int __builtin_ia32_ptestz128 (v2di, v2di)
10249 v2df __builtin_ia32_roundpd (v2df, const int)
10250 v4sf __builtin_ia32_roundps (v4sf, const int)
10251 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
10252 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
10253 @end smallexample
10254
10255 The following built-in functions are available when @option{-msse4.1} is
10256 used.
10257
10258 @table @code
10259 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
10260 Generates the @code{insertps} machine instruction.
10261 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
10262 Generates the @code{pextrb} machine instruction.
10263 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
10264 Generates the @code{pinsrb} machine instruction.
10265 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
10266 Generates the @code{pinsrd} machine instruction.
10267 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
10268 Generates the @code{pinsrq} machine instruction in 64bit mode.
10269 @end table
10270
10271 The following built-in functions are changed to generate new SSE4.1
10272 instructions when @option{-msse4.1} is used.
10273
10274 @table @code
10275 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
10276 Generates the @code{extractps} machine instruction.
10277 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
10278 Generates the @code{pextrd} machine instruction.
10279 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
10280 Generates the @code{pextrq} machine instruction in 64bit mode.
10281 @end table
10282
10283 The following built-in functions are available when @option{-msse4.2} is
10284 used. All of them generate the machine instruction that is part of the
10285 name.
10286
10287 @smallexample
10288 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
10289 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
10290 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
10291 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
10292 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
10293 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
10294 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
10295 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
10296 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
10297 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
10298 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
10299 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
10300 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
10301 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
10302 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
10303 @end smallexample
10304
10305 The following built-in functions are available when @option{-msse4.2} is
10306 used.
10307
10308 @table @code
10309 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
10310 Generates the @code{crc32b} machine instruction.
10311 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
10312 Generates the @code{crc32w} machine instruction.
10313 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
10314 Generates the @code{crc32l} machine instruction.
10315 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
10316 Generates the @code{crc32q} machine instruction.
10317 @end table
10318
10319 The following built-in functions are changed to generate new SSE4.2
10320 instructions when @option{-msse4.2} is used.
10321
10322 @table @code
10323 @item int __builtin_popcount (unsigned int)
10324 Generates the @code{popcntl} machine instruction.
10325 @item int __builtin_popcountl (unsigned long)
10326 Generates the @code{popcntl} or @code{popcntq} machine instruction,
10327 depending on the size of @code{unsigned long}.
10328 @item int __builtin_popcountll (unsigned long long)
10329 Generates the @code{popcntq} machine instruction.
10330 @end table
10331
10332 The following built-in functions are available when @option{-mavx} is
10333 used. All of them generate the machine instruction that is part of the
10334 name.
10335
10336 @smallexample
10337 v4df __builtin_ia32_addpd256 (v4df,v4df)
10338 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
10339 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
10340 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
10341 v4df __builtin_ia32_andnpd256 (v4df,v4df)
10342 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
10343 v4df __builtin_ia32_andpd256 (v4df,v4df)
10344 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
10345 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
10346 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
10347 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
10348 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
10349 v2df __builtin_ia32_cmppd (v2df,v2df,int)
10350 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
10351 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
10352 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
10353 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
10354 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
10355 v4df __builtin_ia32_cvtdq2pd256 (v4si)
10356 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
10357 v4si __builtin_ia32_cvtpd2dq256 (v4df)
10358 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
10359 v8si __builtin_ia32_cvtps2dq256 (v8sf)
10360 v4df __builtin_ia32_cvtps2pd256 (v4sf)
10361 v4si __builtin_ia32_cvttpd2dq256 (v4df)
10362 v8si __builtin_ia32_cvttps2dq256 (v8sf)
10363 v4df __builtin_ia32_divpd256 (v4df,v4df)
10364 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
10365 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
10366 v4df __builtin_ia32_haddpd256 (v4df,v4df)
10367 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
10368 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
10369 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
10370 v32qi __builtin_ia32_lddqu256 (pcchar)
10371 v32qi __builtin_ia32_loaddqu256 (pcchar)
10372 v4df __builtin_ia32_loadupd256 (pcdouble)
10373 v8sf __builtin_ia32_loadups256 (pcfloat)
10374 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
10375 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
10376 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
10377 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
10378 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
10379 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
10380 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
10381 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
10382 v4df __builtin_ia32_maxpd256 (v4df,v4df)
10383 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
10384 v4df __builtin_ia32_minpd256 (v4df,v4df)
10385 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
10386 v4df __builtin_ia32_movddup256 (v4df)
10387 int __builtin_ia32_movmskpd256 (v4df)
10388 int __builtin_ia32_movmskps256 (v8sf)
10389 v8sf __builtin_ia32_movshdup256 (v8sf)
10390 v8sf __builtin_ia32_movsldup256 (v8sf)
10391 v4df __builtin_ia32_mulpd256 (v4df,v4df)
10392 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
10393 v4df __builtin_ia32_orpd256 (v4df,v4df)
10394 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
10395 v2df __builtin_ia32_pd_pd256 (v4df)
10396 v4df __builtin_ia32_pd256_pd (v2df)
10397 v4sf __builtin_ia32_ps_ps256 (v8sf)
10398 v8sf __builtin_ia32_ps256_ps (v4sf)
10399 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
10400 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
10401 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
10402 v8sf __builtin_ia32_rcpps256 (v8sf)
10403 v4df __builtin_ia32_roundpd256 (v4df,int)
10404 v8sf __builtin_ia32_roundps256 (v8sf,int)
10405 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
10406 v8sf __builtin_ia32_rsqrtps256 (v8sf)
10407 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
10408 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
10409 v4si __builtin_ia32_si_si256 (v8si)
10410 v8si __builtin_ia32_si256_si (v4si)
10411 v4df __builtin_ia32_sqrtpd256 (v4df)
10412 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
10413 v8sf __builtin_ia32_sqrtps256 (v8sf)
10414 void __builtin_ia32_storedqu256 (pchar,v32qi)
10415 void __builtin_ia32_storeupd256 (pdouble,v4df)
10416 void __builtin_ia32_storeups256 (pfloat,v8sf)
10417 v4df __builtin_ia32_subpd256 (v4df,v4df)
10418 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
10419 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
10420 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
10421 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
10422 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
10423 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
10424 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
10425 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
10426 v4sf __builtin_ia32_vbroadcastss (pcfloat)
10427 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
10428 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
10429 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
10430 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
10431 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
10432 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
10433 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
10434 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
10435 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
10436 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
10437 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
10438 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
10439 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
10440 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
10441 v2df __builtin_ia32_vpermilpd (v2df,int)
10442 v4df __builtin_ia32_vpermilpd256 (v4df,int)
10443 v4sf __builtin_ia32_vpermilps (v4sf,int)
10444 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
10445 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
10446 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
10447 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
10448 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
10449 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
10450 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
10451 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
10452 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
10453 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
10454 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
10455 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
10456 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
10457 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
10458 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
10459 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
10460 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
10461 void __builtin_ia32_vzeroall (void)
10462 void __builtin_ia32_vzeroupper (void)
10463 v4df __builtin_ia32_xorpd256 (v4df,v4df)
10464 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
10465 @end smallexample
10466
10467 The following built-in functions are available when @option{-mavx2} is
10468 used. All of them generate the machine instruction that is part of the
10469 name.
10470
10471 @smallexample
10472 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,v32qi,int)
10473 v32qi __builtin_ia32_pabsb256 (v32qi)
10474 v16hi __builtin_ia32_pabsw256 (v16hi)
10475 v8si __builtin_ia32_pabsd256 (v8si)
10476 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
10477 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
10478 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
10479 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
10480 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
10481 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
10482 v8si __builtin_ia32_paddd256 (v8si,v8si)
10483 v4di __builtin_ia32_paddq256 (v4di,v4di)
10484 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
10485 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
10486 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
10487 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
10488 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
10489 v4di __builtin_ia32_andsi256 (v4di,v4di)
10490 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
10491 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
10492 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
10493 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
10494 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
10495 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
10496 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
10497 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
10498 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
10499 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
10500 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
10501 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
10502 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
10503 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
10504 v8si __builtin_ia32_phaddd256 (v8si,v8si)
10505 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
10506 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
10507 v8si __builtin_ia32_phsubd256 (v8si,v8si)
10508 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
10509 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
10510 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
10511 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
10512 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
10513 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
10514 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
10515 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
10516 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
10517 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
10518 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
10519 v8si __builtin_ia32_pminsd256 (v8si,v8si)
10520 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
10521 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
10522 v8si __builtin_ia32_pminud256 (v8si,v8si)
10523 int __builtin_ia32_pmovmskb256 (v32qi)
10524 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
10525 v8si __builtin_ia32_pmovsxbd256 (v16qi)
10526 v4di __builtin_ia32_pmovsxbq256 (v16qi)
10527 v8si __builtin_ia32_pmovsxwd256 (v8hi)
10528 v4di __builtin_ia32_pmovsxwq256 (v8hi)
10529 v4di __builtin_ia32_pmovsxdq256 (v4si)
10530 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
10531 v8si __builtin_ia32_pmovzxbd256 (v16qi)
10532 v4di __builtin_ia32_pmovzxbq256 (v16qi)
10533 v8si __builtin_ia32_pmovzxwd256 (v8hi)
10534 v4di __builtin_ia32_pmovzxwq256 (v8hi)
10535 v4di __builtin_ia32_pmovzxdq256 (v4si)
10536 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
10537 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
10538 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
10539 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
10540 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
10541 v8si __builtin_ia32_pmulld256 (v8si,v8si)
10542 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
10543 v4di __builtin_ia32_por256 (v4di,v4di)
10544 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
10545 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
10546 v8si __builtin_ia32_pshufd256 (v8si,int)
10547 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
10548 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
10549 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
10550 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
10551 v8si __builtin_ia32_psignd256 (v8si,v8si)
10552 v4di __builtin_ia32_pslldqi256 (v4di,int)
10553 v16hi __builtin_ia32_psllwi256 (16hi,int)
10554 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
10555 v8si __builtin_ia32_pslldi256 (v8si,int)
10556 v8si __builtin_ia32_pslld256(v8si,v4si)
10557 v4di __builtin_ia32_psllqi256 (v4di,int)
10558 v4di __builtin_ia32_psllq256(v4di,v2di)
10559 v16hi __builtin_ia32_psrawi256 (v16hi,int)
10560 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
10561 v8si __builtin_ia32_psradi256 (v8si,int)
10562 v8si __builtin_ia32_psrad256 (v8si,v4si)
10563 v4di __builtin_ia32_psrldqi256 (v4di, int)
10564 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
10565 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
10566 v8si __builtin_ia32_psrldi256 (v8si,int)
10567 v8si __builtin_ia32_psrld256 (v8si,v4si)
10568 v4di __builtin_ia32_psrlqi256 (v4di,int)
10569 v4di __builtin_ia32_psrlq256(v4di,v2di)
10570 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
10571 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
10572 v8si __builtin_ia32_psubd256 (v8si,v8si)
10573 v4di __builtin_ia32_psubq256 (v4di,v4di)
10574 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
10575 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
10576 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
10577 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
10578 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
10579 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
10580 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
10581 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
10582 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
10583 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
10584 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
10585 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
10586 v4di __builtin_ia32_pxor256 (v4di,v4di)
10587 v4di __builtin_ia32_movntdqa256 (pv4di)
10588 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
10589 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
10590 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
10591 v4di __builtin_ia32_vbroadcastsi256 (v2di)
10592 v4si __builtin_ia32_pblendd128 (v4si,v4si)
10593 v8si __builtin_ia32_pblendd256 (v8si,v8si)
10594 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
10595 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
10596 v8si __builtin_ia32_pbroadcastd256 (v4si)
10597 v4di __builtin_ia32_pbroadcastq256 (v2di)
10598 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
10599 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
10600 v4si __builtin_ia32_pbroadcastd128 (v4si)
10601 v2di __builtin_ia32_pbroadcastq128 (v2di)
10602 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
10603 v4df __builtin_ia32_permdf256 (v4df,int)
10604 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
10605 v4di __builtin_ia32_permdi256 (v4di,int)
10606 v4di __builtin_ia32_permti256 (v4di,v4di,int)
10607 v4di __builtin_ia32_extract128i256 (v4di,int)
10608 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
10609 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
10610 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
10611 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
10612 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
10613 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
10614 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
10615 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
10616 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
10617 v8si __builtin_ia32_psllv8si (v8si,v8si)
10618 v4si __builtin_ia32_psllv4si (v4si,v4si)
10619 v4di __builtin_ia32_psllv4di (v4di,v4di)
10620 v2di __builtin_ia32_psllv2di (v2di,v2di)
10621 v8si __builtin_ia32_psrav8si (v8si,v8si)
10622 v4si __builtin_ia32_psrav4si (v4si,v4si)
10623 v8si __builtin_ia32_psrlv8si (v8si,v8si)
10624 v4si __builtin_ia32_psrlv4si (v4si,v4si)
10625 v4di __builtin_ia32_psrlv4di (v4di,v4di)
10626 v2di __builtin_ia32_psrlv2di (v2di,v2di)
10627 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
10628 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
10629 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
10630 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
10631 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
10632 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
10633 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
10634 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
10635 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
10636 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
10637 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
10638 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
10639 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
10640 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
10641 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
10642 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
10643 @end smallexample
10644
10645 The following built-in functions are available when @option{-maes} is
10646 used. All of them generate the machine instruction that is part of the
10647 name.
10648
10649 @smallexample
10650 v2di __builtin_ia32_aesenc128 (v2di, v2di)
10651 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
10652 v2di __builtin_ia32_aesdec128 (v2di, v2di)
10653 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
10654 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
10655 v2di __builtin_ia32_aesimc128 (v2di)
10656 @end smallexample
10657
10658 The following built-in function is available when @option{-mpclmul} is
10659 used.
10660
10661 @table @code
10662 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
10663 Generates the @code{pclmulqdq} machine instruction.
10664 @end table
10665
10666 The following built-in function is available when @option{-mfsgsbase} is
10667 used. All of them generate the machine instruction that is part of the
10668 name.
10669
10670 @smallexample
10671 unsigned int __builtin_ia32_rdfsbase32 (void)
10672 unsigned long long __builtin_ia32_rdfsbase64 (void)
10673 unsigned int __builtin_ia32_rdgsbase32 (void)
10674 unsigned long long __builtin_ia32_rdgsbase64 (void)
10675 void _writefsbase_u32 (unsigned int)
10676 void _writefsbase_u64 (unsigned long long)
10677 void _writegsbase_u32 (unsigned int)
10678 void _writegsbase_u64 (unsigned long long)
10679 @end smallexample
10680
10681 The following built-in function is available when @option{-mrdrnd} is
10682 used. All of them generate the machine instruction that is part of the
10683 name.
10684
10685 @smallexample
10686 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
10687 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
10688 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
10689 @end smallexample
10690
10691 The following built-in functions are available when @option{-msse4a} is used.
10692 All of them generate the machine instruction that is part of the name.
10693
10694 @smallexample
10695 void __builtin_ia32_movntsd (double *, v2df)
10696 void __builtin_ia32_movntss (float *, v4sf)
10697 v2di __builtin_ia32_extrq (v2di, v16qi)
10698 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
10699 v2di __builtin_ia32_insertq (v2di, v2di)
10700 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
10701 @end smallexample
10702
10703 The following built-in functions are available when @option{-mxop} is used.
10704 @smallexample
10705 v2df __builtin_ia32_vfrczpd (v2df)
10706 v4sf __builtin_ia32_vfrczps (v4sf)
10707 v2df __builtin_ia32_vfrczsd (v2df, v2df)
10708 v4sf __builtin_ia32_vfrczss (v4sf, v4sf)
10709 v4df __builtin_ia32_vfrczpd256 (v4df)
10710 v8sf __builtin_ia32_vfrczps256 (v8sf)
10711 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
10712 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
10713 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
10714 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
10715 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
10716 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
10717 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
10718 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
10719 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
10720 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
10721 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
10722 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
10723 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
10724 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
10725 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
10726 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
10727 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
10728 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
10729 v4si __builtin_ia32_vpcomequd (v4si, v4si)
10730 v2di __builtin_ia32_vpcomequq (v2di, v2di)
10731 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
10732 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
10733 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
10734 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
10735 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
10736 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
10737 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
10738 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
10739 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
10740 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
10741 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
10742 v4si __builtin_ia32_vpcomged (v4si, v4si)
10743 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
10744 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
10745 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
10746 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
10747 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
10748 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
10749 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
10750 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
10751 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
10752 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
10753 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
10754 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
10755 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
10756 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
10757 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
10758 v4si __builtin_ia32_vpcomled (v4si, v4si)
10759 v2di __builtin_ia32_vpcomleq (v2di, v2di)
10760 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
10761 v4si __builtin_ia32_vpcomleud (v4si, v4si)
10762 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
10763 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
10764 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
10765 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
10766 v4si __builtin_ia32_vpcomltd (v4si, v4si)
10767 v2di __builtin_ia32_vpcomltq (v2di, v2di)
10768 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
10769 v4si __builtin_ia32_vpcomltud (v4si, v4si)
10770 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
10771 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
10772 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
10773 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
10774 v4si __builtin_ia32_vpcomned (v4si, v4si)
10775 v2di __builtin_ia32_vpcomneq (v2di, v2di)
10776 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
10777 v4si __builtin_ia32_vpcomneud (v4si, v4si)
10778 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
10779 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
10780 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
10781 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
10782 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
10783 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
10784 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
10785 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
10786 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
10787 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
10788 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
10789 v4si __builtin_ia32_vphaddbd (v16qi)
10790 v2di __builtin_ia32_vphaddbq (v16qi)
10791 v8hi __builtin_ia32_vphaddbw (v16qi)
10792 v2di __builtin_ia32_vphadddq (v4si)
10793 v4si __builtin_ia32_vphaddubd (v16qi)
10794 v2di __builtin_ia32_vphaddubq (v16qi)
10795 v8hi __builtin_ia32_vphaddubw (v16qi)
10796 v2di __builtin_ia32_vphaddudq (v4si)
10797 v4si __builtin_ia32_vphadduwd (v8hi)
10798 v2di __builtin_ia32_vphadduwq (v8hi)
10799 v4si __builtin_ia32_vphaddwd (v8hi)
10800 v2di __builtin_ia32_vphaddwq (v8hi)
10801 v8hi __builtin_ia32_vphsubbw (v16qi)
10802 v2di __builtin_ia32_vphsubdq (v4si)
10803 v4si __builtin_ia32_vphsubwd (v8hi)
10804 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
10805 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
10806 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
10807 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
10808 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
10809 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
10810 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
10811 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
10812 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
10813 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
10814 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
10815 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
10816 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
10817 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
10818 v4si __builtin_ia32_vprotd (v4si, v4si)
10819 v2di __builtin_ia32_vprotq (v2di, v2di)
10820 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
10821 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
10822 v4si __builtin_ia32_vpshad (v4si, v4si)
10823 v2di __builtin_ia32_vpshaq (v2di, v2di)
10824 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
10825 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
10826 v4si __builtin_ia32_vpshld (v4si, v4si)
10827 v2di __builtin_ia32_vpshlq (v2di, v2di)
10828 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
10829 @end smallexample
10830
10831 The following built-in functions are available when @option{-mfma4} is used.
10832 All of them generate the machine instruction that is part of the name
10833 with MMX registers.
10834
10835 @smallexample
10836 v2df __builtin_ia32_fmaddpd (v2df, v2df, v2df)
10837 v4sf __builtin_ia32_fmaddps (v4sf, v4sf, v4sf)
10838 v2df __builtin_ia32_fmaddsd (v2df, v2df, v2df)
10839 v4sf __builtin_ia32_fmaddss (v4sf, v4sf, v4sf)
10840 v2df __builtin_ia32_fmsubpd (v2df, v2df, v2df)
10841 v4sf __builtin_ia32_fmsubps (v4sf, v4sf, v4sf)
10842 v2df __builtin_ia32_fmsubsd (v2df, v2df, v2df)
10843 v4sf __builtin_ia32_fmsubss (v4sf, v4sf, v4sf)
10844 v2df __builtin_ia32_fnmaddpd (v2df, v2df, v2df)
10845 v4sf __builtin_ia32_fnmaddps (v4sf, v4sf, v4sf)
10846 v2df __builtin_ia32_fnmaddsd (v2df, v2df, v2df)
10847 v4sf __builtin_ia32_fnmaddss (v4sf, v4sf, v4sf)
10848 v2df __builtin_ia32_fnmsubpd (v2df, v2df, v2df)
10849 v4sf __builtin_ia32_fnmsubps (v4sf, v4sf, v4sf)
10850 v2df __builtin_ia32_fnmsubsd (v2df, v2df, v2df)
10851 v4sf __builtin_ia32_fnmsubss (v4sf, v4sf, v4sf)
10852 v2df __builtin_ia32_fmaddsubpd (v2df, v2df, v2df)
10853 v4sf __builtin_ia32_fmaddsubps (v4sf, v4sf, v4sf)
10854 v2df __builtin_ia32_fmsubaddpd (v2df, v2df, v2df)
10855 v4sf __builtin_ia32_fmsubaddps (v4sf, v4sf, v4sf)
10856 v4df __builtin_ia32_fmaddpd256 (v4df, v4df, v4df)
10857 v8sf __builtin_ia32_fmaddps256 (v8sf, v8sf, v8sf)
10858 v4df __builtin_ia32_fmsubpd256 (v4df, v4df, v4df)
10859 v8sf __builtin_ia32_fmsubps256 (v8sf, v8sf, v8sf)
10860 v4df __builtin_ia32_fnmaddpd256 (v4df, v4df, v4df)
10861 v8sf __builtin_ia32_fnmaddps256 (v8sf, v8sf, v8sf)
10862 v4df __builtin_ia32_fnmsubpd256 (v4df, v4df, v4df)
10863 v8sf __builtin_ia32_fnmsubps256 (v8sf, v8sf, v8sf)
10864 v4df __builtin_ia32_fmaddsubpd256 (v4df, v4df, v4df)
10865 v8sf __builtin_ia32_fmaddsubps256 (v8sf, v8sf, v8sf)
10866 v4df __builtin_ia32_fmsubaddpd256 (v4df, v4df, v4df)
10867 v8sf __builtin_ia32_fmsubaddps256 (v8sf, v8sf, v8sf)
10868
10869 @end smallexample
10870
10871 The following built-in functions are available when @option{-mlwp} is used.
10872
10873 @smallexample
10874 void __builtin_ia32_llwpcb16 (void *);
10875 void __builtin_ia32_llwpcb32 (void *);
10876 void __builtin_ia32_llwpcb64 (void *);
10877 void * __builtin_ia32_llwpcb16 (void);
10878 void * __builtin_ia32_llwpcb32 (void);
10879 void * __builtin_ia32_llwpcb64 (void);
10880 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
10881 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
10882 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
10883 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
10884 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
10885 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
10886 @end smallexample
10887
10888 The following built-in functions are available when @option{-mbmi} is used.
10889 All of them generate the machine instruction that is part of the name.
10890 @smallexample
10891 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
10892 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
10893 @end smallexample
10894
10895 The following built-in functions are available when @option{-mbmi2} is used.
10896 All of them generate the machine instruction that is part of the name.
10897 @smallexample
10898 unsigned int _bzhi_u32 (unsigned int, unsigned int)
10899 unsigned int _pdep_u32 (unsigned int, unsigned int)
10900 unsigned int _pext_u32 (unsigned int, unsigned int)
10901 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
10902 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
10903 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
10904 @end smallexample
10905
10906 The following built-in functions are available when @option{-mlzcnt} is used.
10907 All of them generate the machine instruction that is part of the name.
10908 @smallexample
10909 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
10910 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
10911 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
10912 @end smallexample
10913
10914 The following built-in functions are available when @option{-mtbm} is used.
10915 Both of them generate the immediate form of the bextr machine instruction.
10916 @smallexample
10917 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
10918 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
10919 @end smallexample
10920
10921
10922 The following built-in functions are available when @option{-m3dnow} is used.
10923 All of them generate the machine instruction that is part of the name.
10924
10925 @smallexample
10926 void __builtin_ia32_femms (void)
10927 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
10928 v2si __builtin_ia32_pf2id (v2sf)
10929 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
10930 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
10931 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
10932 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
10933 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
10934 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
10935 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
10936 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
10937 v2sf __builtin_ia32_pfrcp (v2sf)
10938 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
10939 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
10940 v2sf __builtin_ia32_pfrsqrt (v2sf)
10941 v2sf __builtin_ia32_pfrsqrtit1 (v2sf, v2sf)
10942 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
10943 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
10944 v2sf __builtin_ia32_pi2fd (v2si)
10945 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
10946 @end smallexample
10947
10948 The following built-in functions are available when both @option{-m3dnow}
10949 and @option{-march=athlon} are used. All of them generate the machine
10950 instruction that is part of the name.
10951
10952 @smallexample
10953 v2si __builtin_ia32_pf2iw (v2sf)
10954 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
10955 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
10956 v2sf __builtin_ia32_pi2fw (v2si)
10957 v2sf __builtin_ia32_pswapdsf (v2sf)
10958 v2si __builtin_ia32_pswapdsi (v2si)
10959 @end smallexample
10960
10961 The following built-in functions are available when @option{-mrtm} is used
10962 They are used for restricted transactional memory. These are the internal
10963 low level functions. Normally the functions in
10964 @ref{X86 transactional memory intrinsics} should be used instead.
10965
10966 @smallexample
10967 int __builtin_ia32_xbegin ()
10968 void __builtin_ia32_xend ()
10969 void __builtin_ia32_xabort (status)
10970 int __builtin_ia32_xtest ()
10971 @end smallexample
10972
10973 @node X86 transactional memory intrinsics
10974 @subsection X86 transaction memory intrinsics
10975
10976 Hardware transactional memory intrinsics for i386. These allow to use
10977 memory transactions with RTM (Restricted Transactional Memory).
10978 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
10979 This support is enabled with the @option{-mrtm} option.
10980
10981 A memory transaction commits all changes to memory in an atomic way,
10982 as visible to other threads. If the transaction fails it is rolled back
10983 and all side effects discarded.
10984
10985 Generally there is no guarantee that a memory transaction ever suceeds
10986 and suitable fallback code always needs to be supplied.
10987
10988 @deftypefn {RTM Function} {unsigned} _xbegin ()
10989 Start a RTM (Restricted Transactional Memory) transaction.
10990 Returns _XBEGIN_STARTED when the transaction
10991 started successfully (note this is not 0, so the constant has to be
10992 explicitely tested). When the transaction aborts all side effects
10993 are undone and an abort code is returned. There is no guarantee
10994 any transaction ever succeeds, so there always needs to be a valid
10995 tested fallback path.
10996 @end deftypefn
10997
10998 @smallexample
10999 #include <immintrin.h>
11000
11001 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
11002 ... transaction code...
11003 _xend ();
11004 @} else @{
11005 ... non transactional fallback path...
11006 @}
11007 @end smallexample
11008
11009 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
11010
11011 @table @code
11012 @item _XABORT_EXPLICIT
11013 Transaction explicitely aborted with @code{_xabort}. The parameter passed
11014 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
11015 @item _XABORT_RETRY
11016 Transaction retry is possible.
11017 @item _XABORT_CONFLICT
11018 Transaction abort due to a memory conflict with another thread
11019 @item _XABORT_CAPACITY
11020 Transaction abort due to the transaction using too much memory
11021 @item _XABORT_DEBUG
11022 Transaction abort due to a debug trap
11023 @item _XABORT_NESTED
11024 Transaction abort in a inner nested transaction
11025 @end table
11026
11027 @deftypefn {RTM Function} {void} _xend ()
11028 Commit the current transaction. When no transaction is active this will
11029 fault. All memory side effects of the transactions will become visible
11030 to other threads in an atomic matter.
11031 @end deftypefn
11032
11033 @deftypefn {RTM Function} {int} _xtest ()
11034 Return a value not zero when a transaction is currently active, otherwise 0.
11035 @end deftypefn
11036
11037 @deftypefn {RTM Function} {void} _xabort (status)
11038 Abort the current transaction. When no transaction is active this is a no-op.
11039 status must be a 8bit constant, that is included in the status code returned
11040 by @code{_xbegin}
11041 @end deftypefn
11042
11043 @node MIPS DSP Built-in Functions
11044 @subsection MIPS DSP Built-in Functions
11045
11046 The MIPS DSP Application-Specific Extension (ASE) includes new
11047 instructions that are designed to improve the performance of DSP and
11048 media applications. It provides instructions that operate on packed
11049 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
11050
11051 GCC supports MIPS DSP operations using both the generic
11052 vector extensions (@pxref{Vector Extensions}) and a collection of
11053 MIPS-specific built-in functions. Both kinds of support are
11054 enabled by the @option{-mdsp} command-line option.
11055
11056 Revision 2 of the ASE was introduced in the second half of 2006.
11057 This revision adds extra instructions to the original ASE, but is
11058 otherwise backwards-compatible with it. You can select revision 2
11059 using the command-line option @option{-mdspr2}; this option implies
11060 @option{-mdsp}.
11061
11062 The SCOUNT and POS bits of the DSP control register are global. The
11063 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
11064 POS bits. During optimization, the compiler does not delete these
11065 instructions and it does not delete calls to functions containing
11066 these instructions.
11067
11068 At present, GCC only provides support for operations on 32-bit
11069 vectors. The vector type associated with 8-bit integer data is
11070 usually called @code{v4i8}, the vector type associated with Q7
11071 is usually called @code{v4q7}, the vector type associated with 16-bit
11072 integer data is usually called @code{v2i16}, and the vector type
11073 associated with Q15 is usually called @code{v2q15}. They can be
11074 defined in C as follows:
11075
11076 @smallexample
11077 typedef signed char v4i8 __attribute__ ((vector_size(4)));
11078 typedef signed char v4q7 __attribute__ ((vector_size(4)));
11079 typedef short v2i16 __attribute__ ((vector_size(4)));
11080 typedef short v2q15 __attribute__ ((vector_size(4)));
11081 @end smallexample
11082
11083 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
11084 initialized in the same way as aggregates. For example:
11085
11086 @smallexample
11087 v4i8 a = @{1, 2, 3, 4@};
11088 v4i8 b;
11089 b = (v4i8) @{5, 6, 7, 8@};
11090
11091 v2q15 c = @{0x0fcb, 0x3a75@};
11092 v2q15 d;
11093 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
11094 @end smallexample
11095
11096 @emph{Note:} The CPU's endianness determines the order in which values
11097 are packed. On little-endian targets, the first value is the least
11098 significant and the last value is the most significant. The opposite
11099 order applies to big-endian targets. For example, the code above
11100 sets the lowest byte of @code{a} to @code{1} on little-endian targets
11101 and @code{4} on big-endian targets.
11102
11103 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
11104 representation. As shown in this example, the integer representation
11105 of a Q7 value can be obtained by multiplying the fractional value by
11106 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
11107 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
11108 @code{0x1.0p31}.
11109
11110 The table below lists the @code{v4i8} and @code{v2q15} operations for which
11111 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
11112 and @code{c} and @code{d} are @code{v2q15} values.
11113
11114 @multitable @columnfractions .50 .50
11115 @item C code @tab MIPS instruction
11116 @item @code{a + b} @tab @code{addu.qb}
11117 @item @code{c + d} @tab @code{addq.ph}
11118 @item @code{a - b} @tab @code{subu.qb}
11119 @item @code{c - d} @tab @code{subq.ph}
11120 @end multitable
11121
11122 The table below lists the @code{v2i16} operation for which
11123 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
11124 @code{v2i16} values.
11125
11126 @multitable @columnfractions .50 .50
11127 @item C code @tab MIPS instruction
11128 @item @code{e * f} @tab @code{mul.ph}
11129 @end multitable
11130
11131 It is easier to describe the DSP built-in functions if we first define
11132 the following types:
11133
11134 @smallexample
11135 typedef int q31;
11136 typedef int i32;
11137 typedef unsigned int ui32;
11138 typedef long long a64;
11139 @end smallexample
11140
11141 @code{q31} and @code{i32} are actually the same as @code{int}, but we
11142 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
11143 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
11144 @code{long long}, but we use @code{a64} to indicate values that are
11145 placed in one of the four DSP accumulators (@code{$ac0},
11146 @code{$ac1}, @code{$ac2} or @code{$ac3}).
11147
11148 Also, some built-in functions prefer or require immediate numbers as
11149 parameters, because the corresponding DSP instructions accept both immediate
11150 numbers and register operands, or accept immediate numbers only. The
11151 immediate parameters are listed as follows.
11152
11153 @smallexample
11154 imm0_3: 0 to 3.
11155 imm0_7: 0 to 7.
11156 imm0_15: 0 to 15.
11157 imm0_31: 0 to 31.
11158 imm0_63: 0 to 63.
11159 imm0_255: 0 to 255.
11160 imm_n32_31: -32 to 31.
11161 imm_n512_511: -512 to 511.
11162 @end smallexample
11163
11164 The following built-in functions map directly to a particular MIPS DSP
11165 instruction. Please refer to the architecture specification
11166 for details on what each instruction does.
11167
11168 @smallexample
11169 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
11170 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
11171 q31 __builtin_mips_addq_s_w (q31, q31)
11172 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
11173 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
11174 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
11175 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
11176 q31 __builtin_mips_subq_s_w (q31, q31)
11177 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
11178 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
11179 i32 __builtin_mips_addsc (i32, i32)
11180 i32 __builtin_mips_addwc (i32, i32)
11181 i32 __builtin_mips_modsub (i32, i32)
11182 i32 __builtin_mips_raddu_w_qb (v4i8)
11183 v2q15 __builtin_mips_absq_s_ph (v2q15)
11184 q31 __builtin_mips_absq_s_w (q31)
11185 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
11186 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
11187 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
11188 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
11189 q31 __builtin_mips_preceq_w_phl (v2q15)
11190 q31 __builtin_mips_preceq_w_phr (v2q15)
11191 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
11192 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
11193 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
11194 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
11195 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
11196 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
11197 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
11198 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
11199 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
11200 v4i8 __builtin_mips_shll_qb (v4i8, i32)
11201 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
11202 v2q15 __builtin_mips_shll_ph (v2q15, i32)
11203 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
11204 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
11205 q31 __builtin_mips_shll_s_w (q31, imm0_31)
11206 q31 __builtin_mips_shll_s_w (q31, i32)
11207 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
11208 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
11209 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
11210 v2q15 __builtin_mips_shra_ph (v2q15, i32)
11211 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
11212 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
11213 q31 __builtin_mips_shra_r_w (q31, imm0_31)
11214 q31 __builtin_mips_shra_r_w (q31, i32)
11215 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
11216 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
11217 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
11218 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
11219 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
11220 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
11221 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
11222 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
11223 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
11224 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
11225 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
11226 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
11227 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
11228 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
11229 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
11230 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
11231 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
11232 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
11233 i32 __builtin_mips_bitrev (i32)
11234 i32 __builtin_mips_insv (i32, i32)
11235 v4i8 __builtin_mips_repl_qb (imm0_255)
11236 v4i8 __builtin_mips_repl_qb (i32)
11237 v2q15 __builtin_mips_repl_ph (imm_n512_511)
11238 v2q15 __builtin_mips_repl_ph (i32)
11239 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
11240 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
11241 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
11242 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
11243 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
11244 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
11245 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
11246 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
11247 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
11248 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
11249 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
11250 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
11251 i32 __builtin_mips_extr_w (a64, imm0_31)
11252 i32 __builtin_mips_extr_w (a64, i32)
11253 i32 __builtin_mips_extr_r_w (a64, imm0_31)
11254 i32 __builtin_mips_extr_s_h (a64, i32)
11255 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
11256 i32 __builtin_mips_extr_rs_w (a64, i32)
11257 i32 __builtin_mips_extr_s_h (a64, imm0_31)
11258 i32 __builtin_mips_extr_r_w (a64, i32)
11259 i32 __builtin_mips_extp (a64, imm0_31)
11260 i32 __builtin_mips_extp (a64, i32)
11261 i32 __builtin_mips_extpdp (a64, imm0_31)
11262 i32 __builtin_mips_extpdp (a64, i32)
11263 a64 __builtin_mips_shilo (a64, imm_n32_31)
11264 a64 __builtin_mips_shilo (a64, i32)
11265 a64 __builtin_mips_mthlip (a64, i32)
11266 void __builtin_mips_wrdsp (i32, imm0_63)
11267 i32 __builtin_mips_rddsp (imm0_63)
11268 i32 __builtin_mips_lbux (void *, i32)
11269 i32 __builtin_mips_lhx (void *, i32)
11270 i32 __builtin_mips_lwx (void *, i32)
11271 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
11272 i32 __builtin_mips_bposge32 (void)
11273 a64 __builtin_mips_madd (a64, i32, i32);
11274 a64 __builtin_mips_maddu (a64, ui32, ui32);
11275 a64 __builtin_mips_msub (a64, i32, i32);
11276 a64 __builtin_mips_msubu (a64, ui32, ui32);
11277 a64 __builtin_mips_mult (i32, i32);
11278 a64 __builtin_mips_multu (ui32, ui32);
11279 @end smallexample
11280
11281 The following built-in functions map directly to a particular MIPS DSP REV 2
11282 instruction. Please refer to the architecture specification
11283 for details on what each instruction does.
11284
11285 @smallexample
11286 v4q7 __builtin_mips_absq_s_qb (v4q7);
11287 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
11288 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
11289 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
11290 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
11291 i32 __builtin_mips_append (i32, i32, imm0_31);
11292 i32 __builtin_mips_balign (i32, i32, imm0_3);
11293 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
11294 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
11295 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
11296 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
11297 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
11298 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
11299 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
11300 q31 __builtin_mips_mulq_rs_w (q31, q31);
11301 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
11302 q31 __builtin_mips_mulq_s_w (q31, q31);
11303 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
11304 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
11305 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
11306 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
11307 i32 __builtin_mips_prepend (i32, i32, imm0_31);
11308 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
11309 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
11310 v4i8 __builtin_mips_shra_qb (v4i8, i32);
11311 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
11312 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
11313 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
11314 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
11315 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
11316 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
11317 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
11318 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
11319 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
11320 q31 __builtin_mips_addqh_w (q31, q31);
11321 q31 __builtin_mips_addqh_r_w (q31, q31);
11322 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
11323 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
11324 q31 __builtin_mips_subqh_w (q31, q31);
11325 q31 __builtin_mips_subqh_r_w (q31, q31);
11326 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
11327 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
11328 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
11329 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
11330 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
11331 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
11332 @end smallexample
11333
11334
11335 @node MIPS Paired-Single Support
11336 @subsection MIPS Paired-Single Support
11337
11338 The MIPS64 architecture includes a number of instructions that
11339 operate on pairs of single-precision floating-point values.
11340 Each pair is packed into a 64-bit floating-point register,
11341 with one element being designated the ``upper half'' and
11342 the other being designated the ``lower half''.
11343
11344 GCC supports paired-single operations using both the generic
11345 vector extensions (@pxref{Vector Extensions}) and a collection of
11346 MIPS-specific built-in functions. Both kinds of support are
11347 enabled by the @option{-mpaired-single} command-line option.
11348
11349 The vector type associated with paired-single values is usually
11350 called @code{v2sf}. It can be defined in C as follows:
11351
11352 @smallexample
11353 typedef float v2sf __attribute__ ((vector_size (8)));
11354 @end smallexample
11355
11356 @code{v2sf} values are initialized in the same way as aggregates.
11357 For example:
11358
11359 @smallexample
11360 v2sf a = @{1.5, 9.1@};
11361 v2sf b;
11362 float e, f;
11363 b = (v2sf) @{e, f@};
11364 @end smallexample
11365
11366 @emph{Note:} The CPU's endianness determines which value is stored in
11367 the upper half of a register and which value is stored in the lower half.
11368 On little-endian targets, the first value is the lower one and the second
11369 value is the upper one. The opposite order applies to big-endian targets.
11370 For example, the code above sets the lower half of @code{a} to
11371 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
11372
11373 @node MIPS Loongson Built-in Functions
11374 @subsection MIPS Loongson Built-in Functions
11375
11376 GCC provides intrinsics to access the SIMD instructions provided by the
11377 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
11378 available after inclusion of the @code{loongson.h} header file,
11379 operate on the following 64-bit vector types:
11380
11381 @itemize
11382 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
11383 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
11384 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
11385 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
11386 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
11387 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
11388 @end itemize
11389
11390 The intrinsics provided are listed below; each is named after the
11391 machine instruction to which it corresponds, with suffixes added as
11392 appropriate to distinguish intrinsics that expand to the same machine
11393 instruction yet have different argument types. Refer to the architecture
11394 documentation for a description of the functionality of each
11395 instruction.
11396
11397 @smallexample
11398 int16x4_t packsswh (int32x2_t s, int32x2_t t);
11399 int8x8_t packsshb (int16x4_t s, int16x4_t t);
11400 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
11401 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
11402 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
11403 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
11404 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
11405 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
11406 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
11407 uint64_t paddd_u (uint64_t s, uint64_t t);
11408 int64_t paddd_s (int64_t s, int64_t t);
11409 int16x4_t paddsh (int16x4_t s, int16x4_t t);
11410 int8x8_t paddsb (int8x8_t s, int8x8_t t);
11411 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
11412 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
11413 uint64_t pandn_ud (uint64_t s, uint64_t t);
11414 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
11415 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
11416 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
11417 int64_t pandn_sd (int64_t s, int64_t t);
11418 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
11419 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
11420 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
11421 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
11422 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
11423 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
11424 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
11425 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
11426 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
11427 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
11428 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
11429 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
11430 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
11431 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
11432 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
11433 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
11434 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
11435 uint16x4_t pextrh_u (uint16x4_t s, int field);
11436 int16x4_t pextrh_s (int16x4_t s, int field);
11437 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
11438 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
11439 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
11440 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
11441 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
11442 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
11443 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
11444 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
11445 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
11446 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
11447 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
11448 int16x4_t pminsh (int16x4_t s, int16x4_t t);
11449 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
11450 uint8x8_t pmovmskb_u (uint8x8_t s);
11451 int8x8_t pmovmskb_s (int8x8_t s);
11452 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
11453 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
11454 int16x4_t pmullh (int16x4_t s, int16x4_t t);
11455 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
11456 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
11457 uint16x4_t biadd (uint8x8_t s);
11458 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
11459 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
11460 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
11461 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
11462 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
11463 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
11464 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
11465 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
11466 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
11467 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
11468 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
11469 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
11470 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
11471 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
11472 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
11473 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
11474 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
11475 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
11476 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
11477 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
11478 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
11479 uint64_t psubd_u (uint64_t s, uint64_t t);
11480 int64_t psubd_s (int64_t s, int64_t t);
11481 int16x4_t psubsh (int16x4_t s, int16x4_t t);
11482 int8x8_t psubsb (int8x8_t s, int8x8_t t);
11483 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
11484 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
11485 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
11486 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
11487 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
11488 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
11489 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
11490 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
11491 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
11492 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
11493 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
11494 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
11495 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
11496 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
11497 @end smallexample
11498
11499 @menu
11500 * Paired-Single Arithmetic::
11501 * Paired-Single Built-in Functions::
11502 * MIPS-3D Built-in Functions::
11503 @end menu
11504
11505 @node Paired-Single Arithmetic
11506 @subsubsection Paired-Single Arithmetic
11507
11508 The table below lists the @code{v2sf} operations for which hardware
11509 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
11510 values and @code{x} is an integral value.
11511
11512 @multitable @columnfractions .50 .50
11513 @item C code @tab MIPS instruction
11514 @item @code{a + b} @tab @code{add.ps}
11515 @item @code{a - b} @tab @code{sub.ps}
11516 @item @code{-a} @tab @code{neg.ps}
11517 @item @code{a * b} @tab @code{mul.ps}
11518 @item @code{a * b + c} @tab @code{madd.ps}
11519 @item @code{a * b - c} @tab @code{msub.ps}
11520 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
11521 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
11522 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
11523 @end multitable
11524
11525 Note that the multiply-accumulate instructions can be disabled
11526 using the command-line option @code{-mno-fused-madd}.
11527
11528 @node Paired-Single Built-in Functions
11529 @subsubsection Paired-Single Built-in Functions
11530
11531 The following paired-single functions map directly to a particular
11532 MIPS instruction. Please refer to the architecture specification
11533 for details on what each instruction does.
11534
11535 @table @code
11536 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
11537 Pair lower lower (@code{pll.ps}).
11538
11539 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
11540 Pair upper lower (@code{pul.ps}).
11541
11542 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
11543 Pair lower upper (@code{plu.ps}).
11544
11545 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
11546 Pair upper upper (@code{puu.ps}).
11547
11548 @item v2sf __builtin_mips_cvt_ps_s (float, float)
11549 Convert pair to paired single (@code{cvt.ps.s}).
11550
11551 @item float __builtin_mips_cvt_s_pl (v2sf)
11552 Convert pair lower to single (@code{cvt.s.pl}).
11553
11554 @item float __builtin_mips_cvt_s_pu (v2sf)
11555 Convert pair upper to single (@code{cvt.s.pu}).
11556
11557 @item v2sf __builtin_mips_abs_ps (v2sf)
11558 Absolute value (@code{abs.ps}).
11559
11560 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
11561 Align variable (@code{alnv.ps}).
11562
11563 @emph{Note:} The value of the third parameter must be 0 or 4
11564 modulo 8, otherwise the result is unpredictable. Please read the
11565 instruction description for details.
11566 @end table
11567
11568 The following multi-instruction functions are also available.
11569 In each case, @var{cond} can be any of the 16 floating-point conditions:
11570 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
11571 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
11572 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
11573
11574 @table @code
11575 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11576 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11577 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
11578 @code{movt.ps}/@code{movf.ps}).
11579
11580 The @code{movt} functions return the value @var{x} computed by:
11581
11582 @smallexample
11583 c.@var{cond}.ps @var{cc},@var{a},@var{b}
11584 mov.ps @var{x},@var{c}
11585 movt.ps @var{x},@var{d},@var{cc}
11586 @end smallexample
11587
11588 The @code{movf} functions are similar but use @code{movf.ps} instead
11589 of @code{movt.ps}.
11590
11591 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11592 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11593 Comparison of two paired-single values (@code{c.@var{cond}.ps},
11594 @code{bc1t}/@code{bc1f}).
11595
11596 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
11597 and return either the upper or lower half of the result. For example:
11598
11599 @smallexample
11600 v2sf a, b;
11601 if (__builtin_mips_upper_c_eq_ps (a, b))
11602 upper_halves_are_equal ();
11603 else
11604 upper_halves_are_unequal ();
11605
11606 if (__builtin_mips_lower_c_eq_ps (a, b))
11607 lower_halves_are_equal ();
11608 else
11609 lower_halves_are_unequal ();
11610 @end smallexample
11611 @end table
11612
11613 @node MIPS-3D Built-in Functions
11614 @subsubsection MIPS-3D Built-in Functions
11615
11616 The MIPS-3D Application-Specific Extension (ASE) includes additional
11617 paired-single instructions that are designed to improve the performance
11618 of 3D graphics operations. Support for these instructions is controlled
11619 by the @option{-mips3d} command-line option.
11620
11621 The functions listed below map directly to a particular MIPS-3D
11622 instruction. Please refer to the architecture specification for
11623 more details on what each instruction does.
11624
11625 @table @code
11626 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
11627 Reduction add (@code{addr.ps}).
11628
11629 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
11630 Reduction multiply (@code{mulr.ps}).
11631
11632 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
11633 Convert paired single to paired word (@code{cvt.pw.ps}).
11634
11635 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
11636 Convert paired word to paired single (@code{cvt.ps.pw}).
11637
11638 @item float __builtin_mips_recip1_s (float)
11639 @itemx double __builtin_mips_recip1_d (double)
11640 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
11641 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
11642
11643 @item float __builtin_mips_recip2_s (float, float)
11644 @itemx double __builtin_mips_recip2_d (double, double)
11645 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
11646 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
11647
11648 @item float __builtin_mips_rsqrt1_s (float)
11649 @itemx double __builtin_mips_rsqrt1_d (double)
11650 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
11651 Reduced-precision reciprocal square root (sequence step 1)
11652 (@code{rsqrt1.@var{fmt}}).
11653
11654 @item float __builtin_mips_rsqrt2_s (float, float)
11655 @itemx double __builtin_mips_rsqrt2_d (double, double)
11656 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
11657 Reduced-precision reciprocal square root (sequence step 2)
11658 (@code{rsqrt2.@var{fmt}}).
11659 @end table
11660
11661 The following multi-instruction functions are also available.
11662 In each case, @var{cond} can be any of the 16 floating-point conditions:
11663 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
11664 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
11665 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
11666
11667 @table @code
11668 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
11669 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
11670 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
11671 @code{bc1t}/@code{bc1f}).
11672
11673 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
11674 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
11675 For example:
11676
11677 @smallexample
11678 float a, b;
11679 if (__builtin_mips_cabs_eq_s (a, b))
11680 true ();
11681 else
11682 false ();
11683 @end smallexample
11684
11685 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11686 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11687 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
11688 @code{bc1t}/@code{bc1f}).
11689
11690 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
11691 and return either the upper or lower half of the result. For example:
11692
11693 @smallexample
11694 v2sf a, b;
11695 if (__builtin_mips_upper_cabs_eq_ps (a, b))
11696 upper_halves_are_equal ();
11697 else
11698 upper_halves_are_unequal ();
11699
11700 if (__builtin_mips_lower_cabs_eq_ps (a, b))
11701 lower_halves_are_equal ();
11702 else
11703 lower_halves_are_unequal ();
11704 @end smallexample
11705
11706 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11707 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11708 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
11709 @code{movt.ps}/@code{movf.ps}).
11710
11711 The @code{movt} functions return the value @var{x} computed by:
11712
11713 @smallexample
11714 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
11715 mov.ps @var{x},@var{c}
11716 movt.ps @var{x},@var{d},@var{cc}
11717 @end smallexample
11718
11719 The @code{movf} functions are similar but use @code{movf.ps} instead
11720 of @code{movt.ps}.
11721
11722 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11723 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11724 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11725 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11726 Comparison of two paired-single values
11727 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
11728 @code{bc1any2t}/@code{bc1any2f}).
11729
11730 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
11731 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
11732 result is true and the @code{all} forms return true if both results are true.
11733 For example:
11734
11735 @smallexample
11736 v2sf a, b;
11737 if (__builtin_mips_any_c_eq_ps (a, b))
11738 one_is_true ();
11739 else
11740 both_are_false ();
11741
11742 if (__builtin_mips_all_c_eq_ps (a, b))
11743 both_are_true ();
11744 else
11745 one_is_false ();
11746 @end smallexample
11747
11748 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11749 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11750 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11751 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11752 Comparison of four paired-single values
11753 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
11754 @code{bc1any4t}/@code{bc1any4f}).
11755
11756 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
11757 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
11758 The @code{any} forms return true if any of the four results are true
11759 and the @code{all} forms return true if all four results are true.
11760 For example:
11761
11762 @smallexample
11763 v2sf a, b, c, d;
11764 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
11765 some_are_true ();
11766 else
11767 all_are_false ();
11768
11769 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
11770 all_are_true ();
11771 else
11772 some_are_false ();
11773 @end smallexample
11774 @end table
11775
11776 @node Other MIPS Built-in Functions
11777 @subsection Other MIPS Built-in Functions
11778
11779 GCC provides other MIPS-specific built-in functions:
11780
11781 @table @code
11782 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
11783 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
11784 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
11785 when this function is available.
11786 @end table
11787
11788 @node picoChip Built-in Functions
11789 @subsection picoChip Built-in Functions
11790
11791 GCC provides an interface to selected machine instructions from the
11792 picoChip instruction set.
11793
11794 @table @code
11795 @item int __builtin_sbc (int @var{value})
11796 Sign bit count. Return the number of consecutive bits in @var{value}
11797 that have the same value as the sign bit. The result is the number of
11798 leading sign bits minus one, giving the number of redundant sign bits in
11799 @var{value}.
11800
11801 @item int __builtin_byteswap (int @var{value})
11802 Byte swap. Return the result of swapping the upper and lower bytes of
11803 @var{value}.
11804
11805 @item int __builtin_brev (int @var{value})
11806 Bit reversal. Return the result of reversing the bits in
11807 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
11808 and so on.
11809
11810 @item int __builtin_adds (int @var{x}, int @var{y})
11811 Saturating addition. Return the result of adding @var{x} and @var{y},
11812 storing the value 32767 if the result overflows.
11813
11814 @item int __builtin_subs (int @var{x}, int @var{y})
11815 Saturating subtraction. Return the result of subtracting @var{y} from
11816 @var{x}, storing the value @minus{}32768 if the result overflows.
11817
11818 @item void __builtin_halt (void)
11819 Halt. The processor stops execution. This built-in is useful for
11820 implementing assertions.
11821
11822 @end table
11823
11824 @node PowerPC Built-in Functions
11825 @subsection PowerPC Built-in Functions
11826
11827 These built-in functions are available for the PowerPC family of
11828 processors:
11829 @smallexample
11830 float __builtin_recipdivf (float, float);
11831 float __builtin_rsqrtf (float);
11832 double __builtin_recipdiv (double, double);
11833 double __builtin_rsqrt (double);
11834 long __builtin_bpermd (long, long);
11835 uint64_t __builtin_ppc_get_timebase ();
11836 unsigned long __builtin_ppc_mftb ();
11837 @end smallexample
11838
11839 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
11840 @code{__builtin_rsqrtf} functions generate multiple instructions to
11841 implement the reciprocal sqrt functionality using reciprocal sqrt
11842 estimate instructions.
11843
11844 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
11845 functions generate multiple instructions to implement division using
11846 the reciprocal estimate instructions.
11847
11848 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
11849 functions generate instructions to read the Time Base Register. The
11850 @code{__builtin_ppc_get_timebase} function may generate multiple
11851 instructions and always returns the 64 bits of the Time Base Register.
11852 The @code{__builtin_ppc_mftb} function always generates one instruction and
11853 returns the Time Base Register value as an unsigned long, throwing away
11854 the most significant word on 32-bit environments.
11855
11856 @node PowerPC AltiVec/VSX Built-in Functions
11857 @subsection PowerPC AltiVec Built-in Functions
11858
11859 GCC provides an interface for the PowerPC family of processors to access
11860 the AltiVec operations described in Motorola's AltiVec Programming
11861 Interface Manual. The interface is made available by including
11862 @code{<altivec.h>} and using @option{-maltivec} and
11863 @option{-mabi=altivec}. The interface supports the following vector
11864 types.
11865
11866 @smallexample
11867 vector unsigned char
11868 vector signed char
11869 vector bool char
11870
11871 vector unsigned short
11872 vector signed short
11873 vector bool short
11874 vector pixel
11875
11876 vector unsigned int
11877 vector signed int
11878 vector bool int
11879 vector float
11880 @end smallexample
11881
11882 If @option{-mvsx} is used the following additional vector types are
11883 implemented.
11884
11885 @smallexample
11886 vector unsigned long
11887 vector signed long
11888 vector double
11889 @end smallexample
11890
11891 The long types are only implemented for 64-bit code generation, and
11892 the long type is only used in the floating point/integer conversion
11893 instructions.
11894
11895 GCC's implementation of the high-level language interface available from
11896 C and C++ code differs from Motorola's documentation in several ways.
11897
11898 @itemize @bullet
11899
11900 @item
11901 A vector constant is a list of constant expressions within curly braces.
11902
11903 @item
11904 A vector initializer requires no cast if the vector constant is of the
11905 same type as the variable it is initializing.
11906
11907 @item
11908 If @code{signed} or @code{unsigned} is omitted, the signedness of the
11909 vector type is the default signedness of the base type. The default
11910 varies depending on the operating system, so a portable program should
11911 always specify the signedness.
11912
11913 @item
11914 Compiling with @option{-maltivec} adds keywords @code{__vector},
11915 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
11916 @code{bool}. When compiling ISO C, the context-sensitive substitution
11917 of the keywords @code{vector}, @code{pixel} and @code{bool} is
11918 disabled. To use them, you must include @code{<altivec.h>} instead.
11919
11920 @item
11921 GCC allows using a @code{typedef} name as the type specifier for a
11922 vector type.
11923
11924 @item
11925 For C, overloaded functions are implemented with macros so the following
11926 does not work:
11927
11928 @smallexample
11929 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
11930 @end smallexample
11931
11932 @noindent
11933 Since @code{vec_add} is a macro, the vector constant in the example
11934 is treated as four separate arguments. Wrap the entire argument in
11935 parentheses for this to work.
11936 @end itemize
11937
11938 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
11939 Internally, GCC uses built-in functions to achieve the functionality in
11940 the aforementioned header file, but they are not supported and are
11941 subject to change without notice.
11942
11943 The following interfaces are supported for the generic and specific
11944 AltiVec operations and the AltiVec predicates. In cases where there
11945 is a direct mapping between generic and specific operations, only the
11946 generic names are shown here, although the specific operations can also
11947 be used.
11948
11949 Arguments that are documented as @code{const int} require literal
11950 integral values within the range required for that operation.
11951
11952 @smallexample
11953 vector signed char vec_abs (vector signed char);
11954 vector signed short vec_abs (vector signed short);
11955 vector signed int vec_abs (vector signed int);
11956 vector float vec_abs (vector float);
11957
11958 vector signed char vec_abss (vector signed char);
11959 vector signed short vec_abss (vector signed short);
11960 vector signed int vec_abss (vector signed int);
11961
11962 vector signed char vec_add (vector bool char, vector signed char);
11963 vector signed char vec_add (vector signed char, vector bool char);
11964 vector signed char vec_add (vector signed char, vector signed char);
11965 vector unsigned char vec_add (vector bool char, vector unsigned char);
11966 vector unsigned char vec_add (vector unsigned char, vector bool char);
11967 vector unsigned char vec_add (vector unsigned char,
11968 vector unsigned char);
11969 vector signed short vec_add (vector bool short, vector signed short);
11970 vector signed short vec_add (vector signed short, vector bool short);
11971 vector signed short vec_add (vector signed short, vector signed short);
11972 vector unsigned short vec_add (vector bool short,
11973 vector unsigned short);
11974 vector unsigned short vec_add (vector unsigned short,
11975 vector bool short);
11976 vector unsigned short vec_add (vector unsigned short,
11977 vector unsigned short);
11978 vector signed int vec_add (vector bool int, vector signed int);
11979 vector signed int vec_add (vector signed int, vector bool int);
11980 vector signed int vec_add (vector signed int, vector signed int);
11981 vector unsigned int vec_add (vector bool int, vector unsigned int);
11982 vector unsigned int vec_add (vector unsigned int, vector bool int);
11983 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
11984 vector float vec_add (vector float, vector float);
11985
11986 vector float vec_vaddfp (vector float, vector float);
11987
11988 vector signed int vec_vadduwm (vector bool int, vector signed int);
11989 vector signed int vec_vadduwm (vector signed int, vector bool int);
11990 vector signed int vec_vadduwm (vector signed int, vector signed int);
11991 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
11992 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
11993 vector unsigned int vec_vadduwm (vector unsigned int,
11994 vector unsigned int);
11995
11996 vector signed short vec_vadduhm (vector bool short,
11997 vector signed short);
11998 vector signed short vec_vadduhm (vector signed short,
11999 vector bool short);
12000 vector signed short vec_vadduhm (vector signed short,
12001 vector signed short);
12002 vector unsigned short vec_vadduhm (vector bool short,
12003 vector unsigned short);
12004 vector unsigned short vec_vadduhm (vector unsigned short,
12005 vector bool short);
12006 vector unsigned short vec_vadduhm (vector unsigned short,
12007 vector unsigned short);
12008
12009 vector signed char vec_vaddubm (vector bool char, vector signed char);
12010 vector signed char vec_vaddubm (vector signed char, vector bool char);
12011 vector signed char vec_vaddubm (vector signed char, vector signed char);
12012 vector unsigned char vec_vaddubm (vector bool char,
12013 vector unsigned char);
12014 vector unsigned char vec_vaddubm (vector unsigned char,
12015 vector bool char);
12016 vector unsigned char vec_vaddubm (vector unsigned char,
12017 vector unsigned char);
12018
12019 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
12020
12021 vector unsigned char vec_adds (vector bool char, vector unsigned char);
12022 vector unsigned char vec_adds (vector unsigned char, vector bool char);
12023 vector unsigned char vec_adds (vector unsigned char,
12024 vector unsigned char);
12025 vector signed char vec_adds (vector bool char, vector signed char);
12026 vector signed char vec_adds (vector signed char, vector bool char);
12027 vector signed char vec_adds (vector signed char, vector signed char);
12028 vector unsigned short vec_adds (vector bool short,
12029 vector unsigned short);
12030 vector unsigned short vec_adds (vector unsigned short,
12031 vector bool short);
12032 vector unsigned short vec_adds (vector unsigned short,
12033 vector unsigned short);
12034 vector signed short vec_adds (vector bool short, vector signed short);
12035 vector signed short vec_adds (vector signed short, vector bool short);
12036 vector signed short vec_adds (vector signed short, vector signed short);
12037 vector unsigned int vec_adds (vector bool int, vector unsigned int);
12038 vector unsigned int vec_adds (vector unsigned int, vector bool int);
12039 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
12040 vector signed int vec_adds (vector bool int, vector signed int);
12041 vector signed int vec_adds (vector signed int, vector bool int);
12042 vector signed int vec_adds (vector signed int, vector signed int);
12043
12044 vector signed int vec_vaddsws (vector bool int, vector signed int);
12045 vector signed int vec_vaddsws (vector signed int, vector bool int);
12046 vector signed int vec_vaddsws (vector signed int, vector signed int);
12047
12048 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
12049 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
12050 vector unsigned int vec_vadduws (vector unsigned int,
12051 vector unsigned int);
12052
12053 vector signed short vec_vaddshs (vector bool short,
12054 vector signed short);
12055 vector signed short vec_vaddshs (vector signed short,
12056 vector bool short);
12057 vector signed short vec_vaddshs (vector signed short,
12058 vector signed short);
12059
12060 vector unsigned short vec_vadduhs (vector bool short,
12061 vector unsigned short);
12062 vector unsigned short vec_vadduhs (vector unsigned short,
12063 vector bool short);
12064 vector unsigned short vec_vadduhs (vector unsigned short,
12065 vector unsigned short);
12066
12067 vector signed char vec_vaddsbs (vector bool char, vector signed char);
12068 vector signed char vec_vaddsbs (vector signed char, vector bool char);
12069 vector signed char vec_vaddsbs (vector signed char, vector signed char);
12070
12071 vector unsigned char vec_vaddubs (vector bool char,
12072 vector unsigned char);
12073 vector unsigned char vec_vaddubs (vector unsigned char,
12074 vector bool char);
12075 vector unsigned char vec_vaddubs (vector unsigned char,
12076 vector unsigned char);
12077
12078 vector float vec_and (vector float, vector float);
12079 vector float vec_and (vector float, vector bool int);
12080 vector float vec_and (vector bool int, vector float);
12081 vector bool int vec_and (vector bool int, vector bool int);
12082 vector signed int vec_and (vector bool int, vector signed int);
12083 vector signed int vec_and (vector signed int, vector bool int);
12084 vector signed int vec_and (vector signed int, vector signed int);
12085 vector unsigned int vec_and (vector bool int, vector unsigned int);
12086 vector unsigned int vec_and (vector unsigned int, vector bool int);
12087 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
12088 vector bool short vec_and (vector bool short, vector bool short);
12089 vector signed short vec_and (vector bool short, vector signed short);
12090 vector signed short vec_and (vector signed short, vector bool short);
12091 vector signed short vec_and (vector signed short, vector signed short);
12092 vector unsigned short vec_and (vector bool short,
12093 vector unsigned short);
12094 vector unsigned short vec_and (vector unsigned short,
12095 vector bool short);
12096 vector unsigned short vec_and (vector unsigned short,
12097 vector unsigned short);
12098 vector signed char vec_and (vector bool char, vector signed char);
12099 vector bool char vec_and (vector bool char, vector bool char);
12100 vector signed char vec_and (vector signed char, vector bool char);
12101 vector signed char vec_and (vector signed char, vector signed char);
12102 vector unsigned char vec_and (vector bool char, vector unsigned char);
12103 vector unsigned char vec_and (vector unsigned char, vector bool char);
12104 vector unsigned char vec_and (vector unsigned char,
12105 vector unsigned char);
12106
12107 vector float vec_andc (vector float, vector float);
12108 vector float vec_andc (vector float, vector bool int);
12109 vector float vec_andc (vector bool int, vector float);
12110 vector bool int vec_andc (vector bool int, vector bool int);
12111 vector signed int vec_andc (vector bool int, vector signed int);
12112 vector signed int vec_andc (vector signed int, vector bool int);
12113 vector signed int vec_andc (vector signed int, vector signed int);
12114 vector unsigned int vec_andc (vector bool int, vector unsigned int);
12115 vector unsigned int vec_andc (vector unsigned int, vector bool int);
12116 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
12117 vector bool short vec_andc (vector bool short, vector bool short);
12118 vector signed short vec_andc (vector bool short, vector signed short);
12119 vector signed short vec_andc (vector signed short, vector bool short);
12120 vector signed short vec_andc (vector signed short, vector signed short);
12121 vector unsigned short vec_andc (vector bool short,
12122 vector unsigned short);
12123 vector unsigned short vec_andc (vector unsigned short,
12124 vector bool short);
12125 vector unsigned short vec_andc (vector unsigned short,
12126 vector unsigned short);
12127 vector signed char vec_andc (vector bool char, vector signed char);
12128 vector bool char vec_andc (vector bool char, vector bool char);
12129 vector signed char vec_andc (vector signed char, vector bool char);
12130 vector signed char vec_andc (vector signed char, vector signed char);
12131 vector unsigned char vec_andc (vector bool char, vector unsigned char);
12132 vector unsigned char vec_andc (vector unsigned char, vector bool char);
12133 vector unsigned char vec_andc (vector unsigned char,
12134 vector unsigned char);
12135
12136 vector unsigned char vec_avg (vector unsigned char,
12137 vector unsigned char);
12138 vector signed char vec_avg (vector signed char, vector signed char);
12139 vector unsigned short vec_avg (vector unsigned short,
12140 vector unsigned short);
12141 vector signed short vec_avg (vector signed short, vector signed short);
12142 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
12143 vector signed int vec_avg (vector signed int, vector signed int);
12144
12145 vector signed int vec_vavgsw (vector signed int, vector signed int);
12146
12147 vector unsigned int vec_vavguw (vector unsigned int,
12148 vector unsigned int);
12149
12150 vector signed short vec_vavgsh (vector signed short,
12151 vector signed short);
12152
12153 vector unsigned short vec_vavguh (vector unsigned short,
12154 vector unsigned short);
12155
12156 vector signed char vec_vavgsb (vector signed char, vector signed char);
12157
12158 vector unsigned char vec_vavgub (vector unsigned char,
12159 vector unsigned char);
12160
12161 vector float vec_copysign (vector float);
12162
12163 vector float vec_ceil (vector float);
12164
12165 vector signed int vec_cmpb (vector float, vector float);
12166
12167 vector bool char vec_cmpeq (vector signed char, vector signed char);
12168 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
12169 vector bool short vec_cmpeq (vector signed short, vector signed short);
12170 vector bool short vec_cmpeq (vector unsigned short,
12171 vector unsigned short);
12172 vector bool int vec_cmpeq (vector signed int, vector signed int);
12173 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
12174 vector bool int vec_cmpeq (vector float, vector float);
12175
12176 vector bool int vec_vcmpeqfp (vector float, vector float);
12177
12178 vector bool int vec_vcmpequw (vector signed int, vector signed int);
12179 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
12180
12181 vector bool short vec_vcmpequh (vector signed short,
12182 vector signed short);
12183 vector bool short vec_vcmpequh (vector unsigned short,
12184 vector unsigned short);
12185
12186 vector bool char vec_vcmpequb (vector signed char, vector signed char);
12187 vector bool char vec_vcmpequb (vector unsigned char,
12188 vector unsigned char);
12189
12190 vector bool int vec_cmpge (vector float, vector float);
12191
12192 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
12193 vector bool char vec_cmpgt (vector signed char, vector signed char);
12194 vector bool short vec_cmpgt (vector unsigned short,
12195 vector unsigned short);
12196 vector bool short vec_cmpgt (vector signed short, vector signed short);
12197 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
12198 vector bool int vec_cmpgt (vector signed int, vector signed int);
12199 vector bool int vec_cmpgt (vector float, vector float);
12200
12201 vector bool int vec_vcmpgtfp (vector float, vector float);
12202
12203 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
12204
12205 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
12206
12207 vector bool short vec_vcmpgtsh (vector signed short,
12208 vector signed short);
12209
12210 vector bool short vec_vcmpgtuh (vector unsigned short,
12211 vector unsigned short);
12212
12213 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
12214
12215 vector bool char vec_vcmpgtub (vector unsigned char,
12216 vector unsigned char);
12217
12218 vector bool int vec_cmple (vector float, vector float);
12219
12220 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
12221 vector bool char vec_cmplt (vector signed char, vector signed char);
12222 vector bool short vec_cmplt (vector unsigned short,
12223 vector unsigned short);
12224 vector bool short vec_cmplt (vector signed short, vector signed short);
12225 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
12226 vector bool int vec_cmplt (vector signed int, vector signed int);
12227 vector bool int vec_cmplt (vector float, vector float);
12228
12229 vector float vec_ctf (vector unsigned int, const int);
12230 vector float vec_ctf (vector signed int, const int);
12231
12232 vector float vec_vcfsx (vector signed int, const int);
12233
12234 vector float vec_vcfux (vector unsigned int, const int);
12235
12236 vector signed int vec_cts (vector float, const int);
12237
12238 vector unsigned int vec_ctu (vector float, const int);
12239
12240 void vec_dss (const int);
12241
12242 void vec_dssall (void);
12243
12244 void vec_dst (const vector unsigned char *, int, const int);
12245 void vec_dst (const vector signed char *, int, const int);
12246 void vec_dst (const vector bool char *, int, const int);
12247 void vec_dst (const vector unsigned short *, int, const int);
12248 void vec_dst (const vector signed short *, int, const int);
12249 void vec_dst (const vector bool short *, int, const int);
12250 void vec_dst (const vector pixel *, int, const int);
12251 void vec_dst (const vector unsigned int *, int, const int);
12252 void vec_dst (const vector signed int *, int, const int);
12253 void vec_dst (const vector bool int *, int, const int);
12254 void vec_dst (const vector float *, int, const int);
12255 void vec_dst (const unsigned char *, int, const int);
12256 void vec_dst (const signed char *, int, const int);
12257 void vec_dst (const unsigned short *, int, const int);
12258 void vec_dst (const short *, int, const int);
12259 void vec_dst (const unsigned int *, int, const int);
12260 void vec_dst (const int *, int, const int);
12261 void vec_dst (const unsigned long *, int, const int);
12262 void vec_dst (const long *, int, const int);
12263 void vec_dst (const float *, int, const int);
12264
12265 void vec_dstst (const vector unsigned char *, int, const int);
12266 void vec_dstst (const vector signed char *, int, const int);
12267 void vec_dstst (const vector bool char *, int, const int);
12268 void vec_dstst (const vector unsigned short *, int, const int);
12269 void vec_dstst (const vector signed short *, int, const int);
12270 void vec_dstst (const vector bool short *, int, const int);
12271 void vec_dstst (const vector pixel *, int, const int);
12272 void vec_dstst (const vector unsigned int *, int, const int);
12273 void vec_dstst (const vector signed int *, int, const int);
12274 void vec_dstst (const vector bool int *, int, const int);
12275 void vec_dstst (const vector float *, int, const int);
12276 void vec_dstst (const unsigned char *, int, const int);
12277 void vec_dstst (const signed char *, int, const int);
12278 void vec_dstst (const unsigned short *, int, const int);
12279 void vec_dstst (const short *, int, const int);
12280 void vec_dstst (const unsigned int *, int, const int);
12281 void vec_dstst (const int *, int, const int);
12282 void vec_dstst (const unsigned long *, int, const int);
12283 void vec_dstst (const long *, int, const int);
12284 void vec_dstst (const float *, int, const int);
12285
12286 void vec_dststt (const vector unsigned char *, int, const int);
12287 void vec_dststt (const vector signed char *, int, const int);
12288 void vec_dststt (const vector bool char *, int, const int);
12289 void vec_dststt (const vector unsigned short *, int, const int);
12290 void vec_dststt (const vector signed short *, int, const int);
12291 void vec_dststt (const vector bool short *, int, const int);
12292 void vec_dststt (const vector pixel *, int, const int);
12293 void vec_dststt (const vector unsigned int *, int, const int);
12294 void vec_dststt (const vector signed int *, int, const int);
12295 void vec_dststt (const vector bool int *, int, const int);
12296 void vec_dststt (const vector float *, int, const int);
12297 void vec_dststt (const unsigned char *, int, const int);
12298 void vec_dststt (const signed char *, int, const int);
12299 void vec_dststt (const unsigned short *, int, const int);
12300 void vec_dststt (const short *, int, const int);
12301 void vec_dststt (const unsigned int *, int, const int);
12302 void vec_dststt (const int *, int, const int);
12303 void vec_dststt (const unsigned long *, int, const int);
12304 void vec_dststt (const long *, int, const int);
12305 void vec_dststt (const float *, int, const int);
12306
12307 void vec_dstt (const vector unsigned char *, int, const int);
12308 void vec_dstt (const vector signed char *, int, const int);
12309 void vec_dstt (const vector bool char *, int, const int);
12310 void vec_dstt (const vector unsigned short *, int, const int);
12311 void vec_dstt (const vector signed short *, int, const int);
12312 void vec_dstt (const vector bool short *, int, const int);
12313 void vec_dstt (const vector pixel *, int, const int);
12314 void vec_dstt (const vector unsigned int *, int, const int);
12315 void vec_dstt (const vector signed int *, int, const int);
12316 void vec_dstt (const vector bool int *, int, const int);
12317 void vec_dstt (const vector float *, int, const int);
12318 void vec_dstt (const unsigned char *, int, const int);
12319 void vec_dstt (const signed char *, int, const int);
12320 void vec_dstt (const unsigned short *, int, const int);
12321 void vec_dstt (const short *, int, const int);
12322 void vec_dstt (const unsigned int *, int, const int);
12323 void vec_dstt (const int *, int, const int);
12324 void vec_dstt (const unsigned long *, int, const int);
12325 void vec_dstt (const long *, int, const int);
12326 void vec_dstt (const float *, int, const int);
12327
12328 vector float vec_expte (vector float);
12329
12330 vector float vec_floor (vector float);
12331
12332 vector float vec_ld (int, const vector float *);
12333 vector float vec_ld (int, const float *);
12334 vector bool int vec_ld (int, const vector bool int *);
12335 vector signed int vec_ld (int, const vector signed int *);
12336 vector signed int vec_ld (int, const int *);
12337 vector signed int vec_ld (int, const long *);
12338 vector unsigned int vec_ld (int, const vector unsigned int *);
12339 vector unsigned int vec_ld (int, const unsigned int *);
12340 vector unsigned int vec_ld (int, const unsigned long *);
12341 vector bool short vec_ld (int, const vector bool short *);
12342 vector pixel vec_ld (int, const vector pixel *);
12343 vector signed short vec_ld (int, const vector signed short *);
12344 vector signed short vec_ld (int, const short *);
12345 vector unsigned short vec_ld (int, const vector unsigned short *);
12346 vector unsigned short vec_ld (int, const unsigned short *);
12347 vector bool char vec_ld (int, const vector bool char *);
12348 vector signed char vec_ld (int, const vector signed char *);
12349 vector signed char vec_ld (int, const signed char *);
12350 vector unsigned char vec_ld (int, const vector unsigned char *);
12351 vector unsigned char vec_ld (int, const unsigned char *);
12352
12353 vector signed char vec_lde (int, const signed char *);
12354 vector unsigned char vec_lde (int, const unsigned char *);
12355 vector signed short vec_lde (int, const short *);
12356 vector unsigned short vec_lde (int, const unsigned short *);
12357 vector float vec_lde (int, const float *);
12358 vector signed int vec_lde (int, const int *);
12359 vector unsigned int vec_lde (int, const unsigned int *);
12360 vector signed int vec_lde (int, const long *);
12361 vector unsigned int vec_lde (int, const unsigned long *);
12362
12363 vector float vec_lvewx (int, float *);
12364 vector signed int vec_lvewx (int, int *);
12365 vector unsigned int vec_lvewx (int, unsigned int *);
12366 vector signed int vec_lvewx (int, long *);
12367 vector unsigned int vec_lvewx (int, unsigned long *);
12368
12369 vector signed short vec_lvehx (int, short *);
12370 vector unsigned short vec_lvehx (int, unsigned short *);
12371
12372 vector signed char vec_lvebx (int, char *);
12373 vector unsigned char vec_lvebx (int, unsigned char *);
12374
12375 vector float vec_ldl (int, const vector float *);
12376 vector float vec_ldl (int, const float *);
12377 vector bool int vec_ldl (int, const vector bool int *);
12378 vector signed int vec_ldl (int, const vector signed int *);
12379 vector signed int vec_ldl (int, const int *);
12380 vector signed int vec_ldl (int, const long *);
12381 vector unsigned int vec_ldl (int, const vector unsigned int *);
12382 vector unsigned int vec_ldl (int, const unsigned int *);
12383 vector unsigned int vec_ldl (int, const unsigned long *);
12384 vector bool short vec_ldl (int, const vector bool short *);
12385 vector pixel vec_ldl (int, const vector pixel *);
12386 vector signed short vec_ldl (int, const vector signed short *);
12387 vector signed short vec_ldl (int, const short *);
12388 vector unsigned short vec_ldl (int, const vector unsigned short *);
12389 vector unsigned short vec_ldl (int, const unsigned short *);
12390 vector bool char vec_ldl (int, const vector bool char *);
12391 vector signed char vec_ldl (int, const vector signed char *);
12392 vector signed char vec_ldl (int, const signed char *);
12393 vector unsigned char vec_ldl (int, const vector unsigned char *);
12394 vector unsigned char vec_ldl (int, const unsigned char *);
12395
12396 vector float vec_loge (vector float);
12397
12398 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
12399 vector unsigned char vec_lvsl (int, const volatile signed char *);
12400 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
12401 vector unsigned char vec_lvsl (int, const volatile short *);
12402 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
12403 vector unsigned char vec_lvsl (int, const volatile int *);
12404 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
12405 vector unsigned char vec_lvsl (int, const volatile long *);
12406 vector unsigned char vec_lvsl (int, const volatile float *);
12407
12408 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
12409 vector unsigned char vec_lvsr (int, const volatile signed char *);
12410 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
12411 vector unsigned char vec_lvsr (int, const volatile short *);
12412 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
12413 vector unsigned char vec_lvsr (int, const volatile int *);
12414 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
12415 vector unsigned char vec_lvsr (int, const volatile long *);
12416 vector unsigned char vec_lvsr (int, const volatile float *);
12417
12418 vector float vec_madd (vector float, vector float, vector float);
12419
12420 vector signed short vec_madds (vector signed short,
12421 vector signed short,
12422 vector signed short);
12423
12424 vector unsigned char vec_max (vector bool char, vector unsigned char);
12425 vector unsigned char vec_max (vector unsigned char, vector bool char);
12426 vector unsigned char vec_max (vector unsigned char,
12427 vector unsigned char);
12428 vector signed char vec_max (vector bool char, vector signed char);
12429 vector signed char vec_max (vector signed char, vector bool char);
12430 vector signed char vec_max (vector signed char, vector signed char);
12431 vector unsigned short vec_max (vector bool short,
12432 vector unsigned short);
12433 vector unsigned short vec_max (vector unsigned short,
12434 vector bool short);
12435 vector unsigned short vec_max (vector unsigned short,
12436 vector unsigned short);
12437 vector signed short vec_max (vector bool short, vector signed short);
12438 vector signed short vec_max (vector signed short, vector bool short);
12439 vector signed short vec_max (vector signed short, vector signed short);
12440 vector unsigned int vec_max (vector bool int, vector unsigned int);
12441 vector unsigned int vec_max (vector unsigned int, vector bool int);
12442 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
12443 vector signed int vec_max (vector bool int, vector signed int);
12444 vector signed int vec_max (vector signed int, vector bool int);
12445 vector signed int vec_max (vector signed int, vector signed int);
12446 vector float vec_max (vector float, vector float);
12447
12448 vector float vec_vmaxfp (vector float, vector float);
12449
12450 vector signed int vec_vmaxsw (vector bool int, vector signed int);
12451 vector signed int vec_vmaxsw (vector signed int, vector bool int);
12452 vector signed int vec_vmaxsw (vector signed int, vector signed int);
12453
12454 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
12455 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
12456 vector unsigned int vec_vmaxuw (vector unsigned int,
12457 vector unsigned int);
12458
12459 vector signed short vec_vmaxsh (vector bool short, vector signed short);
12460 vector signed short vec_vmaxsh (vector signed short, vector bool short);
12461 vector signed short vec_vmaxsh (vector signed short,
12462 vector signed short);
12463
12464 vector unsigned short vec_vmaxuh (vector bool short,
12465 vector unsigned short);
12466 vector unsigned short vec_vmaxuh (vector unsigned short,
12467 vector bool short);
12468 vector unsigned short vec_vmaxuh (vector unsigned short,
12469 vector unsigned short);
12470
12471 vector signed char vec_vmaxsb (vector bool char, vector signed char);
12472 vector signed char vec_vmaxsb (vector signed char, vector bool char);
12473 vector signed char vec_vmaxsb (vector signed char, vector signed char);
12474
12475 vector unsigned char vec_vmaxub (vector bool char,
12476 vector unsigned char);
12477 vector unsigned char vec_vmaxub (vector unsigned char,
12478 vector bool char);
12479 vector unsigned char vec_vmaxub (vector unsigned char,
12480 vector unsigned char);
12481
12482 vector bool char vec_mergeh (vector bool char, vector bool char);
12483 vector signed char vec_mergeh (vector signed char, vector signed char);
12484 vector unsigned char vec_mergeh (vector unsigned char,
12485 vector unsigned char);
12486 vector bool short vec_mergeh (vector bool short, vector bool short);
12487 vector pixel vec_mergeh (vector pixel, vector pixel);
12488 vector signed short vec_mergeh (vector signed short,
12489 vector signed short);
12490 vector unsigned short vec_mergeh (vector unsigned short,
12491 vector unsigned short);
12492 vector float vec_mergeh (vector float, vector float);
12493 vector bool int vec_mergeh (vector bool int, vector bool int);
12494 vector signed int vec_mergeh (vector signed int, vector signed int);
12495 vector unsigned int vec_mergeh (vector unsigned int,
12496 vector unsigned int);
12497
12498 vector float vec_vmrghw (vector float, vector float);
12499 vector bool int vec_vmrghw (vector bool int, vector bool int);
12500 vector signed int vec_vmrghw (vector signed int, vector signed int);
12501 vector unsigned int vec_vmrghw (vector unsigned int,
12502 vector unsigned int);
12503
12504 vector bool short vec_vmrghh (vector bool short, vector bool short);
12505 vector signed short vec_vmrghh (vector signed short,
12506 vector signed short);
12507 vector unsigned short vec_vmrghh (vector unsigned short,
12508 vector unsigned short);
12509 vector pixel vec_vmrghh (vector pixel, vector pixel);
12510
12511 vector bool char vec_vmrghb (vector bool char, vector bool char);
12512 vector signed char vec_vmrghb (vector signed char, vector signed char);
12513 vector unsigned char vec_vmrghb (vector unsigned char,
12514 vector unsigned char);
12515
12516 vector bool char vec_mergel (vector bool char, vector bool char);
12517 vector signed char vec_mergel (vector signed char, vector signed char);
12518 vector unsigned char vec_mergel (vector unsigned char,
12519 vector unsigned char);
12520 vector bool short vec_mergel (vector bool short, vector bool short);
12521 vector pixel vec_mergel (vector pixel, vector pixel);
12522 vector signed short vec_mergel (vector signed short,
12523 vector signed short);
12524 vector unsigned short vec_mergel (vector unsigned short,
12525 vector unsigned short);
12526 vector float vec_mergel (vector float, vector float);
12527 vector bool int vec_mergel (vector bool int, vector bool int);
12528 vector signed int vec_mergel (vector signed int, vector signed int);
12529 vector unsigned int vec_mergel (vector unsigned int,
12530 vector unsigned int);
12531
12532 vector float vec_vmrglw (vector float, vector float);
12533 vector signed int vec_vmrglw (vector signed int, vector signed int);
12534 vector unsigned int vec_vmrglw (vector unsigned int,
12535 vector unsigned int);
12536 vector bool int vec_vmrglw (vector bool int, vector bool int);
12537
12538 vector bool short vec_vmrglh (vector bool short, vector bool short);
12539 vector signed short vec_vmrglh (vector signed short,
12540 vector signed short);
12541 vector unsigned short vec_vmrglh (vector unsigned short,
12542 vector unsigned short);
12543 vector pixel vec_vmrglh (vector pixel, vector pixel);
12544
12545 vector bool char vec_vmrglb (vector bool char, vector bool char);
12546 vector signed char vec_vmrglb (vector signed char, vector signed char);
12547 vector unsigned char vec_vmrglb (vector unsigned char,
12548 vector unsigned char);
12549
12550 vector unsigned short vec_mfvscr (void);
12551
12552 vector unsigned char vec_min (vector bool char, vector unsigned char);
12553 vector unsigned char vec_min (vector unsigned char, vector bool char);
12554 vector unsigned char vec_min (vector unsigned char,
12555 vector unsigned char);
12556 vector signed char vec_min (vector bool char, vector signed char);
12557 vector signed char vec_min (vector signed char, vector bool char);
12558 vector signed char vec_min (vector signed char, vector signed char);
12559 vector unsigned short vec_min (vector bool short,
12560 vector unsigned short);
12561 vector unsigned short vec_min (vector unsigned short,
12562 vector bool short);
12563 vector unsigned short vec_min (vector unsigned short,
12564 vector unsigned short);
12565 vector signed short vec_min (vector bool short, vector signed short);
12566 vector signed short vec_min (vector signed short, vector bool short);
12567 vector signed short vec_min (vector signed short, vector signed short);
12568 vector unsigned int vec_min (vector bool int, vector unsigned int);
12569 vector unsigned int vec_min (vector unsigned int, vector bool int);
12570 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
12571 vector signed int vec_min (vector bool int, vector signed int);
12572 vector signed int vec_min (vector signed int, vector bool int);
12573 vector signed int vec_min (vector signed int, vector signed int);
12574 vector float vec_min (vector float, vector float);
12575
12576 vector float vec_vminfp (vector float, vector float);
12577
12578 vector signed int vec_vminsw (vector bool int, vector signed int);
12579 vector signed int vec_vminsw (vector signed int, vector bool int);
12580 vector signed int vec_vminsw (vector signed int, vector signed int);
12581
12582 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
12583 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
12584 vector unsigned int vec_vminuw (vector unsigned int,
12585 vector unsigned int);
12586
12587 vector signed short vec_vminsh (vector bool short, vector signed short);
12588 vector signed short vec_vminsh (vector signed short, vector bool short);
12589 vector signed short vec_vminsh (vector signed short,
12590 vector signed short);
12591
12592 vector unsigned short vec_vminuh (vector bool short,
12593 vector unsigned short);
12594 vector unsigned short vec_vminuh (vector unsigned short,
12595 vector bool short);
12596 vector unsigned short vec_vminuh (vector unsigned short,
12597 vector unsigned short);
12598
12599 vector signed char vec_vminsb (vector bool char, vector signed char);
12600 vector signed char vec_vminsb (vector signed char, vector bool char);
12601 vector signed char vec_vminsb (vector signed char, vector signed char);
12602
12603 vector unsigned char vec_vminub (vector bool char,
12604 vector unsigned char);
12605 vector unsigned char vec_vminub (vector unsigned char,
12606 vector bool char);
12607 vector unsigned char vec_vminub (vector unsigned char,
12608 vector unsigned char);
12609
12610 vector signed short vec_mladd (vector signed short,
12611 vector signed short,
12612 vector signed short);
12613 vector signed short vec_mladd (vector signed short,
12614 vector unsigned short,
12615 vector unsigned short);
12616 vector signed short vec_mladd (vector unsigned short,
12617 vector signed short,
12618 vector signed short);
12619 vector unsigned short vec_mladd (vector unsigned short,
12620 vector unsigned short,
12621 vector unsigned short);
12622
12623 vector signed short vec_mradds (vector signed short,
12624 vector signed short,
12625 vector signed short);
12626
12627 vector unsigned int vec_msum (vector unsigned char,
12628 vector unsigned char,
12629 vector unsigned int);
12630 vector signed int vec_msum (vector signed char,
12631 vector unsigned char,
12632 vector signed int);
12633 vector unsigned int vec_msum (vector unsigned short,
12634 vector unsigned short,
12635 vector unsigned int);
12636 vector signed int vec_msum (vector signed short,
12637 vector signed short,
12638 vector signed int);
12639
12640 vector signed int vec_vmsumshm (vector signed short,
12641 vector signed short,
12642 vector signed int);
12643
12644 vector unsigned int vec_vmsumuhm (vector unsigned short,
12645 vector unsigned short,
12646 vector unsigned int);
12647
12648 vector signed int vec_vmsummbm (vector signed char,
12649 vector unsigned char,
12650 vector signed int);
12651
12652 vector unsigned int vec_vmsumubm (vector unsigned char,
12653 vector unsigned char,
12654 vector unsigned int);
12655
12656 vector unsigned int vec_msums (vector unsigned short,
12657 vector unsigned short,
12658 vector unsigned int);
12659 vector signed int vec_msums (vector signed short,
12660 vector signed short,
12661 vector signed int);
12662
12663 vector signed int vec_vmsumshs (vector signed short,
12664 vector signed short,
12665 vector signed int);
12666
12667 vector unsigned int vec_vmsumuhs (vector unsigned short,
12668 vector unsigned short,
12669 vector unsigned int);
12670
12671 void vec_mtvscr (vector signed int);
12672 void vec_mtvscr (vector unsigned int);
12673 void vec_mtvscr (vector bool int);
12674 void vec_mtvscr (vector signed short);
12675 void vec_mtvscr (vector unsigned short);
12676 void vec_mtvscr (vector bool short);
12677 void vec_mtvscr (vector pixel);
12678 void vec_mtvscr (vector signed char);
12679 void vec_mtvscr (vector unsigned char);
12680 void vec_mtvscr (vector bool char);
12681
12682 vector unsigned short vec_mule (vector unsigned char,
12683 vector unsigned char);
12684 vector signed short vec_mule (vector signed char,
12685 vector signed char);
12686 vector unsigned int vec_mule (vector unsigned short,
12687 vector unsigned short);
12688 vector signed int vec_mule (vector signed short, vector signed short);
12689
12690 vector signed int vec_vmulesh (vector signed short,
12691 vector signed short);
12692
12693 vector unsigned int vec_vmuleuh (vector unsigned short,
12694 vector unsigned short);
12695
12696 vector signed short vec_vmulesb (vector signed char,
12697 vector signed char);
12698
12699 vector unsigned short vec_vmuleub (vector unsigned char,
12700 vector unsigned char);
12701
12702 vector unsigned short vec_mulo (vector unsigned char,
12703 vector unsigned char);
12704 vector signed short vec_mulo (vector signed char, vector signed char);
12705 vector unsigned int vec_mulo (vector unsigned short,
12706 vector unsigned short);
12707 vector signed int vec_mulo (vector signed short, vector signed short);
12708
12709 vector signed int vec_vmulosh (vector signed short,
12710 vector signed short);
12711
12712 vector unsigned int vec_vmulouh (vector unsigned short,
12713 vector unsigned short);
12714
12715 vector signed short vec_vmulosb (vector signed char,
12716 vector signed char);
12717
12718 vector unsigned short vec_vmuloub (vector unsigned char,
12719 vector unsigned char);
12720
12721 vector float vec_nmsub (vector float, vector float, vector float);
12722
12723 vector float vec_nor (vector float, vector float);
12724 vector signed int vec_nor (vector signed int, vector signed int);
12725 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
12726 vector bool int vec_nor (vector bool int, vector bool int);
12727 vector signed short vec_nor (vector signed short, vector signed short);
12728 vector unsigned short vec_nor (vector unsigned short,
12729 vector unsigned short);
12730 vector bool short vec_nor (vector bool short, vector bool short);
12731 vector signed char vec_nor (vector signed char, vector signed char);
12732 vector unsigned char vec_nor (vector unsigned char,
12733 vector unsigned char);
12734 vector bool char vec_nor (vector bool char, vector bool char);
12735
12736 vector float vec_or (vector float, vector float);
12737 vector float vec_or (vector float, vector bool int);
12738 vector float vec_or (vector bool int, vector float);
12739 vector bool int vec_or (vector bool int, vector bool int);
12740 vector signed int vec_or (vector bool int, vector signed int);
12741 vector signed int vec_or (vector signed int, vector bool int);
12742 vector signed int vec_or (vector signed int, vector signed int);
12743 vector unsigned int vec_or (vector bool int, vector unsigned int);
12744 vector unsigned int vec_or (vector unsigned int, vector bool int);
12745 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
12746 vector bool short vec_or (vector bool short, vector bool short);
12747 vector signed short vec_or (vector bool short, vector signed short);
12748 vector signed short vec_or (vector signed short, vector bool short);
12749 vector signed short vec_or (vector signed short, vector signed short);
12750 vector unsigned short vec_or (vector bool short, vector unsigned short);
12751 vector unsigned short vec_or (vector unsigned short, vector bool short);
12752 vector unsigned short vec_or (vector unsigned short,
12753 vector unsigned short);
12754 vector signed char vec_or (vector bool char, vector signed char);
12755 vector bool char vec_or (vector bool char, vector bool char);
12756 vector signed char vec_or (vector signed char, vector bool char);
12757 vector signed char vec_or (vector signed char, vector signed char);
12758 vector unsigned char vec_or (vector bool char, vector unsigned char);
12759 vector unsigned char vec_or (vector unsigned char, vector bool char);
12760 vector unsigned char vec_or (vector unsigned char,
12761 vector unsigned char);
12762
12763 vector signed char vec_pack (vector signed short, vector signed short);
12764 vector unsigned char vec_pack (vector unsigned short,
12765 vector unsigned short);
12766 vector bool char vec_pack (vector bool short, vector bool short);
12767 vector signed short vec_pack (vector signed int, vector signed int);
12768 vector unsigned short vec_pack (vector unsigned int,
12769 vector unsigned int);
12770 vector bool short vec_pack (vector bool int, vector bool int);
12771
12772 vector bool short vec_vpkuwum (vector bool int, vector bool int);
12773 vector signed short vec_vpkuwum (vector signed int, vector signed int);
12774 vector unsigned short vec_vpkuwum (vector unsigned int,
12775 vector unsigned int);
12776
12777 vector bool char vec_vpkuhum (vector bool short, vector bool short);
12778 vector signed char vec_vpkuhum (vector signed short,
12779 vector signed short);
12780 vector unsigned char vec_vpkuhum (vector unsigned short,
12781 vector unsigned short);
12782
12783 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
12784
12785 vector unsigned char vec_packs (vector unsigned short,
12786 vector unsigned short);
12787 vector signed char vec_packs (vector signed short, vector signed short);
12788 vector unsigned short vec_packs (vector unsigned int,
12789 vector unsigned int);
12790 vector signed short vec_packs (vector signed int, vector signed int);
12791
12792 vector signed short vec_vpkswss (vector signed int, vector signed int);
12793
12794 vector unsigned short vec_vpkuwus (vector unsigned int,
12795 vector unsigned int);
12796
12797 vector signed char vec_vpkshss (vector signed short,
12798 vector signed short);
12799
12800 vector unsigned char vec_vpkuhus (vector unsigned short,
12801 vector unsigned short);
12802
12803 vector unsigned char vec_packsu (vector unsigned short,
12804 vector unsigned short);
12805 vector unsigned char vec_packsu (vector signed short,
12806 vector signed short);
12807 vector unsigned short vec_packsu (vector unsigned int,
12808 vector unsigned int);
12809 vector unsigned short vec_packsu (vector signed int, vector signed int);
12810
12811 vector unsigned short vec_vpkswus (vector signed int,
12812 vector signed int);
12813
12814 vector unsigned char vec_vpkshus (vector signed short,
12815 vector signed short);
12816
12817 vector float vec_perm (vector float,
12818 vector float,
12819 vector unsigned char);
12820 vector signed int vec_perm (vector signed int,
12821 vector signed int,
12822 vector unsigned char);
12823 vector unsigned int vec_perm (vector unsigned int,
12824 vector unsigned int,
12825 vector unsigned char);
12826 vector bool int vec_perm (vector bool int,
12827 vector bool int,
12828 vector unsigned char);
12829 vector signed short vec_perm (vector signed short,
12830 vector signed short,
12831 vector unsigned char);
12832 vector unsigned short vec_perm (vector unsigned short,
12833 vector unsigned short,
12834 vector unsigned char);
12835 vector bool short vec_perm (vector bool short,
12836 vector bool short,
12837 vector unsigned char);
12838 vector pixel vec_perm (vector pixel,
12839 vector pixel,
12840 vector unsigned char);
12841 vector signed char vec_perm (vector signed char,
12842 vector signed char,
12843 vector unsigned char);
12844 vector unsigned char vec_perm (vector unsigned char,
12845 vector unsigned char,
12846 vector unsigned char);
12847 vector bool char vec_perm (vector bool char,
12848 vector bool char,
12849 vector unsigned char);
12850
12851 vector float vec_re (vector float);
12852
12853 vector signed char vec_rl (vector signed char,
12854 vector unsigned char);
12855 vector unsigned char vec_rl (vector unsigned char,
12856 vector unsigned char);
12857 vector signed short vec_rl (vector signed short, vector unsigned short);
12858 vector unsigned short vec_rl (vector unsigned short,
12859 vector unsigned short);
12860 vector signed int vec_rl (vector signed int, vector unsigned int);
12861 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
12862
12863 vector signed int vec_vrlw (vector signed int, vector unsigned int);
12864 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
12865
12866 vector signed short vec_vrlh (vector signed short,
12867 vector unsigned short);
12868 vector unsigned short vec_vrlh (vector unsigned short,
12869 vector unsigned short);
12870
12871 vector signed char vec_vrlb (vector signed char, vector unsigned char);
12872 vector unsigned char vec_vrlb (vector unsigned char,
12873 vector unsigned char);
12874
12875 vector float vec_round (vector float);
12876
12877 vector float vec_recip (vector float, vector float);
12878
12879 vector float vec_rsqrt (vector float);
12880
12881 vector float vec_rsqrte (vector float);
12882
12883 vector float vec_sel (vector float, vector float, vector bool int);
12884 vector float vec_sel (vector float, vector float, vector unsigned int);
12885 vector signed int vec_sel (vector signed int,
12886 vector signed int,
12887 vector bool int);
12888 vector signed int vec_sel (vector signed int,
12889 vector signed int,
12890 vector unsigned int);
12891 vector unsigned int vec_sel (vector unsigned int,
12892 vector unsigned int,
12893 vector bool int);
12894 vector unsigned int vec_sel (vector unsigned int,
12895 vector unsigned int,
12896 vector unsigned int);
12897 vector bool int vec_sel (vector bool int,
12898 vector bool int,
12899 vector bool int);
12900 vector bool int vec_sel (vector bool int,
12901 vector bool int,
12902 vector unsigned int);
12903 vector signed short vec_sel (vector signed short,
12904 vector signed short,
12905 vector bool short);
12906 vector signed short vec_sel (vector signed short,
12907 vector signed short,
12908 vector unsigned short);
12909 vector unsigned short vec_sel (vector unsigned short,
12910 vector unsigned short,
12911 vector bool short);
12912 vector unsigned short vec_sel (vector unsigned short,
12913 vector unsigned short,
12914 vector unsigned short);
12915 vector bool short vec_sel (vector bool short,
12916 vector bool short,
12917 vector bool short);
12918 vector bool short vec_sel (vector bool short,
12919 vector bool short,
12920 vector unsigned short);
12921 vector signed char vec_sel (vector signed char,
12922 vector signed char,
12923 vector bool char);
12924 vector signed char vec_sel (vector signed char,
12925 vector signed char,
12926 vector unsigned char);
12927 vector unsigned char vec_sel (vector unsigned char,
12928 vector unsigned char,
12929 vector bool char);
12930 vector unsigned char vec_sel (vector unsigned char,
12931 vector unsigned char,
12932 vector unsigned char);
12933 vector bool char vec_sel (vector bool char,
12934 vector bool char,
12935 vector bool char);
12936 vector bool char vec_sel (vector bool char,
12937 vector bool char,
12938 vector unsigned char);
12939
12940 vector signed char vec_sl (vector signed char,
12941 vector unsigned char);
12942 vector unsigned char vec_sl (vector unsigned char,
12943 vector unsigned char);
12944 vector signed short vec_sl (vector signed short, vector unsigned short);
12945 vector unsigned short vec_sl (vector unsigned short,
12946 vector unsigned short);
12947 vector signed int vec_sl (vector signed int, vector unsigned int);
12948 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
12949
12950 vector signed int vec_vslw (vector signed int, vector unsigned int);
12951 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
12952
12953 vector signed short vec_vslh (vector signed short,
12954 vector unsigned short);
12955 vector unsigned short vec_vslh (vector unsigned short,
12956 vector unsigned short);
12957
12958 vector signed char vec_vslb (vector signed char, vector unsigned char);
12959 vector unsigned char vec_vslb (vector unsigned char,
12960 vector unsigned char);
12961
12962 vector float vec_sld (vector float, vector float, const int);
12963 vector signed int vec_sld (vector signed int,
12964 vector signed int,
12965 const int);
12966 vector unsigned int vec_sld (vector unsigned int,
12967 vector unsigned int,
12968 const int);
12969 vector bool int vec_sld (vector bool int,
12970 vector bool int,
12971 const int);
12972 vector signed short vec_sld (vector signed short,
12973 vector signed short,
12974 const int);
12975 vector unsigned short vec_sld (vector unsigned short,
12976 vector unsigned short,
12977 const int);
12978 vector bool short vec_sld (vector bool short,
12979 vector bool short,
12980 const int);
12981 vector pixel vec_sld (vector pixel,
12982 vector pixel,
12983 const int);
12984 vector signed char vec_sld (vector signed char,
12985 vector signed char,
12986 const int);
12987 vector unsigned char vec_sld (vector unsigned char,
12988 vector unsigned char,
12989 const int);
12990 vector bool char vec_sld (vector bool char,
12991 vector bool char,
12992 const int);
12993
12994 vector signed int vec_sll (vector signed int,
12995 vector unsigned int);
12996 vector signed int vec_sll (vector signed int,
12997 vector unsigned short);
12998 vector signed int vec_sll (vector signed int,
12999 vector unsigned char);
13000 vector unsigned int vec_sll (vector unsigned int,
13001 vector unsigned int);
13002 vector unsigned int vec_sll (vector unsigned int,
13003 vector unsigned short);
13004 vector unsigned int vec_sll (vector unsigned int,
13005 vector unsigned char);
13006 vector bool int vec_sll (vector bool int,
13007 vector unsigned int);
13008 vector bool int vec_sll (vector bool int,
13009 vector unsigned short);
13010 vector bool int vec_sll (vector bool int,
13011 vector unsigned char);
13012 vector signed short vec_sll (vector signed short,
13013 vector unsigned int);
13014 vector signed short vec_sll (vector signed short,
13015 vector unsigned short);
13016 vector signed short vec_sll (vector signed short,
13017 vector unsigned char);
13018 vector unsigned short vec_sll (vector unsigned short,
13019 vector unsigned int);
13020 vector unsigned short vec_sll (vector unsigned short,
13021 vector unsigned short);
13022 vector unsigned short vec_sll (vector unsigned short,
13023 vector unsigned char);
13024 vector bool short vec_sll (vector bool short, vector unsigned int);
13025 vector bool short vec_sll (vector bool short, vector unsigned short);
13026 vector bool short vec_sll (vector bool short, vector unsigned char);
13027 vector pixel vec_sll (vector pixel, vector unsigned int);
13028 vector pixel vec_sll (vector pixel, vector unsigned short);
13029 vector pixel vec_sll (vector pixel, vector unsigned char);
13030 vector signed char vec_sll (vector signed char, vector unsigned int);
13031 vector signed char vec_sll (vector signed char, vector unsigned short);
13032 vector signed char vec_sll (vector signed char, vector unsigned char);
13033 vector unsigned char vec_sll (vector unsigned char,
13034 vector unsigned int);
13035 vector unsigned char vec_sll (vector unsigned char,
13036 vector unsigned short);
13037 vector unsigned char vec_sll (vector unsigned char,
13038 vector unsigned char);
13039 vector bool char vec_sll (vector bool char, vector unsigned int);
13040 vector bool char vec_sll (vector bool char, vector unsigned short);
13041 vector bool char vec_sll (vector bool char, vector unsigned char);
13042
13043 vector float vec_slo (vector float, vector signed char);
13044 vector float vec_slo (vector float, vector unsigned char);
13045 vector signed int vec_slo (vector signed int, vector signed char);
13046 vector signed int vec_slo (vector signed int, vector unsigned char);
13047 vector unsigned int vec_slo (vector unsigned int, vector signed char);
13048 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
13049 vector signed short vec_slo (vector signed short, vector signed char);
13050 vector signed short vec_slo (vector signed short, vector unsigned char);
13051 vector unsigned short vec_slo (vector unsigned short,
13052 vector signed char);
13053 vector unsigned short vec_slo (vector unsigned short,
13054 vector unsigned char);
13055 vector pixel vec_slo (vector pixel, vector signed char);
13056 vector pixel vec_slo (vector pixel, vector unsigned char);
13057 vector signed char vec_slo (vector signed char, vector signed char);
13058 vector signed char vec_slo (vector signed char, vector unsigned char);
13059 vector unsigned char vec_slo (vector unsigned char, vector signed char);
13060 vector unsigned char vec_slo (vector unsigned char,
13061 vector unsigned char);
13062
13063 vector signed char vec_splat (vector signed char, const int);
13064 vector unsigned char vec_splat (vector unsigned char, const int);
13065 vector bool char vec_splat (vector bool char, const int);
13066 vector signed short vec_splat (vector signed short, const int);
13067 vector unsigned short vec_splat (vector unsigned short, const int);
13068 vector bool short vec_splat (vector bool short, const int);
13069 vector pixel vec_splat (vector pixel, const int);
13070 vector float vec_splat (vector float, const int);
13071 vector signed int vec_splat (vector signed int, const int);
13072 vector unsigned int vec_splat (vector unsigned int, const int);
13073 vector bool int vec_splat (vector bool int, const int);
13074
13075 vector float vec_vspltw (vector float, const int);
13076 vector signed int vec_vspltw (vector signed int, const int);
13077 vector unsigned int vec_vspltw (vector unsigned int, const int);
13078 vector bool int vec_vspltw (vector bool int, const int);
13079
13080 vector bool short vec_vsplth (vector bool short, const int);
13081 vector signed short vec_vsplth (vector signed short, const int);
13082 vector unsigned short vec_vsplth (vector unsigned short, const int);
13083 vector pixel vec_vsplth (vector pixel, const int);
13084
13085 vector signed char vec_vspltb (vector signed char, const int);
13086 vector unsigned char vec_vspltb (vector unsigned char, const int);
13087 vector bool char vec_vspltb (vector bool char, const int);
13088
13089 vector signed char vec_splat_s8 (const int);
13090
13091 vector signed short vec_splat_s16 (const int);
13092
13093 vector signed int vec_splat_s32 (const int);
13094
13095 vector unsigned char vec_splat_u8 (const int);
13096
13097 vector unsigned short vec_splat_u16 (const int);
13098
13099 vector unsigned int vec_splat_u32 (const int);
13100
13101 vector signed char vec_sr (vector signed char, vector unsigned char);
13102 vector unsigned char vec_sr (vector unsigned char,
13103 vector unsigned char);
13104 vector signed short vec_sr (vector signed short,
13105 vector unsigned short);
13106 vector unsigned short vec_sr (vector unsigned short,
13107 vector unsigned short);
13108 vector signed int vec_sr (vector signed int, vector unsigned int);
13109 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
13110
13111 vector signed int vec_vsrw (vector signed int, vector unsigned int);
13112 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
13113
13114 vector signed short vec_vsrh (vector signed short,
13115 vector unsigned short);
13116 vector unsigned short vec_vsrh (vector unsigned short,
13117 vector unsigned short);
13118
13119 vector signed char vec_vsrb (vector signed char, vector unsigned char);
13120 vector unsigned char vec_vsrb (vector unsigned char,
13121 vector unsigned char);
13122
13123 vector signed char vec_sra (vector signed char, vector unsigned char);
13124 vector unsigned char vec_sra (vector unsigned char,
13125 vector unsigned char);
13126 vector signed short vec_sra (vector signed short,
13127 vector unsigned short);
13128 vector unsigned short vec_sra (vector unsigned short,
13129 vector unsigned short);
13130 vector signed int vec_sra (vector signed int, vector unsigned int);
13131 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
13132
13133 vector signed int vec_vsraw (vector signed int, vector unsigned int);
13134 vector unsigned int vec_vsraw (vector unsigned int,
13135 vector unsigned int);
13136
13137 vector signed short vec_vsrah (vector signed short,
13138 vector unsigned short);
13139 vector unsigned short vec_vsrah (vector unsigned short,
13140 vector unsigned short);
13141
13142 vector signed char vec_vsrab (vector signed char, vector unsigned char);
13143 vector unsigned char vec_vsrab (vector unsigned char,
13144 vector unsigned char);
13145
13146 vector signed int vec_srl (vector signed int, vector unsigned int);
13147 vector signed int vec_srl (vector signed int, vector unsigned short);
13148 vector signed int vec_srl (vector signed int, vector unsigned char);
13149 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
13150 vector unsigned int vec_srl (vector unsigned int,
13151 vector unsigned short);
13152 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
13153 vector bool int vec_srl (vector bool int, vector unsigned int);
13154 vector bool int vec_srl (vector bool int, vector unsigned short);
13155 vector bool int vec_srl (vector bool int, vector unsigned char);
13156 vector signed short vec_srl (vector signed short, vector unsigned int);
13157 vector signed short vec_srl (vector signed short,
13158 vector unsigned short);
13159 vector signed short vec_srl (vector signed short, vector unsigned char);
13160 vector unsigned short vec_srl (vector unsigned short,
13161 vector unsigned int);
13162 vector unsigned short vec_srl (vector unsigned short,
13163 vector unsigned short);
13164 vector unsigned short vec_srl (vector unsigned short,
13165 vector unsigned char);
13166 vector bool short vec_srl (vector bool short, vector unsigned int);
13167 vector bool short vec_srl (vector bool short, vector unsigned short);
13168 vector bool short vec_srl (vector bool short, vector unsigned char);
13169 vector pixel vec_srl (vector pixel, vector unsigned int);
13170 vector pixel vec_srl (vector pixel, vector unsigned short);
13171 vector pixel vec_srl (vector pixel, vector unsigned char);
13172 vector signed char vec_srl (vector signed char, vector unsigned int);
13173 vector signed char vec_srl (vector signed char, vector unsigned short);
13174 vector signed char vec_srl (vector signed char, vector unsigned char);
13175 vector unsigned char vec_srl (vector unsigned char,
13176 vector unsigned int);
13177 vector unsigned char vec_srl (vector unsigned char,
13178 vector unsigned short);
13179 vector unsigned char vec_srl (vector unsigned char,
13180 vector unsigned char);
13181 vector bool char vec_srl (vector bool char, vector unsigned int);
13182 vector bool char vec_srl (vector bool char, vector unsigned short);
13183 vector bool char vec_srl (vector bool char, vector unsigned char);
13184
13185 vector float vec_sro (vector float, vector signed char);
13186 vector float vec_sro (vector float, vector unsigned char);
13187 vector signed int vec_sro (vector signed int, vector signed char);
13188 vector signed int vec_sro (vector signed int, vector unsigned char);
13189 vector unsigned int vec_sro (vector unsigned int, vector signed char);
13190 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
13191 vector signed short vec_sro (vector signed short, vector signed char);
13192 vector signed short vec_sro (vector signed short, vector unsigned char);
13193 vector unsigned short vec_sro (vector unsigned short,
13194 vector signed char);
13195 vector unsigned short vec_sro (vector unsigned short,
13196 vector unsigned char);
13197 vector pixel vec_sro (vector pixel, vector signed char);
13198 vector pixel vec_sro (vector pixel, vector unsigned char);
13199 vector signed char vec_sro (vector signed char, vector signed char);
13200 vector signed char vec_sro (vector signed char, vector unsigned char);
13201 vector unsigned char vec_sro (vector unsigned char, vector signed char);
13202 vector unsigned char vec_sro (vector unsigned char,
13203 vector unsigned char);
13204
13205 void vec_st (vector float, int, vector float *);
13206 void vec_st (vector float, int, float *);
13207 void vec_st (vector signed int, int, vector signed int *);
13208 void vec_st (vector signed int, int, int *);
13209 void vec_st (vector unsigned int, int, vector unsigned int *);
13210 void vec_st (vector unsigned int, int, unsigned int *);
13211 void vec_st (vector bool int, int, vector bool int *);
13212 void vec_st (vector bool int, int, unsigned int *);
13213 void vec_st (vector bool int, int, int *);
13214 void vec_st (vector signed short, int, vector signed short *);
13215 void vec_st (vector signed short, int, short *);
13216 void vec_st (vector unsigned short, int, vector unsigned short *);
13217 void vec_st (vector unsigned short, int, unsigned short *);
13218 void vec_st (vector bool short, int, vector bool short *);
13219 void vec_st (vector bool short, int, unsigned short *);
13220 void vec_st (vector pixel, int, vector pixel *);
13221 void vec_st (vector pixel, int, unsigned short *);
13222 void vec_st (vector pixel, int, short *);
13223 void vec_st (vector bool short, int, short *);
13224 void vec_st (vector signed char, int, vector signed char *);
13225 void vec_st (vector signed char, int, signed char *);
13226 void vec_st (vector unsigned char, int, vector unsigned char *);
13227 void vec_st (vector unsigned char, int, unsigned char *);
13228 void vec_st (vector bool char, int, vector bool char *);
13229 void vec_st (vector bool char, int, unsigned char *);
13230 void vec_st (vector bool char, int, signed char *);
13231
13232 void vec_ste (vector signed char, int, signed char *);
13233 void vec_ste (vector unsigned char, int, unsigned char *);
13234 void vec_ste (vector bool char, int, signed char *);
13235 void vec_ste (vector bool char, int, unsigned char *);
13236 void vec_ste (vector signed short, int, short *);
13237 void vec_ste (vector unsigned short, int, unsigned short *);
13238 void vec_ste (vector bool short, int, short *);
13239 void vec_ste (vector bool short, int, unsigned short *);
13240 void vec_ste (vector pixel, int, short *);
13241 void vec_ste (vector pixel, int, unsigned short *);
13242 void vec_ste (vector float, int, float *);
13243 void vec_ste (vector signed int, int, int *);
13244 void vec_ste (vector unsigned int, int, unsigned int *);
13245 void vec_ste (vector bool int, int, int *);
13246 void vec_ste (vector bool int, int, unsigned int *);
13247
13248 void vec_stvewx (vector float, int, float *);
13249 void vec_stvewx (vector signed int, int, int *);
13250 void vec_stvewx (vector unsigned int, int, unsigned int *);
13251 void vec_stvewx (vector bool int, int, int *);
13252 void vec_stvewx (vector bool int, int, unsigned int *);
13253
13254 void vec_stvehx (vector signed short, int, short *);
13255 void vec_stvehx (vector unsigned short, int, unsigned short *);
13256 void vec_stvehx (vector bool short, int, short *);
13257 void vec_stvehx (vector bool short, int, unsigned short *);
13258 void vec_stvehx (vector pixel, int, short *);
13259 void vec_stvehx (vector pixel, int, unsigned short *);
13260
13261 void vec_stvebx (vector signed char, int, signed char *);
13262 void vec_stvebx (vector unsigned char, int, unsigned char *);
13263 void vec_stvebx (vector bool char, int, signed char *);
13264 void vec_stvebx (vector bool char, int, unsigned char *);
13265
13266 void vec_stl (vector float, int, vector float *);
13267 void vec_stl (vector float, int, float *);
13268 void vec_stl (vector signed int, int, vector signed int *);
13269 void vec_stl (vector signed int, int, int *);
13270 void vec_stl (vector unsigned int, int, vector unsigned int *);
13271 void vec_stl (vector unsigned int, int, unsigned int *);
13272 void vec_stl (vector bool int, int, vector bool int *);
13273 void vec_stl (vector bool int, int, unsigned int *);
13274 void vec_stl (vector bool int, int, int *);
13275 void vec_stl (vector signed short, int, vector signed short *);
13276 void vec_stl (vector signed short, int, short *);
13277 void vec_stl (vector unsigned short, int, vector unsigned short *);
13278 void vec_stl (vector unsigned short, int, unsigned short *);
13279 void vec_stl (vector bool short, int, vector bool short *);
13280 void vec_stl (vector bool short, int, unsigned short *);
13281 void vec_stl (vector bool short, int, short *);
13282 void vec_stl (vector pixel, int, vector pixel *);
13283 void vec_stl (vector pixel, int, unsigned short *);
13284 void vec_stl (vector pixel, int, short *);
13285 void vec_stl (vector signed char, int, vector signed char *);
13286 void vec_stl (vector signed char, int, signed char *);
13287 void vec_stl (vector unsigned char, int, vector unsigned char *);
13288 void vec_stl (vector unsigned char, int, unsigned char *);
13289 void vec_stl (vector bool char, int, vector bool char *);
13290 void vec_stl (vector bool char, int, unsigned char *);
13291 void vec_stl (vector bool char, int, signed char *);
13292
13293 vector signed char vec_sub (vector bool char, vector signed char);
13294 vector signed char vec_sub (vector signed char, vector bool char);
13295 vector signed char vec_sub (vector signed char, vector signed char);
13296 vector unsigned char vec_sub (vector bool char, vector unsigned char);
13297 vector unsigned char vec_sub (vector unsigned char, vector bool char);
13298 vector unsigned char vec_sub (vector unsigned char,
13299 vector unsigned char);
13300 vector signed short vec_sub (vector bool short, vector signed short);
13301 vector signed short vec_sub (vector signed short, vector bool short);
13302 vector signed short vec_sub (vector signed short, vector signed short);
13303 vector unsigned short vec_sub (vector bool short,
13304 vector unsigned short);
13305 vector unsigned short vec_sub (vector unsigned short,
13306 vector bool short);
13307 vector unsigned short vec_sub (vector unsigned short,
13308 vector unsigned short);
13309 vector signed int vec_sub (vector bool int, vector signed int);
13310 vector signed int vec_sub (vector signed int, vector bool int);
13311 vector signed int vec_sub (vector signed int, vector signed int);
13312 vector unsigned int vec_sub (vector bool int, vector unsigned int);
13313 vector unsigned int vec_sub (vector unsigned int, vector bool int);
13314 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
13315 vector float vec_sub (vector float, vector float);
13316
13317 vector float vec_vsubfp (vector float, vector float);
13318
13319 vector signed int vec_vsubuwm (vector bool int, vector signed int);
13320 vector signed int vec_vsubuwm (vector signed int, vector bool int);
13321 vector signed int vec_vsubuwm (vector signed int, vector signed int);
13322 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
13323 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
13324 vector unsigned int vec_vsubuwm (vector unsigned int,
13325 vector unsigned int);
13326
13327 vector signed short vec_vsubuhm (vector bool short,
13328 vector signed short);
13329 vector signed short vec_vsubuhm (vector signed short,
13330 vector bool short);
13331 vector signed short vec_vsubuhm (vector signed short,
13332 vector signed short);
13333 vector unsigned short vec_vsubuhm (vector bool short,
13334 vector unsigned short);
13335 vector unsigned short vec_vsubuhm (vector unsigned short,
13336 vector bool short);
13337 vector unsigned short vec_vsubuhm (vector unsigned short,
13338 vector unsigned short);
13339
13340 vector signed char vec_vsububm (vector bool char, vector signed char);
13341 vector signed char vec_vsububm (vector signed char, vector bool char);
13342 vector signed char vec_vsububm (vector signed char, vector signed char);
13343 vector unsigned char vec_vsububm (vector bool char,
13344 vector unsigned char);
13345 vector unsigned char vec_vsububm (vector unsigned char,
13346 vector bool char);
13347 vector unsigned char vec_vsububm (vector unsigned char,
13348 vector unsigned char);
13349
13350 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
13351
13352 vector unsigned char vec_subs (vector bool char, vector unsigned char);
13353 vector unsigned char vec_subs (vector unsigned char, vector bool char);
13354 vector unsigned char vec_subs (vector unsigned char,
13355 vector unsigned char);
13356 vector signed char vec_subs (vector bool char, vector signed char);
13357 vector signed char vec_subs (vector signed char, vector bool char);
13358 vector signed char vec_subs (vector signed char, vector signed char);
13359 vector unsigned short vec_subs (vector bool short,
13360 vector unsigned short);
13361 vector unsigned short vec_subs (vector unsigned short,
13362 vector bool short);
13363 vector unsigned short vec_subs (vector unsigned short,
13364 vector unsigned short);
13365 vector signed short vec_subs (vector bool short, vector signed short);
13366 vector signed short vec_subs (vector signed short, vector bool short);
13367 vector signed short vec_subs (vector signed short, vector signed short);
13368 vector unsigned int vec_subs (vector bool int, vector unsigned int);
13369 vector unsigned int vec_subs (vector unsigned int, vector bool int);
13370 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
13371 vector signed int vec_subs (vector bool int, vector signed int);
13372 vector signed int vec_subs (vector signed int, vector bool int);
13373 vector signed int vec_subs (vector signed int, vector signed int);
13374
13375 vector signed int vec_vsubsws (vector bool int, vector signed int);
13376 vector signed int vec_vsubsws (vector signed int, vector bool int);
13377 vector signed int vec_vsubsws (vector signed int, vector signed int);
13378
13379 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
13380 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
13381 vector unsigned int vec_vsubuws (vector unsigned int,
13382 vector unsigned int);
13383
13384 vector signed short vec_vsubshs (vector bool short,
13385 vector signed short);
13386 vector signed short vec_vsubshs (vector signed short,
13387 vector bool short);
13388 vector signed short vec_vsubshs (vector signed short,
13389 vector signed short);
13390
13391 vector unsigned short vec_vsubuhs (vector bool short,
13392 vector unsigned short);
13393 vector unsigned short vec_vsubuhs (vector unsigned short,
13394 vector bool short);
13395 vector unsigned short vec_vsubuhs (vector unsigned short,
13396 vector unsigned short);
13397
13398 vector signed char vec_vsubsbs (vector bool char, vector signed char);
13399 vector signed char vec_vsubsbs (vector signed char, vector bool char);
13400 vector signed char vec_vsubsbs (vector signed char, vector signed char);
13401
13402 vector unsigned char vec_vsububs (vector bool char,
13403 vector unsigned char);
13404 vector unsigned char vec_vsububs (vector unsigned char,
13405 vector bool char);
13406 vector unsigned char vec_vsububs (vector unsigned char,
13407 vector unsigned char);
13408
13409 vector unsigned int vec_sum4s (vector unsigned char,
13410 vector unsigned int);
13411 vector signed int vec_sum4s (vector signed char, vector signed int);
13412 vector signed int vec_sum4s (vector signed short, vector signed int);
13413
13414 vector signed int vec_vsum4shs (vector signed short, vector signed int);
13415
13416 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
13417
13418 vector unsigned int vec_vsum4ubs (vector unsigned char,
13419 vector unsigned int);
13420
13421 vector signed int vec_sum2s (vector signed int, vector signed int);
13422
13423 vector signed int vec_sums (vector signed int, vector signed int);
13424
13425 vector float vec_trunc (vector float);
13426
13427 vector signed short vec_unpackh (vector signed char);
13428 vector bool short vec_unpackh (vector bool char);
13429 vector signed int vec_unpackh (vector signed short);
13430 vector bool int vec_unpackh (vector bool short);
13431 vector unsigned int vec_unpackh (vector pixel);
13432
13433 vector bool int vec_vupkhsh (vector bool short);
13434 vector signed int vec_vupkhsh (vector signed short);
13435
13436 vector unsigned int vec_vupkhpx (vector pixel);
13437
13438 vector bool short vec_vupkhsb (vector bool char);
13439 vector signed short vec_vupkhsb (vector signed char);
13440
13441 vector signed short vec_unpackl (vector signed char);
13442 vector bool short vec_unpackl (vector bool char);
13443 vector unsigned int vec_unpackl (vector pixel);
13444 vector signed int vec_unpackl (vector signed short);
13445 vector bool int vec_unpackl (vector bool short);
13446
13447 vector unsigned int vec_vupklpx (vector pixel);
13448
13449 vector bool int vec_vupklsh (vector bool short);
13450 vector signed int vec_vupklsh (vector signed short);
13451
13452 vector bool short vec_vupklsb (vector bool char);
13453 vector signed short vec_vupklsb (vector signed char);
13454
13455 vector float vec_xor (vector float, vector float);
13456 vector float vec_xor (vector float, vector bool int);
13457 vector float vec_xor (vector bool int, vector float);
13458 vector bool int vec_xor (vector bool int, vector bool int);
13459 vector signed int vec_xor (vector bool int, vector signed int);
13460 vector signed int vec_xor (vector signed int, vector bool int);
13461 vector signed int vec_xor (vector signed int, vector signed int);
13462 vector unsigned int vec_xor (vector bool int, vector unsigned int);
13463 vector unsigned int vec_xor (vector unsigned int, vector bool int);
13464 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
13465 vector bool short vec_xor (vector bool short, vector bool short);
13466 vector signed short vec_xor (vector bool short, vector signed short);
13467 vector signed short vec_xor (vector signed short, vector bool short);
13468 vector signed short vec_xor (vector signed short, vector signed short);
13469 vector unsigned short vec_xor (vector bool short,
13470 vector unsigned short);
13471 vector unsigned short vec_xor (vector unsigned short,
13472 vector bool short);
13473 vector unsigned short vec_xor (vector unsigned short,
13474 vector unsigned short);
13475 vector signed char vec_xor (vector bool char, vector signed char);
13476 vector bool char vec_xor (vector bool char, vector bool char);
13477 vector signed char vec_xor (vector signed char, vector bool char);
13478 vector signed char vec_xor (vector signed char, vector signed char);
13479 vector unsigned char vec_xor (vector bool char, vector unsigned char);
13480 vector unsigned char vec_xor (vector unsigned char, vector bool char);
13481 vector unsigned char vec_xor (vector unsigned char,
13482 vector unsigned char);
13483
13484 int vec_all_eq (vector signed char, vector bool char);
13485 int vec_all_eq (vector signed char, vector signed char);
13486 int vec_all_eq (vector unsigned char, vector bool char);
13487 int vec_all_eq (vector unsigned char, vector unsigned char);
13488 int vec_all_eq (vector bool char, vector bool char);
13489 int vec_all_eq (vector bool char, vector unsigned char);
13490 int vec_all_eq (vector bool char, vector signed char);
13491 int vec_all_eq (vector signed short, vector bool short);
13492 int vec_all_eq (vector signed short, vector signed short);
13493 int vec_all_eq (vector unsigned short, vector bool short);
13494 int vec_all_eq (vector unsigned short, vector unsigned short);
13495 int vec_all_eq (vector bool short, vector bool short);
13496 int vec_all_eq (vector bool short, vector unsigned short);
13497 int vec_all_eq (vector bool short, vector signed short);
13498 int vec_all_eq (vector pixel, vector pixel);
13499 int vec_all_eq (vector signed int, vector bool int);
13500 int vec_all_eq (vector signed int, vector signed int);
13501 int vec_all_eq (vector unsigned int, vector bool int);
13502 int vec_all_eq (vector unsigned int, vector unsigned int);
13503 int vec_all_eq (vector bool int, vector bool int);
13504 int vec_all_eq (vector bool int, vector unsigned int);
13505 int vec_all_eq (vector bool int, vector signed int);
13506 int vec_all_eq (vector float, vector float);
13507
13508 int vec_all_ge (vector bool char, vector unsigned char);
13509 int vec_all_ge (vector unsigned char, vector bool char);
13510 int vec_all_ge (vector unsigned char, vector unsigned char);
13511 int vec_all_ge (vector bool char, vector signed char);
13512 int vec_all_ge (vector signed char, vector bool char);
13513 int vec_all_ge (vector signed char, vector signed char);
13514 int vec_all_ge (vector bool short, vector unsigned short);
13515 int vec_all_ge (vector unsigned short, vector bool short);
13516 int vec_all_ge (vector unsigned short, vector unsigned short);
13517 int vec_all_ge (vector signed short, vector signed short);
13518 int vec_all_ge (vector bool short, vector signed short);
13519 int vec_all_ge (vector signed short, vector bool short);
13520 int vec_all_ge (vector bool int, vector unsigned int);
13521 int vec_all_ge (vector unsigned int, vector bool int);
13522 int vec_all_ge (vector unsigned int, vector unsigned int);
13523 int vec_all_ge (vector bool int, vector signed int);
13524 int vec_all_ge (vector signed int, vector bool int);
13525 int vec_all_ge (vector signed int, vector signed int);
13526 int vec_all_ge (vector float, vector float);
13527
13528 int vec_all_gt (vector bool char, vector unsigned char);
13529 int vec_all_gt (vector unsigned char, vector bool char);
13530 int vec_all_gt (vector unsigned char, vector unsigned char);
13531 int vec_all_gt (vector bool char, vector signed char);
13532 int vec_all_gt (vector signed char, vector bool char);
13533 int vec_all_gt (vector signed char, vector signed char);
13534 int vec_all_gt (vector bool short, vector unsigned short);
13535 int vec_all_gt (vector unsigned short, vector bool short);
13536 int vec_all_gt (vector unsigned short, vector unsigned short);
13537 int vec_all_gt (vector bool short, vector signed short);
13538 int vec_all_gt (vector signed short, vector bool short);
13539 int vec_all_gt (vector signed short, vector signed short);
13540 int vec_all_gt (vector bool int, vector unsigned int);
13541 int vec_all_gt (vector unsigned int, vector bool int);
13542 int vec_all_gt (vector unsigned int, vector unsigned int);
13543 int vec_all_gt (vector bool int, vector signed int);
13544 int vec_all_gt (vector signed int, vector bool int);
13545 int vec_all_gt (vector signed int, vector signed int);
13546 int vec_all_gt (vector float, vector float);
13547
13548 int vec_all_in (vector float, vector float);
13549
13550 int vec_all_le (vector bool char, vector unsigned char);
13551 int vec_all_le (vector unsigned char, vector bool char);
13552 int vec_all_le (vector unsigned char, vector unsigned char);
13553 int vec_all_le (vector bool char, vector signed char);
13554 int vec_all_le (vector signed char, vector bool char);
13555 int vec_all_le (vector signed char, vector signed char);
13556 int vec_all_le (vector bool short, vector unsigned short);
13557 int vec_all_le (vector unsigned short, vector bool short);
13558 int vec_all_le (vector unsigned short, vector unsigned short);
13559 int vec_all_le (vector bool short, vector signed short);
13560 int vec_all_le (vector signed short, vector bool short);
13561 int vec_all_le (vector signed short, vector signed short);
13562 int vec_all_le (vector bool int, vector unsigned int);
13563 int vec_all_le (vector unsigned int, vector bool int);
13564 int vec_all_le (vector unsigned int, vector unsigned int);
13565 int vec_all_le (vector bool int, vector signed int);
13566 int vec_all_le (vector signed int, vector bool int);
13567 int vec_all_le (vector signed int, vector signed int);
13568 int vec_all_le (vector float, vector float);
13569
13570 int vec_all_lt (vector bool char, vector unsigned char);
13571 int vec_all_lt (vector unsigned char, vector bool char);
13572 int vec_all_lt (vector unsigned char, vector unsigned char);
13573 int vec_all_lt (vector bool char, vector signed char);
13574 int vec_all_lt (vector signed char, vector bool char);
13575 int vec_all_lt (vector signed char, vector signed char);
13576 int vec_all_lt (vector bool short, vector unsigned short);
13577 int vec_all_lt (vector unsigned short, vector bool short);
13578 int vec_all_lt (vector unsigned short, vector unsigned short);
13579 int vec_all_lt (vector bool short, vector signed short);
13580 int vec_all_lt (vector signed short, vector bool short);
13581 int vec_all_lt (vector signed short, vector signed short);
13582 int vec_all_lt (vector bool int, vector unsigned int);
13583 int vec_all_lt (vector unsigned int, vector bool int);
13584 int vec_all_lt (vector unsigned int, vector unsigned int);
13585 int vec_all_lt (vector bool int, vector signed int);
13586 int vec_all_lt (vector signed int, vector bool int);
13587 int vec_all_lt (vector signed int, vector signed int);
13588 int vec_all_lt (vector float, vector float);
13589
13590 int vec_all_nan (vector float);
13591
13592 int vec_all_ne (vector signed char, vector bool char);
13593 int vec_all_ne (vector signed char, vector signed char);
13594 int vec_all_ne (vector unsigned char, vector bool char);
13595 int vec_all_ne (vector unsigned char, vector unsigned char);
13596 int vec_all_ne (vector bool char, vector bool char);
13597 int vec_all_ne (vector bool char, vector unsigned char);
13598 int vec_all_ne (vector bool char, vector signed char);
13599 int vec_all_ne (vector signed short, vector bool short);
13600 int vec_all_ne (vector signed short, vector signed short);
13601 int vec_all_ne (vector unsigned short, vector bool short);
13602 int vec_all_ne (vector unsigned short, vector unsigned short);
13603 int vec_all_ne (vector bool short, vector bool short);
13604 int vec_all_ne (vector bool short, vector unsigned short);
13605 int vec_all_ne (vector bool short, vector signed short);
13606 int vec_all_ne (vector pixel, vector pixel);
13607 int vec_all_ne (vector signed int, vector bool int);
13608 int vec_all_ne (vector signed int, vector signed int);
13609 int vec_all_ne (vector unsigned int, vector bool int);
13610 int vec_all_ne (vector unsigned int, vector unsigned int);
13611 int vec_all_ne (vector bool int, vector bool int);
13612 int vec_all_ne (vector bool int, vector unsigned int);
13613 int vec_all_ne (vector bool int, vector signed int);
13614 int vec_all_ne (vector float, vector float);
13615
13616 int vec_all_nge (vector float, vector float);
13617
13618 int vec_all_ngt (vector float, vector float);
13619
13620 int vec_all_nle (vector float, vector float);
13621
13622 int vec_all_nlt (vector float, vector float);
13623
13624 int vec_all_numeric (vector float);
13625
13626 int vec_any_eq (vector signed char, vector bool char);
13627 int vec_any_eq (vector signed char, vector signed char);
13628 int vec_any_eq (vector unsigned char, vector bool char);
13629 int vec_any_eq (vector unsigned char, vector unsigned char);
13630 int vec_any_eq (vector bool char, vector bool char);
13631 int vec_any_eq (vector bool char, vector unsigned char);
13632 int vec_any_eq (vector bool char, vector signed char);
13633 int vec_any_eq (vector signed short, vector bool short);
13634 int vec_any_eq (vector signed short, vector signed short);
13635 int vec_any_eq (vector unsigned short, vector bool short);
13636 int vec_any_eq (vector unsigned short, vector unsigned short);
13637 int vec_any_eq (vector bool short, vector bool short);
13638 int vec_any_eq (vector bool short, vector unsigned short);
13639 int vec_any_eq (vector bool short, vector signed short);
13640 int vec_any_eq (vector pixel, vector pixel);
13641 int vec_any_eq (vector signed int, vector bool int);
13642 int vec_any_eq (vector signed int, vector signed int);
13643 int vec_any_eq (vector unsigned int, vector bool int);
13644 int vec_any_eq (vector unsigned int, vector unsigned int);
13645 int vec_any_eq (vector bool int, vector bool int);
13646 int vec_any_eq (vector bool int, vector unsigned int);
13647 int vec_any_eq (vector bool int, vector signed int);
13648 int vec_any_eq (vector float, vector float);
13649
13650 int vec_any_ge (vector signed char, vector bool char);
13651 int vec_any_ge (vector unsigned char, vector bool char);
13652 int vec_any_ge (vector unsigned char, vector unsigned char);
13653 int vec_any_ge (vector signed char, vector signed char);
13654 int vec_any_ge (vector bool char, vector unsigned char);
13655 int vec_any_ge (vector bool char, vector signed char);
13656 int vec_any_ge (vector unsigned short, vector bool short);
13657 int vec_any_ge (vector unsigned short, vector unsigned short);
13658 int vec_any_ge (vector signed short, vector signed short);
13659 int vec_any_ge (vector signed short, vector bool short);
13660 int vec_any_ge (vector bool short, vector unsigned short);
13661 int vec_any_ge (vector bool short, vector signed short);
13662 int vec_any_ge (vector signed int, vector bool int);
13663 int vec_any_ge (vector unsigned int, vector bool int);
13664 int vec_any_ge (vector unsigned int, vector unsigned int);
13665 int vec_any_ge (vector signed int, vector signed int);
13666 int vec_any_ge (vector bool int, vector unsigned int);
13667 int vec_any_ge (vector bool int, vector signed int);
13668 int vec_any_ge (vector float, vector float);
13669
13670 int vec_any_gt (vector bool char, vector unsigned char);
13671 int vec_any_gt (vector unsigned char, vector bool char);
13672 int vec_any_gt (vector unsigned char, vector unsigned char);
13673 int vec_any_gt (vector bool char, vector signed char);
13674 int vec_any_gt (vector signed char, vector bool char);
13675 int vec_any_gt (vector signed char, vector signed char);
13676 int vec_any_gt (vector bool short, vector unsigned short);
13677 int vec_any_gt (vector unsigned short, vector bool short);
13678 int vec_any_gt (vector unsigned short, vector unsigned short);
13679 int vec_any_gt (vector bool short, vector signed short);
13680 int vec_any_gt (vector signed short, vector bool short);
13681 int vec_any_gt (vector signed short, vector signed short);
13682 int vec_any_gt (vector bool int, vector unsigned int);
13683 int vec_any_gt (vector unsigned int, vector bool int);
13684 int vec_any_gt (vector unsigned int, vector unsigned int);
13685 int vec_any_gt (vector bool int, vector signed int);
13686 int vec_any_gt (vector signed int, vector bool int);
13687 int vec_any_gt (vector signed int, vector signed int);
13688 int vec_any_gt (vector float, vector float);
13689
13690 int vec_any_le (vector bool char, vector unsigned char);
13691 int vec_any_le (vector unsigned char, vector bool char);
13692 int vec_any_le (vector unsigned char, vector unsigned char);
13693 int vec_any_le (vector bool char, vector signed char);
13694 int vec_any_le (vector signed char, vector bool char);
13695 int vec_any_le (vector signed char, vector signed char);
13696 int vec_any_le (vector bool short, vector unsigned short);
13697 int vec_any_le (vector unsigned short, vector bool short);
13698 int vec_any_le (vector unsigned short, vector unsigned short);
13699 int vec_any_le (vector bool short, vector signed short);
13700 int vec_any_le (vector signed short, vector bool short);
13701 int vec_any_le (vector signed short, vector signed short);
13702 int vec_any_le (vector bool int, vector unsigned int);
13703 int vec_any_le (vector unsigned int, vector bool int);
13704 int vec_any_le (vector unsigned int, vector unsigned int);
13705 int vec_any_le (vector bool int, vector signed int);
13706 int vec_any_le (vector signed int, vector bool int);
13707 int vec_any_le (vector signed int, vector signed int);
13708 int vec_any_le (vector float, vector float);
13709
13710 int vec_any_lt (vector bool char, vector unsigned char);
13711 int vec_any_lt (vector unsigned char, vector bool char);
13712 int vec_any_lt (vector unsigned char, vector unsigned char);
13713 int vec_any_lt (vector bool char, vector signed char);
13714 int vec_any_lt (vector signed char, vector bool char);
13715 int vec_any_lt (vector signed char, vector signed char);
13716 int vec_any_lt (vector bool short, vector unsigned short);
13717 int vec_any_lt (vector unsigned short, vector bool short);
13718 int vec_any_lt (vector unsigned short, vector unsigned short);
13719 int vec_any_lt (vector bool short, vector signed short);
13720 int vec_any_lt (vector signed short, vector bool short);
13721 int vec_any_lt (vector signed short, vector signed short);
13722 int vec_any_lt (vector bool int, vector unsigned int);
13723 int vec_any_lt (vector unsigned int, vector bool int);
13724 int vec_any_lt (vector unsigned int, vector unsigned int);
13725 int vec_any_lt (vector bool int, vector signed int);
13726 int vec_any_lt (vector signed int, vector bool int);
13727 int vec_any_lt (vector signed int, vector signed int);
13728 int vec_any_lt (vector float, vector float);
13729
13730 int vec_any_nan (vector float);
13731
13732 int vec_any_ne (vector signed char, vector bool char);
13733 int vec_any_ne (vector signed char, vector signed char);
13734 int vec_any_ne (vector unsigned char, vector bool char);
13735 int vec_any_ne (vector unsigned char, vector unsigned char);
13736 int vec_any_ne (vector bool char, vector bool char);
13737 int vec_any_ne (vector bool char, vector unsigned char);
13738 int vec_any_ne (vector bool char, vector signed char);
13739 int vec_any_ne (vector signed short, vector bool short);
13740 int vec_any_ne (vector signed short, vector signed short);
13741 int vec_any_ne (vector unsigned short, vector bool short);
13742 int vec_any_ne (vector unsigned short, vector unsigned short);
13743 int vec_any_ne (vector bool short, vector bool short);
13744 int vec_any_ne (vector bool short, vector unsigned short);
13745 int vec_any_ne (vector bool short, vector signed short);
13746 int vec_any_ne (vector pixel, vector pixel);
13747 int vec_any_ne (vector signed int, vector bool int);
13748 int vec_any_ne (vector signed int, vector signed int);
13749 int vec_any_ne (vector unsigned int, vector bool int);
13750 int vec_any_ne (vector unsigned int, vector unsigned int);
13751 int vec_any_ne (vector bool int, vector bool int);
13752 int vec_any_ne (vector bool int, vector unsigned int);
13753 int vec_any_ne (vector bool int, vector signed int);
13754 int vec_any_ne (vector float, vector float);
13755
13756 int vec_any_nge (vector float, vector float);
13757
13758 int vec_any_ngt (vector float, vector float);
13759
13760 int vec_any_nle (vector float, vector float);
13761
13762 int vec_any_nlt (vector float, vector float);
13763
13764 int vec_any_numeric (vector float);
13765
13766 int vec_any_out (vector float, vector float);
13767 @end smallexample
13768
13769 If the vector/scalar (VSX) instruction set is available, the following
13770 additional functions are available:
13771
13772 @smallexample
13773 vector double vec_abs (vector double);
13774 vector double vec_add (vector double, vector double);
13775 vector double vec_and (vector double, vector double);
13776 vector double vec_and (vector double, vector bool long);
13777 vector double vec_and (vector bool long, vector double);
13778 vector double vec_andc (vector double, vector double);
13779 vector double vec_andc (vector double, vector bool long);
13780 vector double vec_andc (vector bool long, vector double);
13781 vector double vec_ceil (vector double);
13782 vector bool long vec_cmpeq (vector double, vector double);
13783 vector bool long vec_cmpge (vector double, vector double);
13784 vector bool long vec_cmpgt (vector double, vector double);
13785 vector bool long vec_cmple (vector double, vector double);
13786 vector bool long vec_cmplt (vector double, vector double);
13787 vector float vec_div (vector float, vector float);
13788 vector double vec_div (vector double, vector double);
13789 vector double vec_floor (vector double);
13790 vector double vec_ld (int, const vector double *);
13791 vector double vec_ld (int, const double *);
13792 vector double vec_ldl (int, const vector double *);
13793 vector double vec_ldl (int, const double *);
13794 vector unsigned char vec_lvsl (int, const volatile double *);
13795 vector unsigned char vec_lvsr (int, const volatile double *);
13796 vector double vec_madd (vector double, vector double, vector double);
13797 vector double vec_max (vector double, vector double);
13798 vector double vec_min (vector double, vector double);
13799 vector float vec_msub (vector float, vector float, vector float);
13800 vector double vec_msub (vector double, vector double, vector double);
13801 vector float vec_mul (vector float, vector float);
13802 vector double vec_mul (vector double, vector double);
13803 vector float vec_nearbyint (vector float);
13804 vector double vec_nearbyint (vector double);
13805 vector float vec_nmadd (vector float, vector float, vector float);
13806 vector double vec_nmadd (vector double, vector double, vector double);
13807 vector double vec_nmsub (vector double, vector double, vector double);
13808 vector double vec_nor (vector double, vector double);
13809 vector double vec_or (vector double, vector double);
13810 vector double vec_or (vector double, vector bool long);
13811 vector double vec_or (vector bool long, vector double);
13812 vector double vec_perm (vector double,
13813 vector double,
13814 vector unsigned char);
13815 vector double vec_rint (vector double);
13816 vector double vec_recip (vector double, vector double);
13817 vector double vec_rsqrt (vector double);
13818 vector double vec_rsqrte (vector double);
13819 vector double vec_sel (vector double, vector double, vector bool long);
13820 vector double vec_sel (vector double, vector double, vector unsigned long);
13821 vector double vec_sub (vector double, vector double);
13822 vector float vec_sqrt (vector float);
13823 vector double vec_sqrt (vector double);
13824 void vec_st (vector double, int, vector double *);
13825 void vec_st (vector double, int, double *);
13826 vector double vec_trunc (vector double);
13827 vector double vec_xor (vector double, vector double);
13828 vector double vec_xor (vector double, vector bool long);
13829 vector double vec_xor (vector bool long, vector double);
13830 int vec_all_eq (vector double, vector double);
13831 int vec_all_ge (vector double, vector double);
13832 int vec_all_gt (vector double, vector double);
13833 int vec_all_le (vector double, vector double);
13834 int vec_all_lt (vector double, vector double);
13835 int vec_all_nan (vector double);
13836 int vec_all_ne (vector double, vector double);
13837 int vec_all_nge (vector double, vector double);
13838 int vec_all_ngt (vector double, vector double);
13839 int vec_all_nle (vector double, vector double);
13840 int vec_all_nlt (vector double, vector double);
13841 int vec_all_numeric (vector double);
13842 int vec_any_eq (vector double, vector double);
13843 int vec_any_ge (vector double, vector double);
13844 int vec_any_gt (vector double, vector double);
13845 int vec_any_le (vector double, vector double);
13846 int vec_any_lt (vector double, vector double);
13847 int vec_any_nan (vector double);
13848 int vec_any_ne (vector double, vector double);
13849 int vec_any_nge (vector double, vector double);
13850 int vec_any_ngt (vector double, vector double);
13851 int vec_any_nle (vector double, vector double);
13852 int vec_any_nlt (vector double, vector double);
13853 int vec_any_numeric (vector double);
13854
13855 vector double vec_vsx_ld (int, const vector double *);
13856 vector double vec_vsx_ld (int, const double *);
13857 vector float vec_vsx_ld (int, const vector float *);
13858 vector float vec_vsx_ld (int, const float *);
13859 vector bool int vec_vsx_ld (int, const vector bool int *);
13860 vector signed int vec_vsx_ld (int, const vector signed int *);
13861 vector signed int vec_vsx_ld (int, const int *);
13862 vector signed int vec_vsx_ld (int, const long *);
13863 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
13864 vector unsigned int vec_vsx_ld (int, const unsigned int *);
13865 vector unsigned int vec_vsx_ld (int, const unsigned long *);
13866 vector bool short vec_vsx_ld (int, const vector bool short *);
13867 vector pixel vec_vsx_ld (int, const vector pixel *);
13868 vector signed short vec_vsx_ld (int, const vector signed short *);
13869 vector signed short vec_vsx_ld (int, const short *);
13870 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
13871 vector unsigned short vec_vsx_ld (int, const unsigned short *);
13872 vector bool char vec_vsx_ld (int, const vector bool char *);
13873 vector signed char vec_vsx_ld (int, const vector signed char *);
13874 vector signed char vec_vsx_ld (int, const signed char *);
13875 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
13876 vector unsigned char vec_vsx_ld (int, const unsigned char *);
13877
13878 void vec_vsx_st (vector double, int, vector double *);
13879 void vec_vsx_st (vector double, int, double *);
13880 void vec_vsx_st (vector float, int, vector float *);
13881 void vec_vsx_st (vector float, int, float *);
13882 void vec_vsx_st (vector signed int, int, vector signed int *);
13883 void vec_vsx_st (vector signed int, int, int *);
13884 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
13885 void vec_vsx_st (vector unsigned int, int, unsigned int *);
13886 void vec_vsx_st (vector bool int, int, vector bool int *);
13887 void vec_vsx_st (vector bool int, int, unsigned int *);
13888 void vec_vsx_st (vector bool int, int, int *);
13889 void vec_vsx_st (vector signed short, int, vector signed short *);
13890 void vec_vsx_st (vector signed short, int, short *);
13891 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
13892 void vec_vsx_st (vector unsigned short, int, unsigned short *);
13893 void vec_vsx_st (vector bool short, int, vector bool short *);
13894 void vec_vsx_st (vector bool short, int, unsigned short *);
13895 void vec_vsx_st (vector pixel, int, vector pixel *);
13896 void vec_vsx_st (vector pixel, int, unsigned short *);
13897 void vec_vsx_st (vector pixel, int, short *);
13898 void vec_vsx_st (vector bool short, int, short *);
13899 void vec_vsx_st (vector signed char, int, vector signed char *);
13900 void vec_vsx_st (vector signed char, int, signed char *);
13901 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
13902 void vec_vsx_st (vector unsigned char, int, unsigned char *);
13903 void vec_vsx_st (vector bool char, int, vector bool char *);
13904 void vec_vsx_st (vector bool char, int, unsigned char *);
13905 void vec_vsx_st (vector bool char, int, signed char *);
13906 @end smallexample
13907
13908 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
13909 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
13910 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
13911 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
13912 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
13913
13914 @node RX Built-in Functions
13915 @subsection RX Built-in Functions
13916 GCC supports some of the RX instructions which cannot be expressed in
13917 the C programming language via the use of built-in functions. The
13918 following functions are supported:
13919
13920 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
13921 Generates the @code{brk} machine instruction.
13922 @end deftypefn
13923
13924 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
13925 Generates the @code{clrpsw} machine instruction to clear the specified
13926 bit in the processor status word.
13927 @end deftypefn
13928
13929 @deftypefn {Built-in Function} void __builtin_rx_int (int)
13930 Generates the @code{int} machine instruction to generate an interrupt
13931 with the specified value.
13932 @end deftypefn
13933
13934 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
13935 Generates the @code{machi} machine instruction to add the result of
13936 multiplying the top 16 bits of the two arguments into the
13937 accumulator.
13938 @end deftypefn
13939
13940 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
13941 Generates the @code{maclo} machine instruction to add the result of
13942 multiplying the bottom 16 bits of the two arguments into the
13943 accumulator.
13944 @end deftypefn
13945
13946 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
13947 Generates the @code{mulhi} machine instruction to place the result of
13948 multiplying the top 16 bits of the two arguments into the
13949 accumulator.
13950 @end deftypefn
13951
13952 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
13953 Generates the @code{mullo} machine instruction to place the result of
13954 multiplying the bottom 16 bits of the two arguments into the
13955 accumulator.
13956 @end deftypefn
13957
13958 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
13959 Generates the @code{mvfachi} machine instruction to read the top
13960 32 bits of the accumulator.
13961 @end deftypefn
13962
13963 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
13964 Generates the @code{mvfacmi} machine instruction to read the middle
13965 32 bits of the accumulator.
13966 @end deftypefn
13967
13968 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
13969 Generates the @code{mvfc} machine instruction which reads the control
13970 register specified in its argument and returns its value.
13971 @end deftypefn
13972
13973 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
13974 Generates the @code{mvtachi} machine instruction to set the top
13975 32 bits of the accumulator.
13976 @end deftypefn
13977
13978 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
13979 Generates the @code{mvtaclo} machine instruction to set the bottom
13980 32 bits of the accumulator.
13981 @end deftypefn
13982
13983 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
13984 Generates the @code{mvtc} machine instruction which sets control
13985 register number @code{reg} to @code{val}.
13986 @end deftypefn
13987
13988 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
13989 Generates the @code{mvtipl} machine instruction set the interrupt
13990 priority level.
13991 @end deftypefn
13992
13993 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
13994 Generates the @code{racw} machine instruction to round the accumulator
13995 according to the specified mode.
13996 @end deftypefn
13997
13998 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
13999 Generates the @code{revw} machine instruction which swaps the bytes in
14000 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
14001 and also bits 16--23 occupy bits 24--31 and vice versa.
14002 @end deftypefn
14003
14004 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
14005 Generates the @code{rmpa} machine instruction which initiates a
14006 repeated multiply and accumulate sequence.
14007 @end deftypefn
14008
14009 @deftypefn {Built-in Function} void __builtin_rx_round (float)
14010 Generates the @code{round} machine instruction which returns the
14011 floating-point argument rounded according to the current rounding mode
14012 set in the floating-point status word register.
14013 @end deftypefn
14014
14015 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
14016 Generates the @code{sat} machine instruction which returns the
14017 saturated value of the argument.
14018 @end deftypefn
14019
14020 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
14021 Generates the @code{setpsw} machine instruction to set the specified
14022 bit in the processor status word.
14023 @end deftypefn
14024
14025 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
14026 Generates the @code{wait} machine instruction.
14027 @end deftypefn
14028
14029 @node SH Built-in Functions
14030 @subsection SH Built-in Functions
14031 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
14032 families of processors:
14033
14034 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
14035 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
14036 used by system code that manages threads and execution contexts. The compiler
14037 normally does not generate code that modifies the contents of @samp{GBR} and
14038 thus the value is preserved across function calls. Changing the @samp{GBR}
14039 value in user code must be done with caution, since the compiler might use
14040 @samp{GBR} in order to access thread local variables.
14041
14042 @end deftypefn
14043
14044 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
14045 Returns the value that is currently set in the @samp{GBR} register.
14046 Memory loads and stores that use the thread pointer as a base address are
14047 turned into @samp{GBR} based displacement loads and stores, if possible.
14048 For example:
14049 @smallexample
14050 struct my_tcb
14051 @{
14052 int a, b, c, d, e;
14053 @};
14054
14055 int get_tcb_value (void)
14056 @{
14057 // Generate @samp{mov.l @@(8,gbr),r0} instruction
14058 return ((my_tcb*)__builtin_thread_pointer ())->c;
14059 @}
14060
14061 @end smallexample
14062 @end deftypefn
14063
14064 @node SPARC VIS Built-in Functions
14065 @subsection SPARC VIS Built-in Functions
14066
14067 GCC supports SIMD operations on the SPARC using both the generic vector
14068 extensions (@pxref{Vector Extensions}) as well as built-in functions for
14069 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
14070 switch, the VIS extension is exposed as the following built-in functions:
14071
14072 @smallexample
14073 typedef int v1si __attribute__ ((vector_size (4)));
14074 typedef int v2si __attribute__ ((vector_size (8)));
14075 typedef short v4hi __attribute__ ((vector_size (8)));
14076 typedef short v2hi __attribute__ ((vector_size (4)));
14077 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
14078 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
14079
14080 void __builtin_vis_write_gsr (int64_t);
14081 int64_t __builtin_vis_read_gsr (void);
14082
14083 void * __builtin_vis_alignaddr (void *, long);
14084 void * __builtin_vis_alignaddrl (void *, long);
14085 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
14086 v2si __builtin_vis_faligndatav2si (v2si, v2si);
14087 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
14088 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
14089
14090 v4hi __builtin_vis_fexpand (v4qi);
14091
14092 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
14093 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
14094 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
14095 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
14096 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
14097 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
14098 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
14099
14100 v4qi __builtin_vis_fpack16 (v4hi);
14101 v8qi __builtin_vis_fpack32 (v2si, v8qi);
14102 v2hi __builtin_vis_fpackfix (v2si);
14103 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
14104
14105 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
14106
14107 long __builtin_vis_edge8 (void *, void *);
14108 long __builtin_vis_edge8l (void *, void *);
14109 long __builtin_vis_edge16 (void *, void *);
14110 long __builtin_vis_edge16l (void *, void *);
14111 long __builtin_vis_edge32 (void *, void *);
14112 long __builtin_vis_edge32l (void *, void *);
14113
14114 long __builtin_vis_fcmple16 (v4hi, v4hi);
14115 long __builtin_vis_fcmple32 (v2si, v2si);
14116 long __builtin_vis_fcmpne16 (v4hi, v4hi);
14117 long __builtin_vis_fcmpne32 (v2si, v2si);
14118 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
14119 long __builtin_vis_fcmpgt32 (v2si, v2si);
14120 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
14121 long __builtin_vis_fcmpeq32 (v2si, v2si);
14122
14123 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
14124 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
14125 v2si __builtin_vis_fpadd32 (v2si, v2si);
14126 v1si __builtin_vis_fpadd32s (v1si, v1si);
14127 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
14128 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
14129 v2si __builtin_vis_fpsub32 (v2si, v2si);
14130 v1si __builtin_vis_fpsub32s (v1si, v1si);
14131
14132 long __builtin_vis_array8 (long, long);
14133 long __builtin_vis_array16 (long, long);
14134 long __builtin_vis_array32 (long, long);
14135 @end smallexample
14136
14137 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
14138 functions also become available:
14139
14140 @smallexample
14141 long __builtin_vis_bmask (long, long);
14142 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
14143 v2si __builtin_vis_bshufflev2si (v2si, v2si);
14144 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
14145 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
14146
14147 long __builtin_vis_edge8n (void *, void *);
14148 long __builtin_vis_edge8ln (void *, void *);
14149 long __builtin_vis_edge16n (void *, void *);
14150 long __builtin_vis_edge16ln (void *, void *);
14151 long __builtin_vis_edge32n (void *, void *);
14152 long __builtin_vis_edge32ln (void *, void *);
14153 @end smallexample
14154
14155 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
14156 functions also become available:
14157
14158 @smallexample
14159 void __builtin_vis_cmask8 (long);
14160 void __builtin_vis_cmask16 (long);
14161 void __builtin_vis_cmask32 (long);
14162
14163 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
14164
14165 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
14166 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
14167 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
14168 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
14169 v2si __builtin_vis_fsll16 (v2si, v2si);
14170 v2si __builtin_vis_fslas16 (v2si, v2si);
14171 v2si __builtin_vis_fsrl16 (v2si, v2si);
14172 v2si __builtin_vis_fsra16 (v2si, v2si);
14173
14174 long __builtin_vis_pdistn (v8qi, v8qi);
14175
14176 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
14177
14178 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
14179 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
14180
14181 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
14182 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
14183 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
14184 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
14185 v2si __builtin_vis_fpadds32 (v2si, v2si);
14186 v1si __builtin_vis_fpadds32s (v1si, v1si);
14187 v2si __builtin_vis_fpsubs32 (v2si, v2si);
14188 v1si __builtin_vis_fpsubs32s (v1si, v1si);
14189
14190 long __builtin_vis_fucmple8 (v8qi, v8qi);
14191 long __builtin_vis_fucmpne8 (v8qi, v8qi);
14192 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
14193 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
14194
14195 float __builtin_vis_fhadds (float, float);
14196 double __builtin_vis_fhaddd (double, double);
14197 float __builtin_vis_fhsubs (float, float);
14198 double __builtin_vis_fhsubd (double, double);
14199 float __builtin_vis_fnhadds (float, float);
14200 double __builtin_vis_fnhaddd (double, double);
14201
14202 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
14203 int64_t __builtin_vis_xmulx (int64_t, int64_t);
14204 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
14205 @end smallexample
14206
14207 @node SPU Built-in Functions
14208 @subsection SPU Built-in Functions
14209
14210 GCC provides extensions for the SPU processor as described in the
14211 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
14212 found at @uref{http://cell.scei.co.jp/} or
14213 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
14214 implementation differs in several ways.
14215
14216 @itemize @bullet
14217
14218 @item
14219 The optional extension of specifying vector constants in parentheses is
14220 not supported.
14221
14222 @item
14223 A vector initializer requires no cast if the vector constant is of the
14224 same type as the variable it is initializing.
14225
14226 @item
14227 If @code{signed} or @code{unsigned} is omitted, the signedness of the
14228 vector type is the default signedness of the base type. The default
14229 varies depending on the operating system, so a portable program should
14230 always specify the signedness.
14231
14232 @item
14233 By default, the keyword @code{__vector} is added. The macro
14234 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
14235 undefined.
14236
14237 @item
14238 GCC allows using a @code{typedef} name as the type specifier for a
14239 vector type.
14240
14241 @item
14242 For C, overloaded functions are implemented with macros so the following
14243 does not work:
14244
14245 @smallexample
14246 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
14247 @end smallexample
14248
14249 @noindent
14250 Since @code{spu_add} is a macro, the vector constant in the example
14251 is treated as four separate arguments. Wrap the entire argument in
14252 parentheses for this to work.
14253
14254 @item
14255 The extended version of @code{__builtin_expect} is not supported.
14256
14257 @end itemize
14258
14259 @emph{Note:} Only the interface described in the aforementioned
14260 specification is supported. Internally, GCC uses built-in functions to
14261 implement the required functionality, but these are not supported and
14262 are subject to change without notice.
14263
14264 @node TI C6X Built-in Functions
14265 @subsection TI C6X Built-in Functions
14266
14267 GCC provides intrinsics to access certain instructions of the TI C6X
14268 processors. These intrinsics, listed below, are available after
14269 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
14270 to C6X instructions.
14271
14272 @smallexample
14273
14274 int _sadd (int, int)
14275 int _ssub (int, int)
14276 int _sadd2 (int, int)
14277 int _ssub2 (int, int)
14278 long long _mpy2 (int, int)
14279 long long _smpy2 (int, int)
14280 int _add4 (int, int)
14281 int _sub4 (int, int)
14282 int _saddu4 (int, int)
14283
14284 int _smpy (int, int)
14285 int _smpyh (int, int)
14286 int _smpyhl (int, int)
14287 int _smpylh (int, int)
14288
14289 int _sshl (int, int)
14290 int _subc (int, int)
14291
14292 int _avg2 (int, int)
14293 int _avgu4 (int, int)
14294
14295 int _clrr (int, int)
14296 int _extr (int, int)
14297 int _extru (int, int)
14298 int _abs (int)
14299 int _abs2 (int)
14300
14301 @end smallexample
14302
14303 @node TILE-Gx Built-in Functions
14304 @subsection TILE-Gx Built-in Functions
14305
14306 GCC provides intrinsics to access every instruction of the TILE-Gx
14307 processor. The intrinsics are of the form:
14308
14309 @smallexample
14310
14311 unsigned long long __insn_@var{op} (...)
14312
14313 @end smallexample
14314
14315 Where @var{op} is the name of the instruction. Refer to the ISA manual
14316 for the complete list of instructions.
14317
14318 GCC also provides intrinsics to directly access the network registers.
14319 The intrinsics are:
14320
14321 @smallexample
14322
14323 unsigned long long __tile_idn0_receive (void)
14324 unsigned long long __tile_idn1_receive (void)
14325 unsigned long long __tile_udn0_receive (void)
14326 unsigned long long __tile_udn1_receive (void)
14327 unsigned long long __tile_udn2_receive (void)
14328 unsigned long long __tile_udn3_receive (void)
14329 void __tile_idn_send (unsigned long long)
14330 void __tile_udn_send (unsigned long long)
14331
14332 @end smallexample
14333
14334 The intrinsic @code{void __tile_network_barrier (void)} is used to
14335 guarantee that no network operations before it are reordered with
14336 those after it.
14337
14338 @node TILEPro Built-in Functions
14339 @subsection TILEPro Built-in Functions
14340
14341 GCC provides intrinsics to access every instruction of the TILEPro
14342 processor. The intrinsics are of the form:
14343
14344 @smallexample
14345
14346 unsigned __insn_@var{op} (...)
14347
14348 @end smallexample
14349
14350 @noindent
14351 where @var{op} is the name of the instruction. Refer to the ISA manual
14352 for the complete list of instructions.
14353
14354 GCC also provides intrinsics to directly access the network registers.
14355 The intrinsics are:
14356
14357 @smallexample
14358
14359 unsigned __tile_idn0_receive (void)
14360 unsigned __tile_idn1_receive (void)
14361 unsigned __tile_sn_receive (void)
14362 unsigned __tile_udn0_receive (void)
14363 unsigned __tile_udn1_receive (void)
14364 unsigned __tile_udn2_receive (void)
14365 unsigned __tile_udn3_receive (void)
14366 void __tile_idn_send (unsigned)
14367 void __tile_sn_send (unsigned)
14368 void __tile_udn_send (unsigned)
14369
14370 @end smallexample
14371
14372 The intrinsic @code{void __tile_network_barrier (void)} is used to
14373 guarantee that no network operations before it are reordered with
14374 those after it.
14375
14376 @node Target Format Checks
14377 @section Format Checks Specific to Particular Target Machines
14378
14379 For some target machines, GCC supports additional options to the
14380 format attribute
14381 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
14382
14383 @menu
14384 * Solaris Format Checks::
14385 * Darwin Format Checks::
14386 @end menu
14387
14388 @node Solaris Format Checks
14389 @subsection Solaris Format Checks
14390
14391 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
14392 check. @code{cmn_err} accepts a subset of the standard @code{printf}
14393 conversions, and the two-argument @code{%b} conversion for displaying
14394 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
14395
14396 @node Darwin Format Checks
14397 @subsection Darwin Format Checks
14398
14399 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
14400 attribute context. Declarations made with such attribution are parsed for correct syntax
14401 and format argument types. However, parsing of the format string itself is currently undefined
14402 and is not carried out by this version of the compiler.
14403
14404 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
14405 also be used as format arguments. Note that the relevant headers are only likely to be
14406 available on Darwin (OSX) installations. On such installations, the XCode and system
14407 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
14408 associated functions.
14409
14410 @node Pragmas
14411 @section Pragmas Accepted by GCC
14412 @cindex pragmas
14413 @cindex @code{#pragma}
14414
14415 GCC supports several types of pragmas, primarily in order to compile
14416 code originally written for other compilers. Note that in general
14417 we do not recommend the use of pragmas; @xref{Function Attributes},
14418 for further explanation.
14419
14420 @menu
14421 * ARM Pragmas::
14422 * M32C Pragmas::
14423 * MeP Pragmas::
14424 * RS/6000 and PowerPC Pragmas::
14425 * Darwin Pragmas::
14426 * Solaris Pragmas::
14427 * Symbol-Renaming Pragmas::
14428 * Structure-Packing Pragmas::
14429 * Weak Pragmas::
14430 * Diagnostic Pragmas::
14431 * Visibility Pragmas::
14432 * Push/Pop Macro Pragmas::
14433 * Function Specific Option Pragmas::
14434 @end menu
14435
14436 @node ARM Pragmas
14437 @subsection ARM Pragmas
14438
14439 The ARM target defines pragmas for controlling the default addition of
14440 @code{long_call} and @code{short_call} attributes to functions.
14441 @xref{Function Attributes}, for information about the effects of these
14442 attributes.
14443
14444 @table @code
14445 @item long_calls
14446 @cindex pragma, long_calls
14447 Set all subsequent functions to have the @code{long_call} attribute.
14448
14449 @item no_long_calls
14450 @cindex pragma, no_long_calls
14451 Set all subsequent functions to have the @code{short_call} attribute.
14452
14453 @item long_calls_off
14454 @cindex pragma, long_calls_off
14455 Do not affect the @code{long_call} or @code{short_call} attributes of
14456 subsequent functions.
14457 @end table
14458
14459 @node M32C Pragmas
14460 @subsection M32C Pragmas
14461
14462 @table @code
14463 @item GCC memregs @var{number}
14464 @cindex pragma, memregs
14465 Overrides the command-line option @code{-memregs=} for the current
14466 file. Use with care! This pragma must be before any function in the
14467 file, and mixing different memregs values in different objects may
14468 make them incompatible. This pragma is useful when a
14469 performance-critical function uses a memreg for temporary values,
14470 as it may allow you to reduce the number of memregs used.
14471
14472 @item ADDRESS @var{name} @var{address}
14473 @cindex pragma, address
14474 For any declared symbols matching @var{name}, this does three things
14475 to that symbol: it forces the symbol to be located at the given
14476 address (a number), it forces the symbol to be volatile, and it
14477 changes the symbol's scope to be static. This pragma exists for
14478 compatibility with other compilers, but note that the common
14479 @code{1234H} numeric syntax is not supported (use @code{0x1234}
14480 instead). Example:
14481
14482 @smallexample
14483 #pragma ADDRESS port3 0x103
14484 char port3;
14485 @end smallexample
14486
14487 @end table
14488
14489 @node MeP Pragmas
14490 @subsection MeP Pragmas
14491
14492 @table @code
14493
14494 @item custom io_volatile (on|off)
14495 @cindex pragma, custom io_volatile
14496 Overrides the command-line option @code{-mio-volatile} for the current
14497 file. Note that for compatibility with future GCC releases, this
14498 option should only be used once before any @code{io} variables in each
14499 file.
14500
14501 @item GCC coprocessor available @var{registers}
14502 @cindex pragma, coprocessor available
14503 Specifies which coprocessor registers are available to the register
14504 allocator. @var{registers} may be a single register, register range
14505 separated by ellipses, or comma-separated list of those. Example:
14506
14507 @smallexample
14508 #pragma GCC coprocessor available $c0...$c10, $c28
14509 @end smallexample
14510
14511 @item GCC coprocessor call_saved @var{registers}
14512 @cindex pragma, coprocessor call_saved
14513 Specifies which coprocessor registers are to be saved and restored by
14514 any function using them. @var{registers} may be a single register,
14515 register range separated by ellipses, or comma-separated list of
14516 those. Example:
14517
14518 @smallexample
14519 #pragma GCC coprocessor call_saved $c4...$c6, $c31
14520 @end smallexample
14521
14522 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
14523 @cindex pragma, coprocessor subclass
14524 Creates and defines a register class. These register classes can be
14525 used by inline @code{asm} constructs. @var{registers} may be a single
14526 register, register range separated by ellipses, or comma-separated
14527 list of those. Example:
14528
14529 @smallexample
14530 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
14531
14532 asm ("cpfoo %0" : "=B" (x));
14533 @end smallexample
14534
14535 @item GCC disinterrupt @var{name} , @var{name} @dots{}
14536 @cindex pragma, disinterrupt
14537 For the named functions, the compiler adds code to disable interrupts
14538 for the duration of those functions. If any functions so named
14539 are not encountered in the source, a warning is emitted that the pragma is
14540 not used. Examples:
14541
14542 @smallexample
14543 #pragma disinterrupt foo
14544 #pragma disinterrupt bar, grill
14545 int foo () @{ @dots{} @}
14546 @end smallexample
14547
14548 @item GCC call @var{name} , @var{name} @dots{}
14549 @cindex pragma, call
14550 For the named functions, the compiler always uses a register-indirect
14551 call model when calling the named functions. Examples:
14552
14553 @smallexample
14554 extern int foo ();
14555 #pragma call foo
14556 @end smallexample
14557
14558 @end table
14559
14560 @node RS/6000 and PowerPC Pragmas
14561 @subsection RS/6000 and PowerPC Pragmas
14562
14563 The RS/6000 and PowerPC targets define one pragma for controlling
14564 whether or not the @code{longcall} attribute is added to function
14565 declarations by default. This pragma overrides the @option{-mlongcall}
14566 option, but not the @code{longcall} and @code{shortcall} attributes.
14567 @xref{RS/6000 and PowerPC Options}, for more information about when long
14568 calls are and are not necessary.
14569
14570 @table @code
14571 @item longcall (1)
14572 @cindex pragma, longcall
14573 Apply the @code{longcall} attribute to all subsequent function
14574 declarations.
14575
14576 @item longcall (0)
14577 Do not apply the @code{longcall} attribute to subsequent function
14578 declarations.
14579 @end table
14580
14581 @c Describe h8300 pragmas here.
14582 @c Describe sh pragmas here.
14583 @c Describe v850 pragmas here.
14584
14585 @node Darwin Pragmas
14586 @subsection Darwin Pragmas
14587
14588 The following pragmas are available for all architectures running the
14589 Darwin operating system. These are useful for compatibility with other
14590 Mac OS compilers.
14591
14592 @table @code
14593 @item mark @var{tokens}@dots{}
14594 @cindex pragma, mark
14595 This pragma is accepted, but has no effect.
14596
14597 @item options align=@var{alignment}
14598 @cindex pragma, options align
14599 This pragma sets the alignment of fields in structures. The values of
14600 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
14601 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
14602 properly; to restore the previous setting, use @code{reset} for the
14603 @var{alignment}.
14604
14605 @item segment @var{tokens}@dots{}
14606 @cindex pragma, segment
14607 This pragma is accepted, but has no effect.
14608
14609 @item unused (@var{var} [, @var{var}]@dots{})
14610 @cindex pragma, unused
14611 This pragma declares variables to be possibly unused. GCC does not
14612 produce warnings for the listed variables. The effect is similar to
14613 that of the @code{unused} attribute, except that this pragma may appear
14614 anywhere within the variables' scopes.
14615 @end table
14616
14617 @node Solaris Pragmas
14618 @subsection Solaris Pragmas
14619
14620 The Solaris target supports @code{#pragma redefine_extname}
14621 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
14622 @code{#pragma} directives for compatibility with the system compiler.
14623
14624 @table @code
14625 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
14626 @cindex pragma, align
14627
14628 Increase the minimum alignment of each @var{variable} to @var{alignment}.
14629 This is the same as GCC's @code{aligned} attribute @pxref{Variable
14630 Attributes}). Macro expansion occurs on the arguments to this pragma
14631 when compiling C and Objective-C@. It does not currently occur when
14632 compiling C++, but this is a bug which may be fixed in a future
14633 release.
14634
14635 @item fini (@var{function} [, @var{function}]...)
14636 @cindex pragma, fini
14637
14638 This pragma causes each listed @var{function} to be called after
14639 main, or during shared module unloading, by adding a call to the
14640 @code{.fini} section.
14641
14642 @item init (@var{function} [, @var{function}]...)
14643 @cindex pragma, init
14644
14645 This pragma causes each listed @var{function} to be called during
14646 initialization (before @code{main}) or during shared module loading, by
14647 adding a call to the @code{.init} section.
14648
14649 @end table
14650
14651 @node Symbol-Renaming Pragmas
14652 @subsection Symbol-Renaming Pragmas
14653
14654 For compatibility with the Solaris system headers, GCC
14655 supports two @code{#pragma} directives that change the name used in
14656 assembly for a given declaration. To get this effect
14657 on all platforms supported by GCC, use the asm labels extension (@pxref{Asm
14658 Labels}).
14659
14660 @table @code
14661 @item redefine_extname @var{oldname} @var{newname}
14662 @cindex pragma, redefine_extname
14663
14664 This pragma gives the C function @var{oldname} the assembly symbol
14665 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
14666 is defined if this pragma is available (currently on all platforms).
14667 @end table
14668
14669 This pragma and the asm labels extension interact in a complicated
14670 manner. Here are some corner cases you may want to be aware of.
14671
14672 @enumerate
14673 @item Both pragmas silently apply only to declarations with external
14674 linkage. Asm labels do not have this restriction.
14675
14676 @item In C++, both pragmas silently apply only to declarations with
14677 ``C'' linkage. Again, asm labels do not have this restriction.
14678
14679 @item If any of the three ways of changing the assembly name of a
14680 declaration is applied to a declaration whose assembly name has
14681 already been determined (either by a previous use of one of these
14682 features, or because the compiler needed the assembly name in order to
14683 generate code), and the new name is different, a warning issues and
14684 the name does not change.
14685
14686 @item The @var{oldname} used by @code{#pragma redefine_extname} is
14687 always the C-language name.
14688 @end enumerate
14689
14690 @node Structure-Packing Pragmas
14691 @subsection Structure-Packing Pragmas
14692
14693 For compatibility with Microsoft Windows compilers, GCC supports a
14694 set of @code{#pragma} directives that change the maximum alignment of
14695 members of structures (other than zero-width bit-fields), unions, and
14696 classes subsequently defined. The @var{n} value below always is required
14697 to be a small power of two and specifies the new alignment in bytes.
14698
14699 @enumerate
14700 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
14701 @item @code{#pragma pack()} sets the alignment to the one that was in
14702 effect when compilation started (see also command-line option
14703 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
14704 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
14705 setting on an internal stack and then optionally sets the new alignment.
14706 @item @code{#pragma pack(pop)} restores the alignment setting to the one
14707 saved at the top of the internal stack (and removes that stack entry).
14708 Note that @code{#pragma pack([@var{n}])} does not influence this internal
14709 stack; thus it is possible to have @code{#pragma pack(push)} followed by
14710 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
14711 @code{#pragma pack(pop)}.
14712 @end enumerate
14713
14714 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
14715 @code{#pragma} which lays out a structure as the documented
14716 @code{__attribute__ ((ms_struct))}.
14717 @enumerate
14718 @item @code{#pragma ms_struct on} turns on the layout for structures
14719 declared.
14720 @item @code{#pragma ms_struct off} turns off the layout for structures
14721 declared.
14722 @item @code{#pragma ms_struct reset} goes back to the default layout.
14723 @end enumerate
14724
14725 @node Weak Pragmas
14726 @subsection Weak Pragmas
14727
14728 For compatibility with SVR4, GCC supports a set of @code{#pragma}
14729 directives for declaring symbols to be weak, and defining weak
14730 aliases.
14731
14732 @table @code
14733 @item #pragma weak @var{symbol}
14734 @cindex pragma, weak
14735 This pragma declares @var{symbol} to be weak, as if the declaration
14736 had the attribute of the same name. The pragma may appear before
14737 or after the declaration of @var{symbol}. It is not an error for
14738 @var{symbol} to never be defined at all.
14739
14740 @item #pragma weak @var{symbol1} = @var{symbol2}
14741 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
14742 It is an error if @var{symbol2} is not defined in the current
14743 translation unit.
14744 @end table
14745
14746 @node Diagnostic Pragmas
14747 @subsection Diagnostic Pragmas
14748
14749 GCC allows the user to selectively enable or disable certain types of
14750 diagnostics, and change the kind of the diagnostic. For example, a
14751 project's policy might require that all sources compile with
14752 @option{-Werror} but certain files might have exceptions allowing
14753 specific types of warnings. Or, a project might selectively enable
14754 diagnostics and treat them as errors depending on which preprocessor
14755 macros are defined.
14756
14757 @table @code
14758 @item #pragma GCC diagnostic @var{kind} @var{option}
14759 @cindex pragma, diagnostic
14760
14761 Modifies the disposition of a diagnostic. Note that not all
14762 diagnostics are modifiable; at the moment only warnings (normally
14763 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
14764 Use @option{-fdiagnostics-show-option} to determine which diagnostics
14765 are controllable and which option controls them.
14766
14767 @var{kind} is @samp{error} to treat this diagnostic as an error,
14768 @samp{warning} to treat it like a warning (even if @option{-Werror} is
14769 in effect), or @samp{ignored} if the diagnostic is to be ignored.
14770 @var{option} is a double quoted string that matches the command-line
14771 option.
14772
14773 @smallexample
14774 #pragma GCC diagnostic warning "-Wformat"
14775 #pragma GCC diagnostic error "-Wformat"
14776 #pragma GCC diagnostic ignored "-Wformat"
14777 @end smallexample
14778
14779 Note that these pragmas override any command-line options. GCC keeps
14780 track of the location of each pragma, and issues diagnostics according
14781 to the state as of that point in the source file. Thus, pragmas occurring
14782 after a line do not affect diagnostics caused by that line.
14783
14784 @item #pragma GCC diagnostic push
14785 @itemx #pragma GCC diagnostic pop
14786
14787 Causes GCC to remember the state of the diagnostics as of each
14788 @code{push}, and restore to that point at each @code{pop}. If a
14789 @code{pop} has no matching @code{push}, the command-line options are
14790 restored.
14791
14792 @smallexample
14793 #pragma GCC diagnostic error "-Wuninitialized"
14794 foo(a); /* error is given for this one */
14795 #pragma GCC diagnostic push
14796 #pragma GCC diagnostic ignored "-Wuninitialized"
14797 foo(b); /* no diagnostic for this one */
14798 #pragma GCC diagnostic pop
14799 foo(c); /* error is given for this one */
14800 #pragma GCC diagnostic pop
14801 foo(d); /* depends on command-line options */
14802 @end smallexample
14803
14804 @end table
14805
14806 GCC also offers a simple mechanism for printing messages during
14807 compilation.
14808
14809 @table @code
14810 @item #pragma message @var{string}
14811 @cindex pragma, diagnostic
14812
14813 Prints @var{string} as a compiler message on compilation. The message
14814 is informational only, and is neither a compilation warning nor an error.
14815
14816 @smallexample
14817 #pragma message "Compiling " __FILE__ "..."
14818 @end smallexample
14819
14820 @var{string} may be parenthesized, and is printed with location
14821 information. For example,
14822
14823 @smallexample
14824 #define DO_PRAGMA(x) _Pragma (#x)
14825 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
14826
14827 TODO(Remember to fix this)
14828 @end smallexample
14829
14830 @noindent
14831 prints @samp{/tmp/file.c:4: note: #pragma message:
14832 TODO - Remember to fix this}.
14833
14834 @end table
14835
14836 @node Visibility Pragmas
14837 @subsection Visibility Pragmas
14838
14839 @table @code
14840 @item #pragma GCC visibility push(@var{visibility})
14841 @itemx #pragma GCC visibility pop
14842 @cindex pragma, visibility
14843
14844 This pragma allows the user to set the visibility for multiple
14845 declarations without having to give each a visibility attribute
14846 @xref{Function Attributes}, for more information about visibility and
14847 the attribute syntax.
14848
14849 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
14850 declarations. Class members and template specializations are not
14851 affected; if you want to override the visibility for a particular
14852 member or instantiation, you must use an attribute.
14853
14854 @end table
14855
14856
14857 @node Push/Pop Macro Pragmas
14858 @subsection Push/Pop Macro Pragmas
14859
14860 For compatibility with Microsoft Windows compilers, GCC supports
14861 @samp{#pragma push_macro(@var{"macro_name"})}
14862 and @samp{#pragma pop_macro(@var{"macro_name"})}.
14863
14864 @table @code
14865 @item #pragma push_macro(@var{"macro_name"})
14866 @cindex pragma, push_macro
14867 This pragma saves the value of the macro named as @var{macro_name} to
14868 the top of the stack for this macro.
14869
14870 @item #pragma pop_macro(@var{"macro_name"})
14871 @cindex pragma, pop_macro
14872 This pragma sets the value of the macro named as @var{macro_name} to
14873 the value on top of the stack for this macro. If the stack for
14874 @var{macro_name} is empty, the value of the macro remains unchanged.
14875 @end table
14876
14877 For example:
14878
14879 @smallexample
14880 #define X 1
14881 #pragma push_macro("X")
14882 #undef X
14883 #define X -1
14884 #pragma pop_macro("X")
14885 int x [X];
14886 @end smallexample
14887
14888 @noindent
14889 In this example, the definition of X as 1 is saved by @code{#pragma
14890 push_macro} and restored by @code{#pragma pop_macro}.
14891
14892 @node Function Specific Option Pragmas
14893 @subsection Function Specific Option Pragmas
14894
14895 @table @code
14896 @item #pragma GCC target (@var{"string"}...)
14897 @cindex pragma GCC target
14898
14899 This pragma allows you to set target specific options for functions
14900 defined later in the source file. One or more strings can be
14901 specified. Each function that is defined after this point is as
14902 if @code{attribute((target("STRING")))} was specified for that
14903 function. The parenthesis around the options is optional.
14904 @xref{Function Attributes}, for more information about the
14905 @code{target} attribute and the attribute syntax.
14906
14907 The @code{#pragma GCC target} attribute is not implemented in GCC versions earlier
14908 than 4.4 for the i386/x86_64 and 4.6 for the PowerPC back ends. At
14909 present, it is not implemented for other back ends.
14910 @end table
14911
14912 @table @code
14913 @item #pragma GCC optimize (@var{"string"}...)
14914 @cindex pragma GCC optimize
14915
14916 This pragma allows you to set global optimization options for functions
14917 defined later in the source file. One or more strings can be
14918 specified. Each function that is defined after this point is as
14919 if @code{attribute((optimize("STRING")))} was specified for that
14920 function. The parenthesis around the options is optional.
14921 @xref{Function Attributes}, for more information about the
14922 @code{optimize} attribute and the attribute syntax.
14923
14924 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
14925 versions earlier than 4.4.
14926 @end table
14927
14928 @table @code
14929 @item #pragma GCC push_options
14930 @itemx #pragma GCC pop_options
14931 @cindex pragma GCC push_options
14932 @cindex pragma GCC pop_options
14933
14934 These pragmas maintain a stack of the current target and optimization
14935 options. It is intended for include files where you temporarily want
14936 to switch to using a different @samp{#pragma GCC target} or
14937 @samp{#pragma GCC optimize} and then to pop back to the previous
14938 options.
14939
14940 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
14941 pragmas are not implemented in GCC versions earlier than 4.4.
14942 @end table
14943
14944 @table @code
14945 @item #pragma GCC reset_options
14946 @cindex pragma GCC reset_options
14947
14948 This pragma clears the current @code{#pragma GCC target} and
14949 @code{#pragma GCC optimize} to use the default switches as specified
14950 on the command line.
14951
14952 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
14953 versions earlier than 4.4.
14954 @end table
14955
14956 @node Unnamed Fields
14957 @section Unnamed struct/union fields within structs/unions
14958 @cindex @code{struct}
14959 @cindex @code{union}
14960
14961 As permitted by ISO C11 and for compatibility with other compilers,
14962 GCC allows you to define
14963 a structure or union that contains, as fields, structures and unions
14964 without names. For example:
14965
14966 @smallexample
14967 struct @{
14968 int a;
14969 union @{
14970 int b;
14971 float c;
14972 @};
14973 int d;
14974 @} foo;
14975 @end smallexample
14976
14977 @noindent
14978 In this example, you are able to access members of the unnamed
14979 union with code like @samp{foo.b}. Note that only unnamed structs and
14980 unions are allowed, you may not have, for example, an unnamed
14981 @code{int}.
14982
14983 You must never create such structures that cause ambiguous field definitions.
14984 For example, in this structure:
14985
14986 @smallexample
14987 struct @{
14988 int a;
14989 struct @{
14990 int a;
14991 @};
14992 @} foo;
14993 @end smallexample
14994
14995 @noindent
14996 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
14997 The compiler gives errors for such constructs.
14998
14999 @opindex fms-extensions
15000 Unless @option{-fms-extensions} is used, the unnamed field must be a
15001 structure or union definition without a tag (for example, @samp{struct
15002 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
15003 also be a definition with a tag such as @samp{struct foo @{ int a;
15004 @};}, a reference to a previously defined structure or union such as
15005 @samp{struct foo;}, or a reference to a @code{typedef} name for a
15006 previously defined structure or union type.
15007
15008 @opindex fplan9-extensions
15009 The option @option{-fplan9-extensions} enables
15010 @option{-fms-extensions} as well as two other extensions. First, a
15011 pointer to a structure is automatically converted to a pointer to an
15012 anonymous field for assignments and function calls. For example:
15013
15014 @smallexample
15015 struct s1 @{ int a; @};
15016 struct s2 @{ struct s1; @};
15017 extern void f1 (struct s1 *);
15018 void f2 (struct s2 *p) @{ f1 (p); @}
15019 @end smallexample
15020
15021 @noindent
15022 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
15023 converted into a pointer to the anonymous field.
15024
15025 Second, when the type of an anonymous field is a @code{typedef} for a
15026 @code{struct} or @code{union}, code may refer to the field using the
15027 name of the @code{typedef}.
15028
15029 @smallexample
15030 typedef struct @{ int a; @} s1;
15031 struct s2 @{ s1; @};
15032 s1 f1 (struct s2 *p) @{ return p->s1; @}
15033 @end smallexample
15034
15035 These usages are only permitted when they are not ambiguous.
15036
15037 @node Thread-Local
15038 @section Thread-Local Storage
15039 @cindex Thread-Local Storage
15040 @cindex @acronym{TLS}
15041 @cindex @code{__thread}
15042
15043 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
15044 are allocated such that there is one instance of the variable per extant
15045 thread. The runtime model GCC uses to implement this originates
15046 in the IA-64 processor-specific ABI, but has since been migrated
15047 to other processors as well. It requires significant support from
15048 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
15049 system libraries (@file{libc.so} and @file{libpthread.so}), so it
15050 is not available everywhere.
15051
15052 At the user level, the extension is visible with a new storage
15053 class keyword: @code{__thread}. For example:
15054
15055 @smallexample
15056 __thread int i;
15057 extern __thread struct state s;
15058 static __thread char *p;
15059 @end smallexample
15060
15061 The @code{__thread} specifier may be used alone, with the @code{extern}
15062 or @code{static} specifiers, but with no other storage class specifier.
15063 When used with @code{extern} or @code{static}, @code{__thread} must appear
15064 immediately after the other storage class specifier.
15065
15066 The @code{__thread} specifier may be applied to any global, file-scoped
15067 static, function-scoped static, or static data member of a class. It may
15068 not be applied to block-scoped automatic or non-static data member.
15069
15070 When the address-of operator is applied to a thread-local variable, it is
15071 evaluated at run time and returns the address of the current thread's
15072 instance of that variable. An address so obtained may be used by any
15073 thread. When a thread terminates, any pointers to thread-local variables
15074 in that thread become invalid.
15075
15076 No static initialization may refer to the address of a thread-local variable.
15077
15078 In C++, if an initializer is present for a thread-local variable, it must
15079 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
15080 standard.
15081
15082 See @uref{http://www.akkadia.org/drepper/tls.pdf,
15083 ELF Handling For Thread-Local Storage} for a detailed explanation of
15084 the four thread-local storage addressing models, and how the runtime
15085 is expected to function.
15086
15087 @menu
15088 * C99 Thread-Local Edits::
15089 * C++98 Thread-Local Edits::
15090 @end menu
15091
15092 @node C99 Thread-Local Edits
15093 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
15094
15095 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
15096 that document the exact semantics of the language extension.
15097
15098 @itemize @bullet
15099 @item
15100 @cite{5.1.2 Execution environments}
15101
15102 Add new text after paragraph 1
15103
15104 @quotation
15105 Within either execution environment, a @dfn{thread} is a flow of
15106 control within a program. It is implementation defined whether
15107 or not there may be more than one thread associated with a program.
15108 It is implementation defined how threads beyond the first are
15109 created, the name and type of the function called at thread
15110 startup, and how threads may be terminated. However, objects
15111 with thread storage duration shall be initialized before thread
15112 startup.
15113 @end quotation
15114
15115 @item
15116 @cite{6.2.4 Storage durations of objects}
15117
15118 Add new text before paragraph 3
15119
15120 @quotation
15121 An object whose identifier is declared with the storage-class
15122 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
15123 Its lifetime is the entire execution of the thread, and its
15124 stored value is initialized only once, prior to thread startup.
15125 @end quotation
15126
15127 @item
15128 @cite{6.4.1 Keywords}
15129
15130 Add @code{__thread}.
15131
15132 @item
15133 @cite{6.7.1 Storage-class specifiers}
15134
15135 Add @code{__thread} to the list of storage class specifiers in
15136 paragraph 1.
15137
15138 Change paragraph 2 to
15139
15140 @quotation
15141 With the exception of @code{__thread}, at most one storage-class
15142 specifier may be given [@dots{}]. The @code{__thread} specifier may
15143 be used alone, or immediately following @code{extern} or
15144 @code{static}.
15145 @end quotation
15146
15147 Add new text after paragraph 6
15148
15149 @quotation
15150 The declaration of an identifier for a variable that has
15151 block scope that specifies @code{__thread} shall also
15152 specify either @code{extern} or @code{static}.
15153
15154 The @code{__thread} specifier shall be used only with
15155 variables.
15156 @end quotation
15157 @end itemize
15158
15159 @node C++98 Thread-Local Edits
15160 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
15161
15162 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
15163 that document the exact semantics of the language extension.
15164
15165 @itemize @bullet
15166 @item
15167 @b{[intro.execution]}
15168
15169 New text after paragraph 4
15170
15171 @quotation
15172 A @dfn{thread} is a flow of control within the abstract machine.
15173 It is implementation defined whether or not there may be more than
15174 one thread.
15175 @end quotation
15176
15177 New text after paragraph 7
15178
15179 @quotation
15180 It is unspecified whether additional action must be taken to
15181 ensure when and whether side effects are visible to other threads.
15182 @end quotation
15183
15184 @item
15185 @b{[lex.key]}
15186
15187 Add @code{__thread}.
15188
15189 @item
15190 @b{[basic.start.main]}
15191
15192 Add after paragraph 5
15193
15194 @quotation
15195 The thread that begins execution at the @code{main} function is called
15196 the @dfn{main thread}. It is implementation defined how functions
15197 beginning threads other than the main thread are designated or typed.
15198 A function so designated, as well as the @code{main} function, is called
15199 a @dfn{thread startup function}. It is implementation defined what
15200 happens if a thread startup function returns. It is implementation
15201 defined what happens to other threads when any thread calls @code{exit}.
15202 @end quotation
15203
15204 @item
15205 @b{[basic.start.init]}
15206
15207 Add after paragraph 4
15208
15209 @quotation
15210 The storage for an object of thread storage duration shall be
15211 statically initialized before the first statement of the thread startup
15212 function. An object of thread storage duration shall not require
15213 dynamic initialization.
15214 @end quotation
15215
15216 @item
15217 @b{[basic.start.term]}
15218
15219 Add after paragraph 3
15220
15221 @quotation
15222 The type of an object with thread storage duration shall not have a
15223 non-trivial destructor, nor shall it be an array type whose elements
15224 (directly or indirectly) have non-trivial destructors.
15225 @end quotation
15226
15227 @item
15228 @b{[basic.stc]}
15229
15230 Add ``thread storage duration'' to the list in paragraph 1.
15231
15232 Change paragraph 2
15233
15234 @quotation
15235 Thread, static, and automatic storage durations are associated with
15236 objects introduced by declarations [@dots{}].
15237 @end quotation
15238
15239 Add @code{__thread} to the list of specifiers in paragraph 3.
15240
15241 @item
15242 @b{[basic.stc.thread]}
15243
15244 New section before @b{[basic.stc.static]}
15245
15246 @quotation
15247 The keyword @code{__thread} applied to a non-local object gives the
15248 object thread storage duration.
15249
15250 A local variable or class data member declared both @code{static}
15251 and @code{__thread} gives the variable or member thread storage
15252 duration.
15253 @end quotation
15254
15255 @item
15256 @b{[basic.stc.static]}
15257
15258 Change paragraph 1
15259
15260 @quotation
15261 All objects that have neither thread storage duration, dynamic
15262 storage duration nor are local [@dots{}].
15263 @end quotation
15264
15265 @item
15266 @b{[dcl.stc]}
15267
15268 Add @code{__thread} to the list in paragraph 1.
15269
15270 Change paragraph 1
15271
15272 @quotation
15273 With the exception of @code{__thread}, at most one
15274 @var{storage-class-specifier} shall appear in a given
15275 @var{decl-specifier-seq}. The @code{__thread} specifier may
15276 be used alone, or immediately following the @code{extern} or
15277 @code{static} specifiers. [@dots{}]
15278 @end quotation
15279
15280 Add after paragraph 5
15281
15282 @quotation
15283 The @code{__thread} specifier can be applied only to the names of objects
15284 and to anonymous unions.
15285 @end quotation
15286
15287 @item
15288 @b{[class.mem]}
15289
15290 Add after paragraph 6
15291
15292 @quotation
15293 Non-@code{static} members shall not be @code{__thread}.
15294 @end quotation
15295 @end itemize
15296
15297 @node Binary constants
15298 @section Binary constants using the @samp{0b} prefix
15299 @cindex Binary constants using the @samp{0b} prefix
15300
15301 Integer constants can be written as binary constants, consisting of a
15302 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
15303 @samp{0B}. This is particularly useful in environments that operate a
15304 lot on the bit level (like microcontrollers).
15305
15306 The following statements are identical:
15307
15308 @smallexample
15309 i = 42;
15310 i = 0x2a;
15311 i = 052;
15312 i = 0b101010;
15313 @end smallexample
15314
15315 The type of these constants follows the same rules as for octal or
15316 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
15317 can be applied.
15318
15319 @node C++ Extensions
15320 @chapter Extensions to the C++ Language
15321 @cindex extensions, C++ language
15322 @cindex C++ language extensions
15323
15324 The GNU compiler provides these extensions to the C++ language (and you
15325 can also use most of the C language extensions in your C++ programs). If you
15326 want to write code that checks whether these features are available, you can
15327 test for the GNU compiler the same way as for C programs: check for a
15328 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
15329 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
15330 Predefined Macros,cpp,The GNU C Preprocessor}).
15331
15332 @menu
15333 * C++ Volatiles:: What constitutes an access to a volatile object.
15334 * Restricted Pointers:: C99 restricted pointers and references.
15335 * Vague Linkage:: Where G++ puts inlines, vtables and such.
15336 * C++ Interface:: You can use a single C++ header file for both
15337 declarations and definitions.
15338 * Template Instantiation:: Methods for ensuring that exactly one copy of
15339 each needed template instantiation is emitted.
15340 * Bound member functions:: You can extract a function pointer to the
15341 method denoted by a @samp{->*} or @samp{.*} expression.
15342 * C++ Attributes:: Variable, function, and type attributes for C++ only.
15343 * Function Multiversioning:: Declaring multiple function versions.
15344 * Namespace Association:: Strong using-directives for namespace association.
15345 * Type Traits:: Compiler support for type traits
15346 * Java Exceptions:: Tweaking exception handling to work with Java.
15347 * Deprecated Features:: Things will disappear from G++.
15348 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
15349 @end menu
15350
15351 @node C++ Volatiles
15352 @section When is a Volatile C++ Object Accessed?
15353 @cindex accessing volatiles
15354 @cindex volatile read
15355 @cindex volatile write
15356 @cindex volatile access
15357
15358 The C++ standard differs from the C standard in its treatment of
15359 volatile objects. It fails to specify what constitutes a volatile
15360 access, except to say that C++ should behave in a similar manner to C
15361 with respect to volatiles, where possible. However, the different
15362 lvalueness of expressions between C and C++ complicate the behavior.
15363 G++ behaves the same as GCC for volatile access, @xref{C
15364 Extensions,,Volatiles}, for a description of GCC's behavior.
15365
15366 The C and C++ language specifications differ when an object is
15367 accessed in a void context:
15368
15369 @smallexample
15370 volatile int *src = @var{somevalue};
15371 *src;
15372 @end smallexample
15373
15374 The C++ standard specifies that such expressions do not undergo lvalue
15375 to rvalue conversion, and that the type of the dereferenced object may
15376 be incomplete. The C++ standard does not specify explicitly that it
15377 is lvalue to rvalue conversion that is responsible for causing an
15378 access. There is reason to believe that it is, because otherwise
15379 certain simple expressions become undefined. However, because it
15380 would surprise most programmers, G++ treats dereferencing a pointer to
15381 volatile object of complete type as GCC would do for an equivalent
15382 type in C@. When the object has incomplete type, G++ issues a
15383 warning; if you wish to force an error, you must force a conversion to
15384 rvalue with, for instance, a static cast.
15385
15386 When using a reference to volatile, G++ does not treat equivalent
15387 expressions as accesses to volatiles, but instead issues a warning that
15388 no volatile is accessed. The rationale for this is that otherwise it
15389 becomes difficult to determine where volatile access occur, and not
15390 possible to ignore the return value from functions returning volatile
15391 references. Again, if you wish to force a read, cast the reference to
15392 an rvalue.
15393
15394 G++ implements the same behavior as GCC does when assigning to a
15395 volatile object---there is no reread of the assigned-to object, the
15396 assigned rvalue is reused. Note that in C++ assignment expressions
15397 are lvalues, and if used as an lvalue, the volatile object is
15398 referred to. For instance, @var{vref} refers to @var{vobj}, as
15399 expected, in the following example:
15400
15401 @smallexample
15402 volatile int vobj;
15403 volatile int &vref = vobj = @var{something};
15404 @end smallexample
15405
15406 @node Restricted Pointers
15407 @section Restricting Pointer Aliasing
15408 @cindex restricted pointers
15409 @cindex restricted references
15410 @cindex restricted this pointer
15411
15412 As with the C front end, G++ understands the C99 feature of restricted pointers,
15413 specified with the @code{__restrict__}, or @code{__restrict} type
15414 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
15415 language flag, @code{restrict} is not a keyword in C++.
15416
15417 In addition to allowing restricted pointers, you can specify restricted
15418 references, which indicate that the reference is not aliased in the local
15419 context.
15420
15421 @smallexample
15422 void fn (int *__restrict__ rptr, int &__restrict__ rref)
15423 @{
15424 /* @r{@dots{}} */
15425 @}
15426 @end smallexample
15427
15428 @noindent
15429 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
15430 @var{rref} refers to a (different) unaliased integer.
15431
15432 You may also specify whether a member function's @var{this} pointer is
15433 unaliased by using @code{__restrict__} as a member function qualifier.
15434
15435 @smallexample
15436 void T::fn () __restrict__
15437 @{
15438 /* @r{@dots{}} */
15439 @}
15440 @end smallexample
15441
15442 @noindent
15443 Within the body of @code{T::fn}, @var{this} has the effective
15444 definition @code{T *__restrict__ const this}. Notice that the
15445 interpretation of a @code{__restrict__} member function qualifier is
15446 different to that of @code{const} or @code{volatile} qualifier, in that it
15447 is applied to the pointer rather than the object. This is consistent with
15448 other compilers that implement restricted pointers.
15449
15450 As with all outermost parameter qualifiers, @code{__restrict__} is
15451 ignored in function definition matching. This means you only need to
15452 specify @code{__restrict__} in a function definition, rather than
15453 in a function prototype as well.
15454
15455 @node Vague Linkage
15456 @section Vague Linkage
15457 @cindex vague linkage
15458
15459 There are several constructs in C++ that require space in the object
15460 file but are not clearly tied to a single translation unit. We say that
15461 these constructs have ``vague linkage''. Typically such constructs are
15462 emitted wherever they are needed, though sometimes we can be more
15463 clever.
15464
15465 @table @asis
15466 @item Inline Functions
15467 Inline functions are typically defined in a header file which can be
15468 included in many different compilations. Hopefully they can usually be
15469 inlined, but sometimes an out-of-line copy is necessary, if the address
15470 of the function is taken or if inlining fails. In general, we emit an
15471 out-of-line copy in all translation units where one is needed. As an
15472 exception, we only emit inline virtual functions with the vtable, since
15473 it always requires a copy.
15474
15475 Local static variables and string constants used in an inline function
15476 are also considered to have vague linkage, since they must be shared
15477 between all inlined and out-of-line instances of the function.
15478
15479 @item VTables
15480 @cindex vtable
15481 C++ virtual functions are implemented in most compilers using a lookup
15482 table, known as a vtable. The vtable contains pointers to the virtual
15483 functions provided by a class, and each object of the class contains a
15484 pointer to its vtable (or vtables, in some multiple-inheritance
15485 situations). If the class declares any non-inline, non-pure virtual
15486 functions, the first one is chosen as the ``key method'' for the class,
15487 and the vtable is only emitted in the translation unit where the key
15488 method is defined.
15489
15490 @emph{Note:} If the chosen key method is later defined as inline, the
15491 vtable is still emitted in every translation unit that defines it.
15492 Make sure that any inline virtuals are declared inline in the class
15493 body, even if they are not defined there.
15494
15495 @item @code{type_info} objects
15496 @cindex @code{type_info}
15497 @cindex RTTI
15498 C++ requires information about types to be written out in order to
15499 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
15500 For polymorphic classes (classes with virtual functions), the @samp{type_info}
15501 object is written out along with the vtable so that @samp{dynamic_cast}
15502 can determine the dynamic type of a class object at run time. For all
15503 other types, we write out the @samp{type_info} object when it is used: when
15504 applying @samp{typeid} to an expression, throwing an object, or
15505 referring to a type in a catch clause or exception specification.
15506
15507 @item Template Instantiations
15508 Most everything in this section also applies to template instantiations,
15509 but there are other options as well.
15510 @xref{Template Instantiation,,Where's the Template?}.
15511
15512 @end table
15513
15514 When used with GNU ld version 2.8 or later on an ELF system such as
15515 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
15516 these constructs will be discarded at link time. This is known as
15517 COMDAT support.
15518
15519 On targets that don't support COMDAT, but do support weak symbols, GCC
15520 uses them. This way one copy overrides all the others, but
15521 the unused copies still take up space in the executable.
15522
15523 For targets that do not support either COMDAT or weak symbols,
15524 most entities with vague linkage are emitted as local symbols to
15525 avoid duplicate definition errors from the linker. This does not happen
15526 for local statics in inlines, however, as having multiple copies
15527 almost certainly breaks things.
15528
15529 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
15530 another way to control placement of these constructs.
15531
15532 @node C++ Interface
15533 @section #pragma interface and implementation
15534
15535 @cindex interface and implementation headers, C++
15536 @cindex C++ interface and implementation headers
15537 @cindex pragmas, interface and implementation
15538
15539 @code{#pragma interface} and @code{#pragma implementation} provide the
15540 user with a way of explicitly directing the compiler to emit entities
15541 with vague linkage (and debugging information) in a particular
15542 translation unit.
15543
15544 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
15545 most cases, because of COMDAT support and the ``key method'' heuristic
15546 mentioned in @ref{Vague Linkage}. Using them can actually cause your
15547 program to grow due to unnecessary out-of-line copies of inline
15548 functions. Currently (3.4) the only benefit of these
15549 @code{#pragma}s is reduced duplication of debugging information, and
15550 that should be addressed soon on DWARF 2 targets with the use of
15551 COMDAT groups.
15552
15553 @table @code
15554 @item #pragma interface
15555 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
15556 @kindex #pragma interface
15557 Use this directive in @emph{header files} that define object classes, to save
15558 space in most of the object files that use those classes. Normally,
15559 local copies of certain information (backup copies of inline member
15560 functions, debugging information, and the internal tables that implement
15561 virtual functions) must be kept in each object file that includes class
15562 definitions. You can use this pragma to avoid such duplication. When a
15563 header file containing @samp{#pragma interface} is included in a
15564 compilation, this auxiliary information is not generated (unless
15565 the main input source file itself uses @samp{#pragma implementation}).
15566 Instead, the object files contain references to be resolved at link
15567 time.
15568
15569 The second form of this directive is useful for the case where you have
15570 multiple headers with the same name in different directories. If you
15571 use this form, you must specify the same string to @samp{#pragma
15572 implementation}.
15573
15574 @item #pragma implementation
15575 @itemx #pragma implementation "@var{objects}.h"
15576 @kindex #pragma implementation
15577 Use this pragma in a @emph{main input file}, when you want full output from
15578 included header files to be generated (and made globally visible). The
15579 included header file, in turn, should use @samp{#pragma interface}.
15580 Backup copies of inline member functions, debugging information, and the
15581 internal tables used to implement virtual functions are all generated in
15582 implementation files.
15583
15584 @cindex implied @code{#pragma implementation}
15585 @cindex @code{#pragma implementation}, implied
15586 @cindex naming convention, implementation headers
15587 If you use @samp{#pragma implementation} with no argument, it applies to
15588 an include file with the same basename@footnote{A file's @dfn{basename}
15589 is the name stripped of all leading path information and of trailing
15590 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
15591 file. For example, in @file{allclass.cc}, giving just
15592 @samp{#pragma implementation}
15593 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
15594
15595 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
15596 an implementation file whenever you would include it from
15597 @file{allclass.cc} even if you never specified @samp{#pragma
15598 implementation}. This was deemed to be more trouble than it was worth,
15599 however, and disabled.
15600
15601 Use the string argument if you want a single implementation file to
15602 include code from multiple header files. (You must also use
15603 @samp{#include} to include the header file; @samp{#pragma
15604 implementation} only specifies how to use the file---it doesn't actually
15605 include it.)
15606
15607 There is no way to split up the contents of a single header file into
15608 multiple implementation files.
15609 @end table
15610
15611 @cindex inlining and C++ pragmas
15612 @cindex C++ pragmas, effect on inlining
15613 @cindex pragmas in C++, effect on inlining
15614 @samp{#pragma implementation} and @samp{#pragma interface} also have an
15615 effect on function inlining.
15616
15617 If you define a class in a header file marked with @samp{#pragma
15618 interface}, the effect on an inline function defined in that class is
15619 similar to an explicit @code{extern} declaration---the compiler emits
15620 no code at all to define an independent version of the function. Its
15621 definition is used only for inlining with its callers.
15622
15623 @opindex fno-implement-inlines
15624 Conversely, when you include the same header file in a main source file
15625 that declares it as @samp{#pragma implementation}, the compiler emits
15626 code for the function itself; this defines a version of the function
15627 that can be found via pointers (or by callers compiled without
15628 inlining). If all calls to the function can be inlined, you can avoid
15629 emitting the function by compiling with @option{-fno-implement-inlines}.
15630 If any calls are not inlined, you will get linker errors.
15631
15632 @node Template Instantiation
15633 @section Where's the Template?
15634 @cindex template instantiation
15635
15636 C++ templates are the first language feature to require more
15637 intelligence from the environment than one usually finds on a UNIX
15638 system. Somehow the compiler and linker have to make sure that each
15639 template instance occurs exactly once in the executable if it is needed,
15640 and not at all otherwise. There are two basic approaches to this
15641 problem, which are referred to as the Borland model and the Cfront model.
15642
15643 @table @asis
15644 @item Borland model
15645 Borland C++ solved the template instantiation problem by adding the code
15646 equivalent of common blocks to their linker; the compiler emits template
15647 instances in each translation unit that uses them, and the linker
15648 collapses them together. The advantage of this model is that the linker
15649 only has to consider the object files themselves; there is no external
15650 complexity to worry about. This disadvantage is that compilation time
15651 is increased because the template code is being compiled repeatedly.
15652 Code written for this model tends to include definitions of all
15653 templates in the header file, since they must be seen to be
15654 instantiated.
15655
15656 @item Cfront model
15657 The AT&T C++ translator, Cfront, solved the template instantiation
15658 problem by creating the notion of a template repository, an
15659 automatically maintained place where template instances are stored. A
15660 more modern version of the repository works as follows: As individual
15661 object files are built, the compiler places any template definitions and
15662 instantiations encountered in the repository. At link time, the link
15663 wrapper adds in the objects in the repository and compiles any needed
15664 instances that were not previously emitted. The advantages of this
15665 model are more optimal compilation speed and the ability to use the
15666 system linker; to implement the Borland model a compiler vendor also
15667 needs to replace the linker. The disadvantages are vastly increased
15668 complexity, and thus potential for error; for some code this can be
15669 just as transparent, but in practice it can been very difficult to build
15670 multiple programs in one directory and one program in multiple
15671 directories. Code written for this model tends to separate definitions
15672 of non-inline member templates into a separate file, which should be
15673 compiled separately.
15674 @end table
15675
15676 When used with GNU ld version 2.8 or later on an ELF system such as
15677 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
15678 Borland model. On other systems, G++ implements neither automatic
15679 model.
15680
15681 You have the following options for dealing with template instantiations:
15682
15683 @enumerate
15684 @item
15685 @opindex frepo
15686 Compile your template-using code with @option{-frepo}. The compiler
15687 generates files with the extension @samp{.rpo} listing all of the
15688 template instantiations used in the corresponding object files that
15689 could be instantiated there; the link wrapper, @samp{collect2},
15690 then updates the @samp{.rpo} files to tell the compiler where to place
15691 those instantiations and rebuild any affected object files. The
15692 link-time overhead is negligible after the first pass, as the compiler
15693 continues to place the instantiations in the same files.
15694
15695 This is your best option for application code written for the Borland
15696 model, as it just works. Code written for the Cfront model
15697 needs to be modified so that the template definitions are available at
15698 one or more points of instantiation; usually this is as simple as adding
15699 @code{#include <tmethods.cc>} to the end of each template header.
15700
15701 For library code, if you want the library to provide all of the template
15702 instantiations it needs, just try to link all of its object files
15703 together; the link will fail, but cause the instantiations to be
15704 generated as a side effect. Be warned, however, that this may cause
15705 conflicts if multiple libraries try to provide the same instantiations.
15706 For greater control, use explicit instantiation as described in the next
15707 option.
15708
15709 @item
15710 @opindex fno-implicit-templates
15711 Compile your code with @option{-fno-implicit-templates} to disable the
15712 implicit generation of template instances, and explicitly instantiate
15713 all the ones you use. This approach requires more knowledge of exactly
15714 which instances you need than do the others, but it's less
15715 mysterious and allows greater control. You can scatter the explicit
15716 instantiations throughout your program, perhaps putting them in the
15717 translation units where the instances are used or the translation units
15718 that define the templates themselves; you can put all of the explicit
15719 instantiations you need into one big file; or you can create small files
15720 like
15721
15722 @smallexample
15723 #include "Foo.h"
15724 #include "Foo.cc"
15725
15726 template class Foo<int>;
15727 template ostream& operator <<
15728 (ostream&, const Foo<int>&);
15729 @end smallexample
15730
15731 @noindent
15732 for each of the instances you need, and create a template instantiation
15733 library from those.
15734
15735 If you are using Cfront-model code, you can probably get away with not
15736 using @option{-fno-implicit-templates} when compiling files that don't
15737 @samp{#include} the member template definitions.
15738
15739 If you use one big file to do the instantiations, you may want to
15740 compile it without @option{-fno-implicit-templates} so you get all of the
15741 instances required by your explicit instantiations (but not by any
15742 other files) without having to specify them as well.
15743
15744 The ISO C++ 2011 standard allows forward declaration of explicit
15745 instantiations (with @code{extern}). G++ supports explicit instantiation
15746 declarations in C++98 mode and has extended the template instantiation
15747 syntax to support instantiation of the compiler support data for a
15748 template class (i.e.@: the vtable) without instantiating any of its
15749 members (with @code{inline}), and instantiation of only the static data
15750 members of a template class, without the support data or member
15751 functions (with (@code{static}):
15752
15753 @smallexample
15754 extern template int max (int, int);
15755 inline template class Foo<int>;
15756 static template class Foo<int>;
15757 @end smallexample
15758
15759 @item
15760 Do nothing. Pretend G++ does implement automatic instantiation
15761 management. Code written for the Borland model works fine, but
15762 each translation unit contains instances of each of the templates it
15763 uses. In a large program, this can lead to an unacceptable amount of code
15764 duplication.
15765 @end enumerate
15766
15767 @node Bound member functions
15768 @section Extracting the function pointer from a bound pointer to member function
15769 @cindex pmf
15770 @cindex pointer to member function
15771 @cindex bound pointer to member function
15772
15773 In C++, pointer to member functions (PMFs) are implemented using a wide
15774 pointer of sorts to handle all the possible call mechanisms; the PMF
15775 needs to store information about how to adjust the @samp{this} pointer,
15776 and if the function pointed to is virtual, where to find the vtable, and
15777 where in the vtable to look for the member function. If you are using
15778 PMFs in an inner loop, you should really reconsider that decision. If
15779 that is not an option, you can extract the pointer to the function that
15780 would be called for a given object/PMF pair and call it directly inside
15781 the inner loop, to save a bit of time.
15782
15783 Note that you still pay the penalty for the call through a
15784 function pointer; on most modern architectures, such a call defeats the
15785 branch prediction features of the CPU@. This is also true of normal
15786 virtual function calls.
15787
15788 The syntax for this extension is
15789
15790 @smallexample
15791 extern A a;
15792 extern int (A::*fp)();
15793 typedef int (*fptr)(A *);
15794
15795 fptr p = (fptr)(a.*fp);
15796 @end smallexample
15797
15798 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
15799 no object is needed to obtain the address of the function. They can be
15800 converted to function pointers directly:
15801
15802 @smallexample
15803 fptr p1 = (fptr)(&A::foo);
15804 @end smallexample
15805
15806 @opindex Wno-pmf-conversions
15807 You must specify @option{-Wno-pmf-conversions} to use this extension.
15808
15809 @node C++ Attributes
15810 @section C++-Specific Variable, Function, and Type Attributes
15811
15812 Some attributes only make sense for C++ programs.
15813
15814 @table @code
15815 @item abi_tag ("@var{tag}", ...)
15816 @cindex @code{abi_tag} attribute
15817 The @code{abi_tag} attribute can be applied to a function or class
15818 declaration. It modifies the mangled name of the function or class to
15819 incorporate the tag name, in order to distinguish the function or
15820 class from an earlier version with a different ABI; perhaps the class
15821 has changed size, or the function has a different return type that is
15822 not encoded in the mangled name.
15823
15824 The argument can be a list of strings of arbitrary length. The
15825 strings are sorted on output, so the order of the list is
15826 unimportant.
15827
15828 A redeclaration of a function or class must not add new ABI tags,
15829 since doing so would change the mangled name.
15830
15831 The @option{-Wabi-tag} flag enables a warning about a class which does
15832 not have all the ABI tags used by its subobjects and virtual functions; for users with code
15833 that needs to coexist with an earlier ABI, using this option can help
15834 to find all affected types that need to be tagged.
15835
15836 @item init_priority (@var{priority})
15837 @cindex @code{init_priority} attribute
15838
15839
15840 In Standard C++, objects defined at namespace scope are guaranteed to be
15841 initialized in an order in strict accordance with that of their definitions
15842 @emph{in a given translation unit}. No guarantee is made for initializations
15843 across translation units. However, GNU C++ allows users to control the
15844 order of initialization of objects defined at namespace scope with the
15845 @code{init_priority} attribute by specifying a relative @var{priority},
15846 a constant integral expression currently bounded between 101 and 65535
15847 inclusive. Lower numbers indicate a higher priority.
15848
15849 In the following example, @code{A} would normally be created before
15850 @code{B}, but the @code{init_priority} attribute reverses that order:
15851
15852 @smallexample
15853 Some_Class A __attribute__ ((init_priority (2000)));
15854 Some_Class B __attribute__ ((init_priority (543)));
15855 @end smallexample
15856
15857 @noindent
15858 Note that the particular values of @var{priority} do not matter; only their
15859 relative ordering.
15860
15861 @item java_interface
15862 @cindex @code{java_interface} attribute
15863
15864 This type attribute informs C++ that the class is a Java interface. It may
15865 only be applied to classes declared within an @code{extern "Java"} block.
15866 Calls to methods declared in this interface are dispatched using GCJ's
15867 interface table mechanism, instead of regular virtual table dispatch.
15868
15869 @end table
15870
15871 See also @ref{Namespace Association}.
15872
15873 @node Function Multiversioning
15874 @section Function Multiversioning
15875 @cindex function versions
15876
15877 With the GNU C++ front end, for target i386, you may specify multiple
15878 versions of a function, where each function is specialized for a
15879 specific target feature. At runtime, the appropriate version of the
15880 function is automatically executed depending on the characteristics of
15881 the execution platform. Here is an example.
15882
15883 @smallexample
15884 __attribute__ ((target ("default")))
15885 int foo ()
15886 @{
15887 // The default version of foo.
15888 return 0;
15889 @}
15890
15891 __attribute__ ((target ("sse4.2")))
15892 int foo ()
15893 @{
15894 // foo version for SSE4.2
15895 return 1;
15896 @}
15897
15898 __attribute__ ((target ("arch=atom")))
15899 int foo ()
15900 @{
15901 // foo version for the Intel ATOM processor
15902 return 2;
15903 @}
15904
15905 __attribute__ ((target ("arch=amdfam10")))
15906 int foo ()
15907 @{
15908 // foo version for the AMD Family 0x10 processors.
15909 return 3;
15910 @}
15911
15912 int main ()
15913 @{
15914 int (*p)() = &foo;
15915 assert ((*p) () == foo ());
15916 return 0;
15917 @}
15918 @end smallexample
15919
15920 In the above example, four versions of function foo are created. The
15921 first version of foo with the target attribute "default" is the default
15922 version. This version gets executed when no other target specific
15923 version qualifies for execution on a particular platform. A new version
15924 of foo is created by using the same function signature but with a
15925 different target string. Function foo is called or a pointer to it is
15926 taken just like a regular function. GCC takes care of doing the
15927 dispatching to call the right version at runtime. Refer to the
15928 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
15929 Function Multiversioning} for more details.
15930
15931 @node Namespace Association
15932 @section Namespace Association
15933
15934 @strong{Caution:} The semantics of this extension are equivalent
15935 to C++ 2011 inline namespaces. Users should use inline namespaces
15936 instead as this extension will be removed in future versions of G++.
15937
15938 A using-directive with @code{__attribute ((strong))} is stronger
15939 than a normal using-directive in two ways:
15940
15941 @itemize @bullet
15942 @item
15943 Templates from the used namespace can be specialized and explicitly
15944 instantiated as though they were members of the using namespace.
15945
15946 @item
15947 The using namespace is considered an associated namespace of all
15948 templates in the used namespace for purposes of argument-dependent
15949 name lookup.
15950 @end itemize
15951
15952 The used namespace must be nested within the using namespace so that
15953 normal unqualified lookup works properly.
15954
15955 This is useful for composing a namespace transparently from
15956 implementation namespaces. For example:
15957
15958 @smallexample
15959 namespace std @{
15960 namespace debug @{
15961 template <class T> struct A @{ @};
15962 @}
15963 using namespace debug __attribute ((__strong__));
15964 template <> struct A<int> @{ @}; // @r{ok to specialize}
15965
15966 template <class T> void f (A<T>);
15967 @}
15968
15969 int main()
15970 @{
15971 f (std::A<float>()); // @r{lookup finds} std::f
15972 f (std::A<int>());
15973 @}
15974 @end smallexample
15975
15976 @node Type Traits
15977 @section Type Traits
15978
15979 The C++ front end implements syntactic extensions that allow
15980 compile-time determination of
15981 various characteristics of a type (or of a
15982 pair of types).
15983
15984 @table @code
15985 @item __has_nothrow_assign (type)
15986 If @code{type} is const qualified or is a reference type then the trait is
15987 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
15988 is true, else if @code{type} is a cv class or union type with copy assignment
15989 operators that are known not to throw an exception then the trait is true,
15990 else it is false. Requires: @code{type} shall be a complete type,
15991 (possibly cv-qualified) @code{void}, or an array of unknown bound.
15992
15993 @item __has_nothrow_copy (type)
15994 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
15995 @code{type} is a cv class or union type with copy constructors that
15996 are known not to throw an exception then the trait is true, else it is false.
15997 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
15998 @code{void}, or an array of unknown bound.
15999
16000 @item __has_nothrow_constructor (type)
16001 If @code{__has_trivial_constructor (type)} is true then the trait is
16002 true, else if @code{type} is a cv class or union type (or array
16003 thereof) with a default constructor that is known not to throw an
16004 exception then the trait is true, else it is false. Requires:
16005 @code{type} shall be a complete type, (possibly cv-qualified)
16006 @code{void}, or an array of unknown bound.
16007
16008 @item __has_trivial_assign (type)
16009 If @code{type} is const qualified or is a reference type then the trait is
16010 false. Otherwise if @code{__is_pod (type)} is true then the trait is
16011 true, else if @code{type} is a cv class or union type with a trivial
16012 copy assignment ([class.copy]) then the trait is true, else it is
16013 false. Requires: @code{type} shall be a complete type, (possibly
16014 cv-qualified) @code{void}, or an array of unknown bound.
16015
16016 @item __has_trivial_copy (type)
16017 If @code{__is_pod (type)} is true or @code{type} is a reference type
16018 then the trait is true, else if @code{type} is a cv class or union type
16019 with a trivial copy constructor ([class.copy]) then the trait
16020 is true, else it is false. Requires: @code{type} shall be a complete
16021 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
16022
16023 @item __has_trivial_constructor (type)
16024 If @code{__is_pod (type)} is true then the trait is true, else if
16025 @code{type} is a cv class or union type (or array thereof) with a
16026 trivial default constructor ([class.ctor]) then the trait is true,
16027 else it is false. Requires: @code{type} shall be a complete
16028 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
16029
16030 @item __has_trivial_destructor (type)
16031 If @code{__is_pod (type)} is true or @code{type} is a reference type then
16032 the trait is true, else if @code{type} is a cv class or union type (or
16033 array thereof) with a trivial destructor ([class.dtor]) then the trait
16034 is true, else it is false. Requires: @code{type} shall be a complete
16035 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
16036
16037 @item __has_virtual_destructor (type)
16038 If @code{type} is a class type with a virtual destructor
16039 ([class.dtor]) then the trait is true, else it is false. Requires:
16040 @code{type} shall be a complete type, (possibly cv-qualified)
16041 @code{void}, or an array of unknown bound.
16042
16043 @item __is_abstract (type)
16044 If @code{type} is an abstract class ([class.abstract]) then the trait
16045 is true, else it is false. Requires: @code{type} shall be a complete
16046 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
16047
16048 @item __is_base_of (base_type, derived_type)
16049 If @code{base_type} is a base class of @code{derived_type}
16050 ([class.derived]) then the trait is true, otherwise it is false.
16051 Top-level cv qualifications of @code{base_type} and
16052 @code{derived_type} are ignored. For the purposes of this trait, a
16053 class type is considered is own base. Requires: if @code{__is_class
16054 (base_type)} and @code{__is_class (derived_type)} are true and
16055 @code{base_type} and @code{derived_type} are not the same type
16056 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
16057 type. Diagnostic is produced if this requirement is not met.
16058
16059 @item __is_class (type)
16060 If @code{type} is a cv class type, and not a union type
16061 ([basic.compound]) the trait is true, else it is false.
16062
16063 @item __is_empty (type)
16064 If @code{__is_class (type)} is false then the trait is false.
16065 Otherwise @code{type} is considered empty if and only if: @code{type}
16066 has no non-static data members, or all non-static data members, if
16067 any, are bit-fields of length 0, and @code{type} has no virtual
16068 members, and @code{type} has no virtual base classes, and @code{type}
16069 has no base classes @code{base_type} for which
16070 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
16071 be a complete type, (possibly cv-qualified) @code{void}, or an array
16072 of unknown bound.
16073
16074 @item __is_enum (type)
16075 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
16076 true, else it is false.
16077
16078 @item __is_literal_type (type)
16079 If @code{type} is a literal type ([basic.types]) the trait is
16080 true, else it is false. Requires: @code{type} shall be a complete type,
16081 (possibly cv-qualified) @code{void}, or an array of unknown bound.
16082
16083 @item __is_pod (type)
16084 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
16085 else it is false. Requires: @code{type} shall be a complete type,
16086 (possibly cv-qualified) @code{void}, or an array of unknown bound.
16087
16088 @item __is_polymorphic (type)
16089 If @code{type} is a polymorphic class ([class.virtual]) then the trait
16090 is true, else it is false. Requires: @code{type} shall be a complete
16091 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
16092
16093 @item __is_standard_layout (type)
16094 If @code{type} is a standard-layout type ([basic.types]) the trait is
16095 true, else it is false. Requires: @code{type} shall be a complete
16096 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
16097
16098 @item __is_trivial (type)
16099 If @code{type} is a trivial type ([basic.types]) the trait is
16100 true, else it is false. Requires: @code{type} shall be a complete
16101 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
16102
16103 @item __is_union (type)
16104 If @code{type} is a cv union type ([basic.compound]) the trait is
16105 true, else it is false.
16106
16107 @item __underlying_type (type)
16108 The underlying type of @code{type}. Requires: @code{type} shall be
16109 an enumeration type ([dcl.enum]).
16110
16111 @end table
16112
16113 @node Java Exceptions
16114 @section Java Exceptions
16115
16116 The Java language uses a slightly different exception handling model
16117 from C++. Normally, GNU C++ automatically detects when you are
16118 writing C++ code that uses Java exceptions, and handle them
16119 appropriately. However, if C++ code only needs to execute destructors
16120 when Java exceptions are thrown through it, GCC guesses incorrectly.
16121 Sample problematic code is:
16122
16123 @smallexample
16124 struct S @{ ~S(); @};
16125 extern void bar(); // @r{is written in Java, and may throw exceptions}
16126 void foo()
16127 @{
16128 S s;
16129 bar();
16130 @}
16131 @end smallexample
16132
16133 @noindent
16134 The usual effect of an incorrect guess is a link failure, complaining of
16135 a missing routine called @samp{__gxx_personality_v0}.
16136
16137 You can inform the compiler that Java exceptions are to be used in a
16138 translation unit, irrespective of what it might think, by writing
16139 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
16140 @samp{#pragma} must appear before any functions that throw or catch
16141 exceptions, or run destructors when exceptions are thrown through them.
16142
16143 You cannot mix Java and C++ exceptions in the same translation unit. It
16144 is believed to be safe to throw a C++ exception from one file through
16145 another file compiled for the Java exception model, or vice versa, but
16146 there may be bugs in this area.
16147
16148 @node Deprecated Features
16149 @section Deprecated Features
16150
16151 In the past, the GNU C++ compiler was extended to experiment with new
16152 features, at a time when the C++ language was still evolving. Now that
16153 the C++ standard is complete, some of those features are superseded by
16154 superior alternatives. Using the old features might cause a warning in
16155 some cases that the feature will be dropped in the future. In other
16156 cases, the feature might be gone already.
16157
16158 While the list below is not exhaustive, it documents some of the options
16159 that are now deprecated:
16160
16161 @table @code
16162 @item -fexternal-templates
16163 @itemx -falt-external-templates
16164 These are two of the many ways for G++ to implement template
16165 instantiation. @xref{Template Instantiation}. The C++ standard clearly
16166 defines how template definitions have to be organized across
16167 implementation units. G++ has an implicit instantiation mechanism that
16168 should work just fine for standard-conforming code.
16169
16170 @item -fstrict-prototype
16171 @itemx -fno-strict-prototype
16172 Previously it was possible to use an empty prototype parameter list to
16173 indicate an unspecified number of parameters (like C), rather than no
16174 parameters, as C++ demands. This feature has been removed, except where
16175 it is required for backwards compatibility. @xref{Backwards Compatibility}.
16176 @end table
16177
16178 G++ allows a virtual function returning @samp{void *} to be overridden
16179 by one returning a different pointer type. This extension to the
16180 covariant return type rules is now deprecated and will be removed from a
16181 future version.
16182
16183 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
16184 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
16185 and are now removed from G++. Code using these operators should be
16186 modified to use @code{std::min} and @code{std::max} instead.
16187
16188 The named return value extension has been deprecated, and is now
16189 removed from G++.
16190
16191 The use of initializer lists with new expressions has been deprecated,
16192 and is now removed from G++.
16193
16194 Floating and complex non-type template parameters have been deprecated,
16195 and are now removed from G++.
16196
16197 The implicit typename extension has been deprecated and is now
16198 removed from G++.
16199
16200 The use of default arguments in function pointers, function typedefs
16201 and other places where they are not permitted by the standard is
16202 deprecated and will be removed from a future version of G++.
16203
16204 G++ allows floating-point literals to appear in integral constant expressions,
16205 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
16206 This extension is deprecated and will be removed from a future version.
16207
16208 G++ allows static data members of const floating-point type to be declared
16209 with an initializer in a class definition. The standard only allows
16210 initializers for static members of const integral types and const
16211 enumeration types so this extension has been deprecated and will be removed
16212 from a future version.
16213
16214 @node Backwards Compatibility
16215 @section Backwards Compatibility
16216 @cindex Backwards Compatibility
16217 @cindex ARM [Annotated C++ Reference Manual]
16218
16219 Now that there is a definitive ISO standard C++, G++ has a specification
16220 to adhere to. The C++ language evolved over time, and features that
16221 used to be acceptable in previous drafts of the standard, such as the ARM
16222 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
16223 compilation of C++ written to such drafts, G++ contains some backwards
16224 compatibilities. @emph{All such backwards compatibility features are
16225 liable to disappear in future versions of G++.} They should be considered
16226 deprecated. @xref{Deprecated Features}.
16227
16228 @table @code
16229 @item For scope
16230 If a variable is declared at for scope, it used to remain in scope until
16231 the end of the scope that contained the for statement (rather than just
16232 within the for scope). G++ retains this, but issues a warning, if such a
16233 variable is accessed outside the for scope.
16234
16235 @item Implicit C language
16236 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
16237 scope to set the language. On such systems, all header files are
16238 implicitly scoped inside a C language scope. Also, an empty prototype
16239 @code{()} is treated as an unspecified number of arguments, rather
16240 than no arguments, as C++ demands.
16241 @end table